@rectify-dev/core 2.1.0 → 2.4.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/dist/index.d.cts CHANGED
@@ -1,5 +1,6 @@
1
- import { RectifyNode, FC, Fiber } from '@rectify-dev/shared';
2
- export { AnchorHTMLAttributes, AriaAttributes, AudioHTMLAttributes, ButtonHTMLAttributes, CSSProperties, FC, FormHTMLAttributes, HTMLAttributes, IframeHTMLAttributes, ImgHTMLAttributes, InputHTMLAttributes, LabelHTMLAttributes, MetaHTMLAttributes, OptGroupHTMLAttributes, OptionHTMLAttributes, RectifyEventHandlers, RectifyIntrinsicElements, RectifyNode, ScriptHTMLAttributes, SelectHTMLAttributes, SyntheticAnimationEvent, SyntheticChangeEvent, SyntheticClipboardEvent, SyntheticDragEvent, SyntheticEvent as SyntheticEventType, SyntheticFocusEvent, SyntheticInputEvent, SyntheticKeyboardEvent, SyntheticMouseEvent, SyntheticPointerEvent, SyntheticSubmitEvent, SyntheticTouchEvent, SyntheticTransitionEvent, SyntheticWheelEvent, TextareaHTMLAttributes, VideoHTMLAttributes } from '@rectify-dev/shared';
1
+ import * as _rectify_dev_shared from '@rectify-dev/shared';
2
+ import { RectifyNode, RectifyKey, RectifyPortal, FC, LazyComponent, SuspenseProps, Fiber } from '@rectify-dev/shared';
3
+ export { AnchorHTMLAttributes, AriaAttributes, AudioHTMLAttributes, ButtonHTMLAttributes, CSSProperties, FC, FormHTMLAttributes, HTMLAttributes, IframeHTMLAttributes, ImgHTMLAttributes, InputHTMLAttributes, LabelHTMLAttributes, MetaHTMLAttributes, OptGroupHTMLAttributes, OptionHTMLAttributes, RectifyEventHandlers, RectifyIntrinsicElements, RectifyNode, RectifyPortal, ScriptHTMLAttributes, SelectHTMLAttributes, SuspenseProps, SyntheticAnimationEvent, SyntheticChangeEvent, SyntheticClipboardEvent, SyntheticDragEvent, SyntheticEvent as SyntheticEventType, SyntheticFocusEvent, SyntheticInputEvent, SyntheticKeyboardEvent, SyntheticMouseEvent, SyntheticPointerEvent, SyntheticSubmitEvent, SyntheticTouchEvent, SyntheticTransitionEvent, SyntheticWheelEvent, TextareaHTMLAttributes, VideoHTMLAttributes } from '@rectify-dev/shared';
3
4
  export { Fragment, jsx } from './runtime.cjs';
4
5
 
