@faiwer/react 0.8.3 → 0.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -14
- package/dist/core/Children.d.ts +11 -0
- package/dist/core/Children.d.ts.map +1 -0
- package/dist/core/Children.js +35 -0
- package/dist/core/Children.js.map +1 -0
- package/dist/core/actions/applyAction.d.ts.map +1 -1
- package/dist/core/actions/applyAction.js +2 -0
- package/dist/core/actions/applyAction.js.map +1 -1
- package/dist/core/actions/createComment.action.d.ts +2 -2
- package/dist/core/actions/createComment.action.d.ts.map +1 -1
- package/dist/core/actions/createComment.action.js +1 -8
- package/dist/core/actions/createComment.action.js.map +1 -1
- package/dist/core/actions/createContainer.action.d.ts +7 -0
- package/dist/core/actions/createContainer.action.d.ts.map +1 -0
- package/dist/core/actions/createContainer.action.js +28 -0
- package/dist/core/actions/createContainer.action.js.map +1 -0
- package/dist/core/actions/createTag.action.d.ts +2 -1
- package/dist/core/actions/createTag.action.d.ts.map +1 -1
- package/dist/core/actions/createTag.action.js +107 -5
- package/dist/core/actions/createTag.action.js.map +1 -1
- package/dist/core/actions/createText.action.d.ts.map +1 -1
- package/dist/core/actions/createText.action.js +2 -5
- package/dist/core/actions/createText.action.js.map +1 -1
- package/dist/core/actions/dom/attributes.d.ts +4 -0
- package/dist/core/actions/dom/attributes.d.ts.map +1 -0
- package/dist/core/actions/dom/attributes.js +56 -0
- package/dist/core/actions/dom/attributes.js.map +1 -0
- package/dist/core/actions/dom/css.d.ts +6 -0
- package/dist/core/actions/dom/css.d.ts.map +1 -0
- package/dist/core/actions/dom/css.js +54 -0
- package/dist/core/actions/dom/css.js.map +1 -0
- package/dist/core/actions/dom/events.d.ts +3 -0
- package/dist/core/actions/dom/events.d.ts.map +1 -0
- package/dist/core/actions/dom/events.js +45 -0
- package/dist/core/actions/dom/events.js.map +1 -0
- package/dist/core/actions/dom/svg.d.ts +7 -0
- package/dist/core/actions/dom/svg.d.ts.map +1 -0
- package/dist/core/actions/dom/svg.js +76 -0
- package/dist/core/actions/dom/svg.js.map +1 -0
- package/dist/core/actions/dom/value.d.ts +17 -0
- package/dist/core/actions/dom/value.d.ts.map +1 -0
- package/dist/core/actions/dom/value.js +204 -0
- package/dist/core/actions/dom/value.js.map +1 -0
- package/dist/core/actions/helpers.d.ts +18 -11
- package/dist/core/actions/helpers.d.ts.map +1 -1
- package/dist/core/actions/helpers.js +78 -68
- package/dist/core/actions/helpers.js.map +1 -1
- package/dist/core/actions/relayout.action.d.ts +2 -1
- package/dist/core/actions/relayout.action.d.ts.map +1 -1
- package/dist/core/actions/relayout.action.js +119 -30
- package/dist/core/actions/relayout.action.js.map +1 -1
- package/dist/core/actions/remove.action.d.ts +3 -2
- package/dist/core/actions/remove.action.d.ts.map +1 -1
- package/dist/core/actions/remove.action.js +22 -18
- package/dist/core/actions/remove.action.js.map +1 -1
- package/dist/core/actions/replace.action.d.ts +1 -1
- package/dist/core/actions/replace.action.d.ts.map +1 -1
- package/dist/core/actions/replace.action.js +36 -11
- package/dist/core/actions/replace.action.js.map +1 -1
- package/dist/core/actions/setAttr.action.d.ts +1 -1
- package/dist/core/actions/setAttr.action.d.ts.map +1 -1
- package/dist/core/actions/setAttr.action.js +55 -87
- package/dist/core/actions/setAttr.action.js.map +1 -1
- package/dist/core/actions/setProps.action.d.ts.map +1 -1
- package/dist/core/actions/setProps.action.js +2 -1
- package/dist/core/actions/setProps.action.js.map +1 -1
- package/dist/core/actions/setRef.action.d.ts +1 -1
- package/dist/core/actions/setRef.action.d.ts.map +1 -1
- package/dist/core/actions/setRef.action.js +5 -6
- package/dist/core/actions/setRef.action.js.map +1 -1
- package/dist/core/actions/setText.action.d.ts.map +1 -1
- package/dist/core/actions/setText.action.js +3 -3
- package/dist/core/actions/setText.action.js.map +1 -1
- package/dist/core/classComponent.d.ts +33 -0
- package/dist/core/classComponent.d.ts.map +1 -0
- package/dist/core/classComponent.js +127 -0
- package/dist/core/classComponent.js.map +1 -0
- package/dist/core/compact.d.ts +10 -29
- package/dist/core/compact.d.ts.map +1 -1
- package/dist/core/compact.js +12 -100
- package/dist/core/compact.js.map +1 -1
- package/dist/core/components.d.ts +2 -2
- package/dist/core/components.d.ts.map +1 -1
- package/dist/core/components.js +22 -5
- package/dist/core/components.js.map +1 -1
- package/dist/core/createElement.d.ts +9 -9
- package/dist/core/createElement.d.ts.map +1 -1
- package/dist/core/createElement.js +19 -3
- package/dist/core/createElement.js.map +1 -1
- package/dist/core/createRoot.js.map +1 -1
- package/dist/core/reactNodeToFiberNode.d.ts.map +1 -1
- package/dist/core/reactNodeToFiberNode.js +6 -1
- package/dist/core/reactNodeToFiberNode.js.map +1 -1
- package/dist/core/reconciliation/app.js +3 -3
- package/dist/core/reconciliation/app.js.map +1 -1
- package/dist/core/reconciliation/collect/fromApp.d.ts.map +1 -1
- package/dist/core/reconciliation/collect/fromApp.js +3 -27
- package/dist/core/reconciliation/collect/fromApp.js.map +1 -1
- package/dist/core/reconciliation/collect/fromChildrenPair.d.ts.map +1 -1
- package/dist/core/reconciliation/collect/fromChildrenPair.js +24 -15
- package/dist/core/reconciliation/collect/fromChildrenPair.js.map +1 -1
- package/dist/core/reconciliation/collect/fromComponent.d.ts +2 -2
- package/dist/core/reconciliation/collect/fromComponent.d.ts.map +1 -1
- package/dist/core/reconciliation/collect/fromComponent.js +4 -8
- package/dist/core/reconciliation/collect/fromComponent.js.map +1 -1
- package/dist/core/reconciliation/collect/fromFiberPair.d.ts.map +1 -1
- package/dist/core/reconciliation/collect/fromFiberPair.js +6 -4
- package/dist/core/reconciliation/collect/fromFiberPair.js.map +1 -1
- package/dist/core/reconciliation/collect/fromNewFiber.d.ts.map +1 -1
- package/dist/core/reconciliation/collect/fromNewFiber.js +7 -15
- package/dist/core/reconciliation/collect/fromNewFiber.js.map +1 -1
- package/dist/core/reconciliation/effects.d.ts.map +1 -1
- package/dist/core/reconciliation/effects.js +0 -5
- package/dist/core/reconciliation/effects.js.map +1 -1
- package/dist/core/reconciliation/errors/ReactError.d.ts +7 -0
- package/dist/core/reconciliation/errors/ReactError.d.ts.map +1 -0
- package/dist/core/reconciliation/errors/ReactError.js +26 -0
- package/dist/core/reconciliation/errors/ReactError.js.map +1 -0
- package/dist/core/reconciliation/errors/stack.d.ts +9 -0
- package/dist/core/reconciliation/errors/stack.d.ts.map +1 -0
- package/dist/core/reconciliation/errors/stack.js +80 -0
- package/dist/core/reconciliation/errors/stack.js.map +1 -0
- package/dist/core/reconciliation/fibers.d.ts +7 -0
- package/dist/core/reconciliation/fibers.d.ts.map +1 -1
- package/dist/core/reconciliation/fibers.js +9 -2
- package/dist/core/reconciliation/fibers.js.map +1 -1
- package/dist/core/reconciliation/heap.d.ts +18 -0
- package/dist/core/reconciliation/heap.d.ts.map +1 -0
- package/dist/core/reconciliation/heap.js +81 -0
- package/dist/core/reconciliation/heap.js.map +1 -0
- package/dist/core/reconciliation/invalidateFiber.d.ts.map +1 -1
- package/dist/core/reconciliation/invalidateFiber.js +10 -4
- package/dist/core/reconciliation/invalidateFiber.js.map +1 -1
- package/dist/core/reconciliation/mount.d.ts.map +1 -1
- package/dist/core/reconciliation/mount.js +17 -7
- package/dist/core/reconciliation/mount.js.map +1 -1
- package/dist/core/reconciliation/postCommit.d.ts +1 -1
- package/dist/core/reconciliation/postCommit.d.ts.map +1 -1
- package/dist/core/reconciliation/postCommit.js +19 -4
- package/dist/core/reconciliation/postCommit.js.map +1 -1
- package/dist/core/reconciliation/queue.d.ts +21 -0
- package/dist/core/reconciliation/queue.d.ts.map +1 -0
- package/dist/core/reconciliation/queue.js +55 -0
- package/dist/core/reconciliation/queue.js.map +1 -0
- package/dist/core/reconciliation/render.js +5 -5
- package/dist/core/reconciliation/render.js.map +1 -1
- package/dist/core/reconciliation/runFiberComponents.d.ts.map +1 -1
- package/dist/core/reconciliation/runFiberComponents.js +2 -1
- package/dist/core/reconciliation/runFiberComponents.js.map +1 -1
- package/dist/core/reconciliation/typeGuards.d.ts +9 -1
- package/dist/core/reconciliation/typeGuards.d.ts.map +1 -1
- package/dist/core/reconciliation/typeGuards.js +25 -0
- package/dist/core/reconciliation/typeGuards.js.map +1 -1
- package/dist/core/reconciliation/validateApp.d.ts +3 -0
- package/dist/core/reconciliation/validateApp.d.ts.map +1 -0
- package/dist/core/reconciliation/validateApp.js +74 -0
- package/dist/core/reconciliation/validateApp.js.map +1 -0
- package/dist/hooks/helpers.d.ts +2 -2
- package/dist/hooks/helpers.d.ts.map +1 -1
- package/dist/hooks/helpers.js +3 -2
- package/dist/hooks/helpers.js.map +1 -1
- package/dist/hooks/index.d.ts +1 -1
- package/dist/hooks/index.d.ts.map +1 -1
- package/dist/hooks/index.js +1 -1
- package/dist/hooks/index.js.map +1 -1
- package/dist/hooks/useContext.d.ts.map +1 -1
- package/dist/hooks/useContext.js +16 -0
- package/dist/hooks/useContext.js.map +1 -1
- package/dist/hooks/useEffect.d.ts +2 -1
- package/dist/hooks/useEffect.d.ts.map +1 -1
- package/dist/hooks/useEffect.js +1 -1
- package/dist/hooks/useEffect.js.map +1 -1
- package/dist/hooks/useRef.d.ts +8 -3
- package/dist/hooks/useRef.d.ts.map +1 -1
- package/dist/hooks/useRef.js +27 -0
- package/dist/hooks/useRef.js.map +1 -1
- package/dist/hooks/useState.d.ts +1 -1
- package/dist/hooks/useState.d.ts.map +1 -1
- package/dist/hooks/useState.js +24 -1
- package/dist/hooks/useState.js.map +1 -1
- package/dist/index.d.ts +8 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -1
- package/dist/jsx-dev-runtime.d.ts +4 -4
- package/dist/jsx-dev-runtime.d.ts.map +1 -1
- package/dist/jsx-dev-runtime.js +4 -4
- package/dist/jsx-dev-runtime.js.map +1 -1
- package/dist/jsx-runtime.d.ts +3 -3
- package/dist/jsx-runtime.d.ts.map +1 -1
- package/dist/jsx-runtime.js +3 -3
- package/dist/jsx-runtime.js.map +1 -1
- package/dist/jsx.d.ts +176 -36
- package/dist/mocks.d.ts +21 -0
- package/dist/mocks.d.ts.map +1 -0
- package/dist/mocks.js +27 -0
- package/dist/mocks.js.map +1 -0
- package/dist/react.d.ts +46 -0
- package/dist/types/actions.d.ts +12 -4
- package/dist/types/actions.d.ts.map +1 -1
- package/dist/types/app.d.ts +17 -2
- package/dist/types/app.d.ts.map +1 -1
- package/dist/types/attributes.d.ts +42 -0
- package/dist/types/attributes.d.ts.map +1 -0
- package/dist/types/attributes.js +2 -0
- package/dist/types/attributes.js.map +1 -0
- package/dist/types/common.d.ts +13 -0
- package/dist/types/common.d.ts.map +1 -0
- package/dist/types/common.js +2 -0
- package/dist/types/common.js.map +1 -0
- package/dist/types/component.d.ts +5 -1
- package/dist/types/component.d.ts.map +1 -1
- package/dist/types/context.d.ts +3 -2
- package/dist/types/context.d.ts.map +1 -1
- package/dist/types/core.d.ts +17 -13
- package/dist/types/core.d.ts.map +1 -1
- package/dist/types/dom.d.ts +23 -27
- package/dist/types/dom.d.ts.map +1 -1
- package/dist/types/events.d.ts +31 -0
- package/dist/types/events.d.ts.map +1 -0
- package/dist/types/events.js +2 -0
- package/dist/types/events.js.map +1 -0
- package/dist/types/fiber.d.ts +31 -11
- package/dist/types/fiber.d.ts.map +1 -1
- package/dist/types/fiber.js +5 -1
- package/dist/types/fiber.js.map +1 -1
- package/dist/types/hooks.d.ts +8 -5
- package/dist/types/hooks.d.ts.map +1 -1
- package/dist/types/react.d.ts +35 -0
- package/dist/types/react.d.ts.map +1 -0
- package/dist/types/react.js +2 -0
- package/dist/types/react.js.map +1 -0
- package/dist/types/refs.d.ts +5 -8
- package/dist/types/refs.d.ts.map +1 -1
- package/package.json +15 -3
- package/dist/core/reconciliation/validateTree.d.ts +0 -6
- package/dist/core/reconciliation/validateTree.d.ts.map +0 -1
- package/dist/core/reconciliation/validateTree.js +0 -48
- package/dist/core/reconciliation/validateTree.js.map +0 -1
package/dist/types/hooks.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import type { ReactContext } from './context';
|
|
2
|
-
import type { ContextFiberNode } from './fiber';
|
|
3
|
-
import type {
|
|
2
|
+
import type { ContextFiberNode, FiberNode } from './fiber';
|
|
3
|
+
import type { RefObject } from './refs';
|
|
4
4
|
export type UseStateItem<T = unknown> = {
|
|
5
5
|
type: 'state';
|
|
6
6
|
state: T;
|
|
7
7
|
setter: StateSetter<T>;
|
|
8
|
+
destructor: null | (() => void);
|
|
9
|
+
move: (newFiber: FiberNode) => void;
|
|
8
10
|
};
|
|
9
11
|
export type UseMemoItem = {
|
|
10
12
|
type: 'memo';
|
|
@@ -13,7 +15,7 @@ export type UseMemoItem = {
|
|
|
13
15
|
};
|
|
14
16
|
export type UseRefItem<T = unknown> = {
|
|
15
17
|
type: 'ref';
|
|
16
|
-
value:
|
|
18
|
+
value: RefObject<T>;
|
|
17
19
|
};
|
|
18
20
|
export type UseEffectItem = {
|
|
19
21
|
type: 'effect';
|
|
@@ -26,6 +28,7 @@ export type UseContextItem<T = unknown> = {
|
|
|
26
28
|
type: 'context';
|
|
27
29
|
ctx: ReactContext<T>;
|
|
28
30
|
destructor: () => void;
|
|
31
|
+
move: (newFiber: FiberNode) => void;
|
|
29
32
|
providerFiber: ContextFiberNode | null;
|
|
30
33
|
};
|
|
31
34
|
export type HookStateItem = UseStateItem | UseMemoItem | UseRefItem | UseEffectItem | UseContextItem;
|
|
@@ -36,12 +39,12 @@ export type HookStore = HookStateItem[];
|
|
|
36
39
|
*/
|
|
37
40
|
export type HookDeps = unknown[];
|
|
38
41
|
/** const [, setter] = useState(...) */
|
|
39
|
-
export type StateSetter<T> = (valueOrFn:
|
|
42
|
+
export type StateSetter<T> = (valueOrFn: T | ((prev: T) => T)) => void;
|
|
40
43
|
/**
|
|
41
44
|
* In this library useEffect & useLayoutEffect are a little more complex. They
|
|
42
45
|
* support async functions and abort signals. But they are still back-compatible
|
|
43
46
|
* with the original React ones.
|
|
44
47
|
*/
|
|
45
48
|
export type EffectHandler = (signal: AbortSignal) => void | Promise<void> | (() => void);
|
|
46
|
-
export type EffectMode = '
|
|
49
|
+
export type EffectMode = 'afterActions' | 'refsUnmount' | 'refsMount' | 'layout' | 'normal';
|
|
47
50
|
//# sourceMappingURL=hooks.d.ts.map
|
|
@@ -1 +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;
|
|
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,SAAS,EAAE,MAAM,SAAS,CAAC;AAC3D,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,QAAQ,CAAC;AAExC,MAAM,MAAM,YAAY,CAAC,CAAC,GAAG,OAAO,IAAI;IACtC,IAAI,EAAE,OAAO,CAAC;IACd,KAAK,EAAE,CAAC,CAAC;IACT,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC;IACvB,UAAU,EAAE,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC;IAChC,IAAI,EAAE,CAAC,QAAQ,EAAE,SAAS,KAAK,IAAI,CAAC;CACrC,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,OAAO,CAAC;IACf,IAAI,EAAE,QAAQ,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,UAAU,CAAC,CAAC,GAAG,OAAO,IAAI;IACpC,IAAI,EAAE,KAAK,CAAC;IACZ,KAAK,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC;CACrB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,IAAI,EAAE,QAAQ,CAAC;IACf,IAAI,EAAE,UAAU,CAAC;IACjB,EAAE,EAAE,aAAa,CAAC;IAClB,UAAU,EAAE,IAAI,GAAG,CAAC,MAAM,IAAI,CAAC,CAAC;IAChC,IAAI,EAAE,QAAQ,GAAG,IAAI,CAAC;CACvB,CAAC;AAEF,MAAM,MAAM,cAAc,CAAC,CAAC,GAAG,OAAO,IAAI;IACxC,IAAI,EAAE,SAAS,CAAC;IAChB,GAAG,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC;IACrB,UAAU,EAAE,MAAM,IAAI,CAAC;IACvB,IAAI,EAAE,CAAC,QAAQ,EAAE,SAAS,KAAK,IAAI,CAAC;IACpC,aAAa,EAAE,gBAAgB,GAAG,IAAI,CAAC;CACxC,CAAC;AAEF,MAAM,MAAM,aAAa,GACrB,YAAY,GACZ,WAAW,GACX,UAAU,GACV,aAAa,GACb,cAAc,CAAC;AAEnB,MAAM,MAAM,SAAS,GAAG,aAAa,EAAE,CAAC;AAExC;;;GAGG;AACH,MAAM,MAAM,QAAQ,GAAG,OAAO,EAAE,CAAC;AAEjC,uCAAuC;AACvC,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI,CAAC,SAAS,EAAE,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,KAAK,IAAI,CAAC;AAEvE;;;;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,cAAc,GAEd,aAAa,GACb,WAAW,GAEX,QAAQ,GAER,QAAQ,CAAC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { ReactContext } from './context';
|
|
2
|
+
import { type ReactComponent } from './component';
|
|
3
|
+
import type { ElementCommonAttrs, UnknownProps } from './core';
|
|
4
|
+
import type { EventHandler, PatchEvent } from './events';
|
|
5
|
+
import type { TagNativeProps } from './attributes';
|
|
6
|
+
import type { TagProps, TagStyles } from './dom';
|
|
7
|
+
import type { Ref } from './refs';
|
|
8
|
+
export type FC<Props extends UnknownProps = UnknownProps> = ReactComponent<Props>;
|
|
9
|
+
export type ReactNode = JSX.Element;
|
|
10
|
+
export type Context<T> = ReactContext<T>;
|
|
11
|
+
export type CSSProperties = TagStyles;
|
|
12
|
+
export type ComponentType<Props extends UnknownProps = UnknownProps> = ReactComponent<Props>;
|
|
13
|
+
export type ForwardRefExoticComponent<Props extends UnknownProps = UnknownProps> = FC<Props>;
|
|
14
|
+
export type ErrorInfo = {
|
|
15
|
+
componentStack: string | null;
|
|
16
|
+
digest?: string | null;
|
|
17
|
+
};
|
|
18
|
+
export type SyntheticEvent<T extends Element = Element, E extends Event = Event> = PatchEvent<T, E>;
|
|
19
|
+
export type ClipboardEvent<T extends Element = Element> = SyntheticEvent<T> & {
|
|
20
|
+
clipboardData: DataTransfer;
|
|
21
|
+
};
|
|
22
|
+
export type FormEvent<T extends Element = Element> = SyntheticEvent<T>;
|
|
23
|
+
export type ChangeEvent<T extends Element = Element> = Omit<SyntheticEvent<T>, 'target'> & {
|
|
24
|
+
target: EventTarget & T;
|
|
25
|
+
};
|
|
26
|
+
export type ChangeEventHandler<T extends Element = Element> = EventHandler<T, Event>;
|
|
27
|
+
export type KeyboardEvent<T extends Element = Element> = PatchEvent<T, globalThis.KeyboardEvent>;
|
|
28
|
+
export type ReactEventHandler<T extends Element = Element> = EventHandler<T, Event>;
|
|
29
|
+
export type HTMLAttributes<T extends Element> = TagNativeProps<T>;
|
|
30
|
+
export type TextareaHTMLAttributes<T extends Element = HTMLTextAreaElement> = TagProps<T>;
|
|
31
|
+
export type InputHTMLAttributes<T extends Element = HTMLInputElement> = TagProps<T>;
|
|
32
|
+
export type RefAttributes<T extends Element> = {
|
|
33
|
+
ref?: Ref<T>;
|
|
34
|
+
} & ElementCommonAttrs;
|
|
35
|
+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CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"react.js","sourceRoot":"","sources":["../../src/types/react.ts"],"names":[],"mappings":""}
|
package/dist/types/refs.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/** A ref produced in `useRef(default)` */
|
|
2
|
-
export type
|
|
2
|
+
export type RefObject<T> = {
|
|
3
3
|
current: T;
|
|
4
4
|
};
|
|
5
5
|
/**
|
|
@@ -8,12 +8,9 @@ export type Ref<T> = {
|
|
|
8
8
|
* <div ref={(node: HTMLDivElement | null) => …}
|
|
9
9
|
* // ^ RefSetter<HTMLDivElement | null>
|
|
10
10
|
**/
|
|
11
|
-
export type RefSetter<T> = (v: T) => void;
|
|
11
|
+
export type RefSetter<T> = (v: T | null) => void;
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
* <div ref={ref}/>
|
|
17
|
-
**/
|
|
18
|
-
export type HtmlRef<T extends HTMLElement | SVGElement> = Ref<T | null | undefined>;
|
|
13
|
+
* Both `RefSetter` or `RefObject`.
|
|
14
|
+
*/
|
|
15
|
+
export type Ref<T> = RefObject<T | null> | RefSetter<T>;
|
|
19
16
|
//# sourceMappingURL=refs.d.ts.map
|
package/dist/types/refs.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"refs.d.ts","sourceRoot":"","sources":["../../src/types/refs.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,MAAM,MAAM,
|
|
1
|
+
{"version":3,"file":"refs.d.ts","sourceRoot":"","sources":["../../src/types/refs.ts"],"names":[],"mappings":"AAAA,0CAA0C;AAC1C,MAAM,MAAM,SAAS,CAAC,CAAC,IAAI;IAAE,OAAO,EAAE,CAAC,CAAA;CAAE,CAAC;AAE1C;;;;;IAKI;AACJ,MAAM,MAAM,SAAS,CAAC,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,GAAG,IAAI,KAAK,IAAI,CAAC;AAEjD;;GAEG;AACH,MAAM,MAAM,GAAG,CAAC,CAAC,IAAI,SAAS,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,8 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@faiwer/react",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.9.0",
|
|
4
4
|
"description": "A hobby project. A naive and simplified React implementation",
|
|
5
|
-
"keywords": [
|
|
5
|
+
"keywords": [
|
|
6
|
+
"react",
|
|
7
|
+
"jsx",
|
|
8
|
+
"hooks",
|
|
9
|
+
"virtual-dom",
|
|
10
|
+
"frontend",
|
|
11
|
+
"ui-library"
|
|
12
|
+
],
|
|
6
13
|
"repository": {
|
|
7
14
|
"type": "git",
|
|
8
15
|
"url": "https://github.com/faiwer/faiwer-react.git"
|
|
@@ -22,6 +29,10 @@
|
|
|
22
29
|
"types": "./dist/index.d.ts",
|
|
23
30
|
"default": "./dist/index.js"
|
|
24
31
|
},
|
|
32
|
+
"./client": {
|
|
33
|
+
"types": "./dist/index.d.ts",
|
|
34
|
+
"default": "./dist/index.js"
|
|
35
|
+
},
|
|
25
36
|
"./jsx-runtime": {
|
|
26
37
|
"types": "./dist/jsx-runtime.d.ts",
|
|
27
38
|
"default": "./dist/jsx-runtime.js"
|
|
@@ -35,7 +46,8 @@
|
|
|
35
46
|
}
|
|
36
47
|
},
|
|
37
48
|
"scripts": {
|
|
38
|
-
"build": "npm run clean && npx tsgo -p tsconfig.build.json && npx tsc-alias -p tsconfig.build.json && cp src/jsx.d.ts dist/jsx.d.ts",
|
|
49
|
+
"build": "npm run clean && npx tsgo -p tsconfig.build.json && npx tsc-alias -p tsconfig.build.json && cp src/jsx.d.ts dist/jsx.d.ts && npm run prepend-dts",
|
|
50
|
+
"prepend-dts": "cp ./src/react.d.ts ./dist && printf '/// <reference path=\"./jsx.d.ts\" />\n/// <reference path=\"./react.d.ts\" />\n' | cat - ./dist/index.d.ts > temp && mv temp ./dist/index.d.ts",
|
|
39
51
|
"clean": "rm -rf dist",
|
|
40
52
|
"prepublishOnly": "npm run build",
|
|
41
53
|
"test": "jest",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validateTree.d.ts","sourceRoot":"","sources":["../../../src/core/reconciliation/validateTree.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAGpD;;GAEG;AACH,eAAO,MAAM,YAAY,0CA+BxB,CAAC"}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { nullthrows } from '../../utils';
|
|
2
|
-
/**
|
|
3
|
-
* Validates the given fiber node and its subnodes. In case of error it throws.
|
|
4
|
-
*/
|
|
5
|
-
export const validateTree = (node, path = '') => {
|
|
6
|
-
// Each rendered node must be associated with at least one real DOM node.
|
|
7
|
-
nullthrows(node.element, `${path}.element`);
|
|
8
|
-
if (node.type === 'tag') {
|
|
9
|
-
if (!node.tag) {
|
|
10
|
-
throw new Error(`${path} has empty "tag" field `);
|
|
11
|
-
}
|
|
12
|
-
const domNode = node.role === 'portal' ? node.data : node.element;
|
|
13
|
-
if (!(domNode instanceof Element)) {
|
|
14
|
-
throw new Error(`${path} doesn't have element`);
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
else if (node.type === 'component' && !node.component) {
|
|
18
|
-
throw new Error(`${path} has empty "component" field `);
|
|
19
|
-
}
|
|
20
|
-
else if (node.role === 'context' && !node.data.ctx) {
|
|
21
|
-
throw new Error(`${path} has no context`);
|
|
22
|
-
}
|
|
23
|
-
else if (node.type === 'text' && !(node.element instanceof Text)) {
|
|
24
|
-
throw new Error(`${path}'s element is not a Text`);
|
|
25
|
-
}
|
|
26
|
-
for (const [idx, child] of node.children.entries()) {
|
|
27
|
-
const label = getFiberPathLabel(child);
|
|
28
|
-
const key = (child.key ?? idx) + `^${label}`;
|
|
29
|
-
if (child.parent !== node) {
|
|
30
|
-
throw new Error(`${path}.${key}.parent is ${child.parent ? 'wrong' : 'empty'}`);
|
|
31
|
-
}
|
|
32
|
-
validateTree(child, `${path}.${key}`);
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
const getFiberPathLabel = (node) => {
|
|
36
|
-
return node.type === 'text' || node.type === 'null'
|
|
37
|
-
? node.type
|
|
38
|
-
: node.type === 'tag'
|
|
39
|
-
? `<${nullthrows(node.tag)}/>`
|
|
40
|
-
: node.type === 'fragment'
|
|
41
|
-
? node.role === 'context'
|
|
42
|
-
? '<ctx/>'
|
|
43
|
-
: '[]'
|
|
44
|
-
: node.type === 'component'
|
|
45
|
-
? `<${node.component.name || 'Comp'}/>`
|
|
46
|
-
: 'unknown';
|
|
47
|
-
};
|
|
48
|
-
//# sourceMappingURL=validateTree.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validateTree.js","sourceRoot":"","sources":["../../../src/core/reconciliation/validateTree.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD;;GAEG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,IAAe,EAAE,IAAI,GAAG,EAAE,EAAQ,EAAE,CAAC;IAChE,yEAAyE;IACzE,UAAU,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,IAAI,UAAU,CAAC,CAAC;IAE5C,IAAI,IAAI,CAAC,IAAI,KAAK,KAAK,EAAE,CAAC;QACxB,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC;YACd,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,yBAAyB,CAAC,CAAC;QACpD,CAAC;QAED,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC;QAClE,IAAI,CAAC,CAAC,OAAO,YAAY,OAAO,CAAC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