@faiwer/react 0.8.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 +90 -0
- package/dist/core/actions/applyAction.d.ts +11 -0
- package/dist/core/actions/applyAction.d.ts.map +1 -0
- package/dist/core/actions/applyAction.js +35 -0
- package/dist/core/actions/applyAction.js.map +1 -0
- package/dist/core/actions/createComment.action.d.ts +7 -0
- package/dist/core/actions/createComment.action.d.ts.map +1 -0
- package/dist/core/actions/createComment.action.js +20 -0
- package/dist/core/actions/createComment.action.js.map +1 -0
- package/dist/core/actions/createTag.action.d.ts +10 -0
- package/dist/core/actions/createTag.action.d.ts.map +1 -0
- package/dist/core/actions/createTag.action.js +27 -0
- package/dist/core/actions/createTag.action.js.map +1 -0
- package/dist/core/actions/createText.action.d.ts +6 -0
- package/dist/core/actions/createText.action.d.ts.map +1 -0
- package/dist/core/actions/createText.action.js +16 -0
- package/dist/core/actions/createText.action.js.map +1 -0
- package/dist/core/actions/helpers.d.ts +43 -0
- package/dist/core/actions/helpers.d.ts.map +1 -0
- package/dist/core/actions/helpers.js +141 -0
- package/dist/core/actions/helpers.js.map +1 -0
- package/dist/core/actions/relayout.action.d.ts +20 -0
- package/dist/core/actions/relayout.action.d.ts.map +1 -0
- package/dist/core/actions/relayout.action.js +113 -0
- package/dist/core/actions/relayout.action.js.map +1 -0
- package/dist/core/actions/remove.action.d.ts +7 -0
- package/dist/core/actions/remove.action.d.ts.map +1 -0
- package/dist/core/actions/remove.action.js +64 -0
- package/dist/core/actions/remove.action.js.map +1 -0
- package/dist/core/actions/replace.action.d.ts +18 -0
- package/dist/core/actions/replace.action.d.ts.map +1 -0
- package/dist/core/actions/replace.action.js +57 -0
- package/dist/core/actions/replace.action.js.map +1 -0
- package/dist/core/actions/setAttr.action.d.ts +9 -0
- package/dist/core/actions/setAttr.action.d.ts.map +1 -0
- package/dist/core/actions/setAttr.action.js +62 -0
- package/dist/core/actions/setAttr.action.js.map +1 -0
- package/dist/core/actions/setProps.action.d.ts +8 -0
- package/dist/core/actions/setProps.action.d.ts.map +1 -0
- package/dist/core/actions/setProps.action.js +13 -0
- package/dist/core/actions/setProps.action.js.map +1 -0
- package/dist/core/actions/setRef.action.d.ts +11 -0
- package/dist/core/actions/setRef.action.d.ts.map +1 -0
- package/dist/core/actions/setRef.action.js +38 -0
- package/dist/core/actions/setRef.action.js.map +1 -0
- package/dist/core/actions/setText.action.d.ts +7 -0
- package/dist/core/actions/setText.action.d.ts.map +1 -0
- package/dist/core/actions/setText.action.js +12 -0
- package/dist/core/actions/setText.action.js.map +1 -0
- package/dist/core/compact.d.ts +38 -0
- package/dist/core/compact.d.ts.map +1 -0
- package/dist/core/compact.js +112 -0
- package/dist/core/compact.js.map +1 -0
- package/dist/core/components.d.ts +32 -0
- package/dist/core/components.d.ts.map +1 -0
- package/dist/core/components.js +57 -0
- package/dist/core/components.js.map +1 -0
- package/dist/core/createElement.d.ts +47 -0
- package/dist/core/createElement.d.ts.map +1 -0
- package/dist/core/createElement.js +73 -0
- package/dist/core/createElement.js.map +1 -0
- package/dist/core/createRoot.d.ts +13 -0
- package/dist/core/createRoot.d.ts.map +1 -0
- package/dist/core/createRoot.js +33 -0
- package/dist/core/createRoot.js.map +1 -0
- package/dist/core/reactNodeToFiberNode.d.ts +8 -0
- package/dist/core/reactNodeToFiberNode.d.ts.map +1 -0
- package/dist/core/reactNodeToFiberNode.js +132 -0
- package/dist/core/reactNodeToFiberNode.js.map +1 -0
- package/dist/core/reconciliation/app.d.ts +5 -0
- package/dist/core/reconciliation/app.d.ts.map +1 -0
- package/dist/core/reconciliation/app.js +20 -0
- package/dist/core/reconciliation/app.js.map +1 -0
- package/dist/core/reconciliation/applyActions.d.ts +8 -0
- package/dist/core/reconciliation/applyActions.d.ts.map +1 -0
- package/dist/core/reconciliation/applyActions.js +12 -0
- package/dist/core/reconciliation/applyActions.js.map +1 -0
- package/dist/core/reconciliation/collect/fromApp.d.ts +9 -0
- package/dist/core/reconciliation/collect/fromApp.d.ts.map +1 -0
- package/dist/core/reconciliation/collect/fromApp.js +39 -0
- package/dist/core/reconciliation/collect/fromApp.js.map +1 -0
- package/dist/core/reconciliation/collect/fromChildrenPair.d.ts +9 -0
- package/dist/core/reconciliation/collect/fromChildrenPair.d.ts.map +1 -0
- package/dist/core/reconciliation/collect/fromChildrenPair.js +127 -0
- package/dist/core/reconciliation/collect/fromChildrenPair.js.map +1 -0
- package/dist/core/reconciliation/collect/fromComponent.d.ts +10 -0
- package/dist/core/reconciliation/collect/fromComponent.d.ts.map +1 -0
- package/dist/core/reconciliation/collect/fromComponent.js +22 -0
- package/dist/core/reconciliation/collect/fromComponent.js.map +1 -0
- package/dist/core/reconciliation/collect/fromFiberPair.d.ts +9 -0
- package/dist/core/reconciliation/collect/fromFiberPair.d.ts.map +1 -0
- package/dist/core/reconciliation/collect/fromFiberPair.js +125 -0
- package/dist/core/reconciliation/collect/fromFiberPair.js.map +1 -0
- package/dist/core/reconciliation/collect/fromNewFiber.d.ts +7 -0
- package/dist/core/reconciliation/collect/fromNewFiber.d.ts.map +1 -0
- package/dist/core/reconciliation/collect/fromNewFiber.js +45 -0
- package/dist/core/reconciliation/collect/fromNewFiber.js.map +1 -0
- package/dist/core/reconciliation/comments.d.ts +3 -0
- package/dist/core/reconciliation/comments.d.ts.map +1 -0
- package/dist/core/reconciliation/comments.js +3 -0
- package/dist/core/reconciliation/comments.js.map +1 -0
- package/dist/core/reconciliation/compare/areFiberNodesEq.d.ts +7 -0
- package/dist/core/reconciliation/compare/areFiberNodesEq.d.ts.map +1 -0
- package/dist/core/reconciliation/compare/areFiberNodesEq.js +14 -0
- package/dist/core/reconciliation/compare/areFiberNodesEq.js.map +1 -0
- package/dist/core/reconciliation/compare/areFiberPropsEq.d.ts +7 -0
- package/dist/core/reconciliation/compare/areFiberPropsEq.d.ts.map +1 -0
- package/dist/core/reconciliation/compare/areFiberPropsEq.js +18 -0
- package/dist/core/reconciliation/compare/areFiberPropsEq.js.map +1 -0
- package/dist/core/reconciliation/effects.d.ts +14 -0
- package/dist/core/reconciliation/effects.d.ts.map +1 -0
- package/dist/core/reconciliation/effects.js +26 -0
- package/dist/core/reconciliation/effects.js.map +1 -0
- package/dist/core/reconciliation/fibers.d.ts +35 -0
- package/dist/core/reconciliation/fibers.d.ts.map +1 -0
- package/dist/core/reconciliation/fibers.js +51 -0
- package/dist/core/reconciliation/fibers.js.map +1 -0
- package/dist/core/reconciliation/invalidateFiber.d.ts +8 -0
- package/dist/core/reconciliation/invalidateFiber.d.ts.map +1 -0
- package/dist/core/reconciliation/invalidateFiber.js +28 -0
- package/dist/core/reconciliation/invalidateFiber.js.map +1 -0
- package/dist/core/reconciliation/mount.d.ts +7 -0
- package/dist/core/reconciliation/mount.d.ts.map +1 -0
- package/dist/core/reconciliation/mount.js +53 -0
- package/dist/core/reconciliation/mount.js.map +1 -0
- package/dist/core/reconciliation/postCommit.d.ts +11 -0
- package/dist/core/reconciliation/postCommit.d.ts.map +1 -0
- package/dist/core/reconciliation/postCommit.js +47 -0
- package/dist/core/reconciliation/postCommit.js.map +1 -0
- package/dist/core/reconciliation/render.d.ts +11 -0
- package/dist/core/reconciliation/render.d.ts.map +1 -0
- package/dist/core/reconciliation/render.js +35 -0
- package/dist/core/reconciliation/render.js.map +1 -0
- package/dist/core/reconciliation/runFiberComponents.d.ts +10 -0
- package/dist/core/reconciliation/runFiberComponents.d.ts.map +1 -0
- package/dist/core/reconciliation/runFiberComponents.js +37 -0
- package/dist/core/reconciliation/runFiberComponents.js.map +1 -0
- package/dist/core/reconciliation/typeGuards.d.ts +12 -0
- package/dist/core/reconciliation/typeGuards.d.ts.map +1 -0
- package/dist/core/reconciliation/typeGuards.js +32 -0
- package/dist/core/reconciliation/typeGuards.js.map +1 -0
- package/dist/core/reconciliation/validateTree.d.ts +6 -0
- package/dist/core/reconciliation/validateTree.d.ts.map +1 -0
- package/dist/core/reconciliation/validateTree.js +48 -0
- package/dist/core/reconciliation/validateTree.js.map +1 -0
- package/dist/hooks/helpers.d.ts +19 -0
- package/dist/hooks/helpers.d.ts.map +1 -0
- package/dist/hooks/helpers.js +40 -0
- package/dist/hooks/helpers.js.map +1 -0
- package/dist/hooks/index.d.ts +9 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +9 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/hooks/useCallback.d.ts +2 -0
- package/dist/hooks/useCallback.d.ts.map +1 -0
- package/dist/hooks/useCallback.js +5 -0
- package/dist/hooks/useCallback.js.map +1 -0
- package/dist/hooks/useContext.d.ts +37 -0
- package/dist/hooks/useContext.d.ts.map +1 -0
- package/dist/hooks/useContext.js +101 -0
- package/dist/hooks/useContext.js.map +1 -0
- package/dist/hooks/useEffect.d.ts +48 -0
- package/dist/hooks/useEffect.d.ts.map +1 -0
- package/dist/hooks/useEffect.js +100 -0
- package/dist/hooks/useEffect.js.map +1 -0
- package/dist/hooks/useId.d.ts +2 -0
- package/dist/hooks/useId.d.ts.map +1 -0
- package/dist/hooks/useId.js +10 -0
- package/dist/hooks/useId.js.map +1 -0
- package/dist/hooks/useMemo.d.ts +20 -0
- package/dist/hooks/useMemo.d.ts.map +1 -0
- package/dist/hooks/useMemo.js +33 -0
- package/dist/hooks/useMemo.js.map +1 -0
- package/dist/hooks/useRef.d.ts +4 -0
- package/dist/hooks/useRef.d.ts.map +1 -0
- package/dist/hooks/useRef.js +9 -0
- package/dist/hooks/useRef.js.map +1 -0
- package/dist/hooks/useStableCallback.d.ts +45 -0
- package/dist/hooks/useStableCallback.d.ts.map +1 -0
- package/dist/hooks/useStableCallback.js +66 -0
- package/dist/hooks/useStableCallback.js.map +1 -0
- package/dist/hooks/useState.d.ts +15 -0
- package/dist/hooks/useState.d.ts.map +1 -0
- package/dist/hooks/useState.js +39 -0
- package/dist/hooks/useState.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +13 -0
- package/dist/index.js.map +1 -0
- package/dist/jsx-dev-runtime.d.ts +6 -0
- package/dist/jsx-dev-runtime.d.ts.map +1 -0
- package/dist/jsx-dev-runtime.js +7 -0
- package/dist/jsx-dev-runtime.js.map +1 -0
- package/dist/jsx-runtime.d.ts +31 -0
- package/dist/jsx-runtime.d.ts.map +1 -0
- package/dist/jsx-runtime.js +32 -0
- package/dist/jsx-runtime.js.map +1 -0
- package/dist/testing.d.ts +8 -0
- package/dist/testing.d.ts.map +1 -0
- package/dist/testing.js +10 -0
- package/dist/testing.js.map +1 -0
- package/dist/types/actions.d.ts +53 -0
- package/dist/types/actions.d.ts.map +1 -0
- package/dist/types/actions.js +2 -0
- package/dist/types/actions.js.map +1 -0
- package/dist/types/app.d.ts +74 -0
- package/dist/types/app.d.ts.map +1 -0
- package/dist/types/app.js +2 -0
- package/dist/types/app.js.map +1 -0
- package/dist/types/component.d.ts +11 -0
- package/dist/types/component.d.ts.map +1 -0
- package/dist/types/component.js +2 -0
- package/dist/types/component.js.map +1 -0
- package/dist/types/context.d.ts +28 -0
- package/dist/types/context.d.ts.map +1 -0
- package/dist/types/context.js +2 -0
- package/dist/types/context.js.map +1 -0
- package/dist/types/core.d.ts +51 -0
- package/dist/types/core.d.ts.map +1 -0
- package/dist/types/core.js +2 -0
- package/dist/types/core.js.map +1 -0
- package/dist/types/dom.d.ts +48 -0
- package/dist/types/dom.d.ts.map +1 -0
- package/dist/types/dom.js +2 -0
- package/dist/types/dom.js.map +1 -0
- package/dist/types/fiber.d.ts +169 -0
- package/dist/types/fiber.d.ts.map +1 -0
- package/dist/types/fiber.js +2 -0
- package/dist/types/fiber.js.map +1 -0
- package/dist/types/hooks.d.ts +47 -0
- package/dist/types/hooks.d.ts.map +1 -0
- package/dist/types/hooks.js +2 -0
- package/dist/types/hooks.js.map +1 -0
- package/dist/types/index.d.ts +9 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +9 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/refs.d.ts +19 -0
- package/dist/types/refs.d.ts.map +1 -0
- package/dist/types/refs.js +2 -0
- package/dist/types/refs.js.map +1 -0
- package/dist/utils.d.ts +2 -0
- package/dist/utils.d.ts.map +1 -0
- package/dist/utils.js +7 -0
- package/dist/utils.js.map +1 -0
- package/package.json +67 -0
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import type { FiberNode } from './fiber';
|
|
2
|
+
import type { EffectMode } from './hooks';
|
|
3
|
+
export type AppState =
|
|
4
|
+
/** Waiting for updates */
|
|
5
|
+
'idle'
|
|
6
|
+
/**
|
|
7
|
+
* At least one component has been invalidated. A new render cycle is
|
|
8
|
+
* scheduled.
|
|
9
|
+
**/
|
|
10
|
+
| 'scheduled'
|
|
11
|
+
/**
|
|
12
|
+
* 1. Invalidates affected fiber nodes. It includes re-running components.
|
|
13
|
+
* 2. Compares the old and the new fiber trees.
|
|
14
|
+
* 3. Prepares a list of actions that would convert the old tree to the new
|
|
15
|
+
* one.
|
|
16
|
+
*
|
|
17
|
+
* It's a pure state. Its result may be dropped if needed. It doesn't update
|
|
18
|
+
* any already existing fiber nodes, refs. It doesn't run any effects.
|
|
19
|
+
*/
|
|
20
|
+
| 'render'
|
|
21
|
+
/**
|
|
22
|
+
* Applies the actions from the render phase to the DOM and the app fiber
|
|
23
|
+
* tree. Some of the actions may schedule extra effects.
|
|
24
|
+
*/
|
|
25
|
+
| 'commit'
|
|
26
|
+
/**
|
|
27
|
+
* Runs scheduled normal effects. It's guaranteed that the browser didn't
|
|
28
|
+
* update the UI since the render started. Effect handlers may update
|
|
29
|
+
* components' state. In such a case the normal scheduled effects will be
|
|
30
|
+
* applied immediately.
|
|
31
|
+
*/
|
|
32
|
+
| 'layoutEffects'
|
|
33
|
+
/**
|
|
34
|
+
* Runs scheduled normal effects. At this point the browser could have updated
|
|
35
|
+
* the UI. Such effects also may change component state.
|
|
36
|
+
*/
|
|
37
|
+
| 'effects'
|
|
38
|
+
/**
|
|
39
|
+
* The app was destroyed.
|
|
40
|
+
*/
|
|
41
|
+
| 'killed';
|
|
42
|
+
export type App = {
|
|
43
|
+
/** Unique ID per app. */
|
|
44
|
+
id: number;
|
|
45
|
+
/** The root of the fiber tree. Never changes. */
|
|
46
|
+
root: FiberNode;
|
|
47
|
+
/** The current stage of the app rendering cycle. */
|
|
48
|
+
state: AppState;
|
|
49
|
+
/** The lists of pending effect handlers. */
|
|
50
|
+
effects: Record<EffectMode, Array<() => void>>;
|
|
51
|
+
/** The list of components to rerender. */
|
|
52
|
+
invalidatedComponents: Set<FiberNode>;
|
|
53
|
+
/** If `true`, extra validators are applied. */
|
|
54
|
+
testMode: boolean;
|
|
55
|
+
/**
|
|
56
|
+
* A special storage that contains invalidated context values. We need it to
|
|
57
|
+
* keep the "render" phase pure (so we don't update the existing fibers) and
|
|
58
|
+
* at the same time be able to run invalidated components with the fresh
|
|
59
|
+
* context values.
|
|
60
|
+
*/
|
|
61
|
+
tempContext: Map<number, unknown>;
|
|
62
|
+
};
|
|
63
|
+
export type AppOptions = {
|
|
64
|
+
/**
|
|
65
|
+
* If `true`, extra validators are applied.
|
|
66
|
+
* Warning: It slows down the app.
|
|
67
|
+
**/
|
|
68
|
+
testMode?: boolean;
|
|
69
|
+
};
|
|
70
|
+
export type AppRoot = {
|
|
71
|
+
render: (element: JSX.Element) => void;
|
|
72
|
+
unmount: () => void;
|
|
73
|
+
};
|
|
74
|
+
//# sourceMappingURL=app.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../../src/types/app.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AACzC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE1C,MAAM,MAAM,QAAQ;AAClB,0BAA0B;AACxB,MAAM;AACR;;;IAGI;GACF,WAAW;AACb;;;;;;;;GAQG;GACD,QAAQ;AACV;;;GAGG;GACD,QAAQ;AACV;;;;;GAKG;GACD,eAAe;AACjB;;;GAGG;GACD,SAAS;AACX;;GAEG;GACD,QAAQ,CAAC;AAEb,MAAM,MAAM,GAAG,GAAG;IAChB,yBAAyB;IACzB,EAAE,EAAE,MAAM,CAAC;IACX,iDAAiD;IACjD,IAAI,EAAE,SAAS,CAAC;IAChB,oDAAoD;IACpD,KAAK,EAAE,QAAQ,CAAC;IAChB,4CAA4C;IAC5C,OAAO,EAAE,MAAM,CAAC,UAAU,EAAE,KAAK,CAAC,MAAM,IAAI,CAAC,CAAC,CAAC;IAC/C,0CAA0C;IAC1C,qBAAqB,EAAE,GAAG,CAAC,SAAS,CAAC,CAAC;IACtC,+CAA+C;IAC/C,QAAQ,EAAE,OAAO,CAAC;IAClB;;;;;OAKG;IACH,WAAW,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACnC,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG;IACvB;;;QAGI;IACJ,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,OAAO,GAAG;IACpB,MAAM,EAAE,CAAC,OAAO,EAAE,GAAG,CAAC,OAAO,KAAK,IAAI,CAAC;IACvC,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"app.js","sourceRoot":"","sources":["../../src/types/app.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { ElementCommonAttrs, UnknownProps } from './core';
|
|
2
|
+
import type { HookStore } from './hooks';
|
|
3
|
+
export type ComponentState = {
|
|
4
|
+
hooks: HookStore | null;
|
|
5
|
+
};
|
|
6
|
+
export type ReactComponent<TProps extends UnknownProps = UnknownProps> = (props: TProps & ElementCommonAttrs) => JSX.Element;
|
|
7
|
+
export type PropsWithChildren<TProps extends UnknownProps = UnknownProps> = TProps & {
|
|
8
|
+
children?: JSX.Element;
|
|
9
|
+
};
|
|
10
|
+
export type ReactComponentWithChildren<TProps extends UnknownProps = UnknownProps> = ReactComponent<PropsWithChildren<TProps>>;
|
|
11
|
+
//# sourceMappingURL=component.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"component.d.ts","sourceRoot":"","sources":["../../src/types/component.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,YAAY,EAAE,MAAM,QAAQ,CAAC;AAC/D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEzC,MAAM,MAAM,cAAc,GAAG;IAC3B,KAAK,EAAE,SAAS,GAAG,IAAI,CAA4B;CACpD,CAAC;AAEF,MAAM,MAAM,cAAc,CAAC,MAAM,SAAS,YAAY,GAAG,YAAY,IAAI,CACvE,KAAK,EAAE,MAAM,GAAG,kBAAkB,KAC/B,GAAG,CAAC,OAAO,CAAC;AAEjB,MAAM,MAAM,iBAAiB,CAAC,MAAM,SAAS,YAAY,GAAG,YAAY,IACtE,MAAM,GAAG;IAAE,QAAQ,CAAC,EAAE,GAAG,CAAC,OAAO,CAAA;CAAE,CAAC;AAEtC,MAAM,MAAM,0BAA0B,CACpC,MAAM,SAAS,YAAY,GAAG,YAAY,IACxC,cAAc,CAAC,iBAAiB,CAAC,MAAM,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"component.js","sourceRoot":"","sources":["../../src/types/component.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { ReactComponent } from './component';
|
|
2
|
+
import type { FiberNode } from './fiber';
|
|
3
|
+
export type ReactContextProvider<T = unknown> = ReactComponent<{
|
|
4
|
+
children: JSX.Element;
|
|
5
|
+
value: T;
|
|
6
|
+
}> & {
|
|
7
|
+
__ctx: ReactContext<T>;
|
|
8
|
+
};
|
|
9
|
+
export type ReactContextConsumer<T = unknown> = ReactComponent<{
|
|
10
|
+
children: (value: T) => JSX.Element;
|
|
11
|
+
}>;
|
|
12
|
+
export type ReactContext<T = unknown> = {
|
|
13
|
+
Provider: ReactContextProvider<T>;
|
|
14
|
+
Consumer: ReactContextConsumer<T>;
|
|
15
|
+
/**
|
|
16
|
+
* Unique ID. We can't use `providerFiber.id` as a context ID because each
|
|
17
|
+
* context might have multiple providers within the same app. Also, the same
|
|
18
|
+
* context can be used in multiple apps simultaneously.
|
|
19
|
+
*/
|
|
20
|
+
__id: number;
|
|
21
|
+
__default: T;
|
|
22
|
+
};
|
|
23
|
+
/** `.data` of the `ContextFiberNode` */
|
|
24
|
+
export type ContextState<T = unknown> = {
|
|
25
|
+
ctx: ReactContext<T>;
|
|
26
|
+
consumers: Set<FiberNode>;
|
|
27
|
+
};
|
|
28
|
+
//# sourceMappingURL=context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../../src/types/context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,SAAS,CAAC;AAEzC,MAAM,MAAM,oBAAoB,CAAC,CAAC,GAAG,OAAO,IAIxC,cAAc,CAAC;IAAE,QAAQ,EAAE,GAAG,CAAC,OAAO,CAAC;IAAC,KAAK,EAAE,CAAC,CAAA;CAAE,CAAC,GACnD;IAAE,KAAK,EAAE,YAAY,CAAC,CAAC,CAAC,CAAA;CAAE,CAAC;AAE/B,MAAM,MAAM,oBAAoB,CAAC,CAAC,GAAG,OAAO,IAAI,cAAc,CAAC;IAC7D,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,GAAG,CAAC,OAAO,CAAC;CACrC,CAAC,CAAC;AAEH,MAAM,MAAM,YAAY,CAAC,CAAC,GAAG,OAAO,IAAI;IACtC,QAAQ,EAAE,oBAAoB,CAAC,CAAC,CAAC,CAAC;IAClC,QAAQ,EAAE,oBAAoB,CAAC,CAAC,CAAC,CAAC;IAClC;;;;OAIG;IACH,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,CAAC,CAAC;CACd,CAAC;AAEF,wCAAwC;AACxC,MAAM,MAAM,YAAY,CAAC,CAAC,GAAG,OAAO,IAAI;IACtC,GAAG,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC;IACrB,SAAS,EAAE,GAAG,CAAC,SAAS,CAAC,CAAC;CAC3B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../../src/types/context.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type { ReactComponent } from './component';
|
|
2
|
+
import type { ReactContextProvider } from './context';
|
|
3
|
+
/**
|
|
4
|
+
* Any unique string or number that can help the React engine to identify the
|
|
5
|
+
* given node in the reconciliation algorithm. Also can be used to forcibly
|
|
6
|
+
* recreate the given node by purpose.
|
|
7
|
+
*/
|
|
8
|
+
export type ReactKey = string | number;
|
|
9
|
+
/**
|
|
10
|
+
* Generic type to reflect props that can be used for both <tag/>s and
|
|
11
|
+
* <Component/>s.
|
|
12
|
+
*/
|
|
13
|
+
export type UnknownProps = Record<PropertyKey, unknown> & ElementCommonAttrs;
|
|
14
|
+
/**
|
|
15
|
+
* The 1st argument of `createElement` function. Basically, this type reflects
|
|
16
|
+
* everything that can be created in "<" & "/>" brackets: tags, components,
|
|
17
|
+
* fragments, context providers.
|
|
18
|
+
*/
|
|
19
|
+
export type ElementType = string | ReactComponent;
|
|
20
|
+
/**
|
|
21
|
+
* JSX values that aren't passed to `createElement`. JSX keeps them intact.
|
|
22
|
+
*/
|
|
23
|
+
export type ScalarNode = string | number | boolean | null | undefined;
|
|
24
|
+
/**
|
|
25
|
+
* The result type of the `createElement` function. It's not used internally. We
|
|
26
|
+
* have `FiberNode` for it.
|
|
27
|
+
*/
|
|
28
|
+
export type ElementNode = {
|
|
29
|
+
type: ElementType | ReactContextProvider | HTMLElement;
|
|
30
|
+
props: UnknownProps;
|
|
31
|
+
key: ReactKey | null | undefined;
|
|
32
|
+
children: JsxElement[];
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* Common props for <tag/>s and <Component/>s.
|
|
36
|
+
*/
|
|
37
|
+
export type ElementCommonAttrs = {
|
|
38
|
+
key?: ReactKey | null;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* An implementation for `JSX.Element`. For some reason in real React it's
|
|
42
|
+
* called `ReactNode` and it's a little different from `JSX.Element`. It creates
|
|
43
|
+
* type-issues, so I didn't repeat the same.
|
|
44
|
+
*/
|
|
45
|
+
export type JsxElement = ElementNode | ScalarNode | JsxElement[];
|
|
46
|
+
/**
|
|
47
|
+
* Available !--comment types.
|
|
48
|
+
* E.g. <!--r:null:14-->
|
|
49
|
+
*/
|
|
50
|
+
export type CommentMode = 'null' | 'begin' | 'end' | 'portal' | 'empty';
|
|
51
|
+
//# sourceMappingURL=core.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core.d.ts","sourceRoot":"","sources":["../../src/types/core.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AAEtD;;;;GAIG;AACH,MAAM,MAAM,QAAQ,GAAG,MAAM,GAAG,MAAM,CAAC;AAEvC;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG,MAAM,CAAC,WAAW,EAAE,OAAO,CAAC,GAAG,kBAAkB,CAAC;AAE7E;;;;GAIG;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,GAAkB,cAAc,CAAC;AAEjE;;GAEG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS,CAAC;AAEtE;;;GAGG;AACH,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EAAE,WAAW,GAAG,oBAAoB,GAAG,WAAW,CAAC;IACvD,KAAK,EAAE,YAAY,CAAC;IACpB,GAAG,EAAE,QAAQ,GAAG,IAAI,GAAG,SAAS,CAAC;IACjC,QAAQ,EAAE,UAAU,EAAE,CAAC;CACxB,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAAE,GAAG,CAAC,EAAE,QAAQ,GAAG,IAAI,CAAA;CAAE,CAAC;AAE3D;;;;GAIG;AACH,MAAM,MAAM,UAAU,GAElB,WAAW,GAEX,UAAU,GAEV,UAAU,EAAE,CAAC;AAEjB;;;GAGG;AACH,MAAM,MAAM,WAAW,GAEnB,MAAM,GAEN,OAAO,GACP,KAAK,GAEL,QAAQ,GAER,OAAO,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core.js","sourceRoot":"","sources":["../../src/types/core.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import type { ElementCommonAttrs, ScalarNode } from './core';
|
|
2
|
+
import type { HtmlRef, RefSetter } from './refs';
|
|
3
|
+
/** The list of possible DOM tree node types. */
|
|
4
|
+
export type DomNode = Element | Text | Comment;
|
|
5
|
+
export type TagAttrValue = string | number | boolean | null | undefined | Function;
|
|
6
|
+
type EventKeys<T extends HTMLElement> = {
|
|
7
|
+
[K in keyof T]: K extends `on${string}` ? K : never;
|
|
8
|
+
}[keyof T];
|
|
9
|
+
/**
|
|
10
|
+
* Each HTMLElement contains a ton of properties. Most of them shouldn't be used
|
|
11
|
+
* in JSX tag nodes. This type matches most inapplicable generic properties.
|
|
12
|
+
*/
|
|
13
|
+
type GeneralRemove = `DOCUMENT_${string}` | `${string}_NODE` | `client${string}` | `offset${string}` | `node${string}` | `inner${string}` | `scroll${string}` | `set${string}` | `outer${string}` | 'children' | 'attributes' | 'childNodes' | 'classList' | 'tagName' | 'style' | `key` | `dataset` | 'textContent' | 'shadowRoot';
|
|
14
|
+
/**
|
|
15
|
+
* Returns a list of tag-based properties that can probably be set via a JSX tag
|
|
16
|
+
* node.
|
|
17
|
+
**/
|
|
18
|
+
type PropertiesOnly<T extends HTMLElement> = {
|
|
19
|
+
[K in keyof T]: T[K] extends (...args: any[]) => any ? never : ChildNode extends T[K] ? never : Element extends T[K] ? never : HTMLElement extends T[K] ? never : K;
|
|
20
|
+
}[keyof T];
|
|
21
|
+
type TagNativeProps<T extends HTMLElement> = Partial<Omit<Pick<T, PropertiesOnly<T>>, GeneralRemove>> & {
|
|
22
|
+
[K in EventKeys<T>]?: DomEventHandlerX<K>;
|
|
23
|
+
};
|
|
24
|
+
type EventHandler<E extends Event> = (event: E) => boolean | void;
|
|
25
|
+
type DomEventHandlerX<E extends string> = E extends `ondrag${string}` ? EventHandler<DragEvent> : E extends `onmouse${string}` ? EventHandler<MouseEvent> : E extends `onkey${string}` ? EventHandler<KeyboardEvent> : E extends `onfocus` | `onblur` ? EventHandler<FocusEvent> : E extends `onwheel` ? EventHandler<WheelEvent> : E extends `onpointer${string}` ? EventHandler<PointerEvent> : E extends `ontouch${string}` ? EventHandler<TouchEvent> : E extends `onanimation${string}` ? EventHandler<AnimationEvent> : E extends `ontransition${string}` ? EventHandler<TransitionEvent> : E extends `onload` | `onerror` | `onabort` ? EventHandler<ProgressEvent> : E extends `oninput` | `onchange` | `onsubmit` | `onreset` ? EventHandler<Event> : EventHandler<Event>;
|
|
26
|
+
export type TagProps<T extends HTMLElement = HTMLElement> = TagNativeProps<T> & ElementCommonAttrs & {
|
|
27
|
+
ref?: HtmlRef<T> | RefSetter<T | null>;
|
|
28
|
+
} & Record<`data-${string}`, ScalarNode> & {
|
|
29
|
+
children?: JSX.Element;
|
|
30
|
+
};
|
|
31
|
+
export type SvgRootProps = TagProps<HTMLElement> & {
|
|
32
|
+
xmlns?: string;
|
|
33
|
+
width?: number;
|
|
34
|
+
height?: number;
|
|
35
|
+
viewBox?: string;
|
|
36
|
+
};
|
|
37
|
+
/**
|
|
38
|
+
* It's a whole world of non-implemented types :(. I haven't found any simple
|
|
39
|
+
* way to get it from the default DOM types, so I left a fallback that at least
|
|
40
|
+
* doesn't block SVG tags.
|
|
41
|
+
*/
|
|
42
|
+
export type SvgTagProps = {
|
|
43
|
+
[K in string]?: unknown;
|
|
44
|
+
} & {
|
|
45
|
+
children?: JSX.Element;
|
|
46
|
+
};
|
|
47
|
+
export {};
|
|
48
|
+
//# sourceMappingURL=dom.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dom.d.ts","sourceRoot":"","sources":["../../src/types/dom.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAC7D,OAAO,KAAK,EAAE,OAAO,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAEjD,gDAAgD;AAChD,MAAM,MAAM,OAAO,GAAG,OAAO,GAAG,IAAI,GAAG,OAAO,CAAC;AAE/C,MAAM,MAAM,YAAY,GAEpB,MAAM,GACN,MAAM,GACN,OAAO,GAEP,IAAI,GACJ,SAAS,GAET,QAAQ,CAAC;AAGb,KAAK,SAAS,CAAC,CAAC,SAAS,WAAW,IAAI;KACrC,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,SAAS,KAAK,MAAM,EAAE,GAAG,CAAC,GAAG,KAAK;CACpD,CAAC,MAAM,CAAC,CAAC,CAAC;AAEX;;;GAGG;AACH,KAAK,aAAa,GACd,YAAY,MAAM,EAAE,GACpB,GAAG,MAAM,OAAO,GAChB,SAAS,MAAM,EAAE,GACjB,SAAS,MAAM,EAAE,GACjB,OAAO,MAAM,EAAE,GACf,QAAQ,MAAM,EAAE,GAChB,SAAS,MAAM,EAAE,GACjB,MAAM,MAAM,EAAE,GACd,QAAQ,MAAM,EAAE,GAChB,UAAU,GACV,YAAY,GACZ,YAAY,GACZ,WAAW,GACX,SAAS,GACT,OAAO,GACP,KAAK,GACL,SAAS,GACT,aAAa,GACb,Y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@
|
|
|
1
|
+
import type { ComponentState, ReactComponent } from './component';
|
|
2
|
+
import type { ContextState } from './context';
|
|
3
|
+
import type { UnknownProps, ReactKey } from './core';
|
|
4
|
+
import type { DomNode } from './dom';
|
|
5
|
+
import type { Ref, RefSetter } from './refs';
|
|
6
|
+
/**
|
|
7
|
+
* A single node in the Fiber tree.
|
|
8
|
+
*/
|
|
9
|
+
export type FiberNode = NullFiberNode | FragmentFiberNode | TextFiberNode | TagFiberNode | ComponentFiberNode | ContextFiberNode | PortalFiberNode;
|
|
10
|
+
type CommonFiber = {
|
|
11
|
+
/** Unique (within the given app) ID of the fiber. */
|
|
12
|
+
id: number;
|
|
13
|
+
/** Since we support multiple apps simultaneously this is the ID of the map
|
|
14
|
+
* this node belongs to. */
|
|
15
|
+
appId: number;
|
|
16
|
+
/**
|
|
17
|
+
* The parent fiber node.
|
|
18
|
+
* Note: For the root node it's null.
|
|
19
|
+
*/
|
|
20
|
+
parent: FiberNode;
|
|
21
|
+
/** Lazily calculated position within the fiber tree. */
|
|
22
|
+
level: number | null;
|
|
23
|
+
/**
|
|
24
|
+
* A list of fiber children. For simplicity every fiber has this field. Even
|
|
25
|
+
* though text and fragment-based fibers don't support children.
|
|
26
|
+
*
|
|
27
|
+
* Note: `children` for component fibers is not equal the component's
|
|
28
|
+
* children-prop. A children-prop may be anything. It's used only to run the
|
|
29
|
+
* component. `fiber.children` reflects only the rendered part of the fiber
|
|
30
|
+
* tree. Not the fiber props.
|
|
31
|
+
*/
|
|
32
|
+
children: FiberNode[];
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* false, null, undefined.
|
|
36
|
+
*/
|
|
37
|
+
export type NullFiberNode = CommonFiber & {
|
|
38
|
+
type: 'null';
|
|
39
|
+
/** <!--r:null:id--> */
|
|
40
|
+
element: Comment | null;
|
|
41
|
+
key: ReactKey | null;
|
|
42
|
+
component: null;
|
|
43
|
+
data: null;
|
|
44
|
+
props: null;
|
|
45
|
+
role: null;
|
|
46
|
+
tag: null;
|
|
47
|
+
ref: null;
|
|
48
|
+
};
|
|
49
|
+
/**
|
|
50
|
+
* <Component/>
|
|
51
|
+
*/
|
|
52
|
+
export type ComponentFiberNode = CommonFiber & {
|
|
53
|
+
type: 'component';
|
|
54
|
+
component: ReactComponent<UnknownProps>;
|
|
55
|
+
data: ComponentState;
|
|
56
|
+
props: UnknownProps;
|
|
57
|
+
/**
|
|
58
|
+
* Since components can render everything we never know the element.
|
|
59
|
+
*
|
|
60
|
+
* Note: when component is rendered in the compact mode `element` refers to
|
|
61
|
+
* the only rendered DOM node of one of its child fiber nodes.
|
|
62
|
+
*
|
|
63
|
+
* Note: when `element` refers to <!--r:end:id--> it means it renders a
|
|
64
|
+
* fragment-like content (2+ DOM nodes) that is clamped between
|
|
65
|
+
* <!--r:begin:id--> and <!--r:end:id--> HTML-comment nodes.
|
|
66
|
+
*/
|
|
67
|
+
element: DomNode | null;
|
|
68
|
+
key: ReactKey | null;
|
|
69
|
+
role: null;
|
|
70
|
+
tag: null;
|
|
71
|
+
ref: null;
|
|
72
|
+
};
|
|
73
|
+
/**
|
|
74
|
+
* - "text" in <div>text</div>.
|
|
75
|
+
* - or `scalar` in <div>{scalar}</div> where scalar is a boolean, a number or a
|
|
76
|
+
* string.
|
|
77
|
+
*/
|
|
78
|
+
export type TextFiberNode = CommonFiber & {
|
|
79
|
+
type: 'text';
|
|
80
|
+
props: {
|
|
81
|
+
text: string;
|
|
82
|
+
};
|
|
83
|
+
key: ReactKey | null;
|
|
84
|
+
element: Text | null;
|
|
85
|
+
role: null;
|
|
86
|
+
component: null;
|
|
87
|
+
tag: null;
|
|
88
|
+
ref: null;
|
|
89
|
+
data: null;
|
|
90
|
+
};
|
|
91
|
+
/**
|
|
92
|
+
* createPortal(...);
|
|
93
|
+
*/
|
|
94
|
+
export type PortalFiberNode = CommonFiber & {
|
|
95
|
+
type: 'tag';
|
|
96
|
+
/** A target DOM node. */
|
|
97
|
+
data: HTMLElement;
|
|
98
|
+
key: ReactKey | null;
|
|
99
|
+
role: 'portal';
|
|
100
|
+
element: HTMLElement | null;
|
|
101
|
+
tag: string;
|
|
102
|
+
props: null;
|
|
103
|
+
component: null;
|
|
104
|
+
ref: null;
|
|
105
|
+
};
|
|
106
|
+
/**
|
|
107
|
+
* - <></>
|
|
108
|
+
* - <Fragment/>
|
|
109
|
+
* - […]
|
|
110
|
+
* - {array.map(() => …)}
|
|
111
|
+
*/
|
|
112
|
+
export type FragmentFiberNode = CommonFiber & {
|
|
113
|
+
type: 'fragment';
|
|
114
|
+
key: ReactKey | null;
|
|
115
|
+
/** The same as in ComponentFiberNode. */
|
|
116
|
+
element: Comment | null;
|
|
117
|
+
role: null;
|
|
118
|
+
props: null;
|
|
119
|
+
data: null;
|
|
120
|
+
tag: null;
|
|
121
|
+
component: null;
|
|
122
|
+
ref: null;
|
|
123
|
+
};
|
|
124
|
+
/**
|
|
125
|
+
* <ctx.Provider value={value}/>
|
|
126
|
+
*/
|
|
127
|
+
export type ContextFiberNode<T = unknown> = Omit<FragmentFiberNode, 'role' | 'props' | 'data'> & {
|
|
128
|
+
role: 'context';
|
|
129
|
+
props: {
|
|
130
|
+
value: T;
|
|
131
|
+
};
|
|
132
|
+
data: ContextState<T>;
|
|
133
|
+
};
|
|
134
|
+
export type TagState = {
|
|
135
|
+
/**
|
|
136
|
+
* To avoid running `(add|remove)EventListener` every render we wrap the given
|
|
137
|
+
* event handlers and put the methods in this map. `null` means the first
|
|
138
|
+
* render, when the event handler is not yet set up but is presented in JSX.
|
|
139
|
+
*/
|
|
140
|
+
events: Partial<Record<string, {
|
|
141
|
+
wrapper: EventListener;
|
|
142
|
+
handler: Function | null;
|
|
143
|
+
}>>;
|
|
144
|
+
};
|
|
145
|
+
/**
|
|
146
|
+
* <div>content</div>, <div/>
|
|
147
|
+
*/
|
|
148
|
+
export type TagFiberNode<T = Element> = CommonFiber & {
|
|
149
|
+
type: 'tag';
|
|
150
|
+
tag: string;
|
|
151
|
+
key: ReactKey | null;
|
|
152
|
+
element: T | null;
|
|
153
|
+
data: TagState;
|
|
154
|
+
ref: RefSetter<T | null> | Ref<T | null> | null;
|
|
155
|
+
props: Record<PropertyKey, unknown>;
|
|
156
|
+
role: null;
|
|
157
|
+
component: null;
|
|
158
|
+
};
|
|
159
|
+
/**
|
|
160
|
+
* A wrapper over a Fiber used to compare fibers with their position within the
|
|
161
|
+
* same parent fiber node.
|
|
162
|
+
*/
|
|
163
|
+
export type AuxFiber<T extends FiberNode = FiberNode> = {
|
|
164
|
+
order: number | null;
|
|
165
|
+
fiber: T;
|
|
166
|
+
};
|
|
167
|
+
export type FiberMap = Map<ReactKey, AuxFiber>;
|
|
168
|
+
export {};
|
|
169
|
+
//# sourceMappingURL=fiber.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fiber.d.ts","sourceRoot":"","sources":["../../src/types/fiber.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClE,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AACrD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AACrC,OAAO,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAE7C;;GAEG;AACH,MAAM,MAAM,SAAS,GACjB,aAAa,GACb,iBAAiB,GACjB,aAAa,GACb,YAAY,GACZ,kBAAkB,GAClB,gBAAgB,GAChB,eAAe,CAAC;AAEpB,KAAK,WAAW,GAAG;IACjB,qDAAqD;IACrD,EAAE,EAAE,MAAM,CAAC;IACX;+BAC2B;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd;;;OAGG;IACH,MAAM,EAAE,SAAS,CAAC;IAClB,wDAAwD;IACxD,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB;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;CACH,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,YAAY,CAAC,CAAC,GAAG,OAAO,IAAI,WAAW,GAAG;IACpD,IAAI,EAAE,KAAK,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,QAAQ,GAAG,IAAI,CAAC;IACrB,OAAO,EAAE,CAAC,GAAG,IAAI,CAAC;IAClB,IAAI,EAAE,QAAQ,CAAC;IACf,GAAG,EAAE,SAAS,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC;IAChD,KAAK,EAAE,MAAM,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;IAEpC,IAAI,EAAE,IAAI,CAAC;IACX,SAAS,EAAE,IAAI,CAAC;CACjB,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,QAAQ,CAAC,CAAC,SAAS,SAAS,GAAG,SAAS,IAAI;IACtD,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,KAAK,EAAE,CAAC,CAAC;CACV,CAAC;AACF,MAAM,MAAM,QAAQ,GAAG,GAAG,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fiber.js","sourceRoot":"","sources":["../../src/types/fiber.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { ReactContext } from './context';
|
|
2
|
+
import type { ContextFiberNode } from './fiber';
|
|
3
|
+
import type { Ref } from './refs';
|
|
4
|
+
export type UseStateItem<T = unknown> = {
|
|
5
|
+
type: 'state';
|
|
6
|
+
state: T;
|
|
7
|
+
setter: StateSetter<T>;
|
|
8
|
+
};
|
|
9
|
+
export type UseMemoItem = {
|
|
10
|
+
type: 'memo';
|
|
11
|
+
value: unknown;
|
|
12
|
+
deps: HookDeps;
|
|
13
|
+
};
|
|
14
|
+
export type UseRefItem<T = unknown> = {
|
|
15
|
+
type: 'ref';
|
|
16
|
+
value: Ref<T>;
|
|
17
|
+
};
|
|
18
|
+
export type UseEffectItem = {
|
|
19
|
+
type: 'effect';
|
|
20
|
+
mode: EffectMode;
|
|
21
|
+
fn: EffectHandler;
|
|
22
|
+
destructor: null | (() => void);
|
|
23
|
+
deps: HookDeps | null;
|
|
24
|
+
};
|
|
25
|
+
export type UseContextItem<T = unknown> = {
|
|
26
|
+
type: 'context';
|
|
27
|
+
ctx: ReactContext<T>;
|
|
28
|
+
destructor: () => void;
|
|
29
|
+
providerFiber: ContextFiberNode | null;
|
|
30
|
+
};
|
|
31
|
+
export type HookStateItem = UseStateItem | UseMemoItem | UseRefItem | UseEffectItem | UseContextItem;
|
|
32
|
+
export type HookStore = HookStateItem[];
|
|
33
|
+
/**
|
|
34
|
+
* Deps used to invalidate the hook.
|
|
35
|
+
* e.g., useMemo(..., [deps]);
|
|
36
|
+
*/
|
|
37
|
+
export type HookDeps = unknown[];
|
|
38
|
+
/** const [, setter] = useState(...) */
|
|
39
|
+
export type StateSetter<T> = (valueOrFn: (T extends Function ? (prev: T) => T : T) | ((prev: T) => T)) => void;
|
|
40
|
+
/**
|
|
41
|
+
* In this library useEffect & useLayoutEffect are a little more complex. They
|
|
42
|
+
* support async functions and abort signals. But they are still back-compatible
|
|
43
|
+
* with the original React ones.
|
|
44
|
+
*/
|
|
45
|
+
export type EffectHandler = (signal: AbortSignal) => void | Promise<void> | (() => void);
|
|
46
|
+
export type EffectMode = 'refs' | 'layout' | 'normal';
|
|
47
|
+
//# sourceMappingURL=hooks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hooks.d.ts","sourceRoot":"","sources":["../../src/types/hooks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,SAAS,CAAC;AAChD,OAAO,KAAK,EAAE,GAAG,EAAE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G,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,GACvC,CAAC,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KACjB,IAAI,CAAC;AAEV;;;;GAIG;AACH,MAAM,MAAM,aAAa,GAAG,CAC1B,MAAM,EAAE,WAAW,KAChB,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC;AAEzC,MAAM,MAAM,UAAU,GAElB,MAAM,GAEN,QAAQ,GAER,QAAQ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hooks.js","sourceRoot":"","sources":["../../src/types/hooks.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC;AACtB,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC;AACvB,cAAc,OAAO,CAAC;AACtB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC;AACtB,cAAc,aAAa,CAAC;AAC5B,cAAc,WAAW,CAAC;AAC1B,cAAc,QAAQ,CAAC;AACvB,cAAc,OAAO,CAAC;AACtB,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,QAAQ,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/** A ref produced in `useRef(default)` */
|
|
2
|
+
export type Ref<T> = {
|
|
3
|
+
current: T;
|
|
4
|
+
};
|
|
5
|
+
/**
|
|
6
|
+
* A function-based ref setter.
|
|
7
|
+
* @example
|
|
8
|
+
* <div ref={(node: HTMLDivElement | null) => …}
|
|
9
|
+
* // ^ RefSetter<HTMLDivElement | null>
|
|
10
|
+
**/
|
|
11
|
+
export type RefSetter<T> = (v: T) => void;
|
|
12
|
+
/**
|
|
13
|
+
* HTML Tag refs:
|
|
14
|
+
* @example
|
|
15
|
+
* const ref = useRef<HTMLDivElement>()
|
|
16
|
+
* <div ref={ref}/>
|
|
17
|
+
**/
|
|
18
|
+
export type HtmlRef<T extends HTMLElement | SVGElement> = Ref<T | null | undefined>;
|
|
19
|
+
//# sourceMappingURL=refs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"refs.d.ts","sourceRoot":"","sources":["../../src/types/refs.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,MAAM,MAAM,GAAG,CAAC,CAAC,IAAI;IAAE,OAAO,EAAE,CAAC,CAAA;CAAE,CAAC;AAEpC;;;;;IAKI;AACJ,MAAM,MAAM,SAAS,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,KAAK,IAAI,CAAC;AAE1C;;;;;IAKI;AACJ,MAAM,MAAM,OAAO,CAAC,CAAC,SAAS,WAAW,GAAG,UAAU,IAAI,GAAG,CACzD,CAAC,GACD,IAAI,GACJ,SAAS,CACZ,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"refs.js","sourceRoot":"","sources":["../../src/types/refs.ts"],"names":[],"mappings":""}
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,UAAU,GAAI,CAAC,gDAS3B,CAAC"}
|
package/dist/utils.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,UAAU,GAAG,CACxB,GAAyB,EACzB,IAAI,GAAG,aAAa,EACjB,EAAE,CAAC;IACN,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC;QAChB,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,uBAAuB,CAAC,CAAC;IAClD,CAAC;IAED,OAAO,GAAG,CAAC;AAAA,CACZ,CAAC"}
|