@my-react/react-reconciler-compact 0.0.8 → 0.0.10

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.
@@ -183,6 +183,7 @@ function requireIndex_development_1 () {
183
183
  var ScopeSuspense = Symbol.for("react.scope_suspense");
184
184
  var Comment = Symbol.for("react.comment");
185
185
  var Offscreen = Symbol.for("react.offscreen");
186
+ var Activity = Symbol.for("react.activity");
186
187
  var Profiler = Symbol.for("react.profiler");
187
188
 
188
189
  function isObject(target) {
@@ -282,6 +283,7 @@ function requireIndex_development_1 () {
282
283
  HOOK_TYPE[HOOK_TYPE["useImperativeHandle"] = 14] = "useImperativeHandle";
283
284
  HOOK_TYPE[HOOK_TYPE["useSyncExternalStore"] = 15] = "useSyncExternalStore";
284
285
  HOOK_TYPE[HOOK_TYPE["useOptimistic"] = 16] = "useOptimistic";
286
+ HOOK_TYPE[HOOK_TYPE["useEffectEvent"] = 17] = "useEffectEvent";
285
287
  })(exports.HOOK_TYPE || (exports.HOOK_TYPE = {}));
286
288
 
287
289
  exports.UpdateQueueType = void 0;
@@ -311,6 +313,7 @@ function requireIndex_development_1 () {
311
313
  STATE_TYPE[STATE_TYPE["__retrigger__"] = 512] = "__retrigger__";
312
314
  STATE_TYPE[STATE_TYPE["__reschedule__"] = 1024] = "__reschedule__";
313
315
  STATE_TYPE[STATE_TYPE["__recreate__"] = 2048] = "__recreate__";
316
+ STATE_TYPE[STATE_TYPE["__suspense__"] = 4096] = "__suspense__";
314
317
  })(exports.STATE_TYPE || (exports.STATE_TYPE = {}));
315
318
 
316
319
  exports.PATCH_TYPE = void 0;
@@ -703,6 +706,7 @@ function requireIndex_development_1 () {
703
706
  });
704
707
  }
705
708
 
709
+ exports.Activity = Activity;
706
710
  exports.Comment = Comment;
707
711
  exports.Consumer = Consumer;
708
712
  exports.Context = Context;
@@ -892,6 +896,7 @@ function requireIndex_development_1 () {
892
896
  NODE_TYPE[NODE_TYPE["__context__"] = 524288] = "__context__";
893
897
  NODE_TYPE[NODE_TYPE["__scopeLazy__"] = 1048576] = "__scopeLazy__";
894
898
  NODE_TYPE[NODE_TYPE["__scopeSuspense__"] = 2097152] = "__scopeSuspense__";
899
+ NODE_TYPE[NODE_TYPE["__activity__"] = 4194304] = "__activity__";
895
900
  })(exports.NODE_TYPE || (exports.NODE_TYPE = {}));
896
901
 
897
902
  var enableSyncFlush$1 = react.__my_react_shared__.enableSyncFlush;
@@ -1391,7 +1396,7 @@ function requireIndex_development_1 () {
1391
1396
  }
1392
1397
  nodeType = myreactSharedExports.merge(nodeType, exports.NODE_TYPE.__empty__);
1393
1398
  }
