@bgub/fig-reconciler 0.1.0-alpha.0 → 0.1.0-alpha.1

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.
package/dist/act.d.ts ADDED
@@ -0,0 +1,4 @@
1
+ //#region src/scheduler.d.ts
2
+ declare function act<T>(callback: () => T | PromiseLike<T>): Promise<Awaited<T>>;
3
+ //#endregion
4
+ export { act };
package/dist/act.js ADDED
@@ -0,0 +1,2 @@
1
+ import { t as act } from "./scheduler-WVeIVb_n.js";
2
+ export { act };
@@ -0,0 +1,21 @@
1
+ //#region src/commit-coordinator.d.ts
2
+ type ReconcilerCommitResult = false | "committed" | "deferred";
3
+ type ReconcilerWorkPriority = "blocking" | "transition" | "suspense" | "idle";
4
+ declare const ReconcilerCommitCoordinatorHostTypes: unique symbol;
5
+ interface ReconcilerCommitContext<Container> {
6
+ readonly container: Container;
7
+ readonly finishedWork: object;
8
+ readonly priority: ReconcilerWorkPriority;
9
+ readonly root: object;
10
+ captureFinished(this: void): void;
11
+ runMutation<Result>(this: void, afterMutation: () => Result): Result | undefined;
12
+ }
13
+ interface ReconcilerCommitCoordinator<Container, Instance> {
14
+ readonly [ReconcilerCommitCoordinatorHostTypes]?: (container: Container, instance: Instance) => readonly [Container, Instance];
15
+ readonly name: string;
16
+ readonly viewTransitions?: true;
17
+ commit(this: void, context: ReconcilerCommitContext<Container>): ReconcilerCommitResult;
18
+ suspend?(this: void, root: object, onReady: () => void): boolean;
19
+ }
20
+ //#endregion
21
+ export { ReconcilerCommitContext, ReconcilerCommitCoordinator, ReconcilerCommitResult, ReconcilerWorkPriority };
@@ -0,0 +1 @@
1
+ export {};
@@ -1,4 +1,4 @@
1
- import { DependencyList, ElementType, FigContext, Props } from "@bgub/fig";
1
+ import { DependencyList, Props } from "@bgub/fig";
2
2
  import { DataStoreEntrySnapshot } from "@bgub/fig/internal";
3
3
  //#region src/devtools.d.ts
4
4
  type FigDevtoolsFiberKind = "root" | "host" | "text" | "function" | "fragment" | "assets" | "context-provider" | "suspense" | "error-boundary" | "portal" | "activity" | "view-transition";
