solid-js 2.0.0-beta.10 → 2.0.0-beta.12

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.
@@ -3,18 +3,26 @@ export type { RevealOrder };
3
3
  import type { Element as SolidElement } from "../types.js";
4
4
  type NonZeroParams<T extends (...args: any[]) => any> = Parameters<T>["length"] extends 0 ? never : T;
5
5
  type ConditionalRenderCallback<T> = (item: Accessor<NonNullable<T>>) => SolidElement;
6
+ type KeyedConditionalRenderCallback<T> = (item: NonNullable<T>) => SolidElement;
6
7
  type ConditionalRenderChildren<T, F extends ConditionalRenderCallback<T> = ConditionalRenderCallback<T>> = SolidElement | NonZeroParams<F>;
8
+ type KeyedConditionalRenderChildren<T, F extends KeyedConditionalRenderCallback<T> = KeyedConditionalRenderCallback<T>> = SolidElement | NonZeroParams<F>;
7
9
  /**
8
10
  * Creates a list of elements from a list.
9
11
  *
10
- * Receives a map function as its child that takes list element and index
11
- * accessors and returns a JSX element; if the list is empty, an optional
12
- * `fallback` is rendered instead.
12
+ * Receives a map function as its child and returns a JSX element for each
13
+ * list item; if the list is empty, an optional `fallback` is rendered instead.
14
+ *
15
+ * The child callback shape follows the keying mode:
16
+ * - default / `keyed={true}` receives `(item, index)` where `item` is the raw
17
+ * row value and `index` is an accessor.
18
+ * - `keyed={false}` receives `(item, index)` where `item` is an accessor and
19
+ * `index` is a stable number.
20
+ * - `keyed={(item) => key}` receives accessors for both arguments.
13
21
  *
14
22
  * @example
15
23
  * ```tsx
16
24
  * <For each={items} fallback={<div>No items</div>}>
17
- * {(item, index) => <div data-index={index()}>{item()}</div>}
25
+ * {(item, index) => <div data-index={index()}>{item.label}</div>}
18
26
  * </For>
19
27
  * ```
20
28
  *
@@ -23,7 +31,19 @@ type ConditionalRenderChildren<T, F extends ConditionalRenderCallback<T> = Condi
23
31
  export declare function For<T extends readonly any[], U extends SolidElement>(props: {
24
32
  each: T | undefined | null | false;
25
33
  fallback?: SolidElement;
26
- keyed?: boolean | ((item: T[number]) => any);
34
+ keyed?: true;
35
+ children: (item: T[number], index: Accessor<number>) => U;
36
+ }): SolidElement;
37
+ export declare function For<T extends readonly any[], U extends SolidElement>(props: {
38
+ each: T | undefined | null | false;
39
+ fallback?: SolidElement;
40
+ keyed: false;
41
+ children: (item: Accessor<T[number]>, index: number) => U;
42
+ }): SolidElement;
43
+ export declare function For<T extends readonly any[], U extends SolidElement>(props: {
44
+ each: T | undefined | null | false;
45
+ fallback?: SolidElement;
46
+ keyed: (item: T[number]) => any;
27
47
  children: (item: Accessor<T[number]>, index: Accessor<number>) => U;
28
48
  }): SolidElement;
29
49
  /**
@@ -51,10 +71,10 @@ export declare function Repeat<T extends SolidElement>(props: {
51
71
  * Conditionally renders its children when `when` is truthy, otherwise renders
52
72
  * the optional `fallback`.
53
73
  *
54
- * The function-child form receives an accessor for the narrowed value call
55
- * it to read. Without `keyed` (default), the child is preserved across
56
- * truthy values; with `keyed`, the child remounts whenever the value's
57
- * identity changes.
74
+ * The function-child form receives a narrowed value. Without `keyed`
75
+ * (default), it receives an accessor and the child is preserved across truthy
76
+ * values; with `keyed`, it receives the raw value and remounts whenever the
77
+ * value's identity changes.
58
78
  *
59
79
  * @example
60
80
  * ```tsx
@@ -65,11 +85,29 @@ export declare function Repeat<T extends SolidElement>(props: {
65
85
  *
66
86
  * @description https://docs.solidjs.com/reference/components/show
67
87
  */
88
+ export declare function Show<T>(props: {
89
+ when: T | undefined | null | false;
90
+ keyed: true;
91
+ fallback?: SolidElement;
92
+ children: SolidElement;
93
+ }): SolidElement;
94
+ export declare function Show<T, F extends KeyedConditionalRenderCallback<T>>(props: {
95
+ when: T | undefined | null | false;
96
+ keyed: true;
97
+ fallback?: SolidElement;
98
+ children: NonZeroParams<F>;
99
+ }): SolidElement;
100
+ export declare function Show<T>(props: {
101
+ when: T | undefined | null | false;
102
+ keyed?: false;
103
+ fallback?: SolidElement;
104
+ children: SolidElement;
105
+ }): SolidElement;
68
106
  export declare function Show<T, F extends ConditionalRenderCallback<T>>(props: {
69
107
  when: T | undefined | null | false;
70
- keyed?: boolean;
108
+ keyed?: false;
71
109
  fallback?: SolidElement;
72
- children: ConditionalRenderChildren<T, F>;
110
+ children: NonZeroParams<F>;
73
111
  }): SolidElement;
