@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.
- package/dist/cjs/index.development.js +316 -149
- package/dist/cjs/index.production.js +307 -149
- package/dist/types/api/ref.d.ts.map +1 -1
- package/dist/types/dispatch.d.ts +6 -0
- package/dist/types/dispatch.d.ts.map +1 -1
- package/dist/types/dispatchFiber.d.ts.map +1 -1
- package/dist/types/dispatchMount.d.ts.map +1 -1
- package/dist/types/dispatchUpdate.d.ts.map +1 -1
- package/package.json +4 -4
|
@@ -183,6 +183,7 @@ function requireIndex_production_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_production_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_production_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;
|
|
@@ -696,6 +699,7 @@ function requireIndex_production_1 () {
|
|
|
696
699
|
return ListTree;
|
|
697
700
|
}());
|
|
698
701
|
|
|
702
|
+
exports.Activity = Activity;
|
|
699
703
|
exports.Comment = Comment;
|
|
700
704
|
exports.Consumer = Consumer;
|
|
701
705
|
exports.Context = Context;
|
|
@@ -885,6 +889,7 @@ function requireIndex_production_1 () {
|
|
|
885
889
|
NODE_TYPE[NODE_TYPE["__context__"] = 524288] = "__context__";
|
|
886
890
|
NODE_TYPE[NODE_TYPE["__scopeLazy__"] = 1048576] = "__scopeLazy__";
|
|
887
891
|
NODE_TYPE[NODE_TYPE["__scopeSuspense__"] = 2097152] = "__scopeSuspense__";
|
|
892
|
+
NODE_TYPE[NODE_TYPE["__activity__"] = 4194304] = "__activity__";
|
|
888
893
|
})(exports.NODE_TYPE || (exports.NODE_TYPE = {}));
|
|
889
894
|
|
|
890
895
|
var enableSyncFlush$1 = react.__my_react_shared__.enableSyncFlush;
|
|
@@ -1330,7 +1335,7 @@ function requireIndex_production_1 () {
|
|
|
1330
1335
|
if (typeof element === "object" && element !== null) {
|
|
1331
1336
|
nodeType = myreactSharedExports.merge(nodeType, exports.NODE_TYPE.__empty__);
|
|
1332
1337
|
}
|
|
1333
|
-
else if (element === null || element === undefined || typeof element === "boolean" || typeof element === "function") {
|
|
1338
|
+
else if (element === null || element === undefined || typeof element === "boolean" || typeof element === "function" || element === "") {
|
|
1334
1339
|
nodeType = myreactSharedExports.merge(nodeType, exports.NODE_TYPE.__null__);
|
|
1335
1340
|
}
|
|
1336
1341
|
else {
|
|
@@ -1447,11 +1452,14 @@ function requireIndex_production_1 () {
|
|
|
1447
1452
|
case myreactSharedExports.Profiler:
|
|
1448
1453
|
nodeType = myreactSharedExports.merge(nodeType, exports.NODE_TYPE.__profiler__);
|
|
1449
1454
|
break;
|
|
1455
|
+
case myreactSharedExports.Activity:
|
|
1456
|
+
nodeType = myreactSharedExports.merge(nodeType, exports.NODE_TYPE.__activity__);
|
|
1457
|
+
break;
|
|
1450
1458
|
default:
|
|
1451
1459
|
throw new Error("[@my-react/react] invalid symbol element type \"".concat(elementType === null || elementType === void 0 ? void 0 : elementType.toString(), "\""));
|
|
1452
1460
|
}
|
|
1453
1461
|
}
|
|
1454
|
-
else if (typeof elementType === "string") {
|
|
1462
|
+
else if (typeof elementType === "string" && elementType !== "") {
|
|
1455
1463
|
nodeType = myreactSharedExports.merge(nodeType, exports.NODE_TYPE.__plain__);
|
|
1456
1464
|
}
|
|
1457
1465
|
else {
|
|
@@ -1488,7 +1496,17 @@ function requireIndex_production_1 () {
|
|
|
1488
1496
|
return new Set(Array.from(fibers || []).map(function (fiber) { return fiberToDispatchMap.get(fiber); }));
|
|
1489
1497
|
};
|
|
1490
1498
|
var getCurrentDispatchFromFiber = function (fiber) {
|
|
1491
|
-
|
|
1499
|
+
var dispatch = fiberToDispatchMap.get(fiber);
|
|
1500
|
+
if (dispatch)
|
|
1501
|
+
return dispatch;
|
|
1502
|
+
var parent = fiber.parent;
|
|
1503
|
+
while (parent) {
|
|
1504
|
+
var typedFiberRoot = parent;
|
|
1505
|
+
if (typedFiberRoot.renderDispatch) {
|
|
1506
|
+
return typedFiberRoot.renderDispatch;
|
|
1507
|
+
}
|
|
1508
|
+
parent = parent.parent;
|
|
1509
|
+
}
|
|
1492
1510
|
};
|
|
1493
1511
|
var getElementFromRefreshIfExist = function (element) {
|
|
1494
1512
|
var _a, _b;
|
|
@@ -1539,10 +1557,10 @@ function requireIndex_production_1 () {
|
|
|
1539
1557
|
var dispatchError = function (_params) {
|
|
1540
1558
|
var fiber = _params.fiber || currentRunningFiber$3.current;
|
|
1541
1559
|
if (!fiber) {
|
|
1542
|
-
|
|
1560
|
+
// a normal error
|
|
1561
|
+
throw _params.error;
|
|
1543
1562
|
}
|
|
1544
|
-
if (
|
|
1545
|
-
return;
|
|
1563
|
+
// if (include(fiber.state, STATE_TYPE.__unmount__)) return;
|
|
1546
1564
|
var dispatch = getCurrentDispatchFromFiber(fiber);
|
|
1547
1565
|
if (!dispatch) {
|
|
1548
1566
|
throw new Error("No dispatch found for the current running fiber.");
|
|
@@ -1554,14 +1572,25 @@ function requireIndex_production_1 () {
|
|
|
1554
1572
|
if (!fiber) {
|
|
1555
1573
|
throw new Error("No fiber found for dispatching promise.");
|
|
1556
1574
|
}
|
|
1557
|
-
if (
|
|
1558
|
-
return;
|
|
1575
|
+
// if (include(fiber.state, STATE_TYPE.__unmount__)) return;
|
|
1559
1576
|
var dispatch = getCurrentDispatchFromFiber(fiber);
|
|
1560
1577
|
if (!dispatch) {
|
|
1561
1578
|
throw new Error("No dispatch found for the current running fiber.");
|
|
1562
1579
|
}
|
|
1563
1580
|
return dispatch.dispatchPromise(_params);
|
|
1564
1581
|
};
|
|
1582
|
+
var dispatchSuspensePromise = function (_params) {
|
|
1583
|
+
var fiber = _params.fiber || currentRunningFiber$3.current;
|
|
1584
|
+
if (!fiber) {
|
|
1585
|
+
throw new Error("No fiber found for dispatching suspense promise.");
|
|
1586
|
+
}
|
|
1587
|
+
// if (include(fiber.state, STATE_TYPE.__unmount__)) return;
|
|
1588
|
+
var dispatch = getCurrentDispatchFromFiber(fiber);
|
|
1589
|
+
if (!dispatch) {
|
|
1590
|
+
throw new Error("No dispatch found for the current running fiber.");
|
|
1591
|
+
}
|
|
1592
|
+
return dispatch.dispatchSuspensePromise(_params);
|
|
1593
|
+
};
|
|
1565
1594
|
var readContext = function (_params) {
|
|
1566
1595
|
var fiber = currentRunningFiber$3.current;
|
|
1567
1596
|
if (!fiber) {
|
|
@@ -1606,6 +1635,7 @@ function requireIndex_production_1 () {
|
|
|
1606
1635
|
scheduler.dispatchHook = dispatchHook;
|
|
1607
1636
|
scheduler.dispatchError = dispatchError;
|
|
1608
1637
|
scheduler.dispatchPromise = dispatchPromise;
|
|
1638
|
+
scheduler.dispatchSuspensePromise = dispatchSuspensePromise;
|
|
1609
1639
|
};
|
|
1610
1640
|
|
|
1611
1641
|
react.__my_react_shared__.enableHMRForDev;
|
|
@@ -1809,6 +1839,16 @@ function requireIndex_production_1 () {
|
|
|
1809
1839
|
child = child.sibling;
|
|
1810
1840
|
}
|
|
1811
1841
|
};
|
|
1842
|
+
var effectCallbackList = new myreactSharedExports.ListTree();
|
|
1843
|
+
var addEffectCallback = function (cb) {
|
|
1844
|
+
effectCallbackList.push(cb);
|
|
1845
|
+
};
|
|
1846
|
+
var flushEffectCallback = function () {
|
|
1847
|
+
effectCallbackList.listToFoot(function (cb) {
|
|
1848
|
+
cb();
|
|
1849
|
+
});
|
|
1850
|
+
effectCallbackList.clear();
|
|
1851
|
+
};
|
|
1812
1852
|
var effect = defaultInvokeEffect;
|
|
1813
1853
|
var layoutEffect = defaultInvokeLayoutEffect;
|
|
1814
1854
|
var insertionEffect = defaultInvokeInsertionEffect;
|
|
@@ -1875,7 +1915,10 @@ function requireIndex_production_1 () {
|
|
|
1875
1915
|
}
|
|
1876
1916
|
currentRunningFiber$2.current = null;
|
|
1877
1917
|
}
|
|
1878
|
-
if (
|
|
1918
|
+
if (myreactSharedExports.include(fiber.state, myreactSharedExports.STATE_TYPE.__suspense__)) {
|
|
1919
|
+
fiber.state = myreactSharedExports.STATE_TYPE.__recreate__;
|
|
1920
|
+
}
|
|
1921
|
+
else if (!myreactSharedExports.include(fiber.state, myreactSharedExports.STATE_TYPE.__retrigger__)) {
|
|
1879
1922
|
fiber.state = myreactSharedExports.STATE_TYPE.__stable__;
|
|
1880
1923
|
}
|
|
1881
1924
|
else {
|
|
@@ -1914,7 +1957,10 @@ function requireIndex_production_1 () {
|
|
|
1914
1957
|
currentRunningFiber$2.current = null;
|
|
1915
1958
|
triggerFiberUpdateListener(renderDispatch, fiber);
|
|
1916
1959
|
}
|
|
1917
|
-
if (
|
|
1960
|
+
if (myreactSharedExports.include(fiber.state, myreactSharedExports.STATE_TYPE.__suspense__)) {
|
|
1961
|
+
fiber.state = myreactSharedExports.STATE_TYPE.__recreate__;
|
|
1962
|
+
}
|
|
1963
|
+
else if (!myreactSharedExports.include(fiber.state, myreactSharedExports.STATE_TYPE.__retrigger__)) {
|
|
1918
1964
|
fiber.state = myreactSharedExports.STATE_TYPE.__stable__;
|
|
1919
1965
|
}
|
|
1920
1966
|
else {
|
|
@@ -2114,15 +2160,12 @@ function requireIndex_production_1 () {
|
|
|
2114
2160
|
throw new Error("[@my-react/reconciler] should not process async load list on sync mount without enableAsyncLoad, you may use a wrong renderDispatch instance");
|
|
2115
2161
|
}
|
|
2116
2162
|
}
|
|
2117
|
-
// TODO update flow
|
|
2118
2163
|
if (enableSuspenseRoot$3.current) {
|
|
2119
2164
|
var suspenseField_2 = getInstanceFieldByInstance(renderDispatch);
|
|
2120
2165
|
var list = suspenseField_2.asyncLoadList.getAll();
|
|
2121
2166
|
if (list.length === 0)
|
|
2122
2167
|
return;
|
|
2123
2168
|
if (renderDispatch.enableAsyncLoad) {
|
|
2124
|
-
// defaultDeleteCurrentEffect(renderDispatch, renderDispatch.rootFiber);
|
|
2125
|
-
// defaultDeleteChildEffect(renderDispatch, renderDispatch.rootFiber);
|
|
2126
2169
|
var allPendingLoadArray = list.filter(function (item) {
|
|
2127
2170
|
if (myreactSharedExports.isPromise(item)) {
|
|
2128
2171
|
return typeof item.status !== "string";
|
|
@@ -2169,13 +2212,6 @@ function requireIndex_production_1 () {
|
|
|
2169
2212
|
});
|
|
2170
2213
|
}); }));
|
|
2171
2214
|
}
|
|
2172
|
-
// suspenseField.isHidden = true;
|
|
2173
|
-
// const root = renderDispatch.rootFiber;
|
|
2174
|
-
// root.state = remove(root.state, STATE_TYPE.__stable__);
|
|
2175
|
-
// root.state = merge(root.state, STATE_TYPE.__retrigger__);
|
|
2176
|
-
// // TODO use hide tree to improve
|
|
2177
|
-
// mountLoopAll(renderDispatch, root);
|
|
2178
|
-
// suspenseField.isHidden = false;
|
|
2179
2215
|
}
|
|
2180
2216
|
else {
|
|
2181
2217
|
throw new Error("[@my-react/reconciler] should not process async load list on sync mount without enableAsyncLoad, you may use a wrong renderDispatch instance");
|
|
@@ -2302,66 +2338,12 @@ function requireIndex_production_1 () {
|
|
|
2302
2338
|
}
|
|
2303
2339
|
// TODO update flow
|
|
2304
2340
|
if (enableSuspenseRoot$2.current) {
|
|
2305
|
-
var
|
|
2306
|
-
var list =
|
|
2341
|
+
var suspenseField = getInstanceFieldByInstance(renderDispatch);
|
|
2342
|
+
var list = suspenseField.asyncLoadList.getAll();
|
|
2307
2343
|
if (list.length === 0)
|
|
2308
2344
|
return;
|
|
2309
2345
|
if (renderDispatch.enableAsyncLoad) {
|
|
2310
|
-
|
|
2311
|
-
// defaultDeleteChildEffect(renderDispatch, renderDispatch.rootFiber);
|
|
2312
|
-
var allPendingLoadArray = list.filter(function (item) {
|
|
2313
|
-
if (myreactSharedExports.isPromise(item)) {
|
|
2314
|
-
return typeof item.status !== "string";
|
|
2315
|
-
}
|
|
2316
|
-
else {
|
|
2317
|
-
return !item._loading && !item._loaded && !item._error;
|
|
2318
|
-
}
|
|
2319
|
-
});
|
|
2320
|
-
if (allPendingLoadArray.length) {
|
|
2321
|
-
allPendingLoadArray.forEach(function (item) { var _a; return (_a = item._list) === null || _a === void 0 ? void 0 : _a.forEach(function (node) { return defaultDeleteCurrentEffect(renderDispatch, node); }); });
|
|
2322
|
-
Promise.all(allPendingLoadArray.map(function (item) { return __awaiter(void 0, void 0, void 0, function () {
|
|
2323
|
-
var allFiber;
|
|
2324
|
-
var _a;
|
|
2325
|
-
return __generator(this, function (_b) {
|
|
2326
|
-
switch (_b.label) {
|
|
2327
|
-
case 0:
|
|
2328
|
-
if (!myreactSharedExports.isPromise(item)) return [3 /*break*/, 2];
|
|
2329
|
-
return [4 /*yield*/, renderDispatch.processPromise(item)];
|
|
2330
|
-
case 1:
|
|
2331
|
-
_b.sent();
|
|
2332
|
-
return [3 /*break*/, 4];
|
|
2333
|
-
case 2: return [4 /*yield*/, renderDispatch.processLazy(item)];
|
|
2334
|
-
case 3:
|
|
2335
|
-
_b.sent();
|
|
2336
|
-
_b.label = 4;
|
|
2337
|
-
case 4:
|
|
2338
|
-
allFiber = new Set(item._list);
|
|
2339
|
-
(_a = item._list) === null || _a === void 0 ? void 0 : _a.clear();
|
|
2340
|
-
allFiber.forEach(function (node) {
|
|
2341
|
-
node.state = myreactSharedExports.STATE_TYPE.__recreate__;
|
|
2342
|
-
var renderScheduler = currentScheduler$d.current;
|
|
2343
|
-
var updater = {
|
|
2344
|
-
type: myreactSharedExports.UpdateQueueType.suspense,
|
|
2345
|
-
trigger: node,
|
|
2346
|
-
isSync: true,
|
|
2347
|
-
isForce: true,
|
|
2348
|
-
payLoad: [item],
|
|
2349
|
-
};
|
|
2350
|
-
renderScheduler.dispatchState(updater);
|
|
2351
|
-
});
|
|
2352
|
-
suspenseField_1.asyncLoadList.uniDelete(item);
|
|
2353
|
-
return [2 /*return*/];
|
|
2354
|
-
}
|
|
2355
|
-
});
|
|
2356
|
-
}); }));
|
|
2357
|
-
}
|
|
2358
|
-
// suspenseField.isHidden = true;
|
|
2359
|
-
// const root = renderDispatch.rootFiber;
|
|
2360
|
-
// root.state = remove(root.state, STATE_TYPE.__stable__);
|
|
2361
|
-
// root.state = merge(root.state, STATE_TYPE.__retrigger__);
|
|
2362
|
-
// // TODO use hide tree to improve
|
|
2363
|
-
// mountLoopAll(renderDispatch, root);
|
|
2364
|
-
// suspenseField.isHidden = false;
|
|
2346
|
+
throw new Error("[@my-react/reconciler] not implemented yet");
|
|
2365
2347
|
}
|
|
2366
2348
|
else {
|
|
2367
2349
|
throw new Error("[@my-react/reconciler] should not process async load list on sync mount without enableAsyncLoad, you may use a wrong renderDispatch instance");
|
|
@@ -2824,7 +2806,7 @@ function requireIndex_production_1 () {
|
|
|
2824
2806
|
_loop_1();
|
|
2825
2807
|
}
|
|
2826
2808
|
if (allQueue.length) {
|
|
2827
|
-
renderScheduler.
|
|
2809
|
+
renderScheduler.microTask(function prepareUpdateOnFiberTask() {
|
|
2828
2810
|
prepareUpdateOnFiber(renderDispatch, fiber, true);
|
|
2829
2811
|
});
|
|
2830
2812
|
}
|
|
@@ -2905,7 +2887,7 @@ function requireIndex_production_1 () {
|
|
|
2905
2887
|
var allQueue = fiber.updateQueue;
|
|
2906
2888
|
var node = allQueue === null || allQueue === void 0 ? void 0 : allQueue.head;
|
|
2907
2889
|
var needUpdate = true;
|
|
2908
|
-
var isSync =
|
|
2890
|
+
var isSync = true;
|
|
2909
2891
|
var isForce = false;
|
|
2910
2892
|
var isImmediate = false;
|
|
2911
2893
|
var isRetrigger = false;
|
|
@@ -3037,7 +3019,7 @@ function requireIndex_production_1 () {
|
|
|
3037
3019
|
_loop_3();
|
|
3038
3020
|
}
|
|
3039
3021
|
if (allQueue.length) {
|
|
3040
|
-
renderScheduler.
|
|
3022
|
+
renderScheduler.microTask(function prepareUpdateOnFiberTask() {
|
|
3041
3023
|
prepareUpdateOnFiber(renderDispatch, fiber, true);
|
|
3042
3024
|
});
|
|
3043
3025
|
}
|
|
@@ -3136,7 +3118,7 @@ function requireIndex_production_1 () {
|
|
|
3136
3118
|
var allQueue = fiber.updateQueue;
|
|
3137
3119
|
var node = allQueue === null || allQueue === void 0 ? void 0 : allQueue.head;
|
|
3138
3120
|
var needUpdate = false;
|
|
3139
|
-
var isSync =
|
|
3121
|
+
var isSync = true;
|
|
3140
3122
|
var isForce = false;
|
|
3141
3123
|
var isImmediate = false;
|
|
3142
3124
|
var isRetrigger = false;
|
|
@@ -3256,7 +3238,7 @@ function requireIndex_production_1 () {
|
|
|
3256
3238
|
var renderScheduler = currentScheduler$c.current;
|
|
3257
3239
|
var node = allQueue === null || allQueue === void 0 ? void 0 : allQueue.head;
|
|
3258
3240
|
var needUpdate = true;
|
|
3259
|
-
var isSync =
|
|
3241
|
+
var isSync = true;
|
|
3260
3242
|
var isForce = false;
|
|
3261
3243
|
var isImmediate = false;
|
|
3262
3244
|
var isRetrigger = false;
|
|
@@ -3579,6 +3561,7 @@ function requireIndex_production_1 () {
|
|
|
3579
3561
|
|
|
3580
3562
|
var globalLoop$2 = react.__my_react_internal__.globalLoop, currentScheduler$a = react.__my_react_internal__.currentScheduler;
|
|
3581
3563
|
var scheduleUpdateFromRoot = function (renderDispatch) {
|
|
3564
|
+
flushEffectCallback();
|
|
3582
3565
|
var allLive = renderDispatch.pendingUpdateFiberArray.getAll().filter(function (f) { return myreactSharedExports.exclude(f.state, myreactSharedExports.STATE_TYPE.__unmount__); });
|
|
3583
3566
|
renderDispatch.pendingUpdateFiberArray.clear();
|
|
3584
3567
|
if (allLive.length) {
|
|
@@ -3684,7 +3667,7 @@ function requireIndex_production_1 () {
|
|
|
3684
3667
|
return myreactSharedExports.include(renderDispatch.runtimeFiber.nextWorkingFiber.state, myreactSharedExports.STATE_TYPE.__triggerSync__ | myreactSharedExports.STATE_TYPE.__triggerSyncForce__);
|
|
3685
3668
|
// include(renderDispatch.runtimeFiber.nextWorkingFiber.state, STATE_TYPE.__retrigger__)
|
|
3686
3669
|
}
|
|
3687
|
-
function
|
|
3670
|
+
function updateConcurrentNextFrame(renderDispatch) {
|
|
3688
3671
|
var renderScheduler = currentScheduler$9.current;
|
|
3689
3672
|
var hasSync = updateLoopConcurrentFromRoot(renderDispatch);
|
|
3690
3673
|
if (renderDispatch.runtimeFiber.nextWorkingFiber) {
|
|
@@ -3697,7 +3680,7 @@ function requireIndex_production_1 () {
|
|
|
3697
3680
|
updateSyncFromRoot(renderDispatch);
|
|
3698
3681
|
}
|
|
3699
3682
|
else {
|
|
3700
|
-
|
|
3683
|
+
updateConcurrentNextFrame(renderDispatch);
|
|
3701
3684
|
}
|
|
3702
3685
|
});
|
|
3703
3686
|
}
|
|
@@ -3706,7 +3689,6 @@ function requireIndex_production_1 () {
|
|
|
3706
3689
|
processAsyncLoadListOnUpdate(renderDispatch);
|
|
3707
3690
|
finishUpdateConcurrentFromRoot(renderDispatch);
|
|
3708
3691
|
renderScheduler.microTask(function callScheduleNext() {
|
|
3709
|
-
// TODO! flash all effect
|
|
3710
3692
|
globalLoop$1.current = false;
|
|
3711
3693
|
scheduleNext(renderDispatch);
|
|
3712
3694
|
});
|
|
@@ -3726,7 +3708,7 @@ function requireIndex_production_1 () {
|
|
|
3726
3708
|
updateSyncFromRoot(renderDispatch);
|
|
3727
3709
|
}
|
|
3728
3710
|
else {
|
|
3729
|
-
|
|
3711
|
+
updateConcurrentNextFrame(renderDispatch);
|
|
3730
3712
|
}
|
|
3731
3713
|
});
|
|
3732
3714
|
}
|
|
@@ -3735,7 +3717,6 @@ function requireIndex_production_1 () {
|
|
|
3735
3717
|
processAsyncLoadListOnUpdate(renderDispatch);
|
|
3736
3718
|
finishUpdateConcurrentFromRoot(renderDispatch);
|
|
3737
3719
|
renderScheduler.microTask(function callScheduleNext() {
|
|
3738
|
-
// TODO! flash all effect
|
|
3739
3720
|
globalLoop$1.current = false;
|
|
3740
3721
|
scheduleNext(renderDispatch);
|
|
3741
3722
|
});
|
|
@@ -3776,7 +3757,9 @@ function requireIndex_production_1 () {
|
|
|
3776
3757
|
if (!field)
|
|
3777
3758
|
throw new Error("[@my-react/react] hook instance not found, look like a bug for @my-react");
|
|
3778
3759
|
var typedField = field;
|
|
3779
|
-
typedField.dispatch = function (action) {
|
|
3760
|
+
typedField.dispatch = function dispatchAction(action) {
|
|
3761
|
+
hookNode._update({ payLoad: action, isForce: false, isSync: enableSyncFlush.current });
|
|
3762
|
+
};
|
|
3780
3763
|
};
|
|
3781
3764
|
|
|
3782
3765
|
var currentComponentFiber$3 = react.__my_react_internal__.currentComponentFiber;
|
|
@@ -3812,12 +3795,22 @@ function requireIndex_production_1 () {
|
|
|
3812
3795
|
};
|
|
3813
3796
|
var defaultOptimisticReducer = function (state) { return state; };
|
|
3814
3797
|
var createHookNode = function (renderDispatch, _a, fiber) {
|
|
3815
|
-
var _b;
|
|
3798
|
+
var _b, _c;
|
|
3816
3799
|
var type = _a.type, value = _a.value, reducer = _a.reducer, deps = _a.deps;
|
|
3817
3800
|
var currentHook = (_b = currentHookTreeNode$2.current) === null || _b === void 0 ? void 0 : _b.value;
|
|
3818
3801
|
var currentHookIndex = currentHookNodeIndex$2.current;
|
|
3802
|
+
var currentIsReCreate = myreactSharedExports.include(fiber.state, myreactSharedExports.STATE_TYPE.__recreate__);
|
|
3819
3803
|
if (currentHook) {
|
|
3820
|
-
|
|
3804
|
+
if (currentIsReCreate) {
|
|
3805
|
+
if (currentHookIndex === 0) {
|
|
3806
|
+
defaultDeleteChildEffect(renderDispatch, fiber);
|
|
3807
|
+
defaultDeleteCurrentEffect(renderDispatch, fiber);
|
|
3808
|
+
fiber.hookList.clear();
|
|
3809
|
+
}
|
|
3810
|
+
}
|
|
3811
|
+
else {
|
|
3812
|
+
throw new Error("[@my-react/react] should not have a hookList for current node, this is a bug for @my-react");
|
|
3813
|
+
}
|
|
3821
3814
|
}
|
|
3822
3815
|
var hookNode = new MyReactHookNode(type, value, reducer || defaultReducer, deps);
|
|
3823
3816
|
initInstance(hookNode);
|
|
@@ -3838,9 +3831,16 @@ function requireIndex_production_1 () {
|
|
|
3838
3831
|
hookNode.result = hookNode.value;
|
|
3839
3832
|
hookNode.hasEffect = true;
|
|
3840
3833
|
}
|
|
3841
|
-
if (hookNode.type === myreactSharedExports.HOOK_TYPE.useRef ||
|
|
3834
|
+
if (hookNode.type === myreactSharedExports.HOOK_TYPE.useRef ||
|
|
3835
|
+
hookNode.type === myreactSharedExports.HOOK_TYPE.useCallback ||
|
|
3836
|
+
hookNode.type === myreactSharedExports.HOOK_TYPE.useDeferredValue ||
|
|
3837
|
+
hookNode.type === myreactSharedExports.HOOK_TYPE.useEffectEvent) {
|
|
3842
3838
|
hookNode.result = hookNode.value;
|
|
3843
3839
|
}
|
|
3840
|
+
// cache ref state from recreate
|
|
3841
|
+
if (hookNode.type === myreactSharedExports.HOOK_TYPE.useRef && currentHook && currentHook.type === myreactSharedExports.HOOK_TYPE.useRef) {
|
|
3842
|
+
hookNode.result = currentHook.result;
|
|
3843
|
+
}
|
|
3844
3844
|
if (hookNode.type === myreactSharedExports.HOOK_TYPE.useId) {
|
|
3845
3845
|
hookNode.result = "\u00AB-".concat(currentHookIndex, "-").concat(renderDispatch.uniqueIdCount++, "-\u00BB");
|
|
3846
3846
|
hookNode.cancel = function () { return renderDispatch.uniqueIdCount--; };
|
|
@@ -3863,12 +3863,13 @@ function requireIndex_production_1 () {
|
|
|
3863
3863
|
return safeCallWithCurrentFiber({
|
|
3864
3864
|
fiber: fiber,
|
|
3865
3865
|
action: function safeCallGetSnapshot() {
|
|
3866
|
-
var _a;
|
|
3867
3866
|
return renderDispatch.isAppMounted
|
|
3868
3867
|
? storeApi_1.getSnapshot.call(null)
|
|
3869
|
-
:
|
|
3870
|
-
|
|
3871
|
-
|
|
3868
|
+
: // SEE https://github.com/facebook/react/blob/main/packages/use-sync-external-store/src/useSyncExternalStoreShimClient.js#L33
|
|
3869
|
+
// : storeApi.getServerSnapshot
|
|
3870
|
+
// ? storeApi.getServerSnapshot?.call(null)
|
|
3871
|
+
// : storeApi.getSnapshot.call(null);
|
|
3872
|
+
storeApi_1.getSnapshot.call(null);
|
|
3872
3873
|
},
|
|
3873
3874
|
});
|
|
3874
3875
|
};
|
|
@@ -3962,6 +3963,7 @@ function requireIndex_production_1 () {
|
|
|
3962
3963
|
},
|
|
3963
3964
|
};
|
|
3964
3965
|
}
|
|
3966
|
+
currentHookTreeNode$2.current = (_c = currentHookTreeNode$2.current) === null || _c === void 0 ? void 0 : _c.next;
|
|
3965
3967
|
return hookNode;
|
|
3966
3968
|
};
|
|
3967
3969
|
|
|
@@ -4203,6 +4205,13 @@ function requireIndex_production_1 () {
|
|
|
4203
4205
|
// currentHook._update({ isForce: true, payLoad: (last) => ({ value: value.value, start: last.start }) });
|
|
4204
4206
|
}
|
|
4205
4207
|
}
|
|
4208
|
+
if (currentHook.type === myreactSharedExports.HOOK_TYPE.useEffectEvent) {
|
|
4209
|
+
if (typeof value !== "function") {
|
|
4210
|
+
throw new Error("[@my-react/react] useEffectEvent should be a function");
|
|
4211
|
+
}
|
|
4212
|
+
currentHook.value = value;
|
|
4213
|
+
currentHook.result = value;
|
|
4214
|
+
}
|
|
4206
4215
|
if (currentHook.type === myreactSharedExports.HOOK_TYPE.useDebugValue) {
|
|
4207
4216
|
if (!myreactSharedExports.isArrayEquals(currentHook.value, value)) {
|
|
4208
4217
|
currentHook.value = value;
|
|
@@ -4506,7 +4515,7 @@ function requireIndex_production_1 () {
|
|
|
4506
4515
|
renderDispatch.pendingUpdate(fiber);
|
|
4507
4516
|
}
|
|
4508
4517
|
}
|
|
4509
|
-
if (
|
|
4518
|
+
if (prevRef !== nextRef) {
|
|
4510
4519
|
renderDispatch.pendingRef(fiber);
|
|
4511
4520
|
}
|
|
4512
4521
|
if (fiber !== prevFiber) {
|
|
@@ -4659,8 +4668,8 @@ function requireIndex_production_1 () {
|
|
|
4659
4668
|
return updateFiberNode(renderDispatch, { fiber: draftFiber_1, parent: parentFiber, prevFiber: prevFiberChild }, newElement);
|
|
4660
4669
|
}
|
|
4661
4670
|
else {
|
|
4662
|
-
renderDispatch.generateChangedList(parentFiber);
|
|
4663
|
-
renderDispatch.pendingUnmount(parentFiber, draftFiber_1);
|
|
4671
|
+
draftFiber_1 && renderDispatch.generateChangedList(parentFiber);
|
|
4672
|
+
draftFiber_1 && renderDispatch.pendingUnmount(parentFiber, draftFiber_1);
|
|
4664
4673
|
return createFragmentWithUpdate(renderDispatch, newChild, parentFiber);
|
|
4665
4674
|
}
|
|
4666
4675
|
}
|
|
@@ -4677,7 +4686,7 @@ function requireIndex_production_1 () {
|
|
|
4677
4686
|
}
|
|
4678
4687
|
else {
|
|
4679
4688
|
draftFiber && renderDispatch.pendingUnmount(parentFiber, draftFiber);
|
|
4680
|
-
renderDispatch.generateChangedList(parentFiber);
|
|
4689
|
+
draftFiber && renderDispatch.generateChangedList(parentFiber);
|
|
4681
4690
|
return createFiberNode(renderDispatch, { parent: parentFiber, type: "position" }, newChild);
|
|
4682
4691
|
}
|
|
4683
4692
|
};
|
|
@@ -4692,9 +4701,13 @@ function requireIndex_production_1 () {
|
|
|
4692
4701
|
var isUpdate = myreactSharedExports.exclude(parentFiber.state, myreactSharedExports.STATE_TYPE.__create__);
|
|
4693
4702
|
var isHMR = myreactSharedExports.include(parentFiber.state, myreactSharedExports.STATE_TYPE.__hmr__);
|
|
4694
4703
|
var isRetrigger = myreactSharedExports.include(parentFiber.state, myreactSharedExports.STATE_TYPE.__retrigger__);
|
|
4704
|
+
var isSuspense = myreactSharedExports.include(parentFiber.state, myreactSharedExports.STATE_TYPE.__suspense__);
|
|
4695
4705
|
// is current is retrigger update, skip update children
|
|
4696
4706
|
if (isRetrigger)
|
|
4697
4707
|
return;
|
|
4708
|
+
// if is suspense, skip update children
|
|
4709
|
+
if (isSuspense)
|
|
4710
|
+
return;
|
|
4698
4711
|
if (isUpdate || isHMR) {
|
|
4699
4712
|
var _a = getExistingChildren(parentFiber), existingChildrenMap = _a.existingChildrenMap, existingChildrenArray = _a.existingChildrenArray;
|
|
4700
4713
|
parentFiber.child = null;
|
|
@@ -4738,6 +4751,14 @@ function requireIndex_production_1 () {
|
|
|
4738
4751
|
}
|
|
4739
4752
|
};
|
|
4740
4753
|
|
|
4754
|
+
// TODO
|
|
4755
|
+
var processActivity = function (fiber) {
|
|
4756
|
+
var props = fiber.pendingProps;
|
|
4757
|
+
if (props.mode === "visible")
|
|
4758
|
+
return props.children;
|
|
4759
|
+
return null;
|
|
4760
|
+
};
|
|
4761
|
+
|
|
4741
4762
|
var currentComponentFiber$2 = react.__my_react_internal__.currentComponentFiber, MyReactInternalInstance$3 = react.__my_react_internal__.MyReactInternalInstance;
|
|
4742
4763
|
var processProvider = function (renderDispatch, fiber) {
|
|
4743
4764
|
if (renderDispatch.isAppMounted) {
|
|
@@ -4780,6 +4801,11 @@ function requireIndex_production_1 () {
|
|
|
4780
4801
|
};
|
|
4781
4802
|
|
|
4782
4803
|
var currentHookTreeNode = react.__my_react_internal__.currentHookTreeNode, currentHookNodeIndex$1 = react.__my_react_internal__.currentHookNodeIndex, currentScheduler$4 = react.__my_react_internal__.currentScheduler;
|
|
4804
|
+
var triggerState = myreactSharedExports.STATE_TYPE.__triggerSync__ |
|
|
4805
|
+
myreactSharedExports.STATE_TYPE.__triggerSyncForce__ |
|
|
4806
|
+
myreactSharedExports.STATE_TYPE.__triggerConcurrent__ |
|
|
4807
|
+
myreactSharedExports.STATE_TYPE.__triggerConcurrentForce__ |
|
|
4808
|
+
myreactSharedExports.STATE_TYPE.__retrigger__;
|
|
4783
4809
|
var processFunction = function (fiber) {
|
|
4784
4810
|
var _a;
|
|
4785
4811
|
currentHookTreeNode.current = (_a = fiber.hookList) === null || _a === void 0 ? void 0 : _a.head;
|
|
@@ -4791,14 +4817,20 @@ function requireIndex_production_1 () {
|
|
|
4791
4817
|
children = safeCallWithCurrentFiber({
|
|
4792
4818
|
fiber: fiber,
|
|
4793
4819
|
action: function safeCallForwardRefFunctionalComponent() {
|
|
4794
|
-
var _a, _b;
|
|
4820
|
+
var _a, _b, _c, _d;
|
|
4795
4821
|
var re = undefined;
|
|
4796
4822
|
try {
|
|
4797
4823
|
re = typedElementTypeWithRef_1(fiber.pendingProps, fiber.ref);
|
|
4798
4824
|
}
|
|
4799
4825
|
catch (e) {
|
|
4800
4826
|
if (myreactSharedExports.isPromise(e)) {
|
|
4801
|
-
|
|
4827
|
+
var currentIsTrigger = myreactSharedExports.include(fiber.state, triggerState);
|
|
4828
|
+
if (currentIsTrigger) {
|
|
4829
|
+
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 });
|
|
4830
|
+
}
|
|
4831
|
+
else {
|
|
4832
|
+
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 });
|
|
4833
|
+
}
|
|
4802
4834
|
}
|
|
4803
4835
|
else {
|
|
4804
4836
|
throw e;
|
|
@@ -4812,14 +4844,20 @@ function requireIndex_production_1 () {
|
|
|
4812
4844
|
children = safeCallWithCurrentFiber({
|
|
4813
4845
|
fiber: fiber,
|
|
4814
4846
|
action: function safeCallFunctionalComponent() {
|
|
4815
|
-
var _a, _b;
|
|
4847
|
+
var _a, _b, _c, _d;
|
|
4816
4848
|
var re = undefined;
|
|
4817
4849
|
try {
|
|
4818
4850
|
re = typedElementType(fiber.pendingProps);
|
|
4819
4851
|
}
|
|
4820
4852
|
catch (e) {
|
|
4821
4853
|
if (myreactSharedExports.isPromise(e)) {
|
|
4822
|
-
|
|
4854
|
+
var currentIsTrigger = myreactSharedExports.include(fiber.state, triggerState);
|
|
4855
|
+
if (currentIsTrigger) {
|
|
4856
|
+
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 });
|
|
4857
|
+
}
|
|
4858
|
+
else {
|
|
4859
|
+
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 });
|
|
4860
|
+
}
|
|
4823
4861
|
}
|
|
4824
4862
|
else {
|
|
4825
4863
|
throw e;
|
|
@@ -4905,7 +4943,7 @@ function requireIndex_production_1 () {
|
|
|
4905
4943
|
return null;
|
|
4906
4944
|
}
|
|
4907
4945
|
else {
|
|
4908
|
-
// TODO
|
|
4946
|
+
// TODO update flow
|
|
4909
4947
|
if (enableSuspenseRoot$1.current && !renderDispatch.isAppMounted) {
|
|
4910
4948
|
var suspenseField = getInstanceFieldByInstance(renderDispatch);
|
|
4911
4949
|
suspenseField.asyncLoadList.uniPush(typedElementType);
|
|
@@ -5106,6 +5144,10 @@ function requireIndex_production_1 () {
|
|
|
5106
5144
|
var children = processConsumer(renderDispatch, fiber);
|
|
5107
5145
|
nextWorkCommon(renderDispatch, fiber, children);
|
|
5108
5146
|
};
|
|
5147
|
+
var nextWorkActivity = function (renderDispatch, fiber) {
|
|
5148
|
+
var children = processActivity(fiber);
|
|
5149
|
+
nextWorkCommon(renderDispatch, fiber, children);
|
|
5150
|
+
};
|
|
5109
5151
|
var nextWorkRoot = function (renderDispatch, fiber) {
|
|
5110
5152
|
var isUpdate = !!fiber.instance;
|
|
5111
5153
|
fiber.instance = fiber.instance || new MyReactInternalInstance$2();
|
|
@@ -5293,6 +5335,9 @@ function requireIndex_production_1 () {
|
|
|
5293
5335
|
RenderDispatchEvent.prototype.dispatchPromise = function (_params) {
|
|
5294
5336
|
throw new Error("Method not implemented.");
|
|
5295
5337
|
};
|
|
5338
|
+
RenderDispatchEvent.prototype.dispatchSuspensePromise = function (_params) {
|
|
5339
|
+
throw new Error("Method not implemented.");
|
|
5340
|
+
};
|
|
5296
5341
|
RenderDispatchEvent.prototype.trigger = function (_fiber, _state, cb) {
|
|
5297
5342
|
return triggerUpdateOnFiber(_fiber, _state, cb);
|
|
5298
5343
|
};
|
|
@@ -5776,6 +5821,9 @@ function requireIndex_production_1 () {
|
|
|
5776
5821
|
else if (myreactSharedExports.include(fiber.type, exports.NODE_TYPE.__provider__ | exports.NODE_TYPE.__context__)) {
|
|
5777
5822
|
nextWorkProvider(renderDispatch, fiber);
|
|
5778
5823
|
}
|
|
5824
|
+
else if (myreactSharedExports.include(fiber.type, exports.NODE_TYPE.__activity__)) {
|
|
5825
|
+
nextWorkActivity(renderDispatch, fiber);
|
|
5826
|
+
}
|
|
5779
5827
|
else {
|
|
5780
5828
|
nextWorkNormal(renderDispatch, fiber);
|
|
5781
5829
|
}
|
|
@@ -5823,12 +5871,23 @@ function requireIndex_production_1 () {
|
|
|
5823
5871
|
layoutEffect(_dispatch, _fiber);
|
|
5824
5872
|
});
|
|
5825
5873
|
afterSyncUpdate();
|
|
5826
|
-
|
|
5827
|
-
renderScheduler.microTask(function invokeEffectListTask() {
|
|
5874
|
+
function invokeEffectListTask() {
|
|
5828
5875
|
_list.listToFoot(function invokeEffectList(_fiber) {
|
|
5829
5876
|
effect(_dispatch, _fiber);
|
|
5830
5877
|
});
|
|
5831
|
-
}
|
|
5878
|
+
}
|
|
5879
|
+
addEffectCallback(invokeEffectListTask);
|
|
5880
|
+
var renderScheduler = currentScheduler$2.current;
|
|
5881
|
+
if (_dispatch.enableConcurrentMode) {
|
|
5882
|
+
renderScheduler.macroTask(function flushEffect() {
|
|
5883
|
+
flushEffectCallback();
|
|
5884
|
+
});
|
|
5885
|
+
}
|
|
5886
|
+
else {
|
|
5887
|
+
renderScheduler.microTask(function flushEffect() {
|
|
5888
|
+
flushEffectCallback();
|
|
5889
|
+
});
|
|
5890
|
+
}
|
|
5832
5891
|
};
|
|
5833
5892
|
var defaultDispatchMount = defaultDispatchMountLatest;
|
|
5834
5893
|
|
|
@@ -5912,15 +5971,25 @@ function requireIndex_production_1 () {
|
|
|
5912
5971
|
}
|
|
5913
5972
|
});
|
|
5914
5973
|
afterSyncUpdate();
|
|
5915
|
-
|
|
5916
|
-
// TODO before next update flow, make sure all the effect has done
|
|
5917
|
-
renderScheduler.microTask(function invokeEffectListTask() {
|
|
5974
|
+
function invokeEffectListTask() {
|
|
5918
5975
|
_list.listToFoot(function invokeEffectList(_fiber) {
|
|
5919
5976
|
if (myreactSharedExports.exclude(_fiber.state, myreactSharedExports.STATE_TYPE.__unmount__) && !_dispatch.isAppUnmounted) {
|
|
5920
5977
|
effect(_dispatch, _fiber);
|
|
5921
5978
|
}
|
|
5922
5979
|
});
|
|
5923
|
-
}
|
|
5980
|
+
}
|
|
5981
|
+
addEffectCallback(invokeEffectListTask);
|
|
5982
|
+
var renderScheduler = currentScheduler$1.current;
|
|
5983
|
+
if (_dispatch.enableConcurrentMode) {
|
|
5984
|
+
renderScheduler.macroTask(function flushEffect() {
|
|
5985
|
+
flushEffectCallback();
|
|
5986
|
+
});
|
|
5987
|
+
}
|
|
5988
|
+
else {
|
|
5989
|
+
renderScheduler.microTask(function flushEffect() {
|
|
5990
|
+
flushEffectCallback();
|
|
5991
|
+
});
|
|
5992
|
+
}
|
|
5924
5993
|
};
|
|
5925
5994
|
|
|
5926
5995
|
var enableSuspenseRoot = react.__my_react_shared__.enableSuspenseRoot;
|
|
@@ -5981,7 +6050,9 @@ function requireIndex_production_1 () {
|
|
|
5981
6050
|
promise._loading = true;
|
|
5982
6051
|
promise.status = "pending";
|
|
5983
6052
|
var renderScheduler_1 = currentScheduler.current;
|
|
5984
|
-
renderDispatch
|
|
6053
|
+
renderDispatch
|
|
6054
|
+
.processPromise(promise)
|
|
6055
|
+
.then(function () {
|
|
5985
6056
|
fiber.state = myreactSharedExports.STATE_TYPE.__recreate__;
|
|
5986
6057
|
promise._list.delete(fiber);
|
|
5987
6058
|
promise._loading = false;
|
|
@@ -5993,9 +6064,44 @@ function requireIndex_production_1 () {
|
|
|
5993
6064
|
payLoad: promise,
|
|
5994
6065
|
};
|
|
5995
6066
|
renderScheduler_1.dispatchState(updater);
|
|
5996
|
-
})
|
|
6067
|
+
})
|
|
6068
|
+
.catch(function (e) { return renderScheduler_1.dispatchError({ fiber: fiber, error: e }); });
|
|
6069
|
+
return null;
|
|
6070
|
+
}
|
|
6071
|
+
};
|
|
6072
|
+
var processSuspensePromise = function (renderDispatch, fiber, promise) {
|
|
6073
|
+
var _a, _b;
|
|
6074
|
+
defaultDeleteCurrentEffect(renderDispatch, fiber);
|
|
6075
|
+
fiber.state = myreactSharedExports.STATE_TYPE.__suspense__;
|
|
6076
|
+
if (promise.status === "rejected") {
|
|
6077
|
+
(_b = (_a = currentScheduler.current).dispatchError) === null || _b === void 0 ? void 0 : _b.call(_a, { fiber: fiber, error: promise._reason });
|
|
5997
6078
|
return null;
|
|
5998
6079
|
}
|
|
6080
|
+
if (promise.status === "fulfilled") ;
|
|
6081
|
+
promise._list = promise._list || new Set();
|
|
6082
|
+
promise._list.add(fiber);
|
|
6083
|
+
if (promise._loading)
|
|
6084
|
+
return null;
|
|
6085
|
+
promise._loading = true;
|
|
6086
|
+
promise.status = "pending";
|
|
6087
|
+
var renderScheduler = currentScheduler.current;
|
|
6088
|
+
renderDispatch
|
|
6089
|
+
.processPromise(promise)
|
|
6090
|
+
.then(function () {
|
|
6091
|
+
fiber.state = myreactSharedExports.STATE_TYPE.__recreate__;
|
|
6092
|
+
promise._list.delete(fiber);
|
|
6093
|
+
promise._loading = false;
|
|
6094
|
+
var updater = {
|
|
6095
|
+
type: myreactSharedExports.UpdateQueueType.promise,
|
|
6096
|
+
trigger: fiber,
|
|
6097
|
+
isSync: true,
|
|
6098
|
+
isForce: true,
|
|
6099
|
+
payLoad: promise,
|
|
6100
|
+
};
|
|
6101
|
+
renderScheduler.dispatchState(updater);
|
|
6102
|
+
})
|
|
6103
|
+
.catch(function (e) { return renderScheduler.dispatchError({ fiber: fiber, error: e }); });
|
|
6104
|
+
return null;
|
|
5999
6105
|
};
|
|
6000
6106
|
|
|
6001
6107
|
var CustomRenderDispatch = /** @class */ (function (_super) {
|
|
@@ -6007,7 +6113,7 @@ function requireIndex_production_1 () {
|
|
|
6007
6113
|
_this.isAppMounted = false;
|
|
6008
6114
|
_this.isAppCrashed = false;
|
|
6009
6115
|
_this.isAppUnmounted = false;
|
|
6010
|
-
_this.version = "0.3.
|
|
6116
|
+
_this.version = "0.3.19";
|
|
6011
6117
|
_this.mode = "production";
|
|
6012
6118
|
_this.renderMode = "render";
|
|
6013
6119
|
_this.pendingCommitFiberList = null;
|
|
@@ -6324,6 +6430,7 @@ function requireIndex_production_1 () {
|
|
|
6324
6430
|
case myreactSharedExports.HOOK_TYPE.useCallback:
|
|
6325
6431
|
case myreactSharedExports.HOOK_TYPE.useDeferredValue:
|
|
6326
6432
|
case myreactSharedExports.HOOK_TYPE.useSyncExternalStore:
|
|
6433
|
+
case myreactSharedExports.HOOK_TYPE.useEffectEvent:
|
|
6327
6434
|
return hookNode.result;
|
|
6328
6435
|
case myreactSharedExports.HOOK_TYPE.useOptimistic:
|
|
6329
6436
|
case myreactSharedExports.HOOK_TYPE.useTransition:
|
|
@@ -6419,7 +6526,7 @@ function requireIndex_production_1 () {
|
|
|
6419
6526
|
});
|
|
6420
6527
|
}); };
|
|
6421
6528
|
|
|
6422
|
-
var version = "0.3.
|
|
6529
|
+
var version = "0.3.19";
|
|
6423
6530
|
|
|
6424
6531
|
exports.CustomRenderDispatch = CustomRenderDispatch;
|
|
6425
6532
|
exports.MyReactFiberNode = MyReactFiberNode;
|
|
@@ -6428,6 +6535,7 @@ function requireIndex_production_1 () {
|
|
|
6428
6535
|
exports.RenderDispatchEvent = RenderDispatchEvent;
|
|
6429
6536
|
exports.WrapperByLazyScope = WrapperByLazyScope;
|
|
6430
6537
|
exports.WrapperBySuspenseScope = WrapperBySuspenseScope;
|
|
6538
|
+
exports.addEffectCallback = addEffectCallback;
|
|
6431
6539
|
exports.afterSyncFlush = afterSyncFlush;
|
|
6432
6540
|
exports.afterSyncUpdate = afterSyncUpdate;
|
|
6433
6541
|
exports.applyTriggerFiberCb = applyTriggerFiberCb;
|
|
@@ -6477,6 +6585,7 @@ function requireIndex_production_1 () {
|
|
|
6477
6585
|
exports.enableLogForCurrentFlowIsRunning = enableLogForCurrentFlowIsRunning;
|
|
6478
6586
|
exports.enableValidMyReactElement = enableValidMyReactElement;
|
|
6479
6587
|
exports.fiberToDispatchMap = fiberToDispatchMap;
|
|
6588
|
+
exports.flushEffectCallback = flushEffectCallback;
|
|
6480
6589
|
exports.generateFiberToListWithAction = generateFiberToListWithAction;
|
|
6481
6590
|
exports.generateFiberToMountList = generateFiberToMountList;
|
|
6482
6591
|
exports.generateFiberToUnmountList = generateFiberToUnmountList;
|
|
@@ -6528,6 +6637,7 @@ function requireIndex_production_1 () {
|
|
|
6528
6637
|
exports.mountLoopAllFromScheduler = mountLoopAllFromScheduler;
|
|
6529
6638
|
exports.mountSync = mountSync;
|
|
6530
6639
|
exports.mountToNextFiberFromRoot = mountToNextFiberFromRoot;
|
|
6640
|
+
exports.nextWorkActivity = nextWorkActivity;
|
|
6531
6641
|
exports.nextWorkClassComponent = nextWorkClassComponent;
|
|
6532
6642
|
exports.nextWorkCommon = nextWorkCommon;
|
|
6533
6643
|
exports.nextWorkComponent = nextWorkComponent;
|
|
@@ -6566,6 +6676,7 @@ function requireIndex_production_1 () {
|
|
|
6566
6676
|
exports.processProvider = processProvider;
|
|
6567
6677
|
exports.processState = processState;
|
|
6568
6678
|
exports.processSuspense = processSuspense;
|
|
6679
|
+
exports.processSuspensePromise = processSuspensePromise;
|
|
6569
6680
|
exports.resetLogScope = resetLogScope;
|
|
6570
6681
|
exports.runtimeNextWork = runtimeNextWork;
|
|
6571
6682
|
exports.runtimeNextWorkDev = runtimeNextWorkDev;
|
|
@@ -6714,6 +6825,7 @@ function requireIndex_production () {
|
|
|
6714
6825
|
var ScopeSuspense = Symbol.for("react.scope_suspense");
|
|
6715
6826
|
var Comment = Symbol.for("react.comment");
|
|
6716
6827
|
var Offscreen = Symbol.for("react.offscreen");
|
|
6828
|
+
var Activity = Symbol.for("react.activity");
|
|
6717
6829
|
var Profiler = Symbol.for("react.profiler");
|
|
6718
6830
|
|
|
6719
6831
|
function isObject(target) {
|
|
@@ -6813,6 +6925,7 @@ function requireIndex_production () {
|
|
|
6813
6925
|
HOOK_TYPE[HOOK_TYPE["useImperativeHandle"] = 14] = "useImperativeHandle";
|
|
6814
6926
|
HOOK_TYPE[HOOK_TYPE["useSyncExternalStore"] = 15] = "useSyncExternalStore";
|
|
6815
6927
|
HOOK_TYPE[HOOK_TYPE["useOptimistic"] = 16] = "useOptimistic";
|
|
6928
|
+
HOOK_TYPE[HOOK_TYPE["useEffectEvent"] = 17] = "useEffectEvent";
|
|
6816
6929
|
})(exports.HOOK_TYPE || (exports.HOOK_TYPE = {}));
|
|
6817
6930
|
|
|
6818
6931
|
exports.UpdateQueueType = void 0;
|
|
@@ -6842,6 +6955,7 @@ function requireIndex_production () {
|
|
|
6842
6955
|
STATE_TYPE[STATE_TYPE["__retrigger__"] = 512] = "__retrigger__";
|
|
6843
6956
|
STATE_TYPE[STATE_TYPE["__reschedule__"] = 1024] = "__reschedule__";
|
|
6844
6957
|
STATE_TYPE[STATE_TYPE["__recreate__"] = 2048] = "__recreate__";
|
|
6958
|
+
STATE_TYPE[STATE_TYPE["__suspense__"] = 4096] = "__suspense__";
|
|
6845
6959
|
})(exports.STATE_TYPE || (exports.STATE_TYPE = {}));
|
|
6846
6960
|
|
|
6847
6961
|
exports.PATCH_TYPE = void 0;
|
|
@@ -7227,6 +7341,7 @@ function requireIndex_production () {
|
|
|
7227
7341
|
return ListTree;
|
|
7228
7342
|
}());
|
|
7229
7343
|
|
|
7344
|
+
exports.Activity = Activity;
|
|
7230
7345
|
exports.Comment = Comment;
|
|
7231
7346
|
exports.Consumer = Consumer;
|
|
7232
7347
|
exports.Context = Context;
|
|
@@ -7320,27 +7435,50 @@ var delGlobalDispatch = function (dispatch) {
|
|
|
7320
7435
|
* @internal
|
|
7321
7436
|
*/
|
|
7322
7437
|
var setRef = function (_fiber, config) {
|
|
7323
|
-
var _a, _b;
|
|
7324
7438
|
if (myreactSharedExports.include(_fiber.patch, myreactSharedExports.PATCH_TYPE.__ref__)) {
|
|
7439
|
+
var cleanUp = function () {
|
|
7440
|
+
// const refPrevious = _fiber.refPrevious;
|
|
7441
|
+
// safeCallWithCurrentFiber({
|
|
7442
|
+
// fiber: _fiber,
|
|
7443
|
+
// action: function safeCallRefPrevious() {
|
|
7444
|
+
// if (typeof refPrevious === "object" && refPrevious !== null) {
|
|
7445
|
+
// refPrevious.current = null;
|
|
7446
|
+
// } else if (typeof refPrevious === "function") {
|
|
7447
|
+
// refPrevious?.(null);
|
|
7448
|
+
// }
|
|
7449
|
+
// },
|
|
7450
|
+
// });
|
|
7451
|
+
// _fiber.refPrevious = undefined;
|
|
7452
|
+
var refCleanup = _fiber.refCleanup;
|
|
7453
|
+
myreactReconcilerExports.safeCallWithCurrentFiber({
|
|
7454
|
+
fiber: _fiber,
|
|
7455
|
+
action: function safeCallRefCleanup() {
|
|
7456
|
+
if (typeof refCleanup === "function") {
|
|
7457
|
+
refCleanup();
|
|
7458
|
+
}
|
|
7459
|
+
},
|
|
7460
|
+
});
|
|
7461
|
+
_fiber.refCleanup = undefined;
|
|
7462
|
+
};
|
|
7325
7463
|
if (myreactSharedExports.include(_fiber.type, myreactReconcilerExports.NODE_TYPE.__plain__)) {
|
|
7326
7464
|
if (_fiber.nativeNode) {
|
|
7465
|
+
cleanUp();
|
|
7327
7466
|
var ref_1 = _fiber.ref;
|
|
7328
|
-
|
|
7329
|
-
|
|
7330
|
-
|
|
7331
|
-
|
|
7332
|
-
|
|
7333
|
-
|
|
7334
|
-
|
|
7335
|
-
|
|
7336
|
-
(_a = _fiber.refCleanup) === null || _a === void 0 ? void 0 : _a.call(_fiber);
|
|
7467
|
+
myreactReconcilerExports.safeCallWithCurrentFiber({
|
|
7468
|
+
fiber: _fiber,
|
|
7469
|
+
action: function safeCallSetRef() {
|
|
7470
|
+
var _a, _b;
|
|
7471
|
+
if (typeof ref_1 === "object" && ref_1 !== null) {
|
|
7472
|
+
ref_1.current = (_a = config === null || config === void 0 ? void 0 : config.getPublicInstance) === null || _a === void 0 ? void 0 : _a.call(config, _fiber.nativeNode);
|
|
7473
|
+
}
|
|
7474
|
+
else if (typeof ref_1 === "function") {
|
|
7337
7475
|
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));
|
|
7338
7476
|
if (typeof refCleanUp === "function") {
|
|
7339
7477
|
_fiber.refCleanup = refCleanUp;
|
|
7340
7478
|
}
|
|
7341
|
-
}
|
|
7342
|
-
}
|
|
7343
|
-
}
|
|
7479
|
+
}
|
|
7480
|
+
},
|
|
7481
|
+
});
|
|
7344
7482
|
}
|
|
7345
7483
|
else {
|
|
7346
7484
|
throw new Error("[@my-react/react] plain element do not have a native node");
|
|
@@ -7348,23 +7486,23 @@ var setRef = function (_fiber, config) {
|
|
|
7348
7486
|
}
|
|
7349
7487
|
else if (myreactSharedExports.include(_fiber.type, myreactReconcilerExports.NODE_TYPE.__class__)) {
|
|
7350
7488
|
if (_fiber.instance) {
|
|
7489
|
+
cleanUp();
|
|
7351
7490
|
var ref_2 = _fiber.ref;
|
|
7352
|
-
|
|
7353
|
-
|
|
7354
|
-
|
|
7355
|
-
|
|
7356
|
-
|
|
7357
|
-
|
|
7358
|
-
|
|
7359
|
-
|
|
7360
|
-
(_a = _fiber.refCleanup) === null || _a === void 0 ? void 0 : _a.call(_fiber);
|
|
7491
|
+
myreactReconcilerExports.safeCallWithCurrentFiber({
|
|
7492
|
+
fiber: _fiber,
|
|
7493
|
+
action: function safeCallSetRef() {
|
|
7494
|
+
var _a, _b;
|
|
7495
|
+
if (typeof ref_2 === "object" && ref_2 !== null) {
|
|
7496
|
+
ref_2.current = (_a = config === null || config === void 0 ? void 0 : config.getPublicInstance) === null || _a === void 0 ? void 0 : _a.call(config, _fiber.instance);
|
|
7497
|
+
}
|
|
7498
|
+
else if (typeof ref_2 === "function") {
|
|
7361
7499
|
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));
|
|
7362
7500
|
if (typeof refCleanUp === "function") {
|
|
7363
7501
|
_fiber.refCleanup = refCleanUp;
|
|
7364
7502
|
}
|
|
7365
|
-
}
|
|
7366
|
-
}
|
|
7367
|
-
}
|
|
7503
|
+
}
|
|
7504
|
+
},
|
|
7505
|
+
});
|
|
7368
7506
|
}
|
|
7369
7507
|
else {
|
|
7370
7508
|
throw new Error("[@my-react/react-dom] class component do not have a instance");
|
|
@@ -7764,6 +7902,9 @@ var ReconcilerDispatchFiber = function (renderDispatch, fiber) {
|
|
|
7764
7902
|
else if (myreactSharedExports.include(fiber.type, myreactReconcilerExports.NODE_TYPE.__provider__ | myreactReconcilerExports.NODE_TYPE.__context__)) {
|
|
7765
7903
|
myreactReconcilerExports.nextWorkProvider(renderDispatch, fiber);
|
|
7766
7904
|
}
|
|
7905
|
+
else if (myreactSharedExports.include(fiber.type, myreactReconcilerExports.NODE_TYPE.__activity__)) {
|
|
7906
|
+
myreactReconcilerExports.nextWorkActivity(renderDispatch, fiber);
|
|
7907
|
+
}
|
|
7767
7908
|
else {
|
|
7768
7909
|
myreactReconcilerExports.nextWorkNormal(renderDispatch, fiber);
|
|
7769
7910
|
}
|
|
@@ -7830,11 +7971,15 @@ var ReconcilerDispatchMount = function (_dispatch, _fiber, config) {
|
|
|
7830
7971
|
myreactReconcilerExports.layoutEffect(_dispatch, _fiber);
|
|
7831
7972
|
});
|
|
7832
7973
|
myreactReconcilerExports.afterSyncUpdate();
|
|
7833
|
-
|
|
7834
|
-
renderScheduler.microTask(function invokeEffectListTask() {
|
|
7974
|
+
function invokeEffectListTask() {
|
|
7835
7975
|
_list.listToFoot(function invokeEffectList(_fiber) {
|
|
7836
7976
|
myreactReconcilerExports.effect(_dispatch, _fiber);
|
|
7837
7977
|
});
|
|
7978
|
+
}
|
|
7979
|
+
myreactReconcilerExports.addEffectCallback(invokeEffectListTask);
|
|
7980
|
+
var renderScheduler = currentScheduler$2.current;
|
|
7981
|
+
renderScheduler.macroTask(function flushEffect() {
|
|
7982
|
+
myreactReconcilerExports.flushEffectCallback();
|
|
7838
7983
|
});
|
|
7839
7984
|
};
|
|
7840
7985
|
|
|
@@ -7931,15 +8076,25 @@ var ReconcilerDispatchUpdate = function (_dispatch, _list, config) {
|
|
|
7931
8076
|
}
|
|
7932
8077
|
});
|
|
7933
8078
|
myreactReconcilerExports.afterSyncUpdate();
|
|
7934
|
-
|
|
7935
|
-
// TODO before next update flow, make sure all the effect has done
|
|
7936
|
-
renderScheduler.microTask(function invokeEffectListTask() {
|
|
8079
|
+
function invokeEffectListTask() {
|
|
7937
8080
|
_list.listToFoot(function invokeEffectList(_fiber) {
|
|
7938
8081
|
if (myreactSharedExports.exclude(_fiber.state, myreactSharedExports.STATE_TYPE.__unmount__) && !_dispatch.isAppUnmounted) {
|
|
7939
8082
|
myreactReconcilerExports.effect(_dispatch, _fiber);
|
|
7940
8083
|
}
|
|
7941
8084
|
});
|
|
7942
|
-
}
|
|
8085
|
+
}
|
|
8086
|
+
myreactReconcilerExports.addEffectCallback(invokeEffectListTask);
|
|
8087
|
+
var renderScheduler = currentScheduler$1.current;
|
|
8088
|
+
if (_dispatch.enableConcurrentMode) {
|
|
8089
|
+
renderScheduler.macroTask(function flushEffect() {
|
|
8090
|
+
myreactReconcilerExports.flushEffectCallback();
|
|
8091
|
+
});
|
|
8092
|
+
}
|
|
8093
|
+
else {
|
|
8094
|
+
renderScheduler.microTask(function flushEffect() {
|
|
8095
|
+
myreactReconcilerExports.flushEffectCallback();
|
|
8096
|
+
});
|
|
8097
|
+
}
|
|
7943
8098
|
};
|
|
7944
8099
|
|
|
7945
8100
|
require$$0.__my_react_internal__.currentComponentFiber;
|
|
@@ -8045,6 +8200,9 @@ var createDispatch = function (rootNode, rootFiber, rootElement, config, flag) {
|
|
|
8045
8200
|
ReconcilerDispatch.prototype.dispatchPromise = function (_params) {
|
|
8046
8201
|
return myreactReconcilerExports.processPromise(this, _params.fiber, _params.promise);
|
|
8047
8202
|
};
|
|
8203
|
+
ReconcilerDispatch.prototype.dispatchSuspensePromise = function (_params) {
|
|
8204
|
+
return myreactReconcilerExports.processSuspensePromise(this, _params.fiber, _params.promise);
|
|
8205
|
+
};
|
|
8048
8206
|
ReconcilerDispatch.prototype.dispatchError = function (_params) {
|
|
8049
8207
|
myreactReconcilerExports.triggerError(this, _params.fiber, _params.error);
|
|
8050
8208
|
return void 0;
|
|
@@ -8130,7 +8288,7 @@ var prepareScheduler = function () {
|
|
|
8130
8288
|
|
|
8131
8289
|
var enableDebugFiled = require$$0.__my_react_shared__.enableDebugFiled, enableScopeTreeLog = require$$0.__my_react_shared__.enableScopeTreeLog;
|
|
8132
8290
|
var currentScheduler = require$$0.__my_react_internal__.currentScheduler;
|
|
8133
|
-
// react-reconciler
|
|
8291
|
+
// react-reconciler compat implementation
|
|
8134
8292
|
var Reconciler = function (_config) {
|
|
8135
8293
|
var rendererPackageName = "@my-react";
|
|
8136
8294
|
var ReconcilerSet = new Set();
|
|
@@ -8146,7 +8304,7 @@ var Reconciler = function (_config) {
|
|
|
8146
8304
|
}
|
|
8147
8305
|
enableDebugFiled.current = false;
|
|
8148
8306
|
enableScopeTreeLog.current = false;
|
|
8149
|
-
|
|
8307
|
+
myreactReconcilerExports.enableFiberForLog.current = false;
|
|
8150
8308
|
return _container;
|
|
8151
8309
|
};
|
|
8152
8310
|
var updateContainer = function (_element, _container, _ignore, _cb) {
|
|
@@ -8239,7 +8397,7 @@ var Reconciler = function (_config) {
|
|
|
8239
8397
|
};
|
|
8240
8398
|
};
|
|
8241
8399
|
|
|
8242
|
-
var version = "0.0.
|
|
8400
|
+
var version = "0.0.10";
|
|
8243
8401
|
var createReconciler = Reconciler;
|
|
8244
8402
|
|
|
8245
8403
|
exports.createReconciler = createReconciler;
|