solid-js 2.0.0-beta.7 → 2.0.0-beta.8

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.
@@ -4,10 +4,27 @@ export { sharedConfig, NoHydrateContext } from "./shared.js";
4
4
  export type { HydrationContext, SSRTemplateObject } from "./shared.js";
5
5
  export type ServerRevealGroup = {
6
6
  id: string;
7
+ /**
8
+ * Register a child fragment (Loading) or composite child (inner Reveal).
9
+ * Returns `collapseFallback` (hide fallback visually, used for collapsed-sequential
10
+ * tail) and `held` (stash `revealFragments` swaps until the parent releases us).
11
+ * `held` only applies when the caller is a nested Reveal — Loadings ignore it.
12
+ */
7
13
  register(key: string, options?: {
8
14
  onActivate?: () => void;
9
- }): boolean;
15
+ }): {
16
+ collapseFallback: boolean;
17
+ held: boolean;
18
+ };
19
+ /** Called by a child when its subtree is fully resolved. */
10
20
  onResolved(key: string): void;
21
+ /**
22
+ * Called by a nested Reveal when it becomes "minimally resolved" under its own
23
+ * order (together: fully resolved; sequential: first registered fragment resolved;
24
+ * natural: any fragment resolved). Loadings don't fire this — their `onResolved`
25
+ * implies minimal readiness at the same time.
26
+ */
27
+ onMinimallyResolved?(key: string): void;
11
28
  };
12
29
  export declare const RevealGroupContext: Context<ServerRevealGroup | null>;
