|
2530 | 2530 | } |
2531 | 2531 |
|
2532 | 2532 | var linkStateToHookIndex = new WeakMap(); |
| 2533 | + var linkStateToUpdaterNode = new WeakMap(); |
2533 | 2534 | var parseHooksTreeToHOOKTree = function (node, d, p) { |
2534 | 2535 | var _p = p || { index: 0 }; |
2535 | 2536 | return node.map(function (item) { |
|
2636 | 2637 | } |
2637 | 2638 | }; |
2638 | 2639 | var tryLinkStateToHookIndex = function (fiber, state) { |
2639 | | - var _a, _b, _c, _d, _e, _f; |
| 2640 | + var _a, _b, _c; |
2640 | 2641 | if (state.needUpdate && state.nodes) { |
2641 | 2642 | // filter all hook update queue |
2642 | | - var nodes = (_b = (_a = state.nodes) === null || _a === void 0 ? void 0 : _a.filter) === null || _b === void 0 ? void 0 : _b.call(_a, function (node) { return node.type === UpdateQueueType.hook; }); |
| 2643 | + // const nodes = state.nodes?.filter?.((node) => node.type === UpdateQueueType.hook); |
2643 | 2644 | // get all the keys from the nodes; |
2644 | | - var allHooksArray_1 = ((_d = (_c = fiber.hookList) === null || _c === void 0 ? void 0 : _c.toArray) === null || _d === void 0 ? void 0 : _d.call(_c)) || []; |
2645 | | - var keys = ((_f = (_e = nodes === null || nodes === void 0 ? void 0 : nodes.map) === null || _e === void 0 ? void 0 : _e.call(nodes, function (node) { var _a; return (_a = allHooksArray_1 === null || allHooksArray_1 === void 0 ? void 0 : allHooksArray_1.findIndex) === null || _a === void 0 ? void 0 : _a.call(allHooksArray_1, function (_node) { return (node === null || node === void 0 ? void 0 : node.trigger) === _node; }); })) === null || _f === void 0 ? void 0 : _f.filter(function (i) { return i !== -1; })) || []; |
| 2645 | + var allHooksArray_1 = ((_b = (_a = fiber.hookList) === null || _a === void 0 ? void 0 : _a.toArray) === null || _b === void 0 ? void 0 : _b.call(_a)) || []; |
| 2646 | + var nodes = state.nodes || []; |
| 2647 | + var indexMap_1 = {}; |
| 2648 | + var keys = ((_c = nodes.map) === null || _c === void 0 ? void 0 : _c.call(nodes, function (node) { |
| 2649 | + var _a; |
| 2650 | + if (node.type !== UpdateQueueType.hook) |
| 2651 | + return -1; |
| 2652 | + var index = (_a = allHooksArray_1 === null || allHooksArray_1 === void 0 ? void 0 : allHooksArray_1.findIndex) === null || _a === void 0 ? void 0 : _a.call(allHooksArray_1, function (_node) { return (node === null || node === void 0 ? void 0 : node.trigger) === _node; }); |
| 2653 | + // there are a valid updater, link the before node value |
| 2654 | + if (index !== -1 && Object.prototype.hasOwnProperty.call(node, "_debugBeforeValue")) { |
| 2655 | + var data = getNode(node._debugBeforeValue); |
| 2656 | + indexMap_1[index] = data; |
| 2657 | + } |
| 2658 | + return index; |
| 2659 | + })) || []; |
2646 | 2660 | // link the keys to the state |
2647 | 2661 | linkStateToHookIndex.set(state, keys); |
| 2662 | + linkStateToUpdaterNode.set(state, indexMap_1); |
2648 | 2663 | } |
2649 | 2664 | }; |
2650 | 2665 | var getHookIndexFromState = function (state) { |
2651 | 2666 | return linkStateToHookIndex.get(state); |
2652 | 2667 | }; |
| 2668 | + var getUpdaterNodeFromState = function (state) { |
| 2669 | + return linkStateToUpdaterNode.get(state); |
| 2670 | + }; |
2653 | 2671 | var deleteLinkState = function (state) { |
2654 | 2672 | linkStateToHookIndex.delete(state); |
| 2673 | + linkStateToUpdaterNode.delete(state); |
2655 | 2674 | }; |
2656 | 2675 |
|
2657 | 2676 | var treeMap = new Map(); |
|
3520 | 3539 | var finalStatus = status.filter(function (i) { return (i.isRetrigger ? runtime._enableRetrigger : true); }).slice(-10); |
3521 | 3540 | return finalStatus.map(function (i) { |
3522 | 3541 | var _keysToLinkHook = getHookIndexFromState(i); |
| 3542 | + var _nodesToLinkHook = getUpdaterNodeFromState(i); |
3523 | 3543 | var node = getNode(i); |
3524 | 3544 | if (_keysToLinkHook && _keysToLinkHook.length > 0) { |
3525 | 3545 | node._keysToLinkHook = _keysToLinkHook; |
3526 | 3546 | } |
| 3547 | + if (_nodesToLinkHook && Object.keys(_nodesToLinkHook).length > 0) { |
| 3548 | + node._nodesToLinkHook = _nodesToLinkHook; |
| 3549 | + } |
3527 | 3550 | return node; |
3528 | 3551 | }); |
3529 | 3552 | }; |
|
0 commit comments