@faiwer/react 0.8.4 → 19.0.1
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 +43 -21
- package/dist/core/actions/applyAction.d.ts.map +1 -1
- package/dist/core/actions/applyAction.js +6 -0
- package/dist/core/actions/applyAction.js.map +1 -1
- package/dist/core/actions/catchError.action.d.ts +10 -0
- package/dist/core/actions/catchError.action.d.ts.map +1 -0
- package/dist/core/actions/catchError.action.js +51 -0
- package/dist/core/actions/catchError.action.js.map +1 -0
- 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 +22 -4
- 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.map +1 -1
- package/dist/core/actions/dom/attributes.js +4 -1
- package/dist/core/actions/dom/attributes.js.map +1 -1
- package/dist/core/actions/dom/css.d.ts.map +1 -1
- package/dist/core/actions/dom/css.js +2 -1
- package/dist/core/actions/dom/css.js.map +1 -1
- package/dist/core/actions/dom/events.d.ts.map +1 -1
- package/dist/core/actions/dom/events.js +15 -3
- package/dist/core/actions/dom/events.js.map +1 -1
- package/dist/core/actions/dom/value.d.ts +18 -0
- package/dist/core/actions/dom/value.d.ts.map +1 -0
- package/dist/core/actions/dom/value.js +211 -0
- package/dist/core/actions/dom/value.js.map +1 -0
- package/dist/core/actions/helpers.d.ts +17 -10
- package/dist/core/actions/helpers.d.ts.map +1 -1
- package/dist/core/actions/helpers.js +64 -70
- 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 +2 -2
- package/dist/core/actions/remove.action.d.ts.map +1 -1
- package/dist/core/actions/remove.action.js +20 -17
- 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 +34 -23
- package/dist/core/actions/replace.action.js.map +1 -1
- package/dist/core/actions/scheduleEffect.action.d.ts +7 -0
- package/dist/core/actions/scheduleEffect.action.d.ts.map +1 -0
- package/dist/core/actions/scheduleEffect.action.js +8 -0
- package/dist/core/actions/scheduleEffect.action.js.map +1 -0
- 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 +47 -6
- 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 +2 -1
- package/dist/core/classComponent.d.ts.map +1 -1
- package/dist/core/classComponent.js +20 -12
- package/dist/core/classComponent.js.map +1 -1
- 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 +6 -4
- package/dist/core/components.d.ts.map +1 -1
- package/dist/core/components.js +26 -8
- package/dist/core/components.js.map +1 -1
- package/dist/core/createElement.d.ts +2 -8
- package/dist/core/createElement.d.ts.map +1 -1
- package/dist/core/createElement.js +3 -1
- package/dist/core/createElement.js.map +1 -1
- package/dist/core/reactNodeToFiberNode.d.ts +3 -1
- package/dist/core/reactNodeToFiberNode.d.ts.map +1 -1
- package/dist/core/reactNodeToFiberNode.js +80 -17
- 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 +2 -1
- package/dist/core/reconciliation/collect/fromApp.d.ts.map +1 -1
- package/dist/core/reconciliation/collect/fromApp.js +7 -26
- package/dist/core/reconciliation/collect/fromApp.js.map +1 -1
- package/dist/core/reconciliation/collect/fromChildrenPair.d.ts +2 -1
- package/dist/core/reconciliation/collect/fromChildrenPair.d.ts.map +1 -1
- package/dist/core/reconciliation/collect/fromChildrenPair.js +37 -10
- package/dist/core/reconciliation/collect/fromChildrenPair.js.map +1 -1
- package/dist/core/reconciliation/collect/fromComponent.d.ts +3 -2
- package/dist/core/reconciliation/collect/fromComponent.d.ts.map +1 -1
- package/dist/core/reconciliation/collect/fromComponent.js +27 -9
- package/dist/core/reconciliation/collect/fromComponent.js.map +1 -1
- package/dist/core/reconciliation/collect/fromFiberPair.d.ts +2 -1
- package/dist/core/reconciliation/collect/fromFiberPair.d.ts.map +1 -1
- package/dist/core/reconciliation/collect/fromFiberPair.js +8 -5
- 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 +2 -2
- package/dist/core/reconciliation/effects.d.ts.map +1 -1
- package/dist/core/reconciliation/effects.js +52 -4
- package/dist/core/reconciliation/effects.js.map +1 -1
- package/dist/core/reconciliation/errors/ReactError.d.ts +15 -0
- package/dist/core/reconciliation/errors/ReactError.d.ts.map +1 -0
- package/dist/core/reconciliation/errors/ReactError.js +56 -0
- package/dist/core/reconciliation/errors/ReactError.js.map +1 -0
- package/dist/core/reconciliation/errors/stack.d.ts +8 -2
- package/dist/core/reconciliation/errors/stack.d.ts.map +1 -1
- package/dist/core/reconciliation/errors/stack.js +65 -8
- package/dist/core/reconciliation/errors/stack.js.map +1 -1
- package/dist/core/reconciliation/fibers.d.ts +1 -0
- package/dist/core/reconciliation/fibers.d.ts.map +1 -1
- package/dist/core/reconciliation/fibers.js +3 -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 +6 -5
- 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 +24 -6
- 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 +17 -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.d.ts.map +1 -1
- package/dist/core/reconciliation/render.js +9 -3
- package/dist/core/reconciliation/render.js.map +1 -1
- package/dist/core/reconciliation/runFiberComponents.d.ts +3 -1
- package/dist/core/reconciliation/runFiberComponents.d.ts.map +1 -1
- package/dist/core/reconciliation/runFiberComponents.js +33 -5
- package/dist/core/reconciliation/runFiberComponents.js.map +1 -1
- package/dist/core/reconciliation/typeGuards.d.ts +3 -0
- package/dist/core/reconciliation/typeGuards.d.ts.map +1 -1
- package/dist/core/reconciliation/typeGuards.js +13 -0
- package/dist/core/reconciliation/typeGuards.js.map +1 -1
- package/dist/core/reconciliation/validateApp.d.ts +1 -1
- package/dist/core/reconciliation/validateApp.d.ts.map +1 -1
- package/dist/core/reconciliation/validateApp.js +28 -21
- package/dist/core/reconciliation/validateApp.js.map +1 -1
- package/dist/hooks/helpers.d.ts +3 -3
- 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 +2 -1
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +2 -1
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/useContext.d.ts.map +1 -1
- package/dist/hooks/useContext.js +6 -6
- 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 +21 -7
- package/dist/hooks/useEffect.js.map +1 -1
- package/dist/hooks/useError.d.ts +5 -0
- package/dist/hooks/useError.d.ts.map +1 -0
- package/dist/hooks/useError.js +19 -0
- package/dist/hooks/useError.js.map +1 -0
- package/dist/hooks/useReducer.d.ts +7 -0
- package/dist/hooks/useReducer.d.ts.map +1 -0
- package/dist/hooks/useReducer.js +10 -0
- package/dist/hooks/useReducer.js.map +1 -0
- 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 +3 -6
- package/dist/hooks/useState.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/jsx.d.ts +159 -44
- package/dist/mocks.d.ts +0 -7
- package/dist/mocks.d.ts.map +1 -1
- package/dist/mocks.js +0 -6
- package/dist/mocks.js.map +1 -1
- package/dist/react.d.ts +46 -0
- package/dist/types/actions.d.ts +23 -5
- package/dist/types/actions.d.ts.map +1 -1
- package/dist/types/app.d.ts +17 -3
- 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 +10 -1
- package/dist/types/common.d.ts.map +1 -1
- package/dist/types/component.d.ts +11 -2
- 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 -22
- package/dist/types/dom.d.ts.map +1 -1
- package/dist/types/events.d.ts +18 -11
- package/dist/types/events.d.ts.map +1 -1
- package/dist/types/fiber.d.ts +30 -12
- 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 +16 -6
- package/dist/types/hooks.d.ts.map +1 -1
- package/dist/types/react.d.ts +31 -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 +11 -3
|
@@ -5,6 +5,8 @@ import { applyActions } from './applyActions';
|
|
|
5
5
|
import { postCommit } from './postCommit';
|
|
6
6
|
import { removeApp, registerApp } from './app';
|
|
7
7
|
import { createFiberNode, toFiberChildren } from './fibers';
|
|
8
|
+
import { Queue } from './queue';
|
|
9
|
+
import { ReactError } from './errors/ReactError';
|
|
8
10
|
/**
|
|
9
11
|
* Mounts an app (`jsxElement`) to the given DOM node (`container`). Returns
|
|
10
12
|
* a function that destroys the app and removes all of its DOM nodes.
|
|
@@ -14,23 +16,39 @@ export const mount = (container, jsxElement, options) => {
|
|
|
14
16
|
const app = registerApp((appId) => ({
|
|
15
17
|
id: appId,
|
|
16
18
|
root: createRootFiber(appId),
|
|
17
|
-
effects: {
|
|
18
|
-
|
|
19
|
+
effects: {
|
|
20
|
+
afterActions: [],
|
|
21
|
+
refsMount: [],
|
|
22
|
+
refsUnmount: [],
|
|
23
|
+
layout: [],
|
|
24
|
+
normal: [],
|
|
25
|
+
},
|
|
26
|
+
invalidatedComponents: new Queue(),
|
|
19
27
|
state: 'render',
|
|
20
28
|
testMode: !!options.testMode,
|
|
29
|
+
transformSource: options.transformSource,
|
|
21
30
|
tempContext: new Map(),
|
|
22
31
|
}));
|
|
23
|
-
const
|
|
32
|
+
const actions = [];
|
|
33
|
+
const mountX = jsxElementToFiberNode(jsxElement, app.root, true);
|
|
34
|
+
if (mountX instanceof ReactError) {
|
|
35
|
+
// Could not mount the app. No error boundary was found. Terminate the app.
|
|
36
|
+
throw mountX;
|
|
37
|
+
}
|
|
38
|
+
const [content, mountActions] = mountX;
|
|
39
|
+
actions.push(...mountActions);
|
|
24
40
|
app.root.children = toFiberChildren(content);
|
|
25
41
|
app.root.element = container;
|
|
26
|
-
|
|
42
|
+
actions.push(...collectActionsFromNewFiber(app.root).flat());
|
|
27
43
|
applyActions(app, actions);
|
|
28
44
|
if (app.testMode)
|
|
29
45
|
validateApp(app);
|
|
30
46
|
postCommit(app, 0);
|
|
31
47
|
return function destroyApp() {
|
|
32
|
-
app.invalidatedComponents
|
|
33
|
-
app.effects.
|
|
48
|
+
app.invalidatedComponents = new Queue();
|
|
49
|
+
app.effects.afterActions = [];
|
|
50
|
+
app.effects.refsMount = [];
|
|
51
|
+
app.effects.refsUnmount = [];
|
|
34
52
|
app.effects.layout = [];
|
|
35
53
|
app.effects.normal = [];
|
|
36
54
|
applyActions(app, [{ type: 'Remove', fiber: app.root, immediate: true }]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mount.js","sourceRoot":"","sources":["../../../src/core/reconciliation/mount.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,0BAA0B,EAAE,MAAM,wBAAwB,CAAC;AACpE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAE/C,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"mount.js","sourceRoot":"","sources":["../../../src/core/reconciliation/mount.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,0BAA0B,EAAE,MAAM,wBAAwB,CAAC;AACpE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AAE/C,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAC5D,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEjD;;;GAGG;AACH,MAAM,CAA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C3B,IAAI,GAAG,CAAC,QAAQ;QAAE,WAAW,CAAC,GAAG,CAAC,CAAC;IAEnC,UAAU,CAAC,GAAG,EAAE,CAAC,CAAC,CAAC;IAEnB,OAAO,SAAS,UAAU,GAAS;QACjC,GAAG,CAAC,qBAAqB,GAAG,IAAI,KAAK,EAAE,CAAC;QACxC,GAAG,CAAC,OAAO,CAAC,YAAY,GAAG,EAAE,CAAC;QAC9B,GAAG,CAAC,OAAO,CAAC,SAAS,GAAG,EAAE,CAAC;QAC3B,GAAG,CAAC,OAAO,CAAC,WAAW,GAAG,EAAE,CAAC;QAC7B,GAAG,CAAC,OAAO,CAAC,MAAM,GAAG,EAAE,CAAC;QACxB,GAAG,CAAC,OAAO,CAAC,MAAM,GAAG,EAAE,CAAC;QAExB,YAAY,CAAC,GAAG,EAAE,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,GAAG,CAAC,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;QAE1E,GAAG,CAAC,KAAK,GAAG,QAAQ,CAAC;QACrB,SAAS,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAAA,CACnB,CAAC;AAAA,CACH,CAAC;AAEF;;;GAGG;AACH,MAAM,eAAe,GAAG,CAAC,KAAa,EAAgB,EAAE,CAAC,CAAC;IACxD,GAAG,eAAe,CAAC,EAAE,KAAK,EAA0B,CAAC;IACrD,IAAI,EAAE,KAAK;IACX,GAAG,EAAE,MAAM;IACX,KAAK,EAAE,CAAC;IACR,IAAI,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE;IAClC,KAAK,EAAE,EAAE;CACV,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"postCommit.d.ts","sourceRoot":"","sources":["../../../src/core/reconciliation/postCommit.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"postCommit.d.ts","sourceRoot":"","sources":["../../../src/core/reconciliation/postCommit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,KAAK,GAAG,EAAE,MAAM,oBAAoB,CAAC;AAK5D;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,QA2DjD"}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
|
+
import { containerSym } from '../../types';
|
|
1
2
|
import { reactRender } from './render';
|
|
2
3
|
import { runEffects } from './effects';
|
|
4
|
+
import { traverseFiberTree } from '../actions/helpers';
|
|
3
5
|
/**
|
|
4
6
|
* A stage that happens after we've applied all necessary DOM and fiber changes
|
|
5
7
|
* in applyActions (the "commit" phase). In this stage we:
|
|
@@ -9,15 +11,26 @@ import { runEffects } from './effects';
|
|
|
9
11
|
* - or move the app to the idle stage
|
|
10
12
|
*/
|
|
11
13
|
export function postCommit(app, depth) {
|
|
14
|
+
if (app.testMode) {
|
|
15
|
+
traverseFiberTree(app.root, (fiber) => {
|
|
16
|
+
if (fiber.element !== containerSym) {
|
|
17
|
+
fiber.element.__fiber = fiber;
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
runEffects(app, 'afterActions');
|
|
12
22
|
app.tempContext.clear();
|
|
13
23
|
// Run "ref" and "layout" effects. They must be run in the same microtask
|
|
14
24
|
// queue as the commit phase.
|
|
15
|
-
if (app.effects.layout.length > 0 ||
|
|
25
|
+
if (app.effects.layout.length > 0 ||
|
|
26
|
+
app.effects.refsUnmount.length > 0 ||
|
|
27
|
+
app.effects.refsMount.length > 0) {
|
|
16
28
|
app.state = 'refEffects';
|
|
17
|
-
runEffects(app, '
|
|
29
|
+
runEffects(app, 'refsUnmount');
|
|
30
|
+
runEffects(app, 'refsMount');
|
|
18
31
|
app.state = 'layoutEffects';
|
|
19
32
|
runEffects(app, 'layout');
|
|
20
|
-
if (app.invalidatedComponents.
|
|
33
|
+
if (!app.invalidatedComponents.isEmpty()) {
|
|
21
34
|
// 1+ component was invalidated in an effect
|
|
22
35
|
if (app.effects.normal.length > 0) {
|
|
23
36
|
// Layout effect component invalidations should be applied within the
|
|
@@ -38,7 +51,7 @@ export function postCommit(app, depth) {
|
|
|
38
51
|
app.state = 'effects';
|
|
39
52
|
setTimeout(() => {
|
|
40
53
|
runEffects(app, 'normal');
|
|
41
|
-
if (app.invalidatedComponents.
|
|
54
|
+
if (!app.invalidatedComponents.isEmpty()) {
|
|
42
55
|
app.state = 'scheduled';
|
|
43
56
|
setTimeout(() => reactRender(app), 0);
|
|
44
57
|
return;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"postCommit.js","sourceRoot":"","sources":["../../../src/core/reconciliation/postCommit.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"postCommit.js","sourceRoot":"","sources":["../../../src/core/reconciliation/postCommit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAY,MAAM,oBAAoB,CAAC;AAC5D,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAEvD;;;;;;;GAOG;AACH,MAAM,UAAU,UAAU,CAAC,GAAQ,EAAE,KAAa,EAAE;IAClD,IAAI,GAAG,CAAC,QAAQ,EAAE,CAAC;QACjB,iBAAiB,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC;YACrC,IAAI,KAAK,CAAC,OAAO,KAAK,YAAY,EAAE,CAAC;gBACnC,KAAK,CAAC,OAAQ,CAAC,OAAO,GAAG,KAAK,CAAC;YACjC,CAAC;QAAA,CACF,CAAC,CAAC;IACL,CAAC;IAED,UAAU,CAAC,GAAG,EAAE,cAAc,CAAC,CAAC;IAChC,GAAG,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC;IAExB,yEAAyE;IACzE,6BAA6B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AAO,EAAE,EAAE,CAAC;YACzC,GAAG,CAAC,KAAK,GAAG,WAAW,CAAC;YACxB,UAAU,CAAC,GAAG,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC;YACtC,OAAO;QACT,CAAC;QAED,GAAG,CAAC,KAAK,GAAG,MAAM,CAAC;IAAA,CACpB,EAAE,CAAC,CAAC,CAAC;AAAA,CACP"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { FiberNode, UnknownProps } from '../../types';
|
|
2
|
+
/**
|
|
3
|
+
* A wrapper over Heap and Set to control the queue of invalidated components.
|
|
4
|
+
* Using a heap to be able to return the highest item (within the tree). Using
|
|
5
|
+
* a map to be able to remove items when needed (e.g. a parent component removes
|
|
6
|
+
* some children that were already invalidated).
|
|
7
|
+
*
|
|
8
|
+
* TODO: Add tests
|
|
9
|
+
*/
|
|
10
|
+
export declare class Queue {
|
|
11
|
+
private heap;
|
|
12
|
+
private map;
|
|
13
|
+
isEmpty(): boolean;
|
|
14
|
+
add(fiber: FiberNode, props: UnknownProps | null): void;
|
|
15
|
+
has(fiber: FiberNode): boolean;
|
|
16
|
+
poll(): [fiber: FiberNode, props: UnknownProps | null];
|
|
17
|
+
delete(fiber: FiberNode): void;
|
|
18
|
+
traverse(fn: (fiber: FiberNode) => void | boolean): void;
|
|
19
|
+
private prune;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=queue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queue.d.ts","sourceRoot":"","sources":["../../../src/core/reconciliation/queue.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAIlE;;;;;;;GAOG;AACH,qBAAa,KAAK;IAChB,OAAO,CAAC,IAAI,CAEV;IACF,OAAO,CAAC,GAAG,CAA6C;IAExD,OAAO,IAAI,OAAO,CAGjB;IAED,GAAG,CAAC,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,YAAY,GAAG,IAAI,GAAG,IAAI,CAUtD;IAED,GAAG,CAAC,KAAK,EAAE,SAAS,GAAG,OAAO,CAE7B;IAED,IAAI,IAAI,CAAC,KAAK,EAAE,SAAS,EAAE,KAAK,EAAE,YAAY,GAAG,IAAI,CAAC,CAOrD;IAED,MAAM,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI,CAG7B;IAED,QAAQ,CAAC,EAAE,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,IAAI,GAAG,OAAO,GAAG,IAAI,CAMvD;IAED,OAAO,CAAC,KAAK;CAKd"}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { Heap } from './heap';
|
|
2
|
+
import { getFiberLevel } from './fibers';
|
|
3
|
+
/**
|
|
4
|
+
* A wrapper over Heap and Set to control the queue of invalidated components.
|
|
5
|
+
* Using a heap to be able to return the highest item (within the tree). Using
|
|
6
|
+
* a map to be able to remove items when needed (e.g. a parent component removes
|
|
7
|
+
* some children that were already invalidated).
|
|
8
|
+
*
|
|
9
|
+
* TODO: Add tests
|
|
10
|
+
*/
|
|
11
|
+
export class Queue {
|
|
12
|
+
heap = new Heap((a, b) => getFiberLevel(b) - getFiberLevel(a));
|
|
13
|
+
map = new Map();
|
|
14
|
+
isEmpty() {
|
|
15
|
+
this.prune();
|
|
16
|
+
return this.heap.size() === 0;
|
|
17
|
+
}
|
|
18
|
+
add(fiber, props) {
|
|
19
|
+
if (this.map.has(fiber)) {
|
|
20
|
+
if (props) {
|
|
21
|
+
this.map.set(fiber, props);
|
|
22
|
+
}
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
this.map.set(fiber, props);
|
|
26
|
+
this.heap.add(fiber);
|
|
27
|
+
}
|
|
28
|
+
has(fiber) {
|
|
29
|
+
return this.map.has(fiber);
|
|
30
|
+
}
|
|
31
|
+
poll() {
|
|
32
|
+
this.prune();
|
|
33
|
+
const fiber = this.heap.poll();
|
|
34
|
+
const props = this.map.get(fiber);
|
|
35
|
+
this.map.delete(fiber);
|
|
36
|
+
return [fiber, props];
|
|
37
|
+
}
|
|
38
|
+
delete(fiber) {
|
|
39
|
+
this.map.delete(fiber);
|
|
40
|
+
this.prune();
|
|
41
|
+
}
|
|
42
|
+
traverse(fn) {
|
|
43
|
+
for (const fiber of this.heap.arr) {
|
|
44
|
+
if (this.map.has(fiber)) {
|
|
45
|
+
fn(fiber);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
prune() {
|
|
50
|
+
while (this.heap.size() > 0 && !this.map.has(this.heap.peek())) {
|
|
51
|
+
this.heap.poll();
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
//# sourceMappingURL=queue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queue.js","sourceRoot":"","sources":["../../../src/core/reconciliation/queue.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,IAAI,EAAE,MAAM,QAAQ,CAAC;AAC9B,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC;;;;;;;GAOG;AACH,MAAM,OAAO,KAAK;IACR,IAAI,GAAG,IAAI,IAAI,CACrB,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,aAAa,CAAC,CAAC,CAAC,GAAG,aAAa,CAAC,CAAC,CAAC,CAC9C,CAAC;IACM,GAAG,GAAG,IAAI,GAAG,EAAkC,CAAC;IAExD,OAAO,GAAY;QACjB,IAAI,CAAC,KAAK,EAAE,CAAC;QACb,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAAA,CAC/B;IAED,GAAG,CAAC,KAAgB,EAAE,KAA0B,EAAQ;QACtD,IAAI,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;YACxB,IAAI,KAAK,EAAE,CAAC;gBACV,IAAI,CAAC,GAAG,CAAC,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AAC,IAAI,CAAC,IAAI,EAAE,CAAC;QACnB,CAAC;IAAA,CACF;CACF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../../src/core/reconciliation/render.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../../src/core/reconciliation/render.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,oBAAoB,CAAC;AAO9C;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,SAAI,QA4B9C"}
|
|
@@ -2,6 +2,7 @@ import { validateApp } from './validateApp';
|
|
|
2
2
|
import { collectActionsFromApp } from './collect/fromApp';
|
|
3
3
|
import { postCommit } from './postCommit';
|
|
4
4
|
import { applyActions } from './applyActions';
|
|
5
|
+
import { ReactError } from './errors/ReactError';
|
|
5
6
|
/**
|
|
6
7
|
* Performs another rendering round. Once anything changes a component's state
|
|
7
8
|
* (invalidates it), a new render cycle is scheduled. The render consists of:
|
|
@@ -14,7 +15,7 @@ export function reactRender(app, depth = 0) {
|
|
|
14
15
|
if (depth > MAX_DEPTH) {
|
|
15
16
|
throw new Error(`Maximum update depth exceeded`);
|
|
16
17
|
}
|
|
17
|
-
if (app.testMode && app.invalidatedComponents.
|
|
18
|
+
if (app.testMode && app.invalidatedComponents.isEmpty()) {
|
|
18
19
|
throw new Error(`Unnecessary react render`);
|
|
19
20
|
}
|
|
20
21
|
if (app.state === 'killed') {
|
|
@@ -23,10 +24,15 @@ export function reactRender(app, depth = 0) {
|
|
|
23
24
|
if (app.testMode)
|
|
24
25
|
validateApp(app);
|
|
25
26
|
app.state = 'render';
|
|
26
|
-
const
|
|
27
|
+
const actionsX = collectActionsFromApp(app);
|
|
28
|
+
if (actionsX instanceof ReactError) {
|
|
29
|
+
// Couldn't perform a subsequent render. No error boundary found or could
|
|
30
|
+
// manage this render error. Pass it through.
|
|
31
|
+
throw actionsX;
|
|
32
|
+
}
|
|
27
33
|
if (app.testMode)
|
|
28
34
|
validateApp(app);
|
|
29
|
-
applyActions(app,
|
|
35
|
+
applyActions(app, actionsX);
|
|
30
36
|
if (app.testMode)
|
|
31
37
|
validateApp(app);
|
|
32
38
|
postCommit(app, depth);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render.js","sourceRoot":"","sources":["../../../src/core/reconciliation/render.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"render.js","sourceRoot":"","sources":["../../../src/core/reconciliation/render.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAC1D,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC1C,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC9C,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEjD;;;;;;;GAOG;AACH,MAAM,UAAU,WAAW,CAAC,GAAQ,EAAE,KAAK,GAAG,CAAC,EAAE;IAC/C,IAAI,KAAK,GAAG,SAAS,EAAE,CAAC;QACtB,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;IACnD,CAAC;IAED,IAAI,GAAG,CAAC,QAAQ,IAAI,GAAG,CAAC,qBAAqB,CAAC,OAAO,EAAE,EAAE,CAAC;QACxD,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;IAC9C,CAAC;IAED,IAAI,GAAG,CAAC,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC3B,OAAO;IACT,CAAC;IAED,IAAI,GAAG,CAAC,QAAQ;QAAE,WAAW,CAAC,GAAG,CAAC,CAAC;IAEnC,GAAG,CAAC,KAAK,GAAG,QAAQ,CAAC;IACrB,MAAM,QAAQ,GAAG,qBAAqB,CAAC,GAAG,CAAC,CAAC;IAC5C,IAAI,QAAQ,YAAY,UAAU,EAAE,CAAC;QACnC,yEAAyE;QACzE,6CAA6C;QAC7C,MAAM,QAAQ,CAAC;IACjB,CAAC;IACD,IAAI,GAAG,CAAC,QAAQ;QAAE,WAAW,CAAC,GAAG,CAAC,CAAC;IAEnC,YAAY,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;IAC5B,IAAI,GAAG,CAAC,QAAQ;QAAE,WAAW,CAAC,GAAG,CAAC,CAAC;IAEnC,UAAU,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;AAAA,CACxB;AAED,MAAM,SAAS,GAAG,EAAE,CAAC,CAAC,iBAAiB"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { App, FiberNode } from '../../types';
|
|
2
|
+
import { ReactError } from './errors/ReactError';
|
|
3
|
+
import type { Action } from '../../types/actions';
|
|
2
4
|
/**
|
|
3
5
|
* By default we don't run all components. We run only those that were manually
|
|
4
6
|
* invalidated, as if they were all wrapped with `memo()`. So the `.children`
|
|
@@ -6,5 +8,5 @@ import type { App, FiberNode } from '../../types';
|
|
|
6
8
|
* given fiber DOM subtree nodes and runs all found components to fill their
|
|
7
9
|
* `.children`. Should be used only for not-yet-mounted component fiber nodes.
|
|
8
10
|
*/
|
|
9
|
-
export declare const runFiberComponents: (app: App, fiber: FiberNode) =>
|
|
11
|
+
export declare const runFiberComponents: (app: App, fiber: FiberNode) => Action[] | ReactError;
|
|
10
12
|
//# sourceMappingURL=runFiberComponents.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runFiberComponents.d.ts","sourceRoot":"","sources":["../../../src/core/reconciliation/runFiberComponents.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,SAAS,
|
|
1
|
+
{"version":3,"file":"runFiberComponents.d.ts","sourceRoot":"","sources":["../../../src/core/reconciliation/runFiberComponents.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,SAAS,EAAiB,MAAM,oBAAoB,CAAC;AAIxE,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAGzD;;;;;;GAMG;AACH,eAAO,MAAM,kBAAkB,uDAkD9B,CAAC"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { runComponent } from '../components';
|
|
2
2
|
import { jsxElementToFiberNode } from '../reactNodeToFiberNode';
|
|
3
|
-
import { FAKE_CONTAINER_TAG, toFiberChildren } from './fibers';
|
|
3
|
+
import { createFiberNode, FAKE_CONTAINER_TAG, toFiberChildren } from './fibers';
|
|
4
|
+
import { ReactError } from './errors/ReactError';
|
|
5
|
+
import { isErrorBoundary } from '../../hooks/useError';
|
|
4
6
|
/**
|
|
5
7
|
* By default we don't run all components. We run only those that were manually
|
|
6
8
|
* invalidated, as if they were all wrapped with `memo()`. So the `.children`
|
|
@@ -11,27 +13,53 @@ import { FAKE_CONTAINER_TAG, toFiberChildren } from './fibers';
|
|
|
11
13
|
export const runFiberComponents = (app, fiber) => {
|
|
12
14
|
if (app.testMode)
|
|
13
15
|
checkParents(fiber);
|
|
16
|
+
const actions = [];
|
|
14
17
|
switch (fiber.type) {
|
|
15
18
|
case 'fragment':
|
|
16
19
|
case 'tag':
|
|
17
20
|
for (const child of fiber.children) {
|
|
18
|
-
runFiberComponents(app, child);
|
|
21
|
+
const childActionsX = runFiberComponents(app, child);
|
|
22
|
+
// Tags & fragemtns can't be error boundaries. Pass it through.
|
|
23
|
+
if (childActionsX instanceof ReactError)
|
|
24
|
+
return childActionsX;
|
|
25
|
+
actions.push(...childActionsX);
|
|
19
26
|
}
|
|
20
27
|
break;
|
|
21
28
|
case 'component': {
|
|
22
|
-
const
|
|
23
|
-
|
|
29
|
+
const compX = runComponent(fiber, null);
|
|
30
|
+
// `fiber` can't be an error boundary for itself.
|
|
31
|
+
if (compX instanceof ReactError)
|
|
32
|
+
return compX;
|
|
33
|
+
const [newChildren, compActions] = compX;
|
|
34
|
+
let childrenX = jsxElementToFiberNode(newChildren, fiber, true /* run children-components recursively */);
|
|
35
|
+
if (childrenX instanceof ReactError) {
|
|
36
|
+
if (isErrorBoundary(fiber)) {
|
|
37
|
+
// `fiber` is not mounted yet, and it must have at least one child node.
|
|
38
|
+
const nullFiber = {
|
|
39
|
+
...createFiberNode(fiber),
|
|
40
|
+
type: 'null',
|
|
41
|
+
parent: fiber,
|
|
42
|
+
props: null,
|
|
43
|
+
};
|
|
44
|
+
childrenX = [nullFiber, [childrenX.genCatchAction()]];
|
|
45
|
+
}
|
|
46
|
+
else
|
|
47
|
+
return childrenX;
|
|
48
|
+
}
|
|
49
|
+
const [child, childrenActions] = childrenX;
|
|
24
50
|
fiber.children = toFiberChildren(child);
|
|
51
|
+
actions.push(...compActions, ...childrenActions);
|
|
25
52
|
break;
|
|
26
53
|
}
|
|
27
54
|
}
|
|
55
|
+
return actions;
|
|
28
56
|
};
|
|
29
57
|
const checkParents = (fiber) => {
|
|
30
58
|
let parent = fiber.parent;
|
|
31
59
|
while (parent && parent.tag !== FAKE_CONTAINER_TAG)
|
|
32
60
|
parent = parent.parent;
|
|
33
61
|
if (!parent) {
|
|
34
|
-
throw new
|
|
62
|
+
throw new ReactError(fiber, `runFiberComponents shouldn't be called for already mounted fiber nodes`);
|
|
35
63
|
}
|
|
36
64
|
};
|
|
37
65
|
//# sourceMappingURL=runFiberComponents.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"runFiberComponents.js","sourceRoot":"","sources":["../../../src/core/reconciliation/runFiberComponents.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"runFiberComponents.js","sourceRoot":"","sources":["../../../src/core/reconciliation/runFiberComponents.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,EAAE,qBAAqB,EAAE,MAAM,yBAAyB,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,kBAAkB,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAChF,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEjD,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAE9D;;;;;;GAMG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAChC,GAAQ,EACR,KAAgB,EACO,EAAE,CAAC;IAC1B,IAAI,GAAG,CAAC,QAAQ;QAAE,YAAY,CAAC,KAAK,CAAC,CAAC;IACtC,MAAM,OAAO,GAAa,EAAE,CAAC;IAE7B,QAAQ,KAAK,CAAC,IAAI,EAAE,CAAC;QACnB,KAAK,UAAU,CAAC;QAChB,KAAK,KAAK;YACR,KAAK,MAAM,KAAK,IAAI,KAAK,CAAC,QAAQ,EAAE,CAAC;gBACnC,MAAM,aAAa,GAAG,kBAAkB,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;gBACrD,+DAA+D;gBAC/D,IAAI,aAAa,YAAY,UAAU;oBAAE,OAAO,aAAa,CAAC;gBAC9D,OAAO,CAAC,IAAI,CAAC,GAAG,aAAa,CAAC,CAAC;YACjC,CAAC;YACD,MAAM;QAER,KAAK,WAAW,EAAE,CAAC;YACjB,MAAM,KAAK,GAAG,YAAY,CAAC,KAAK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AAAA,CACF,CAAC"}
|
|
@@ -13,6 +13,9 @@ export declare const isContextProvider: (node: ElementType | import("../../index
|
|
|
13
13
|
* Throws if not.
|
|
14
14
|
*/
|
|
15
15
|
export declare function assertsTagAttrValue(name: string, v: unknown): asserts v is TagAttrValue;
|
|
16
|
+
export declare const isSetHtml: (value: unknown) => value is {
|
|
17
|
+
__html: string;
|
|
18
|
+
};
|
|
16
19
|
/**
|
|
17
20
|
* Not used in the library, but it's a part of what React exports. Returns true
|
|
18
21
|
* if the given value is something that `createElement` returns.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typeGuards.d.ts","sourceRoot":"","sources":["../../../src/core/reconciliation/typeGuards.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,WAAW,EACX,SAAS,EAET,YAAY,EACb,MAAM,oBAAoB,CAAC;AAE5B;;GAEG;AACH,eAAO,MAAM,gBAAgB,+BAGP,CAAC;AAGvB,eAAO,MAAM,iBAAiB,4IAM7B,CAAC;AAEF;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,MAAM,EACZ,CAAC,EAAE,OAAO,GACT,OAAO,CAAC,CAAC,IAAI,YAAY,
|
|
1
|
+
{"version":3,"file":"typeGuards.d.ts","sourceRoot":"","sources":["../../../src/core/reconciliation/typeGuards.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,WAAW,EACX,WAAW,EACX,SAAS,EAET,YAAY,EACb,MAAM,oBAAoB,CAAC;AAE5B;;GAEG;AACH,eAAO,MAAM,gBAAgB,+BAGP,CAAC;AAGvB,eAAO,MAAM,iBAAiB,4IAM7B,CAAC;AAEF;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,MAAM,EACZ,CAAC,EAAE,OAAO,GACT,OAAO,CAAC,CAAC,IAAI,YAAY,CAqB3B;AAED,eAAO,MAAM,SAAS;;CASrB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,cAAc,0CAS1B,CAAC"}
|
|
@@ -26,6 +26,10 @@ export function assertsTagAttrValue(name, v) {
|
|
|
26
26
|
case 'function':
|
|
27
27
|
return;
|
|
28
28
|
case 'object':
|
|
29
|
+
if (name === 'dangerouslySetInnerHTML' && isSetHtml(v))
|
|
30
|
+
return;
|
|
31
|
+
if ((name === 'defaultValue' || name === 'value') && Array.isArray(v))
|
|
32
|
+
return; // <select multiple/>
|
|
29
33
|
if (v === null || name === 'style')
|
|
30
34
|
return;
|
|
31
35
|
case 'bigint':
|
|
@@ -33,6 +37,15 @@ export function assertsTagAttrValue(name, v) {
|
|
|
33
37
|
throw new Error(`Unsupported format of tag attribute value (${String(v)})`);
|
|
34
38
|
}
|
|
35
39
|
}
|
|
40
|
+
export const isSetHtml = (value) => {
|
|
41
|
+
let html = typeof value === 'object' &&
|
|
42
|
+
!!value &&
|
|
43
|
+
'__html' in value &&
|
|
44
|
+
typeof value.__html === 'string'
|
|
45
|
+
? { __html: value.__html }
|
|
46
|
+
: null;
|
|
47
|
+
return html !== null;
|
|
48
|
+
};
|
|
36
49
|
/**
|
|
37
50
|
* Not used in the library, but it's a part of what React exports. Returns true
|
|
38
51
|
* if the given value is something that `createElement` returns.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"typeGuards.js","sourceRoot":"","sources":["../../../src/core/reconciliation/typeGuards.ts"],"names":[],"mappings":"AAQA;;GAEG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,KAAgB,EAAW,EAAE,CAC5D,KAAK,CAAC,IAAI,KAAK,WAAW;IAC1B,KAAK,CAAC,IAAI,KAAK,UAAU;IACzB,KAAK,CAAC,IAAI,KAAK,KAAK,CAAC;AACvB,oCAAoC;AAEpC,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAC/B,IAA4C,EACV,EAAE,CAAC;IACrC,MAAM,GAAG,GACP,OAAO,IAAI,KAAK,QAAQ,IAAI,IAAI,IAAI,OAAO,IAAI,IAAI,CAAC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MAAM,cAAc,GAAG,CAAC,KAAc,EAAwB,EAAE,CAAC;IACtE,OAAO,CACL,OAAO,KAAK,KAAK,QAAQ;QACzB,CAAC,CAAC,KAAK;QACP,MAAM,IAAI,KAAK;QACf,OAAO,IAAI,KAAK;QAChB,KAAK,IAAI,KAAK;QACd,UAAU,IAAI,KAAK,CACpB,CAAC;AAAA,CACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validateApp.d.ts","sourceRoot":"","sources":["../../../src/core/reconciliation/validateApp.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"validateApp.d.ts","sourceRoot":"","sources":["../../../src/core/reconciliation/validateApp.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,GAAG,EAAkB,MAAM,oBAAoB,CAAC;AAS9D,eAAO,MAAM,WAAW,oBAYvB,CAAC"}
|
|
@@ -1,21 +1,15 @@
|
|
|
1
|
-
import { nullthrows } from '../../utils';
|
|
2
|
-
import { captureStack } from './errors/stack';
|
|
3
1
|
import { FAKE_CONTAINER_TAG } from './fibers';
|
|
2
|
+
import { nullthrowsForFiber, ReactError } from './errors/ReactError';
|
|
3
|
+
import { isEmptyContainer, isSingleChildContainer, isAutoContainer, } from '../compact';
|
|
4
4
|
export const validateApp = (app) => {
|
|
5
|
-
|
|
5
|
+
app.invalidatedComponents.traverse((fiber) => {
|
|
6
6
|
if (!fiber.parent) {
|
|
7
|
-
throw new
|
|
7
|
+
throw new ReactError(fiber, 'Orphan component invalidated');
|
|
8
8
|
}
|
|
9
9
|
if (fiber.parent.tag === FAKE_CONTAINER_TAG) {
|
|
10
|
-
|
|
11
|
-
e.message +=
|
|
12
|
-
'\n' +
|
|
13
|
-
captureStack(fiber)
|
|
14
|
-
.map((s, i) => `\t${i + 1}: ${s}`)
|
|
15
|
-
.join('\n');
|
|
16
|
-
throw e;
|
|
10
|
+
throw new ReactError(fiber, `Cannot invalidate not-mounted fiber node`);
|
|
17
11
|
}
|
|
18
|
-
}
|
|
12
|
+
});
|
|
19
13
|
validateTree(app.root);
|
|
20
14
|
};
|
|
21
15
|
/**
|
|
@@ -23,30 +17,43 @@ export const validateApp = (app) => {
|
|
|
23
17
|
*/
|
|
24
18
|
const validateTree = (node, path = '') => {
|
|
25
19
|
// Each rendered node must be associated with at least one real DOM node.
|
|
26
|
-
|
|
20
|
+
nullthrowsForFiber(node, node.element, `${path}.element`);
|
|
27
21
|
if (node.type === 'tag') {
|
|
28
22
|
if (!node.tag) {
|
|
29
|
-
throw new
|
|
23
|
+
throw new ReactError(node, `${path} has empty "tag" field `);
|
|
30
24
|
}
|
|
31
25
|
const domNode = node.role === 'portal' ? node.data : node.element;
|
|
32
26
|
if (!(domNode instanceof Element)) {
|
|
33
|
-
throw new
|
|
27
|
+
throw new ReactError(node, `${path} doesn't have element`);
|
|
34
28
|
}
|
|
35
29
|
}
|
|
36
|
-
else if (node.type === 'component'
|
|
37
|
-
|
|
30
|
+
else if (node.type === 'component') {
|
|
31
|
+
if (!node.component) {
|
|
32
|
+
throw new ReactError(node, `${path} has empty "component" field `);
|
|
33
|
+
}
|
|
34
|
+
if (isAutoContainer(node) && node.children.length < 2) {
|
|
35
|
+
if (!node.children[0] || !isAutoContainer(node.children[0])) {
|
|
36
|
+
throw new ReactError(node, `Fiber containers must have more than 1 child.`);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
else if (isEmptyContainer(node) && node.children.length !== 0) {
|
|
40
|
+
throw new ReactError(node, `Empty fiber containers must have 0 children.`);
|
|
41
|
+
}
|
|
42
|
+
else if (isSingleChildContainer(node) && node.children.length !== 1) {
|
|
43
|
+
throw new ReactError(node, `Single-child fibers must have exactly 1 child.`);
|
|
44
|
+
}
|
|
38
45
|
}
|
|
39
46
|
else if (node.role === 'context' && !node.data.ctx) {
|
|
40
|
-
throw new
|
|
47
|
+
throw new ReactError(node, `${path} has no context`);
|
|
41
48
|
}
|
|
42
49
|
else if (node.type === 'text' && !(node.element instanceof Text)) {
|
|
43
|
-
throw new
|
|
50
|
+
throw new ReactError(node, `${path}'s element is not a Text`);
|
|
44
51
|
}
|
|
45
52
|
for (const [idx, child] of node.children.entries()) {
|
|
46
53
|
const label = getFiberPathLabel(child);
|
|
47
54
|
const key = (child.key ?? idx) + `^${label}`;
|
|
48
55
|
if (child.parent !== node) {
|
|
49
|
-
throw new
|
|
56
|
+
throw new ReactError(child, `${path}.${key}.parent is ${child.parent ? 'wrong' : 'empty'}`);
|
|
50
57
|
}
|
|
51
58
|
validateTree(child, `${path}.${key}`);
|
|
52
59
|
}
|
|
@@ -55,7 +62,7 @@ const getFiberPathLabel = (node) => {
|
|
|
55
62
|
return node.type === 'text' || node.type === 'null'
|
|
56
63
|
? node.type
|
|
57
64
|
: node.type === 'tag'
|
|
58
|
-
? `<${
|
|
65
|
+
? `<${nullthrowsForFiber(node, node.tag)}/>`
|
|
59
66
|
: node.type === 'fragment'
|
|
60
67
|
? node.role === 'context'
|
|
61
68
|
? '<ctx/>'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validateApp.js","sourceRoot":"","sources":["../../../src/core/reconciliation/validateApp.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"validateApp.js","sourceRoot":"","sources":["../../../src/core/reconciliation/validateApp.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAC9C,OAAO,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACrE,OAAO,EACL,gBAAgB,EAChB,sBAAsB,EACtB,eAAe,GAChB,MAAM,YAAY,CAAC;AAEpB,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,GAAQ,EAAQ,EAAE,CAAC;IAC7C,GAAG,CAAC,qBAAqB,CAAC,QAAQ,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC;QAC5C,IAAI,CAAC,KAAK,CAAC,MAAM,EAAE,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G,IAAI,KAAK,EAAE,CAAC;QAC7C,IAAI,KAAK,CAAC,MAAM,KAAK,IAAI,EAAE,CAAC;YAC1B,MAAM,IAAI,UAAU,CAClB,KAAK,EACL,GAAG,IAAI,IAAI,GAAG,cAAc,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,EAAE,CAC/D,CAAC;QACJ,CAAC;QACD,YAAY,CAAC,KAAK,EAAE,GAAG,IAAI,IAAI,GAAG,EAAE,CAAC,CAAC;IACxC,CAAC;AAAA,CACF,CAAC;AAEF,MAAM,iBAAiB,GAAG,CAAC,IAAe,EAAU,EAAE,CAAC;IACrD,OAAO,IAAI,CAAC,IAAI,KAAK,MAAM,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM;QACjD,CAAC,CAAC,IAAI,CAAC,IAAI;QACX,CAAC,CAAC,IAAI,CAAC,IAAI,KAAK,KAAK;YACnB,CAAC,CAAC,IAAI,kBAAkB,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,IAAI;YAC5C,CAAC,CAAC,IAAI,CAAC,IAAI,KAAK,UAAU;gBACxB,CAAC,CAAC,IAAI,CAAC,IAAI,KAAK,SAAS;oBACvB,CAAC,CAAC,QAAQ;oBACV,CAAC,CAAC,IAAI;gBACR,CAAC,CAAC,IAAI,CAAC,IAAI,KAAK,WAAW;oBACzB,CAAC,CAAC,IAAI,IAAI,CAAC,SAAU,CAAC,IAAI,IAAI,MAAM,IAAI;oBACxC,CAAC,CAAC,SAAS,CAAC;AAAA,CACrB,CAAC"}
|
package/dist/hooks/helpers.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type HookDeps, type ComponentFiberNode } from '../types';
|
|
2
2
|
/**
|
|
3
3
|
* We could save the given deps as is, but this version allows to avoid memory
|
|
4
4
|
* leaks by means of using WeakRefs for object-based dependencies.
|
|
@@ -14,6 +14,6 @@ export declare const checkDeps: (saved: unknown[], deps: unknown[]) => boolean;
|
|
|
14
14
|
* create the initial hook state during the 1st render.
|
|
15
15
|
*/
|
|
16
16
|
export declare const getNextHookOrCreate: <T extends {
|
|
17
|
-
type: "context" | "effect" | "memo" | "ref" | "state";
|
|
18
|
-
}>(type: "context" | "effect" | "memo" | "ref" | "state", fn: (fiber:
|
|
17
|
+
type: "context" | "effect" | "error" | "memo" | "ref" | "state";
|
|
18
|
+
}>(type: "context" | "effect" | "error" | "memo" | "ref" | "state", fn: (fiber: ComponentFiberNode) => T) => T;
|
|
19
19
|
//# sourceMappingURL=helpers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/hooks/helpers.ts"],"names":[],"mappings":"AAMA,OAAO,
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../src/hooks/helpers.ts"],"names":[],"mappings":"AAMA,OAAO,EAEL,KAAK,QAAQ,EACb,KAAK,kBAAkB,EACxB,MAAM,UAAU,CAAC;AAGlB;;;GAGG;AACH,eAAO,MAAM,QAAQ,+BAIpB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,SAAS,gDASrB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,mBAAmB,GAAI,CAAC;;8GA0BpC,CAAC"}
|
package/dist/hooks/helpers.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { getCurrentComponentFiber, getNextFiberState, isFirstFiberRender, registerStateItem, } from '../core/components';
|
|
2
|
+
import { ReactError } from '../core/reconciliation/errors/ReactError';
|
|
2
3
|
/**
|
|
3
4
|
* We could save the given deps as is, but this version allows to avoid memory
|
|
4
5
|
* leaks by means of using WeakRefs for object-based dependencies.
|
|
@@ -24,7 +25,7 @@ export const getNextHookOrCreate = (type, fn) => {
|
|
|
24
25
|
const firstRender = isFirstFiberRender();
|
|
25
26
|
const fiber = getCurrentComponentFiber();
|
|
26
27
|
if (!Array.isArray(fiber.data.hooks)) {
|
|
27
|
-
throw new
|
|
28
|
+
throw new ReactError(fiber, `Hooks cannot be used outside of components`);
|
|
28
29
|
}
|
|
29
30
|
if (firstRender) {
|
|
30
31
|
const item = fn(fiber);
|
|
@@ -33,7 +34,7 @@ export const getNextHookOrCreate = (type, fn) => {
|
|
|
33
34
|
}
|
|
34
35
|
const item = firstRender ? fiber.data.hooks.at(-1) : getNextFiberState();
|
|
35
36
|
if (item.type !== type) {
|
|
36
|
-
throw new
|
|
37
|
+
throw new ReactError(fiber, `The hook order is violated. Expected: ${type}, got: ${item.type}`);
|
|
37
38
|
}
|
|
38
39
|
return item;
|
|
39
40
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/hooks/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,EACxB,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/hooks/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,EACxB,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,GAClB,MAAM,mBAAmB,CAAC;AAM3B,OAAO,EAAE,UAAU,EAAE,MAAM,oDAAoD,CAAC;AAEhF;;;GAGG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,IAAe,EAAY,EAAE,CAAC;IACrD,OAAO,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CACtB,OAAO,GAAG,KAAK,QAAQ,IAAI,GAAG,CAAC,CAAC,CAAC,IAAI,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CACxD,CAAC;AAAA,CACH,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,KAAgB,EAAE,IAAe,EAAW,EAAE,CAAC;IACvE,OAAO,CACL,KAAK,CAAC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-4,6 +4,7 @@ export { useEffect, useLayoutEffect } from './useEffect';
|
|
|
4
4
|
export { useStableCallback } from './useStableCallback';
|
|
5
5
|
export { useId } from './useId';
|
|
6
6
|
export { useMemo } from './useMemo';
|
|
7
|
-
export { useRef } from './useRef';
|
|
7
|
+
export { useRef, forwardRef } from './useRef';
|
|
8
8
|
export { useState } from './useState';
|
|
9
|
+
export { useError } from './useError';
|
|
9
10
|
//# sourceMappingURL=index.d.ts.map
|