13
30
  /**
@@ -12,27 +12,46 @@ interface ServerComputation<T = any> {
12
12
  computed: boolean;
13
13
  disposed: boolean;
14
14
  }
15
+ type SsrSourceMode = "server" | "hybrid" | "client";
16
+ type ServerSsrOptions = {
17
+ deferStream?: boolean;
18
+ ssrSource?: SsrSourceMode;
19
+ };
20
+ type ServerClientMemoOptions<T> = Omit<MemoOptions<T>, "ssrSource"> & {
21
+ ssrSource: "client";
22
+ };
23
+ type ServerMemoOptions<T> = Omit<MemoOptions<T>, "ssrSource"> & {
24
+ ssrSource?: "server" | "hybrid";
25
+ };
26
+ type ServerClientSignalOptions<T> = Omit<SignalOptions<T>, "ssrSource"> & {
27
+ ssrSource: "client";
28
+ };
29
+ type ServerSignalOptions<T> = Omit<SignalOptions<T>, "ssrSource"> & {
30
+ ssrSource?: "server" | "hybrid";
31
+ };
15
32
  export declare function getObserver(): ServerComputation<any> | null;
16
33
  export declare function createSignal<T>(): Signal<T | undefined>;
17
34
  export declare function createSignal<T>(value: Exclude<T, Function>, options?: SignalOptions<T>): Signal<T>;
18
- export declare function createSignal<T>(fn: ComputeFunction<undefined | NoInfer<T>, T>, options?: SignalOptions<T>): Signal<T>;
19
- export declare function createMemo<T>(compute: ComputeFunction<undefined | NoInfer<T>, T>, options?: MemoOptions<T>): Accessor<T>;
35
+ export declare function createSignal<T>(fn: ComputeFunction<undefined | NoInfer<T>, T>, options: ServerClientSignalOptions<T>): Signal<T | undefined>;
36
+ 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>;
20
39
  export type PatchOp = [path: PropertyKey[]] | [path: PropertyKey[], value: any] | [path: PropertyKey[], value: any, insert: 1];
21
40
  export declare function createDeepProxy<T extends object>(target: T, patches: PatchOp[], basePath?: PropertyKey[]): T;
22
41
  export declare function createEffect<T>(compute: ComputeFunction<undefined | NoInfer<T>, T>, effect: EffectFunction<NoInfer<T>, T> | EffectBundle<NoInfer<T>, T>, options?: EffectOptions): void;
23
42
  export declare function createRenderEffect<T>(compute: ComputeFunction<undefined | NoInfer<T>, T>, effectFn: EffectFunction<NoInfer<T>, T>, options?: EffectOptions): void;
24
- export declare function createTrackedEffect(compute: () => void | (() => void), options?: EffectOptions): void;
43
+ export declare function createTrackedEffect(compute: () => void | (() => void), options?: {
44
+ name?: string;
45
+ }): void;
25
46
  export declare function createReaction(effectFn: EffectFunction<undefined> | EffectBundle<undefined>, options?: EffectOptions): (tracking: () => void) => void;
26
47
  export declare function createOptimistic<T>(): Signal<T | undefined>;
27
48
  export declare function createOptimistic<T>(value: Exclude<T, Function>, options?: SignalOptions<T>): Signal<T>;
28
- export declare function createOptimistic<T>(fn: ComputeFunction<undefined | NoInfer<T>, T>, options?: SignalOptions<T>): Signal<T>;
49
+ export declare function createOptimistic<T>(fn: ComputeFunction<undefined | NoInfer<T>, T>, options: ServerClientSignalOptions<T>): Signal<T | undefined>;
50
+ export declare function createOptimistic<T>(fn: ComputeFunction<undefined | NoInfer<T>, T>, options?: ServerSignalOptions<T>): Signal<T>;
29
51
  export declare function createStore<T extends object>(store: T | Store<T>): [get: Store<T>, set: StoreSetter<T>];
30
52
  export declare function createStore<T extends object>(fn: (store: T) => void | T | Promise<void | T>, store: Partial<T> | Store<T>): [get: Store<T>, set: StoreSetter<T>];
31
53
  export declare const createOptimisticStore: typeof createStore;
32
- export declare function createProjection<T extends object>(fn: (draft: T) => void | T | Promise<void | T> | AsyncIterable<void | T>, initialValue: Partial<T>, options?: {
33
- deferStream?: boolean;
34
- ssrSource?: string;
35
- }): Store<T>;
54
+ 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>;
36
55
  export declare function reconcile<T extends U, U extends object>(value: T): (state: U) => T;
37
56
  export declare function deep<T extends object>(store: Store<T>): Store<T>;
38
57
  export declare function mapArray<T, U>(list: Accessor<readonly T[] | undefined | null | false>, mapFn: (v: Accessor<T>, i: Accessor<number>) => U, options?: {
@@ -51,8 +70,9 @@ export declare function createErrorBoundary<U>(fn: () => any, fallback: (error:
51
70
  export declare function createLoadingBoundary(fn: () => any, fallback: () => any, options?: {
52
71
  on?: () => any;
53
72
  }): () => unknown;
73
+ export type RevealOrder = "sequential" | "together" | "natural";
54
74
  export declare function createRevealOrder<T>(fn: () => T, _options?: {
55
- together?: () => boolean;
75
+ order?: () => RevealOrder;
56
76
  collapsed?: () => boolean;
57
77
  }): T;
58
78
  export declare function untrack<T>(fn: () => T): T;
@@ -1,4 +1,5 @@
1
- import type { Accessor } from "@solidjs/signals";
1
+ import type { Accessor, RevealOrder } from "@solidjs/signals";
2
+ export type { RevealOrder };
2
3
  import type { JSX } from "../jsx.cjs";
3
4
  type NonZeroParams<T extends (...args: any[]) => any> = Parameters<T>["length"] extends 0 ? never : T;
4
5
  type ConditionalRenderCallback<T> = (item: Accessor<NonNullable<T>>) => JSX.Element;
@@ -117,26 +118,46 @@ export declare function Loading(props: {
117
118
  on?: any;
118
119
  children: JSX.Element;
119
120
  }): JSX.Element;
121
+ export type RevealProps = {
122
+ order?: RevealOrder;
123
+ collapsed?: boolean;
124
+ children: JSX.Element;
125
+ };
120
126
  /**
121
127
  * Coordinates the reveal timing of sibling `<Loading>` boundaries.
122
128
  *
123
- * - **Sequential** (default): boundaries reveal in DOM order as each resolves.
124
- * - **Together** (`together`): all boundaries wait until the group is ready, then reveal at once.
125
- * - **Collapsed** (`collapsed`, sequential only): only the frontier boundary shows its fallback;
126
- * later boundaries produce nothing until their turn.
129
+ * The `order` prop picks the reveal policy:
130
+ * - `"sequential"` (default) boundaries reveal in registration order; later boundaries
131
+ * stay on their fallback until earlier ones resolve.
132
+ * - `"together"` every direct slot stays on its fallback until the whole group is
133
+ * "minimally ready" (every direct slot has its own first visible content available),
134
+ * then the group releases in one cohesive reveal.
135
+ * - `"natural"` — each boundary reveals as its own data resolves. At the top level
136
+ * this is equivalent to omitting `<Reveal>`; the mode exists for nesting, where
137
+ * the group registers as a single composite slot in an enclosing `<Reveal>`.
138
+ *
139
+ * The `collapsed` prop is only consulted when `order="sequential"` (the default);
140
+ * it is ignored under `"together"` and `"natural"`. When set, tail boundaries past
141
+ * the frontier suppress their own fallback output.
142
+ *
143
+ * Nested `<Reveal>` groups compose: the inner group is one slot in the outer order
144
+ * and is held on its fallbacks until the outer releases the slot. Once released, the
145
+ * inner group runs its own `order` locally over whatever is still pending. There is
146
+ * no escape hatch — nesting under an outer group means participating in its ordering.
147
+ * See `documentation/solid-2.0/03-control-flow.md` for the full nesting matrix and the
148
+ * "minimally ready" definition per order.
127
149
  *
128
150
  * ```typescript
129
- * <Reveal>
151
+ * <Reveal order="sequential">
130
152
  * <Loading fallback={<Skeleton />}><ProfileHeader /></Loading>
131
- * <Loading fallback={<Skeleton />}><Posts /></Loading>
153
+ * <Reveal order="natural">
154
+ * <Loading fallback={<Skeleton />}><PostA /></Loading>
155
+ * <Loading fallback={<Skeleton />}><PostB /></Loading>
156
+ * </Reveal>
157
+ * <Loading fallback={<Skeleton />}><Comments /></Loading>
132
158
  * </Reveal>
133
159
  * ```
134
160
  *
135
161
  * @description https://docs.solidjs.com/reference/components/reveal
136
162
  */
