pulse-js-framework 1.4.3 → 1.4.4
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 +22 -0
- package/cli/mobile.js +48 -71
- package/compiler/parser.js +57 -136
- package/compiler/transformer.js +75 -197
- package/package.json +22 -4
- package/types/dom.d.ts +288 -0
- package/types/index.d.ts +120 -0
- package/types/pulse.d.ts +149 -0
- package/types/router.d.ts +197 -0
- package/types/store.d.ts +170 -0
package/types/dom.d.ts
ADDED
|
@@ -0,0 +1,288 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pulse Framework - DOM Helpers Type Definitions
|
|
3
|
+
* @module pulse-js-framework/runtime
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
import { Pulse } from './pulse';
|
|
7
|
+
|
|
8
|
+
/** Value or getter function */
|
|
9
|
+
export type MaybeGetter<T> = T | (() => T);
|
|
10
|
+
|
|
11
|
+
/** Value, getter, or Pulse */
|
|
12
|
+
export type Reactive<T> = T | (() => T) | Pulse<T>;
|
|
13
|
+
|
|
14
|
+
/** Child content type for elements */
|
|
15
|
+
export type Child =
|
|
16
|
+
| string
|
|
17
|
+
| number
|
|
18
|
+
| Node
|
|
19
|
+
| null
|
|
20
|
+
| undefined
|
|
21
|
+
| (() => Child | Child[])
|
|
22
|
+
| Child[];
|
|
23
|
+
|
|
24
|
+
/** Parsed selector result */
|
|
25
|
+
export interface ParsedSelector {
|
|
26
|
+
tag: string;
|
|
27
|
+
id: string | null;
|
|
28
|
+
classes: string[];
|
|
29
|
+
attrs: Record<string, string>;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Parse CSS selector into configuration
|
|
34
|
+
*/
|
|
35
|
+
export declare function parseSelector(selector: string): ParsedSelector;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Create element from CSS selector syntax
|
|
39
|
+
* @example el('div.container#main', 'Hello')
|
|
40
|
+
* @example el('input[type=text][placeholder=Name]')
|
|
41
|
+
*/
|
|
42
|
+
export declare function el(selector: string, ...children: Child[]): HTMLElement;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Create reactive text node
|
|
46
|
+
*/
|
|
47
|
+
export declare function text(getValue: MaybeGetter<string | number>): Text;
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Bind attribute reactively
|
|
51
|
+
* @returns Element (chainable)
|
|
52
|
+
*/
|
|
53
|
+
export declare function bind<E extends HTMLElement>(
|
|
54
|
+
element: E,
|
|
55
|
+
attr: string,
|
|
56
|
+
getValue: MaybeGetter<string | boolean | number | null>
|
|
57
|
+
): E;
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Bind property reactively
|
|
61
|
+
* @returns Element (chainable)
|
|
62
|
+
*/
|
|
63
|
+
export declare function prop<E extends HTMLElement>(
|
|
64
|
+
element: E,
|
|
65
|
+
propName: string,
|
|
66
|
+
getValue: MaybeGetter<unknown>
|
|
67
|
+
): E;
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Bind CSS class reactively
|
|
71
|
+
* @returns Element (chainable)
|
|
72
|
+
*/
|
|
73
|
+
export declare function cls<E extends HTMLElement>(
|
|
74
|
+
element: E,
|
|
75
|
+
className: string,
|
|
76
|
+
condition: MaybeGetter<boolean>
|
|
77
|
+
): E;
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Bind style property reactively
|
|
81
|
+
* @returns Element (chainable)
|
|
82
|
+
*/
|
|
83
|
+
export declare function style<E extends HTMLElement>(
|
|
84
|
+
element: E,
|
|
85
|
+
prop: string,
|
|
86
|
+
getValue: MaybeGetter<string>
|
|
87
|
+
): E;
|
|
88
|
+
|
|
89
|
+
/** Event handler options */
|
|
90
|
+
export interface EventOptions {
|
|
91
|
+
capture?: boolean;
|
|
92
|
+
once?: boolean;
|
|
93
|
+
passive?: boolean;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Attach event listener
|
|
98
|
+
* @returns Element (chainable)
|
|
99
|
+
*/
|
|
100
|
+
export declare function on<E extends HTMLElement, K extends keyof HTMLElementEventMap>(
|
|
101
|
+
element: E,
|
|
102
|
+
event: K,
|
|
103
|
+
handler: (e: HTMLElementEventMap[K]) => void,
|
|
104
|
+
options?: EventOptions
|
|
105
|
+
): E;
|
|
106
|
+
export declare function on<E extends HTMLElement>(
|
|
107
|
+
element: E,
|
|
108
|
+
event: string,
|
|
109
|
+
handler: (e: Event) => void,
|
|
110
|
+
options?: EventOptions
|
|
111
|
+
): E;
|
|
112
|
+
|
|
113
|
+
/** Key function for list rendering */
|
|
114
|
+
export type KeyFn<T> = (item: T, index: number) => unknown;
|
|
115
|
+
|
|
116
|
+
/** Template function for list items */
|
|
117
|
+
export type ListTemplate<T> = (item: T, index: number) => Node | Node[];
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* Render reactive list with efficient keyed diffing
|
|
121
|
+
*/
|
|
122
|
+
export declare function list<T>(
|
|
123
|
+
getItems: Reactive<T[]>,
|
|
124
|
+
template: ListTemplate<T>,
|
|
125
|
+
keyFn?: KeyFn<T>
|
|
126
|
+
): DocumentFragment;
|
|
127
|
+
|
|
128
|
+
/** Template function for conditional rendering */
|
|
129
|
+
export type ConditionTemplate = () => Node | Node[] | null;
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Conditional rendering (removes unmounted elements)
|
|
133
|
+
*/
|
|
134
|
+
export declare function when(
|
|
135
|
+
condition: Reactive<boolean>,
|
|
136
|
+
thenTemplate: ConditionTemplate,
|
|
137
|
+
elseTemplate?: ConditionTemplate
|
|
138
|
+
): DocumentFragment;
|
|
139
|
+
|
|
140
|
+
/** Match cases object */
|
|
141
|
+
export interface MatchCases<T extends string | number | symbol = string> {
|
|
142
|
+
[key: string]: ConditionTemplate;
|
|
143
|
+
default?: ConditionTemplate;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Switch/case rendering
|
|
148
|
+
*/
|
|
149
|
+
export declare function match<T extends string | number>(
|
|
150
|
+
getValue: Reactive<T>,
|
|
151
|
+
cases: MatchCases
|
|
152
|
+
): Comment;
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Two-way binding for form inputs
|
|
156
|
+
* @returns Element (chainable)
|
|
157
|
+
*/
|
|
158
|
+
export declare function model<E extends HTMLInputElement | HTMLSelectElement | HTMLTextAreaElement>(
|
|
159
|
+
element: E,
|
|
160
|
+
pulseValue: Pulse<string | number | boolean>
|
|
161
|
+
): E;
|
|
162
|
+
|
|
163
|
+
/**
|
|
164
|
+
* Mount element to DOM target
|
|
165
|
+
* @returns Unmount function
|
|
166
|
+
*/
|
|
167
|
+
export declare function mount(
|
|
168
|
+
target: string | HTMLElement,
|
|
169
|
+
element: Node
|
|
170
|
+
): () => void;
|
|
171
|
+
|
|
172
|
+
/** Component context object */
|
|
173
|
+
export interface ComponentContext {
|
|
174
|
+
/** Create reactive state */
|
|
175
|
+
state: <T extends Record<string, unknown>>(initial: T) => T;
|
|
176
|
+
/** Create methods bound to component */
|
|
177
|
+
methods: <T extends Record<string, (...args: unknown[]) => unknown>>(fns: T) => T;
|
|
178
|
+
/** Component props */
|
|
179
|
+
props: Record<string, unknown>;
|
|
180
|
+
/** Create pulse */
|
|
181
|
+
pulse: <T>(value: T) => Pulse<T>;
|
|
182
|
+
/** Create element */
|
|
183
|
+
el: typeof el;
|
|
184
|
+
/** Create text node */
|
|
185
|
+
text: typeof text;
|
|
186
|
+
/** Render list */
|
|
187
|
+
list: typeof list;
|
|
188
|
+
/** Conditional render */
|
|
189
|
+
when: typeof when;
|
|
190
|
+
/** Attach event */
|
|
191
|
+
on: typeof on;
|
|
192
|
+
/** Bind attribute */
|
|
193
|
+
bind: typeof bind;
|
|
194
|
+
/** Two-way binding */
|
|
195
|
+
model: typeof model;
|
|
196
|
+
/** Register mount callback */
|
|
197
|
+
onMount: (fn: () => void) => void;
|
|
198
|
+
/** Register unmount callback */
|
|
199
|
+
onUnmount: (fn: () => void) => void;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
/** Component setup function */
|
|
203
|
+
export type ComponentSetup = (ctx: ComponentContext) => Node;
|
|
204
|
+
|
|
205
|
+
/** Component factory function */
|
|
206
|
+
export type ComponentFactory = (props?: Record<string, unknown>) => Node;
|
|
207
|
+
|
|
208
|
+
/**
|
|
209
|
+
* Create component with lifecycle support
|
|
210
|
+
*/
|
|
211
|
+
export declare function component(setup: ComponentSetup): ComponentFactory;
|
|
212
|
+
|
|
213
|
+
/**
|
|
214
|
+
* Register mount callback
|
|
215
|
+
*/
|
|
216
|
+
export declare function onMount(fn: () => void): void;
|
|
217
|
+
|
|
218
|
+
/**
|
|
219
|
+
* Register unmount callback
|
|
220
|
+
*/
|
|
221
|
+
export declare function onUnmount(fn: () => void): void;
|
|
222
|
+
|
|
223
|
+
/**
|
|
224
|
+
* Toggle visibility without removing from DOM
|
|
225
|
+
* @returns Element (chainable)
|
|
226
|
+
*/
|
|
227
|
+
export declare function show<E extends HTMLElement>(
|
|
228
|
+
condition: Reactive<boolean>,
|
|
229
|
+
element: E
|
|
230
|
+
): E;
|
|
231
|
+
|
|
232
|
+
/**
|
|
233
|
+
* Render content into different DOM location
|
|
234
|
+
*/
|
|
235
|
+
export declare function portal(
|
|
236
|
+
children: Node | Node[] | (() => Node | Node[]),
|
|
237
|
+
target: string | HTMLElement
|
|
238
|
+
): Comment;
|
|
239
|
+
|
|
240
|
+
/** Error fallback function */
|
|
241
|
+
export type ErrorFallback = (error: Error) => Node | Node[];
|
|
242
|
+
|
|
243
|
+
/**
|
|
244
|
+
* Error boundary for child components
|
|
245
|
+
*/
|
|
246
|
+
export declare function errorBoundary(
|
|
247
|
+
children: Node | Node[] | (() => Node | Node[]),
|
|
248
|
+
fallback?: ErrorFallback
|
|
249
|
+
): DocumentFragment;
|
|
250
|
+
|
|
251
|
+
/** Transition options */
|
|
252
|
+
export interface TransitionOptions {
|
|
253
|
+
enter?: string;
|
|
254
|
+
exit?: string;
|
|
255
|
+
duration?: number;
|
|
256
|
+
onEnter?: (el: HTMLElement) => void;
|
|
257
|
+
onExit?: (el: HTMLElement) => void;
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/** Element with transition methods */
|
|
261
|
+
export interface TransitionElement extends HTMLElement {
|
|
262
|
+
_pulseTransitionExit?: () => void;
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
/**
|
|
266
|
+
* Animate element enter/exit
|
|
267
|
+
*/
|
|
268
|
+
export declare function transition<E extends HTMLElement>(
|
|
269
|
+
element: E,
|
|
270
|
+
options?: TransitionOptions
|
|
271
|
+
): E & TransitionElement;
|
|
272
|
+
|
|
273
|
+
/** WhenTransition options */
|
|
274
|
+
export interface WhenTransitionOptions {
|
|
275
|
+
duration?: number;
|
|
276
|
+
enterClass?: string;
|
|
277
|
+
exitClass?: string;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
/**
|
|
281
|
+
* Conditional rendering with transitions
|
|
282
|
+
*/
|
|
283
|
+
export declare function whenTransition(
|
|
284
|
+
condition: Reactive<boolean>,
|
|
285
|
+
thenTemplate: ConditionTemplate,
|
|
286
|
+
elseTemplate?: ConditionTemplate,
|
|
287
|
+
options?: WhenTransitionOptions
|
|
288
|
+
): DocumentFragment;
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pulse Framework - Type Definitions
|
|
3
|
+
* @module pulse-js-framework
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
// Core Reactivity
|
|
7
|
+
export {
|
|
8
|
+
Pulse,
|
|
9
|
+
PulseOptions,
|
|
10
|
+
ComputedOptions,
|
|
11
|
+
MemoOptions,
|
|
12
|
+
MemoComputedOptions,
|
|
13
|
+
EqualsFn,
|
|
14
|
+
ReactiveState,
|
|
15
|
+
PromiseState,
|
|
16
|
+
pulse,
|
|
17
|
+
computed,
|
|
18
|
+
effect,
|
|
19
|
+
batch,
|
|
20
|
+
watch,
|
|
21
|
+
createState,
|
|
22
|
+
memo,
|
|
23
|
+
memoComputed,
|
|
24
|
+
fromPromise,
|
|
25
|
+
untrack,
|
|
26
|
+
onCleanup
|
|
27
|
+
} from './pulse';
|
|
28
|
+
|
|
29
|
+
// DOM Helpers
|
|
30
|
+
export {
|
|
31
|
+
MaybeGetter,
|
|
32
|
+
Reactive,
|
|
33
|
+
Child,
|
|
34
|
+
ParsedSelector,
|
|
35
|
+
EventOptions,
|
|
36
|
+
KeyFn,
|
|
37
|
+
ListTemplate,
|
|
38
|
+
ConditionTemplate,
|
|
39
|
+
MatchCases,
|
|
40
|
+
ComponentContext,
|
|
41
|
+
ComponentSetup,
|
|
42
|
+
ComponentFactory,
|
|
43
|
+
ErrorFallback,
|
|
44
|
+
TransitionOptions,
|
|
45
|
+
TransitionElement,
|
|
46
|
+
WhenTransitionOptions,
|
|
47
|
+
parseSelector,
|
|
48
|
+
el,
|
|
49
|
+
text,
|
|
50
|
+
bind,
|
|
51
|
+
prop,
|
|
52
|
+
cls,
|
|
53
|
+
style,
|
|
54
|
+
on,
|
|
55
|
+
list,
|
|
56
|
+
when,
|
|
57
|
+
match,
|
|
58
|
+
model,
|
|
59
|
+
mount,
|
|
60
|
+
component,
|
|
61
|
+
onMount,
|
|
62
|
+
onUnmount,
|
|
63
|
+
show,
|
|
64
|
+
portal,
|
|
65
|
+
errorBoundary,
|
|
66
|
+
transition,
|
|
67
|
+
whenTransition
|
|
68
|
+
} from './dom';
|
|
69
|
+
|
|
70
|
+
// Router
|
|
71
|
+
export {
|
|
72
|
+
RouteParams,
|
|
73
|
+
QueryParams,
|
|
74
|
+
RouteMeta,
|
|
75
|
+
NavigationTarget,
|
|
76
|
+
NavigationGuardReturn,
|
|
77
|
+
NavigationGuard,
|
|
78
|
+
AfterNavigationHook,
|
|
79
|
+
ScrollPosition,
|
|
80
|
+
ScrollBehaviorFn,
|
|
81
|
+
RouteHandler,
|
|
82
|
+
RouteDefinition,
|
|
83
|
+
Routes,
|
|
84
|
+
RouterOptions,
|
|
85
|
+
NavigateOptions,
|
|
86
|
+
LinkOptions,
|
|
87
|
+
MatchedRoute,
|
|
88
|
+
Router,
|
|
89
|
+
createRouter,
|
|
90
|
+
simpleRouter
|
|
91
|
+
} from './router';
|
|
92
|
+
|
|
93
|
+
// Store
|
|
94
|
+
export {
|
|
95
|
+
StoreOptions,
|
|
96
|
+
StoreState,
|
|
97
|
+
StoreMethods,
|
|
98
|
+
Store,
|
|
99
|
+
ActionFn,
|
|
100
|
+
ActionsDef,
|
|
101
|
+
BoundActions,
|
|
102
|
+
GetterFn,
|
|
103
|
+
GettersDef,
|
|
104
|
+
ComputedGetters,
|
|
105
|
+
CombinedStores,
|
|
106
|
+
ModuleDef,
|
|
107
|
+
ModulesDef,
|
|
108
|
+
ModuleStore,
|
|
109
|
+
RootModuleStore,
|
|
110
|
+
StorePlugin,
|
|
111
|
+
HistoryStore,
|
|
112
|
+
createStore,
|
|
113
|
+
createActions,
|
|
114
|
+
createGetters,
|
|
115
|
+
combineStores,
|
|
116
|
+
createModuleStore,
|
|
117
|
+
usePlugin,
|
|
118
|
+
loggerPlugin,
|
|
119
|
+
historyPlugin
|
|
120
|
+
} from './store';
|
package/types/pulse.d.ts
ADDED
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pulse Framework - Core Reactivity Type Definitions
|
|
3
|
+
* @module pulse-js-framework/runtime
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/** Equality function for comparing values */
|
|
7
|
+
export type EqualsFn<T> = (a: T, b: T) => boolean;
|
|
8
|
+
|
|
9
|
+
/** Pulse options */
|
|
10
|
+
export interface PulseOptions<T> {
|
|
11
|
+
equals?: EqualsFn<T>;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/** Computed options */
|
|
15
|
+
export interface ComputedOptions {
|
|
16
|
+
lazy?: boolean;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/** Memo options */
|
|
20
|
+
export interface MemoOptions<T> {
|
|
21
|
+
equals?: EqualsFn<T>;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** MemoComputed options */
|
|
25
|
+
export interface MemoComputedOptions<T> {
|
|
26
|
+
deps?: unknown[];
|
|
27
|
+
equals?: EqualsFn<T>;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Reactive value container (signal)
|
|
32
|
+
*/
|
|
33
|
+
export declare class Pulse<T = unknown> {
|
|
34
|
+
constructor(value: T, options?: PulseOptions<T>);
|
|
35
|
+
|
|
36
|
+
/** Read value and track dependency */
|
|
37
|
+
get(): T;
|
|
38
|
+
|
|
39
|
+
/** Read value without tracking dependency */
|
|
40
|
+
peek(): T;
|
|
41
|
+
|
|
42
|
+
/** Set new value and notify subscribers */
|
|
43
|
+
set(newValue: T): void;
|
|
44
|
+
|
|
45
|
+
/** Update value using function */
|
|
46
|
+
update(fn: (value: T) => T): void;
|
|
47
|
+
|
|
48
|
+
/** Subscribe to changes, returns unsubscribe function */
|
|
49
|
+
subscribe(fn: (value: T) => void): () => void;
|
|
50
|
+
|
|
51
|
+
/** Create derived pulse */
|
|
52
|
+
derive<U>(fn: (value: T) => U): Pulse<U>;
|
|
53
|
+
|
|
54
|
+
/** Cleanup (for computed pulses) */
|
|
55
|
+
dispose(): void;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* Create a reactive value
|
|
60
|
+
*/
|
|
61
|
+
export declare function pulse<T>(value: T, options?: PulseOptions<T>): Pulse<T>;
|
|
62
|
+
|
|
63
|
+
/**
|
|
64
|
+
* Create a computed (derived) reactive value
|
|
65
|
+
*/
|
|
66
|
+
export declare function computed<T>(fn: () => T, options?: ComputedOptions): Pulse<T>;
|
|
67
|
+
|
|
68
|
+
/**
|
|
69
|
+
* Create a side effect that runs when dependencies change
|
|
70
|
+
* @returns Cleanup function
|
|
71
|
+
*/
|
|
72
|
+
export declare function effect(fn: () => void | (() => void)): () => void;
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Batch multiple updates into a single effect run
|
|
76
|
+
*/
|
|
77
|
+
export declare function batch(fn: () => void): void;
|
|
78
|
+
|
|
79
|
+
/**
|
|
80
|
+
* Watch specific pulses and run callback on change
|
|
81
|
+
* @returns Cleanup function
|
|
82
|
+
*/
|
|
83
|
+
export declare function watch<T>(
|
|
84
|
+
source: Pulse<T>,
|
|
85
|
+
callback: (newValue: T, oldValue: T) => void
|
|
86
|
+
): () => void;
|
|
87
|
+
export declare function watch<T extends readonly Pulse<unknown>[]>(
|
|
88
|
+
sources: T,
|
|
89
|
+
callback: (
|
|
90
|
+
newValues: { [K in keyof T]: T[K] extends Pulse<infer U> ? U : never },
|
|
91
|
+
oldValues: { [K in keyof T]: T[K] extends Pulse<infer U> ? U : never }
|
|
92
|
+
) => void
|
|
93
|
+
): () => void;
|
|
94
|
+
|
|
95
|
+
/** State object with reactive properties */
|
|
96
|
+
export interface ReactiveState<T extends Record<string, unknown>> {
|
|
97
|
+
/** Access raw pulses */
|
|
98
|
+
$pulses: { [K in keyof T]: Pulse<T[K]> };
|
|
99
|
+
/** Get pulse by key */
|
|
100
|
+
$pulse<K extends keyof T>(key: K): Pulse<T[K]>;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Create reactive state object from plain object
|
|
105
|
+
*/
|
|
106
|
+
export declare function createState<T extends Record<string, unknown>>(
|
|
107
|
+
obj: T
|
|
108
|
+
): T & ReactiveState<T>;
|
|
109
|
+
|
|
110
|
+
/**
|
|
111
|
+
* Memoize a function based on arguments
|
|
112
|
+
*/
|
|
113
|
+
export declare function memo<T extends (...args: unknown[]) => unknown>(
|
|
114
|
+
fn: T,
|
|
115
|
+
options?: MemoOptions<ReturnType<T>>
|
|
116
|
+
): T;
|
|
117
|
+
|
|
118
|
+
/**
|
|
119
|
+
* Create memoized computed value
|
|
120
|
+
*/
|
|
121
|
+
export declare function memoComputed<T>(
|
|
122
|
+
fn: () => T,
|
|
123
|
+
options?: MemoComputedOptions<T>
|
|
124
|
+
): Pulse<T>;
|
|
125
|
+
|
|
126
|
+
/** Promise result state */
|
|
127
|
+
export interface PromiseState<T> {
|
|
128
|
+
value: Pulse<T | undefined>;
|
|
129
|
+
loading: Pulse<boolean>;
|
|
130
|
+
error: Pulse<Error | null>;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* Create reactive values from a promise
|
|
135
|
+
*/
|
|
136
|
+
export declare function fromPromise<T>(
|
|
137
|
+
promise: Promise<T>,
|
|
138
|
+
initialValue?: T
|
|
139
|
+
): PromiseState<T>;
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Read pulses without creating dependencies
|
|
143
|
+
*/
|
|
144
|
+
export declare function untrack<T>(fn: () => T): T;
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Register cleanup function for current effect
|
|
148
|
+
*/
|
|
149
|
+
export declare function onCleanup(fn: () => void): void;
|