74
112
  /**
75
113
  * Switches between content based on mutually exclusive conditions. Renders
@@ -96,15 +134,26 @@ export declare function Switch(props: {
96
134
  }): SolidElement;
97
135
  export type MatchProps<T, F extends ConditionalRenderCallback<T> = ConditionalRenderCallback<T>> = {
98
136
  when: T | undefined | null | false;
99
- keyed?: boolean;
137
+ keyed?: false;
100
138
  children: ConditionalRenderChildren<T, F>;
101
139
  };
140
+ export type KeyedMatchProps<T, F extends KeyedConditionalRenderCallback<T> = KeyedConditionalRenderCallback<T>> = {
141
+ when: T | undefined | null | false;
142
+ keyed: true;
143
+ children: KeyedConditionalRenderChildren<T, F>;
144
+ };
145
+ export type AnyMatchProps<T> = MatchProps<T> | KeyedMatchProps<T> | {
146
+ when: T | undefined | null | false;
147
+ keyed?: boolean;
148
+ children: SolidElement;
149
+ };
102
150
  /**
103
151
  * A branch inside a `<Switch>`. The first `<Match>` whose `when` is truthy
104
152
  * wins; remaining matches are skipped.
105
153
  *
106
- * Like `<Show>`, `<Match>` supports a function child that receives an
107
- * accessor for the narrowed value.
154
+ * Like `<Show>`, `<Match>` supports a function child. Non-keyed children
155
+ * receive an accessor for the narrowed value; keyed children receive the raw
156
+ * narrowed value.
108
157
  *
109
158
  * @example
110
159
  * ```tsx
@@ -120,7 +169,19 @@ export type MatchProps<T, F extends ConditionalRenderCallback<T> = ConditionalRe
120
169
  *
121
170
  * @description https://docs.solidjs.com/reference/components/switch-and-match
122
171
  */
172
+ export declare function Match<T>(props: {
173
+ when: T | undefined | null | false;
174
+ keyed: true;
175
+ children: SolidElement;
176
+ }): SolidElement;
177
+ export declare function Match<T, F extends KeyedConditionalRenderCallback<T>>(props: KeyedMatchProps<T, F>): SolidElement;
178
+ export declare function Match<T>(props: {
179
+ when: T | undefined | null | false;
180
+ keyed?: false;
181
+ children: SolidElement;
182
+ }): SolidElement;
123
183
  export declare function Match<T, F extends ConditionalRenderCallback<T>>(props: MatchProps<T, F>): SolidElement;
184
+ export declare function Match<T>(props: AnyMatchProps<T>): SolidElement;
124
185
  /**
125
186
  * Catches uncaught errors inside its subtree and renders fallback content
126
187
  * instead. The `fallback` prop can be a JSX element, or a callback that
@@ -1,4 +1,4 @@
1
- import { createErrorBoundary as coreErrorBoundary, createRenderEffect as coreRenderEffect, createEffect as coreEffect, type Accessor, type ComputeFunction, type MemoOptions, type NoInfer, type ProjectionOptions, type Refreshable, type Signal, type SignalOptions, type Store, type StoreSetter, type Context } from "@solidjs/signals";
1
+ import { createErrorBoundary as coreErrorBoundary, createRenderEffect as coreRenderEffect, createEffect as coreEffect, type ComputeFunction, type MemoOptions, type NoInfer, type ProjectionOptions, type Refreshable, type Signal, type SignalOptions, type SourceAccessor, type Store, type StoreSetter, type Context } from "@solidjs/signals";
2
2
  import type { Element as SolidElement } from "../types.js";
3
3
  type HydrationSsrFields = {
4
4
  /**
@@ -34,11 +34,12 @@ declare module "@solidjs/signals" {
34
34
  }
35
35
  interface EffectOptions extends HydrationSsrFields {
36
36
  }
37
+ interface ProjectionOptions extends HydrationSsrFields {
38
+ }
37
39
  }
38
40
  /**
39
41
  * Options for `createProjection`, `createStore(fn, ...)`, and
40
- * `createOptimisticStore(fn, ...)` — `ProjectionOptions` plus a
41
- * hydration-aware `ssrSource` field.
42
+ * `createOptimisticStore(fn, ...)`.
42
43
  *
43
44
  * `ssrSource` controls what initial value the client uses and whether
44
45
  * the projection's compute re-runs:
@@ -52,9 +53,6 @@ declare module "@solidjs/signals" {
52
53
  *
53
54
  * See {@link HydrationSsrFields} for the fuller explanation.
54
55
  */
55
- export type HydrationProjectionOptions = ProjectionOptions & {
56
- ssrSource?: "server" | "hybrid" | "client";
57
- };
58
56
  type HydrationClientMemoOptions<T> = Omit<MemoOptions<T>, "ssrSource"> & {
59
57
  ssrSource: "client";
60
58
  };
@@ -157,8 +155,8 @@ export declare function enableHydration(): void;
157
155
  * @description https://docs.solidjs.com/reference/basic-reactivity/create-memo
158
156
  */
