solid-js 2.0.0-experimental.12 → 2.0.0-experimental.14

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/solid.js CHANGED
@@ -1,5 +1,5 @@
1
- import { getContext, createMemo, flatten, createRoot, setContext, NotReadyError, getOwner, getNextChildId, createLoadBoundary, createSignal, flush, runWithOwner, untrack, mapArray, repeat, createErrorBoundary, createBoundary } from '@solidjs/signals';
2
- export { $PROXY, $TRACK, createEffect, createMemo, createOptimistic, createOptimisticStore, createProjection, createReaction, createRenderEffect, createRoot, createSignal, createStore, createTrackedEffect, deep, flatten, flush, getObserver, getOwner, isEqual, isPending, isRefreshing, isWrappable, mapArray, merge, omit, onCleanup, onSettled, pending, reconcile, refresh, repeat, resolve, runWithOwner, snapshot, untrack } from '@solidjs/signals';
1
+ import { getContext, createMemo as createMemo$1, flatten, createRoot, setContext, getOwner, getNextChildId, createSignal as createSignal$1, createLoadBoundary, flush, runWithOwner, untrack, mapArray, repeat, createErrorBoundary } from '@solidjs/signals';
2
+ export { $PROXY, $TRACK, NotReadyError, action, createEffect, createOptimistic, createOptimisticStore, createProjection, createReaction, createRenderEffect, createRoot, createStore, createTrackedEffect, deep, flatten, flush, getObserver, getOwner, isEqual, isPending, isRefreshing, isWrappable, mapArray, merge, omit, onCleanup, onSettled, pending, reconcile, refresh, repeat, resolve, runWithOwner, snapshot, untrack } from '@solidjs/signals';
3
3
 
4
4
  const $DEVCOMP = Symbol(0);
