solid-js 1.10.0-beta.0 → 2.0.0-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.
Files changed (82) hide show
  1. package/dist/dev.cjs +730 -1723
  2. package/dist/dev.js +595 -1688
  3. package/dist/server.cjs +769 -703
  4. package/dist/server.js +682 -670
  5. package/dist/solid.cjs +696 -1667
  6. package/dist/solid.js +560 -1631
  7. package/package.json +7 -151
  8. package/types/{render → client}/component.d.ts +1 -38
  9. package/types/client/core.d.ts +65 -0
  10. package/types/client/flow.d.ts +100 -0
  11. package/types/client/hydration.d.ts +76 -0
  12. package/types/index.d.ts +11 -14
  13. package/types/jsx.d.ts +1508 -1633
  14. package/types/server/component.d.ts +66 -0
  15. package/types/server/core.d.ts +44 -0
  16. package/types/server/flow.d.ts +60 -0
  17. package/types/server/hydration.d.ts +21 -0
  18. package/types/server/index.d.ts +12 -3
  19. package/types/server/shared.d.ts +45 -0
  20. package/types/server/signals.d.ts +60 -0
  21. package/h/dist/h.cjs +0 -115
  22. package/h/dist/h.js +0 -113
  23. package/h/jsx-dev-runtime/package.json +0 -8
  24. package/h/jsx-runtime/dist/jsx.cjs +0 -15
  25. package/h/jsx-runtime/dist/jsx.js +0 -10
  26. package/h/jsx-runtime/package.json +0 -8
  27. package/h/jsx-runtime/types/index.d.ts +0 -11
  28. package/h/jsx-runtime/types/jsx.d.ts +0 -4242
  29. package/h/package.json +0 -8
  30. package/h/types/hyperscript.d.ts +0 -20
  31. package/h/types/index.d.ts +0 -3
  32. package/html/dist/html.cjs +0 -583
  33. package/html/dist/html.js +0 -581
  34. package/html/package.json +0 -8
  35. package/html/types/index.d.ts +0 -3
  36. package/html/types/lit.d.ts +0 -41
  37. package/store/dist/dev.cjs +0 -458
  38. package/store/dist/dev.js +0 -449
  39. package/store/dist/server.cjs +0 -126
  40. package/store/dist/server.js +0 -114
  41. package/store/dist/store.cjs +0 -438
  42. package/store/dist/store.js +0 -429
  43. package/store/package.json +0 -46
  44. package/store/types/index.d.ts +0 -12
  45. package/store/types/modifiers.d.ts +0 -6
  46. package/store/types/mutable.d.ts +0 -5
  47. package/store/types/server.d.ts +0 -17
  48. package/store/types/store.d.ts +0 -107
  49. package/types/reactive/array.d.ts +0 -44
  50. package/types/reactive/observable.d.ts +0 -36
  51. package/types/reactive/scheduler.d.ts +0 -10
  52. package/types/reactive/signal.d.ts +0 -586
  53. package/types/render/Suspense.d.ts +0 -26
  54. package/types/render/flow.d.ts +0 -118
  55. package/types/render/hydration.d.ts +0 -24
  56. package/types/render/index.d.ts +0 -4
  57. package/types/server/reactive.d.ts +0 -98
  58. package/types/server/rendering.d.ts +0 -159
  59. package/universal/dist/dev.cjs +0 -245
  60. package/universal/dist/dev.js +0 -243
  61. package/universal/dist/universal.cjs +0 -245
  62. package/universal/dist/universal.js +0 -243
  63. package/universal/package.json +0 -20
  64. package/universal/types/index.d.ts +0 -3
  65. package/universal/types/universal.d.ts +0 -30
  66. package/web/dist/dev.cjs +0 -894
  67. package/web/dist/dev.js +0 -782
  68. package/web/dist/server.cjs +0 -892
  69. package/web/dist/server.js +0 -782
  70. package/web/dist/web.cjs +0 -883
  71. package/web/dist/web.js +0 -771
  72. package/web/package.json +0 -46
  73. package/web/storage/dist/storage.cjs +0 -12
  74. package/web/storage/dist/storage.js +0 -10
  75. package/web/storage/package.json +0 -15
  76. package/web/storage/types/index.d.ts +0 -2
  77. package/web/types/client.d.ts +0 -79
  78. package/web/types/core.d.ts +0 -2
  79. package/web/types/index.d.ts +0 -50
  80. package/web/types/jsx.d.ts +0 -1
  81. package/web/types/server-mock.d.ts +0 -65
  82. package/web/types/server.d.ts +0 -177
