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/dev.cjs +82 -38
- package/dist/dev.js +88 -43
- package/dist/server.cjs +535 -0
- package/dist/server.js +441 -0
- package/dist/solid.cjs +82 -38
- package/dist/solid.js +88 -43
- package/package.json +4 -4
- package/types/client/component.d.ts +0 -1
- package/types/client/flow.d.ts +1 -5
- package/types/client/hydration.d.ts +5 -1
- package/types/index.d.ts +3 -4
- package/types/server/component.d.ts +62 -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 +24 -0
- package/types/server/signals.d.ts +54 -0
- package/types/utilities.d.ts +0 -36
package/dist/dev.cjs
CHANGED
|
@@ -50,27 +50,6 @@ function registerGraph(value) {
|
|
|
50
50
|
value.graph = owner;
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
function tryCatch(fn) {
|
|
54
|
-
try {
|
|
55
|
-
const v = fn();
|
|
56
|
-
if (v instanceof Promise) {
|
|
57
|
-
return v.then(v => [undefined, v], e => {
|
|
58
|
-
if (e instanceof signals.NotReadyError) throw e;
|
|
59
|
-
return [e];
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
return [undefined, v];
|
|
63
|
-
} catch (e) {
|
|
64
|
-
if (e instanceof signals.NotReadyError) throw e;
|
|
65
|
-
return [e];
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
function reducer(source, reducerFn) {
|
|
69
|
-
return [source[0], action => {
|
|
70
|
-
source[1](s => reducerFn(s, action));
|
|
71
|
-
}];
|
|
72
|
-
}
|
|
73
|
-
|
|
74
53
|
const sharedConfig = {
|
|
75
54
|
hydrating: false,
|
|
76
55
|
registry: undefined,
|
|
@@ -81,6 +60,77 @@ const sharedConfig = {
|
|
|
81
60
|
return signals.getNextChildId(o);
|
|
82
61
|
}
|
|
83
62
|
};
|
|
63
|
+
let _createMemo;
|
|
64
|
+
let _createSignal;
|
|
65
|
+
class MockPromise {
|
|
66
|
+
static all() {
|
|
67
|
+
return new MockPromise();
|
|
68
|
+
}
|
|
69
|
+
static allSettled() {
|
|
70
|
+
return new MockPromise();
|
|
71
|
+
}
|
|
72
|
+
static any() {
|
|
73
|
+
return new MockPromise();
|
|
74
|
+
}
|
|
75
|
+
static race() {
|
|
76
|
+
return new MockPromise();
|
|
77
|
+
}
|
|
78
|
+
static reject() {
|
|
79
|
+
return new MockPromise();
|
|
80
|
+
}
|
|
81
|
+
static resolve() {
|
|
82
|
+
return new MockPromise();
|
|
83
|
+
}
|
|
84
|
+
catch() {
|
|
85
|
+
return new MockPromise();
|
|
86
|
+
}
|
|
87
|
+
then() {
|
|
88
|
+
return new MockPromise();
|
|
89
|
+
}
|
|
90
|
+
finally() {
|
|
91
|
+
return new MockPromise();
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
function subFetch(fn, prev) {
|
|
95
|
+
const ogFetch = fetch;
|
|
96
|
+
const ogPromise = Promise;
|
|
97
|
+
try {
|
|
98
|
+
window.fetch = () => new MockPromise();
|
|
99
|
+
Promise = MockPromise;
|
|
100
|
+
return fn(prev);
|
|
101
|
+
} finally {
|
|
102
|
+
window.fetch = ogFetch;
|
|
103
|
+
Promise = ogPromise;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
function hydratedCreateMemo(compute, value, options) {
|
|
107
|
+
if (!sharedConfig.hydrating) return signals.createMemo(compute, value, options);
|
|
108
|
+
return signals.createMemo(prev => {
|
|
109
|
+
const o = signals.getOwner();
|
|
110
|
+
if (!sharedConfig.hydrating) return compute(prev);
|
|
111
|
+
let initP;
|
|
112
|
+
if (sharedConfig.has(o.id)) initP = sharedConfig.load(o.id);
|
|
113
|
+
const init = initP?.v ?? initP;
|
|
114
|
+
return init != null ? (subFetch(compute, prev), init) : compute(prev);
|
|
115
|
+
}, value, options);
|
|
116
|
+
}
|
|
117
|
+
function hydratedCreateSignal(fn, second, third) {
|
|
118
|
+
if (typeof fn !== "function" || !sharedConfig.hydrating) return signals.createSignal(fn, second, third);
|
|
119
|
+
return signals.createSignal(prev => {
|
|
120
|
+
if (!sharedConfig.hydrating) return fn(prev);
|
|
121
|
+
const o = signals.getOwner();
|
|
122
|
+
let initP;
|
|
123
|
+
if (sharedConfig.has(o.id)) initP = sharedConfig.load(o.id);
|
|
124
|
+
const init = initP?.v ?? initP;
|
|
125
|
+
return init != null ? (subFetch(fn, prev), init) : fn(prev);
|
|
126
|
+
}, second, third);
|
|
127
|
+
}
|
|
128
|
+
function enableHydration() {
|
|
129
|
+
_createMemo = hydratedCreateMemo;
|
|
130
|
+
_createSignal = hydratedCreateSignal;
|
|
131
|
+
}
|
|
132
|
+
const createMemo = (...args) => (_createMemo || signals.createMemo)(...args);
|
|
133
|
+
const createSignal = (...args) => (_createSignal || signals.createSignal)(...args);
|
|
84
134
|
function Loading(props) {
|
|
85
135
|
if (!sharedConfig.hydrating) return signals.createLoadBoundary(() => props.children, () => props.fallback);
|
|
86
136
|
return signals.createMemo(() => {
|
|
@@ -90,7 +140,7 @@ function Loading(props) {
|
|
|
90
140
|
let ref = sharedConfig.load(id);
|
|
91
141
|
let p;
|
|
92
142
|
if (ref) {
|
|
93
|
-
if (typeof ref !== "object" || ref.s !==
|
|
143
|
+
if (typeof ref !== "object" || ref.s !== 1) p = ref;else sharedConfig.gather(id);
|
|
94
144
|
}
|
|
95
145
|
if (p) {
|
|
96
146
|
const [s, set] = signals.createSignal(undefined, {
|
|
@@ -115,8 +165,6 @@ function Loading(props) {
|
|
|
115
165
|
});
|
|
116
166
|
}
|
|
117
167
|
|
|
118
|
-
function enableHydration() {
|
|
119
|
-
}
|
|
120
168
|
function createComponent(Comp, props) {
|
|
121
169
|
return devComponent(Comp, props || {});
|
|
122
170
|
}
|
|
@@ -226,9 +274,6 @@ function Errored(props) {
|
|
|
226
274
|
return typeof f === "function" && f.length ? f(err, reset) : f;
|
|
227
275
|
});
|
|
228
276
|
}
|
|
229
|
-
function Boundary(props) {
|
|
230
|
-
return signals.createBoundary(() => props.children, () => props.mode);
|
|
231
|
-
}
|
|
232
277
|
|
|
233
278
|
function ssrHandleError() {}
|
|
234
279
|
function ssrRunInScope() {}
|
|
@@ -249,13 +294,17 @@ Object.defineProperty(exports, "$TRACK", {
|
|
|
249
294
|
enumerable: true,
|
|
250
295
|
get: function () { return signals.$TRACK; }
|
|
251
296
|
});
|
|
252
|
-
Object.defineProperty(exports, "
|
|
297
|
+
Object.defineProperty(exports, "NotReadyError", {
|
|
253
298
|
enumerable: true,
|
|
254
|
-
get: function () { return signals.
|
|
299
|
+
get: function () { return signals.NotReadyError; }
|
|
255
300
|
});
|
|
256
|
-
Object.defineProperty(exports, "
|
|
301
|
+
Object.defineProperty(exports, "action", {
|
|
257
302
|
enumerable: true,
|
|
258
|
-
get: function () { return signals.
|
|
303
|
+
get: function () { return signals.action; }
|
|
304
|
+
});
|
|
305
|
+
Object.defineProperty(exports, "createEffect", {
|
|
306
|
+
enumerable: true,
|
|
307
|
+
get: function () { return signals.createEffect; }
|
|
259
308
|
});
|
|
260
309
|
Object.defineProperty(exports, "createOptimistic", {
|
|
261
310
|
enumerable: true,
|
|
@@ -281,10 +330,6 @@ Object.defineProperty(exports, "createRoot", {
|
|
|
281
330
|
enumerable: true,
|
|
282
331
|
get: function () { return signals.createRoot; }
|
|
283
332
|
});
|
|
284
|
-
Object.defineProperty(exports, "createSignal", {
|
|
285
|
-
enumerable: true,
|
|
286
|
-
get: function () { return signals.createSignal; }
|
|
287
|
-
});
|
|
288
333
|
Object.defineProperty(exports, "createStore", {
|
|
289
334
|
enumerable: true,
|
|
290
335
|
get: function () { return signals.createStore; }
|
|
@@ -382,7 +427,6 @@ Object.defineProperty(exports, "untrack", {
|
|
|
382
427
|
get: function () { return signals.untrack; }
|
|
383
428
|
});
|
|
384
429
|
exports.$DEVCOMP = $DEVCOMP;
|
|
385
|
-
exports.Boundary = Boundary;
|
|
386
430
|
exports.DEV = DEV;
|
|
387
431
|
exports.Errored = Errored;
|
|
388
432
|
exports.For = For;
|
|
@@ -394,12 +438,12 @@ exports.Switch = Switch;
|
|
|
394
438
|
exports.children = children;
|
|
395
439
|
exports.createComponent = createComponent;
|
|
396
440
|
exports.createContext = createContext;
|
|
441
|
+
exports.createMemo = createMemo;
|
|
442
|
+
exports.createSignal = createSignal;
|
|
397
443
|
exports.createUniqueId = createUniqueId;
|
|
398
444
|
exports.enableHydration = enableHydration;
|
|
399
445
|
exports.lazy = lazy;
|
|
400
|
-
exports.reducer = reducer;
|
|
401
446
|
exports.sharedConfig = sharedConfig;
|
|
402
447
|
exports.ssrHandleError = ssrHandleError;
|
|
403
448
|
exports.ssrRunInScope = ssrRunInScope;
|
|
404
|
-
exports.tryCatch = tryCatch;
|
|
405
449
|
exports.useContext = useContext;
|
package/dist/dev.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { getContext, createMemo, flatten, createRoot, setContext, getOwner, untrack,
|
|
2
|
-
export { $PROXY, $TRACK,
|
|
1
|
+
import { getContext, createMemo as createMemo$1, flatten, createRoot, setContext, getOwner, untrack, getNextChildId, createSignal as createSignal$1, createLoadBoundary, flush, runWithOwner, 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("COMPONENT_DEV" );
|
|
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()), undefined, {
|
|
21
|
+
const children = createMemo$1(fn);
|
|
22
|
+
const memo = createMemo$1(() => flatten(children()), undefined, {
|
|
23
23
|
name: "children"
|
|
24
24
|
}) ;
|
|
25
25
|
memo.toArray = () => {
|
|
@@ -49,27 +49,6 @@ function registerGraph(value) {
|
|
|
49
49
|
value.graph = owner;
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
function tryCatch(fn) {
|
|
53
|
-
try {
|
|
54
|
-
const v = fn();
|
|
55
|
-
if (v instanceof Promise) {
|
|
56
|
-
return v.then(v => [undefined, v], e => {
|
|
57
|
-
if (e instanceof NotReadyError) throw e;
|
|
58
|
-
return [e];
|
|
59
|
-
});
|
|
60
|
-
}
|
|
61
|
-
return [undefined, v];
|
|
62
|
-
} catch (e) {
|
|
63
|
-
if (e instanceof NotReadyError) throw e;
|
|
64
|
-
return [e];
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
function reducer(source, reducerFn) {
|
|
68
|
-
return [source[0], action => {
|
|
69
|
-
source[1](s => reducerFn(s, action));
|
|
70
|
-
}];
|
|
71
|
-
}
|
|
72
|
-
|
|
73
52
|
const sharedConfig = {
|
|
74
53
|
hydrating: false,
|
|
75
54
|
registry: undefined,
|
|
@@ -80,19 +59,90 @@ const sharedConfig = {
|
|
|
80
59
|
return getNextChildId(o);
|
|
81
60
|
}
|
|
82
61
|
};
|
|
62
|
+
let _createMemo;
|
|
63
|
+
let _createSignal;
|
|
64
|
+
class MockPromise {
|
|
65
|
+
static all() {
|
|
66
|
+
return new MockPromise();
|
|
67
|
+
}
|
|
68
|
+
static allSettled() {
|
|
69
|
+
return new MockPromise();
|
|
70
|
+
}
|
|
71
|
+
static any() {
|
|
72
|
+
return new MockPromise();
|
|
73
|
+
}
|
|
74
|
+
static race() {
|
|
75
|
+
return new MockPromise();
|
|
76
|
+
}
|
|
77
|
+
static reject() {
|
|
78
|
+
return new MockPromise();
|
|
79
|
+
}
|
|
80
|
+
static resolve() {
|
|
81
|
+
return new MockPromise();
|
|
82
|
+
}
|
|
83
|
+
catch() {
|
|
84
|
+
return new MockPromise();
|
|
85
|
+
}
|
|
86
|
+
then() {
|
|
87
|
+
return new MockPromise();
|
|
88
|
+
}
|
|
89
|
+
finally() {
|
|
90
|
+
return new MockPromise();
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
function subFetch(fn, prev) {
|
|
94
|
+
const ogFetch = fetch;
|
|
95
|
+
const ogPromise = Promise;
|
|
96
|
+
try {
|
|
97
|
+
window.fetch = () => new MockPromise();
|
|
98
|
+
Promise = MockPromise;
|
|
99
|
+
return fn(prev);
|
|
100
|
+
} finally {
|
|
101
|
+
window.fetch = ogFetch;
|
|
102
|
+
Promise = ogPromise;
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
function hydratedCreateMemo(compute, value, options) {
|
|
106
|
+
if (!sharedConfig.hydrating) return createMemo$1(compute, value, options);
|
|
107
|
+
return createMemo$1(prev => {
|
|
108
|
+
const o = getOwner();
|
|
109
|
+
if (!sharedConfig.hydrating) return compute(prev);
|
|
110
|
+
let initP;
|
|
111
|
+
if (sharedConfig.has(o.id)) initP = sharedConfig.load(o.id);
|
|
112
|
+
const init = initP?.v ?? initP;
|
|
113
|
+
return init != null ? (subFetch(compute, prev), init) : compute(prev);
|
|
114
|
+
}, value, options);
|
|
115
|
+
}
|
|
116
|
+
function hydratedCreateSignal(fn, second, third) {
|
|
117
|
+
if (typeof fn !== "function" || !sharedConfig.hydrating) return createSignal$1(fn, second, third);
|
|
118
|
+
return createSignal$1(prev => {
|
|
119
|
+
if (!sharedConfig.hydrating) return fn(prev);
|
|
120
|
+
const o = getOwner();
|
|
121
|
+
let initP;
|
|
122
|
+
if (sharedConfig.has(o.id)) initP = sharedConfig.load(o.id);
|
|
123
|
+
const init = initP?.v ?? initP;
|
|
124
|
+
return init != null ? (subFetch(fn, prev), init) : fn(prev);
|
|
125
|
+
}, second, third);
|
|
126
|
+
}
|
|
127
|
+
function enableHydration() {
|
|
128
|
+
_createMemo = hydratedCreateMemo;
|
|
129
|
+
_createSignal = hydratedCreateSignal;
|
|
130
|
+
}
|
|
131
|
+
const createMemo = (...args) => (_createMemo || createMemo$1)(...args);
|
|
132
|
+
const createSignal = (...args) => (_createSignal || createSignal$1)(...args);
|
|
83
133
|
function Loading(props) {
|
|
84
134
|
if (!sharedConfig.hydrating) return createLoadBoundary(() => props.children, () => props.fallback);
|
|
85
|
-
return createMemo(() => {
|
|
135
|
+
return createMemo$1(() => {
|
|
86
136
|
const o = getOwner();
|
|
87
137
|
const id = o.id;
|
|
88
138
|
if (sharedConfig.hydrating && sharedConfig.has(id)) {
|
|
89
139
|
let ref = sharedConfig.load(id);
|
|
90
140
|
let p;
|
|
91
141
|
if (ref) {
|
|
92
|
-
if (typeof ref !== "object" || ref.s !==
|
|
142
|
+
if (typeof ref !== "object" || ref.s !== 1) p = ref;else sharedConfig.gather(id);
|
|
93
143
|
}
|
|
94
144
|
if (p) {
|
|
95
|
-
const [s, set] = createSignal(undefined, {
|
|
145
|
+
const [s, set] = createSignal$1(undefined, {
|
|
96
146
|
equals: false
|
|
97
147
|
});
|
|
98
148
|
s();
|
|
@@ -114,8 +164,6 @@ function Loading(props) {
|
|
|
114
164
|
});
|
|
115
165
|
}
|
|
116
166
|
|
|
117
|
-
function enableHydration() {
|
|
118
|
-
}
|
|
119
167
|
function createComponent(Comp, props) {
|
|
120
168
|
return devComponent(Comp, props || {});
|
|
121
169
|
}
|
|
@@ -123,9 +171,9 @@ function lazy(fn) {
|
|
|
123
171
|
let comp;
|
|
124
172
|
let p;
|
|
125
173
|
const wrap = props => {
|
|
126
|
-
comp = createMemo(() => (p || (p = fn())).then(mod => mod.default));
|
|
174
|
+
comp = createMemo$1(() => (p || (p = fn())).then(mod => mod.default));
|
|
127
175
|
let Comp;
|
|
128
|
-
return createMemo(() => (Comp = comp()) ? untrack(() => {
|
|
176
|
+
return createMemo$1(() => (Comp = comp()) ? untrack(() => {
|
|
129
177
|
Object.assign(Comp, {
|
|
130
178
|
[$DEVCOMP]: true
|
|
131
179
|
});
|
|
@@ -159,14 +207,14 @@ function Repeat(props) {
|
|
|
159
207
|
}
|
|
160
208
|
function Show(props) {
|
|
161
209
|
const keyed = props.keyed;
|
|
162
|
-
const conditionValue = createMemo(() => props.when, undefined, {
|
|
210
|
+
const conditionValue = createMemo$1(() => props.when, undefined, {
|
|
163
211
|
name: "condition value"
|
|
164
212
|
} );
|
|
165
|
-
const condition = keyed ? conditionValue : createMemo(conditionValue, undefined, {
|
|
213
|
+
const condition = keyed ? conditionValue : createMemo$1(conditionValue, undefined, {
|
|
166
214
|
equals: (a, b) => !a === !b,
|
|
167
215
|
name: "condition"
|
|
168
216
|
} );
|
|
169
|
-
return createMemo(() => {
|
|
217
|
+
return createMemo$1(() => {
|
|
170
218
|
const c = condition();
|
|
171
219
|
if (c) {
|
|
172
220
|
const child = props.children;
|
|
@@ -183,17 +231,17 @@ function Show(props) {
|
|
|
183
231
|
}
|
|
184
232
|
function Switch(props) {
|
|
185
233
|
const chs = children(() => props.children);
|
|
186
|
-
const switchFunc = createMemo(() => {
|
|
234
|
+
const switchFunc = createMemo$1(() => {
|
|
187
235
|
const mps = chs.toArray();
|
|
188
236
|
let func = () => undefined;
|
|
189
237
|
for (let i = 0; i < mps.length; i++) {
|
|
190
238
|
const index = i;
|
|
191
239
|
const mp = mps[i];
|
|
192
240
|
const prevFunc = func;
|
|
193
|
-
const conditionValue = createMemo(() => prevFunc() ? undefined : mp.when, undefined, {
|
|
241
|
+
const conditionValue = createMemo$1(() => prevFunc() ? undefined : mp.when, undefined, {
|
|
194
242
|
name: "condition value"
|
|
195
243
|
} );
|
|
196
|
-
const condition = mp.keyed ? conditionValue : createMemo(conditionValue, undefined, {
|
|
244
|
+
const condition = mp.keyed ? conditionValue : createMemo$1(conditionValue, undefined, {
|
|
197
245
|
equals: (a, b) => !a === !b,
|
|
198
246
|
name: "condition"
|
|
199
247
|
} );
|
|
@@ -201,7 +249,7 @@ function Switch(props) {
|
|
|
201
249
|
}
|
|
202
250
|
return func;
|
|
203
251
|
});
|
|
204
|
-
return createMemo(() => {
|
|
252
|
+
return createMemo$1(() => {
|
|
205
253
|
const sel = switchFunc()();
|
|
206
254
|
if (!sel) return props.fallback;
|
|
207
255
|
const [index, conditionValue, mp] = sel;
|
|
@@ -225,9 +273,6 @@ function Errored(props) {
|
|
|
225
273
|
return typeof f === "function" && f.length ? f(err, reset) : f;
|
|
226
274
|
});
|
|
227
275
|
}
|
|
228
|
-
function Boundary(props) {
|
|
229
|
-
return createBoundary(() => props.children, () => props.mode);
|
|
230
|
-
}
|
|
231
276
|
|
|
232
277
|
function ssrHandleError() {}
|
|
233
278
|
function ssrRunInScope() {}
|
|
@@ -240,4 +285,4 @@ if (globalThis) {
|
|
|
240
285
|
if (!globalThis.Solid$$) globalThis.Solid$$ = true;else console.warn("You appear to have multiple instances of Solid. This can lead to unexpected behavior.");
|
|
241
286
|
}
|
|
242
287
|
|
|
243
|
-
export { $DEVCOMP,
|
|
288
|
+
export { $DEVCOMP, DEV, Errored, For, Loading, Match, Repeat, Show, Switch, children, createComponent, createContext, createMemo, createSignal, createUniqueId, enableHydration, lazy, sharedConfig, ssrHandleError, ssrRunInScope, useContext };
|