flexium 0.8.15 → 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/dist/{DrawText-CeXBL8Ev.d.ts → DrawText-Bvzl40Vi.d.ts} +1 -1
- package/dist/{DrawText-JB58mpQT.d.cts → DrawText-CJikXQjL.d.cts} +1 -1
- package/dist/advanced.d.cts +3 -1
- package/dist/advanced.d.ts +3 -1
- package/dist/advanced.js +1 -1
- package/dist/advanced.mjs +1 -1
- package/dist/advanced.mjs.map +1 -1
- package/dist/canvas.d.cts +5 -3
- package/dist/canvas.d.ts +5 -3
- package/dist/canvas.js +1 -1
- package/dist/canvas.mjs +1 -1
- package/dist/chunk-6RV7ARJT.mjs +3 -0
- package/dist/chunk-6RV7ARJT.mjs.map +1 -0
- package/dist/{chunk-CNY6FPKJ.js → chunk-CBO2X74Q.js} +2 -2
- package/dist/{chunk-CZYIK6FD.mjs.map → chunk-CBO2X74Q.js.map} +1 -1
- package/dist/chunk-GFL4VRAO.mjs +3 -0
- package/dist/chunk-GFL4VRAO.mjs.map +1 -0
- package/dist/{chunk-MLZTCKTH.mjs → chunk-GQKN4NPW.mjs} +2 -2
- package/dist/{chunk-MLZTCKTH.mjs.map → chunk-GQKN4NPW.mjs.map} +1 -1
- package/dist/{chunk-CZYIK6FD.mjs → chunk-JDTJFAXO.mjs} +2 -2
- package/dist/chunk-JDTJFAXO.mjs.map +1 -0
- package/dist/{chunk-ZNPYN2TZ.mjs → chunk-LXXN76HJ.mjs} +2 -2
- package/dist/{chunk-ZNPYN2TZ.mjs.map → chunk-LXXN76HJ.mjs.map} +1 -1
- package/dist/chunk-MKE3KA43.js +3 -0
- package/dist/chunk-MKE3KA43.js.map +1 -0
- package/dist/{chunk-DOGIWSDA.js → chunk-PDOEMOWN.js} +2 -2
- package/dist/{chunk-DOGIWSDA.js.map → chunk-PDOEMOWN.js.map} +1 -1
- package/dist/{chunk-GDBJ322I.js → chunk-RIVNKTUR.js} +2 -2
- package/dist/{chunk-GDBJ322I.js.map → chunk-RIVNKTUR.js.map} +1 -1
- package/dist/chunk-TQLZ7UZX.js +2 -0
- package/dist/chunk-TQLZ7UZX.js.map +1 -0
- package/dist/chunk-WEYAKKNF.js +3 -0
- package/dist/chunk-WEYAKKNF.js.map +1 -0
- package/dist/chunk-WO6NQ3KR.mjs +3 -0
- package/dist/chunk-WO6NQ3KR.mjs.map +1 -0
- package/dist/chunk-Y4DUMNIW.mjs +2 -0
- package/dist/chunk-Y4DUMNIW.mjs.map +1 -0
- package/dist/chunk-ZG3LULLU.js +3 -0
- package/dist/chunk-ZG3LULLU.js.map +1 -0
- package/dist/components-D4WeooPi.d.ts +126 -0
- package/dist/components-DZy2r6m5.d.cts +126 -0
- package/dist/core.d.cts +159 -15
- package/dist/core.d.ts +159 -15
- package/dist/core.js +1 -1
- package/dist/core.mjs +1 -1
- package/dist/dom.d.cts +2 -3
- package/dist/dom.d.ts +2 -3
- package/dist/dom.js +1 -1
- package/dist/dom.js.map +1 -1
- package/dist/dom.mjs +1 -1
- package/dist/dom.mjs.map +1 -1
- package/dist/effect-BlnnM1t5.d.cts +20 -0
- package/dist/effect-BlnnM1t5.d.ts +20 -0
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/interactive.d.cts +1 -1
- package/dist/interactive.d.ts +1 -1
- package/dist/interactive.js +1 -1
- package/dist/interactive.mjs +1 -1
- package/dist/interactive.mjs.map +1 -1
- package/dist/metafile-cjs.json +1 -1
- package/dist/metafile-esm.json +1 -1
- package/dist/owner-Ce7KCWzi.d.cts +34 -0
- package/dist/owner-Ce7KCWzi.d.ts +34 -0
- package/dist/{portal-DBwz7gD0.d.ts → portal-C3ESJhlv.d.ts} +1 -1
- package/dist/{portal-BpcIlK9y.d.cts → portal-CAEbiMUZ.d.cts} +1 -1
- package/dist/primitives/motion.js +1 -1
- package/dist/primitives/motion.mjs +1 -1
- package/dist/primitives/ui.d.cts +1 -1
- package/dist/primitives/ui.d.ts +1 -1
- package/dist/primitives/ui.js +1 -1
- package/dist/primitives/ui.mjs +1 -1
- package/dist/primitives/ui.mjs.map +1 -1
- package/dist/primitives.d.cts +6 -4
- package/dist/primitives.d.ts +6 -4
- package/dist/primitives.js +1 -1
- package/dist/primitives.mjs +1 -1
- package/dist/router.d.cts +11 -120
- package/dist/router.d.ts +11 -120
- package/dist/router.js +1 -1
- package/dist/router.mjs +1 -1
- package/dist/scheduler-Z4QqUDjF.d.cts +25 -0
- package/dist/scheduler-Z4QqUDjF.d.ts +25 -0
- package/dist/server.js +1 -1
- package/dist/server.mjs +1 -1
- package/dist/signal-AXKUQJVA.js +2 -0
- package/dist/{signal-XZXQ4VYQ.js.map → signal-AXKUQJVA.js.map} +1 -1
- package/dist/signal-Dxh9PsKr.d.cts +69 -0
- package/dist/signal-Dxh9PsKr.d.ts +69 -0
- package/dist/signal-HM2LG5YL.mjs +2 -0
- package/dist/{signal-PWBIM6JV.mjs.map → signal-HM2LG5YL.mjs.map} +1 -1
- package/dist/test-exports.d.cts +29 -8
- package/dist/test-exports.d.ts +29 -8
- package/dist/test-exports.js +1 -1
- package/dist/test-exports.mjs +1 -1
- package/package.json +1 -1
- package/dist/chunk-2MVKTSFR.mjs +0 -3
- package/dist/chunk-2MVKTSFR.mjs.map +0 -1
- package/dist/chunk-2U4DW375.mjs +0 -2
- package/dist/chunk-2U4DW375.mjs.map +0 -1
- package/dist/chunk-5S3ZQ2LB.mjs +0 -3
- package/dist/chunk-5S3ZQ2LB.mjs.map +0 -1
- package/dist/chunk-CNY6FPKJ.js.map +0 -1
- package/dist/chunk-EX2GURH5.mjs +0 -3
- package/dist/chunk-EX2GURH5.mjs.map +0 -1
- package/dist/chunk-I7UCVARB.js +0 -2
- package/dist/chunk-I7UCVARB.js.map +0 -1
- package/dist/chunk-REETNY2Z.js +0 -3
- package/dist/chunk-REETNY2Z.js.map +0 -1
- package/dist/chunk-ROYFUJN5.js +0 -3
- package/dist/chunk-ROYFUJN5.js.map +0 -1
- package/dist/chunk-V4K6WOXN.js +0 -3
- package/dist/chunk-V4K6WOXN.js.map +0 -1
- package/dist/signal-PWBIM6JV.mjs +0 -2
- package/dist/signal-XZXQ4VYQ.js +0 -2
- package/dist/signal-mNtlF8-v.d.cts +0 -158
- package/dist/signal-mNtlF8-v.d.ts +0 -158
- package/dist/state-kK9sQh9s.d.cts +0 -73
- package/dist/state-kK9sQh9s.d.ts +0 -73
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Runs a function once when the component mounts.
|
|
3
|
-
* Unlike effect(), onMount does not track dependencies - it runs exactly once.
|
|
4
|
-
*
|
|
5
|
-
* @param fn - Function to run on mount. Can return a cleanup function.
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
* ```tsx
|
|
9
|
-
* function MyComponent() {
|
|
10
|
-
* onMount(() => {
|
|
11
|
-
* console.log('Mounted!');
|
|
12
|
-
* return () => console.log('Unmounted!');
|
|
13
|
-
* });
|
|
14
|
-
* return <div>Hello</div>;
|
|
15
|
-
* }
|
|
16
|
-
* ```
|
|
17
|
-
*/
|
|
18
|
-
declare function onMount(fn: () => void | (() => void)): void;
|
|
19
|
-
/**
|
|
20
|
-
* Base interface for reactive signals
|
|
21
|
-
* @internal
|
|
22
|
-
*/
|
|
23
|
-
interface Signal<T> {
|
|
24
|
-
value: T;
|
|
25
|
-
(): T;
|
|
26
|
-
set(value: T): void;
|
|
27
|
-
peek(): T;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Computed signal interface (read-only)
|
|
31
|
-
* @internal
|
|
32
|
-
*/
|
|
33
|
-
interface Computed<T> {
|
|
34
|
-
readonly value: T;
|
|
35
|
-
(): T;
|
|
36
|
-
peek(): T;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Creates a reactive signal
|
|
40
|
-
*
|
|
41
|
-
* @param initialValue - The initial value of the signal
|
|
42
|
-
* @returns A signal object with value getter/setter
|
|
43
|
-
*
|
|
44
|
-
* @example
|
|
45
|
-
* const count = signal(0);
|
|
46
|
-
* count.value++; // triggers subscribers
|
|
47
|
-
* console.log(count()); // alternative getter syntax
|
|
48
|
-
*/
|
|
49
|
-
declare function signal<T>(initialValue: T): Signal<T>;
|
|
50
|
-
/**
|
|
51
|
-
* Creates a computed signal (derived value)
|
|
52
|
-
* @internal Use `state(() => ...)` instead
|
|
53
|
-
*/
|
|
54
|
-
declare function computed<T>(fn: () => T): Computed<T>;
|
|
55
|
-
/**
|
|
56
|
-
* Creates a side effect that runs when dependencies change
|
|
57
|
-
*
|
|
58
|
-
* @param fn - Effect function, can return a cleanup function
|
|
59
|
-
* @param options - Optional error handler
|
|
60
|
-
* @returns Dispose function to stop the effect
|
|
61
|
-
*
|
|
62
|
-
* @example
|
|
63
|
-
* const count = signal(0);
|
|
64
|
-
* const dispose = effect(() => {
|
|
65
|
-
* console.log('Count:', count.value);
|
|
66
|
-
* return () => console.log('Cleanup');
|
|
67
|
-
* });
|
|
68
|
-
*/
|
|
69
|
-
declare function effect(fn: () => void | (() => void), options?: {
|
|
70
|
-
onError?: (error: Error) => void;
|
|
71
|
-
name?: string;
|
|
72
|
-
}): () => void;
|
|
73
|
-
/**
|
|
74
|
-
* Execute a function without tracking signal dependencies.
|
|
75
|
-
* Useful when you need to read signals inside an effect without creating dependencies.
|
|
76
|
-
*
|
|
77
|
-
* @param fn - Function to execute without tracking
|
|
78
|
-
* @returns The return value of fn
|
|
79
|
-
*
|
|
80
|
-
* @example
|
|
81
|
-
* ```tsx
|
|
82
|
-
* const count = signal(0);
|
|
83
|
-
* const name = signal('Alice');
|
|
84
|
-
*
|
|
85
|
-
* effect(() => {
|
|
86
|
-
* // Only re-runs when count changes, not name
|
|
87
|
-
* console.log(count(), untrack(() => name()));
|
|
88
|
-
* });
|
|
89
|
-
* ```
|
|
90
|
-
*/
|
|
91
|
-
declare function untrack<T>(fn: () => T): T;
|
|
92
|
-
/**
|
|
93
|
-
* Batches multiple signal updates together.
|
|
94
|
-
* Effects will only run once after all updates complete.
|
|
95
|
-
*
|
|
96
|
-
* @param fn - Function containing signal updates to batch
|
|
97
|
-
* @returns The return value of fn
|
|
98
|
-
*
|
|
99
|
-
* @example
|
|
100
|
-
* ```tsx
|
|
101
|
-
* const count = signal(0);
|
|
102
|
-
* const name = signal('Alice');
|
|
103
|
-
*
|
|
104
|
-
* effect(() => console.log(count(), name())); // runs once
|
|
105
|
-
*
|
|
106
|
-
* batch(() => {
|
|
107
|
-
* count.value = 1;
|
|
108
|
-
* name.value = 'Bob';
|
|
109
|
-
* }); // effect runs only once after batch completes
|
|
110
|
-
* ```
|
|
111
|
-
*/
|
|
112
|
-
declare function batch<T>(fn: () => T): T;
|
|
113
|
-
/**
|
|
114
|
-
* Creates a root scope for effects
|
|
115
|
-
* All effects created within the scope can be disposed together
|
|
116
|
-
*
|
|
117
|
-
* @param fn - Function that creates effects
|
|
118
|
-
* @returns Dispose function for all effects in the scope
|
|
119
|
-
*/
|
|
120
|
-
declare function root<T>(fn: (dispose: () => void) => T): T;
|
|
121
|
-
/**
|
|
122
|
-
* Check if a value is a signal
|
|
123
|
-
* @internal Use state() which handles all reactive patterns
|
|
124
|
-
*/
|
|
125
|
-
declare function isSignal(value: unknown): value is Signal<any> | Computed<any>;
|
|
126
|
-
/**
|
|
127
|
-
* Registers a cleanup function that runs before the current effect re-runs or is disposed
|
|
128
|
-
*
|
|
129
|
-
* @param fn - Cleanup function
|
|
130
|
-
*/
|
|
131
|
-
declare function onCleanup(fn: () => void): void;
|
|
132
|
-
/**
|
|
133
|
-
* Resource interface for async data
|
|
134
|
-
*/
|
|
135
|
-
interface Resource<T> extends Signal<T | undefined> {
|
|
136
|
-
loading: boolean;
|
|
137
|
-
error: any;
|
|
138
|
-
state: 'unresolved' | 'pending' | 'ready' | 'refreshing' | 'errored';
|
|
139
|
-
latest: T | undefined;
|
|
140
|
-
/**
|
|
141
|
-
* Read value, throwing Promise if pending or Error if failed.
|
|
142
|
-
* Used by Suspense.
|
|
143
|
-
*/
|
|
144
|
-
read: () => T | undefined;
|
|
145
|
-
}
|
|
146
|
-
/**
|
|
147
|
-
* Creates a resource for handling async data
|
|
148
|
-
* @internal Use state(async () => ...) instead which returns [data, refetch, status, error]
|
|
149
|
-
*/
|
|
150
|
-
declare function createResource<T, S = any>(source: S | Signal<S> | (() => S), fetcher: (source: S, { value, refetching }: {
|
|
151
|
-
value: T | undefined;
|
|
152
|
-
refetching: any;
|
|
153
|
-
}) => Promise<T>): [Resource<T>, {
|
|
154
|
-
mutate: (v: T | undefined) => void;
|
|
155
|
-
refetch: () => void;
|
|
156
|
-
}];
|
|
157
|
-
|
|
158
|
-
export { type Computed as C, type Signal as S, createResource as a, onMount as b, computed as c, batch as d, effect as e, isSignal as i, onCleanup as o, root as r, signal as s, untrack as u };
|
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Runs a function once when the component mounts.
|
|
3
|
-
* Unlike effect(), onMount does not track dependencies - it runs exactly once.
|
|
4
|
-
*
|
|
5
|
-
* @param fn - Function to run on mount. Can return a cleanup function.
|
|
6
|
-
*
|
|
7
|
-
* @example
|
|
8
|
-
* ```tsx
|
|
9
|
-
* function MyComponent() {
|
|
10
|
-
* onMount(() => {
|
|
11
|
-
* console.log('Mounted!');
|
|
12
|
-
* return () => console.log('Unmounted!');
|
|
13
|
-
* });
|
|
14
|
-
* return <div>Hello</div>;
|
|
15
|
-
* }
|
|
16
|
-
* ```
|
|
17
|
-
*/
|
|
18
|
-
declare function onMount(fn: () => void | (() => void)): void;
|
|
19
|
-
/**
|
|
20
|
-
* Base interface for reactive signals
|
|
21
|
-
* @internal
|
|
22
|
-
*/
|
|
23
|
-
interface Signal<T> {
|
|
24
|
-
value: T;
|
|
25
|
-
(): T;
|
|
26
|
-
set(value: T): void;
|
|
27
|
-
peek(): T;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Computed signal interface (read-only)
|
|
31
|
-
* @internal
|
|
32
|
-
*/
|
|
33
|
-
interface Computed<T> {
|
|
34
|
-
readonly value: T;
|
|
35
|
-
(): T;
|
|
36
|
-
peek(): T;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Creates a reactive signal
|
|
40
|
-
*
|
|
41
|
-
* @param initialValue - The initial value of the signal
|
|
42
|
-
* @returns A signal object with value getter/setter
|
|
43
|
-
*
|
|
44
|
-
* @example
|
|
45
|
-
* const count = signal(0);
|
|
46
|
-
* count.value++; // triggers subscribers
|
|
47
|
-
* console.log(count()); // alternative getter syntax
|
|
48
|
-
*/
|
|
49
|
-
declare function signal<T>(initialValue: T): Signal<T>;
|
|
50
|
-
/**
|
|
51
|
-
* Creates a computed signal (derived value)
|
|
52
|
-
* @internal Use `state(() => ...)` instead
|
|
53
|
-
*/
|
|
54
|
-
declare function computed<T>(fn: () => T): Computed<T>;
|
|
55
|
-
/**
|
|
56
|
-
* Creates a side effect that runs when dependencies change
|
|
57
|
-
*
|
|
58
|
-
* @param fn - Effect function, can return a cleanup function
|
|
59
|
-
* @param options - Optional error handler
|
|
60
|
-
* @returns Dispose function to stop the effect
|
|
61
|
-
*
|
|
62
|
-
* @example
|
|
63
|
-
* const count = signal(0);
|
|
64
|
-
* const dispose = effect(() => {
|
|
65
|
-
* console.log('Count:', count.value);
|
|
66
|
-
* return () => console.log('Cleanup');
|
|
67
|
-
* });
|
|
68
|
-
*/
|
|
69
|
-
declare function effect(fn: () => void | (() => void), options?: {
|
|
70
|
-
onError?: (error: Error) => void;
|
|
71
|
-
name?: string;
|
|
72
|
-
}): () => void;
|
|
73
|
-
/**
|
|
74
|
-
* Execute a function without tracking signal dependencies.
|
|
75
|
-
* Useful when you need to read signals inside an effect without creating dependencies.
|
|
76
|
-
*
|
|
77
|
-
* @param fn - Function to execute without tracking
|
|
78
|
-
* @returns The return value of fn
|
|
79
|
-
*
|
|
80
|
-
* @example
|
|
81
|
-
* ```tsx
|
|
82
|
-
* const count = signal(0);
|
|
83
|
-
* const name = signal('Alice');
|
|
84
|
-
*
|
|
85
|
-
* effect(() => {
|
|
86
|
-
* // Only re-runs when count changes, not name
|
|
87
|
-
* console.log(count(), untrack(() => name()));
|
|
88
|
-
* });
|
|
89
|
-
* ```
|
|
90
|
-
*/
|
|
91
|
-
declare function untrack<T>(fn: () => T): T;
|
|
92
|
-
/**
|
|
93
|
-
* Batches multiple signal updates together.
|
|
94
|
-
* Effects will only run once after all updates complete.
|
|
95
|
-
*
|
|
96
|
-
* @param fn - Function containing signal updates to batch
|
|
97
|
-
* @returns The return value of fn
|
|
98
|
-
*
|
|
99
|
-
* @example
|
|
100
|
-
* ```tsx
|
|
101
|
-
* const count = signal(0);
|
|
102
|
-
* const name = signal('Alice');
|
|
103
|
-
*
|
|
104
|
-
* effect(() => console.log(count(), name())); // runs once
|
|
105
|
-
*
|
|
106
|
-
* batch(() => {
|
|
107
|
-
* count.value = 1;
|
|
108
|
-
* name.value = 'Bob';
|
|
109
|
-
* }); // effect runs only once after batch completes
|
|
110
|
-
* ```
|
|
111
|
-
*/
|
|
112
|
-
declare function batch<T>(fn: () => T): T;
|
|
113
|
-
/**
|
|
114
|
-
* Creates a root scope for effects
|
|
115
|
-
* All effects created within the scope can be disposed together
|
|
116
|
-
*
|
|
117
|
-
* @param fn - Function that creates effects
|
|
118
|
-
* @returns Dispose function for all effects in the scope
|
|
119
|
-
*/
|
|
120
|
-
declare function root<T>(fn: (dispose: () => void) => T): T;
|
|
121
|
-
/**
|
|
122
|
-
* Check if a value is a signal
|
|
123
|
-
* @internal Use state() which handles all reactive patterns
|
|
124
|
-
*/
|
|
125
|
-
declare function isSignal(value: unknown): value is Signal<any> | Computed<any>;
|
|
126
|
-
/**
|
|
127
|
-
* Registers a cleanup function that runs before the current effect re-runs or is disposed
|
|
128
|
-
*
|
|
129
|
-
* @param fn - Cleanup function
|
|
130
|
-
*/
|
|
131
|
-
declare function onCleanup(fn: () => void): void;
|
|
132
|
-
/**
|
|
133
|
-
* Resource interface for async data
|
|
134
|
-
*/
|
|
135
|
-
interface Resource<T> extends Signal<T | undefined> {
|
|
136
|
-
loading: boolean;
|
|
137
|
-
error: any;
|
|
138
|
-
state: 'unresolved' | 'pending' | 'ready' | 'refreshing' | 'errored';
|
|
139
|
-
latest: T | undefined;
|
|
140
|
-
/**
|
|
141
|
-
* Read value, throwing Promise if pending or Error if failed.
|
|
142
|
-
* Used by Suspense.
|
|
143
|
-
*/
|
|
144
|
-
read: () => T | undefined;
|
|
145
|
-
}
|
|
146
|
-
/**
|
|
147
|
-
* Creates a resource for handling async data
|
|
148
|
-
* @internal Use state(async () => ...) instead which returns [data, refetch, status, error]
|
|
149
|
-
*/
|
|
150
|
-
declare function createResource<T, S = any>(source: S | Signal<S> | (() => S), fetcher: (source: S, { value, refetching }: {
|
|
151
|
-
value: T | undefined;
|
|
152
|
-
refetching: any;
|
|
153
|
-
}) => Promise<T>): [Resource<T>, {
|
|
154
|
-
mutate: (v: T | undefined) => void;
|
|
155
|
-
refetch: () => void;
|
|
156
|
-
}];
|
|
157
|
-
|
|
158
|
-
export { type Computed as C, type Signal as S, createResource as a, onMount as b, computed as c, batch as d, effect as e, isSignal as i, onCleanup as o, root as r, signal as s, untrack as u };
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
/** Key type - string or array of serializable values */
|
|
2
|
-
type StateKey = string | readonly (string | number | boolean | null | undefined | object)[];
|
|
3
|
-
/** Action function type for state mutation */
|
|
4
|
-
type StateAction<T> = (newValue: T | ((prev: T) => T)) => void;
|
|
5
|
-
/**
|
|
6
|
-
* StateValue type - a value-like proxy that behaves like T.
|
|
7
|
-
* Can be used directly in expressions and JSX.
|
|
8
|
-
*/
|
|
9
|
-
type StateValue<T> = T & (() => T);
|
|
10
|
-
/** Async state status */
|
|
11
|
-
type AsyncStatus = 'idle' | 'loading' | 'success' | 'error';
|
|
12
|
-
/** Options for state() */
|
|
13
|
-
interface StateOptions<P = unknown> {
|
|
14
|
-
/**
|
|
15
|
-
* Key for global state sharing. Can be a string or array.
|
|
16
|
-
* Array keys are useful for hierarchical namespacing.
|
|
17
|
-
* @example
|
|
18
|
-
* state('light', { key: 'theme' })
|
|
19
|
-
* state(null, { key: ['user', 'profile', userId] })
|
|
20
|
-
*/
|
|
21
|
-
key?: StateKey;
|
|
22
|
-
/**
|
|
23
|
-
* Parameters to pass to the function (for computed/async state).
|
|
24
|
-
* Improves DX by making dependencies explicit.
|
|
25
|
-
* @example
|
|
26
|
-
* state(
|
|
27
|
-
* async ({ userId }) => fetch(`/api/users/${userId}`),
|
|
28
|
-
* { key: ['user', userId], params: { userId } }
|
|
29
|
-
* )
|
|
30
|
-
*/
|
|
31
|
-
params?: P;
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Unified State API
|
|
35
|
-
*
|
|
36
|
-
* One function for all reactive state needs - always returns an array for consistency:
|
|
37
|
-
* 1. Simple state: const [count, setCount] = state(0)
|
|
38
|
-
* 2. Derived state: const [doubled] = state(() => count * 2)
|
|
39
|
-
* 3. Async state: const [data, refetch, status, error] = state(async () => fetch(...))
|
|
40
|
-
* 4. Global state: const [theme, setTheme] = state('light', { key: 'theme' })
|
|
41
|
-
* 5. With params: const [user] = state(async (p) => fetch(`/api/${p.id}`), { params: { id } })
|
|
42
|
-
*
|
|
43
|
-
* @example
|
|
44
|
-
* ```tsx
|
|
45
|
-
* function Counter() {
|
|
46
|
-
* const [count, setCount] = state(0)
|
|
47
|
-
* const [doubled] = state(() => count * 2)
|
|
48
|
-
* return <Button onPress={() => setCount(count + 1)}>{doubled}</Button>
|
|
49
|
-
* }
|
|
50
|
-
* ```
|
|
51
|
-
*/
|
|
52
|
-
interface StateFunction {
|
|
53
|
-
<T>(initialValue: T, options?: StateOptions): [StateValue<T>, StateAction<T>];
|
|
54
|
-
<T, P>(computeFn: (params: P) => T, options: StateOptions<P> & {
|
|
55
|
-
params: P;
|
|
56
|
-
}): [StateValue<T>];
|
|
57
|
-
<T>(computeFn: () => T, options?: StateOptions): [StateValue<T>];
|
|
58
|
-
<T, P>(fetcher: (params: P) => Promise<T>, options: StateOptions<P> & {
|
|
59
|
-
params: P;
|
|
60
|
-
}): [StateValue<T | undefined>, () => void, StateValue<AsyncStatus>, StateValue<unknown>];
|
|
61
|
-
<T>(fetcher: () => Promise<T>, options?: StateOptions): [StateValue<T | undefined>, () => void, StateValue<AsyncStatus>, StateValue<unknown>];
|
|
62
|
-
/** Delete a specific global state by key */
|
|
63
|
-
delete: (key: StateKey) => boolean;
|
|
64
|
-
/** Clear all global states */
|
|
65
|
-
clear: () => void;
|
|
66
|
-
/** Check if a global state exists */
|
|
67
|
-
has: (key: StateKey) => boolean;
|
|
68
|
-
/** Current number of global states */
|
|
69
|
-
readonly size: number;
|
|
70
|
-
}
|
|
71
|
-
declare const _state: StateFunction;
|
|
72
|
-
|
|
73
|
-
export { type AsyncStatus as A, type StateAction as S, _state as _, type StateValue as a, type StateKey as b, type StateOptions as c };
|
package/dist/state-kK9sQh9s.d.ts
DELETED
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
/** Key type - string or array of serializable values */
|
|
2
|
-
type StateKey = string | readonly (string | number | boolean | null | undefined | object)[];
|
|
3
|
-
/** Action function type for state mutation */
|
|
4
|
-
type StateAction<T> = (newValue: T | ((prev: T) => T)) => void;
|
|
5
|
-
/**
|
|
6
|
-
* StateValue type - a value-like proxy that behaves like T.
|
|
7
|
-
* Can be used directly in expressions and JSX.
|
|
8
|
-
*/
|
|
9
|
-
type StateValue<T> = T & (() => T);
|
|
10
|
-
/** Async state status */
|
|
11
|
-
type AsyncStatus = 'idle' | 'loading' | 'success' | 'error';
|
|
12
|
-
/** Options for state() */
|
|
13
|
-
interface StateOptions<P = unknown> {
|
|
14
|
-
/**
|
|
15
|
-
* Key for global state sharing. Can be a string or array.
|
|
16
|
-
* Array keys are useful for hierarchical namespacing.
|
|
17
|
-
* @example
|
|
18
|
-
* state('light', { key: 'theme' })
|
|
19
|
-
* state(null, { key: ['user', 'profile', userId] })
|
|
20
|
-
*/
|
|
21
|
-
key?: StateKey;
|
|
22
|
-
/**
|
|
23
|
-
* Parameters to pass to the function (for computed/async state).
|
|
24
|
-
* Improves DX by making dependencies explicit.
|
|
25
|
-
* @example
|
|
26
|
-
* state(
|
|
27
|
-
* async ({ userId }) => fetch(`/api/users/${userId}`),
|
|
28
|
-
* { key: ['user', userId], params: { userId } }
|
|
29
|
-
* )
|
|
30
|
-
*/
|
|
31
|
-
params?: P;
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Unified State API
|
|
35
|
-
*
|
|
36
|
-
* One function for all reactive state needs - always returns an array for consistency:
|
|
37
|
-
* 1. Simple state: const [count, setCount] = state(0)
|
|
38
|
-
* 2. Derived state: const [doubled] = state(() => count * 2)
|
|
39
|
-
* 3. Async state: const [data, refetch, status, error] = state(async () => fetch(...))
|
|
40
|
-
* 4. Global state: const [theme, setTheme] = state('light', { key: 'theme' })
|
|
41
|
-
* 5. With params: const [user] = state(async (p) => fetch(`/api/${p.id}`), { params: { id } })
|
|
42
|
-
*
|
|
43
|
-
* @example
|
|
44
|
-
* ```tsx
|
|
45
|
-
* function Counter() {
|
|
46
|
-
* const [count, setCount] = state(0)
|
|
47
|
-
* const [doubled] = state(() => count * 2)
|
|
48
|
-
* return <Button onPress={() => setCount(count + 1)}>{doubled}</Button>
|
|
49
|
-
* }
|
|
50
|
-
* ```
|
|
51
|
-
*/
|
|
52
|
-
interface StateFunction {
|
|
53
|
-
<T>(initialValue: T, options?: StateOptions): [StateValue<T>, StateAction<T>];
|
|
54
|
-
<T, P>(computeFn: (params: P) => T, options: StateOptions<P> & {
|
|
55
|
-
params: P;
|
|
56
|
-
}): [StateValue<T>];
|
|
57
|
-
<T>(computeFn: () => T, options?: StateOptions): [StateValue<T>];
|
|
58
|
-
<T, P>(fetcher: (params: P) => Promise<T>, options: StateOptions<P> & {
|
|
59
|
-
params: P;
|
|
60
|
-
}): [StateValue<T | undefined>, () => void, StateValue<AsyncStatus>, StateValue<unknown>];
|
|
61
|
-
<T>(fetcher: () => Promise<T>, options?: StateOptions): [StateValue<T | undefined>, () => void, StateValue<AsyncStatus>, StateValue<unknown>];
|
|
62
|
-
/** Delete a specific global state by key */
|
|
63
|
-
delete: (key: StateKey) => boolean;
|
|
64
|
-
/** Clear all global states */
|
|
65
|
-
clear: () => void;
|
|
66
|
-
/** Check if a global state exists */
|
|
67
|
-
has: (key: StateKey) => boolean;
|
|
68
|
-
/** Current number of global states */
|
|
69
|
-
readonly size: number;
|
|
70
|
-
}
|
|
71
|
-
declare const _state: StateFunction;
|
|
72
|
-
|
|
73
|
-
export { type AsyncStatus as A, type StateAction as S, _state as _, type StateValue as a, type StateKey as b, type StateOptions as c };
|