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