1394
- else if (element === null || element === undefined || typeof element === "boolean" || typeof element === "function") {
1399
+ else if (element === null || element === undefined || typeof element === "boolean" || typeof element === "function" || element === "") {
1395
1400
  nodeType = myreactSharedExports.merge(nodeType, exports.NODE_TYPE.__null__);
1396
1401
  }
1397
1402
  else {
@@ -1515,11 +1520,14 @@ function requireIndex_development_1 () {
1515
1520
  case myreactSharedExports.Profiler:
1516
1521
  nodeType = myreactSharedExports.merge(nodeType, exports.NODE_TYPE.__profiler__);
1517
1522
  break;
1523
+ case myreactSharedExports.Activity:
1524
+ nodeType = myreactSharedExports.merge(nodeType, exports.NODE_TYPE.__activity__);
1525
+ break;
1518
1526
  default:
1519
1527
  throw new Error("[@my-react/react] invalid symbol element type \"".concat(elementType === null || elementType === void 0 ? void 0 : elementType.toString(), "\""));
1520
1528
  }
1521
1529
  }
1522
- else if (typeof elementType === "string") {
1530
+ else if (typeof elementType === "string" && elementType !== "") {
1523
1531
  nodeType = myreactSharedExports.merge(nodeType, exports.NODE_TYPE.__plain__);
1524
1532
  }
1525
1533
  else {
@@ -1567,7 +1575,17 @@ function requireIndex_development_1 () {
1567
1575
  return new Set(Array.from(fibers || []).map(function (fiber) { return fiberToDispatchMap.get(fiber); }));
1568
1576
  };
1569
1577
  var getCurrentDispatchFromFiber = function (fiber) {
1570
- return fiberToDispatchMap.get(fiber);
1578
+ var dispatch = fiberToDispatchMap.get(fiber);
1579
+ if (dispatch)
1580
+ return dispatch;
1581
+ var parent = fiber.parent;
1582
+ while (parent) {
1583
+ var typedFiberRoot = parent;
1584
+ if (typedFiberRoot.renderDispatch) {
1585
+ return typedFiberRoot.renderDispatch;
1586
+ }
1587
+ parent = parent.parent;
1588
+ }
1571
1589
  };
1572
1590
  var getElementFromRefreshIfExist = function (element) {
1573
1591
  var _a, _b;
@@ -1636,10 +1654,10 @@ function requireIndex_development_1 () {
1636
1654
  var dispatchError = function (_params) {
1637
1655
  var fiber = _params.fiber || currentRunningFiber$3.current;
1638
1656
  if (!fiber) {
1639
- throw new Error("No fiber found for dispatching error.");
1657
+ // a normal error
1658
+ throw _params.error;
1640
1659
  }
1641
- if (myreactSharedExports.include(fiber.state, myreactSharedExports.STATE_TYPE.__unmount__))
1642
- return;
1660
+ // if (include(fiber.state, STATE_TYPE.__unmount__)) return;
1643
1661
  var dispatch = getCurrentDispatchFromFiber(fiber);
1644
1662
  if (!dispatch) {
1645
1663
  throw new Error("No dispatch found for the current running fiber.");
@@ -1651,14 +1669,25 @@ function requireIndex_development_1 () {
1651
1669
  if (!fiber) {
1652
1670
  throw new Error("No fiber found for dispatching promise.");
1653
1671
  }
1654
- if (myreactSharedExports.include(fiber.state, myreactSharedExports.STATE_TYPE.__unmount__))
1655
- return;
1672
+ // if (include(fiber.state, STATE_TYPE.__unmount__)) return;
1656
1673
  var dispatch = getCurrentDispatchFromFiber(fiber);
1657
1674
  if (!dispatch) {
1658
1675
  throw new Error("No dispatch found for the current running fiber.");
1659
1676
  }
1660
1677
  return dispatch.dispatchPromise(_params);
1661
1678
  };
1679
+ var dispatchSuspensePromise = function (_params) {
1680
+ var fiber = _params.fiber || currentRunningFiber$3.current;
1681
+ if (!fiber) {
1682
+ throw new Error("No fiber found for dispatching suspense promise.");
1683
+ }
1684
+ // if (include(fiber.state, STATE_TYPE.__unmount__)) return;
1685
+ var dispatch = getCurrentDispatchFromFiber(fiber);
1686
+ if (!dispatch) {
1687
+ throw new Error("No dispatch found for the current running fiber.");
1688
+ }
1689
+ return dispatch.dispatchSuspensePromise(_params);
1690
+ };
1662
1691
  var readContext = function (_params) {
1663
1692
  var fiber = currentRunningFiber$3.current;
1664
1693
  if (!fiber) {
@@ -1703,6 +1732,7 @@ function requireIndex_development_1 () {
1703
1732
  scheduler.dispatchHook = dispatchHook;
1704
1733
  scheduler.dispatchError = dispatchError;
1705
1734
  scheduler.dispatchPromise = dispatchPromise;
1735
+ scheduler.dispatchSuspensePromise = dispatchSuspensePromise;
1706
1736
  };
1707
1737
 
1708
1738
  var enableHMRForDev = react.__my_react_shared__.enableHMRForDev;
@@ -1913,6 +1943,16 @@ function requireIndex_development_1 () {
1913
1943
  child = child.sibling;
1914
1944
  }
1915
1945
  };
1946
+ var effectCallbackList = new myreactSharedExports.ListTree();
1947
+ var addEffectCallback = function (cb) {
1948
+ effectCallbackList.push(cb);
1949
+ };
1950
+ var flushEffectCallback = function () {
1951
+ effectCallbackList.listToFoot(function (cb) {
1952
+ cb();
1953
+ });
1954
+ effectCallbackList.clear();
1955
+ };
1916
1956
  var effect = defaultInvokeEffect;
1917
1957
  var layoutEffect = defaultInvokeLayoutEffect;
1918
1958
  var insertionEffect = defaultInvokeInsertionEffect;
@@ -1982,7 +2022,10 @@ function requireIndex_development_1 () {
1982
2022
  }
1983
2023
  currentRunningFiber$2.current = null;
1984
2024
  }
1985
- if (!myreactSharedExports.include(fiber.state, myreactSharedExports.STATE_TYPE.__retrigger__)) {
2025
+ if (myreactSharedExports.include(fiber.state, myreactSharedExports.STATE_TYPE.__suspense__)) {
2026
+ fiber.state = myreactSharedExports.STATE_TYPE.__recreate__;
2027
+ }
2028
+ else if (!myreactSharedExports.include(fiber.state, myreactSharedExports.STATE_TYPE.__retrigger__)) {
1986
2029
  fiber.state = myreactSharedExports.STATE_TYPE.__stable__;
1987
2030
  }
1988
2031
  else {
@@ -2034,7 +2077,10 @@ function requireIndex_development_1 () {
2034
2077
  currentRunningFiber$2.current = null;
2035
2078
  triggerFiberUpdateListener(renderDispatch, fiber);
2036
2079
  }
2037
- if (!myreactSharedExports.include(fiber.state, myreactSharedExports.STATE_TYPE.__retrigger__)) {
2080
+ if (myreactSharedExports.include(fiber.state, myreactSharedExports.STATE_TYPE.__suspense__)) {
2081
+ fiber.state = myreactSharedExports.STATE_TYPE.__recreate__;
2082
+ }
2083
+ else if (!myreactSharedExports.include(fiber.state, myreactSharedExports.STATE_TYPE.__retrigger__)) {
2038
2084
  fiber.state = myreactSharedExports.STATE_TYPE.__stable__;
2039
2085
  }
2040
2086
  else {
@@ -2243,15 +2289,12 @@ function requireIndex_development_1 () {
2243
2289
  throw new Error("[@my-react/reconciler] should not process async load list on sync mount without enableAsyncLoad, you may use a wrong renderDispatch instance");
2244
2290
  }
2245
2291
  }
2246
- // TODO update flow
2247
2292
  if (enableSuspenseRoot$3.current) {
2248
2293
  var suspenseField_2 = getInstanceFieldByInstance(renderDispatch);
2249
2294
  var list = suspenseField_2.asyncLoadList.getAll();
2250
2295
  if (list.length === 0)
2251
2296
  return;
2252
2297
  if (renderDispatch.enableAsyncLoad) {
2253
- // defaultDeleteCurrentEffect(renderDispatch, renderDispatch.rootFiber);
2254
- // defaultDeleteChildEffect(renderDispatch, renderDispatch.rootFiber);
2255
2298
  var allPendingLoadArray = list.filter(function (item) {
2256
2299
  if (myreactSharedExports.isPromise(item)) {
2257
2300
  return typeof item.status !== "string";
@@ -2298,13 +2341,6 @@ function requireIndex_development_1 () {
2298
2341
  });
2299
2342
  }); }));
2300
2343
  }
2301
- // suspenseField.isHidden = true;
2302
- // const root = renderDispatch.rootFiber;
2303
- // root.state = remove(root.state, STATE_TYPE.__stable__);
2304
- // root.state = merge(root.state, STATE_TYPE.__retrigger__);
2305
- // // TODO use hide tree to improve
2306
- // mountLoopAll(renderDispatch, root);
2307
- // suspenseField.isHidden = false;
2308
2344
  }
2309
2345
  else {
2310
2346
  throw new Error("[@my-react/reconciler] should not process async load list on sync mount without enableAsyncLoad, you may use a wrong renderDispatch instance");
@@ -2431,66 +2467,12 @@ function requireIndex_development_1 () {
2431
2467
  }
2432
2468
  // TODO update flow
2433
2469
  if (enableSuspenseRoot$2.current) {
2434
- var suspenseField_1 = getInstanceFieldByInstance(renderDispatch);
2435
- var list = suspenseField_1.asyncLoadList.getAll();
2470
+ var suspenseField = getInstanceFieldByInstance(renderDispatch);
2471
+ var list = suspenseField.asyncLoadList.getAll();
2436
2472
  if (list.length === 0)
2437
2473
  return;
2438
2474
  if (renderDispatch.enableAsyncLoad) {
2439
- // defaultDeleteCurrentEffect(renderDispatch, renderDispatch.rootFiber);
2440
- // defaultDeleteChildEffect(renderDispatch, renderDispatch.rootFiber);
2441
- var allPendingLoadArray = list.filter(function (item) {
2442
- if (myreactSharedExports.isPromise(item)) {
2443
- return typeof item.status !== "string";
2444
- }
2445
- else {
2446
- return !item._loading && !item._loaded && !item._error;
2447
- }
2448
- });
2449
- if (allPendingLoadArray.length) {
2450
- allPendingLoadArray.forEach(function (item) { var _a; return (_a = item._list) === null || _a === void 0 ? void 0 : _a.forEach(function (node) { return defaultDeleteCurrentEffect(renderDispatch, node); }); });
2451
- Promise.all(allPendingLoadArray.map(function (item) { return __awaiter(void 0, void 0, void 0, function () {
2452
- var allFiber;
2453
- var _a;
2454
- return __generator(this, function (_b) {
2455
- switch (_b.label) {
2456
- case 0:
2457
- if (!myreactSharedExports.isPromise(item)) return [3 /*break*/, 2];
2458
- return [4 /*yield*/, renderDispatch.processPromise(item)];
2459
- case 1:
2460
- _b.sent();
2461
- return [3 /*break*/, 4];
2462
- case 2: return [4 /*yield*/, renderDispatch.processLazy(item)];
2463
- case 3:
2464
- _b.sent();
2465
- _b.label = 4;
2466
- case 4:
2467
- allFiber = new Set(item._list);
2468
- (_a = item._list) === null || _a === void 0 ? void 0 : _a.clear();
2469
- allFiber.forEach(function (node) {
2470
- node.state = myreactSharedExports.STATE_TYPE.__recreate__;
2471
- var renderScheduler = currentScheduler$d.current;
2472
- var updater = {
2473
- type: myreactSharedExports.UpdateQueueType.suspense,
2474
- trigger: node,
2475
- isSync: true,
2476
- isForce: true,
2477
- payLoad: [item],
2478
- };
2479
- renderScheduler.dispatchState(updater);
2480
- });
2481
- suspenseField_1.asyncLoadList.uniDelete(item);
2482
- return [2 /*return*/];
2483
- }
2484
- });
2485
- }); }));
2486
- }
2487
- // suspenseField.isHidden = true;
2488
- // const root = renderDispatch.rootFiber;
2489
- // root.state = remove(root.state, STATE_TYPE.__stable__);
2490
- // root.state = merge(root.state, STATE_TYPE.__retrigger__);
2491
- // // TODO use hide tree to improve
2492
- // mountLoopAll(renderDispatch, root);
2493
- // suspenseField.isHidden = false;
2475
+ throw new Error("[@my-react/reconciler] not implemented yet");
2494
2476
  }
2495
2477
  else {
2496
2478
  throw new Error("[@my-react/reconciler] should not process async load list on sync mount without enableAsyncLoad, you may use a wrong renderDispatch instance");
@@ -2999,7 +2981,7 @@ function requireIndex_development_1 () {
2999
2981
  _loop_1();
3000
2982
  }
3001
2983
  if (allQueue.length) {
3002
- renderScheduler.macroTask(function prepareUpdateOnFiberTask() {
2984
+ renderScheduler.microTask(function prepareUpdateOnFiberTask() {
3003
2985
  prepareUpdateOnFiber(renderDispatch, fiber, true);
3004
2986
  });
3005
2987
  }
@@ -3105,7 +3087,7 @@ function requireIndex_development_1 () {
3105
3087
  var typedFiber = fiber;
3106
3088
  var node = allQueue === null || allQueue === void 0 ? void 0 : allQueue.head;
3107
3089
  var needUpdate = true;
3108
- var isSync = false;
3090
+ var isSync = true;
3109
3091
  var isForce = false;
3110
3092
  var isImmediate = false;
3111
3093
  var isRetrigger = false;
@@ -3287,7 +3269,7 @@ function requireIndex_development_1 () {
3287
3269
  _loop_3();
3288
3270
  }
3289
3271
  if (allQueue.length) {
3290
- renderScheduler.macroTask(function prepareUpdateOnFiberTask() {
3272
+ renderScheduler.microTask(function prepareUpdateOnFiberTask() {
3291
3273
  prepareUpdateOnFiber(renderDispatch, fiber, true);
3292
3274
  });
3293
3275
  }
@@ -3412,7 +3394,7 @@ function requireIndex_development_1 () {
3412
3394
  var typedFiber = fiber;
3413
3395
  var node = allQueue === null || allQueue === void 0 ? void 0 : allQueue.head;
3414
3396
  var needUpdate = false;
3415
- var isSync = false;
3397
+ var isSync = true;
3416
3398
  var isForce = false;
3417
3399
  var isImmediate = false;
3418
3400
  var isRetrigger = false;
@@ -3569,7 +3551,7 @@ function requireIndex_development_1 () {
3569
3551
  var renderScheduler = currentScheduler$c.current;
3570
3552
  var node = allQueue === null || allQueue === void 0 ? void 0 : allQueue.head;
3571
3553
  var needUpdate = true;
3572
- var isSync = false;
3554
+ var isSync = true;
3573
3555
  var isForce = false;
3574
3556
  var isImmediate = false;
3575
3557
  var isRetrigger = false;
@@ -3981,6 +3963,7 @@ function requireIndex_development_1 () {
3981
3963
  var globalLoop$2 = react.__my_react_internal__.globalLoop, currentScheduler$a = react.__my_react_internal__.currentScheduler;
3982
3964
  var scheduleUpdateFromRoot = function (renderDispatch) {
3983
3965
  var _a, _b, _c, _d;
3966
+ flushEffectCallback();
3984
3967
  var allLive = renderDispatch.pendingUpdateFiberArray.getAll().filter(function (f) { return myreactSharedExports.exclude(f.state, myreactSharedExports.STATE_TYPE.__unmount__); });
3985
3968
  renderDispatch.pendingUpdateFiberArray.clear();
3986
3969
  if (allLive.length) {
@@ -4104,7 +4087,7 @@ function requireIndex_development_1 () {
4104
4087
  return myreactSharedExports.include(renderDispatch.runtimeFiber.nextWorkingFiber.state, myreactSharedExports.STATE_TYPE.__triggerSync__ | myreactSharedExports.STATE_TYPE.__triggerSyncForce__);
4105
4088
  // include(renderDispatch.runtimeFiber.nextWorkingFiber.state, STATE_TYPE.__retrigger__)
4106
4089
  }
4107
- function updateConCurrentNextFrame(renderDispatch) {
4090
+ function updateConcurrentNextFrame(renderDispatch) {
4108
4091
  var renderScheduler = currentScheduler$9.current;
4109
4092
  enableScopeTreeLog$3.current && setLogScope();
4110
4093
  var hasSync = updateLoopConcurrentFromRoot(renderDispatch);
@@ -4119,7 +4102,7 @@ function requireIndex_development_1 () {
4119
4102
  updateSyncFromRoot(renderDispatch);
4120
4103
  }
4121
4104
  else {
4122
- updateConCurrentNextFrame(renderDispatch);
4105
+ updateConcurrentNextFrame(renderDispatch);
4123
4106
  }
4124
4107
  });
4125
4108
  }
@@ -4128,7 +4111,6 @@ function requireIndex_development_1 () {
4128
4111
  processAsyncLoadListOnUpdate(renderDispatch);
4129
4112
  finishUpdateConcurrentFromRoot(renderDispatch);
4130
4113
  renderScheduler.microTask(function callScheduleNext() {
4131
- // TODO! flash all effect
4132
4114
  globalLoop$1.current = false;
4133
4115
  scheduleNext(renderDispatch);
4134
4116
  });
@@ -4150,7 +4132,7 @@ function requireIndex_development_1 () {
4150
4132
  updateSyncFromRoot(renderDispatch);
4151
4133
  }
4152
4134
  else {
4153
- updateConCurrentNextFrame(renderDispatch);
4135
+ updateConcurrentNextFrame(renderDispatch);
4154
4136
  }
4155
4137
  });
4156
4138
  }
@@ -4159,7 +4141,6 @@ function requireIndex_development_1 () {
4159
4141
  processAsyncLoadListOnUpdate(renderDispatch);
4160
4142
  finishUpdateConcurrentFromRoot(renderDispatch);
4161
4143
  renderScheduler.microTask(function callScheduleNext() {
4162
- // TODO! flash all effect
4163
4144
  globalLoop$1.current = false;
4164
4145
  scheduleNext(renderDispatch);
4165
4146
  });
@@ -4192,6 +4173,11 @@ function requireIndex_development_1 () {
4192
4173
  throw new Error("[@my-react/react] ".concat(myreactSharedExports.HOOK_TYPE[hookNode.type], " initial error"));
4193
4174
  }
4194
4175
  }
4176
+ if (hookNode.type === myreactSharedExports.HOOK_TYPE.useEffectEvent) {
4177
+ if (typeof hookNode.value !== "function") {
4178
+ throw new Error("[@my-react/react] ".concat(myreactSharedExports.HOOK_TYPE[hookNode.type], " initial error"));
4179
+ }
4180
+ }
4195
4181
  };
4196
4182
 
4197
4183
  var MyReactInternalInstance$4 = react.__my_react_internal__.MyReactInternalInstance, currentScheduler$8 = react.__my_react_internal__.currentScheduler;
@@ -4228,7 +4214,9 @@ function requireIndex_development_1 () {
4228
4214
  if (!field)
4229
4215
  throw new Error("[@my-react/react] hook instance not found, look like a bug for @my-react");
4230
4216
  var typedField = field;
4231
- typedField.dispatch = function (action) { return hookNode._update({ payLoad: action, isForce: false, isSync: enableSyncFlush.current }); };
4217
+ typedField.dispatch = function dispatchAction(action) {
4218
+ hookNode._update({ payLoad: action, isForce: false, isSync: enableSyncFlush.current });
4219
+ };
4232
4220
  };
4233
4221
 
4234
4222
  var currentComponentFiber$3 = react.__my_react_internal__.currentComponentFiber;
@@ -4264,12 +4252,22 @@ function requireIndex_development_1 () {
4264
4252
  };
4265
4253
  var defaultOptimisticReducer = function (state) { return state; };
4266
4254
  var createHookNode = function (renderDispatch, _a, fiber) {
4267
- var _b;
4255
+ var _b, _c;
4268
4256
  var type = _a.type, value = _a.value, reducer = _a.reducer, deps = _a.deps;
4269
4257
  var currentHook = (_b = currentHookTreeNode$2.current) === null || _b === void 0 ? void 0 : _b.value;
4270
4258
  var currentHookIndex = currentHookNodeIndex$2.current;
4259
+ var currentIsReCreate = myreactSharedExports.include(fiber.state, myreactSharedExports.STATE_TYPE.__recreate__);
4271
4260
  if (currentHook) {
4272
- throw new Error("[@my-react/react] should not have a hookList for current node, this is a bug for @my-react");
4261
+ if (currentIsReCreate) {
4262
+ if (currentHookIndex === 0) {
4263
+ defaultDeleteChildEffect(renderDispatch, fiber);
4264
+ defaultDeleteCurrentEffect(renderDispatch, fiber);
4265
+ fiber.hookList.clear();
4266
+ }
4267
+ }
4268
+ else {
4269
+ throw new Error("[@my-react/react] should not have a hookList for current node, this is a bug for @my-react");
4270
+ }
4273
4271
  }
4274
4272
  var hookNode = new MyReactHookNode(type, value, reducer || defaultReducer, deps);
4275
4273
  initInstance(hookNode);
@@ -4291,9 +4289,16 @@ function requireIndex_development_1 () {
4291
4289
  hookNode.result = hookNode.value;
4292
4290
  hookNode.hasEffect = true;
4293
4291
  }
4294
- if (hookNode.type === myreactSharedExports.HOOK_TYPE.useRef || hookNode.type === myreactSharedExports.HOOK_TYPE.useCallback || hookNode.type === myreactSharedExports.HOOK_TYPE.useDeferredValue) {
4292
+ if (hookNode.type === myreactSharedExports.HOOK_TYPE.useRef ||
4293
+ hookNode.type === myreactSharedExports.HOOK_TYPE.useCallback ||
4294
+ hookNode.type === myreactSharedExports.HOOK_TYPE.useDeferredValue ||
4295
+ hookNode.type === myreactSharedExports.HOOK_TYPE.useEffectEvent) {
4295
4296
  hookNode.result = hookNode.value;
4296
4297
  }
4298
+ // cache ref state from recreate
4299
+ if (hookNode.type === myreactSharedExports.HOOK_TYPE.useRef && currentHook && currentHook.type === myreactSharedExports.HOOK_TYPE.useRef) {
4300
+ hookNode.result = currentHook.result;
4301
+ }
4297
4302
  if (hookNode.type === myreactSharedExports.HOOK_TYPE.useId) {
4298
4303
  hookNode.result = "\u00AB-".concat(currentHookIndex, "-").concat(renderDispatch.uniqueIdCount++, "-\u00BB");
4299
4304
  hookNode.cancel = function () { return renderDispatch.uniqueIdCount--; };
@@ -4316,12 +4321,13 @@ function requireIndex_development_1 () {
4316
4321
  return safeCallWithCurrentFiber({
4317
4322
  fiber: fiber,
4318
4323
  action: function safeCallGetSnapshot() {
4319
- var _a;
4320
4324
  return renderDispatch.isAppMounted
4321
4325
  ? storeApi_1.getSnapshot.call(null)
4322
- : storeApi_1.getServerSnapshot
4323
- ? (_a = storeApi_1.getServerSnapshot) === null || _a === void 0 ? void 0 : _a.call(null)
4324
- : storeApi_1.getSnapshot.call(null);
4326
+ : // SEE https://github.com/facebook/react/blob/main/packages/use-sync-external-store/src/useSyncExternalStoreShimClient.js#L33
4327
+ // : storeApi.getServerSnapshot
4328
+ // ? storeApi.getServerSnapshot?.call(null)
4329
+ // : storeApi.getSnapshot.call(null);
4330
+ storeApi_1.getSnapshot.call(null);
4325
4331
  },
4326
4332
  });
4327
4333
  };
@@ -4423,6 +4429,7 @@ function requireIndex_development_1 () {
4423
4429
  typedHook._debugType = myreactSharedExports.HOOK_TYPE[hookNode.type];
4424
4430
  typedHook._debugIndex = currentHookIndex;
4425
4431
  }
4432
+ currentHookTreeNode$2.current = (_c = currentHookTreeNode$2.current) === null || _c === void 0 ? void 0 : _c.next;
4426
4433
  return hookNode;
4427
4434
  };
4428
4435
 
@@ -4664,6 +4671,13 @@ function requireIndex_development_1 () {
4664
4671
  // currentHook._update({ isForce: true, payLoad: (last) => ({ value: value.value, start: last.start }) });
4665
4672
  }
4666
4673
  }
4674
+ if (currentHook.type === myreactSharedExports.HOOK_TYPE.useEffectEvent) {
4675
+ if (typeof value !== "function") {
4676
+ throw new Error("[@my-react/react] useEffectEvent should be a function");
4677
+ }
4678
+ currentHook.value = value;
4679
+ currentHook.result = value;
4680
+ }
4667
4681
  if (currentHook.type === myreactSharedExports.HOOK_TYPE.useDebugValue) {
4668
4682
  if (!myreactSharedExports.isArrayEquals(currentHook.value, value)) {
4669
4683
  currentHook.value = value;
@@ -5022,7 +5036,7 @@ function requireIndex_development_1 () {
5022
5036
  renderDispatch.pendingUpdate(fiber);
5023
5037
  }
5024
5038
  }
5025
- if (nextRef && prevRef !== nextRef) {
5039
+ if (prevRef !== nextRef) {
5026
5040
  renderDispatch.pendingRef(fiber);
5027
5041
  }
5028
5042
  if (fiber !== prevFiber) {
@@ -5181,8 +5195,8 @@ function requireIndex_development_1 () {
5181
5195
  return updateFiberNode(renderDispatch, { fiber: draftFiber_1, parent: parentFiber, prevFiber: prevFiberChild }, newElement);
5182
5196
  }
5183
5197
  else {
5184
- renderDispatch.generateChangedList(parentFiber);
5185
- renderDispatch.pendingUnmount(parentFiber, draftFiber_1);
5198
+ draftFiber_1 && renderDispatch.generateChangedList(parentFiber);
5199
+ draftFiber_1 && renderDispatch.pendingUnmount(parentFiber, draftFiber_1);
5186
5200
  return createFragmentWithUpdate(renderDispatch, newChild, parentFiber);
5187
5201
  }
5188
5202
  }
@@ -5199,7 +5213,7 @@ function requireIndex_development_1 () {
5199
5213
  }
5200
5214
  else {
5201
5215
  draftFiber && renderDispatch.pendingUnmount(parentFiber, draftFiber);
5202
- renderDispatch.generateChangedList(parentFiber);
5216
+ draftFiber && renderDispatch.generateChangedList(parentFiber);
5203
5217
  return createFiberNode(renderDispatch, { parent: parentFiber, type: "position" }, newChild);
5204
5218
  }
5205
5219
  };
@@ -5214,9 +5228,13 @@ function requireIndex_development_1 () {
5214
5228
  var isUpdate = myreactSharedExports.exclude(parentFiber.state, myreactSharedExports.STATE_TYPE.__create__);
5215
5229
  var isHMR = myreactSharedExports.include(parentFiber.state, myreactSharedExports.STATE_TYPE.__hmr__);
5216
5230
  var isRetrigger = myreactSharedExports.include(parentFiber.state, myreactSharedExports.STATE_TYPE.__retrigger__);
5231
+ var isSuspense = myreactSharedExports.include(parentFiber.state, myreactSharedExports.STATE_TYPE.__suspense__);
5217
5232
  // is current is retrigger update, skip update children
5218
5233
  if (isRetrigger)
5219
5234
  return;
5235
+ // if is suspense, skip update children
5236
+ if (isSuspense)
5237
+ return;
5220
5238
  if (isUpdate || isHMR) {
5221
5239
  var _a = getExistingChildren(parentFiber), existingChildrenMap = _a.existingChildrenMap, existingChildrenArray = _a.existingChildrenArray;
5222
5240
  parentFiber.child = null;
@@ -5278,6 +5296,14 @@ function requireIndex_development_1 () {
5278
5296
  }
5279
5297
  };
5280
5298
 
5299
+ // TODO
5300
+ var processActivity = function (fiber) {
5301
+ var props = fiber.pendingProps;
5302
+ if (props.mode === "visible")
5303
+ return props.children;
5304
+ return null;
5305
+ };
5306
+
5281
5307
  var currentComponentFiber$2 = react.__my_react_internal__.currentComponentFiber, MyReactInternalInstance$3 = react.__my_react_internal__.MyReactInternalInstance;
5282
5308
  var processProvider = function (renderDispatch, fiber) {
5283
5309
  if (renderDispatch.isAppMounted) {
@@ -5320,6 +5346,11 @@ function requireIndex_development_1 () {
5320
5346
  };
5321
5347
 
5322
5348
  var currentHookTreeNode = react.__my_react_internal__.currentHookTreeNode, currentHookNodeIndex$1 = react.__my_react_internal__.currentHookNodeIndex, currentScheduler$4 = react.__my_react_internal__.currentScheduler;
5349
+ var triggerState = myreactSharedExports.STATE_TYPE.__triggerSync__ |
5350
+ myreactSharedExports.STATE_TYPE.__triggerSyncForce__ |
5351
+ myreactSharedExports.STATE_TYPE.__triggerConcurrent__ |
5352
+ myreactSharedExports.STATE_TYPE.__triggerConcurrentForce__ |
5353
+ myreactSharedExports.STATE_TYPE.__retrigger__;
5323
5354
  var processFunction = function (fiber) {
5324
5355
  var _a;
5325
5356
  currentHookTreeNode.current = (_a = fiber.hookList) === null || _a === void 0 ? void 0 : _a.head;
@@ -5331,14 +5362,20 @@ function requireIndex_development_1 () {
5331
5362
  children = safeCallWithCurrentFiber({
5332
5363
  fiber: fiber,
5333
5364
  action: function safeCallForwardRefFunctionalComponent() {
5334
- var _a, _b;
5365
+ var _a, _b, _c, _d;
5335
5366
  var re = undefined;
5336
5367
  try {
5337
5368
  re = typedElementTypeWithRef_1(fiber.pendingProps, fiber.ref);
5338
5369
  }
5339
5370
  catch (e) {
5340
5371
  if (myreactSharedExports.isPromise(e)) {
5341
- re = (_b = (_a = currentScheduler$4.current) === null || _a === void 0 ? void 0 : _a.dispatchPromise) === null || _b === void 0 ? void 0 : _b.call(_a, { fiber: fiber, promise: e });
5372
+ var currentIsTrigger = myreactSharedExports.include(fiber.state, triggerState);
5373
+ if (currentIsTrigger) {
5374
+ re = (_b = (_a = currentScheduler$4.current) === null || _a === void 0 ? void 0 : _a.dispatchSuspensePromise) === null || _b === void 0 ? void 0 : _b.call(_a, { fiber: fiber, promise: e });
5375
+ }
5376
+ else {
5377
+ re = (_d = (_c = currentScheduler$4.current) === null || _c === void 0 ? void 0 : _c.dispatchPromise) === null || _d === void 0 ? void 0 : _d.call(_c, { fiber: fiber, promise: e });
5378
+ }
5342
5379
  }
5343
5380
  else {
5344
5381
  throw e;
@@ -5352,14 +5389,20 @@ function requireIndex_development_1 () {
5352
5389
  children = safeCallWithCurrentFiber({
5353
5390
  fiber: fiber,
5354
5391
  action: function safeCallFunctionalComponent() {
5355
- var _a, _b;
5392
+ var _a, _b, _c, _d;
5356
5393
  var re = undefined;
5357
5394
  try {
5358
5395
  re = typedElementType(fiber.pendingProps);
5359
5396
  }
5360
5397
  catch (e) {
5361
5398
  if (myreactSharedExports.isPromise(e)) {
5362
- re = (_b = (_a = currentScheduler$4.current) === null || _a === void 0 ? void 0 : _a.dispatchPromise) === null || _b === void 0 ? void 0 : _b.call(_a, { fiber: fiber, promise: e });
5399
+ var currentIsTrigger = myreactSharedExports.include(fiber.state, triggerState);
5400
+ if (currentIsTrigger) {
5401
+ re = (_b = (_a = currentScheduler$4.current) === null || _a === void 0 ? void 0 : _a.dispatchSuspensePromise) === null || _b === void 0 ? void 0 : _b.call(_a, { fiber: fiber, promise: e });
5402
+ }
5403
+ else {
5404
+ re = (_d = (_c = currentScheduler$4.current) === null || _c === void 0 ? void 0 : _c.dispatchPromise) === null || _d === void 0 ? void 0 : _d.call(_c, { fiber: fiber, promise: e });
5405
+ }
5363
5406
  }
5364
5407
  else {
5365
5408
  throw e;
@@ -5448,7 +5491,7 @@ function requireIndex_development_1 () {
5448
5491
  return null;
5449
5492
  }
5450
5493
  else {
5451
- // TODO update flow
5494
+ // TODO update flow
5452
5495
  if (enableSuspenseRoot$1.current && !renderDispatch.isAppMounted) {
5453
5496
  var suspenseField = getInstanceFieldByInstance(renderDispatch);
5454
5497
  suspenseField.asyncLoadList.uniPush(typedElementType);
@@ -5660,6 +5703,10 @@ function requireIndex_development_1 () {
5660
5703
  var children = processConsumer(renderDispatch, fiber);
5661
5704
  nextWorkCommon(renderDispatch, fiber, children);
5662
5705
  };
5706
+ var nextWorkActivity = function (renderDispatch, fiber) {
5707
+ var children = processActivity(fiber);
5708
+ nextWorkCommon(renderDispatch, fiber, children);
5709
+ };
5663
5710
  var nextWorkRoot = function (renderDispatch, fiber) {
5664
5711
  var isUpdate = !!fiber.instance;
5665
5712
  fiber.instance = fiber.instance || new MyReactInternalInstance$2();
@@ -5857,6 +5904,9 @@ function requireIndex_development_1 () {
5857
5904
  RenderDispatchEvent.prototype.dispatchPromise = function (_params) {
5858
5905
  throw new Error("Method not implemented.");
5859
5906
  };
5907
+ RenderDispatchEvent.prototype.dispatchSuspensePromise = function (_params) {
5908
+ throw new Error("Method not implemented.");
5909
+ };
5860
5910
  RenderDispatchEvent.prototype.trigger = function (_fiber, _state, cb) {
5861
5911
  return triggerUpdateOnFiber(_fiber, _state, cb);
5862
5912
  };
@@ -6340,6 +6390,9 @@ function requireIndex_development_1 () {
6340
6390
  else if (myreactSharedExports.include(fiber.type, exports.NODE_TYPE.__provider__ | exports.NODE_TYPE.__context__)) {
6341
6391
  nextWorkProvider(renderDispatch, fiber);
6342
6392
  }
6393
+ else if (myreactSharedExports.include(fiber.type, exports.NODE_TYPE.__activity__)) {
6394
+ nextWorkActivity(renderDispatch, fiber);
6395
+ }
6343
6396
  else {
6344
6397
  nextWorkNormal(renderDispatch, fiber);
6345
6398
  }
@@ -6387,14 +6440,25 @@ function requireIndex_development_1 () {
6387
6440
  layoutEffect(_dispatch, _fiber);
6388
6441
  });
6389
6442
  afterSyncUpdate();
6390
- var renderScheduler = currentScheduler$2.current;
6391
- renderScheduler.microTask(function invokeEffectListTask() {
6443
+ function invokeEffectListTask() {
6392
6444
  enableScopeTreeLog$2.current && setLogScope();
6393
6445
  _list.listToFoot(function invokeEffectList(_fiber) {
6394
6446
  effect(_dispatch, _fiber);
6395
6447
  });
6396
6448
  enableScopeTreeLog$2.current && resetLogScope();
6397
- });
6449
+ }
6450
+ addEffectCallback(invokeEffectListTask);
6451
+ var renderScheduler = currentScheduler$2.current;
6452
+ if (_dispatch.enableConcurrentMode) {
6453
+ renderScheduler.macroTask(function flushEffect() {
6454
+ flushEffectCallback();
6455
+ });
6456
+ }
6457
+ else {
6458
+ renderScheduler.microTask(function flushEffect() {
6459
+ flushEffectCallback();
6460
+ });
6461
+ }
6398
6462
  };
6399
6463
  var defaultDispatchMount = defaultDispatchMountLatest;
6400
6464
 
@@ -6495,9 +6559,7 @@ function requireIndex_development_1 () {
6495
6559
  }
6496
6560
  });
6497
6561
  afterSyncUpdate();
6498
- var renderScheduler = currentScheduler$1.current;
6499
- // TODO before next update flow, make sure all the effect has done
6500
- renderScheduler.microTask(function invokeEffectListTask() {
6562
+ function invokeEffectListTask() {
6501
6563
  enableScopeTreeLog$1.current && setLogScope();
6502
6564
  _list.listToFoot(function invokeEffectList(_fiber) {
6503
6565
  if (myreactSharedExports.exclude(_fiber.state, myreactSharedExports.STATE_TYPE.__unmount__) && !_dispatch.isAppUnmounted) {
@@ -6505,7 +6567,19 @@ function requireIndex_development_1 () {
6505
6567
  }
6506
6568
  });
6507
6569
  enableScopeTreeLog$1.current && resetLogScope();
6508
- });
6570
+ }
6571
+ addEffectCallback(invokeEffectListTask);
6572
+ var renderScheduler = currentScheduler$1.current;
6573
+ if (_dispatch.enableConcurrentMode) {
6574
+ renderScheduler.macroTask(function flushEffect() {
6575
+ flushEffectCallback();
6576
+ });
6577
+ }
6578
+ else {
6579
+ renderScheduler.microTask(function flushEffect() {
6580
+ flushEffectCallback();
6581
+ });
6582
+ }
6509
6583
  };
6510
6584
 
6511
6585
  var enableSuspenseRoot = react.__my_react_shared__.enableSuspenseRoot;
@@ -6570,7 +6644,9 @@ function requireIndex_development_1 () {
6570
6644
  promise._loading = true;
6571
6645
  promise.status = "pending";
6572
6646
  var renderScheduler_1 = currentScheduler.current;
6573
- renderDispatch.processPromise(promise).then(function () {
6647
+ renderDispatch
6648
+ .processPromise(promise)
6649
+ .then(function () {
6574
6650
  fiber.state = myreactSharedExports.STATE_TYPE.__recreate__;
6575
6651
  promise._list.delete(fiber);
6576
6652
  promise._loading = false;
@@ -6582,10 +6658,49 @@ function requireIndex_development_1 () {
6582
6658
  payLoad: promise,
6583
6659
  };
6584
6660
  renderScheduler_1.dispatchState(updater);
6585
- });
6661
+ })
6662
+ .catch(function (e) { return renderScheduler_1.dispatchError({ fiber: fiber, error: e }); });
6586
6663
  return null;
6587
6664
  }
6588
6665
  };
6666
+ var processSuspensePromise = function (renderDispatch, fiber, promise) {
6667
+ var _a, _b;
6668
+ defaultDeleteCurrentEffect(renderDispatch, fiber);
6669
+ fiber.state = myreactSharedExports.STATE_TYPE.__suspense__;
6670
+ if (promise.status === "rejected") {
6671
+ (_b = (_a = currentScheduler.current).dispatchError) === null || _b === void 0 ? void 0 : _b.call(_a, { fiber: fiber, error: promise._reason });
6672
+ return null;
6673
+ }
6674
+ if (promise.status === "fulfilled") {
6675
+ {
6676
+ console.warn("[@my-react/react] throw a promise what has already fulfilled, this is not a valid usage");
6677
+ }
6678
+ }
6679
+ promise._list = promise._list || new Set();
6680
+ promise._list.add(fiber);
6681
+ if (promise._loading)
6682
+ return null;
6683
+ promise._loading = true;
6684
+ promise.status = "pending";
6685
+ var renderScheduler = currentScheduler.current;
6686
+ renderDispatch
6687
+ .processPromise(promise)
6688
+ .then(function () {
6689
+ fiber.state = myreactSharedExports.STATE_TYPE.__recreate__;
6690
+ promise._list.delete(fiber);
6691
+ promise._loading = false;
6692
+ var updater = {
6693
+ type: myreactSharedExports.UpdateQueueType.promise,
6694
+ trigger: fiber,
6695
+ isSync: true,
6696
+ isForce: true,
6697
+ payLoad: promise,
6698
+ };
6699
+ renderScheduler.dispatchState(updater);
6700
+ })
6701
+ .catch(function (e) { return renderScheduler.dispatchError({ fiber: fiber, error: e }); });
6702
+ return null;
6703
+ };
6589
6704
 
6590
6705
  var CustomRenderDispatch = /** @class */ (function (_super) {
6591
6706
  __extends(CustomRenderDispatch, _super);
@@ -6596,7 +6711,7 @@ function requireIndex_development_1 () {
6596
6711
  _this.isAppMounted = false;
6597
6712
  _this.isAppCrashed = false;
6598
6713
  _this.isAppUnmounted = false;
6599
- _this.version = "0.3.17";
6714
+ _this.version = "0.3.19";
6600
6715
  _this.mode = "development" ;
6601
6716
  _this.renderMode = "render";
6602
6717
  _this.pendingCommitFiberList = null;
@@ -6926,6 +7041,7 @@ function requireIndex_development_1 () {
6926
7041
  case myreactSharedExports.HOOK_TYPE.useCallback:
6927
7042
  case myreactSharedExports.HOOK_TYPE.useDeferredValue:
6928
7043
  case myreactSharedExports.HOOK_TYPE.useSyncExternalStore:
7044
+ case myreactSharedExports.HOOK_TYPE.useEffectEvent:
6929
7045
  return hookNode.result;
6930
7046
  case myreactSharedExports.HOOK_TYPE.useOptimistic:
6931
7047
  case myreactSharedExports.HOOK_TYPE.useTransition:
@@ -7035,7 +7151,7 @@ function requireIndex_development_1 () {
7035
7151
  });
7036
7152
  }); };
7037
7153
 
7038
- var version = "0.3.17";
7154
+ var version = "0.3.19";
7039
7155
 
7040
7156
  exports.CustomRenderDispatch = CustomRenderDispatch;
7041
7157
  exports.MyReactFiberNode = MyReactFiberNode;
@@ -7044,6 +7160,7 @@ function requireIndex_development_1 () {
7044
7160
  exports.RenderDispatchEvent = RenderDispatchEvent;
7045
7161
  exports.WrapperByLazyScope = WrapperByLazyScope;
7046
7162
  exports.WrapperBySuspenseScope = WrapperBySuspenseScope;
7163
+ exports.addEffectCallback = addEffectCallback;
7047
7164
  exports.afterSyncFlush = afterSyncFlush;
7048
7165
  exports.afterSyncUpdate = afterSyncUpdate;
7049
7166
  exports.applyTriggerFiberCb = applyTriggerFiberCb;
@@ -7093,6 +7210,7 @@ function requireIndex_development_1 () {
7093
7210
  exports.enableLogForCurrentFlowIsRunning = enableLogForCurrentFlowIsRunning;
7094
7211
  exports.enableValidMyReactElement = enableValidMyReactElement;
7095
7212
  exports.fiberToDispatchMap = fiberToDispatchMap;
7213
+ exports.flushEffectCallback = flushEffectCallback;
7096
7214
  exports.generateFiberToListWithAction = generateFiberToListWithAction;
7097
7215
  exports.generateFiberToMountList = generateFiberToMountList;
7098
7216
  exports.generateFiberToUnmountList = generateFiberToUnmountList;
@@ -7144,6 +7262,7 @@ function requireIndex_development_1 () {
7144
7262
  exports.mountLoopAllFromScheduler = mountLoopAllFromScheduler;
7145
7263
  exports.mountSync = mountSync;
7146
7264
  exports.mountToNextFiberFromRoot = mountToNextFiberFromRoot;
7265
+ exports.nextWorkActivity = nextWorkActivity;
7147
7266
  exports.nextWorkClassComponent = nextWorkClassComponent;
7148
7267
  exports.nextWorkCommon = nextWorkCommon;
7149
7268
  exports.nextWorkComponent = nextWorkComponent;
@@ -7182,6 +7301,7 @@ function requireIndex_development_1 () {
7182
7301
  exports.processProvider = processProvider;
7183
7302
  exports.processState = processState;
7184
7303
  exports.processSuspense = processSuspense;
7304
+ exports.processSuspensePromise = processSuspensePromise;
7185
7305
  exports.resetLogScope = resetLogScope;
7186
7306
  exports.runtimeNextWork = runtimeNextWork;
7187
7307
  exports.runtimeNextWorkDev = runtimeNextWorkDev;
@@ -7330,6 +7450,7 @@ function requireIndex_development () {
7330
7450
  var ScopeSuspense = Symbol.for("react.scope_suspense");
7331
7451
  var Comment = Symbol.for("react.comment");
7332
7452
  var Offscreen = Symbol.for("react.offscreen");
7453
+ var Activity = Symbol.for("react.activity");
7333
7454
  var Profiler = Symbol.for("react.profiler");
7334
7455
 
7335
7456
  function isObject(target) {
@@ -7429,6 +7550,7 @@ function requireIndex_development () {
7429
7550
  HOOK_TYPE[HOOK_TYPE["useImperativeHandle"] = 14] = "useImperativeHandle";
7430
7551
  HOOK_TYPE[HOOK_TYPE["useSyncExternalStore"] = 15] = "useSyncExternalStore";
7431
7552
  HOOK_TYPE[HOOK_TYPE["useOptimistic"] = 16] = "useOptimistic";
7553
+ HOOK_TYPE[HOOK_TYPE["useEffectEvent"] = 17] = "useEffectEvent";
7432
7554
  })(exports.HOOK_TYPE || (exports.HOOK_TYPE = {}));
7433
7555
 
7434
7556
  exports.UpdateQueueType = void 0;
@@ -7458,6 +7580,7 @@ function requireIndex_development () {
7458
7580
  STATE_TYPE[STATE_TYPE["__retrigger__"] = 512] = "__retrigger__";
7459
7581
  STATE_TYPE[STATE_TYPE["__reschedule__"] = 1024] = "__reschedule__";
7460
7582
  STATE_TYPE[STATE_TYPE["__recreate__"] = 2048] = "__recreate__";
7583
+ STATE_TYPE[STATE_TYPE["__suspense__"] = 4096] = "__suspense__";
7461
7584
  })(exports.STATE_TYPE || (exports.STATE_TYPE = {}));
7462
7585
 
7463
7586
  exports.PATCH_TYPE = void 0;
@@ -7850,6 +7973,7 @@ function requireIndex_development () {
7850
7973
  });
7851
7974
  }
7852
7975
 
7976
+ exports.Activity = Activity;
7853
7977
  exports.Comment = Comment;
7854
7978
  exports.Consumer = Consumer;
7855
7979
  exports.Context = Context;
@@ -7943,27 +8067,50 @@ var delGlobalDispatch = function (dispatch) {
7943
8067
  * @internal
7944
8068
  */
7945
8069
  var setRef = function (_fiber, config) {
7946
- var _a, _b;
7947
8070
  if (myreactSharedExports.include(_fiber.patch, myreactSharedExports.PATCH_TYPE.__ref__)) {
8071
+ var cleanUp = function () {
8072
+ // const refPrevious = _fiber.refPrevious;
8073
+ // safeCallWithCurrentFiber({
8074
+ // fiber: _fiber,
8075
+ // action: function safeCallRefPrevious() {
8076
+ // if (typeof refPrevious === "object" && refPrevious !== null) {
8077
+ // refPrevious.current = null;
8078
+ // } else if (typeof refPrevious === "function") {
8079
+ // refPrevious?.(null);
8080
+ // }
8081
+ // },
8082
+ // });
8083
+ // _fiber.refPrevious = undefined;
8084
+ var refCleanup = _fiber.refCleanup;
8085
+ myreactReconcilerExports.safeCallWithCurrentFiber({
8086
+ fiber: _fiber,
8087
+ action: function safeCallRefCleanup() {
8088
+ if (typeof refCleanup === "function") {
8089
+ refCleanup();
8090
+ }
8091
+ },
8092
+ });
8093
+ _fiber.refCleanup = undefined;
8094
+ };
7948
8095
  if (myreactSharedExports.include(_fiber.type, myreactReconcilerExports.NODE_TYPE.__plain__)) {
7949
8096
  if (_fiber.nativeNode) {
8097
+ cleanUp();
7950
8098
  var ref_1 = _fiber.ref;
7951
- if (typeof ref_1 === "object" && ref_1 !== null) {
7952
- ref_1.current = (_a = config === null || config === void 0 ? void 0 : config.getPublicInstance) === null || _a === void 0 ? void 0 : _a.call(config, _fiber.nativeNode);
7953
- }
7954
- else if (typeof ref_1 === "function") {
7955
- myreactReconcilerExports.safeCallWithCurrentFiber({
7956
- fiber: _fiber,
7957
- action: function safeCallSetRef() {
7958
- var _a, _b;
7959
- (_a = _fiber.refCleanup) === null || _a === void 0 ? void 0 : _a.call(_fiber);
8099
+ myreactReconcilerExports.safeCallWithCurrentFiber({
8100
+ fiber: _fiber,
8101
+ action: function safeCallSetRef() {
8102
+ var _a, _b;
8103
+ if (typeof ref_1 === "object" && ref_1 !== null) {
8104
+ ref_1.current = (_a = config === null || config === void 0 ? void 0 : config.getPublicInstance) === null || _a === void 0 ? void 0 : _a.call(config, _fiber.nativeNode);
8105
+ }
8106
+ else if (typeof ref_1 === "function") {
7960
8107
  var refCleanUp = ref_1((_b = config === null || config === void 0 ? void 0 : config.getPublicInstance) === null || _b === void 0 ? void 0 : _b.call(config, _fiber.nativeNode));
7961
8108
  if (typeof refCleanUp === "function") {
7962
8109
  _fiber.refCleanup = refCleanUp;
7963
8110
  }
7964
- },
7965
- });
7966
- }
8111
+ }
8112
+ },
8113
+ });
7967
8114
  }
7968
8115
  else {
7969
8116
  throw new Error("[@my-react/react] plain element do not have a native node");
@@ -7971,23 +8118,23 @@ var setRef = function (_fiber, config) {
7971
8118
  }
7972
8119
  else if (myreactSharedExports.include(_fiber.type, myreactReconcilerExports.NODE_TYPE.__class__)) {
7973
8120
  if (_fiber.instance) {
8121
+ cleanUp();
7974
8122
  var ref_2 = _fiber.ref;
7975
- if (typeof ref_2 === "object" && ref_2 !== null) {
7976
- ref_2.current = (_b = config === null || config === void 0 ? void 0 : config.getPublicInstance) === null || _b === void 0 ? void 0 : _b.call(config, _fiber.instance);
7977
- }
7978
- else if (typeof ref_2 === "function") {
7979
- myreactReconcilerExports.safeCallWithCurrentFiber({
7980
- fiber: _fiber,
7981
- action: function safeCallSetRef() {
7982
- var _a, _b;
7983
- (_a = _fiber.refCleanup) === null || _a === void 0 ? void 0 : _a.call(_fiber);
8123
+ myreactReconcilerExports.safeCallWithCurrentFiber({
8124
+ fiber: _fiber,
8125
+ action: function safeCallSetRef() {
8126
+ var _a, _b;
8127
+ if (typeof ref_2 === "object" && ref_2 !== null) {
8128
+ ref_2.current = (_a = config === null || config === void 0 ? void 0 : config.getPublicInstance) === null || _a === void 0 ? void 0 : _a.call(config, _fiber.instance);
8129
+ }
8130
+ else if (typeof ref_2 === "function") {
7984
8131
  var refCleanUp = ref_2((_b = config === null || config === void 0 ? void 0 : config.getPublicInstance) === null || _b === void 0 ? void 0 : _b.call(config, _fiber.instance));
7985
8132
  if (typeof refCleanUp === "function") {
7986
8133
  _fiber.refCleanup = refCleanUp;
7987
8134
  }
7988
- },
7989
- });
7990
- }
8135
+ }
8136
+ },
8137
+ });
7991
8138
  }
7992
8139
  else {
7993
8140
  throw new Error("[@my-react/react-dom] class component do not have a instance");
@@ -8391,6 +8538,9 @@ var ReconcilerDispatchFiber = function (renderDispatch, fiber) {
8391
8538
  else if (myreactSharedExports.include(fiber.type, myreactReconcilerExports.NODE_TYPE.__provider__ | myreactReconcilerExports.NODE_TYPE.__context__)) {
8392
8539
  myreactReconcilerExports.nextWorkProvider(renderDispatch, fiber);
8393
8540
  }
8541
+ else if (myreactSharedExports.include(fiber.type, myreactReconcilerExports.NODE_TYPE.__activity__)) {
8542
+ myreactReconcilerExports.nextWorkActivity(renderDispatch, fiber);
8543
+ }
8394
8544
  else {
8395
8545
  myreactReconcilerExports.nextWorkNormal(renderDispatch, fiber);
8396
8546
  }
@@ -8457,13 +8607,17 @@ var ReconcilerDispatchMount = function (_dispatch, _fiber, config) {
8457
8607
  myreactReconcilerExports.layoutEffect(_dispatch, _fiber);
8458
8608
  });
8459
8609
  myreactReconcilerExports.afterSyncUpdate();
8460
- var renderScheduler = currentScheduler$2.current;
8461
- renderScheduler.microTask(function invokeEffectListTask() {
8610
+ function invokeEffectListTask() {
8462
8611
  enableScopeTreeLog$3.current && myreactReconcilerExports.setLogScope();
8463
8612
  _list.listToFoot(function invokeEffectList(_fiber) {
8464
8613
  myreactReconcilerExports.effect(_dispatch, _fiber);
8465
8614
  });
8466
8615
  enableScopeTreeLog$3.current && myreactReconcilerExports.resetLogScope();
8616
+ }
8617
+ myreactReconcilerExports.addEffectCallback(invokeEffectListTask);
8618
+ var renderScheduler = currentScheduler$2.current;
8619
+ renderScheduler.macroTask(function flushEffect() {
8620
+ myreactReconcilerExports.flushEffectCallback();
8467
8621
  });
8468
8622
  };
8469
8623
 
@@ -8560,9 +8714,7 @@ var ReconcilerDispatchUpdate = function (_dispatch, _list, config) {
8560
8714
  }
8561
8715
  });
8562
8716
  myreactReconcilerExports.afterSyncUpdate();
8563
- var renderScheduler = currentScheduler$1.current;
8564
- // TODO before next update flow, make sure all the effect has done
8565
- renderScheduler.microTask(function invokeEffectListTask() {
8717
+ function invokeEffectListTask() {
8566
8718
  enableScopeTreeLog$2.current && myreactReconcilerExports.setLogScope();
8567
8719
  _list.listToFoot(function invokeEffectList(_fiber) {
8568
8720
  if (myreactSharedExports.exclude(_fiber.state, myreactSharedExports.STATE_TYPE.__unmount__) && !_dispatch.isAppUnmounted) {
@@ -8570,7 +8722,19 @@ var ReconcilerDispatchUpdate = function (_dispatch, _list, config) {
8570
8722
  }
8571
8723
  });
8572
8724
  enableScopeTreeLog$2.current && myreactReconcilerExports.resetLogScope();
8573
- });
8725
+ }
8726
+ myreactReconcilerExports.addEffectCallback(invokeEffectListTask);
8727
+ var renderScheduler = currentScheduler$1.current;
8728
+ if (_dispatch.enableConcurrentMode) {
8729
+ renderScheduler.macroTask(function flushEffect() {
8730
+ myreactReconcilerExports.flushEffectCallback();
8731
+ });
8732
+ }
8733
+ else {
8734
+ renderScheduler.microTask(function flushEffect() {
8735
+ myreactReconcilerExports.flushEffectCallback();
8736
+ });
8737
+ }
8574
8738
  };
8575
8739
 
8576
8740
  var currentComponentFiber = require$$0.__my_react_internal__.currentComponentFiber;
@@ -8676,6 +8840,9 @@ var createDispatch = function (rootNode, rootFiber, rootElement, config, flag) {
8676
8840
  ReconcilerDispatch.prototype.dispatchPromise = function (_params) {
8677
8841
  return myreactReconcilerExports.processPromise(this, _params.fiber, _params.promise);
8678
8842
  };
8843
+ ReconcilerDispatch.prototype.dispatchSuspensePromise = function (_params) {
8844
+ return myreactReconcilerExports.processSuspensePromise(this, _params.fiber, _params.promise);
8845
+ };
8679
8846
  ReconcilerDispatch.prototype.dispatchError = function (_params) {
8680
8847
  {
8681
8848
  myreactReconcilerExports.devErrorWithFiber(_params.fiber, _params.error);
@@ -8797,7 +8964,7 @@ var prepareScheduler = function () {
8797
8964
 
8798
8965
  var enableDebugFiled = require$$0.__my_react_shared__.enableDebugFiled, enableScopeTreeLog = require$$0.__my_react_shared__.enableScopeTreeLog;
8799
8966
  var currentScheduler = require$$0.__my_react_internal__.currentScheduler;
8800
- // react-reconciler compact implementation
8967
+ // react-reconciler compat implementation
8801
8968
  var Reconciler = function (_config) {
8802
8969
  var rendererPackageName = "@my-react";
8803
8970
  var ReconcilerSet = new Set();
@@ -8813,7 +8980,7 @@ var Reconciler = function (_config) {
8813
8980
  }
8814
8981
  enableDebugFiled.current = true;
8815
8982
  enableScopeTreeLog.current = false;
8816
- // enableFiberForLog.current = false;
8983
+ myreactReconcilerExports.enableFiberForLog.current = false;
8817
8984
  return _container;
8818
8985
  };
8819
8986
  var updateContainer = function (_element, _container, _ignore, _cb) {
@@ -8907,7 +9074,7 @@ var Reconciler = function (_config) {
8907
9074
  };
8908
9075
  };
8909
9076
 
8910
- var version = "0.0.8";
9077
+ var version = "0.0.10";
8911
9078
  var createReconciler = Reconciler;
8912
9079
 
8913
9080
  exports.createReconciler = createReconciler;