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

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 (38) hide show
  1. package/CHEATSHEET.md +640 -0
  2. package/README.md +42 -188
  3. package/dist/dev.cjs +431 -283
  4. package/dist/dev.js +411 -286
  5. package/dist/server.cjs +701 -281
  6. package/dist/server.js +684 -284
  7. package/dist/solid.cjs +423 -255
  8. package/dist/solid.js +403 -258
  9. package/package.json +67 -39
  10. package/types/client/component.d.ts +64 -19
  11. package/types/client/core.d.ts +110 -34
  12. package/types/client/flow.d.ts +176 -42
  13. package/types/client/hydration.d.ts +514 -36
  14. package/types/index.d.ts +9 -12
  15. package/types/server/component.d.ts +11 -11
  16. package/types/server/core.d.ts +19 -14
  17. package/types/server/flow.d.ts +76 -21
  18. package/types/server/hydration.d.ts +34 -9
  19. package/types/server/index.d.ts +5 -7
  20. package/types/server/shared.d.ts +5 -1
  21. package/types/server/signals.d.ts +44 -19
  22. package/types/types.d.ts +15 -0
  23. package/types-cjs/client/component.d.cts +120 -0
  24. package/types-cjs/client/core.d.cts +141 -0
  25. package/types-cjs/client/flow.d.cts +234 -0
  26. package/types-cjs/client/hydration.d.cts +570 -0
  27. package/types-cjs/index.d.cts +17 -0
  28. package/types-cjs/package.json +3 -0
  29. package/types-cjs/server/component.d.cts +67 -0
  30. package/types-cjs/server/core.d.cts +49 -0
  31. package/types-cjs/server/flow.d.cts +115 -0
  32. package/types-cjs/server/hydration.d.cts +63 -0
  33. package/types-cjs/server/index.d.cts +10 -0
  34. package/types-cjs/server/shared.d.cts +50 -0
  35. package/types-cjs/server/signals.d.cts +87 -0
  36. package/types-cjs/types.d.cts +15 -0
  37. package/jsx-runtime.d.ts +0 -1
  38. package/types/jsx.d.ts +0 -4129
@@ -1,10 +1,10 @@
1
- import type { JSX } from "../jsx.js";
1
+ import type { Element as SolidElement } from "../types.js";
2
2
  export declare function enableHydration(): void;
3
3
  /**
4
- * A general `Component` has no implicit `children` prop. If desired, you can
5
- * specify one as in `Component<{name: String, children: JSX.Element}>`.
4
+ * A general `Component` has no implicit `children` prop. If desired, specify
5
+ * one explicitly, e.g. `Component<{ name: string; children: Element }>`.
6
6
  */
7
- export type Component<P extends Record<string, any> = {}> = (props: P) => JSX.Element;
7
+ export type Component<P extends Record<string, any> = {}> = (props: P) => SolidElement;
8
8
  /**
9
9
  * Extend props to forbid the `children` prop.
10
10
  */
