@reckona/mreact-compat 0.0.153 → 0.0.155
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 +0 -21
- package/dist/dom-props.js.map +1 -1
- package/dist/element.d.ts +0 -1
- package/dist/element.d.ts.map +1 -1
- package/dist/element.js +2 -41
- package/dist/element.js.map +1 -1
- package/dist/host-reconciler.d.ts.map +1 -1
- package/dist/host-reconciler.js +37 -32
- package/dist/host-reconciler.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/react-default.d.ts +2 -1
- package/dist/react-default.d.ts.map +1 -1
- package/dist/react-default.js +2 -1
- package/dist/react-default.js.map +1 -1
- package/dist/server-render.d.ts +1 -0
- package/dist/server-render.d.ts.map +1 -1
- package/dist/server-render.js +92 -38
- package/dist/server-render.js.map +1 -1
- package/package.json +3 -3
- package/src/dom-props.ts +0 -30
- package/src/element.ts +4 -57
- package/src/host-reconciler.ts +43 -36
- package/src/index.ts +1 -1
- package/src/react-default.ts +2 -1
- package/src/server-render.ts +104 -45
package/dist/host-reconciler.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Activity, ERROR_BOUNDARY_TYPE, FORWARD_REF_TYPE, Fragment, HOST_CHILDREN_ONLY_PROPS_META,
|
|
1
|
+
import { Activity, ERROR_BOUNDARY_TYPE, FORWARD_REF_TYPE, Fragment, HOST_CHILDREN_ONLY_PROPS_META, LAZY_TYPE, MEMO_TYPE, Profiler, REACTIVE_TEXT_BINDING_META, STRICT_MODE_TYPE, Suspense, SuspenseList, isReactCompatElement, isReactCompatPortal, } from "./element.js";
|
|
2
2
|
import { consumerContext, isReactCompatConsumer, isReactCompatProvider, renderWithContextProvider, useContext, } from "./context.js";
|
|
3
3
|
import { applyPostChildFormProps, applyProps } from "./dom-props.js";
|
|
4
4
|
import { syncChildNodes, syncOwnedChildNodes, syncScopedChildNodes } from "./dom-children.js";
|
|
@@ -346,8 +346,8 @@ function getReusableKeyedRowHostFiber(current, row) {
|
|
|
346
346
|
return undefined;
|
|
347
347
|
}
|
|
348
348
|
const previousRecord = previousProps;
|
|
349
|
-
if (
|
|
350
|
-
|
|
349
|
+
if (getDirectHostTextChild(previousRecord.children) !== row.text ||
|
|
350
|
+
!hostOwnPropsEqual(previousRecord, row.element.props)) {
|
|
351
351
|
return undefined;
|
|
352
352
|
}
|
|
353
353
|
current.pendingProps = row.element.props;
|
|
@@ -364,7 +364,6 @@ function createKeyedRowHostElementScratch() {
|
|
|
364
364
|
element: undefined,
|
|
365
365
|
key: "",
|
|
366
366
|
type: "",
|
|
367
|
-
meta: 0,
|
|
368
367
|
text: "",
|
|
369
368
|
};
|
|
370
369
|
}
|
|
@@ -375,16 +374,15 @@ function readKeyedRowHostElement(node, row) {
|
|
|
375
374
|
node.ref !== null) {
|
|
376
375
|
return false;
|
|
377
376
|
}
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
const text =
|
|
381
|
-
if (
|
|
377
|
+
// Any keyed host row whose children collapse to a single text value
|
|
378
|
+
// qualifies; row props are compared per reuse with hostOwnPropsEqual.
|
|
379
|
+
const text = getDirectHostTextChild(node.props.children);
|
|
380
|
+
if (text === undefined) {
|
|
382
381
|
return false;
|
|
383
382
|
}
|
|
384
383
|
row.element = node;
|
|
385
384
|
row.key = node.key;
|
|
386
385
|
row.type = node.type;
|
|
387
|
-
row.meta = meta;
|
|
388
386
|
row.text = text;
|
|
389
387
|
return true;
|
|
390
388
|
}
|
|
@@ -412,11 +410,8 @@ function createKeyedRowHostFiber(parent, current, row, options) {
|
|
|
412
410
|
return fiber;
|
|
413
411
|
}
|
|
414
412
|
const previousProps = current.memoizedProps ?? current.pendingProps;
|
|
415
|
-
const previousMeta = typeof previousProps === "object" && previousProps !== null
|
|
416
|
-
? getHostOwnPropsMeta(previousProps)
|
|
417
|
-
: undefined;
|
|
418
413
|
const previousText = getDirectHostTextChild(hostFiberChildrenProp(previousProps));
|
|
419
|
-
if (
|
|
414
|
+
if (previousText !== row.text || !hostOwnPropsEqual(previousProps, row.element.props)) {
|
|
420
415
|
fiber.flags |= Update;
|
|
421
416
|
}
|
|
422
417
|
return fiber;
|
|
@@ -1015,7 +1010,9 @@ function commitHostDirtyFiber(fiber, parent, eventRoot, path, options = {}) {
|
|
|
1015
1010
|
(fiber.hydrateExisting !== true &&
|
|
1016
1011
|
hostPropsAreChildrenOnly(fiber.memoizedProps) &&
|
|
1017
1012
|
hostPropsAreChildrenOnly(props));
|
|
1018
|
-
const textOnlyRowUpdate =
|
|
1013
|
+
const textOnlyRowUpdate = !propsAreUnchanged &&
|
|
1014
|
+
!propsAreChildrenOnly &&
|
|
1015
|
+
fiber.hydrateExisting !== true &&
|
|
1019
1016
|
isRowTextOnlyUpdate(fiber.memoizedProps, props);
|
|
1020
1017
|
if (!propsAreUnchanged && !propsAreChildrenOnly && !textOnlyRowUpdate) {
|
|
1021
1018
|
applyProps(element, props, path, {
|
|
@@ -1287,7 +1284,9 @@ function commitHostFiber(fiber, parent, eventRoot, path, options = {}) {
|
|
|
1287
1284
|
(fiber.hydrateExisting !== true &&
|
|
1288
1285
|
hostPropsAreChildrenOnly(fiber.memoizedProps) &&
|
|
1289
1286
|
hostPropsAreChildrenOnly(props));
|
|
1290
|
-
const textOnlyRowUpdate =
|
|
1287
|
+
const textOnlyRowUpdate = !propsAreUnchanged &&
|
|
1288
|
+
!propsAreChildrenOnly &&
|
|
1289
|
+
fiber.hydrateExisting !== true &&
|
|
1291
1290
|
isRowTextOnlyUpdate(fiber.memoizedProps, props);
|
|
1292
1291
|
if (!propsAreUnchanged && !propsAreChildrenOnly && !textOnlyRowUpdate) {
|
|
1293
1292
|
applyProps(element, props, path, {
|
|
@@ -1459,11 +1458,6 @@ function hostOwnPropsEqual(previous, next) {
|
|
|
1459
1458
|
return false;
|
|
1460
1459
|
}
|
|
1461
1460
|
const previousProps = previous;
|
|
1462
|
-
const previousMeta = getHostOwnPropsMeta(previousProps);
|
|
1463
|
-
const nextMeta = getHostOwnPropsMeta(next);
|
|
1464
|
-
if (previousMeta !== undefined && nextMeta !== undefined) {
|
|
1465
|
-
return previousMeta === nextMeta;
|
|
1466
|
-
}
|
|
1467
1461
|
let previousCount = 0;
|
|
1468
1462
|
let nextCount = 0;
|
|
1469
1463
|
for (const key in previousProps) {
|
|
@@ -1485,9 +1479,6 @@ function hostOwnPropsEqual(previous, next) {
|
|
|
1485
1479
|
}
|
|
1486
1480
|
return previousCount === nextCount;
|
|
1487
1481
|
}
|
|
1488
|
-
function getHostOwnPropsMeta(props) {
|
|
1489
|
-
return props[HOST_OWN_PROPS_META];
|
|
1490
|
-
}
|
|
1491
1482
|
function hostDirectTextChildChanged(previous, next) {
|
|
1492
1483
|
const previousText = getDirectHostTextChild(hostFiberChildrenProp(previous));
|
|
1493
1484
|
const nextText = getDirectHostTextChild(next.children);
|
|
@@ -1556,14 +1547,12 @@ function isRowTextOnlyUpdate(previous, next) {
|
|
|
1556
1547
|
return false;
|
|
1557
1548
|
}
|
|
1558
1549
|
const previousProps = previous;
|
|
1559
|
-
const previousMeta = getHostOwnPropsMeta(previousProps);
|
|
1560
|
-
const nextMeta = getHostOwnPropsMeta(next);
|
|
1561
|
-
if (previousMeta === undefined || previousMeta !== nextMeta) {
|
|
1562
|
-
return false;
|
|
1563
|
-
}
|
|
1564
1550
|
const previousText = getDirectHostTextChild(previousProps.children);
|
|
1565
1551
|
const nextText = getDirectHostTextChild(next.children);
|
|
1566
|
-
return previousText !== undefined &&
|
|
1552
|
+
return (previousText !== undefined &&
|
|
1553
|
+
nextText !== undefined &&
|
|
1554
|
+
previousText !== nextText &&
|
|
1555
|
+
hostOwnPropsEqual(previousProps, next));
|
|
1567
1556
|
}
|
|
1568
1557
|
function hostFiberChildrenProp(props) {
|
|
1569
1558
|
return typeof props === "object" && props !== null
|
|
@@ -1575,10 +1564,26 @@ function getDirectHostTextChild(children) {
|
|
|
1575
1564
|
? String(children)
|
|
1576
1565
|
: undefined;
|
|
1577
1566
|
}
|
|
1567
|
+
const hostFastPathMode = (() => {
|
|
1568
|
+
try {
|
|
1569
|
+
// The literal process.env.NODE_ENV member expression is what bundler
|
|
1570
|
+
// define rewriting matches; a globalThis.process indirection is never
|
|
1571
|
+
// rewritten and leaves deployed browser bundles without any fast path.
|
|
1572
|
+
return process.env.NODE_ENV === "production" ? "static-fast" : "dynamic";
|
|
1573
|
+
}
|
|
1574
|
+
catch {
|
|
1575
|
+
// No process global at all: an unbundled browser runtime. Treat it as
|
|
1576
|
+
// production rather than running every host update on the slow path.
|
|
1577
|
+
return "static-fast";
|
|
1578
|
+
}
|
|
1579
|
+
})();
|
|
1578
1580
|
function shouldUseDirectHostTextChild() {
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1581
|
+
if (hostFastPathMode === "static-fast") {
|
|
1582
|
+
return true;
|
|
1583
|
+
}
|
|
1584
|
+
// Node dev/test environments keep the per-call env read so test harnesses
|
|
1585
|
+
// can flip NODE_ENV (vi.stubEnv) without re-importing this module.
|
|
1586
|
+
return process.env.NODE_ENV === "production";
|
|
1582
1587
|
}
|
|
1583
1588
|
function syncDirectHostTextChild(element, text) {
|
|
1584
1589
|
const firstChild = element.firstChild;
|