5
6
  type RectifyDomRoot = {
@@ -8,6 +9,8 @@ type RectifyDomRoot = {
8
9
  };
9
10
  declare const createRoot: (container: Element) => RectifyDomRoot;
10
11
 
12
+ declare const createPortal: (children: RectifyNode, container: Element, key?: RectifyKey) => RectifyPortal;
13
+
11
14
  type AnyNativeEvent = Event | KeyboardEvent | MouseEvent | TouchEvent;
12
15
 
13
16
  declare class SyntheticEvent {
@@ -44,6 +47,109 @@ type MemoComponent<P = any> = FC<P> & {
44
47
  */
45
48
  declare function memo<P = any>(Component: FC<P>, compare?: (prevProps: P, nextProps: P) => boolean): MemoComponent<P>;
46
49
 
50
+ /**
51
+ * Lazily loads a component via a dynamic import factory.
52
+ *
53
+ * The returned object is used as a JSX element type and behaves like a normal
54
+ * function component once loaded. While loading it suspends the nearest
55
+ * `<Suspense>` boundary, which renders its `fallback` instead.
56
+ *
57
+ * @example
58
+ * const HeavyChart = lazy(() => import("./HeavyChart"));
59
+ *
60
+ * function App() {
61
+ * return (
62
+ * <Suspense fallback={<Spinner />}>
63
+ * <HeavyChart />
64
+ * </Suspense>
65
+ * );
66
+ * }
67
+ */
68
+ declare const lazy: <T>(factory: () => Promise<{
69
+ default: T;
70
+ } | T>) => LazyComponent<T>;
71
+
72
+ /**
73
+ * Catches thrown promises from any child (including lazy components) and
74
+ * renders `fallback` until they resolve.
75
+ *
76
+ * Marked as a sentinel with `_isSuspense` so the reconciler can identify it
77
+ * without a dedicated $$typeof symbol — consistent with how MemoComponent
78
+ * and ContextProvider are detected.
79
+ *
80
+ * @example
81
+ * <Suspense fallback={<Spinner />}>
82
+ * <LazyPage />
83
+ * </Suspense>
84
+ */
85
+ declare const Suspense: (_props: SuspenseProps) => null;
86
+
87
+ /**
88
+ * Base class for Rectify class components.
89
+ *
90
+ * @example
91
+ * class Counter extends Component<{}, { count: number }> {
92
+ * state = { count: 0 };
93
+ *
94
+ * render() {
95
+ * return (
96
+ * <button onClick={() => this.setState({ count: this.state.count + 1 })}>
97
+ * {this.state.count}
98
+ * </button>
99
+ * );
100
+ * }
101
+ * }
102
+ */
103
+ declare class Component<P = {}, S = {}> {
104
+ /** Marks this as a class component for the reconciler. */
105
+ static readonly _isClassComponent = true;
106
+ props: P;
107
+ state: S;
108
+ /**
109
+ * @internal Set by the reconciler when the instance is created so
110
+ * `setState` can enqueue a re-render on the correct fiber.
111
+ */
112
+ _fiber: _rectify_dev_shared.Fiber | null;
113
+ /**
114
+ * @internal Snapshots taken by the reconciler in beginWork before each
115
+ * update render so that `componentDidUpdate` receives the correct prev values.
116
+ * Cleared after `componentDidUpdate` is called.
117
+ */
118
+ _prevProps: P | undefined;
119
+ _prevState: S | undefined;
120
+ /**
121
+ * @internal Queue of pending setState updates, flushed by the reconciler
122
+ * during beginWork so that prevState snapshots can be taken first.
123
+ */
124
+ _pendingStateQueue: Array<Partial<S> | ((prevState: S, prevProps: P) => Partial<S>)>;
125
+ constructor(props: P);
126
+ /** Called once, immediately after the component is inserted into the DOM. */
127
+ componentDidMount?(): void;
128
+ /**
129
+ * Called after every re-render.
130
+ * @param prevProps — props before the update
131
+ * @param prevState — state before the update
132
+ */
133
+ componentDidUpdate?(prevProps: P, prevState: S): void;
134
+ /** Called immediately before the component is removed from the DOM. */
135
+ componentWillUnmount?(): void;
136
+ /**
137
+ * Return false to skip re-rendering when props or state haven't changed.
138
+ * Defaults to always re-render.
139
+ */
140
+ shouldComponentUpdate?(nextProps: P, nextState: S): boolean;
141
+ /**
142
+ * Merges `partialState` into the current state and schedules a re-render.
143
+ * Accepts either a plain partial state object or an updater function.
144
+ */
145
+ setState(partialState: Partial<S> | ((prevState: S, prevProps: P) => Partial<S>)): void;
146
+ /**
147
+ * Must be implemented by every class component.
148
+ * Returns the subtree to render.
149
+ */
150
+ render(): RectifyNode;
151
+ }
152
+
47
153
  type StateUpdater<S> = S | ((prevState: S) => S);
48
154
  type StateDispatcher<S> = (updater: StateUpdater<S>) => void;
49
155
 
@@ -162,4 +268,22 @@ declare function createContext<T>(defaultValue: T): RectifyContext<T>;
162
268
  */
163
269
  declare function useContext<T>(context: RectifyContext<T>): T;
164
270
 
165
- export { type Dispatch, type MemoComponent, type RectifyContext, type Reducer, type RefObject, SyntheticEvent, createContext, createRoot, memo, useCallback, useContext, useEffect, useLayoutEffect, useMemo, useReducer, useRef, useState };
271
+ /**
272
+ * Returns a stable, globally unique ID string that is consistent across
273
+ * server and client renders within the same component instance.
274
+ *
275
+ * The ID is generated once on mount and returned unchanged on every
276
+ * subsequent render — it never changes for the lifetime of the component.
277
+ *
278
+ * @example
279
+ * const inputId = useId();
280
+ * return (
281
+ * <>
282
+ * <label htmlFor={inputId}>Name</label>
283
+ * <input id={inputId} />
284
+ * </>
285
+ * );
286
+ */
287
+ declare const useId: () => string;
288
+
289
+ export { Component, type Dispatch, type MemoComponent, type RectifyContext, type Reducer, type RefObject, Suspense, SyntheticEvent, createContext, createPortal, createRoot, lazy, memo, useCallback, useContext, useEffect, useId, useLayoutEffect, useMemo, useReducer, useRef, useState };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,6 @@
1
- import { RectifyNode, FC, Fiber } from '@rectify-dev/shared';
2
- export { AnchorHTMLAttributes, AriaAttributes, AudioHTMLAttributes, ButtonHTMLAttributes, CSSProperties, FC, FormHTMLAttributes, HTMLAttributes, IframeHTMLAttributes, ImgHTMLAttributes, InputHTMLAttributes, LabelHTMLAttributes, MetaHTMLAttributes, OptGroupHTMLAttributes, OptionHTMLAttributes, RectifyEventHandlers, RectifyIntrinsicElements, RectifyNode, ScriptHTMLAttributes, SelectHTMLAttributes, SyntheticAnimationEvent, SyntheticChangeEvent, SyntheticClipboardEvent, SyntheticDragEvent, SyntheticEvent as SyntheticEventType, SyntheticFocusEvent, SyntheticInputEvent, SyntheticKeyboardEvent, SyntheticMouseEvent, SyntheticPointerEvent, SyntheticSubmitEvent, SyntheticTouchEvent, SyntheticTransitionEvent, SyntheticWheelEvent, TextareaHTMLAttributes, VideoHTMLAttributes } from '@rectify-dev/shared';
1
+ import * as _rectify_dev_shared from '@rectify-dev/shared';
2
+ import { RectifyNode, RectifyKey, RectifyPortal, FC, LazyComponent, SuspenseProps, Fiber } from '@rectify-dev/shared';
3
+ export { AnchorHTMLAttributes, AriaAttributes, AudioHTMLAttributes, ButtonHTMLAttributes, CSSProperties, FC, FormHTMLAttributes, HTMLAttributes, IframeHTMLAttributes, ImgHTMLAttributes, InputHTMLAttributes, LabelHTMLAttributes, MetaHTMLAttributes, OptGroupHTMLAttributes, OptionHTMLAttributes, RectifyEventHandlers, RectifyIntrinsicElements, RectifyNode, RectifyPortal, ScriptHTMLAttributes, SelectHTMLAttributes, SuspenseProps, SyntheticAnimationEvent, SyntheticChangeEvent, SyntheticClipboardEvent, SyntheticDragEvent, SyntheticEvent as SyntheticEventType, SyntheticFocusEvent, SyntheticInputEvent, SyntheticKeyboardEvent, SyntheticMouseEvent, SyntheticPointerEvent, SyntheticSubmitEvent, SyntheticTouchEvent, SyntheticTransitionEvent, SyntheticWheelEvent, TextareaHTMLAttributes, VideoHTMLAttributes } from '@rectify-dev/shared';
3
4
  export { Fragment, jsx } from './runtime.js';
4
5
 
5
6
  type RectifyDomRoot = {
@@ -8,6 +9,8 @@ type RectifyDomRoot = {
8
9
  };
9
10
  declare const createRoot: (container: Element) => RectifyDomRoot;
10
11
 
12
+ declare const createPortal: (children: RectifyNode, container: Element, key?: RectifyKey) => RectifyPortal;
13
+
11
14
  type AnyNativeEvent = Event | KeyboardEvent | MouseEvent | TouchEvent;
12
15
 
13
16
  declare class SyntheticEvent {
@@ -44,6 +47,109 @@ type MemoComponent<P = any> = FC<P> & {
44
47
  */
45
48
  declare function memo<P = any>(Component: FC<P>, compare?: (prevProps: P, nextProps: P) => boolean): MemoComponent<P>;
46
49
 
50
+ /**
51
+ * Lazily loads a component via a dynamic import factory.
52
+ *
53
+ * The returned object is used as a JSX element type and behaves like a normal
54
+ * function component once loaded. While loading it suspends the nearest
55
+ * `<Suspense>` boundary, which renders its `fallback` instead.
56
+ *
57
+ * @example
58
+ * const HeavyChart = lazy(() => import("./HeavyChart"));
59
+ *
60
+ * function App() {
61
+ * return (
62
+ * <Suspense fallback={<Spinner />}>
63
+ * <HeavyChart />
64
+ * </Suspense>
65
+ * );
66
+ * }
67
+ */
68
+ declare const lazy: <T>(factory: () => Promise<{
69
+ default: T;
70
+ } | T>) => LazyComponent<T>;
71
+
72
+ /**
73
+ * Catches thrown promises from any child (including lazy components) and
74
+ * renders `fallback` until they resolve.
75
+ *
76
+ * Marked as a sentinel with `_isSuspense` so the reconciler can identify it
77
+ * without a dedicated $$typeof symbol — consistent with how MemoComponent
78
+ * and ContextProvider are detected.
79
+ *
80
+ * @example
81
+ * <Suspense fallback={<Spinner />}>
82
+ * <LazyPage />
83
+ * </Suspense>
84
+ */
85
+ declare const Suspense: (_props: SuspenseProps) => null;
86
+
87
+ /**
88
+ * Base class for Rectify class components.
89
+ *
90
+ * @example
91
+ * class Counter extends Component<{}, { count: number }> {
92
+ * state = { count: 0 };
93
+ *
94
+ * render() {
95
+ * return (
96
+ * <button onClick={() => this.setState({ count: this.state.count + 1 })}>
97
+ * {this.state.count}
98
+ * </button>
99
+ * );
100
+ * }
101
+ * }
102
+ */
103
+ declare class Component<P = {}, S = {}> {
104
+ /** Marks this as a class component for the reconciler. */
105
+ static readonly _isClassComponent = true;
106
+ props: P;
107
+ state: S;
108
+ /**
109
+ * @internal Set by the reconciler when the instance is created so
110
+ * `setState` can enqueue a re-render on the correct fiber.
111
+ */
112
+ _fiber: _rectify_dev_shared.Fiber | null;
113
+ /**
114
+ * @internal Snapshots taken by the reconciler in beginWork before each
115
+ * update render so that `componentDidUpdate` receives the correct prev values.
116
+ * Cleared after `componentDidUpdate` is called.
117
+ */
118
+ _prevProps: P | undefined;
119
+ _prevState: S | undefined;
120
+ /**
121
+ * @internal Queue of pending setState updates, flushed by the reconciler
122
+ * during beginWork so that prevState snapshots can be taken first.
123
+ */
124
+ _pendingStateQueue: Array<Partial<S> | ((prevState: S, prevProps: P) => Partial<S>)>;
125
+ constructor(props: P);
126
+ /** Called once, immediately after the component is inserted into the DOM. */
127
+ componentDidMount?(): void;
128
+ /**
129
+ * Called after every re-render.
130
+ * @param prevProps — props before the update
131
+ * @param prevState — state before the update
132
+ */
133
+ componentDidUpdate?(prevProps: P, prevState: S): void;
134
+ /** Called immediately before the component is removed from the DOM. */
135
+ componentWillUnmount?(): void;
136
+ /**
137
+ * Return false to skip re-rendering when props or state haven't changed.
138
+ * Defaults to always re-render.
139
+ */
140
+ shouldComponentUpdate?(nextProps: P, nextState: S): boolean;
141
+ /**
142
+ * Merges `partialState` into the current state and schedules a re-render.
143
+ * Accepts either a plain partial state object or an updater function.
144
+ */
145
+ setState(partialState: Partial<S> | ((prevState: S, prevProps: P) => Partial<S>)): void;
146
+ /**
147
+ * Must be implemented by every class component.
148
+ * Returns the subtree to render.
149
+ */
150
+ render(): RectifyNode;
151
+ }
152
+
47
153
  type StateUpdater<S> = S | ((prevState: S) => S);
48
154
  type StateDispatcher<S> = (updater: StateUpdater<S>) => void;
49
155
 
@@ -162,4 +268,22 @@ declare function createContext<T>(defaultValue: T): RectifyContext<T>;
162
268
  */
163
269
  declare function useContext<T>(context: RectifyContext<T>): T;
164
270
 
165
- export { type Dispatch, type MemoComponent, type RectifyContext, type Reducer, type RefObject, SyntheticEvent, createContext, createRoot, memo, useCallback, useContext, useEffect, useLayoutEffect, useMemo, useReducer, useRef, useState };
271
+ /**
272
+ * Returns a stable, globally unique ID string that is consistent across
273
+ * server and client renders within the same component instance.
274
+ *
275
+ * The ID is generated once on mount and returned unchanged on every
276
+ * subsequent render — it never changes for the lifetime of the component.
277
+ *
278
+ * @example
279
+ * const inputId = useId();
280
+ * return (
281
+ * <>
282
+ * <label htmlFor={inputId}>Name</label>
283
+ * <input id={inputId} />
284
+ * </>
285
+ * );
286
+ */
287
+ declare const useId: () => string;
288
+
289
+ export { Component, type Dispatch, type MemoComponent, type RectifyContext, type Reducer, type RefObject, Suspense, SyntheticEvent, createContext, createPortal, createRoot, lazy, memo, useCallback, useContext, useEffect, useId, useLayoutEffect, useMemo, useReducer, useRef, useState };