solid-js 1.1.2 → 1.1.6-beta.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.
@@ -0,0 +1,429 @@
1
+ import { requestCallback } from "./scheduler";
2
+ import type { JSX } from "../jsx";
3
+ export declare type Accessor<T> = () => T;
4
+ export declare type Setter<T> = undefined extends T ? <U extends T>(v?: (U extends Function ? never : U) | ((prev?: U) => U)) => U : <U extends T>(v: (U extends Function ? never : U) | ((prev: U) => U)) => U;
5
+ export declare const equalFn: <T>(a: T, b: T) => boolean;
6
+ export declare const $PROXY: unique symbol;
7
+ export declare const NOTPENDING: {};
8
+ export declare var Owner: Owner | null;
9
+ export declare let Transition: Transition | null;
10
+ declare global {
11
+ var _$afterUpdate: () => void;
12
+ }
13
+ interface Signal<T> {
14
+ value?: T;
15
+ observer: any;
16
+ observerSlot: number;
17
+ observers: Computation<any>[] | null;
18
+ observerSlots: number[] | null;
19
+ pending: T | {};
20
+ comparator?: (prev: T, next: T) => boolean;
21
+ name?: string;
22
+ }
23
+ interface Owner {
24
+ owned: Computation<any>[] | null;
25
+ cleanups: (() => void)[] | null;
26
+ owner: Owner | null;
27
+ context: any | null;
28
+ sourceMap?: Record<string, {
29
+ value: unknown;
30
+ }>;
31
+ name?: string;
32
+ componentName?: string;
33
+ }
34
+ interface Computation<T> extends Owner {
35
+ fn: (v?: T) => T;
36
+ state: number;
37
+ source: Signal<T> | null;
38
+ sourceSlot: number;
39
+ sources: Signal<T>[] | null;
40
+ sourceSlots: number[] | null;
41
+ value?: T;
42
+ updatedAt: number;
43
+ pure: boolean;
44
+ user?: boolean;
45
+ suspense?: SuspenseContextType;
46
+ }
47
+ interface Transition {
48
+ sources: Set<Signal<any> | Computation<any>>;
49
+ lookup: Map<Signal<any> | Computation<any>, Signal<any> | Computation<any>>;
50
+ updated: Set<Computation<any>>;
51
+ effects: Computation<any>[];
52
+ promises: Set<Promise<any>>;
53
+ queue: Set<Computation<any>>;
54
+ scheduler?: (fn: () => void) => unknown;
55
+ running: boolean;
56
+ cb: (() => void)[];
57
+ }
58
+ /**
59
+ * Creates a new non-tracked reactive context that doesn't auto-dispose
60
+ *
61
+ * @param fn a function in which the reactive state is scoped
62
+ * @param detachedOwner optional reactive context to bind the root to
63
+ * @returns the output of `fn`.
64
+ *
65
+ * @description https://www.solidjs.com/docs/latest/api#createroot
66
+ */
67
+ export declare function createRoot<T>(fn: (dispose: () => void) => T, detachedOwner?: Owner): T;
68
+ export declare type SignalOptions<T> = {
69
+ name?: string;
70
+ equals?: false | ((prev: T, next: T) => boolean);
71
+ };
72
+ /**
73
+ * Creates a simple reactive state with a getter and setter
74
+ * ```typescript
75
+ * const [state: Accessor<T>, setState: Setter<T>] = createSignal<T>(
76
+ * value: T,
77
+ * options?: { name?: string, equals?: false | ((prev: T, next: T) => boolean) }
78
+ * )
79
+ * ```
80
+ * @param value initial value of the state; if empty, the state's type will automatically extended with undefined; otherwise you need to extend the type manually if you want setting to undefined not be an error
81
+ * @param options optional object with a name for debugging purposes and equals, a comparator function for the previous and next value to allow fine-grained control over the reactivity
82
+ *
83
+ * @returns ```typescript
84
+ * [state: Accessor<T>, setState: Setter<T>]
85
+ * ```
86
+ * * the Accessor is merely a function that returns the current value and registers each call to the reactive root
87
+ * * the Setter is a function that allows directly setting or mutating the value:
88
+ * ```typescript
89
+ * const [count, setCount] = createSignal(0);
90
+ * setCount(count => count + 1);
91
+ * ```
92
+ *
93
+ * @description https://www.solidjs.com/docs/latest/api#createsignal
94
+ */
95
+ export declare function createSignal<T>(): [get: Accessor<T | undefined>, set: Setter<T | undefined>];
96
+ export declare function createSignal<T>(value: T, options?: {
97
+ equals?: false | ((prev: T, next: T) => boolean);
98
+ name?: string;
99
+ internal?: boolean;
100
+ }): [get: Accessor<T>, set: Setter<T>];
101
+ /**
102
+ * Creates a reactive computation that runs immediately before render, mainly used to write to other reactive primitives
103
+ * ```typescript
104
+ * export function createComputed<T>(
105
+ * fn: (v: T) => T,
106
+ * value?: T,
107
+ * options?: { name?: string }
108
+ * ): void;
109
+ * ```
110
+ * @param fn a function that receives its previous or the initial value, if set, and returns a new value used to react on a computation
111
+ * @param value an optional initial value for the computation; if set, fn will never receive undefined as first argument
112
+ * @param options allows to set a name in dev mode for debugging purposes
113
+ *
114
+ * @description https://www.solidjs.com/docs/latest/api#createcomputed
115
+ */
116
+ export declare function createComputed<T>(fn: (v?: T) => T | undefined): void;
117
+ export declare function createComputed<T>(fn: (v: T) => T, value: T, options?: {
118
+ name?: string;
119
+ }): void;
120
+ /**
121
+ * Creates a reactive computation that runs during the render phase as DOM elements are created and updated but not necessarily connected
122
+ * ```typescript
123
+ * export function createRenderEffect<T>(
124
+ * fn: (v: T) => T,
125
+ * value?: T,
126
+ * options?: { name?: string }
127
+ * ): void;
128
+ * ```
129
+ * @param fn a function that receives its previous or the initial value, if set, and returns a new value used to react on a computation
130
+ * @param value an optional initial value for the computation; if set, fn will never receive undefined as first argument
131
+ * @param options allows to set a name in dev mode for debugging purposes
132
+ *
133
+ * @description https://www.solidjs.com/docs/latest/api#createrendereffect
134
+ */
135
+ export declare function createRenderEffect<T>(fn: (v?: T) => T | undefined): void;
136
+ export declare function createRenderEffect<T>(fn: (v: T) => T, value: T, options?: {
137
+ name?: string;
138
+ }): void;
139
+ /**
140
+ * Creates a reactive computation that runs after the render phase
141
+ * ```typescript
142
+ * export function createEffect<T>(
143
+ * fn: (v: T) => T,
144
+ * value?: T,
145
+ * options?: { name?: string }
146
+ * ): void;
147
+ * ```
148
+ * @param fn a function that receives its previous or the initial value, if set, and returns a new value used to react on a computation
149
+ * @param value an optional initial value for the computation; if set, fn will never receive undefined as first argument
150
+ * @param options allows to set a name in dev mode for debugging purposes
151
+ *
152
+ * @description https://www.solidjs.com/docs/latest/api#createeffect
153
+ */
154
+ export declare function createEffect<T>(fn: (v?: T) => T | undefined): void;
155
+ export declare function createEffect<T>(fn: (v: T) => T, value: T, options?: {
156
+ name?: string;
157
+ }): void;
158
+ /**
159
+ * Creates a readonly derived reactive memoized signal
160
+ * ```typescript
161
+ * export function createMemo<T>(
162
+ * fn: (v: T) => T,
163
+ * value?: T,
164
+ * options?: { name?: string, equals?: false | ((prev: T, next: T) => boolean) }
165
+ * ): T;
166
+ * ```
167
+ * @param fn a function that receives its previous or the initial value, if set, and returns a new value used to react on a computation
168
+ * @param value an optional initial value for the computation; if set, fn will never receive undefined as first argument
169
+ * @param options allows to set a name in dev mode for debugging purposes and use a custom comparison function in equals
170
+ *
171
+ * @description https://www.solidjs.com/docs/latest/api#creatememo
172
+ */
173
+ export declare function createMemo<T>(fn: (v?: T) => T, value?: undefined, options?: {
174
+ equals?: false | ((prev: T, next: T) => boolean);
175
+ name?: string;
176
+ }): Accessor<T>;
177
+ export declare function createMemo<T>(fn: (v: T) => T, value: T, options?: {
178
+ equals?: false | ((prev: T, next: T) => boolean);
179
+ name?: string;
180
+ }): Accessor<T>;
181
+ export interface Resource<T> extends Accessor<T> {
182
+ loading: boolean;
183
+ error: any;
184
+ }
185
+ export declare type ResourceActions<T> = {
186
+ mutate: Setter<T>;
187
+ refetch: () => void;
188
+ };
189
+ export declare type ResourceReturn<T> = [Resource<T>, ResourceActions<T>];
190
+ export declare type ResourceSource<S> = S | false | null | (() => S | false | null);
191
+ export declare type ResourceFetcher<S, T> = (k: S, getPrev: Accessor<T>) => T | Promise<T>;
192
+ export declare type ResourceOptions<T> = T extends undefined ? {
193
+ initialValue?: T;
194
+ name?: string;
195
+ } : {
196
+ initialValue: T;
197
+ name?: string;
198
+ };
199
+ /**
200
+ * Creates a resource that wraps a repeated promise in a reactive pattern:
201
+ * ```typescript
202
+ * const [resource, { mutate, refetch }] = crateResource(source, fetcher, options);
203
+ * ```
204
+ * @param source - reactive data function to toggle the request, optional
205
+ * @param fetcher - function that receives the source (or true) and an accessor for the last or initial value and returns a value or a Promise with the value:
206
+ * ```typescript
207
+ * const fetcher: ResourceFetcher<S, T, > = (
208
+ * sourceOutput: ReturnValue<typeof source>,
209
+ * getPrev: Accessor<T>
210
+ * ) => T | Promise<T>;
211
+ * ```
212
+ * @param options - an optional object with the initialValue and the name (for debugging purposes)
213
+ *
214
+ * @returns ```typescript
215
+ * [Resource<T>, { mutate: Setter<T>, refetch: () => void }]
216
+ * ```
217
+ *
218
+ * * Setting an `initialValue` in the options will mean that both the prev() accessor and the resource should never return undefined (if that is wanted, you need to extend the type with undefined)
219
+ * * `mutate` allows to manually overwrite the resource without calling the fetcher
220
+ * * `refetch` will re-run the fetcher without changing the source
221
+ *
222
+ * @description https://www.solidjs.com/docs/latest/api#createresource
223
+ */
224
+ export declare function createResource<T extends any, S = true>(fetcher: ResourceFetcher<S, T>, options?: ResourceOptions<undefined>): [Resource<T | undefined>, ResourceActions<T | undefined>];
225
+ export declare function createResource<T, S = true>(fetcher: ResourceFetcher<S, T>, options: ResourceOptions<T>): [Resource<T>, ResourceActions<T>];
226
+ export declare function createResource<T, S>(source: ResourceSource<S>, fetcher: ResourceFetcher<S, T>, options?: ResourceOptions<undefined>): [Resource<T | undefined>, ResourceActions<T | undefined>];
227
+ export declare function createResource<T, S>(source: ResourceSource<S>, fetcher: ResourceFetcher<S, T>, options: ResourceOptions<T>): [Resource<T>, ResourceActions<T>];
228
+ /**
229
+ * Creates a reactive computation that only runs and notifies the reactive context when the browser is idle
230
+ * ```typescript
231
+ * export function createDeferred<T>(
232
+ * fn: (v: T) => T,
233
+ * value?: T,
234
+ * options?: { timeoutMs?: number, name?: string, equals?: false | ((prev: T, next: T) => boolean) }
235
+ * ): () => T);
236
+ * ```
237
+ * @param fn a function that receives its previous or the initial value, if set, and returns a new value used to react on a computation
238
+ * @param value an optional initial value for the computation; if set, fn will never receive undefined as first argument
239
+ * @param options allows to set the timeout in milliseconds, use a custom comparison function and set a name in dev mode for debugging purposes
240
+ *
241
+ * @description https://www.solidjs.com/docs/latest/api#createdeferred
242
+ */
243
+ export declare function createDeferred<T>(source: Accessor<T>, options?: {
244
+ equals?: false | ((prev: T, next: T) => boolean);
245
+ name?: string;
246
+ timeoutMs?: number;
247
+ }): Accessor<T>;
248
+ /**
249
+ * Creates a conditional signal that only notifies subscribers when entering or exiting their key matching the value
250
+ * ```typescript
251
+ * export function createRenderEffect<T, U>(
252
+ * source: () => T
253
+ * fn: (a: U, b: T) => boolean,
254
+ * options?: { name?: string }
255
+ * ): (k: U) => boolean;
256
+ * ```
257
+ * @param source
258
+ * @param fn a function that receives its previous or the initial value, if set, and returns a new value used to react on a computation
259
+ * @param options allows to set a name in dev mode for debugging purposes, optional
260
+ *
261
+ * ```typescript
262
+ * const isSelected = createSelector(selectedId);
263
+ * <For each={list()}>
264
+ * {(item) => <li classList={{ active: isSelected(item.id) }}>{item.name}</li>}
265
+ * </For>
266
+ * ```
267
+ *
268
+ * This makes the operation O(2) instead of O(n).
269
+ *
270
+ * @description https://www.solidjs.com/docs/latest/api#createrendereffect
271
+ */
272
+ export declare function createSelector<T, U>(source: Accessor<T>, fn?: (a: U, b: T) => boolean, options?: {
273
+ name?: string;
274
+ }): (key: U) => boolean;
275
+ /**
276
+ * Holds changes inside the block before the reactive context is updated
277
+ * @param fn wraps the reactive updates that should be batched
278
+ * @returns the return value from `fn`
279
+ *
280
+ * @description https://www.solidjs.com/docs/latest/api#batch
281
+ */
282
+ export declare function batch<T>(fn: () => T): T;
283
+ /**
284
+ * Ignores tracking context inside its scope
285
+ * @param fn the scope that is out of the tracking context
286
+ * @returns the return value of `fn`
287
+ *
288
+ * @description https://www.solidjs.com/docs/latest/api#untrack
289
+ */
290
+ export declare function untrack<T>(fn: Accessor<T>): T;
291
+ export declare type ReturnTypes<T> = T extends (() => any)[] ? {
292
+ [I in keyof T]: ReturnTypes<T[I]>;
293
+ } : T extends () => any ? ReturnType<T> : never;
294
+ /**
295
+ * on - make dependencies of a computation explicit
296
+ * ```typescript
297
+ * export function on<T extends Array<() => any> | (() => any), U>(
298
+ * deps: T | T[],
299
+ * fn: (input: T, prevInput: T, prevValue?: U) => U,
300
+ * options?: { defer?: boolean } = {}
301
+ * ): (prevValue?: U) => U | undefined;
302
+ * ```
303
+ * @param deps list of reactive dependencies or a single reactive dependency
304
+ * @param fn computation on input; the current previous content(s) of input and the previous value are given as arguments and it returns a new value
305
+ * @param options optional, allows deferred computation until at the end of the next change
306
+ * ```typescript
307
+ * createEffect(on(a, (v) => console.log(v, b())));
308
+ *
309
+ * // is equivalent to:
310
+ * createEffect(() => {
311
+ * const v = a();
312
+ * untrack(() => console.log(v, b()));
313
+ * });
314
+ * ```
315
+ *
316
+ * @description https://www.solidjs.com/docs/latest/api#on
317
+ */
318
+ export declare function on<T extends (() => any)[], U>(deps: [...T], fn: (input: ReturnTypes<T>, prevInput: ReturnTypes<T>, prevValue?: U) => U, options?: {
319
+ defer?: boolean;
320
+ }): (prevValue?: U) => U;
321
+ export declare function on<T extends () => any, U>(deps: T, fn: (input: ReturnType<T>, prevInput: ReturnType<T>, prevValue?: U) => U, options?: {
322
+ defer?: boolean;
323
+ }): (prevValue?: U) => U;
324
+ /**
325
+ * onMount - run an effect only after initial render on mount
326
+ * @param fn an effect that should run only once on mount
327
+ *
328
+ * @description https://www.solidjs.com/docs/latest/api#onmount
329
+ */
330
+ export declare function onMount(fn: () => void): void;
331
+ /**
332
+ * onCleanup - run an effect once before the reactive scope is disposed
333
+ * @param fn an effect that should run only once on cleanup
334
+ *
335
+ * @description https://www.solidjs.com/docs/latest/api#oncleanup
336
+ */
337
+ export declare function onCleanup(fn: () => void): () => void;
338
+ /**
339
+ * onError - run an effect whenever an error is thrown within the context of the child scopes
340
+ * @param fn an error handler that receives the error
341
+ *
342
+ * * If the error is thrown again inside the error handler, it will trigger the next available parent handler
343
+ *
344
+ * @description https://www.solidjs.com/docs/latest/api#onerror
345
+ */
346
+ export declare function onError(fn: (err: any) => void): void;
347
+ export declare function getListener(): Computation<any> | null;
348
+ export declare function getOwner(): Owner | null;
349
+ export declare function runWithOwner(o: Owner, fn: () => any): any;
350
+ export declare function enableScheduling(scheduler?: typeof requestCallback): void;
351
+ export declare function startTransition(fn: () => void, cb?: () => void): void;
352
+ /**
353
+ * ```typescript
354
+ * export function useTransition(): [
355
+ * () => boolean,
356
+ * (fn: () => void, cb?: () => void) => void
357
+ * ];
358
+ * @returns a tuple; first value is an accessor if the transition is pending and a callback to start the transition
359
+ *
360
+ * @description https://www.solidjs.com/docs/latest/api#usetransition
361
+ */
362
+ export declare function useTransition(): [Accessor<boolean>, (fn: () => void, cb?: () => void) => void];
363
+ export declare function resumeEffects(e: Computation<any>[]): void;
364
+ export declare function devComponent<T>(Comp: (props: T) => JSX.Element, props: T): JSX.Element;
365
+ export declare function hashValue(v: any): string;
366
+ export declare function registerGraph(name: string, value: {
367
+ value: unknown;
368
+ }): string;
369
+ interface GraphRecord {
370
+ [k: string]: GraphRecord | unknown;
371
+ }
372
+ export declare function serializeGraph(owner?: Owner | null): GraphRecord;
373
+ export interface Context<T> {
374
+ id: symbol;
375
+ Provider: (props: {
376
+ value: T;
377
+ children: any;
378
+ }) => any;
379
+ defaultValue: T;
380
+ }
381
+ /**
382
+ * Creates a Context to handle a state scoped for the children of a component
383
+ * ```typescript
384
+ * interface Context<T> {
385
+ * id: symbol;
386
+ * Provider: (props: { value: T; children: any }) => any;
387
+ * defaultValue: T;
388
+ * }
389
+ * export function createContext<T>(defaultValue?: T): Context<T | undefined>;
390
+ * ```
391
+ * @param defaultValue optional default to inject into context
392
+ * @returns The context that contains the Provider Component and that can be used with `useContext`
393
+ *
394
+ * @description https://www.solidjs.com/docs/latest/api#createcontext
395
+ */
396
+ export declare function createContext<T>(): Context<T | undefined>;
397
+ export declare function createContext<T>(defaultValue: T): Context<T>;
398
+ /**
399
+ * use a context to receive a scoped state from a parent's Context.Provider
400
+ *
401
+ * @param context Context object made by `createContext`
402
+ * @returns the current or `defaultValue`, if present
403
+ *
404
+ * @description https://www.solidjs.com/docs/latest/api#usecontext
405
+ */
406
+ export declare function useContext<T>(context: Context<T>): T;
407
+ /**
408
+ * Resolves child elements to help interact with children
409
+ *
410
+ * @param fn an accessor for the children
411
+ * @returns a accessor of the same children, but resolved
412
+ *
413
+ * @description https://www.solidjs.com/docs/latest/api#children
414
+ */
415
+ export declare function children(fn: Accessor<JSX.Element>): Accessor<JSX.Element>;
416
+ declare type SuspenseContextType = {
417
+ increment?: () => void;
418
+ decrement?: () => void;
419
+ inFallback?: () => boolean;
420
+ effects?: Computation<any>[];
421
+ resolved?: boolean;
422
+ };
423
+ export declare function getSuspenseContext(): Context<SuspenseContextType> & {
424
+ active?(): boolean;
425
+ increment?(): void;
426
+ decrement?(): void;
427
+ };
428
+ export declare function writeSignal(node: Signal<any>, value: any): any;
429
+ export {};
@@ -0,0 +1,178 @@
1
+ import { requestCallback } from "./scheduler";
2
+ import type { JSX } from "../jsx";
3
+ export declare type Accessor<T> = () => T;
4
+ export declare type Setter<T> = undefined extends T ? <U extends T>(v?: (U extends Function ? never : U) | ((prev?: U) => U)) => U : <U extends T>(v: (U extends Function ? never : U) | ((prev: U) => U)) => U;
5
+ export declare const equalFn: <T>(a: T, b: T) => boolean;
6
+ export declare const $PROXY: unique symbol;
7
+ export declare const NOTPENDING: {};
8
+ export declare var Owner: Owner | null;
9
+ export declare let Transition: Transition | null;
10
+ declare global {
11
+ var _$afterUpdate: () => void;
12
+ }
13
+ interface Signal<T> {
14
+ value?: T;
15
+ observer: Computation<any> | null;
16
+ observerSlot: number;
17
+ observers: Computation<any>[] | null;
18
+ observerSlots: number[] | null;
19
+ pending: T | {};
20
+ comparator?: (prev: T, next: T) => boolean;
21
+ name?: string;
22
+ }
23
+ interface Owner {
24
+ owned: Computation<any>[] | null;
25
+ cleanups: (() => void)[] | null;
26
+ owner: Owner | null;
27
+ context: any | null;
28
+ sourceMap?: Record<string, {
29
+ value: unknown;
30
+ }>;
31
+ name?: string;
32
+ componentName?: string;
33
+ }
34
+ interface Computation<T> extends Owner {
35
+ fn: (v?: T) => T;
36
+ stale: number;
37
+ ready: number;
38
+ source: Signal<T> | null;
39
+ sourceSlot: number;
40
+ sources: Signal<T>[] | null;
41
+ sourceSlots: number[] | null;
42
+ value?: T;
43
+ updatedAt: number;
44
+ pure: boolean;
45
+ user?: boolean;
46
+ suspense?: SuspenseContextType;
47
+ }
48
+ interface Memo<T> extends Signal<T>, Computation<T> {
49
+ }
50
+ interface Transition {
51
+ sources: Set<Signal<any> | Computation<any>>;
52
+ lookup: Map<Signal<any> | Computation<any>, Signal<any> | Computation<any>>;
53
+ updated: Set<Computation<any>>;
54
+ effects: Computation<any>[];
55
+ promises: Set<Promise<any>>;
56
+ queue: Set<Computation<any>>;
57
+ scheduler?: (fn: () => void) => unknown;
58
+ running: boolean;
59
+ cb: (() => void)[];
60
+ }
61
+ export declare function createRoot<T>(fn: (dispose: () => void) => T, detachedOwner?: Owner): T;
62
+ export declare function createSignal<T>(): [get: Accessor<T | undefined>, set: Setter<T | undefined>];
63
+ export declare function createSignal<T>(value: T, options?: {
64
+ equals?: false | ((prev: T, next: T) => boolean);
65
+ name?: string;
66
+ internal?: boolean;
67
+ }): [get: Accessor<T>, set: Setter<T>];
68
+ export declare function createComputed<T>(fn: (v?: T) => T | undefined): void;
69
+ export declare function createComputed<T>(fn: (v: T) => T, value: T, options?: {
70
+ name?: string;
71
+ }): void;
72
+ export declare function createRenderEffect<T>(fn: (v?: T) => T | undefined): void;
73
+ export declare function createRenderEffect<T>(fn: (v: T) => T, value: T, options?: {
74
+ name?: string;
75
+ }): void;
76
+ export declare function createEffect<T>(fn: (v?: T) => T | undefined): void;
77
+ export declare function createEffect<T>(fn: (v: T) => T, value: T, options?: {
78
+ name?: string;
79
+ }): void;
80
+ export declare function createMemo<T>(fn: (v?: T) => T, value?: undefined, options?: {
81
+ equals?: false | ((prev: T, next: T) => boolean);
82
+ name?: string;
83
+ }): Accessor<T>;
84
+ export declare function createMemo<T>(fn: (v: T) => T, value: T, options?: {
85
+ equals?: false | ((prev: T, next: T) => boolean);
86
+ name?: string;
87
+ }): Accessor<T>;
88
+ export interface Resource<T> extends Accessor<T> {
89
+ loading: boolean;
90
+ error: any;
91
+ }
92
+ export declare type ResourceReturn<T> = [
93
+ Resource<T>,
94
+ {
95
+ mutate: Setter<T>;
96
+ refetch: () => void;
97
+ }
98
+ ];
99
+ export declare function createResource<T, U = true>(fetcher: (k: U, getPrev: Accessor<T | undefined>) => T | Promise<T>, options?: {
100
+ initialValue?: undefined;
101
+ name?: string;
102
+ }): ResourceReturn<T | undefined>;
103
+ export declare function createResource<T, U = true>(fetcher: (k: U, getPrev: Accessor<T>) => T | Promise<T>, options: {
104
+ initialValue: T;
105
+ name?: string;
106
+ }): ResourceReturn<T>;
107
+ export declare function createResource<T, U>(source: U | false | null | (() => U | false | null), fetcher: (k: U, getPrev: Accessor<T | undefined>) => T | Promise<T>, options?: {
108
+ initialValue?: undefined;
109
+ name?: string;
110
+ }): ResourceReturn<T | undefined>;
111
+ export declare function createResource<T, U>(source: U | false | null | (() => U | false | null), fetcher: (k: U, getPrev: Accessor<T>) => T | Promise<T>, options: {
112
+ initialValue: T;
113
+ name?: string;
114
+ }): ResourceReturn<T>;
115
+ export declare function createDeferred<T>(source: Accessor<T>, options?: {
116
+ equals?: false | ((prev: T, next: T) => boolean);
117
+ name?: string;
118
+ timeoutMs?: number;
119
+ }): Accessor<T>;
120
+ export declare function createSelector<T, U>(source: Accessor<T>, fn?: (a: U, b: T) => boolean, options?: {
121
+ name?: string;
122
+ }): (key: U) => boolean;
123
+ export declare function batch<T, U>(fn: () => T): T;
124
+ export declare function untrack<T>(fn: Accessor<T>): T;
125
+ export declare type ReturnTypes<T> = T extends (() => any)[] ? {
126
+ [I in keyof T]: ReturnTypes<T[I]>;
127
+ } : T extends () => any ? ReturnType<T> : never;
128
+ export declare function on<T extends (() => any)[], U>(deps: [...T], fn: (input: ReturnTypes<T>, prevInput: ReturnTypes<T>, prevValue?: U) => U, options?: {
129
+ defer?: boolean;
130
+ }): (prevValue?: U) => U;
131
+ export declare function on<T extends () => any, U>(deps: T, fn: (input: ReturnType<T>, prevInput: ReturnType<T>, prevValue?: U) => U, options?: {
132
+ defer?: boolean;
133
+ }): (prevValue?: U) => U;
134
+ export declare function onMount(fn: () => void): void;
135
+ export declare function onCleanup(fn: () => void): () => void;
136
+ export declare function onError(fn: (err: any) => void): void;
137
+ export declare function getListener(): Computation<any> | null;
138
+ export declare function getOwner(): Owner | null;
139
+ export declare function runWithOwner(o: Owner, fn: () => any): any;
140
+ export declare function enableScheduling(scheduler?: typeof requestCallback): void;
141
+ export declare function startTransition(fn: () => void, cb?: () => void): void;
142
+ export declare function useTransition(): [Accessor<boolean>, (fn: () => void, cb?: () => void) => void];
143
+ export declare function resumeEffects(e: Computation<any>[]): void;
144
+ export declare function devComponent<T>(Comp: (props: T) => JSX.Element, props: T): JSX.Element;
145
+ export declare function hashValue(v: any): string;
146
+ export declare function registerGraph(name: string, value: {
147
+ value: unknown;
148
+ }): string;
149
+ interface GraphRecord {
150
+ [k: string]: GraphRecord | unknown;
151
+ }
152
+ export declare function serializeGraph(owner?: Owner | null): GraphRecord;
153
+ export interface Context<T> {
154
+ id: symbol;
155
+ Provider: (props: {
156
+ value: T;
157
+ children: any;
158
+ }) => any;
159
+ defaultValue: T;
160
+ }
161
+ export declare function createContext<T>(): Context<T | undefined>;
162
+ export declare function createContext<T>(defaultValue: T): Context<T>;
163
+ export declare function useContext<T>(context: Context<T>): T;
164
+ export declare function children(fn: Accessor<JSX.Element>): Accessor<JSX.Element>;
165
+ declare type SuspenseContextType = {
166
+ increment?: () => void;
167
+ decrement?: () => void;
168
+ inFallback?: () => boolean;
169
+ effects?: Computation<any>[];
170
+ resolved?: boolean;
171
+ };
172
+ export declare function getSuspenseContext(): Context<SuspenseContextType> & {
173
+ active?(): boolean;
174
+ increment?(): void;
175
+ decrement?(): void;
176
+ };
177
+ export declare function writeSignal(node: Signal<any> | Memo<any>, value: any, isComp?: boolean): true | undefined;
178
+ export {};