@@ -25,6 +25,7 @@ interface FigDevtoolsFiberSnapshot {
25
25
  childWork: FigDevtoolsWorkLabel[];
26
26
  hooks: FigDevtoolsHookSnapshot[];
27
27
  contextDependencies: string[];
28
+ dataResourceCanonicalKeys: string[];
28
29
  host?: FigDevtoolsHostSnapshot;
29
30
  capturedError?: unknown;
30
31
  componentStack?: string;
@@ -63,7 +64,5 @@ interface FigDevtoolsGlobalHook {
63
64
  inject(renderer: FigDevtoolsRendererInfo): number;
64
65
  onCommitRoot(rendererId: number, snapshot: FigDevtoolsRootSnapshot, inspection?: FigDevtoolsCommitInspection): void;
65
66
  }
66
- declare function devtoolsTypeName(type: ElementType | FigContext<unknown> | null, fallback: string): string;
67
- declare function getFigDevtoolsGlobalHook(): FigDevtoolsGlobalHook | null;
68
67
  //#endregion
69
- export { FigDevtoolsCommitInspection, FigDevtoolsEffectPhase, FigDevtoolsElementInspection, FigDevtoolsFiberKind, FigDevtoolsFiberSnapshot, FigDevtoolsGlobalHook, FigDevtoolsHookKind, FigDevtoolsHookSnapshot, FigDevtoolsHostSnapshot, FigDevtoolsRendererInfo, FigDevtoolsRootSnapshot, FigDevtoolsWorkLabel, devtoolsTypeName, getFigDevtoolsGlobalHook };
68
+ export { FigDevtoolsCommitInspection, FigDevtoolsEffectPhase, FigDevtoolsElementInspection, FigDevtoolsFiberKind, FigDevtoolsFiberSnapshot, FigDevtoolsGlobalHook, FigDevtoolsHookKind, FigDevtoolsHookSnapshot, FigDevtoolsHostSnapshot, FigDevtoolsRendererInfo, FigDevtoolsRootSnapshot, FigDevtoolsWorkLabel };
package/dist/devtools.js CHANGED
@@ -1,22 +1 @@
1
- import { Fragment } from "@bgub/fig";
2
- //#region src/devtools.ts
3
- function devtoolsTypeName(type, fallback) {
4
- if (typeof type === "string") return type;
5
- if (type === Fragment) return "Fragment";
6
- if (typeof type !== "function") return fallback;
7
- const namedType = type;
8
- if (typeof namedType.displayName === "string" && namedType.displayName !== "") return namedType.displayName;
9
- if (typeof namedType.name === "string" && namedType.name !== "") return namedType.name;
10
- return fallback;
11
- }
12
- function getFigDevtoolsGlobalHook() {
13
- const hook = globalThis.__FIG_DEVTOOLS_GLOBAL_HOOK__;
14
- if (typeof hook !== "object" || hook === null || !("inject" in hook) || !("onCommitRoot" in hook)) return null;
15
- const candidate = hook;
16
- if (typeof candidate.inject !== "function" || typeof candidate.onCommitRoot !== "function") return null;
17
- return candidate;
18
- }
19
- //#endregion
20
- export { devtoolsTypeName, getFigDevtoolsGlobalHook };
21
-
22
- //# sourceMappingURL=devtools.js.map
1
+ export {};
@@ -0,0 +1,251 @@
1
+ import { Fragment } from "@bgub/fig";
2
+ import { isActivity, isAssets, isContext, isErrorBoundary, isSuspense, isThenable, isViewTransition } from "@bgub/fig/internal";
3
+ //#region src/fiber-work.ts
4
+ const StoreConsistencyFlag = 2048;
5
+ const AssetFlag = 16384;
6
+ const ContextPropagationFlag = 1024;
7
+ const ViewTransitionStaticFlag = 4096;
8
+ const HoistedStaticFlag = 8192;
9
+ const StaticFlagsMask = 12288;
10
+ function childSubtreeFlags(node) {
11
+ return node.flags & -24843 | node.subtreeFlags;
12
+ }
13
+ function clearTransientFlags(node) {
14
+ node.flags &= StaticFlagsMask;
15
+ node.subtreeFlags &= StaticFlagsMask;
16
+ }
17
+ function tagFor(element) {
18
+ if (typeof element.type === "string") return 1;
19
+ if (element.type === Fragment) return 4;
20
+ if (isAssets(element.type)) return 9;
21
+ if (isContext(element.type)) return 5;
22
+ if (isSuspense(element.type)) return 6;
23
+ if (isActivity(element.type)) return 10;
24
+ if (isErrorBoundary(element.type)) return 7;
25
+ if (isViewTransition(element.type)) return 11;
26
+ return 3;
27
+ }
28
+ const RetryLane1 = 1 << 22;
29
+ const SelectiveHydrationLane = 1 << 26;
30
+ const IdleLane = 1 << 28;
31
+ const OffscreenLane = 1 << 29;
32
+ const DeferredLane = 1 << 30;
33
+ const AllTransitionLanes = 4194048;
34
+ const RetryLanes = 62914560;
35
+ const syncLaneExpirationMs = 250;
36
+ const transitionLaneExpirationMs = 5e3;
37
+ let currentUpdateLane = 32;
38
+ let nextTransitionLane = 256;
39
+ let nextRetryLane = RetryLane1;
40
+ let asyncTransitionLanes = 0;
41
+ const asyncTransitionLaneCounts = createLaneMap(0);
42
+ const transitionTypeHooks = {};
43
+ function createLaneMap(initial) {
44
+ return Array.from({ length: 31 }, () => initial);
45
+ }
46
+ function mergeLanes(a, b) {
47
+ return a | b;
48
+ }
49
+ function includesSomeLane(set, subset) {
50
+ return (set & subset) !== 0;
51
+ }
52
+ function getHighestPriorityLane(lanes) {
53
+ return lanes & -lanes;
54
+ }
55
+ function getHighestPriorityLanes(lanes) {
56
+ const lane = getHighestPriorityLane(lanes);
57
+ if (includesSomeLane(4194048, lane)) return lanes & AllTransitionLanes;
58
+ if (includesSomeLane(62914560, lane)) return lanes & RetryLanes;
59
+ return lane;
60
+ }
61
+ function getNextLanes(root, wipLanes = 0) {
62
+ const pending = root.pendingLanes;
63
+ if (pending === 0) return 0;
64
+ const unblocked = pending & ~root.suspendedLanes;
65
+ const pinged = pending & root.pingedLanes;
66
+ let next = root.expiredLanes & unblocked;
67
+ if (next === 0) {
68
+ next = getHighestPriorityLanes(unblocked);
69
+ if (next === 0) {
70
+ const expiredPinged = root.expiredLanes & pinged;
71
+ next = expiredPinged !== 0 ? expiredPinged : getHighestPriorityLanes(pinged);
72
+ }
73
+ }
74
+ if (next === 0) return 0;
75
+ if (wipLanes !== 0 && wipLanes !== next && !includesSomeLane(root.expiredLanes, wipLanes) && getHighestPriorityLane(next) >= getHighestPriorityLane(wipLanes)) return wipLanes;
76
+ return getEntangledLanes(root, next);
77
+ }
78
+ function getEntangledLanes(root, lanes) {
79
+ let entangled = lanes;
80
+ let visited = 0;
81
+ let laneSet = entangled & root.entangledLanes;
82
+ while (laneSet !== 0) {
83
+ const index = laneToIndex(laneSet);
84
+ const lane = 1 << index;
85
+ entangled |= root.entanglements[index];
86
+ visited |= lane;
87
+ laneSet = entangled & root.entangledLanes & ~visited;
88
+ }
89
+ return entangled;
90
+ }
91
+ function markRootUpdated(root, lane) {
92
+ root.pendingLanes |= lane;
93
+ if (lane !== 268435456) {
94
+ root.suspendedLanes = 0;
95
+ root.pingedLanes = 0;
96
+ }
97
+ }
98
+ function markRootFinished(root, remainingLanes) {
99
+ const noLongerPending = root.pendingLanes & ~remainingLanes;
100
+ root.pendingLanes = remainingLanes;
101
+ root.suspendedLanes = 0;
102
+ root.pingedLanes = 0;
103
+ root.expiredLanes &= remainingLanes;
104
+ root.entangledLanes &= remainingLanes;
105
+ let lanes = noLongerPending;
106
+ while (lanes !== 0) {
107
+ const index = laneToIndex(lanes);
108
+ const lane = 1 << index;
109
+ root.entanglements[index] = 0;
110
+ root.expirationTimes[index] = -1;
111
+ lanes &= ~lane;
112
+ }
113
+ }
114
+ function markRootSuspended(root, lanes) {
115
+ root.suspendedLanes |= lanes;
116
+ root.pingedLanes &= ~lanes;
117
+ let laneSet = lanes;
118
+ while (laneSet !== 0) {
119
+ const index = laneToIndex(laneSet);
120
+ const lane = 1 << index;
121
+ root.expirationTimes[index] = -1;
122
+ laneSet &= ~lane;
123
+ }
124
+ }
125
+ function markRootPinged(root, lanes) {
126
+ root.pingedLanes |= root.suspendedLanes & lanes;
127
+ }
128
+ function markRootEntangled(root, lanes) {
129
+ root.entangledLanes |= lanes;
130
+ let laneSet = lanes;
131
+ while (laneSet !== 0) {
132
+ const index = laneToIndex(laneSet);
133
+ const lane = 1 << index;
134
+ root.entanglements[index] |= lanes;
135
+ laneSet &= ~lane;
136
+ }
137
+ }
138
+ function markStarvedLanesAsExpired(root, currentTime) {
139
+ let lanes = root.pendingLanes & -62914561;
140
+ while (lanes !== 0) {
141
+ const index = laneToIndex(lanes);
142
+ const lane = 1 << index;
143
+ const expiration = root.expirationTimes[index];
144
+ if (expiration === -1) {
145
+ if (!includesSomeLane(root.suspendedLanes, lane) || includesSomeLane(root.pingedLanes, lane)) root.expirationTimes[index] = computeExpirationTime(lane, currentTime);
146
+ } else if (expiration <= currentTime) root.expiredLanes |= lane;
147
+ lanes &= ~lane;
148
+ }
149
+ }
150
+ function claimNextTransitionLane() {
151
+ const lane = nextTransitionLane;
152
+ nextTransitionLane <<= 1;
153
+ if (!includesSomeLane(261888, nextTransitionLane)) nextTransitionLane = 256;
154
+ return lane;
155
+ }
156
+ function claimNextRetryLane() {
157
+ const lane = nextRetryLane;
158
+ nextRetryLane <<= 1;
159
+ if (!includesSomeLane(62914560, nextRetryLane)) nextRetryLane = RetryLane1;
160
+ return lane;
161
+ }
162
+ function isSyncLane(lane) {
163
+ return includesSomeLane(3, lane);
164
+ }
165
+ function includesOnlyTransitions(lanes) {
166
+ return (lanes & AllTransitionLanes) === lanes;
167
+ }
168
+ function getLaneSchedulerPriority(lane) {
169
+ if (includesSomeLane(3, lane)) return 1;
170
+ if (includesSomeLane(76, lane)) return 2;
171
+ if (includesSomeLane(71303088, lane)) return 3;
172
+ if (includesSomeLane(62914560, lane)) return 4;
173
+ return 5;
174
+ }
175
+ function requestUpdateLane() {
176
+ if (currentUpdateLane === 32 && asyncTransitionLanes !== 0) return getHighestPriorityLane(asyncTransitionLanes);
177
+ return currentUpdateLane;
178
+ }
179
+ function runWithPriority(lane, callback) {
180
+ const previousLane = currentUpdateLane;
181
+ currentUpdateLane = lane;
182
+ try {
183
+ return callback();
184
+ } finally {
185
+ currentUpdateLane = previousLane;
186
+ }
187
+ }
188
+ function runWithTransition(callback, options) {
189
+ return runWithTransitionLane(includesSomeLane(4194048, currentUpdateLane) ? currentUpdateLane : claimNextTransitionLane(), callback, options);
190
+ }
191
+ function runWithTransitionLane(lane, callback, options) {
192
+ const releaseTransition = transitionTypeHooks.retain?.(lane, options?.types);
193
+ let result;
194
+ try {
195
+ result = runWithPriority(lane, callback);
196
+ } catch (error) {
197
+ releaseTransition?.();
198
+ throw error;
199
+ }
200
+ if (isThenable(result)) {
201
+ const releaseAsyncLane = trackAsyncTransitionLane(lane);
202
+ let released = false;
203
+ const release = () => {
204
+ if (released) return;
205
+ released = true;
206
+ releaseAsyncLane();
207
+ releaseTransition?.();
208
+ };
209
+ result.then(release, release);
210
+ } else releaseTransition?.();
211
+ return result;
212
+ }
213
+ function trackAsyncTransitionLane(lane) {
214
+ const index = laneToIndex(lane);
215
+ asyncTransitionLaneCounts[index] += 1;
216
+ asyncTransitionLanes |= lane;
217
+ return () => releaseAsyncTransitionLane(lane, index);
218
+ }
219
+ function releaseAsyncTransitionLane(lane, index) {
220
+ asyncTransitionLaneCounts[index] = Math.max(0, asyncTransitionLaneCounts[index] - 1);
221
+ if (asyncTransitionLaneCounts[index] === 0) asyncTransitionLanes &= ~lane;
222
+ }
223
+ function computeExpirationTime(lane, currentTime) {
224
+ if (includesSomeLane(79, lane)) return currentTime + syncLaneExpirationMs;
225
+ if (includesSomeLane(4194224, lane)) return currentTime + transitionLaneExpirationMs;
226
+ return -1;
227
+ }
228
+ function laneToIndex(lanes) {
229
+ return 31 - Math.clz32(lanes);
230
+ }
231
+ //#endregion
232
+ //#region src/fiber-traversal.ts
233
+ function walkFiberForest(node, visitor) {
234
+ walkFiberTree(node, true, visitor);
235
+ }
236
+ function walkFiberSubtree(node, visitor) {
237
+ walkFiberTree(node, false, visitor);
238
+ }
239
+ function walkFiberTree(node, includeRootSiblings, visitor) {
240
+ const stack = [];
241
+ let cursor = node;
242
+ while (cursor !== null) {
243
+ const shouldDescend = visitor(cursor) !== false && cursor.child !== null;
244
+ if ((includeRootSiblings || cursor !== node) && cursor.sibling !== null) stack.push(cursor.sibling);
245
+ cursor = shouldDescend ? cursor.child : stack.pop() ?? null;
246
+ }
247
+ }
248
+ //#endregion
249
+ export { transitionTypeHooks as A, markRootUpdated as C, runWithPriority as D, requestUpdateLane as E, StaticFlagsMask as F, StoreConsistencyFlag as I, ViewTransitionStaticFlag as L, AssetFlag as M, ContextPropagationFlag as N, runWithTransition as O, HoistedStaticFlag as P, childSubtreeFlags as R, markRootSuspended as S, mergeLanes as T, isSyncLane as _, IdleLane as a, markRootFinished as b, SelectiveHydrationLane as c, createLaneMap as d, getHighestPriorityLane as f, includesSomeLane as g, includesOnlyTransitions as h, DeferredLane as i, tagFor as j, runWithTransitionLane as k, claimNextRetryLane as l, getNextLanes as m, walkFiberSubtree as n, OffscreenLane as o, getLaneSchedulerPriority as p, AllTransitionLanes as r, RetryLanes as s, walkFiberForest as t, claimNextTransitionLane as u, laneToIndex as v, markStarvedLanesAsExpired as w, markRootPinged as x, markRootEntangled as y, clearTransientFlags as z };
250
+
251
+ //# sourceMappingURL=fiber-traversal-BHyIAyG9.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fiber-traversal-BHyIAyG9.js","names":[],"sources":["../src/fiber-work.ts","../src/fiber-tags.ts","../src/lanes.ts","../src/fiber-traversal.ts"],"sourcesContent":["export const NoFlags = 0;\n\n// Render emits transient work on individual fibers. Completion folds the\n// subset in SubtreeVisibleFlags into subtreeFlags, and commit interprets the\n// resulting tree summary in host order.\nexport const PlacementFlag = 1 << 0;\nexport const UpdateFlag = 1 << 1;\nexport const HydrationFlag = 1 << 2;\nexport const TextContentFlag = 1 << 3;\nexport const VisibilityFlag = 1 << 5;\nexport const DeletionFlag = 1 << 7;\nexport const EffectFlag = 1 << 9;\nexport const StoreConsistencyFlag = 1 << 11;\n// An Assets fiber owes its renderer a committed descriptor-list diff. Asset\n// work is sparse-indexed and out-of-band, so it never enters subtreeFlags.\nexport const AssetFlag = 1 << 14;\n\n// The fiber reused its committed children without cloning; render skips the\n// subtree and commit walks must not consume already-committed state below it.\nexport const AdoptedFlag = 1 << 4;\n// A host fiber assembled its children at complete-time, so placement inserts\n// the whole subtree once instead of placing each child independently.\nexport const AssembledFlag = 1 << 6;\n// Membership in the root's sparse commit index. Recording is idempotent, and\n// rollback clears this bit from every discarded index entry.\nexport const CommitIndexedFlag = 1 << 8;\n// This render already propagated changed providers through the subtree.\nexport const ContextPropagationFlag = 1 << 10;\n// Static capabilities survive commits and bailouts. A subtree capability is\n// a durable fact about tree shape, unlike transient work owed by this commit.\nexport const ViewTransitionStaticFlag = 1 << 12;\n// The host resolved this fiber to an out-of-band instance. Placement is fixed\n// for the fiber's lifetime and survives updates without reclassifying props.\nexport const HoistedStaticFlag = 1 << 13;\n\nexport type Flag = number;\n\nexport const MutationMask =\n PlacementFlag | UpdateFlag | HydrationFlag | TextContentFlag | VisibilityFlag;\nexport const HostUpdateMask = UpdateFlag | TextContentFlag;\n\n// These marks never enter subtreeFlags. Host updates are found through the\n// sparse commit index; membership and cache marks are not descendant work.\nconst SubtreeMaskedFlags =\n AssetFlag | CommitIndexedFlag | HostUpdateMask | HoistedStaticFlag;\n// Static facts survive commits and bailouts so adopted and deleted subtrees\n// remain searchable without rebuilding their summaries.\nexport const StaticFlagsMask = ViewTransitionStaticFlag | HoistedStaticFlag;\n\nexport function childSubtreeFlags(node: {\n flags: Flag;\n subtreeFlags: Flag;\n}): Flag {\n return (node.flags & ~SubtreeMaskedFlags) | node.subtreeFlags;\n}\n\nexport function clearTransientFlags(node: {\n flags: Flag;\n subtreeFlags: Flag;\n}): void {\n node.flags &= StaticFlagsMask;\n node.subtreeFlags &= StaticFlagsMask;\n}\n","import { type FigElement, Fragment } from \"@bgub/fig\";\nimport {\n isActivity,\n isAssets,\n isContext,\n isErrorBoundary,\n isSuspense,\n isViewTransition,\n} from \"@bgub/fig/internal\";\n\nexport const RootTag = 0;\nexport const HostTag = 1;\nexport const TextTag = 2;\nexport const FunctionTag = 3;\nexport const FragmentTag = 4;\nexport const ContextProviderTag = 5;\nexport const SuspenseTag = 6;\nexport const ErrorBoundaryTag = 7;\nexport const PortalTag = 8;\nexport const AssetsTag = 9;\nexport const ActivityTag = 10;\nexport const ViewTransitionTag = 11;\nexport const ThenableTag = 12;\n\nexport type Tag =\n | typeof RootTag\n | typeof HostTag\n | typeof TextTag\n | typeof FunctionTag\n | typeof FragmentTag\n | typeof ContextProviderTag\n | typeof SuspenseTag\n | typeof ErrorBoundaryTag\n | typeof PortalTag\n | typeof AssetsTag\n | typeof ActivityTag\n | typeof ViewTransitionTag\n | typeof ThenableTag;\n\nexport function tagFor(element: FigElement): Tag {\n if (typeof element.type === \"string\") return HostTag;\n if (element.type === Fragment) return FragmentTag;\n if (isAssets(element.type)) return AssetsTag;\n if (isContext(element.type)) return ContextProviderTag;\n if (isSuspense(element.type)) return SuspenseTag;\n if (isActivity(element.type)) return ActivityTag;\n if (isErrorBoundary(element.type)) return ErrorBoundaryTag;\n if (isViewTransition(element.type)) return ViewTransitionTag;\n return FunctionTag;\n}\n","import { isThenable, type TransitionOptions } from \"@bgub/fig/internal\";\nimport {\n IdlePriority,\n ImmediatePriority,\n LowPriority,\n NormalPriority,\n type PriorityLevel,\n UserBlockingPriority,\n} from \"./scheduler.ts\";\n\nexport type Lane = number;\nexport type Lanes = number;\nexport type LaneMap<T extends number> = T[];\n\nexport const TotalLanes = 31;\nexport const NoTimestamp = -1;\nexport const NoLane = 0;\nexport const NoLanes = 0;\n\nexport const SyncHydrationLane = 1 << 0;\nexport const SyncLane = 1 << 1;\nexport const InputContinuousHydrationLane = 1 << 2;\nexport const InputContinuousLane = 1 << 3;\nexport const DefaultHydrationLane = 1 << 4;\nexport const DefaultLane = 1 << 5;\nexport const GestureLane = 1 << 6;\nexport const TransitionHydrationLane = 1 << 7;\nexport const TransitionLane1 = 1 << 8;\nexport const TransitionLane2 = 1 << 9;\nexport const TransitionLane3 = 1 << 10;\nexport const TransitionLane4 = 1 << 11;\nexport const TransitionLane5 = 1 << 12;\nexport const TransitionLane6 = 1 << 13;\nexport const TransitionLane7 = 1 << 14;\nexport const TransitionLane8 = 1 << 15;\nexport const TransitionLane9 = 1 << 16;\nexport const TransitionLane10 = 1 << 17;\nexport const TransitionLane11 = 1 << 18;\nexport const TransitionLane12 = 1 << 19;\nexport const TransitionLane13 = 1 << 20;\nexport const TransitionLane14 = 1 << 21;\nexport const RetryLane1 = 1 << 22;\nexport const RetryLane2 = 1 << 23;\nexport const RetryLane3 = 1 << 24;\nexport const RetryLane4 = 1 << 25;\nexport const SelectiveHydrationLane = 1 << 26;\nexport const IdleHydrationLane = 1 << 27;\nexport const IdleLane = 1 << 28;\nexport const OffscreenLane = 1 << 29;\nexport const DeferredLane = 1 << 30;\n\nexport const TransitionLane = TransitionLane1;\n\nexport const TransitionLanes =\n TransitionLane1 |\n TransitionLane2 |\n TransitionLane3 |\n TransitionLane4 |\n TransitionLane5 |\n TransitionLane6 |\n TransitionLane7 |\n TransitionLane8 |\n TransitionLane9 |\n TransitionLane10;\nexport const TransitionDeferredLanes =\n TransitionLane11 | TransitionLane12 | TransitionLane13 | TransitionLane14;\nexport const AllTransitionLanes = TransitionLanes | TransitionDeferredLanes;\nexport const RetryLanes = RetryLane1 | RetryLane2 | RetryLane3 | RetryLane4;\nexport const IdleLanes = IdleHydrationLane | IdleLane | OffscreenLane;\nexport const NonIdleLanes = (1 << 27) - 1;\nexport const HydrationLanes =\n SyncHydrationLane |\n InputContinuousHydrationLane |\n DefaultHydrationLane |\n TransitionHydrationLane |\n SelectiveHydrationLane |\n IdleHydrationLane;\n\nexport type LanePriority =\n | \"sync\"\n | \"input\"\n | \"default\"\n | \"gesture\"\n | \"transition\"\n | \"retry\"\n | \"idle\"\n | \"offscreen\"\n | \"deferred\";\n\nexport interface LaneRoot {\n pendingLanes: Lanes;\n suspendedLanes: Lanes;\n pingedLanes: Lanes;\n expiredLanes: Lanes;\n entangledLanes: Lanes;\n entanglements: LaneMap<Lanes>;\n expirationTimes: LaneMap<number>;\n}\n\nconst syncLaneExpirationMs = 250;\nconst transitionLaneExpirationMs = 5_000;\n\nlet currentUpdateLane: Lane = DefaultLane;\nlet nextTransitionLane: Lane = TransitionLane1;\nlet nextRetryLane: Lane = RetryLane1;\n// JavaScript does not expose per-continuation async context in browsers yet, so\n// async transitions keep their lane ambient while the returned thenable is\n// pending. Explicit event/sync priorities still override this fallback.\nlet asyncTransitionLanes: Lanes = NoLanes;\nconst asyncTransitionLaneCounts = createLaneMap<number>(0);\n\ninterface TransitionTypeHooks {\n retain?(lane: Lane, types: readonly string[] | undefined): () => void;\n record?(root: object, lane: Lane): void;\n complete?(root: object, remainingLanes: Lanes): void;\n}\n\n// The optional View Transition entry installs these hooks. Keeping the state\n// behind that entry leaves ordinary renderer bundles with only the hook calls.\nexport const transitionTypeHooks: TransitionTypeHooks = {};\n\nexport function createLaneMap<T extends number>(initial: T): LaneMap<T> {\n return Array.from({ length: TotalLanes }, () => initial);\n}\n\nexport function mergeLanes(a: Lanes, b: Lanes): Lanes {\n return a | b;\n}\n\nexport function includesSomeLane(set: Lanes, subset: Lanes): boolean {\n return (set & subset) !== NoLanes;\n}\n\nexport function getHighestPriorityLane(lanes: Lanes): Lane {\n return lanes & -lanes;\n}\n\nexport function getHighestPriorityLanes(lanes: Lanes): Lanes {\n const lane = getHighestPriorityLane(lanes);\n\n if (includesSomeLane(AllTransitionLanes, lane)) {\n return lanes & AllTransitionLanes;\n }\n\n if (includesSomeLane(RetryLanes, lane)) {\n return lanes & RetryLanes;\n }\n\n return lane;\n}\n\nexport function getNextLanes(root: LaneRoot, wipLanes: Lanes = NoLanes): Lanes {\n const pending = root.pendingLanes;\n if (pending === NoLanes) return NoLanes;\n\n const unblocked = pending & ~root.suspendedLanes;\n const pinged = pending & root.pingedLanes;\n let next = root.expiredLanes & unblocked;\n if (next === NoLanes) {\n next = getHighestPriorityLanes(unblocked);\n\n if (next === NoLanes) {\n // Expired pinged work wins over fresh pinged work; NoLanes is 0, so the\n // fallback only runs when no expired pinged lane exists.\n const expiredPinged = root.expiredLanes & pinged;\n next =\n expiredPinged !== NoLanes\n ? expiredPinged\n : getHighestPriorityLanes(pinged);\n }\n }\n\n if (next === NoLanes) return NoLanes;\n\n if (\n wipLanes !== NoLanes &&\n wipLanes !== next &&\n !includesSomeLane(root.expiredLanes, wipLanes) &&\n getHighestPriorityLane(next) >= getHighestPriorityLane(wipLanes)\n ) {\n return wipLanes;\n }\n\n return getEntangledLanes(root, next);\n}\n\nexport function getEntangledLanes(root: LaneRoot, lanes: Lanes): Lanes {\n let entangled = lanes;\n let visited = NoLanes;\n let laneSet = entangled & root.entangledLanes;\n\n while (laneSet !== NoLanes) {\n const index = laneToIndex(laneSet);\n const lane = 1 << index;\n entangled |= root.entanglements[index];\n visited |= lane;\n laneSet = entangled & root.entangledLanes & ~visited;\n }\n\n return entangled;\n}\n\nexport function markRootUpdated(root: LaneRoot, lane: Lane): void {\n root.pendingLanes |= lane;\n\n if (lane !== IdleLane) {\n root.suspendedLanes = NoLanes;\n root.pingedLanes = NoLanes;\n }\n}\n\nexport function markRootFinished(root: LaneRoot, remainingLanes: Lanes): void {\n const noLongerPending = root.pendingLanes & ~remainingLanes;\n root.pendingLanes = remainingLanes;\n root.suspendedLanes = NoLanes;\n root.pingedLanes = NoLanes;\n root.expiredLanes &= remainingLanes;\n root.entangledLanes &= remainingLanes;\n\n let lanes = noLongerPending;\n while (lanes !== NoLanes) {\n const index = laneToIndex(lanes);\n const lane = 1 << index;\n root.entanglements[index] = NoLanes;\n root.expirationTimes[index] = NoTimestamp;\n lanes &= ~lane;\n }\n}\n\nexport function markRootSuspended(root: LaneRoot, lanes: Lanes): void {\n root.suspendedLanes |= lanes;\n root.pingedLanes &= ~lanes;\n\n let laneSet = lanes;\n while (laneSet !== NoLanes) {\n const index = laneToIndex(laneSet);\n const lane = 1 << index;\n root.expirationTimes[index] = NoTimestamp;\n laneSet &= ~lane;\n }\n}\n\nexport function markRootPinged(root: LaneRoot, lanes: Lanes): void {\n root.pingedLanes |= root.suspendedLanes & lanes;\n}\n\nexport function markRootEntangled(root: LaneRoot, lanes: Lanes): void {\n root.entangledLanes |= lanes;\n\n let laneSet = lanes;\n while (laneSet !== NoLanes) {\n const index = laneToIndex(laneSet);\n const lane = 1 << index;\n root.entanglements[index] |= lanes;\n laneSet &= ~lane;\n }\n}\n\nexport function markStarvedLanesAsExpired(\n root: LaneRoot,\n currentTime: number,\n): void {\n let lanes = root.pendingLanes & ~RetryLanes;\n\n while (lanes !== NoLanes) {\n const index = laneToIndex(lanes);\n const lane = 1 << index;\n const expiration = root.expirationTimes[index];\n\n if (expiration === NoTimestamp) {\n if (\n !includesSomeLane(root.suspendedLanes, lane) ||\n includesSomeLane(root.pingedLanes, lane)\n ) {\n root.expirationTimes[index] = computeExpirationTime(lane, currentTime);\n }\n } else if (expiration <= currentTime) {\n root.expiredLanes |= lane;\n }\n\n lanes &= ~lane;\n }\n}\n\nexport function claimNextTransitionLane(): Lane {\n const lane = nextTransitionLane;\n nextTransitionLane <<= 1;\n\n if (!includesSomeLane(TransitionLanes, nextTransitionLane)) {\n nextTransitionLane = TransitionLane1;\n }\n\n return lane;\n}\n\nexport function claimNextRetryLane(): Lane {\n const lane = nextRetryLane;\n nextRetryLane <<= 1;\n\n if (!includesSomeLane(RetryLanes, nextRetryLane)) {\n nextRetryLane = RetryLane1;\n }\n\n return lane;\n}\n\nexport function isSyncLane(lane: Lane): boolean {\n return includesSomeLane(SyncHydrationLane | SyncLane, lane);\n}\n\nexport function includesOnlyTransitions(lanes: Lanes): boolean {\n return (lanes & AllTransitionLanes) === lanes;\n}\n\nexport function getLanePriority(lane: Lane): LanePriority {\n if (includesSomeLane(SyncHydrationLane | SyncLane, lane)) return \"sync\";\n if (\n includesSomeLane(InputContinuousHydrationLane | InputContinuousLane, lane)\n ) {\n return \"input\";\n }\n if (\n includesSomeLane(\n DefaultHydrationLane | DefaultLane | SelectiveHydrationLane,\n lane,\n )\n ) {\n return \"default\";\n }\n if (includesSomeLane(GestureLane, lane)) return \"gesture\";\n if (includesSomeLane(AllTransitionLanes | TransitionHydrationLane, lane)) {\n return \"transition\";\n }\n if (includesSomeLane(RetryLanes, lane)) return \"retry\";\n if (includesSomeLane(DeferredLane, lane)) return \"deferred\";\n if (includesSomeLane(OffscreenLane, lane)) return \"offscreen\";\n return \"idle\";\n}\n\n// Mask checks directly instead of via getLanePriority's string names, so the\n// name table stays out of production bundles (getLanePriority survives for\n// tests and diagnostics only). `lane` is a single bit (highest-priority\n// lane), so merging the groups is exact.\nexport function getLaneSchedulerPriority(lane: Lane): PriorityLevel {\n if (includesSomeLane(SyncHydrationLane | SyncLane, lane)) {\n return ImmediatePriority;\n }\n if (\n includesSomeLane(\n InputContinuousHydrationLane | InputContinuousLane | GestureLane,\n lane,\n )\n ) {\n return UserBlockingPriority;\n }\n // SelectiveHydrationLane is non-idle work (event-triggered hydration of a\n // dehydrated boundary): schedule it at Normal like React, or it starves\n // behind every transition and never gets a scheduler timeout.\n if (\n includesSomeLane(\n DefaultHydrationLane |\n DefaultLane |\n AllTransitionLanes |\n TransitionHydrationLane |\n SelectiveHydrationLane,\n lane,\n )\n ) {\n return NormalPriority;\n }\n if (includesSomeLane(RetryLanes, lane)) return LowPriority;\n return IdlePriority;\n}\n\nexport function requestUpdateLane(): Lane {\n if (currentUpdateLane === DefaultLane && asyncTransitionLanes !== NoLanes) {\n return getHighestPriorityLane(asyncTransitionLanes);\n }\n\n return currentUpdateLane;\n}\n\nexport function runWithPriority<T>(lane: Lane, callback: () => T): T {\n const previousLane = currentUpdateLane;\n currentUpdateLane = lane;\n\n try {\n return callback();\n } finally {\n currentUpdateLane = previousLane;\n }\n}\n\nexport function runWithTransition<T>(\n callback: () => T,\n options?: TransitionOptions,\n): T {\n const lane = includesSomeLane(AllTransitionLanes, currentUpdateLane)\n ? currentUpdateLane\n : claimNextTransitionLane();\n\n return runWithTransitionLane(lane, callback, options);\n}\n\nexport function runWithTransitionLane<T>(\n lane: Lane,\n callback: () => T,\n options?: TransitionOptions,\n): T {\n const releaseTransition = transitionTypeHooks.retain?.(lane, options?.types);\n let result: T;\n try {\n result = runWithPriority(lane, callback);\n } catch (error) {\n releaseTransition?.();\n throw error;\n }\n\n if (isThenable(result)) {\n const releaseAsyncLane = trackAsyncTransitionLane(lane);\n let released = false;\n const release = (): void => {\n if (released) return;\n released = true;\n releaseAsyncLane();\n releaseTransition?.();\n };\n result.then(release, release);\n } else {\n releaseTransition?.();\n }\n\n return result;\n}\n\nfunction trackAsyncTransitionLane(lane: Lane): () => void {\n const index = laneToIndex(lane);\n asyncTransitionLaneCounts[index] += 1;\n asyncTransitionLanes |= lane;\n\n return () => releaseAsyncTransitionLane(lane, index);\n}\n\nfunction releaseAsyncTransitionLane(lane: Lane, index: number): void {\n asyncTransitionLaneCounts[index] = Math.max(\n 0,\n asyncTransitionLaneCounts[index] - 1,\n );\n\n if (asyncTransitionLaneCounts[index] === 0) {\n asyncTransitionLanes &= ~lane;\n }\n}\n\nfunction computeExpirationTime(lane: Lane, currentTime: number): number {\n if (\n includesSomeLane(\n SyncHydrationLane |\n SyncLane |\n InputContinuousHydrationLane |\n InputContinuousLane |\n GestureLane,\n lane,\n )\n ) {\n return currentTime + syncLaneExpirationMs;\n }\n\n if (\n includesSomeLane(\n DefaultHydrationLane |\n DefaultLane |\n TransitionHydrationLane |\n AllTransitionLanes,\n lane,\n )\n ) {\n return currentTime + transitionLaneExpirationMs;\n }\n\n return NoTimestamp;\n}\n\nexport function laneToIndex(lanes: Lanes): number {\n return 31 - Math.clz32(lanes);\n}\n","interface TreeNode<Node> {\n child: Node | null;\n sibling: Node | null;\n}\n\nexport function walkFiberForest<Node extends TreeNode<Node>>(\n node: Node | null,\n visitor: (node: Node) => boolean | void,\n): void {\n walkFiberTree(node, true, visitor);\n}\n\nexport function walkFiberSubtree<Node extends TreeNode<Node>>(\n node: Node,\n visitor: (node: Node) => boolean | void,\n): void {\n walkFiberTree(node, false, visitor);\n}\n\n// The explicit sibling stack bounds a subtree walk even when a detached\n// deletion still points at kept siblings through its old fiber links.\nfunction walkFiberTree<Node extends TreeNode<Node>>(\n node: Node | null,\n includeRootSiblings: boolean,\n visitor: (node: Node) => boolean | void,\n): void {\n const stack: Node[] = [];\n let cursor = node;\n\n while (cursor !== null) {\n const shouldDescend = visitor(cursor) !== false && cursor.child !== null;\n\n if ((includeRootSiblings || cursor !== node) && cursor.sibling !== null) {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from "./commit-coordinator.js";
1
2
  import { RefreshUpdate } from "./refresh.js";
2
- import { DataResourceKeyInput, ErrorInfo, FigDataHydrationEntry, FigDataStoreHandle, FigNode, Props } from "@bgub/fig";
3
- //#region src/scheduler.d.ts
4
- declare function act<T>(callback: () => T | PromiseLike<T>): Promise<Awaited<T>>;
5
- //#endregion
3
+ import { DataResourceKeyInput, ErrorInfo, FigAssetResourceList, FigDataHydrationEntry, FigDataStoreController, FigDataStoreHandle, FigNode, Props } from "@bgub/fig";
6
4
  //#region src/index.d.ts
7
5
  type EventPriority = "default" | "continuous" | "discrete";
8
6
  declare function runWithEventPriority<T>(priority: EventPriority, callback: () => T): T;
@@ -20,25 +18,10 @@ interface DehydratedSuspenseBoundary<Instance = unknown, TextInstance = unknown>
20
18
  status: "completed" | "pending" | "client-rendered";
21
19
  forceClientRender: boolean;
22
20
  }
