@bgub/fig-reconciler 0.1.0-alpha.2 → 0.1.0-alpha.3
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/refresh.d.ts +5 -1
- package/dist/refresh.js.map +1 -1
- package/dist-development/act.js +2 -0
- package/dist-development/commit-coordinator.js +1 -0
- package/dist-development/devtools.js +1 -0
- package/dist-development/fiber-traversal-B_egclZy.js +252 -0
- package/dist-development/fiber-traversal-B_egclZy.js.map +1 -0
- package/dist-development/index.js +3632 -0
- package/dist-development/index.js.map +1 -0
- package/dist-development/refresh-internal-C6pcjhGn.js +34 -0
- package/dist-development/refresh-internal-C6pcjhGn.js.map +1 -0
- package/dist-development/refresh.js +9 -0
- package/dist-development/refresh.js.map +1 -0
- package/dist-development/scheduler-WVeIVb_n.js +209 -0
- package/dist-development/scheduler-WVeIVb_n.js.map +1 -0
- package/dist-development/view-transitions.js +462 -0
- package/dist-development/view-transitions.js.map +1 -0
- package/package.json +11 -4
|
@@ -0,0 +1,3632 @@
|
|
|
1
|
+
import { A as runWithTransitionLane, B as clearTransientFlags, C as markRootSuspended, D as requestUpdateLane, E as mergeLanes, F as HoistedStaticFlag, I as StaticFlagsMask, L as StoreConsistencyFlag, M as tagFor, N as AssetFlag, O as runWithPriority, P as ContextPropagationFlag, R as ViewTransitionStaticFlag, S as markRootPinged, T as markStarvedLanesAsExpired, _ as includesSomeLane, b as markRootEntangled, c as RetryLanes, d as claimNextTransitionLane, f as createLaneMap, g as includesOnlyTransitions, h as getNextLanes, i as DeferredLane, j as transitionTypeHooks, k as runWithTransition, l as SelectiveHydrationLane, m as getLaneSchedulerPriority, n as walkFiberSubtree, p as getHighestPriorityLane, s as OffscreenLane, t as walkFiberForest, u as claimNextRetryLane, v as isSyncLane, w as markRootUpdated, x as markRootFinished, z as childSubtreeFlags } from "./fiber-traversal-B_egclZy.js";
|
|
2
|
+
import { a as shouldYieldToHost, i as scheduleCallback, n as now, r as requestPaint } from "./scheduler-WVeIVb_n.js";
|
|
3
|
+
import { a as runWithStaleRefreshFamilies, i as resolveLatestType, n as matchesComponentFamily, r as refreshFamilyFor, t as hasRefreshHandler } from "./refresh-internal-C6pcjhGn.js";
|
|
4
|
+
import { Fragment, isValidElement } from "@bgub/fig";
|
|
5
|
+
import { attachDataStore, collectChildren, dataResourceKeysForError, invalidChildError, isPortal, isThenable, readThenable, setCurrentDataStore, setCurrentDispatcher, setTransitionHandler, trackThenable } from "@bgub/fig/internal";
|
|
6
|
+
//#region src/commit-index.ts
|
|
7
|
+
function recordCommitWork(index, node, flags = 0) {
|
|
8
|
+
node.flags |= flags;
|
|
9
|
+
if ((node.flags & 256) !== 0) return;
|
|
10
|
+
node.flags |= 256;
|
|
11
|
+
index.push(node);
|
|
12
|
+
}
|
|
13
|
+
function rollbackCommitIndex(index, checkpoint) {
|
|
14
|
+
if (checkpoint === void 0 || checkpoint >= index.length) return;
|
|
15
|
+
for (let offset = checkpoint; offset < index.length; offset += 1) index[offset].flags &= -257;
|
|
16
|
+
index.length = checkpoint;
|
|
17
|
+
}
|
|
18
|
+
function clearCommitIndex(index) {
|
|
19
|
+
for (const node of index) node.flags &= -257;
|
|
20
|
+
index.length = 0;
|
|
21
|
+
}
|
|
22
|
+
//#endregion
|
|
23
|
+
//#region src/devtools-internal.ts
|
|
24
|
+
function devtoolsTypeName(type, fallback) {
|
|
25
|
+
if (typeof type === "string") return type;
|
|
26
|
+
if (type === Fragment) return "Fragment";
|
|
27
|
+
if (typeof type !== "function") return fallback;
|
|
28
|
+
const namedType = type;
|
|
29
|
+
if (typeof namedType.displayName === "string" && namedType.displayName !== "") return namedType.displayName;
|
|
30
|
+
if (typeof namedType.name === "string" && namedType.name !== "") return namedType.name;
|
|
31
|
+
return fallback;
|
|
32
|
+
}
|
|
33
|
+
function getFigDevtoolsGlobalHook() {
|
|
34
|
+
const hook = globalThis.__FIG_DEVTOOLS_GLOBAL_HOOK__;
|
|
35
|
+
if (typeof hook !== "object" || hook === null || !("inject" in hook) || !("onCommitRoot" in hook)) return null;
|
|
36
|
+
const candidate = hook;
|
|
37
|
+
if (typeof candidate.inject !== "function" || typeof candidate.onCommitRoot !== "function") return null;
|
|
38
|
+
return candidate;
|
|
39
|
+
}
|
|
40
|
+
const hookKindNames = [
|
|
41
|
+
"reactive",
|
|
42
|
+
"before-paint",
|
|
43
|
+
"before-layout",
|
|
44
|
+
"state",
|
|
45
|
+
"action-state",
|
|
46
|
+
"id",
|
|
47
|
+
"deferred-value",
|
|
48
|
+
"external-store",
|
|
49
|
+
"memo",
|
|
50
|
+
"transition",
|
|
51
|
+
"stable-event"
|
|
52
|
+
];
|
|
53
|
+
function isEffectHook(kind) {
|
|
54
|
+
return kind <= 2;
|
|
55
|
+
}
|
|
56
|
+
//#endregion
|
|
57
|
+
//#region src/devtools-snapshot.ts
|
|
58
|
+
const devtoolsFiberIds = /* @__PURE__ */ new WeakMap();
|
|
59
|
+
const devtoolsRootIds = /* @__PURE__ */ new WeakMap();
|
|
60
|
+
const devtoolsRendererIds = /* @__PURE__ */ new WeakMap();
|
|
61
|
+
let nextDevtoolsFiberId = 1;
|
|
62
|
+
let nextDevtoolsRootId = 1;
|
|
63
|
+
function emitDevtoolsCommit(renderer, root) {
|
|
64
|
+
const hook = getFigDevtoolsGlobalHook();
|
|
65
|
+
if (hook === null) return;
|
|
66
|
+
try {
|
|
67
|
+
let rendererId = devtoolsRendererIds.get(renderer);
|
|
68
|
+
if (rendererId === void 0) {
|
|
69
|
+
rendererId = hook.inject({
|
|
70
|
+
name: "Fig",
|
|
71
|
+
packageName: "@bgub/fig-reconciler"
|
|
72
|
+
});
|
|
73
|
+
devtoolsRendererIds.set(renderer, rendererId);
|
|
74
|
+
}
|
|
75
|
+
const inspection = {
|
|
76
|
+
hostFibers: /* @__PURE__ */ new WeakMap(),
|
|
77
|
+
fiberElements: /* @__PURE__ */ new Map()
|
|
78
|
+
};
|
|
79
|
+
const snapshot = snapshotDevtoolsRoot(root, rendererId, inspection);
|
|
80
|
+
hook.onCommitRoot(rendererId, snapshot, createDevtoolsCommitInspection(snapshot.id, inspection));
|
|
81
|
+
} catch {}
|
|
82
|
+
}
|
|
83
|
+
function snapshotDevtoolsRoot(root, rendererId, inspection) {
|
|
84
|
+
return {
|
|
85
|
+
id: devtoolsRootId(root),
|
|
86
|
+
rendererId,
|
|
87
|
+
committedAt: now(),
|
|
88
|
+
dataResources: root.dataStore.inspectDataEntries(),
|
|
89
|
+
pendingWork: devtoolsWorkLabels(root.pendingLanes),
|
|
90
|
+
suspendedWork: devtoolsWorkLabels(root.suspendedLanes),
|
|
91
|
+
pingedWork: devtoolsWorkLabels(root.pingedLanes),
|
|
92
|
+
expiredWork: devtoolsWorkLabels(root.expiredLanes),
|
|
93
|
+
tree: snapshotDevtoolsFiber(root.current, null, root.dataStore, inspection)
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
function snapshotDevtoolsFiber(node, parentId, dataStore, inspection) {
|
|
97
|
+
const id = devtoolsFiberId(node);
|
|
98
|
+
const { kind, name } = devtoolsFiberInfo(node);
|
|
99
|
+
const children = [];
|
|
100
|
+
const errorState = devtoolsErrorBoundaryState(node);
|
|
101
|
+
recordDevtoolsHostFiber(node, id, inspection);
|
|
102
|
+
for (let child = node.child; child !== null; child = child.sibling) appendDevtoolsChildSnapshots(child, id, dataStore, inspection, children);
|
|
103
|
+
return {
|
|
104
|
+
id,
|
|
105
|
+
parentId,
|
|
106
|
+
name,
|
|
107
|
+
kind,
|
|
108
|
+
key: node.key,
|
|
109
|
+
index: node.index,
|
|
110
|
+
props: devtoolsProps(node),
|
|
111
|
+
pendingWork: devtoolsWorkLabels(node.lanes),
|
|
112
|
+
childWork: devtoolsWorkLabels(node.childLanes),
|
|
113
|
+
hooks: devtoolsHooks(node.memoizedState),
|
|
114
|
+
contextDependencies: devtoolsContextDependencies(node),
|
|
115
|
+
dataResourceCanonicalKeys: devtoolsDataResourceKeys(node, dataStore),
|
|
116
|
+
host: devtoolsHost(node),
|
|
117
|
+
capturedError: errorState?.error,
|
|
118
|
+
componentStack: errorState?.info.componentStack,
|
|
119
|
+
children
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
function devtoolsErrorBoundaryState(node) {
|
|
123
|
+
return node.tag === 7 ? node.boundaryState : null;
|
|
124
|
+
}
|
|
125
|
+
function devtoolsWorkLabels(lanes) {
|
|
126
|
+
const labels = [];
|
|
127
|
+
if (includesSomeLane(lanes, 3)) labels.push("sync");
|
|
128
|
+
if (includesSomeLane(lanes, 12)) labels.push("input");
|
|
129
|
+
if (includesSomeLane(lanes, 48)) labels.push("default");
|
|
130
|
+
if (includesSomeLane(lanes, 64)) labels.push("gesture");
|
|
131
|
+
if (includesSomeLane(lanes, 4194176)) labels.push("transition");
|
|
132
|
+
if (includesSomeLane(lanes, 62914560)) labels.push("retry");
|
|
133
|
+
if (includesSomeLane(lanes, 402653184)) labels.push("idle");
|
|
134
|
+
if (includesSomeLane(lanes, 536870912)) labels.push("offscreen");
|
|
135
|
+
if (includesSomeLane(lanes, 1073741824)) labels.push("deferred");
|
|
136
|
+
if (includesSomeLane(lanes, 67108864)) labels.push("selective-hydration");
|
|
137
|
+
return labels;
|
|
138
|
+
}
|
|
139
|
+
function devtoolsDataResourceKeys(node, dataStore) {
|
|
140
|
+
const keys = dataStore.inspectDataDependencyCanonicalKeys(node);
|
|
141
|
+
if (keys.length > 0 || node.alternate === null) return keys;
|
|
142
|
+
return dataStore.inspectDataDependencyCanonicalKeys(node.alternate);
|
|
143
|
+
}
|
|
144
|
+
function appendDevtoolsChildSnapshots(node, parentId, dataStore, inspection, children) {
|
|
145
|
+
if (node.tag === 10 && node.type === null || node.tag === 12) {
|
|
146
|
+
for (let child = node.child; child !== null; child = child.sibling) appendDevtoolsChildSnapshots(child, parentId, dataStore, inspection, children);
|
|
147
|
+
return;
|
|
148
|
+
}
|
|
149
|
+
children.push(snapshotDevtoolsFiber(node, parentId, dataStore, inspection));
|
|
150
|
+
}
|
|
151
|
+
function devtoolsRootId(root) {
|
|
152
|
+
const existing = devtoolsRootIds.get(root);
|
|
153
|
+
if (existing !== void 0) return existing;
|
|
154
|
+
const id = nextDevtoolsRootId++;
|
|
155
|
+
devtoolsRootIds.set(root, id);
|
|
156
|
+
return id;
|
|
157
|
+
}
|
|
158
|
+
function createDevtoolsCommitInspection(rootId, inspection) {
|
|
159
|
+
return {
|
|
160
|
+
inspectElement(target) {
|
|
161
|
+
if (typeof target !== "object" || target === null) return null;
|
|
162
|
+
const fiberId = inspection.hostFibers.get(target);
|
|
163
|
+
return fiberId === void 0 ? null : {
|
|
164
|
+
rootId,
|
|
165
|
+
fiberId
|
|
166
|
+
};
|
|
167
|
+
},
|
|
168
|
+
elementForFiber(fiberId) {
|
|
169
|
+
return inspection.fiberElements.get(fiberId) ?? null;
|
|
170
|
+
}
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
function recordDevtoolsHostFiber(node, id, inspection) {
|
|
174
|
+
if (node.tag !== 1 && node.tag !== 2) return;
|
|
175
|
+
if (typeof node.stateNode !== "object" || node.stateNode === null) return;
|
|
176
|
+
inspection.hostFibers.set(node.stateNode, id);
|
|
177
|
+
inspection.fiberElements.set(id, node.stateNode);
|
|
178
|
+
}
|
|
179
|
+
function devtoolsFiberId(node) {
|
|
180
|
+
const existing = devtoolsFiberIds.get(node) ?? (node.alternate === null ? void 0 : devtoolsFiberIds.get(node.alternate));
|
|
181
|
+
if (existing !== void 0) {
|
|
182
|
+
devtoolsFiberIds.set(node, existing);
|
|
183
|
+
if (node.alternate !== null) devtoolsFiberIds.set(node.alternate, existing);
|
|
184
|
+
return existing;
|
|
185
|
+
}
|
|
186
|
+
const id = nextDevtoolsFiberId++;
|
|
187
|
+
devtoolsFiberIds.set(node, id);
|
|
188
|
+
if (node.alternate !== null) devtoolsFiberIds.set(node.alternate, id);
|
|
189
|
+
return id;
|
|
190
|
+
}
|
|
191
|
+
function devtoolsProps(node) {
|
|
192
|
+
const props = {};
|
|
193
|
+
const source = node.memoizedProps ?? node.props;
|
|
194
|
+
for (const [key, value] of Object.entries(source)) if (key !== "children") props[key] = value;
|
|
195
|
+
return props;
|
|
196
|
+
}
|
|
197
|
+
function devtoolsHooks(firstHook) {
|
|
198
|
+
const hooks = [];
|
|
199
|
+
let id = 0;
|
|
200
|
+
for (let hook = firstHook; hook !== null; hook = hook.next) {
|
|
201
|
+
id += 1;
|
|
202
|
+
const kind = hookKindNames[hook.kind];
|
|
203
|
+
if (isEffectHook(hook.kind)) {
|
|
204
|
+
const effect = hook.memoizedState;
|
|
205
|
+
hooks.push({
|
|
206
|
+
id,
|
|
207
|
+
kind,
|
|
208
|
+
deps: effect.deps,
|
|
209
|
+
phase: devtoolsEffectPhase(effect.phase),
|
|
210
|
+
active: effect.controller !== null
|
|
211
|
+
});
|
|
212
|
+
} else if (hook.kind === 8) {
|
|
213
|
+
const memo = hook.memoizedState;
|
|
214
|
+
hooks.push({
|
|
215
|
+
id,
|
|
216
|
+
kind,
|
|
217
|
+
state: memo.value,
|
|
218
|
+
deps: memo.deps
|
|
219
|
+
});
|
|
220
|
+
} else if (hook.kind === 7) {
|
|
221
|
+
const store = hook.memoizedState;
|
|
222
|
+
hooks.push({
|
|
223
|
+
id,
|
|
224
|
+
kind,
|
|
225
|
+
state: store.value
|
|
226
|
+
});
|
|
227
|
+
} else hooks.push({
|
|
228
|
+
id,
|
|
229
|
+
kind,
|
|
230
|
+
state: hook.memoizedState
|
|
231
|
+
});
|
|
232
|
+
}
|
|
233
|
+
return hooks;
|
|
234
|
+
}
|
|
235
|
+
function devtoolsContextDependencies(node) {
|
|
236
|
+
return node.contextDependencies?.map((dependency) => devtoolsTypeName(dependency.context, "Context")) ?? [];
|
|
237
|
+
}
|
|
238
|
+
function devtoolsHost(node) {
|
|
239
|
+
if (node.tag === 2) {
|
|
240
|
+
const text = node.stateNode;
|
|
241
|
+
const value = typeof text?.nodeValue === "string" ? text.nodeValue : typeof node.memoizedProps?.nodeValue === "string" ? node.memoizedProps.nodeValue : void 0;
|
|
242
|
+
return {
|
|
243
|
+
kind: "text",
|
|
244
|
+
text: value === void 0 ? void 0 : devtoolsTruncate(value)
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
if (node.tag !== 1) return void 0;
|
|
248
|
+
const instance = node.stateNode;
|
|
249
|
+
return {
|
|
250
|
+
kind: "element",
|
|
251
|
+
tagName: typeof instance?.localName === "string" ? instance.localName : typeof instance?.tagName === "string" ? instance.tagName.toLowerCase() : String(node.type),
|
|
252
|
+
attributes: {}
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
function devtoolsFiberInfo(node) {
|
|
256
|
+
switch (node.tag) {
|
|
257
|
+
case 0: return {
|
|
258
|
+
kind: "root",
|
|
259
|
+
name: "Root"
|
|
260
|
+
};
|
|
261
|
+
case 1: return {
|
|
262
|
+
kind: "host",
|
|
263
|
+
name: String(node.type)
|
|
264
|
+
};
|
|
265
|
+
case 2: return {
|
|
266
|
+
kind: "text",
|
|
267
|
+
name: "#text"
|
|
268
|
+
};
|
|
269
|
+
case 3: return {
|
|
270
|
+
kind: "function",
|
|
271
|
+
name: devtoolsTypeName(node.type, "Anonymous")
|
|
272
|
+
};
|
|
273
|
+
case 4: return {
|
|
274
|
+
kind: "fragment",
|
|
275
|
+
name: "Fragment"
|
|
276
|
+
};
|
|
277
|
+
case 5: return {
|
|
278
|
+
kind: "context-provider",
|
|
279
|
+
name: `${devtoolsTypeName(node.type, "Context")}.Provider`
|
|
280
|
+
};
|
|
281
|
+
case 6: return {
|
|
282
|
+
kind: "suspense",
|
|
283
|
+
name: "Suspense"
|
|
284
|
+
};
|
|
285
|
+
case 7: return {
|
|
286
|
+
kind: "error-boundary",
|
|
287
|
+
name: "ErrorBoundary"
|
|
288
|
+
};
|
|
289
|
+
case 10: return {
|
|
290
|
+
kind: "activity",
|
|
291
|
+
name: "Activity"
|
|
292
|
+
};
|
|
293
|
+
case 11: return {
|
|
294
|
+
kind: "view-transition",
|
|
295
|
+
name: "ViewTransition"
|
|
296
|
+
};
|
|
297
|
+
case 8: return {
|
|
298
|
+
kind: "portal",
|
|
299
|
+
name: "Portal"
|
|
300
|
+
};
|
|
301
|
+
case 9: return {
|
|
302
|
+
kind: "assets",
|
|
303
|
+
name: "Assets"
|
|
304
|
+
};
|
|
305
|
+
case 12: return {
|
|
306
|
+
kind: "fragment",
|
|
307
|
+
name: "Promise"
|
|
308
|
+
};
|
|
309
|
+
}
|
|
310
|
+
}
|
|
311
|
+
function devtoolsEffectPhase(phase) {
|
|
312
|
+
if (phase === 1) return "before-paint";
|
|
313
|
+
if (phase === 2) return "before-layout";
|
|
314
|
+
return "reactive";
|
|
315
|
+
}
|
|
316
|
+
function devtoolsTruncate(value) {
|
|
317
|
+
return value.length > 120 ? `${value.slice(0, 117)}...` : value;
|
|
318
|
+
}
|
|
319
|
+
//#endregion
|
|
320
|
+
//#region src/hook-queue.ts
|
|
321
|
+
var HookUpdate = class {
|
|
322
|
+
action;
|
|
323
|
+
lane;
|
|
324
|
+
next = this;
|
|
325
|
+
constructor(action, lane) {
|
|
326
|
+
this.action = action;
|
|
327
|
+
this.lane = lane;
|
|
328
|
+
}
|
|
329
|
+
};
|
|
330
|
+
function mergeQueues(baseQueue, pendingQueue) {
|
|
331
|
+
if (baseQueue === null) return pendingQueue;
|
|
332
|
+
const baseFirst = baseQueue.next;
|
|
333
|
+
baseQueue.next = pendingQueue.next;
|
|
334
|
+
pendingQueue.next = baseFirst;
|
|
335
|
+
return pendingQueue;
|
|
336
|
+
}
|
|
337
|
+
function cloneUpdateNode(update) {
|
|
338
|
+
return new HookUpdate(update.action, update.lane);
|
|
339
|
+
}
|
|
340
|
+
function cloneQueue(queue) {
|
|
341
|
+
return queue === null ? null : cloneQueueNodes(queue);
|
|
342
|
+
}
|
|
343
|
+
function cloneQueueNodes(queue) {
|
|
344
|
+
const first = queue.next;
|
|
345
|
+
let clone = cloneUpdateNode(first);
|
|
346
|
+
let update = first.next;
|
|
347
|
+
while (update !== first) {
|
|
348
|
+
clone = mergeQueues(clone, cloneUpdateNode(update));
|
|
349
|
+
update = update.next;
|
|
350
|
+
}
|
|
351
|
+
return clone;
|
|
352
|
+
}
|
|
353
|
+
function clearQueueLanes(queue) {
|
|
354
|
+
let update = queue.next;
|
|
355
|
+
do {
|
|
356
|
+
update.lane = 0;
|
|
357
|
+
update = update.next;
|
|
358
|
+
} while (update !== queue.next);
|
|
359
|
+
}
|
|
360
|
+
//#endregion
|
|
361
|
+
//#region src/host-content.ts
|
|
362
|
+
const EmptyHostTextContent = Symbol("fig.empty-host-text-content");
|
|
363
|
+
const NonTextHostContent = Symbol("fig.non-text-host-content");
|
|
364
|
+
function hostTextContent(children) {
|
|
365
|
+
const text = hostTextContentPart(children);
|
|
366
|
+
return typeof text === "string" ? text : null;
|
|
367
|
+
}
|
|
368
|
+
function hostChildren(props) {
|
|
369
|
+
if (!hasUnsafeHTML(props)) return props.children;
|
|
370
|
+
if (hasRenderableChild(props.children)) throw new Error("Host elements cannot have both unsafeHTML and children.");
|
|
371
|
+
return null;
|
|
372
|
+
}
|
|
373
|
+
function hasUnsafeHTML(props) {
|
|
374
|
+
return !emptyValue(props.unsafeHTML);
|
|
375
|
+
}
|
|
376
|
+
function hasRenderableChild(node) {
|
|
377
|
+
if (Array.isArray(node)) return node.some(hasRenderableChild);
|
|
378
|
+
return !emptyChild(node);
|
|
379
|
+
}
|
|
380
|
+
function emptyValue(value) {
|
|
381
|
+
return value === null || value === void 0 || value === false;
|
|
382
|
+
}
|
|
383
|
+
function emptyChild(value) {
|
|
384
|
+
return value === null || value === void 0 || typeof value === "boolean";
|
|
385
|
+
}
|
|
386
|
+
function hostTextContentPart(node) {
|
|
387
|
+
if (Array.isArray(node)) {
|
|
388
|
+
let hasText = false;
|
|
389
|
+
let text = "";
|
|
390
|
+
for (const child of node) {
|
|
391
|
+
const childText = hostTextContentPart(child);
|
|
392
|
+
if (childText === NonTextHostContent) return NonTextHostContent;
|
|
393
|
+
if (childText === EmptyHostTextContent) continue;
|
|
394
|
+
hasText = true;
|
|
395
|
+
text += childText;
|
|
396
|
+
}
|
|
397
|
+
return hasText ? text : EmptyHostTextContent;
|
|
398
|
+
}
|
|
399
|
+
if (node === null || node === void 0 || typeof node === "boolean") return EmptyHostTextContent;
|
|
400
|
+
if (typeof node === "string" || typeof node === "number") return String(node);
|
|
401
|
+
if (isValidElement(node) || isPortal(node) || isThenable(node)) return NonTextHostContent;
|
|
402
|
+
throw invalidChildError(node);
|
|
403
|
+
}
|
|
404
|
+
//#endregion
|
|
405
|
+
//#region src/root-data-store.ts
|
|
406
|
+
const DataStoreFactorySymbol = Symbol.for("fig.data-store-factory");
|
|
407
|
+
function createRootDataStore(host) {
|
|
408
|
+
let inner = null;
|
|
409
|
+
let buffered = null;
|
|
410
|
+
let disposed = false;
|
|
411
|
+
function installStore(resource) {
|
|
412
|
+
if (inner !== null) return inner;
|
|
413
|
+
if (disposed) throw new Error("Data resource APIs require a live Fig root.");
|
|
414
|
+
const factory = resource[DataStoreFactorySymbol];
|
|
415
|
+
if (factory === void 0) throw new Error("Data resource APIs require @bgub/fig.");
|
|
416
|
+
inner = factory(host);
|
|
417
|
+
if (buffered !== null) inner.hydrate(buffered);
|
|
418
|
+
buffered = null;
|
|
419
|
+
return inner;
|
|
420
|
+
}
|
|
421
|
+
const store = {
|
|
422
|
+
hydrate(entries) {
|
|
423
|
+
if (inner !== null) {
|
|
424
|
+
inner.hydrate(entries);
|
|
425
|
+
return;
|
|
426
|
+
}
|
|
427
|
+
(buffered ??= []).push(...entries);
|
|
428
|
+
},
|
|
429
|
+
run(callback) {
|
|
430
|
+
if (inner !== null) return inner.run(callback);
|
|
431
|
+
const previousStore = setCurrentDataStore(store);
|
|
432
|
+
try {
|
|
433
|
+
return callback();
|
|
434
|
+
} finally {
|
|
435
|
+
setCurrentDataStore(previousStore);
|
|
436
|
+
}
|
|
437
|
+
},
|
|
438
|
+
readData(resource, args, owner) {
|
|
439
|
+
return installStore(resource).readData(resource, args, owner);
|
|
440
|
+
},
|
|
441
|
+
preloadData(resource, ...args) {
|
|
442
|
+
installStore(resource).preloadData(resource, ...args);
|
|
443
|
+
},
|
|
444
|
+
ensureData(resource, ...args) {
|
|
445
|
+
return installStore(resource).ensureData(resource, ...args);
|
|
446
|
+
},
|
|
447
|
+
invalidateData(resource, ...args) {
|
|
448
|
+
installStore(resource).invalidateData(resource, ...args);
|
|
449
|
+
},
|
|
450
|
+
invalidateDataError(error) {
|
|
451
|
+
return inner?.invalidateDataError(error) ?? false;
|
|
452
|
+
},
|
|
453
|
+
invalidateDataKey(key) {
|
|
454
|
+
inner?.invalidateDataKey(key);
|
|
455
|
+
},
|
|
456
|
+
invalidateDataPrefix(prefix) {
|
|
457
|
+
inner?.invalidateDataPrefix(prefix);
|
|
458
|
+
},
|
|
459
|
+
refreshData(resource, ...args) {
|
|
460
|
+
return installStore(resource).refreshData(resource, ...args);
|
|
461
|
+
},
|
|
462
|
+
commitDataDependencies(owner, previousOwner) {
|
|
463
|
+
inner?.commitDataDependencies(owner, previousOwner);
|
|
464
|
+
},
|
|
465
|
+
deleteDataOwner(owner) {
|
|
466
|
+
inner?.deleteDataOwner(owner);
|
|
467
|
+
},
|
|
468
|
+
releaseDataOwner(owner) {
|
|
469
|
+
inner?.releaseDataOwner(owner);
|
|
470
|
+
},
|
|
471
|
+
resetDataDependencies(owner) {
|
|
472
|
+
inner?.resetDataDependencies(owner);
|
|
473
|
+
},
|
|
474
|
+
dispose() {
|
|
475
|
+
disposed = true;
|
|
476
|
+
inner?.dispose();
|
|
477
|
+
inner = null;
|
|
478
|
+
buffered = null;
|
|
479
|
+
},
|
|
480
|
+
inspectDataEntries() {
|
|
481
|
+
return inner?.inspectDataEntries() ?? [];
|
|
482
|
+
},
|
|
483
|
+
inspectDataDependencyCanonicalKeys(owner) {
|
|
484
|
+
return inner?.inspectDataDependencyCanonicalKeys(owner) ?? [];
|
|
485
|
+
},
|
|
486
|
+
snapshot() {
|
|
487
|
+
return inner?.snapshot() ?? buffered?.slice() ?? [];
|
|
488
|
+
}
|
|
489
|
+
};
|
|
490
|
+
return store;
|
|
491
|
+
}
|
|
492
|
+
//#endregion
|
|
493
|
+
//#region src/index.ts
|
|
494
|
+
function runWithEventPriority(priority, callback) {
|
|
495
|
+
return runWithPriority(eventPriorityLane(priority), callback);
|
|
496
|
+
}
|
|
497
|
+
function eventPriorityLane(priority) {
|
|
498
|
+
switch (priority) {
|
|
499
|
+
case "discrete": return 2;
|
|
500
|
+
case "continuous": return 8;
|
|
501
|
+
case "default": return 32;
|
|
502
|
+
}
|
|
503
|
+
}
|
|
504
|
+
function hydrationLaneForPriority(priority) {
|
|
505
|
+
return priority === "discrete" ? 2 : SelectiveHydrationLane;
|
|
506
|
+
}
|
|
507
|
+
setTransitionHandler(runWithTransition);
|
|
508
|
+
const NoActionStateError = Symbol();
|
|
509
|
+
const PreservedSuspense = Symbol("fig.preserved-suspense");
|
|
510
|
+
const NoHydrationInitialElement = Symbol("fig.no-hydration-initial-element");
|
|
511
|
+
var HydrationMismatchError = class extends Error {};
|
|
512
|
+
function createRenderer(host) {
|
|
513
|
+
const noSuspenseRetries = [];
|
|
514
|
+
const roots = /* @__PURE__ */ new WeakMap();
|
|
515
|
+
const mountedRoots = /* @__PURE__ */ new Set();
|
|
516
|
+
const pendingRoots = /* @__PURE__ */ new Set();
|
|
517
|
+
const batchedRoots = /* @__PURE__ */ new Set();
|
|
518
|
+
const abandonedHydrationBoundaries = /* @__PURE__ */ new WeakSet();
|
|
519
|
+
let commitCoordinator = null;
|
|
520
|
+
let didWarnMissingViewTransitionCoordinator = false;
|
|
521
|
+
let batchDepth = 0;
|
|
522
|
+
let flushingSyncWork = false;
|
|
523
|
+
let commitDepth = 0;
|
|
524
|
+
let needsPostCommitSyncFlush = false;
|
|
525
|
+
let flushingPostCommitSyncWork = false;
|
|
526
|
+
let nestedPostCommitSyncFlushes = 0;
|
|
527
|
+
const nestedPostCommitSyncFlushLimit = 50;
|
|
528
|
+
let currentCommitEffectPhase = null;
|
|
529
|
+
let hasHiddenBoundaries = false;
|
|
530
|
+
const hiddenStates = /* @__PURE__ */ new Set();
|
|
531
|
+
let activityHostConfig = null;
|
|
532
|
+
let activityHydrationHostConfig = null;
|
|
533
|
+
let hoistedAssetHostConfig = null;
|
|
534
|
+
let renderingFiber = null;
|
|
535
|
+
let currentHook = null;
|
|
536
|
+
let workInProgressHook = null;
|
|
537
|
+
let localIdCounter = 0;
|
|
538
|
+
function installCommitCoordinator(coordinator) {
|
|
539
|
+
if (commitCoordinator === coordinator) return;
|
|
540
|
+
if (commitCoordinator !== null) throw new Error(`Cannot install commit coordinator "${coordinator.name}": commit coordination is already owned by "${commitCoordinator.name}".`);
|
|
541
|
+
commitCoordinator = coordinator;
|
|
542
|
+
}
|
|
543
|
+
function commitPriority(lanes) {
|
|
544
|
+
const lane = getHighestPriorityLane(lanes);
|
|
545
|
+
if (includesSomeLane(130023424, lane)) return "suspense";
|
|
546
|
+
if (includesSomeLane(1077935872, lane)) return "transition";
|
|
547
|
+
if (includesSomeLane(805306368, lane)) return "idle";
|
|
548
|
+
return "blocking";
|
|
549
|
+
}
|
|
550
|
+
const dispatcher = {
|
|
551
|
+
useState: updateStateHook,
|
|
552
|
+
useActionState: updateActionStateHook,
|
|
553
|
+
useId: updateIdHook,
|
|
554
|
+
useDeferredValue: updateDeferredValueHook,
|
|
555
|
+
useMemo: updateMemoHook,
|
|
556
|
+
useTransition: updateTransitionHook,
|
|
557
|
+
useReactive(effect, deps) {
|
|
558
|
+
updateEffectHook(0, effect, deps);
|
|
559
|
+
},
|
|
560
|
+
useBeforePaint(effect, deps) {
|
|
561
|
+
updateEffectHook(1, effect, deps);
|
|
562
|
+
},
|
|
563
|
+
useBeforeLayout(effect, deps) {
|
|
564
|
+
updateEffectHook(2, effect, deps);
|
|
565
|
+
},
|
|
566
|
+
useSyncExternalStore: updateExternalStoreHook,
|
|
567
|
+
useStableEvent: updateStableEventHook,
|
|
568
|
+
readContext: readContextValue,
|
|
569
|
+
readData(resource, args) {
|
|
570
|
+
const fiber = requireRenderingFiber();
|
|
571
|
+
return rootOf(fiber).dataStore.readData(resource, args, fiber);
|
|
572
|
+
},
|
|
573
|
+
preloadData(resource, args) {
|
|
574
|
+
rootOf(requireRenderingFiber()).dataStore.preloadData(resource, ...args);
|
|
575
|
+
},
|
|
576
|
+
readPromise(promise) {
|
|
577
|
+
return readThenable(promise);
|
|
578
|
+
}
|
|
579
|
+
};
|
|
580
|
+
function createRoot(container, options = {}) {
|
|
581
|
+
return rootHandle(rootForContainer(container, {
|
|
582
|
+
kind: "client",
|
|
583
|
+
options
|
|
584
|
+
}));
|
|
585
|
+
}
|
|
586
|
+
function hydrateRoot(container, children, options = {}) {
|
|
587
|
+
const root = rootForContainer(container, {
|
|
588
|
+
kind: "hydration",
|
|
589
|
+
options
|
|
590
|
+
});
|
|
591
|
+
root.hydrationInitialElement = children;
|
|
592
|
+
updateRoot(root, children);
|
|
593
|
+
return rootHandle(root);
|
|
594
|
+
}
|
|
595
|
+
function rootForContainer(container, request) {
|
|
596
|
+
if (roots.has(container)) throw duplicateRootError(request.kind);
|
|
597
|
+
if (request.kind === "hydration") requireHydrationHostConfig();
|
|
598
|
+
const root = createFiberRoot(container, request.options);
|
|
599
|
+
roots.set(container, root);
|
|
600
|
+
if (hasRefreshHandler()) mountedRoots.add(root);
|
|
601
|
+
if (request.kind === "hydration") {
|
|
602
|
+
root.isHydrating = true;
|
|
603
|
+
root.isHydrationRoot = true;
|
|
604
|
+
root.needsRootHydrationCompletion = true;
|
|
605
|
+
}
|
|
606
|
+
return root;
|
|
607
|
+
}
|
|
608
|
+
function createFiberRoot(container, options) {
|
|
609
|
+
const current = fiber(0, null, null, { children: null }, null);
|
|
610
|
+
const dataStoreHost = {
|
|
611
|
+
getLane: requestUpdateLane,
|
|
612
|
+
partition: options.dataPartition,
|
|
613
|
+
schedule(owner, lane) {
|
|
614
|
+
scheduleFiber(owner, hiddenSubtreeLane(owner, lane));
|
|
615
|
+
}
|
|
616
|
+
};
|
|
617
|
+
const dataStore = options.dataStore === void 0 ? createRootDataStore(dataStoreHost) : attachDataStore(options.dataStore, dataStoreHost, options.initialData);
|
|
618
|
+
const root = {
|
|
619
|
+
container,
|
|
620
|
+
current,
|
|
621
|
+
element: null,
|
|
622
|
+
identifierPrefix: options.identifierPrefix ?? "",
|
|
623
|
+
nextClientId: 0,
|
|
624
|
+
devtools: options.devtools ?? true,
|
|
625
|
+
pendingLanes: 0,
|
|
626
|
+
suspendedLanes: 0,
|
|
627
|
+
pingedLanes: 0,
|
|
628
|
+
expiredLanes: 0,
|
|
629
|
+
entangledLanes: 0,
|
|
630
|
+
entanglements: createLaneMap(0),
|
|
631
|
+
expirationTimes: createLaneMap(-1),
|
|
632
|
+
callback: null,
|
|
633
|
+
callbackPriority: 0,
|
|
634
|
+
wip: null,
|
|
635
|
+
finishedWork: null,
|
|
636
|
+
renderLanes: 0,
|
|
637
|
+
pendingCoordinatedCommit: false,
|
|
638
|
+
parkedCoordinatedCommit: false,
|
|
639
|
+
dataStore,
|
|
640
|
+
contextValues: /* @__PURE__ */ new Map(),
|
|
641
|
+
contextStack: [],
|
|
642
|
+
externalStores: /* @__PURE__ */ new Set(),
|
|
643
|
+
pendingReactiveEffects: [],
|
|
644
|
+
reactiveCallback: null,
|
|
645
|
+
suspendedThenables: /* @__PURE__ */ new WeakMap(),
|
|
646
|
+
pendingSuspenseRetries: [],
|
|
647
|
+
attachedSuspenseRetries: /* @__PURE__ */ new WeakMap(),
|
|
648
|
+
consumedPendingQueues: [],
|
|
649
|
+
onRecoverableError: options.onRecoverableError ?? noop,
|
|
650
|
+
onUncaughtError: options.onUncaughtError ?? null,
|
|
651
|
+
recoverableErrors: [],
|
|
652
|
+
uncaughtErrorInfo: null,
|
|
653
|
+
commitEffectPhases: 0,
|
|
654
|
+
needsCommitDeletions: false,
|
|
655
|
+
commitIndex: [],
|
|
656
|
+
committedCaughtErrors: [],
|
|
657
|
+
isHydrating: false,
|
|
658
|
+
isHydrationRoot: false,
|
|
659
|
+
hydrationParent: null,
|
|
660
|
+
hydratingSuspenseBoundary: null,
|
|
661
|
+
hydratingActivityBoundary: null,
|
|
662
|
+
dehydratedSuspenseCount: 0,
|
|
663
|
+
dehydratedBoundaries: /* @__PURE__ */ new Map(),
|
|
664
|
+
needsRootHydrationCompletion: false,
|
|
665
|
+
nextHydratableInstance: null,
|
|
666
|
+
clearContainerBeforeCommit: false,
|
|
667
|
+
hydrationInitialElement: NoHydrationInitialElement
|
|
668
|
+
};
|
|
669
|
+
if (options.dataStore === void 0 && options.initialData !== void 0) dataStore.hydrate(options.initialData);
|
|
670
|
+
current.stateNode = root;
|
|
671
|
+
return root;
|
|
672
|
+
}
|
|
673
|
+
function duplicateRootError(kind) {
|
|
674
|
+
return /* @__PURE__ */ new Error(`Cannot call ${kind === "hydration" ? "hydrateRoot" : "createRoot"} on a container that already has a Fig root. Use the existing root.render(...) to update it instead.`);
|
|
675
|
+
}
|
|
676
|
+
function noop() {}
|
|
677
|
+
function rootHandle(root) {
|
|
678
|
+
let unmounted = false;
|
|
679
|
+
return {
|
|
680
|
+
data: root.dataStore,
|
|
681
|
+
render: (children) => {
|
|
682
|
+
if (unmounted) throw new Error("Cannot update an unmounted root.");
|
|
683
|
+
updateRoot(root, children);
|
|
684
|
+
},
|
|
685
|
+
unmount: () => {
|
|
686
|
+
if (unmounted) return;
|
|
687
|
+
unmounted = true;
|
|
688
|
+
flushSync(() => updateRoot(root, null));
|
|
689
|
+
root.dataStore.dispose();
|
|
690
|
+
if (roots.get(root.container) === root) roots.delete(root.container);
|
|
691
|
+
mountedRoots.delete(root);
|
|
692
|
+
}
|
|
693
|
+
};
|
|
694
|
+
}
|
|
695
|
+
function hydrateTarget(container, target, priority = "default") {
|
|
696
|
+
const lane = hydrationLaneForPriority(priority);
|
|
697
|
+
const root = roots.get(container);
|
|
698
|
+
if (root === void 0) return "none";
|
|
699
|
+
if (rootShellPendingHydration(root)) {
|
|
700
|
+
if (isSyncLane(lane)) performRoot(root, true);
|
|
701
|
+
if (rootShellPendingHydration(root)) return "blocked";
|
|
702
|
+
}
|
|
703
|
+
if (root.dehydratedSuspenseCount === 0) return "none";
|
|
704
|
+
const boundary = dehydratedBoundaryForTarget(root, target);
|
|
705
|
+
if (boundary === null) return "none";
|
|
706
|
+
scheduleFiber(boundary, lane);
|
|
707
|
+
if (isSyncLane(lane)) performRoot(root, true);
|
|
708
|
+
return dehydratedBoundaryForTarget(root, target) === null ? "hydrated" : "blocked";
|
|
709
|
+
}
|
|
710
|
+
function rootShellPendingHydration(root) {
|
|
711
|
+
return root.needsRootHydrationCompletion && root.current.child === null;
|
|
712
|
+
}
|
|
713
|
+
function dehydratedBoundaryForTarget(root, target) {
|
|
714
|
+
if (host.getEnclosingSuspenseBoundaryStart === void 0) return findDehydratedSuspenseBoundaryForTarget(root.current.child, target);
|
|
715
|
+
let start = host.getEnclosingSuspenseBoundaryStart(target);
|
|
716
|
+
while (start !== null) {
|
|
717
|
+
const fiber = root.dehydratedBoundaries.get(start) ?? null;
|
|
718
|
+
if (fiberSuspenseState(fiber)?.kind === "dehydrated") return fiber;
|
|
719
|
+
start = host.getEnclosingSuspenseBoundaryStart(start);
|
|
720
|
+
}
|
|
721
|
+
return null;
|
|
722
|
+
}
|
|
723
|
+
function flushSync(callback) {
|
|
724
|
+
if (renderingFiber !== null) throw new Error("flushSync cannot be called while rendering a component.");
|
|
725
|
+
try {
|
|
726
|
+
return runWithPriority(2, callback);
|
|
727
|
+
} finally {
|
|
728
|
+
flushSyncWork();
|
|
729
|
+
}
|
|
730
|
+
}
|
|
731
|
+
function flushSyncWork() {
|
|
732
|
+
if (commitDepth > 0) {
|
|
733
|
+
needsPostCommitSyncFlush = true;
|
|
734
|
+
return;
|
|
735
|
+
}
|
|
736
|
+
const previousFlushingSyncWork = flushingSyncWork;
|
|
737
|
+
flushingSyncWork = true;
|
|
738
|
+
try {
|
|
739
|
+
for (const root of pendingRoots) if (root.pendingLanes !== 0) {
|
|
740
|
+
root.callback?.cancel();
|
|
741
|
+
root.callback = null;
|
|
742
|
+
root.callbackPriority = 0;
|
|
743
|
+
performRoot(root, true);
|
|
744
|
+
} else pendingRoots.delete(root);
|
|
745
|
+
} finally {
|
|
746
|
+
flushingSyncWork = previousFlushingSyncWork;
|
|
747
|
+
}
|
|
748
|
+
}
|
|
749
|
+
function flushPostCommitSyncWork() {
|
|
750
|
+
if (commitDepth > 0 || !needsPostCommitSyncFlush || flushingPostCommitSyncWork) return;
|
|
751
|
+
flushingPostCommitSyncWork = true;
|
|
752
|
+
try {
|
|
753
|
+
do {
|
|
754
|
+
nestedPostCommitSyncFlushes += 1;
|
|
755
|
+
if (nestedPostCommitSyncFlushes > nestedPostCommitSyncFlushLimit) throw new Error("Maximum update depth exceeded.");
|
|
756
|
+
needsPostCommitSyncFlush = false;
|
|
757
|
+
flushSyncWork();
|
|
758
|
+
} while (needsPostCommitSyncFlush);
|
|
759
|
+
} finally {
|
|
760
|
+
nestedPostCommitSyncFlushes = 0;
|
|
761
|
+
flushingPostCommitSyncWork = false;
|
|
762
|
+
}
|
|
763
|
+
}
|
|
764
|
+
function batchedUpdates(callback) {
|
|
765
|
+
batchDepth += 1;
|
|
766
|
+
try {
|
|
767
|
+
return callback();
|
|
768
|
+
} finally {
|
|
769
|
+
batchDepth -= 1;
|
|
770
|
+
if (batchDepth === 0) {
|
|
771
|
+
for (const root of batchedRoots) scheduleRoot(root);
|
|
772
|
+
batchedRoots.clear();
|
|
773
|
+
}
|
|
774
|
+
}
|
|
775
|
+
}
|
|
776
|
+
function updateRoot(root, children) {
|
|
777
|
+
if (shouldClientRenderEarlyHydrationUpdate(root, children)) forceClientRender(root);
|
|
778
|
+
const lane = requestUpdateLane();
|
|
779
|
+
root.element = children;
|
|
780
|
+
markRootPending(root, lane);
|
|
781
|
+
scheduleOrBatchRoot(root);
|
|
782
|
+
}
|
|
783
|
+
function markRootPending(root, lane) {
|
|
784
|
+
markRootUpdated(root, lane);
|
|
785
|
+
transitionTypeHooks.record?.(root, lane);
|
|
786
|
+
pendingRoots.add(root);
|
|
787
|
+
if (currentCommitEffectPhase === 1 && isSyncLane(lane)) needsPostCommitSyncFlush = true;
|
|
788
|
+
}
|
|
789
|
+
function markRootCompleted(root, remainingLanes) {
|
|
790
|
+
markRootFinished(root, remainingLanes);
|
|
791
|
+
transitionTypeHooks.complete?.(root, remainingLanes);
|
|
792
|
+
}
|
|
793
|
+
function markCommitEffectPhase(root, phase) {
|
|
794
|
+
root.commitEffectPhases |= 1 << phase;
|
|
795
|
+
}
|
|
796
|
+
function scheduleOrBatchRoot(root) {
|
|
797
|
+
if (batchDepth > 0) batchedRoots.add(root);
|
|
798
|
+
else scheduleRoot(root);
|
|
799
|
+
}
|
|
800
|
+
function scheduleRoot(root) {
|
|
801
|
+
if (root.pendingCoordinatedCommit) return;
|
|
802
|
+
markStarvedLanesAsExpired(root, now());
|
|
803
|
+
const nextLanes = getNextLanes(root, root.renderLanes);
|
|
804
|
+
if (nextLanes === 0) {
|
|
805
|
+
if (root.pendingLanes === 0) pendingRoots.delete(root);
|
|
806
|
+
return;
|
|
807
|
+
}
|
|
808
|
+
const priorityLane = getHighestPriorityLane(nextLanes);
|
|
809
|
+
if (root.callback !== null && root.callbackPriority === priorityLane) return;
|
|
810
|
+
root.callback?.cancel();
|
|
811
|
+
root.callbackPriority = priorityLane;
|
|
812
|
+
root.callback = scheduleCallback(getLaneSchedulerPriority(priorityLane), () => {
|
|
813
|
+
performRoot(root, isSyncLane(priorityLane));
|
|
814
|
+
});
|
|
815
|
+
}
|
|
816
|
+
function performRoot(root, forceSync) {
|
|
817
|
+
try {
|
|
818
|
+
performRootWork(root, forceSync);
|
|
819
|
+
} catch (error) {
|
|
820
|
+
if (error === PreservedSuspense) {
|
|
821
|
+
restartRootWork(root);
|
|
822
|
+
scheduleRoot(root);
|
|
823
|
+
return;
|
|
824
|
+
}
|
|
825
|
+
if (error instanceof HydrationMismatchError) {
|
|
826
|
+
recoverFromHydrationMismatch(root);
|
|
827
|
+
return;
|
|
828
|
+
}
|
|
829
|
+
if (isThenable(error)) {
|
|
830
|
+
const suspendedLanes = root.renderLanes;
|
|
831
|
+
restartRootWork(root);
|
|
832
|
+
markRootSuspended(root, suspendedLanes);
|
|
833
|
+
attachPing(root, error, suspendedLanes);
|
|
834
|
+
scheduleRoot(root);
|
|
835
|
+
return;
|
|
836
|
+
}
|
|
837
|
+
const info = root.uncaughtErrorInfo ?? errorInfoFor(root.current, error);
|
|
838
|
+
restartRootWork(root);
|
|
839
|
+
clearRootAfterUncaughtError(root);
|
|
840
|
+
reportUncaughtError(root, error, info);
|
|
841
|
+
if (flushingSyncWork) throw error;
|
|
842
|
+
if (root.onUncaughtError === null) setTimeout(() => {
|
|
843
|
+
throw error;
|
|
844
|
+
});
|
|
845
|
+
}
|
|
846
|
+
}
|
|
847
|
+
function recoverFromHydrationMismatch(root) {
|
|
848
|
+
if (root.hydratingSuspenseBoundary !== null) {
|
|
849
|
+
recoverFromSuspenseHydrationMismatch(root, root.hydratingSuspenseBoundary);
|
|
850
|
+
return;
|
|
851
|
+
}
|
|
852
|
+
markHydrationRecovery(root, "root");
|
|
853
|
+
restartRootWork(root);
|
|
854
|
+
forceClientRender(root);
|
|
855
|
+
performRoot(root, true);
|
|
856
|
+
}
|
|
857
|
+
function recoverFromSuspenseHydrationMismatch(root, boundary) {
|
|
858
|
+
const current = boundary.alternate ?? boundary;
|
|
859
|
+
const state = fiberSuspenseState(current);
|
|
860
|
+
restartRootWork(root);
|
|
861
|
+
if (state?.kind !== "dehydrated") {
|
|
862
|
+
markHydrationRecovery(root, "root");
|
|
863
|
+
forceClientRender(root);
|
|
864
|
+
performRoot(root, true);
|
|
865
|
+
return;
|
|
866
|
+
}
|
|
867
|
+
if (host.shouldRecoverSuspenseMismatchAtRoot?.(root.container, state.boundary) === true) {
|
|
868
|
+
markHydrationRecovery(root, "root");
|
|
869
|
+
state.boundary.forceClientRender = true;
|
|
870
|
+
forceClientRender(root);
|
|
871
|
+
performRoot(root, true);
|
|
872
|
+
return;
|
|
873
|
+
}
|
|
874
|
+
markHydrationRecovery(root, "suspense");
|
|
875
|
+
state.boundary.forceClientRender = true;
|
|
876
|
+
deactivateHydration(root);
|
|
877
|
+
scheduleFiber(current, SelectiveHydrationLane);
|
|
878
|
+
performRoot(root, true);
|
|
879
|
+
}
|
|
880
|
+
function markHydrationRecovery(root, recovery) {
|
|
881
|
+
for (const record of root.recoverableErrors) if (record.info.source === "hydration") record.info.recovery = recovery;
|
|
882
|
+
}
|
|
883
|
+
function shouldClientRenderEarlyHydrationUpdate(root, children) {
|
|
884
|
+
return root.isHydrating && root.current.child === null && root.hydrationInitialElement !== NoHydrationInitialElement && root.hydrationInitialElement !== children;
|
|
885
|
+
}
|
|
886
|
+
function forceClientRender(root) {
|
|
887
|
+
deactivateHydration(root);
|
|
888
|
+
root.clearContainerBeforeCommit = true;
|
|
889
|
+
root.hydrationInitialElement = NoHydrationInitialElement;
|
|
890
|
+
}
|
|
891
|
+
function performRootWork(root, forceSync) {
|
|
892
|
+
if (root.pendingCoordinatedCommit) return;
|
|
893
|
+
if (root.pendingLanes === 0 && root.wip === null) {
|
|
894
|
+
pendingRoots.delete(root);
|
|
895
|
+
return;
|
|
896
|
+
}
|
|
897
|
+
flushPendingReactiveEffects(root);
|
|
898
|
+
if (root.parkedCoordinatedCommit) {
|
|
899
|
+
root.parkedCoordinatedCommit = false;
|
|
900
|
+
if (!((root.pendingLanes & ~root.renderLanes) !== 0) && root.wip === null && root.finishedWork !== null) {
|
|
901
|
+
if (commitRoot(root, root.finishedWork)) return;
|
|
902
|
+
finishRootWork(root);
|
|
903
|
+
flushPostCommitSyncWork();
|
|
904
|
+
return;
|
|
905
|
+
}
|
|
906
|
+
restartRootWork(root);
|
|
907
|
+
}
|
|
908
|
+
const nextLanes = getNextLanes(root, root.renderLanes);
|
|
909
|
+
if (nextLanes === 0 && root.wip === null) {
|
|
910
|
+
root.callback = null;
|
|
911
|
+
root.callbackPriority = 0;
|
|
912
|
+
return;
|
|
913
|
+
}
|
|
914
|
+
if (root.wip !== null && nextLanes !== 0 && nextLanes !== root.renderLanes) restartRootWork(root);
|
|
915
|
+
if (root.wip === null) {
|
|
916
|
+
root.renderLanes = nextLanes;
|
|
917
|
+
root.consumedPendingQueues = [];
|
|
918
|
+
resetContextStack(root);
|
|
919
|
+
root.finishedWork = createWorkInProgress(root.current, { children: root.element });
|
|
920
|
+
root.wip = root.finishedWork;
|
|
921
|
+
prepareToHydrateRoot(root);
|
|
922
|
+
}
|
|
923
|
+
while (root.wip !== null && (forceSync || isSyncLane(getHighestPriorityLane(root.renderLanes)) || !shouldYieldToHost())) root.wip = performUnit(root.wip);
|
|
924
|
+
if (root.wip !== null) {
|
|
925
|
+
root.callback = null;
|
|
926
|
+
root.callbackPriority = 0;
|
|
927
|
+
scheduleRoot(root);
|
|
928
|
+
return;
|
|
929
|
+
}
|
|
930
|
+
if (root.finishedWork !== null && commitRoot(root, root.finishedWork)) return;
|
|
931
|
+
finishRootWork(root);
|
|
932
|
+
flushPostCommitSyncWork();
|
|
933
|
+
}
|
|
934
|
+
function finishRootWork(root) {
|
|
935
|
+
resetRootWork(root);
|
|
936
|
+
if (root.pendingLanes !== 0) scheduleRoot(root);
|
|
937
|
+
else pendingRoots.delete(root);
|
|
938
|
+
}
|
|
939
|
+
function restartRootWork(root) {
|
|
940
|
+
restoreConsumedPendingQueues(root);
|
|
941
|
+
resetRootWork(root);
|
|
942
|
+
}
|
|
943
|
+
function resetRootWork(root) {
|
|
944
|
+
const wasHydratingCompletedBoundary = root.hydrationInitialElement === NoHydrationInitialElement && (root.hydratingSuspenseBoundary !== null || root.hydratingActivityBoundary !== null);
|
|
945
|
+
root.wip = null;
|
|
946
|
+
root.finishedWork = null;
|
|
947
|
+
root.renderLanes = 0;
|
|
948
|
+
root.callback = null;
|
|
949
|
+
root.callbackPriority = 0;
|
|
950
|
+
if (root.pendingSuspenseRetries.length > 0) root.pendingSuspenseRetries = [];
|
|
951
|
+
clearCommitIndex(root.commitIndex);
|
|
952
|
+
resetHydrationPointers(root);
|
|
953
|
+
resetContextStack(root);
|
|
954
|
+
if (wasHydratingCompletedBoundary) root.isHydrating = false;
|
|
955
|
+
root.uncaughtErrorInfo = null;
|
|
956
|
+
}
|
|
957
|
+
function resetHydrationPointers(root) {
|
|
958
|
+
root.hydrationParent = null;
|
|
959
|
+
root.hydratingSuspenseBoundary = null;
|
|
960
|
+
root.hydratingActivityBoundary = null;
|
|
961
|
+
root.nextHydratableInstance = null;
|
|
962
|
+
}
|
|
963
|
+
function deactivateHydration(root) {
|
|
964
|
+
root.isHydrating = false;
|
|
965
|
+
resetHydrationPointers(root);
|
|
966
|
+
}
|
|
967
|
+
function performUnit(node) {
|
|
968
|
+
try {
|
|
969
|
+
begin(node);
|
|
970
|
+
} catch (error) {
|
|
971
|
+
return handleThrownValue(node, error);
|
|
972
|
+
}
|
|
973
|
+
if ((node.flags & 16) === 0 && node.child !== null) return node.child;
|
|
974
|
+
return completeUnit(node);
|
|
975
|
+
}
|
|
976
|
+
function handleThrownValue(node, error) {
|
|
977
|
+
const root = rootOf(node);
|
|
978
|
+
if (root.hydratingActivityBoundary !== null) abandonActivityHydration(root, error instanceof HydrationMismatchError);
|
|
979
|
+
if (isThenable(error)) {
|
|
980
|
+
const boundary = findSuspenseBoundary(node);
|
|
981
|
+
if (boundary !== null) {
|
|
982
|
+
unwindContextTo(root, boundary);
|
|
983
|
+
return captureSuspenseBoundary(boundary, error);
|
|
984
|
+
}
|
|
985
|
+
unwindContextTo(root, null);
|
|
986
|
+
throw error;
|
|
987
|
+
}
|
|
988
|
+
if (error instanceof HydrationMismatchError) {
|
|
989
|
+
unwindContextTo(root, null);
|
|
990
|
+
throw error;
|
|
991
|
+
}
|
|
992
|
+
const boundary = findErrorBoundary(node);
|
|
993
|
+
if (boundary !== null) {
|
|
994
|
+
unwindContextTo(root, boundary);
|
|
995
|
+
return captureErrorBoundary(boundary, error, node);
|
|
996
|
+
}
|
|
997
|
+
unwindContextTo(root, null);
|
|
998
|
+
rootOf(node).uncaughtErrorInfo = errorInfoFor(node, error);
|
|
999
|
+
throw error;
|
|
1000
|
+
}
|
|
1001
|
+
function completeUnit(node) {
|
|
1002
|
+
let next = node;
|
|
1003
|
+
while (next !== null) {
|
|
1004
|
+
complete(next);
|
|
1005
|
+
if (next.sibling !== null) return next.sibling;
|
|
1006
|
+
next = next.return;
|
|
1007
|
+
}
|
|
1008
|
+
return null;
|
|
1009
|
+
}
|
|
1010
|
+
function begin(node) {
|
|
1011
|
+
const root = rootOf(node);
|
|
1012
|
+
if (node.tag === 6 || node.tag === 7) node.commitIndexCheckpoint = root.commitIndex.length;
|
|
1013
|
+
if (canBailout(node, root)) {
|
|
1014
|
+
let hasChildWork = includesSomeLane(node.childLanes, root.renderLanes);
|
|
1015
|
+
if (!hasChildWork) hasChildWork = lazilyPropagateParentContextChanges(node, root);
|
|
1016
|
+
if (!hasChildWork) {
|
|
1017
|
+
node.flags |= 16;
|
|
1018
|
+
node.child = node.alternate?.child ?? null;
|
|
1019
|
+
return;
|
|
1020
|
+
}
|
|
1021
|
+
if (node.tag !== 6) {
|
|
1022
|
+
if (node.tag === 5) pushContextProvider(node, root);
|
|
1023
|
+
cloneChildFibers(node);
|
|
1024
|
+
return;
|
|
1025
|
+
}
|
|
1026
|
+
}
|
|
1027
|
+
if (node.tag === 5) pushContextProvider(node, root);
|
|
1028
|
+
const hasOwnWork = includesSomeLane(node.lanes, root.renderLanes);
|
|
1029
|
+
node.lanes &= ~root.renderLanes;
|
|
1030
|
+
if (node.tag === 3) {
|
|
1031
|
+
renderFunction(node, root);
|
|
1032
|
+
return;
|
|
1033
|
+
}
|
|
1034
|
+
if (node.tag === 12) {
|
|
1035
|
+
reconcileCurrentChildren(node, readThenable(node.props.thenable), root);
|
|
1036
|
+
return;
|
|
1037
|
+
}
|
|
1038
|
+
if (node.tag === 2) {
|
|
1039
|
+
if (node.alternate === null || node.alternate.props.nodeValue !== node.props.nodeValue) host.validateTextNesting?.(String(node.props.nodeValue), hostAncestorTypes(node));
|
|
1040
|
+
if (tryHydrateText(node, root)) return;
|
|
1041
|
+
node.stateNode ??= host.createTextInstance(String(node.props.nodeValue));
|
|
1042
|
+
return;
|
|
1043
|
+
}
|
|
1044
|
+
if (node.tag === 1) {
|
|
1045
|
+
const type = String(node.type);
|
|
1046
|
+
const children = hostChildren(node.props);
|
|
1047
|
+
const hoisted = resolveHoistedFiber(node, root);
|
|
1048
|
+
{
|
|
1049
|
+
let ancestors = null;
|
|
1050
|
+
if (!hoisted && node.alternate === null && host.validateInstanceNesting) {
|
|
1051
|
+
ancestors = hostAncestorTypes(node);
|
|
1052
|
+
host.validateInstanceNesting(type, node.props, ancestors);
|
|
1053
|
+
}
|
|
1054
|
+
if (host.validateTextNesting && shouldUseHostTextContent(node, root)) {
|
|
1055
|
+
const textContent = hostTextContent(children);
|
|
1056
|
+
if (textContent !== null) {
|
|
1057
|
+
ancestors ??= hostAncestorTypes(node);
|
|
1058
|
+
ancestors.unshift(type);
|
|
1059
|
+
host.validateTextNesting(textContent, ancestors);
|
|
1060
|
+
}
|
|
1061
|
+
}
|
|
1062
|
+
}
|
|
1063
|
+
if (!hoisted && tryHydrateInstance(node, root)) {
|
|
1064
|
+
reconcileCurrentChildren(node, children, root);
|
|
1065
|
+
return;
|
|
1066
|
+
}
|
|
1067
|
+
if (!hoisted) node.stateNode ??= host.createInstance(type, node.props, hostParent(node));
|
|
1068
|
+
reconcileCurrentChildren(node, children === null || shouldUseHostTextContent(node, root) ? null : children, root);
|
|
1069
|
+
return;
|
|
1070
|
+
}
|
|
1071
|
+
if (node.tag === 6) {
|
|
1072
|
+
beginSuspense(node, hasOwnWork);
|
|
1073
|
+
return;
|
|
1074
|
+
}
|
|
1075
|
+
if (node.tag === 7) {
|
|
1076
|
+
beginErrorBoundary(node);
|
|
1077
|
+
return;
|
|
1078
|
+
}
|
|
1079
|
+
if (node.tag === 10 && node.type === null) {
|
|
1080
|
+
beginHiddenBoundary(root, node);
|
|
1081
|
+
return;
|
|
1082
|
+
}
|
|
1083
|
+
if (node.tag === 10) {
|
|
1084
|
+
beginActivity(root, node);
|
|
1085
|
+
return;
|
|
1086
|
+
}
|
|
1087
|
+
if (node.tag === 11) {
|
|
1088
|
+
beginViewTransition(node);
|
|
1089
|
+
return;
|
|
1090
|
+
}
|
|
1091
|
+
if (node.tag === 8) {
|
|
1092
|
+
beginPortal(node);
|
|
1093
|
+
return;
|
|
1094
|
+
}
|
|
1095
|
+
reconcileCurrentChildren(node, node.props.children, root);
|
|
1096
|
+
}
|
|
1097
|
+
function beginViewTransition(node) {
|
|
1098
|
+
{
|
|
1099
|
+
const name = node.props.name;
|
|
1100
|
+
if (name === "none" || name === "") throw new Error(`<ViewTransition> received the reserved name "${name}". "none" disables the browser feature and "" is not a valid view-transition-name; use "auto" or omit the prop for a generated name.`);
|
|
1101
|
+
if (commitCoordinator?.viewTransitions !== true && !didWarnMissingViewTransitionCoordinator) {
|
|
1102
|
+
didWarnMissingViewTransitionCoordinator = true;
|
|
1103
|
+
const coordinatorDescription = commitCoordinator === null ? "this renderer has no commit coordinator with View Transition support" : `the installed commit coordinator "${commitCoordinator.name}" does not provide View Transition support`;
|
|
1104
|
+
console.error(`A <ViewTransition> rendered, but ${coordinatorDescription}. Install View Transition support for this renderer. Fig DOM applications can call enableViewTransitions() from "@bgub/fig-dom/view-transitions".`);
|
|
1105
|
+
}
|
|
1106
|
+
}
|
|
1107
|
+
node.stateNode ??= { autoName: null };
|
|
1108
|
+
reconcileCurrentChildren(node, node.props.children);
|
|
1109
|
+
}
|
|
1110
|
+
function beginActivity(root, node) {
|
|
1111
|
+
const hidden = activityHidden(node.props);
|
|
1112
|
+
if (hidden) hasHiddenBoundaries = true;
|
|
1113
|
+
const state = ensureFiberActivityState(node);
|
|
1114
|
+
if (state.dehydrated === null && tryDehydrateActivityBoundary(root, node, state)) {
|
|
1115
|
+
if (!hidden) scheduleFiber(node, 32);
|
|
1116
|
+
return;
|
|
1117
|
+
}
|
|
1118
|
+
if (state.dehydrated !== null) {
|
|
1119
|
+
if (hidden) return;
|
|
1120
|
+
hydrateDehydratedActivityBoundary(root, node);
|
|
1121
|
+
return;
|
|
1122
|
+
}
|
|
1123
|
+
beginHiddenBoundary(root, node);
|
|
1124
|
+
}
|
|
1125
|
+
function beginHiddenBoundary(root, node) {
|
|
1126
|
+
const hidden = activityHidden(node.props);
|
|
1127
|
+
if (hidden) hasHiddenBoundaries = true;
|
|
1128
|
+
const hiddenState = node.hiddenState;
|
|
1129
|
+
const previousHidden = node.alternate === null ? false : activityHidden(node.alternate.memoizedProps ?? {});
|
|
1130
|
+
ensureFiberActivityState(node);
|
|
1131
|
+
if (hidden !== previousHidden) node.flags |= 32;
|
|
1132
|
+
if (!hidden && hiddenState?.currentFirstChild != null) node.flags |= 32;
|
|
1133
|
+
if (!hidden && previousHidden) {
|
|
1134
|
+
markSubtreeLanes(node.alternate?.child ?? null, root.renderLanes);
|
|
1135
|
+
if (includesSomeLane(node.childLanes, 536870912) && !includesSomeLane(root.renderLanes, 536870912)) root.renderLanes = mergeLanes(root.renderLanes, OffscreenLane);
|
|
1136
|
+
}
|
|
1137
|
+
reconcile(node, node.props.children, hiddenState?.currentFirstChild ?? node.alternate?.child ?? null, hiddenState?.currentFirstChild != null && node.alternate === null);
|
|
1138
|
+
node.hiddenState = null;
|
|
1139
|
+
}
|
|
1140
|
+
function prepareToHydrateRoot(root) {
|
|
1141
|
+
if (!root.isHydrating) return;
|
|
1142
|
+
const hydrationHost = requireHydrationHostConfig();
|
|
1143
|
+
root.hydrationParent = root.finishedWork;
|
|
1144
|
+
root.nextHydratableInstance = hydrationHost.getFirstHydratableChild(root.container);
|
|
1145
|
+
}
|
|
1146
|
+
function tryHydrateInstance(node, root) {
|
|
1147
|
+
if (!shouldHydrateFiber(root, node)) return false;
|
|
1148
|
+
const hydrationHost = requireHydrationHostConfig();
|
|
1149
|
+
const hydratable = root.nextHydratableInstance;
|
|
1150
|
+
const type = String(node.type);
|
|
1151
|
+
if (hydratable === null || !hydrationHost.canHydrateInstance(hydratable, type, node.props)) throwHydrationMismatch(root, node, `<${type}>`);
|
|
1152
|
+
node.stateNode = hydratable;
|
|
1153
|
+
recordCommitWork(root.commitIndex, node, 6);
|
|
1154
|
+
root.hydrationParent = node;
|
|
1155
|
+
root.nextHydratableInstance = hydrationHost.getFirstHydratableChild(hydratable, node.props);
|
|
1156
|
+
return true;
|
|
1157
|
+
}
|
|
1158
|
+
function tryHydrateText(node, root) {
|
|
1159
|
+
if (!shouldHydrateFiber(root, node)) return false;
|
|
1160
|
+
const hydrationHost = requireHydrationHostConfig();
|
|
1161
|
+
const hydratable = root.nextHydratableInstance;
|
|
1162
|
+
const text = String(node.props.nodeValue);
|
|
1163
|
+
const suppressHydrationWarning = node.return?.tag === 1 && node.return.props.suppressHydrationWarning === true || canHydratePendingSuspenseTextMismatch(root);
|
|
1164
|
+
if (hydratable === null || !hydrationHost.canHydrateTextInstance(hydratable, text, suppressHydrationWarning)) throwHydrationMismatch(root, node, "text");
|
|
1165
|
+
node.stateNode = hydratable;
|
|
1166
|
+
recordCommitWork(root.commitIndex, node, 2);
|
|
1167
|
+
root.nextHydratableInstance = hydrationHost.getNextHydratableSibling(hydratable);
|
|
1168
|
+
return true;
|
|
1169
|
+
}
|
|
1170
|
+
function shouldHydrateFiber(root, node) {
|
|
1171
|
+
return root.isHydrating && node.alternate === null && node.stateNode === null && !insideHydrationExemptHost(node);
|
|
1172
|
+
}
|
|
1173
|
+
function insideHydrationExemptHost(node) {
|
|
1174
|
+
for (let parent = node.return; parent !== null && parent.alternate === null; parent = parent.return) {
|
|
1175
|
+
if (parent.tag !== 1) continue;
|
|
1176
|
+
return hydrationBypassedHost(parent);
|
|
1177
|
+
}
|
|
1178
|
+
return false;
|
|
1179
|
+
}
|
|
1180
|
+
function completeHydration(node) {
|
|
1181
|
+
const root = rootOf(node);
|
|
1182
|
+
if (node.tag === 6 && (node.flags & 4) !== 0 && root.hydratingSuspenseBoundary === node) {
|
|
1183
|
+
completeDehydratedSuspenseHydration(root, node);
|
|
1184
|
+
return;
|
|
1185
|
+
}
|
|
1186
|
+
if (node.tag === 10 && (node.flags & 4) !== 0 && root.hydratingActivityBoundary === node) {
|
|
1187
|
+
if (root.nextHydratableInstance !== null) throwHydrationMismatch(root, node, void 0, " in Activity");
|
|
1188
|
+
leaveActivityHydration(root, node);
|
|
1189
|
+
return;
|
|
1190
|
+
}
|
|
1191
|
+
if (!root.isHydrating || root.hydrationParent !== node) return;
|
|
1192
|
+
if (root.nextHydratableInstance !== null && !(node.tag === 1 && host.canRetainHydrationTail?.(node.stateNode) === true)) throwHydrationMismatch(root, node);
|
|
1193
|
+
const hydrationHost = requireHydrationHostConfig();
|
|
1194
|
+
root.hydrationParent = nextHydrationParent(node.return);
|
|
1195
|
+
root.nextHydratableInstance = node.tag === 1 ? hydrationHost.getNextHydratableSibling(node.stateNode) : null;
|
|
1196
|
+
}
|
|
1197
|
+
function completeDehydratedSuspenseHydration(root, node) {
|
|
1198
|
+
const boundary = dehydratedSuspenseBoundary(node.alternate);
|
|
1199
|
+
if (boundary === null) return;
|
|
1200
|
+
if (boundary.status === "completed" && !boundary.forceClientRender && root.nextHydratableInstance !== boundary.end) throwHydrationMismatch(root, node, void 0, " in Suspense", boundary.id ?? void 0);
|
|
1201
|
+
leaveSuspenseHydration(root, node, boundary);
|
|
1202
|
+
}
|
|
1203
|
+
function nextHydrationParent(node) {
|
|
1204
|
+
for (let parent = node; parent !== null; parent = parent.return) if (parent.tag === 0 || parent.tag === 1 || parent.tag === 6 && (parent.flags & 4) !== 0 && dehydratedSuspenseBoundary(parent.alternate) !== null || parent.tag === 10 && (parent.flags & 4) !== 0 && fiberActivityState(parent)?.dehydrated != null) return parent;
|
|
1205
|
+
return null;
|
|
1206
|
+
}
|
|
1207
|
+
function firstWithinSuspenseBoundary(boundary) {
|
|
1208
|
+
const first = requireHydrationHostConfig().getNextHydratableSibling(boundary.start);
|
|
1209
|
+
return first === boundary.end ? null : first;
|
|
1210
|
+
}
|
|
1211
|
+
function nextAfterSuspenseBoundary(boundary) {
|
|
1212
|
+
return requireHydrationHostConfig().getNextHydratableSibling(boundary.end);
|
|
1213
|
+
}
|
|
1214
|
+
function requireHydrationHostConfig() {
|
|
1215
|
+
if (host.getFirstHydratableChild === void 0 || host.getNextHydratableSibling === void 0 || host.canHydrateInstance === void 0 || host.canHydrateTextInstance === void 0 || host.clearContainer === void 0) throw new Error("Hydration is not supported by this renderer.");
|
|
1216
|
+
return host;
|
|
1217
|
+
}
|
|
1218
|
+
function throwHydrationMismatch(root, node, expected, where = "", boundaryId) {
|
|
1219
|
+
const nothing = root.nextHydratableInstance === null;
|
|
1220
|
+
const message = expected === void 0 ? `found an extra DOM node${where}` : nothing ? `expected ${expected}, but found no DOM node` : `expected ${expected}`;
|
|
1221
|
+
const error = /* @__PURE__ */ new Error(`Hydration mismatch: ${message}.`);
|
|
1222
|
+
queueRecoverableError(root, node, error, {
|
|
1223
|
+
actual: expected === void 0 ? "extra DOM node" : nothing ? "nothing" : "different DOM node",
|
|
1224
|
+
boundaryId,
|
|
1225
|
+
expected,
|
|
1226
|
+
recovery: "root",
|
|
1227
|
+
source: "hydration"
|
|
1228
|
+
});
|
|
1229
|
+
throw new HydrationMismatchError(error.message);
|
|
1230
|
+
}
|
|
1231
|
+
function canBailout(node, root) {
|
|
1232
|
+
return node.alternate !== null && (node.flags & 1) === 0 && node.props === node.alternate.memoizedProps && !includesSomeLane(node.lanes, root.renderLanes) && !contextDependenciesChanged(node, root);
|
|
1233
|
+
}
|
|
1234
|
+
function contextDependenciesChanged(node, root) {
|
|
1235
|
+
const dependencies = node.contextDependencies;
|
|
1236
|
+
if (dependencies === null) return false;
|
|
1237
|
+
for (const dependency of dependencies) if (!Object.is(currentContextValue(root, dependency.context), dependency.memoizedValue)) return true;
|
|
1238
|
+
return false;
|
|
1239
|
+
}
|
|
1240
|
+
function currentContextValue(root, context) {
|
|
1241
|
+
return root.contextValues.has(context) ? root.contextValues.get(context) : context.defaultValue;
|
|
1242
|
+
}
|
|
1243
|
+
function shouldUseHostTextContent(node, root = rootOf(node)) {
|
|
1244
|
+
return host.setTextContent !== void 0 && (!root.isHydrating || hydrationBypassedHost(node)) && !adoptedSingleTextChild(node) && hostTextContent(node.props.children) !== null;
|
|
1245
|
+
}
|
|
1246
|
+
function adoptedSingleTextChild(node) {
|
|
1247
|
+
const child = node.alternate?.child ?? node.child;
|
|
1248
|
+
return child !== null && child.tag === 2 && child.sibling === null;
|
|
1249
|
+
}
|
|
1250
|
+
function hydrationBypassedHost(node) {
|
|
1251
|
+
return node.alternate === null && node.stateNode !== null && (node.flags & 4) === 0;
|
|
1252
|
+
}
|
|
1253
|
+
function resolveHoistedFiber(node, root) {
|
|
1254
|
+
if (isHoistedFiber(node)) return true;
|
|
1255
|
+
if (node.tag !== 1 || node.stateNode !== null || host.resolveHoistedInstance === void 0) return false;
|
|
1256
|
+
const hydrating = shouldHydrateFiber(root, node);
|
|
1257
|
+
const instance = host.resolveHoistedInstance(String(node.type), node.props, hostParent(node));
|
|
1258
|
+
if (instance === null) return false;
|
|
1259
|
+
requireHoistedAssetHostConfig();
|
|
1260
|
+
node.stateNode = instance;
|
|
1261
|
+
node.flags |= HoistedStaticFlag;
|
|
1262
|
+
if (hydrating) node.flags |= 1;
|
|
1263
|
+
return true;
|
|
1264
|
+
}
|
|
1265
|
+
function isHoistedFiber(node) {
|
|
1266
|
+
return node.tag === 1 && (node.flags & 8192) !== 0;
|
|
1267
|
+
}
|
|
1268
|
+
function requireHoistedAssetHostConfig() {
|
|
1269
|
+
if (hoistedAssetHostConfig !== null) return hoistedAssetHostConfig;
|
|
1270
|
+
if (host.resolveHoistedInstance === void 0 || host.commitHoistedInstance === void 0 || host.removeHoistedInstance === void 0 || host.updateHoistedInstance === void 0) throw new Error("Hoisted assets are not supported by this renderer.");
|
|
1271
|
+
hoistedAssetHostConfig = host;
|
|
1272
|
+
return hoistedAssetHostConfig;
|
|
1273
|
+
}
|
|
1274
|
+
function renderFunction(node, root) {
|
|
1275
|
+
if (hasRefreshHandler()) node.type = resolveLatestType(node.type);
|
|
1276
|
+
prepareHookRender(node, root);
|
|
1277
|
+
const previousDispatcher = setCurrentDispatcher(dispatcher);
|
|
1278
|
+
const previousDataStore = setCurrentDataStore(root.dataStore);
|
|
1279
|
+
try {
|
|
1280
|
+
{
|
|
1281
|
+
const consumedBefore = root.consumedPendingQueues.length;
|
|
1282
|
+
const nextClientIdBefore = root.nextClientId;
|
|
1283
|
+
observeDiscardedPromiseChildren(node.type(node.props));
|
|
1284
|
+
if (currentHook !== null) throw hookOrderError("fewer");
|
|
1285
|
+
restoreConsumedPendingQueues(root, consumedBefore);
|
|
1286
|
+
root.nextClientId = nextClientIdBefore;
|
|
1287
|
+
prepareHookRender(node, root);
|
|
1288
|
+
node.effects = null;
|
|
1289
|
+
}
|
|
1290
|
+
reconcileCurrentChildren(node, node.type(node.props), root);
|
|
1291
|
+
if (currentHook !== null) throw hookOrderError("fewer");
|
|
1292
|
+
} finally {
|
|
1293
|
+
setCurrentDataStore(previousDataStore);
|
|
1294
|
+
setCurrentDispatcher(previousDispatcher);
|
|
1295
|
+
renderingFiber = null;
|
|
1296
|
+
currentHook = null;
|
|
1297
|
+
workInProgressHook = null;
|
|
1298
|
+
localIdCounter = 0;
|
|
1299
|
+
}
|
|
1300
|
+
}
|
|
1301
|
+
function prepareHookRender(node, root) {
|
|
1302
|
+
renderingFiber = node;
|
|
1303
|
+
currentHook = node.alternate?.memoizedState ?? null;
|
|
1304
|
+
workInProgressHook = null;
|
|
1305
|
+
localIdCounter = 0;
|
|
1306
|
+
node.memoizedState = null;
|
|
1307
|
+
node.contextDependencies = null;
|
|
1308
|
+
root.dataStore.resetDataDependencies(node);
|
|
1309
|
+
node.dataDependenciesDirty = true;
|
|
1310
|
+
recordCommitWork(root.commitIndex, node);
|
|
1311
|
+
}
|
|
1312
|
+
function beginSuspense(node, hasOwnWork) {
|
|
1313
|
+
const root = rootOf(node);
|
|
1314
|
+
const previousSuspenseState = fiberSuspenseState(node.alternate);
|
|
1315
|
+
node.boundaryState = null;
|
|
1316
|
+
if (previousSuspenseState?.kind === "dehydrated") {
|
|
1317
|
+
if (!hasOwnWork) {
|
|
1318
|
+
node.boundaryState = previousSuspenseState;
|
|
1319
|
+
return;
|
|
1320
|
+
}
|
|
1321
|
+
hydrateDehydratedSuspenseBoundary(node, previousSuspenseState);
|
|
1322
|
+
return;
|
|
1323
|
+
}
|
|
1324
|
+
if (tryDehydrateSuspenseBoundary(node)) return;
|
|
1325
|
+
node.suspenseQueueStart = root.consumedPendingQueues.length;
|
|
1326
|
+
if (previousSuspenseState === null) {
|
|
1327
|
+
beginSuspensePrimary(node, suspensePrimaryFiber(node.alternate));
|
|
1328
|
+
return;
|
|
1329
|
+
}
|
|
1330
|
+
const currentPrimary = suspensePrimaryFiber(node.alternate);
|
|
1331
|
+
if (currentPrimary !== null) markSubtreeLanes(currentPrimary.child, root.renderLanes);
|
|
1332
|
+
beginSuspensePrimary(node, currentPrimary, previousSuspenseState.primaryChild);
|
|
1333
|
+
appendDeletions(node, suspenseFallbackFiber(node.alternate));
|
|
1334
|
+
}
|
|
1335
|
+
function markSubtreeLanes(node, lanes) {
|
|
1336
|
+
for (let child = node; child !== null; child = child.sibling) {
|
|
1337
|
+
child.lanes = mergeLanes(child.lanes, lanes);
|
|
1338
|
+
child.childLanes = mergeLanes(child.childLanes, lanes);
|
|
1339
|
+
markSubtreeLanes(child.child, lanes);
|
|
1340
|
+
}
|
|
1341
|
+
}
|
|
1342
|
+
function beginSuspensePrimary(boundary, currentPrimary, capturedPrimary = null) {
|
|
1343
|
+
if (capturedPrimary !== null) hasHiddenBoundaries = true;
|
|
1344
|
+
boundary.child = suspensePrimaryWorkInProgress(boundary, currentPrimary, "visible", capturedPrimary);
|
|
1345
|
+
}
|
|
1346
|
+
function suspensePrimaryWorkInProgress(boundary, currentPrimary, mode, capturedPrimary = null) {
|
|
1347
|
+
const props = {
|
|
1348
|
+
mode,
|
|
1349
|
+
children: boundary.props.children
|
|
1350
|
+
};
|
|
1351
|
+
const primary = currentPrimary === null ? fiber(10, null, null, props, null) : createWorkInProgress(currentPrimary, props);
|
|
1352
|
+
primary.hiddenState = { currentFirstChild: capturedPrimary };
|
|
1353
|
+
primary.index = 0;
|
|
1354
|
+
primary.return = boundary;
|
|
1355
|
+
primary.sibling = null;
|
|
1356
|
+
return primary;
|
|
1357
|
+
}
|
|
1358
|
+
function suspenseFallbackWorkInProgress(boundary, currentFallback, index) {
|
|
1359
|
+
const props = { children: boundary.props.fallback };
|
|
1360
|
+
const fallback = currentFallback?.tag === 4 ? createWorkInProgress(currentFallback, props) : fiber(4, null, null, props, null);
|
|
1361
|
+
fallback.index = index;
|
|
1362
|
+
fallback.return = boundary;
|
|
1363
|
+
fallback.sibling = null;
|
|
1364
|
+
if (currentFallback === null) fallback.flags |= 1;
|
|
1365
|
+
return fallback;
|
|
1366
|
+
}
|
|
1367
|
+
function suspensePrimaryFiber(node) {
|
|
1368
|
+
const child = node?.child ?? null;
|
|
1369
|
+
return child?.tag === 10 && child.type === null ? child : null;
|
|
1370
|
+
}
|
|
1371
|
+
function suspenseFallbackFiber(node) {
|
|
1372
|
+
const primary = suspensePrimaryFiber(node);
|
|
1373
|
+
return primary === null ? node?.child ?? null : primary.sibling;
|
|
1374
|
+
}
|
|
1375
|
+
function cloneSuspendedPrimary(node, parent) {
|
|
1376
|
+
let first = null;
|
|
1377
|
+
let previous = null;
|
|
1378
|
+
for (let current = node; current !== null; current = current.sibling) {
|
|
1379
|
+
const clone = createWorkInProgress(current, current.props);
|
|
1380
|
+
clone.return = parent;
|
|
1381
|
+
clone.child = cloneSuspendedPrimary(current.child, clone);
|
|
1382
|
+
clone.sibling = null;
|
|
1383
|
+
clone.lanes = 0;
|
|
1384
|
+
clone.childLanes = 0;
|
|
1385
|
+
if (previous === null) first = clone;
|
|
1386
|
+
else previous.sibling = clone;
|
|
1387
|
+
previous = clone;
|
|
1388
|
+
}
|
|
1389
|
+
return first;
|
|
1390
|
+
}
|
|
1391
|
+
function tryDehydrateSuspenseBoundary(node) {
|
|
1392
|
+
const root = rootOf(node);
|
|
1393
|
+
if (!shouldHydrateFiber(root, node)) return false;
|
|
1394
|
+
if (host.getSuspenseBoundary === void 0) return false;
|
|
1395
|
+
const hydratable = root.nextHydratableInstance;
|
|
1396
|
+
if (hydratable === null) return false;
|
|
1397
|
+
const boundary = host.getSuspenseBoundary(hydratable);
|
|
1398
|
+
if (boundary === null) return false;
|
|
1399
|
+
node.boundaryState = {
|
|
1400
|
+
boundary,
|
|
1401
|
+
idPath: hydrationIdPath(root, node),
|
|
1402
|
+
kind: "dehydrated",
|
|
1403
|
+
wasPending: boundary.status === "pending"
|
|
1404
|
+
};
|
|
1405
|
+
host.registerSuspenseBoundaryRetry?.(boundary, () => scheduleFiber(node, 32));
|
|
1406
|
+
root.nextHydratableInstance = nextAfterSuspenseBoundary(boundary);
|
|
1407
|
+
return true;
|
|
1408
|
+
}
|
|
1409
|
+
function hydrateDehydratedSuspenseBoundary(node, state) {
|
|
1410
|
+
const boundary = state.boundary;
|
|
1411
|
+
abandonedHydrationBoundaries.delete(node);
|
|
1412
|
+
if (node.alternate !== null) abandonedHydrationBoundaries.delete(node.alternate);
|
|
1413
|
+
if (!boundary.forceClientRender) {
|
|
1414
|
+
if (boundary.status === "completed") {
|
|
1415
|
+
enterSuspenseHydration(node, boundary);
|
|
1416
|
+
node.boundaryState = null;
|
|
1417
|
+
node.flags |= 4;
|
|
1418
|
+
beginSuspensePrimary(node, suspensePrimaryFiber(node.alternate));
|
|
1419
|
+
return;
|
|
1420
|
+
}
|
|
1421
|
+
if (boundary.status === "pending") {
|
|
1422
|
+
node.boundaryState = state;
|
|
1423
|
+
return;
|
|
1424
|
+
}
|
|
1425
|
+
}
|
|
1426
|
+
if (boundary.status === "client-rendered") queueClientRenderedSuspenseError(rootOf(node), node, boundary);
|
|
1427
|
+
node.boundaryState = null;
|
|
1428
|
+
node.flags |= 4;
|
|
1429
|
+
beginSuspensePrimary(node, suspensePrimaryFiber(node.alternate));
|
|
1430
|
+
}
|
|
1431
|
+
function queueClientRenderedSuspenseError(root, node, boundary) {
|
|
1432
|
+
const boundaryError = boundary.error;
|
|
1433
|
+
const error = new Error(boundaryError?.message ?? "The server could not finish this Suspense boundary. Switched to client rendering.");
|
|
1434
|
+
if (boundaryError?.digest !== void 0) error.digest = boundaryError.digest;
|
|
1435
|
+
queueRecoverableError(root, node, error, {
|
|
1436
|
+
boundaryId: boundary.id ?? void 0,
|
|
1437
|
+
digest: boundaryError?.digest,
|
|
1438
|
+
recovery: "suspense",
|
|
1439
|
+
source: "server"
|
|
1440
|
+
});
|
|
1441
|
+
}
|
|
1442
|
+
function canHydratePendingSuspenseTextMismatch(root) {
|
|
1443
|
+
const boundary = root.hydratingSuspenseBoundary;
|
|
1444
|
+
const state = fiberSuspenseState(boundary?.alternate);
|
|
1445
|
+
return state?.kind === "dehydrated" && state.wasPending;
|
|
1446
|
+
}
|
|
1447
|
+
function requireActivityHydrationHostConfig() {
|
|
1448
|
+
if (activityHydrationHostConfig !== null) return activityHydrationHostConfig;
|
|
1449
|
+
if (host.getActivityBoundary === void 0 || host.getFirstActivityHydratable === void 0 || host.commitHydratedActivityBoundary === void 0) throw new Error("Activity hydration requires getActivityBoundary, getFirstActivityHydratable, and commitHydratedActivityBoundary.");
|
|
1450
|
+
activityHydrationHostConfig = host;
|
|
1451
|
+
return activityHydrationHostConfig;
|
|
1452
|
+
}
|
|
1453
|
+
function tryDehydrateActivityBoundary(root, node, state) {
|
|
1454
|
+
if (!shouldHydrateFiber(root, node)) return false;
|
|
1455
|
+
if (host.getActivityBoundary === void 0) return false;
|
|
1456
|
+
const hydratable = root.nextHydratableInstance;
|
|
1457
|
+
if (hydratable === null) return false;
|
|
1458
|
+
const boundary = host.getActivityBoundary(hydratable);
|
|
1459
|
+
if (boundary === null) return false;
|
|
1460
|
+
requireActivityHydrationHostConfig();
|
|
1461
|
+
hasHiddenBoundaries = true;
|
|
1462
|
+
state.dehydrated = {
|
|
1463
|
+
boundary,
|
|
1464
|
+
idPath: hydrationIdPath(root, node)
|
|
1465
|
+
};
|
|
1466
|
+
root.nextHydratableInstance = requireHydrationHostConfig().getNextHydratableSibling(boundary);
|
|
1467
|
+
return true;
|
|
1468
|
+
}
|
|
1469
|
+
function hydrateDehydratedActivityBoundary(root, node) {
|
|
1470
|
+
enterActivityHydration(root, node);
|
|
1471
|
+
node.flags |= 36;
|
|
1472
|
+
reconcile(node, node.props.children, null, false);
|
|
1473
|
+
}
|
|
1474
|
+
function enterActivityHydration(root, node) {
|
|
1475
|
+
const boundary = dehydratedActivityBoundary(node);
|
|
1476
|
+
if (boundary === null) throw new Error("Expected a dehydrated Activity boundary.");
|
|
1477
|
+
root.isHydrating = true;
|
|
1478
|
+
root.hydrationParent = node;
|
|
1479
|
+
root.hydratingActivityBoundary = node;
|
|
1480
|
+
root.nextHydratableInstance = requireActivityHydrationHostConfig().getFirstActivityHydratable(boundary);
|
|
1481
|
+
}
|
|
1482
|
+
function leaveActivityHydration(root, node) {
|
|
1483
|
+
root.hydrationParent = nextHydrationParent(node.return);
|
|
1484
|
+
root.nextHydratableInstance = null;
|
|
1485
|
+
root.hydratingActivityBoundary = null;
|
|
1486
|
+
root.isHydrating = false;
|
|
1487
|
+
}
|
|
1488
|
+
function abandonActivityHydration(root, forceClientRender = false) {
|
|
1489
|
+
if (forceClientRender) {
|
|
1490
|
+
const state = fiberActivityState(root.hydratingActivityBoundary);
|
|
1491
|
+
if (state !== null) state.dehydrated = null;
|
|
1492
|
+
}
|
|
1493
|
+
deactivateHydration(root);
|
|
1494
|
+
}
|
|
1495
|
+
function enterSuspenseHydration(node, boundary) {
|
|
1496
|
+
const root = rootOf(node);
|
|
1497
|
+
root.isHydrating = true;
|
|
1498
|
+
root.hydrationParent = node;
|
|
1499
|
+
root.hydratingSuspenseBoundary = node;
|
|
1500
|
+
root.nextHydratableInstance = firstWithinSuspenseBoundary(boundary);
|
|
1501
|
+
}
|
|
1502
|
+
function leaveSuspenseHydration(root, node, boundary) {
|
|
1503
|
+
root.hydrationParent = nextHydrationParent(node.return);
|
|
1504
|
+
root.nextHydratableInstance = nextAfterSuspenseBoundary(boundary);
|
|
1505
|
+
root.hydratingSuspenseBoundary = null;
|
|
1506
|
+
root.isHydrating = false;
|
|
1507
|
+
}
|
|
1508
|
+
function beginErrorBoundary(node) {
|
|
1509
|
+
const previousErrorState = fiberErrorBoundaryState(node.alternate);
|
|
1510
|
+
node.boundaryState = previousErrorState;
|
|
1511
|
+
reconcileCurrentChildren(node, previousErrorState === null ? node.props.children : errorBoundaryFallback(node, previousErrorState));
|
|
1512
|
+
}
|
|
1513
|
+
function errorBoundaryFallback(node, state) {
|
|
1514
|
+
const fallback = node.props.fallback;
|
|
1515
|
+
return typeof fallback === "function" && !isThenable(fallback) ? fallback(state.error, state.info) : fallback;
|
|
1516
|
+
}
|
|
1517
|
+
function beginPortal(node) {
|
|
1518
|
+
reconcileCurrentChildren(node, node.props.children);
|
|
1519
|
+
}
|
|
1520
|
+
function updateStateHook(initialState) {
|
|
1521
|
+
const hook = updateQueuedHook(3, initialState);
|
|
1522
|
+
const queue = hook.queue;
|
|
1523
|
+
const fiber = requireRenderingFiber();
|
|
1524
|
+
queue.dispatch ??= (action) => {
|
|
1525
|
+
if (renderingFiber !== null) throw new Error("State updates are not allowed while rendering a component.");
|
|
1526
|
+
scheduleHookUpdate(fiber, queue, action, requestUpdateLane());
|
|
1527
|
+
};
|
|
1528
|
+
return [hook.memoizedState, queue.dispatch];
|
|
1529
|
+
}
|
|
1530
|
+
function updateActionStateHook(action, initialState) {
|
|
1531
|
+
const hook = updateQueuedHook(4, () => createActionState(action, initialState));
|
|
1532
|
+
const queue = hook.queue;
|
|
1533
|
+
const fiber = requireRenderingFiber();
|
|
1534
|
+
const instance = hook.memoizedState.instance;
|
|
1535
|
+
const nextState = {
|
|
1536
|
+
...hook.memoizedState,
|
|
1537
|
+
action
|
|
1538
|
+
};
|
|
1539
|
+
hook.memoizedState = nextState;
|
|
1540
|
+
if (hook.baseQueue === null) hook.baseState = nextState;
|
|
1541
|
+
else hook.baseState = {
|
|
1542
|
+
...hook.baseState,
|
|
1543
|
+
action
|
|
1544
|
+
};
|
|
1545
|
+
if (instance.runner === null) {
|
|
1546
|
+
const updatePending = (delta, lane) => {
|
|
1547
|
+
scheduleHookUpdate(fiber, queue, (state) => ({
|
|
1548
|
+
...state,
|
|
1549
|
+
pending: Math.max(0, state.pending + delta)
|
|
1550
|
+
}), lane);
|
|
1551
|
+
};
|
|
1552
|
+
const finish = (lane, error, ...value) => {
|
|
1553
|
+
scheduleHookUpdate(fiber, queue, (state) => ({
|
|
1554
|
+
...state,
|
|
1555
|
+
error,
|
|
1556
|
+
pending: Math.max(0, state.pending - 1),
|
|
1557
|
+
value: value.length === 0 ? state.value : value[0]
|
|
1558
|
+
}), lane);
|
|
1559
|
+
};
|
|
1560
|
+
instance.runner = (...args) => {
|
|
1561
|
+
if (renderingFiber !== null) throw new Error("Action state updates are not allowed during render.");
|
|
1562
|
+
runLatest(instance, fiber, (signal) => instance.action(instance.value, ...args, signal), updatePending, (lane, value, failed) => {
|
|
1563
|
+
if (failed) finish(lane, value);
|
|
1564
|
+
else finish(lane, NoActionStateError, value);
|
|
1565
|
+
});
|
|
1566
|
+
};
|
|
1567
|
+
}
|
|
1568
|
+
if (hook.memoizedState.error !== NoActionStateError) throw hook.memoizedState.error;
|
|
1569
|
+
return [
|
|
1570
|
+
hook.memoizedState.value,
|
|
1571
|
+
instance.runner,
|
|
1572
|
+
hook.memoizedState.pending > 0
|
|
1573
|
+
];
|
|
1574
|
+
}
|
|
1575
|
+
function updateIdHook() {
|
|
1576
|
+
const fiber = requireRenderingFiber();
|
|
1577
|
+
const oldHook = updateHook(5);
|
|
1578
|
+
const id = oldHook === null ? createFiberId(rootOf(fiber), fiber, localIdCounter) : oldHook.memoizedState;
|
|
1579
|
+
localIdCounter += 1;
|
|
1580
|
+
appendHook(createHook(5, id));
|
|
1581
|
+
return id;
|
|
1582
|
+
}
|
|
1583
|
+
function updateMemoHook(calculate, deps) {
|
|
1584
|
+
requireRenderingFiber();
|
|
1585
|
+
const previous = updateHook(8)?.memoizedState;
|
|
1586
|
+
const state = previous !== void 0 && areHookInputsEqual(deps, previous.deps) ? previous : {
|
|
1587
|
+
deps,
|
|
1588
|
+
value: calculate()
|
|
1589
|
+
};
|
|
1590
|
+
appendHook(createHook(8, state));
|
|
1591
|
+
return state.value;
|
|
1592
|
+
}
|
|
1593
|
+
function updateDeferredValueHook(value, initialValue, hasInitialValue) {
|
|
1594
|
+
const fiber = requireRenderingFiber();
|
|
1595
|
+
const oldHook = updateHook(6);
|
|
1596
|
+
let next = oldHook === null ? initialDeferredValue(value, initialValue, hasInitialValue) : oldHook.memoizedState;
|
|
1597
|
+
if (!Object.is(next, value)) if (isTransitionOrDeferredRender(rootOf(fiber))) next = value;
|
|
1598
|
+
else scheduleFiber(fiber, DeferredLane);
|
|
1599
|
+
appendHook(createHook(6, next));
|
|
1600
|
+
return next;
|
|
1601
|
+
}
|
|
1602
|
+
function initialDeferredValue(value, initialValue, hasInitialValue) {
|
|
1603
|
+
return hasInitialValue ? initialValue : value;
|
|
1604
|
+
}
|
|
1605
|
+
function isTransitionOrDeferredRender(root) {
|
|
1606
|
+
return includesOnlyTransitions(root.renderLanes) || includesSomeLane(root.renderLanes, 1073741824);
|
|
1607
|
+
}
|
|
1608
|
+
function updateTransitionHook() {
|
|
1609
|
+
const hook = updateQueuedHook(9, {
|
|
1610
|
+
instance: {
|
|
1611
|
+
controller: null,
|
|
1612
|
+
generation: 0
|
|
1613
|
+
},
|
|
1614
|
+
pendingCount: 0,
|
|
1615
|
+
start: null
|
|
1616
|
+
});
|
|
1617
|
+
const queue = hook.queue;
|
|
1618
|
+
let start = hook.memoizedState.start;
|
|
1619
|
+
if (start === null) {
|
|
1620
|
+
const fiber = requireRenderingFiber();
|
|
1621
|
+
const updatePending = (delta, lane) => {
|
|
1622
|
+
scheduleHookUpdate(fiber, queue, (state) => ({
|
|
1623
|
+
...state,
|
|
1624
|
+
pendingCount: Math.max(0, state.pendingCount + delta)
|
|
1625
|
+
}), lane);
|
|
1626
|
+
};
|
|
1627
|
+
const instance = hook.memoizedState.instance;
|
|
1628
|
+
start = (callback, options) => {
|
|
1629
|
+
if (renderingFiber !== null) throw new Error("Transitions cannot be started while rendering a component.");
|
|
1630
|
+
runLatest(instance, fiber, callback, updatePending, (lane, value, failed, asynchronous) => {
|
|
1631
|
+
updatePending(-1, lane);
|
|
1632
|
+
if (failed) {
|
|
1633
|
+
if (!asynchronous) throw value;
|
|
1634
|
+
queueMicrotask(() => {
|
|
1635
|
+
throw value;
|
|
1636
|
+
});
|
|
1637
|
+
}
|
|
1638
|
+
}, options);
|
|
1639
|
+
};
|
|
1640
|
+
hook.memoizedState.start = start;
|
|
1641
|
+
}
|
|
1642
|
+
return [hook.memoizedState.pendingCount > 0, start];
|
|
1643
|
+
}
|
|
1644
|
+
function runLatest(instance, fiber, run, updatePending, settled, options) {
|
|
1645
|
+
if (retireRun(instance)) updatePending(-1, 32);
|
|
1646
|
+
const lane = claimNextTransitionLane();
|
|
1647
|
+
const controller = new AbortController();
|
|
1648
|
+
const generation = instance.generation += 1;
|
|
1649
|
+
instance.controller = controller;
|
|
1650
|
+
updatePending(1, 2);
|
|
1651
|
+
const settle = (value, failed, asynchronous) => {
|
|
1652
|
+
if (generation !== instance.generation) return;
|
|
1653
|
+
instance.controller = null;
|
|
1654
|
+
settled(lane, value, failed, asynchronous);
|
|
1655
|
+
};
|
|
1656
|
+
const store = rootOfOrNull(fiber)?.dataStore;
|
|
1657
|
+
let result;
|
|
1658
|
+
try {
|
|
1659
|
+
const invoke = () => runWithTransitionLane(lane, () => run(controller.signal), options);
|
|
1660
|
+
result = store === void 0 ? invoke() : store.run(invoke);
|
|
1661
|
+
} catch (error) {
|
|
1662
|
+
settle(error, true, false);
|
|
1663
|
+
return;
|
|
1664
|
+
}
|
|
1665
|
+
if (!isThenable(result)) {
|
|
1666
|
+
settle(result, false, false);
|
|
1667
|
+
return;
|
|
1668
|
+
}
|
|
1669
|
+
result.then((value) => settle(value, false, true), (error) => settle(error, true, true));
|
|
1670
|
+
}
|
|
1671
|
+
function requireRenderingFiber() {
|
|
1672
|
+
if (renderingFiber === null) throw new Error("Hooks can only be called while rendering a component.");
|
|
1673
|
+
return renderingFiber;
|
|
1674
|
+
}
|
|
1675
|
+
function updateQueuedHook(kind, initialState) {
|
|
1676
|
+
const fiber = requireRenderingFiber();
|
|
1677
|
+
const oldHook = updateHook(kind);
|
|
1678
|
+
const hook = oldHook === null ? createHook(kind, resolveInitialState(initialState)) : {
|
|
1679
|
+
...oldHook,
|
|
1680
|
+
next: null
|
|
1681
|
+
};
|
|
1682
|
+
appendHook(hook);
|
|
1683
|
+
const root = rootOf(fiber);
|
|
1684
|
+
const pending = hook.queue.pending;
|
|
1685
|
+
if (pending !== null) hook.baseQueue = consumePendingHookQueue(root, hook, pending);
|
|
1686
|
+
if (hook.baseQueue !== null) processHookQueue(hook, root.renderLanes);
|
|
1687
|
+
return hook;
|
|
1688
|
+
}
|
|
1689
|
+
function updateExternalStoreHook(subscribe, getSnapshot, getServerSnapshot) {
|
|
1690
|
+
const fiber = requireRenderingFiber();
|
|
1691
|
+
const oldHook = updateHook(7);
|
|
1692
|
+
const root = rootOf(fiber);
|
|
1693
|
+
const value = readExternalStoreSnapshot(root, getSnapshot, getServerSnapshot);
|
|
1694
|
+
const state = {
|
|
1695
|
+
getSnapshot,
|
|
1696
|
+
instance: oldHook?.memoizedState.instance ?? {
|
|
1697
|
+
committedSubscribe: null,
|
|
1698
|
+
getSnapshot,
|
|
1699
|
+
owner: null,
|
|
1700
|
+
unsubscribe: null,
|
|
1701
|
+
value
|
|
1702
|
+
},
|
|
1703
|
+
subscribe,
|
|
1704
|
+
value
|
|
1705
|
+
};
|
|
1706
|
+
recordCommitWork(root.commitIndex, fiber, StoreConsistencyFlag);
|
|
1707
|
+
appendHook(createHook(7, state));
|
|
1708
|
+
return value;
|
|
1709
|
+
}
|
|
1710
|
+
function updateStableEventHook(handler) {
|
|
1711
|
+
requireRenderingFiber();
|
|
1712
|
+
const instance = updateHook(10)?.memoizedState.instance ?? createStableEventInstance();
|
|
1713
|
+
appendHook(createHook(10, {
|
|
1714
|
+
instance,
|
|
1715
|
+
next: handler
|
|
1716
|
+
}));
|
|
1717
|
+
return instance.stable;
|
|
1718
|
+
}
|
|
1719
|
+
function createStableEventInstance() {
|
|
1720
|
+
const instance = {
|
|
1721
|
+
controller: null,
|
|
1722
|
+
handler: null,
|
|
1723
|
+
live: false,
|
|
1724
|
+
stable: (...args) => {
|
|
1725
|
+
if (renderingFiber !== null) throw new Error("Stable events cannot be called while rendering a component.");
|
|
1726
|
+
const handler = instance.handler;
|
|
1727
|
+
if (handler === null) throw new Error("Stable events cannot be called before their first commit.");
|
|
1728
|
+
instance.controller?.abort();
|
|
1729
|
+
instance.controller = new AbortController();
|
|
1730
|
+
if (!instance.live) instance.controller.abort();
|
|
1731
|
+
return handler(...args, instance.controller.signal);
|
|
1732
|
+
}
|
|
1733
|
+
};
|
|
1734
|
+
return instance;
|
|
1735
|
+
}
|
|
1736
|
+
function readExternalStoreSnapshot(root, getSnapshot, getServerSnapshot) {
|
|
1737
|
+
if (!root.isHydrating) return getSnapshot();
|
|
1738
|
+
if (getServerSnapshot === void 0) throw new Error("useSyncExternalStore requires getServerSnapshot during hydration.");
|
|
1739
|
+
return getServerSnapshot();
|
|
1740
|
+
}
|
|
1741
|
+
function processHookQueue(hook, renderLanes) {
|
|
1742
|
+
const baseQueue = hook.baseQueue;
|
|
1743
|
+
if (baseQueue === null) return;
|
|
1744
|
+
let state = hook.baseState;
|
|
1745
|
+
let newBaseState = state;
|
|
1746
|
+
let newBaseQueue = null;
|
|
1747
|
+
let update = baseQueue.next;
|
|
1748
|
+
do {
|
|
1749
|
+
if (update.lane !== 0 && !includesSomeLane(renderLanes, update.lane)) {
|
|
1750
|
+
const cloneUpdate = cloneUpdateNode(update);
|
|
1751
|
+
if (newBaseQueue === null) newBaseState = state;
|
|
1752
|
+
newBaseQueue = mergeQueues(newBaseQueue, cloneUpdate);
|
|
1753
|
+
} else {
|
|
1754
|
+
state = typeof update.action === "function" ? update.action(state) : update.action;
|
|
1755
|
+
if (newBaseQueue !== null) {
|
|
1756
|
+
const cloneUpdate = cloneUpdateNode(update);
|
|
1757
|
+
cloneUpdate.lane = 0;
|
|
1758
|
+
newBaseQueue = mergeQueues(newBaseQueue, cloneUpdate);
|
|
1759
|
+
}
|
|
1760
|
+
}
|
|
1761
|
+
update = update.next;
|
|
1762
|
+
} while (update !== baseQueue.next);
|
|
1763
|
+
hook.memoizedState = state;
|
|
1764
|
+
hook.baseState = newBaseQueue === null ? state : newBaseState;
|
|
1765
|
+
hook.baseQueue = newBaseQueue;
|
|
1766
|
+
}
|
|
1767
|
+
function scheduleHookUpdate(fiber, queue, action, lane) {
|
|
1768
|
+
if (currentCommitEffectPhase === 2) throw new Error("State updates are not allowed from useBeforeLayout effects.");
|
|
1769
|
+
lane = hiddenSubtreeLane(fiber, lane);
|
|
1770
|
+
const update = new HookUpdate(action, lane);
|
|
1771
|
+
queue.pending = mergeQueues(queue.pending, update);
|
|
1772
|
+
scheduleFiber(fiber, lane);
|
|
1773
|
+
}
|
|
1774
|
+
function hiddenSubtreeLane(node, lane) {
|
|
1775
|
+
if (!hasHiddenBoundaries || lane === 536870912) return lane;
|
|
1776
|
+
for (let parent = node.return; parent !== null; parent = parent.return) if (parent.tag === 10 && fiberActivityState(parent)?.hidden === true) return OffscreenLane;
|
|
1777
|
+
return lane;
|
|
1778
|
+
}
|
|
1779
|
+
function createFiberId(root, fiber, localId) {
|
|
1780
|
+
if (!root.isHydrating || insideHydrationExemptHost(fiber)) {
|
|
1781
|
+
const id = root.nextClientId;
|
|
1782
|
+
root.nextClientId += 1;
|
|
1783
|
+
return `${root.identifierPrefix}fig-C-${id.toString(32)}`;
|
|
1784
|
+
}
|
|
1785
|
+
return `${root.identifierPrefix}fig-${hydrationIdPath(root, fiber)}-${localId.toString(32)}`;
|
|
1786
|
+
}
|
|
1787
|
+
function hydrationIdPath(root, fiber) {
|
|
1788
|
+
const suspense = root.hydratingSuspenseBoundary;
|
|
1789
|
+
if (suspense !== null) {
|
|
1790
|
+
const state = fiberSuspenseState(suspense.alternate);
|
|
1791
|
+
if (state?.kind === "dehydrated") return appendIdPath(state.idPath, fiberPath(fiber, suspense));
|
|
1792
|
+
}
|
|
1793
|
+
const activity = root.hydratingActivityBoundary;
|
|
1794
|
+
if (activity !== null) {
|
|
1795
|
+
const base = fiberActivityState(activity)?.dehydrated?.idPath ?? null;
|
|
1796
|
+
if (base !== null) return appendIdPath(base, fiberPath(fiber, activity));
|
|
1797
|
+
}
|
|
1798
|
+
return fiberPath(fiber, null);
|
|
1799
|
+
}
|
|
1800
|
+
function appendIdPath(base, relative) {
|
|
1801
|
+
return relative === "" ? base : `${base}-${relative}`;
|
|
1802
|
+
}
|
|
1803
|
+
function fiberPath(fiber, stopBefore) {
|
|
1804
|
+
const parts = [];
|
|
1805
|
+
for (let node = fiber; node !== null && node !== stopBefore && node.tag !== 0; node = node.return) if (node.tag !== 10 || node.type !== null) parts.push(node.index.toString(32));
|
|
1806
|
+
return parts.reverse().join("-");
|
|
1807
|
+
}
|
|
1808
|
+
function consumePendingHookQueue(root, hook, pending) {
|
|
1809
|
+
const queue = hook.queue;
|
|
1810
|
+
queue.pending = null;
|
|
1811
|
+
root.consumedPendingQueues.push({
|
|
1812
|
+
queue,
|
|
1813
|
+
pending
|
|
1814
|
+
});
|
|
1815
|
+
return mergeQueues(cloneQueue(hook.baseQueue), cloneQueueNodes(pending));
|
|
1816
|
+
}
|
|
1817
|
+
function appendHook(hook) {
|
|
1818
|
+
if (renderingFiber === null) return;
|
|
1819
|
+
if (workInProgressHook === null) renderingFiber.memoizedState = hook;
|
|
1820
|
+
else workInProgressHook.next = hook;
|
|
1821
|
+
workInProgressHook = hook;
|
|
1822
|
+
}
|
|
1823
|
+
function updateEffectHook(phase, create, deps) {
|
|
1824
|
+
const fiber = requireRenderingFiber();
|
|
1825
|
+
const oldHook = updateHook(phase);
|
|
1826
|
+
const nextDeps = deps ?? null;
|
|
1827
|
+
const previousEffect = oldHook?.memoizedState ?? null;
|
|
1828
|
+
const hasChanged = previousEffect === null || previousEffect.controller === null || previousEffect.controller.signal.aborted || !areHookInputsEqual(nextDeps, previousEffect.deps);
|
|
1829
|
+
const effect = {
|
|
1830
|
+
phase,
|
|
1831
|
+
create,
|
|
1832
|
+
controller: previousEffect?.controller ?? null,
|
|
1833
|
+
deps: nextDeps,
|
|
1834
|
+
owner: fiber,
|
|
1835
|
+
strictRan: previousEffect?.strictRan === true
|
|
1836
|
+
};
|
|
1837
|
+
appendHook(createHook(phase, effect));
|
|
1838
|
+
if (hasChanged) {
|
|
1839
|
+
fiber.effects ??= [];
|
|
1840
|
+
fiber.effects.push(effect);
|
|
1841
|
+
const root = rootOf(fiber);
|
|
1842
|
+
recordCommitWork(root.commitIndex, fiber, 512);
|
|
1843
|
+
markCommitEffectPhase(root, phase);
|
|
1844
|
+
}
|
|
1845
|
+
}
|
|
1846
|
+
function readContextValue(context) {
|
|
1847
|
+
if (renderingFiber === null) throw new Error("readContext can only be called while rendering a component.");
|
|
1848
|
+
const root = rootOf(renderingFiber);
|
|
1849
|
+
const contextKey = context;
|
|
1850
|
+
const value = currentContextValue(root, contextKey);
|
|
1851
|
+
addContextDependency(renderingFiber, contextKey, value);
|
|
1852
|
+
return value;
|
|
1853
|
+
}
|
|
1854
|
+
function pushContextProvider(node, root = rootOf(node)) {
|
|
1855
|
+
const context = node.type;
|
|
1856
|
+
const values = root.contextValues;
|
|
1857
|
+
const hadPrevious = values.has(context);
|
|
1858
|
+
const previous = values.get(context);
|
|
1859
|
+
values.set(context, node.props.value);
|
|
1860
|
+
root.contextStack.push({
|
|
1861
|
+
context,
|
|
1862
|
+
hadPrevious,
|
|
1863
|
+
previous,
|
|
1864
|
+
provider: node
|
|
1865
|
+
});
|
|
1866
|
+
}
|
|
1867
|
+
function popContextProvider(node) {
|
|
1868
|
+
const root = rootOf(node);
|
|
1869
|
+
const entry = root.contextStack.pop();
|
|
1870
|
+
if (entry === void 0 || entry.provider !== node) {
|
|
1871
|
+
resetContextStack(root);
|
|
1872
|
+
return;
|
|
1873
|
+
}
|
|
1874
|
+
restoreContextEntry(root, entry);
|
|
1875
|
+
}
|
|
1876
|
+
function unwindContextTo(root, node) {
|
|
1877
|
+
while (root.contextStack.length > 0) {
|
|
1878
|
+
const entry = root.contextStack[root.contextStack.length - 1];
|
|
1879
|
+
if (node !== null && isAncestorOf(entry.provider, node)) return;
|
|
1880
|
+
restoreContextEntry(root, root.contextStack.pop());
|
|
1881
|
+
}
|
|
1882
|
+
}
|
|
1883
|
+
function restoreContextEntry(root, entry) {
|
|
1884
|
+
if (entry.hadPrevious) root.contextValues.set(entry.context, entry.previous);
|
|
1885
|
+
else root.contextValues.delete(entry.context);
|
|
1886
|
+
}
|
|
1887
|
+
function resetContextStack(root) {
|
|
1888
|
+
root.contextValues = /* @__PURE__ */ new Map();
|
|
1889
|
+
root.contextStack = [];
|
|
1890
|
+
}
|
|
1891
|
+
function isAncestorOf(ancestor, node) {
|
|
1892
|
+
for (let parent = node; parent !== null; parent = parent.return) if (parent === ancestor) return true;
|
|
1893
|
+
return false;
|
|
1894
|
+
}
|
|
1895
|
+
function addContextDependency(node, context, memoizedValue) {
|
|
1896
|
+
node.contextDependencies ??= [];
|
|
1897
|
+
const dependency = contextDependency(node, context);
|
|
1898
|
+
if (dependency === null) node.contextDependencies.push({
|
|
1899
|
+
context,
|
|
1900
|
+
memoizedValue
|
|
1901
|
+
});
|
|
1902
|
+
else dependency.memoizedValue = memoizedValue;
|
|
1903
|
+
}
|
|
1904
|
+
function contextDependency(node, context) {
|
|
1905
|
+
return node.contextDependencies?.find((dependency) => dependency.context === context) ?? null;
|
|
1906
|
+
}
|
|
1907
|
+
function appendContextDependencies(list, dependencies) {
|
|
1908
|
+
if (dependencies === null) return list;
|
|
1909
|
+
let next = list;
|
|
1910
|
+
for (const dependency of dependencies) next = appendContext(next, dependency.context);
|
|
1911
|
+
return next;
|
|
1912
|
+
}
|
|
1913
|
+
function appendContextList(list, contexts) {
|
|
1914
|
+
if (contexts === null) return list;
|
|
1915
|
+
let next = list;
|
|
1916
|
+
for (const context of contexts) next = appendContext(next, context);
|
|
1917
|
+
return next;
|
|
1918
|
+
}
|
|
1919
|
+
function appendContext(list, context) {
|
|
1920
|
+
if (list === null) return [context];
|
|
1921
|
+
if (!list.includes(context)) list.push(context);
|
|
1922
|
+
return list;
|
|
1923
|
+
}
|
|
1924
|
+
function contextListIncludes(list, context) {
|
|
1925
|
+
return list?.includes(context) === true;
|
|
1926
|
+
}
|
|
1927
|
+
function updateHook(kind) {
|
|
1928
|
+
const hook = currentHook;
|
|
1929
|
+
if (hook === null) {
|
|
1930
|
+
if (didRenderBefore(renderingFiber)) throw hookOrderError("more");
|
|
1931
|
+
return null;
|
|
1932
|
+
}
|
|
1933
|
+
if (hook.kind !== kind) throw new Error(`Hook order changed: expected ${hookKindName(hook.kind)}, received ${hookKindName(kind)}.`);
|
|
1934
|
+
currentHook = hook.next;
|
|
1935
|
+
return hook;
|
|
1936
|
+
}
|
|
1937
|
+
function didRenderBefore(node) {
|
|
1938
|
+
const previous = node?.alternate ?? null;
|
|
1939
|
+
return previous !== null && previous.memoizedProps !== null;
|
|
1940
|
+
}
|
|
1941
|
+
function hookOrderError(direction) {
|
|
1942
|
+
return /* @__PURE__ */ new Error(`Rendered ${direction} hooks than during the previous render.`);
|
|
1943
|
+
}
|
|
1944
|
+
function complete(node) {
|
|
1945
|
+
completeHydration(node);
|
|
1946
|
+
let child = node.child;
|
|
1947
|
+
let childLanes = 0;
|
|
1948
|
+
let subtreeFlags = 0;
|
|
1949
|
+
let contextSubtreeDependencies = null;
|
|
1950
|
+
while (child !== null) {
|
|
1951
|
+
childLanes = mergeLanes(childLanes, child.lanes);
|
|
1952
|
+
childLanes = mergeLanes(childLanes, child.childLanes);
|
|
1953
|
+
subtreeFlags |= childSubtreeFlags(child);
|
|
1954
|
+
contextSubtreeDependencies = appendContextDependencies(contextSubtreeDependencies, child.contextDependencies);
|
|
1955
|
+
contextSubtreeDependencies = appendContextList(contextSubtreeDependencies, child.contextSubtreeDependencies);
|
|
1956
|
+
child = child.sibling;
|
|
1957
|
+
}
|
|
1958
|
+
if (isNewHostInstance(node)) {
|
|
1959
|
+
host.finalizeInitialInstance?.(node.stateNode, node.props);
|
|
1960
|
+
if (!setInitialHostTextContent(node)) {
|
|
1961
|
+
if (node.alternate !== null && node.child !== null) host.setTextContent?.(node.stateNode, "");
|
|
1962
|
+
appendAllHostChildren(node.stateNode, node.child);
|
|
1963
|
+
}
|
|
1964
|
+
if (host.appendInitialChild !== void 0) node.flags |= 64;
|
|
1965
|
+
}
|
|
1966
|
+
if (node.tag === 11) node.flags |= ViewTransitionStaticFlag;
|
|
1967
|
+
if (node.tag === 9 && host.commitAssetResources !== void 0 && (node.committedProps === null || node.committedProps.assets !== node.props.assets)) recordCommitWork(rootOf(node).commitIndex, node, AssetFlag);
|
|
1968
|
+
node.childLanes = childLanes;
|
|
1969
|
+
node.subtreeFlags = subtreeFlags;
|
|
1970
|
+
node.contextSubtreeDependencies = contextSubtreeDependencies;
|
|
1971
|
+
node.memoizedProps = node.props;
|
|
1972
|
+
if (node.tag === 5 && (node.flags & 16) === 0) popContextProvider(node);
|
|
1973
|
+
}
|
|
1974
|
+
function isNewHostInstance(node) {
|
|
1975
|
+
return node.tag === 1 && node.committedProps === null && (node.flags & 4) === 0;
|
|
1976
|
+
}
|
|
1977
|
+
function setInitialHostTextContent(node) {
|
|
1978
|
+
const text = hostTextContent(node.props.children);
|
|
1979
|
+
if (text === null || host.setTextContent === void 0) return false;
|
|
1980
|
+
host.setTextContent(node.stateNode, text);
|
|
1981
|
+
return true;
|
|
1982
|
+
}
|
|
1983
|
+
function appendAllHostChildren(parent, child) {
|
|
1984
|
+
if (host.appendInitialChild === void 0) return;
|
|
1985
|
+
for (let node = child; node !== null; node = node.sibling) {
|
|
1986
|
+
if (node.tag === 8) continue;
|
|
1987
|
+
if (isHoistedFiber(node)) continue;
|
|
1988
|
+
if (node.tag === 1 || node.tag === 2) host.appendInitialChild(parent, hostNode(node));
|
|
1989
|
+
else appendAllHostChildren(parent, node.child);
|
|
1990
|
+
}
|
|
1991
|
+
}
|
|
1992
|
+
function reconcileCurrentChildren(parent, children, root = rootOf(parent)) {
|
|
1993
|
+
reconcile(parent, children, parent.alternate?.child ?? null, false, root);
|
|
1994
|
+
}
|
|
1995
|
+
function reconcile(parent, children, currentFirstChild, forcePlacement, root = rootOf(parent)) {
|
|
1996
|
+
const nextChildren = collectChildren(children);
|
|
1997
|
+
const seenKeys = /* @__PURE__ */ new Set();
|
|
1998
|
+
parent.child = null;
|
|
1999
|
+
parent.deletions = null;
|
|
2000
|
+
let previous = null;
|
|
2001
|
+
let old = currentFirstChild;
|
|
2002
|
+
let index = 0;
|
|
2003
|
+
let lastPlacedIndex = 0;
|
|
2004
|
+
const isHydratingNewTree = parent.tag !== 8 && root.isHydrating && currentFirstChild === null;
|
|
2005
|
+
for (; old !== null && index < nextChildren.length; index += 1) {
|
|
2006
|
+
const child = nextChildren[index];
|
|
2007
|
+
if (!sameChildKey(old, child, index) || !sameType(old, child)) break;
|
|
2008
|
+
validateChildKey(child, seenKeys);
|
|
2009
|
+
const next = createWorkInProgress(old, propsFor(child));
|
|
2010
|
+
next.index = index;
|
|
2011
|
+
next.return = parent;
|
|
2012
|
+
const updateFlags = hostUpdateFlags(old, next.props);
|
|
2013
|
+
if (updateFlags !== 0) recordCommitWork(root.commitIndex, next, updateFlags);
|
|
2014
|
+
if (forcePlacement) next.flags |= 1;
|
|
2015
|
+
else lastPlacedIndex = old.index;
|
|
2016
|
+
previous = appendChild(parent, previous, next);
|
|
2017
|
+
old = old.sibling;
|
|
2018
|
+
}
|
|
2019
|
+
if (index === nextChildren.length) {
|
|
2020
|
+
appendDeletions(parent, old);
|
|
2021
|
+
return;
|
|
2022
|
+
}
|
|
2023
|
+
if (old === null) {
|
|
2024
|
+
for (; index < nextChildren.length; index += 1) {
|
|
2025
|
+
validateChildKey(nextChildren[index], seenKeys);
|
|
2026
|
+
const next = fiberFrom(nextChildren[index]);
|
|
2027
|
+
if (next === null) continue;
|
|
2028
|
+
next.index = index;
|
|
2029
|
+
next.return = parent;
|
|
2030
|
+
if (!isHydratingNewTree) next.flags |= 1;
|
|
2031
|
+
previous = appendChild(parent, previous, next);
|
|
2032
|
+
}
|
|
2033
|
+
return;
|
|
2034
|
+
}
|
|
2035
|
+
let existingByKey = null;
|
|
2036
|
+
let existingByIndex = null;
|
|
2037
|
+
for (; old !== null; old = old.sibling) if (old.key === null) (existingByIndex ??= /* @__PURE__ */ new Map()).set(old.index, old);
|
|
2038
|
+
else (existingByKey ??= /* @__PURE__ */ new Map()).set(String(old.key), old);
|
|
2039
|
+
for (; index < nextChildren.length; index += 1) {
|
|
2040
|
+
const child = nextChildren[index];
|
|
2041
|
+
validateChildKey(child, seenKeys);
|
|
2042
|
+
const key = childExplicitKey(child);
|
|
2043
|
+
const matched = key === null ? existingByIndex?.get(index) : existingByKey?.get(key);
|
|
2044
|
+
const canReuse = matched !== void 0 && sameType(matched, child);
|
|
2045
|
+
const next = canReuse ? createWorkInProgress(matched, propsFor(child)) : fiberFrom(child);
|
|
2046
|
+
if (next === null) continue;
|
|
2047
|
+
next.index = index;
|
|
2048
|
+
next.return = parent;
|
|
2049
|
+
if (canReuse) {
|
|
2050
|
+
if (key === null) existingByIndex?.delete(index);
|
|
2051
|
+
else existingByKey?.delete(key);
|
|
2052
|
+
const updateFlags = hostUpdateFlags(matched, next.props);
|
|
2053
|
+
if (updateFlags !== 0) recordCommitWork(root.commitIndex, next, updateFlags);
|
|
2054
|
+
if (forcePlacement || matched.index < lastPlacedIndex) next.flags |= 1;
|
|
2055
|
+
else lastPlacedIndex = matched.index;
|
|
2056
|
+
} else if (!isHydratingNewTree) next.flags |= 1;
|
|
2057
|
+
previous = appendChild(parent, previous, next);
|
|
2058
|
+
}
|
|
2059
|
+
if (existingByKey !== null) for (const child of existingByKey.values()) appendDeletion(parent, child);
|
|
2060
|
+
if (existingByIndex !== null) for (const child of existingByIndex.values()) appendDeletion(parent, child);
|
|
2061
|
+
}
|
|
2062
|
+
function appendDeletions(parent, firstChild) {
|
|
2063
|
+
for (let child = firstChild; child !== null; child = child.sibling) appendDeletion(parent, child);
|
|
2064
|
+
}
|
|
2065
|
+
function appendDeletion(parent, child) {
|
|
2066
|
+
const root = rootOf(parent);
|
|
2067
|
+
parent.deletions ??= [];
|
|
2068
|
+
parent.deletions.push(child);
|
|
2069
|
+
root.needsCommitDeletions = true;
|
|
2070
|
+
recordCommitWork(root.commitIndex, parent, 128);
|
|
2071
|
+
}
|
|
2072
|
+
function hostUpdateFlags(current, nextProps) {
|
|
2073
|
+
if (current.tag === 2) return current.committedProps?.nodeValue !== nextProps.nodeValue ? 2 : 0;
|
|
2074
|
+
if (current.tag !== 1) return 0;
|
|
2075
|
+
const previousProps = current.committedProps ?? {};
|
|
2076
|
+
let flags = 0;
|
|
2077
|
+
if (hostPropsChanged(previousProps, nextProps)) flags |= 2;
|
|
2078
|
+
if (host.shouldCommitUpdate?.(String(current.type), previousProps, nextProps)) flags |= 2;
|
|
2079
|
+
if (hostTextContentChanged(current, previousProps, nextProps)) flags |= 8;
|
|
2080
|
+
return flags;
|
|
2081
|
+
}
|
|
2082
|
+
function hostTextContentChanged(current, previous, next) {
|
|
2083
|
+
if (host.setTextContent === void 0) return false;
|
|
2084
|
+
if (hasUnsafeHTML(next)) return false;
|
|
2085
|
+
if (adoptedSingleTextChild(current)) return false;
|
|
2086
|
+
const previousText = hostTextContent(previous.children);
|
|
2087
|
+
const nextText = hostTextContent(next.children);
|
|
2088
|
+
return previousText !== nextText || nextText !== null && current.child !== null;
|
|
2089
|
+
}
|
|
2090
|
+
function hostPropsChanged(previous, next) {
|
|
2091
|
+
let previousCount = 0;
|
|
2092
|
+
for (const key in previous) {
|
|
2093
|
+
if (!Object.hasOwn(previous, key)) continue;
|
|
2094
|
+
if (!committedHostProp(key)) continue;
|
|
2095
|
+
previousCount += 1;
|
|
2096
|
+
if (!(key in next) || previous[key] !== next[key]) return true;
|
|
2097
|
+
}
|
|
2098
|
+
let nextCount = 0;
|
|
2099
|
+
for (const key in next) {
|
|
2100
|
+
if (!Object.hasOwn(next, key)) continue;
|
|
2101
|
+
if (committedHostProp(key)) nextCount += 1;
|
|
2102
|
+
}
|
|
2103
|
+
return previousCount !== nextCount;
|
|
2104
|
+
}
|
|
2105
|
+
function committedHostProp(name) {
|
|
2106
|
+
return name !== "children";
|
|
2107
|
+
}
|
|
2108
|
+
function commitRoot(root, finishedWork) {
|
|
2109
|
+
if (!root.pendingCoordinatedCommit && commitCoordinator?.suspend?.(root, () => scheduleRoot(root)) === true) {
|
|
2110
|
+
parkCoordinatedCommit(root);
|
|
2111
|
+
return true;
|
|
2112
|
+
}
|
|
2113
|
+
commitDepth += 1;
|
|
2114
|
+
try {
|
|
2115
|
+
let suspenseRetries = noSuspenseRetries;
|
|
2116
|
+
if (root.pendingSuspenseRetries.length > 0) {
|
|
2117
|
+
suspenseRetries = root.pendingSuspenseRetries;
|
|
2118
|
+
root.pendingSuspenseRetries = [];
|
|
2119
|
+
}
|
|
2120
|
+
commitLiveHookInstances(root);
|
|
2121
|
+
assertLiveHookInstanceParity(finishedWork.child);
|
|
2122
|
+
if (hasHiddenBoundaries) armRevealedHiddenBoundaries(finishedWork.child);
|
|
2123
|
+
commitEffects(root, finishedWork.child, 2);
|
|
2124
|
+
const commitHostChanges = () => {
|
|
2125
|
+
const recoveringHydration = root.clearContainerBeforeCommit;
|
|
2126
|
+
if (recoveringHydration) requireHydrationHostConfig().clearContainer(root.container);
|
|
2127
|
+
if (root.needsCommitDeletions) {
|
|
2128
|
+
commitDeletions(root);
|
|
2129
|
+
root.needsCommitDeletions = false;
|
|
2130
|
+
}
|
|
2131
|
+
assertDeletionCommitParity(finishedWork);
|
|
2132
|
+
if (!recoveringHydration) {
|
|
2133
|
+
commitAssetResourceUpdates(root);
|
|
2134
|
+
assertAssetResourceCommitParity(finishedWork.child);
|
|
2135
|
+
}
|
|
2136
|
+
commitDataDependencies(root);
|
|
2137
|
+
assertDataDependencyCommitParity(finishedWork.child);
|
|
2138
|
+
commitHostUpdates(root);
|
|
2139
|
+
assertHostUpdateCommitParity(finishedWork.child);
|
|
2140
|
+
commitMutationEffects(finishedWork.child);
|
|
2141
|
+
if (hasHiddenBoundaries) commitHiddenBoundaryVisibility(finishedWork.child);
|
|
2142
|
+
assertPlacedHostCommitParity(finishedWork.child, false);
|
|
2143
|
+
if (recoveringHydration) {
|
|
2144
|
+
commitAssetResourceUpdates(root);
|
|
2145
|
+
assertAssetResourceCommitParity(finishedWork.child);
|
|
2146
|
+
}
|
|
2147
|
+
root.clearContainerBeforeCommit = false;
|
|
2148
|
+
};
|
|
2149
|
+
const completeCommit = () => {
|
|
2150
|
+
hasHiddenBoundaries = hiddenStates.size > 0;
|
|
2151
|
+
root.current = finishedWork;
|
|
2152
|
+
deactivateHydration(root);
|
|
2153
|
+
root.hydrationInitialElement = NoHydrationInitialElement;
|
|
2154
|
+
root.consumedPendingQueues = [];
|
|
2155
|
+
markRootCompleted(root, root.pendingLanes & ~root.renderLanes | finishedWork.lanes | finishedWork.childLanes);
|
|
2156
|
+
if (includesSomeLane(finishedWork.childLanes, 536870912)) {
|
|
2157
|
+
markRootPending(root, OffscreenLane);
|
|
2158
|
+
root.suspendedLanes &= ~OffscreenLane;
|
|
2159
|
+
}
|
|
2160
|
+
try {
|
|
2161
|
+
commitExternalStores(root);
|
|
2162
|
+
assertExternalStoreCommitParity(finishedWork.child);
|
|
2163
|
+
attachCommittedSuspenseRetries(root, suspenseRetries);
|
|
2164
|
+
scheduleDehydratedSuspenseRetries(root);
|
|
2165
|
+
commitEffects(root, finishedWork.child, 1);
|
|
2166
|
+
flushCaughtBoundaryErrors(root);
|
|
2167
|
+
assertCaughtBoundaryErrorParity(finishedWork.child);
|
|
2168
|
+
} finally {
|
|
2169
|
+
collectReactiveEffects(root, finishedWork.child);
|
|
2170
|
+
clearTransientFlags(finishedWork);
|
|
2171
|
+
scheduleReactiveEffects(root);
|
|
2172
|
+
clearCommitIndex(root.commitIndex);
|
|
2173
|
+
}
|
|
2174
|
+
if (root.devtools) emitDevtoolsCommit(host, root);
|
|
2175
|
+
flushRecoverableErrors(root);
|
|
2176
|
+
requestPaint();
|
|
2177
|
+
};
|
|
2178
|
+
const finishDeferredCommit = () => {
|
|
2179
|
+
if (!root.pendingCoordinatedCommit) return;
|
|
2180
|
+
root.pendingCoordinatedCommit = false;
|
|
2181
|
+
finishRootWork(root);
|
|
2182
|
+
flushPostCommitSyncWork();
|
|
2183
|
+
};
|
|
2184
|
+
if (commitCoordinator !== null) {
|
|
2185
|
+
let didRunMutation = false;
|
|
2186
|
+
let didFinishCapture = false;
|
|
2187
|
+
const context = {
|
|
2188
|
+
container: root.container,
|
|
2189
|
+
finishedWork,
|
|
2190
|
+
priority: commitPriority(root.renderLanes),
|
|
2191
|
+
root,
|
|
2192
|
+
captureFinished() {
|
|
2193
|
+
if (!didRunMutation) throw new Error("A commit coordinator cannot finish capture before running the mutation transaction.");
|
|
2194
|
+
didFinishCapture = true;
|
|
2195
|
+
finishDeferredCommit();
|
|
2196
|
+
},
|
|
2197
|
+
runMutation(afterMutation) {
|
|
2198
|
+
if (didRunMutation) throw new Error("A commit coordinator may run its mutation transaction only once.");
|
|
2199
|
+
didRunMutation = true;
|
|
2200
|
+
const isDeferredCommit = root.pendingCoordinatedCommit;
|
|
2201
|
+
if (isDeferredCommit) commitDepth += 1;
|
|
2202
|
+
try {
|
|
2203
|
+
commitHostChanges();
|
|
2204
|
+
completeCommit();
|
|
2205
|
+
return afterMutation();
|
|
2206
|
+
} catch (error) {
|
|
2207
|
+
if (!isDeferredCommit) throw error;
|
|
2208
|
+
const info = root.uncaughtErrorInfo ?? errorInfoFor(root.current, error);
|
|
2209
|
+
restartRootWork(root);
|
|
2210
|
+
clearRootAfterUncaughtError(root);
|
|
2211
|
+
reportUncaughtError(root, error, info);
|
|
2212
|
+
if (root.onUncaughtError === null) setTimeout(() => {
|
|
2213
|
+
throw error;
|
|
2214
|
+
});
|
|
2215
|
+
return;
|
|
2216
|
+
} finally {
|
|
2217
|
+
if (isDeferredCommit) commitDepth -= 1;
|
|
2218
|
+
}
|
|
2219
|
+
}
|
|
2220
|
+
};
|
|
2221
|
+
switch (commitCoordinator.commit(context)) {
|
|
2222
|
+
case false:
|
|
2223
|
+
if (didRunMutation) throw new Error("A commit coordinator returned false after running the mutation transaction.");
|
|
2224
|
+
break;
|
|
2225
|
+
case "committed":
|
|
2226
|
+
if (!didRunMutation) throw new Error("A commit coordinator returned \"committed\" without running the mutation transaction.");
|
|
2227
|
+
return false;
|
|
2228
|
+
case "deferred":
|
|
2229
|
+
root.pendingCoordinatedCommit = true;
|
|
2230
|
+
root.callback = null;
|
|
2231
|
+
root.callbackPriority = 0;
|
|
2232
|
+
if (didFinishCapture) finishDeferredCommit();
|
|
2233
|
+
return true;
|
|
2234
|
+
}
|
|
2235
|
+
}
|
|
2236
|
+
commitHostChanges();
|
|
2237
|
+
completeCommit();
|
|
2238
|
+
return false;
|
|
2239
|
+
} finally {
|
|
2240
|
+
commitDepth -= 1;
|
|
2241
|
+
}
|
|
2242
|
+
}
|
|
2243
|
+
function parkCoordinatedCommit(root) {
|
|
2244
|
+
root.parkedCoordinatedCommit = true;
|
|
2245
|
+
root.callback = null;
|
|
2246
|
+
root.callbackPriority = 0;
|
|
2247
|
+
}
|
|
2248
|
+
function scheduleDehydratedSuspenseRetries(root) {
|
|
2249
|
+
if (!root.isHydrationRoot && root.dehydratedSuspenseCount === 0 && !root.needsRootHydrationCompletion) {
|
|
2250
|
+
root.dehydratedBoundaries = /* @__PURE__ */ new Map();
|
|
2251
|
+
return;
|
|
2252
|
+
}
|
|
2253
|
+
const boundaries = [];
|
|
2254
|
+
root.dehydratedBoundaries = /* @__PURE__ */ new Map();
|
|
2255
|
+
updateDehydratedSuspenseCount(root, collectDehydratedSuspense(root.current.child, boundaries, root.dehydratedBoundaries));
|
|
2256
|
+
if (boundaries.length === 0) return;
|
|
2257
|
+
queueMicrotask(() => {
|
|
2258
|
+
for (const boundary of boundaries) {
|
|
2259
|
+
const state = fiberSuspenseState(boundary);
|
|
2260
|
+
if (state?.kind !== "dehydrated") continue;
|
|
2261
|
+
const lane = dehydratedSuspenseRetryLane(state.boundary);
|
|
2262
|
+
if (lane !== 0) scheduleFiber(boundary, lane);
|
|
2263
|
+
}
|
|
2264
|
+
});
|
|
2265
|
+
}
|
|
2266
|
+
function collectDehydratedSuspense(node, boundaries, byStartMarker) {
|
|
2267
|
+
let count = 0;
|
|
2268
|
+
walkFiberForest(node, (cursor) => {
|
|
2269
|
+
const state = fiberSuspenseState(cursor);
|
|
2270
|
+
if (state?.kind === "dehydrated") {
|
|
2271
|
+
count += 1;
|
|
2272
|
+
byStartMarker.set(state.boundary.start, cursor);
|
|
2273
|
+
if (!abandonedHydrationBoundaries.has(cursor) && dehydratedSuspenseRetryLane(state.boundary) !== 0) boundaries.push(cursor);
|
|
2274
|
+
return false;
|
|
2275
|
+
}
|
|
2276
|
+
return true;
|
|
2277
|
+
});
|
|
2278
|
+
return count;
|
|
2279
|
+
}
|
|
2280
|
+
function updateDehydratedSuspenseCount(root, count) {
|
|
2281
|
+
const previous = root.dehydratedSuspenseCount;
|
|
2282
|
+
root.dehydratedSuspenseCount = count;
|
|
2283
|
+
if ((previous > 0 || root.needsRootHydrationCompletion) && count === 0) {
|
|
2284
|
+
root.needsRootHydrationCompletion = false;
|
|
2285
|
+
host.completeRootHydration?.(root.container);
|
|
2286
|
+
}
|
|
2287
|
+
}
|
|
2288
|
+
function dehydratedSuspenseRetryLane(boundary) {
|
|
2289
|
+
if (boundary.forceClientRender) return 32;
|
|
2290
|
+
if (boundary.status === "completed") return 16;
|
|
2291
|
+
if (boundary.status === "client-rendered") return 32;
|
|
2292
|
+
return 0;
|
|
2293
|
+
}
|
|
2294
|
+
function flushRecoverableErrors(root) {
|
|
2295
|
+
const errors = root.recoverableErrors;
|
|
2296
|
+
if (errors.length === 0) return;
|
|
2297
|
+
root.recoverableErrors = [];
|
|
2298
|
+
for (const { error, info } of errors) try {
|
|
2299
|
+
root.onRecoverableError(error, info);
|
|
2300
|
+
} catch {}
|
|
2301
|
+
}
|
|
2302
|
+
function flushCaughtBoundaryErrors(root) {
|
|
2303
|
+
if (root.committedCaughtErrors.length > 0) {
|
|
2304
|
+
const boundaries = root.committedCaughtErrors;
|
|
2305
|
+
root.committedCaughtErrors = [];
|
|
2306
|
+
for (const boundary of boundaries) flushCaughtBoundaryError(root, boundary);
|
|
2307
|
+
}
|
|
2308
|
+
for (const boundary of root.commitIndex) flushCaughtBoundaryError(root, boundary);
|
|
2309
|
+
}
|
|
2310
|
+
function assertCaughtBoundaryErrorParity(node) {
|
|
2311
|
+
walkFiberForest(node, (cursor) => {
|
|
2312
|
+
const state = fiberErrorBoundaryState(cursor);
|
|
2313
|
+
if (state !== null && !state.didReport) throw new Error("Fig internal parity error: a caught boundary error was missing from the commit index.");
|
|
2314
|
+
});
|
|
2315
|
+
}
|
|
2316
|
+
function flushCaughtBoundaryError(root, node) {
|
|
2317
|
+
const state = fiberErrorBoundaryState(node);
|
|
2318
|
+
if (state === null || state.didReport) return;
|
|
2319
|
+
state.didReport = true;
|
|
2320
|
+
if (node.alternate !== null) node.alternate.boundaryState = state;
|
|
2321
|
+
const onError = node.props.onError;
|
|
2322
|
+
if (typeof onError !== "function") return;
|
|
2323
|
+
try {
|
|
2324
|
+
onError(state.error, state.info);
|
|
2325
|
+
} catch (error) {
|
|
2326
|
+
reportUncaughtError(root, error, errorInfoFor(node, error));
|
|
2327
|
+
}
|
|
2328
|
+
}
|
|
2329
|
+
function reportUncaughtError(root, error, info) {
|
|
2330
|
+
try {
|
|
2331
|
+
root.onUncaughtError?.(error, info);
|
|
2332
|
+
} catch {}
|
|
2333
|
+
}
|
|
2334
|
+
function clearRootAfterUncaughtError(root) {
|
|
2335
|
+
root.reactiveCallback?.cancel();
|
|
2336
|
+
root.reactiveCallback = null;
|
|
2337
|
+
root.pendingReactiveEffects = [];
|
|
2338
|
+
root.element = null;
|
|
2339
|
+
if (root.current.child !== null) {
|
|
2340
|
+
deleteFiberDataTree(root.current.child);
|
|
2341
|
+
abortFiberEffects(root.current);
|
|
2342
|
+
}
|
|
2343
|
+
if (host.clearContainer !== void 0) {
|
|
2344
|
+
removePortalDescendants(root.current.child);
|
|
2345
|
+
releaseOutOfBandDescendants(root.current.child);
|
|
2346
|
+
host.clearContainer(root.container);
|
|
2347
|
+
} else if (root.current.child !== null) {
|
|
2348
|
+
let child = root.current.child;
|
|
2349
|
+
while (child !== null) {
|
|
2350
|
+
const next = child.sibling;
|
|
2351
|
+
remove(child, root.container);
|
|
2352
|
+
child = next;
|
|
2353
|
+
}
|
|
2354
|
+
}
|
|
2355
|
+
const current = fiber(0, null, null, { children: null }, root);
|
|
2356
|
+
current.memoizedProps = current.props;
|
|
2357
|
+
current.committedProps = current.props;
|
|
2358
|
+
root.current = current;
|
|
2359
|
+
resetRootWork(root);
|
|
2360
|
+
root.clearContainerBeforeCommit = false;
|
|
2361
|
+
root.hydrationInitialElement = NoHydrationInitialElement;
|
|
2362
|
+
root.consumedPendingQueues = [];
|
|
2363
|
+
root.commitEffectPhases = 0;
|
|
2364
|
+
root.needsCommitDeletions = false;
|
|
2365
|
+
root.committedCaughtErrors.length = 0;
|
|
2366
|
+
markRootCompleted(root, 0);
|
|
2367
|
+
pendingRoots.delete(root);
|
|
2368
|
+
}
|
|
2369
|
+
function commitMutationEffects(node, hidden = false) {
|
|
2370
|
+
let cursor = node;
|
|
2371
|
+
while (cursor !== null) {
|
|
2372
|
+
const subtreeMutation = (cursor.subtreeFlags & 47) !== 0;
|
|
2373
|
+
if ((cursor.flags & 47) === 0 && !subtreeMutation) {
|
|
2374
|
+
cursor = cursor.sibling;
|
|
2375
|
+
continue;
|
|
2376
|
+
}
|
|
2377
|
+
if ((cursor.flags & 1) !== 0) {
|
|
2378
|
+
cursor = commitPlacementRun(cursor, hidden);
|
|
2379
|
+
continue;
|
|
2380
|
+
}
|
|
2381
|
+
if (cursor.tag === 8) commitPortal(cursor);
|
|
2382
|
+
if (cursor.tag === 10 && (cursor.flags & 4) !== 0) commitHydratedActivityBoundary(cursor);
|
|
2383
|
+
if ((cursor.flags & 4) !== 0 && (cursor.flags & 10) !== 0 && isHost(cursor)) {
|
|
2384
|
+
const hostFiber = cursor;
|
|
2385
|
+
commitHostMutation(hostFiber, () => commitUpdate(hostFiber));
|
|
2386
|
+
if (hidden) hideHostFiber(hostFiber);
|
|
2387
|
+
}
|
|
2388
|
+
if ((cursor.flags & 16) === 0 && subtreeMutation) commitMutationEffects(cursor.child, hidden || isHiddenBoundary(cursor));
|
|
2389
|
+
if (cursor.tag === 6 && (cursor.flags & 4) !== 0) commitHydratedSuspenseBoundary(cursor);
|
|
2390
|
+
cursor = cursor.sibling;
|
|
2391
|
+
}
|
|
2392
|
+
}
|
|
2393
|
+
function commitPlacementRun(firstPlaced, hidden) {
|
|
2394
|
+
const lastPlaced = placementRunTail(firstPlaced);
|
|
2395
|
+
const afterPlaced = lastPlaced.sibling;
|
|
2396
|
+
const before = hostSibling(lastPlaced);
|
|
2397
|
+
for (let placed = firstPlaced; placed !== afterPlaced;) {
|
|
2398
|
+
if (placed === null) break;
|
|
2399
|
+
const current = placed;
|
|
2400
|
+
const next = current.sibling;
|
|
2401
|
+
const placedHidden = hidden || isHiddenBoundary(current);
|
|
2402
|
+
if (placedHidden) hidePlacedNode(current);
|
|
2403
|
+
if (hasHiddenBoundaries && isPreassembledHostSubtree(current)) hideNestedBoundaryContent(current.child);
|
|
2404
|
+
commitHostMutation(current, () => commitPlacement(current, before));
|
|
2405
|
+
if (placedHidden) hidePlacedNode(current);
|
|
2406
|
+
if (!isPreassembledHostSubtree(current)) commitMutationEffects(current.child, placedHidden);
|
|
2407
|
+
else commitPortalsInPreassembledSubtree(current.child, placedHidden);
|
|
2408
|
+
placed = next;
|
|
2409
|
+
}
|
|
2410
|
+
return afterPlaced;
|
|
2411
|
+
}
|
|
2412
|
+
function hidePlacedNode(node) {
|
|
2413
|
+
if (isHiddenBoundary(node)) setSubtreeVisibility(node.child, true);
|
|
2414
|
+
else setNodeVisibility(node, true);
|
|
2415
|
+
}
|
|
2416
|
+
function hideNestedBoundaryContent(node) {
|
|
2417
|
+
for (let cursor = node; cursor !== null; cursor = cursor.sibling) {
|
|
2418
|
+
if (isHiddenBoundary(cursor)) setSubtreeVisibility(cursor.child, true);
|
|
2419
|
+
hideNestedBoundaryContent(cursor.child);
|
|
2420
|
+
}
|
|
2421
|
+
}
|
|
2422
|
+
function commitPortalsInPreassembledSubtree(node, hidden) {
|
|
2423
|
+
for (let cursor = node; cursor !== null; cursor = cursor.sibling) {
|
|
2424
|
+
const cursorHidden = hidden || isHiddenBoundary(cursor);
|
|
2425
|
+
if (cursor.tag === 8) {
|
|
2426
|
+
if (cursorHidden) setSubtreeVisibility(cursor.child, true);
|
|
2427
|
+
if (hasHiddenBoundaries) hideNestedBoundaryContent(cursor.child);
|
|
2428
|
+
commitHostMutation(cursor, () => commitPlacement(cursor));
|
|
2429
|
+
if (cursorHidden) setNodeVisibility(cursor, true);
|
|
2430
|
+
commitMutationEffects(cursor.child, cursorHidden);
|
|
2431
|
+
} else commitPortalsInPreassembledSubtree(cursor.child, cursorHidden);
|
|
2432
|
+
}
|
|
2433
|
+
}
|
|
2434
|
+
function commitHostMutation(source, mutation) {
|
|
2435
|
+
try {
|
|
2436
|
+
mutation();
|
|
2437
|
+
} catch (error) {
|
|
2438
|
+
rootOf(source).uncaughtErrorInfo = errorInfoFor(source, error);
|
|
2439
|
+
throw error;
|
|
2440
|
+
}
|
|
2441
|
+
}
|
|
2442
|
+
function isPreassembledHostSubtree(node) {
|
|
2443
|
+
return (node.flags & 64) !== 0;
|
|
2444
|
+
}
|
|
2445
|
+
function placementRunTail(node) {
|
|
2446
|
+
let tail = node;
|
|
2447
|
+
while (tail.sibling !== null && (tail.sibling.flags & 1) !== 0) tail = tail.sibling;
|
|
2448
|
+
return tail;
|
|
2449
|
+
}
|
|
2450
|
+
function commitPlacement(node, before = hostSibling(node)) {
|
|
2451
|
+
if (isHost(node)) {
|
|
2452
|
+
if (node.tag === 1 && isHoistedFiber(node)) {
|
|
2453
|
+
if (node.committedProps === null) acquireHoistedInstance(node);
|
|
2454
|
+
markHostCommitted(node);
|
|
2455
|
+
markHostSubtreeCommitted(node.child);
|
|
2456
|
+
return;
|
|
2457
|
+
}
|
|
2458
|
+
if (shouldCommitPlacementUpdate(node)) commitUpdate(node);
|
|
2459
|
+
host.insertBefore(hostParent(node), hostNode(node), before);
|
|
2460
|
+
markHostCommitted(node);
|
|
2461
|
+
if (isPreassembledHostSubtree(node)) markHostSubtreeCommitted(node.child);
|
|
2462
|
+
} else if (node.tag === 8) {
|
|
2463
|
+
commitPortal(node);
|
|
2464
|
+
if (node.alternate !== null) insertPortalChildren(node);
|
|
2465
|
+
} else if (node.alternate !== null) insertHostSubtree(node, hostParent(node), before);
|
|
2466
|
+
}
|
|
2467
|
+
function commitPortal(node) {
|
|
2468
|
+
host.preparePortalContainer?.(portalTarget(node), rootOf(node).container, hostParent(node));
|
|
2469
|
+
}
|
|
2470
|
+
function shouldCommitPlacementUpdate(node) {
|
|
2471
|
+
if ((node.flags & 10) !== 0) return true;
|
|
2472
|
+
if (node.alternate !== null || node.tag === 2) return false;
|
|
2473
|
+
return host.finalizeInitialInstance === void 0;
|
|
2474
|
+
}
|
|
2475
|
+
function insertHostSubtree(node, parent, before) {
|
|
2476
|
+
visitHostNodes(node, (child) => host.insertBefore(parent, child, before));
|
|
2477
|
+
visitHostFibers(node, (child) => {
|
|
2478
|
+
if (child.committedProps !== null) return;
|
|
2479
|
+
if (child.tag === 1 && isHoistedFiber(child)) {
|
|
2480
|
+
acquireHoistedInstance(child);
|
|
2481
|
+
markHostCommitted(child);
|
|
2482
|
+
markHostSubtreeCommitted(child.child);
|
|
2483
|
+
return;
|
|
2484
|
+
}
|
|
2485
|
+
markHostCommitted(child);
|
|
2486
|
+
if (isPreassembledHostSubtree(child)) markHostSubtreeCommitted(child.child);
|
|
2487
|
+
});
|
|
2488
|
+
}
|
|
2489
|
+
function visitHostFibers(node, visitor) {
|
|
2490
|
+
if (isHost(node)) {
|
|
2491
|
+
visitor(node);
|
|
2492
|
+
return;
|
|
2493
|
+
}
|
|
2494
|
+
if (node.tag === 8) return;
|
|
2495
|
+
for (let child = node.child; child !== null; child = child.sibling) visitHostFibers(child, visitor);
|
|
2496
|
+
}
|
|
2497
|
+
function insertPortalChildren(node) {
|
|
2498
|
+
const parent = portalTarget(node);
|
|
2499
|
+
for (let child = node.child; child !== null; child = child.sibling) visitHostNodes(child, (hostChild) => host.insertBefore(parent, hostChild, null));
|
|
2500
|
+
}
|
|
2501
|
+
function commitUpdate(node) {
|
|
2502
|
+
if (node.tag === 2) host.commitTextUpdate(node.stateNode, String(node.props.nodeValue));
|
|
2503
|
+
else if (node.tag === 1 && isHoistedFiber(node)) commitHoistedUpdate(node);
|
|
2504
|
+
else if ((node.flags & 4) !== 0 && host.commitHydratedInstance !== void 0) host.commitHydratedInstance(node.stateNode, node.props);
|
|
2505
|
+
else {
|
|
2506
|
+
const previousProps = previousCommittedProps(node);
|
|
2507
|
+
if ((node.flags & 2) !== 0) host.commitUpdate(node.stateNode, previousProps, node.props);
|
|
2508
|
+
if ((node.flags & 8) !== 0) commitHostTextContent(node, previousProps);
|
|
2509
|
+
}
|
|
2510
|
+
markHostCommitted(node);
|
|
2511
|
+
}
|
|
2512
|
+
function commitHoistedUpdate(node) {
|
|
2513
|
+
const hoistedHost = requireHoistedAssetHostConfig();
|
|
2514
|
+
const previousProps = previousCommittedProps(node);
|
|
2515
|
+
const instance = node.stateNode;
|
|
2516
|
+
const next = hoistedHost.updateHoistedInstance(instance, previousProps, node.props, assetResourceOwner(node)) ?? instance;
|
|
2517
|
+
if (next !== instance) adoptSwappedHoistedInstance(node, next);
|
|
2518
|
+
}
|
|
2519
|
+
function adoptSwappedHoistedInstance(node, next) {
|
|
2520
|
+
node.stateNode = next;
|
|
2521
|
+
if (node.alternate !== null) node.alternate.stateNode = next;
|
|
2522
|
+
}
|
|
2523
|
+
function commitHydratedSuspenseBoundary(node) {
|
|
2524
|
+
const boundary = dehydratedSuspenseBoundary(node.alternate);
|
|
2525
|
+
if (boundary === null) return;
|
|
2526
|
+
host.commitHydratedSuspenseBoundary?.(boundary);
|
|
2527
|
+
}
|
|
2528
|
+
function commitHydratedActivityBoundary(node) {
|
|
2529
|
+
const state = fiberActivityState(node);
|
|
2530
|
+
if (state?.dehydrated == null) return;
|
|
2531
|
+
requireActivityHydrationHostConfig().commitHydratedActivityBoundary(state.dehydrated.boundary);
|
|
2532
|
+
state.dehydrated = null;
|
|
2533
|
+
}
|
|
2534
|
+
function commitHostTextContent(node, previousProps) {
|
|
2535
|
+
if (host.setTextContent === void 0 || node.tag !== 1) return;
|
|
2536
|
+
const nextText = hostTextContent(node.props.children);
|
|
2537
|
+
if (nextText !== null) host.setTextContent(node.stateNode, nextText);
|
|
2538
|
+
else if (hostTextContent(previousProps.children) !== null) host.setTextContent(node.stateNode, "");
|
|
2539
|
+
}
|
|
2540
|
+
function previousCommittedProps(node) {
|
|
2541
|
+
return node.committedProps ?? node.alternate?.committedProps ?? node.alternate?.memoizedProps ?? {};
|
|
2542
|
+
}
|
|
2543
|
+
function markHostCommitted(node) {
|
|
2544
|
+
if (!isHost(node)) return;
|
|
2545
|
+
node.committedProps = node.props;
|
|
2546
|
+
if (node.alternate !== null) node.alternate.committedProps = node.props;
|
|
2547
|
+
}
|
|
2548
|
+
function markHostSubtreeCommitted(node) {
|
|
2549
|
+
walkFiberForest(node, (child) => {
|
|
2550
|
+
if (child.committedProps === null && isHoistedFiber(child)) acquireHoistedInstance(child);
|
|
2551
|
+
markHostCommitted(child);
|
|
2552
|
+
});
|
|
2553
|
+
}
|
|
2554
|
+
function acquireHoistedInstance(node) {
|
|
2555
|
+
const hoistedHost = requireHoistedAssetHostConfig();
|
|
2556
|
+
const instance = node.stateNode;
|
|
2557
|
+
const resolved = hoistedHost.commitHoistedInstance(instance, node.props, assetResourceOwner(node)) ?? instance;
|
|
2558
|
+
if (resolved === instance) return;
|
|
2559
|
+
adoptSwappedHoistedInstance(node, resolved);
|
|
2560
|
+
}
|
|
2561
|
+
function commitHostUpdates(root) {
|
|
2562
|
+
for (const cursor of root.commitIndex) {
|
|
2563
|
+
if ((cursor.flags & 10) === 0 || !isHost(cursor)) continue;
|
|
2564
|
+
if ((cursor.flags & 5) !== 0) continue;
|
|
2565
|
+
if (cursor.committedProps === null && cursor.tag !== 2) continue;
|
|
2566
|
+
commitHostMutation(cursor, () => commitUpdate(cursor));
|
|
2567
|
+
if (hasHiddenBoundaries && isInsideHiddenBoundary(cursor)) hideHostFiber(cursor);
|
|
2568
|
+
cursor.flags &= -11;
|
|
2569
|
+
}
|
|
2570
|
+
}
|
|
2571
|
+
function assertHostUpdateCommitParity(node) {
|
|
2572
|
+
walkFiberForest(node, (cursor) => {
|
|
2573
|
+
if ((cursor.flags & 10) !== 0 && (cursor.flags & 5) === 0 && (cursor.committedProps !== null || cursor.tag === 2) && isHost(cursor)) throw new Error("Fig internal parity error: a host fiber with pending updates was missing from the commit index.");
|
|
2574
|
+
return (cursor.flags & 16) === 0;
|
|
2575
|
+
});
|
|
2576
|
+
}
|
|
2577
|
+
function commitDeletions(root) {
|
|
2578
|
+
const store = root.dataStore;
|
|
2579
|
+
for (const cursor of root.commitIndex) {
|
|
2580
|
+
if (cursor.deletions === null) continue;
|
|
2581
|
+
const parent = isHostParent(cursor) ? hostParentFor(cursor) : hostParent(cursor);
|
|
2582
|
+
for (const child of cursor.deletions) {
|
|
2583
|
+
walkFiberSubtree(child, (deleted) => {
|
|
2584
|
+
deleteFiberDataOwner(deleted, store);
|
|
2585
|
+
abortFiberHooks(deleted, false);
|
|
2586
|
+
});
|
|
2587
|
+
child.return = null;
|
|
2588
|
+
if (child.alternate !== null) child.alternate.return = null;
|
|
2589
|
+
remove(child, parent);
|
|
2590
|
+
}
|
|
2591
|
+
cursor.deletions = null;
|
|
2592
|
+
}
|
|
2593
|
+
}
|
|
2594
|
+
function assertDeletionCommitParity(node) {
|
|
2595
|
+
walkFiberSubtree(node, (cursor) => {
|
|
2596
|
+
if (cursor.deletions !== null) throw new Error("Fig internal parity error: a fiber with pending deletions was missing from the commit index.");
|
|
2597
|
+
return (cursor.flags & 16) === 0 && (cursor.subtreeFlags & 128) !== 0;
|
|
2598
|
+
});
|
|
2599
|
+
}
|
|
2600
|
+
function commitDataDependencies(root) {
|
|
2601
|
+
for (const cursor of root.commitIndex) {
|
|
2602
|
+
if (!cursor.dataDependenciesDirty) continue;
|
|
2603
|
+
root.dataStore.commitDataDependencies(cursor, cursor.alternate);
|
|
2604
|
+
cursor.dataDependenciesDirty = false;
|
|
2605
|
+
if (cursor.alternate !== null) cursor.alternate.dataDependenciesDirty = false;
|
|
2606
|
+
}
|
|
2607
|
+
}
|
|
2608
|
+
function commitAssetResourceUpdates(root) {
|
|
2609
|
+
if (host.commitAssetResources === void 0) return;
|
|
2610
|
+
for (const cursor of root.commitIndex) {
|
|
2611
|
+
if ((cursor.flags & 16384) === 0) continue;
|
|
2612
|
+
commitHostMutation(cursor, () => host.commitAssetResources?.(cursor.committedProps?.assets ?? null, cursor.props.assets, assetResourceOwner(cursor)));
|
|
2613
|
+
cursor.committedProps = cursor.props;
|
|
2614
|
+
if (cursor.alternate !== null) cursor.alternate.committedProps = cursor.props;
|
|
2615
|
+
cursor.flags &= ~AssetFlag;
|
|
2616
|
+
}
|
|
2617
|
+
}
|
|
2618
|
+
function assertAssetResourceCommitParity(node) {
|
|
2619
|
+
walkFiberForest(node, (cursor) => {
|
|
2620
|
+
if ((cursor.flags & 16384) !== 0) throw new Error("Fig internal parity error: an Assets fiber with pending resource work was missing from the commit index.");
|
|
2621
|
+
return (cursor.flags & 16) === 0;
|
|
2622
|
+
});
|
|
2623
|
+
}
|
|
2624
|
+
function assertPlacedHostCommitParity(node, placed) {
|
|
2625
|
+
for (let child = node; child !== null; child = child.sibling) {
|
|
2626
|
+
const childPlaced = placed || (child.flags & 1) !== 0;
|
|
2627
|
+
if (childPlaced && isHost(child) && child.committedProps === null) throw new Error("Fig internal parity error: a placed host fiber has no committed props after the mutation phase (a subtree insertion skipped commit marking).");
|
|
2628
|
+
if (childPlaced || (child.subtreeFlags & 1) !== 0) assertPlacedHostCommitParity(child.child, childPlaced);
|
|
2629
|
+
}
|
|
2630
|
+
}
|
|
2631
|
+
function assertDataDependencyCommitParity(node) {
|
|
2632
|
+
walkFiberForest(node, (cursor) => {
|
|
2633
|
+
if (cursor.dataDependenciesDirty) throw new Error("Fig internal parity error: a fiber with dirty data dependencies was missing from the commit index.");
|
|
2634
|
+
return (cursor.flags & 16) === 0;
|
|
2635
|
+
});
|
|
2636
|
+
}
|
|
2637
|
+
function deleteFiberDataTree(node) {
|
|
2638
|
+
const store = rootOf(node).dataStore;
|
|
2639
|
+
walkFiberForest(node, (cursor) => {
|
|
2640
|
+
deleteFiberDataOwner(cursor, store);
|
|
2641
|
+
});
|
|
2642
|
+
}
|
|
2643
|
+
function deleteFiberDataOwner(node, store) {
|
|
2644
|
+
store.releaseDataOwner(node);
|
|
2645
|
+
if (node.alternate !== null) store.releaseDataOwner(node.alternate);
|
|
2646
|
+
const state = fiberActivityState(node);
|
|
2647
|
+
if (state !== null) hiddenStates.delete(state);
|
|
2648
|
+
}
|
|
2649
|
+
function dehydratedActivityBoundary(node) {
|
|
2650
|
+
return node.tag === 10 ? fiberActivityState(node)?.dehydrated?.boundary ?? null : null;
|
|
2651
|
+
}
|
|
2652
|
+
function remove(node, parent) {
|
|
2653
|
+
const dehydratedActivity = dehydratedActivityBoundary(node);
|
|
2654
|
+
if (dehydratedActivity !== null) {
|
|
2655
|
+
host.removeChild(parent, dehydratedActivity);
|
|
2656
|
+
return;
|
|
2657
|
+
}
|
|
2658
|
+
const boundary = dehydratedSuspenseBoundary(node);
|
|
2659
|
+
if (boundary !== null && host.removeDehydratedSuspenseBoundary !== void 0) {
|
|
2660
|
+
host.removeDehydratedSuspenseBoundary(boundary);
|
|
2661
|
+
return;
|
|
2662
|
+
}
|
|
2663
|
+
if (node.tag === 8) {
|
|
2664
|
+
removePortalChildren(node);
|
|
2665
|
+
host.removePortalContainer?.(portalTarget(node));
|
|
2666
|
+
return;
|
|
2667
|
+
}
|
|
2668
|
+
if (node.tag === 9) releaseAssetResources(node);
|
|
2669
|
+
if (node.tag === 1 && isHoistedFiber(node)) {
|
|
2670
|
+
if (node.committedProps !== null) requireHoistedAssetHostConfig().removeHoistedInstance(node.stateNode, assetResourceOwner(node));
|
|
2671
|
+
return;
|
|
2672
|
+
}
|
|
2673
|
+
if (isHost(node)) {
|
|
2674
|
+
removePortalDescendants(node.child);
|
|
2675
|
+
releaseOutOfBandDescendants(node.child);
|
|
2676
|
+
host.removeChild(parent, hostNode(node));
|
|
2677
|
+
return;
|
|
2678
|
+
}
|
|
2679
|
+
for (let child = node.child; child !== null; child = child.sibling) remove(child, parent);
|
|
2680
|
+
}
|
|
2681
|
+
function releaseOutOfBandDescendants(node) {
|
|
2682
|
+
if (host.resolveHoistedInstance === void 0 && host.commitAssetResources === void 0) return;
|
|
2683
|
+
for (let child = node; child !== null; child = child.sibling) {
|
|
2684
|
+
if (child.tag === 8) continue;
|
|
2685
|
+
if (child.tag === 9) releaseAssetResources(child);
|
|
2686
|
+
if (child.tag === 1 && isHoistedFiber(child)) {
|
|
2687
|
+
if (child.committedProps !== null && child.stateNode !== null) requireHoistedAssetHostConfig().removeHoistedInstance(child.stateNode, assetResourceOwner(child));
|
|
2688
|
+
continue;
|
|
2689
|
+
}
|
|
2690
|
+
releaseOutOfBandDescendants(child.child);
|
|
2691
|
+
}
|
|
2692
|
+
}
|
|
2693
|
+
function releaseAssetResources(node) {
|
|
2694
|
+
if (node.tag !== 9 || node.committedProps === null || host.commitAssetResources === void 0) return;
|
|
2695
|
+
host.commitAssetResources(node.committedProps.assets, null, assetResourceOwner(node));
|
|
2696
|
+
node.committedProps = null;
|
|
2697
|
+
if (node.alternate !== null) node.alternate.committedProps = null;
|
|
2698
|
+
}
|
|
2699
|
+
function removePortalChildren(node) {
|
|
2700
|
+
const parent = portalTarget(node);
|
|
2701
|
+
for (let child = node.child; child !== null; child = child.sibling) remove(child, parent);
|
|
2702
|
+
}
|
|
2703
|
+
function removePortalDescendants(node) {
|
|
2704
|
+
for (let child = node; child !== null; child = child.sibling) if (child.tag === 8) {
|
|
2705
|
+
removePortalChildren(child);
|
|
2706
|
+
host.removePortalContainer?.(portalTarget(child));
|
|
2707
|
+
} else removePortalDescendants(child.child);
|
|
2708
|
+
}
|
|
2709
|
+
function visitHostNodes(node, visitor) {
|
|
2710
|
+
if (isHost(node)) {
|
|
2711
|
+
if (node.tag === 1 && isHoistedFiber(node)) return;
|
|
2712
|
+
visitor(hostNode(node));
|
|
2713
|
+
return;
|
|
2714
|
+
}
|
|
2715
|
+
if (node.tag === 8) return;
|
|
2716
|
+
for (let child = node.child; child !== null; child = child.sibling) visitHostNodes(child, visitor);
|
|
2717
|
+
}
|
|
2718
|
+
function hostParent(node) {
|
|
2719
|
+
for (let parent = node.return; parent !== null; parent = parent.return) if (isHostParent(parent)) return hostParentFor(parent);
|
|
2720
|
+
throw new Error("Could not find a host parent for fiber.");
|
|
2721
|
+
}
|
|
2722
|
+
function hostAncestorTypes(node) {
|
|
2723
|
+
const ancestors = [];
|
|
2724
|
+
for (let parent = node.return; parent !== null; parent = parent.return) {
|
|
2725
|
+
if (parent.tag === 1) {
|
|
2726
|
+
ancestors.push(String(parent.type));
|
|
2727
|
+
continue;
|
|
2728
|
+
}
|
|
2729
|
+
if (parent.tag === 8 || parent.tag === 0) {
|
|
2730
|
+
const container = host.containerType?.(hostParentFor(parent));
|
|
2731
|
+
if (container != null) ancestors.push(container);
|
|
2732
|
+
break;
|
|
2733
|
+
}
|
|
2734
|
+
}
|
|
2735
|
+
return ancestors;
|
|
2736
|
+
}
|
|
2737
|
+
function hostSibling(node) {
|
|
2738
|
+
if (rootOf(node).clearContainerBeforeCommit) return null;
|
|
2739
|
+
const dehydratedBoundary = dehydratedSuspenseParent(node);
|
|
2740
|
+
if (dehydratedBoundary !== null) return dehydratedBoundary.start;
|
|
2741
|
+
let cursor = node;
|
|
2742
|
+
search: while (true) {
|
|
2743
|
+
while (cursor.sibling === null) {
|
|
2744
|
+
if (cursor.return === null || isHostParent(cursor.return)) return null;
|
|
2745
|
+
cursor = cursor.return;
|
|
2746
|
+
}
|
|
2747
|
+
cursor = cursor.sibling;
|
|
2748
|
+
while (!isHost(cursor)) {
|
|
2749
|
+
const dehydratedActivity = dehydratedActivityBoundary(cursor);
|
|
2750
|
+
if (dehydratedActivity !== null) return dehydratedActivity;
|
|
2751
|
+
if (cursor.tag === 8 || (cursor.flags & 1) !== 0 || cursor.child === null) continue search;
|
|
2752
|
+
cursor = cursor.child;
|
|
2753
|
+
}
|
|
2754
|
+
if ((cursor.flags & 1) === 0 && !isHoistedFiber(cursor)) return hostNode(cursor);
|
|
2755
|
+
}
|
|
2756
|
+
}
|
|
2757
|
+
function dehydratedSuspenseParent(node) {
|
|
2758
|
+
for (let parent = node.return; parent !== null; parent = parent.return) {
|
|
2759
|
+
if ((parent.flags & 4) !== 0) {
|
|
2760
|
+
const boundary = dehydratedSuspenseBoundary(parent.alternate);
|
|
2761
|
+
if (boundary !== null && (boundary.status !== "completed" || boundary.forceClientRender)) return boundary;
|
|
2762
|
+
}
|
|
2763
|
+
if (isHostParent(parent)) return null;
|
|
2764
|
+
}
|
|
2765
|
+
return null;
|
|
2766
|
+
}
|
|
2767
|
+
function isHostParent(node) {
|
|
2768
|
+
return node.tag === 0 || node.tag === 1 || node.tag === 8;
|
|
2769
|
+
}
|
|
2770
|
+
function hostParentFor(node) {
|
|
2771
|
+
if (node.tag === 0) return node.stateNode.container;
|
|
2772
|
+
if (node.tag === 1) return node.stateNode;
|
|
2773
|
+
return portalTarget(node);
|
|
2774
|
+
}
|
|
2775
|
+
function dehydratedSuspenseBoundary(node) {
|
|
2776
|
+
const state = fiberSuspenseState(node);
|
|
2777
|
+
return state?.kind === "dehydrated" ? state.boundary : null;
|
|
2778
|
+
}
|
|
2779
|
+
function fiberSuspenseState(node) {
|
|
2780
|
+
return node?.tag === 6 ? node.boundaryState : null;
|
|
2781
|
+
}
|
|
2782
|
+
function fiberErrorBoundaryState(node) {
|
|
2783
|
+
return node?.tag === 7 ? node.boundaryState : null;
|
|
2784
|
+
}
|
|
2785
|
+
function fiberActivityState(node) {
|
|
2786
|
+
return node?.tag === 10 ? node.boundaryState : null;
|
|
2787
|
+
}
|
|
2788
|
+
function ensureFiberActivityState(node) {
|
|
2789
|
+
const current = fiberActivityState(node);
|
|
2790
|
+
if (current !== null) return current;
|
|
2791
|
+
const state = {
|
|
2792
|
+
hidden: false,
|
|
2793
|
+
dehydrated: null
|
|
2794
|
+
};
|
|
2795
|
+
node.boundaryState = state;
|
|
2796
|
+
return state;
|
|
2797
|
+
}
|
|
2798
|
+
function scheduleFiber(node, lane) {
|
|
2799
|
+
markLanes(node, lane);
|
|
2800
|
+
const root = scheduleParentPath(node.return, lane);
|
|
2801
|
+
const alternateRoot = scheduleParentPath(node.alternate?.return ?? null, lane);
|
|
2802
|
+
const scheduledRoot = root ?? alternateRoot;
|
|
2803
|
+
if (scheduledRoot === null) return;
|
|
2804
|
+
markRootPending(scheduledRoot, lane);
|
|
2805
|
+
scheduleOrBatchRoot(scheduledRoot);
|
|
2806
|
+
}
|
|
2807
|
+
function scheduleParentPath(parent, lane) {
|
|
2808
|
+
for (; parent !== null; parent = parent.return) {
|
|
2809
|
+
markChildLanes(parent, lane);
|
|
2810
|
+
if (parent.tag === 0) return parent.stateNode;
|
|
2811
|
+
}
|
|
2812
|
+
return null;
|
|
2813
|
+
}
|
|
2814
|
+
function attachPing(root, thenable, lanes) {
|
|
2815
|
+
if (lanes === 0) return;
|
|
2816
|
+
const previousLanes = root.suspendedThenables.get(thenable) ?? 0;
|
|
2817
|
+
root.suspendedThenables.set(thenable, mergeLanes(previousLanes, lanes));
|
|
2818
|
+
if (previousLanes !== 0) return;
|
|
2819
|
+
thenable.then(() => ping(root, thenable), () => ping(root, thenable));
|
|
2820
|
+
}
|
|
2821
|
+
function ping(root, thenable) {
|
|
2822
|
+
const lanes = root.suspendedThenables.get(thenable) ?? 0;
|
|
2823
|
+
if (lanes === 0) return;
|
|
2824
|
+
root.suspendedThenables.delete(thenable);
|
|
2825
|
+
markRootPinged(root, lanes);
|
|
2826
|
+
pendingRoots.add(root);
|
|
2827
|
+
scheduleRoot(root);
|
|
2828
|
+
}
|
|
2829
|
+
function findSuspenseBoundary(node) {
|
|
2830
|
+
for (let parent = node.return; parent !== null; parent = parent.return) if (parent.tag === 6 && fiberSuspenseState(parent) === null) return parent;
|
|
2831
|
+
return null;
|
|
2832
|
+
}
|
|
2833
|
+
function findErrorBoundary(node) {
|
|
2834
|
+
for (let parent = node.return; parent !== null; parent = parent.return) if (parent.tag === 7 && fiberErrorBoundaryState(parent) === null) return parent;
|
|
2835
|
+
return null;
|
|
2836
|
+
}
|
|
2837
|
+
function captureSuspenseBoundary(boundary, thenable) {
|
|
2838
|
+
const root = rootOf(boundary);
|
|
2839
|
+
const lanes = root.renderLanes;
|
|
2840
|
+
attachPing(root, thenable, lanes);
|
|
2841
|
+
root.pendingSuspenseRetries.push({
|
|
2842
|
+
boundary,
|
|
2843
|
+
thenable,
|
|
2844
|
+
lanes
|
|
2845
|
+
});
|
|
2846
|
+
rollbackCommitIndex(root.commitIndex, boundary.commitIndexCheckpoint);
|
|
2847
|
+
if (boundary.deletions !== null) recordCommitWork(root.commitIndex, boundary);
|
|
2848
|
+
const dehydrated = fiberSuspenseState(boundary.alternate);
|
|
2849
|
+
if (root.hydratingSuspenseBoundary === boundary && dehydrated?.kind === "dehydrated") {
|
|
2850
|
+
leaveSuspenseHydration(root, boundary, dehydrated.boundary);
|
|
2851
|
+
boundary.boundaryState = dehydrated;
|
|
2852
|
+
boundary.flags &= -5;
|
|
2853
|
+
boundary.child = null;
|
|
2854
|
+
abandonedHydrationBoundaries.add(boundary);
|
|
2855
|
+
if (boundary.alternate !== null) abandonedHydrationBoundaries.add(boundary.alternate);
|
|
2856
|
+
return completeUnit(boundary);
|
|
2857
|
+
}
|
|
2858
|
+
if (shouldPreserveSuspenseBoundary(root, boundary)) {
|
|
2859
|
+
markRootSuspended(root, lanes);
|
|
2860
|
+
throw PreservedSuspense;
|
|
2861
|
+
}
|
|
2862
|
+
const currentPrimary = suspensePrimaryFiber(boundary.alternate);
|
|
2863
|
+
if (currentPrimary !== null) {
|
|
2864
|
+
boundary.boundaryState = {
|
|
2865
|
+
kind: "fallback",
|
|
2866
|
+
primaryChild: null
|
|
2867
|
+
};
|
|
2868
|
+
boundary.deletions = null;
|
|
2869
|
+
restoreConsumedPendingQueuesForRetry(root, boundary.suspenseQueueStart ?? root.consumedPendingQueues.length);
|
|
2870
|
+
hasHiddenBoundaries = true;
|
|
2871
|
+
const primary = suspensePrimaryWorkInProgress(boundary, currentPrimary, "hidden");
|
|
2872
|
+
primary.child = cloneSuspendedPrimary(currentPrimary.child, primary);
|
|
2873
|
+
primary.flags |= 32;
|
|
2874
|
+
primary.memoizedProps = primary.props;
|
|
2875
|
+
primary.lanes = 0;
|
|
2876
|
+
primary.childLanes = 0;
|
|
2877
|
+
boundary.child = primary;
|
|
2878
|
+
const fallback = suspenseFallbackWorkInProgress(boundary, currentPrimary.sibling, 1);
|
|
2879
|
+
primary.sibling = fallback;
|
|
2880
|
+
return fallback;
|
|
2881
|
+
}
|
|
2882
|
+
boundary.boundaryState = {
|
|
2883
|
+
kind: "fallback",
|
|
2884
|
+
primaryChild: boundary.child?.tag === 10 && boundary.child.type === null ? boundary.child.child : boundary.child
|
|
2885
|
+
};
|
|
2886
|
+
const fallback = suspenseFallbackWorkInProgress(boundary, null, 0);
|
|
2887
|
+
boundary.child = fallback;
|
|
2888
|
+
return fallback;
|
|
2889
|
+
}
|
|
2890
|
+
function captureErrorBoundary(boundary, error, source) {
|
|
2891
|
+
const root = rootOf(boundary);
|
|
2892
|
+
rollbackCommitIndex(root.commitIndex, boundary.commitIndexCheckpoint);
|
|
2893
|
+
recordCommitWork(root.commitIndex, boundary);
|
|
2894
|
+
const state = createErrorBoundaryState(error, source);
|
|
2895
|
+
boundary.boundaryState = state;
|
|
2896
|
+
reconcileCurrentChildren(boundary, errorBoundaryFallback(boundary, state));
|
|
2897
|
+
return boundary.child ?? completeUnit(boundary);
|
|
2898
|
+
}
|
|
2899
|
+
function captureCommittedErrorBoundary(boundary, error, source) {
|
|
2900
|
+
rootOf(boundary).committedCaughtErrors.push(boundary);
|
|
2901
|
+
const state = createErrorBoundaryState(error, source);
|
|
2902
|
+
boundary.boundaryState = state;
|
|
2903
|
+
if (boundary.alternate !== null) boundary.alternate.boundaryState = state;
|
|
2904
|
+
}
|
|
2905
|
+
function createErrorBoundaryState(error, source) {
|
|
2906
|
+
return {
|
|
2907
|
+
error,
|
|
2908
|
+
info: errorInfoFor(source, error),
|
|
2909
|
+
didReport: false
|
|
2910
|
+
};
|
|
2911
|
+
}
|
|
2912
|
+
function shouldPreserveSuspenseBoundary(root, boundary) {
|
|
2913
|
+
return boundary.alternate !== null && fiberSuspenseState(boundary.alternate) === null && isTransitionOrDeferredRender(root);
|
|
2914
|
+
}
|
|
2915
|
+
function attachCommittedSuspenseRetries(root, retries) {
|
|
2916
|
+
for (const { boundary, thenable, lanes } of retries) {
|
|
2917
|
+
let attached = root.attachedSuspenseRetries.get(thenable);
|
|
2918
|
+
if (attached === void 0) {
|
|
2919
|
+
attached = /* @__PURE__ */ new WeakSet();
|
|
2920
|
+
root.attachedSuspenseRetries.set(thenable, attached);
|
|
2921
|
+
}
|
|
2922
|
+
if (attached.has(boundary) || boundary.alternate !== null && attached.has(boundary.alternate)) continue;
|
|
2923
|
+
attached.add(boundary);
|
|
2924
|
+
const retry = () => scheduleFiber(boundary, suspenseRetryLane(lanes));
|
|
2925
|
+
thenable.then(retry, retry);
|
|
2926
|
+
}
|
|
2927
|
+
}
|
|
2928
|
+
function lazilyPropagateParentContextChanges(node, root) {
|
|
2929
|
+
if ((node.flags & 1024) !== 0) return false;
|
|
2930
|
+
const contexts = changedParentContexts(node);
|
|
2931
|
+
node.flags |= ContextPropagationFlag;
|
|
2932
|
+
if (contexts === null) return false;
|
|
2933
|
+
const current = node.alternate;
|
|
2934
|
+
if (current === null) return false;
|
|
2935
|
+
for (const context of contexts) {
|
|
2936
|
+
if (!contextListIncludes(current.contextSubtreeDependencies, context)) continue;
|
|
2937
|
+
for (let child = current.child; child !== null; child = child.sibling) markContextConsumers(child, current, context, root.renderLanes);
|
|
2938
|
+
}
|
|
2939
|
+
return includesSomeLane(node.childLanes, root.renderLanes);
|
|
2940
|
+
}
|
|
2941
|
+
function changedParentContexts(node) {
|
|
2942
|
+
let seen = node.tag === 5 ? [node.type] : null;
|
|
2943
|
+
let changed = null;
|
|
2944
|
+
for (let parent = node.return; parent !== null; parent = parent.return) {
|
|
2945
|
+
if ((parent.flags & 1024) !== 0) break;
|
|
2946
|
+
if (parent.tag !== 5) continue;
|
|
2947
|
+
const context = parent.type;
|
|
2948
|
+
if (contextListIncludes(seen, context)) continue;
|
|
2949
|
+
seen = appendContext(seen, context);
|
|
2950
|
+
if (changedContextProvider(parent)) changed = appendContext(changed, context);
|
|
2951
|
+
}
|
|
2952
|
+
return changed;
|
|
2953
|
+
}
|
|
2954
|
+
function markContextConsumers(node, propagationRoot, context, lanes) {
|
|
2955
|
+
if (node.tag === 5 && node.type === context) return;
|
|
2956
|
+
if (contextDependency(node, context) !== null) {
|
|
2957
|
+
markLanes(node, lanes);
|
|
2958
|
+
markParentPath(node, propagationRoot, lanes);
|
|
2959
|
+
}
|
|
2960
|
+
if (!contextListIncludes(node.contextSubtreeDependencies, context)) return;
|
|
2961
|
+
for (let child = node.child; child !== null; child = child.sibling) markContextConsumers(child, propagationRoot, context, lanes);
|
|
2962
|
+
}
|
|
2963
|
+
function markParentPath(node, stopAt, lanes) {
|
|
2964
|
+
for (let parent = node.return; parent !== null && parent !== stopAt; parent = parent.return) markChildLanes(parent, lanes);
|
|
2965
|
+
markChildLanes(stopAt, lanes);
|
|
2966
|
+
}
|
|
2967
|
+
function markLanes(node, lane) {
|
|
2968
|
+
node.lanes = mergeLanes(node.lanes, lane);
|
|
2969
|
+
if (node.alternate !== null) node.alternate.lanes = mergeLanes(node.alternate.lanes, lane);
|
|
2970
|
+
}
|
|
2971
|
+
function markChildLanes(node, lane) {
|
|
2972
|
+
node.childLanes = mergeLanes(node.childLanes, lane);
|
|
2973
|
+
if (node.alternate !== null) node.alternate.childLanes = mergeLanes(node.alternate.childLanes, lane);
|
|
2974
|
+
}
|
|
2975
|
+
function markSubtreeFlag(node, flag) {
|
|
2976
|
+
for (let parent = node.return; parent !== null; parent = parent.return) parent.subtreeFlags |= flag;
|
|
2977
|
+
}
|
|
2978
|
+
function createWorkInProgress(current, props) {
|
|
2979
|
+
const next = current.alternate ?? fiber(current.tag, current.type, current.key, props, current.stateNode);
|
|
2980
|
+
next.props = props;
|
|
2981
|
+
next.memoizedProps = current.memoizedProps;
|
|
2982
|
+
next.committedProps = current.committedProps;
|
|
2983
|
+
next.assetResourceOwner = current.assetResourceOwner;
|
|
2984
|
+
next.memoizedState = current.memoizedState;
|
|
2985
|
+
next.stateNode = current.stateNode;
|
|
2986
|
+
next.return = current.return;
|
|
2987
|
+
next.child = null;
|
|
2988
|
+
next.sibling = null;
|
|
2989
|
+
next.index = current.index;
|
|
2990
|
+
next.flags = current.flags & HoistedStaticFlag;
|
|
2991
|
+
next.subtreeFlags = 0;
|
|
2992
|
+
next.deletions = null;
|
|
2993
|
+
next.lanes = current.lanes;
|
|
2994
|
+
next.childLanes = current.childLanes;
|
|
2995
|
+
next.effects = null;
|
|
2996
|
+
next.contextDependencies = current.contextDependencies;
|
|
2997
|
+
next.contextSubtreeDependencies = current.contextSubtreeDependencies;
|
|
2998
|
+
next.dataDependenciesDirty = false;
|
|
2999
|
+
next.boundaryState = current.boundaryState;
|
|
3000
|
+
next.hiddenState = null;
|
|
3001
|
+
next.alternate = current;
|
|
3002
|
+
current.alternate = next;
|
|
3003
|
+
return next;
|
|
3004
|
+
}
|
|
3005
|
+
function cloneChildFibers(parent) {
|
|
3006
|
+
let current = parent.alternate?.child ?? null;
|
|
3007
|
+
let previous = null;
|
|
3008
|
+
parent.child = null;
|
|
3009
|
+
parent.deletions = null;
|
|
3010
|
+
while (current !== null) {
|
|
3011
|
+
const next = createWorkInProgress(current, current.props);
|
|
3012
|
+
next.return = parent;
|
|
3013
|
+
previous = appendChild(parent, previous, next);
|
|
3014
|
+
current = current.sibling;
|
|
3015
|
+
}
|
|
3016
|
+
}
|
|
3017
|
+
function appendChild(parent, previous, child) {
|
|
3018
|
+
if (previous === null) parent.child = child;
|
|
3019
|
+
else previous.sibling = child;
|
|
3020
|
+
return child;
|
|
3021
|
+
}
|
|
3022
|
+
function fiberFrom(child) {
|
|
3023
|
+
if (typeof child === "string") return fiber(2, null, null, { nodeValue: child }, null);
|
|
3024
|
+
if (isPortal(child)) return fiber(8, null, child.key, portalProps(child), null);
|
|
3025
|
+
if (isValidElement(child)) return fiber(tagFor(child), child.type, child.key, child.props, null);
|
|
3026
|
+
if (isThenable(child)) return fiber(12, null, null, { thenable: child }, null);
|
|
3027
|
+
return null;
|
|
3028
|
+
}
|
|
3029
|
+
function portalTarget(node) {
|
|
3030
|
+
return node.props.target;
|
|
3031
|
+
}
|
|
3032
|
+
function fiber(tag, type, key, props, stateNode) {
|
|
3033
|
+
return {
|
|
3034
|
+
tag,
|
|
3035
|
+
type,
|
|
3036
|
+
key,
|
|
3037
|
+
props,
|
|
3038
|
+
memoizedProps: null,
|
|
3039
|
+
committedProps: null,
|
|
3040
|
+
memoizedState: null,
|
|
3041
|
+
stateNode,
|
|
3042
|
+
return: null,
|
|
3043
|
+
child: null,
|
|
3044
|
+
sibling: null,
|
|
3045
|
+
index: 0,
|
|
3046
|
+
alternate: null,
|
|
3047
|
+
flags: 0,
|
|
3048
|
+
subtreeFlags: 0,
|
|
3049
|
+
deletions: null,
|
|
3050
|
+
lanes: 0,
|
|
3051
|
+
childLanes: 0,
|
|
3052
|
+
effects: null,
|
|
3053
|
+
contextDependencies: null,
|
|
3054
|
+
contextSubtreeDependencies: null,
|
|
3055
|
+
dataDependenciesDirty: false,
|
|
3056
|
+
assetResourceOwner: null,
|
|
3057
|
+
boundaryState: null,
|
|
3058
|
+
hiddenState: null
|
|
3059
|
+
};
|
|
3060
|
+
}
|
|
3061
|
+
function assetResourceOwner(node) {
|
|
3062
|
+
const owner = node.assetResourceOwner ?? node.alternate?.assetResourceOwner ?? {};
|
|
3063
|
+
node.assetResourceOwner = owner;
|
|
3064
|
+
if (node.alternate !== null) node.alternate.assetResourceOwner = owner;
|
|
3065
|
+
return owner;
|
|
3066
|
+
}
|
|
3067
|
+
function rootOf(node) {
|
|
3068
|
+
const root = rootOfOrNull(node);
|
|
3069
|
+
if (root === null) throw new Error("Could not find a root for fiber.");
|
|
3070
|
+
return root;
|
|
3071
|
+
}
|
|
3072
|
+
function rootOfOrNull(node) {
|
|
3073
|
+
for (let parent = node; parent !== null; parent = parent.return) if (parent.tag === 0) return parent.stateNode;
|
|
3074
|
+
return null;
|
|
3075
|
+
}
|
|
3076
|
+
function errorInfoFor(node, error) {
|
|
3077
|
+
const dataResourceKeys = error === void 0 ? void 0 : dataResourceKeysForError(error);
|
|
3078
|
+
return dataResourceKeys === void 0 ? { componentStack: componentStackFor(node) } : {
|
|
3079
|
+
componentStack: componentStackFor(node),
|
|
3080
|
+
dataResourceKeys
|
|
3081
|
+
};
|
|
3082
|
+
}
|
|
3083
|
+
function queueRecoverableError(root, node, error, details) {
|
|
3084
|
+
root.recoverableErrors.push({
|
|
3085
|
+
error,
|
|
3086
|
+
info: {
|
|
3087
|
+
...details,
|
|
3088
|
+
componentStack: componentStackFor(node)
|
|
3089
|
+
}
|
|
3090
|
+
});
|
|
3091
|
+
}
|
|
3092
|
+
function componentStackFor(node) {
|
|
3093
|
+
const frames = [];
|
|
3094
|
+
for (let fiber = node; fiber !== null; fiber = fiber.return) {
|
|
3095
|
+
const name = componentStackName(fiber);
|
|
3096
|
+
if (name !== null) frames.push(` at ${name}`);
|
|
3097
|
+
}
|
|
3098
|
+
return frames.length === 0 ? "" : `\n${frames.join("\n")}`;
|
|
3099
|
+
}
|
|
3100
|
+
function componentStackName(node) {
|
|
3101
|
+
switch (node.tag) {
|
|
3102
|
+
case 3: return devtoolsTypeName(node.type, "Anonymous");
|
|
3103
|
+
case 5: return `${devtoolsTypeName(node.type, "Context")}.Provider`;
|
|
3104
|
+
case 6: return "Suspense";
|
|
3105
|
+
case 7: return "ErrorBoundary";
|
|
3106
|
+
case 11: return "ViewTransition";
|
|
3107
|
+
case 8: return "Portal";
|
|
3108
|
+
case 9: return "Assets";
|
|
3109
|
+
default: return null;
|
|
3110
|
+
}
|
|
3111
|
+
}
|
|
3112
|
+
return {
|
|
3113
|
+
batchedUpdates,
|
|
3114
|
+
createRoot,
|
|
3115
|
+
hydrateRoot,
|
|
3116
|
+
hydrateTarget,
|
|
3117
|
+
flushSync,
|
|
3118
|
+
installCommitCoordinator,
|
|
3119
|
+
scheduleRefresh
|
|
3120
|
+
};
|
|
3121
|
+
function scheduleRefresh(update) {
|
|
3122
|
+
if (!hasRefreshHandler() || mountedRoots.size === 0) return;
|
|
3123
|
+
runWithStaleRefreshFamilies(update.staleFamilies, () => {
|
|
3124
|
+
flushSync(() => {
|
|
3125
|
+
for (const root of mountedRoots) scheduleFamilyRefresh(root.current.child, update);
|
|
3126
|
+
});
|
|
3127
|
+
});
|
|
3128
|
+
}
|
|
3129
|
+
function scheduleFamilyRefresh(node, update) {
|
|
3130
|
+
if (node === null) return;
|
|
3131
|
+
if (node.tag === 3 && hasRefreshHandler()) {
|
|
3132
|
+
const family = refreshFamilyFor(node.type);
|
|
3133
|
+
if (family !== void 0) {
|
|
3134
|
+
if (update.staleFamilies.has(family)) remountForRefresh(node);
|
|
3135
|
+
else if (update.updatedFamilies.has(family)) scheduleFiber(node, 2);
|
|
3136
|
+
}
|
|
3137
|
+
}
|
|
3138
|
+
scheduleFamilyRefresh(node.child, update);
|
|
3139
|
+
scheduleFamilyRefresh(node.sibling, update);
|
|
3140
|
+
}
|
|
3141
|
+
function remountForRefresh(node) {
|
|
3142
|
+
{
|
|
3143
|
+
const parent = node.return;
|
|
3144
|
+
if (parent === null || parent.tag === 0) {
|
|
3145
|
+
const root = rootOf(node);
|
|
3146
|
+
updateRoot(root, root.element);
|
|
3147
|
+
} else scheduleFiber(parent, 2);
|
|
3148
|
+
}
|
|
3149
|
+
}
|
|
3150
|
+
function findDehydratedSuspenseBoundaryForTarget(node, target) {
|
|
3151
|
+
if (node === null || host.isTargetWithinSuspenseBoundary === void 0) return null;
|
|
3152
|
+
const state = fiberSuspenseState(node);
|
|
3153
|
+
if (state?.kind === "dehydrated" && host.isTargetWithinSuspenseBoundary(target, state.boundary)) return node;
|
|
3154
|
+
return findDehydratedSuspenseBoundaryForTarget(node.child, target) ?? findDehydratedSuspenseBoundaryForTarget(node.sibling, target);
|
|
3155
|
+
}
|
|
3156
|
+
function isHiddenBoundary(node) {
|
|
3157
|
+
return node.tag === 10 && activityHidden(node.props);
|
|
3158
|
+
}
|
|
3159
|
+
function requireActivityHostConfig() {
|
|
3160
|
+
if (activityHostConfig !== null) return activityHostConfig;
|
|
3161
|
+
if (host.hideInstance === void 0 || host.unhideInstance === void 0 || host.hideTextInstance === void 0 || host.unhideTextInstance === void 0) throw new Error("Activity is not supported by this renderer.");
|
|
3162
|
+
activityHostConfig = host;
|
|
3163
|
+
return activityHostConfig;
|
|
3164
|
+
}
|
|
3165
|
+
function commitHiddenBoundaryVisibility(node, hidden = false) {
|
|
3166
|
+
for (let cursor = node; cursor !== null; cursor = cursor.sibling) {
|
|
3167
|
+
if ((cursor.flags & 16) !== 0) continue;
|
|
3168
|
+
const subtreeVisibility = (cursor.subtreeFlags & 32) !== 0;
|
|
3169
|
+
if ((cursor.flags & 32) === 0 && !subtreeVisibility) continue;
|
|
3170
|
+
const boundary = cursor.tag === 10;
|
|
3171
|
+
const boundaryHidden = boundary && activityHidden(cursor.props);
|
|
3172
|
+
if (boundary && (cursor.flags & 32) !== 0) {
|
|
3173
|
+
const effectiveHidden = hidden || boundaryHidden;
|
|
3174
|
+
const state = fiberActivityState(cursor);
|
|
3175
|
+
if (state !== null) {
|
|
3176
|
+
state.hidden = effectiveHidden;
|
|
3177
|
+
if (effectiveHidden) hiddenStates.add(state);
|
|
3178
|
+
else hiddenStates.delete(state);
|
|
3179
|
+
}
|
|
3180
|
+
setSubtreeVisibility(cursor.child, effectiveHidden);
|
|
3181
|
+
if (effectiveHidden && cursor.child !== null) abortFiberEffects(cursor.child, true);
|
|
3182
|
+
if (!effectiveHidden && includesSomeLane(cursor.childLanes, 536870912)) {
|
|
3183
|
+
const root = rootOf(cursor);
|
|
3184
|
+
markRootPending(root, 32);
|
|
3185
|
+
markRootEntangled(root, 32 | OffscreenLane);
|
|
3186
|
+
scheduleOrBatchRoot(root);
|
|
3187
|
+
}
|
|
3188
|
+
}
|
|
3189
|
+
if (subtreeVisibility) commitHiddenBoundaryVisibility(cursor.child, hidden || boundaryHidden);
|
|
3190
|
+
}
|
|
3191
|
+
}
|
|
3192
|
+
function setSubtreeVisibility(node, hidden) {
|
|
3193
|
+
for (let cursor = node; cursor !== null; cursor = cursor.sibling) setNodeVisibility(cursor, hidden);
|
|
3194
|
+
}
|
|
3195
|
+
function setNodeVisibility(cursor, hidden) {
|
|
3196
|
+
if (isHiddenBoundary(cursor)) return;
|
|
3197
|
+
if (cursor.tag === 1) {
|
|
3198
|
+
const activityHost = requireActivityHostConfig();
|
|
3199
|
+
if (hidden) activityHost.hideInstance(cursor.stateNode);
|
|
3200
|
+
else activityHost.unhideInstance(cursor.stateNode, cursor.props);
|
|
3201
|
+
} else if (cursor.tag === 2) {
|
|
3202
|
+
const activityHost = requireActivityHostConfig();
|
|
3203
|
+
if (hidden) activityHost.hideTextInstance(cursor.stateNode);
|
|
3204
|
+
else activityHost.unhideTextInstance(cursor.stateNode, String(cursor.props.nodeValue));
|
|
3205
|
+
}
|
|
3206
|
+
setSubtreeVisibility(cursor.child, hidden);
|
|
3207
|
+
}
|
|
3208
|
+
function hideHostFiber(node) {
|
|
3209
|
+
const activityHost = requireActivityHostConfig();
|
|
3210
|
+
if (node.tag === 1) activityHost.hideInstance(node.stateNode);
|
|
3211
|
+
else activityHost.hideTextInstance(node.stateNode);
|
|
3212
|
+
}
|
|
3213
|
+
function armRevealedHiddenBoundaries(node) {
|
|
3214
|
+
for (let cursor = node; cursor !== null; cursor = cursor.sibling) {
|
|
3215
|
+
if ((cursor.flags & 16) !== 0) continue;
|
|
3216
|
+
const subtreeVisibility = (cursor.subtreeFlags & 32) !== 0;
|
|
3217
|
+
if ((cursor.flags & 32) === 0 && !subtreeVisibility) continue;
|
|
3218
|
+
if (cursor.tag === 10 && (cursor.flags & 32) !== 0 && !activityHidden(cursor.props) && cursor.child !== null) armDeferredEffects(cursor.child);
|
|
3219
|
+
if (subtreeVisibility) armRevealedHiddenBoundaries(cursor.child);
|
|
3220
|
+
}
|
|
3221
|
+
}
|
|
3222
|
+
function armDeferredEffects(node) {
|
|
3223
|
+
visitFiberHooks(node, (owner, hook) => {
|
|
3224
|
+
if (hook.kind === 10) {
|
|
3225
|
+
const state = hook.memoizedState;
|
|
3226
|
+
const instance = state.instance;
|
|
3227
|
+
instance.handler = state.next;
|
|
3228
|
+
instance.live = true;
|
|
3229
|
+
return;
|
|
3230
|
+
}
|
|
3231
|
+
if (!isEffectHook(hook.kind)) return;
|
|
3232
|
+
const effect = hook.memoizedState;
|
|
3233
|
+
if (effect.controller !== null) return;
|
|
3234
|
+
const effects = owner.effects ??= [];
|
|
3235
|
+
if (!effects.includes(effect)) effects.push(effect);
|
|
3236
|
+
const root = rootOf(owner);
|
|
3237
|
+
recordCommitWork(root.commitIndex, owner, 512);
|
|
3238
|
+
markSubtreeFlag(owner, 512);
|
|
3239
|
+
markCommitEffectPhase(root, effect.phase);
|
|
3240
|
+
});
|
|
3241
|
+
}
|
|
3242
|
+
function commitLiveHookInstances(root) {
|
|
3243
|
+
for (const owner of root.commitIndex) for (let hook = owner.memoizedState; hook !== null; hook = hook.next) commitLiveHookInstance(owner, hook);
|
|
3244
|
+
}
|
|
3245
|
+
function commitLiveHookInstance(owner, hook) {
|
|
3246
|
+
if (isStableEventHook(hook)) {
|
|
3247
|
+
const instance = hook.memoizedState.instance;
|
|
3248
|
+
instance.handler = hook.memoizedState.next;
|
|
3249
|
+
instance.live = !hasHiddenBoundaries || !isInsideHiddenBoundary(owner);
|
|
3250
|
+
}
|
|
3251
|
+
if (hook.kind === 4) {
|
|
3252
|
+
const state = hook.memoizedState;
|
|
3253
|
+
state.instance.action = state.action;
|
|
3254
|
+
state.instance.value = state.value;
|
|
3255
|
+
}
|
|
3256
|
+
}
|
|
3257
|
+
function assertLiveHookInstanceParity(node) {
|
|
3258
|
+
visitRenderedFiberHooks(node, (owner, hook) => {
|
|
3259
|
+
if (isStableEventHook(hook)) {
|
|
3260
|
+
const instance = hook.memoizedState.instance;
|
|
3261
|
+
if (instance.handler !== hook.memoizedState.next || instance.live !== (!hasHiddenBoundaries || !isInsideHiddenBoundary(owner))) throw new Error("Fig internal parity error: a stable-event hook was not published by the commit index.");
|
|
3262
|
+
}
|
|
3263
|
+
if (hook.kind === 4) {
|
|
3264
|
+
const state = hook.memoizedState;
|
|
3265
|
+
if (state.instance.action !== state.action || state.instance.value !== state.value) throw new Error("Fig internal parity error: an action-state hook was not published by the commit index.");
|
|
3266
|
+
}
|
|
3267
|
+
});
|
|
3268
|
+
}
|
|
3269
|
+
function isInsideHiddenBoundary(node) {
|
|
3270
|
+
for (let parent = node.return; parent !== null; parent = parent.return) if (isHiddenBoundary(parent)) return true;
|
|
3271
|
+
return false;
|
|
3272
|
+
}
|
|
3273
|
+
function isStableEventHook(hook) {
|
|
3274
|
+
return hook.kind === 10;
|
|
3275
|
+
}
|
|
3276
|
+
function commitExternalStores(root) {
|
|
3277
|
+
for (const cursor of root.commitIndex) {
|
|
3278
|
+
if ((cursor.flags & 2048) === 0) continue;
|
|
3279
|
+
if (hasHiddenBoundaries && isInsideHiddenBoundary(cursor)) continue;
|
|
3280
|
+
for (let hook = cursor.memoizedState; hook !== null; hook = hook.next) if (isExternalStoreHook(hook)) commitExternalStore(root, cursor, hook.memoizedState);
|
|
3281
|
+
}
|
|
3282
|
+
}
|
|
3283
|
+
function assertExternalStoreCommitParity(node) {
|
|
3284
|
+
walkFiberForest(node, (cursor) => {
|
|
3285
|
+
if ((cursor.flags & 16) !== 0) return false;
|
|
3286
|
+
if ((cursor.flags & 2048) !== 0) for (let hook = cursor.memoizedState; hook !== null; hook = hook.next) {
|
|
3287
|
+
if (!isExternalStoreHook(hook)) continue;
|
|
3288
|
+
const state = hook.memoizedState;
|
|
3289
|
+
const instance = state.instance;
|
|
3290
|
+
if (instance.committedSubscribe !== state.subscribe || instance.getSnapshot !== state.getSnapshot || instance.owner !== cursor || !Object.is(instance.value, state.value)) throw new Error("Fig internal parity error: an external-store hook was not committed by the commit index.");
|
|
3291
|
+
}
|
|
3292
|
+
return !isHiddenBoundary(cursor) && (cursor.subtreeFlags & 2048) !== 0;
|
|
3293
|
+
});
|
|
3294
|
+
}
|
|
3295
|
+
function commitExternalStore(root, owner, state) {
|
|
3296
|
+
const instance = state.instance;
|
|
3297
|
+
if (instance.committedSubscribe !== state.subscribe) {
|
|
3298
|
+
instance.unsubscribe?.();
|
|
3299
|
+
instance.unsubscribe = null;
|
|
3300
|
+
instance.committedSubscribe = state.subscribe;
|
|
3301
|
+
}
|
|
3302
|
+
instance.getSnapshot = state.getSnapshot;
|
|
3303
|
+
instance.owner = owner;
|
|
3304
|
+
instance.value = state.value;
|
|
3305
|
+
root.externalStores.add(instance);
|
|
3306
|
+
instance.unsubscribe ??= state.subscribe(() => {
|
|
3307
|
+
scheduleExternalStoreIfChanged(instance.owner, instance, requestExternalStoreUpdateLane());
|
|
3308
|
+
});
|
|
3309
|
+
scheduleExternalStoreIfChanged(instance.owner, instance, 2);
|
|
3310
|
+
}
|
|
3311
|
+
function scheduleExternalStoreIfChanged(owner, instance, lane) {
|
|
3312
|
+
if (owner === null) return;
|
|
3313
|
+
const latestValue = instance.getSnapshot();
|
|
3314
|
+
if (!Object.is(latestValue, instance.value)) scheduleFiber(owner, lane);
|
|
3315
|
+
}
|
|
3316
|
+
function requestExternalStoreUpdateLane() {
|
|
3317
|
+
const lane = requestUpdateLane();
|
|
3318
|
+
return lane === 32 ? 2 : lane;
|
|
3319
|
+
}
|
|
3320
|
+
function commitEffects(root, node, phase) {
|
|
3321
|
+
const mask = 1 << phase;
|
|
3322
|
+
if ((root.commitEffectPhases & mask) === 0) return;
|
|
3323
|
+
let executed = 0;
|
|
3324
|
+
const runEffects = () => {
|
|
3325
|
+
for (const owner of root.commitIndex) {
|
|
3326
|
+
const effects = owner.effects;
|
|
3327
|
+
if (effects === null) continue;
|
|
3328
|
+
if (hasHiddenBoundaries && isInsideHiddenBoundary(owner)) continue;
|
|
3329
|
+
for (const effect of effects) {
|
|
3330
|
+
if (effect.phase !== phase) continue;
|
|
3331
|
+
executed += 1;
|
|
3332
|
+
runCommitEffect(effect, phase);
|
|
3333
|
+
}
|
|
3334
|
+
}
|
|
3335
|
+
};
|
|
3336
|
+
if (phase === 1) runWithPriority(2, runEffects);
|
|
3337
|
+
else runEffects();
|
|
3338
|
+
root.commitEffectPhases &= ~mask;
|
|
3339
|
+
{
|
|
3340
|
+
let expected = 0;
|
|
3341
|
+
visitEffects(node, (effect) => {
|
|
3342
|
+
if (effect.phase === phase) expected += 1;
|
|
3343
|
+
});
|
|
3344
|
+
if (executed !== expected) throw new Error(`Fig internal parity error: the commit index executed ${executed} ${hookKindNames[phase]} effect(s) where the tree walk found ${expected}.`);
|
|
3345
|
+
}
|
|
3346
|
+
}
|
|
3347
|
+
function runCommitEffect(effect, phase) {
|
|
3348
|
+
const previousPhase = currentCommitEffectPhase;
|
|
3349
|
+
currentCommitEffectPhase = phase;
|
|
3350
|
+
try {
|
|
3351
|
+
runEffect(effect);
|
|
3352
|
+
} finally {
|
|
3353
|
+
currentCommitEffectPhase = previousPhase;
|
|
3354
|
+
}
|
|
3355
|
+
}
|
|
3356
|
+
function collectReactiveEffects(root, node) {
|
|
3357
|
+
walkFiberForest(node, (cursor) => {
|
|
3358
|
+
for (const effect of cursor.effects ?? []) if (effect.phase === 0) root.pendingReactiveEffects.push(effect);
|
|
3359
|
+
cursor.effects = null;
|
|
3360
|
+
const adopted = (cursor.flags & 16) !== 0;
|
|
3361
|
+
const subtreeFlags = cursor.subtreeFlags;
|
|
3362
|
+
clearTransientFlags(cursor);
|
|
3363
|
+
if (adopted) return false;
|
|
3364
|
+
if (isHiddenBoundary(cursor)) {
|
|
3365
|
+
if (subtreeFlags !== 0) clearHiddenSubtreeFlags(cursor.child);
|
|
3366
|
+
return false;
|
|
3367
|
+
}
|
|
3368
|
+
return (subtreeFlags & ~StaticFlagsMask) !== 0;
|
|
3369
|
+
});
|
|
3370
|
+
}
|
|
3371
|
+
function clearHiddenSubtreeFlags(node) {
|
|
3372
|
+
walkFiberForest(node, (cursor) => {
|
|
3373
|
+
const adopted = (cursor.flags & 16) !== 0;
|
|
3374
|
+
const subtreeFlags = cursor.subtreeFlags;
|
|
3375
|
+
clearTransientFlags(cursor);
|
|
3376
|
+
return !adopted && (subtreeFlags & -12289) !== 0;
|
|
3377
|
+
});
|
|
3378
|
+
}
|
|
3379
|
+
function scheduleReactiveEffects(root) {
|
|
3380
|
+
if (root.pendingReactiveEffects.length === 0 || root.reactiveCallback !== null) return;
|
|
3381
|
+
root.reactiveCallback = scheduleCallback(3, () => {
|
|
3382
|
+
performReactiveEffects(root);
|
|
3383
|
+
});
|
|
3384
|
+
}
|
|
3385
|
+
function performReactiveEffects(root) {
|
|
3386
|
+
try {
|
|
3387
|
+
flushReactiveEffects(root);
|
|
3388
|
+
} catch (error) {
|
|
3389
|
+
const info = root.uncaughtErrorInfo ?? errorInfoFor(root.current, error);
|
|
3390
|
+
clearRootAfterUncaughtError(root);
|
|
3391
|
+
reportUncaughtError(root, error, info);
|
|
3392
|
+
if (root.onUncaughtError === null) setTimeout(() => {
|
|
3393
|
+
throw error;
|
|
3394
|
+
});
|
|
3395
|
+
}
|
|
3396
|
+
}
|
|
3397
|
+
function flushPendingReactiveEffects(root) {
|
|
3398
|
+
root.reactiveCallback?.cancel();
|
|
3399
|
+
flushReactiveEffects(root);
|
|
3400
|
+
}
|
|
3401
|
+
function flushReactiveEffects(root) {
|
|
3402
|
+
root.reactiveCallback = null;
|
|
3403
|
+
const effects = root.pendingReactiveEffects;
|
|
3404
|
+
root.pendingReactiveEffects = [];
|
|
3405
|
+
for (const effect of effects) runEffect(effect);
|
|
3406
|
+
}
|
|
3407
|
+
function visitEffects(node, visitor) {
|
|
3408
|
+
walkFiberForest(node, (cursor) => {
|
|
3409
|
+
for (const effect of cursor.effects ?? []) visitor(effect);
|
|
3410
|
+
return (cursor.flags & 16) === 0 && !isHiddenBoundary(cursor) && (cursor.subtreeFlags & 512) !== 0;
|
|
3411
|
+
});
|
|
3412
|
+
}
|
|
3413
|
+
function visitFiberHooks(node, visitor) {
|
|
3414
|
+
walkFiberForest(node, (cursor) => {
|
|
3415
|
+
for (let hook = cursor.memoizedState; hook !== null; hook = hook.next) visitor(cursor, hook);
|
|
3416
|
+
});
|
|
3417
|
+
}
|
|
3418
|
+
function visitRenderedFiberHooks(node, visitor) {
|
|
3419
|
+
walkFiberForest(node, (cursor) => {
|
|
3420
|
+
for (let hook = cursor.memoizedState; hook !== null; hook = hook.next) visitor(cursor, hook);
|
|
3421
|
+
return (cursor.flags & 16) === 0;
|
|
3422
|
+
});
|
|
3423
|
+
}
|
|
3424
|
+
function isExternalStoreHook(hook) {
|
|
3425
|
+
return hook.kind === 7;
|
|
3426
|
+
}
|
|
3427
|
+
function runEffect(effect) {
|
|
3428
|
+
let runStrict = false;
|
|
3429
|
+
runStrict = !effect.strictRan;
|
|
3430
|
+
effect.strictRan = true;
|
|
3431
|
+
abortEffect(effect);
|
|
3432
|
+
let controller = new AbortController();
|
|
3433
|
+
effect.controller = controller;
|
|
3434
|
+
const dataStore = rootOf(effect.owner).dataStore;
|
|
3435
|
+
try {
|
|
3436
|
+
dataStore.run(() => effect.create(controller.signal));
|
|
3437
|
+
if (runStrict) {
|
|
3438
|
+
abortEffect(effect);
|
|
3439
|
+
controller = new AbortController();
|
|
3440
|
+
effect.controller = controller;
|
|
3441
|
+
dataStore.run(() => effect.create(controller.signal));
|
|
3442
|
+
}
|
|
3443
|
+
} catch (error) {
|
|
3444
|
+
abortEffect(effect);
|
|
3445
|
+
handleEffectError(effect, error);
|
|
3446
|
+
}
|
|
3447
|
+
}
|
|
3448
|
+
function handleEffectError(effect, error) {
|
|
3449
|
+
const owner = effect.owner;
|
|
3450
|
+
const boundary = findErrorBoundary(owner);
|
|
3451
|
+
if (boundary !== null) {
|
|
3452
|
+
captureCommittedErrorBoundary(boundary, error, owner);
|
|
3453
|
+
scheduleFiber(boundary, 32);
|
|
3454
|
+
return;
|
|
3455
|
+
}
|
|
3456
|
+
rootOf(owner).uncaughtErrorInfo = errorInfoFor(owner, error);
|
|
3457
|
+
throw error;
|
|
3458
|
+
}
|
|
3459
|
+
function abortFiberEffects(node, retirePending = false) {
|
|
3460
|
+
walkFiberForest(node, (cursor) => {
|
|
3461
|
+
abortFiberHooks(cursor, retirePending);
|
|
3462
|
+
});
|
|
3463
|
+
}
|
|
3464
|
+
function abortFiberHooks(owner, retirePending) {
|
|
3465
|
+
for (let hook = owner.memoizedState; hook !== null; hook = hook.next) {
|
|
3466
|
+
if (isEffectHook(hook.kind)) abortEffect(hook.memoizedState);
|
|
3467
|
+
if (isExternalStoreHook(hook)) unsubscribeExternalStore(hook.memoizedState);
|
|
3468
|
+
if (isStableEventHook(hook)) {
|
|
3469
|
+
const instance = hook.memoizedState.instance;
|
|
3470
|
+
instance.controller?.abort();
|
|
3471
|
+
instance.controller = null;
|
|
3472
|
+
instance.live = false;
|
|
3473
|
+
}
|
|
3474
|
+
if (hook.kind === 9) {
|
|
3475
|
+
const state = hook.memoizedState;
|
|
3476
|
+
if (retireRun(state.instance) && retirePending) scheduleHookUpdate(owner, hook.queue, (previous) => ({
|
|
3477
|
+
...previous,
|
|
3478
|
+
pendingCount: Math.max(0, previous.pendingCount - 1)
|
|
3479
|
+
}), 32);
|
|
3480
|
+
}
|
|
3481
|
+
if (hook.kind === 4) {
|
|
3482
|
+
const state = hook.memoizedState;
|
|
3483
|
+
if (retireRun(state.instance) && retirePending) scheduleHookUpdate(owner, hook.queue, (previous) => ({
|
|
3484
|
+
...previous,
|
|
3485
|
+
pending: Math.max(0, previous.pending - 1)
|
|
3486
|
+
}), 32);
|
|
3487
|
+
}
|
|
3488
|
+
}
|
|
3489
|
+
}
|
|
3490
|
+
function abortEffect(effect) {
|
|
3491
|
+
effect.controller?.abort();
|
|
3492
|
+
effect.controller = null;
|
|
3493
|
+
}
|
|
3494
|
+
function unsubscribeExternalStore(state) {
|
|
3495
|
+
if (state.instance.owner !== null) rootOf(state.instance.owner).externalStores.delete(state.instance);
|
|
3496
|
+
state.instance.unsubscribe?.();
|
|
3497
|
+
state.instance.unsubscribe = null;
|
|
3498
|
+
state.instance.committedSubscribe = null;
|
|
3499
|
+
state.instance.owner = null;
|
|
3500
|
+
}
|
|
3501
|
+
function restoreConsumedPendingQueues(root, from = 0) {
|
|
3502
|
+
for (const consumed of root.consumedPendingQueues.splice(from)) restoreConsumedPendingQueue(consumed);
|
|
3503
|
+
}
|
|
3504
|
+
function restoreConsumedPendingQueuesForRetry(root, from) {
|
|
3505
|
+
for (const consumed of root.consumedPendingQueues.splice(from)) {
|
|
3506
|
+
clearQueueLanes(consumed.pending);
|
|
3507
|
+
restoreConsumedPendingQueue(consumed);
|
|
3508
|
+
}
|
|
3509
|
+
}
|
|
3510
|
+
function restoreConsumedPendingQueue({ queue, pending }) {
|
|
3511
|
+
queue.pending = queue.pending === null ? pending : mergeQueues(pending, queue.pending);
|
|
3512
|
+
}
|
|
3513
|
+
}
|
|
3514
|
+
function observeDiscardedPromiseChildren(node) {
|
|
3515
|
+
if (Array.isArray(node)) {
|
|
3516
|
+
for (const child of node) observeDiscardedPromiseChildren(child);
|
|
3517
|
+
return;
|
|
3518
|
+
}
|
|
3519
|
+
if (isValidElement(node)) {
|
|
3520
|
+
observeDiscardedPromiseChildren(node.props.children);
|
|
3521
|
+
return;
|
|
3522
|
+
}
|
|
3523
|
+
if (isPortal(node)) {
|
|
3524
|
+
observeDiscardedPromiseChildren(node.children);
|
|
3525
|
+
return;
|
|
3526
|
+
}
|
|
3527
|
+
if (isThenable(node)) trackThenable(node);
|
|
3528
|
+
}
|
|
3529
|
+
function activityHidden(props) {
|
|
3530
|
+
return props.mode === "hidden";
|
|
3531
|
+
}
|
|
3532
|
+
function hookKindName(kind) {
|
|
3533
|
+
return hookKindNames[kind];
|
|
3534
|
+
}
|
|
3535
|
+
function createHook(kind, state) {
|
|
3536
|
+
return {
|
|
3537
|
+
kind,
|
|
3538
|
+
memoizedState: state,
|
|
3539
|
+
baseState: state,
|
|
3540
|
+
baseQueue: null,
|
|
3541
|
+
queue: {
|
|
3542
|
+
pending: null,
|
|
3543
|
+
dispatch: null
|
|
3544
|
+
},
|
|
3545
|
+
next: null
|
|
3546
|
+
};
|
|
3547
|
+
}
|
|
3548
|
+
function retireRun(instance) {
|
|
3549
|
+
const controller = instance.controller;
|
|
3550
|
+
if (controller === null) return false;
|
|
3551
|
+
instance.controller = null;
|
|
3552
|
+
instance.generation += 1;
|
|
3553
|
+
controller.abort();
|
|
3554
|
+
return true;
|
|
3555
|
+
}
|
|
3556
|
+
function createActionState(action, value) {
|
|
3557
|
+
return {
|
|
3558
|
+
action,
|
|
3559
|
+
error: NoActionStateError,
|
|
3560
|
+
instance: {
|
|
3561
|
+
action,
|
|
3562
|
+
controller: null,
|
|
3563
|
+
generation: 0,
|
|
3564
|
+
runner: null,
|
|
3565
|
+
value
|
|
3566
|
+
},
|
|
3567
|
+
pending: 0,
|
|
3568
|
+
value
|
|
3569
|
+
};
|
|
3570
|
+
}
|
|
3571
|
+
function resolveInitialState(initialState) {
|
|
3572
|
+
return typeof initialState === "function" ? initialState() : initialState;
|
|
3573
|
+
}
|
|
3574
|
+
function sameType(fiber, child) {
|
|
3575
|
+
if (typeof child === "string") return fiber.tag === 2;
|
|
3576
|
+
if (isPortal(child)) return fiber.tag === 8 && fiber.props.target === child.target;
|
|
3577
|
+
if (isValidElement(child)) return matchesComponentFamily(fiber.type, child.type);
|
|
3578
|
+
return isThenable(child) && fiber.tag === 12;
|
|
3579
|
+
}
|
|
3580
|
+
function propsFor(child) {
|
|
3581
|
+
if (typeof child === "string") return { nodeValue: child };
|
|
3582
|
+
if (isPortal(child)) return portalProps(child);
|
|
3583
|
+
if (isValidElement(child)) return child.props;
|
|
3584
|
+
if (isThenable(child)) return { thenable: child };
|
|
3585
|
+
throw invalidChildError(child);
|
|
3586
|
+
}
|
|
3587
|
+
function portalProps(child) {
|
|
3588
|
+
return {
|
|
3589
|
+
children: child.children,
|
|
3590
|
+
target: child.target
|
|
3591
|
+
};
|
|
3592
|
+
}
|
|
3593
|
+
function validateChildKey(child, seenKeys) {
|
|
3594
|
+
if (seenKeys === null) return;
|
|
3595
|
+
const key = childExplicitKey(child);
|
|
3596
|
+
if (key === null) return;
|
|
3597
|
+
if (seenKeys.has(key)) throw duplicateKeyError(key);
|
|
3598
|
+
seenKeys.add(key);
|
|
3599
|
+
}
|
|
3600
|
+
function sameChildKey(fiber, child, index) {
|
|
3601
|
+
const key = childExplicitKey(child);
|
|
3602
|
+
return key === null ? fiber.key === null && fiber.index === index : fiber.key !== null && String(fiber.key) === key;
|
|
3603
|
+
}
|
|
3604
|
+
function childExplicitKey(child) {
|
|
3605
|
+
return (isValidElement(child) || isPortal(child)) && child.key !== null ? String(child.key) : null;
|
|
3606
|
+
}
|
|
3607
|
+
function duplicateKeyError(key) {
|
|
3608
|
+
return /* @__PURE__ */ new Error(`Duplicate key "${String(key)}" found among siblings.`);
|
|
3609
|
+
}
|
|
3610
|
+
function isHost(fiber) {
|
|
3611
|
+
return fiber.tag === 1 || fiber.tag === 2;
|
|
3612
|
+
}
|
|
3613
|
+
function hostNode(fiber) {
|
|
3614
|
+
return fiber.stateNode;
|
|
3615
|
+
}
|
|
3616
|
+
function areHookInputsEqual(nextDeps, previousDeps) {
|
|
3617
|
+
if (nextDeps === null || previousDeps === null) return false;
|
|
3618
|
+
if (nextDeps.length !== previousDeps.length) return false;
|
|
3619
|
+
for (let index = 0; index < nextDeps.length; index += 1) if (!Object.is(nextDeps[index], previousDeps[index])) return false;
|
|
3620
|
+
return true;
|
|
3621
|
+
}
|
|
3622
|
+
function changedContextProvider(fiber) {
|
|
3623
|
+
return fiber.tag === 5 && fiber.alternate !== null && !Object.is(fiber.props.value, fiber.alternate.memoizedProps?.value);
|
|
3624
|
+
}
|
|
3625
|
+
function suspenseRetryLane(lanes) {
|
|
3626
|
+
const retryLanes = lanes & RetryLanes;
|
|
3627
|
+
return retryLanes === 0 ? claimNextRetryLane() : getHighestPriorityLane(retryLanes);
|
|
3628
|
+
}
|
|
3629
|
+
//#endregion
|
|
3630
|
+
export { createRenderer, runWithEventPriority };
|
|
3631
|
+
|
|
3632
|
+
//# sourceMappingURL=index.js.map
|