Wire signal-driven updates: scheduleUpdate, flushUpdates, reconcileProps, commitEffects, wireSignalToFiber, re-renderable render()

This commit is contained in:
2026-05-18 16:50:08 +00:00
parent 87ec672641
commit 24d0134ae4
4 changed files with 472 additions and 0 deletions

View File

@@ -2,6 +2,7 @@ import type { UNode, UElement, URoot, ComponentFn, UComponent } from "../core/sc
import { isURoot, isUPrimitive } from "../core/schema.js";
import { Context } from "../core/context.js";
import type { Fiber } from "./fiber.js";
import { reconcileProps, commitEffects } from "./reconcile.js";
export interface HostConfig<TTag extends string, Instance, RootCtx> {
name: string;
@@ -122,6 +123,19 @@ export function createRoot<TTag extends string, Instance, RootCtx>(
context: rootContext,
rootFiber: null,
render(node: UNode) {
if (this.rootFiber) {
const payloadChildren = isURoot(node) ? (node as URoot).children : [node];
for (let i = 0; i < payloadChildren.length; i++) {
const childFiber = this.rootFiber.children[i];
if (childFiber) {
reconcileProps(childFiber, payloadChildren[i]!, host as HostConfig<string, Instance, unknown>, ctx as unknown);
}
}
commitEffects(this.rootFiber, host as HostConfig<string, Instance, unknown>, ctx as unknown);
host.emit?.("root.render", `root_${Date.now()}`, { childCount: payloadChildren.length });
return;
}
const root: Fiber<Instance> = {
instance: undefined as unknown as Instance,
tag: "#root",