137
- export declare function Reveal(props: {
138
- together?: boolean;
139
- collapsed?: boolean;
140
- children: JSX.Element;
141
- }): JSX.Element;
142
- export {};
163
+ export declare function Reveal(props: RevealProps): JSX.Element;
@@ -1,8 +1,8 @@
1
- import { createErrorBoundary as coreErrorBoundary, createMemo as coreMemo, createSignal as coreSignal, createOptimistic as coreOptimistic, createRenderEffect as coreRenderEffect, createEffect as coreEffect, $REFRESH, type ProjectionOptions, type Store, type StoreSetter, type Context } from "@solidjs/signals";
1
+ import { createErrorBoundary as coreErrorBoundary, createRenderEffect as coreRenderEffect, createEffect as coreEffect, $REFRESH, type Accessor, type ComputeFunction, type MemoOptions, type NoInfer, type ProjectionOptions, type Signal, type SignalOptions, type Store, type StoreSetter, type Context } from "@solidjs/signals";
2
2
  import { JSX } from "../jsx.cjs";
3
3
  type HydrationSsrFields = {
4
4
  deferStream?: boolean;
5
- ssrSource?: "server" | "hybrid" | "initial" | "client";
5
+ ssrSource?: "server" | "hybrid" | "client";
6
6
  };