@@ -1,36 +0,0 @@
1
- import { Accessor, Setter } from "./signal.js";
2
- declare global {
3
- interface SymbolConstructor {
4
- readonly observable: symbol;
5
- }
6
- }
7
- interface Observable<T> {
8
- subscribe(observer: ObservableObserver<T>): {
9
- unsubscribe(): void;
10
- };
11
- [Symbol.observable](): Observable<T>;
12
- }
13
- export type ObservableObserver<T> = ((v: T) => void) | {
14
- next?: (v: T) => void;
15
- error?: (v: any) => void;
16
- complete?: (v: boolean) => void;
17
- };
18
- /**
19
- * Creates a simple observable from a signal's accessor to be used with the `from` operator of observable libraries like e.g. rxjs
20
- * ```typescript
21
- * import { from } from "rxjs";
22
- * const [s, set] = createSignal(0);
23
- * const obsv$ = from(observable(s));
24
- * obsv$.subscribe((v) => console.log(v));
25
- * ```
26
- * description https://docs.solidjs.com/reference/reactive-utilities/observable
27
- */
28
- export declare function observable<T>(input: Accessor<T>): Observable<T>;
29
- type Producer<T> = ((setter: Setter<T>) => () => void) | {
30
- subscribe: (fn: (v: T) => void) => (() => void) | {
31
- unsubscribe: () => void;
32
- };
33
- };
34
- export declare function from<T>(producer: Producer<T>, initalValue: T): Accessor<T>;
35
- export declare function from<T>(producer: Producer<T | undefined>): Accessor<T | undefined>;
36
- export {};
@@ -1,10 +0,0 @@
1
- export interface Task {
2
- id: number;
3
- fn: ((didTimeout: boolean) => void) | null;
4
- startTime: number;
5
- expirationTime: number;
6
- }
7
- export declare function requestCallback(fn: () => void, options?: {
8
- timeout: number;
9
- }): Task;
10
- export declare function cancelCallback(task: Task): void;
@@ -1,586 +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 IS_DEV: string | boolean;
28
- export declare const equalFn: <T>(a: T, b: T) => boolean;
29
- export declare const $PROXY: unique symbol;
30
- export declare const SUPPORTS_PROXY: boolean;
31
- export declare const $TRACK: unique symbol;
32
- export declare const $DEVCOMP: unique symbol;
33
- export declare var Owner: Owner | null;
34
- export declare let Transition: TransitionState | null;
35
- /** Object storing callbacks for debugging during development */
36
- export declare const DevHooks: {
37
- afterUpdate: (() => void) | null;
38
- afterCreateOwner: ((owner: Owner) => void) | null;
39
- /** @deprecated use `afterRegisterGraph` */
40
- afterCreateSignal: ((signal: SignalState<any>) => void) | null;
41
- afterRegisterGraph: ((sourceMapValue: SourceMapValue) => void) | null;
42
- };
43
- export type ComputationState = 0 | 1 | 2;
44
- export interface SourceMapValue {
45
- value: unknown;
46
- name?: string;
47
- graph?: Owner;
48
- }
49
- export interface SignalState<T> extends SourceMapValue {
50
- value: T;
51
- observers: ReactiveLink | null;
52
- observersTail: ReactiveLink | null;
53
- tValue?: T;
54
- comparator?: (prev: T, next: T) => boolean;
55
- internal?: true;
56
- }
57
- export interface Owner {
58
- owned: Computation<any>[] | null;
59
- cleanups: (() => void)[] | null;
60
- owner: Owner | null;
61
- context: any | null;
62
- sourceMap?: SourceMapValue[];
63
- name?: string;
64
- }
65
- interface ReactiveLink {
66
- source: SignalState<unknown> | Memo<any>;
67
- observer: Computation<any>;
68
- nextSource: ReactiveLink | null;
69
- prevObserver: ReactiveLink | null;
70
- nextObserver: ReactiveLink | null;
71
- version: number;
72
- }
73
- export interface Computation<Init, Next extends Init = Init> extends Owner {
74
- fn: EffectFunction<Init, Next>;
75
- state: ComputationState;
76
- tState?: ComputationState;
77
- sources: ReactiveLink | null;
78
- sourcesTail: ReactiveLink | null;
79
- value?: Init;
80
- updatedAt: number | null;
81
- pure: boolean;
82
- relinkTime: number;
83
- user?: boolean;
84
- suspense?: SuspenseContextType;
85
- }
86
- export interface TransitionState {
87
- sources: Set<SignalState<any>>;
88
- effects: Computation<any>[];
89
- promises: Set<Promise<any>>;
90
- disposed: Set<Computation<any>>;
91
- queue: Set<Computation<any>>;
92
- scheduler?: (fn: () => void) => unknown;
93
- running: boolean;
94
- done?: Promise<void>;
95
- resolve?: () => void;
96
- }
97
- type ExternalSourceFactory = <Prev, Next extends Prev = Prev>(fn: EffectFunction<Prev, Next>, trigger: () => void) => ExternalSource;
98
- export interface ExternalSource {
99
- track: EffectFunction<any, any>;
100
- dispose: () => void;
101
- }
102
- export type RootFunction<T> = (dispose: () => void) => T;
103
- /**
104
- * Creates a new non-tracked reactive context that doesn't auto-dispose
105
- *
106
- * @param fn a function in which the reactive state is scoped
107
- * @param detachedOwner optional reactive context to bind the root to
108
- * @returns the output of `fn`.
109
- *
110
- * @description https://docs.solidjs.com/reference/reactive-utilities/create-root
111
- */
112
- export declare function createRoot<T>(fn: RootFunction<T>, detachedOwner?: typeof Owner): T;
113
- export type Accessor<T> = () => T;
114
- export type Setter<in out T> = {
115
- <U extends T>(...args: undefined extends T ? [] : [value: Exclude<U, Function> | ((prev: T) => U)]): undefined extends T ? undefined : U;
116
- <U extends T>(value: (prev: T) => U): U;
117
- <U extends T>(value: Exclude<U, Function>): U;
118
- <U extends T>(value: Exclude<U, Function> | ((prev: T) => U)): U;
119
- };
120
- export type Signal<T> = [get: Accessor<T>, set: Setter<T>];
121
- export interface SignalOptions<T> extends MemoOptions<T> {
122
- internal?: boolean;
123
- }
124
- /**
125
- * Creates a simple reactive state with a getter and setter
126
- * ```typescript
127
- * const [state: Accessor<T>, setState: Setter<T>] = createSignal<T>(
128
- * value: T,
129
- * options?: { name?: string, equals?: false | ((prev: T, next: T) => boolean) }
130
- * )
131
- * ```
132
- * @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
133
- * @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
134
- *
135
- * @returns ```typescript
136
- * [state: Accessor<T>, setState: Setter<T>]
137
- * ```
138
- * * the Accessor is merely a function that returns the current value and registers each call to the reactive root
139
- * * the Setter is a function that allows directly setting or mutating the value:
140
- * ```typescript
141
- * const [count, setCount] = createSignal(0);
142
- * setCount(count => count + 1);
143
- * ```
144
- *
145
- * @description https://docs.solidjs.com/reference/basic-reactivity/create-signal
146
- */
147
- export declare function createSignal<T>(): Signal<T | undefined>;
148
- export declare function createSignal<T>(value: T, options?: SignalOptions<T>): Signal<T>;
149
- export interface BaseOptions {
150
- name?: string;
151
- }
152
- export type NoInfer<T extends any> = [T][T extends any ? 0 : never];
153
- export interface EffectOptions extends BaseOptions {
154
- }
155
- export type EffectFunction<Prev, Next extends Prev = Prev> = (v: Prev) => Next;
156
- /**
157
- * Creates a reactive computation that runs immediately before render, mainly used to write to other reactive primitives
158
- * ```typescript
159
- * export function createComputed<Next, Init = Next>(
160
- * fn: (v: Init | Next) => Next,
161
- * value?: Init,
162
- * options?: { name?: string }
163
- * ): void;
164
- * ```
165
- * @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
166
- * @param value an optional initial value for the computation; if set, fn will never receive undefined as first argument
167
- * @param options allows to set a name in dev mode for debugging purposes
168
- *
169
- * @description https://docs.solidjs.com/reference/secondary-primitives/create-computed
170
- */
171
- export declare function createComputed<Next>(fn: EffectFunction<undefined | NoInfer<Next>, Next>): void;
172
- export declare function createComputed<Next, Init = Next>(fn: EffectFunction<Init | Next, Next>, value: Init, options?: EffectOptions): void;
173
- /**
174
- * Creates a reactive computation that runs during the render phase as DOM elements are created and updated but not necessarily connected
175
- * ```typescript
176
- * export function createRenderEffect<T>(
177
- * fn: (v: T) => T,
178
- * value?: T,
179
- * options?: { name?: string }
180
- * ): void;
181
- * ```
182
- * @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
183
- * @param value an optional initial value for the computation; if set, fn will never receive undefined as first argument
184
- * @param options allows to set a name in dev mode for debugging purposes
185
- *
186
- * @description https://docs.solidjs.com/reference/secondary-primitives/create-render-effect
187
- */
188
- export declare function createRenderEffect<Next>(fn: EffectFunction<undefined | NoInfer<Next>, Next>): void;
189
- export declare function createRenderEffect<Next, Init = Next>(fn: EffectFunction<Init | Next, Next>, value: Init, options?: EffectOptions): void;
190
- /**
191
- * Creates a reactive computation that runs after the render phase
192
- * ```typescript
193
- * export function createEffect<T>(
194
- * fn: (v: T) => T,
195
- * value?: T,
196
- * options?: { name?: string }
197
- * ): void;
198
- * ```
199
- * @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
200
- * @param value an optional initial value for the computation; if set, fn will never receive undefined as first argument
201
- * @param options allows to set a name in dev mode for debugging purposes
202
- *
203
- * @description https://docs.solidjs.com/reference/basic-reactivity/create-effect
204
- */
205
- export declare function createEffect<Next>(fn: EffectFunction<undefined | NoInfer<Next>, Next>): void;
206
- export declare function createEffect<Next, Init = Next>(fn: EffectFunction<Init | Next, Next>, value: Init, options?: EffectOptions & {
207
- render?: boolean;
208
- }): void;
209
- /**
210
- * Creates a reactive computation that runs after the render phase with flexible tracking
211
- * ```typescript
212
- * export function createReaction(
213
- * onInvalidate: () => void,
214
- * options?: { name?: string }
215
- * ): (fn: () => void) => void;
216
- * ```
217
- * @param invalidated a function that is called when tracked function is invalidated.
218
- * @param options allows to set a name in dev mode for debugging purposes
219
- *
220
- * @description https://docs.solidjs.com/reference/secondary-primitives/create-reaction
221
- */
222
- export declare function createReaction(onInvalidate: () => void, options?: EffectOptions): (tracking: () => void) => void;
223
- export interface Memo<Prev, Next = Prev> extends SignalState<Next>, Computation<Next> {
224
- value: Next;
225
- tOwned?: Computation<Prev | Next, Next>[];
226
- }
227
- export interface MemoOptions<T> extends EffectOptions {
228
- equals?: false | ((prev: T, next: T) => boolean);
229
- }
230
- /**
231
- * Creates a readonly derived reactive memoized signal
232
- * ```typescript
233
- * export function createMemo<T>(
234
- * fn: (v: T) => T,
235
- * value?: T,
236
- * options?: { name?: string, equals?: false | ((prev: T, next: T) => boolean) }
237
- * ): () => T;
238
- * ```
239
- * @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
240
- * @param value an optional initial value for the computation; if set, fn will never receive undefined as first argument
241
- * @param options allows to set a name in dev mode for debugging purposes and use a custom comparison function in equals
242
- *
243
- * @description https://docs.solidjs.com/reference/basic-reactivity/create-memo
244
- */
245
- export declare function createMemo<Next extends Prev, Prev = Next>(fn: EffectFunction<undefined | NoInfer<Prev>, Next>): Accessor<Next>;
246
- export declare function createMemo<Next extends Prev, Init = Next, Prev = Next>(fn: EffectFunction<Init | Prev, Next>, value: Init, options?: MemoOptions<Next>): Accessor<Next>;
247
- interface Unresolved {
248
- state: "unresolved";
249
- loading: false;
250
- error: undefined;
251
- latest: undefined;
252
- (): undefined;
253
- }
254
- interface Pending {
255
- state: "pending";
256
- loading: true;
257
- error: undefined;
258
- latest: undefined;
259
- (): undefined;
260
- }
261
- interface Ready<T> {
262
- state: "ready";
263
- loading: false;
264
- error: undefined;
265
- latest: T;
266
- (): T;
267
- }
268
- interface Refreshing<T> {
269
- state: "refreshing";
270
- loading: true;
271
- error: undefined;
272
- latest: T;
273
- (): T;
274
- }
275
- interface Errored {
276
- state: "errored";
277
- loading: false;
278
- error: any;
279
- latest: never;
280
- (): never;
281
- }
282
- export type Resource<T> = Unresolved | Pending | Ready<T> | Refreshing<T> | Errored;
283
- export type InitializedResource<T> = Ready<T> | Refreshing<T> | Errored;
284
- export type ResourceActions<T, R = unknown> = {
285
- mutate: Setter<T>;
286
- refetch: (info?: R) => T | Promise<T> | undefined | null;
287
- };
288
- export type ResourceSource<S> = S | false | null | undefined | (() => S | false | null | undefined);
289
- export type ResourceFetcher<S, T, R = unknown> = (k: S, info: ResourceFetcherInfo<T, R>) => T | Promise<T>;
290
- export type ResourceFetcherInfo<T, R = unknown> = {
291
- value: T | undefined;
292
- refetching: R | boolean;
293
- };
294
- export type ResourceOptions<T, S = unknown> = {
295
- initialValue?: T;
296
- name?: string;
297
- deferStream?: boolean;
298
- ssrLoadFrom?: "initial" | "server";
299
- storage?: (init: T | undefined) => [Accessor<T | undefined>, Setter<T | undefined>];
300
- onHydrated?: (k: S | undefined, info: {
301
- value: T | undefined;
302
- }) => void;
303
- };
304
- export type InitializedResourceOptions<T, S = unknown> = ResourceOptions<T, S> & {
305
- initialValue: T;
306
- };
307
- export type ResourceReturn<T, R = unknown> = [Resource<T>, ResourceActions<T | undefined, R>];
308
- export type InitializedResourceReturn<T, R = unknown> = [
309
- InitializedResource<T>,
310
- ResourceActions<T, R>
311
- ];
312
- /**
313
- * Creates a resource that wraps a repeated promise in a reactive pattern:
314
- * ```typescript
315
- * // Without source
316
- * const [resource, { mutate, refetch }] = createResource(fetcher, options);
317
- * // With source
318
- * const [resource, { mutate, refetch }] = createResource(source, fetcher, options);
319
- * ```
320
- * @param source - reactive data function which has its non-nullish and non-false values passed to the fetcher, optional
321
- * @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:
322
- * ```typescript
323
- * const fetcher: ResourceFetcher<S, T, R> = (
324
- * sourceOutput: S,
325
- * info: { value: T | undefined, refetching: R | boolean }
326
- * ) => T | Promise<T>;
327
- * ```
328
- * @param options - an optional object with the initialValue and the name (for debugging purposes); see {@link ResourceOptions}
329
- *
330
- * @returns ```typescript
331
- * [Resource<T>, { mutate: Setter<T>, refetch: () => void }]
332
- * ```
333
- *
334
- * * 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)
335
- * * `mutate` allows to manually overwrite the resource without calling the fetcher
336
- * * `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
337
- *
338
- * @description https://docs.solidjs.com/reference/basic-reactivity/create-resource
339
- */
340
- export declare function createResource<T, R = unknown>(fetcher: ResourceFetcher<true, T, R>, options: InitializedResourceOptions<NoInfer<T>, true>): InitializedResourceReturn<T, R>;
341
- export declare function createResource<T, R = unknown>(fetcher: ResourceFetcher<true, T, R>, options?: ResourceOptions<NoInfer<T>, true>): ResourceReturn<T, R>;
342
- export declare function createResource<T, S, R = unknown>(source: ResourceSource<S>, fetcher: ResourceFetcher<S, T, R>, options: InitializedResourceOptions<NoInfer<T>, S>): InitializedResourceReturn<T, R>;
343
- export declare function createResource<T, S, R = unknown>(source: ResourceSource<S>, fetcher: ResourceFetcher<S, T, R>, options?: ResourceOptions<NoInfer<T>, S>): ResourceReturn<T, R>;
344
- export interface DeferredOptions<T> {
345
- equals?: false | ((prev: T, next: T) => boolean);
346
- name?: string;
347
- timeoutMs?: number;
348
- }
349
- /**
350
- * Creates a reactive computation that only runs and notifies the reactive context when the browser is idle
351
- * ```typescript
352
- * export function createDeferred<T>(
353
- * fn: (v: T) => T,
354
- * options?: { timeoutMs?: number, name?: string, equals?: false | ((prev: T, next: T) => boolean) }
355
- * ): () => T);
356
- * ```
357
- * @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
358
- * @param options allows to set the timeout in milliseconds, use a custom comparison function and set a name in dev mode for debugging purposes
359
- *
360
- * @description https://docs.solidjs.com/reference/secondary-primitives/create-deferred
361
- */
362
- export declare function createDeferred<T>(source: Accessor<T>, options?: DeferredOptions<T>): Accessor<T>;
363
- export type EqualityCheckerFunction<T, U> = (a: U, b: T) => boolean;
364
- /**
365
- * Creates a conditional signal that only notifies subscribers when entering or exiting their key matching the value
366
- * ```typescript
367
- * export function createSelector<T, U>(
368
- * source: () => T
369
- * fn: (a: U, b: T) => boolean,
370
- * options?: { name?: string }
371
- * ): (k: U) => boolean;
372
- * ```
373
- * @param source
374
- * @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
375
- * @param options allows to set a name in dev mode for debugging purposes, optional
376
- *
377
- * ```typescript
378
- * const isSelected = createSelector(selectedId);
379
- * <For each={list()}>
380
- * {(item) => <li classList={{ active: isSelected(item.id) }}>{item.name}</li>}
381
- * </For>
382
- * ```
383
- *
384
- * This makes the operation O(2) instead of O(n).
385
- *
386
- * @description https://docs.solidjs.com/reference/secondary-primitives/create-selector
387
- */
388
- export declare function createSelector<T, U = T>(source: Accessor<T>, fn?: EqualityCheckerFunction<T, U>, options?: BaseOptions): (key: U) => boolean;
389
- /**
390
- * Holds changes inside the block before the reactive context is updated
391
- * @param fn wraps the reactive updates that should be batched
392
- * @returns the return value from `fn`
393
- *
394
- * @description https://docs.solidjs.com/reference/reactive-utilities/batch
395
- */
396
- export declare function batch<T>(fn: Accessor<T>): T;
397
- /**
398
- * Ignores tracking context inside its scope
399
- * @param fn the scope that is out of the tracking context
400
- * @returns the return value of `fn`
401
- *
402
- * @description https://docs.solidjs.com/reference/reactive-utilities/untrack
403
- */
404
- export declare function untrack<T>(fn: Accessor<T>): T;
405
- /** @deprecated */
406
- export type ReturnTypes<T> = T extends readonly Accessor<unknown>[] ? {
407
- [K in keyof T]: T[K] extends Accessor<infer I> ? I : never;
408
- } : T extends Accessor<infer I> ? I : never;
409
- export type AccessorArray<T> = [...Extract<{
410
- [K in keyof T]: Accessor<T[K]>;
411
- }, readonly unknown[]>];
412
- export type OnEffectFunction<S, Prev, Next extends Prev = Prev> = (input: S, prevInput: S | undefined, prev: Prev) => Next;
413
- export interface OnOptions {
414
- defer?: boolean;
415
- }
416
- /**
417
- * Makes dependencies of a computation explicit
418
- * ```typescript
419
- * export function on<S, U>(
420
- * deps: Accessor<S> | AccessorArray<S>,
421
- * fn: (input: S, prevInput: S | undefined, prevValue: U | undefined) => U,
422
- * options?: { defer?: boolean } = {}
423
- * ): (prevValue: U | undefined) => U;
424
- * ```
425
- * @param deps list of reactive dependencies or a single reactive dependency
426
- * @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
427
- * @param options optional, allows deferred computation until at the end of the next change
428
- * @returns an effect function that is passed into createEffect. For example:
429
- *
430
- * ```typescript
431
- * createEffect(on(a, (v) => console.log(v, b())));
432
- *
433
- * // is equivalent to:
434
- * createEffect(() => {
435
- * const v = a();
436
- * untrack(() => console.log(v, b()));
437
- * });
438
- * ```
439
- *
440
- * @description https://docs.solidjs.com/reference/reactive-utilities/on-util
441
- */
442
- export declare function on<S, Next extends Prev, Prev = Next>(deps: AccessorArray<S> | Accessor<S>, fn: OnEffectFunction<S, undefined | NoInfer<Prev>, Next>, options?: OnOptions & {
443
- defer?: false;
444
- }): EffectFunction<undefined | NoInfer<Next>, NoInfer<Next>>;
445
- export declare function on<S, Next extends Prev, Prev = Next>(deps: AccessorArray<S> | Accessor<S>, fn: OnEffectFunction<S, undefined | NoInfer<Prev>, Next>, options: OnOptions | {
446
- defer: true;
447
- }): EffectFunction<undefined | NoInfer<Next>>;
448
- /**
449
- * Runs an effect only after initial render on mount
450
- * @param fn an effect that should run only once on mount
451
- *
452
- * @description https://docs.solidjs.com/reference/lifecycle/on-mount
453
- */
454
- export declare function onMount(fn: () => void): void;
455
- /**
456
- * Runs an effect once before the reactive scope is disposed
457
- * @param fn an effect that should run only once on cleanup
458
- *
459
- * @returns the same {@link fn} function that was passed in
460
- *
461
- * @description https://docs.solidjs.com/reference/lifecycle/on-cleanup
462
- */
463
- export declare function onCleanup<T extends () => any>(fn: T): T;
464
- /**
465
- * Runs an effect whenever an error is thrown within the context of the child scopes
466
- * @param fn boundary for the error
467
- * @param handler an error handler that receives the error
468
- *
469
- * * If the error is thrown again inside the error handler, it will trigger the next available parent handler
470
- *
471
- * @description https://docs.solidjs.com/reference/reactive-utilities/catch-error
472
- */
473
- export declare function catchError<T>(fn: () => T, handler: (err: Error) => void): T | undefined;
474
- export declare function getListener(): Computation<any, any> | null;
475
- export declare function getOwner(): Owner | null;
476
- export declare function runWithOwner<T>(o: typeof Owner, fn: () => T): T | undefined;
477
- export declare function enableScheduling(scheduler?: typeof requestCallback): void;
478
- /**
479
- * ```typescript
480
- * export function startTransition(fn: () => void) => Promise<void>
481
- * ```
482
- *
483
- * @description https://docs.solidjs.com/reference/reactive-utilities/start-transition
484
- */
485
- export declare function startTransition(fn: () => unknown): Promise<void>;
486
- export type Transition = [Accessor<boolean>, (fn: () => void) => Promise<void>];
487
- /**
488
- * ```typescript
489
- * export function useTransition(): [
490
- * () => boolean,
491
- * (fn: () => void, cb?: () => void) => void
492
- * ];
493
- * ```
494
- * @returns a tuple; first value is an accessor if the transition is pending and a callback to start the transition
495
- *
496
- * @description https://docs.solidjs.com/reference/reactive-utilities/use-transition
497
- */
498
- export declare function useTransition(): Transition;
499
- export declare function resumeEffects(e: Computation<any>[]): void;
500
- export interface DevComponent<T> extends Memo<unknown> {
501
- props: T;
502
- name: string;
503
- component: (props: T) => unknown;
504
- }
505
- export declare function devComponent<P, V>(Comp: (props: P) => V, props: P): V;
506
- export declare function registerGraph(value: SourceMapValue): void;
507
- export type ContextProviderComponent<T> = FlowComponent<{
508
- value: T;
509
- }>;
510
- export interface Context<T> {
511
- id: symbol;
512
- Provider: ContextProviderComponent<T>;
513
- defaultValue: T;
514
- }
515
- /**
516
- * Creates a Context to handle a state scoped for the children of a component
517
- * ```typescript
518
- * interface Context<T> {
519
- * id: symbol;
520
- * Provider: FlowComponent<{ value: T }>;
521
- * defaultValue: T;
522
- * }
523
- * export function createContext<T>(
524
- * defaultValue?: T,
525
- * options?: { name?: string }
526
- * ): Context<T | undefined>;
527
- * ```
528
- * @param defaultValue optional default to inject into context
529
- * @param options allows to set a name in dev mode for debugging purposes
530
- * @returns The context that contains the Provider Component and that can be used with `useContext`
531
- *
532
- * @description https://docs.solidjs.com/reference/component-apis/create-context
533
- */
534
- export declare function createContext<T>(defaultValue?: undefined, options?: EffectOptions): Context<T | undefined>;
535
- export declare function createContext<T>(defaultValue: T, options?: EffectOptions): Context<T>;
536
- /**
537
- * Uses a context to receive a scoped state from a parent's Context.Provider
538
- *
539
- * @param context Context object made by `createContext`
540
- * @returns the current or `defaultValue`, if present
541
- *
542
- * @description https://docs.solidjs.com/reference/component-apis/use-context
543
- */
544
- export declare function useContext<T>(context: Context<T>): T;
545
- export type ResolvedJSXElement = Exclude<JSX.Element, JSX.ArrayElement>;
546
- export type ResolvedChildren = ResolvedJSXElement | ResolvedJSXElement[];
547
- export type ChildrenReturn = Accessor<ResolvedChildren> & {
548
- toArray: () => ResolvedJSXElement[];
549
- };
550
- /**
551
- * Resolves child elements to help interact with children
552
- *
553
- * @param fn an accessor for the children
554
- * @returns a accessor of the same children, but resolved
555
- *
556
- * @description https://docs.solidjs.com/reference/component-apis/children
557
- */
558
- export declare function children(fn: Accessor<JSX.Element>): ChildrenReturn;
559
- export type SuspenseContextType = {
560
- increment?: () => void;
561
- decrement?: () => void;
562
- inFallback?: () => boolean;
563
- effects?: Computation<any>[];
564
- resolved?: boolean;
565
- };
566
- type SuspenseContext = Context<SuspenseContextType | undefined> & {
567
- active?(): boolean;
568
- increment?(): void;
569
- decrement?(): void;
570
- };
571
- declare let SuspenseContext: SuspenseContext;
572
- export declare function getSuspenseContext(): SuspenseContext;
573
- export declare function enableExternalSource(factory: ExternalSourceFactory, untrack?: <V>(fn: () => V) => V): void;
574
- export declare function readSignal(this: SignalState<any> | Memo<any>): any;
575
- export declare function writeSignal(node: SignalState<any> | Memo<any>, value: any, isComp?: boolean): any;
576
- /**
577
- * @deprecated since version 1.7.0 and will be removed in next major - use catchError instead
578
- * onError - run an effect whenever an error is thrown within the context of the child scopes
579
- * @param fn an error handler that receives the error
580
- *
581
- * * If the error is thrown again inside the error handler, it will trigger the next available parent handler
582
- *
583
- * @description https://docs.solidjs.com/reference/reactive-utilities/catch-error
584
- */
585
- export declare function onError(fn: (err: Error) => void): void;
586
- 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;