MCPcopy Create free account
hub / github.com/RtlZeroMemory/Rezi / commitVNodeTree

Function commitVNodeTree

packages/core/src/runtime/commit.ts:286–359  ·  view source on GitHub ↗
(
  prevRoot: RuntimeInstance | null,
  nextRootVNode: VNode,
  opts: Readonly<{
    allocator: InstanceIdAllocator;
    localState?: RuntimeLocalStateStore;
    collectLifecycleInstanceIds?: boolean;
    interactiveIdIndex?: Map<string, string>;
    composite?: CompositeCommitRuntime;
    errorBoundary?: CommitErrorBoundaryController;
  }>,
)

Source from the content-addressed store, hash-verified

284}
285
286export function commitVNodeTree(
287 prevRoot: RuntimeInstance | null,
288 nextRootVNode: VNode,
289 opts: Readonly<{
290 allocator: InstanceIdAllocator;
291 localState?: RuntimeLocalStateStore;
292 collectLifecycleInstanceIds?: boolean;
293 interactiveIdIndex?: Map<string, string>;
294 composite?: CompositeCommitRuntime;
295 errorBoundary?: CommitErrorBoundaryController;
296 }>,
297): CommitResult {
298 const collectLifecycleInstanceIds = opts.collectLifecycleInstanceIds !== false;
299 const interactiveIdIndex = opts.interactiveIdIndex ?? new Map<string, string>();
300 interactiveIdIndex.clear();
301 const ctx: CommitCtx = {
302 allocator: opts.allocator,
303 localState: opts.localState,
304 seenInteractiveIds: interactiveIdIndex,
305 seenFocusContainerIds: new Map<string, FocusContainerKind>(),
306 prevNodeStack: [],
307 containerChildOverrides: new Map<InstanceId, readonly VNode[]>(),
308 layoutDepthRef: { value: 0 },
309 layoutPathTail: [],
310 emittedWarnings: new Set<string>(),
311 lists: { mounted: [], reused: [], unmounted: [] },
312 collectLifecycleInstanceIds,
313 composite: opts.composite ?? null,
314 compositeThemeStack: opts.composite?.theme ? [opts.composite.theme] : [],
315 compositeRenderStack: [],
316 pendingExitAnimations: [],
317 pendingCleanups: [],
318 pendingEffects: [],
319 errorBoundary: opts.errorBoundary ?? null,
320 };
321
322 const prevChildren = prevRoot ? [{ instanceId: prevRoot.instanceId, vnode: prevRoot.vnode }] : [];
323 const res = reconcileChildren(0, prevChildren, [nextRootVNode], opts.allocator, {
324 kind: "root",
325 });
326 if (!res.ok) return { ok: false, fatal: res.fatal };
327
328 const rootPlan = res.value.nextChildren[0];
329 if (!rootPlan) {
330 return {
331 ok: false,
332 fatal: { code: "ZRUI_INVALID_PROPS", detail: "commitVNodeTree: missing root vnode" },
333 };
334 }
335
336 if (prevRoot && rootPlan.prevIndex === null) {
337 if (!tryScheduleExitAnimation(ctx, prevRoot, 0)) {
338 deleteLocalStateForSubtree(opts.localState, prevRoot);
339 collectSubtreeInstanceIds(prevRoot, ctx.lists.unmounted);
340 }
341 }
342
343 const prevMatch = rootPlan.prevIndex === 0 ? prevRoot : null;

Callers 15

renderAndGetLayoutTreeFunction · 0.85
commitTreeFunction · 0.85
renderOpsFunction · 0.85
renderOpsFunction · 0.85
buildSceneFunction · 0.85
renderOpsFunction · 0.85
renderTextareaWithCursorFunction · 0.85
renderStringsFunction · 0.85
renderOpsFunction · 0.85
commitTreeFunction · 0.85
commitTreeFunction · 0.85

Calls 6

reconcileChildrenFunction · 0.85
tryScheduleExitAnimationFunction · 0.85
commitNodeFunction · 0.85
clearMethod · 0.65

Tested by 15

renderAndGetLayoutTreeFunction · 0.68
commitTreeFunction · 0.68
renderOpsFunction · 0.68
renderOpsFunction · 0.68
buildSceneFunction · 0.68
renderOpsFunction · 0.68
renderTextareaWithCursorFunction · 0.68
renderStringsFunction · 0.68
renderOpsFunction · 0.68
commitTreeFunction · 0.68
commitTreeFunction · 0.68
buildSceneFunction · 0.68