@reckona/mreact-compat 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/LICENSE +21 -0
- package/README.md +32 -0
- package/dist/class-component.d.ts +48 -0
- package/dist/class-component.d.ts.map +1 -0
- package/dist/class-component.js +186 -0
- package/dist/class-component.js.map +1 -0
- package/dist/context.d.ts +31 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +83 -0
- package/dist/context.js.map +1 -0
- package/dist/devtools.d.ts +5 -0
- package/dist/devtools.d.ts.map +1 -0
- package/dist/devtools.js +839 -0
- package/dist/devtools.js.map +1 -0
- package/dist/dom-children.d.ts +3 -0
- package/dist/dom-children.d.ts.map +1 -0
- package/dist/dom-children.js +23 -0
- package/dist/dom-children.js.map +1 -0
- package/dist/dom-props.d.ts +4 -0
- package/dist/dom-props.d.ts.map +1 -0
- package/dist/dom-props.js +266 -0
- package/dist/dom-props.js.map +1 -0
- package/dist/element.d.ts +94 -0
- package/dist/element.d.ts.map +1 -0
- package/dist/element.js +160 -0
- package/dist/element.js.map +1 -0
- package/dist/event-listeners.d.ts +12 -0
- package/dist/event-listeners.d.ts.map +1 -0
- package/dist/event-listeners.js +11 -0
- package/dist/event-listeners.js.map +1 -0
- package/dist/event-replay.d.ts +18 -0
- package/dist/event-replay.d.ts.map +1 -0
- package/dist/event-replay.js +94 -0
- package/dist/event-replay.js.map +1 -0
- package/dist/event-types.d.ts +19 -0
- package/dist/event-types.d.ts.map +1 -0
- package/dist/event-types.js +2 -0
- package/dist/event-types.js.map +1 -0
- package/dist/events.d.ts +6 -0
- package/dist/events.d.ts.map +1 -0
- package/dist/events.js +306 -0
- package/dist/events.js.map +1 -0
- package/dist/fiber-child.d.ts +4 -0
- package/dist/fiber-child.d.ts.map +1 -0
- package/dist/fiber-child.js +262 -0
- package/dist/fiber-child.js.map +1 -0
- package/dist/fiber-commit.d.ts +4 -0
- package/dist/fiber-commit.d.ts.map +1 -0
- package/dist/fiber-commit.js +54 -0
- package/dist/fiber-commit.js.map +1 -0
- package/dist/fiber-flags.d.ts +15 -0
- package/dist/fiber-flags.d.ts.map +1 -0
- package/dist/fiber-flags.js +18 -0
- package/dist/fiber-flags.js.map +1 -0
- package/dist/fiber-host.d.ts +16 -0
- package/dist/fiber-host.d.ts.map +1 -0
- package/dist/fiber-host.js +892 -0
- package/dist/fiber-host.js.map +1 -0
- package/dist/fiber-lanes.d.ts +30 -0
- package/dist/fiber-lanes.d.ts.map +1 -0
- package/dist/fiber-lanes.js +71 -0
- package/dist/fiber-lanes.js.map +1 -0
- package/dist/fiber-reconciler.d.ts +8 -0
- package/dist/fiber-reconciler.d.ts.map +1 -0
- package/dist/fiber-reconciler.js +385 -0
- package/dist/fiber-reconciler.js.map +1 -0
- package/dist/fiber-scheduler.d.ts +37 -0
- package/dist/fiber-scheduler.d.ts.map +1 -0
- package/dist/fiber-scheduler.js +307 -0
- package/dist/fiber-scheduler.js.map +1 -0
- package/dist/fiber-work-loop.d.ts +21 -0
- package/dist/fiber-work-loop.d.ts.map +1 -0
- package/dist/fiber-work-loop.js +116 -0
- package/dist/fiber-work-loop.js.map +1 -0
- package/dist/fiber.d.ts +50 -0
- package/dist/fiber.d.ts.map +1 -0
- package/dist/fiber.js +73 -0
- package/dist/fiber.js.map +1 -0
- package/dist/flight-decoder.d.ts +8 -0
- package/dist/flight-decoder.d.ts.map +1 -0
- package/dist/flight-decoder.js +132 -0
- package/dist/flight-decoder.js.map +1 -0
- package/dist/flight-element-builder.d.ts +6 -0
- package/dist/flight-element-builder.d.ts.map +1 -0
- package/dist/flight-element-builder.js +56 -0
- package/dist/flight-element-builder.js.map +1 -0
- package/dist/flight-parser.d.ts +3 -0
- package/dist/flight-parser.d.ts.map +1 -0
- package/dist/flight-parser.js +508 -0
- package/dist/flight-parser.js.map +1 -0
- package/dist/flight-protocol.d.ts +11 -0
- package/dist/flight-protocol.d.ts.map +1 -0
- package/dist/flight-protocol.js +61 -0
- package/dist/flight-protocol.js.map +1 -0
- package/dist/flight-types.d.ts +98 -0
- package/dist/flight-types.d.ts.map +1 -0
- package/dist/flight-types.js +2 -0
- package/dist/flight-types.js.map +1 -0
- package/dist/flight.d.ts +26 -0
- package/dist/flight.d.ts.map +1 -0
- package/dist/flight.js +66 -0
- package/dist/flight.js.map +1 -0
- package/dist/hooks.d.ts +214 -0
- package/dist/hooks.d.ts.map +1 -0
- package/dist/hooks.js +1296 -0
- package/dist/hooks.js.map +1 -0
- package/dist/hydration.d.ts +34 -0
- package/dist/hydration.d.ts.map +1 -0
- package/dist/hydration.js +164 -0
- package/dist/hydration.js.map +1 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/internal.d.ts +2 -0
- package/dist/internal.d.ts.map +1 -0
- package/dist/internal.js +2 -0
- package/dist/internal.js.map +1 -0
- package/dist/jsx-dev-runtime.d.ts +19 -0
- package/dist/jsx-dev-runtime.d.ts.map +1 -0
- package/dist/jsx-dev-runtime.js +6 -0
- package/dist/jsx-dev-runtime.js.map +1 -0
- package/dist/jsx-runtime.d.ts +24 -0
- package/dist/jsx-runtime.d.ts.map +1 -0
- package/dist/jsx-runtime.js +21 -0
- package/dist/jsx-runtime.js.map +1 -0
- package/dist/prop-comparison.d.ts +6 -0
- package/dist/prop-comparison.d.ts.map +1 -0
- package/dist/prop-comparison.js +28 -0
- package/dist/prop-comparison.js.map +1 -0
- package/dist/reconcile-types.d.ts +10 -0
- package/dist/reconcile-types.d.ts.map +1 -0
- package/dist/reconcile-types.js +2 -0
- package/dist/reconcile-types.js.map +1 -0
- package/dist/reconciler.d.ts +7 -0
- package/dist/reconciler.d.ts.map +1 -0
- package/dist/reconciler.js +318 -0
- package/dist/reconciler.js.map +1 -0
- package/dist/render.d.ts +7 -0
- package/dist/render.d.ts.map +1 -0
- package/dist/render.js +4 -0
- package/dist/render.js.map +1 -0
- package/dist/root.d.ts +44 -0
- package/dist/root.d.ts.map +1 -0
- package/dist/root.js +278 -0
- package/dist/root.js.map +1 -0
- package/dist/scheduler.d.ts +30 -0
- package/dist/scheduler.d.ts.map +1 -0
- package/dist/scheduler.js +90 -0
- package/dist/scheduler.js.map +1 -0
- package/dist/suspense.d.ts +8 -0
- package/dist/suspense.d.ts.map +1 -0
- package/dist/suspense.js +164 -0
- package/dist/suspense.js.map +1 -0
- package/dist/thenable.d.ts +2 -0
- package/dist/thenable.d.ts.map +1 -0
- package/dist/thenable.js +6 -0
- package/dist/thenable.js.map +1 -0
- package/dist/url-safety.d.ts +2 -0
- package/dist/url-safety.d.ts.map +1 -0
- package/dist/url-safety.js +2 -0
- package/dist/url-safety.js.map +1 -0
- package/package.json +65 -0
package/dist/devtools.js
ADDED
|
@@ -0,0 +1,839 @@
|
|
|
1
|
+
import { Fragment, Profiler, Suspense, SuspenseList, isReactCompatElement, isReactCompatPortal, } from "./element.js";
|
|
2
|
+
const roots = new WeakMap();
|
|
3
|
+
const hostInstanceFibers = new WeakMap();
|
|
4
|
+
const rootHostInstances = new WeakMap();
|
|
5
|
+
let rendererRoots = new Set();
|
|
6
|
+
let rendererId;
|
|
7
|
+
let injectedHook;
|
|
8
|
+
let isProfiling = false;
|
|
9
|
+
let profilingCommitData = [];
|
|
10
|
+
let suspenseHandler;
|
|
11
|
+
let errorHandler;
|
|
12
|
+
export function commitDevToolsRoot(container, source, didError = false) {
|
|
13
|
+
const hook = getDevToolsHook();
|
|
14
|
+
const id = injectDevToolsRenderer(hook);
|
|
15
|
+
if (hook === undefined || id === undefined) {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
const previousRoot = roots.get(container);
|
|
19
|
+
const commitStart = getCurrentTime();
|
|
20
|
+
if (previousRoot !== undefined) {
|
|
21
|
+
rendererRoots.delete(previousRoot);
|
|
22
|
+
clearHostInstanceFibers(previousRoot);
|
|
23
|
+
}
|
|
24
|
+
const nextRoot = isFiberRoot(source)
|
|
25
|
+
? createDevToolsFiberRoot(container, source)
|
|
26
|
+
: createFallbackDevToolsRoot(container, source);
|
|
27
|
+
const root = previousRoot ?? nextRoot;
|
|
28
|
+
if (previousRoot !== undefined) {
|
|
29
|
+
linkDevToolsAlternates(nextRoot.current, previousRoot.current);
|
|
30
|
+
root.current = nextRoot.current;
|
|
31
|
+
root.current.stateNode = root;
|
|
32
|
+
rootHostInstances.set(root, rootHostInstances.get(nextRoot) ?? []);
|
|
33
|
+
}
|
|
34
|
+
roots.set(container, root);
|
|
35
|
+
rendererRoots.add(root);
|
|
36
|
+
recordDevToolsCommit(root, commitStart);
|
|
37
|
+
hook.onCommitFiberRoot?.(id, root, undefined, didError);
|
|
38
|
+
hook.onPostCommitFiberRoot?.(id, root);
|
|
39
|
+
}
|
|
40
|
+
export function unmountDevToolsRoot(container) {
|
|
41
|
+
const hook = getDevToolsHook();
|
|
42
|
+
const id = injectDevToolsRenderer(hook);
|
|
43
|
+
const root = roots.get(container);
|
|
44
|
+
if (hook === undefined || id === undefined || root === undefined) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
notifyFiberUnmounts(hook, id, root.current.child);
|
|
48
|
+
markDevToolsRootUnmounted(root);
|
|
49
|
+
hook.onCommitFiberRoot?.(id, root, undefined, false);
|
|
50
|
+
hook.onPostCommitFiberRoot?.(id, root);
|
|
51
|
+
rendererRoots.delete(root);
|
|
52
|
+
clearHostInstanceFibers(root);
|
|
53
|
+
roots.delete(container);
|
|
54
|
+
}
|
|
55
|
+
function injectDevToolsRenderer(hook) {
|
|
56
|
+
if (rendererId !== undefined && injectedHook === hook) {
|
|
57
|
+
return rendererId;
|
|
58
|
+
}
|
|
59
|
+
if (hook?.inject === undefined) {
|
|
60
|
+
return undefined;
|
|
61
|
+
}
|
|
62
|
+
injectedHook = hook;
|
|
63
|
+
rendererRoots = new Set();
|
|
64
|
+
rendererId = hook.inject({
|
|
65
|
+
bundleType: 1,
|
|
66
|
+
version: "0.0.0",
|
|
67
|
+
reconcilerVersion: "0.0.0",
|
|
68
|
+
rendererPackageName: "@reckona/mreact-compat",
|
|
69
|
+
supportsFiber: true,
|
|
70
|
+
getLaneLabelMap() {
|
|
71
|
+
return new Map([
|
|
72
|
+
[1, "Sync"],
|
|
73
|
+
[2, "Continuous"],
|
|
74
|
+
[4, "Default"],
|
|
75
|
+
[8, "Transition"],
|
|
76
|
+
]);
|
|
77
|
+
},
|
|
78
|
+
getCurrentFiber() {
|
|
79
|
+
return null;
|
|
80
|
+
},
|
|
81
|
+
findFiberByHostInstance(hostInstance) {
|
|
82
|
+
return typeof hostInstance === "object" && hostInstance !== null
|
|
83
|
+
? (hostInstanceFibers.get(hostInstance) ?? null)
|
|
84
|
+
: null;
|
|
85
|
+
},
|
|
86
|
+
findHostInstanceByFiber(fiber) {
|
|
87
|
+
return findFirstHostInstance(fiber);
|
|
88
|
+
},
|
|
89
|
+
findNativeNodesForFiber(fiber) {
|
|
90
|
+
const hostInstances = new Set();
|
|
91
|
+
collectHostInstances(fiber, hostInstances);
|
|
92
|
+
return hostInstances;
|
|
93
|
+
},
|
|
94
|
+
getDisplayNameForFiber(fiber) {
|
|
95
|
+
return getDisplayNameForDevToolsFiber(fiber);
|
|
96
|
+
},
|
|
97
|
+
getFiberCurrentPropsFromNode(hostInstance) {
|
|
98
|
+
const fiber = typeof hostInstance === "object" && hostInstance !== null
|
|
99
|
+
? hostInstanceFibers.get(hostInstance)
|
|
100
|
+
: undefined;
|
|
101
|
+
return fiber?.memoizedProps ?? null;
|
|
102
|
+
},
|
|
103
|
+
getInstanceByFiber(fiber) {
|
|
104
|
+
return fiber.stateNode;
|
|
105
|
+
},
|
|
106
|
+
overrideProps(fiber, path, value) {
|
|
107
|
+
setFiberPropsPath(fiber, path, value);
|
|
108
|
+
},
|
|
109
|
+
overridePropsDeletePath(fiber, path) {
|
|
110
|
+
deleteFiberPropsPath(fiber, path);
|
|
111
|
+
},
|
|
112
|
+
overridePropsRenamePath(fiber, oldPath, newPath) {
|
|
113
|
+
renameFiberPropsPath(fiber, oldPath, newPath);
|
|
114
|
+
},
|
|
115
|
+
overrideHookState(fiber, id, path, value) {
|
|
116
|
+
setFiberHookStatePath(fiber, id, path, value);
|
|
117
|
+
},
|
|
118
|
+
overrideHookStateDeletePath(fiber, id, path) {
|
|
119
|
+
deleteFiberHookStatePath(fiber, id, path);
|
|
120
|
+
},
|
|
121
|
+
overrideHookStateRenamePath(fiber, id, oldPath, newPath) {
|
|
122
|
+
renameFiberHookStatePath(fiber, id, oldPath, newPath);
|
|
123
|
+
},
|
|
124
|
+
scheduleUpdate(fiber) {
|
|
125
|
+
commitEditedFiberRoot(fiber);
|
|
126
|
+
},
|
|
127
|
+
scheduleRefresh: noop,
|
|
128
|
+
scheduleRetry(fiber) {
|
|
129
|
+
commitEditedFiberRoot(fiber);
|
|
130
|
+
},
|
|
131
|
+
setSuspenseHandler(handler) {
|
|
132
|
+
suspenseHandler = handler;
|
|
133
|
+
},
|
|
134
|
+
setErrorHandler(handler) {
|
|
135
|
+
errorHandler = handler;
|
|
136
|
+
},
|
|
137
|
+
shouldSuspend(fiber) {
|
|
138
|
+
return suspenseHandler?.(fiber) ?? false;
|
|
139
|
+
},
|
|
140
|
+
shouldError(fiber) {
|
|
141
|
+
return errorHandler?.(fiber) ?? false;
|
|
142
|
+
},
|
|
143
|
+
injectProfilingHooks: noop,
|
|
144
|
+
startProfiling() {
|
|
145
|
+
isProfiling = true;
|
|
146
|
+
},
|
|
147
|
+
stopProfiling() {
|
|
148
|
+
isProfiling = false;
|
|
149
|
+
},
|
|
150
|
+
clearProfilingData() {
|
|
151
|
+
profilingCommitData = [];
|
|
152
|
+
},
|
|
153
|
+
getProfilingData() {
|
|
154
|
+
return {
|
|
155
|
+
rendererID: rendererId,
|
|
156
|
+
commitData: profilingCommitData,
|
|
157
|
+
};
|
|
158
|
+
},
|
|
159
|
+
});
|
|
160
|
+
return rendererId;
|
|
161
|
+
}
|
|
162
|
+
function noop() { }
|
|
163
|
+
function getDevToolsHook() {
|
|
164
|
+
return globalThis
|
|
165
|
+
.__REACT_DEVTOOLS_GLOBAL_HOOK__;
|
|
166
|
+
}
|
|
167
|
+
function isFiberRoot(value) {
|
|
168
|
+
return (typeof value === "object" &&
|
|
169
|
+
value !== null &&
|
|
170
|
+
"current" in value &&
|
|
171
|
+
"container" in value);
|
|
172
|
+
}
|
|
173
|
+
function createDevToolsFiberRoot(container, fiberRoot) {
|
|
174
|
+
const hostInstances = [];
|
|
175
|
+
const root = {
|
|
176
|
+
containerInfo: container,
|
|
177
|
+
current: undefined,
|
|
178
|
+
pendingChildren: null,
|
|
179
|
+
hydrate: fiberRoot.hydrationState !== undefined,
|
|
180
|
+
};
|
|
181
|
+
root.current = toDevToolsFiber(fiberRoot.current, null, 0, root, hostInstances);
|
|
182
|
+
root.current.stateNode = root;
|
|
183
|
+
rootHostInstances.set(root, hostInstances);
|
|
184
|
+
return root;
|
|
185
|
+
}
|
|
186
|
+
function toDevToolsFiber(fiber, parent, index, root, hostInstances) {
|
|
187
|
+
const devToolsFiber = createDevToolsFiberShell(fiber, parent, index, root);
|
|
188
|
+
if (isHostInstance(devToolsFiber.stateNode)) {
|
|
189
|
+
hostInstanceFibers.set(devToolsFiber.stateNode, devToolsFiber);
|
|
190
|
+
hostInstances.push(devToolsFiber.stateNode);
|
|
191
|
+
}
|
|
192
|
+
let previousChild;
|
|
193
|
+
let childIndex = 0;
|
|
194
|
+
let child = fiber.child;
|
|
195
|
+
while (child !== undefined) {
|
|
196
|
+
const devToolsChild = toDevToolsFiber(child, devToolsFiber, childIndex, root, hostInstances);
|
|
197
|
+
if (previousChild === undefined) {
|
|
198
|
+
devToolsFiber.child = devToolsChild;
|
|
199
|
+
}
|
|
200
|
+
else {
|
|
201
|
+
previousChild.sibling = devToolsChild;
|
|
202
|
+
}
|
|
203
|
+
previousChild = devToolsChild;
|
|
204
|
+
child = child.sibling;
|
|
205
|
+
childIndex += 1;
|
|
206
|
+
}
|
|
207
|
+
devToolsFiber.deletions =
|
|
208
|
+
fiber.deletions?.map((deletedFiber, deletedIndex) => toDevToolsFiber(deletedFiber, devToolsFiber, deletedIndex, root, hostInstances)) ?? null;
|
|
209
|
+
return devToolsFiber;
|
|
210
|
+
}
|
|
211
|
+
function createDevToolsFiberShell(fiber, parent, index, root) {
|
|
212
|
+
const pendingProps = fiber.tag === "host-root" ? fiber.pendingProps : fiber.pendingProps;
|
|
213
|
+
const memoizedProps = fiber.tag === "host-root" ? fiber.memoizedProps : fiber.memoizedProps;
|
|
214
|
+
return {
|
|
215
|
+
tag: getReactFiberTag(fiber.tag),
|
|
216
|
+
key: fiber.key ?? null,
|
|
217
|
+
elementType: getElementType(fiber),
|
|
218
|
+
type: getFiberType(fiber),
|
|
219
|
+
stateNode: fiber.tag === "host-root" ? root : fiber.stateNode,
|
|
220
|
+
return: parent,
|
|
221
|
+
child: null,
|
|
222
|
+
sibling: null,
|
|
223
|
+
index,
|
|
224
|
+
ref: getFiberRef(fiber),
|
|
225
|
+
pendingProps,
|
|
226
|
+
memoizedProps,
|
|
227
|
+
memoizedState: fiber.tag === "host-root"
|
|
228
|
+
? createMountedHostRootState(memoizedProps)
|
|
229
|
+
: createDevToolsMemoizedState(fiber.memoizedState),
|
|
230
|
+
updateQueue: null,
|
|
231
|
+
dependencies: null,
|
|
232
|
+
mode: 0,
|
|
233
|
+
flags: fiber.flags,
|
|
234
|
+
subtreeFlags: fiber.subtreeFlags,
|
|
235
|
+
deletions: null,
|
|
236
|
+
lanes: fiber.lanes,
|
|
237
|
+
childLanes: fiber.childLanes,
|
|
238
|
+
alternate: null,
|
|
239
|
+
actualDuration: 0,
|
|
240
|
+
actualStartTime: -1,
|
|
241
|
+
selfBaseDuration: 0,
|
|
242
|
+
treeBaseDuration: 0,
|
|
243
|
+
_debugOwner: null,
|
|
244
|
+
_debugSource: null,
|
|
245
|
+
_debugHookTypes: getDevToolsHookTypes(fiber.memoizedState),
|
|
246
|
+
};
|
|
247
|
+
}
|
|
248
|
+
function createDevToolsHookList(state) {
|
|
249
|
+
if (!isDevToolsHookSnapshot(state)) {
|
|
250
|
+
return null;
|
|
251
|
+
}
|
|
252
|
+
const nodes = state.hooks
|
|
253
|
+
.filter((hook) => hook.kind !== "debug")
|
|
254
|
+
.map(createDevToolsHookNode);
|
|
255
|
+
for (let index = 0; index < nodes.length - 1; index += 1) {
|
|
256
|
+
const next = nodes[index + 1];
|
|
257
|
+
if (next !== undefined) {
|
|
258
|
+
nodes[index].next = next;
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
return nodes[0] ?? null;
|
|
262
|
+
}
|
|
263
|
+
function createDevToolsMemoizedState(state) {
|
|
264
|
+
return isDevToolsHookSnapshot(state)
|
|
265
|
+
? createDevToolsHookList(state)
|
|
266
|
+
: state;
|
|
267
|
+
}
|
|
268
|
+
function createDevToolsHookNode(hook) {
|
|
269
|
+
const memoizedState = getDevToolsHookMemoizedState(hook);
|
|
270
|
+
const isStateful = hook.kind === "state" ||
|
|
271
|
+
hook.kind === "reducer" ||
|
|
272
|
+
hook.kind === "store" ||
|
|
273
|
+
hook.kind === "transition" ||
|
|
274
|
+
hook.kind === "deferred";
|
|
275
|
+
return {
|
|
276
|
+
memoizedState,
|
|
277
|
+
baseState: isStateful ? memoizedState : null,
|
|
278
|
+
baseQueue: null,
|
|
279
|
+
queue: isStateful
|
|
280
|
+
? {
|
|
281
|
+
pending: null,
|
|
282
|
+
lanes: 0,
|
|
283
|
+
dispatch: null,
|
|
284
|
+
lastRenderedReducer: null,
|
|
285
|
+
lastRenderedState: memoizedState,
|
|
286
|
+
}
|
|
287
|
+
: null,
|
|
288
|
+
next: null,
|
|
289
|
+
};
|
|
290
|
+
}
|
|
291
|
+
function getDevToolsHookMemoizedState(hook) {
|
|
292
|
+
if (hook.kind === "memo" || hook.kind === "callback") {
|
|
293
|
+
return [hook.value, hook.deps ?? null];
|
|
294
|
+
}
|
|
295
|
+
if (hook.kind === "ref") {
|
|
296
|
+
return typeof hook.value === "object" && hook.value !== null
|
|
297
|
+
? hook.value
|
|
298
|
+
: { current: hook.value };
|
|
299
|
+
}
|
|
300
|
+
if (hook.kind === "effect" || hook.kind === "imperative-handle") {
|
|
301
|
+
return {
|
|
302
|
+
tag: hook.kind === "effect" ? hook.effectKind ?? "normal" : "imperative-handle",
|
|
303
|
+
create: null,
|
|
304
|
+
destroy: null,
|
|
305
|
+
deps: hook.deps ?? null,
|
|
306
|
+
next: null,
|
|
307
|
+
};
|
|
308
|
+
}
|
|
309
|
+
return hook.value;
|
|
310
|
+
}
|
|
311
|
+
function getDevToolsHookTypes(state) {
|
|
312
|
+
if (!isDevToolsHookSnapshot(state)) {
|
|
313
|
+
return null;
|
|
314
|
+
}
|
|
315
|
+
return state.hookTypes === undefined || state.hookTypes.length === 0
|
|
316
|
+
? null
|
|
317
|
+
: [...state.hookTypes];
|
|
318
|
+
}
|
|
319
|
+
function isDevToolsHookSnapshot(state) {
|
|
320
|
+
return (typeof state === "object" &&
|
|
321
|
+
state !== null &&
|
|
322
|
+
"hooks" in state &&
|
|
323
|
+
Array.isArray(state.hooks));
|
|
324
|
+
}
|
|
325
|
+
function createFallbackDevToolsRoot(container, element) {
|
|
326
|
+
const hostInstances = [];
|
|
327
|
+
const root = {
|
|
328
|
+
containerInfo: container,
|
|
329
|
+
current: undefined,
|
|
330
|
+
pendingChildren: null,
|
|
331
|
+
hydrate: false,
|
|
332
|
+
};
|
|
333
|
+
root.current = {
|
|
334
|
+
...createFallbackDevToolsFiber("host-root", { children: element }, null, 0),
|
|
335
|
+
tag: 3,
|
|
336
|
+
stateNode: root,
|
|
337
|
+
memoizedState: createMountedHostRootState({ children: element }),
|
|
338
|
+
};
|
|
339
|
+
root.current.child = toFallbackDevToolsFiber(element, root.current, 0, hostInstances);
|
|
340
|
+
rootHostInstances.set(root, hostInstances);
|
|
341
|
+
return root;
|
|
342
|
+
}
|
|
343
|
+
function createMountedHostRootState(props) {
|
|
344
|
+
return {
|
|
345
|
+
element: typeof props === "object" && props !== null && "children" in props
|
|
346
|
+
? props.children
|
|
347
|
+
: null,
|
|
348
|
+
};
|
|
349
|
+
}
|
|
350
|
+
function markDevToolsRootUnmounted(root) {
|
|
351
|
+
root.current.child = null;
|
|
352
|
+
root.current.memoizedProps = null;
|
|
353
|
+
root.current.pendingProps = null;
|
|
354
|
+
root.current.memoizedState = null;
|
|
355
|
+
}
|
|
356
|
+
function toFallbackDevToolsFiber(node, parent, index, hostInstances) {
|
|
357
|
+
if (Array.isArray(node)) {
|
|
358
|
+
const fragment = createFallbackDevToolsFiber(Fragment, {}, parent, index);
|
|
359
|
+
linkFallbackChildren(fragment, node, hostInstances);
|
|
360
|
+
return fragment;
|
|
361
|
+
}
|
|
362
|
+
if (!isReactCompatElement(node)) {
|
|
363
|
+
if (isReactCompatPortal(node)) {
|
|
364
|
+
const portal = createFallbackDevToolsFiber("portal", {}, parent, index);
|
|
365
|
+
portal.stateNode = node.container;
|
|
366
|
+
portal.child = toFallbackDevToolsFiber(node.children, portal, 0, hostInstances);
|
|
367
|
+
return portal;
|
|
368
|
+
}
|
|
369
|
+
return createFallbackDevToolsFiber("#text", node, parent, index);
|
|
370
|
+
}
|
|
371
|
+
const fiber = createFallbackDevToolsFiber(node.type, node.props, parent, index);
|
|
372
|
+
fiber.key = node.key;
|
|
373
|
+
fiber.ref = node.ref;
|
|
374
|
+
linkFallbackChildren(fiber, getChildren(node.props.children), hostInstances);
|
|
375
|
+
return fiber;
|
|
376
|
+
}
|
|
377
|
+
function linkFallbackChildren(parent, children, hostInstances) {
|
|
378
|
+
let previous;
|
|
379
|
+
for (const [index, child] of children.entries()) {
|
|
380
|
+
const childFiber = toFallbackDevToolsFiber(child, parent, index, hostInstances);
|
|
381
|
+
if (childFiber === null) {
|
|
382
|
+
continue;
|
|
383
|
+
}
|
|
384
|
+
if (previous === undefined) {
|
|
385
|
+
parent.child = childFiber;
|
|
386
|
+
}
|
|
387
|
+
else {
|
|
388
|
+
previous.sibling = childFiber;
|
|
389
|
+
}
|
|
390
|
+
previous = childFiber;
|
|
391
|
+
}
|
|
392
|
+
}
|
|
393
|
+
function createFallbackDevToolsFiber(type, props, parent, index) {
|
|
394
|
+
const tag = type === "#text"
|
|
395
|
+
? 6
|
|
396
|
+
: type === "host-root"
|
|
397
|
+
? 3
|
|
398
|
+
: type === "portal"
|
|
399
|
+
? 4
|
|
400
|
+
: typeof type === "string"
|
|
401
|
+
? 5
|
|
402
|
+
: type === Fragment
|
|
403
|
+
? 7
|
|
404
|
+
: type === Profiler
|
|
405
|
+
? 12
|
|
406
|
+
: type === Suspense
|
|
407
|
+
? 13
|
|
408
|
+
: type === SuspenseList
|
|
409
|
+
? 19
|
|
410
|
+
: typeof type === "function"
|
|
411
|
+
? 0
|
|
412
|
+
: 0;
|
|
413
|
+
return {
|
|
414
|
+
tag,
|
|
415
|
+
key: null,
|
|
416
|
+
elementType: type,
|
|
417
|
+
type,
|
|
418
|
+
stateNode: null,
|
|
419
|
+
return: parent,
|
|
420
|
+
child: null,
|
|
421
|
+
sibling: null,
|
|
422
|
+
index,
|
|
423
|
+
ref: null,
|
|
424
|
+
pendingProps: props,
|
|
425
|
+
memoizedProps: props,
|
|
426
|
+
memoizedState: null,
|
|
427
|
+
updateQueue: null,
|
|
428
|
+
dependencies: null,
|
|
429
|
+
mode: 0,
|
|
430
|
+
flags: 0,
|
|
431
|
+
subtreeFlags: 0,
|
|
432
|
+
deletions: null,
|
|
433
|
+
lanes: 0,
|
|
434
|
+
childLanes: 0,
|
|
435
|
+
alternate: null,
|
|
436
|
+
actualDuration: 0,
|
|
437
|
+
actualStartTime: -1,
|
|
438
|
+
selfBaseDuration: 0,
|
|
439
|
+
treeBaseDuration: 0,
|
|
440
|
+
_debugOwner: null,
|
|
441
|
+
_debugSource: null,
|
|
442
|
+
_debugHookTypes: null,
|
|
443
|
+
};
|
|
444
|
+
}
|
|
445
|
+
function notifyFiberUnmounts(hook, id, fiber) {
|
|
446
|
+
let cursor = fiber;
|
|
447
|
+
while (cursor !== null) {
|
|
448
|
+
hook.onCommitFiberUnmount?.(id, cursor);
|
|
449
|
+
notifyFiberUnmounts(hook, id, cursor.child);
|
|
450
|
+
cursor = cursor.sibling;
|
|
451
|
+
}
|
|
452
|
+
}
|
|
453
|
+
function clearHostInstanceFibers(root) {
|
|
454
|
+
for (const hostInstance of rootHostInstances.get(root) ?? []) {
|
|
455
|
+
hostInstanceFibers.delete(hostInstance);
|
|
456
|
+
}
|
|
457
|
+
rootHostInstances.delete(root);
|
|
458
|
+
}
|
|
459
|
+
function recordDevToolsCommit(root, commitStart) {
|
|
460
|
+
if (!isProfiling) {
|
|
461
|
+
return;
|
|
462
|
+
}
|
|
463
|
+
const timestamp = getCurrentTime();
|
|
464
|
+
const fiberActualDurations = [];
|
|
465
|
+
collectFiberDurations(root.current, fiberActualDurations);
|
|
466
|
+
profilingCommitData.push({
|
|
467
|
+
timestamp,
|
|
468
|
+
duration: Math.max(0, timestamp - commitStart),
|
|
469
|
+
fiberActualDurations,
|
|
470
|
+
});
|
|
471
|
+
}
|
|
472
|
+
function collectFiberDurations(fiber, durations) {
|
|
473
|
+
let cursor = fiber;
|
|
474
|
+
while (cursor !== null) {
|
|
475
|
+
durations.push({
|
|
476
|
+
fiber: cursor,
|
|
477
|
+
duration: cursor.actualDuration,
|
|
478
|
+
});
|
|
479
|
+
collectFiberDurations(cursor.child, durations);
|
|
480
|
+
cursor = cursor.sibling;
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
function linkDevToolsAlternates(current, alternate) {
|
|
484
|
+
if (current === null || alternate === null || !canLinkDevToolsAlternates(current, alternate)) {
|
|
485
|
+
return;
|
|
486
|
+
}
|
|
487
|
+
current.alternate = alternate;
|
|
488
|
+
alternate.alternate = current;
|
|
489
|
+
linkDevToolsChildAlternates(current.child, alternate.child);
|
|
490
|
+
}
|
|
491
|
+
function linkDevToolsChildAlternates(currentChild, alternateChild) {
|
|
492
|
+
const unmatchedAlternates = new Set();
|
|
493
|
+
let alternateCursor = alternateChild;
|
|
494
|
+
while (alternateCursor !== null) {
|
|
495
|
+
unmatchedAlternates.add(alternateCursor);
|
|
496
|
+
alternateCursor = alternateCursor.sibling;
|
|
497
|
+
}
|
|
498
|
+
let currentCursor = currentChild;
|
|
499
|
+
while (currentCursor !== null) {
|
|
500
|
+
const alternate = findMatchingDevToolsAlternate(currentCursor, unmatchedAlternates);
|
|
501
|
+
if (alternate !== null) {
|
|
502
|
+
unmatchedAlternates.delete(alternate);
|
|
503
|
+
linkDevToolsAlternates(currentCursor, alternate);
|
|
504
|
+
}
|
|
505
|
+
currentCursor = currentCursor.sibling;
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
function findMatchingDevToolsAlternate(current, candidates) {
|
|
509
|
+
for (const candidate of candidates) {
|
|
510
|
+
if (canLinkDevToolsAlternates(current, candidate)) {
|
|
511
|
+
return candidate;
|
|
512
|
+
}
|
|
513
|
+
}
|
|
514
|
+
return null;
|
|
515
|
+
}
|
|
516
|
+
function canLinkDevToolsAlternates(current, alternate) {
|
|
517
|
+
return (current.tag === alternate.tag &&
|
|
518
|
+
current.key === alternate.key &&
|
|
519
|
+
current.elementType === alternate.elementType &&
|
|
520
|
+
current.type === alternate.type);
|
|
521
|
+
}
|
|
522
|
+
function setFiberPropsPath(fiber, path, value) {
|
|
523
|
+
const props = ensureRecord(fiber.memoizedProps);
|
|
524
|
+
setPath(props, path, value);
|
|
525
|
+
fiber.memoizedProps = props;
|
|
526
|
+
fiber.pendingProps = props;
|
|
527
|
+
}
|
|
528
|
+
function deleteFiberPropsPath(fiber, path) {
|
|
529
|
+
const props = ensureRecord(fiber.memoizedProps);
|
|
530
|
+
deletePath(props, path);
|
|
531
|
+
fiber.memoizedProps = props;
|
|
532
|
+
fiber.pendingProps = props;
|
|
533
|
+
}
|
|
534
|
+
function renameFiberPropsPath(fiber, oldPath, newPath) {
|
|
535
|
+
const props = ensureRecord(fiber.memoizedProps);
|
|
536
|
+
renamePath(props, oldPath, newPath);
|
|
537
|
+
fiber.memoizedProps = props;
|
|
538
|
+
fiber.pendingProps = props;
|
|
539
|
+
}
|
|
540
|
+
function readHookState(fiber, id) {
|
|
541
|
+
const index = Number.parseInt(id, 10);
|
|
542
|
+
const state = fiber.memoizedState;
|
|
543
|
+
if (Number.isInteger(index) &&
|
|
544
|
+
typeof state === "object" &&
|
|
545
|
+
state !== null &&
|
|
546
|
+
"hooks" in state &&
|
|
547
|
+
Array.isArray(state.hooks)) {
|
|
548
|
+
return state.hooks[index];
|
|
549
|
+
}
|
|
550
|
+
const hookNode = readHookNode(fiber, id);
|
|
551
|
+
if (hookNode !== null) {
|
|
552
|
+
return hookNode.memoizedState;
|
|
553
|
+
}
|
|
554
|
+
return state;
|
|
555
|
+
}
|
|
556
|
+
function setFiberHookStatePath(fiber, id, path, value) {
|
|
557
|
+
const hookNode = readHookNode(fiber, id);
|
|
558
|
+
if (hookNode === null) {
|
|
559
|
+
setPath(readHookState(fiber, id), path, value);
|
|
560
|
+
return;
|
|
561
|
+
}
|
|
562
|
+
if (path.length === 0) {
|
|
563
|
+
hookNode.memoizedState = value;
|
|
564
|
+
hookNode.baseState = value;
|
|
565
|
+
if (isDevToolsStateQueue(hookNode.queue)) {
|
|
566
|
+
hookNode.queue.lastRenderedState = value;
|
|
567
|
+
}
|
|
568
|
+
return;
|
|
569
|
+
}
|
|
570
|
+
setPath(hookNode.memoizedState, path, value);
|
|
571
|
+
}
|
|
572
|
+
function deleteFiberHookStatePath(fiber, id, path) {
|
|
573
|
+
const hookNode = readHookNode(fiber, id);
|
|
574
|
+
if (hookNode === null) {
|
|
575
|
+
deletePath(readHookState(fiber, id), path);
|
|
576
|
+
return;
|
|
577
|
+
}
|
|
578
|
+
deletePath(hookNode.memoizedState, path);
|
|
579
|
+
}
|
|
580
|
+
function renameFiberHookStatePath(fiber, id, oldPath, newPath) {
|
|
581
|
+
const hookNode = readHookNode(fiber, id);
|
|
582
|
+
if (hookNode === null) {
|
|
583
|
+
renamePath(readHookState(fiber, id), oldPath, newPath);
|
|
584
|
+
return;
|
|
585
|
+
}
|
|
586
|
+
renamePath(hookNode.memoizedState, oldPath, newPath);
|
|
587
|
+
}
|
|
588
|
+
function readHookNode(fiber, id) {
|
|
589
|
+
const index = Number.parseInt(id, 10);
|
|
590
|
+
if (!Number.isInteger(index)) {
|
|
591
|
+
return null;
|
|
592
|
+
}
|
|
593
|
+
let cursor = fiber.memoizedState;
|
|
594
|
+
let cursorIndex = 0;
|
|
595
|
+
while (isDevToolsHookNode(cursor)) {
|
|
596
|
+
if (cursorIndex === index) {
|
|
597
|
+
return cursor;
|
|
598
|
+
}
|
|
599
|
+
cursor = cursor.next;
|
|
600
|
+
cursorIndex += 1;
|
|
601
|
+
}
|
|
602
|
+
return null;
|
|
603
|
+
}
|
|
604
|
+
function isDevToolsHookNode(value) {
|
|
605
|
+
return (typeof value === "object" &&
|
|
606
|
+
value !== null &&
|
|
607
|
+
"memoizedState" in value &&
|
|
608
|
+
"baseState" in value &&
|
|
609
|
+
"baseQueue" in value &&
|
|
610
|
+
"queue" in value &&
|
|
611
|
+
"next" in value);
|
|
612
|
+
}
|
|
613
|
+
function isDevToolsStateQueue(value) {
|
|
614
|
+
return typeof value === "object" && value !== null && "lastRenderedState" in value;
|
|
615
|
+
}
|
|
616
|
+
function commitEditedFiberRoot(fiber) {
|
|
617
|
+
const hook = getDevToolsHook();
|
|
618
|
+
const id = injectDevToolsRenderer(hook);
|
|
619
|
+
const root = findDevToolsRootForFiber(fiber);
|
|
620
|
+
if (hook === undefined || id === undefined || root === null) {
|
|
621
|
+
return;
|
|
622
|
+
}
|
|
623
|
+
hook.onCommitFiberRoot?.(id, root);
|
|
624
|
+
hook.onPostCommitFiberRoot?.(id, root);
|
|
625
|
+
}
|
|
626
|
+
function findDevToolsRootForFiber(fiber) {
|
|
627
|
+
let cursor = fiber;
|
|
628
|
+
while (cursor.return !== null) {
|
|
629
|
+
cursor = cursor.return;
|
|
630
|
+
}
|
|
631
|
+
return cursor.stateNode !== null &&
|
|
632
|
+
typeof cursor.stateNode === "object" &&
|
|
633
|
+
"current" in cursor.stateNode
|
|
634
|
+
? cursor.stateNode
|
|
635
|
+
: null;
|
|
636
|
+
}
|
|
637
|
+
function ensureRecord(value) {
|
|
638
|
+
return typeof value === "object" && value !== null
|
|
639
|
+
? value
|
|
640
|
+
: {};
|
|
641
|
+
}
|
|
642
|
+
function setPath(target, path, value) {
|
|
643
|
+
const parent = readPathParent(target, path, true);
|
|
644
|
+
const key = path.at(-1);
|
|
645
|
+
if (parent === undefined || key === undefined) {
|
|
646
|
+
return;
|
|
647
|
+
}
|
|
648
|
+
if (Array.isArray(parent) && typeof key === "number") {
|
|
649
|
+
parent[key] = value;
|
|
650
|
+
return;
|
|
651
|
+
}
|
|
652
|
+
parent[key] = value;
|
|
653
|
+
}
|
|
654
|
+
function deletePath(target, path) {
|
|
655
|
+
const parent = readPathParent(target, path, false);
|
|
656
|
+
const key = path.at(-1);
|
|
657
|
+
if (parent === undefined || key === undefined) {
|
|
658
|
+
return;
|
|
659
|
+
}
|
|
660
|
+
if (Array.isArray(parent) && typeof key === "number") {
|
|
661
|
+
parent.splice(key, 1);
|
|
662
|
+
return;
|
|
663
|
+
}
|
|
664
|
+
delete parent[key];
|
|
665
|
+
}
|
|
666
|
+
function renamePath(target, oldPath, newPath) {
|
|
667
|
+
const value = readPath(target, oldPath);
|
|
668
|
+
if (value === undefined) {
|
|
669
|
+
return;
|
|
670
|
+
}
|
|
671
|
+
deletePath(target, oldPath);
|
|
672
|
+
setPath(target, newPath, value);
|
|
673
|
+
}
|
|
674
|
+
function readPath(target, path) {
|
|
675
|
+
let cursor = target;
|
|
676
|
+
for (const key of path) {
|
|
677
|
+
if (typeof cursor !== "object" || cursor === null) {
|
|
678
|
+
return undefined;
|
|
679
|
+
}
|
|
680
|
+
cursor = cursor[key];
|
|
681
|
+
}
|
|
682
|
+
return cursor;
|
|
683
|
+
}
|
|
684
|
+
function readPathParent(target, path, createMissing) {
|
|
685
|
+
if (path.length === 0 || typeof target !== "object" || target === null) {
|
|
686
|
+
return undefined;
|
|
687
|
+
}
|
|
688
|
+
let cursor = target;
|
|
689
|
+
for (const [index, key] of path.slice(0, -1).entries()) {
|
|
690
|
+
const nextKey = path[index + 1];
|
|
691
|
+
let next = cursor[key];
|
|
692
|
+
if (typeof next !== "object" || next === null) {
|
|
693
|
+
if (!createMissing) {
|
|
694
|
+
return undefined;
|
|
695
|
+
}
|
|
696
|
+
next = typeof nextKey === "number" ? [] : {};
|
|
697
|
+
cursor[key] = next;
|
|
698
|
+
}
|
|
699
|
+
cursor = next;
|
|
700
|
+
}
|
|
701
|
+
return cursor;
|
|
702
|
+
}
|
|
703
|
+
function getCurrentTime() {
|
|
704
|
+
return typeof performance === "undefined" ? Date.now() : performance.now();
|
|
705
|
+
}
|
|
706
|
+
function findFirstHostInstance(fiber) {
|
|
707
|
+
if (fiber === null) {
|
|
708
|
+
return null;
|
|
709
|
+
}
|
|
710
|
+
if (isHostInstance(fiber.stateNode)) {
|
|
711
|
+
return fiber.stateNode;
|
|
712
|
+
}
|
|
713
|
+
let child = fiber.child;
|
|
714
|
+
while (child !== null) {
|
|
715
|
+
const hostInstance = findFirstHostInstance(child);
|
|
716
|
+
if (hostInstance !== null) {
|
|
717
|
+
return hostInstance;
|
|
718
|
+
}
|
|
719
|
+
child = child.sibling;
|
|
720
|
+
}
|
|
721
|
+
return null;
|
|
722
|
+
}
|
|
723
|
+
function collectHostInstances(fiber, hostInstances) {
|
|
724
|
+
if (fiber === null) {
|
|
725
|
+
return;
|
|
726
|
+
}
|
|
727
|
+
if (isHostInstance(fiber.stateNode)) {
|
|
728
|
+
hostInstances.add(fiber.stateNode);
|
|
729
|
+
}
|
|
730
|
+
let child = fiber.child;
|
|
731
|
+
while (child !== null) {
|
|
732
|
+
collectHostInstances(child, hostInstances);
|
|
733
|
+
child = child.sibling;
|
|
734
|
+
}
|
|
735
|
+
}
|
|
736
|
+
function getReactFiberTag(tag) {
|
|
737
|
+
switch (tag) {
|
|
738
|
+
case "function-component":
|
|
739
|
+
return 0;
|
|
740
|
+
case "class-component":
|
|
741
|
+
return 1;
|
|
742
|
+
case "host-root":
|
|
743
|
+
return 3;
|
|
744
|
+
case "portal":
|
|
745
|
+
return 4;
|
|
746
|
+
case "host-component":
|
|
747
|
+
return 5;
|
|
748
|
+
case "host-text":
|
|
749
|
+
return 6;
|
|
750
|
+
case "fragment":
|
|
751
|
+
return 7;
|
|
752
|
+
case "strict-mode":
|
|
753
|
+
return 8;
|
|
754
|
+
case "context-consumer":
|
|
755
|
+
return 9;
|
|
756
|
+
case "context-provider":
|
|
757
|
+
return 10;
|
|
758
|
+
case "forward-ref":
|
|
759
|
+
return 11;
|
|
760
|
+
case "profiler":
|
|
761
|
+
return 12;
|
|
762
|
+
case "suspense":
|
|
763
|
+
return 13;
|
|
764
|
+
case "memo":
|
|
765
|
+
return 14;
|
|
766
|
+
case "lazy":
|
|
767
|
+
return 16;
|
|
768
|
+
case "suspense-list":
|
|
769
|
+
return 19;
|
|
770
|
+
case "error-boundary":
|
|
771
|
+
return 1;
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
function getElementType(fiber) {
|
|
775
|
+
return fiber.tag === "host-root" || fiber.tag === "host-text"
|
|
776
|
+
? null
|
|
777
|
+
: fiber.type;
|
|
778
|
+
}
|
|
779
|
+
function getFiberType(fiber) {
|
|
780
|
+
return fiber.tag === "host-root" || fiber.tag === "host-text"
|
|
781
|
+
? null
|
|
782
|
+
: fiber.type;
|
|
783
|
+
}
|
|
784
|
+
function getFiberRef(fiber) {
|
|
785
|
+
const props = (fiber.memoizedProps ?? fiber.pendingProps);
|
|
786
|
+
return props?.ref ?? null;
|
|
787
|
+
}
|
|
788
|
+
function getDisplayNameForDevToolsFiber(fiber) {
|
|
789
|
+
if (fiber.tag === 3) {
|
|
790
|
+
return "Root";
|
|
791
|
+
}
|
|
792
|
+
if (fiber.tag === 6) {
|
|
793
|
+
return "Text";
|
|
794
|
+
}
|
|
795
|
+
return getElementTypeName(fiber.elementType ?? fiber.type);
|
|
796
|
+
}
|
|
797
|
+
function isHostInstance(value) {
|
|
798
|
+
return ((typeof Element !== "undefined" && value instanceof Element) ||
|
|
799
|
+
(typeof Text !== "undefined" && value instanceof Text));
|
|
800
|
+
}
|
|
801
|
+
function getChildren(children) {
|
|
802
|
+
if (children === undefined || children === null || typeof children === "boolean") {
|
|
803
|
+
return [];
|
|
804
|
+
}
|
|
805
|
+
return Array.isArray(children) ? children : [children];
|
|
806
|
+
}
|
|
807
|
+
function getElementTypeName(type) {
|
|
808
|
+
if (typeof type === "string") {
|
|
809
|
+
return type;
|
|
810
|
+
}
|
|
811
|
+
if (typeof type === "function") {
|
|
812
|
+
return type.name === "" ? "Anonymous" : type.name;
|
|
813
|
+
}
|
|
814
|
+
if (type === Fragment) {
|
|
815
|
+
return "Fragment";
|
|
816
|
+
}
|
|
817
|
+
if (type === Profiler) {
|
|
818
|
+
return "Profiler";
|
|
819
|
+
}
|
|
820
|
+
if (type === Suspense) {
|
|
821
|
+
return "Suspense";
|
|
822
|
+
}
|
|
823
|
+
if (type === SuspenseList) {
|
|
824
|
+
return "SuspenseList";
|
|
825
|
+
}
|
|
826
|
+
if (typeof type === "object" &&
|
|
827
|
+
type !== null &&
|
|
828
|
+
"render" in type &&
|
|
829
|
+
typeof type.render === "function") {
|
|
830
|
+
return getElementTypeName(type.render);
|
|
831
|
+
}
|
|
832
|
+
if (typeof type === "object" &&
|
|
833
|
+
type !== null &&
|
|
834
|
+
"type" in type) {
|
|
835
|
+
return getElementTypeName(type.type);
|
|
836
|
+
}
|
|
837
|
+
return null;
|
|
838
|
+
}
|
|
839
|
+
//# sourceMappingURL=devtools.js.map
|