@reckona/mreact-compat 0.0.160 → 0.0.162

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.
Files changed (102) hide show
  1. package/dist/class-component.d.ts +5 -0
  2. package/dist/class-component.d.ts.map +1 -1
  3. package/dist/class-component.js +36 -11
  4. package/dist/class-component.js.map +1 -1
  5. package/dist/context.d.ts +4 -0
  6. package/dist/context.d.ts.map +1 -1
  7. package/dist/context.js +4 -0
  8. package/dist/context.js.map +1 -1
  9. package/dist/element.d.ts +28 -0
  10. package/dist/element.d.ts.map +1 -1
  11. package/dist/element.js +21 -1
  12. package/dist/element.js.map +1 -1
  13. package/dist/event-priority.d.ts +1 -0
  14. package/dist/event-priority.d.ts.map +1 -1
  15. package/dist/event-priority.js +1 -0
  16. package/dist/event-priority.js.map +1 -1
  17. package/dist/event-replay.d.ts +6 -0
  18. package/dist/event-replay.d.ts.map +1 -1
  19. package/dist/event-replay.js +4 -0
  20. package/dist/event-replay.js.map +1 -1
  21. package/dist/flight-decoder.d.ts +1 -0
  22. package/dist/flight-decoder.d.ts.map +1 -1
  23. package/dist/flight-decoder.js.map +1 -1
  24. package/dist/flight-protocol.d.ts +2 -0
  25. package/dist/flight-protocol.d.ts.map +1 -1
  26. package/dist/flight-protocol.js +1 -0
  27. package/dist/flight-protocol.js.map +1 -1
  28. package/dist/flight-types.d.ts +21 -0
  29. package/dist/flight-types.d.ts.map +1 -1
  30. package/dist/flight-types.js.map +1 -1
  31. package/dist/flight.d.ts +7 -0
  32. package/dist/flight.d.ts.map +1 -1
  33. package/dist/flight.js +5 -0
  34. package/dist/flight.js.map +1 -1
  35. package/dist/hooks-entry.d.ts +2 -0
  36. package/dist/hooks-entry.d.ts.map +1 -1
  37. package/dist/hooks-entry.js +1 -0
  38. package/dist/hooks-entry.js.map +1 -1
  39. package/dist/hooks.d.ts +36 -0
  40. package/dist/hooks.d.ts.map +1 -1
  41. package/dist/hooks.js +42 -10
  42. package/dist/hooks.js.map +1 -1
  43. package/dist/host-reconciler.js +30 -30
  44. package/dist/host-reconciler.js.map +1 -1
  45. package/dist/hydration.d.ts +2 -0
  46. package/dist/hydration.d.ts.map +1 -1
  47. package/dist/hydration.js +1 -0
  48. package/dist/hydration.js.map +1 -1
  49. package/dist/index.d.ts +3 -0
  50. package/dist/index.d.ts.map +1 -1
  51. package/dist/index.js +1 -0
  52. package/dist/index.js.map +1 -1
  53. package/dist/internal.d.ts +1 -0
  54. package/dist/internal.d.ts.map +1 -1
  55. package/dist/internal.js +1 -0
  56. package/dist/internal.js.map +1 -1
  57. package/dist/jsx-dev-runtime.d.ts +5 -0
  58. package/dist/jsx-dev-runtime.d.ts.map +1 -1
  59. package/dist/jsx-dev-runtime.js +3 -0
  60. package/dist/jsx-dev-runtime.js.map +1 -1
  61. package/dist/jsx-runtime.d.ts +13 -0
  62. package/dist/jsx-runtime.d.ts.map +1 -1
  63. package/dist/jsx-runtime.js +4 -0
  64. package/dist/jsx-runtime.js.map +1 -1
  65. package/dist/react-default.d.ts +2 -0
  66. package/dist/react-default.d.ts.map +1 -1
  67. package/dist/react-default.js +2 -0
  68. package/dist/react-default.js.map +1 -1
  69. package/dist/root.d.ts +13 -0
  70. package/dist/root.d.ts.map +1 -1
  71. package/dist/root.js +6 -0
  72. package/dist/root.js.map +1 -1
  73. package/dist/scheduler.d.ts +23 -0
  74. package/dist/scheduler.d.ts.map +1 -1
  75. package/dist/scheduler.js +19 -0
  76. package/dist/scheduler.js.map +1 -1
  77. package/dist/server-render.d.ts +1 -0
  78. package/dist/server-render.d.ts.map +1 -1
  79. package/dist/server-render.js +1 -0
  80. package/dist/server-render.js.map +1 -1
  81. package/package.json +3 -3
  82. package/src/class-component.ts +47 -11
  83. package/src/context.ts +4 -0
  84. package/src/element.ts +33 -6
  85. package/src/event-priority.ts +1 -0
  86. package/src/event-replay.ts +6 -0
  87. package/src/flight-decoder.ts +1 -0
  88. package/src/flight-protocol.ts +2 -0
  89. package/src/flight-types.ts +21 -0
  90. package/src/flight.ts +7 -0
  91. package/src/hooks-entry.ts +2 -0
  92. package/src/hooks.ts +55 -15
  93. package/src/host-reconciler.ts +39 -38
  94. package/src/hydration.ts +2 -0
  95. package/src/index.ts +3 -0
  96. package/src/internal.ts +1 -0
  97. package/src/jsx-dev-runtime.ts +5 -0
  98. package/src/jsx-runtime.ts +13 -0
  99. package/src/react-default.ts +2 -0
  100. package/src/root.ts +13 -0
  101. package/src/scheduler.ts +23 -0
  102. package/src/server-render.ts +1 -0
