MCPcopy Create free account
hub / github.com/thetarnav/solid-devtools / updateNode

Function updateNode

packages/frontend/src/structure.tsx:215–254  ·  view source on GitHub ↗
(
    node: Node,
    rootId: debug.NodeID,
    raw: debug.Mapped.Owner | undefined,
    level: number,
)

Source from the content-addressed store, hash-verified

213}
214
215function updateNode(
216 node: Node,
217 rootId: debug.NodeID,
218 raw: debug.Mapped.Owner | undefined,
219 level: number,
220): Node {
221 const {id, children} = node
222 NewNodeList.push(node)
223 node.level = level
224
225 if (!raw) raw = Updated[rootId]?.[id]
226
227 if (raw) {
228 // update frozen computations
229 if ('frozen' in raw && raw.frozen) node.frozen = true
230
231 const {children: rawChildren} = raw
232 const newChildren: Node[] = (node.children = [])
233
234 if (rawChildren.length) {
235 const prevChildrenMap: Record<debug.NodeID, Node> = {}
236 for (const child of children) prevChildrenMap[child.id] = child
237
238 for (const childRaw of rawChildren) {
239 const childNode = prevChildrenMap[childRaw.id]
240 newChildren.push(
241 childNode
242 ? updateNode(childNode, rootId, childRaw, level + 1)
243 : createNode(childRaw, node, level + 1),
244 )
245 }
246 }
247 } else {
248 for (const child of children) {
249 updateNode(child, rootId, Updated[rootId]?.[child.id], level + 1)
250 }
251 }
252
253 return node
254}
255
256export function reconcileStructure(
257 prevRoots: Node[],

Callers 1

reconcileStructureFunction · 0.85

Calls 1

createNodeFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…