@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.
@@ -812,12 +812,13 @@ function requireIndex_production () {
812
812
 
813
813
  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;
814
814
  var safeCall = function (action) {
815
+ var _a;
815
816
  var args = [];
816
817
  for (var _i = 1; _i < arguments.length; _i++) {
817
818
  args[_i - 1] = arguments[_i];
818
819
  }
819
820
  try {
820
- return action.call.apply(action, __spreadArray([null], args, false));
821
+ 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));
821
822
  }
822
823
  catch (e) {
823
824
  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;
@@ -827,6 +828,7 @@ function requireIndex_production () {
827
828
  }
828
829
  };
829
830
  var safeCallWithCurrentFiber = function (_a) {
831
+ var _b;
830
832
  var action = _a.action, fiber = _a.fiber, fallback = _a.fallback;
831
833
  var args = [];
832
834
  for (var _i = 1; _i < arguments.length; _i++) {
@@ -834,7 +836,7 @@ function requireIndex_production () {
834
836
  }
835
837
  currentCallingFiber$1.push(fiber);
836
838
  try {
837
- return action.call.apply(action, __spreadArray([null], args, false));
839
+ 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));
838
840
  }
839
841
  catch (e) {
840
842
  if (fallback) {
@@ -851,6 +853,7 @@ function requireIndex_production () {
851
853
  }
852
854
  };
853
855
  var callWithFiber = function (_a) {
856
+ var _b;
854
857
  var action = _a.action, fiber = _a.fiber;
855
858
  var args = [];
856
859
  for (var _i = 1; _i < arguments.length; _i++) {
@@ -858,20 +861,21 @@ function requireIndex_production () {
858
861
  }
859
862
  currentScopeFiber$1.current = fiber;
860
863
  try {
861
- return action.call.apply(action, __spreadArray([null], args, false));
864
+ 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));
862
865
  }
863
866
  finally {
864
867
  currentScopeFiber$1.current = null;
865
868
  }
866
869
  };
867
870
  var safeCallWithSync = function (action) {
871
+ var _a;
868
872
  var args = [];
869
873
  for (var _i = 1; _i < arguments.length; _i++) {
870
874
  args[_i - 1] = arguments[_i];
871
875
  }
872
876
  try {
873
877
  beforeSyncUpdate();
874
- return action.call.apply(action, __spreadArray([null], args, false));
878
+ 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));
875
879
  }
