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

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 +446 -291
  4. package/dist/dev.js +426 -293
  5. package/dist/server.cjs +941 -345
  6. package/dist/server.js +897 -299
  7. package/dist/solid.cjs +438 -261
  8. package/dist/solid.js +418 -263
  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 +513 -37
  14. package/types/index.d.ts +8 -13
  15. package/types/server/component.d.ts +11 -11
  16. package/types/server/core.d.ts +19 -21
  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 +6 -8
  20. package/types/server/shared.d.ts +10 -2
  21. package/types/server/signals.d.ts +80 -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 +568 -0
  27. package/types-cjs/index.d.cts +15 -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 +42 -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 +54 -0
  35. package/types-cjs/server/signals.d.cts +123 -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,37 +8,35 @@ 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;
38
- /**
39
- * Pass-through for SSR dynamic expressions.
40
- * On the client, insert() render effects are transparent (0 owner slots),
41
- * so the server doesn't need to create owners for these either.
42
- */
43
- export declare function ssrRunInScope(fn: () => any): () => any;
44
- export declare function ssrRunInScope(array: (() => any)[]): (() => any)[];
42
+ export declare function children(fn: Accessor<SolidElement>): ChildrenReturn;
@@ -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";
3
- export { $DEVCOMP, children, createContext, useContext, ssrRunInScope } from "./core.js";
4
- export type { ChildrenReturn, Context, ContextProviderComponent, ResolvedChildren, ResolvedJSXElement } from "./core.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
+ export { $DEVCOMP, children, createContext, useContext } 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;
@@ -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;
@@ -19,7 +23,11 @@ export type HydrationContext = {
19
23
  escape(value: any): string;
20
24
  replace: (id: string, replacement: () => any) => void;
21
25
  block: (p: Promise<any>) => void;
22
- registerFragment: (v: string) => (v?: string, err?: any) => boolean;
26
+ registerFragment: (v: string, options?: {
27
+ revealGroup?: string;
28
+ }) => (v?: string, err?: any) => boolean;
29
+ revealFragments?: (groupOrKeys: string | string[]) => void;
30
+ revealFallbacks?: (groupOrKeys: string | string[]) => void;
23
31
  /** Register a client-side asset URL discovered during SSR (e.g. from lazy()). */
24
32
  registerAsset?: (type: "module" | "style", url: string) => void;
25
33
  /** Register a moduleUrl-to-entryUrl mapping for the current boundary. */
@@ -1,9 +1,45 @@
1
- export { createRoot, createOwner, runWithOwner, getOwner, onCleanup, getNextChildId, createContext, setContext, getContext, NotReadyError, NoOwnerError, ContextNotFoundError, isEqual, isWrappable, SUPPORTS_PROXY } 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
5
  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";
6
+ import type { Accessor as SignalAccessor, Refreshable } from "@solidjs/signals";
7
+ export type SourceAccessor<T> = Refreshable<SignalAccessor<T>>;
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
9
  import type { Accessor, ComputeFunction, EffectFunction, EffectBundle, EffectOptions, MemoOptions, SignalOptions, Signal, Owner, Store, StoreSetter, Context } from "@solidjs/signals";
6
- import { NoHydrateContext } from "./shared.js";
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;
@@ -12,29 +48,46 @@ interface ServerComputation<T = any> {
12
48
  computed: boolean;
13
49
  disposed: boolean;
14
50
  }
51
+ type SsrSourceMode = "server" | "hybrid" | "client";
52
+ type ServerSsrOptions = {
53
+ deferStream?: boolean;
54
+ ssrSource?: SsrSourceMode;
55
+ };
56
+ type ServerClientMemoOptions<T> = Omit<MemoOptions<T>, "ssrSource"> & {
57
+ ssrSource: "client";
58
+ };
59
+ type ServerMemoOptions<T> = Omit<MemoOptions<T>, "ssrSource"> & {
60
+ ssrSource?: "server" | "hybrid";
61
+ };
62
+ type ServerClientSignalOptions<T> = Omit<SignalOptions<T>, "ssrSource"> & {
63
+ ssrSource: "client";
64
+ };
65
+ type ServerSignalOptions<T> = Omit<SignalOptions<T>, "ssrSource"> & {
66
+ ssrSource?: "server" | "hybrid";
67
+ };
15
68
  export declare function getObserver(): ServerComputation<any> | null;
16
69
  export declare function createSignal<T>(): Signal<T | undefined>;
17
70
  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>;
71
+ export declare function createSignal<T>(fn: ComputeFunction<undefined | NoInfer<T>, T>, options: ServerClientSignalOptions<T>): Signal<T | undefined>;
72
+ export declare function createSignal<T>(fn: ComputeFunction<undefined | NoInfer<T>, T>, options?: ServerSignalOptions<T>): Signal<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>;
21
75
  export type PatchOp = [path: PropertyKey[]] | [path: PropertyKey[], value: any] | [path: PropertyKey[], value: any, insert: 1];
22
76
  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;
77
+ export declare function createEffect<T>(compute: ComputeFunction<undefined | NoInfer<T>, T>, effect: EffectFunction<NoInfer<T>, T> | EffectBundle<NoInfer<T>, T>, options?: EffectOptions): void;
78
+ export declare function createRenderEffect<T>(compute: ComputeFunction<undefined | NoInfer<T>, T>, effectFn: EffectFunction<NoInfer<T>, T>, options?: EffectOptions): void;
79
+ export declare function createTrackedEffect(compute: () => void | (() => void), options?: {
80
+ name?: string;
81
+ }): void;
28
82
  export declare function createReaction(effectFn: EffectFunction<undefined> | EffectBundle<undefined>, options?: EffectOptions): (tracking: () => void) => void;
29
83
  export declare function createOptimistic<T>(): Signal<T | undefined>;
30
84
  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>];
