solid-js 2.0.0-experimental.1 → 2.0.0-experimental.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.
- package/LICENSE +1 -1
- package/dist/dev.cjs +197 -118
- package/dist/dev.js +161 -96
- package/dist/server.cjs +0 -825
- package/dist/server.js +0 -769
- package/dist/solid.cjs +191 -112
- package/dist/solid.js +155 -90
- package/package.json +5 -3
- package/types/client/component.d.ts +2 -2
- package/types/client/flow.d.ts +9 -19
- package/types/client/hydration.d.ts +38 -10
- package/types/client/observable.d.ts +4 -2
- package/types/index.d.ts +6 -3
- package/types/jsx.d.ts +1626 -1637
- package/types/server/index.d.ts +1 -4
- package/types/utilities.d.ts +36 -0
- package/types/server/reactive.d.ts +0 -98
- package/types/server/rendering.d.ts +0 -159
- package/types/server/store.d.ts +0 -6
package/dist/solid.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { createEffect, getContext, createMemo, flatten,
|
|
2
|
-
export { $PROXY, $
|
|
1
|
+
import { createEffect, getContext, createMemo, flatten, createRoot, setContext, NotReadyError, getOwner, onCleanup, createSignal, getNextChildId, createLoadBoundary, flush, runWithOwner, createAsync as createAsync$1, 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, isWrappable, mapArray, merge, omit, onCleanup, onSettled, pending, reconcile, repeat, resolve, runWithOwner, snapshot, untrack } from '@solidjs/signals';
|
|
3
3
|
|
|
4
4
|
const $DEVCOMP = Symbol(0);
|
|
5
5
|
function onMount(fn) {
|
|
@@ -8,8 +8,8 @@ function onMount(fn) {
|
|
|
8
8
|
function createContext(defaultValue, options) {
|
|
9
9
|
const id = Symbol(options && options.name || "");
|
|
10
10
|
function provider(props) {
|
|
11
|
-
return
|
|
12
|
-
setContext(provider,
|
|
11
|
+
return createRoot(() => {
|
|
12
|
+
setContext(provider, props.value);
|
|
13
13
|
return children(() => props.children);
|
|
14
14
|
});
|
|
15
15
|
}
|
|
@@ -30,6 +30,27 @@ function children(fn) {
|
|
|
30
30
|
return memo;
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
+
function tryCatch(fn) {
|
|
34
|
+
try {
|
|
35
|
+
const v = fn();
|
|
36
|
+
if (v instanceof Promise) {
|
|
37
|
+
return v.then(v => [undefined, v], e => {
|
|
38
|
+
if (e instanceof NotReadyError) throw e;
|
|
39
|
+
return [e];
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
return [undefined, v];
|
|
43
|
+
} catch (e) {
|
|
44
|
+
if (e instanceof NotReadyError) throw e;
|
|
45
|
+
return [e];
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
function reducer(source, reducerFn) {
|
|
49
|
+
return [source[0], action => {
|
|
50
|
+
source[1](s => reducerFn(s, action));
|
|
51
|
+
}];
|
|
52
|
+
}
|
|
53
|
+
|
|
33
54
|
function observable(input) {
|
|
34
55
|
return {
|
|
35
56
|
subscribe(observer) {
|
|
@@ -60,8 +81,8 @@ function observable(input) {
|
|
|
60
81
|
}
|
|
61
82
|
};
|
|
62
83
|
}
|
|
63
|
-
function from(producer) {
|
|
64
|
-
const [s, set] = createSignal(
|
|
84
|
+
function from(producer, initialValue = undefined) {
|
|
85
|
+
const [s, set] = createSignal(() => initialValue, initialValue, {
|
|
65
86
|
equals: false
|
|
66
87
|
});
|
|
67
88
|
if ("subscribe" in producer) {
|
|
@@ -75,76 +96,117 @@ function from(producer) {
|
|
|
75
96
|
}
|
|
76
97
|
|
|
77
98
|
const sharedConfig = {
|
|
78
|
-
|
|
99
|
+
hydrating: false,
|
|
79
100
|
registry: undefined,
|
|
80
101
|
done: false,
|
|
81
|
-
getContextId() {
|
|
82
|
-
return getContextId(this.context.count);
|
|
83
|
-
},
|
|
84
102
|
getNextContextId() {
|
|
85
|
-
|
|
103
|
+
const o = getOwner();
|
|
104
|
+
if (!o) throw new Error(`getNextContextId cannot be used under non-hydrating context`);
|
|
105
|
+
return getNextChildId(o);
|
|
86
106
|
}
|
|
87
107
|
};
|
|
88
|
-
function
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
108
|
+
function Loading(props) {
|
|
109
|
+
if (!sharedConfig.hydrating) return createLoadBoundary(() => props.children, () => props.fallback);
|
|
110
|
+
return createMemo(() => {
|
|
111
|
+
const o = getOwner();
|
|
112
|
+
const id = o.id;
|
|
113
|
+
if (sharedConfig.hydrating && sharedConfig.has(id)) {
|
|
114
|
+
let ref = sharedConfig.load(id);
|
|
115
|
+
let p;
|
|
116
|
+
if (ref) {
|
|
117
|
+
if (typeof ref !== "object" || ref.s !== "success") p = ref;else sharedConfig.gather(id);
|
|
118
|
+
}
|
|
119
|
+
if (p) {
|
|
120
|
+
const [s, set] = createSignal(undefined, {
|
|
121
|
+
equals: false
|
|
122
|
+
});
|
|
123
|
+
s();
|
|
124
|
+
if (p !== "$$f") {
|
|
125
|
+
p.then(() => {
|
|
126
|
+
sharedConfig.gather(id);
|
|
127
|
+
sharedConfig.hydrating = true;
|
|
128
|
+
set();
|
|
129
|
+
flush();
|
|
130
|
+
sharedConfig.hydrating = false;
|
|
131
|
+
}, err => runWithOwner(o, () => {
|
|
132
|
+
throw err;
|
|
133
|
+
}));
|
|
134
|
+
} else queueMicrotask(set);
|
|
135
|
+
return props.fallback;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
return createLoadBoundary(() => props.children, () => props.fallback);
|
|
139
|
+
});
|
|
92
140
|
}
|
|
93
|
-
function
|
|
94
|
-
sharedConfig.
|
|
141
|
+
function createAsync(compute, value, options) {
|
|
142
|
+
if (!sharedConfig.hydrating) return createAsync$1(compute, value, options);
|
|
143
|
+
return createAsync$1(prev => {
|
|
144
|
+
if (!sharedConfig.hydrating) return compute(prev);
|
|
145
|
+
const o = getOwner();
|
|
146
|
+
let initP;
|
|
147
|
+
if (sharedConfig.has(o.id)) initP = sharedConfig.load(o.id);
|
|
148
|
+
const init = initP?.value || initP;
|
|
149
|
+
return init ? (subFetch(compute, prev), init) : compute(prev);
|
|
150
|
+
}, value, options);
|
|
95
151
|
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
152
|
+
class MockPromise {
|
|
153
|
+
static all() {
|
|
154
|
+
return new MockPromise();
|
|
155
|
+
}
|
|
156
|
+
static allSettled() {
|
|
157
|
+
return new MockPromise();
|
|
158
|
+
}
|
|
159
|
+
static any() {
|
|
160
|
+
return new MockPromise();
|
|
161
|
+
}
|
|
162
|
+
static race() {
|
|
163
|
+
return new MockPromise();
|
|
164
|
+
}
|
|
165
|
+
static reject() {
|
|
166
|
+
return new MockPromise();
|
|
167
|
+
}
|
|
168
|
+
static resolve() {
|
|
169
|
+
return new MockPromise();
|
|
170
|
+
}
|
|
171
|
+
catch() {
|
|
172
|
+
return new MockPromise();
|
|
173
|
+
}
|
|
174
|
+
then() {
|
|
175
|
+
return new MockPromise();
|
|
176
|
+
}
|
|
177
|
+
finally() {
|
|
178
|
+
return new MockPromise();
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
function subFetch(fn, prev) {
|
|
182
|
+
const ogFetch = fetch;
|
|
183
|
+
const ogPromise = Promise;
|
|
184
|
+
try {
|
|
185
|
+
window.fetch = () => new MockPromise();
|
|
186
|
+
Promise = MockPromise;
|
|
187
|
+
return fn(prev);
|
|
188
|
+
} finally {
|
|
189
|
+
window.fetch = ogFetch;
|
|
190
|
+
Promise = ogPromise;
|
|
191
|
+
}
|
|
102
192
|
}
|
|
103
193
|
|
|
104
|
-
let hydrationEnabled = false;
|
|
105
194
|
function enableHydration() {
|
|
106
|
-
hydrationEnabled = true;
|
|
107
195
|
}
|
|
108
196
|
function createComponent(Comp, props) {
|
|
109
|
-
if (hydrationEnabled) {
|
|
110
|
-
if (sharedConfig.context) {
|
|
111
|
-
const c = sharedConfig.context;
|
|
112
|
-
setHydrateContext(nextHydrateContext());
|
|
113
|
-
const r = untrack(() => Comp(props || {}));
|
|
114
|
-
setHydrateContext(c);
|
|
115
|
-
return r;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
197
|
return untrack(() => Comp(props || {}));
|
|
119
198
|
}
|
|
120
199
|
function lazy(fn) {
|
|
121
200
|
let comp;
|
|
122
201
|
let p;
|
|
123
202
|
const wrap = props => {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
const [s, set] = createSignal();
|
|
127
|
-
sharedConfig.count || (sharedConfig.count = 0);
|
|
128
|
-
sharedConfig.count++;
|
|
129
|
-
(p || (p = fn())).then(mod => {
|
|
130
|
-
!sharedConfig.done && setHydrateContext(ctx);
|
|
131
|
-
sharedConfig.count--;
|
|
132
|
-
set(() => mod.default);
|
|
133
|
-
setHydrateContext();
|
|
134
|
-
});
|
|
135
|
-
comp = s;
|
|
136
|
-
} else if (!comp) {
|
|
137
|
-
const s = createAsync(() => (p || (p = fn())).then(mod => mod.default));
|
|
203
|
+
if (!comp) {
|
|
204
|
+
const s = createAsync$1(() => (p || (p = fn())).then(mod => mod.default));
|
|
138
205
|
comp = s;
|
|
139
206
|
}
|
|
140
207
|
let Comp;
|
|
141
208
|
return createMemo(() => (Comp = comp()) ? untrack(() => {
|
|
142
|
-
|
|
143
|
-
const c = sharedConfig.context;
|
|
144
|
-
setHydrateContext(ctx);
|
|
145
|
-
const r = Comp(props);
|
|
146
|
-
setHydrateContext(c);
|
|
147
|
-
return r;
|
|
209
|
+
return Comp(props);
|
|
148
210
|
}) : "");
|
|
149
211
|
};
|
|
150
212
|
wrap.preload = () => p || ((p = fn()).then(mod => comp = () => mod.default), p);
|
|
@@ -152,8 +214,7 @@ function lazy(fn) {
|
|
|
152
214
|
}
|
|
153
215
|
let counter = 0;
|
|
154
216
|
function createUniqueId() {
|
|
155
|
-
|
|
156
|
-
return ctx ? sharedConfig.getNextContextId() : `cl-${counter++}`;
|
|
217
|
+
return sharedConfig.hydrating ? sharedConfig.getNextContextId() : `cl-${counter++}`;
|
|
157
218
|
}
|
|
158
219
|
|
|
159
220
|
const narrowedError = name => `Stale read from <${name}>.`;
|
|
@@ -164,18 +225,20 @@ function For(props) {
|
|
|
164
225
|
} : {
|
|
165
226
|
keyed: props.keyed
|
|
166
227
|
};
|
|
167
|
-
return
|
|
228
|
+
return mapArray(() => props.each, props.children, options);
|
|
168
229
|
}
|
|
169
230
|
function Repeat(props) {
|
|
170
231
|
const options = "fallback" in props ? {
|
|
171
232
|
fallback: () => props.fallback
|
|
172
233
|
} : {};
|
|
173
|
-
|
|
234
|
+
options.from = () => props.from;
|
|
235
|
+
return repeat(() => props.count, index => typeof props.children === "function" ? props.children(index) : props.children, options);
|
|
174
236
|
}
|
|
175
237
|
function Show(props) {
|
|
176
238
|
const keyed = props.keyed;
|
|
177
|
-
const
|
|
178
|
-
|
|
239
|
+
const conditionValue = createMemo(() => props.when, undefined, undefined);
|
|
240
|
+
const condition = keyed ? conditionValue : createMemo(conditionValue, undefined, {
|
|
241
|
+
equals: (a, b) => !a === !b
|
|
179
242
|
});
|
|
180
243
|
return createMemo(() => {
|
|
181
244
|
const c = condition();
|
|
@@ -184,54 +247,56 @@ function Show(props) {
|
|
|
184
247
|
const fn = typeof child === "function" && child.length > 0;
|
|
185
248
|
return fn ? untrack(() => child(() => {
|
|
186
249
|
if (!untrack(condition)) throw narrowedError("Show");
|
|
187
|
-
return
|
|
250
|
+
return conditionValue();
|
|
188
251
|
})) : child;
|
|
189
252
|
}
|
|
190
253
|
return props.fallback;
|
|
191
254
|
}, undefined, undefined);
|
|
192
255
|
}
|
|
193
256
|
function Switch(props) {
|
|
194
|
-
|
|
195
|
-
const
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
});
|
|
257
|
+
const chs = children(() => props.children);
|
|
258
|
+
const switchFunc = createMemo(() => {
|
|
259
|
+
const mps = chs.toArray();
|
|
260
|
+
let func = () => undefined;
|
|
261
|
+
for (let i = 0; i < mps.length; i++) {
|
|
262
|
+
const index = i;
|
|
263
|
+
const mp = mps[i];
|
|
264
|
+
const prevFunc = func;
|
|
265
|
+
const conditionValue = createMemo(() => prevFunc() ? undefined : mp.when, undefined, undefined);
|
|
266
|
+
const condition = mp.keyed ? conditionValue : createMemo(conditionValue, undefined, {
|
|
267
|
+
equals: (a, b) => !a === !b
|
|
268
|
+
});
|
|
269
|
+
func = () => prevFunc() || (condition() ? [index, conditionValue, mp] : undefined);
|
|
270
|
+
}
|
|
271
|
+
return func;
|
|
272
|
+
});
|
|
211
273
|
return createMemo(() => {
|
|
212
|
-
const
|
|
213
|
-
if (
|
|
214
|
-
const
|
|
215
|
-
const
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
274
|
+
const sel = switchFunc()();
|
|
275
|
+
if (!sel) return props.fallback;
|
|
276
|
+
const [index, conditionValue, mp] = sel;
|
|
277
|
+
const child = mp.children;
|
|
278
|
+
const fn = typeof child === "function" && child.length > 0;
|
|
279
|
+
return fn ? untrack(() => child(() => {
|
|
280
|
+
if (untrack(switchFunc)()?.[0] !== index) throw narrowedError("Match");
|
|
281
|
+
return conditionValue();
|
|
282
|
+
})) : child;
|
|
220
283
|
}, undefined, undefined);
|
|
221
284
|
}
|
|
222
285
|
function Match(props) {
|
|
223
286
|
return props;
|
|
224
287
|
}
|
|
225
|
-
function
|
|
288
|
+
function Errored(props) {
|
|
226
289
|
return createErrorBoundary(() => props.children, (err, reset) => {
|
|
227
290
|
const f = props.fallback;
|
|
228
291
|
return typeof f === "function" && f.length ? f(err, reset) : f;
|
|
229
292
|
});
|
|
230
293
|
}
|
|
231
|
-
function
|
|
232
|
-
return
|
|
294
|
+
function Boundary(props) {
|
|
295
|
+
return createBoundary(() => props.children, () => props.mode);
|
|
233
296
|
}
|
|
234
297
|
|
|
298
|
+
function ssrHandleError() {}
|
|
299
|
+
function ssrRunInScope() {}
|
|
235
300
|
const DEV = undefined;
|
|
236
301
|
|
|
237
|
-
export { $DEVCOMP, DEV,
|
|
302
|
+
export { $DEVCOMP, Boundary, DEV, Errored, For, Loading, Match, Repeat, Show, Switch, children, createAsync, createComponent, createContext, createUniqueId, enableHydration, from, lazy, observable, onMount, reducer, sharedConfig, ssrHandleError, ssrRunInScope, tryCatch, 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.
|
|
4
|
+
"version": "2.0.0-experimental.11",
|
|
5
5
|
"author": "Ryan Carniato",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"homepage": "https://solidjs.com",
|
|
@@ -79,8 +79,10 @@
|
|
|
79
79
|
"performance"
|
|
80
80
|
],
|
|
81
81
|
"dependencies": {
|
|
82
|
-
"@solidjs/signals": "^0.
|
|
83
|
-
"csstype": "^3.1.0"
|
|
82
|
+
"@solidjs/signals": "^0.8.0",
|
|
83
|
+
"csstype": "^3.1.0",
|
|
84
|
+
"seroval": "~1.3.0",
|
|
85
|
+
"seroval-plugins": "~1.3.0"
|
|
84
86
|
},
|
|
85
87
|
"scripts": {
|
|
86
88
|
"build": "npm-run-all -nl build:*",
|
|
@@ -21,7 +21,7 @@ export type VoidProps<P extends Record<string, any> = {}> = P & {
|
|
|
21
21
|
export type VoidComponent<P extends Record<string, any> = {}> = Component<VoidProps<P>>;
|
|
22
22
|
/**
|
|
23
23
|
* Extend props to allow an optional `children` prop with the usual
|
|
24
|
-
* type in JSX, `JSX.Element` (which allows elements, arrays,
|
|
24
|
+
* type in JSX, `JSX.Element` (which allows elements, arrays, strings, etc.).
|
|
25
25
|
* Use this for components that you want to accept children.
|
|
26
26
|
*/
|
|
27
27
|
export type ParentProps<P extends Record<string, any> = {}> = P & {
|
|
@@ -29,7 +29,7 @@ export type ParentProps<P extends Record<string, any> = {}> = P & {
|
|
|
29
29
|
};
|
|
30
30
|
/**
|
|
31
31
|
* `ParentComponent` allows an optional `children` prop with the usual
|
|
32
|
-
* type in JSX, `JSX.Element` (which allows elements, arrays,
|
|
32
|
+
* type in JSX, `JSX.Element` (which allows elements, arrays, strings, etc.).
|
|
33
33
|
* Use this for components that you want to accept children.
|
|
34
34
|
*/
|
|
35
35
|
export type ParentComponent<P extends Record<string, any> = {}> = Component<ParentProps<P>>;
|
package/types/client/flow.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Accessor } from "@solidjs/signals";
|
|
1
|
+
import type { Accessor, BoundaryMode } from "@solidjs/signals";
|
|
2
2
|
import type { JSX } from "../jsx.js";
|
|
3
3
|
/**
|
|
4
4
|
* Creates a list of elements from a list
|
|
@@ -15,7 +15,7 @@ import type { JSX } from "../jsx.js";
|
|
|
15
15
|
export declare function For<T extends readonly any[], U extends JSX.Element>(props: {
|
|
16
16
|
each: T | undefined | null | false;
|
|
17
17
|
fallback?: JSX.Element;
|
|
18
|
-
keyed?: boolean | ((item: T) => any);
|
|
18
|
+
keyed?: boolean | ((item: T[number]) => any);
|
|
19
19
|
children: (item: Accessor<T[number]>, index: Accessor<number>) => U;
|
|
20
20
|
}): JSX.Element;
|
|
21
21
|
/**
|
|
@@ -32,6 +32,7 @@ export declare function For<T extends readonly any[], U extends JSX.Element>(pro
|
|
|
32
32
|
*/
|
|
33
33
|
export declare function Repeat<T extends JSX.Element>(props: {
|
|
34
34
|
count: number;
|
|
35
|
+
from?: number | undefined;
|
|
35
36
|
fallback?: JSX.Element;
|
|
36
37
|
children: ((index: number) => T) | T;
|
|
37
38
|
}): JSX.Element;
|
|
@@ -83,32 +84,21 @@ export declare function Match<T>(props: MatchProps<T>): JSX.Element;
|
|
|
83
84
|
*
|
|
84
85
|
* Also supports a callback form that passes the error and a reset function:
|
|
85
86
|
* ```typescript
|
|
86
|
-
* <
|
|
87
|
+
* <Errored fallback={
|
|
87
88
|
* (err, reset) => <div onClick={reset}>Error: {err.toString()}</div>
|
|
88
89
|
* }>
|
|
89
90
|
* <MyComp />
|
|
90
|
-
* </
|
|
91
|
+
* </Errored>
|
|
91
92
|
* ```
|
|
92
|
-
* Errors thrown from the fallback can be caught by a parent
|
|
93
|
+
* Errors thrown from the fallback can be caught by a parent Errored
|
|
93
94
|
*
|
|
94
95
|
* @description https://docs.solidjs.com/reference/components/error-boundary
|
|
95
96
|
*/
|
|
96
|
-
export declare function
|
|
97
|
+
export declare function Errored(props: {
|
|
97
98
|
fallback: JSX.Element | ((err: any, reset: () => void) => JSX.Element);
|
|
98
99
|
children: JSX.Element;
|
|
99
100
|
}): JSX.Element;
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
* ```typescript
|
|
103
|
-
* const AsyncComponent = lazy(() => import('./component'));
|
|
104
|
-
*
|
|
105
|
-
* <Suspense fallback={<LoadingIndicator />}>
|
|
106
|
-
* <AsyncComponent />
|
|
107
|
-
* </Suspense>
|
|
108
|
-
* ```
|
|
109
|
-
* @description https://docs.solidjs.com/reference/components/suspense
|
|
110
|
-
*/
|
|
111
|
-
export declare function Suspense(props: {
|
|
112
|
-
fallback?: JSX.Element;
|
|
101
|
+
export declare function Boundary(props: {
|
|
102
|
+
mode: BoundaryMode;
|
|
113
103
|
children: JSX.Element;
|
|
114
104
|
}): JSX.Element;
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
1
|
+
import { MemoOptions } from "@solidjs/signals";
|
|
2
|
+
import { JSX } from "../jsx.js";
|
|
3
|
+
export type HydrationContext = {};
|
|
5
4
|
type SharedConfig = {
|
|
6
|
-
|
|
5
|
+
hydrating: boolean;
|
|
7
6
|
resources?: {
|
|
8
7
|
[key: string]: any;
|
|
9
8
|
};
|
|
@@ -11,12 +10,41 @@ type SharedConfig = {
|
|
|
11
10
|
has?: (id: string) => boolean;
|
|
12
11
|
gather?: (key: string) => void;
|
|
13
12
|
registry?: Map<string, Element>;
|
|
14
|
-
done
|
|
15
|
-
count?: number;
|
|
16
|
-
getContextId(): string;
|
|
13
|
+
done: boolean;
|
|
17
14
|
getNextContextId(): string;
|
|
18
15
|
};
|
|
19
16
|
export declare const sharedConfig: SharedConfig;
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
/**
|
|
18
|
+
* Tracks all resources inside a component and renders a fallback until they are all resolved
|
|
19
|
+
* ```typescript
|
|
20
|
+
* const AsyncComponent = lazy(() => import('./component'));
|
|
21
|
+
*
|
|
22
|
+
* <Loading fallback={<LoadingIndicator />}>
|
|
23
|
+
* <AsyncComponent />
|
|
24
|
+
* </Loading>
|
|
25
|
+
* ```
|
|
26
|
+
* @description https://docs.solidjs.com/reference/components/suspense
|
|
27
|
+
*/
|
|
28
|
+
export declare function Loading(props: {
|
|
29
|
+
fallback?: JSX.Element;
|
|
30
|
+
children: JSX.Element;
|
|
31
|
+
}): JSX.Element;
|
|
32
|
+
/**
|
|
33
|
+
* Creates a readonly derived async reactive memoized signal
|
|
34
|
+
* ```typescript
|
|
35
|
+
* export function createAsync<T>(
|
|
36
|
+
* compute: (v: T) => Promise<T> | T,
|
|
37
|
+
* value?: T,
|
|
38
|
+
* options?: { name?: string, equals?: false | ((prev: T, next: T) => boolean) }
|
|
39
|
+
* ): () => T & { refresh: () => void };
|
|
40
|
+
* ```
|
|
41
|
+
* @param compute a function that receives its previous or the initial value, if set, and returns a new value used to react on a computation
|
|
42
|
+
* @param value an optional initial value for the computation; if set, fn will never receive undefined as first argument
|
|
43
|
+
* @param options allows to set a name in dev mode for debugging purposes and use a custom comparison function in equals
|
|
44
|
+
*
|
|
45
|
+
* @description https://docs.solidjs.com/reference/basic-reactivity/create-async
|
|
46
|
+
*/
|
|
47
|
+
export declare function createAsync<T>(compute: (prev?: T) => Promise<T> | AsyncIterable<T> | T, value?: T, options?: MemoOptions<T>): import("@solidjs/signals").Accessor<T> & {
|
|
48
|
+
refresh: () => void;
|
|
49
|
+
};
|
|
22
50
|
export {};
|
|
@@ -26,9 +26,11 @@ export type ObservableObserver<T> = ((v: T) => void) | {
|
|
|
26
26
|
* description https://docs.solidjs.com/reference/reactive-utilities/observable
|
|
27
27
|
*/
|
|
28
28
|
export declare function observable<T>(input: Accessor<T>): Observable<T>;
|
|
29
|
-
|
|
29
|
+
type Producer<T> = ((setter: Setter<T>) => () => void) | {
|
|
30
30
|
subscribe: (fn: (v: T) => void) => (() => void) | {
|
|
31
31
|
unsubscribe: () => void;
|
|
32
32
|
};
|
|
33
|
-
}
|
|
33
|
+
};
|
|
34
|
+
export declare function from<T>(producer: Producer<T>, initalValue: T): Accessor<T>;
|
|
35
|
+
export declare function from<T>(producer: Producer<T | undefined>): Accessor<T | undefined>;
|
|
34
36
|
export {};
|
package/types/index.d.ts
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
export { $PROXY, $TRACK,
|
|
2
|
-
export type { Accessor, ComputeFunction, EffectFunction, EffectOptions, Merge, NoInfer, NotWrappable, Omit, Owner, Signal, SignalOptions, Setter, Store, SolidStore, StoreNode, StoreSetter } from "@solidjs/signals";
|
|
1
|
+
export { $PROXY, $TRACK, createEffect, createMemo, createOptimistic, createOptimisticStore, createProjection, createReaction, createRenderEffect, createRoot, createSignal, createStore, createTrackedEffect, deep, flatten, flush, getObserver, getOwner, isEqual, isPending, isWrappable, mapArray, merge, omit, onCleanup, onSettled, pending, reconcile, 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";
|
|
3
3
|
export { $DEVCOMP, children, createContext, onMount, useContext } from "./client/core.js";
|
|
4
4
|
export type { ChildrenReturn, Context, ContextProviderComponent, ResolvedChildren, ResolvedJSXElement } from "./client/core.js";
|
|
5
|
+
export * from "./utilities.js";
|
|
5
6
|
export * from "./client/observable.js";
|
|
6
7
|
export * from "./client/component.js";
|
|
7
8
|
export * from "./client/flow.js";
|
|
8
|
-
export { sharedConfig } from "./client/hydration.js";
|
|
9
|
+
export { sharedConfig, createAsync, Loading } from "./client/hydration.js";
|
|
10
|
+
export declare function ssrHandleError(): void;
|
|
11
|
+
export declare function ssrRunInScope(): void;
|
|
9
12
|
import type { JSX } from "./jsx.js";
|
|
10
13
|
type JSXElement = JSX.Element;
|
|
11
14
|
export type { JSXElement, JSX };
|