@tanstack/redact 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/core/index.d.ts +2 -0
- package/dist/core/index.js +4 -0
- package/dist/core/index.js.map +7 -0
- package/dist/core/internal.d.ts +76 -0
- package/dist/core/internal.js +59 -0
- package/dist/core/internal.js.map +7 -0
- package/dist/core/types.d.ts +21 -0
- package/dist/core/types.js +10 -0
- package/dist/core/types.js.map +7 -0
- package/dist/dom/_all.d.ts +17 -0
- package/dist/dom/_all.js +51 -0
- package/dist/dom/_all.js.map +7 -0
- package/dist/dom/client.d.ts +3 -0
- package/dist/dom/client.js +8 -0
- package/dist/dom/client.js.map +7 -0
- package/dist/dom/dispatcher.d.ts +20 -0
- package/dist/dom/dispatcher.js +267 -0
- package/dist/dom/dispatcher.js.map +7 -0
- package/dist/dom/dom.d.ts +10 -0
- package/dist/dom/dom.js +262 -0
- package/dist/dom/dom.js.map +7 -0
- package/dist/dom/event-replay.d.ts +13 -0
- package/dist/dom/event-replay.js +46 -0
- package/dist/dom/event-replay.js.map +7 -0
- package/dist/dom/features/class/full.d.ts +1 -0
- package/dist/dom/features/class/full.js +91 -0
- package/dist/dom/features/class/full.js.map +7 -0
- package/dist/dom/features/class/index.d.ts +1 -0
- package/dist/dom/features/class/index.js +3 -0
- package/dist/dom/features/class/index.js.map +7 -0
- package/dist/dom/features/class/stub.d.ts +1 -0
- package/dist/dom/features/class/stub.js +50 -0
- package/dist/dom/features/class/stub.js.map +7 -0
- package/dist/dom/features/context/full.d.ts +1 -0
- package/dist/dom/features/context/full.js +49 -0
- package/dist/dom/features/context/full.js.map +7 -0
- package/dist/dom/features/context/index.d.ts +1 -0
- package/dist/dom/features/context/index.js +3 -0
- package/dist/dom/features/context/index.js.map +7 -0
- package/dist/dom/features/context/stub.d.ts +1 -0
- package/dist/dom/features/context/stub.js +22 -0
- package/dist/dom/features/context/stub.js.map +7 -0
- package/dist/dom/features/forward-ref/full.d.ts +1 -0
- package/dist/dom/features/forward-ref/full.js +51 -0
- package/dist/dom/features/forward-ref/full.js.map +7 -0
- package/dist/dom/features/forward-ref/index.d.ts +1 -0
- package/dist/dom/features/forward-ref/index.js +3 -0
- package/dist/dom/features/forward-ref/index.js.map +7 -0
- package/dist/dom/features/forward-ref/stub.d.ts +1 -0
- package/dist/dom/features/forward-ref/stub.js +22 -0
- package/dist/dom/features/forward-ref/stub.js.map +7 -0
- package/dist/dom/features/hydration/full.d.ts +61 -0
- package/dist/dom/features/hydration/full.js +264 -0
- package/dist/dom/features/hydration/full.js.map +7 -0
- package/dist/dom/features/hydration/index.d.ts +1 -0
- package/dist/dom/features/hydration/index.js +3 -0
- package/dist/dom/features/hydration/index.js.map +7 -0
- package/dist/dom/features/hydration/stub.d.ts +28 -0
- package/dist/dom/features/hydration/stub.js +66 -0
- package/dist/dom/features/hydration/stub.js.map +7 -0
- package/dist/dom/features/index.d.ts +7 -0
- package/dist/dom/features/index.js +9 -0
- package/dist/dom/features/index.js.map +7 -0
- package/dist/dom/features/lazy/full.d.ts +1 -0
- package/dist/dom/features/lazy/full.js +78 -0
- package/dist/dom/features/lazy/full.js.map +7 -0
- package/dist/dom/features/lazy/index.d.ts +1 -0
- package/dist/dom/features/lazy/index.js +3 -0
- package/dist/dom/features/lazy/index.js.map +7 -0
- package/dist/dom/features/lazy/stub.d.ts +1 -0
- package/dist/dom/features/lazy/stub.js +36 -0
- package/dist/dom/features/lazy/stub.js.map +7 -0
- package/dist/dom/features/memo/full.d.ts +1 -0
- package/dist/dom/features/memo/full.js +59 -0
- package/dist/dom/features/memo/full.js.map +7 -0
- package/dist/dom/features/memo/index.d.ts +1 -0
- package/dist/dom/features/memo/index.js +3 -0
- package/dist/dom/features/memo/index.js.map +7 -0
- package/dist/dom/features/memo/stub.d.ts +1 -0
- package/dist/dom/features/memo/stub.js +36 -0
- package/dist/dom/features/memo/stub.js.map +7 -0
- package/dist/dom/features/portal/full.d.ts +1 -0
- package/dist/dom/features/portal/full.js +19 -0
- package/dist/dom/features/portal/full.js.map +7 -0
- package/dist/dom/features/portal/index.d.ts +1 -0
- package/dist/dom/features/portal/index.js +3 -0
- package/dist/dom/features/portal/index.js.map +7 -0
- package/dist/dom/features/portal/stub.d.ts +1 -0
- package/dist/dom/features/portal/stub.js +7 -0
- package/dist/dom/features/portal/stub.js.map +7 -0
- package/dist/dom/features/suspense/full.d.ts +1 -0
- package/dist/dom/features/suspense/full.js +146 -0
- package/dist/dom/features/suspense/full.js.map +7 -0
- package/dist/dom/features/suspense/index.d.ts +1 -0
- package/dist/dom/features/suspense/index.js +3 -0
- package/dist/dom/features/suspense/index.js.map +7 -0
- package/dist/dom/features/suspense/stub.d.ts +1 -0
- package/dist/dom/features/suspense/stub.js +6 -0
- package/dist/dom/features/suspense/stub.js.map +7 -0
- package/dist/dom/index.d.ts +25 -0
- package/dist/dom/index.js +45 -0
- package/dist/dom/index.js.map +7 -0
- package/dist/dom/portal.d.ts +2 -0
- package/dist/dom/portal.js +15 -0
- package/dist/dom/portal.js.map +7 -0
- package/dist/dom/reconcile.d.ts +40 -0
- package/dist/dom/reconcile.js +795 -0
- package/dist/dom/reconcile.js.map +7 -0
- package/dist/dom/root.d.ts +15 -0
- package/dist/dom/root.js +85 -0
- package/dist/dom/root.js.map +7 -0
- package/dist/dom/test-utils.d.ts +1 -0
- package/dist/dom/test-utils.js +10 -0
- package/dist/dom/test-utils.js.map +7 -0
- package/dist/react/children.d.ts +8 -0
- package/dist/react/children.js +75 -0
- package/dist/react/children.js.map +7 -0
- package/dist/react/class.d.ts +31 -0
- package/dist/react/class.js +40 -0
- package/dist/react/class.js.map +7 -0
- package/dist/react/context.d.ts +27 -0
- package/dist/react/context.js +31 -0
- package/dist/react/context.js.map +7 -0
- package/dist/react/element.d.ts +10 -0
- package/dist/react/element.js +64 -0
- package/dist/react/element.js.map +7 -0
- package/dist/react/hooks.d.ts +37 -0
- package/dist/react/hooks.js +146 -0
- package/dist/react/hooks.js.map +7 -0
- package/dist/react/index.d.ts +76 -0
- package/dist/react/index.js +187 -0
- package/dist/react/index.js.map +7 -0
- package/dist/react/jsx-runtime.d.ts +5 -0
- package/dist/react/jsx-runtime.js +21 -0
- package/dist/react/jsx-runtime.js.map +7 -0
- package/dist/react/memo.d.ts +29 -0
- package/dist/react/memo.js +47 -0
- package/dist/react/memo.js.map +7 -0
- package/dist/react/portal.d.ts +1 -0
- package/dist/react/portal.js +6 -0
- package/dist/react/portal.js.map +7 -0
- package/dist/react/shared-internals.d.ts +33 -0
- package/dist/react/shared-internals.js +29 -0
- package/dist/react/shared-internals.js.map +7 -0
- package/dist/react/suspense.d.ts +15 -0
- package/dist/react/suspense.js +16 -0
- package/dist/react/suspense.js.map +7 -0
- package/dist/scheduler/index.d.ts +44 -0
- package/dist/scheduler/index.js +109 -0
- package/dist/scheduler/index.js.map +7 -0
- package/dist/server/bootstrap-script.d.ts +22 -0
- package/dist/server/bootstrap-script.js +16 -0
- package/dist/server/bootstrap-script.js.map +7 -0
- package/dist/server/dispatcher.d.ts +37 -0
- package/dist/server/dispatcher.js +140 -0
- package/dist/server/dispatcher.js.map +7 -0
- package/dist/server/escape.d.ts +7 -0
- package/dist/server/escape.js +159 -0
- package/dist/server/escape.js.map +7 -0
- package/dist/server/index.d.ts +16 -0
- package/dist/server/index.js +26 -0
- package/dist/server/index.js.map +7 -0
- package/dist/server/renderToString.d.ts +7 -0
- package/dist/server/renderToString.js +29 -0
- package/dist/server/renderToString.js.map +7 -0
- package/dist/server/stream.d.ts +40 -0
- package/dist/server/stream.js +200 -0
- package/dist/server/stream.js.map +7 -0
- package/dist/server/walk.d.ts +33 -0
- package/dist/server/walk.js +298 -0
- package/dist/server/walk.js.map +7 -0
- package/dist/vite/index.d.ts +96 -0
- package/dist/vite/index.js +217 -0
- package/dist/vite/index.js.map +7 -0
- package/package.json +83 -0
- package/src/core/index.ts +2 -0
- package/src/core/internal.ts +107 -0
- package/src/core/types.ts +36 -0
- package/src/dom/_all.ts +54 -0
- package/src/dom/client.ts +4 -0
- package/src/dom/dispatcher.ts +318 -0
- package/src/dom/dom.ts +316 -0
- package/src/dom/event-replay.ts +55 -0
- package/src/dom/features/class/full.ts +104 -0
- package/src/dom/features/class/index.ts +1 -0
- package/src/dom/features/class/stub.ts +65 -0
- package/src/dom/features/context/full.ts +57 -0
- package/src/dom/features/context/index.ts +1 -0
- package/src/dom/features/context/stub.ts +32 -0
- package/src/dom/features/forward-ref/full.ts +54 -0
- package/src/dom/features/forward-ref/index.ts +1 -0
- package/src/dom/features/forward-ref/stub.ts +28 -0
- package/src/dom/features/hydration/full.ts +345 -0
- package/src/dom/features/hydration/index.ts +1 -0
- package/src/dom/features/hydration/stub.ts +72 -0
- package/src/dom/features/index.ts +11 -0
- package/src/dom/features/lazy/full.ts +98 -0
- package/src/dom/features/lazy/index.ts +1 -0
- package/src/dom/features/lazy/stub.ts +45 -0
- package/src/dom/features/memo/full.ts +74 -0
- package/src/dom/features/memo/index.ts +1 -0
- package/src/dom/features/memo/stub.ts +42 -0
- package/src/dom/features/portal/full.ts +22 -0
- package/src/dom/features/portal/index.ts +1 -0
- package/src/dom/features/portal/stub.ts +11 -0
- package/src/dom/features/suspense/full.ts +191 -0
- package/src/dom/features/suspense/index.ts +1 -0
- package/src/dom/features/suspense/stub.ts +12 -0
- package/src/dom/index.ts +33 -0
- package/src/dom/portal.ts +16 -0
- package/src/dom/reconcile.ts +1169 -0
- package/src/dom/root.ts +107 -0
- package/src/dom/test-utils.ts +6 -0
- package/src/react/children.ts +85 -0
- package/src/react/class.ts +56 -0
- package/src/react/context.ts +50 -0
- package/src/react/element.ts +80 -0
- package/src/react/hooks.ts +190 -0
- package/src/react/index.ts +132 -0
- package/src/react/jsx-runtime.ts +16 -0
- package/src/react/memo.ts +45 -0
- package/src/react/portal.ts +1 -0
- package/src/react/shared-internals.ts +79 -0
- package/src/react/suspense.ts +18 -0
- package/src/scheduler/index.ts +124 -0
- package/src/server/bootstrap-script.ts +52 -0
- package/src/server/dispatcher.ts +158 -0
- package/src/server/escape.ts +187 -0
- package/src/server/index.ts +26 -0
- package/src/server/renderToString.ts +33 -0
- package/src/server/stream.ts +302 -0
- package/src/server/walk.ts +448 -0
- package/src/vite/index.ts +401 -0
|
@@ -0,0 +1,795 @@
|
|
|
1
|
+
// packages/redact/src/dom/reconcile.ts
|
|
2
|
+
import {
|
|
3
|
+
FiberTag,
|
|
4
|
+
createFiber,
|
|
5
|
+
REACT_ELEMENT_TYPE,
|
|
6
|
+
REACT_LEGACY_ELEMENT_TYPE,
|
|
7
|
+
REACT_FRAGMENT_TYPE
|
|
8
|
+
} from "../core";
|
|
9
|
+
import {
|
|
10
|
+
ReactSharedInternals,
|
|
11
|
+
REACT_LAZY_TYPE,
|
|
12
|
+
REACT_STRICT_MODE_TYPE,
|
|
13
|
+
REACT_PROFILER_TYPE
|
|
14
|
+
} from "../react";
|
|
15
|
+
import { createHostNode, setProp } from "./dom";
|
|
16
|
+
import { makeDispatcher } from "./dispatcher";
|
|
17
|
+
import {
|
|
18
|
+
adoptHostDom,
|
|
19
|
+
adoptTextDom,
|
|
20
|
+
setHydrationCursor,
|
|
21
|
+
getHydrationCursor,
|
|
22
|
+
clearHydrationCursor,
|
|
23
|
+
findHostParent as findHydrationHost
|
|
24
|
+
} from "./features/hydration";
|
|
25
|
+
var currentRoot = null;
|
|
26
|
+
var flushing = false;
|
|
27
|
+
var isBatching = false;
|
|
28
|
+
var pendingRoots = /* @__PURE__ */ new Set();
|
|
29
|
+
var forceRerenderingFiber = null;
|
|
30
|
+
function scheduleUpdate(fiber) {
|
|
31
|
+
if (fiber.unmounted) return;
|
|
32
|
+
const root = findRoot(fiber);
|
|
33
|
+
if (!root) return;
|
|
34
|
+
root.pending.add(fiber);
|
|
35
|
+
fiber.dirty = true;
|
|
36
|
+
pendingRoots.add(root);
|
|
37
|
+
if (isBatching) return;
|
|
38
|
+
if (!root.scheduled) {
|
|
39
|
+
root.scheduled = true;
|
|
40
|
+
queueMicrotask(flushPending);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
function flushSyncWork(fn) {
|
|
44
|
+
const wasBatching = isBatching;
|
|
45
|
+
isBatching = true;
|
|
46
|
+
try {
|
|
47
|
+
fn();
|
|
48
|
+
} finally {
|
|
49
|
+
isBatching = wasBatching;
|
|
50
|
+
}
|
|
51
|
+
flushPending();
|
|
52
|
+
}
|
|
53
|
+
function batchedUpdates(fn) {
|
|
54
|
+
const wasBatching = isBatching;
|
|
55
|
+
isBatching = true;
|
|
56
|
+
try {
|
|
57
|
+
return fn();
|
|
58
|
+
} finally {
|
|
59
|
+
isBatching = wasBatching;
|
|
60
|
+
if (!wasBatching) flushPending();
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
function flushPending() {
|
|
64
|
+
if (flushing) return;
|
|
65
|
+
flushing = true;
|
|
66
|
+
try {
|
|
67
|
+
let guard = 0;
|
|
68
|
+
while (pendingRoots.size > 0) {
|
|
69
|
+
if (++guard > 50) {
|
|
70
|
+
throw new Error("flushPending exceeded 50 iterations \u2014 suspected infinite update loop.");
|
|
71
|
+
}
|
|
72
|
+
const roots = [...pendingRoots];
|
|
73
|
+
pendingRoots.clear();
|
|
74
|
+
for (const root of roots) {
|
|
75
|
+
root.scheduled = false;
|
|
76
|
+
const pending = [...root.pending];
|
|
77
|
+
root.pending.clear();
|
|
78
|
+
pending.sort((a, b) => fiberDepth(a) - fiberDepth(b));
|
|
79
|
+
for (const fiber of pending) {
|
|
80
|
+
rerenderFiber(fiber, root);
|
|
81
|
+
}
|
|
82
|
+
runEffects(root);
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
} finally {
|
|
86
|
+
flushing = false;
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
function fiberDepth(fiber) {
|
|
90
|
+
let d = 0;
|
|
91
|
+
let p = fiber.parent;
|
|
92
|
+
while (p) {
|
|
93
|
+
d++;
|
|
94
|
+
p = p.parent;
|
|
95
|
+
}
|
|
96
|
+
return d;
|
|
97
|
+
}
|
|
98
|
+
function findRoot(fiber) {
|
|
99
|
+
let f = fiber;
|
|
100
|
+
while (f) {
|
|
101
|
+
if (f.root) return f.root;
|
|
102
|
+
f = f.parent;
|
|
103
|
+
}
|
|
104
|
+
return null;
|
|
105
|
+
}
|
|
106
|
+
function renderRoot(root, children) {
|
|
107
|
+
const rootFiber = root.current;
|
|
108
|
+
rootFiber.pendingProps = { children };
|
|
109
|
+
currentRoot = root;
|
|
110
|
+
try {
|
|
111
|
+
reconcileChildren(rootFiber, childrenToArray(children), root.container, null);
|
|
112
|
+
rootFiber.memoizedProps = rootFiber.pendingProps;
|
|
113
|
+
rootFiber.dirty = false;
|
|
114
|
+
} finally {
|
|
115
|
+
currentRoot = null;
|
|
116
|
+
}
|
|
117
|
+
runEffects(root);
|
|
118
|
+
}
|
|
119
|
+
function rerenderFiber(fiber, root) {
|
|
120
|
+
if (!fiber.dirty) return;
|
|
121
|
+
if (fiber.unmounted) return;
|
|
122
|
+
fiber.dirty = false;
|
|
123
|
+
currentRoot = root;
|
|
124
|
+
const resumeHydration = fiber.memoizedState && fiber.memoizedState._pendingHydration === true;
|
|
125
|
+
const prevHydrating = root.hydrating;
|
|
126
|
+
if (resumeHydration) {
|
|
127
|
+
delete fiber.memoizedState._pendingHydration;
|
|
128
|
+
root.hydrating = true;
|
|
129
|
+
}
|
|
130
|
+
const prevForcing = forceRerenderingFiber;
|
|
131
|
+
forceRerenderingFiber = fiber;
|
|
132
|
+
try {
|
|
133
|
+
renderFiber(fiber, getHostParent(fiber), getAnchor(fiber));
|
|
134
|
+
} finally {
|
|
135
|
+
forceRerenderingFiber = prevForcing;
|
|
136
|
+
if (resumeHydration) {
|
|
137
|
+
root.hydrating = prevHydrating;
|
|
138
|
+
clearHydrationCursor(fiber);
|
|
139
|
+
}
|
|
140
|
+
currentRoot = null;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
function isTextChild(child) {
|
|
144
|
+
return child.$$typeof === void 0;
|
|
145
|
+
}
|
|
146
|
+
function childrenToArray(children) {
|
|
147
|
+
const out = [];
|
|
148
|
+
pushChildren(children, out);
|
|
149
|
+
return out;
|
|
150
|
+
}
|
|
151
|
+
function pushChildren(node, out) {
|
|
152
|
+
if (node == null || typeof node === "boolean") return;
|
|
153
|
+
if (typeof node === "string" || typeof node === "number") {
|
|
154
|
+
if (node === "") return;
|
|
155
|
+
out.push({ _text: "" + node });
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
if (Array.isArray(node)) {
|
|
159
|
+
for (let i = 0; i < node.length; i++) pushChildren(node[i], out);
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
if (isIterable(node)) {
|
|
163
|
+
for (const item of node) pushChildren(item, out);
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
if (typeof node === "object") {
|
|
167
|
+
const t = node.$$typeof;
|
|
168
|
+
if (ACCEPTED_ELEMENT_MARKERS.has(t)) {
|
|
169
|
+
out.push(node);
|
|
170
|
+
return;
|
|
171
|
+
}
|
|
172
|
+
if (t === REACT_LAZY_TYPE) {
|
|
173
|
+
const lazy = node;
|
|
174
|
+
const resolved = lazy._init(lazy._payload);
|
|
175
|
+
pushChildren(resolved, out);
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
function isIterable(obj) {
|
|
181
|
+
return obj != null && typeof obj !== "string" && typeof obj[Symbol.iterator] === "function";
|
|
182
|
+
}
|
|
183
|
+
function sameType(fiber, child) {
|
|
184
|
+
if (!child) return false;
|
|
185
|
+
if (isTextChild(child)) return fiber.tag === FiberTag.Text;
|
|
186
|
+
return fiber.type === child.type && sameKey(fiber.key, child.key);
|
|
187
|
+
}
|
|
188
|
+
function sameKey(a, b) {
|
|
189
|
+
return (a ?? null) === (b ?? null);
|
|
190
|
+
}
|
|
191
|
+
function fiberFromChild(child, parent) {
|
|
192
|
+
if (!child) return createFiber(FiberTag.Fragment, null, null);
|
|
193
|
+
if (isTextChild(child)) {
|
|
194
|
+
const f2 = createFiber(FiberTag.Text, null, null);
|
|
195
|
+
f2.pendingProps = child._text;
|
|
196
|
+
f2.parent = parent;
|
|
197
|
+
return f2;
|
|
198
|
+
}
|
|
199
|
+
const type = child.type;
|
|
200
|
+
let tag = FiberTag.Host;
|
|
201
|
+
const marker = type && type.$$typeof;
|
|
202
|
+
if (typeof type === "string") tag = FiberTag.Host;
|
|
203
|
+
else if (type === REACT_FRAGMENT_TYPE) tag = FiberTag.Fragment;
|
|
204
|
+
else if (type === REACT_STRICT_MODE_TYPE || type === REACT_PROFILER_TYPE) tag = FiberTag.Fragment;
|
|
205
|
+
else {
|
|
206
|
+
let matched = null;
|
|
207
|
+
for (const m of TYPE_MATCHERS) {
|
|
208
|
+
matched = m(type, marker);
|
|
209
|
+
if (matched !== null) break;
|
|
210
|
+
}
|
|
211
|
+
if (matched !== null) tag = matched;
|
|
212
|
+
else if (typeof type === "function") {
|
|
213
|
+
tag = type.prototype && type.prototype.isReactComponent ? FiberTag.Class : FiberTag.Function;
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
const f = createFiber(tag, type, child.key ?? null);
|
|
217
|
+
f.ref = child.ref ?? null;
|
|
218
|
+
f.pendingProps = child.props;
|
|
219
|
+
f.parent = parent;
|
|
220
|
+
return f;
|
|
221
|
+
}
|
|
222
|
+
function reconcileChildren(parent, newChildren, domParent, anchor) {
|
|
223
|
+
const existing = collectChildren(parent);
|
|
224
|
+
const keyed = /* @__PURE__ */ new Map();
|
|
225
|
+
for (const f of existing) {
|
|
226
|
+
if (f.key != null) keyed.set("k" + f.key, f);
|
|
227
|
+
}
|
|
228
|
+
let prevNewFiber = null;
|
|
229
|
+
const claimed = /* @__PURE__ */ new Set();
|
|
230
|
+
let structurallyChanged = false;
|
|
231
|
+
let existingIdx = 0;
|
|
232
|
+
let unkeyedOld = 0;
|
|
233
|
+
for (const f of existing) if (f.key == null) unkeyedOld++;
|
|
234
|
+
let unkeyedNew = 0;
|
|
235
|
+
for (const c of newChildren) if (c != null) unkeyedNew++;
|
|
236
|
+
let budget = unkeyedNew - unkeyedOld;
|
|
237
|
+
for (let i = 0; i < newChildren.length; i++) {
|
|
238
|
+
const child = newChildren[i];
|
|
239
|
+
if (child == null) continue;
|
|
240
|
+
let match = null;
|
|
241
|
+
if (child && typeof child === "object" && !isTextChild(child) && child.key != null) {
|
|
242
|
+
const k = "k" + child.key;
|
|
243
|
+
const m = keyed.get(k);
|
|
244
|
+
if (m && m.type === child.type) {
|
|
245
|
+
match = m;
|
|
246
|
+
keyed.delete(k);
|
|
247
|
+
}
|
|
248
|
+
}
|
|
249
|
+
if (!match) {
|
|
250
|
+
while (existingIdx < existing.length) {
|
|
251
|
+
const cand = existing[existingIdx];
|
|
252
|
+
if (claimed.has(cand) || cand.key != null) {
|
|
253
|
+
existingIdx++;
|
|
254
|
+
continue;
|
|
255
|
+
}
|
|
256
|
+
if (sameType(cand, child)) {
|
|
257
|
+
match = cand;
|
|
258
|
+
existingIdx++;
|
|
259
|
+
break;
|
|
260
|
+
}
|
|
261
|
+
if (budget > 0) {
|
|
262
|
+
break;
|
|
263
|
+
}
|
|
264
|
+
existingIdx++;
|
|
265
|
+
budget++;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
if (match && existing[i] !== match) structurallyChanged = true;
|
|
269
|
+
let fiber;
|
|
270
|
+
if (match) {
|
|
271
|
+
claimed.add(match);
|
|
272
|
+
fiber = match;
|
|
273
|
+
if (isTextChild(child)) {
|
|
274
|
+
fiber.pendingProps = child._text;
|
|
275
|
+
} else {
|
|
276
|
+
fiber.type = child.type;
|
|
277
|
+
fiber.pendingProps = child.props;
|
|
278
|
+
fiber.ref = child.ref ?? null;
|
|
279
|
+
}
|
|
280
|
+
} else {
|
|
281
|
+
fiber = fiberFromChild(child, parent);
|
|
282
|
+
structurallyChanged = true;
|
|
283
|
+
if (budget > 0) budget--;
|
|
284
|
+
}
|
|
285
|
+
fiber.parent = parent;
|
|
286
|
+
fiber.sibling = null;
|
|
287
|
+
if (prevNewFiber) prevNewFiber.sibling = fiber;
|
|
288
|
+
else parent.child = fiber;
|
|
289
|
+
prevNewFiber = fiber;
|
|
290
|
+
renderFiber(fiber, domParent, anchor);
|
|
291
|
+
}
|
|
292
|
+
if (!prevNewFiber) parent.child = null;
|
|
293
|
+
else prevNewFiber.sibling = null;
|
|
294
|
+
const parentIsHeadHost = parent.tag === FiberTag.Host && typeof parent.type === "string" && parent.type.toLowerCase() === "head";
|
|
295
|
+
if (!parentIsHeadHost) {
|
|
296
|
+
for (const f of existing) {
|
|
297
|
+
if (!claimed.has(f)) {
|
|
298
|
+
unmountFiber(f, domParent);
|
|
299
|
+
structurallyChanged = true;
|
|
300
|
+
}
|
|
301
|
+
}
|
|
302
|
+
for (const f of keyed.values()) {
|
|
303
|
+
if (!claimed.has(f)) {
|
|
304
|
+
unmountFiber(f, domParent);
|
|
305
|
+
structurallyChanged = true;
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
const parentIsHead = domParent.nodeType === 1 && domParent.tagName.toLowerCase() === "head";
|
|
310
|
+
if (structurallyChanged && !currentRoot?.hydrating && !parentIsHead) {
|
|
311
|
+
placeChildrenInOrder(parent, domParent, anchor);
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
function placeChildrenInOrder(parent, domParent, anchor) {
|
|
315
|
+
const doms = [];
|
|
316
|
+
let c = parent.child;
|
|
317
|
+
while (c) {
|
|
318
|
+
collectHostDoms(c, doms);
|
|
319
|
+
c = c.sibling;
|
|
320
|
+
}
|
|
321
|
+
if (doms.length > 0) {
|
|
322
|
+
let current = doms[0];
|
|
323
|
+
let inOrder = current.parentNode === domParent;
|
|
324
|
+
for (let i = 1; inOrder && i < doms.length; i++) {
|
|
325
|
+
current = current.nextSibling;
|
|
326
|
+
while (current && !doms.includes(current)) {
|
|
327
|
+
current = current.nextSibling;
|
|
328
|
+
}
|
|
329
|
+
if (current !== doms[i]) inOrder = false;
|
|
330
|
+
}
|
|
331
|
+
if (inOrder) return;
|
|
332
|
+
}
|
|
333
|
+
for (let i = doms.length - 1; i >= 0; i--) {
|
|
334
|
+
const d = doms[i];
|
|
335
|
+
const targetNext = i + 1 < doms.length ? doms[i + 1] : anchor;
|
|
336
|
+
if (d.parentNode !== domParent || d.nextSibling !== targetNext) {
|
|
337
|
+
domParent.insertBefore(d, targetNext);
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
}
|
|
341
|
+
function collectHostDoms(fiber, out) {
|
|
342
|
+
if (fiber.tag === FiberTag.Host || fiber.tag === FiberTag.Text) {
|
|
343
|
+
if (fiber.dom) out.push(fiber.dom);
|
|
344
|
+
return;
|
|
345
|
+
}
|
|
346
|
+
if (fiber.tag === FiberTag.Portal) return;
|
|
347
|
+
let c = fiber.child;
|
|
348
|
+
while (c) {
|
|
349
|
+
collectHostDoms(c, out);
|
|
350
|
+
c = c.sibling;
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
function collectChildren(parent) {
|
|
354
|
+
const out = [];
|
|
355
|
+
let c = parent.child;
|
|
356
|
+
while (c) {
|
|
357
|
+
out.push(c);
|
|
358
|
+
c = c.sibling;
|
|
359
|
+
}
|
|
360
|
+
return out;
|
|
361
|
+
}
|
|
362
|
+
var RENDERERS = new Array(13);
|
|
363
|
+
var ACCEPTED_ELEMENT_MARKERS = /* @__PURE__ */ new Set([
|
|
364
|
+
REACT_ELEMENT_TYPE,
|
|
365
|
+
REACT_LEGACY_ELEMENT_TYPE
|
|
366
|
+
]);
|
|
367
|
+
var TYPE_MATCHERS = [];
|
|
368
|
+
function registerRenderer(tag, fn) {
|
|
369
|
+
RENDERERS[tag] = fn;
|
|
370
|
+
}
|
|
371
|
+
function registerTypeMatcher(m) {
|
|
372
|
+
TYPE_MATCHERS.push(m);
|
|
373
|
+
}
|
|
374
|
+
function registerElementMarker(sym) {
|
|
375
|
+
ACCEPTED_ELEMENT_MARKERS.add(sym);
|
|
376
|
+
}
|
|
377
|
+
function getCurrentRoot() {
|
|
378
|
+
return currentRoot;
|
|
379
|
+
}
|
|
380
|
+
function withCurrentRoot(root, fn) {
|
|
381
|
+
const prev = currentRoot;
|
|
382
|
+
currentRoot = root;
|
|
383
|
+
try {
|
|
384
|
+
return fn();
|
|
385
|
+
} finally {
|
|
386
|
+
currentRoot = prev;
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
function getForceRerenderingFiber() {
|
|
390
|
+
return forceRerenderingFiber;
|
|
391
|
+
}
|
|
392
|
+
registerRenderer(FiberTag.Text, renderText);
|
|
393
|
+
registerRenderer(FiberTag.Host, renderHost);
|
|
394
|
+
registerRenderer(FiberTag.Function, renderFunction);
|
|
395
|
+
registerRenderer(FiberTag.Fragment, renderFragment);
|
|
396
|
+
function renderFiber(fiber, domParent, anchor) {
|
|
397
|
+
const fn = RENDERERS[fiber.tag];
|
|
398
|
+
if (fn) fn(fiber, domParent, anchor);
|
|
399
|
+
}
|
|
400
|
+
function renderText(fiber, domParent, anchor) {
|
|
401
|
+
const text = fiber.pendingProps;
|
|
402
|
+
if (!fiber.dom) {
|
|
403
|
+
const hydrated = currentRoot?.hydrating ? adoptTextDom(fiber, fiber.parent, text) : false;
|
|
404
|
+
if (!hydrated) {
|
|
405
|
+
fiber.dom = document.createTextNode(text);
|
|
406
|
+
insertInto(domParent, fiber.dom, anchor);
|
|
407
|
+
}
|
|
408
|
+
} else if (fiber.dom.data !== text) {
|
|
409
|
+
;
|
|
410
|
+
fiber.dom.data = text;
|
|
411
|
+
}
|
|
412
|
+
fiber.memoizedProps = text;
|
|
413
|
+
}
|
|
414
|
+
function renderHost(fiber, domParent, anchor) {
|
|
415
|
+
const props = fiber.pendingProps ?? {};
|
|
416
|
+
const prev = fiber.memoizedProps ?? {};
|
|
417
|
+
const type = fiber.type;
|
|
418
|
+
const isSvg = type === "svg" || domParent.namespaceURI === "http://www.w3.org/2000/svg";
|
|
419
|
+
const isSelect = type === "select";
|
|
420
|
+
const deferredSelectValue = isSelect && (props.value !== void 0 || props.defaultValue !== void 0) ? props.value !== void 0 ? props.value : props.defaultValue : void 0;
|
|
421
|
+
if (!fiber.dom) {
|
|
422
|
+
const hydrated = currentRoot?.hydrating ? adoptHostDom(fiber, fiber.parent) : false;
|
|
423
|
+
if (!hydrated) {
|
|
424
|
+
fiber.dom = createHostNode(type, isSvg);
|
|
425
|
+
for (const k in props) {
|
|
426
|
+
if (isSelect && (k === "value" || k === "defaultValue")) continue;
|
|
427
|
+
if (isEventProp(k)) continue;
|
|
428
|
+
setProp(fiber.dom, k, props[k], void 0, isSvg);
|
|
429
|
+
}
|
|
430
|
+
for (const k in props) {
|
|
431
|
+
if (!isEventProp(k)) continue;
|
|
432
|
+
setProp(fiber.dom, k, props[k], void 0, isSvg);
|
|
433
|
+
}
|
|
434
|
+
insertInto(domParent, fiber.dom, anchor);
|
|
435
|
+
}
|
|
436
|
+
attachRef(fiber, fiber.dom);
|
|
437
|
+
} else {
|
|
438
|
+
const el = fiber.dom;
|
|
439
|
+
for (const k in prev) {
|
|
440
|
+
if (!(k in props)) setProp(el, k, void 0, prev[k], isSvg);
|
|
441
|
+
}
|
|
442
|
+
for (const k in props) {
|
|
443
|
+
if (isSelect && (k === "value" || k === "defaultValue")) continue;
|
|
444
|
+
if (isEventProp(k)) continue;
|
|
445
|
+
if (prev[k] !== props[k]) setProp(el, k, props[k], prev[k], isSvg);
|
|
446
|
+
}
|
|
447
|
+
for (const k in props) {
|
|
448
|
+
if (!isEventProp(k)) continue;
|
|
449
|
+
if (prev[k] !== props[k]) setProp(el, k, props[k], prev[k], isSvg);
|
|
450
|
+
}
|
|
451
|
+
if (prev !== props) syncRefIfChanged(fiber, fiber.dom);
|
|
452
|
+
}
|
|
453
|
+
reconcileChildren(fiber, childrenToArray(props.children), fiber.dom, null);
|
|
454
|
+
if (currentRoot?.hydrating) {
|
|
455
|
+
const parentTag = fiber.type.toLowerCase();
|
|
456
|
+
if (parentTag !== "head" && parentTag !== "html") {
|
|
457
|
+
const cursor = getHydrationCursor(fiber);
|
|
458
|
+
if (cursor) {
|
|
459
|
+
const leftover = cursor.remaining().filter(
|
|
460
|
+
(n) => n.nodeType === 1 || n.nodeType === 3
|
|
461
|
+
);
|
|
462
|
+
if (leftover.length > 0 && currentRoot.onRecoverableError) {
|
|
463
|
+
currentRoot.onRecoverableError(
|
|
464
|
+
new Error(
|
|
465
|
+
`Hydration mismatch: server rendered ${leftover.length} extra ${leftover.length === 1 ? "node" : "nodes"} inside <${parentTag}> that the client tree did not.`
|
|
466
|
+
)
|
|
467
|
+
);
|
|
468
|
+
for (const n of leftover) n.parentNode?.removeChild(n);
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
if (isSelect && deferredSelectValue !== void 0) {
|
|
474
|
+
const select = fiber.dom;
|
|
475
|
+
if (Array.isArray(deferredSelectValue)) {
|
|
476
|
+
const asStrings = deferredSelectValue.map((v) => "" + v);
|
|
477
|
+
for (const opt of Array.from(select.options)) {
|
|
478
|
+
opt.selected = asStrings.includes(opt.value);
|
|
479
|
+
}
|
|
480
|
+
} else {
|
|
481
|
+
select.value = "" + deferredSelectValue;
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
fiber.memoizedProps = props;
|
|
485
|
+
}
|
|
486
|
+
function renderFunction(fiber, domParent, anchor) {
|
|
487
|
+
const prevDispatcher = ReactSharedInternals.H;
|
|
488
|
+
const prevFiber = ReactSharedInternals.currentFiber;
|
|
489
|
+
const prevHook = ReactSharedInternals.currentHook;
|
|
490
|
+
const prevIndex = ReactSharedInternals.hookIndex;
|
|
491
|
+
ReactSharedInternals.H = makeDispatcher();
|
|
492
|
+
ReactSharedInternals.currentFiber = fiber;
|
|
493
|
+
ReactSharedInternals.currentHook = null;
|
|
494
|
+
ReactSharedInternals.hookIndex = 0;
|
|
495
|
+
let rendered;
|
|
496
|
+
let deferredForHydration = false;
|
|
497
|
+
try {
|
|
498
|
+
rendered = fiber.type(fiber.pendingProps ?? {});
|
|
499
|
+
} catch (e) {
|
|
500
|
+
if (isThenable(e)) {
|
|
501
|
+
if (currentRoot?.hydrating) {
|
|
502
|
+
const hostParent = findHydrationHost(fiber);
|
|
503
|
+
const inheritedCursor = getHydrationCursor(hostParent);
|
|
504
|
+
if (inheritedCursor) {
|
|
505
|
+
setHydrationCursor(fiber, inheritedCursor);
|
|
506
|
+
}
|
|
507
|
+
fiber.memoizedState = {
|
|
508
|
+
...fiber.memoizedState ?? {},
|
|
509
|
+
_pendingHydration: true
|
|
510
|
+
};
|
|
511
|
+
let sus = fiber.parent;
|
|
512
|
+
while (sus && sus.tag !== FiberTag.Suspense) sus = sus.parent;
|
|
513
|
+
if (sus && sus.memoizedState) {
|
|
514
|
+
;
|
|
515
|
+
sus.memoizedState._awaitingLazyHydration = true;
|
|
516
|
+
}
|
|
517
|
+
const clearAwait = () => {
|
|
518
|
+
if (sus && sus.memoizedState) {
|
|
519
|
+
;
|
|
520
|
+
sus.memoizedState._awaitingLazyHydration = false;
|
|
521
|
+
}
|
|
522
|
+
scheduleUpdate(fiber);
|
|
523
|
+
};
|
|
524
|
+
e.then(clearAwait, clearAwait);
|
|
525
|
+
deferredForHydration = true;
|
|
526
|
+
} else {
|
|
527
|
+
CAPABILITIES.handleSuspended(fiber, e);
|
|
528
|
+
rendered = null;
|
|
529
|
+
}
|
|
530
|
+
} else {
|
|
531
|
+
handleErrorInRender(fiber, e);
|
|
532
|
+
return;
|
|
533
|
+
}
|
|
534
|
+
} finally {
|
|
535
|
+
ReactSharedInternals.H = prevDispatcher;
|
|
536
|
+
ReactSharedInternals.currentFiber = prevFiber;
|
|
537
|
+
ReactSharedInternals.currentHook = prevHook;
|
|
538
|
+
ReactSharedInternals.hookIndex = prevIndex;
|
|
539
|
+
}
|
|
540
|
+
if (deferredForHydration) return;
|
|
541
|
+
reconcileChildren(fiber, childrenToArray(rendered), domParent, anchor);
|
|
542
|
+
fiber.memoizedProps = fiber.pendingProps;
|
|
543
|
+
}
|
|
544
|
+
function renderFragment(fiber, domParent, anchor) {
|
|
545
|
+
const props = fiber.pendingProps ?? {};
|
|
546
|
+
reconcileChildren(fiber, childrenToArray(props.children), domParent, anchor);
|
|
547
|
+
fiber.memoizedProps = props;
|
|
548
|
+
}
|
|
549
|
+
function defaultHandleSuspended(fiber, thenable) {
|
|
550
|
+
thenable.then(
|
|
551
|
+
() => scheduleUpdate(fiber),
|
|
552
|
+
() => scheduleUpdate(fiber)
|
|
553
|
+
);
|
|
554
|
+
}
|
|
555
|
+
var CAPABILITIES = {
|
|
556
|
+
handleSuspended: defaultHandleSuspended,
|
|
557
|
+
readContext: defaultReadContext
|
|
558
|
+
};
|
|
559
|
+
function installCapability(name, fn) {
|
|
560
|
+
CAPABILITIES[name] = fn;
|
|
561
|
+
}
|
|
562
|
+
function handleSuspended(fiber, thenable) {
|
|
563
|
+
CAPABILITIES.handleSuspended(fiber, thenable);
|
|
564
|
+
}
|
|
565
|
+
function handleErrorInRender(fiber, err) {
|
|
566
|
+
let f = fiber.parent;
|
|
567
|
+
while (f) {
|
|
568
|
+
if (f.tag === FiberTag.Class) {
|
|
569
|
+
const Ctor = f.type;
|
|
570
|
+
const instance = f.stateNode;
|
|
571
|
+
if (Ctor.getDerivedStateFromError) {
|
|
572
|
+
const update = Ctor.getDerivedStateFromError(err);
|
|
573
|
+
instance.state = { ...instance.state, ...update };
|
|
574
|
+
}
|
|
575
|
+
if (instance.componentDidCatch) {
|
|
576
|
+
try {
|
|
577
|
+
instance.componentDidCatch(err, { componentStack: "" });
|
|
578
|
+
} catch {
|
|
579
|
+
}
|
|
580
|
+
}
|
|
581
|
+
scheduleUpdate(f);
|
|
582
|
+
return;
|
|
583
|
+
}
|
|
584
|
+
f = f.parent;
|
|
585
|
+
}
|
|
586
|
+
if (currentRoot?.onUncaughtError) currentRoot.onUncaughtError(err);
|
|
587
|
+
else throw err;
|
|
588
|
+
}
|
|
589
|
+
function isThenable(x) {
|
|
590
|
+
return x != null && typeof x.then === "function";
|
|
591
|
+
}
|
|
592
|
+
function unmountFiber(fiber, domParent) {
|
|
593
|
+
fiber.unmounted = true;
|
|
594
|
+
let c = fiber.child;
|
|
595
|
+
while (c) {
|
|
596
|
+
const next = c.sibling;
|
|
597
|
+
unmountFiber(c, fiber.tag === FiberTag.Host ? fiber.dom : domParent);
|
|
598
|
+
c = next;
|
|
599
|
+
}
|
|
600
|
+
fiber.child = null;
|
|
601
|
+
if (fiber.cleanups) {
|
|
602
|
+
for (const cleanup of fiber.cleanups) {
|
|
603
|
+
try {
|
|
604
|
+
cleanup();
|
|
605
|
+
} catch (e) {
|
|
606
|
+
if (currentRoot?.onRecoverableError) currentRoot.onRecoverableError(e);
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
fiber.cleanups = null;
|
|
610
|
+
}
|
|
611
|
+
if (fiber.tag === FiberTag.Class && fiber.stateNode?.componentWillUnmount) {
|
|
612
|
+
try {
|
|
613
|
+
fiber.stateNode.componentWillUnmount();
|
|
614
|
+
} catch (e) {
|
|
615
|
+
if (currentRoot?.onRecoverableError) currentRoot.onRecoverableError(e);
|
|
616
|
+
}
|
|
617
|
+
fiber.stateNode._fiber = null;
|
|
618
|
+
fiber.stateNode._enqueueUpdate = null;
|
|
619
|
+
fiber.stateNode._forceUpdate = null;
|
|
620
|
+
}
|
|
621
|
+
if (fiber.ref) detachRef(fiber.ref);
|
|
622
|
+
if (fiber.tag === FiberTag.Host && fiber.dom && fiber.dom.parentNode) {
|
|
623
|
+
fiber.dom.parentNode.removeChild(fiber.dom);
|
|
624
|
+
} else if (fiber.tag === FiberTag.Text && fiber.dom && fiber.dom.parentNode) {
|
|
625
|
+
fiber.dom.parentNode.removeChild(fiber.dom);
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
function unmountAllChildren(parent, domParent) {
|
|
629
|
+
let c = parent.child;
|
|
630
|
+
while (c) {
|
|
631
|
+
const next = c.sibling;
|
|
632
|
+
unmountFiber(c, domParent);
|
|
633
|
+
c = next;
|
|
634
|
+
}
|
|
635
|
+
parent.child = null;
|
|
636
|
+
}
|
|
637
|
+
function insertInto(parent, node, anchor) {
|
|
638
|
+
if (anchor && anchor.parentNode === parent) {
|
|
639
|
+
parent.insertBefore(node, anchor);
|
|
640
|
+
} else {
|
|
641
|
+
parent.appendChild(node);
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
function getHostParent(fiber) {
|
|
645
|
+
let p = fiber.parent;
|
|
646
|
+
while (p) {
|
|
647
|
+
if (p.tag === FiberTag.Host) return p.dom;
|
|
648
|
+
if (p.tag === FiberTag.Root)
|
|
649
|
+
return p.stateNode || p.dom || p.root?.container;
|
|
650
|
+
if (p.tag === FiberTag.Portal) {
|
|
651
|
+
const props = p.pendingProps ?? p.memoizedProps;
|
|
652
|
+
return props?.container || p.stateNode || p.dom || p.root?.container;
|
|
653
|
+
}
|
|
654
|
+
p = p.parent;
|
|
655
|
+
}
|
|
656
|
+
throw new Error("No host parent found.");
|
|
657
|
+
}
|
|
658
|
+
function getAnchor(fiber) {
|
|
659
|
+
let f = fiber.sibling;
|
|
660
|
+
while (f) {
|
|
661
|
+
const d = firstDomNode(f);
|
|
662
|
+
if (d) return d;
|
|
663
|
+
f = f.sibling;
|
|
664
|
+
}
|
|
665
|
+
let p = fiber.parent;
|
|
666
|
+
while (p && p.tag !== FiberTag.Host && p.tag !== FiberTag.Root && p.tag !== FiberTag.Portal) {
|
|
667
|
+
if (p.sibling) {
|
|
668
|
+
const d = firstDomNode(p.sibling);
|
|
669
|
+
if (d) return d;
|
|
670
|
+
}
|
|
671
|
+
p = p.parent;
|
|
672
|
+
}
|
|
673
|
+
return null;
|
|
674
|
+
}
|
|
675
|
+
function firstDomNode(fiber) {
|
|
676
|
+
if (fiber.tag === FiberTag.Host || fiber.tag === FiberTag.Text) return fiber.dom;
|
|
677
|
+
let c = fiber.child;
|
|
678
|
+
while (c) {
|
|
679
|
+
const d = firstDomNode(c);
|
|
680
|
+
if (d) return d;
|
|
681
|
+
c = c.sibling;
|
|
682
|
+
}
|
|
683
|
+
return null;
|
|
684
|
+
}
|
|
685
|
+
function readContext(fiber, ctx) {
|
|
686
|
+
return CAPABILITIES.readContext(fiber, ctx);
|
|
687
|
+
}
|
|
688
|
+
function defaultReadContext(_fiber, ctx) {
|
|
689
|
+
return ctx._currentValue;
|
|
690
|
+
}
|
|
691
|
+
function attachRef(fiber, value) {
|
|
692
|
+
const ref = fiber.ref ?? (fiber.pendingProps?.ref ?? null);
|
|
693
|
+
if (!ref) return;
|
|
694
|
+
if (typeof ref === "function") {
|
|
695
|
+
const cleanup = ref(value);
|
|
696
|
+
if (typeof cleanup === "function") {
|
|
697
|
+
fiber.cleanups ||= [];
|
|
698
|
+
fiber.cleanups.push(cleanup);
|
|
699
|
+
} else {
|
|
700
|
+
fiber.cleanups ||= [];
|
|
701
|
+
fiber.cleanups.push(() => ref(null));
|
|
702
|
+
}
|
|
703
|
+
} else {
|
|
704
|
+
ref.current = value;
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
function syncRefIfChanged(fiber, value) {
|
|
708
|
+
const ref = fiber.ref ?? (fiber.pendingProps?.ref ?? null);
|
|
709
|
+
if (!ref) return;
|
|
710
|
+
if (typeof ref === "object" && ref.current !== value) ref.current = value;
|
|
711
|
+
}
|
|
712
|
+
function detachRef(ref) {
|
|
713
|
+
if (typeof ref === "function") {
|
|
714
|
+
try {
|
|
715
|
+
ref(null);
|
|
716
|
+
} catch {
|
|
717
|
+
}
|
|
718
|
+
} else if (ref && typeof ref === "object") {
|
|
719
|
+
ref.current = null;
|
|
720
|
+
}
|
|
721
|
+
}
|
|
722
|
+
var pendingEffects = [];
|
|
723
|
+
var pendingLayoutEffects = [];
|
|
724
|
+
var pendingLifecycles = [];
|
|
725
|
+
function enqueueEffect(fiber, effect) {
|
|
726
|
+
if (effect.tag === "layout" || effect.tag === "insertion") {
|
|
727
|
+
pendingLayoutEffects.push({ fiber, effect });
|
|
728
|
+
} else {
|
|
729
|
+
pendingEffects.push({ fiber, effect });
|
|
730
|
+
}
|
|
731
|
+
}
|
|
732
|
+
function scheduleLifecycle(fiber, fn) {
|
|
733
|
+
pendingLifecycles.push({ fiber, fn });
|
|
734
|
+
}
|
|
735
|
+
function runEffects(root) {
|
|
736
|
+
while (pendingLayoutEffects.length) {
|
|
737
|
+
const { fiber, effect } = pendingLayoutEffects.shift();
|
|
738
|
+
runEffect(fiber, effect, root);
|
|
739
|
+
}
|
|
740
|
+
while (pendingLifecycles.length) {
|
|
741
|
+
const { fn } = pendingLifecycles.shift();
|
|
742
|
+
try {
|
|
743
|
+
fn();
|
|
744
|
+
} catch (e) {
|
|
745
|
+
if (root.onCaughtError) root.onCaughtError(e);
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
if (pendingEffects.length) {
|
|
749
|
+
const batch = pendingEffects.splice(0);
|
|
750
|
+
queueMicrotask(() => {
|
|
751
|
+
for (const { fiber, effect } of batch) runEffect(fiber, effect, root);
|
|
752
|
+
});
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
function runEffect(fiber, effect, root) {
|
|
756
|
+
try {
|
|
757
|
+
const cleanup = effect.create();
|
|
758
|
+
effect.destroy = typeof cleanup === "function" ? cleanup : void 0;
|
|
759
|
+
if (effect.destroy) {
|
|
760
|
+
fiber.cleanups ||= [];
|
|
761
|
+
fiber.cleanups.push(effect.destroy);
|
|
762
|
+
}
|
|
763
|
+
} catch (e) {
|
|
764
|
+
if (root.onCaughtError) root.onCaughtError(e);
|
|
765
|
+
}
|
|
766
|
+
}
|
|
767
|
+
function isEventProp(name) {
|
|
768
|
+
return name.length > 2 && name.charCodeAt(0) === 111 && name.charCodeAt(1) === 110 && name.charCodeAt(2) >= 65;
|
|
769
|
+
}
|
|
770
|
+
export {
|
|
771
|
+
batchedUpdates,
|
|
772
|
+
childrenToArray,
|
|
773
|
+
enqueueEffect,
|
|
774
|
+
findRoot,
|
|
775
|
+
flushSyncWork,
|
|
776
|
+
getCurrentRoot,
|
|
777
|
+
getForceRerenderingFiber,
|
|
778
|
+
handleErrorInRender,
|
|
779
|
+
handleSuspended,
|
|
780
|
+
installCapability,
|
|
781
|
+
isThenable,
|
|
782
|
+
readContext,
|
|
783
|
+
reconcileChildren,
|
|
784
|
+
registerElementMarker,
|
|
785
|
+
registerRenderer,
|
|
786
|
+
registerTypeMatcher,
|
|
787
|
+
renderFiber,
|
|
788
|
+
renderRoot,
|
|
789
|
+
runEffects,
|
|
790
|
+
scheduleLifecycle,
|
|
791
|
+
scheduleUpdate,
|
|
792
|
+
unmountAllChildren,
|
|
793
|
+
withCurrentRoot
|
|
794
|
+
};
|
|
795
|
+
//# sourceMappingURL=reconcile.js.map
|