( prev: RuntimeInstance | null, instanceId: InstanceId, vnode: VNode, ctx: CommitCtx, nodePath: string, )
| 65 | export { __commitDiag } from "./commit/equality.js"; |
| 66 | |
| 67 | function commitNode( |
| 68 | prev: RuntimeInstance | null, |
| 69 | instanceId: InstanceId, |
| 70 | vnode: VNode, |
| 71 | ctx: CommitCtx, |
| 72 | nodePath: string, |
| 73 | ): CommitNodeResult { |
| 74 | ctx.layoutDepthRef.value += 1; |
| 75 | const layoutDepth = ctx.layoutDepthRef.value; |
| 76 | const trackPath = layoutDepth >= LAYOUT_DEPTH_PATH_TRACK_START; |
| 77 | if (trackPath) ctx.layoutPathTail.push(widgetPathEntry(vnode)); |
| 78 | ctx.prevNodeStack.push(prev); |
| 79 | try { |
| 80 | if ( |
| 81 | DEV_MODE && |
| 82 | layoutDepth > LAYOUT_DEPTH_WARN_THRESHOLD && |
| 83 | !ctx.emittedWarnings.has("layout_depth") |
| 84 | ) { |
| 85 | ctx.emittedWarnings.add("layout_depth"); |
| 86 | warnDev( |
| 87 | `[rezi][commit] layout depth ${String(layoutDepth)} exceeds warning threshold ${String( |
| 88 | LAYOUT_DEPTH_WARN_THRESHOLD, |
| 89 | )}. Deep trees may fail near depth ${String( |
| 90 | MAX_LAYOUT_NESTING_DEPTH, |
| 91 | )}. Path: ${formatWidgetPath(layoutDepth, ctx.layoutPathTail)}`, |
| 92 | ); |
| 93 | } |
| 94 | if (layoutDepth > MAX_LAYOUT_NESTING_DEPTH) { |
| 95 | return { |
| 96 | ok: false, |
| 97 | fatal: { |
| 98 | code: "ZRUI_INVALID_PROPS", |
| 99 | detail: `ZRUI_MAX_DEPTH: layout nesting depth ${String(layoutDepth)} exceeds max ${String( |
| 100 | MAX_LAYOUT_NESTING_DEPTH, |
| 101 | )}. Path: ${formatWidgetPath(layoutDepth, ctx.layoutPathTail)}`, |
| 102 | }, |
| 103 | }; |
| 104 | } |
| 105 | |
| 106 | const commitDebug = globalThis as Record<string, unknown> & { |
| 107 | __commitDebug?: unknown; |
| 108 | __commitDebugLog?: string[] | undefined; |
| 109 | }; |
| 110 | if (commitDebug.__commitDebug) { |
| 111 | const debugLog = commitDebug.__commitDebugLog; |
| 112 | if (debugLog) { |
| 113 | debugLog.push( |
| 114 | `commitNode(${String(instanceId)}, ${vnode.kind}, prev=${prev ? `${prev.vnode.kind}:${String(prev.instanceId)}` : "null"})`, |
| 115 | ); |
| 116 | } |
| 117 | } |
| 118 | |
| 119 | if (prev && prev.vnode.kind === vnode.kind && leafVNodeEqual(prev.vnode, vnode)) { |
| 120 | if (__commitDiag.enabled) { |
| 121 | const wasDirty = prev.selfDirty; |
| 122 | __commitDiag.push({ |
| 123 | id: instanceId as number, |
| 124 | kind: vnode.kind, |
no test coverage detected