@@ -16,10 +16,10 @@ export type VoidProps<P extends Record<string, any> = {}> = P & {
16
16
  */
17
17
  export type VoidComponent<P extends Record<string, any> = {}> = Component<VoidProps<P>>;
18
18
  /**
19
- * Extend props to allow an optional `children` prop with the usual type in JSX.
19
+ * Extend props to allow optional Solid children.
20
20
  */
21
21
  export type ParentProps<P extends Record<string, any> = {}> = P & {
22
- children?: JSX.Element;
22
+ children?: SolidElement;
23
23
  };
24
24
  /**
25
25
  * `ParentComponent` allows an optional `children` prop with the usual type in JSX.
@@ -28,18 +28,18 @@ export type ParentComponent<P extends Record<string, any> = {}> = Component<Pare
28
28
  /**
29
29
  * Extend props to require a `children` prop with the specified type.
30
30
  */
31
- export type FlowProps<P extends Record<string, any> = {}, C = JSX.Element> = P & {
31
+ export type FlowProps<P extends Record<string, any> = {}, C = SolidElement> = P & {
32
32
  children: C;
33
33
  };
34
34
  /**
35
35
  * `FlowComponent` requires a `children` prop with the specified type.
36
36
  */
37
- export type FlowComponent<P extends Record<string, any> = {}, C = JSX.Element> = Component<FlowProps<P, C>>;
38
- export type ValidComponent = keyof JSX.IntrinsicElements | Component<any> | (string & {});
37
+ export type FlowComponent<P extends Record<string, any> = {}, C = SolidElement> = Component<FlowProps<P, C>>;
38
+ export type ValidComponent = Component<any>;
39
39
  /**
40
40
  * Takes the props of the passed component and returns its type
41
41
  */
42
- export type ComponentProps<T extends ValidComponent> = T extends Component<infer P> ? P : T extends keyof JSX.IntrinsicElements ? JSX.IntrinsicElements[T] : Record<string, unknown>;
42
+ export type ComponentProps<T extends ValidComponent> = T extends Component<infer P> ? P : never;
43
43
  /**
44
44
  * Type of `props.ref`, for use in `Component` or `props` typing.
45
45
  */
@@ -47,7 +47,7 @@ export type Ref<T> = T | ((val: T) => void);
47
47
  /**
48
48
  * Creates a component. On server, just calls the function directly (no untrack needed).
49
49
  */
50
- export declare function createComponent<T extends Record<string, any>>(Comp: Component<T>, props: T): JSX.Element;
50
+ export declare function createComponent<T extends Record<string, any>>(Comp: Component<T>, props: T): SolidElement;
51
51
  /**
52
52
  * Lazy load a function component asynchronously.
53
53
  * On server, returns a createMemo that throws NotReadyError until the module resolves,
@@ -1,5 +1,5 @@
1
1
  import type { Accessor, EffectOptions } from "./signals.js";
2
- import type { JSX } from "../jsx.js";
2
+ import type { ArrayElement, Element as SolidElement } from "../types.js";
3
3
  import type { FlowComponent } from "./component.js";
4
4
  export declare const $DEVCOMP: unique symbol;
5
5
  export type NoInfer<T extends any> = [T][T extends any ? 0 : never];
@@ -8,33 +8,38 @@ export type ContextProviderComponent<T> = FlowComponent<{
8
8
  }>;
9
9
  export interface Context<T> extends ContextProviderComponent<T> {
10
10
  id: symbol;
11
- defaultValue: T;
11
+ defaultValue: T | undefined;
12
12
  }
13
13
  /**
14
- * Creates a Context to handle a state scoped for the children of a component
15
- * @param defaultValue optional default to inject into context
14
+ * Creates a Context to share state with descendants of a Provider.
15
+ *
16
+ * - `createContext<T>()` — default-less. `useContext` throws
17
+ * `ContextNotFoundError` outside any Provider. Use this for any context
18
+ * carrying reactive state.
19
+ * - `createContext<T>(defaultValue)` — default form. `useContext` falls back
20
+ * to `defaultValue` outside a Provider. Reserved for primitive fallbacks
21
+ * (theme, locale, frozen config).
22
+ *
23
+ * @param defaultValue optional default; only meaningful for primitive fallbacks
16
24
  * @param options allows to set a name in dev mode for debugging purposes
17
- * @returns The context that contains the Provider Component and that can be used with `useContext`
18
25
  */
19
- export declare function createContext<T>(defaultValue?: undefined, options?: EffectOptions): Context<T | undefined>;
20
- export declare function createContext<T>(defaultValue: T, options?: EffectOptions): Context<T>;
26
+ export declare function createContext<T>(defaultValue?: T, options?: EffectOptions): Context<T>;
21
27
  /**
22
- * Uses a context to receive a scoped state from a parent's Context.Provider
23
- * @param context Context object made by `createContext`
24
- * @returns the current or `defaultValue`, if present
28
+ * Reads the current value of a context. Throws `ContextNotFoundError` if no
29
+ * Provider is mounted and the context was created without a default.
25
30
  */
26
31
  export declare function useContext<T>(context: Context<T>): T;
27
- export type ResolvedJSXElement = Exclude<JSX.Element, JSX.ArrayElement>;
28
- export type ResolvedChildren = ResolvedJSXElement | ResolvedJSXElement[];
32
+ export type ResolvedElement = Exclude<SolidElement, ArrayElement>;
33
+ export type ResolvedChildren = ResolvedElement | ResolvedElement[];
29
34
  export type ChildrenReturn = Accessor<ResolvedChildren> & {
30
- toArray: () => ResolvedJSXElement[];
35
+ toArray: () => ResolvedElement[];
31
36
  };
32
37
  /**
33
38
  * Resolves child elements to help interact with children
34
39
  * @param fn an accessor for the children
35
40
  * @returns a accessor of the same children, but resolved
36
41
  */
37
- export declare function children(fn: Accessor<JSX.Element>): ChildrenReturn;
42
+ export declare function children(fn: Accessor<SolidElement>): ChildrenReturn;
38
43
  /**
39
44
  * Pass-through for SSR dynamic expressions.
40
45
  * On the client, insert() render effects are transparent (0 owner slots),
@@ -1,60 +1,115 @@
1
- import type { Accessor } from "./signals.js";
2
- import type { JSX } from "../jsx.js";
1
+ import type { Accessor, RevealOrder } from "./signals.js";
2
+ import type { Element as SolidElement } from "../types.js";
3
+ export type { RevealOrder };
4
+ type NonZeroParams<T extends (...args: any[]) => any> = Parameters<T>["length"] extends 0 ? never : T;
5
+ type ConditionalRenderCallback<T> = (item: Accessor<NonNullable<T>>) => SolidElement;
6
+ type ConditionalRenderChildren<T, F extends ConditionalRenderCallback<T> = ConditionalRenderCallback<T>> = SolidElement | NonZeroParams<F>;
3
7
  /**
4
8
  * Creates a list of elements from a list
5
9
  *
6
10
  * @description https://docs.solidjs.com/reference/components/for
7
11
  */
8
- export declare function For<T extends readonly any[], U extends JSX.Element>(props: {
12
+ export declare function For<T extends readonly any[], U extends SolidElement>(props: {
9
13
  each: T | undefined | null | false;
10
- fallback?: JSX.Element;
14
+ fallback?: SolidElement;
11
15
  keyed?: boolean | ((item: T[number]) => any);
12
16
  children: (item: Accessor<T[number]>, index: Accessor<number>) => U;
13
- }): JSX.Element;
17
+ }): SolidElement;
14
18
  /**
15
19
  * Creates a list elements from a count
16
20
  *
17
21
  * @description https://docs.solidjs.com/reference/components/repeat
18
22
  */
19
- export declare function Repeat<T extends JSX.Element>(props: {
23
+ export declare function Repeat<T extends SolidElement>(props: {
20
24
  count: number;
21
25
  from?: number | undefined;
22
- fallback?: JSX.Element;
26
+ fallback?: SolidElement;
23
27
  children: ((index: number) => T) | T;
24
- }): JSX.Element;
28
+ }): SolidElement;
25
29
  /**
26
30
  * Conditionally render its children or an optional fallback component
27
31
  * @description https://docs.solidjs.com/reference/components/show
28
32
  */
29
- export declare function Show<T>(props: {
33
+ export declare function Show<T, F extends ConditionalRenderCallback<T>>(props: {
30
34
  when: T | undefined | null | false;
31
35
  keyed?: boolean;
32
- fallback?: JSX.Element;
33
- children: JSX.Element | ((item: Accessor<NonNullable<T>>) => JSX.Element);
34
- }): JSX.Element;
36
+ fallback?: SolidElement;
37
+ children: ConditionalRenderChildren<T, F>;
38
+ }): SolidElement;
35
39
  /**
36
40
  * Switches between content based on mutually exclusive conditions
37
41
  * @description https://docs.solidjs.com/reference/components/switch-and-match
38
42
  */
39
43
  export declare function Switch(props: {
40
- fallback?: JSX.Element;
41
- children: JSX.Element;
42
- }): JSX.Element;
43
- export type MatchProps<T> = {
44
+ fallback?: SolidElement;
45
+ children: SolidElement;
46
+ }): SolidElement;
47
+ export type MatchProps<T, F extends ConditionalRenderCallback<T> = ConditionalRenderCallback<T>> = {
44
48
  when: T | undefined | null | false;
45
49
  keyed?: boolean;
46
- children: JSX.Element | ((item: Accessor<NonNullable<T>>) => JSX.Element);
50
+ children: ConditionalRenderChildren<T, F>;
47
51
  };
48
52
  /**
49
53
  * Selects a content based on condition when inside a `<Switch>` control flow
50
54
  * @description https://docs.solidjs.com/reference/components/switch-and-match
51
55
  */
52
- export declare function Match<T>(props: MatchProps<T>): JSX.Element;
56
+ export declare function Match<T, F extends ConditionalRenderCallback<T>>(props: MatchProps<T, F>): SolidElement;
53
57
  /**
54
58
  * Catches uncaught errors inside components and renders a fallback content
55
59
  * @description https://docs.solidjs.com/reference/components/error-boundary
56
60
  */
57
61
  export declare function Errored(props: {
58
- fallback: JSX.Element | ((err: any, reset: () => void) => JSX.Element);
59
- children: JSX.Element;
60
- }): JSX.Element;
62
+ fallback: SolidElement | ((err: any, reset: () => void) => SolidElement);
63
+ children: SolidElement;
64
+ }): SolidElement;
65
+ /**
66
+ * Tracks all resources inside a component and renders a fallback until they are all resolved
67
+ * @description https://docs.solidjs.com/reference/components/suspense
68
+ */
69
+ export declare function Loading(props: {
70
+ fallback?: SolidElement;
71
+ on?: any;
72
+ children: SolidElement;
73
+ }): SolidElement;
74
+ export type RevealProps = {
75
+ order?: RevealOrder;
76
+ collapsed?: boolean;
77
+ children: SolidElement;
78
+ };
79
+ /**
80
+ * Coordinates the reveal timing of sibling `<Loading>` boundaries during SSR.
81
+ *
82
+ * The `order` prop picks the reveal policy:
83
+ * - `"sequential"` (default) — boundaries reveal in streamed order; out-of-order
84
+ * resolutions have their fragment HTML streamed into templates as data arrives,
85
+ * but the swap from fallback to content waits until the frontier reaches them.
86
+ * - `"together"` — every direct slot holds its fallback until the whole group is
87
+ * "minimally ready" (every direct slot has its own first visible content
88
+ * available), then the whole group releases in a single activation.
89
+ * - `"natural"` — each boundary's swap is triggered as its own data resolves. At
90
+ * the top level this is equivalent to omitting `<Reveal>`; the mode exists for
91
+ * nesting, where the group registers as a single composite slot in an enclosing
92
+ * `<Reveal>`.
93
+ *
94
+ * The `collapsed` prop is only consulted when `order="sequential"` (the default);
95
+ * it is ignored under `"together"` and `"natural"`.
96
+ *
97
+ * Nesting: a nested `<Reveal>` is held on its fallbacks until its parent releases
98
+ * the slot it occupies. HTML for resolved fragments still streams through normally;
99
+ * only the `revealFragments` swap calls are deferred. Once released, the inner
100
+ * group runs its own `order` locally over whatever is still pending. There is no
101
+ * escape hatch.
102
+ *
103
+ * Engine support:
104
+ * - `renderToString` fully supports `order="sequential"` (without `collapsed`) and
105
+ * `order="natural"` because neither requires streamed activation.
106
+ * - `order="together"` and `collapsed` rely on streamed activation and require
107
+ * `renderToStream` / `renderToStringAsync`. Using them inside a nested `<Reveal>`
108
+ * under `renderToString` logs a warning.
109
+ *
110
+ * See `documentation/solid-2.0/03-control-flow.md` for the full outer/inner
111
+ * nesting matrix and the "minimally ready" definition per order.
112
+ *
113
+ * @description https://docs.solidjs.com/reference/components/reveal
114
+ */
115
+ export declare function Reveal(props: RevealProps): SolidElement;
@@ -1,6 +1,32 @@
1
- import type { JSX } from "../jsx.js";
1
+ import type { Context } from "./signals.js";
2
+ import type { Element as SolidElement } from "../types.js";
2
3
  export { sharedConfig, NoHydrateContext } from "./shared.js";
