@my-react/react-reconciler-compact 0.0.15 → 0.0.17

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.
@@ -819,12 +819,13 @@ function requireIndex_development () {
819
819
 
820
820
  var currentRunningFiber$5 = typeExports.__my_react_internal__.currentRunningFiber, currentScheduler$h = typeExports.__my_react_internal__.currentScheduler, currentScopeFiber$1 = typeExports.__my_react_internal__.currentScopeFiber, currentError$1 = typeExports.__my_react_internal__.currentError, currentCallingFiber$1 = typeExports.__my_react_internal__.currentCallingFiber;
821
821
  var safeCall = function (action) {
822
+ var _a;
822
823
  var args = [];
823
824
  for (var _i = 1; _i < arguments.length; _i++) {
824
825
  args[_i - 1] = arguments[_i];
825
826
  }
826
827
  try {
827
- return action.call.apply(action, __spreadArray([null], args, false));
828
+ return (_a = action === null || action === void 0 ? void 0 : action.call) === null || _a === void 0 ? void 0 : _a.call.apply(_a, __spreadArray([action, null], args, false));
828
829
  }
829
830
  catch (e) {
830
831
  var fiber = (currentCallingFiber$1 === null || currentCallingFiber$1 === void 0 ? void 0 : currentCallingFiber$1[(currentCallingFiber$1 === null || currentCallingFiber$1 === void 0 ? void 0 : currentCallingFiber$1.length) - 1]) || currentScopeFiber$1.current || currentRunningFiber$5.current;
@@ -834,6 +835,7 @@ function requireIndex_development () {
834
835
  }
835
836
  };
836
837
  var safeCallWithCurrentFiber = function (_a) {
838
+ var _b;
837
839
  var action = _a.action, fiber = _a.fiber, fallback = _a.fallback;
838
840
  var args = [];
839
841
  for (var _i = 1; _i < arguments.length; _i++) {
@@ -841,7 +843,7 @@ function requireIndex_development () {
841
843
  }
842
844
  currentCallingFiber$1.push(fiber);
843
845
  try {
844
- return action.call.apply(action, __spreadArray([null], args, false));
846
+ return (_b = action === null || action === void 0 ? void 0 : action.call) === null || _b === void 0 ? void 0 : _b.call.apply(_b, __spreadArray([action, null], args, false));
845
847
  }
846
848
  catch (e) {
847
849
  if (fallback) {
@@ -858,6 +860,7 @@ function requireIndex_development () {
858
860
  }
859
861
  };
860
862
  var callWithFiber = function (_a) {
863
+ var _b;
861
864
  var action = _a.action, fiber = _a.fiber;
862
865
  var args = [];
863
866
  for (var _i = 1; _i < arguments.length; _i++) {
@@ -865,20 +868,21 @@ function requireIndex_development () {
865
868
  }
866
869
  currentScopeFiber$1.current = fiber;
867
870
  try {
868
- return action.call.apply(action, __spreadArray([null], args, false));
871
+ return (_b = action === null || action === void 0 ? void 0 : action.call) === null || _b === void 0 ? void 0 : _b.call.apply(_b, __spreadArray([action, null], args, false));
869
872
  }
870
873
  finally {
871
874
  currentScopeFiber$1.current = null;
872
875
  }
873
876
  };
874
877
  var safeCallWithSync = function (action) {
878
+ var _a;
875
879
  var args = [];
876
880
  for (var _i = 1; _i < arguments.length; _i++) {
877
881
  args[_i - 1] = arguments[_i];
878
882
  }
879
883
  try {
880
884
  beforeSyncUpdate();
881
- return action.call.apply(action, __spreadArray([null], args, false));
885
+ return (_a = action === null || action === void 0 ? void 0 : action.call) === null || _a === void 0 ? void 0 : _a.call.apply(_a, __spreadArray([action, null], args, false));
882
886
  }
883
887
  catch (e) {
884
888
  var fiber = (currentCallingFiber$1 === null || currentCallingFiber$1 === void 0 ? void 0 : currentCallingFiber$1[(currentCallingFiber$1 === null || currentCallingFiber$1 === void 0 ? void 0 : currentCallingFiber$1.length) - 1]) || currentScopeFiber$1.current || currentRunningFiber$5.current;
@@ -4476,9 +4480,11 @@ function requireIndex_development () {
4476
4480
  var renderScheduler = currentScheduler$7.current;
4477
4481
  var currentHook = (_b = currentHookTreeNode$1.current) === null || _b === void 0 ? void 0 : _b.value;
4478
4482
  if (!currentHook) {
4479
- throw new Error("[@my-react/react] should have a hookList for current node, this is a bug for @my-react");
4483
+ // throw new Error(`[@my-react/react] should have a hookList for current node, this is a bug for @my-react`);
4484
+ return createHookNode(renderDispatch, { type: type, value: value, reducer: reducer, deps: deps }, fiber);
4480
4485
  }
4481
4486
  if (type !== (currentHook === null || currentHook === void 0 ? void 0 : currentHook.type)) {
4487
+ // only throw error when type not match
4482
4488
  throw new Error(getHookTree(currentHookTreeNode$1.current.prev, {
4483
4489
  lastRender: currentHook === null || currentHook === void 0 ? void 0 : currentHook.type,
4484
4490
  nextRender: type,
@@ -7107,7 +7113,7 @@ function requireIndex_development () {
7107
7113
  _this.isAppMounted = false;
7108
7114
  _this.isAppCrashed = false;
7109
7115
  _this.isAppUnmounted = false;
7110
- _this.version = "0.3.24";
7116
+ _this.version = "0.3.26";
7111
7117
  _this.id = Math.random().toString(16).slice(2);
7112
7118
  _this.mode = "development" ;
7113
7119
  _this.renderMode = "render";
@@ -7153,9 +7159,7 @@ function requireIndex_development () {
7153
7159
  if (include(_fiber.type, this.runtimeRef.typeForRef)) {
7154
7160
  _fiber.patch = merge(_fiber.patch, PATCH_TYPE.__ref__);
7155
7161
  }
7156
- else if (exclude(_fiber.type, exports$1.NODE_TYPE.__forwardRef__)) {
7157
- onceWarnWithKeyAndFiber(_fiber, "ref", "[@my-react/react] set ref for current element will be ignored");
7158
- }
7162
+ else if (exclude(_fiber.type, exports$1.NODE_TYPE.__forwardRef__)) ;
7159
7163
  }
7160
7164
  };
7161
7165
  CustomRenderDispatch.prototype.pendingUnmount = function (_fiber, _pendingUnmount) {
@@ -7365,7 +7369,7 @@ function requireIndex_development () {
7365
7369
  });
7366
7370
  }); };
7367
7371
 
7368
- var version = "0.3.24";
7372
+ var version = "0.3.26";
7369
7373
 
7370
7374
  exports$1.CustomRenderDispatch = CustomRenderDispatch;
7371
7375
  exports$1.MyReactFiberNode = MyReactFiberNode;
@@ -8899,6 +8903,7 @@ var currentScheduler = typeExports.__my_react_internal__.currentScheduler;
8899
8903
  // react-reconciler compat implementation
8900
8904
  var Reconciler = function (_config) {
8901
8905
  var rendererPackageName = "@my-react";
8906
+ var isRendering = false;
8902
8907
  var ReconcilerSet = new Set();
8903
8908
  if (enableKnownConfigLog.current) {
8904
8909
  knownConfig(_config);
@@ -8906,11 +8911,9 @@ var Reconciler = function (_config) {
8906
8911
  var createContainer = function (_container, flag) {
8907
8912
  prepareScheduler();
8908
8913
  if (flag === 0) {
8909
- // legacy mode
8910
8914
  _container.__flag__ = 0;
8911
8915
  }
8912
8916
  else {
8913
- // concurrent mode
8914
8917
  _container.__flag__ = 1;
8915
8918
  }
8916
8919
  enableDebugFiled.current = true;
@@ -8919,49 +8922,60 @@ var Reconciler = function (_config) {
8919
8922
  myreactReconcilerExports.enableFiberForLog.current = false;
8920
8923
  return _container;
8921
8924
  };
8925
+ var createHydrationContainer = function (_initialChildren, _callback, _container, flag, _hydrationCallbacks, _isStrictMode, _concurrentUpdatesByDefaultOverride, _identifierPrefix, _onRecoverableError, _transitionCallbacks) {
8926
+ var opaqueRoot = createContainer(_container, flag);
8927
+ updateContainer(_initialChildren, opaqueRoot, null, _callback !== null && _callback !== void 0 ? _callback : (function () { }));
8928
+ return opaqueRoot;
8929
+ };
8922
8930
  var updateContainer = function (_element, _container, _ignore, _cb) {
8923
8931
  var _a;
8924
8932
  var renderDispatch = _container.__container__;
8925
8933
  var renderScheduler = currentScheduler.current;
8926
- if (renderDispatch instanceof myreactReconcilerExports.CustomRenderDispatch) {
8927
- var _fiber_1 = _container.__fiber__;
8928
- if (renderDispatch.isAppCrashed || include(_fiber_1.state, STATE_TYPE.__unmount__)) {
8929
- // is there are not a valid render tree, try do the pure rerender
8930
- _container.__fiber__ = null;
8931
- _container.__container__ = null;
8932
- updateContainer(_element, _container, _config, _cb);
8933
- return;
8934
- }
8935
- if (myreactReconcilerExports.checkIsSameType(_fiber_1, _element)) {
8936
- _fiber_1._installElement(_element);
8937
- myreactReconcilerExports.triggerUpdateOnFiber(_fiber_1, STATE_TYPE.__triggerSync__, _cb);
8938
- return;
8934
+ isRendering = true;
8935
+ try {
8936
+ if (renderDispatch instanceof myreactReconcilerExports.CustomRenderDispatch) {
8937
+ var _fiber_1 = _container.__fiber__;
8938
+ if (renderDispatch.isAppCrashed || include(_fiber_1.state, STATE_TYPE.__unmount__)) {
8939
+ _container.__fiber__ = null;
8940
+ _container.__container__ = null;
8941
+ updateContainer(_element, _container, _config, _cb);
8942
+ return;
8943
+ }
8944
+ if (myreactReconcilerExports.checkIsSameType(_fiber_1, _element)) {
8945
+ _fiber_1._installElement(_element);
8946
+ myreactReconcilerExports.triggerUpdateOnFiber(_fiber_1, STATE_TYPE.__triggerSync__, _cb);
8947
+ return;
8948
+ }
8949
+ myreactReconcilerExports.unmountContainer(renderDispatch);
8950
+ (_a = _config === null || _config === void 0 ? void 0 : _config.clearContainer) === null || _a === void 0 ? void 0 : _a.call(_config, _container);
8951
+ ReconcilerSet.delete(renderDispatch);
8952
+ renderScheduler.dispatchSet.uniDelete(renderDispatch);
8953
+ delGlobalDispatch(renderDispatch);
8939
8954
  }
8940
- myreactReconcilerExports.unmountContainer(renderDispatch);
8941
- (_a = _config === null || _config === void 0 ? void 0 : _config.clearContainer) === null || _a === void 0 ? void 0 : _a.call(_config, _container);
8942
- ReconcilerSet.delete(renderDispatch);
8943
- renderScheduler.dispatchSet.uniDelete(renderDispatch);
8944
- delGlobalDispatch(renderDispatch);
8955
+ var _fiber = new myreactReconcilerExports.MyReactFiberNode(_element);
8956
+ var _renderDispatch = createDispatch(_container, _fiber, _element, _config, _container.__flag__);
8957
+ _cb && _renderDispatch.pendingEffect(_fiber, _cb);
8958
+ ReconcilerSet.add(_renderDispatch);
8959
+ renderScheduler.dispatchSet.uniPush(_renderDispatch);
8960
+ _renderDispatch.renderPackage = rendererPackageName;
8961
+ _container.__fiber__ = _fiber;
8962
+ _container.__container__ = _renderDispatch;
8963
+ autoSetDevTools(_renderDispatch);
8964
+ autoSetDevHMR(_renderDispatch);
8965
+ myreactReconcilerExports.initialFiberNode(_renderDispatch, _fiber);
8966
+ myreactReconcilerExports.mountSync(_renderDispatch, _fiber);
8967
+ _renderDispatch.isAppMounted = true;
8968
+ }
8969
+ finally {
8970
+ isRendering = false;
8945
8971
  }
8946
- var _fiber = new myreactReconcilerExports.MyReactFiberNode(_element);
8947
- var _renderDispatch = createDispatch(_container, _fiber, _element, _config, _container.__flag__);
8948
- _cb && _renderDispatch.pendingEffect(_fiber, _cb);
8949
- ReconcilerSet.add(_renderDispatch);
8950
- renderScheduler.dispatchSet.uniPush(_renderDispatch);
8951
- _renderDispatch.renderPackage = rendererPackageName;
8952
- _container.__fiber__ = _fiber;
8953
- _container.__container__ = _renderDispatch;
8954
- autoSetDevTools(_renderDispatch);
8955
- autoSetDevHMR(_renderDispatch);
8956
- myreactReconcilerExports.initialFiberNode(_renderDispatch, _fiber);
8957
- myreactReconcilerExports.mountSync(_renderDispatch, _fiber);
8958
- _renderDispatch.isAppMounted = true;
8959
8972
  };
8960
8973
  var injectIntoDevTools = function (_config) {
8961
8974
  rendererPackageName = _config.rendererPackageName || rendererPackageName;
8962
8975
  ReconcilerSet.forEach(function (renderDispatch) { return (renderDispatch.renderPackage = rendererPackageName); });
8963
8976
  if (globalThis["__MY_REACT_DEVTOOL_INTERNAL__"])
8964
- return;
8977
+ return true;
8978
+ return false;
8965
8979
  };
8966
8980
  var injectIntoDevToolsAuto = function (url, _config) { return __awaiter(void 0, void 0, void 0, function () {
8967
8981
  var init;
@@ -8987,25 +9001,179 @@ var Reconciler = function (_config) {
8987
9001
  });
8988
9002
  }); };
8989
9003
  var getPublicRootInstance = function (_container) {
8990
- return _container.__container__;
9004
+ var fiber = _container.__fiber__;
9005
+ if (!fiber || !fiber.child) {
9006
+ return null;
9007
+ }
9008
+ return fiber.child.nativeNode;
9009
+ };
9010
+ var discreteUpdates = function (fn, a, b, c, d) {
9011
+ myreactReconcilerExports.beforeSyncUpdate();
9012
+ try {
9013
+ return fn(a, b, c, d);
9014
+ }
9015
+ finally {
9016
+ myreactReconcilerExports.afterSyncUpdate();
9017
+ }
9018
+ };
9019
+ var updateContainerSync = function (element, container, ignore, callback) {
9020
+ myreactReconcilerExports.beforeSyncUpdate();
9021
+ try {
9022
+ updateContainer(element, container, ignore, callback);
9023
+ }
9024
+ finally {
9025
+ myreactReconcilerExports.afterSyncUpdate();
9026
+ }
9027
+ };
9028
+ var flushPassiveEffects = function () {
9029
+ try {
9030
+ myreactReconcilerExports.flushEffectCallback();
9031
+ return true;
9032
+ }
9033
+ catch (_a) {
9034
+ return false;
9035
+ }
9036
+ };
9037
+ var isAlreadyRendering = function () {
9038
+ return isRendering;
9039
+ };
9040
+ var deferredUpdates = function (fn) {
9041
+ return fn();
9042
+ };
9043
+ var findHostInstance = function (component) {
9044
+ try {
9045
+ var fiber = myreactReconcilerExports.getInstanceOwnerFiber(component);
9046
+ if (!fiber)
9047
+ return null;
9048
+ var current = fiber;
9049
+ while (current) {
9050
+ if (current.nativeNode && typeof current.type === "string") {
9051
+ return (_config === null || _config === void 0 ? void 0 : _config.getPublicInstance) ? _config.getPublicInstance(current.nativeNode) : current.nativeNode;
9052
+ }
9053
+ current = current.child;
9054
+ }
9055
+ return null;
9056
+ }
9057
+ catch (_a) {
9058
+ return null;
9059
+ }
9060
+ };
9061
+ var findHostInstanceWithWarning = function (component, _methodName) {
9062
+ return findHostInstance(component);
9063
+ };
9064
+ var findHostInstanceWithNoPortals = function (fiber) {
9065
+ return findHostInstance(fiber);
9066
+ };
9067
+ var attemptSynchronousHydration = function (_fiber) {
9068
+ // no-op: hydration not yet supported in MyReact reconciler-compact
9069
+ };
9070
+ var attemptDiscreteHydration = function (_fiber) {
9071
+ // no-op
9072
+ };
9073
+ var attemptContinuousHydration = function (_fiber) {
9074
+ // no-op
9075
+ };
9076
+ var attemptHydrationAtCurrentPriority = function (_fiber) {
9077
+ // no-op
9078
+ };
9079
+ var getCurrentUpdatePriority = function () {
9080
+ return 0;
9081
+ };
9082
+ var runWithPriority = function (_priority, fn) {
9083
+ return fn();
9084
+ };
9085
+ var shouldErrorImpl = null;
9086
+ var shouldSuspendImpl = null;
9087
+ var shouldError = function (fiber) {
9088
+ return shouldErrorImpl ? shouldErrorImpl(fiber) : undefined;
9089
+ };
9090
+ var shouldSuspend = function (fiber) {
9091
+ return shouldSuspendImpl ? shouldSuspendImpl(fiber) : false;
9092
+ };
9093
+ var registerMutableSourceForHydration = function (_root, _mutableSource) {
9094
+ // no-op
9095
+ };
9096
+ var createComponentSelector = function (component) { return ({ $$typeof: Symbol.for("react.test.selector"), value: component }); };
9097
+ var createHasPseudoClassSelector = function (selectors) { return ({ $$typeof: Symbol.for("react.test.selector"), value: selectors }); };
9098
+ var createRoleSelector = function (role) { return ({ $$typeof: Symbol.for("react.test.selector"), value: role }); };
9099
+ var createTextSelector = function (text) { return ({ $$typeof: Symbol.for("react.test.selector"), value: text }); };
9100
+ var createTestNameSelector = function (id) { return ({ $$typeof: Symbol.for("react.test.selector"), value: id }); };
9101
+ var getFindAllNodesFailureDescription = function (_hostRoot, _selectors) {
9102
+ return null;
9103
+ };
9104
+ var findAllNodes = function (_hostRoot, _selectors) {
9105
+ return [];
9106
+ };
9107
+ var findBoundingRects = function (_hostRoot, _selectors) {
9108
+ return [];
9109
+ };
9110
+ var focusWithin = function (_hostRoot, _selectors) {
9111
+ return false;
9112
+ };
9113
+ var observeVisibleRects = function (_hostRoot, _selectors, _callback, _options) {
9114
+ return { disconnect: function () { } };
8991
9115
  };
8992
9116
  return {
8993
9117
  createPortal: createPortal,
8994
9118
  createContainer: createContainer,
9119
+ createHydrationContainer: createHydrationContainer,
8995
9120
  updateContainer: updateContainer,
9121
+ updateContainerSync: updateContainerSync,
8996
9122
  injectIntoDevTools: injectIntoDevTools,
8997
9123
  getPublicRootInstance: getPublicRootInstance,
8998
9124
  injectIntoDevToolsAuto: injectIntoDevToolsAuto,
8999
9125
  flushSync: myreactReconcilerExports.safeCallWithSync,
9000
9126
  flushSyncWork: myreactReconcilerExports.safeCallWithSync,
9001
9127
  batchedUpdates: myreactReconcilerExports.safeCallWithSync,
9128
+ discreteUpdates: discreteUpdates,
9129
+ deferredUpdates: deferredUpdates,
9130
+ flushPassiveEffects: flushPassiveEffects,
9131
+ isAlreadyRendering: isAlreadyRendering,
9132
+ findHostInstance: findHostInstance,
9133
+ findHostInstanceWithWarning: findHostInstanceWithWarning,
9134
+ findHostInstanceWithNoPortals: findHostInstanceWithNoPortals,
9135
+ attemptSynchronousHydration: attemptSynchronousHydration,
9136
+ attemptDiscreteHydration: attemptDiscreteHydration,
9137
+ attemptContinuousHydration: attemptContinuousHydration,
9138
+ attemptHydrationAtCurrentPriority: attemptHydrationAtCurrentPriority,
9139
+ getCurrentUpdatePriority: getCurrentUpdatePriority,
9140
+ runWithPriority: runWithPriority,
9141
+ shouldError: shouldError,
9142
+ shouldSuspend: shouldSuspend,
9143
+ registerMutableSourceForHydration: registerMutableSourceForHydration,
9144
+ createComponentSelector: createComponentSelector,
9145
+ createHasPseudoClassSelector: createHasPseudoClassSelector,
9146
+ createRoleSelector: createRoleSelector,
9147
+ createTextSelector: createTextSelector,
9148
+ createTestNameSelector: createTestNameSelector,
9149
+ getFindAllNodesFailureDescription: getFindAllNodesFailureDescription,
9150
+ findAllNodes: findAllNodes,
9151
+ findBoundingRects: findBoundingRects,
9152
+ focusWithin: focusWithin,
9153
+ observeVisibleRects: observeVisibleRects,
9002
9154
  };
9003
9155
  };
9004
9156
 
9005
- var version = "0.0.15";
9157
+ var version = "0.0.17";
9006
9158
  var createReconciler = Reconciler;
9159
+ var defaultOnUncaughtError = function (error) {
9160
+ console.error("Uncaught", error);
9161
+ };
9162
+ var defaultOnCaughtError = function (error) {
9163
+ console.error("Caught", error);
9164
+ };
9165
+ var defaultOnRecoverableError = function (error) {
9166
+ console.error("Recoverable", error);
9167
+ };
9168
+ var startHostTransition = function () {
9169
+ // no-op
9170
+ };
9007
9171
 
9008
9172
  exports.createReconciler = createReconciler;
9009
9173
  exports.default = createReconciler;
9174
+ exports.defaultOnCaughtError = defaultOnCaughtError;
9175
+ exports.defaultOnRecoverableError = defaultOnRecoverableError;
9176
+ exports.defaultOnUncaughtError = defaultOnUncaughtError;
9010
9177
  exports.enableKnownConfigLog = enableKnownConfigLog;
9178
+ exports.startHostTransition = startHostTransition;
9011
9179
  exports.version = version;