@reckona/mreact-compat 0.0.138 → 0.0.140
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/dom-props.d.ts.map +1 -1
- package/dist/dom-props.js +111 -44
- package/dist/dom-props.js.map +1 -1
- package/dist/element.d.ts +3 -0
- package/dist/element.d.ts.map +1 -1
- package/dist/element.js +32 -2
- package/dist/element.js.map +1 -1
- package/dist/event-listeners.d.ts +2 -4
- package/dist/event-listeners.d.ts.map +1 -1
- package/dist/event-listeners.js +2 -1
- package/dist/event-listeners.js.map +1 -1
- package/dist/fiber-child.d.ts.map +1 -1
- package/dist/fiber-child.js +44 -0
- package/dist/fiber-child.js.map +1 -1
- package/dist/fiber-commit.d.ts.map +1 -1
- package/dist/fiber-commit.js +70 -0
- package/dist/fiber-commit.js.map +1 -1
- package/dist/hooks.d.ts +4 -2
- package/dist/hooks.d.ts.map +1 -1
- package/dist/hooks.js +64 -6
- package/dist/hooks.js.map +1 -1
- package/dist/host-reconciler.d.ts.map +1 -1
- package/dist/host-reconciler.js +2 -2
- package/dist/host-reconciler.js.map +1 -1
- package/dist/jsx-runtime.d.ts.map +1 -1
- package/dist/jsx-runtime.js +2 -11
- package/dist/jsx-runtime.js.map +1 -1
- package/dist/reconciler.d.ts.map +1 -1
- package/dist/reconciler.js +2 -2
- package/dist/reconciler.js.map +1 -1
- package/dist/server-render.d.ts.map +1 -1
- package/dist/server-render.js +29 -4
- package/dist/server-render.js.map +1 -1
- package/dist/url-safety.d.ts +1 -1
- package/dist/url-safety.d.ts.map +1 -1
- package/dist/url-safety.js +1 -1
- package/dist/url-safety.js.map +1 -1
- package/package.json +3 -3
- package/src/dom-props.ts +189 -49
- package/src/element.ts +45 -1
- package/src/event-listeners.ts +4 -5
- package/src/fiber-child.ts +67 -0
- package/src/fiber-commit.ts +92 -0
- package/src/hooks.ts +88 -8
- package/src/host-reconciler.ts +2 -3
- package/src/jsx-runtime.ts +2 -18
- package/src/reconciler.ts +2 -3
- package/src/server-render.ts +43 -4
- package/src/url-safety.ts +1 -0
package/dist/hooks.js
CHANGED
|
@@ -85,6 +85,7 @@ function flushActWork() {
|
|
|
85
85
|
export function createRootRuntime(rerender, options = {}) {
|
|
86
86
|
return {
|
|
87
87
|
instances: new Map(),
|
|
88
|
+
instanceKeysByPrefix: new Map(),
|
|
88
89
|
activeInstanceKeys: undefined,
|
|
89
90
|
activeProfilerPaths: undefined,
|
|
90
91
|
mountedProfilerPaths: new Set(),
|
|
@@ -256,20 +257,25 @@ export function renderWithRootRuntime(runtime, path, render, owner) {
|
|
|
256
257
|
hooks: [],
|
|
257
258
|
hookIndex: 0,
|
|
258
259
|
dirty: false,
|
|
259
|
-
devToolsHooks: [],
|
|
260
|
-
devToolsHookTypes: [],
|
|
261
260
|
devToolsHookSuppressionDepth: 0,
|
|
262
261
|
};
|
|
263
262
|
instance.owner = owner;
|
|
264
263
|
instance.path = path;
|
|
265
264
|
runtime.instances.set(path, instance);
|
|
265
|
+
indexInstanceKey(runtime, path);
|
|
266
266
|
runtime.activeInstanceKeys?.add(path);
|
|
267
267
|
instance.hookIndex = 0;
|
|
268
268
|
instance.dirty = false;
|
|
269
269
|
instance.disposed = false;
|
|
270
270
|
delete instance.contextDependencies;
|
|
271
|
-
|
|
272
|
-
|
|
271
|
+
if (hasInstalledDevToolsHook()) {
|
|
272
|
+
instance.devToolsHooks = [];
|
|
273
|
+
instance.devToolsHookTypes = [];
|
|
274
|
+
}
|
|
275
|
+
else {
|
|
276
|
+
delete instance.devToolsHooks;
|
|
277
|
+
delete instance.devToolsHookTypes;
|
|
278
|
+
}
|
|
273
279
|
instance.devToolsHookSuppressionDepth = 0;
|
|
274
280
|
hookRenderState.currentRuntime = runtime;
|
|
275
281
|
hookRenderState.currentInstance = instance;
|
|
@@ -300,9 +306,24 @@ export function hasChangedContextDependency(runtime, keys) {
|
|
|
300
306
|
export function hasContextDependency(runtime, keys) {
|
|
301
307
|
return keys.some((key) => runtime.instances.get(key)?.contextDependencies !== undefined);
|
|
302
308
|
}
|
|
309
|
+
export function collectRuntimeInstanceKeys(runtime, prefix) {
|
|
310
|
+
const keys = runtime.instanceKeysByPrefix.get(prefix);
|
|
311
|
+
if (keys === undefined) {
|
|
312
|
+
return [];
|
|
313
|
+
}
|
|
314
|
+
const activeKeys = [];
|
|
315
|
+
for (const key of keys) {
|
|
316
|
+
if (runtime.instances.has(key)) {
|
|
317
|
+
activeKeys.push(key);
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
return activeKeys;
|
|
321
|
+
}
|
|
303
322
|
export function getDevToolsHookState(runtime, path) {
|
|
304
323
|
const instance = runtime.instances.get(path);
|
|
305
|
-
if (instance === undefined
|
|
324
|
+
if (instance === undefined ||
|
|
325
|
+
instance.devToolsHooks === undefined ||
|
|
326
|
+
instance.devToolsHookTypes === undefined) {
|
|
306
327
|
return undefined;
|
|
307
328
|
}
|
|
308
329
|
return {
|
|
@@ -616,12 +637,18 @@ function assignRef(ref, value) {
|
|
|
616
637
|
}
|
|
617
638
|
function recordDevToolsHook(type, value) {
|
|
618
639
|
const instance = hookRenderState.currentInstance;
|
|
619
|
-
if (instance === undefined ||
|
|
640
|
+
if (instance === undefined ||
|
|
641
|
+
instance.devToolsHookSuppressionDepth > 0 ||
|
|
642
|
+
instance.devToolsHooks === undefined ||
|
|
643
|
+
instance.devToolsHookTypes === undefined) {
|
|
620
644
|
return;
|
|
621
645
|
}
|
|
622
646
|
instance.devToolsHookTypes.push(type);
|
|
623
647
|
instance.devToolsHooks.push(value);
|
|
624
648
|
}
|
|
649
|
+
function hasInstalledDevToolsHook() {
|
|
650
|
+
return typeof globalThis.__REACT_DEVTOOLS_GLOBAL_HOOK__?.inject === "function";
|
|
651
|
+
}
|
|
625
652
|
function runWithoutDevToolsHookTracking(callback) {
|
|
626
653
|
const instance = requireInstance();
|
|
627
654
|
instance.devToolsHookSuppressionDepth += 1;
|
|
@@ -1337,9 +1364,40 @@ function cleanupInactiveInstances(runtime) {
|
|
|
1337
1364
|
if (!activeInstanceKeys.has(key)) {
|
|
1338
1365
|
cleanupInstance(instance);
|
|
1339
1366
|
runtime.instances.delete(key);
|
|
1367
|
+
removeInstanceKeyFromIndex(runtime, key);
|
|
1340
1368
|
}
|
|
1341
1369
|
}
|
|
1342
1370
|
}
|
|
1371
|
+
function indexInstanceKey(runtime, key) {
|
|
1372
|
+
for (const prefix of instanceKeyPrefixes(key)) {
|
|
1373
|
+
let keys = runtime.instanceKeysByPrefix.get(prefix);
|
|
1374
|
+
if (keys === undefined) {
|
|
1375
|
+
keys = new Set();
|
|
1376
|
+
runtime.instanceKeysByPrefix.set(prefix, keys);
|
|
1377
|
+
}
|
|
1378
|
+
keys.add(key);
|
|
1379
|
+
}
|
|
1380
|
+
}
|
|
1381
|
+
function removeInstanceKeyFromIndex(runtime, key) {
|
|
1382
|
+
for (const prefix of instanceKeyPrefixes(key)) {
|
|
1383
|
+
const keys = runtime.instanceKeysByPrefix.get(prefix);
|
|
1384
|
+
if (keys === undefined) {
|
|
1385
|
+
continue;
|
|
1386
|
+
}
|
|
1387
|
+
keys.delete(key);
|
|
1388
|
+
if (keys.size === 0) {
|
|
1389
|
+
runtime.instanceKeysByPrefix.delete(prefix);
|
|
1390
|
+
}
|
|
1391
|
+
}
|
|
1392
|
+
}
|
|
1393
|
+
function instanceKeyPrefixes(key) {
|
|
1394
|
+
const parts = key.split(".");
|
|
1395
|
+
const prefixes = [];
|
|
1396
|
+
for (let index = 1; index <= parts.length; index += 1) {
|
|
1397
|
+
prefixes.push(parts.slice(0, index).join("."));
|
|
1398
|
+
}
|
|
1399
|
+
return prefixes;
|
|
1400
|
+
}
|
|
1343
1401
|
function cleanupInstance(instance) {
|
|
1344
1402
|
instance.disposed = true;
|
|
1345
1403
|
for (const slot of instance.hooks) {
|