5
5
  function createContext(defaultValue, options) {
@@ -18,8 +18,8 @@ function useContext(context) {
18
18
  return getContext(context);
19
19
  }
20
20
  function children(fn) {
21
- const children = createMemo(fn);
22
- const memo = createMemo(() => flatten(children()));
21
+ const children = createMemo$1(fn);
22
+ const memo = createMemo$1(() => flatten(children()));
23
23
  memo.toArray = () => {
24
24
  const c = memo();
25
25
  return Array.isArray(c) ? c : c != null ? [c] : [];
@@ -27,27 +27,6 @@ function children(fn) {
27
27
  return memo;
28
28
  }
29
29
 
30
- function tryCatch(fn) {
31
- try {
32
- const v = fn();
33
- if (v instanceof Promise) {
34
- return v.then(v => [undefined, v], e => {
35
- if (e instanceof NotReadyError) throw e;
36
- return [e];
37
- });
38
- }
39
- return [undefined, v];
40
- } catch (e) {
41
- if (e instanceof NotReadyError) throw e;
42
- return [e];
43
- }
44
- }
45
- function reducer(source, reducerFn) {
46
- return [source[0], action => {
47
- source[1](s => reducerFn(s, action));
48
- }];
49
- }
50
-
51
30
  const sharedConfig = {
52
31
  hydrating: false,
53
32
  registry: undefined,
@@ -58,19 +37,90 @@ const sharedConfig = {
58
37
  return getNextChildId(o);
59
38
  }
60
39
  };
40
+ let _createMemo;
41
+ let _createSignal;
42
+ class MockPromise {
43
+ static all() {
44
+ return new MockPromise();
45
+ }
46
+ static allSettled() {
47
+ return new MockPromise();
48
+ }
49
+ static any() {
50
+ return new MockPromise();
51
+ }
52
+ static race() {
53
+ return new MockPromise();
54
+ }
55
+ static reject() {
56
+ return new MockPromise();
57
+ }
58
+ static resolve() {
59
+ return new MockPromise();
60
+ }
61
+ catch() {
62
+ return new MockPromise();
63
+ }
64
+ then() {
65
+ return new MockPromise();
66
+ }
67
+ finally() {
68
+ return new MockPromise();
69
+ }
70
+ }
71
+ function subFetch(fn, prev) {
72
+ const ogFetch = fetch;
73
+ const ogPromise = Promise;
74
+ try {
75
+ window.fetch = () => new MockPromise();
76
+ Promise = MockPromise;
77
+ return fn(prev);
78
+ } finally {
79
+ window.fetch = ogFetch;
80
+ Promise = ogPromise;
81
+ }
82
+ }
83
+ function hydratedCreateMemo(compute, value, options) {
84
+ if (!sharedConfig.hydrating) return createMemo$1(compute, value, options);
85
+ return createMemo$1(prev => {
86
+ const o = getOwner();
87
+ if (!sharedConfig.hydrating) return compute(prev);
88
+ let initP;
89
+ if (sharedConfig.has(o.id)) initP = sharedConfig.load(o.id);
90
+ const init = initP?.v ?? initP;
91
+ return init != null ? (subFetch(compute, prev), init) : compute(prev);
92
+ }, value, options);
93
+ }
94
+ function hydratedCreateSignal(fn, second, third) {
95
+ if (typeof fn !== "function" || !sharedConfig.hydrating) return createSignal$1(fn, second, third);
96
+ return createSignal$1(prev => {
97
+ if (!sharedConfig.hydrating) return fn(prev);
98
+ const o = getOwner();
99
+ let initP;
100
+ if (sharedConfig.has(o.id)) initP = sharedConfig.load(o.id);
101
+ const init = initP?.v ?? initP;
102
+ return init != null ? (subFetch(fn, prev), init) : fn(prev);
103
+ }, second, third);
104
+ }
105
+ function enableHydration() {
106
+ _createMemo = hydratedCreateMemo;
107
+ _createSignal = hydratedCreateSignal;
108
+ }
109
+ const createMemo = (...args) => (_createMemo || createMemo$1)(...args);
110
+ const createSignal = (...args) => (_createSignal || createSignal$1)(...args);
61
111
  function Loading(props) {
62
112
  if (!sharedConfig.hydrating) return createLoadBoundary(() => props.children, () => props.fallback);
63
- return createMemo(() => {
113
+ return createMemo$1(() => {
64
114
  const o = getOwner();
65
115
  const id = o.id;
66
116
  if (sharedConfig.hydrating && sharedConfig.has(id)) {
67
117
  let ref = sharedConfig.load(id);
68
118
  let p;
69
119
  if (ref) {
70
- if (typeof ref !== "object" || ref.s !== "success") p = ref;else sharedConfig.gather(id);
120
+ if (typeof ref !== "object" || ref.s !== 1) p = ref;else sharedConfig.gather(id);
71
121
  }
72
122
  if (p) {
73
- const [s, set] = createSignal(undefined, {
123
+ const [s, set] = createSignal$1(undefined, {
74
124
  equals: false
75
125
  });
76
126
  s();
@@ -92,8 +142,6 @@ function Loading(props) {
92
142
  });
93
143
  }
94
144
 
95
- function enableHydration() {
96
- }
97
145
  function createComponent(Comp, props) {
98
146
  return untrack(() => Comp(props || {}));
99
147
  }
@@ -101,9 +149,9 @@ function lazy(fn) {
101
149
  let comp;
102
150
  let p;
103
151
  const wrap = props => {
104
- comp = createMemo(() => (p || (p = fn())).then(mod => mod.default));
152
+ comp = createMemo$1(() => (p || (p = fn())).then(mod => mod.default));
105
153
  let Comp;
106
- return createMemo(() => (Comp = comp()) ? untrack(() => {
154
+ return createMemo$1(() => (Comp = comp()) ? untrack(() => {
107
155
  return Comp(props);
108
156
  }) : "");
109
157
  };
@@ -134,11 +182,11 @@ function Repeat(props) {
134
182
  }
135
183
  function Show(props) {
136
184
  const keyed = props.keyed;
137
- const conditionValue = createMemo(() => props.when, undefined, undefined);
138
- const condition = keyed ? conditionValue : createMemo(conditionValue, undefined, {
185
+ const conditionValue = createMemo$1(() => props.when, undefined, undefined);
186
+ const condition = keyed ? conditionValue : createMemo$1(conditionValue, undefined, {
139
187
  equals: (a, b) => !a === !b
140
188
  });
141
- return createMemo(() => {
189
+ return createMemo$1(() => {
142
190
  const c = condition();
143
191
  if (c) {
144
192
  const child = props.children;
@@ -153,22 +201,22 @@ function Show(props) {
153
201
  }
154
202
  function Switch(props) {
155
203
  const chs = children(() => props.children);
156
- const switchFunc = createMemo(() => {
204
+ const switchFunc = createMemo$1(() => {
157
205
  const mps = chs.toArray();
158
206
  let func = () => undefined;
159
207
  for (let i = 0; i < mps.length; i++) {
160
208
  const index = i;
161
209
  const mp = mps[i];
162
210
  const prevFunc = func;
163
- const conditionValue = createMemo(() => prevFunc() ? undefined : mp.when, undefined, undefined);
164
- const condition = mp.keyed ? conditionValue : createMemo(conditionValue, undefined, {
211
+ const conditionValue = createMemo$1(() => prevFunc() ? undefined : mp.when, undefined, undefined);
212
+ const condition = mp.keyed ? conditionValue : createMemo$1(conditionValue, undefined, {
165
213
  equals: (a, b) => !a === !b
166
214
  });
167
215
  func = () => prevFunc() || (condition() ? [index, conditionValue, mp] : undefined);
168
216
  }
169
217
  return func;
170
218
  });
171
- return createMemo(() => {
219
+ return createMemo$1(() => {
172
220
  const sel = switchFunc()();
173
221
  if (!sel) return props.fallback;
174
222
  const [index, conditionValue, mp] = sel;
@@ -189,12 +237,9 @@ function Errored(props) {
189
237
  return typeof f === "function" && f.length ? f(err, reset) : f;
190
238
  });
191
239
  }
192
- function Boundary(props) {
193
- return createBoundary(() => props.children, () => props.mode);
194
- }
195
240
 
196
241
  function ssrHandleError() {}
197
242
  function ssrRunInScope() {}
198
243
  const DEV = undefined;
199
244
 
200
- export { $DEVCOMP, Boundary, DEV, Errored, For, Loading, Match, Repeat, Show, Switch, children, createComponent, createContext, createUniqueId, enableHydration, lazy, reducer, sharedConfig, ssrHandleError, ssrRunInScope, tryCatch, useContext };
245
+ export { $DEVCOMP, DEV, Errored, For, Loading, Match, Repeat, Show, Switch, children, createComponent, createContext, createMemo, createSignal, createUniqueId, enableHydration, lazy, sharedConfig, ssrHandleError, ssrRunInScope, useContext };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "solid-js",
3
3
  "description": "A declarative JavaScript library for building user interfaces.",
4
- "version": "2.0.0-experimental.12",
4
+ "version": "2.0.0-experimental.14",
5
5
  "author": "Ryan Carniato",
6
6
  "license": "MIT",
7
7
  "homepage": "https://solidjs.com",
@@ -79,10 +79,10 @@
79
79
  "performance"
80
80
  ],
81
81
  "dependencies": {
82
- "@solidjs/signals": "^0.9.0",
82
+ "@solidjs/signals": "^0.10.2",
83
83
  "csstype": "^3.1.0",
84
- "seroval": "~1.3.0",
85
- "seroval-plugins": "~1.3.0"
84
+ "seroval": "~1.5.0",
85
+ "seroval-plugins": "~1.5.0"
86
86
  },
87
87
  "scripts": {
88
88
  "build": "npm-run-all -nl build:*",
@@ -1,5 +1,4 @@
1
1
  import type { JSX } from "../jsx.js";
2
- export declare function enableHydration(): void;
3
2
  /**
4
3
  * A general `Component` has no implicit `children` prop. If desired, you can
5
4
  * specify one as in `Component<{name: String, children: JSX.Element}>`.
@@ -1,4 +1,4 @@
1
- import type { Accessor, BoundaryMode } from "@solidjs/signals";
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,6 @@
1
+ import { createMemo as coreMemo, createSignal as coreSignal } from "@solidjs/signals";
1
2
  import { JSX } from "../jsx.js";
3
+ export { createStore, createProjection, createOptimistic, createOptimisticStore } from "@solidjs/signals";
2
4
  export type HydrationContext = {};
3
5
  type SharedConfig = {
4
6
  hydrating: boolean;
@@ -13,6 +15,9 @@ type SharedConfig = {
13
15
  getNextContextId(): string;
14
16
  };
15
17
  export declare const sharedConfig: SharedConfig;
18
+ export declare function enableHydration(): void;
19
+ export declare const createMemo: typeof coreMemo;
20
+ export declare const createSignal: typeof coreSignal;
16
21
  /**
17
22
  * Tracks all resources inside a component and renders a fallback until they are all resolved
18
23
  * ```typescript
@@ -28,4 +33,3 @@ export declare function Loading(props: {
28
33
  fallback?: JSX.Element;
29
34
  children: JSX.Element;
30
35
  }): JSX.Element;
31
- export {};
package/types/index.d.ts CHANGED
@@ -1,11 +1,10 @@
1
- export { $PROXY, $TRACK, 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, runWithOwner, snapshot, untrack } from "@solidjs/signals";
2
- export type { Accessor, BoundaryMode, ComputeFunction, EffectFunction, EffectOptions, Merge, NoInfer, NotWrappable, Omit, Owner, Signal, SignalOptions, Setter, Store, SolidStore, StoreNode, StoreSetter } from "@solidjs/signals";
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,62 @@
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, caches the promise and throws NotReadyError if not yet loaded.
54
+ */
55
+ export declare function lazy<T extends Component<any>>(fn: () => Promise<{
56
+ default: T;
57
+ }>): T & {
58
+ preload: () => Promise<{
59
+ default: T;
60
+ }>;
61
+ };
62
+ 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;
@@ -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, untrack } from "./signals.js";
2
+ export type { Accessor, ComputeFunction, EffectFunction, EffectOptions, Merge, NoInfer, NotWrappable, Omit, Owner, Signal, SignalOptions, Setter, Store, SolidStore, StoreNode, StoreSetter } 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,24 @@
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
+ serialize: (id: string, v: Promise<any> | any, deferStream?: boolean) => void;
10
+ resolve(value: any): SSRTemplateObject;
11
+ ssr(template: string[], ...values: any[]): SSRTemplateObject;
12
+ escape(value: any): string;
13
+ replace: (id: string, replacement: () => any) => void;
14
+ block: (p: Promise<any>) => void;
15
+ registerFragment: (v: string) => (v?: string, err?: any) => boolean;
16
+ async?: boolean;
17
+ noHydrate: boolean;
18
+ };
19
+ type SharedConfig = {
20
+ context?: HydrationContext;
21
+ getNextContextId(): string;
22
+ };
23
+ export declare const sharedConfig: SharedConfig;
24
+ export {};
@@ -0,0 +1,54 @@
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
+ }
13
+ export declare function getObserver(): ServerComputation<any> | null;
14
+ export declare function createSignal<T>(): Signal<T | undefined>;
15
+ export declare function createSignal<T>(value: Exclude<T, Function>, options?: SignalOptions<T>): Signal<T>;
16
+ export declare function createSignal<T>(fn: ComputeFunction<T>, initialValue?: T, options?: SignalOptions<T>): Signal<T>;
17
+ export declare function createMemo<Next extends Prev, Prev = Next>(compute: ComputeFunction<undefined | NoInfer<Prev>, Next>): Accessor<Next>;
18
+ export declare function createMemo<Next extends Prev, Init = Next, Prev = Next>(compute: ComputeFunction<Init | Prev, Next>, value: Init, options?: MemoOptions<Next>): Accessor<Next>;
19
+ export declare function createEffect<Next>(compute: ComputeFunction<undefined | NoInfer<Next>, Next>, effectFn: EffectFunction<NoInfer<Next>, Next> | EffectBundle<NoInfer<Next>, Next>): void;
20
+ export declare function createEffect<Next, Init = Next>(compute: ComputeFunction<Init | Next, Next>, effect: EffectFunction<Next, Next> | EffectBundle<Next, Next>, value: Init, options?: EffectOptions): void;
21
+ export declare function createRenderEffect<Next>(compute: ComputeFunction<undefined | NoInfer<Next>, Next>, effectFn: EffectFunction<NoInfer<Next>, Next>): void;
22
+ export declare function createRenderEffect<Next, Init = Next>(compute: ComputeFunction<Init | Next, Next>, effectFn: EffectFunction<Next, Next>, value: Init, options?: EffectOptions): void;
23
+ export declare function createTrackedEffect(compute: () => void | (() => void), options?: EffectOptions): void;
24
+ export declare function createReaction(effectFn: EffectFunction<undefined> | EffectBundle<undefined>, options?: EffectOptions): (tracking: () => void) => void;
25
+ export declare function createOptimistic<T>(): Signal<T | undefined>;
26
+ export declare function createOptimistic<T>(value: Exclude<T, Function>, options?: SignalOptions<T>): Signal<T>;
27
+ export declare function createOptimistic<T>(fn: ComputeFunction<T>, initialValue?: T, options?: SignalOptions<T>): Signal<T>;
28
+ export declare function createStore<T extends object>(state: T | Store<T>): [get: Store<T>, set: StoreSetter<T>];
29
+ export declare const createOptimisticStore: typeof createStore;
30
+ export declare function createProjection<T extends object>(fn: (draft: T) => void, initialValue?: T): Store<T>;
31
+ export declare function reconcile<T extends U, U extends object>(value: T): (state: U) => T;
32
+ export declare function deep<T extends object>(store: Store<T>): Store<T>;
33
+ export declare function mapArray<T, U>(list: Accessor<readonly T[] | undefined | null | false>, mapFn: (v: Accessor<T>, i: Accessor<number>) => U, options?: {
34
+ keyed?: boolean | ((item: T) => any);
35
+ fallback?: Accessor<any>;
36
+ }): () => U[];
37
+ export declare function repeat<T>(count: Accessor<number>, mapFn: (i: number) => T, options?: {
38
+ fallback?: Accessor<any>;
39
+ from?: Accessor<number | undefined>;
40
+ }): () => T[];
41
+ declare const ErrorContext: Context<((err: any) => void) | null>;
42
+ export { ErrorContext };
43
+ export declare function createErrorBoundary<U>(fn: () => any, fallback: (error: unknown, reset: () => void) => U): () => unknown;
44
+ export declare function createLoadBoundary(fn: () => any, fallback: () => any): () => unknown;
45
+ export declare function untrack<T>(fn: () => T): T;
46
+ export declare function flush(): void;
47
+ export declare function resolve<T>(fn: () => T): Promise<T>;
48
+ export declare function isPending(fn: () => any, fallback?: boolean): boolean;
49
+ export declare function pending<T>(fn: () => T): T;
50
+ export declare function isRefreshing(): boolean;
51
+ export declare function refresh<T>(fn: () => T): T;
52
+ export declare function action<T extends (...args: any[]) => any>(fn: T): T;
53
+ export declare function onSettled(callback: () => void | (() => void)): void;
54
+ type NoInfer<T extends any> = [T][T extends any ? 0 : never];
@@ -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];