85
+ export declare function createOptimistic<T>(fn: ComputeFunction<undefined | NoInfer<T>, T>, options: ServerClientSignalOptions<T>): Signal<T | undefined>;
86
+ export declare function createOptimistic<T>(fn: ComputeFunction<undefined | NoInfer<T>, T>, options?: ServerSignalOptions<T>): Signal<T>;
87
+ export declare function createStore<T extends object>(store: T | Store<T>): [get: Store<T>, set: StoreSetter<T>];
88
+ 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
89
  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>;
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>;
38
91
  export declare function reconcile<T extends U, U extends object>(value: T): (state: U) => T;
39
92
  export declare function deep<T extends object>(store: Store<T>): Store<T>;
40
93
  export declare function mapArray<T, U>(list: Accessor<readonly T[] | undefined | null | false>, mapFn: (v: Accessor<T>, i: Accessor<number>) => U, options?: {
@@ -47,16 +100,24 @@ export declare function repeat<T>(count: Accessor<number>, mapFn: (i: number) =>
47
100
  }): () => T[];
48
101
  declare const ErrorContext: Context<((err: any) => void) | null>;
49
102
  export { ErrorContext };
103
+ 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
104
  export { NoHydrateContext };
51
105
  export declare function createErrorBoundary<U>(fn: () => any, fallback: (error: unknown, reset: () => void) => U): () => unknown;
52
- export declare function createLoadBoundary(fn: () => any, fallback: () => any): () => unknown;
106
+ export declare function createLoadingBoundary(fn: () => any, fallback: () => any, options?: {
107
+ on?: () => any;
108
+ }): () => unknown;
109
+ export type RevealOrder = "sequential" | "together" | "natural";
110
+ export declare function createRevealOrder<T>(fn: () => T, _options?: {
111
+ order?: () => RevealOrder;
112
+ collapsed?: () => boolean;
113
+ }): T;
53
114
  export declare function untrack<T>(fn: () => T): T;
54
115
  export declare function flush(): void;
55
116
  export declare function resolve<T>(fn: () => T): Promise<T>;
56
117
  export declare function isPending(fn: () => any, fallback?: boolean): boolean;
57
118
  export declare function latest<T>(fn: () => T): T;
58
119
  export declare function isRefreshing(): boolean;
59
- export declare function refresh<T>(fn: () => T): T;
120
+ export declare function refresh<T>(_target: Refreshable<T>): void;
60
121
  export declare function action<T extends (...args: any[]) => any>(fn: T): T;
61
122
  export declare function onSettled(callback: () => void | (() => void)): void;
62
123
  type NoInfer<T extends any> = [T][T extends any ? 0 : never];
@@ -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
+ }