159
157
  export declare const createMemo: {
160
- <T>(compute: ComputeFunction<undefined | NoInfer<T>, T>, options: HydrationClientMemoOptions<T>): Accessor<T | undefined>;
161
- <T>(compute: ComputeFunction<undefined | NoInfer<T>, T>, options?: HydrationMemoOptions<T>): Accessor<T>;
158
+ <T>(compute: ComputeFunction<undefined | NoInfer<T>, T>, options: HydrationClientMemoOptions<T>): SourceAccessor<T | undefined>;
159
+ <T>(compute: ComputeFunction<undefined | NoInfer<T>, T>, options?: HydrationMemoOptions<T>): SourceAccessor<T>;
162
160
  };
163
161
  /**
164
162
  * Creates a simple reactive state with a getter and setter.
@@ -302,11 +300,11 @@ export declare const createOptimistic: {
302
300
  * );
303
301
  * ```
304
302
  *
305
- * **Hydration:** {@link HydrationProjectionOptions} adds `ssrSource`
303
+ * **Hydration:** `ProjectionOptions` accepts an `ssrSource` field
306
304
  * (`"server"` | `"hybrid"` | `"client"`) for the same client-vs-server
307
305
  * tradeoffs as the other primitives. See {@link HydrationSsrFields}.
308
306
  */
309
- export declare const createProjection: <T extends object = {}>(fn: (draft: T) => void | T | Promise<void | T> | AsyncIterable<void | T>, initialValue: T, options?: HydrationProjectionOptions) => Refreshable<Store<T>>;
307
+ export declare const createProjection: <T extends object = {}>(fn: (draft: T) => void | T | Promise<void | T> | AsyncIterable<void | T>, initialValue: T, options?: ProjectionOptions) => Refreshable<Store<T>>;
310
308
  type NoFn<T> = T extends Function ? never : T;
311
309
  /**
312
310
  * Creates a deeply-reactive store backed by a Proxy. Reads track each
@@ -362,15 +360,15 @@ type NoFn<T> = T extends Function ? never : T;
362
360
  * );
363
361
  * ```
364
362
  *
365
- * **Hydration:** the derived form accepts
366
- * {@link HydrationProjectionOptions}, which adds an `ssrSource` field
363
+ * **Hydration:** the derived form accepts `ProjectionOptions`, including
364
+ * an `ssrSource` field
367
365
  * (`"server"` | `"hybrid"` | `"client"`). See {@link HydrationSsrFields}.
368
366
  *
369
367
  * @returns `[store: Store<T>, setStore: StoreSetter<T>]`
370
368
  */
371
369
  export declare const createStore: {
372
370
  <T extends object = {}>(store: NoFn<T> | Store<NoFn<T>>): [get: Store<T>, set: StoreSetter<T>];
373
- <T extends object = {}>(fn: (store: T) => void | T | Promise<void | T> | AsyncIterable<void | T>, store: NoFn<T> | Store<NoFn<T>>, options?: HydrationProjectionOptions): [get: Refreshable<Store<T>>, set: StoreSetter<T>];
371
+ <T extends object = {}>(fn: (store: T) => void | T | Promise<void | T> | AsyncIterable<void | T>, store: NoFn<T> | Store<NoFn<T>>, options?: ProjectionOptions): [get: Refreshable<Store<T>>, set: StoreSetter<T>];
374
372
  };
375
373
  /**
376
374
  * The store equivalent of `createOptimistic`. Writes inside an
@@ -412,15 +410,15 @@ export declare const createStore: {
412
410
  * });
413
411
  * ```
414
412
  *
415
- * **Hydration:** the derived form accepts
416
- * {@link HydrationProjectionOptions}, which adds an `ssrSource` field
413
+ * **Hydration:** the derived form accepts `ProjectionOptions`, including
414
+ * an `ssrSource` field
417
415
  * (`"server"` | `"hybrid"` | `"client"`). See {@link HydrationSsrFields}.
418
416
  *
419
417
  * @returns `[store: Store<T>, setStore: StoreSetter<T>]`
420
418
  */
421
419
  export declare const createOptimisticStore: {
422
420
  <T extends object = {}>(store: NoFn<T> | Store<NoFn<T>>): [get: Store<T>, set: StoreSetter<T>];
423
- <T extends object = {}>(fn: (store: T) => void | T | Promise<void | T> | AsyncIterable<void | T>, store: NoFn<T> | Store<NoFn<T>>, options?: HydrationProjectionOptions): [get: Refreshable<Store<T>>, set: StoreSetter<T>];
421
+ <T extends object = {}>(fn: (store: T) => void | T | Promise<void | T> | AsyncIterable<void | T>, store: NoFn<T> | Store<NoFn<T>>, options?: ProjectionOptions): [get: Refreshable<Store<T>>, set: StoreSetter<T>];
424
422
  };