3
4
  export type { HydrationContext, SSRTemplateObject } from "./shared.js";
5
+ export type ServerRevealGroup = {
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
+ */
13
+ register(key: string, options?: {
14
+ onActivate?: () => void;
15
+ }): {
16
+ collapseFallback: boolean;
17
+ held: boolean;
18
+ };
19
+ /** Called by a child when its subtree is fully resolved. */
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;
28
+ };
29
+ export declare const RevealGroupContext: Context<ServerRevealGroup | null>;
4
30
  /**
5
31
  * Handles errors during SSR rendering.
6
32
  * Returns the promise source for NotReadyError (for async handling),
@@ -15,18 +41,17 @@ export declare function ssrHandleError(err: any): Promise<any> | undefined;
15
41
  *
16
42
  * @description https://docs.solidjs.com/reference/components/suspense
17
43
  */
18
- export declare function Loading(props: {
19
- fallback?: JSX.Element;
20
- children: JSX.Element;
21
- }): JSX.Element;
44
+ export declare function createLoadingBoundary(fn: () => any, fallback: () => any, options?: {
45
+ on?: () => any;
46
+ }): () => unknown;
22
47
  /**
23
48
  * Disables hydration for its children during SSR.
24
49
  * Elements inside will not receive hydration keys (`_hk`) and signals will not be serialized.
25
50
  * Use `Hydration` to re-enable hydration within a `NoHydration` zone.
26
51
  */