@@ -734,7 +734,7 @@ function createHostFiberImpl(parent, current, node, key, runtime, path, options
734
734
  !hasUnflushedMountEffectInstance(runtime, previousMemoState.instanceKeys) &&
735
735
  areMemoPropsEqual(memoType, previousMemoState.props, node.props)) {
736
736
  markActiveInstanceKeys(runtime, previousMemoState.instanceKeys);
737
- fiber.child = current?.child;
737
+ fiber.child = getSkippedChild(current);
738
738
  fiber.memoizedState = previousMemoState;
739
739
  return { fiber, consumed: options.previousNodes?.length ?? 0 };
740
740
  }
@@ -815,15 +815,17 @@ function createHostFiberImpl(parent, current, node, key, runtime, path, options
815
815
  const currentClassInstance = current?.tag === "class-component" && current.type === classType
816
816
  ? current.stateNode
817
817
  : undefined;
818
+ const hasCurrentClassFiber = current?.tag === "class-component" && current.type === classType;
818
819
  const rendered = renderClassComponentWithRuntime(classType, node.props, runtime, path, {
819
820
  ...(currentClassInstance === undefined
820
821
  ? {}
821
822
  : { currentInstance: currentClassInstance }),
822
823
  hasDirtyDescendant: hasDirtyInstance(runtime, previousClassChildKeys, `${path}.class`),
824
+ allowSkip: hasCurrentClassFiber,
823
825
  });
824
826
  applyRef(node.ref, rendered.kind === "skip" ? current?.stateNode : rendered.instance);
825
827
  if (rendered.kind === "skip") {
826
- fiber.child = current?.child;
828
+ fiber.child = getSkippedChild(current);
827
829
  return { fiber, consumed: options.previousNodes?.length ?? 0 };
828
830
  }
829
831
  const childOptions = withHydrationComponentStack(options, getComponentName(classType));
@@ -867,7 +869,7 @@ function createHostFiberImpl(parent, current, node, key, runtime, path, options
867
869
  !hasUnflushedMountEffectInstance(runtime, previousFunctionState.instanceKeys) &&
868
870
  !hasPendingAsyncChild(current?.child)) {
869
871
  markActiveInstanceKeys(runtime, previousFunctionState.instanceKeys);
870
- fiber.child = current?.child;
872
+ fiber.child = getSkippedChild(current);
871
873
  fiber.memoizedState = current?.memoizedState;
872
874
  fiber.stateNode = previousFunctionState;
873
875
  return { fiber, consumed: options.previousNodes?.length ?? 0 };
@@ -1026,6 +1028,15 @@ function commitHostDirtyFiber(fiber, parent, eventRoot, path, options = {}) {
1026
1028
  const text = syncDirectHostTextChild(element, directTextChild);
1027
1029
  subscribeReactiveHostTextBinding(props, text);
1028
1030
  }
1031
+ else if (fiber.hostChildListChanged ||
1032
+ fiber.childListChanged ||
1033
+ fiber.subtreeChildListChanged) {
1034
+ const childNodes = commitHostChildren(fiber.child, element, eventRoot, `${path}.c`, options);
1035
+ if (!(childNodes.length === 0 && committedPortalContainers.has(element)) &&
1036
+ !shouldPreserveContentEditableChildren(element, props, childNodes)) {
1037
+ syncChildNodes(element, childNodes);
1038
+ }
1039
+ }
1029
1040
  else if (fiber.subtreeFlags !== NoFlags) {
1030
1041
  commitHostDirtyChildren(fiber.child, element, eventRoot, `${path}.c`, options);
1031
1042
  }
@@ -1119,7 +1130,7 @@ function commitHostKeyedChildListMutationFiber(fiber, parent, eventRoot, path, o
1119
1130
  return true;
1120
1131
  }
1121
1132
  function commitHostAppendSuffix(fiber, parent, eventRoot, path, options) {
1122
- const append = getPlacementAppendSuffix(fiber.child) ?? getAppendSuffix(fiber.alternate?.child, fiber.child);
1133
+ const append = getAppendSuffix(fiber.alternate?.child, fiber.child);
1123
1134
  if (append === undefined) {
1124
1135
  return false;
1125
1136
  }
@@ -1134,31 +1145,6 @@ function commitHostAppendSuffix(fiber, parent, eventRoot, path, options) {
1134
1145
  }
1135
1146
  return true;
1136
1147
  }
1137
- function getPlacementAppendSuffix(next) {
1138
- let nextCursor = next;
1139
- let index = 0;
1140
- while (nextCursor !== undefined) {
1141
- if ((nextCursor.flags & Placement) !== NoFlags) {
1142
- if (index === 0) {
1143
- return undefined;
1144
- }
1145
- let appendCursor = nextCursor;
1146
- while (appendCursor !== undefined) {
1147
- if ((appendCursor.flags & Placement) === NoFlags) {
1148
- return undefined;
1149
- }
1150
- appendCursor = appendCursor.sibling;
1151
- }
1152
- return { fiber: nextCursor, index };
1153
- }
1154
- if (hasHostCommitWork(nextCursor)) {
1155
- return undefined;
1156
- }
1157
- nextCursor = nextCursor.sibling;
1158
- index += 1;
1159
- }
1160
- return undefined;
1161
- }
1162
1148
  function commitHostSingleRemoval(fiber, parent) {
1163
1149
  const removed = getSingleRemovedFiber(fiber.alternate?.child, fiber.child);
1164
1150
  if (removed === undefined) {
@@ -1237,6 +1223,17 @@ function collectCommittedHostNodes(fiber) {
1237
1223
  }
1238
1224
  return nodes;
1239
1225
  }
1226
+ function getSkippedChild(current) {
1227
+ const child = current?.child;
1228
+ const alternateChild = current?.alternate?.child;
1229
+ if (child !== undefined &&
1230
+ alternateChild !== undefined &&
1231
+ collectCommittedHostNodes(child).length === 0 &&
1232
+ collectCommittedHostNodes(alternateChild).length > 0) {
1233
+ return alternateChild;
1234
+ }
1235
+ return child;
1236
+ }
1240
1237
  function finishHostPassthroughFiber(fiber) {
1241
1238
  fiber.memoizedProps = fiber.pendingProps;
1242
1239
  finishCommittedFiber(fiber);
@@ -1265,7 +1262,9 @@ function commitHostFiber(fiber, parent, eventRoot, path, options = {}) {
1265
1262
  if (fiber.hydrateExisting !== true &&
1266
1263
  fiber.flags === NoFlags &&
1267
1264
  fiber.subtreeFlags === NoFlags &&
1268
- fiber.hostChildListChanged !== true) {
1265
+ fiber.hostChildListChanged !== true &&
1266
+ fiber.childListChanged !== true &&
1267
+ fiber.subtreeChildListChanged !== true) {
1269
1268
  fiber.memoizedProps = fiber.pendingProps;
1270
1269
  return [element];
1271
1270
  }
@@ -1302,6 +1301,7 @@ function commitHostFiber(fiber, parent, eventRoot, path, options = {}) {
1302
1301
  }
1303
1302
  else if (fiber.hostChildListChanged ||
1304
1303
  fiber.childListChanged ||
1304
+ fiber.subtreeChildListChanged ||
1305
1305
  fiber.hydrateExisting === true ||
1306
1306
  (fiber.subtreeFlags & Placement) !== NoFlags) {
1307
1307
  const childNodes = commitHostChildren(fiber.child, element, eventRoot, `${path}.c`, options);