@rectify-dev/core 2.0.0 → 2.0.2
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/dist/chunk-2FA4QXYL.js +27 -0
- package/dist/chunk-2FA4QXYL.js.map +1 -0
- package/dist/chunk-AJJIEZ7G.cjs +31 -0
- package/dist/chunk-AJJIEZ7G.cjs.map +1 -0
- package/dist/index.cjs +164 -163
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +133 -4
- package/dist/index.d.ts +133 -4
- package/dist/index.js +4 -6
- package/dist/index.js.map +1 -1
- package/dist/jsx-runtime.cjs +4 -4
- package/dist/jsx-runtime.js +1 -1
- package/dist/runtime.cjs +3 -3
- package/dist/runtime.js +1 -1
- package/package.json +6 -4
- package/dist/chunk-3ZHJJ32B.js +0 -98
- package/dist/chunk-3ZHJJ32B.js.map +0 -1
- package/dist/chunk-S5YX7TXF.cjs +0 -112
- package/dist/chunk-S5YX7TXF.cjs.map +0 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,8 +1,24 @@
|
|
|
1
|
-
import { FC } from '@rectify-dev/shared';
|
|
1
|
+
import { RectifyNode, FC, Fiber } from '@rectify-dev/shared';
|
|
2
2
|
export { AnchorHTMLAttributes, AriaAttributes, AudioHTMLAttributes, ButtonHTMLAttributes, CSSProperties, FC, FormHTMLAttributes, HTMLAttributes, IframeHTMLAttributes, ImgHTMLAttributes, InputHTMLAttributes, LabelHTMLAttributes, MetaHTMLAttributes, OptGroupHTMLAttributes, OptionHTMLAttributes, RectifyEventHandlers, RectifyIntrinsicElements, ScriptHTMLAttributes, SelectHTMLAttributes, SyntheticAnimationEvent, SyntheticChangeEvent, SyntheticClipboardEvent, SyntheticDragEvent, SyntheticEvent as SyntheticEventType, SyntheticFocusEvent, SyntheticInputEvent, SyntheticKeyboardEvent, SyntheticMouseEvent, SyntheticPointerEvent, SyntheticSubmitEvent, SyntheticTouchEvent, SyntheticTransitionEvent, SyntheticWheelEvent, TextareaHTMLAttributes, VideoHTMLAttributes } from '@rectify-dev/shared';
|
|
3
|
-
export { SyntheticEvent, createRoot } from '@rectify-dev/dom';
|
|
4
3
|
export { Fragment, jsx } from './runtime.cjs';
|
|
5
|
-
|
|
4
|
+
|
|
5
|
+
type RectifyDomRoot = {
|
|
6
|
+
render: (node: RectifyNode) => void;
|
|
7
|
+
unmount: () => void;
|
|
8
|
+
};
|
|
9
|
+
declare const createRoot: (container: Element) => RectifyDomRoot;
|
|
10
|
+
|
|
11
|
+
type AnyNativeEvent = Event | KeyboardEvent | MouseEvent | TouchEvent;
|
|
12
|
+
|
|
13
|
+
declare class SyntheticEvent {
|
|
14
|
+
target: Element | null;
|
|
15
|
+
currentTarget: Element | null;
|
|
16
|
+
nativeEvent: AnyNativeEvent;
|
|
17
|
+
private propagationStopped;
|
|
18
|
+
constructor(nativeEvent: AnyNativeEvent);
|
|
19
|
+
stopPropagation(): void;
|
|
20
|
+
isPropagationStopped(): boolean;
|
|
21
|
+
}
|
|
6
22
|
|
|
7
23
|
type MemoComponent<P = any> = FC<P> & {
|
|
8
24
|
/** Marks this as a memo-wrapped component for the reconciler. */
|
|
@@ -28,4 +44,117 @@ type MemoComponent<P = any> = FC<P> & {
|
|
|
28
44
|
*/
|
|
29
45
|
declare function memo<P = any>(Component: FC<P>, compare?: (prevProps: P, nextProps: P) => boolean): MemoComponent<P>;
|
|
30
46
|
|
|
31
|
-
|
|
47
|
+
type StateUpdater<S> = S | ((prevState: S) => S);
|
|
48
|
+
type StateDispatcher<S> = (updater: StateUpdater<S>) => void;
|
|
49
|
+
|
|
50
|
+
declare function useState<S>(): [S | undefined, StateDispatcher<S | undefined>];
|
|
51
|
+
declare function useState<S>(initialState: S): [S, StateDispatcher<S>];
|
|
52
|
+
declare function useState<S>(initialState: () => S): [S, StateDispatcher<S>];
|
|
53
|
+
|
|
54
|
+
declare function useEffect(create: () => void | (() => void), deps?: any[]): void;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Like `useEffect`, but fires **synchronously after every DOM mutation** and
|
|
58
|
+
* before the browser has a chance to paint. Use this when you need to read
|
|
59
|
+
* layout or synchronously re-style the DOM (tooltips, scroll restoration,
|
|
60
|
+
* measuring element sizes, etc.).
|
|
61
|
+
*
|
|
62
|
+
* Prefer `useEffect` for everything else — `useLayoutEffect` blocks the paint.
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* useLayoutEffect(() => {
|
|
66
|
+
* const { height } = ref.current.getBoundingClientRect();
|
|
67
|
+
* setTooltipTop(-height);
|
|
68
|
+
* }, []);
|
|
69
|
+
*/
|
|
70
|
+
declare function useLayoutEffect(create: () => void | (() => void), deps?: any[]): void;
|
|
71
|
+
|
|
72
|
+
type RefObject<T> = {
|
|
73
|
+
current: T;
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* Returns a stable mutable ref object whose `.current` property is initialised
|
|
77
|
+
* to `initialValue`. The same object is returned on every render — updating
|
|
78
|
+
* `.current` does NOT trigger a re-render.
|
|
79
|
+
*
|
|
80
|
+
* Two common uses:
|
|
81
|
+
* 1. Hold a DOM node: const el = useRef<HTMLDivElement>(null)
|
|
82
|
+
* 2. Hold a mutable value across renders without causing re-renders.
|
|
83
|
+
*/
|
|
84
|
+
declare function useRef<T>(initialValue: T): RefObject<T>;
|
|
85
|
+
declare function useRef<T>(initialValue: T | null): RefObject<T | null>;
|
|
86
|
+
declare function useRef<T = undefined>(): RefObject<T | undefined>;
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Returns a memoized value. `factory` is only re-executed when one of the
|
|
90
|
+
* `deps` changes (using `Object.is` comparison), otherwise the cached value
|
|
91
|
+
* from the previous render is returned unchanged.
|
|
92
|
+
*
|
|
93
|
+
* @example
|
|
94
|
+
* const sorted = useMemo(() => [...list].sort(), [list]);
|
|
95
|
+
*/
|
|
96
|
+
declare function useMemo<T>(factory: () => T, deps: any[]): T;
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Returns a memoized callback. The same function reference is returned on
|
|
100
|
+
* every render unless one of the `deps` changes.
|
|
101
|
+
*
|
|
102
|
+
* This is sugar over `useMemo(() => fn, deps)` — it keeps function identity
|
|
103
|
+
* stable so child components that compare props by reference don't re-render
|
|
104
|
+
* unnecessarily.
|
|
105
|
+
*
|
|
106
|
+
* @example
|
|
107
|
+
* const handleClick = useCallback(() => doSomething(id), [id]);
|
|
108
|
+
*/
|
|
109
|
+
declare function useCallback<T extends (...args: any[]) => any>(callback: T, deps: any[]): T;
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* A context object that is also its own Provider component.
|
|
113
|
+
* Both forms are equivalent:
|
|
114
|
+
* jsx(MyContext, { value, children }) // Context as Provider
|
|
115
|
+
* jsx(MyContext.Provider, { value, children }) // Classic Provider form
|
|
116
|
+
*/
|
|
117
|
+
type RectifyContext<T> = {
|
|
118
|
+
(props: {
|
|
119
|
+
value: T;
|
|
120
|
+
children?: any;
|
|
121
|
+
}): null;
|
|
122
|
+
/** Self-reference used by the reconciler to identify Provider fibers. */
|
|
123
|
+
_context: RectifyContext<T>;
|
|
124
|
+
_defaultValue: T;
|
|
125
|
+
_subscribers: Set<Fiber>;
|
|
126
|
+
/** Alias to self — `Context.Provider === Context`. */
|
|
127
|
+
Provider: RectifyContext<T>;
|
|
128
|
+
};
|
|
129
|
+
/**
|
|
130
|
+
* Creates a new context. The returned object is itself a Provider component,
|
|
131
|
+
* so both forms below are equivalent:
|
|
132
|
+
*
|
|
133
|
+
* @example
|
|
134
|
+
* const ThemeCtx = createContext<'light' | 'dark'>('light');
|
|
135
|
+
*
|
|
136
|
+
* // Option A – Context used directly as Provider
|
|
137
|
+
* jsx(ThemeCtx, { value: 'dark', children: ... })
|
|
138
|
+
*
|
|
139
|
+
* // Option B – Classic .Provider form
|
|
140
|
+
* jsx(ThemeCtx.Provider, { value: 'dark', children: ... })
|
|
141
|
+
*/
|
|
142
|
+
declare function createContext<T>(defaultValue: T): RectifyContext<T>;
|
|
143
|
+
/**
|
|
144
|
+
* Reads the current value of `context` for the calling component.
|
|
145
|
+
*
|
|
146
|
+
* Walks up the fiber tree to the nearest matching Provider and reads its
|
|
147
|
+
* `pendingProps.value` directly — no render-time stack required. This means
|
|
148
|
+
* the correct value is always returned even when the Provider did not
|
|
149
|
+
* re-render in the current pass.
|
|
150
|
+
*
|
|
151
|
+
* The component re-renders whenever the nearest Provider supplies a new value
|
|
152
|
+
* (compared with `Object.is`). Unlike other hooks this does NOT consume a
|
|
153
|
+
* hook slot and may be called conditionally.
|
|
154
|
+
*
|
|
155
|
+
* @example
|
|
156
|
+
* const theme = useContext(ThemeCtx); // 'light' | 'dark'
|
|
157
|
+
*/
|
|
158
|
+
declare function useContext<T>(context: RectifyContext<T>): T;
|
|
159
|
+
|
|
160
|
+
export { type MemoComponent, type RectifyContext, type RefObject, SyntheticEvent, createContext, createRoot, memo, useCallback, useContext, useEffect, useLayoutEffect, useMemo, useRef, useState };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,24 @@
|
|
|
1
|
-
import { FC } from '@rectify-dev/shared';
|
|
1
|
+
import { RectifyNode, FC, Fiber } from '@rectify-dev/shared';
|
|
2
2
|
export { AnchorHTMLAttributes, AriaAttributes, AudioHTMLAttributes, ButtonHTMLAttributes, CSSProperties, FC, FormHTMLAttributes, HTMLAttributes, IframeHTMLAttributes, ImgHTMLAttributes, InputHTMLAttributes, LabelHTMLAttributes, MetaHTMLAttributes, OptGroupHTMLAttributes, OptionHTMLAttributes, RectifyEventHandlers, RectifyIntrinsicElements, ScriptHTMLAttributes, SelectHTMLAttributes, SyntheticAnimationEvent, SyntheticChangeEvent, SyntheticClipboardEvent, SyntheticDragEvent, SyntheticEvent as SyntheticEventType, SyntheticFocusEvent, SyntheticInputEvent, SyntheticKeyboardEvent, SyntheticMouseEvent, SyntheticPointerEvent, SyntheticSubmitEvent, SyntheticTouchEvent, SyntheticTransitionEvent, SyntheticWheelEvent, TextareaHTMLAttributes, VideoHTMLAttributes } from '@rectify-dev/shared';
|
|
3
|
-
export { SyntheticEvent, createRoot } from '@rectify-dev/dom';
|
|
4
3
|
export { Fragment, jsx } from './runtime.js';
|
|
5
|
-
|
|
4
|
+
|
|
5
|
+
type RectifyDomRoot = {
|
|
6
|
+
render: (node: RectifyNode) => void;
|
|
7
|
+
unmount: () => void;
|
|
8
|
+
};
|
|
9
|
+
declare const createRoot: (container: Element) => RectifyDomRoot;
|
|
10
|
+
|
|
11
|
+
type AnyNativeEvent = Event | KeyboardEvent | MouseEvent | TouchEvent;
|
|
12
|
+
|
|
13
|
+
declare class SyntheticEvent {
|
|
14
|
+
target: Element | null;
|
|
15
|
+
currentTarget: Element | null;
|
|
16
|
+
nativeEvent: AnyNativeEvent;
|
|
17
|
+
private propagationStopped;
|
|
18
|
+
constructor(nativeEvent: AnyNativeEvent);
|
|
19
|
+
stopPropagation(): void;
|
|
20
|
+
isPropagationStopped(): boolean;
|
|
21
|
+
}
|
|
6
22
|
|
|
7
23
|
type MemoComponent<P = any> = FC<P> & {
|
|
8
24
|
/** Marks this as a memo-wrapped component for the reconciler. */
|
|
@@ -28,4 +44,117 @@ type MemoComponent<P = any> = FC<P> & {
|
|
|
28
44
|
*/
|
|
29
45
|
declare function memo<P = any>(Component: FC<P>, compare?: (prevProps: P, nextProps: P) => boolean): MemoComponent<P>;
|
|
30
46
|
|
|
31
|
-
|
|
47
|
+
type StateUpdater<S> = S | ((prevState: S) => S);
|
|
48
|
+
type StateDispatcher<S> = (updater: StateUpdater<S>) => void;
|
|
49
|
+
|
|
50
|
+
declare function useState<S>(): [S | undefined, StateDispatcher<S | undefined>];
|
|
51
|
+
declare function useState<S>(initialState: S): [S, StateDispatcher<S>];
|
|
52
|
+
declare function useState<S>(initialState: () => S): [S, StateDispatcher<S>];
|
|
53
|
+
|
|
54
|
+
declare function useEffect(create: () => void | (() => void), deps?: any[]): void;
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* Like `useEffect`, but fires **synchronously after every DOM mutation** and
|
|
58
|
+
* before the browser has a chance to paint. Use this when you need to read
|
|
59
|
+
* layout or synchronously re-style the DOM (tooltips, scroll restoration,
|
|
60
|
+
* measuring element sizes, etc.).
|
|
61
|
+
*
|
|
62
|
+
* Prefer `useEffect` for everything else — `useLayoutEffect` blocks the paint.
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* useLayoutEffect(() => {
|
|
66
|
+
* const { height } = ref.current.getBoundingClientRect();
|
|
67
|
+
* setTooltipTop(-height);
|
|
68
|
+
* }, []);
|
|
69
|
+
*/
|
|
70
|
+
declare function useLayoutEffect(create: () => void | (() => void), deps?: any[]): void;
|
|
71
|
+
|
|
72
|
+
type RefObject<T> = {
|
|
73
|
+
current: T;
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* Returns a stable mutable ref object whose `.current` property is initialised
|
|
77
|
+
* to `initialValue`. The same object is returned on every render — updating
|
|
78
|
+
* `.current` does NOT trigger a re-render.
|
|
79
|
+
*
|
|
80
|
+
* Two common uses:
|
|
81
|
+
* 1. Hold a DOM node: const el = useRef<HTMLDivElement>(null)
|
|
82
|
+
* 2. Hold a mutable value across renders without causing re-renders.
|
|
83
|
+
*/
|
|
84
|
+
declare function useRef<T>(initialValue: T): RefObject<T>;
|
|
85
|
+
declare function useRef<T>(initialValue: T | null): RefObject<T | null>;
|
|
86
|
+
declare function useRef<T = undefined>(): RefObject<T | undefined>;
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Returns a memoized value. `factory` is only re-executed when one of the
|
|
90
|
+
* `deps` changes (using `Object.is` comparison), otherwise the cached value
|
|
91
|
+
* from the previous render is returned unchanged.
|
|
92
|
+
*
|
|
93
|
+
* @example
|
|
94
|
+
* const sorted = useMemo(() => [...list].sort(), [list]);
|
|
95
|
+
*/
|
|
96
|
+
declare function useMemo<T>(factory: () => T, deps: any[]): T;
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* Returns a memoized callback. The same function reference is returned on
|
|
100
|
+
* every render unless one of the `deps` changes.
|
|
101
|
+
*
|
|
102
|
+
* This is sugar over `useMemo(() => fn, deps)` — it keeps function identity
|
|
103
|
+
* stable so child components that compare props by reference don't re-render
|
|
104
|
+
* unnecessarily.
|
|
105
|
+
*
|
|
106
|
+
* @example
|
|
107
|
+
* const handleClick = useCallback(() => doSomething(id), [id]);
|
|
108
|
+
*/
|
|
109
|
+
declare function useCallback<T extends (...args: any[]) => any>(callback: T, deps: any[]): T;
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* A context object that is also its own Provider component.
|
|
113
|
+
* Both forms are equivalent:
|
|
114
|
+
* jsx(MyContext, { value, children }) // Context as Provider
|
|
115
|
+
* jsx(MyContext.Provider, { value, children }) // Classic Provider form
|
|
116
|
+
*/
|
|
117
|
+
type RectifyContext<T> = {
|
|
118
|
+
(props: {
|
|
119
|
+
value: T;
|
|
120
|
+
children?: any;
|
|
121
|
+
}): null;
|
|
122
|
+
/** Self-reference used by the reconciler to identify Provider fibers. */
|
|
123
|
+
_context: RectifyContext<T>;
|
|
124
|
+
_defaultValue: T;
|
|
125
|
+
_subscribers: Set<Fiber>;
|
|
126
|
+
/** Alias to self — `Context.Provider === Context`. */
|
|
127
|
+
Provider: RectifyContext<T>;
|
|
128
|
+
};
|
|
129
|
+
/**
|
|
130
|
+
* Creates a new context. The returned object is itself a Provider component,
|
|
131
|
+
* so both forms below are equivalent:
|
|
132
|
+
*
|
|
133
|
+
* @example
|
|
134
|
+
* const ThemeCtx = createContext<'light' | 'dark'>('light');
|
|
135
|
+
*
|
|
136
|
+
* // Option A – Context used directly as Provider
|
|
137
|
+
* jsx(ThemeCtx, { value: 'dark', children: ... })
|
|
138
|
+
*
|
|
139
|
+
* // Option B – Classic .Provider form
|
|
140
|
+
* jsx(ThemeCtx.Provider, { value: 'dark', children: ... })
|
|
141
|
+
*/
|
|
142
|
+
declare function createContext<T>(defaultValue: T): RectifyContext<T>;
|
|
143
|
+
/**
|
|
144
|
+
* Reads the current value of `context` for the calling component.
|
|
145
|
+
*
|
|
146
|
+
* Walks up the fiber tree to the nearest matching Provider and reads its
|
|
147
|
+
* `pendingProps.value` directly — no render-time stack required. This means
|
|
148
|
+
* the correct value is always returned even when the Provider did not
|
|
149
|
+
* re-render in the current pass.
|
|
150
|
+
*
|
|
151
|
+
* The component re-renders whenever the nearest Provider supplies a new value
|
|
152
|
+
* (compared with `Object.is`). Unlike other hooks this does NOT consume a
|
|
153
|
+
* hook slot and may be called conditionally.
|
|
154
|
+
*
|
|
155
|
+
* @example
|
|
156
|
+
* const theme = useContext(ThemeCtx); // 'light' | 'dark'
|
|
157
|
+
*/
|
|
158
|
+
declare function useContext<T>(context: RectifyContext<T>): T;
|
|
159
|
+
|
|
160
|
+
export { type MemoComponent, type RectifyContext, type RefObject, SyntheticEvent, createContext, createRoot, memo, useCallback, useContext, useEffect, useLayoutEffect, useMemo, useRef, useState };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
import { __name
|
|
2
|
-
export { Fragment, jsx } from './chunk-
|
|
1
|
+
import { __name } from './chunk-2FA4QXYL.js';
|
|
2
|
+
export { Fragment, jsx } from './chunk-2FA4QXYL.js';
|
|
3
|
+
import { isFunction, shallowEqual, createElementFromRectifyNode, isValidRectifyElement, isArray, isPlainObject, omit, RECTIFY_FRAGMENT_TYPE, RECTIFY_TEXT_TYPE, RECTIFY_ELEMENT_TYPE } from '@rectify-dev/shared';
|
|
4
|
+
export { FC } from '@rectify-dev/shared';
|
|
3
5
|
|
|
4
6
|
// ../rectify-dom-binding/src/events/RectifyEventRegistry.ts
|
|
5
7
|
var allNativeEvents = /* @__PURE__ */ new Set();
|
|
@@ -262,8 +264,6 @@ var HostRoot = /* @__PURE__ */ Symbol.for("rectify.host_root");
|
|
|
262
264
|
var FragmentComponent = /* @__PURE__ */ Symbol.for("rectify.fragment_component");
|
|
263
265
|
var ContextProvider = /* @__PURE__ */ Symbol.for("rectify.context_provider");
|
|
264
266
|
var MemoComponent = /* @__PURE__ */ Symbol.for("rectify.memo_component");
|
|
265
|
-
|
|
266
|
-
// ../rectify-reconciler/src/RectifyFiberService.ts
|
|
267
267
|
var addFlagToFiber = /* @__PURE__ */ __name((fiber, flag) => {
|
|
268
268
|
if (hasFlagOnFiber(fiber, flag)) return;
|
|
269
269
|
fiber.flags |= flag;
|
|
@@ -473,8 +473,6 @@ var withHooks = /* @__PURE__ */ __name((wip, Component) => {
|
|
|
473
473
|
}, "NewComponent");
|
|
474
474
|
return NewComponent;
|
|
475
475
|
}, "withHooks");
|
|
476
|
-
|
|
477
|
-
// ../rectify-hook/src/RectifyHookUseState.ts
|
|
478
476
|
var getInitialState = /* @__PURE__ */ __name((initialState) => isFunction(initialState) ? initialState() : initialState, "getInitialState");
|
|
479
477
|
var getState = /* @__PURE__ */ __name((update, prevState) => isFunction(update) ? update(prevState) : update, "getState");
|
|
480
478
|
function useState(initialState) {
|