27
52
  export declare function NoHydration(props: {
28
- children: JSX.Element;
29
- }): JSX.Element;
53
+ children: SolidElement;
54
+ }): SolidElement;
30
55
  /**
31
56
  * Re-enables hydration within a `NoHydration` zone, establishing a new ID namespace.
32
57
  * Pass an `id` prop matching the client's `hydrate({ renderId })` to align hydration keys.
@@ -34,5 +59,5 @@ export declare function NoHydration(props: {
34
59
  */
35
60
  export declare function Hydration(props: {
36
61
  id?: string;
37
- children: JSX.Element;
38
- }): JSX.Element;
62
+ children: SolidElement;
63
+ }): SolidElement;
@@ -1,12 +1,10 @@
1
- export { $PROXY, $TRACK, action, createEffect, createMemo, createOptimistic, createOptimisticStore, createOwner, createProjection, createReaction, createRenderEffect, createRoot, createSignal, createStore, createTrackedEffect, deep, flatten, flush, getNextChildId, getObserver, getOwner, isEqual, isRefreshing, isPending, isWrappable, mapArray, merge, omit, onCleanup, onSettled, latest, reconcile, refresh, repeat, resolve, NotReadyError, runWithOwner, snapshot, storePath, createDeepProxy, untrack } from "./signals.js";
2
- export type { Accessor, ComputeFunction, EffectFunction, EffectOptions, Merge, NoInfer, NotWrappable, Omit, Owner, Signal, SignalOptions, Setter, Store, SolidStore, StoreNode, StoreSetter, StorePathRange, ArrayFilterFn, CustomPartial, Part, PathSetter, PatchOp } from "./signals.js";
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
+ 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
3
  export { $DEVCOMP, children, createContext, useContext, ssrRunInScope } from "./core.js";
