@faiwer/react 0.8.3 → 0.9.0
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/README.md +20 -14
- package/dist/core/Children.d.ts +11 -0
- package/dist/core/Children.d.ts.map +1 -0
- package/dist/core/Children.js +35 -0
- package/dist/core/Children.js.map +1 -0
- package/dist/core/actions/applyAction.d.ts.map +1 -1
- package/dist/core/actions/applyAction.js +2 -0
- package/dist/core/actions/applyAction.js.map +1 -1
- package/dist/core/actions/createComment.action.d.ts +2 -2
- package/dist/core/actions/createComment.action.d.ts.map +1 -1
- package/dist/core/actions/createComment.action.js +1 -8
- package/dist/core/actions/createComment.action.js.map +1 -1
- package/dist/core/actions/createContainer.action.d.ts +7 -0
- package/dist/core/actions/createContainer.action.d.ts.map +1 -0
- package/dist/core/actions/createContainer.action.js +28 -0
- package/dist/core/actions/createContainer.action.js.map +1 -0
- package/dist/core/actions/createTag.action.d.ts +2 -1
- package/dist/core/actions/createTag.action.d.ts.map +1 -1
- package/dist/core/actions/createTag.action.js +107 -5
- package/dist/core/actions/createTag.action.js.map +1 -1
- package/dist/core/actions/createText.action.d.ts.map +1 -1
- package/dist/core/actions/createText.action.js +2 -5
- package/dist/core/actions/createText.action.js.map +1 -1
- package/dist/core/actions/dom/attributes.d.ts +4 -0
- package/dist/core/actions/dom/attributes.d.ts.map +1 -0
- package/dist/core/actions/dom/attributes.js +56 -0
- package/dist/core/actions/dom/attributes.js.map +1 -0
- package/dist/core/actions/dom/css.d.ts +6 -0
- package/dist/core/actions/dom/css.d.ts.map +1 -0
- package/dist/core/actions/dom/css.js +54 -0
- package/dist/core/actions/dom/css.js.map +1 -0
- package/dist/core/actions/dom/events.d.ts +3 -0
- package/dist/core/actions/dom/events.d.ts.map +1 -0
- package/dist/core/actions/dom/events.js +45 -0
- package/dist/core/actions/dom/events.js.map +1 -0
- package/dist/core/actions/dom/svg.d.ts +7 -0
- package/dist/core/actions/dom/svg.d.ts.map +1 -0
- package/dist/core/actions/dom/svg.js +76 -0
- package/dist/core/actions/dom/svg.js.map +1 -0
- package/dist/core/actions/dom/value.d.ts +17 -0
- package/dist/core/actions/dom/value.d.ts.map +1 -0
- package/dist/core/actions/dom/value.js +204 -0
- package/dist/core/actions/dom/value.js.map +1 -0
- package/dist/core/actions/helpers.d.ts +18 -11
- package/dist/core/actions/helpers.d.ts.map +1 -1
- package/dist/core/actions/helpers.js +78 -68
- package/dist/core/actions/helpers.js.map +1 -1
- package/dist/core/actions/relayout.action.d.ts +2 -1
- package/dist/core/actions/relayout.action.d.ts.map +1 -1
- package/dist/core/actions/relayout.action.js +119 -30
- package/dist/core/actions/relayout.action.js.map +1 -1
- package/dist/core/actions/remove.action.d.ts +3 -2
- package/dist/core/actions/remove.action.d.ts.map +1 -1
- package/dist/core/actions/remove.action.js +22 -18
- package/dist/core/actions/remove.action.js.map +1 -1
- package/dist/core/actions/replace.action.d.ts +1 -1
- package/dist/core/actions/replace.action.d.ts.map +1 -1
- package/dist/core/actions/replace.action.js +36 -11
- package/dist/core/actions/replace.action.js.map +1 -1
- package/dist/core/actions/setAttr.action.d.ts +1 -1
- package/dist/core/actions/setAttr.action.d.ts.map +1 -1
- package/dist/core/actions/setAttr.action.js +55 -87
- package/dist/core/actions/setAttr.action.js.map +1 -1
- package/dist/core/actions/setProps.action.d.ts.map +1 -1
- package/dist/core/actions/setProps.action.js +2 -1
- package/dist/core/actions/setProps.action.js.map +1 -1
- package/dist/core/actions/setRef.action.d.ts +1 -1
- package/dist/core/actions/setRef.action.d.ts.map +1 -1
- package/dist/core/actions/setRef.action.js +5 -6
- package/dist/core/actions/setRef.action.js.map +1 -1
- package/dist/core/actions/setText.action.d.ts.map +1 -1
- package/dist/core/actions/setText.action.js +3 -3
- package/dist/core/actions/setText.action.js.map +1 -1
- package/dist/core/classComponent.d.ts +33 -0
- package/dist/core/classComponent.d.ts.map +1 -0
- package/dist/core/classComponent.js +127 -0
- package/dist/core/classComponent.js.map +1 -0
- package/dist/core/compact.d.ts +10 -29
- package/dist/core/compact.d.ts.map +1 -1
- package/dist/core/compact.js +12 -100
- package/dist/core/compact.js.map +1 -1
- package/dist/core/components.d.ts +2 -2
- package/dist/core/components.d.ts.map +1 -1
- package/dist/core/components.js +22 -5
- package/dist/core/components.js.map +1 -1
- package/dist/core/createElement.d.ts +9 -9
- package/dist/core/createElement.d.ts.map +1 -1
- package/dist/core/createElement.js +19 -3
- package/dist/core/createElement.js.map +1 -1
- package/dist/core/createRoot.js.map +1 -1
- package/dist/core/reactNodeToFiberNode.d.ts.map +1 -1
- package/dist/core/reactNodeToFiberNode.js +6 -1
- package/dist/core/reactNodeToFiberNode.js.map +1 -1
- package/dist/core/reconciliation/app.js +3 -3
- package/dist/core/reconciliation/app.js.map +1 -1
- package/dist/core/reconciliation/collect/fromApp.d.ts.map +1 -1
- package/dist/core/reconciliation/collect/fromApp.js +3 -27
- package/dist/core/reconciliation/collect/fromApp.js.map +1 -1
- package/dist/core/reconciliation/collect/fromChildrenPair.d.ts.map +1 -1
- package/dist/core/reconciliation/collect/fromChildrenPair.js +24 -15
- package/dist/core/reconciliation/collect/fromChildrenPair.js.map +1 -1
- package/dist/core/reconciliation/collect/fromComponent.d.ts +2 -2
- package/dist/core/reconciliation/collect/fromComponent.d.ts.map +1 -1
- package/dist/core/reconciliation/collect/fromComponent.js +4 -8
- package/dist/core/reconciliation/collect/fromComponent.js.map +1 -1
- package/dist/core/reconciliation/collect/fromFiberPair.d.ts.map +1 -1
- package/dist/core/reconciliation/collect/fromFiberPair.js +6 -4
- package/dist/core/reconciliation/collect/fromFiberPair.js.map +1 -1
- package/dist/core/reconciliation/collect/fromNewFiber.d.ts.map +1 -1
- package/dist/core/reconciliation/collect/fromNewFiber.js +7 -15
- package/dist/core/reconciliation/collect/fromNewFiber.js.map +1 -1
- package/dist/core/reconciliation/effects.d.ts.map +1 -1
- package/dist/core/reconciliation/effects.js +0 -5
- package/dist/core/reconciliation/effects.js.map +1 -1
- package/dist/core/reconciliation/errors/ReactError.d.ts +7 -0
- package/dist/core/reconciliation/errors/ReactError.d.ts.map +1 -0
- package/dist/core/reconciliation/errors/ReactError.js +26 -0
- package/dist/core/reconciliation/errors/ReactError.js.map +1 -0
- package/dist/core/reconciliation/errors/stack.d.ts +9 -0
- package/dist/core/reconciliation/errors/stack.d.ts.map +1 -0
- package/dist/core/reconciliation/errors/stack.js +80 -0
- package/dist/core/reconciliation/errors/stack.js.map +1 -0
- package/dist/core/reconciliation/fibers.d.ts +7 -0
- package/dist/core/reconciliation/fibers.d.ts.map +1 -1
- package/dist/core/reconciliation/fibers.js +9 -2
- package/dist/core/reconciliation/fibers.js.map +1 -1
- package/dist/core/reconciliation/heap.d.ts +18 -0
- package/dist/core/reconciliation/heap.d.ts.map +1 -0
- package/dist/core/reconciliation/heap.js +81 -0
- package/dist/core/reconciliation/heap.js.map +1 -0
- package/dist/core/reconciliation/invalidateFiber.d.ts.map +1 -1
- package/dist/core/reconciliation/invalidateFiber.js +10 -4
- package/dist/core/reconciliation/invalidateFiber.js.map +1 -1
- package/dist/core/reconciliation/mount.d.ts.map +1 -1
- package/dist/core/reconciliation/mount.js +17 -7
- package/dist/core/reconciliation/mount.js.map +1 -1
- package/dist/core/reconciliation/postCommit.d.ts +1 -1
- package/dist/core/reconciliation/postCommit.d.ts.map +1 -1
- package/dist/core/reconciliation/postCommit.js +19 -4
- package/dist/core/reconciliation/postCommit.js.map +1 -1
- package/dist/core/reconciliation/queue.d.ts +21 -0
- package/dist/core/reconciliation/queue.d.ts.map +1 -0
- package/dist/core/reconciliation/queue.js +55 -0
- package/dist/core/reconciliation/queue.js.map +1 -0
- package/dist/core/reconciliation/render.js +5 -5
- package/dist/core/reconciliation/render.js.map +1 -1
- package/dist/core/reconciliation/runFiberComponents.d.ts.map +1 -1
- package/dist/core/reconciliation/runFiberComponents.js +2 -1
- package/dist/core/reconciliation/runFiberComponents.js.map +1 -1
- package/dist/core/reconciliation/typeGuards.d.ts +9 -1
- package/dist/core/reconciliation/typeGuards.d.ts.map +1 -1
- package/dist/core/reconciliation/typeGuards.js +25 -0
- package/dist/core/reconciliation/typeGuards.js.map +1 -1
- package/dist/core/reconciliation/validateApp.d.ts +3 -0
- package/dist/core/reconciliation/validateApp.d.ts.map +1 -0
- package/dist/core/reconciliation/validateApp.js +74 -0
- package/dist/core/reconciliation/validateApp.js.map +1 -0
- package/dist/hooks/helpers.d.ts +2 -2
- package/dist/hooks/helpers.d.ts.map +1 -1
- package/dist/hooks/helpers.js +3 -2
- package/dist/hooks/helpers.js.map +1 -1
- package/dist/hooks/index.d.ts +1 -1
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +1 -1
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/useContext.d.ts.map +1 -1
- package/dist/hooks/useContext.js +16 -0
- package/dist/hooks/useContext.js.map +1 -1
- package/dist/hooks/useEffect.d.ts +2 -1
- package/dist/hooks/useEffect.d.ts.map +1 -1
- package/dist/hooks/useEffect.js +1 -1
- package/dist/hooks/useEffect.js.map +1 -1
- package/dist/hooks/useRef.d.ts +8 -3
- package/dist/hooks/useRef.d.ts.map +1 -1
- package/dist/hooks/useRef.js +27 -0
- package/dist/hooks/useRef.js.map +1 -1
- package/dist/hooks/useState.d.ts +1 -1
- package/dist/hooks/useState.d.ts.map +1 -1
- package/dist/hooks/useState.js +24 -1
- package/dist/hooks/useState.js.map +1 -1
- package/dist/index.d.ts +8 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/jsx-dev-runtime.d.ts +4 -4
- package/dist/jsx-dev-runtime.d.ts.map +1 -1
- package/dist/jsx-dev-runtime.js +4 -4
- package/dist/jsx-dev-runtime.js.map +1 -1
- package/dist/jsx-runtime.d.ts +3 -3
- package/dist/jsx-runtime.d.ts.map +1 -1
- package/dist/jsx-runtime.js +3 -3
- package/dist/jsx-runtime.js.map +1 -1
- package/dist/jsx.d.ts +176 -36
- package/dist/mocks.d.ts +21 -0
- package/dist/mocks.d.ts.map +1 -0
- package/dist/mocks.js +27 -0
- package/dist/mocks.js.map +1 -0
- package/dist/react.d.ts +46 -0
- package/dist/types/actions.d.ts +12 -4
- package/dist/types/actions.d.ts.map +1 -1
- package/dist/types/app.d.ts +17 -2
- package/dist/types/app.d.ts.map +1 -1
- package/dist/types/attributes.d.ts +42 -0
- package/dist/types/attributes.d.ts.map +1 -0
- package/dist/types/attributes.js +2 -0
- package/dist/types/attributes.js.map +1 -0
- package/dist/types/common.d.ts +13 -0
- package/dist/types/common.d.ts.map +1 -0
- package/dist/types/common.js +2 -0
- package/dist/types/common.js.map +1 -0
- package/dist/types/component.d.ts +5 -1
- package/dist/types/component.d.ts.map +1 -1
- package/dist/types/context.d.ts +3 -2
- package/dist/types/context.d.ts.map +1 -1
- package/dist/types/core.d.ts +17 -13
- package/dist/types/core.d.ts.map +1 -1
- package/dist/types/dom.d.ts +23 -27
- package/dist/types/dom.d.ts.map +1 -1
- package/dist/types/events.d.ts +31 -0
- package/dist/types/events.d.ts.map +1 -0
- package/dist/types/events.js +2 -0
- package/dist/types/events.js.map +1 -0
- package/dist/types/fiber.d.ts +31 -11
- package/dist/types/fiber.d.ts.map +1 -1
- package/dist/types/fiber.js +5 -1
- package/dist/types/fiber.js.map +1 -1
- package/dist/types/hooks.d.ts +8 -5
- package/dist/types/hooks.d.ts.map +1 -1
- package/dist/types/react.d.ts +35 -0
- package/dist/types/react.d.ts.map +1 -0
- package/dist/types/react.js +2 -0
- package/dist/types/react.js.map +1 -0
- package/dist/types/refs.d.ts +5 -8
- package/dist/types/refs.d.ts.map +1 -1
- package/package.json +15 -3
- package/dist/core/reconciliation/validateTree.d.ts +0 -6
- package/dist/core/reconciliation/validateTree.d.ts.map +0 -1
- package/dist/core/reconciliation/validateTree.js +0 -48
- package/dist/core/reconciliation/validateTree.js.map +0 -1
package/dist/core/compact.js
CHANGED
|
@@ -1,112 +1,24 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
* Returns true if domNode is <!--r:begin:ID--> where ID is fiber.id
|
|
4
|
-
*/
|
|
5
|
-
export const isBeginOf = (domNode, fiber) => domNode instanceof Comment &&
|
|
6
|
-
domNode.textContent === buildCommentText('begin', fiber.id);
|
|
7
|
-
/**
|
|
8
|
-
* Returns true if domNode is <!--r:end:ID--> where ID is fiber.id
|
|
9
|
-
*/
|
|
10
|
-
const isEndOf = (domNode, fiber) => domNode instanceof Comment &&
|
|
11
|
-
domNode.textContent === buildCommentText('end', fiber.id);
|
|
1
|
+
import { containerSym, } from '../types';
|
|
2
|
+
import { buildCommentText } from './reconciliation/comments';
|
|
12
3
|
/**
|
|
13
4
|
* Returns true if domNode is <!--r:empty:ID--> where ID is fiber.id
|
|
14
5
|
*/
|
|
15
6
|
const isEmptyOf = (domNode, fiber) => domNode instanceof Comment &&
|
|
16
7
|
domNode.textContent === buildCommentText('empty', fiber.id);
|
|
8
|
+
// Returns true when the given fiber is a component or a fragment that contains
|
|
9
|
+
// more than one direct DOM-nodes.
|
|
10
|
+
export const isAutoContainer = (fiber) => fiber.element === containerSym;
|
|
17
11
|
/**
|
|
18
|
-
* Returns true if the given `fiber` is in
|
|
19
|
-
*
|
|
20
|
-
* only child's `element`, avoiding the need for <!--brackets-->.
|
|
12
|
+
* Returns true if the given `fiber` is in the single-child mode. This means it
|
|
13
|
+
* its `element` refers to its only child's DOM element.
|
|
21
14
|
*/
|
|
22
|
-
export const
|
|
23
|
-
|
|
15
|
+
export const isSingleChildContainer = (fiber) => (fiber.type === 'fragment' || fiber.type === 'component') &&
|
|
16
|
+
fiber.element !== containerSym &&
|
|
24
17
|
!isEmptyOf(fiber.element, fiber);
|
|
25
18
|
/**
|
|
26
|
-
* Returns true if the given `fiber` is in
|
|
27
|
-
*
|
|
19
|
+
* Returns true if the given `fiber` is in the empty mode. This means it has no
|
|
20
|
+
* fiber children, and its element is <!--r:empty:id-->
|
|
28
21
|
*/
|
|
29
|
-
export const
|
|
22
|
+
export const isEmptyContainer = (fiber) => (fiber.type === 'fragment' || fiber.type === 'component') &&
|
|
30
23
|
isEmptyOf(fiber.element, fiber);
|
|
31
|
-
/**
|
|
32
|
-
* If the given fiber node has <!--brackets-->, this function tries to apply one
|
|
33
|
-
* of the "compact" optimizations:
|
|
34
|
-
*
|
|
35
|
-
* - If the node has no children, it replaces the brackets with
|
|
36
|
-
* <!--r:empty:id-->
|
|
37
|
-
* - If the node has only one child, it removes the brackets and sets
|
|
38
|
-
* `fiber.element` to reference its only direct DOM child
|
|
39
|
-
*
|
|
40
|
-
* It also tries to recursively compact parent nodes when possible.
|
|
41
|
-
*/
|
|
42
|
-
export function tryToCompactNode(fiber) {
|
|
43
|
-
if (!isEndOf(fiber.element, fiber)) {
|
|
44
|
-
return; // Node is not a !--container or is already compact.
|
|
45
|
-
}
|
|
46
|
-
// By default each fragment or component is rendered with 3+ nodes:
|
|
47
|
-
// <!--r:begin:id--> + …children + <!--r:end:id-->
|
|
48
|
-
// This approach supports 0 or 2+ nodes without overly complex logic.
|
|
49
|
-
// However, most cases have only one child or none. For these scenarios,
|
|
50
|
-
// we support two different compact modes.
|
|
51
|
-
const prev1 = fiber.element.previousSibling;
|
|
52
|
-
// Scenario 1: 0 children.
|
|
53
|
-
if (prev1 && isBeginOf(prev1, fiber)) {
|
|
54
|
-
const emptyNode = buildComment('empty', fiber.id);
|
|
55
|
-
prev1.parentElement.insertBefore(emptyNode, prev1);
|
|
56
|
-
prev1.remove(); // !--begin
|
|
57
|
-
fiber.element.remove(); // !--end
|
|
58
|
-
fiber.element = emptyNode;
|
|
59
|
-
return;
|
|
60
|
-
// <!--begin--><--end--> are replaced with <!--empty-->
|
|
61
|
-
}
|
|
62
|
-
const prev2 = prev1?.previousSibling;
|
|
63
|
-
// Scenario 2: 1 children
|
|
64
|
-
if (prev2 && isBeginOf(prev2, fiber)) {
|
|
65
|
-
prev2.remove(); // !--begin
|
|
66
|
-
fiber.element.remove(); // !--end
|
|
67
|
-
fiber.element = fiber.children[0].element;
|
|
68
|
-
// <!--begin--><!--end--> are removed. Now `fiber.element` refers to its
|
|
69
|
-
// only child node.
|
|
70
|
-
tryToCompactNode(fiber.parent);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* Converts <!--empty--> or the single compact container node into:
|
|
75
|
-
* <!--begin-->...children...<!--end-->
|
|
76
|
-
*/
|
|
77
|
-
export const unwrapCompactFiber = (fiber) => {
|
|
78
|
-
const container = fiber.element.parentElement;
|
|
79
|
-
let begin = buildComment('begin', fiber.id);
|
|
80
|
-
let end = buildComment('end', fiber.id);
|
|
81
|
-
if (isCompactSingleChild(fiber)) {
|
|
82
|
-
// before: <container><child/></container>
|
|
83
|
-
// after: <container><!--begin--><child/><!--end--></container>
|
|
84
|
-
container.insertBefore(begin, fiber.element);
|
|
85
|
-
container.insertBefore(end, fiber.element.nextSibling);
|
|
86
|
-
fiber.element = end;
|
|
87
|
-
// Repeat the same with every single-compact ancestor:
|
|
88
|
-
let parent = fiber.parent;
|
|
89
|
-
while (isCompactSingleChild(parent)) {
|
|
90
|
-
const pBegin = buildComment('begin', parent.id);
|
|
91
|
-
const pEnd = buildComment('end', parent.id);
|
|
92
|
-
container.insertBefore(pBegin, begin);
|
|
93
|
-
container.insertBefore(pEnd, end.nextSibling);
|
|
94
|
-
parent.element = pEnd;
|
|
95
|
-
begin = pBegin;
|
|
96
|
-
end = pEnd;
|
|
97
|
-
parent = parent.parent;
|
|
98
|
-
}
|
|
99
|
-
return;
|
|
100
|
-
}
|
|
101
|
-
if (isCompactNone(fiber)) {
|
|
102
|
-
// before: <container><!--empty--></container>
|
|
103
|
-
// after: <container><!--begin--><!--end--></container>
|
|
104
|
-
container.insertBefore(begin, fiber.element);
|
|
105
|
-
container.insertBefore(end, fiber.element.nextSibling);
|
|
106
|
-
fiber.element.remove();
|
|
107
|
-
fiber.element = end;
|
|
108
|
-
return;
|
|
109
|
-
}
|
|
110
|
-
throw new Error(`Unsupported format of compact node`);
|
|
111
|
-
};
|
|
112
24
|
//# sourceMappingURL=compact.js.map
|
package/dist/core/compact.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compact.js","sourceRoot":"","sources":["../../src/core/compact.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"compact.js","sourceRoot":"","sources":["../../src/core/compact.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,GAIb,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,gBAAgB,EAAE,MAAM,2BAA2B,CAAC;AAE7D;;GAEG;AACH,MAAM,SAAS,GAAG,CAChB,OAAoC,EACpC,KAAgB,EACI,EAAE,CACtB,OAAO,YAAY,OAAO;IAC1B,OAAO,CAAC,WAAW,KAAK,gBAAgB,CAAC,OAAO,EAAE,KAAK,CAAC,EAAE,CAAC,CAAC;AAE9D,+EAA+E;AAC/E,kCAAkC;AAClC,MAAM,CAAC,MAAM,eAAe,GAAG,CAC7B,KAAgB,EAC6B,EAAE,CAC/C,KAAK,CAAC,OAAO,KAAK,YAAY,CAAC;AAEjC;;;GAGG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,CACpC,KAAgB,EAGhB,EAAE,CACF,CAAC,KAAK,CAAC,IAAI,KAAK,UAAU,IAAI,KAAK,CAAC,IAAI,KAAK,WAAW,CAAC;IACzD,KAAK,CAAC,OAAO,KAAK,YAAY;IAC9B,CAAC,SAAS,CAAC,KAAK,CAAC,OAAQ,EAAE,KAAK,CAAC,CAAC;AAEpC;;;GAGG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAC9B,KAAgB,EAGhB,EAAE,CACF,CAAC,KAAK,CAAC,IAAI,KAAK,UAAU,IAAI,KAAK,CAAC,IAAI,KAAK,WAAW,CAAC;IACzD,SAAS,CAAC,KAAK,CAAC,OAAQ,EAAE,KAAK,CAAC,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type HookStateItem, type FiberNode, type App, type ComponentFiberNode } from '../types';
|
|
1
|
+
import { type HookStateItem, type FiberNode, type App, type ComponentFiberNode, type UnknownProps } from '../types';
|
|
2
2
|
/**
|
|
3
3
|
* Returns the fiber of the component that is being rendered right now. Don't
|
|
4
4
|
* run this function outside of the render phase.
|
|
@@ -18,7 +18,7 @@ export declare const isFirstFiberRender: () => boolean;
|
|
|
18
18
|
* is required to make hooks work. The result is JSX returned from the component
|
|
19
19
|
* function.
|
|
20
20
|
*/
|
|
21
|
-
export declare const runComponent: (fiber: FiberNode,
|
|
21
|
+
export declare const runComponent: (fiber: FiberNode, props: UnknownProps | null) => import("../index.js").JsxElement;
|
|
22
22
|
/**
|
|
23
23
|
* Switches to the next hook and returns its state.
|
|
24
24
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"components.d.ts","sourceRoot":"","sources":["../../src/core/components.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,SAAS,EAEd,KAAK,GAAG,EACR,KAAK,kBAAkB,
|
|
1
|
+
{"version":3,"file":"components.d.ts","sourceRoot":"","sources":["../../src/core/components.ts"],"names":[],"mappings":"AACA,OAAO,EACL,KAAK,aAAa,EAClB,KAAK,SAAS,EAEd,KAAK,GAAG,EACR,KAAK,kBAAkB,EACvB,KAAK,YAAY,EAClB,MAAM,UAAU,CAAC;AAWlB;;;GAGG;AACH,eAAO,MAAM,wBAAwB,0BACX,CAAC;AAE3B;;;GAGG;AACH,eAAO,MAAM,aAAa,WAGzB,CAAC;AAIF;;GAEG;AACH,eAAO,MAAM,kBAAkB,eAAkC,CAAC;AAElE;;;;GAIG;AACH,eAAO,MAAM,YAAY,qFAuCxB,CAAC;AAYF;;GAEG;AACH,eAAO,MAAM,iBAAiB,qBACgC,CAAC;AAE/D;;GAEG;AACH,eAAO,MAAM,iBAAiB;;UAI7B,CAAC"}
|
package/dist/core/components.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { nullthrows } from '../utils';
|
|
2
2
|
import { getAppByFiber } from './reconciliation/app';
|
|
3
|
+
import { isFiberDead } from './reconciliation/fibers';
|
|
4
|
+
import { nullthrowsForFiber, ReactError, } from './reconciliation/errors/ReactError';
|
|
3
5
|
/** Component that is rendered right now. */
|
|
4
6
|
let currentFiber;
|
|
5
7
|
/**
|
|
@@ -11,7 +13,10 @@ export const getCurrentComponentFiber = () => nullthrows(currentFiber);
|
|
|
11
13
|
* The app of the component that is being rendered right now. Don't run this
|
|
12
14
|
* function outside of the render phase.
|
|
13
15
|
*/
|
|
14
|
-
export const getCurrentApp = () =>
|
|
16
|
+
export const getCurrentApp = () => {
|
|
17
|
+
const fiber = getCurrentComponentFiber();
|
|
18
|
+
return nullthrowsForFiber(fiber, getAppByFiber(fiber));
|
|
19
|
+
};
|
|
15
20
|
let firstFiberRender = false;
|
|
16
21
|
/**
|
|
17
22
|
* Returns true when it's the 1st render of currentFiber's component.
|
|
@@ -24,15 +29,27 @@ export const isFirstFiberRender = () => firstFiberRender;
|
|
|
24
29
|
*/
|
|
25
30
|
export const runComponent = (fiber,
|
|
26
31
|
/** Source of `.props`. If not given `fiber.props` are used. */
|
|
27
|
-
|
|
32
|
+
props) => {
|
|
28
33
|
if (fiber.type !== 'component') {
|
|
29
|
-
throw new
|
|
34
|
+
throw new ReactError(fiber, `Can't run ${fiber.type} as a component`);
|
|
35
|
+
}
|
|
36
|
+
if (isFiberDead(fiber)) {
|
|
37
|
+
throw new ReactError(fiber, `Can't run a dead component`);
|
|
30
38
|
}
|
|
31
39
|
currentFiber = fiber;
|
|
32
40
|
firstFiberRender = !fiber.data.hooks;
|
|
33
41
|
fiber.data.hooks ??= [];
|
|
34
42
|
hookIdx = -1;
|
|
35
|
-
let jsxElement
|
|
43
|
+
let jsxElement;
|
|
44
|
+
try {
|
|
45
|
+
jsxElement = fiber.component(props ?? fiber.props);
|
|
46
|
+
}
|
|
47
|
+
catch (error) {
|
|
48
|
+
throw new ReactError(fiber, error, `Error during rendering a component: %fiber%`);
|
|
49
|
+
}
|
|
50
|
+
if (!firstFiberRender && hookIdx !== fiber.data.hooks.length - 1) {
|
|
51
|
+
throw new ReactError(fiber, `The hook order is violated. There were ${fiber.data.hooks.length} hooks in the previous render. Now only ${hookIdx + 1}`);
|
|
52
|
+
}
|
|
36
53
|
currentFiber = null;
|
|
37
54
|
firstFiberRender = false;
|
|
38
55
|
return jsxElement;
|
|
@@ -40,7 +57,7 @@ propsSource) => {
|
|
|
40
57
|
let hookIdx = -1;
|
|
41
58
|
const getComponentHookStore = (fiberNode) => {
|
|
42
59
|
if (!fiberNode.data.hooks) {
|
|
43
|
-
throw new
|
|
60
|
+
throw new ReactError(fiberNode, `HookStore is empty.`);
|
|
44
61
|
}
|
|
45
62
|
return fiberNode.data.hooks;
|
|
46
63
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"components.js","sourceRoot":"","sources":["../../src/core/components.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"components.js","sourceRoot":"","sources":["../../src/core/components.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AASrC,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AACrD,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EACL,kBAAkB,EAClB,UAAU,GACX,MAAM,oCAAoC,CAAC;AAE5C,4CAA4C;AAC5C,IAAI,YAAuC,CAAC;AAE5C;;;GAGG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,GAAuB,EAAE,CAC/D,UAAU,CAAC,YAAY,CAAC,CAAC;AAE3B;;;GAGG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,GAAQ,EAAE,CAAC;IACtC,MAAM,KAAK,GAAG,wBAAwB,EAAE,CAAC;IACzC,OAAO,kBAAkB,CAAC,KAAK,EAAE,aA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CAC1H,CAAC;IACJ,CAAC;IAED,YAAY,GAAG,IAAI,CAAC;IACpB,gBAAgB,GAAG,KAAK,CAAC;IAEzB,OAAO,UAAU,CAAC;AAAA,CACnB,CAAC;AAEF,IAAI,OAAO,GAAG,CAAC,CAAC,CAAC;AAEjB,MAAM,qBAAqB,GAAG,CAAC,SAA6B,EAAa,EAAE,CAAC;IAC1E,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,EAAE,CAAC;QAC1B,MAAM,IAAI,UAAU,CAAC,SAAS,EAAE,qBAAqB,CAAC,CAAC;IACzD,CAAC;IAED,OAAO,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC;AAAA,CAC7B,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAkB,EAAE,CACnD,qBAAqB,CAAC,wBAAwB,EAAE,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;AAE/D;;GAEG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,IAEjC,EAAQ,EAAE,CAAC;IACV,qBAAqB,CAAC,wBAAwB,EAAE,CAAC,CAAC,IAAI,CAAC,IAAqB,CAAC,CAAC;AAAA,CAC/E,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type { ElementNode, ElementType, ReactContextProvider, ReactKey } from '../types';
|
|
1
|
+
import type { ElementNode, ElementType, JsxSource, ReactContextProvider, ReactKey } from '../types';
|
|
2
|
+
import { type ComponentClass } from './classComponent';
|
|
2
3
|
/**
|
|
3
4
|
* This method is used as the JSX resolver. Every <tag/> or <Component/> is a
|
|
4
5
|
* call to this method.
|
|
@@ -17,17 +18,12 @@ import type { ElementNode, ElementType, ReactContextProvider, ReactKey } from '.
|
|
|
17
18
|
* key
|
|
18
19
|
* );
|
|
19
20
|
*/
|
|
20
|
-
export declare function
|
|
21
|
+
export declare function createElementNew(
|
|
21
22
|
/**
|
|
22
23
|
* What to render. Can be a tag (string), a component (function),
|
|
23
24
|
* or a portal target (HTMLElement).
|
|
24
25
|
*/
|
|
25
|
-
type: ReactContextProvider | ElementType | HTMLElement, propsRaw: Record<PropertyKey, unknown>, key: ReactKey | null | undefined, _isStaticChildren?: boolean,
|
|
26
|
-
type Source = {
|
|
27
|
-
fileName: string;
|
|
28
|
-
lineNumber: number;
|
|
29
|
-
columnNumber: number;
|
|
30
|
-
};
|
|
26
|
+
type: ReactContextProvider | ElementType | HTMLElement | ComponentClass, propsRaw: Record<PropertyKey, unknown>, key: ReactKey | null | undefined, _isStaticChildren?: boolean, source?: JsxSource | null, _self?: unknown): ElementNode;
|
|
31
27
|
/**
|
|
32
28
|
* Renders content into an external HTML node. Unlike React, this version
|
|
33
29
|
* doesn't support interdimensional event bubbling.
|
|
@@ -43,5 +39,9 @@ children: JSX.Element,
|
|
|
43
39
|
domNode: HTMLElement,
|
|
44
40
|
/** Custom key if you need to conditionally recreate portals. */
|
|
45
41
|
key?: string): ElementNode;
|
|
46
|
-
|
|
42
|
+
/**
|
|
43
|
+
* @deprecated Legacy version of `createElement` for 3rd party libs that already
|
|
44
|
+
* built with this signature.
|
|
45
|
+
*/
|
|
46
|
+
export declare function createElement(type: ReactContextProvider | ElementType | HTMLElement, propsRaw: Record<PropertyKey, unknown>, ...children: JSX.Element[]): ElementNode;
|
|
47
47
|
//# sourceMappingURL=createElement.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createElement.d.ts","sourceRoot":"","sources":["../../src/core/createElement.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,WAAW,EACX,oBAAoB,EACpB,QAAQ,EAET,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"createElement.d.ts","sourceRoot":"","sources":["../../src/core/createElement.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,WAAW,EACX,SAAS,EACT,oBAAoB,EACpB,QAAQ,EAET,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAGL,KAAK,cAAc,EACpB,MAAM,kBAAkB,CAAC;AAE1B;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,gBAAgB;AAC9B;;;GAGG;AAEH,IAAI,EAEA,oBAAoB,GAEpB,WAAW,GAEX,WAAW,GAEX,cAAc,EAClB,QAAQ,EAAE,MAAM,CAAC,WAAW,EAAE,OAAO,CAAC,EACtC,GAAG,EAAE,QAAQ,GAAG,IAAI,GAAG,SAAS,EAGhC,iBAAiB,CAAC,EAAE,OAAO,EAC3B,MAAM,GAAE,SAAS,GAAG,IAAW,EAC/B,KAAK,CAAC,EAAE,OAAO,GACd,WAAW,CAsCb;AAMD;;;;;;;GAOG;AACH,wBAAgB,YAAY;AAC1B,sBAAsB;AACtB,QAAQ,EAAE,GAAG,CAAC,OAAO;AACrB,uBAAuB;AACvB,OAAO,EAAE,WAAW;AACpB,gEAAgE;AAChE,GAAG,CAAC,EAAE,MAAM,eAGb;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAE3B,IAAI,EACA,oBAAoB,GAEpB,WAAW,GAEX,WAAW,EACf,QAAQ,EAAE,MAAM,CAAC,WAAW,EAAE,OAAO,CAAC,EACtC,GAAG,QAAQ,EAAE,GAAG,CAAC,OAAO,EAAE,GACzB,WAAW,CAOb"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { convertClassComponentToFC, isComponentClass, } from './classComponent';
|
|
1
2
|
/**
|
|
2
3
|
* This method is used as the JSX resolver. Every <tag/> or <Component/> is a
|
|
3
4
|
* call to this method.
|
|
@@ -16,7 +17,7 @@
|
|
|
16
17
|
* key
|
|
17
18
|
* );
|
|
18
19
|
*/
|
|
19
|
-
export function
|
|
20
|
+
export function createElementNew(
|
|
20
21
|
/**
|
|
21
22
|
* What to render. Can be a tag (string), a component (function),
|
|
22
23
|
* or a portal target (HTMLElement).
|
|
@@ -25,8 +26,11 @@ export function createElement(
|
|
|
25
26
|
type, propsRaw, key,
|
|
26
27
|
// The following arguments are provided only in the development mode.
|
|
27
28
|
// TODO: Support them to show more informative warnings and errors.
|
|
28
|
-
_isStaticChildren,
|
|
29
|
+
_isStaticChildren, source = null, _self) {
|
|
29
30
|
key ??= null; // Narrow the type for simplicity.
|
|
31
|
+
if (isComponentClass(type)) {
|
|
32
|
+
type = convertClassComponentToFC(type);
|
|
33
|
+
}
|
|
30
34
|
if (typeof type === 'function') {
|
|
31
35
|
// Any component instance (<Message/>).
|
|
32
36
|
return {
|
|
@@ -37,6 +41,7 @@ _isStaticChildren, _source, _self) {
|
|
|
37
41
|
// what's inside until the component runs. Children are passed via `props`
|
|
38
42
|
// instead.
|
|
39
43
|
children: [],
|
|
44
|
+
source,
|
|
40
45
|
};
|
|
41
46
|
}
|
|
42
47
|
// Any tag instance (<div/>).
|
|
@@ -51,6 +56,7 @@ _isStaticChildren, _source, _self) {
|
|
|
51
56
|
props: propsWithoutChildren,
|
|
52
57
|
key,
|
|
53
58
|
children,
|
|
59
|
+
source,
|
|
54
60
|
};
|
|
55
61
|
}
|
|
56
62
|
/**
|
|
@@ -68,6 +74,16 @@ children,
|
|
|
68
74
|
domNode,
|
|
69
75
|
/** Custom key if you need to conditionally recreate portals. */
|
|
70
76
|
key) {
|
|
71
|
-
return
|
|
77
|
+
return createElementNew(domNode, { children }, key);
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* @deprecated Legacy version of `createElement` for 3rd party libs that already
|
|
81
|
+
* built with this signature.
|
|
82
|
+
*/
|
|
83
|
+
export function createElement(
|
|
84
|
+
// prettier-ignore
|
|
85
|
+
type, propsRaw, ...children) {
|
|
86
|
+
const { key, ...props } = propsRaw ?? {};
|
|
87
|
+
return createElementNew(type, { ...props, children: props.children ?? children }, key);
|
|
72
88
|
}
|
|
73
89
|
//# sourceMappingURL=createElement.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createElement.js","sourceRoot":"","sources":["../../src/core/createElement.ts"],"names":[],"mappings":"AAQA;;;;;;;;;;;;;;;;;G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AACtB,QAAqB;AACrB,uBAAuB;AACvB,OAAoB;AACpB,gEAAgE;AAChE,GAAY,EACZ;IACA,OAAO,gBAAgB,CAAC,OAAO,EAAE,EAAE,QAAQ,EAAE,EAAE,GAAG,CAAC,CAAC;AAAA,CACrD;AAED;;;GAGG;AACH,MAAM,UAAU,aAAa;AAC3B,kBAAkB;AAClB,IAKe,EACf,QAAsC,EACtC,GAAG,QAAuB,EACb;IACb,MAAM,EAAE,GAAG,EAAE,GAAG,KAAK,EAAE,GAAG,QAAQ,IAAI,EAAE,CAAC;IACzC,OAAO,gBAAgB,CACrB,IAAI,EACJ,EAAE,GAAG,KAAK,EAAE,QAAQ,EAAE,KAAK,CAAC,QAAQ,IAAI,QAAQ,EAAE,EAClD,GAA2B,CAC5B,CAAC;AAAA,CACH"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createRoot.js","sourceRoot":"","sources":["../../src/core/createRoot.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAE/C;;;;;;;;;GASG;AACH,MAAM,UAAU,UAAU,CAAC,IAAiB,EAAE,OAAoB,EAAW;IAC3E,IAAI,OAAO,GAAG,KAAK,CAAC;IACpB,IAAI,OAAO,GAAwB,IAAI,CAAC;IAExC,MAAM,GAAG,GAAY;QACnB,MAAM,EAAE,CAAC,OAAoB,EAAQ,EAAE,CAAC;YACtC,IAAI,OAAO,EAAE,CAAC;gBACZ,GAAG,CAAC,OAAO,EAAE,CAAC;YAChB,CAAC;YAED,OAAO,GAAG,KAAK,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,IAAI,eAAe,CAAC,CAAC;YAC3D,OAAO,GAAG,IAAI,CAAC;QAAA,CAChB;QACD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"createRoot.js","sourceRoot":"","sources":["../../src/core/createRoot.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAE/C;;;;;;;;;GASG;AACH,MAAM,UAAU,UAAU,CAAC,IAAiB,EAAE,OAAoB,EAAW;IAC3E,IAAI,OAAO,GAAG,KAAK,CAAC;IACpB,IAAI,OAAO,GAAwB,IAAI,CAAC;IAExC,MAAM,GAAG,GAAY;QACnB,MAAM,EAAE,CAAC,OAAoB,EAAQ,EAAE,CAAC;YACtC,IAAI,OAAO,EAAE,CAAC;gBACZ,GAAG,CAAC,OAAO,EAAE,CAAC;YAChB,CAAC;YAED,OAAO,GAAG,KAAK,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,IAAI,eAAe,CAAC,CAAC;YAC3D,OAAO,GAAG,IAAI,CAAC;QAAA,CAChB;QACD,OAAO,EAAE,GAAS,EAAE,CAAC;YACnB,OAAO,EAAE,EAAE,CAAC;YACZ,OAAO,GAAG,KAAK,CAAC;QAAA,CACjB;KACF,CAAC;IAEF,OAAO,GAAG,CAAC;AAAA,CACZ;AAED,MAAM,eAAe,GAAe;IAClC,QAAQ,EAAE,KAAK;CAChB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reactNodeToFiberNode.d.ts","sourceRoot":"","sources":["../../src/core/reactNodeToFiberNode.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,SAAS,
|
|
1
|
+
{"version":3,"file":"reactNodeToFiberNode.d.ts","sourceRoot":"","sources":["../../src/core/reactNodeToFiberNode.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,SAAS,EAUf,MAAM,UAAU,CAAC;AASlB;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,4GAoIjC,CAAC"}
|
|
@@ -19,6 +19,7 @@ unwrapComponents) => {
|
|
|
19
19
|
props: {},
|
|
20
20
|
key: null,
|
|
21
21
|
children: jsxElement,
|
|
22
|
+
source: null,
|
|
22
23
|
};
|
|
23
24
|
}
|
|
24
25
|
// Any null-like value, i.e. it doesn't render a tag or a text node.
|
|
@@ -66,6 +67,7 @@ unwrapComponents) => {
|
|
|
66
67
|
role: 'context',
|
|
67
68
|
props,
|
|
68
69
|
data: { ctx: jsxElement.type.__ctx, consumers: new Set() },
|
|
70
|
+
source: jsxElement.source,
|
|
69
71
|
};
|
|
70
72
|
contextFiber.children = jsxElement.children.map((n) => jsxElementToFiberNode(n, contextFiber, unwrapComponents));
|
|
71
73
|
return contextFiber;
|
|
@@ -76,6 +78,7 @@ unwrapComponents) => {
|
|
|
76
78
|
...createFiberNode(parent),
|
|
77
79
|
type: 'fragment',
|
|
78
80
|
key,
|
|
81
|
+
source: jsxElement.source,
|
|
79
82
|
};
|
|
80
83
|
fragmentFiber.children = jsxElement.children.map((n) => jsxElementToFiberNode(n, fragmentFiber, unwrapComponents));
|
|
81
84
|
return fragmentFiber;
|
|
@@ -87,8 +90,9 @@ unwrapComponents) => {
|
|
|
87
90
|
type: 'component',
|
|
88
91
|
component: jsxElement.type,
|
|
89
92
|
key,
|
|
90
|
-
props,
|
|
93
|
+
props: jsxElement.props,
|
|
91
94
|
data: { hooks: null },
|
|
95
|
+
source: jsxElement.source,
|
|
92
96
|
};
|
|
93
97
|
if (unwrapComponents) {
|
|
94
98
|
const content = runComponent(fiber, null);
|
|
@@ -107,6 +111,7 @@ unwrapComponents) => {
|
|
|
107
111
|
tag: jsxElement.type,
|
|
108
112
|
ref,
|
|
109
113
|
data: { events: {}, styles: null },
|
|
114
|
+
source: jsxElement.source,
|
|
110
115
|
};
|
|
111
116
|
tagFiber.children = jsxElement.children
|
|
112
117
|
.map((n) => jsxElementToFiberNode(n, tagFiber, unwrapComponents))
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reactNodeToFiberNode.js","sourceRoot":"","sources":["../../src/core/reactNodeToFiberNode.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"reactNodeToFiberNode.js","sourceRoot":"","sources":["../../src/core/reactNodeToFiberNode.ts"],"names":[],"mappings":"AAcA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC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Q,CAAC,QAAQ,GAAG,UAAU,CAAC,QAAQ;aACpC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,qBAAqB,CAAC,CAAC,EAAE,QAAQ,EAAE,gBAAgB,CAAC,CAAC;aAChE,IAAI,EAAE,CAAC;QACV,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,MAAM,IAAI,KAAK,CAAC,kCAAkC,UAAU,CAAC,IAAI,GAAG,CAAC,CAAC;AAAA,CACvE,CAAC;AAEF,SAAS,4BAA4B,CACnC,KAAmB,EACkB;IACrC,IAAI,CAAC,CAAC,OAAO,IAAI,KAAK,CAAC,EAAE,CAAC;QACxB,MAAM,IAAI,KAAK,CAAC,wCAAwC,CAAC,CAAC;IAC5D,CAAC;AAAA,CACF;AAED,SAAS,WAAW,CAClB,GAAY,EACqD;IACjE,IACE,GAAG,KAAK,IAAI;QACZ,0DAA0D;QAC1D,OAAO,GAAG,KAAK,UAAU;QACzB,CAAC,CAAC,CAAC,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ,IAAI,SAAS,IAAI,GAAG,CAAC,EACtD,CAAC;QACD,OAAO;IACT,CAAC;IAED,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAC;AAAA,CACjE"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { nullthrowsForFiber } from './errors/ReactError';
|
|
2
2
|
const apps = [];
|
|
3
3
|
export const getAppByFiber = (fiber) => {
|
|
4
|
-
return
|
|
4
|
+
return nullthrowsForFiber(fiber, apps[fiber.appId]);
|
|
5
5
|
};
|
|
6
6
|
export const registerApp = (fn) => {
|
|
7
7
|
apps.push(fn(apps.length));
|
|
@@ -14,7 +14,7 @@ export const removeApp = (id) => {
|
|
|
14
14
|
// Help with garbage collection.
|
|
15
15
|
app.root = app.tempContext = null;
|
|
16
16
|
app.effects = { normal: [] };
|
|
17
|
-
app.invalidatedComponents = {
|
|
17
|
+
app.invalidatedComponents = { isEmpty: () => true };
|
|
18
18
|
}
|
|
19
19
|
};
|
|
20
20
|
//# sourceMappingURL=app.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.js","sourceRoot":"","sources":["../../../src/core/reconciliation/app.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"app.js","sourceRoot":"","sources":["../../../src/core/reconciliation/app.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAEzD,MAAM,IAAI,GAAsB,EAAE,CAAC;AAEnC,MAAM,CAAC,MAAM,aAAa,GAAG,CAAC,KAAgB,EAAO,EAAE,CAAC;IACtD,OAAO,kBAAkB,CAAC,KAAK,EAAE,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;AAAA,CACrD,CAAC;AAEF,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,EAAuB,EAAO,EAAE,CAAC;IAC3D,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC;IAC3B,OAAO,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAE,CAAC;AAAA,CACrB,CAAC;AAEF,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,EAAU,EAAQ,EAAE,CAAC;IAC7C,MAAM,GAAG,GAAG,IAAI,CAAC,EAAE,CAA4B,CAAC;IAChD,IAAI,GAAG,EAAE,CAAC;QACR,IAAI,CAAC,EAAE,CAAC,GAAG,IAAI,CAAC;QAChB,gCAAgC;QAChC,GAAG,CAAC,IAAI,GAAG,GAAG,CAAC,WAAW,GAAG,IAAI,CAAC;QAClC,GAAG,CAAC,OAAO,GAAG,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC;QAC7B,GAAG,CAAC,qBAAqB,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,IAAI,EAAE,CAAC;IACtD,CAAC;AAAA,CACF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fromApp.d.ts","sourceRoot":"","sources":["../../../../src/core/reconciliation/collect/fromApp.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"fromApp.d.ts","sourceRoot":"","sources":["../../../../src/core/reconciliation/collect/fromApp.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAGzD;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,wBASjC,CAAC"}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { collectActionsFromComponent } from './fromComponent';
|
|
2
|
-
import { getFiberLevel } from '../fibers';
|
|
3
2
|
/**
|
|
4
3
|
* Goes through the list of invalidated components, runs them, finds the diff,
|
|
5
4
|
* and returns the list of actions to convert the previous fiber tree to the new
|
|
@@ -7,32 +6,9 @@ import { getFiberLevel } from '../fibers';
|
|
|
7
6
|
*/
|
|
8
7
|
export const collectActionsFromApp = (app) => {
|
|
9
8
|
const actions = [];
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
.map((f) => ({ fiber: f, level: getFiberLevel(f) }))
|
|
14
|
-
.sort((a, b) => a.level - b.level);
|
|
15
|
-
for (const { fiber } of sorted) {
|
|
16
|
-
// Redo the check because some components can be indirectly removed in between.
|
|
17
|
-
if (app.invalidatedComponents.has(fiber)) {
|
|
18
|
-
actions.push(...collectActionsFromComponent(app, fiber, null));
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
if (app.invalidatedComponents.size > 0) {
|
|
22
|
-
// The only reason why a component might be kept in `invalidatedComponents`
|
|
23
|
-
// after the first run is that this component was "trapped" inside a
|
|
24
|
-
// non-invalidated component. We don't traverse through the whole fiber
|
|
25
|
-
// tree, so we need to run the rest of the queue again.
|
|
26
|
-
if (app.testMode) {
|
|
27
|
-
// A sanity check
|
|
28
|
-
for (const fiber of app.invalidatedComponents) {
|
|
29
|
-
if (fiber.type !== 'component' ||
|
|
30
|
-
!fiber.data.hooks?.some((h) => h.type === 'context')) {
|
|
31
|
-
throw new Error(`Fiber node is stuck`);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
actions.push(...collectActionsFromApp(app));
|
|
9
|
+
while (!app.invalidatedComponents.isEmpty()) {
|
|
10
|
+
const [fiber, props] = app.invalidatedComponents.poll();
|
|
11
|
+
actions.push(...collectActionsFromComponent(fiber, props));
|
|
36
12
|
}
|
|
37
13
|
return actions;
|
|
38
14
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fromApp.js","sourceRoot":"","sources":["../../../../src/core/reconciliation/collect/fromApp.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,2BAA2B,EAAE,MAAM,iBAAiB,CAAC;
|
|
1
|
+
{"version":3,"file":"fromApp.js","sourceRoot":"","sources":["../../../../src/core/reconciliation/collect/fromApp.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,2BAA2B,EAAE,MAAM,iBAAiB,CAAC;AAE9D;;;;GAIG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,GAAQ,EAAY,EAAE,CAAC;IAC3D,MAAM,OAAO,GAAa,EAAE,CAAC;IAE7B,OAAO,CAAC,GAAG,CAAC,qBAAqB,CAAC,OAAO,EAAE,EAAE,CAAC;QAC5C,MAAM,CAAC,KAAK,EAAE,KAAK,CAAC,GAAG,GAAG,CAAC,qBAAqB,CAAC,IAAI,EAAE,CAAC;QACxD,OAAO,CAAC,IAAI,CAAC,GAAG,2BAA2B,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC;IAC7D,CAAC;IAED,OAAO,OAAO,CAAC;AAAA,CAChB,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fromChildrenPair.d.ts","sourceRoot":"","sources":["../../../../src/core/reconciliation/collect/fromChildrenPair.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAIV,SAAS,EAGV,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AASzD;;;;GAIG;AACH,eAAO,MAAM,8BAA8B,
|
|
1
|
+
{"version":3,"file":"fromChildrenPair.d.ts","sourceRoot":"","sources":["../../../../src/core/reconciliation/collect/fromChildrenPair.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAIV,SAAS,EAGV,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AASzD;;;;GAIG;AACH,eAAO,MAAM,8BAA8B,oDAsE1C,CAAC"}
|
|
@@ -25,12 +25,20 @@ after) => {
|
|
|
25
25
|
const actions = [];
|
|
26
26
|
// Search for nodes that were in the past render but don't exist in the
|
|
27
27
|
// current render. Then remove them.
|
|
28
|
+
let survived = left.size;
|
|
28
29
|
for (const [key, l] of left.entries()) {
|
|
29
30
|
if (!right.has(key)) {
|
|
31
|
+
--survived;
|
|
30
32
|
// Don't run components from the removing node even if they were invalidated
|
|
31
33
|
uninvalidateFiberSubTree(app, l.fiber);
|
|
32
|
-
actions.push({
|
|
33
|
-
|
|
34
|
+
actions.push({
|
|
35
|
+
type: 'Remove',
|
|
36
|
+
fiber: l.fiber,
|
|
37
|
+
// Set to true if it's the last child of `fiber` and we remove them all.
|
|
38
|
+
// It's needed to convert the fiber to !--empty.
|
|
39
|
+
last: survived === 0,
|
|
40
|
+
});
|
|
41
|
+
relayoutNeeded = true; // to correct the container's .element
|
|
34
42
|
}
|
|
35
43
|
}
|
|
36
44
|
for (const [key, r] of right.entries()) {
|
|
@@ -39,7 +47,7 @@ after) => {
|
|
|
39
47
|
// 1. There was no node with this key before. Create a new one.
|
|
40
48
|
// 2. There was one, but it was very different. Replace it.
|
|
41
49
|
relayoutNeeded = true;
|
|
42
|
-
actions.push(...createFiberActions(app, r.fiber));
|
|
50
|
+
actions.push(...createFiberActions(app, r.fiber, fiber));
|
|
43
51
|
if (l) {
|
|
44
52
|
// Don't run components from the removing node even if they were invalidated
|
|
45
53
|
uninvalidateFiberSubTree(app, l.fiber);
|
|
@@ -60,7 +68,7 @@ after) => {
|
|
|
60
68
|
// It'll:
|
|
61
69
|
// - update node positions when needed
|
|
62
70
|
// - move new nodes from a temporary container to the existing l-container
|
|
63
|
-
// -
|
|
71
|
+
// - updates component's .element accordingly
|
|
64
72
|
actions.push({ type: 'Relayout', fiber, before: left, after: right });
|
|
65
73
|
}
|
|
66
74
|
return actions;
|
|
@@ -82,9 +90,8 @@ const uninvalidateFiberSubTree = (app, fiberNode) => {
|
|
|
82
90
|
* Returns a list of actions to create from scratch the DOM nodes of the given
|
|
83
91
|
* fiber node.
|
|
84
92
|
*/
|
|
85
|
-
const createFiberActions = (app, fiber) => {
|
|
86
|
-
const fakeParent = createFakeFiberContainer(
|
|
87
|
-
fakeParent.parent = fiber.parent;
|
|
93
|
+
const createFiberActions = (app, fiber, parent) => {
|
|
94
|
+
const fakeParent = createFakeFiberContainer(parent);
|
|
88
95
|
// Wrap the given node with a fake <x-container/> node to force `applyActions`
|
|
89
96
|
// to create new DOM nodes in the fake DOM node, not in the mounted container.
|
|
90
97
|
// The Relayout action will move them into the real node and then reassign the
|
|
@@ -102,14 +109,16 @@ const createFiberActions = (app, fiber) => {
|
|
|
102
109
|
* It will be used to store new DOM nodes until the Relayout action repositions
|
|
103
110
|
* them into their real parent.
|
|
104
111
|
*/
|
|
105
|
-
const createFakeFiberContainer = (
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
}
|
|
112
|
+
const createFakeFiberContainer = (parentFiber) => {
|
|
113
|
+
return {
|
|
114
|
+
...createFiberNode(parentFiber),
|
|
115
|
+
type: 'tag',
|
|
116
|
+
element: document.createElement('x-container'),
|
|
117
|
+
tag: FAKE_CONTAINER_TAG,
|
|
118
|
+
data: { events: {}, styles: null },
|
|
119
|
+
props: {},
|
|
120
|
+
};
|
|
121
|
+
};
|
|
113
122
|
/**
|
|
114
123
|
* Converts FiberNode[] to Map<key, { order, fiber }>.
|
|
115
124
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fromChildrenPair.js","sourceRoot":"","sources":["../../../../src/core/reconciliation/collect/fromChildrenPair.ts"],"names":[],"mappings":"AASA,OAAO,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AACvC,OAAO,EAAE,2BAA2B,EAAE,MAAM,iBAAiB,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAC3D,OAAO,EAAE,0BAA0B,EAAE,MAAM,uDAAuD,CAAC;AACnG,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEjD;;;;GAIG;AACH,MAAM,CAAC,MAAM,8BAA8B,GAAG;AAC5C,qDAAqD;AACrD,KAAgB;AAChB,oEAAoE;AACpE,KAAkB,EACR,EAAE,CAAC;IACb,MAAM,GAAG,GAAG,aAAa,CAAC,KAAK,CAAC,CAAC;IACjC,MAAM,IAAI,GAAG,cAAc,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAC5C,MAAM,KAAK,GAAG,cAAc,CAAC,KAAK,CAAC,CAAC;IACpC;;qBAEiB;IACjB,IAAI,cAAc,GAAG,KAAK,CAAC;IAE3B,MAAM,OAAO,GAAa,EAAE,CAAC;IAE7B,uEAAuE;IACvE,oCAAoC;IACpC,KAAK,MAAM,CAAC,GAAG,EAAE,CAAC,CAAC,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DAAsD;IACtD,OAAO,0BAA0B,CAAC,KAAK,CAAC,CAAC;AAAA,CAC1C,CAAC;AAEF;;;;GAIG;AACH,MAAM,wBAAwB,GAAG,CAAC,WAAsB,EAAgB,EAAE,CAAC;IACzE,OAAO;QACL,GAAG,eAAe,CAAC,WAAW,CAAC;QAC/B,IAAI,EAAE,KAAK;QACX,OAAO,EAAE,QAAQ,CAAC,aAAa,CAAC,aAAa,CAAC;QAC9C,GAAG,EAAE,kBAAkB;QACvB,IAAI,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE;QAClC,KAAK,EAAE,EAAE;KACV,CAAC;AAAA,CACH,CAAC;AAEF;;GAEG;AACH,MAAM,cAAc,GAAG,CAAC,MAAmB,EAAY,EAAE,CAAC;IACxD,IAAI,UAAU,GAAG,CAAC,CAAC,CAAC;IACpB,OAAO,IAAI,GAAG,CACZ,MAAM,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,GAAG,EAAwB,EAAE,CAAC;QAC/C,IAAI,KAAK,CAAC,GAAG,IAAI,IAAI;YAAE,EAAE,UAAU,CAAC;QACpC,OAAO;YACL,KAAK,CAAC,GAAG,IAAI,QAAQ,UAAU,EAAE;YACjC,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE;SACb,CAAC;IAAA,CACZ,CAAC,CACH,CAAC;AAAA,CACH,CAAC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { FiberNode, UnknownProps } from '../../../types';
|
|
2
2
|
import type { Action } from '../../../types/actions';
|
|
3
3
|
/**
|
|
4
4
|
* 1. Runs a component
|
|
@@ -6,5 +6,5 @@ import type { Action } from '../../../types/actions';
|
|
|
6
6
|
*
|
|
7
7
|
* Throws when the given component is not invalidated.
|
|
8
8
|
*/
|
|
9
|
-
export declare const collectActionsFromComponent: (
|
|
9
|
+
export declare const collectActionsFromComponent: (fiber: FiberNode, props: UnknownProps | null) => Action[];
|
|
10
10
|
//# sourceMappingURL=fromComponent.d.ts.map
|