effectable 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (124) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +157 -0
  3. package/build/LICENSE +21 -0
  4. package/build/bootstrap/bootstrap.d.ts +32 -0
  5. package/build/bootstrap/bootstrap.d.ts.map +1 -0
  6. package/build/bootstrap/bootstrap.js +179 -0
  7. package/build/bootstrap/bootstrap.js.map +1 -0
  8. package/build/bootstrap/index.d.ts +9 -0
  9. package/build/bootstrap/index.d.ts.map +1 -0
  10. package/build/bootstrap/index.js +14 -0
  11. package/build/bootstrap/index.js.map +1 -0
  12. package/build/bootstrap/types.d.ts +105 -0
  13. package/build/bootstrap/types.d.ts.map +1 -0
  14. package/build/bootstrap/types.js +26 -0
  15. package/build/bootstrap/types.js.map +1 -0
  16. package/build/component/Component.d.ts +126 -0
  17. package/build/component/Component.d.ts.map +1 -0
  18. package/build/component/Component.js +123 -0
  19. package/build/component/Component.js.map +1 -0
  20. package/build/component/GraphRuntime.d.ts +457 -0
  21. package/build/component/GraphRuntime.d.ts.map +1 -0
  22. package/build/component/GraphRuntime.js +1168 -0
  23. package/build/component/GraphRuntime.js.map +1 -0
  24. package/build/component/constants.d.ts +1 -0
  25. package/build/component/constants.d.ts.map +1 -0
  26. package/build/component/constants.js +2 -0
  27. package/build/component/constants.js.map +1 -0
  28. package/build/component/context.d.ts +199 -0
  29. package/build/component/context.d.ts.map +1 -0
  30. package/build/component/context.js +262 -0
  31. package/build/component/context.js.map +1 -0
  32. package/build/component/graphRuntime.constants.d.ts +13 -0
  33. package/build/component/graphRuntime.constants.d.ts.map +1 -0
  34. package/build/component/graphRuntime.constants.js +15 -0
  35. package/build/component/graphRuntime.constants.js.map +1 -0
  36. package/build/component/h.d.ts +48 -0
  37. package/build/component/h.d.ts.map +1 -0
  38. package/build/component/h.js +72 -0
  39. package/build/component/h.js.map +1 -0
  40. package/build/component/index.d.ts +19 -0
  41. package/build/component/index.d.ts.map +1 -0
  42. package/build/component/index.js +39 -0
  43. package/build/component/index.js.map +1 -0
  44. package/build/component/lifecycle.d.ts +179 -0
  45. package/build/component/lifecycle.d.ts.map +1 -0
  46. package/build/component/lifecycle.js +367 -0
  47. package/build/component/lifecycle.js.map +1 -0
  48. package/build/component/refs.d.ts +105 -0
  49. package/build/component/refs.d.ts.map +1 -0
  50. package/build/component/refs.js +128 -0
  51. package/build/component/refs.js.map +1 -0
  52. package/build/component/types.d.ts +169 -0
  53. package/build/component/types.d.ts.map +1 -0
  54. package/build/component/types.js +40 -0
  55. package/build/component/types.js.map +1 -0
  56. package/build/connect/connect.d.ts +31 -0
  57. package/build/connect/connect.d.ts.map +1 -0
  58. package/build/connect/connect.js +500 -0
  59. package/build/connect/connect.js.map +1 -0
  60. package/build/connect/index.d.ts +8 -0
  61. package/build/connect/index.d.ts.map +1 -0
  62. package/build/connect/index.js +11 -0
  63. package/build/connect/index.js.map +1 -0
  64. package/build/connect/types.d.ts +90 -0
  65. package/build/connect/types.d.ts.map +1 -0
  66. package/build/connect/types.js +8 -0
  67. package/build/connect/types.js.map +1 -0
  68. package/build/index.d.ts +26 -0
  69. package/build/index.d.ts.map +1 -0
  70. package/build/index.js +60 -0
  71. package/build/index.js.map +1 -0
  72. package/build/runtime/BusDecorators.d.ts +113 -0
  73. package/build/runtime/BusDecorators.d.ts.map +1 -0
  74. package/build/runtime/BusDecorators.js +302 -0
  75. package/build/runtime/BusDecorators.js.map +1 -0
  76. package/build/runtime/CommandBus.d.ts +43 -0
  77. package/build/runtime/CommandBus.d.ts.map +1 -0
  78. package/build/runtime/CommandBus.js +65 -0
  79. package/build/runtime/CommandBus.js.map +1 -0
  80. package/build/runtime/EventBus.d.ts +50 -0
  81. package/build/runtime/EventBus.d.ts.map +1 -0
  82. package/build/runtime/EventBus.js +90 -0
  83. package/build/runtime/EventBus.js.map +1 -0
  84. package/build/runtime/HandleRegistry.d.ts +143 -0
  85. package/build/runtime/HandleRegistry.d.ts.map +1 -0
  86. package/build/runtime/HandleRegistry.js +244 -0
  87. package/build/runtime/HandleRegistry.js.map +1 -0
  88. package/build/runtime/QueryBus.d.ts +43 -0
  89. package/build/runtime/QueryBus.d.ts.map +1 -0
  90. package/build/runtime/QueryBus.js +65 -0
  91. package/build/runtime/QueryBus.js.map +1 -0
  92. package/build/runtime/index.d.ts +13 -0
  93. package/build/runtime/index.d.ts.map +1 -0
  94. package/build/runtime/index.js +32 -0
  95. package/build/runtime/index.js.map +1 -0
  96. package/build/runtime/types.d.ts +79 -0
  97. package/build/runtime/types.d.ts.map +1 -0
  98. package/build/runtime/types.js +8 -0
  99. package/build/runtime/types.js.map +1 -0
  100. package/build/store/createStore.d.ts +36 -0
  101. package/build/store/createStore.d.ts.map +1 -0
  102. package/build/store/createStore.js +131 -0
  103. package/build/store/createStore.js.map +1 -0
  104. package/build/store/index.d.ts +14 -0
  105. package/build/store/index.d.ts.map +1 -0
  106. package/build/store/index.js +39 -0
  107. package/build/store/index.js.map +1 -0
  108. package/build/store/middleware.d.ts +38 -0
  109. package/build/store/middleware.d.ts.map +1 -0
  110. package/build/store/middleware.js +99 -0
  111. package/build/store/middleware.js.map +1 -0
  112. package/build/store/selector.d.ts +62 -0
  113. package/build/store/selector.d.ts.map +1 -0
  114. package/build/store/selector.js +226 -0
  115. package/build/store/selector.js.map +1 -0
  116. package/build/store/semanticStateTree.d.ts +91 -0
  117. package/build/store/semanticStateTree.d.ts.map +1 -0
  118. package/build/store/semanticStateTree.js +263 -0
  119. package/build/store/semanticStateTree.js.map +1 -0
  120. package/build/store/types.d.ts +259 -0
  121. package/build/store/types.d.ts.map +1 -0
  122. package/build/store/types.js +28 -0
  123. package/build/store/types.js.map +1 -0
  124. package/package.json +109 -0