425
423
  /**
426
424
  * Creates a reactive computation that runs during the render phase as
package/types/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export { $PROXY, $REFRESH, $TRACK, action, createOwner, createReaction, createRevealOrder, createRoot, createTrackedEffect, deep, flatten, flush, getNextChildId, getObserver, getOwner, isDisposed, isEqual, isRefreshing, isPending, isWrappable, mapArray, merge, omit, onCleanup, onSettled, latest, reconcile, refresh, repeat, resolve, NotReadyError, runWithOwner, enableExternalSource, enforceLoadingBoundary, snapshot, storePath, untrack } from "@solidjs/signals";
2
- export type { Accessor, ComputeFunction, EffectFunction, EffectOptions, ExternalSource, ExternalSourceConfig, ExternalSourceFactory, Merge, NoInfer, NotWrappable, Omit, Owner, Refreshable, Signal, SignalOptions, Setter, Store, SolidStore, StoreNode, StoreSetter, StorePathRange, ArrayFilterFn, CustomPartial, Part, PathSetter } from "@solidjs/signals";
2
+ export type { Accessor, ComputeFunction, EffectBundle, EffectFunction, EffectOptions, ExternalSource, ExternalSourceConfig, ExternalSourceFactory, Merge, MemoOptions, NoInfer, NotWrappable, Omit, Owner, ProjectionOptions, Refreshable, Signal, SignalOptions, SourceAccessor, Setter, Store, StoreOptions, SolidStore, StoreNode, StoreSetter, StorePathRange, ArrayFilterFn, CustomPartial, Part, PathSetter } from "@solidjs/signals";
3
3
  export { $DEVCOMP, children, createContext, useContext } from "./client/core.js";
4
4
  export type { ChildrenReturn, Context, ContextProviderComponent, ResolvedChildren, ResolvedElement } from "./client/core.js";
5
5
  export * from "./client/component.js";
@@ -8,8 +8,6 @@ export type { ArrayElement, Element } from "./types.js";
8
8
  export { sharedConfig, enableHydration, createErrorBoundary, createLoadingBoundary, createMemo, createSignal, createStore, createProjection, createOptimistic, createOptimisticStore, createRenderEffect, createEffect, NoHydration, Hydration, NoHydrateContext } from "./client/hydration.js";
9
9
  /** @internal */
10
10
  export declare function ssrHandleError(): void;
11
- /** @internal */
12
- export declare function ssrRunInScope(): void;
13
11
  import { type Dev } from "@solidjs/signals";
14
12
  export declare const DEV: Dev | undefined;
