@faiwer/react 0.9.0 → 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 +28 -9
- package/dist/core/actions/applyAction.d.ts.map +1 -1
- package/dist/core/actions/applyAction.js +4 -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/dom/value.d.ts +3 -2
- package/dist/core/actions/dom/value.d.ts.map +1 -1
- package/dist/core/actions/dom/value.js +20 -13
- package/dist/core/actions/dom/value.js.map +1 -1
- package/dist/core/actions/helpers.d.ts.map +1 -1
- package/dist/core/actions/helpers.js +1 -2
- package/dist/core/actions/helpers.js.map +1 -1
- package/dist/core/actions/remove.action.d.ts.map +1 -1
- package/dist/core/actions/remove.action.js +2 -3
- package/dist/core/actions/remove.action.js.map +1 -1
- package/dist/core/actions/replace.action.d.ts.map +1 -1
- package/dist/core/actions/replace.action.js +4 -0
- 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.map +1 -1
- package/dist/core/actions/setAttr.action.js +2 -3
- package/dist/core/actions/setAttr.action.js.map +1 -1
- package/dist/core/actions/setRef.action.d.ts.map +1 -1
- package/dist/core/actions/setRef.action.js +1 -2
- package/dist/core/actions/setRef.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 +17 -10
- package/dist/core/classComponent.js.map +1 -1
- package/dist/core/components.d.ts +5 -3
- package/dist/core/components.d.ts.map +1 -1
- package/dist/core/components.js +8 -3
- package/dist/core/components.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 +74 -16
- package/dist/core/reactNodeToFiberNode.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 +6 -1
- 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 +26 -4
- package/dist/core/reconciliation/collect/fromChildrenPair.js.map +1 -1
- package/dist/core/reconciliation/collect/fromComponent.d.ts +2 -1
- package/dist/core/reconciliation/collect/fromComponent.d.ts.map +1 -1
- package/dist/core/reconciliation/collect/fromComponent.js +25 -3
- 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 +6 -1
- package/dist/core/reconciliation/collect/fromFiberPair.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 +8 -0
- package/dist/core/reconciliation/errors/ReactError.d.ts.map +1 -1
- package/dist/core/reconciliation/errors/ReactError.js +30 -0
- package/dist/core/reconciliation/errors/ReactError.js.map +1 -1
- package/dist/core/reconciliation/errors/stack.d.ts +1 -1
- package/dist/core/reconciliation/errors/stack.d.ts.map +1 -1
- package/dist/core/reconciliation/errors/stack.js +3 -3
- package/dist/core/reconciliation/errors/stack.js.map +1 -1
- package/dist/core/reconciliation/mount.d.ts.map +1 -1
- package/dist/core/reconciliation/mount.js +10 -2
- package/dist/core/reconciliation/mount.js.map +1 -1
- package/dist/core/reconciliation/render.d.ts.map +1 -1
- package/dist/core/reconciliation/render.js +8 -2
- 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 +31 -4
- package/dist/core/reconciliation/runFiberComponents.js.map +1 -1
- package/dist/hooks/helpers.d.ts +2 -2
- package/dist/hooks/helpers.d.ts.map +1 -1
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +1 -0
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/useEffect.d.ts.map +1 -1
- package/dist/hooks/useEffect.js +20 -6
- 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/useState.d.ts.map +1 -1
- package/dist/hooks/useState.js +0 -1
- package/dist/hooks/useState.js.map +1 -1
- package/dist/types/actions.d.ts +12 -1
- package/dist/types/actions.d.ts.map +1 -1
- package/dist/types/app.d.ts +5 -1
- package/dist/types/app.d.ts.map +1 -1
- package/dist/types/component.d.ts +6 -0
- package/dist/types/component.d.ts.map +1 -1
- package/dist/types/fiber.d.ts +1 -1
- package/dist/types/fiber.d.ts.map +1 -1
- package/dist/types/hooks.d.ts +12 -2
- package/dist/types/hooks.d.ts.map +1 -1
- package/dist/types/react.d.ts +0 -4
- package/dist/types/react.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { useContext, useEffect, useLayoutEffect, useMemo, useRef, useState, } from '../hooks';
|
|
2
2
|
import { getCurrentComponentFiber } from './components';
|
|
3
3
|
import { ReactError } from './reconciliation/errors/ReactError';
|
|
4
|
+
import { useError } from '../hooks/useError';
|
|
4
5
|
export const isComponentClass = (value) => {
|
|
5
6
|
return (value != null &&
|
|
6
7
|
typeof value === 'function' &&
|
|
@@ -18,6 +19,8 @@ export class Component {
|
|
|
18
19
|
context;
|
|
19
20
|
static defaultProps;
|
|
20
21
|
static contextType;
|
|
22
|
+
static getDerivedStateFromError;
|
|
23
|
+
static getDerivedStateFromProps;
|
|
21
24
|
constructor(props) {
|
|
22
25
|
this.props = props;
|
|
23
26
|
}
|
|
@@ -39,16 +42,12 @@ export class Component {
|
|
|
39
42
|
render() {
|
|
40
43
|
throw new ReactError(getCurrentComponentFiber(), `Render method must be overridden`);
|
|
41
44
|
}
|
|
42
|
-
componentDidCatch(_error, _info) {
|
|
43
|
-
throw new ReactError(getCurrentComponentFiber(), `Not implemented`);
|
|
44
|
-
}
|
|
45
|
+
componentDidCatch(_error, _info) { }
|
|
45
46
|
getSnapshotBeforeUpdate(_prevProps, _prevState) {
|
|
46
47
|
throw new ReactError(getCurrentComponentFiber(), `Not implemented`);
|
|
47
48
|
}
|
|
48
|
-
static getDerivedStateFromProps(_props, _state) {
|
|
49
|
-
return {};
|
|
50
|
-
}
|
|
51
49
|
}
|
|
50
|
+
const ComponentPrototype = Component.prototype;
|
|
52
51
|
/**
|
|
53
52
|
* Since we're running `convertClassComponentToFC` for the same component each
|
|
54
53
|
* time its JSX.Element was created we need to cache the output wrapper
|
|
@@ -64,11 +63,10 @@ export const convertClassComponentToFC = (Component) => {
|
|
|
64
63
|
if (cache.has(Component)) {
|
|
65
64
|
return cache.get(Component);
|
|
66
65
|
}
|
|
67
|
-
let { defaultProps, contextType, getDerivedStateFromProps } = Component;
|
|
68
|
-
if (getDerivedStateFromProps === Component.prototype.getDerivedStateFromProps) {
|
|
69
|
-
getDerivedStateFromProps = undefined;
|
|
70
|
-
}
|
|
66
|
+
let { defaultProps, contextType, getDerivedStateFromProps, getDerivedStateFromError, } = Component;
|
|
71
67
|
function FromClassComponent(props) {
|
|
68
|
+
// Use the component class name as the component name to simplify debugging.
|
|
69
|
+
FromClassComponent.displayName = Component.name;
|
|
72
70
|
const { current: ref } = useRef({
|
|
73
71
|
mounted: false,
|
|
74
72
|
rendered: 0,
|
|
@@ -115,6 +113,15 @@ export const convertClassComponentToFC = (Component) => {
|
|
|
115
113
|
...props,
|
|
116
114
|
};
|
|
117
115
|
instance.state = state;
|
|
116
|
+
if (instance.componentDidCatch !== ComponentPrototype.componentDidCatch ||
|
|
117
|
+
getDerivedStateFromError) {
|
|
118
|
+
useError((error, info) => {
|
|
119
|
+
instance.componentDidCatch(error, info);
|
|
120
|
+
if (getDerivedStateFromError) {
|
|
121
|
+
setState(getDerivedStateFromError(error));
|
|
122
|
+
}
|
|
123
|
+
});
|
|
124
|
+
}
|
|
118
125
|
if (!ref.mounted || instance.shouldComponentUpdate(props, instance.state)) {
|
|
119
126
|
ref.prevOutput = instance.render();
|
|
120
127
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"classComponent.js","sourceRoot":"","sources":["../../src/core/classComponent.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,SAAS,EACT,eAAe,EACf,OAAO,EACP,MAAM,EACN,QAAQ,GACT,MAAM,oBAAoB,CAAC;AAM5B,OAAO,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;
|
|
1
|
+
{"version":3,"file":"classComponent.js","sourceRoot":"","sources":["../../src/core/classComponent.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,SAAS,EACT,eAAe,EACf,OAAO,EACP,MAAM,EACN,QAAQ,GACT,MAA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YAChB,QAAQ,CAAC,OAAO,GAAG,UAAU,CAAC,WAAW,CAAC,CAAC;QAC7C,CAAC;QAED,QAAQ,CAAC,KAAK,GAAG;YACf,GAAG,YAAY;YACf,GAAG,KAAK;SACT,CAAC;QACF,QAAQ,CAAC,KAAK,GAAG,KAAK,CAAC;QAEvB,IACE,QAAQ,CAAC,iBAAiB,KAAK,kBAAkB,CAAC,iBAAiB;YACnE,wBAAwB,EACxB,CAAC;YACD,QAAQ,CAAC,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC;gBACxB,QAAQ,CAAC,iBAAiB,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;gBACxC,IAAI,wBAAwB,EAAE,CAAC;oBAC7B,QAAQ,CAAC,wBAAwB,CAAC,KAAK,CAAC,CAAC,CAAC;gBAC5C,CAAC;YAAA,CACF,CAAC,CAAC;QACL,CAAC;QAED,IAAI,CAAC,GAAG,CAAC,OAAO,IAAI,QAAQ,CAAC,qBAAqB,CAAC,KAAK,EAAE,QAAQ,CAAC,KAAK,CAAC,EAAE,CAAC;YAC1E,GAAG,CAAC,UAAU,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC;QACrC,CAAC;QAED,EAAE,GAAG,CAAC,QAAQ,CAAC;QACf,OAAO,GAAG,CAAC,UAAU,CAAC;IAAA,CACvB;IAED,KAAK,CAAC,GAAG,CAAC,SAAS,EAAE,kBAAyB,CAAC,CAAC;IAChD,OAAO,kBAAkB,CAAC;AAAA,CAC3B,CAAC"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { type HookStateItem, type FiberNode, type App, type ComponentFiberNode, type UnknownProps } from '../types';
|
|
2
|
+
import { ReactError } from './reconciliation/errors/ReactError';
|
|
3
|
+
import type { Action } from '../types/actions';
|
|
2
4
|
/**
|
|
3
5
|
* Returns the fiber of the component that is being rendered right now. Don't
|
|
4
6
|
* run this function outside of the render phase.
|
|
@@ -16,9 +18,9 @@ export declare const isFirstFiberRender: () => boolean;
|
|
|
16
18
|
/**
|
|
17
19
|
* Runs the functional component. Before running, it prepares everything that
|
|
18
20
|
* is required to make hooks work. The result is JSX returned from the component
|
|
19
|
-
* function.
|
|
21
|
+
* function & the list of actions that must be applied in the commit phase.
|
|
20
22
|
*/
|
|
21
|
-
export declare const runComponent: (fiber: FiberNode, props: UnknownProps | null) => import("../index.js").JsxElement;
|
|
23
|
+
export declare const runComponent: (fiber: FiberNode, props: UnknownProps | null) => ReactError | [import("../index.js").JsxElement, Action[]];
|
|
22
24
|
/**
|
|
23
25
|
* Switches to the next hook and returns its state.
|
|
24
26
|
*/
|
|
@@ -27,6 +29,6 @@ export declare const getNextFiberState: () => HookStateItem;
|
|
|
27
29
|
* Adds a new item to the current component's hook store
|
|
28
30
|
*/
|
|
29
31
|
export declare const registerStateItem: (item: {
|
|
30
|
-
type: "context" | "effect" | "memo" | "ref" | "state";
|
|
32
|
+
type: "context" | "effect" | "error" | "memo" | "ref" | "state";
|
|
31
33
|
}) => void;
|
|
32
34
|
//# sourceMappingURL=components.d.ts.map
|
|
@@ -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,EACvB,KAAK,YAAY,EAClB,MAAM,UAAU,CAAC;
|
|
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;AAGlB,OAAO,EAEL,UAAU,EACX,MAAM,oCAAoC,CAAC;AAC5C,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAKzD;;;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,8GA2CxB,CAAC;AAYF;;GAEG;AACH,eAAO,MAAM,iBAAiB,qBACgC,CAAC;AAE/D;;GAEG;AACH,eAAO,MAAM,iBAAiB;;UAI7B,CAAC"}
|
package/dist/core/components.js
CHANGED
|
@@ -25,7 +25,7 @@ export const isFirstFiberRender = () => firstFiberRender;
|
|
|
25
25
|
/**
|
|
26
26
|
* Runs the functional component. Before running, it prepares everything that
|
|
27
27
|
* is required to make hooks work. The result is JSX returned from the component
|
|
28
|
-
* function.
|
|
28
|
+
* function & the list of actions that must be applied in the commit phase.
|
|
29
29
|
*/
|
|
30
30
|
export const runComponent = (fiber,
|
|
31
31
|
/** Source of `.props`. If not given `fiber.props` are used. */
|
|
@@ -41,18 +41,23 @@ props) => {
|
|
|
41
41
|
fiber.data.hooks ??= [];
|
|
42
42
|
hookIdx = -1;
|
|
43
43
|
let jsxElement;
|
|
44
|
+
let actions = [];
|
|
44
45
|
try {
|
|
45
46
|
jsxElement = fiber.component(props ?? fiber.props);
|
|
47
|
+
actions.push(...fiber.data.actions);
|
|
46
48
|
}
|
|
47
49
|
catch (error) {
|
|
48
|
-
|
|
50
|
+
return new ReactError(fiber, error, `Error during rendering a component: %fiber%`);
|
|
51
|
+
}
|
|
52
|
+
finally {
|
|
53
|
+
fiber.data.actions = [];
|
|
49
54
|
}
|
|
50
55
|
if (!firstFiberRender && hookIdx !== fiber.data.hooks.length - 1) {
|
|
51
56
|
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
57
|
}
|
|
53
58
|
currentFiber = null;
|
|
54
59
|
firstFiberRender = false;
|
|
55
|
-
return jsxElement;
|
|
60
|
+
return [jsxElement, actions];
|
|
56
61
|
};
|
|
57
62
|
let hookIdx = -1;
|
|
58
63
|
const getComponentHookStore = (fiberNode) => {
|
|
@@ -1 +1 @@
|
|
|
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;
|
|
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;AAG5C,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,aAAa,CAAC,KAAK,CAAC,CAAC,CAAC;AAAA,CACxD,CAAC;AAEF,IAAI,gBAAgB,GAAG,KAAK,CAAC;AAE7B;;GAEG;AACH,MAAM,CAAC,MAAM,kBAAkB,GAAG,GAAY,EAAE,CAAC,gBAAgB,CAAC;AAElE;;;;GAIG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAC1B,KAAgB;AAChB,+DAA+D;AAC/D,KAA0B,EACY,EAAE,CAAC;IAC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OAAO,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;AAAA,CAC9B,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,8 +1,10 @@
|
|
|
1
|
+
import type { Action } from '../types/actions';
|
|
1
2
|
import { type FiberNode } from '../types';
|
|
3
|
+
import { ReactError } from './reconciliation/errors/ReactError';
|
|
2
4
|
/**
|
|
3
5
|
* Converts any possible JSX.Element to a FiberNode, that is used by the engine
|
|
4
6
|
* everywhere. We don't use JSX.Elements outside of this function.
|
|
5
7
|
* <div/> -> FiberNode.
|
|
6
8
|
*/
|
|
7
|
-
export declare const jsxElementToFiberNode: (jsxElement: import("../index.js").JsxElement, parent: FiberNode, unwrapComponents: boolean) => FiberNode;
|
|
9
|
+
export declare const jsxElementToFiberNode: (jsxElement: import("../index.js").JsxElement, parent: FiberNode, unwrapComponents: boolean) => ReactError | [FiberNode, Action[]];
|
|
8
10
|
//# sourceMappingURL=reactNodeToFiberNode.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reactNodeToFiberNode.d.ts","sourceRoot":"","sources":["../../src/core/reactNodeToFiberNode.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,SAAS,EAUf,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"reactNodeToFiberNode.d.ts","sourceRoot":"","sources":["../../src/core/reactNodeToFiberNode.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AACzD,OAAO,EAGL,KAAK,SAAS,EAUf,MAAM,UAAU,CAAC;AAQlB,OAAO,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;AAGhE;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,qIAuLjC,CAAC"}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { runComponent } from './components';
|
|
2
2
|
import { createFiberNode, FRAGMENT_TAG, toFiberChildren, } from './reconciliation/fibers';
|
|
3
3
|
import { isContextProvider } from './reconciliation/typeGuards';
|
|
4
|
+
import { ReactError } from './reconciliation/errors/ReactError';
|
|
5
|
+
import { isErrorBoundary } from '../hooks/useError';
|
|
4
6
|
/**
|
|
5
7
|
* Converts any possible JSX.Element to a FiberNode, that is used by the engine
|
|
6
8
|
* everywhere. We don't use JSX.Elements outside of this function.
|
|
@@ -30,7 +32,7 @@ unwrapComponents) => {
|
|
|
30
32
|
parent,
|
|
31
33
|
props: null,
|
|
32
34
|
};
|
|
33
|
-
return nullFiber;
|
|
35
|
+
return [nullFiber, NO_ACTIONS];
|
|
34
36
|
}
|
|
35
37
|
// A text node (string, number or boolean).
|
|
36
38
|
if (typeof jsxElement !== 'object') {
|
|
@@ -40,7 +42,7 @@ unwrapComponents) => {
|
|
|
40
42
|
parent,
|
|
41
43
|
props: { text: String(jsxElement) },
|
|
42
44
|
};
|
|
43
|
-
return textFiber;
|
|
45
|
+
return [textFiber, NO_ACTIONS];
|
|
44
46
|
}
|
|
45
47
|
const { key = null } = jsxElement;
|
|
46
48
|
const { ref = null, ...props } = jsxElement.props;
|
|
@@ -54,8 +56,13 @@ unwrapComponents) => {
|
|
|
54
56
|
role: 'portal',
|
|
55
57
|
data: jsxElement.type,
|
|
56
58
|
};
|
|
57
|
-
|
|
58
|
-
|
|
59
|
+
const childrenX = childrenToNodes(portalFiber, jsxElement.children, unwrapComponents);
|
|
60
|
+
// Portals cannot be error boundaries. Pass through.
|
|
61
|
+
if (childrenX instanceof ReactError)
|
|
62
|
+
return childrenX;
|
|
63
|
+
const [children, childrenActions] = childrenX;
|
|
64
|
+
portalFiber.children = children;
|
|
65
|
+
return [portalFiber, childrenActions];
|
|
59
66
|
}
|
|
60
67
|
// <ctx.Provider value=?/>
|
|
61
68
|
if (isContextProvider(jsxElement.type)) {
|
|
@@ -69,8 +76,13 @@ unwrapComponents) => {
|
|
|
69
76
|
data: { ctx: jsxElement.type.__ctx, consumers: new Set() },
|
|
70
77
|
source: jsxElement.source,
|
|
71
78
|
};
|
|
72
|
-
|
|
73
|
-
|
|
79
|
+
const childrenX = childrenToNodes(contextFiber, jsxElement.children, unwrapComponents);
|
|
80
|
+
// Context providers cannot be error boundaries. Pass through.
|
|
81
|
+
if (childrenX instanceof ReactError)
|
|
82
|
+
return childrenX;
|
|
83
|
+
const [children, childrenActions] = childrenX;
|
|
84
|
+
contextFiber.children = children;
|
|
85
|
+
return [contextFiber, childrenActions];
|
|
74
86
|
}
|
|
75
87
|
// [], </> or <Fragment/>.
|
|
76
88
|
if (jsxElement.type === FRAGMENT_TAG) {
|
|
@@ -80,26 +92,54 @@ unwrapComponents) => {
|
|
|
80
92
|
key,
|
|
81
93
|
source: jsxElement.source,
|
|
82
94
|
};
|
|
83
|
-
|
|
84
|
-
|
|
95
|
+
const childrenX = childrenToNodes(fragmentFiber, jsxElement.children, unwrapComponents);
|
|
96
|
+
// Fragments cannot be error boundaries. Pass through.
|
|
97
|
+
if (childrenX instanceof ReactError)
|
|
98
|
+
return childrenX;
|
|
99
|
+
const [children, childrenActions] = childrenX;
|
|
100
|
+
fragmentFiber.children = children;
|
|
101
|
+
return [fragmentFiber, childrenActions];
|
|
85
102
|
}
|
|
86
103
|
// A component node (<Message/>):
|
|
87
104
|
if (typeof jsxElement.type === 'function') {
|
|
105
|
+
const actions = [];
|
|
88
106
|
const fiber = {
|
|
89
107
|
...createFiberNode(parent),
|
|
90
108
|
type: 'component',
|
|
91
109
|
component: jsxElement.type,
|
|
92
110
|
key,
|
|
93
111
|
props: jsxElement.props,
|
|
94
|
-
data: { hooks: null },
|
|
112
|
+
data: { hooks: null, actions: [], isErrorBoundary: false },
|
|
95
113
|
source: jsxElement.source,
|
|
96
114
|
};
|
|
97
115
|
if (unwrapComponents) {
|
|
98
|
-
const
|
|
99
|
-
|
|
116
|
+
const compX = runComponent(fiber, null);
|
|
117
|
+
// Component can't be its own error boundary, thus pass it through.
|
|
118
|
+
if (compX instanceof ReactError)
|
|
119
|
+
return compX;
|
|
120
|
+
const [content, compActions] = compX;
|
|
121
|
+
let childrenX = jsxElementToFiberNode(content, fiber, unwrapComponents);
|
|
122
|
+
if (childrenX instanceof ReactError) {
|
|
123
|
+
if (isErrorBoundary(fiber)) {
|
|
124
|
+
// Since it's a brand new fiber we don't have any DOM nodes yet. But
|
|
125
|
+
// it must have one. Create a new null nodes to make it an anchor for
|
|
126
|
+
// the error boundary.
|
|
127
|
+
const nullFiber = {
|
|
128
|
+
...createFiberNode(fiber),
|
|
129
|
+
type: 'null',
|
|
130
|
+
parent: fiber,
|
|
131
|
+
props: null,
|
|
132
|
+
};
|
|
133
|
+
childrenX = [nullFiber, [childrenX.genCatchAction()]];
|
|
134
|
+
}
|
|
135
|
+
else
|
|
136
|
+
return childrenX;
|
|
137
|
+
}
|
|
138
|
+
const [child, childrenActions] = childrenX;
|
|
100
139
|
fiber.children = toFiberChildren(child);
|
|
140
|
+
actions.push(...compActions, ...childrenActions);
|
|
101
141
|
}
|
|
102
|
-
return fiber;
|
|
142
|
+
return [fiber, actions];
|
|
103
143
|
}
|
|
104
144
|
if (typeof jsxElement.type === 'string') {
|
|
105
145
|
validateRef(ref);
|
|
@@ -113,13 +153,30 @@ unwrapComponents) => {
|
|
|
113
153
|
data: { events: {}, styles: null },
|
|
114
154
|
source: jsxElement.source,
|
|
115
155
|
};
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
156
|
+
const childrenX = childrenToNodes(tagFiber, jsxElement.children, unwrapComponents);
|
|
157
|
+
// Tags cannot be error boundaries. Pass through.
|
|
158
|
+
if (childrenX instanceof ReactError)
|
|
159
|
+
return childrenX;
|
|
160
|
+
const [children, childrenActions] = childrenX;
|
|
161
|
+
tagFiber.children = children;
|
|
162
|
+
return [tagFiber, childrenActions];
|
|
120
163
|
}
|
|
121
164
|
throw new Error(`Unknown format of JSX.Element (${jsxElement.type})`);
|
|
122
165
|
};
|
|
166
|
+
const childrenToNodes = (fiber, elements, unwrapComponents) => {
|
|
167
|
+
const children = [];
|
|
168
|
+
const actions = [];
|
|
169
|
+
for (const childEl of elements) {
|
|
170
|
+
const childX = jsxElementToFiberNode(childEl, fiber, unwrapComponents);
|
|
171
|
+
// `fiber` can't be a component here, thus it can't be an error boundary.
|
|
172
|
+
if (childX instanceof ReactError)
|
|
173
|
+
return childX;
|
|
174
|
+
const [node, childrenActions] = childX;
|
|
175
|
+
children.push(node);
|
|
176
|
+
actions.push(...childrenActions);
|
|
177
|
+
}
|
|
178
|
+
return [children, actions];
|
|
179
|
+
};
|
|
123
180
|
function validateContextProviderProps(props) {
|
|
124
181
|
if (!('value' in props)) {
|
|
125
182
|
throw new Error(`Context provider value is not provided`);
|
|
@@ -134,4 +191,5 @@ function validateRef(src) {
|
|
|
134
191
|
}
|
|
135
192
|
throw new Error(`Unsupported format of a ref or a ref handler`);
|
|
136
193
|
}
|
|
194
|
+
const NO_ACTIONS = [];
|
|
137
195
|
//# sourceMappingURL=reactNodeToFiberNode.js.map
|
|
@@ -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":"AAeA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EACL,eAAe,EACf,YAAY,EACZ,eAAe,GAChB,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,iBAAiB,EAAE,MAAM,6BAA6B,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,MAAM,oCAAoC,CAAC;AAChE,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAE9D;;;;GAIG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CACnC,UAAuB;AACvB,sEAAsE;AACtE,MAAiB;AACjB;uEACuE;AACvE,gBAAyB,EACW,EAAE,CAAC;IACvC,qDAAqD;IACrD,IAAI,KAAK,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC;QAC9B,UAAU,GAAG;YACX,IAAI,EAAE,YAAY;YAClB,KAAK,EAAE,EAAE;YACT,GAAG,EAAE,IAAI;YACT,QAAQ,EAAE,UAAU;YACpB,MAAM,EAAE,IAAI;SACb,CAAC;IACJ,CAAC;IAED,oEAAoE;IACpE,IAAI,UAAU,KAAK,IAAI,IAAI,UAAU,KAAK,SAAS,IAAI,UAAU,KAAK,KAAK,EAAE,CAAC;QAC5E,MAAM,SAAS,GAAkB;YAC/B,GAAG,eAAe,CAAC,MAAM,CAAC;YAC1B,IAAI,EAAE,MAAM;YACZ,MAAM;YACN,KAAK,EAAE,IAAI;SACZ,CAAC;QACF,OAAO,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;IACjC,CAAC;IAED,2CAA2C;IAC3C,IAAI,OAAO,UAAU,KAAK,QAAQ,EAAE,CAAC;QACnC,MAAM,SAAS,GAAkB;YAC/B,GAAG,eAAe,CAAC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AO,CAAC,IAAI,CAAC,GAAG,eAAe,CAAC,CAAC;IACnC,CAAC;IAED,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;AAAA,CAC5B,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;AAED,MAAM,UAAU,GAAa,EAAE,CAAC"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { App } from '../../../types';
|
|
2
2
|
import type { Action } from '../../../types/actions';
|
|
3
|
+
import { ReactError } from '../errors/ReactError';
|
|
3
4
|
/**
|
|
4
5
|
* Goes through the list of invalidated components, runs them, finds the diff,
|
|
5
6
|
* and returns the list of actions to convert the previous fiber tree to the new
|
|
6
7
|
* one.
|
|
7
8
|
*/
|
|
8
|
-
export declare const collectActionsFromApp: (app: App) => Action[];
|
|
9
|
+
export declare const collectActionsFromApp: (app: App) => Action[] | ReactError;
|
|
9
10
|
//# sourceMappingURL=fromApp.d.ts.map
|
|
@@ -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;AAEzD,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAElD;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,qCAajC,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { collectActionsFromComponent } from './fromComponent';
|
|
2
|
+
import { ReactError } from '../errors/ReactError';
|
|
2
3
|
/**
|
|
3
4
|
* Goes through the list of invalidated components, runs them, finds the diff,
|
|
4
5
|
* and returns the list of actions to convert the previous fiber tree to the new
|
|
@@ -8,7 +9,11 @@ export const collectActionsFromApp = (app) => {
|
|
|
8
9
|
const actions = [];
|
|
9
10
|
while (!app.invalidatedComponents.isEmpty()) {
|
|
10
11
|
const [fiber, props] = app.invalidatedComponents.poll();
|
|
11
|
-
|
|
12
|
+
const actionsX = collectActionsFromComponent(fiber, props);
|
|
13
|
+
if (actionsX instanceof ReactError) {
|
|
14
|
+
return actionsX.catchActionArrOrPassThru();
|
|
15
|
+
}
|
|
16
|
+
actions.push(...actionsX);
|
|
12
17
|
}
|
|
13
18
|
return actions;
|
|
14
19
|
};
|
|
@@ -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;AAC9D,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAElD;;;;GAIG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,GAAQ,EAAyB,EAAE,CAAC;IACxE,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,MAAM,QAAQ,GAAG,2BAA2B,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;QAC3D,IAAI,QAAQ,YAAY,UAAU,EAAE,CAAC;YACnC,OAAO,QAAQ,CAAC,wBAAwB,EAAE,CAAC;QAC7C,CAAC;QACD,OAAO,CAAC,IAAI,CAAC,GAAG,QAAQ,CAAC,CAAC;IAC5B,CAAC;IAED,OAAO,OAAO,CAAC;AAAA,CAChB,CAAC"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { FiberNode } from '../../../types';
|
|
2
2
|
import type { Action } from '../../../types/actions';
|
|
3
|
+
import { ReactError } from '../errors/ReactError';
|
|
3
4
|
/**
|
|
4
5
|
* Returns a list of actions needed to convert `before` to `after`, where
|
|
5
6
|
* `before` is a list of children from the last render, and `after` is the list
|
|
6
7
|
* of children of the same node from the current render.
|
|
7
8
|
*/
|
|
8
|
-
export declare const collectActionsFromChildrenPair: (fiber: FiberNode, after: FiberNode[]) => Action[];
|
|
9
|
+
export declare const collectActionsFromChildrenPair: (fiber: FiberNode, after: FiberNode[]) => Action[] | ReactError;
|
|
9
10
|
//# sourceMappingURL=fromChildrenPair.d.ts.map
|
|
@@ -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;
|
|
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;AAQzD,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAGlD;;;;GAIG;AACH,eAAO,MAAM,8BAA8B,iEA8E1C,CAAC"}
|
|
@@ -5,6 +5,8 @@ import { collectActionsFromNewFiber } from '../../../core/reconciliation/collect
|
|
|
5
5
|
import { createFiberNode, FAKE_CONTAINER_TAG } from '../fibers';
|
|
6
6
|
import { areFiberNodesEq } from '../compare/areFiberNodesEq';
|
|
7
7
|
import { isContainerFiber } from '../typeGuards';
|
|
8
|
+
import { ReactError } from '../errors/ReactError';
|
|
9
|
+
import { isErrorBoundary } from '../../../hooks/useError';
|
|
8
10
|
/**
|
|
9
11
|
* Returns a list of actions needed to convert `before` to `after`, where
|
|
10
12
|
* `before` is a list of children from the last render, and `after` is the list
|
|
@@ -47,7 +49,11 @@ after) => {
|
|
|
47
49
|
// 1. There was no node with this key before. Create a new one.
|
|
48
50
|
// 2. There was one, but it was very different. Replace it.
|
|
49
51
|
relayoutNeeded = true;
|
|
50
|
-
|
|
52
|
+
const createActionsX = createFiberActions(app, r.fiber, fiber);
|
|
53
|
+
// If `fiber` is a component than `fromComponent` (a caller) will handled it.
|
|
54
|
+
if (createActionsX instanceof ReactError)
|
|
55
|
+
return createActionsX;
|
|
56
|
+
actions.push(...createActionsX);
|
|
51
57
|
if (l) {
|
|
52
58
|
// Don't run components from the removing node even if they were invalidated
|
|
53
59
|
uninvalidateFiberSubTree(app, l.fiber);
|
|
@@ -56,9 +62,13 @@ after) => {
|
|
|
56
62
|
continue;
|
|
57
63
|
}
|
|
58
64
|
else {
|
|
65
|
+
const diffActionsX = collectActionsFromFiberPair(app, l.fiber, r.fiber);
|
|
66
|
+
// If `fiber` is a component than `fromComponent` (a caller) will handle it.
|
|
67
|
+
if (diffActionsX instanceof ReactError)
|
|
68
|
+
return diffActionsX;
|
|
59
69
|
// No need to recreate the existing node, but we might need to update it
|
|
60
70
|
// or one of its children.
|
|
61
|
-
actions.push(...
|
|
71
|
+
actions.push(...diffActionsX);
|
|
62
72
|
}
|
|
63
73
|
// Handle the case when the node changed its position. It's possible for
|
|
64
74
|
// nodes with manual keys.
|
|
@@ -97,12 +107,24 @@ const createFiberActions = (app, fiber, parent) => {
|
|
|
97
107
|
// The Relayout action will move them into the real node and then reassign the
|
|
98
108
|
// parent.
|
|
99
109
|
fiber.parent = fakeParent;
|
|
110
|
+
const actions = [];
|
|
100
111
|
if (isContainerFiber(fiber)) {
|
|
112
|
+
const compActionsX = runFiberComponents(app, fiber);
|
|
113
|
+
if (compActionsX instanceof ReactError) {
|
|
114
|
+
if (isErrorBoundary(fiber)) {
|
|
115
|
+
// It should never happen, because this case is specially treated in
|
|
116
|
+
// `runFiberComponents`. So get here a ['CatchError'] action list.
|
|
117
|
+
throw new ReactError(fiber, `Unknown react error`);
|
|
118
|
+
}
|
|
119
|
+
else
|
|
120
|
+
return compActionsX;
|
|
121
|
+
}
|
|
101
122
|
// Since all inner components are also new we need to run them.
|
|
102
|
-
|
|
123
|
+
actions.push(...compActionsX);
|
|
103
124
|
}
|
|
104
125
|
// Reuse the same tooling we use for mounting the app.
|
|
105
|
-
|
|
126
|
+
actions.push(...collectActionsFromNewFiber(fiber));
|
|
127
|
+
return actions;
|
|
106
128
|
};
|
|
107
129
|
/**
|
|
108
130
|
* Create an <x-container/> DOM node that is not mounted to the real DOM tree.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fromChildrenPair.js","sourceRoot":"","sources":["../../../../src/core/reconciliation/collect/fromChildrenPair.ts"],"names":[],"mappings":"AAS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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,10 +1,11 @@
|
|
|
1
1
|
import type { FiberNode, UnknownProps } from '../../../types';
|
|
2
2
|
import type { Action } from '../../../types/actions';
|
|
3
|
+
import { ReactError } from '../errors/ReactError';
|
|
3
4
|
/**
|
|
4
5
|
* 1. Runs a component
|
|
5
6
|
* 2. Collects and returns a list of actions needed to actualize it
|
|
6
7
|
*
|
|
7
8
|
* Throws when the given component is not invalidated.
|
|
8
9
|
*/
|
|
9
|
-
export declare const collectActionsFromComponent: (fiber: FiberNode, props: UnknownProps | null) => Action[];
|
|
10
|
+
export declare const collectActionsFromComponent: (fiber: FiberNode, props: UnknownProps | null) => Action[] | ReactError;
|
|
10
11
|
//# sourceMappingURL=fromComponent.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fromComponent.d.ts","sourceRoot":"","sources":["../../../../src/core/reconciliation/collect/fromComponent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"fromComponent.d.ts","sourceRoot":"","sources":["../../../../src/core/reconciliation/collect/fromComponent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAKzD,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAGlD;;;;;GAKG;AACH,eAAO,MAAM,2BAA2B,yEAoCvC,CAAC"}
|
|
@@ -2,6 +2,8 @@ import { runComponent } from '../../components';
|
|
|
2
2
|
import { jsxElementToFiberNode } from '../../reactNodeToFiberNode';
|
|
3
3
|
import { collectActionsFromChildrenPair } from './fromChildrenPair';
|
|
4
4
|
import { toFiberChildren } from '../fibers';
|
|
5
|
+
import { ReactError } from '../errors/ReactError';
|
|
6
|
+
import { isErrorBoundary } from '../../../hooks/useError';
|
|
5
7
|
/**
|
|
6
8
|
* 1. Runs a component
|
|
7
9
|
* 2. Collects and returns a list of actions needed to actualize it
|
|
@@ -11,8 +13,28 @@ import { toFiberChildren } from '../fibers';
|
|
|
11
13
|
export const collectActionsFromComponent = (fiber,
|
|
12
14
|
/** Custom props (when `fiber.props` are stale). */
|
|
13
15
|
props) => {
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
|
|
16
|
+
const compActionsX = runComponent(fiber, props);
|
|
17
|
+
// Component cannot be its own error boundary. Pass it through.
|
|
18
|
+
if (compActionsX instanceof ReactError)
|
|
19
|
+
return compActionsX;
|
|
20
|
+
const [newReactChildren, compActions] = compActionsX;
|
|
21
|
+
const childrenX = jsxElementToFiberNode(newReactChildren, fiber, false);
|
|
22
|
+
if (childrenX instanceof ReactError) {
|
|
23
|
+
// It should never happen, because `childrenX` could be a `ReactError` only
|
|
24
|
+
// if ran some component that threw an error. But we don't unwrap components
|
|
25
|
+
// here.
|
|
26
|
+
throw new ReactError(fiber, `Unknown fiber error`);
|
|
27
|
+
}
|
|
28
|
+
let [newFiber, childrenActions] = childrenX;
|
|
29
|
+
let diffActionsX = collectActionsFromChildrenPair(fiber, toFiberChildren(newFiber));
|
|
30
|
+
if (diffActionsX instanceof ReactError) {
|
|
31
|
+
if (isErrorBoundary(fiber)) {
|
|
32
|
+
childrenActions = [];
|
|
33
|
+
diffActionsX = [diffActionsX.genCatchAction()];
|
|
34
|
+
}
|
|
35
|
+
else
|
|
36
|
+
return diffActionsX;
|
|
37
|
+
}
|
|
38
|
+
return [...compActions, ...childrenActions, ...diffActionsX];
|
|
17
39
|
};
|
|
18
40
|
//# sourceMappingURL=fromComponent.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fromComponent.js","sourceRoot":"","sources":["../../../../src/core/reconciliation/collect/fromComponent.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,8BAA8B,EAAE,MAAM,oBAAoB,CAAC;AACpE,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"fromComponent.js","sourceRoot":"","sources":["../../../../src/core/reconciliation/collect/fromComponent.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,OAAO,EAAE,8BAA8B,EAAE,MAAM,oBAAoB,CAAC;AACpE,OAAO,EAAE,eAAe,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAE9D;;;;;GAKG;AACH,MAAM,CAAC,MAAM,2BAA2B,GAAG,CACzC,KAAgB;AAChB,mDAAmD;AACnD,KAA0B,EACH,EAAE,CAAC;IAC1B,MAAM,YAAY,GAAG,YAAY,CAAC,KAAK,EAAE,KAAK,CAAC,CAAC;IAChD,+DAA+D;IAC/D,IAAI,YAAY,YAAY,UAAU;QAAE,OAAO,YAAY,CAAC;IAE5D,MAAM,CAAC,gBAAgB,EAAE,WAAW,CAAC,GAAG,YAAY,CAAC;IACrD,MAAM,SAAS,GAAG,qBAAqB,CACrC,gBAAgB,EAChB,KAAK,EACL,KAAK,CACN,CAAC;IACF,IAAI,SAAS,YAAY,UAAU,EAAE,CAAC;QACpC,2EAA2E;QAC3E,4EAA4E;QAC5E,QAAQ;QACR,MAAM,IAAI,UAAU,CAAC,KAAK,EAAE,qBAAqB,CAAC,CAAC;IACrD,CAAC;IAED,IAAI,CAAC,QAAQ,EAAE,eAAe,CAAC,GAAG,SAAS,CAAC;IAC5C,IAAI,YAAY,GAAG,8BAA8B,CAC/C,KAAK,EACL,eAAe,CAAC,QAAQ,CAAC,CAC1B,CAAC;IAEF,IAAI,YAAY,YAAY,UAAU,EAAE,CAAC;QACvC,IAAI,eAAe,CAAC,KAAK,CAAC,EAAE,CAAC;YAC3B,eAAe,GAAG,EAAE,CAAC;YACrB,YAAY,GAAG,CAAC,YAAY,CAAC,cAAc,EAAG,CAAC,CAAC;QAClD,CAAC;;YAAM,OAAO,YAAY,CAAC;IAC7B,CAAC;IAED,OAAO,CAAC,GAAG,WAAW,EAAE,GAAG,eAAe,EAAE,GAAG,YAAY,CAAC,CAAC;AAAA,CAC9D,CAAC"}
|
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import type { App, FiberNode } from '../../../types';
|
|
2
2
|
import type { Action } from '../../../types/actions';
|
|
3
|
+
import { ReactError } from '../errors/ReactError';
|
|
3
4
|
/**
|
|
4
5
|
* `l` and `r` are the same node, but `r` may have some updates. This method
|
|
5
6
|
* collects a list of actions that must be applied to convert `l` to `r`.
|
|
6
7
|
* This doesn't include removing or replacing the existing `l` node.
|
|
7
8
|
*/
|
|
8
|
-
export declare const collectActionsFromFiberPair: (app: App, l: FiberNode, r: FiberNode) => Action[];
|
|
9
|
+
export declare const collectActionsFromFiberPair: (app: App, l: FiberNode, r: FiberNode) => Action[] | ReactError;
|
|
9
10
|
//# sourceMappingURL=fromFiberPair.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fromFiberPair.d.ts","sourceRoot":"","sources":["../../../../src/core/reconciliation/collect/fromFiberPair.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,GAAG,EAEH,SAAS,EAIV,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,MAAM,EAAgB,MAAM,4BAA4B,CAAC;
|
|
1
|
+
{"version":3,"file":"fromFiberPair.d.ts","sourceRoot":"","sources":["../../../../src/core/reconciliation/collect/fromFiberPair.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,GAAG,EAEH,SAAS,EAIV,MAAM,oBAAoB,CAAC;AAC5B,OAAO,KAAK,EAAE,MAAM,EAAgB,MAAM,4BAA4B,CAAC;AAIvE,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAElD;;;;GAIG;AACH,eAAO,MAAM,2BAA2B,iEAkFvC,CAAC"}
|