23
- type ViewTransitionCommitResult = false | "committed" | "deferred";
24
- interface ViewTransitionSurfaceMeasurement {
25
- absolutelyPositioned: boolean;
26
- height: number;
27
- inViewport: boolean;
28
- width: number;
29
- x: number;
30
- y: number;
31
- }
32
- interface ViewTransitionMutationResult {
33
- canceledNames: string[];
34
- cancelRootSnapshot: boolean;
35
- }
36
- interface ViewTransitionHostConfig<Container, Instance> {
37
- commit(this: void, container: Container, prepareSnapshot: () => void, mutate: () => ViewTransitionMutationResult, cleanup: () => void): ViewTransitionCommitResult;
38
- apply(this: void, instance: Instance, name: string, className: string | null): void;
39
- restore(this: void, instance: Instance, props: Props): void;
40
- measure?(this: void, instance: Instance): ViewTransitionSurfaceMeasurement | null;
41
- suspend?(this: void, container: Container, onFinished: () => void): boolean;
21
+ declare const AssetResourceOwnerBrand: unique symbol;
22
+ /** Stable opaque identity for one fiber's asset-resource ownership. */
23
+ interface AssetResourceOwner {
24
+ readonly [AssetResourceOwnerBrand]: true;
42
25
  }
43
26
  interface HostConfig<Container, Instance, TextInstance> {
44
27
  createInstance(type: string, props: Props, parent: Parent<Container, Instance>): Instance;
@@ -53,10 +36,12 @@ interface HostConfig<Container, Instance, TextInstance> {
53
36
  getNextHydratableSibling?(node: HostNode<Instance, TextInstance>): HostNode<Instance, TextInstance> | null;
54
37
  canHydrateInstance?(node: HostNode<Instance, TextInstance>, type: string, props: Props): boolean;
55
38
  canHydrateTextInstance?(node: HostNode<Instance, TextInstance>, text: string, suppressHydrationWarning?: boolean): boolean;
56
- isHoistedInstance?(type: string, props: Props): boolean;
57
- commitHoistedInstance?(instance: Instance): Instance | void;
58
- removeHoistedInstance?(instance: Instance): void;
59
- updateHoistedInstance?(instance: Instance, previousProps: Props, nextProps: Props): Instance;
39
+ canRetainHydrationTail?(instance: Instance): boolean;
40
+ resolveHoistedInstance?(type: string, props: Props, parent: Parent<Container, Instance>): Instance | null;
41
+ commitHoistedInstance?(instance: Instance, props: Props, owner: AssetResourceOwner): Instance | void;
42
+ removeHoistedInstance?(instance: Instance, owner: AssetResourceOwner): void;
43
+ updateHoistedInstance?(instance: Instance, previousProps: Props, nextProps: Props, owner: AssetResourceOwner): Instance;
44
+ commitAssetResources?(previous: FigAssetResourceList | null, next: FigAssetResourceList | null, owner: AssetResourceOwner): void;
60
45
  shouldCommitUpdate?(type: string, previousProps: Props, nextProps: Props): boolean;
61
46
  clearContainer?(container: Container): void;
62
47
  insertBefore(parent: Parent<Container, Instance>, child: HostNode<Instance, TextInstance>, before: HostNode<Instance, TextInstance> | null): void;
@@ -73,28 +58,28 @@ interface HostConfig<Container, Instance, TextInstance> {
73
58
  getSuspenseBoundary?(node: HostNode<Instance, TextInstance>): DehydratedSuspenseBoundary<Instance, TextInstance> | null;
74
59
  getEnclosingSuspenseBoundaryStart?(target: unknown): HostNode<Instance, TextInstance> | null;
75
60
  isTargetWithinSuspenseBoundary?(target: unknown, boundary: DehydratedSuspenseBoundary<Instance, TextInstance>): boolean;
61
+ shouldRecoverSuspenseMismatchAtRoot?(container: Container, boundary: DehydratedSuspenseBoundary<Instance, TextInstance>): boolean;
76
62
  registerSuspenseBoundaryRetry?(boundary: DehydratedSuspenseBoundary<Instance, TextInstance>, retry: () => void): void;
77
63
  commitHydratedSuspenseBoundary?(boundary: DehydratedSuspenseBoundary<Instance, TextInstance>): void;
78
64
  completeRootHydration?(container: Container): void;
79
65
  removeDehydratedSuspenseBoundary?(boundary: DehydratedSuspenseBoundary<Instance, TextInstance>): void;
80
66
  preparePortalContainer?(container: Parent<Container, Instance>, root: Container, logicalParent: Parent<Container, Instance>): void;
81
67
  removePortalContainer?(container: Parent<Container, Instance>): void;
82
- viewTransition?: ViewTransitionHostConfig<Container, Instance>;
83
68
  commitTextUpdate(text: TextInstance, value: string): void;
84
69
  }
85
- type HostRenderConfig<Container, Instance, TextInstance> = Pick<HostConfig<Container, Instance, TextInstance>, "createInstance" | "createTextInstance" | "appendInitialChild" | "finalizeInitialInstance" | "setTextContent" | "insertBefore" | "removeChild" | "commitUpdate" | "commitTextUpdate" | "shouldCommitUpdate" | "clearContainer">;
86
- type HostValidationConfig<Container, Instance, TextInstance> = Pick<HostConfig<Container, Instance, TextInstance>, "validateInstanceNesting" | "validateTextNesting" | "containerType">;
87
70
  type HostHydrationConfig<Container, Instance, TextInstance> = Required<Pick<HostConfig<Container, Instance, TextInstance>, "getFirstHydratableChild" | "getNextHydratableSibling" | "canHydrateInstance" | "canHydrateTextInstance" | "clearContainer">> & Pick<HostConfig<Container, Instance, TextInstance>, "commitHydratedInstance">;
88
71
  type HostActivityConfig<Container, Instance, TextInstance> = Required<Pick<HostConfig<Container, Instance, TextInstance>, "getActivityBoundary" | "getFirstActivityHydratable" | "commitHydratedActivityBoundary" | "hideInstance" | "unhideInstance" | "hideTextInstance" | "unhideTextInstance">>;
89
72
  type HostSuspenseHydrationConfig<Container, Instance, TextInstance> = Required<Pick<HostConfig<Container, Instance, TextInstance>, "getSuspenseBoundary" | "getEnclosingSuspenseBoundaryStart" | "isTargetWithinSuspenseBoundary" | "registerSuspenseBoundaryRetry" | "commitHydratedSuspenseBoundary" | "completeRootHydration" | "removeDehydratedSuspenseBoundary">>;
90
73
  type HostPortalConfig<Container, Instance, TextInstance> = Required<Pick<HostConfig<Container, Instance, TextInstance>, "preparePortalContainer" | "removePortalContainer">>;
91
- type HostHoistedAssetConfig<Container, Instance, TextInstance> = Required<Pick<HostConfig<Container, Instance, TextInstance>, "isHoistedInstance" | "commitHoistedInstance" | "removeHoistedInstance" | "updateHoistedInstance">>;
74
+ type HostHoistedAssetConfig<Container, Instance, TextInstance> = Required<Pick<HostConfig<Container, Instance, TextInstance>, "resolveHoistedInstance" | "commitHoistedInstance" | "removeHoistedInstance" | "updateHoistedInstance">>;
92
75
  interface FigRoot {
93
76
  data: FigDataStoreHandle;
94
77
  render(children: FigNode): void;
95
78
  unmount(): void;
96
79
  }
97
80
  interface FigRootOptions {
81
+ /** Adopt a store populated before the renderer root was created. */
82
+ dataStore?: FigDataStoreController;
98
83
  dataPartition?: DataResourceKeyInput;
99
84
  initialData?: readonly FigDataHydrationEntry[];
100
85
  identifierPrefix?: string;
@@ -112,14 +97,15 @@ interface RecoverableErrorInfo extends ErrorInfo {
112
97
  source: "hydration" | "server";
113
98
  }
114
99
  type HydrationTargetResult = "none" | "hydrated" | "blocked";
115
- interface FigRenderer<Container> {
100
+ interface FigRenderer<Container, Instance = unknown> {
116
101
  batchedUpdates<T>(this: void, callback: () => T): T;
117
102
  createRoot(this: void, container: Container, options?: FigRootOptions): FigRoot;
118
103
  hydrateRoot(this: void, container: Container, children: FigNode, options?: FigRootOptions): FigRoot;
119
104
  hydrateTarget(this: void, container: Container, target: unknown, priority?: EventPriority): HydrationTargetResult;
120
105
  flushSync<T>(this: void, callback: () => T): T;
106
+ installCommitCoordinator(this: void, coordinator: ReconcilerCommitCoordinator<Container, Instance>): void;
121
107
  scheduleRefresh(this: void, update: RefreshUpdate): void;
122
108
  }
123
- declare function createRenderer<Container, Instance, TextInstance>(host: HostConfig<Container, Instance, TextInstance>): FigRenderer<Container>;
109
+ declare function createRenderer<Container, Instance, TextInstance>(host: HostConfig<Container, Instance, TextInstance>): FigRenderer<Container, Instance>;
124
110
  //#endregion
125
- export { DehydratedSuspenseBoundary, DehydratedSuspenseError, EventPriority, FigRenderer, FigRoot, FigRootOptions, HostActivityConfig, HostConfig, HostHoistedAssetConfig, HostHydrationConfig, HostPortalConfig, HostRenderConfig, HostSuspenseHydrationConfig, HostValidationConfig, HydrationTargetResult, RecoverableErrorInfo, type RefreshUpdate, ViewTransitionCommitResult, ViewTransitionHostConfig, ViewTransitionMutationResult, ViewTransitionSurfaceMeasurement, act, createRenderer, runWithEventPriority };
111
+ export { AssetResourceOwner, DehydratedSuspenseBoundary, DehydratedSuspenseError, EventPriority, FigRenderer, FigRoot, FigRootOptions, HostActivityConfig, HostConfig, HostHoistedAssetConfig, HostHydrationConfig, HostPortalConfig, HostSuspenseHydrationConfig, HydrationTargetResult, RecoverableErrorInfo, type RefreshUpdate, createRenderer, runWithEventPriority };