7
7
  declare module "@solidjs/signals" {
8
8
  interface MemoOptions<T> extends HydrationSsrFields {
@@ -13,7 +13,19 @@ declare module "@solidjs/signals" {
13
13
  }
14
14
  }
15
15
  export type HydrationProjectionOptions = ProjectionOptions & {
16
- ssrSource?: "server" | "hybrid" | "initial" | "client";
16
+ ssrSource?: "server" | "hybrid" | "client";
17
+ };
18
+ type HydrationClientMemoOptions<T> = Omit<MemoOptions<T>, "ssrSource"> & {
19
+ ssrSource: "client";
20
+ };
21
+ type HydrationMemoOptions<T> = Omit<MemoOptions<T>, "ssrSource"> & {
22
+ ssrSource?: "server" | "hybrid";
23
+ };
24
+ type HydrationClientSignalOptions<T> = Omit<SignalOptions<T> & MemoOptions<T>, "ssrSource"> & {
25
+ ssrSource: "client";
26
+ };
27
+ type HydrationSignalOptions<T> = Omit<SignalOptions<T> & MemoOptions<T>, "ssrSource"> & {
28
+ ssrSource?: "server" | "hybrid";
17
29
  };
18
30
  export type HydrationContext = {};
19
31
  export declare const NoHydrateContext: Context<boolean>;
@@ -42,10 +54,23 @@ export declare const sharedConfig: SharedConfig;
42
54
  */
43
55
  export declare function onHydrationEnd(callback: () => void): void;
44
56
  export declare function enableHydration(): void;
45
- export declare const createMemo: typeof coreMemo;
46
- export declare const createSignal: typeof coreSignal;
57
+ export declare const createMemo: {
58
+ <T>(compute: ComputeFunction<undefined | NoInfer<T>, T>, options: HydrationClientMemoOptions<T>): Accessor<T | undefined>;
59
+ <T>(compute: ComputeFunction<undefined | NoInfer<T>, T>, options?: HydrationMemoOptions<T>): Accessor<T>;
60
+ };
61
+ export declare const createSignal: {
62
+ <T>(): Signal<T | undefined>;
63
+ <T>(value: Exclude<T, Function>, options?: SignalOptions<T>): Signal<T>;
64
+ <T>(fn: ComputeFunction<undefined | NoInfer<T>, T>, options: HydrationClientSignalOptions<T>): Signal<T | undefined>;
65
+ <T>(fn: ComputeFunction<undefined | NoInfer<T>, T>, options?: HydrationSignalOptions<T>): Signal<T>;
66
+ };
47
67
  export declare const createErrorBoundary: typeof coreErrorBoundary;
48
- export declare const createOptimistic: typeof coreOptimistic;
68
+ export declare const createOptimistic: {
69
+ <T>(): Signal<T | undefined>;
70
+ <T>(value: Exclude<T, Function>, options?: SignalOptions<T>): Signal<T>;
71
+ <T>(fn: ComputeFunction<undefined | NoInfer<T>, T>, options: HydrationClientSignalOptions<T>): Signal<T | undefined>;
72
+ <T>(fn: ComputeFunction<undefined | NoInfer<T>, T>, options?: HydrationSignalOptions<T>): Signal<T>;
73
+ };
49
74
  export declare const createProjection: <T extends object = {}>(fn: (draft: T) => void | T | Promise<void | T> | AsyncIterable<void | T>, initialValue: T, options?: HydrationProjectionOptions) => Store<T> & {
50
75
  [$REFRESH]: any;
51
76
  };
@@ -41,11 +41,8 @@ export type PropValue =
41
41
  * narrowing
42
42
  * - other types pass through unchanged
43
43
  */
44
- export type WidenPropValue<V> = [V] extends [string]
45
- ? string extends V
46
- ? string | number
47
- : V
48
- : V;
44
+ type WidenString<V> = string extends V ? string | number : V;
45
+ export type WidenPropValue<V> = [V] extends [string] ? WidenString<V> : V;
49
46
 
50
47
  /**
51
48
  * Structurally identical → `Y`; distinct → `N`. Used by `IsReadonlyKey` to detect