solid-js 2.0.0-experimental.13 → 2.0.0-experimental.15
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.
- package/dist/dev.cjs +506 -78
- package/dist/dev.js +509 -64
- package/dist/server.cjs +827 -0
- package/dist/server.js +732 -0
- package/dist/solid.cjs +492 -77
- package/dist/solid.js +495 -63
- package/package.json +4 -4
- package/types/client/component.d.ts +1 -2
- package/types/client/flow.d.ts +1 -5
- package/types/client/hydration.d.ts +36 -0
- package/types/index.d.ts +3 -4
- package/types/server/component.d.ts +66 -0
- package/types/server/core.d.ts +43 -0
- package/types/server/flow.d.ts +60 -0
- package/types/server/hydration.d.ts +21 -0
- package/types/server/index.d.ts +12 -1
- package/types/server/shared.d.ts +45 -0
- package/types/server/signals.d.ts +60 -0
- package/types/utilities.d.ts +0 -36
package/types/client/flow.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Accessor
|
|
1
|
+
import type { Accessor } from "@solidjs/signals";
|
|
2
2
|
import type { JSX } from "../jsx.js";
|
|
3
3
|
/**
|
|
4
4
|
* Creates a list of elements from a list
|
|
@@ -98,7 +98,3 @@ export declare function Errored(props: {
|
|
|
98
98
|
fallback: JSX.Element | ((err: any, reset: () => void) => JSX.Element);
|
|
99
99
|
children: JSX.Element;
|
|
100
100
|
}): JSX.Element;
|
|
101
|
-
export declare function Boundary(props: {
|
|
102
|
-
mode: BoundaryMode;
|
|
103
|
-
children: JSX.Element;
|
|
104
|
-
}): JSX.Element;
|
|
@@ -1,4 +1,18 @@
|
|
|
1
|
+
import { createErrorBoundary as coreErrorBoundary, createMemo as coreMemo, createSignal as coreSignal, createOptimistic as coreOptimistic, type ProjectionOptions, type Store, type StoreSetter } from "@solidjs/signals";
|
|
1
2
|
import { JSX } from "../jsx.js";
|
|
3
|
+
declare module "@solidjs/signals" {
|
|
4
|
+
interface MemoOptions<T> {
|
|
5
|
+
deferStream?: boolean;
|
|
6
|
+
ssrSource?: "server" | "hybrid" | "initial" | "client";
|
|
7
|
+
}
|
|
8
|
+
interface SignalOptions<T> {
|
|
9
|
+
deferStream?: boolean;
|
|
10
|
+
ssrSource?: "server" | "hybrid" | "initial" | "client";
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
export type HydrationProjectionOptions = ProjectionOptions & {
|
|
14
|
+
ssrSource?: "server" | "hybrid" | "initial" | "client";
|
|
15
|
+
};
|
|
2
16
|
export type HydrationContext = {};
|
|
3
17
|
type SharedConfig = {
|
|
4
18
|
hydrating: boolean;
|
|
@@ -8,11 +22,33 @@ type SharedConfig = {
|
|
|
8
22
|
load?: (id: string) => Promise<any> | any;
|
|
9
23
|
has?: (id: string) => boolean;
|
|
10
24
|
gather?: (key: string) => void;
|
|
25
|
+
cleanupFragment?: (id: string) => void;
|
|
11
26
|
registry?: Map<string, Element>;
|
|
12
27
|
done: boolean;
|
|
13
28
|
getNextContextId(): string;
|
|
14
29
|
};
|
|
15
30
|
export declare const sharedConfig: SharedConfig;
|
|
31
|
+
/**
|
|
32
|
+
* Registers a callback to run once when all hydration completes
|
|
33
|
+
* (all boundaries hydrated or cancelled). If hydration is already
|
|
34
|
+
* complete (or not hydrating), fires via queueMicrotask.
|
|
35
|
+
*/
|
|
36
|
+
export declare function onHydrationEnd(callback: () => void): void;
|
|
37
|
+
export declare function enableHydration(): void;
|
|
38
|
+
export declare const createMemo: typeof coreMemo;
|
|
39
|
+
export declare const createSignal: typeof coreSignal;
|
|
40
|
+
export declare const createErrorBoundary: typeof coreErrorBoundary;
|
|
41
|
+
export declare const createOptimistic: typeof coreOptimistic;
|
|
42
|
+
export declare const createProjection: <T extends object = {}>(fn: (draft: T) => void | T | Promise<void | T> | AsyncIterable<void | T>, initialValue?: T, options?: HydrationProjectionOptions) => Store<T>;
|
|
43
|
+
type NoFn<T> = T extends Function ? never : T;
|
|
44
|
+
export declare const createStore: {
|
|
45
|
+
<T extends object = {}>(store: NoFn<T> | Store<NoFn<T>>): [get: Store<T>, set: StoreSetter<T>];
|
|
46
|
+
<T extends object = {}>(fn: (store: T) => void | T | Promise<void | T> | AsyncIterable<void | T>, store?: NoFn<T> | Store<NoFn<T>>, options?: HydrationProjectionOptions): [get: Store<T>, set: StoreSetter<T>];
|
|
47
|
+
};
|
|
48
|
+
export declare const createOptimisticStore: {
|
|
49
|
+
<T extends object = {}>(store: NoFn<T> | Store<NoFn<T>>): [get: Store<T>, set: StoreSetter<T>];
|
|
50
|
+
<T extends object = {}>(fn: (store: T) => void | T | Promise<void | T> | AsyncIterable<void | T>, store?: NoFn<T> | Store<NoFn<T>>, options?: HydrationProjectionOptions): [get: Store<T>, set: StoreSetter<T>];
|
|
51
|
+
};
|
|
16
52
|
/**
|
|
17
53
|
* Tracks all resources inside a component and renders a fallback until they are all resolved
|
|
18
54
|
* ```typescript
|
package/types/index.d.ts
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
export { $PROXY, $TRACK, action, createEffect,
|
|
2
|
-
export type { Accessor,
|
|
1
|
+
export { $PROXY, $TRACK, action, createEffect, createReaction, createRenderEffect, createRoot, createTrackedEffect, deep, flatten, flush, getObserver, getOwner, isEqual, isRefreshing, isPending, isWrappable, mapArray, merge, omit, onCleanup, onSettled, pending, reconcile, refresh, repeat, resolve, NotReadyError, runWithOwner, snapshot, untrack } from "@solidjs/signals";
|
|
2
|
+
export type { Accessor, ComputeFunction, EffectFunction, EffectOptions, Merge, NoInfer, NotWrappable, Omit, Owner, Signal, SignalOptions, Setter, Store, SolidStore, StoreNode, StoreSetter } from "@solidjs/signals";
|
|
3
3
|
export { $DEVCOMP, children, createContext, useContext } from "./client/core.js";
|
|
4
4
|
export type { ChildrenReturn, Context, ContextProviderComponent, ResolvedChildren, ResolvedJSXElement } from "./client/core.js";
|
|
5
|
-
export * from "./utilities.js";
|
|
6
5
|
export * from "./client/component.js";
|
|
7
6
|
export * from "./client/flow.js";
|
|
8
|
-
export { sharedConfig, Loading } from "./client/hydration.js";
|
|
7
|
+
export { sharedConfig, Loading, enableHydration, createMemo, createSignal, createStore, createProjection, createOptimistic, createOptimisticStore } from "./client/hydration.js";
|
|
9
8
|
export declare function ssrHandleError(): void;
|
|
10
9
|
export declare function ssrRunInScope(): void;
|
|
11
10
|
import type { JSX } from "./jsx.js";
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import type { JSX } from "../jsx.js";
|
|
2
|
+
export declare function enableHydration(): void;
|
|
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}>`.
|
|
6
|
+
*/
|
|
7
|
+
export type Component<P extends Record<string, any> = {}> = (props: P) => JSX.Element;
|
|
8
|
+
/**
|
|
9
|
+
* Extend props to forbid the `children` prop.
|
|
10
|
+
*/
|
|
11
|
+
export type VoidProps<P extends Record<string, any> = {}> = P & {
|
|
12
|
+
children?: never;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* `VoidComponent` forbids the `children` prop.
|
|
16
|
+
*/
|
|
17
|
+
export type VoidComponent<P extends Record<string, any> = {}> = Component<VoidProps<P>>;
|
|
18
|
+
/**
|
|
19
|
+
* Extend props to allow an optional `children` prop with the usual type in JSX.
|
|
20
|
+
*/
|
|
21
|
+
export type ParentProps<P extends Record<string, any> = {}> = P & {
|
|
22
|
+
children?: JSX.Element;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* `ParentComponent` allows an optional `children` prop with the usual type in JSX.
|
|
26
|
+
*/
|
|
27
|
+
export type ParentComponent<P extends Record<string, any> = {}> = Component<ParentProps<P>>;
|
|
28
|
+
/**
|
|
29
|
+
* Extend props to require a `children` prop with the specified type.
|
|
30
|
+
*/
|
|
31
|
+
export type FlowProps<P extends Record<string, any> = {}, C = JSX.Element> = P & {
|
|
32
|
+
children: C;
|
|
33
|
+
};
|
|
34
|
+
/**
|
|
35
|
+
* `FlowComponent` requires a `children` prop with the specified type.
|
|
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 & {});
|
|
39
|
+
/**
|
|
40
|
+
* Takes the props of the passed component and returns its type
|
|
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>;
|
|
43
|
+
/**
|
|
44
|
+
* Type of `props.ref`, for use in `Component` or `props` typing.
|
|
45
|
+
*/
|
|
46
|
+
export type Ref<T> = T | ((val: T) => void);
|
|
47
|
+
/**
|
|
48
|
+
* Creates a component. On server, just calls the function directly (no untrack needed).
|
|
49
|
+
*/
|
|
50
|
+
export declare function createComponent<T extends Record<string, any>>(Comp: Component<T>, props: T): JSX.Element;
|
|
51
|
+
/**
|
|
52
|
+
* Lazy load a function component asynchronously.
|
|
53
|
+
* On server, returns a createMemo that throws NotReadyError until the module resolves,
|
|
54
|
+
* allowing resolveSSRNode to capture it as a fine-grained hole. The memo naturally
|
|
55
|
+
* scopes the owner so hydration IDs align with the client's createMemo in lazy().
|
|
56
|
+
* Requires `moduleUrl` for SSR — the bundler plugin injects the module specifier
|
|
57
|
+
* so the server can look up client chunk URLs from the asset manifest.
|
|
58
|
+
*/
|
|
59
|
+
export declare function lazy<T extends Component<any>>(fn: () => Promise<{
|
|
60
|
+
default: T;
|
|
61
|
+
}>, moduleUrl?: string): T & {
|
|
62
|
+
preload: () => Promise<{
|
|
63
|
+
default: T;
|
|
64
|
+
}>;
|
|
65
|
+
};
|
|
66
|
+
export declare function createUniqueId(): string;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { Accessor, EffectOptions } from "./signals.js";
|
|
2
|
+
import type { JSX } from "../jsx.js";
|
|
3
|
+
import type { FlowComponent } from "./component.js";
|
|
4
|
+
export declare const $DEVCOMP: unique symbol;
|
|
5
|
+
export type NoInfer<T extends any> = [T][T extends any ? 0 : never];
|
|
6
|
+
export type ContextProviderComponent<T> = FlowComponent<{
|
|
7
|
+
value: T;
|
|
8
|
+
}>;
|
|
9
|
+
export interface Context<T> extends ContextProviderComponent<T> {
|
|
10
|
+
id: symbol;
|
|
11
|
+
defaultValue: T;
|
|
12
|
+
}
|
|
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
|
|
16
|
+
* @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
|
+
*/
|
|
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>;
|
|
21
|
+
/**
|
|
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
|
|
25
|
+
*/
|
|
26
|
+
export declare function useContext<T>(context: Context<T>): T;
|
|
27
|
+
export type ResolvedJSXElement = Exclude<JSX.Element, JSX.ArrayElement>;
|
|
28
|
+
export type ResolvedChildren = ResolvedJSXElement | ResolvedJSXElement[];
|
|
29
|
+
export type ChildrenReturn = Accessor<ResolvedChildren> & {
|
|
30
|
+
toArray: () => ResolvedJSXElement[];
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Resolves child elements to help interact with children
|
|
34
|
+
* @param fn an accessor for the children
|
|
35
|
+
* @returns a accessor of the same children, but resolved
|
|
36
|
+
*/
|
|
37
|
+
export declare function children(fn: Accessor<JSX.Element>): ChildrenReturn;
|
|
38
|
+
/**
|
|
39
|
+
* Runs functions with an isolated owner scope for SSR.
|
|
40
|
+
* Used by dom-expressions to run event handlers and other code in scope.
|
|
41
|
+
*/
|
|
42
|
+
export declare function ssrRunInScope(fn: () => any): () => any;
|
|
43
|
+
export declare function ssrRunInScope(array: (() => any)[]): (() => any)[];
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { Accessor } from "./signals.js";
|
|
2
|
+
import type { JSX } from "../jsx.js";
|
|
3
|
+
/**
|
|
4
|
+
* Creates a list of elements from a list
|
|
5
|
+
*
|
|
6
|
+
* @description https://docs.solidjs.com/reference/components/for
|
|
7
|
+
*/
|
|
8
|
+
export declare function For<T extends readonly any[], U extends JSX.Element>(props: {
|
|
9
|
+
each: T | undefined | null | false;
|
|
10
|
+
fallback?: JSX.Element;
|
|
11
|
+
keyed?: boolean | ((item: T[number]) => any);
|
|
12
|
+
children: (item: Accessor<T[number]>, index: Accessor<number>) => U;
|
|
13
|
+
}): JSX.Element;
|
|
14
|
+
/**
|
|
15
|
+
* Creates a list elements from a count
|
|
16
|
+
*
|
|
17
|
+
* @description https://docs.solidjs.com/reference/components/repeat
|
|
18
|
+
*/
|
|
19
|
+
export declare function Repeat<T extends JSX.Element>(props: {
|
|
20
|
+
count: number;
|
|
21
|
+
from?: number | undefined;
|
|
22
|
+
fallback?: JSX.Element;
|
|
23
|
+
children: ((index: number) => T) | T;
|
|
24
|
+
}): JSX.Element;
|
|
25
|
+
/**
|
|
26
|
+
* Conditionally render its children or an optional fallback component
|
|
27
|
+
* @description https://docs.solidjs.com/reference/components/show
|
|
28
|
+
*/
|
|
29
|
+
export declare function Show<T>(props: {
|
|
30
|
+
when: T | undefined | null | false;
|
|
31
|
+
keyed?: boolean;
|
|
32
|
+
fallback?: JSX.Element;
|
|
33
|
+
children: JSX.Element | ((item: Accessor<NonNullable<T>>) => JSX.Element);
|
|
34
|
+
}): JSX.Element;
|
|
35
|
+
/**
|
|
36
|
+
* Switches between content based on mutually exclusive conditions
|
|
37
|
+
* @description https://docs.solidjs.com/reference/components/switch-and-match
|
|
38
|
+
*/
|
|
39
|
+
export declare function Switch(props: {
|
|
40
|
+
fallback?: JSX.Element;
|
|
41
|
+
children: JSX.Element;
|
|
42
|
+
}): JSX.Element;
|
|
43
|
+
export type MatchProps<T> = {
|
|
44
|
+
when: T | undefined | null | false;
|
|
45
|
+
keyed?: boolean;
|
|
46
|
+
children: JSX.Element | ((item: Accessor<NonNullable<T>>) => JSX.Element);
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Selects a content based on condition when inside a `<Switch>` control flow
|
|
50
|
+
* @description https://docs.solidjs.com/reference/components/switch-and-match
|
|
51
|
+
*/
|
|
52
|
+
export declare function Match<T>(props: MatchProps<T>): JSX.Element;
|
|
53
|
+
/**
|
|
54
|
+
* Catches uncaught errors inside components and renders a fallback content
|
|
55
|
+
* @description https://docs.solidjs.com/reference/components/error-boundary
|
|
56
|
+
*/
|
|
57
|
+
export declare function Errored(props: {
|
|
58
|
+
fallback: JSX.Element | ((err: any, reset: () => void) => JSX.Element);
|
|
59
|
+
children: JSX.Element;
|
|
60
|
+
}): JSX.Element;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { JSX } from "../jsx.js";
|
|
2
|
+
export { sharedConfig } from "./shared.js";
|
|
3
|
+
export type { HydrationContext } from "./shared.js";
|
|
4
|
+
/**
|
|
5
|
+
* Handles errors during SSR rendering.
|
|
6
|
+
* Returns the promise source for NotReadyError (for async handling),
|
|
7
|
+
* or delegates to the ErrorContext handler.
|
|
8
|
+
*/
|
|
9
|
+
export declare function ssrHandleError(err: any): Promise<any> | undefined;
|
|
10
|
+
/**
|
|
11
|
+
* Tracks all resources inside a component and renders a fallback until they are all resolved
|
|
12
|
+
*
|
|
13
|
+
* On the server, this is SSR-aware: it handles async mode (streaming) by registering
|
|
14
|
+
* fragments and resolving asynchronously, and sync mode by serializing fallback markers.
|
|
15
|
+
*
|
|
16
|
+
* @description https://docs.solidjs.com/reference/components/suspense
|
|
17
|
+
*/
|
|
18
|
+
export declare function Loading(props: {
|
|
19
|
+
fallback?: JSX.Element;
|
|
20
|
+
children: JSX.Element;
|
|
21
|
+
}): JSX.Element;
|
package/types/server/index.d.ts
CHANGED
|
@@ -1 +1,12 @@
|
|
|
1
|
-
export {};
|
|
1
|
+
export { $PROXY, $TRACK, action, createEffect, createMemo, createOptimistic, createOptimisticStore, createProjection, createReaction, createRenderEffect, createRoot, createSignal, createStore, createTrackedEffect, deep, flatten, flush, getObserver, getOwner, isEqual, isRefreshing, isPending, isWrappable, mapArray, merge, omit, onCleanup, onSettled, pending, reconcile, refresh, repeat, resolve, NotReadyError, runWithOwner, snapshot, createDeepProxy, untrack } from "./signals.js";
|
|
2
|
+
export type { Accessor, ComputeFunction, EffectFunction, EffectOptions, Merge, NoInfer, NotWrappable, Omit, Owner, Signal, SignalOptions, Setter, Store, SolidStore, StoreNode, StoreSetter, 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";
|
|
5
|
+
export * from "./component.js";
|
|
6
|
+
export * from "./flow.js";
|
|
7
|
+
export { sharedConfig, Loading, ssrHandleError } from "./hydration.js";
|
|
8
|
+
export type { HydrationContext } from "./hydration.js";
|
|
9
|
+
import type { JSX } from "../jsx.js";
|
|
10
|
+
type JSXElement = JSX.Element;
|
|
11
|
+
export type { JSXElement, JSX };
|
|
12
|
+
export declare const DEV: undefined;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
type SSRTemplateObject = {
|
|
2
|
+
t: string[];
|
|
3
|
+
h: Function[];
|
|
4
|
+
p: Promise<any>[];
|
|
5
|
+
};
|
|
6
|
+
export type HydrationContext = {
|
|
7
|
+
id: string;
|
|
8
|
+
count: number;
|
|
9
|
+
/**
|
|
10
|
+
* Serialize a value for client hydration.
|
|
11
|
+
* In renderToStream (async: true), accepts promises and async iterables.
|
|
12
|
+
* In renderToString (async: false), only synchronous values are allowed —
|
|
13
|
+
* passing async values will throw.
|
|
14
|
+
*/
|
|
15
|
+
serialize: (id: string, v: any, deferStream?: boolean) => void;
|
|
16
|
+
resolve(value: any): SSRTemplateObject;
|
|
17
|
+
ssr(template: string[], ...values: any[]): SSRTemplateObject;
|
|
18
|
+
escape(value: any): string;
|
|
19
|
+
replace: (id: string, replacement: () => any) => void;
|
|
20
|
+
block: (p: Promise<any>) => void;
|
|
21
|
+
registerFragment: (v: string) => (v?: string, err?: any) => boolean;
|
|
22
|
+
/** Register a client-side asset URL discovered during SSR (e.g. from lazy()). */
|
|
23
|
+
registerAsset?: (type: "module" | "style", url: string) => void;
|
|
24
|
+
/** Register a moduleUrl-to-entryUrl mapping for the current boundary. */
|
|
25
|
+
registerModule?: (moduleUrl: string, entryUrl: string) => void;
|
|
26
|
+
/** Resolve a module's JS and CSS assets from the asset manifest. Set by dom-expressions. */
|
|
27
|
+
resolveAssets?: (moduleUrl: string) => {
|
|
28
|
+
js: string[];
|
|
29
|
+
css: string[];
|
|
30
|
+
} | null;
|
|
31
|
+
/** Retrieve the moduleUrl-to-entryUrl map for a boundary. */
|
|
32
|
+
getBoundaryModules?: (id: string) => Record<string, string> | null;
|
|
33
|
+
/** @internal Tracks which Loading boundary is currently rendering. Set by dom-expressions via applyAssetTracking(). */
|
|
34
|
+
_currentBoundaryId?: string | null;
|
|
35
|
+
assets: any[];
|
|
36
|
+
/** True only in renderToStream — enables async data serialization and streaming. */
|
|
37
|
+
async?: boolean;
|
|
38
|
+
noHydrate: boolean;
|
|
39
|
+
};
|
|
40
|
+
type SharedConfig = {
|
|
41
|
+
context?: HydrationContext;
|
|
42
|
+
getNextContextId(): string;
|
|
43
|
+
};
|
|
44
|
+
export declare const sharedConfig: SharedConfig;
|
|
45
|
+
export {};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
export { createRoot, createOwner, runWithOwner, getOwner, onCleanup, getNextChildId, createContext, setContext, getContext, NotReadyError, NoOwnerError, ContextNotFoundError, isEqual, isWrappable, SUPPORTS_PROXY } from "@solidjs/signals";
|
|
2
|
+
export { flatten } from "@solidjs/signals";
|
|
3
|
+
export { snapshot, merge, omit, $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 } from "@solidjs/signals";
|
|
5
|
+
import type { Accessor, ComputeFunction, EffectFunction, EffectBundle, EffectOptions, MemoOptions, SignalOptions, Signal, Owner, Store, StoreSetter, Context } from "@solidjs/signals";
|
|
6
|
+
interface ServerComputation<T = any> {
|
|
7
|
+
owner: Owner;
|
|
8
|
+
value: T;
|
|
9
|
+
compute: ComputeFunction<any, T>;
|
|
10
|
+
error: unknown;
|
|
11
|
+
computed: boolean;
|
|
12
|
+
disposed: boolean;
|
|
13
|
+
}
|
|
14
|
+
export declare function getObserver(): ServerComputation<any> | null;
|
|
15
|
+
export declare function createSignal<T>(): Signal<T | undefined>;
|
|
16
|
+
export declare function createSignal<T>(value: Exclude<T, Function>, options?: SignalOptions<T>): Signal<T>;
|
|
17
|
+
export declare function createSignal<T>(fn: ComputeFunction<T>, initialValue?: T, options?: SignalOptions<T>): Signal<T>;
|
|
18
|
+
export declare function createMemo<Next extends Prev, Prev = Next>(compute: ComputeFunction<undefined | NoInfer<Prev>, Next>): Accessor<Next>;
|
|
19
|
+
export declare function createMemo<Next extends Prev, Init = Next, Prev = Next>(compute: ComputeFunction<Init | Prev, Next>, value: Init, options?: MemoOptions<Next>): Accessor<Next>;
|
|
20
|
+
export type PatchOp = [path: PropertyKey[]] | [path: PropertyKey[], value: any] | [path: PropertyKey[], value: any, insert: 1];
|
|
21
|
+
export declare function createDeepProxy<T extends object>(target: T, patches: PatchOp[], basePath?: PropertyKey[]): T;
|
|
22
|
+
export declare function createEffect<Next>(compute: ComputeFunction<undefined | NoInfer<Next>, Next>, effectFn: EffectFunction<NoInfer<Next>, Next> | EffectBundle<NoInfer<Next>, Next>): void;
|
|
23
|
+
export declare function createEffect<Next, Init = Next>(compute: ComputeFunction<Init | Next, Next>, effect: EffectFunction<Next, Next> | EffectBundle<Next, Next>, value: Init, options?: EffectOptions): void;
|
|
24
|
+
export declare function createRenderEffect<Next>(compute: ComputeFunction<undefined | NoInfer<Next>, Next>, effectFn: EffectFunction<NoInfer<Next>, Next>): void;
|
|
25
|
+
export declare function createRenderEffect<Next, Init = Next>(compute: ComputeFunction<Init | Next, Next>, effectFn: EffectFunction<Next, Next>, value: Init, options?: EffectOptions): void;
|
|
26
|
+
export declare function createTrackedEffect(compute: () => void | (() => void), options?: EffectOptions): void;
|
|
27
|
+
export declare function createReaction(effectFn: EffectFunction<undefined> | EffectBundle<undefined>, options?: EffectOptions): (tracking: () => void) => void;
|
|
28
|
+
export declare function createOptimistic<T>(): Signal<T | undefined>;
|
|
29
|
+
export declare function createOptimistic<T>(value: Exclude<T, Function>, options?: SignalOptions<T>): Signal<T>;
|
|
30
|
+
export declare function createOptimistic<T>(fn: ComputeFunction<T>, initialValue?: T, options?: SignalOptions<T>): Signal<T>;
|
|
31
|
+
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>];
|
|
32
|
+
export declare const createOptimisticStore: typeof createStore;
|
|
33
|
+
export declare function createProjection<T extends object>(fn: (draft: T) => void | T | Promise<void | T> | AsyncIterable<void | T>, initialValue?: T, options?: {
|
|
34
|
+
deferStream?: boolean;
|
|
35
|
+
ssrSource?: string;
|
|
36
|
+
}): Store<T>;
|
|
37
|
+
export declare function reconcile<T extends U, U extends object>(value: T): (state: U) => T;
|
|
38
|
+
export declare function deep<T extends object>(store: Store<T>): Store<T>;
|
|
39
|
+
export declare function mapArray<T, U>(list: Accessor<readonly T[] | undefined | null | false>, mapFn: (v: Accessor<T>, i: Accessor<number>) => U, options?: {
|
|
40
|
+
keyed?: boolean | ((item: T) => any);
|
|
41
|
+
fallback?: Accessor<any>;
|
|
42
|
+
}): () => U[];
|
|
43
|
+
export declare function repeat<T>(count: Accessor<number>, mapFn: (i: number) => T, options?: {
|
|
44
|
+
fallback?: Accessor<any>;
|
|
45
|
+
from?: Accessor<number | undefined>;
|
|
46
|
+
}): () => T[];
|
|
47
|
+
declare const ErrorContext: Context<((err: any) => void) | null>;
|
|
48
|
+
export { ErrorContext };
|
|
49
|
+
export declare function createErrorBoundary<U>(fn: () => any, fallback: (error: unknown, reset: () => void) => U): () => unknown;
|
|
50
|
+
export declare function createLoadBoundary(fn: () => any, fallback: () => any): () => unknown;
|
|
51
|
+
export declare function untrack<T>(fn: () => T): T;
|
|
52
|
+
export declare function flush(): void;
|
|
53
|
+
export declare function resolve<T>(fn: () => T): Promise<T>;
|
|
54
|
+
export declare function isPending(fn: () => any, fallback?: boolean): boolean;
|
|
55
|
+
export declare function pending<T>(fn: () => T): T;
|
|
56
|
+
export declare function isRefreshing(): boolean;
|
|
57
|
+
export declare function refresh<T>(fn: () => T): T;
|
|
58
|
+
export declare function action<T extends (...args: any[]) => any>(fn: T): T;
|
|
59
|
+
export declare function onSettled(callback: () => void | (() => void)): void;
|
|
60
|
+
type NoInfer<T extends any> = [T][T extends any ? 0 : never];
|
package/types/utilities.d.ts
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { Accessor, Signal, Store, StoreSetter } from "@solidjs/signals";
|
|
2
|
-
/**
|
|
3
|
-
* Runs the given function and returns a tuple with the result or an error.
|
|
4
|
-
* If the function throws an error, it will be caught and returned as the first element of the tuple.
|
|
5
|
-
* If the function returns a promise, it will resolve to a tuple with the result or an error.
|
|
6
|
-
*
|
|
7
|
-
* @param fn The function to run.
|
|
8
|
-
* @returns A tuple with either [undefined, result] or [error].
|
|
9
|
-
*
|
|
10
|
-
* @description https://docs.solidjs.com/reference/reactive-utilities/try-catch
|
|
11
|
-
*/
|
|
12
|
-
export type TryCatchResult<T, E> = [undefined, T] | [E];
|
|
13
|
-
export declare function tryCatch<T, E = Error>(fn: () => Promise<T>): Promise<TryCatchResult<T, E>>;
|
|
14
|
-
export declare function tryCatch<T, E = Error>(fn: () => T): TryCatchResult<T, E>;
|
|
15
|
-
/**
|
|
16
|
-
* Simple reducer utility for Signals and Stores
|
|
17
|
-
* ```typescript
|
|
18
|
-
* const [state, dispatch] = reducer(createSignal({ count: 0 }), (state, action) => {
|
|
19
|
-
* switch (action.type) {
|
|
20
|
-
* case "increment":
|
|
21
|
-
* return { count: state.count + 1 };
|
|
22
|
-
* case "decrement":
|
|
23
|
-
* return { count: state.count - 1 };
|
|
24
|
-
* default:
|
|
25
|
-
* return state;
|
|
26
|
-
* }
|
|
27
|
-
* });
|
|
28
|
-
* ```
|
|
29
|
-
* @param source Signal or Store tuple
|
|
30
|
-
* @param reducerFn reducer function that receives the current value and an action, and returns the new value for signals or void for stores
|
|
31
|
-
* @returns a tuple with the current value accessor and a dispatch function to send actions to the reducer
|
|
32
|
-
*
|
|
33
|
-
* @description https://docs.solidjs.com/reference/reactive-utilities/reducer
|
|
34
|
-
*/
|
|
35
|
-
export declare function reducer<T, A>(source: Signal<T>, reducerFn: (value: T, action: A) => T): [Accessor<T>, (action: A) => void];
|
|
36
|
-
export declare function reducer<T, A>(source: [Store<T>, StoreSetter<T>], reducerFn: (value: T, action: A) => T | void): [Store<T>, (action: A) => void];
|