MCPcopy
hub / github.com/midrender/revideo / registerNode

Method registerNode

packages/2d/src/lib/scenes/Scene2D.ts:135–153  ·  view source on GitHub ↗
(node: Node, key?: string)

Source from the content-addressed store, hash-verified

133 }
134
135 public registerNode(node: Node, key?: string): [string, () => void] {
136 const className = node.constructor?.name ?? 'unknown';
137 const counter = (this.nodeCounters.get(className) ?? 0) + 1;
138 this.nodeCounters.set(className, counter);
139
140 if (key && this.registeredNodes.has(key)) {
141 useLogger().error({
142 message: `Duplicated node key: "${key}".`,
143 inspect: key,
144 stack: new Error().stack,
145 });
146 key = undefined;
147 }
148
149 key ??= `${this.name}/${className}[${counter}]`;
150 this.registeredNodes.set(key, node);
151 const currentNodeMap = this.registeredNodes;
152 return [key, () => currentNodeMap.delete(key!)];
153 }
154
155 public getNode(key: any): Node | null {
156 if (typeof key !== 'string') return null;

Callers 1

constructorMethod · 0.80

Calls 4

useLoggerFunction · 0.90
setMethod · 0.65
getMethod · 0.45
errorMethod · 0.45

Tested by

no test coverage detected