( instanceId: InstanceId, vnode: VNode, compositeMeta: CompositeWidgetMeta, ctx: CommitCtx, nodePath: string[], depth: number, commitContainer: CommitContainerFn, )
| 67 | } |
| 68 | |
| 69 | export function executeCompositeRender( |
| 70 | instanceId: InstanceId, |
| 71 | vnode: VNode, |
| 72 | compositeMeta: CompositeWidgetMeta, |
| 73 | ctx: CommitCtx, |
| 74 | nodePath: string[], |
| 75 | depth: number, |
| 76 | commitContainer: CommitContainerFn, |
| 77 | ): CommitNodeResult { |
| 78 | const prev = |
| 79 | ctx.prevNodeStack.length > 0 ? (ctx.prevNodeStack[ctx.prevNodeStack.length - 1] ?? null) : null; |
| 80 | const compositeRuntime = ctx.composite as NonNullable<CommitCtx["composite"]>; |
| 81 | |
| 82 | let compositeChild: VNode | null = null; |
| 83 | let popCompositeStack = false; |
| 84 | try { |
| 85 | const activeCompositeMeta = compositeMeta; |
| 86 | const registry = compositeRuntime.registry; |
| 87 | const existing = registry.get(instanceId); |
| 88 | |
| 89 | if (existing && existing.widgetKey !== compositeMeta.widgetKey) { |
| 90 | registry.incrementGeneration(instanceId); |
| 91 | registry.delete(instanceId); |
| 92 | } |
| 93 | |
| 94 | if (!registry.get(instanceId)) { |
| 95 | try { |
| 96 | registry.create(instanceId, compositeMeta.widgetKey); |
| 97 | } catch (e: unknown) { |
| 98 | return { |
| 99 | ok: false, |
| 100 | fatal: { |
| 101 | code: "ZRUI_USER_CODE_THROW", |
| 102 | detail: describeThrown(e), |
| 103 | }, |
| 104 | }; |
| 105 | } |
| 106 | } |
| 107 | |
| 108 | const state = registry.get(instanceId); |
| 109 | if (!state) { |
| 110 | return { |
| 111 | ok: false, |
| 112 | fatal: { |
| 113 | code: "ZRUI_INVALID_PROPS", |
| 114 | detail: `composite state missing for instanceId=${String(instanceId)}`, |
| 115 | }, |
| 116 | }; |
| 117 | } |
| 118 | |
| 119 | const invalidateInstance = () => { |
| 120 | registry.invalidate(instanceId); |
| 121 | ctx.composite?.onInvalidate(instanceId); |
| 122 | }; |
| 123 | |
| 124 | const prevMeta = prev ? getCompositeMeta(prev.vnode) : null; |
| 125 | const prevChild = prev?.children[0] ?? null; |
| 126 | const previousSelections = registry.getAppStateSelections(instanceId); |
no test coverage detected