876
880
  catch (e) {
877
881
  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;
@@ -3956,9 +3960,11 @@ function requireIndex_production () {
3956
3960
  var renderScheduler = currentScheduler$7.current;
3957
3961
  var currentHook = (_b = currentHookTreeNode$1.current) === null || _b === void 0 ? void 0 : _b.value;
3958
3962
  if (!currentHook) {
3959
- throw new Error("[@my-react/react] should have a hookList for current node, this is a bug for @my-react");
3963
+ // throw new Error(`[@my-react/react] should have a hookList for current node, this is a bug for @my-react`);
3964
+ return createHookNode(renderDispatch, { type: type, value: value, reducer: reducer, deps: deps }, fiber);
3960
3965
  }
3961
3966
  if (type !== (currentHook === null || currentHook === void 0 ? void 0 : currentHook.type)) {
3967
+ // only throw error when type not match
3962
3968
  throw new Error(getHookTree(currentHookTreeNode$1.current.prev, {
3963
3969
  lastRender: currentHook === null || currentHook === void 0 ? void 0 : currentHook.type,
3964
3970
  nextRender: type,
@@ -6424,7 +6430,7 @@ function requireIndex_production () {
6424
6430
  _this.isAppMounted = false;
6425
6431
  _this.isAppCrashed = false;
6426
6432
  _this.isAppUnmounted = false;
6427
- _this.version = "0.3.24";
6433
+ _this.version = "0.3.26";
6428
6434
  _this.id = Math.random().toString(16).slice(2);
6429
6435
  _this.mode = "production";
6430
6436
  _this.renderMode = "render";
@@ -6470,9 +6476,7 @@ function requireIndex_production () {
6470
6476
  if (include(_fiber.type, this.runtimeRef.typeForRef)) {
6471
6477
  _fiber.patch = merge(_fiber.patch, PATCH_TYPE.__ref__);
6472
6478
  }
6473
- else if (exclude(_fiber.type, exports$1.NODE_TYPE.__forwardRef__)) {
6474
- onceWarnWithKeyAndFiber(_fiber, "ref", "[@my-react/react] set ref for current element will be ignored");
6475
- }
6479
+ else if (exclude(_fiber.type, exports$1.NODE_TYPE.__forwardRef__)) ;
6476
6480
  }
6477
6481
  };
6478
6482
  CustomRenderDispatch.prototype.pendingUnmount = function (_fiber, _pendingUnmount) {
@@ -6662,7 +6666,7 @@ function requireIndex_production () {
6662
6666
  });
6663
6667
  }); };
6664
6668
 
6665
- var version = "0.3.24";
6669
+ var version = "0.3.26";
6666
6670
 
6667
6671
  exports$1.CustomRenderDispatch = CustomRenderDispatch;
6668
6672
  exports$1.MyReactFiberNode = MyReactFiberNode;
@@ -7796,6 +7800,9 @@ var createDispatch = function (rootNode, rootFiber, rootElement, config, flag) {
7796
7800
  return dispatch;
7797
7801
  };
7798
7802
 
7803
+ var autoSetDevHMR = function (dispatch) {
7804
+ };
7805
+
7799
7806
  var enableDebugFiled$1 = typeExports.__my_react_shared__.enableDebugFiled, enableScopeTreeLog$1 = typeExports.__my_react_shared__.enableScopeTreeLog;
7800
7807
  /**
7801
7808
  * @internal
@@ -7813,15 +7820,14 @@ var currentScheduler = typeExports.__my_react_internal__.currentScheduler;
7813
7820
  // react-reconciler compat implementation
7814
7821
  var Reconciler = function (_config) {
7815
7822
  var rendererPackageName = "@my-react";
7823
+ var isRendering = false;
7816
7824
  var ReconcilerSet = new Set();
7817
7825
  var createContainer = function (_container, flag) {
7818
7826
  prepareScheduler();
7819
7827
  if (flag === 0) {
7820
- // legacy mode
7821
7828
  _container.__flag__ = 0;
7822
7829
  }
7823
7830
  else {
7824
- // concurrent mode
7825
7831
  _container.__flag__ = 1;
7826
7832
  }
7827
7833
  enableDebugFiled.current = false;
@@ -7830,48 +7836,60 @@ var Reconciler = function (_config) {
7830
7836
  myreactReconcilerExports.enableFiberForLog.current = false;
7831
7837
  return _container;
7832
7838
  };
7839
+ var createHydrationContainer = function (_initialChildren, _callback, _container, flag, _hydrationCallbacks, _isStrictMode, _concurrentUpdatesByDefaultOverride, _identifierPrefix, _onRecoverableError, _transitionCallbacks) {
7840
+ var opaqueRoot = createContainer(_container, flag);
7841
+ updateContainer(_initialChildren, opaqueRoot, null, _callback !== null && _callback !== void 0 ? _callback : (function () { }));
7842
+ return opaqueRoot;
7843
+ };
7833
7844
  var updateContainer = function (_element, _container, _ignore, _cb) {
7834
7845
  var _a;
7835
7846
  var renderDispatch = _container.__container__;
7836
7847
  var renderScheduler = currentScheduler.current;
7837
- if (renderDispatch instanceof myreactReconcilerExports.CustomRenderDispatch) {
7838
- var _fiber_1 = _container.__fiber__;
7839
- if (renderDispatch.isAppCrashed || include(_fiber_1.state, STATE_TYPE.__unmount__)) {
7840
- // is there are not a valid render tree, try do the pure rerender
7841
- _container.__fiber__ = null;
7842
- _container.__container__ = null;
7843
- updateContainer(_element, _container, _config, _cb);
7844
- return;
7845
- }
7846
- if (myreactReconcilerExports.checkIsSameType(_fiber_1, _element)) {
7847
- _fiber_1._installElement(_element);
7848
- myreactReconcilerExports.triggerUpdateOnFiber(_fiber_1, STATE_TYPE.__triggerSync__, _cb);
7849
- return;
7848
+ isRendering = true;
7849
+ try {
7850
+ if (renderDispatch instanceof myreactReconcilerExports.CustomRenderDispatch) {
7851
+ var _fiber_1 = _container.__fiber__;
7852
+ if (renderDispatch.isAppCrashed || include(_fiber_1.state, STATE_TYPE.__unmount__)) {
7853
+ _container.__fiber__ = null;
7854
+ _container.__container__ = null;
7855
+ updateContainer(_element, _container, _config, _cb);
7856
+ return;
7857
+ }
7858
+ if (myreactReconcilerExports.checkIsSameType(_fiber_1, _element)) {
7859
+ _fiber_1._installElement(_element);
7860
+ myreactReconcilerExports.triggerUpdateOnFiber(_fiber_1, STATE_TYPE.__triggerSync__, _cb);
7861
+ return;
7862
+ }
7863
+ myreactReconcilerExports.unmountContainer(renderDispatch);
7864
+ (_a = _config === null || _config === void 0 ? void 0 : _config.clearContainer) === null || _a === void 0 ? void 0 : _a.call(_config, _container);
7865
+ ReconcilerSet.delete(renderDispatch);
7866
+ renderScheduler.dispatchSet.uniDelete(renderDispatch);
7867
+ delGlobalDispatch(renderDispatch);
7850
7868
  }
7851
- myreactReconcilerExports.unmountContainer(renderDispatch);
7852
- (_a = _config === null || _config === void 0 ? void 0 : _config.clearContainer) === null || _a === void 0 ? void 0 : _a.call(_config, _container);
7853
- ReconcilerSet.delete(renderDispatch);
7854
- renderScheduler.dispatchSet.uniDelete(renderDispatch);
7855
- delGlobalDispatch(renderDispatch);
7869
+ var _fiber = new myreactReconcilerExports.MyReactFiberNode(_element);
7870
+ var _renderDispatch = createDispatch(_container, _fiber, _element, _config, _container.__flag__);
7871
+ _cb && _renderDispatch.pendingEffect(_fiber, _cb);
7872
+ ReconcilerSet.add(_renderDispatch);
7873
+ renderScheduler.dispatchSet.uniPush(_renderDispatch);
7874
+ _renderDispatch.renderPackage = rendererPackageName;
7875
+ _container.__fiber__ = _fiber;
7876
+ _container.__container__ = _renderDispatch;
7877
+ autoSetDevTools(_renderDispatch);
7878
+ autoSetDevHMR(_renderDispatch);
7879
+ myreactReconcilerExports.initialFiberNode(_renderDispatch, _fiber);
7880
+ myreactReconcilerExports.mountSync(_renderDispatch, _fiber);
7881
+ _renderDispatch.isAppMounted = true;
7882
+ }
7883
+ finally {
7884
+ isRendering = false;
7856
7885
  }
7857
- var _fiber = new myreactReconcilerExports.MyReactFiberNode(_element);
7858
- var _renderDispatch = createDispatch(_container, _fiber, _element, _config, _container.__flag__);
7859
- _cb && _renderDispatch.pendingEffect(_fiber, _cb);
7860
- ReconcilerSet.add(_renderDispatch);
7861
- renderScheduler.dispatchSet.uniPush(_renderDispatch);
7862
- _renderDispatch.renderPackage = rendererPackageName;
7863
- _container.__fiber__ = _fiber;
7864
- _container.__container__ = _renderDispatch;
7865
- autoSetDevTools(_renderDispatch);
7866
- myreactReconcilerExports.initialFiberNode(_renderDispatch, _fiber);
7867
- myreactReconcilerExports.mountSync(_renderDispatch, _fiber);
7868
- _renderDispatch.isAppMounted = true;
7869
7886
  };
7870
7887
  var injectIntoDevTools = function (_config) {
7871
7888
  rendererPackageName = _config.rendererPackageName || rendererPackageName;
7872
7889
  ReconcilerSet.forEach(function (renderDispatch) { return (renderDispatch.renderPackage = rendererPackageName); });
7873
7890
  if (globalThis["__MY_REACT_DEVTOOL_INTERNAL__"])
7874
- return;
7891
+ return true;
7892
+ return false;
7875
7893
  };
7876
7894
  var injectIntoDevToolsAuto = function (url, _config) { return __awaiter(void 0, void 0, void 0, function () {
7877
7895
  var init;
@@ -7897,25 +7915,179 @@ var Reconciler = function (_config) {
7897
7915
  });
7898
7916
  }); };
7899
7917
  var getPublicRootInstance = function (_container) {
7900
- return _container.__container__;
7918
+ var fiber = _container.__fiber__;
7919
+ if (!fiber || !fiber.child) {
7920
+ return null;
7921
+ }
7922
+ return fiber.child.nativeNode;
7923
+ };
7924
+ var discreteUpdates = function (fn, a, b, c, d) {
7925
+ myreactReconcilerExports.beforeSyncUpdate();
7926
+ try {
7927
+ return fn(a, b, c, d);
7928
+ }
7929
+ finally {
7930
+ myreactReconcilerExports.afterSyncUpdate();
7931
+ }
7932
+ };
7933
+ var updateContainerSync = function (element, container, ignore, callback) {
7934
+ myreactReconcilerExports.beforeSyncUpdate();
7935
+ try {
7936
+ updateContainer(element, container, ignore, callback);
7937
+ }
7938
+ finally {
7939
+ myreactReconcilerExports.afterSyncUpdate();
7940
+ }
7941
+ };
7942
+ var flushPassiveEffects = function () {
7943
+ try {
7944
+ myreactReconcilerExports.flushEffectCallback();
7945
+ return true;
7946
+ }
7947
+ catch (_a) {
7948
+ return false;
7949
+ }
7950
+ };
7951
+ var isAlreadyRendering = function () {
7952
+ return isRendering;
7953
+ };
7954
+ var deferredUpdates = function (fn) {
7955
+ return fn();
7956
+ };
7957
+ var findHostInstance = function (component) {
7958
+ try {
7959
+ var fiber = myreactReconcilerExports.getInstanceOwnerFiber(component);
7960
+ if (!fiber)
7961
+ return null;
7962
+ var current = fiber;
7963
+ while (current) {
7964
+ if (current.nativeNode && typeof current.type === "string") {
7965
+ return (_config === null || _config === void 0 ? void 0 : _config.getPublicInstance) ? _config.getPublicInstance(current.nativeNode) : current.nativeNode;
7966
+ }
7967
+ current = current.child;
7968
+ }
7969
+ return null;
7970
+ }
7971
+ catch (_a) {
7972
+ return null;
7973
+ }
7974
+ };
7975
+ var findHostInstanceWithWarning = function (component, _methodName) {
7976
+ return findHostInstance(component);
7977
+ };
7978
+ var findHostInstanceWithNoPortals = function (fiber) {
7979
+ return findHostInstance(fiber);
7980
+ };
7981
+ var attemptSynchronousHydration = function (_fiber) {
7982
+ // no-op: hydration not yet supported in MyReact reconciler-compact
7983
+ };
7984
+ var attemptDiscreteHydration = function (_fiber) {
7985
+ // no-op
7986
+ };
7987
+ var attemptContinuousHydration = function (_fiber) {
7988
+ // no-op
7989
+ };
7990
+ var attemptHydrationAtCurrentPriority = function (_fiber) {
7991
+ // no-op
7992
+ };
7993
+ var getCurrentUpdatePriority = function () {
7994
+ return 0;
7995
+ };
7996
+ var runWithPriority = function (_priority, fn) {
7997
+ return fn();
7998
+ };
7999
+ var shouldErrorImpl = null;
8000
+ var shouldSuspendImpl = null;
8001
+ var shouldError = function (fiber) {
8002
+ return shouldErrorImpl ? shouldErrorImpl(fiber) : undefined;
8003
+ };
8004
+ var shouldSuspend = function (fiber) {
8005
+ return shouldSuspendImpl ? shouldSuspendImpl(fiber) : false;
8006
+ };
8007
+ var registerMutableSourceForHydration = function (_root, _mutableSource) {
8008
+ // no-op
8009
+ };
8010
+ var createComponentSelector = function (component) { return ({ $$typeof: Symbol.for("react.test.selector"), value: component }); };
8011
+ var createHasPseudoClassSelector = function (selectors) { return ({ $$typeof: Symbol.for("react.test.selector"), value: selectors }); };
8012
+ var createRoleSelector = function (role) { return ({ $$typeof: Symbol.for("react.test.selector"), value: role }); };
8013
+ var createTextSelector = function (text) { return ({ $$typeof: Symbol.for("react.test.selector"), value: text }); };
8014
+ var createTestNameSelector = function (id) { return ({ $$typeof: Symbol.for("react.test.selector"), value: id }); };
8015
+ var getFindAllNodesFailureDescription = function (_hostRoot, _selectors) {
8016
+ return null;
8017
+ };
8018
+ var findAllNodes = function (_hostRoot, _selectors) {
8019
+ return [];
8020
+ };
8021
+ var findBoundingRects = function (_hostRoot, _selectors) {
8022
+ return [];
8023
+ };
8024
+ var focusWithin = function (_hostRoot, _selectors) {
8025
+ return false;
8026
+ };
8027
+ var observeVisibleRects = function (_hostRoot, _selectors, _callback, _options) {
8028
+ return { disconnect: function () { } };
7901
8029
  };
7902
8030
  return {
7903
8031
  createPortal: createPortal,
7904
8032
  createContainer: createContainer,
8033
+ createHydrationContainer: createHydrationContainer,
7905
8034
  updateContainer: updateContainer,
8035
+ updateContainerSync: updateContainerSync,
7906
8036
  injectIntoDevTools: injectIntoDevTools,
7907
8037
  getPublicRootInstance: getPublicRootInstance,
7908
8038
  injectIntoDevToolsAuto: injectIntoDevToolsAuto,
7909
8039
  flushSync: myreactReconcilerExports.safeCallWithSync,
7910
8040
  flushSyncWork: myreactReconcilerExports.safeCallWithSync,
7911
8041
  batchedUpdates: myreactReconcilerExports.safeCallWithSync,
8042
+ discreteUpdates: discreteUpdates,
8043
+ deferredUpdates: deferredUpdates,
8044
+ flushPassiveEffects: flushPassiveEffects,
8045
+ isAlreadyRendering: isAlreadyRendering,
8046
+ findHostInstance: findHostInstance,
8047
+ findHostInstanceWithWarning: findHostInstanceWithWarning,
8048
+ findHostInstanceWithNoPortals: findHostInstanceWithNoPortals,
8049
+ attemptSynchronousHydration: attemptSynchronousHydration,
8050
+ attemptDiscreteHydration: attemptDiscreteHydration,
8051
+ attemptContinuousHydration: attemptContinuousHydration,
8052
+ attemptHydrationAtCurrentPriority: attemptHydrationAtCurrentPriority,
8053
+ getCurrentUpdatePriority: getCurrentUpdatePriority,
8054
+ runWithPriority: runWithPriority,
8055
+ shouldError: shouldError,
8056
+ shouldSuspend: shouldSuspend,
8057
+ registerMutableSourceForHydration: registerMutableSourceForHydration,
8058
+ createComponentSelector: createComponentSelector,
8059
+ createHasPseudoClassSelector: createHasPseudoClassSelector,
8060
+ createRoleSelector: createRoleSelector,
8061
+ createTextSelector: createTextSelector,
8062
+ createTestNameSelector: createTestNameSelector,
8063
+ getFindAllNodesFailureDescription: getFindAllNodesFailureDescription,
8064
+ findAllNodes: findAllNodes,
8065
+ findBoundingRects: findBoundingRects,
8066
+ focusWithin: focusWithin,
8067
+ observeVisibleRects: observeVisibleRects,
7912
8068
  };
7913
8069
  };
7914
8070
 
7915
- var version = "0.0.15";
8071
+ var version = "0.0.17";
7916
8072
  var createReconciler = Reconciler;
8073
+ var defaultOnUncaughtError = function (error) {
8074
+ console.error("Uncaught", error);
8075
+ };
8076
+ var defaultOnCaughtError = function (error) {
8077
+ console.error("Caught", error);
8078
+ };
8079
+ var defaultOnRecoverableError = function (error) {
8080
+ console.error("Recoverable", error);
8081
+ };
8082
+ var startHostTransition = function () {
8083
+ // no-op
8084
+ };
7917
8085
 
7918
8086
  exports.createReconciler = createReconciler;
7919
8087
  exports.default = createReconciler;
8088
+ exports.defaultOnCaughtError = defaultOnCaughtError;
8089
+ exports.defaultOnRecoverableError = defaultOnRecoverableError;
8090
+ exports.defaultOnUncaughtError = defaultOnUncaughtError;
7920
8091
  exports.enableKnownConfigLog = enableKnownConfigLog;
8092
+ exports.startHostTransition = startHostTransition;
7921
8093
  exports.version = version;