solid-js 1.9.3 → 2.0.0-experimental.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.
Files changed (76) hide show
  1. package/dist/dev.cjs +213 -1603
  2. package/dist/dev.js +159 -1749
  3. package/dist/server.cjs +88 -11
  4. package/dist/server.js +91 -11
  5. package/dist/solid.cjs +196 -1558
  6. package/dist/solid.js +139 -1682
  7. package/package.json +8 -154
  8. package/types/{render → client}/component.d.ts +0 -61
  9. package/types/client/core.d.ts +75 -0
  10. package/types/client/flow.d.ts +114 -0
  11. package/types/{render → client}/hydration.d.ts +0 -2
  12. package/types/{reactive → client}/observable.d.ts +1 -1
  13. package/types/index.d.ts +44 -55
  14. package/types/jsx.d.ts +1944 -174
  15. package/types/server/index.d.ts +1 -1
  16. package/types/server/reactive.d.ts +6 -1
  17. package/types/server/store.d.ts +6 -0
  18. package/h/dist/h.cjs +0 -115
  19. package/h/dist/h.js +0 -144
  20. package/h/jsx-dev-runtime/package.json +0 -8
  21. package/h/jsx-runtime/dist/jsx.cjs +0 -15
  22. package/h/jsx-runtime/dist/jsx.js +0 -10
  23. package/h/jsx-runtime/package.json +0 -8
  24. package/h/jsx-runtime/types/index.d.ts +0 -14
  25. package/h/jsx-runtime/types/jsx.d.ts +0 -2276
  26. package/h/package.json +0 -8
  27. package/h/types/hyperscript.d.ts +0 -20
  28. package/h/types/index.d.ts +0 -3
  29. package/html/dist/html.cjs +0 -583
  30. package/html/dist/html.js +0 -706
  31. package/html/package.json +0 -8
  32. package/html/types/index.d.ts +0 -3
  33. package/html/types/lit.d.ts +0 -60
  34. package/store/dist/dev.cjs +0 -454
  35. package/store/dist/dev.js +0 -525
  36. package/store/dist/server.cjs +0 -126
  37. package/store/dist/server.js +0 -126
  38. package/store/dist/store.cjs +0 -434
  39. package/store/dist/store.js +0 -499
  40. package/store/package.json +0 -46
  41. package/store/types/index.d.ts +0 -26
  42. package/store/types/modifiers.d.ts +0 -9
  43. package/store/types/mutable.d.ts +0 -8
  44. package/store/types/server.d.ts +0 -37
  45. package/store/types/store.d.ts +0 -263
  46. package/types/reactive/array.d.ts +0 -52
  47. package/types/reactive/scheduler.d.ts +0 -13
  48. package/types/reactive/signal.d.ts +0 -664
  49. package/types/render/Suspense.d.ts +0 -26
  50. package/types/render/flow.d.ts +0 -130
  51. package/types/render/index.d.ts +0 -4
  52. package/universal/dist/dev.cjs +0 -243
  53. package/universal/dist/dev.js +0 -257
  54. package/universal/dist/universal.cjs +0 -243
  55. package/universal/dist/universal.js +0 -257
  56. package/universal/package.json +0 -20
  57. package/universal/types/index.d.ts +0 -4
  58. package/universal/types/universal.d.ts +0 -29
  59. package/web/dist/dev.cjs +0 -804
  60. package/web/dist/dev.js +0 -1241
  61. package/web/dist/server.cjs +0 -793
  62. package/web/dist/server.js +0 -1214
  63. package/web/dist/web.cjs +0 -793
  64. package/web/dist/web.js +0 -1220
  65. package/web/package.json +0 -46
  66. package/web/storage/dist/storage.cjs +0 -12
  67. package/web/storage/dist/storage.js +0 -10
  68. package/web/storage/package.json +0 -15
  69. package/web/storage/types/index.d.ts +0 -2
  70. package/web/storage/types/index.js +0 -13
  71. package/web/types/client.d.ts +0 -79
  72. package/web/types/core.d.ts +0 -10
  73. package/web/types/index.d.ts +0 -54
  74. package/web/types/jsx.d.ts +0 -1
  75. package/web/types/server-mock.d.ts +0 -80
  76. package/web/types/server.d.ts +0 -177