4
- export type { ChildrenReturn, Context, ContextProviderComponent, ResolvedChildren, ResolvedJSXElement } from "./core.js";
4
+ export type { ChildrenReturn, Context, ContextProviderComponent, ResolvedChildren, ResolvedElement } from "./core.js";
5
5
  export * from "./component.js";
6
6
  export * from "./flow.js";
7
- export { sharedConfig, Loading, ssrHandleError, NoHydration, Hydration, NoHydrateContext } from "./hydration.js";
7
+ export type { ArrayElement, Element } from "../types.js";
8
+ export { sharedConfig, createLoadingBoundary, ssrHandleError, NoHydration, Hydration, NoHydrateContext } from "./hydration.js";
8
9
  export type { HydrationContext } from "./hydration.js";
9
- import type { JSX } from "../jsx.js";
10
- type JSXElement = JSX.Element;
11
- export type { JSXElement, JSX };
12
10
  export declare const DEV: undefined;
@@ -19,7 +19,11 @@ export type HydrationContext = {
19
19
  escape(value: any): string;
20
20
  replace: (id: string, replacement: () => any) => void;
21
21
  block: (p: Promise<any>) => void;
22
- registerFragment: (v: string) => (v?: string, err?: any) => boolean;
22
+ registerFragment: (v: string, options?: {
23
+ revealGroup?: string;
24
+ }) => (v?: string, err?: any) => boolean;
25
+ revealFragments?: (groupOrKeys: string | string[]) => void;
26
+ revealFallbacks?: (groupOrKeys: string | string[]) => void;
23
27
  /** Register a client-side asset URL discovered during SSR (e.g. from lazy()). */
24
28
  registerAsset?: (type: "module" | "style", url: string) => void;
25
29
  /** Register a moduleUrl-to-entryUrl mapping for the current boundary. */
@@ -1,9 +1,9 @@
1
- export { createRoot, createOwner, runWithOwner, getOwner, onCleanup, getNextChildId, createContext, setContext, getContext, NotReadyError, NoOwnerError, ContextNotFoundError, isEqual, isWrappable, SUPPORTS_PROXY } from "@solidjs/signals";
1
+ export { createRoot, createOwner, runWithOwner, getOwner, isDisposed, onCleanup, getNextChildId, createContext, setContext, getContext, NotReadyError, NoOwnerError, ContextNotFoundError, isEqual, isWrappable, SUPPORTS_PROXY, enableExternalSource, enforceLoadingBoundary } from "@solidjs/signals";
2
2
  export { flatten } from "@solidjs/signals";
3
- export { snapshot, merge, omit, storePath, $PROXY, $TRACK } from "@solidjs/signals";
4
- export type { Accessor, ComputeFunction, EffectFunction, EffectBundle, EffectOptions, MemoOptions, NoInfer, SignalOptions, Setter, Signal, Owner, Maybe, Store, StoreSetter, StoreNode, NotWrappable, SolidStore, Merge, Omit, Context, ContextRecord, IQueue, StorePathRange, ArrayFilterFn, CustomPartial, Part, PathSetter } from "@solidjs/signals";
3
+ export { snapshot, merge, omit, storePath, $PROXY, $REFRESH, $TRACK } from "@solidjs/signals";
4
+ 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
5
  import type { Accessor, ComputeFunction, EffectFunction, EffectBundle, EffectOptions, MemoOptions, SignalOptions, Signal, Owner, Store, StoreSetter, Context } from "@solidjs/signals";
6
- import { NoHydrateContext } from "./shared.js";
6
+ import { sharedConfig, NoHydrateContext } from "./shared.js";
7
7
  interface ServerComputation<T = any> {
8
8
  owner: Owner;
9
9
  value: T;
@@ -12,29 +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<T>, initialValue?: T, options?: SignalOptions<T>): Signal<T>;
19
- export declare function createMemo<Next extends Prev, Prev = Next>(compute: ComputeFunction<undefined | NoInfer<Prev>, Next>): Accessor<Next>;
20
- export declare function createMemo<Next extends Prev, Init = Next, Prev = Next>(compute: ComputeFunction<Init | Prev, Next>, value: Init, options?: MemoOptions<Next>): Accessor<Next>;
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>;
21
39
  export type PatchOp = [path: PropertyKey[]] | [path: PropertyKey[], value: any] | [path: PropertyKey[], value: any, insert: 1];
22
40
  export declare function createDeepProxy<T extends object>(target: T, patches: PatchOp[], basePath?: PropertyKey[]): T;
23
- export declare function createEffect<Next>(compute: ComputeFunction<undefined | NoInfer<Next>, Next>, effectFn: EffectFunction<NoInfer<Next>, Next> | EffectBundle<NoInfer<Next>, Next>): void;
24
- export declare function createEffect<Next, Init = Next>(compute: ComputeFunction<Init | Next, Next>, effect: EffectFunction<Next, Next> | EffectBundle<Next, Next>, value: Init, options?: EffectOptions): void;
25
- export declare function createRenderEffect<Next>(compute: ComputeFunction<undefined | NoInfer<Next>, Next>, effectFn: EffectFunction<NoInfer<Next>, Next>): void;
26
- export declare function createRenderEffect<Next, Init = Next>(compute: ComputeFunction<Init | Next, Next>, effectFn: EffectFunction<Next, Next>, value: Init, options?: EffectOptions): void;
27
- export declare function createTrackedEffect(compute: () => void | (() => void), options?: EffectOptions): void;
41
+ export declare function createEffect<T>(compute: ComputeFunction<undefined | NoInfer<T>, T>, effect: EffectFunction<NoInfer<T>, T> | EffectBundle<NoInfer<T>, T>, options?: EffectOptions): void;
42
+ export declare function createRenderEffect<T>(compute: ComputeFunction<undefined | NoInfer<T>, T>, effectFn: EffectFunction<NoInfer<T>, T>, options?: EffectOptions): void;
43
+ export declare function createTrackedEffect(compute: () => void | (() => void), options?: {
44
+ name?: string;
45
+ }): void;
28
46
  export declare function createReaction(effectFn: EffectFunction<undefined> | EffectBundle<undefined>, options?: EffectOptions): (tracking: () => void) => void;
29
47
  export declare function createOptimistic<T>(): Signal<T | undefined>;
30
48
  export declare function createOptimistic<T>(value: Exclude<T, Function>, options?: SignalOptions<T>): Signal<T>;
31
- export declare function createOptimistic<T>(fn: ComputeFunction<T>, initialValue?: T, options?: SignalOptions<T>): Signal<T>;
32
- export declare function createStore<T extends object>(first: T | Store<T> | ((store: T) => void | T | Promise<void | T>), second?: T | Store<T>): [get: Store<T>, set: StoreSetter<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>;
51
+ export declare function createStore<T extends object>(store: T | Store<T>): [get: Store<T>, set: StoreSetter<T>];
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>];
33
53
  export declare const createOptimisticStore: typeof createStore;
34
- export declare function createProjection<T extends object>(fn: (draft: T) => void | T | Promise<void | T> | AsyncIterable<void | T>, initialValue?: T, options?: {
35
- deferStream?: boolean;
36
- ssrSource?: string;
37
- }): 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>;
38
55
  export declare function reconcile<T extends U, U extends object>(value: T): (state: U) => T;
39
56
  export declare function deep<T extends object>(store: Store<T>): Store<T>;
40
57
  export declare function mapArray<T, U>(list: Accessor<readonly T[] | undefined | null | false>, mapFn: (v: Accessor<T>, i: Accessor<number>) => U, options?: {
@@ -47,9 +64,17 @@ export declare function repeat<T>(count: Accessor<number>, mapFn: (i: number) =>
47
64
  }): () => T[];
48
65
  declare const ErrorContext: Context<((err: any) => void) | null>;
49
66
  export { ErrorContext };
67
+ export declare function runWithBoundaryErrorContext<T>(owner: Owner, render: () => T, onError: (err: any, parentHandler: ((err: any) => void) | null) => void, context?: NonNullable<typeof sharedConfig.context>, boundaryId?: string): T;
50
68
  export { NoHydrateContext };
51
69
  export declare function createErrorBoundary<U>(fn: () => any, fallback: (error: unknown, reset: () => void) => U): () => unknown;
52
- export declare function createLoadBoundary(fn: () => any, fallback: () => any): () => unknown;
70
+ export declare function createLoadingBoundary(fn: () => any, fallback: () => any, options?: {
71
+ on?: () => any;
72
+ }): () => unknown;
73
+ export type RevealOrder = "sequential" | "together" | "natural";
74
+ export declare function createRevealOrder<T>(fn: () => T, _options?: {
75
+ order?: () => RevealOrder;
76
+ collapsed?: () => boolean;
77
+ }): T;
53
78
  export declare function untrack<T>(fn: () => T): T;
54
79
  export declare function flush(): void;
55
80
  export declare function resolve<T>(fn: () => T): Promise<T>;
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Renderer-owned object value returned from Solid component trees.
3
+ *
4
+ * The concrete rendered value belongs to the active renderer or JSX factory
5
+ * (`@solidjs/web`, `@solidjs/h`, custom renderers, etc.), so core does not
6
+ * model DOM nodes or any other platform object here.
7
+ */
8
+ export type RenderedElement = object & {
9
+ readonly call?: never;
10
+ readonly apply?: never;
11
+ readonly bind?: never;
12
+ };
13
+ export type Element = RenderedElement | ArrayElement | (string & {}) | number | boolean | null | undefined;
14
+ export interface ArrayElement extends Array<Element> {
15
+ }
@@ -0,0 +1,120 @@
1
+ import type { Element as SolidElement } from "../types.cjs";
2
+ /**
3
+ * A general `Component` has no implicit `children` prop. If desired, specify
4
+ * one explicitly, e.g. `Component<{ name: string; children: Element }>`.
5
+ */
6
+ export type Component<P extends Record<string, any> = {}> = (props: P) => SolidElement;
7
+ /**
8
+ * Extend props to forbid the `children` prop.
9
+ * Use this to prevent accidentally passing `children` to components that
10
+ * would silently throw them away.
11
+ */
12
+ export type VoidProps<P extends Record<string, any> = {}> = P & {
13
+ children?: never;
14
+ };
15
+ /**
16
+ * `VoidComponent` forbids the `children` prop.
17
+ * Use this to prevent accidentally passing `children` to components that
18
+ * would silently throw them away.
19
+ */
20
+ export type VoidComponent<P extends Record<string, any> = {}> = Component<VoidProps<P>>;
21
+ /**
22
+ * Extend props to allow optional Solid children.
23
+ * Use this for components that you want to accept children.
24
+ */
25
+ export type ParentProps<P extends Record<string, any> = {}> = P & {
26
+ children?: SolidElement;
27
+ };
28
+ /**
29
+ * `ParentComponent` allows an optional `children` prop.
30
+ * Use this for components that you want to accept children.
31
+ */
32
+ export type ParentComponent<P extends Record<string, any> = {}> = Component<ParentProps<P>>;
33
+ /**
34
+ * Extend props to require a `children` prop with the specified type.
35
+ * Use this for components where you need a specific child type,
36
+ * typically a function that receives specific argument types.
37
+ */
38
+ export type FlowProps<P extends Record<string, any> = {}, C = SolidElement> = P & {
39
+ children: C;
40
+ };
41
+ /**
42
+ * `FlowComponent` requires a `children` prop with the specified type.
43
+ * Use this for components where you need a specific child type,
44
+ * typically a function that receives specific argument types.
45
+ */
46
+ export type FlowComponent<P extends Record<string, any> = {}, C = SolidElement> = Component<FlowProps<P, C>>;
47
+ export type ValidComponent = Component<any>;
48
+ /**
49
+ * Takes the props of the passed component and returns its type
50
+ *
51
+ * Intrinsic element prop extraction is renderer-specific and lives in renderer
52
+ * packages such as `@solidjs/web`.
53
+ */
54
+ export type ComponentProps<T extends ValidComponent> = T extends Component<infer P> ? P : never;
55
+ /**
56
+ * Type of `props.ref`, for use in `Component` or `props` typing.
57
+ *
58
+ * @example Component<{ref: Ref<Element>}>
59
+ */
60
+ export type Ref<T> = T | ((val: T) => void);
61
+ /**
62
+ * Invokes a component, wrapping the call in `untrack` so that reactive reads
63
+ * inside the component body don't subscribe the parent computation. Compiled
64
+ * JSX uses this internally; manual calls are rarely needed unless authoring a
65
+ * custom JSX factory or renderer.
66
+ */
67
+ export declare function createComponent<T extends Record<string, any>>(Comp: Component<T>, props: T): SolidElement;
68
+ /**
69
+ * Defines a code-split component. The returned component triggers its dynamic
70
+ * import on first render and suspends through any enclosing `<Loading>`
71
+ * boundary while the chunk is in flight. Call `.preload()` to start the
72
+ * import early (e.g. on hover).
73
+ *
74
+ * @param fn dynamic import returning the module's default export
75
+ * @param moduleUrl optional module URL used during hydration to look up
76
+ * preloaded chunks; usually injected by the bundler integration
77
+ *
78
+ * @example
79
+ * ```tsx
80
+ * const Profile = lazy(() => import("./Profile"));
81
+ *
82
+ * function App() {
83
+ * return (
84
+ * <Loading fallback={<Spinner />}>
85
+ * <Profile id="42" />
86
+ * </Loading>
87
+ * );
88
+ * }
89
+ *
90
+ * // Preload before the user clicks
91
+ * <button onMouseEnter={() => Profile.preload()}>Open profile</button>
92
+ * ```
93
+ */
94
+ export declare function lazy<T extends Component<any>>(fn: () => Promise<{
95
+ default: T;
96
+ }>, moduleUrl?: string): T & {
97
+ preload: () => Promise<{
98
+ default: T;
99
+ }>;
100
+ moduleUrl?: string;
101
+ };
102
+ /**
103
+ * Returns a stable id string that matches between server-rendered and
104
+ * client-hydrated trees. Use it for `<label for>`, `aria-labelledby`, and
105
+ * other attributes that need consistent ids across SSR.
106
+ *
107
+ * @example
108
+ * ```tsx
109
+ * function Field(props: { label: string }) {
110
+ * const id = createUniqueId();
111
+ * return (
112
+ * <>
113
+ * <label for={id}>{props.label}</label>
114
+ * <input id={id} />
115
+ * </>
116
+ * );
117
+ * }
118
+ * ```
119
+ */
120
+ export declare function createUniqueId(): string;