@@ -0,0 +1,457 @@
1
+ /**
2
+ * GraphRuntime — runtime engine for materialization, reconcile, and lifecycle of a component tree.
3
+ *
4
+ * Responsibilities:
5
+ * - Materialize a VirtualServiceNode tree into real component instances (Fiber tree).
6
+ * - Fiber-like reconcile: diff current vs next trees by key + type, assign effectTags.
7
+ * - Drive lifecycle via LifecycleEngine: startup in topological order (children before parent),
8
+ * shutdown in reverse order (parent before children).
9
+ * - Inject contexts (@UseContext) and bind refs on mount.
10
+ * - Pass updated props into existing instances during reconcile.
11
+ *
12
+ * Current limitations:
13
+ * - Work loop is synchronous (no priority lanes — next increment).
14
+ * - Component.setState() and connect selector updates schedule automatic subtree reconcile
15
+ * via a dirty-fiber queue with microtask coalescing; manual reconcile remains a force-update API.
16
+ * - ContextProvider is handled as a special case in buildScope.
17
+ *
18
+ * @module Effectable/component/GraphRuntime
19
+ */
20
+ import type { Component } from './Component';
21
+ import type { FiberEffectTag, FiberInspectNode, VirtualServiceNode } from './types';
22
+ import type { ContextScope } from './context';
23
+ import type { RuntimeCommand, RuntimeEvent, RuntimeQuery } from '../runtime/types';
24
+ import type { RuntimeBusesBundle } from '../runtime/BusDecorators';
25
+ /**
26
+ * Runtime engine for a declarative component tree.
27
+ *
28
+ * Usage:
29
+ * ```typescript
30
+ * const runtime = await GraphRuntime.mount(h(AppRoot));
31
+ * await runtime.reconcile(h(AppRoot, { newProp: 1 }));
32
+ * await runtime.unmount();
33
+ * ```
34
+ */
35
+ export declare class GraphRuntime {
36
+ /** Current root fiber tree (current tree). */
37
+ private currentRoot;
38
+ /** Whether unmount has completed. */
39
+ private unmounted;
40
+ /**
41
+ * Entry counter for {@link continueStableReconcileAsync} (test/debug probe).
42
+ * Not reset automatically — compare before/after around reconcile.
43
+ */
44
+ private stableAsyncContinueCount;
45
+ /**
46
+ * Runtime buses for auto-wiring decorators on nodes (optional, set in {@link GraphRuntime.mount}).
47
+ */
48
+ private effectableRuntimeBuses;
49
+ /**
50
+ * Depth-indexed pool of Map objects for keyedCurrentMap in reconcileChildren.
51
+ * Index is recursion depth, which provides re-entrancy safety for nested calls.
52
+ * Map.clear() instead of new Map() yields 5.1x speedup.
53
+ */
54
+ private readonly keyedMapPool;
55
+ /**
56
+ * Current reconcileChildren recursion depth.
57
+ * Incremented before async work, decremented in finally.
58
+ */
59
+ private reconcileDepth;
60
+ /**
61
+ * Set of fiber nodes whose `compose()` subtrees need rebuild.
62
+ * Holds only a “minimal cover”: if an ancestor is already in the set, a descendant is not added.
63
+ */
64
+ private readonly dirtyFibers;
65
+ /** `true` — a microtask flush is already queued. */
66
+ private flushScheduled;
67
+ /** `true` — automatic dirty-fiber flush is in progress (re-entrancy guard). */
68
+ private flushing;
69
+ /**
70
+ * Promise of the current/scheduled dirty-flush (microtask).
71
+ * Manual `reconcile` awaits it to avoid overlapping an in-flight flush.
72
+ */
73
+ private activeFlush;
74
+ /**
75
+ * Number of consecutive dirty-flush passes in the current microtask chain.
76
+ * Reset when the queue is empty after a pass or on manual `reconcile`.
77
+ */
78
+ private dirtyFlushPassCount;
79
+ /**
80
+ * Optional hook invoked when automatic reconcile (dirty-fiber flush) fails.
81
+ * Set via the fourth argument of {@link GraphRuntime.mount}.
82
+ */
83
+ private onAutoReconcileError;
84
+ /**
85
+ * Instances are created only via {@link GraphRuntime.mount}; direct `new GraphRuntime()` is unavailable externally.
86
+ */
87
+ private constructor();
88
+ /**
89
+ * Auto-wires runtime-bus decorators onto the instance before {@link LifecycleEngine.runStartup}.
90
+ *
91
+ * @template P
92
+ * @param {Component<unknown, P>} instance - node instance
93
+ * @param {RuntimeFiber<P>} fiber - node fiber (stores disposer)
94
+ * @returns {void}
95
+ */
96
+ private attachEffectableRuntimeBusWiring;
97
+ /**
98
+ * Removes runtime-bus registrations created by {@link attachEffectableRuntimeBusWiring}.
99
+ *
100
+ * @param {RuntimeFiber<unknown>} fiber - node fiber
101
+ * @returns {void}
102
+ */
103
+ private disposeEffectableRuntimeBusWiring;
104
+ /**
105
+ * Injects the scheduler hook onto the component instance after successful startup.
106
+ * The hook is called from {@link Component.setState} and enqueues the fiber for automatic reconcile.
107
+ *
108
+ * If `setState` ran during startup (pre-mount buffer), schedules reconcile immediately.
109
+ *
110
+ * @param {Component<unknown, unknown>} instance - mounted instance
111
+ * @param {RuntimeFiber<unknown>} fiber - instance fiber (captured in the closure)
112
+ * @returns {void}
113
+ */
114
+ private injectUpdateHook;
115
+ /**
116
+ * Pre-mount buffer: `setState` during `onMount` cannot yet schedule reconcile
117
+ * (the live hook is injected after startup). Marks the fiber; {@link injectUpdateHook}
118
+ * after startup will call {@link scheduleUpdate}
119
+ * (deferred until the mount pass completes).
120
+ *
121
+ * @param {Component<unknown, unknown>} instance - instance before/during startup
122
+ * @param {RuntimeFiber<unknown>} fiber - instance fiber
123
+ * @returns {void}
124
+ */
125
+ private injectPreMountUpdateHook;
126
+ /**
127
+ * Removes the scheduler hook from the instance before unmount.
128
+ * After removal, `setState()` no longer triggers automatic reconcile.
129
+ *
130
+ * @param {Component<unknown, unknown>} instance - instance being unmounted
131
+ * @returns {void}
132
+ */
133
+ private clearUpdateHook;
134
+ /**
135
+ * Adds a fiber to the dirty queue with ancestor deduplication and schedules a microtask flush.
136
+ *
137
+ * Deduplication:
138
+ * - If an ancestor of the fiber is already queued → skip (ancestor covers the subtree).
139
+ * - If descendants of the fiber are queued → remove them (fiber covers their subtrees).
140
+ *
141
+ * @param {RuntimeFiber<unknown>} fiber - fiber whose subtree needs rebuild
142
+ * @returns {void}
143
+ */
144
+ private scheduleUpdate;
145
+ /**
146
+ * Queues one dirty-flush microtask and publishes {@link activeFlush} for await from `reconcile`.
147
+ *
148
+ * @returns {void}
149
+ */
150
+ private scheduleDirtyFlushMicrotask;
151
+ /**
152
+ * Flushes accumulated dirty fibers.
153
+ * Called from the microtask queued by {@link scheduleUpdate}.
154
+ * Guarded by the `flushing` flag against re-entrancy.
155
+ * The chain of repeat passes is capped by {@link GRAPH_RUNTIME_MAX_DIRTY_FLUSH_PASSES}.
156
+ *
157
+ * @returns {Promise<void>}
158
+ */
159
+ private flushDirtyFibers;
160
+ /**
161
+ * Rebuilds the `compose()` subtree of one dirty fiber without updating its props.
162
+ *
163
+ * Used for automatic reconcile after `setState()`: the instance already updated `state`,
164
+ * we only need to call `compose()` again and diff children.
165
+ *
166
+ * @param {RuntimeFiber<unknown>} fiber - fiber whose subtree needs rebuild
167
+ * @returns {void | Promise<void>}
168
+ */
169
+ private reconcileDirtyFiber;
170
+ /**
171
+ * Mounts a component tree and returns a running GraphRuntime.
172
+ * Builds the fiber tree, injects contexts, runs lifecycle in order:
173
+ * child nodes first, then the parent.
174
+ *
175
+ * @param {VirtualServiceNode<P>} root - root virtual node
176
+ * @param {ContextScope} initialScope - initial context scope (empty by default)
177
+ * @returns {Promise<GraphRuntime>} running runtime
178
+ * @throws {Error} if any node's startup failed
179
+ */
180
+ static mount<P = unknown>(root: VirtualServiceNode<P>, initialScope?: ContextScope, runtimeBuses?: RuntimeBusesBundle<RuntimeCommand, RuntimeQuery, RuntimeEvent>, onAutoReconcileError?: (err: unknown) => void): Promise<GraphRuntime>;
181
+ /**
182
+ * Reconciles against a new tree.
183
+ * Builds a work-in-progress tree, computes effectTags, applies changes:
184
+ * - PLACE: create and mount a new node
185
+ * - UPDATE: update props on an existing instance, call onUpdate
186
+ * - DELETE: unmount and destroy a node
187
+ *
188
+ * @param {VirtualServiceNode<P>} nextTree - new virtual tree
189
+ * @returns {Promise<void>}
190
+ * @throws {Error} if the runtime is already unmounted
191
+ */
192
+ reconcile<P = unknown>(nextTree: VirtualServiceNode<P>): Promise<void>;
193
+ /**
194
+ * Fully unmounts the component tree.
195
+ * Calls onUnmount for each node in reverse order (children before parent) and
196
+ * moves stages to destroyed via LifecycleEngine.
197
+ *
198
+ * @returns {Promise<void>}
199
+ */
200
+ unmount(): Promise<void>;
201
+ /**
202
+ * Returns the root component instance (for testing and introspection).
203
+ *
204
+ * @returns {Component<unknown, unknown> | null}
205
+ */
206
+ getRootInstance(): Component<unknown, unknown> | null;
207
+ /**
208
+ * Whether the runtime is active (unmount has not been called).
209
+ *
210
+ * @returns {boolean}
211
+ */
212
+ isActive(): boolean;
213
+ /**
214
+ * Readonly snapshot of the root fiber tree for test/debug introspection.
215
+ * Does not export mutable RuntimeFiber; returns null after unmount.
216
+ *
217
+ * @returns {FiberInspectNode | null} root snapshot or null
218
+ */
219
+ inspectRootFiber(): FiberInspectNode | null;
220
+ /**
221
+ * Entity tests only: nulls the root fiber `instance`
222
+ * to exercise the UPDATE guard when `fiber.instance === null`.
223
+ * Do not use in the production control plane.
224
+ *
225
+ * @returns {void}
226
+ */
227
+ nullRootInstanceForTests(): void;
228
+ /**
229
+ * Number of {@link continueStableReconcileAsync} calls since runtime creation.
230
+ * Test/debug probe; not a production API.
231
+ *
232
+ * @returns {number} accumulated counter
233
+ */
234
+ getStableAsyncContinueCount(): number;
235
+ /**
236
+ * Builds a deep readonly {@link FiberInspectNode} from a RuntimeFiber.
237
+ *
238
+ * @param {RuntimeFiber} fiber - source fiber
239
+ * @returns {FiberInspectNode} node snapshot
240
+ */
241
+ private toFiberInspectNode;
242
+ /**
243
+ * Creates a RuntimeFiber for a virtual node: instantiates the component,
244
+ * injects contexts, builds the child scope (for ContextProvider),
245
+ * recursively materializes children, binds ref, runs lifecycle.
246
+ *
247
+ * Returns {@link RuntimeFiber} synchronously if the whole subtree is sync
248
+ * (up to 116x speedup for a tree of 16 sync children); otherwise a Promise.
249
+ * `await` works correctly with either union branch.
250
+ *
251
+ * @param {VirtualServiceNode<P>} vnode - virtual node
252
+ * @param {RuntimeFiber | null} parentFiber - parent fiber
253
+ * @param {ContextScope} parentScope - parent scope
254
+ * @returns {RuntimeFiber<P> | Promise<RuntimeFiber<P>>}
255
+ */
256
+ private materialize;
257
+ /**
258
+ * Async continuation of {@link materialize} after a child returned a Promise.
259
+ * Finishes remaining child fibers with `await`, then runs parent startup.
260
+ *
261
+ * @param {RuntimeFiber<P>} fiber - current fiber
262
+ * @param {Component<unknown, P>} instance - component instance
263
+ * @param {LifecycleEngine} engine - lifecycle engine
264
+ * @param {VirtualServiceNode<P>} vnode - virtual node
265
+ * @param {VirtualServiceNode[]} childVnodes - all child vnodes
266
+ * @param {RuntimeFiber<unknown>[]} childFibers - already materialized child fibers
267
+ * @param {Promise<RuntimeFiber<unknown>>} pending - Promise for the current child
268
+ * @param {number} pendingIdx - index of the current child
269
+ * @returns {Promise<RuntimeFiber<P>>}
270
+ */
271
+ private continueMaterializeAsync;
272
+ /**
273
+ * Async finalization of {@link materialize} when child fibers were gathered synchronously but {@link LifecycleEngine.runStartup} returned a Promise.
274
+ *
275
+ * @template P node props type
276
+ * @param {RuntimeFiber<P>} fiber - fiber of the subtree root node
277
+ * @param {LifecycleEngine} engine - lifecycle engine for this node
278
+ * @param {RuntimeFiber<unknown>[]} childFibers - already mounted child fibers (for rollback on error)
279
+ * @param {PromiseLike<import('./lifecycle').LifecycleTransitionResult>} pendingStartup - Promise of the `runStartup` result
280
+ * @returns {Promise<RuntimeFiber<P>>} ready fiber, or rollback children and rethrow
281
+ */
282
+ private finalizeMaterializeAsync;
283
+ /**
284
+ * Unmounts already-mounted children when parent startup fails.
285
+ * Returns sync void if all demounts are sync, otherwise a Promise.
286
+ *
287
+ * @param {RuntimeFiber<unknown>[]} childFibers
288
+ * @returns {void | Promise<void>}
289
+ */
290
+ private destroyChildrenOnError;
291
+ /**
292
+ * Runs fiber-like reconcile for a single node.
293
+ * If type and key match — UPDATE: update props, reconcile children.
294
+ * If they differ — DELETE the old node, PLACE the new one.
295
+ *
296
+ * @param {RuntimeFiber<P>} current - current fiber
297
+ * @param {VirtualServiceNode<P>} nextVnode - new virtual node
298
+ * @param {RuntimeFiber | null} parentFiber - parent fiber
299
+ * @param {ContextScope} parentScope - parent scope
300
+ * @returns {Promise<RuntimeFiber<P>>}
301
+ */
302
+ private reconcileFiber;
303
+ /**
304
+ * Updates an existing fiber: applies new props to the instance,
305
+ * calls onUpdate, recursively diffs children.
306
+ *
307
+ * @param {RuntimeFiber<P>} current - current fiber
308
+ * @param {VirtualServiceNode<P>} nextVnode - new virtual node
309
+ * @param {RuntimeFiber | null} parentFiber - parent fiber
310
+ * @param {ContextScope} parentScope - parent scope
311
+ * @returns {Promise<RuntimeFiber<P>>}
312
+ */
313
+ private updateFiber;
314
+ /**
315
+ * Fiber cleanup after update/compose error: `runFailedCleanup` + bus dispose.
316
+ * Does not leave the node in `ready`.
317
+ *
318
+ * @param {RuntimeFiber<unknown>} fiber - fiber that failed
319
+ * @returns {void | Promise<void>}
320
+ */
321
+ private runFiberFailedCleanup;
322
+ /**
323
+ * Applies the reconcile result to the current fiber in-place.
324
+ * In-place mutation instead of spread: 0 heap allocations on UPDATE
325
+ * (3.09x speedup). Safe: RuntimeFiber is private.
326
+ *
327
+ * @param {RuntimeFiber<P>} current - current fiber
328
+ * @param {VirtualServiceNode<P>} nextVnode - new vnode
329
+ * @param {RuntimeFiber<unknown> | null} parentFiber - parent fiber
330
+ * @param {ContextScope} parentScope - parent scope
331
+ * @param {RuntimeFiber<unknown>[]} nextChildren - new child fibers
332
+ * @returns {void}
333
+ */
334
+ private applyFiberUpdate;
335
+ /**
336
+ * Diffs children: matches current and next child nodes by key+type.
337
+ * Nodes without a key are matched by position.
338
+ * Extra current nodes — DELETE; new unpaired nodes — PLACE.
339
+ *
340
+ * Optimizations:
341
+ * - isStableChildren fast-path (9.31x): if children are stable (N≤32, same type+key) — indexed loop without Map.
342
+ * - Skip keyedCurrentMap (6.06x): if there are no keyed children — do not create a Map at all.
343
+ * - Depth-indexed Map pool (5.1x): with keyed children, reuse Map via clear() instead of new Map().
344
+ *
345
+ * @param {RuntimeFiber[]} currentChildren - current child fibers
346
+ * @param {VirtualServiceNode[]} nextVnodes - new child virtual nodes
347
+ * @param {RuntimeFiber} parentFiber - parent fiber
348
+ * @param {ContextScope} childScope - scope for child nodes
349
+ * @returns {Promise<RuntimeFiber[]>}
350
+ */
351
+ private reconcileChildren;
352
+ /**
353
+ * Async continuation of the stable fast-path reconcile after an async child.
354
+ *
355
+ * @param {RuntimeFiber<unknown>[]} resultSoFar - already gathered sync children
356
+ * @param {PromiseLike<RuntimeFiber<unknown>>} pending - Promise for the current child
357
+ * @param {number} pendingIdx - index of the pending child
358
+ * @param {VirtualServiceNode[]} nextVnodes - all new vnodes
359
+ * @param {RuntimeFiber<unknown>[]} currentChildren - all current fibers
360
+ * @param {RuntimeFiber<unknown>} parentFiber - parent fiber
361
+ * @param {ContextScope} childScope - children scope
362
+ * @returns {Promise<RuntimeFiber<unknown>[]>}
363
+ */
364
+ private continueStableReconcileAsync;
365
+ /**
366
+ * Full-diff reconcile: keyed/unkeyed Map + destroy orphans.
367
+ * Always async — internal branching is too complex for an efficient sync path.
368
+ *
369
+ * @param {RuntimeFiber<unknown>[]} currentChildren - current child fibers
370
+ * @param {VirtualServiceNode[]} nextVnodes - new vnodes
371
+ * @param {RuntimeFiber<unknown>} parentFiber - parent fiber
372
+ * @param {ContextScope} childScope - children scope
373
+ * @returns {Promise<RuntimeFiber<unknown>[]>}
374
+ */
375
+ private reconcileChildrenFullDiff;
376
+ /**
377
+ * Whether children are stable: same count, same type and key per position.
378
+ * Only for N≤32 — with more children the check does not pay off.
379
+ * When children are stable, reconcileChildren skips the full diff (9.31x speedup).
380
+ *
381
+ * @param {RuntimeFiber<unknown>[]} current - current child fibers
382
+ * @param {VirtualServiceNode[]} next - new child virtual nodes
383
+ * @returns {boolean} true if children are stable and the fast-path may be used
384
+ */
385
+ private isStableChildren;
386
+ /**
387
+ * Returns a Map from the depth-indexed pool for the current recursion depth.
388
+ * On first visit to a depth — creates a new Map (lazy alloc).
389
+ * Repeated calls at the same depth get an already-cleared Map.
390
+ *
391
+ * @returns {Map<string, RuntimeFiber<unknown>>} Map for the current recursion depth
392
+ */
393
+ private acquireKeyedMap;
394
+ /**
395
+ * Clears the Map for the current recursion depth and returns it to the pool.
396
+ * Called in finally after the keyed diff completes.
397
+ *
398
+ * @returns {void}
399
+ */
400
+ private releaseKeyedMap;
401
+ /**
402
+ * Unmounts a fiber and its entire subtree.
403
+ * Order: children first (recursively), then the parent.
404
+ * Afterward: clears ref.current.
405
+ *
406
+ * Returns `void` synchronously if the whole subtree is sync (up to 266x speedup
407
+ * on an 85-node tree); otherwise a Promise. `await` works correctly with either union branch.
408
+ *
409
+ * @param {RuntimeFiber} fiber - fiber to destroy
410
+ * @returns {void | Promise<void>}
411
+ */
412
+ private destroyFiber;
413
+ /**
414
+ * Async continuation of {@link destroyFiber} after one of the children returned a Promise.
415
+ *
416
+ * @param {RuntimeFiber<unknown>} fiber - current fiber
417
+ * @param {Fiber[]} children - children list
418
+ * @param {number} pendingIdx - index of the pending child
419
+ * @param {PromiseLike<void>} pending - Promise from destroying the child
420
+ * @returns {Promise<void>}
421
+ */
422
+ private continueDestroyAsync;
423
+ /**
424
+ * Async finalization of {@link destroyFiber} when children were destroyed synchronously
425
+ * but `runShutdown` returned a Promise.
426
+ *
427
+ * @param {RuntimeFiber<unknown>} fiber
428
+ * @param {PromiseLike<unknown>} pendingShutdown
429
+ * @returns {Promise<void>}
430
+ */
431
+ private finalizeDestroyAsync;
432
+ /**
433
+ * Returns the list of child VirtualServiceNode: first from the instance's compose(),
434
+ * then from explicit vnode children (fallback).
435
+ *
436
+ * @param {Component<unknown, unknown>} instance - component instance
437
+ * @param {VirtualServiceNode[]} explicitChildren - children from vnode.children
438
+ * @returns {VirtualServiceNode[]}
439
+ */
440
+ private getChildVnodes;
441
+ /**
442
+ * Builds the child scope: if the instance is a ContextProvider — extends the scope with its values.
443
+ *
444
+ * @param {Component<unknown, unknown>} instance - component instance
445
+ * @param {ContextScope} parentScope - parent scope
446
+ * @returns {ContextScope}
447
+ */
448
+ private buildChildScope;
449
+ }
450
+ /**
451
+ * Creates a node effectTag from a situation (identity helper for {@link FiberEffectTag}).
452
+ *
453
+ * @param {FiberEffectTag} tag - value from {@link FIBER_EFFECT_TAG} or null
454
+ * @returns {FiberEffectTag}
455
+ */
456
+ export declare function makeFiberEffectTag(tag: FiberEffectTag): FiberEffectTag;
457
+ //# sourceMappingURL=GraphRuntime.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"GraphRuntime.d.ts","sourceRoot":"","sources":["../../src/component/Gra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