@@ -1,664 +0,0 @@
1
- /**
2
- The MIT License (MIT)
3
-
4
- Copyright (c) 2017 Adam Haile
5
-
6
- Permission is hereby granted, free of charge, to any person obtaining a copy
7
- of this software and associated documentation files (the "Software"), to deal
8
- in the Software without restriction, including without limitation the rights
9
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
- copies of the Software, and to permit persons to whom the Software is
11
- furnished to do so, subject to the following conditions:
12
-
13
- The above copyright notice and this permission notice shall be included in all
14
- copies or substantial portions of the Software.
15
-
16
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
- SOFTWARE.
23
- */
24
- import { requestCallback } from "./scheduler.js";
25
- import type { JSX } from "../jsx.js";
26
- import type { FlowComponent } from "../render/index.js";
27
- export declare const equalFn: <T>(a: T, b: T) => boolean;
28
- export declare const $PROXY: unique symbol;
29
- export declare const SUPPORTS_PROXY: boolean;
30
- export declare const $TRACK: unique symbol;
31
- export declare const $DEVCOMP: unique symbol;
32
- export declare var Owner: Owner | null;
33
- export declare let Transition: TransitionState | null;
34
- /** Object storing callbacks for debugging during development */
35
- export declare const DevHooks: {
36
- afterUpdate: (() => void) | null;
37
- afterCreateOwner: ((owner: Owner) => void) | null;
38
- afterCreateSignal: ((signal: SignalState<any>) => void) | null;
39
- };
40
- export type ComputationState = 0 | 1 | 2;
41
- export interface SourceMapValue {
42
- value: unknown;
43
- name?: string;
44
- graph?: Owner;
45
- }
46
- export interface SignalState<T> extends SourceMapValue {
47
- value: T;
48
- observers: Computation<any>[] | null;
49
- observerSlots: number[] | null;
50
- tValue?: T;
51
- comparator?: (prev: T, next: T) => boolean;
52
- }
53
- export interface Owner {
54
- owned: Computation<any>[] | null;
55
- cleanups: (() => void)[] | null;
56
- owner: Owner | null;
57
- context: any | null;
58
- sourceMap?: SourceMapValue[];
59
- name?: string;
60
- }
61
- export interface Computation<Init, Next extends Init = Init> extends Owner {
62
- fn: EffectFunction<Init, Next>;
63
- state: ComputationState;
64
- tState?: ComputationState;
65
- sources: SignalState<Next>[] | null;
66
- sourceSlots: number[] | null;
67
- value?: Init;
68
- updatedAt: number | null;
69
- pure: boolean;
70
- user?: boolean;
71
- suspense?: SuspenseContextType;
72
- }
73
- export interface TransitionState {
74
- sources: Set<SignalState<any>>;
75
- effects: Computation<any>[];
76
- promises: Set<Promise<any>>;
77
- disposed: Set<Computation<any>>;
78
- queue: Set<Computation<any>>;
79
- scheduler?: (fn: () => void) => unknown;
80
- running: boolean;
81
- done?: Promise<void>;
82
- resolve?: () => void;
83
- }
84
- type ExternalSourceFactory = <Prev, Next extends Prev = Prev>(
85
- fn: EffectFunction<Prev, Next>,
86
- trigger: () => void
87
- ) => ExternalSource;
88
- export interface ExternalSource {
89
- track: EffectFunction<any, any>;
90
- dispose: () => void;
91
- }
92
- export type RootFunction<T> = (dispose: () => void) => T;
93
- /**
94
- * Creates a new non-tracked reactive context that doesn't auto-dispose
95
- *
96
- * @param fn a function in which the reactive state is scoped
97
- * @param detachedOwner optional reactive context to bind the root to
98
- * @returns the output of `fn`.
99
- *
100
- * @description https://docs.solidjs.com/reference/reactive-utilities/create-root
101
- */
102
- export declare function createRoot<T>(fn: RootFunction<T>, detachedOwner?: typeof Owner): T;
103
- export type Accessor<T> = () => T;
104
- export type Setter<in out T> = {
105
- <U extends T>(
106
- ...args: undefined extends T ? [] : [value: Exclude<U, Function> | ((prev: T) => U)]
107
- ): undefined extends T ? undefined : U;
108
- <U extends T>(value: (prev: T) => U): U;
109
- <U extends T>(value: Exclude<U, Function>): U;
110
- <U extends T>(value: Exclude<U, Function> | ((prev: T) => U)): U;
111
- };
112
- export type Signal<T> = [get: Accessor<T>, set: Setter<T>];
113
- export interface SignalOptions<T> extends MemoOptions<T> {
114
- internal?: boolean;
115
- }
116
- /**
117
- * Creates a simple reactive state with a getter and setter
118
- * ```typescript
119
- * const [state: Accessor<T>, setState: Setter<T>] = createSignal<T>(
120
- * value: T,
121
- * options?: { name?: string, equals?: false | ((prev: T, next: T) => boolean) }
122
- * )
123
- * ```
124
- * @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
125
- * @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
126
- *
127
- * @returns ```typescript
128
- * [state: Accessor<T>, setState: Setter<T>]
129
- * ```
130
- * * the Accessor is merely a function that returns the current value and registers each call to the reactive root
131
- * * the Setter is a function that allows directly setting or mutating the value:
132
- * ```typescript
133
- * const [count, setCount] = createSignal(0);
134
- * setCount(count => count + 1);
135
- * ```
136
- *
137
- * @description https://docs.solidjs.com/reference/basic-reactivity/create-signal
138
- */
139
- export declare function createSignal<T>(): Signal<T | undefined>;
140
- export declare function createSignal<T>(value: T, options?: SignalOptions<T>): Signal<T>;
141
- export interface BaseOptions {
142
- name?: string;
143
- }
144
- export type NoInfer<T extends any> = [T][T extends any ? 0 : never];
145
- export interface EffectOptions extends BaseOptions {}
146
- export type EffectFunction<Prev, Next extends Prev = Prev> = (v: Prev) => Next;
147
- /**
148
- * Creates a reactive computation that runs immediately before render, mainly used to write to other reactive primitives
149
- * ```typescript
150
- * export function createComputed<Next, Init = Next>(
151
- * fn: (v: Init | Next) => Next,
152
- * value?: Init,
153
- * options?: { name?: string }
154
- * ): void;
155
- * ```
156
- * @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
157
- * @param value an optional initial value for the computation; if set, fn will never receive undefined as first argument
158
- * @param options allows to set a name in dev mode for debugging purposes
159
- *
160
- * @description https://docs.solidjs.com/reference/secondary-primitives/create-computed
161
- */
162
- export declare function createComputed<Next>(
163
- fn: EffectFunction<undefined | NoInfer<Next>, Next>
164
- ): void;
165
- export declare function createComputed<Next, Init = Next>(
166
- fn: EffectFunction<Init | Next, Next>,
167
- value: Init,
168
- options?: EffectOptions
169
- ): void;
170
- /**
171
- * Creates a reactive computation that runs during the render phase as DOM elements are created and updated but not necessarily connected
172
- * ```typescript
173
- * export function createRenderEffect<T>(
174
- * fn: (v: T) => T,
175
- * value?: T,
176
- * options?: { name?: string }
177
- * ): void;
178
- * ```
179
- * @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
180
- * @param value an optional initial value for the computation; if set, fn will never receive undefined as first argument
181
- * @param options allows to set a name in dev mode for debugging purposes
182
- *
183
- * @description https://docs.solidjs.com/reference/secondary-primitives/create-render-effect
184
- */
185
- export declare function createRenderEffect<Next>(
186
- fn: EffectFunction<undefined | NoInfer<Next>, Next>
187
- ): void;
188
- export declare function createRenderEffect<Next, Init = Next>(
189
- fn: EffectFunction<Init | Next, Next>,
190
- value: Init,
191
- options?: EffectOptions
192
- ): void;
193
- /**
194
- * Creates a reactive computation that runs after the render phase
195
- * ```typescript
196
- * export function createEffect<T>(
197
- * fn: (v: T) => T,
198
- * value?: T,
199
- * options?: { name?: string }
200
- * ): void;
201
- * ```
202
- * @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
203
- * @param value an optional initial value for the computation; if set, fn will never receive undefined as first argument
204
- * @param options allows to set a name in dev mode for debugging purposes
205
- *
206
- * @description https://docs.solidjs.com/reference/basic-reactivity/create-effect
207
- */
208
- export declare function createEffect<Next>(
209
- fn: EffectFunction<undefined | NoInfer<Next>, Next>
210
- ): void;
211
- export declare function createEffect<Next, Init = Next>(
212
- fn: EffectFunction<Init | Next, Next>,
213
- value: Init,
214
- options?: EffectOptions & {
215
- render?: boolean;
216
- }
217
- ): void;
218
- /**
219
- * Creates a reactive computation that runs after the render phase with flexible tracking
220
- * ```typescript
221
- * export function createReaction(
222
- * onInvalidate: () => void,
223
- * options?: { name?: string }
224
- * ): (fn: () => void) => void;
225
- * ```
226
- * @param invalidated a function that is called when tracked function is invalidated.
227
- * @param options allows to set a name in dev mode for debugging purposes
228
- *
229
- * @description https://docs.solidjs.com/reference/secondary-primitives/create-reaction
230
- */
231
- export declare function createReaction(
232
- onInvalidate: () => void,
233
- options?: EffectOptions
234
- ): (tracking: () => void) => void;
235
- export interface Memo<Prev, Next = Prev> extends SignalState<Next>, Computation<Next> {
236
- value: Next;
237
- tOwned?: Computation<Prev | Next, Next>[];
238
- }
239
- export interface MemoOptions<T> extends EffectOptions {
240
- equals?: false | ((prev: T, next: T) => boolean);
241
- }
242
- /**
243
- * Creates a readonly derived reactive memoized signal
244
- * ```typescript
245
- * export function createMemo<T>(
246
- * fn: (v: T) => T,
247
- * value?: T,
248
- * options?: { name?: string, equals?: false | ((prev: T, next: T) => boolean) }
249
- * ): () => T;
250
- * ```
251
- * @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
252
- * @param value an optional initial value for the computation; if set, fn will never receive undefined as first argument
253
- * @param options allows to set a name in dev mode for debugging purposes and use a custom comparison function in equals
254
- *
255
- * @description https://docs.solidjs.com/reference/basic-reactivity/create-memo
256
- */
257
- export declare function createMemo<Next extends Prev, Prev = Next>(
258
- fn: EffectFunction<undefined | NoInfer<Prev>, Next>
259
- ): Accessor<Next>;
260
- export declare function createMemo<Next extends Prev, Init = Next, Prev = Next>(
261
- fn: EffectFunction<Init | Prev, Next>,
262
- value: Init,
263
- options?: MemoOptions<Next>
264
- ): Accessor<Next>;
265
- interface Unresolved {
266
- state: "unresolved";
267
- loading: false;
268
- error: undefined;
269
- latest: undefined;
270
- (): undefined;
271
- }
272
- interface Pending {
273
- state: "pending";
274
- loading: true;
275
- error: undefined;
276
- latest: undefined;
277
- (): undefined;
278
- }
279
- interface Ready<T> {
280
- state: "ready";
281
- loading: false;
282
- error: undefined;
283
- latest: T;
284
- (): T;
285
- }
286
- interface Refreshing<T> {
287
- state: "refreshing";
288
- loading: true;
289
- error: undefined;
290
- latest: T;
291
- (): T;
292
- }
293
- interface Errored {
294
- state: "errored";
295
- loading: false;
296
- error: any;
297
- latest: never;
298
- (): never;
299
- }
300
- export type Resource<T> = Unresolved | Pending | Ready<T> | Refreshing<T> | Errored;
301
- export type InitializedResource<T> = Ready<T> | Refreshing<T> | Errored;
302
- export type ResourceActions<T, R = unknown> = {
303
- mutate: Setter<T>;
304
- refetch: (info?: R) => T | Promise<T> | undefined | null;
305
- };
306
- export type ResourceSource<S> = S | false | null | undefined | (() => S | false | null | undefined);
307
- export type ResourceFetcher<S, T, R = unknown> = (
308
- k: S,
309
- info: ResourceFetcherInfo<T, R>
310
- ) => T | Promise<T>;
311
- export type ResourceFetcherInfo<T, R = unknown> = {
312
- value: T | undefined;
313
- refetching: R | boolean;
314
- };
315
- export type ResourceOptions<T, S = unknown> = {
316
- initialValue?: T;
317
- name?: string;
318
- deferStream?: boolean;
319
- ssrLoadFrom?: "initial" | "server";
320
- storage?: (init: T | undefined) => [Accessor<T | undefined>, Setter<T | undefined>];
321
- onHydrated?: (
322
- k: S | undefined,
323
- info: {
324
- value: T | undefined;
325
- }
326
- ) => void;
327
- };
328
- export type InitializedResourceOptions<T, S = unknown> = ResourceOptions<T, S> & {
329
- initialValue: T;
330
- };
331
- export type ResourceReturn<T, R = unknown> = [Resource<T>, ResourceActions<T | undefined, R>];
332
- export type InitializedResourceReturn<T, R = unknown> = [
333
- InitializedResource<T>,
334
- ResourceActions<T, R>
335
- ];
336
- /**
337
- * Creates a resource that wraps a repeated promise in a reactive pattern:
338
- * ```typescript
339
- * // Without source
340
- * const [resource, { mutate, refetch }] = createResource(fetcher, options);
341
- * // With source
342
- * const [resource, { mutate, refetch }] = createResource(source, fetcher, options);
343
- * ```
344
- * @param source - reactive data function which has its non-nullish and non-false values passed to the fetcher, optional
345
- * @param fetcher - function that receives the source (true if source not provided), the last or initial value, and whether the resource is being refetched, and returns a value or a Promise:
346
- * ```typescript
347
- * const fetcher: ResourceFetcher<S, T, R> = (
348
- * sourceOutput: S,
349
- * info: { value: T | undefined, refetching: R | boolean }
350
- * ) => T | Promise<T>;
351
- * ```
352
- * @param options - an optional object with the initialValue and the name (for debugging purposes); see {@link ResourceOptions}
353
- *
354
- * @returns ```typescript
355
- * [Resource<T>, { mutate: Setter<T>, refetch: () => void }]
356
- * ```
357
- *
358
- * * 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)
359
- * * `mutate` allows to manually overwrite the resource without calling the fetcher
360
- * * `refetch` will re-run the fetcher without changing the source, and if called with a value, that value will be passed to the fetcher via the `refetching` property on the fetcher's second parameter
361
- *
362
- * @description https://docs.solidjs.com/reference/basic-reactivity/create-resource
363
- */
364
- export declare function createResource<T, R = unknown>(
365
- fetcher: ResourceFetcher<true, T, R>,
366
- options: InitializedResourceOptions<NoInfer<T>, true>
367
- ): InitializedResourceReturn<T, R>;
368
- export declare function createResource<T, R = unknown>(
369
- fetcher: ResourceFetcher<true, T, R>,
370
- options?: ResourceOptions<NoInfer<T>, true>
371
- ): ResourceReturn<T, R>;
372
- export declare function createResource<T, S, R = unknown>(
373
- source: ResourceSource<S>,
374
- fetcher: ResourceFetcher<S, T, R>,
375
- options: InitializedResourceOptions<NoInfer<T>, S>
376
- ): InitializedResourceReturn<T, R>;
377
- export declare function createResource<T, S, R = unknown>(
378
- source: ResourceSource<S>,
379
- fetcher: ResourceFetcher<S, T, R>,
380
- options?: ResourceOptions<NoInfer<T>, S>
381
- ): ResourceReturn<T, R>;
382
- export interface DeferredOptions<T> {
383
- equals?: false | ((prev: T, next: T) => boolean);
384
- name?: string;
385
- timeoutMs?: number;
386
- }
387
- /**
388
- * Creates a reactive computation that only runs and notifies the reactive context when the browser is idle
389
- * ```typescript
390
- * export function createDeferred<T>(
391
- * fn: (v: T) => T,
392
- * options?: { timeoutMs?: number, name?: string, equals?: false | ((prev: T, next: T) => boolean) }
393
- * ): () => T);
394
- * ```
395
- * @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
396
- * @param options allows to set the timeout in milliseconds, use a custom comparison function and set a name in dev mode for debugging purposes
397
- *
398
- * @description https://docs.solidjs.com/reference/secondary-primitives/create-deferred
399
- */
400
- export declare function createDeferred<T>(
401
- source: Accessor<T>,
402
- options?: DeferredOptions<T>
403
- ): Accessor<T>;
404
- export type EqualityCheckerFunction<T, U> = (a: U, b: T) => boolean;
405
- /**
406
- * Creates a conditional signal that only notifies subscribers when entering or exiting their key matching the value
407
- * ```typescript
408
- * export function createSelector<T, U>(
409
- * source: () => T
410
- * fn: (a: U, b: T) => boolean,
411
- * options?: { name?: string }
412
- * ): (k: U) => boolean;
413
- * ```
414
- * @param source
415
- * @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
416
- * @param options allows to set a name in dev mode for debugging purposes, optional
417
- *
418
- * ```typescript
419
- * const isSelected = createSelector(selectedId);
420
- * <For each={list()}>
421
- * {(item) => <li classList={{ active: isSelected(item.id) }}>{item.name}</li>}
422
- * </For>
423
- * ```
424
- *
425
- * This makes the operation O(2) instead of O(n).
426
- *
427
- * @description https://docs.solidjs.com/reference/secondary-primitives/create-selector
428
- */
429
- export declare function createSelector<T, U = T>(
430
- source: Accessor<T>,
431
- fn?: EqualityCheckerFunction<T, U>,
432
- options?: BaseOptions
433
- ): (key: U) => boolean;
434
- /**
435
- * Holds changes inside the block before the reactive context is updated
436
- * @param fn wraps the reactive updates that should be batched
437
- * @returns the return value from `fn`
438
- *
439
- * @description https://docs.solidjs.com/reference/reactive-utilities/batch
440
- */
441
- export declare function batch<T>(fn: Accessor<T>): T;
442
- /**
443
- * Ignores tracking context inside its scope
444
- * @param fn the scope that is out of the tracking context
445
- * @returns the return value of `fn`
446
- *
447
- * @description https://docs.solidjs.com/reference/reactive-utilities/untrack
448
- */
449
- export declare function untrack<T>(fn: Accessor<T>): T;
450
- /** @deprecated */
451
- export type ReturnTypes<T> = T extends readonly Accessor<unknown>[]
452
- ? {
453
- [K in keyof T]: T[K] extends Accessor<infer I> ? I : never;
454
- }
455
- : T extends Accessor<infer I>
456
- ? I
457
- : never;
458
- export type AccessorArray<T> = [
459
- ...Extract<
460
- {
461
- [K in keyof T]: Accessor<T[K]>;
462
- },
463
- readonly unknown[]
464
- >
465
- ];
466
- export type OnEffectFunction<S, Prev, Next extends Prev = Prev> = (
467
- input: S,
468
- prevInput: S | undefined,
469
- prev: Prev
470
- ) => Next;
471
- export interface OnOptions {
472
- defer?: boolean;
473
- }
474
- /**
475
- * Makes dependencies of a computation explicit
476
- * ```typescript
477
- * export function on<S, U>(
478
- * deps: Accessor<S> | AccessorArray<S>,
479
- * fn: (input: S, prevInput: S | undefined, prevValue: U | undefined) => U,
480
- * options?: { defer?: boolean } = {}
481
- * ): (prevValue: U | undefined) => U;
482
- * ```
483
- * @param deps list of reactive dependencies or a single reactive dependency
484
- * @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
485
- * @param options optional, allows deferred computation until at the end of the next change
486
- * @returns an effect function that is passed into createEffect. For example:
487
- *
488
- * ```typescript
489
- * createEffect(on(a, (v) => console.log(v, b())));
490
- *
491
- * // is equivalent to:
492
- * createEffect(() => {
493
- * const v = a();
494
- * untrack(() => console.log(v, b()));
495
- * });
496
- * ```
497
- *
498
- * @description https://docs.solidjs.com/reference/reactive-utilities/on
499
- */
500
- export declare function on<S, Next extends Prev, Prev = Next>(
501
- deps: AccessorArray<S> | Accessor<S>,
502
- fn: OnEffectFunction<S, undefined | NoInfer<Prev>, Next>,
503
- options?: OnOptions & {
504
- defer?: false;
505
- }
506
- ): EffectFunction<undefined | NoInfer<Next>, NoInfer<Next>>;
507
- export declare function on<S, Next extends Prev, Prev = Next>(
508
- deps: AccessorArray<S> | Accessor<S>,
509
- fn: OnEffectFunction<S, undefined | NoInfer<Prev>, Next>,
510
- options:
511
- | OnOptions
512
- | {
513
- defer: true;
514
- }
515
- ): EffectFunction<undefined | NoInfer<Next>>;
516
- /**
517
- * Runs an effect only after initial render on mount
518
- * @param fn an effect that should run only once on mount
519
- *
520
- * @description https://docs.solidjs.com/reference/lifecycle/on-mount
521
- */
522
- export declare function onMount(fn: () => void): void;
523
- /**
524
- * Runs an effect once before the reactive scope is disposed
525
- * @param fn an effect that should run only once on cleanup
526
- *
527
- * @returns the same {@link fn} function that was passed in
528
- *
529
- * @description https://docs.solidjs.com/reference/lifecycle/on-cleanup
530
- */
531
- export declare function onCleanup<T extends () => any>(fn: T): T;
532
- /**
533
- * Runs an effect whenever an error is thrown within the context of the child scopes
534
- * @param fn boundary for the error
535
- * @param handler an error handler that receives the error
536
- *
537
- * * If the error is thrown again inside the error handler, it will trigger the next available parent handler
538
- *
539
- * @description https://docs.solidjs.com/reference/reactive-utilities/catch-error
540
- */
541
- export declare function catchError<T>(fn: () => T, handler: (err: Error) => void): T | undefined;
542
- export declare function getListener(): Computation<any, any> | null;
543
- export declare function getOwner(): Owner | null;
544
- export declare function runWithOwner<T>(o: typeof Owner, fn: () => T): T | undefined;
545
- export declare function enableScheduling(scheduler?: typeof requestCallback): void;
546
- /**
547
- * ```typescript
548
- * export function startTransition(fn: () => void) => Promise<void>
549
- * ```
550
- *
551
- * @description https://docs.solidjs.com/reference/reactive-utilities/start-transition
552
- */
553
- export declare function startTransition(fn: () => unknown): Promise<void>;
554
- export type Transition = [Accessor<boolean>, (fn: () => void) => Promise<void>];
555
- /**
556
- * ```typescript
557
- * export function useTransition(): [
558
- * () => boolean,
559
- * (fn: () => void, cb?: () => void) => void
560
- * ];
561
- * ```
562
- * @returns a tuple; first value is an accessor if the transition is pending and a callback to start the transition
563
- *
564
- * @description https://docs.solidjs.com/reference/reactive-utilities/use-transition
565
- */
566
- export declare function useTransition(): Transition;
567
- export declare function resumeEffects(e: Computation<any>[]): void;
568
- export interface DevComponent<T> extends Memo<unknown> {
569
- props: T;
570
- name: string;
571
- component: (props: T) => unknown;
572
- }
573
- export declare function devComponent<P, V>(Comp: (props: P) => V, props: P): V;
574
- export declare function registerGraph(value: SourceMapValue): void;
575
- export type ContextProviderComponent<T> = FlowComponent<{
576
- value: T;
577
- }>;
578
- export interface Context<T> {
579
- id: symbol;
580
- Provider: ContextProviderComponent<T>;
581
- defaultValue: T;
582
- }
583
- /**
584
- * Creates a Context to handle a state scoped for the children of a component
585
- * ```typescript
586
- * interface Context<T> {
587
- * id: symbol;
588
- * Provider: FlowComponent<{ value: T }>;
589
- * defaultValue: T;
590
- * }
591
- * export function createContext<T>(
592
- * defaultValue?: T,
593
- * options?: { name?: string }
594
- * ): Context<T | undefined>;
595
- * ```
596
- * @param defaultValue optional default to inject into context
597
- * @param options allows to set a name in dev mode for debugging purposes
598
- * @returns The context that contains the Provider Component and that can be used with `useContext`
599
- *
600
- * @description https://docs.solidjs.com/reference/component-apis/create-context
601
- */
602
- export declare function createContext<T>(
603
- defaultValue?: undefined,
604
- options?: EffectOptions
605
- ): Context<T | undefined>;
606
- export declare function createContext<T>(defaultValue: T, options?: EffectOptions): Context<T>;
607
- /**
608
- * Uses a context to receive a scoped state from a parent's Context.Provider
609
- *
610
- * @param context Context object made by `createContext`
611
- * @returns the current or `defaultValue`, if present
612
- *
613
- * @description https://docs.solidjs.com/reference/component-apis/use-context
614
- */
615
- export declare function useContext<T>(context: Context<T>): T;
616
- export type ResolvedJSXElement = Exclude<JSX.Element, JSX.ArrayElement>;
617
- export type ResolvedChildren = ResolvedJSXElement | ResolvedJSXElement[];
618
- export type ChildrenReturn = Accessor<ResolvedChildren> & {
619
- toArray: () => ResolvedJSXElement[];
620
- };
621
- /**
622
- * Resolves child elements to help interact with children
623
- *
624
- * @param fn an accessor for the children
625
- * @returns a accessor of the same children, but resolved
626
- *
627
- * @description https://docs.solidjs.com/reference/component-apis/children
628
- */
629
- export declare function children(fn: Accessor<JSX.Element>): ChildrenReturn;
630
- export type SuspenseContextType = {
631
- increment?: () => void;
632
- decrement?: () => void;
633
- inFallback?: () => boolean;
634
- effects?: Computation<any>[];
635
- resolved?: boolean;
636
- };
637
- type SuspenseContext = Context<SuspenseContextType | undefined> & {
638
- active?(): boolean;
639
- increment?(): void;
640
- decrement?(): void;
641
- };
642
- declare let SuspenseContext: SuspenseContext;
643
- export declare function getSuspenseContext(): SuspenseContext;
644
- export declare function enableExternalSource(
645
- factory: ExternalSourceFactory,
646
- untrack?: <V>(fn: () => V) => V
647
- ): void;
648
- export declare function readSignal(this: SignalState<any> | Memo<any>): any;
649
- export declare function writeSignal(
650
- node: SignalState<any> | Memo<any>,
651
- value: any,
652
- isComp?: boolean
653
- ): any;
654
- /**
655
- * @deprecated since version 1.7.0 and will be removed in next major - use catchError instead
656
- * onError - run an effect whenever an error is thrown within the context of the child scopes
657
- * @param fn an error handler that receives the error
658
- *
659
- * * If the error is thrown again inside the error handler, it will trigger the next available parent handler
660
- *
661
- * @description https://www.solidjs.com/docs/latest/api#onerror | https://docs.solidjs.com/reference/reactive-utilities/catch-error
662
- */
663
- export declare function onError(fn: (err: Error) => void): void;
664
- export {};
@@ -1,26 +0,0 @@
1
- import type { JSX } from "../jsx.js";
2
- /**
3
- * **[experimental]** Controls the order in which suspended content is rendered
4
- *
5
- * @description https://docs.solidjs.com/reference/components/suspense-list
6
- */
7
- export declare function SuspenseList(props: {
8
- children: JSX.Element;
9
- revealOrder: "forwards" | "backwards" | "together";
10
- tail?: "collapsed" | "hidden";
11
- }): JSX.Element;
12
- /**
13
- * Tracks all resources inside a component and renders a fallback until they are all resolved
14
- * ```typescript
15
- * const AsyncComponent = lazy(() => import('./component'));
16
- *
17
- * <Suspense fallback={<LoadingIndicator />}>
18
- * <AsyncComponent />
19
- * </Suspense>
20
- * ```
21
- * @description https://docs.solidjs.com/reference/components/suspense
22
- */
23
- export declare function Suspense(props: {
24
- fallback?: JSX.Element;
25
- children: JSX.Element;
26
- }): JSX.Element;