15
13
  declare global {
@@ -40,10 +40,3 @@ export type ChildrenReturn = Accessor<ResolvedChildren> & {
40
40
  * @returns a accessor of the same children, but resolved
41
41
  */
42
42
  export declare function children(fn: Accessor<SolidElement>): ChildrenReturn;
43
- /**
44
- * Pass-through for SSR dynamic expressions.
45
- * On the client, insert() render effects are transparent (0 owner slots),
46
- * so the server doesn't need to create owners for these either.
47
- */
48
- export declare function ssrRunInScope(fn: () => any): () => any;
49
- export declare function ssrRunInScope(array: (() => any)[]): (() => any)[];
@@ -3,16 +3,29 @@ import type { Element as SolidElement } from "../types.js";
3
3
  export type { RevealOrder };
4
4
  type NonZeroParams<T extends (...args: any[]) => any> = Parameters<T>["length"] extends 0 ? never : T;
5
5
  type ConditionalRenderCallback<T> = (item: Accessor<NonNullable<T>>) => SolidElement;
6
+ type KeyedConditionalRenderCallback<T> = (item: NonNullable<T>) => SolidElement;
6
7
  type ConditionalRenderChildren<T, F extends ConditionalRenderCallback<T> = ConditionalRenderCallback<T>> = SolidElement | NonZeroParams<F>;
8
+ type KeyedConditionalRenderChildren<T, F extends KeyedConditionalRenderCallback<T> = KeyedConditionalRenderCallback<T>> = SolidElement | NonZeroParams<F>;
7
9
  /**
8
10
  * Creates a list of elements from a list
9
- *
10
11
  * @description https://docs.solidjs.com/reference/components/for
11
12
  */
12
13
  export declare function For<T extends readonly any[], U extends SolidElement>(props: {
13
14
  each: T | undefined | null | false;
14
15
  fallback?: SolidElement;
15
- keyed?: boolean | ((item: T[number]) => any);
16
+ keyed?: true;
17
+ children: (item: T[number], index: Accessor<number>) => U;
18
+ }): SolidElement;
19
+ export declare function For<T extends readonly any[], U extends SolidElement>(props: {
20
+ each: T | undefined | null | false;
21
+ fallback?: SolidElement;
22
+ keyed: false;
23
+ children: (item: Accessor<T[number]>, index: number) => U;
24
+ }): SolidElement;
25
+ export declare function For<T extends readonly any[], U extends SolidElement>(props: {
26
+ each: T | undefined | null | false;
27
+ fallback?: SolidElement;
28
+ keyed: (item: T[number]) => any;
16
29
  children: (item: Accessor<T[number]>, index: Accessor<number>) => U;
17
30
  }): SolidElement;
18
31
  /**
@@ -30,11 +43,29 @@ export declare function Repeat<T extends SolidElement>(props: {
30
43
  * Conditionally render its children or an optional fallback component
31
44
  * @description https://docs.solidjs.com/reference/components/show
32
45
  */
46
+ export declare function Show<T>(props: {
47
+ when: T | undefined | null | false;
48
+ keyed: true;
49
+ fallback?: SolidElement;
50
+ children: SolidElement;
51
+ }): SolidElement;
52
+ export declare function Show<T, F extends KeyedConditionalRenderCallback<T>>(props: {
53
+ when: T | undefined | null | false;
54
+ keyed: true;
55
+ fallback?: SolidElement;
56
+ children: NonZeroParams<F>;
57
+ }): SolidElement;
58
+ export declare function Show<T>(props: {
59
+ when: T | undefined | null | false;
60
+ keyed?: false;
61
+ fallback?: SolidElement;
62
+ children: SolidElement;
63
+ }): SolidElement;
33
64
  export declare function Show<T, F extends ConditionalRenderCallback<T>>(props: {
34
65
  when: T | undefined | null | false;
35
- keyed?: boolean;
66
+ keyed?: false;
36
67
  fallback?: SolidElement;
37
- children: ConditionalRenderChildren<T, F>;
68
+ children: NonZeroParams<F>;
38
69
  }): SolidElement;
39
70
  /**
40
71
  * Switches between content based on mutually exclusive conditions
@@ -46,14 +77,36 @@ export declare function Switch(props: {
46
77
  }): SolidElement;
47
78
  export type MatchProps<T, F extends ConditionalRenderCallback<T> = ConditionalRenderCallback<T>> = {
48
79
  when: T | undefined | null | false;
49
- keyed?: boolean;
80
+ keyed?: false;
50
81
  children: ConditionalRenderChildren<T, F>;
51
82
  };
83
+ export type KeyedMatchProps<T, F extends KeyedConditionalRenderCallback<T> = KeyedConditionalRenderCallback<T>> = {
84
+ when: T | undefined | null | false;
85
+ keyed: true;
86
+ children: KeyedConditionalRenderChildren<T, F>;
87
+ };
88
+ export type AnyMatchProps<T> = MatchProps<T> | KeyedMatchProps<T> | {
89
+ when: T | undefined | null | false;
90
+ keyed?: boolean;
91
+ children: SolidElement;
92
+ };
52
93
  /**
53
94
  * Selects a content based on condition when inside a `<Switch>` control flow
54
95
  * @description https://docs.solidjs.com/reference/components/switch-and-match
55
96
  */
97
+ export declare function Match<T>(props: {
98
+ when: T | undefined | null | false;
99
+ keyed: true;
100
+ children: SolidElement;
101
+ }): SolidElement;
102
+ export declare function Match<T, F extends KeyedConditionalRenderCallback<T>>(props: KeyedMatchProps<T, F>): SolidElement;
103
+ export declare function Match<T>(props: {
104
+ when: T | undefined | null | false;
105
+ keyed?: false;
106
+ children: SolidElement;
107
+ }): SolidElement;
56
108
  export declare function Match<T, F extends ConditionalRenderCallback<T>>(props: MatchProps<T, F>): SolidElement;
109
+ export declare function Match<T>(props: AnyMatchProps<T>): SolidElement;
57
110
  /**
58
111
  * Catches uncaught errors inside components and renders a fallback content
59
112
  * @description https://docs.solidjs.com/reference/components/error-boundary
@@ -1,6 +1,6 @@
1
1
  export { $PROXY, $REFRESH, $TRACK, action, createEffect, createMemo, createOptimistic, createOptimisticStore, createErrorBoundary, createOwner, createProjection, createReaction, createRenderEffect, createRevealOrder, createRoot, createSignal, createStore, createTrackedEffect, deep, flatten, flush, getNextChildId, getObserver, getOwner, isDisposed, isEqual, isRefreshing, isPending, isWrappable, mapArray, merge, omit, onCleanup, onSettled, latest, reconcile, refresh, repeat, resolve, NotReadyError, runWithOwner, snapshot, storePath, createDeepProxy, enableExternalSource, enforceLoadingBoundary, untrack } from "./signals.js";
2
2
  export type { Accessor, ComputeFunction, EffectFunction, EffectOptions, ExternalSource, ExternalSourceConfig, ExternalSourceFactory, Merge, NoInfer, NotWrappable, Omit, Owner, Refreshable, Signal, SignalOptions, Setter, Store, SolidStore, StoreNode, StoreSetter, StorePathRange, ArrayFilterFn, CustomPartial, Part, PathSetter, PatchOp } from "./signals.js";
3
- export { $DEVCOMP, children, createContext, useContext, ssrRunInScope } from "./core.js";
3
+ export { $DEVCOMP, children, createContext, useContext } from "./core.js";
4
4
  export type { ChildrenReturn, Context, ContextProviderComponent, ResolvedChildren, ResolvedElement } from "./core.js";
5
5
  export * from "./component.js";
6
6
  export * from "./flow.js";
@@ -1,8 +1,12 @@
1
- import type { Context } from "@solidjs/signals";
1
+ import type { Context } from "./signals.js";
2
2
  export type SSRTemplateObject = {
3
3
  t: string[];
4
4
  h: Function[];
5
5
  p: Promise<any>[];
6
+ } | {
7
+ t: string;
8
+ h?: undefined;
9
+ p?: undefined;
6
10
  };
7
11
  export type HydrationContext = {
8
12
  id: string;
@@ -1,9 +1,45 @@
1
- export { createRoot, createOwner, runWithOwner, getOwner, isDisposed, onCleanup, getNextChildId, createContext, setContext, getContext, NotReadyError, NoOwnerError, ContextNotFoundError, isEqual, isWrappable, SUPPORTS_PROXY, enableExternalSource, enforceLoadingBoundary } from "@solidjs/signals";
1
+ import { $REFRESH } from "@solidjs/signals";
2
+ export { $REFRESH };
3
+ export { NotReadyError, NoOwnerError, ContextNotFoundError, isEqual, isWrappable, SUPPORTS_PROXY, enableExternalSource, enforceLoadingBoundary } from "@solidjs/signals";
2
4
  export { flatten } from "@solidjs/signals";
3
- export { snapshot, merge, omit, storePath, $PROXY, $REFRESH, $TRACK } from "@solidjs/signals";
5
+ export { snapshot, omit, storePath, $PROXY, $TRACK } from "@solidjs/signals";
6
+ import type { Accessor as SignalAccessor, Refreshable } from "@solidjs/signals";
7
+ export type SourceAccessor<T> = Refreshable<SignalAccessor<T>>;
4
8
  export type { Accessor, ComputeFunction, EffectFunction, EffectBundle, EffectOptions, ExternalSource, ExternalSourceConfig, ExternalSourceFactory, MemoOptions, NoInfer, SignalOptions, Setter, Signal, Owner, Refreshable, Maybe, Store, StoreSetter, StoreNode, NotWrappable, SolidStore, Merge, Omit, Context, ContextRecord, IQueue, StorePathRange, ArrayFilterFn, CustomPartial, Part, PathSetter } from "@solidjs/signals";
5
- import type { Accessor, ComputeFunction, EffectFunction, EffectBundle, EffectOptions, MemoOptions, SignalOptions, Signal, Owner, Store, StoreSetter, Context } from "@solidjs/signals";
9
+ import type { Accessor, ComputeFunction, EffectFunction, EffectBundle, EffectOptions, MemoOptions, SignalOptions, Signal, Merge, Owner, Store, StoreSetter, Context } from "@solidjs/signals";
6
10
  import { sharedConfig, NoHydrateContext } from "./shared.js";
11
+ type Disposable = () => void;
12
+ export declare function getNextChildId(owner: Owner): string;
13
+ export declare function createOwner(options?: {
14
+ id?: string;
15
+ transparent?: boolean;
16
+ }): Owner;
17
+ export declare function runWithOwner<T>(owner: Owner | null, fn: () => T): T;
18
+ export declare function getOwner(): Owner | null;
19
+ export declare function isDisposed(owner: Owner): boolean;
20
+ export declare function onCleanup(fn: Disposable): Disposable;
21
+ export declare function createContext<T>(defaultValue?: T, description?: string): Context<T>;
22
+ export declare function getContext<T>(context: Context<T>, owner?: Owner | null): T;
23
+ export declare function setContext<T>(context: Context<T>, value?: T, owner?: Owner | null): void;
24
+ /**
25
+ * Tears down `owner` (optionally) and all of its descendants. Walks the
26
+ * forward-only `_firstChild` -> `_nextSibling` chain, recursively disposing
27
+ * each child with `self=true`, then runs the owner's own `_disposal` queue
28
+ * and resets `_firstChild` / `_childCount`.
29
+ *
30
+ * `self=false` keeps `owner` itself alive (its `_disposed` flag stays clear,
31
+ * future `runWithOwner(owner, ...)` keeps working) but tears down its
32
+ * subtree. This is what `createErrorBoundary` and `createLoadingBoundary`
33
+ * use on retry — wipe the children, keep the boundary owner around for the
34
+ * re-run.
35
+ *
36
+ * @internal
37
+ */
38
+ export declare function disposeOwner(owner: Owner, self?: boolean): void;
39
+ export declare function createRoot<T>(init: ((dispose: () => void) => T) | (() => T), options?: {
40
+ id?: string;
41
+ transparent?: boolean;
42
+ }): T;
7
43
  interface ServerComputation<T = any> {
8
44
  owner: Owner;
9
45
  value: T;
@@ -34,8 +70,8 @@ export declare function createSignal<T>(): Signal<T | undefined>;
34
70
  export declare function createSignal<T>(value: Exclude<T, Function>, options?: SignalOptions<T>): Signal<T>;
35
71
  export declare function createSignal<T>(fn: ComputeFunction<undefined | NoInfer<T>, T>, options: ServerClientSignalOptions<T>): Signal<T | undefined>;
36
72
  export declare function createSignal<T>(fn: ComputeFunction<undefined | NoInfer<T>, T>, options?: ServerSignalOptions<T>): Signal<T>;
37
- export declare function createMemo<T>(compute: ComputeFunction<undefined | NoInfer<T>, T>, options: ServerClientMemoOptions<T>): Accessor<T | undefined>;
38
- export declare function createMemo<T>(compute: ComputeFunction<undefined | NoInfer<T>, T>, options?: ServerMemoOptions<T>): Accessor<T>;
73
+ export declare function createMemo<T>(compute: ComputeFunction<undefined | NoInfer<T>, T>, options: ServerClientMemoOptions<T>): SourceAccessor<T | undefined>;
74
+ export declare function createMemo<T>(compute: ComputeFunction<undefined | NoInfer<T>, T>, options?: ServerMemoOptions<T>): SourceAccessor<T>;
39
75
  export type PatchOp = [path: PropertyKey[]] | [path: PropertyKey[], value: any] | [path: PropertyKey[], value: any, insert: 1];
40
76
  export declare function createDeepProxy<T extends object>(target: T, patches: PatchOp[], basePath?: PropertyKey[]): T;
41
77
  export declare function createEffect<T>(compute: ComputeFunction<undefined | NoInfer<T>, T>, effect: EffectFunction<NoInfer<T>, T> | EffectBundle<NoInfer<T>, T>, options?: EffectOptions): void;
@@ -54,8 +90,17 @@ export declare const createOptimisticStore: typeof createStore;
54
90
  export declare function createProjection<T extends object>(fn: (draft: T) => void | T | Promise<void | T> | AsyncIterable<void | T>, initialValue: Partial<T>, options?: ServerSsrOptions): Store<T>;
55
91
  export declare function reconcile<T extends U, U extends object>(value: T): (state: U) => T;
56
92
  export declare function deep<T extends object>(store: Store<T>): Store<T>;
57
- export declare function mapArray<T, U>(list: Accessor<readonly T[] | undefined | null | false>, mapFn: (v: Accessor<T>, i: Accessor<number>) => U, options?: {
58
- keyed?: boolean | ((item: T) => any);
93
+ export declare function merge<T extends unknown[]>(...sources: T): Merge<T>;
94
+ export declare function mapArray<T, U>(list: Accessor<readonly T[] | undefined | null | false>, mapFn: (v: T, i: Accessor<number>) => U, options?: {
95
+ keyed?: true;
96
+ fallback?: Accessor<any>;
97
+ }): () => U[];
98
+ export declare function mapArray<T, U>(list: Accessor<readonly T[] | undefined | null | false>, mapFn: (v: Accessor<T>, i: number) => U, options: {
99
+ keyed: false;
100
+ fallback?: Accessor<any>;
101
+ }): () => U[];
102
+ export declare function mapArray<T, U>(list: Accessor<readonly T[] | undefined | null | false>, mapFn: (v: Accessor<T>, i: Accessor<number>) => U, options: {
103
+ keyed: (item: T) => any;
59
104
  fallback?: Accessor<any>;
60
105
  }): () => U[];
61
106
  export declare function repeat<T>(count: Accessor<number>, mapFn: (i: number) => T, options?: {
@@ -81,7 +126,7 @@ export declare function resolve<T>(fn: () => T): Promise<T>;
81
126
  export declare function isPending(fn: () => any, fallback?: boolean): boolean;
82
127
  export declare function latest<T>(fn: () => T): T;
83
128
  export declare function isRefreshing(): boolean;
84
- export declare function refresh<T>(fn: () => T): T;
129
+ export declare function refresh<T>(_target: Refreshable<T>): void;
85
130
  export declare function action<T extends (...args: any[]) => any>(fn: T): T;
86
131
  export declare function onSettled(callback: () => void | (() => void)): void;
87
132
  type NoInfer<T extends any> = [T][T extends any ? 0 : never];
@@ -3,18 +3,26 @@ export type { RevealOrder };
3
3
  import type { Element as SolidElement } from "../types.cjs";
4
4
  type NonZeroParams<T extends (...args: any[]) => any> = Parameters<T>["length"] extends 0 ? never : T;
5
5
  type ConditionalRenderCallback<T> = (item: Accessor<NonNullable<T>>) => SolidElement;
6
+ type KeyedConditionalRenderCallback<T> = (item: NonNullable<T>) => SolidElement;
6
7
  type ConditionalRenderChildren<T, F extends ConditionalRenderCallback<T> = ConditionalRenderCallback<T>> = SolidElement | NonZeroParams<F>;
8
+ type KeyedConditionalRenderChildren<T, F extends KeyedConditionalRenderCallback<T> = KeyedConditionalRenderCallback<T>> = SolidElement | NonZeroParams<F>;
7
9
  /**
8
10
  * Creates a list of elements from a list.
9
11
  *
10
- * Receives a map function as its child that takes list element and index
11
- * accessors and returns a JSX element; if the list is empty, an optional
12
- * `fallback` is rendered instead.
12
+ * Receives a map function as its child and returns a JSX element for each
13
+ * list item; if the list is empty, an optional `fallback` is rendered instead.
14
+ *
15
+ * The child callback shape follows the keying mode:
16
+ * - default / `keyed={true}` receives `(item, index)` where `item` is the raw
17
+ * row value and `index` is an accessor.
18
+ * - `keyed={false}` receives `(item, index)` where `item` is an accessor and
19
+ * `index` is a stable number.
20
+ * - `keyed={(item) => key}` receives accessors for both arguments.
13
21
  *
14
22
  * @example
15
23
  * ```tsx
16
24
  * <For each={items} fallback={<div>No items</div>}>
17
- * {(item, index) => <div data-index={index()}>{item()}</div>}
25
+ * {(item, index) => <div data-index={index()}>{item.label}</div>}
18
26
  * </For>
19
27
  * ```
20
28
  *
@@ -23,7 +31,19 @@ type ConditionalRenderChildren<T, F extends ConditionalRenderCallback<T> = Condi
23
31
  export declare function For<T extends readonly any[], U extends SolidElement>(props: {
24
32
  each: T | undefined | null | false;
25
33
  fallback?: SolidElement;
26
- keyed?: boolean | ((item: T[number]) => any);
34
+ keyed?: true;
35
+ children: (item: T[number], index: Accessor<number>) => U;
36
+ }): SolidElement;
37
+ export declare function For<T extends readonly any[], U extends SolidElement>(props: {
38
+ each: T | undefined | null | false;
39
+ fallback?: SolidElement;
40
+ keyed: false;
41
+ children: (item: Accessor<T[number]>, index: number) => U;
42
+ }): SolidElement;
43
+ export declare function For<T extends readonly any[], U extends SolidElement>(props: {
44
+ each: T | undefined | null | false;
45
+ fallback?: SolidElement;
46
+ keyed: (item: T[number]) => any;
27
47
  children: (item: Accessor<T[number]>, index: Accessor<number>) => U;
28
48
  }): SolidElement;
29
49
  /**
@@ -51,10 +71,10 @@ export declare function Repeat<T extends SolidElement>(props: {
51
71
  * Conditionally renders its children when `when` is truthy, otherwise renders
52
72
  * the optional `fallback`.
53
73
  *
54
- * The function-child form receives an accessor for the narrowed value call
55
- * it to read. Without `keyed` (default), the child is preserved across
56
- * truthy values; with `keyed`, the child remounts whenever the value's
57
- * identity changes.
74
+ * The function-child form receives a narrowed value. Without `keyed`
75
+ * (default), it receives an accessor and the child is preserved across truthy
76
+ * values; with `keyed`, it receives the raw value and remounts whenever the
77
+ * value's identity changes.
58
78
  *
59
79
  * @example
60
80
  * ```tsx
@@ -65,11 +85,29 @@ export declare function Repeat<T extends SolidElement>(props: {
65
85
  *
66
86
  * @description https://docs.solidjs.com/reference/components/show
67
87
  */
88
+ export declare function Show<T>(props: {
89
+ when: T | undefined | null | false;
90
+ keyed: true;
91
+ fallback?: SolidElement;
92
+ children: SolidElement;
93
+ }): SolidElement;
94
+ export declare function Show<T, F extends KeyedConditionalRenderCallback<T>>(props: {
95
+ when: T | undefined | null | false;
96
+ keyed: true;
97
+ fallback?: SolidElement;
98
+ children: NonZeroParams<F>;
99
+ }): SolidElement;
100
+ export declare function Show<T>(props: {
101
+ when: T | undefined | null | false;
102
+ keyed?: false;
103
+ fallback?: SolidElement;
104
+ children: SolidElement;
105
+ }): SolidElement;
68
106
  export declare function Show<T, F extends ConditionalRenderCallback<T>>(props: {
69
107
  when: T | undefined | null | false;
70
- keyed?: boolean;
108
+ keyed?: false;
71
109
  fallback?: SolidElement;
72
- children: ConditionalRenderChildren<T, F>;
110
+ children: NonZeroParams<F>;
73
111
  }): SolidElement;
74
112
  /**
75
113
  * Switches between content based on mutually exclusive conditions. Renders
@@ -96,15 +134,26 @@ export declare function Switch(props: {
96
134
  }): SolidElement;
97
135
  export type MatchProps<T, F extends ConditionalRenderCallback<T> = ConditionalRenderCallback<T>> = {
98
136
  when: T | undefined | null | false;
99
- keyed?: boolean;
137
+ keyed?: false;
100
138
  children: ConditionalRenderChildren<T, F>;
101
139
  };
140
+ export type KeyedMatchProps<T, F extends KeyedConditionalRenderCallback<T> = KeyedConditionalRenderCallback<T>> = {
141
+ when: T | undefined | null | false;
142
+ keyed: true;
143
+ children: KeyedConditionalRenderChildren<T, F>;
144
+ };
145
+ export type AnyMatchProps<T> = MatchProps<T> | KeyedMatchProps<T> | {
146
+ when: T | undefined | null | false;
147
+ keyed?: boolean;
148
+ children: SolidElement;
149
+ };
102
150
  /**
103
151
  * A branch inside a `<Switch>`. The first `<Match>` whose `when` is truthy
104
152
  * wins; remaining matches are skipped.
105
153
  *
106
- * Like `<Show>`, `<Match>` supports a function child that receives an
107
- * accessor for the narrowed value.
154
+ * Like `<Show>`, `<Match>` supports a function child. Non-keyed children
155
+ * receive an accessor for the narrowed value; keyed children receive the raw
156
+ * narrowed value.
108
157
  *
109
158
  * @example
110
159
  * ```tsx
@@ -120,7 +169,19 @@ export type MatchProps<T, F extends ConditionalRenderCallback<T> = ConditionalRe
120
169
  *
121
170
  * @description https://docs.solidjs.com/reference/components/switch-and-match
122
171
  */
172
+ export declare function Match<T>(props: {
173
+ when: T | undefined | null | false;
174
+ keyed: true;
175
+ children: SolidElement;
176
+ }): SolidElement;
177
+ export declare function Match<T, F extends KeyedConditionalRenderCallback<T>>(props: KeyedMatchProps<T, F>): SolidElement;
178
+ export declare function Match<T>(props: {
179
+ when: T | undefined | null | false;
180
+ keyed?: false;
181
+ children: SolidElement;
182
+ }): SolidElement;
123
183
  export declare function Match<T, F extends ConditionalRenderCallback<T>>(props: MatchProps<T, F>): SolidElement;
184
+ export declare function Match<T>(props: AnyMatchProps<T>): SolidElement;
124
185
  /**
125
186
  * Catches uncaught errors inside its subtree and renders fallback content
126
187
  * instead. The `fallback` prop can be a JSX element, or a callback that