MCPcopy
hub / github.com/clientIO/joint / createPortsData

Function createPortsData

packages/joint-react/src/data/create-ports-data.ts:32–63  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

30 * @category Port
31 */
32export function createPortsData() {
33 const data = {
34 ports: new Map<string, SVGElement>(),
35 };
36
37 return {
38 set(cellId: dia.Cell.ID, portElementsCache: Record<string, PortElementsCacheEntry>) {
39 for (const portId in portElementsCache) {
40 const { portSelectors } = portElementsCache[portId];
41 const portalElement = portSelectors[PORTAL_SELECTOR];
42 if (!portalElement) {
43 throw new Error(
44 `Portal element not found for port id: ${portId} via ${PORTAL_SELECTOR} selector`
45 );
46 }
47 const element = Array.isArray(portalElement) ? portalElement[0] : portalElement;
48 const id = getId(cellId, portId);
49 if (util.isEqual(data.ports.get(id), element)) {
50 continue;
51 }
52 data.ports.set(id, element);
53 }
54 },
55 get(cellId: dia.Cell.ID, portId: string) {
56 const id = getId(cellId, portId);
57 return data.ports.get(id);
58 },
59 clear() {
60 data.ports.clear();
61 },
62 };
63}

Callers 2

createPortsStoreFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected