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/dist/dev.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { getContext, createMemo, flatten, createRoot, setContext,
|
|
2
|
-
export { $PROXY, $TRACK, action, createEffect,
|
|
1
|
+
import { getContext, createMemo as createMemo$1, flatten, getOwner, createRoot, setContext, untrack, setStrictRead, createLoadBoundary, onCleanup, isDisposed, runWithOwner, createOptimistic as createOptimistic$1, createOptimisticStore as createOptimisticStore$1, createProjection as createProjection$1, createSignal as createSignal$1, createStore as createStore$1, setSnapshotCapture, releaseSnapshotScope, getNextChildId, createErrorBoundary as createErrorBoundary$1, markSnapshotScope, flush, clearSnapshots, peekNextChildId, mapArray, repeat } from '@solidjs/signals';
|
|
2
|
+
export { $PROXY, $TRACK, NotReadyError, action, createEffect, createReaction, createRenderEffect, createRoot, 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 = () => {
|
|
@@ -38,8 +38,15 @@ function devComponent(Comp, props) {
|
|
|
38
38
|
Object.assign(Comp, {
|
|
39
39
|
[$DEVCOMP]: true
|
|
40
40
|
});
|
|
41
|
-
|
|
41
|
+
setStrictRead(`<${Comp.name || "Anonymous"}>`);
|
|
42
|
+
try {
|
|
43
|
+
return Comp(props);
|
|
44
|
+
} finally {
|
|
45
|
+
setStrictRead(false);
|
|
46
|
+
}
|
|
42
47
|
});
|
|
48
|
+
}, {
|
|
49
|
+
transparent: true
|
|
43
50
|
});
|
|
44
51
|
}
|
|
45
52
|
function registerGraph(value) {
|
|
@@ -49,27 +56,6 @@ function registerGraph(value) {
|
|
|
49
56
|
value.graph = owner;
|
|
50
57
|
}
|
|
51
58
|
|
|
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
59
|
const sharedConfig = {
|
|
74
60
|
hydrating: false,
|
|
75
61
|
registry: undefined,
|
|
@@ -80,52 +66,498 @@ const sharedConfig = {
|
|
|
80
66
|
return getNextChildId(o);
|
|
81
67
|
}
|
|
82
68
|
};
|
|
69
|
+
let _hydrationEndCallbacks = null;
|
|
70
|
+
let _pendingBoundaries = 0;
|
|
71
|
+
let _hydrationDone = false;
|
|
72
|
+
let _snapshotRootOwner = null;
|
|
73
|
+
function markTopLevelSnapshotScope() {
|
|
74
|
+
if (_snapshotRootOwner) return;
|
|
75
|
+
let owner = getOwner();
|
|
76
|
+
if (!owner) return;
|
|
77
|
+
while (owner._parent) owner = owner._parent;
|
|
78
|
+
markSnapshotScope(owner);
|
|
79
|
+
_snapshotRootOwner = owner;
|
|
80
|
+
}
|
|
81
|
+
function drainHydrationCallbacks() {
|
|
82
|
+
if (_hydrationDone) return;
|
|
83
|
+
_hydrationDone = true;
|
|
84
|
+
_doneValue = true;
|
|
85
|
+
clearSnapshots();
|
|
86
|
+
setSnapshotCapture(false);
|
|
87
|
+
flush();
|
|
88
|
+
const cbs = _hydrationEndCallbacks;
|
|
89
|
+
_hydrationEndCallbacks = null;
|
|
90
|
+
if (cbs) for (const cb of cbs) cb();
|
|
91
|
+
setTimeout(() => {
|
|
92
|
+
if (globalThis._$HY) globalThis._$HY.done = true;
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
function checkHydrationComplete() {
|
|
96
|
+
if (_pendingBoundaries === 0) drainHydrationCallbacks();
|
|
97
|
+
}
|
|
98
|
+
let _hydratingValue = false;
|
|
99
|
+
let _doneValue = false;
|
|
100
|
+
let _createMemo;
|
|
101
|
+
let _createSignal;
|
|
102
|
+
let _createErrorBoundary;
|
|
103
|
+
let _createOptimistic;
|
|
104
|
+
let _createProjection;
|
|
105
|
+
let _createStore;
|
|
106
|
+
let _createOptimisticStore;
|
|
107
|
+
class MockPromise {
|
|
108
|
+
static all() {
|
|
109
|
+
return new MockPromise();
|
|
110
|
+
}
|
|
111
|
+
static allSettled() {
|
|
112
|
+
return new MockPromise();
|
|
113
|
+
}
|
|
114
|
+
static any() {
|
|
115
|
+
return new MockPromise();
|
|
116
|
+
}
|
|
117
|
+
static race() {
|
|
118
|
+
return new MockPromise();
|
|
119
|
+
}
|
|
120
|
+
static reject() {
|
|
121
|
+
return new MockPromise();
|
|
122
|
+
}
|
|
123
|
+
static resolve() {
|
|
124
|
+
return new MockPromise();
|
|
125
|
+
}
|
|
126
|
+
catch() {
|
|
127
|
+
return new MockPromise();
|
|
128
|
+
}
|
|
129
|
+
then() {
|
|
130
|
+
return new MockPromise();
|
|
131
|
+
}
|
|
132
|
+
finally() {
|
|
133
|
+
return new MockPromise();
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
function subFetch(fn, prev) {
|
|
137
|
+
const ogFetch = fetch;
|
|
138
|
+
const ogPromise = Promise;
|
|
139
|
+
try {
|
|
140
|
+
window.fetch = () => new MockPromise();
|
|
141
|
+
Promise = MockPromise;
|
|
142
|
+
const result = fn(prev);
|
|
143
|
+
if (result && typeof result[Symbol.asyncIterator] === "function") {
|
|
144
|
+
result[Symbol.asyncIterator]().next();
|
|
145
|
+
}
|
|
146
|
+
return result;
|
|
147
|
+
} finally {
|
|
148
|
+
window.fetch = ogFetch;
|
|
149
|
+
Promise = ogPromise;
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
function consumeFirstSync(ai) {
|
|
153
|
+
const iter = ai[Symbol.asyncIterator]();
|
|
154
|
+
const r = iter.next();
|
|
155
|
+
const value = !(r instanceof Promise) && !r.done ? r.value : undefined;
|
|
156
|
+
return [value, iter];
|
|
157
|
+
}
|
|
158
|
+
function applyPatches(target, patches) {
|
|
159
|
+
for (const patch of patches) {
|
|
160
|
+
const path = patch[0];
|
|
161
|
+
let current = target;
|
|
162
|
+
for (let i = 0; i < path.length - 1; i++) current = current[path[i]];
|
|
163
|
+
const key = path[path.length - 1];
|
|
164
|
+
if (patch.length === 1) {
|
|
165
|
+
Array.isArray(current) ? current.splice(key, 1) : delete current[key];
|
|
166
|
+
} else if (patch.length === 3) {
|
|
167
|
+
current.splice(key, 0, patch[1]);
|
|
168
|
+
} else {
|
|
169
|
+
current[key] = patch[1];
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
function scheduleIteratorConsumption(iter, apply) {
|
|
174
|
+
const consume = () => {
|
|
175
|
+
while (true) {
|
|
176
|
+
const n = iter.next();
|
|
177
|
+
if (n instanceof Promise) {
|
|
178
|
+
n.then(r => {
|
|
179
|
+
if (r.done) return;
|
|
180
|
+
apply(r.value);
|
|
181
|
+
consume();
|
|
182
|
+
});
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
if (n.done) break;
|
|
186
|
+
apply(n.value);
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
consume();
|
|
190
|
+
}
|
|
191
|
+
function isAsyncIterable(v) {
|
|
192
|
+
return v != null && typeof v[Symbol.asyncIterator] === "function";
|
|
193
|
+
}
|
|
194
|
+
function hydrateSignalFromAsyncIterable(coreFn, compute, value, options) {
|
|
195
|
+
const parent = getOwner();
|
|
196
|
+
const expectedId = peekNextChildId(parent);
|
|
197
|
+
if (!sharedConfig.has(expectedId)) return null;
|
|
198
|
+
const initP = sharedConfig.load(expectedId);
|
|
199
|
+
if (!isAsyncIterable(initP)) return null;
|
|
200
|
+
const [firstValue, iter] = consumeFirstSync(initP);
|
|
201
|
+
const [get, set] = createSignal$1(firstValue);
|
|
202
|
+
const result = coreFn(() => get(), firstValue, options);
|
|
203
|
+
scheduleIteratorConsumption(iter, v => {
|
|
204
|
+
set(() => v);
|
|
205
|
+
flush();
|
|
206
|
+
});
|
|
207
|
+
return result;
|
|
208
|
+
}
|
|
209
|
+
function hydrateStoreFromAsyncIterable(coreFn, initialValue, options) {
|
|
210
|
+
const parent = getOwner();
|
|
211
|
+
const expectedId = peekNextChildId(parent);
|
|
212
|
+
if (!sharedConfig.has(expectedId)) return null;
|
|
213
|
+
const initP = sharedConfig.load(expectedId);
|
|
214
|
+
if (!isAsyncIterable(initP)) return null;
|
|
215
|
+
const [firstState, iter] = consumeFirstSync(initP);
|
|
216
|
+
const [store, setStore] = coreFn(() => {}, firstState ?? initialValue, options);
|
|
217
|
+
scheduleIteratorConsumption(iter, patches => {
|
|
218
|
+
setStore(d => {
|
|
219
|
+
applyPatches(d, patches);
|
|
220
|
+
});
|
|
221
|
+
});
|
|
222
|
+
return [store, setStore];
|
|
223
|
+
}
|
|
224
|
+
function hydratedCreateMemo(compute, value, options) {
|
|
225
|
+
if (!sharedConfig.hydrating) return createMemo$1(compute, value, options);
|
|
226
|
+
markTopLevelSnapshotScope();
|
|
227
|
+
const ssrSource = options?.ssrSource;
|
|
228
|
+
if (ssrSource === "client") {
|
|
229
|
+
const [hydrated, setHydrated] = createSignal$1(false);
|
|
230
|
+
const memo = createMemo$1(prev => {
|
|
231
|
+
if (!hydrated()) return prev ?? value;
|
|
232
|
+
return compute(prev);
|
|
233
|
+
}, value, options);
|
|
234
|
+
setHydrated(true);
|
|
235
|
+
return memo;
|
|
236
|
+
}
|
|
237
|
+
if (ssrSource === "initial") {
|
|
238
|
+
return createMemo$1(prev => {
|
|
239
|
+
if (!sharedConfig.hydrating) return compute(prev);
|
|
240
|
+
subFetch(compute, prev);
|
|
241
|
+
return prev ?? value;
|
|
242
|
+
}, value, options);
|
|
243
|
+
}
|
|
244
|
+
const aiResult = hydrateSignalFromAsyncIterable(createMemo$1, compute, value, options);
|
|
245
|
+
if (aiResult !== null) return aiResult;
|
|
246
|
+
return createMemo$1(prev => {
|
|
247
|
+
const o = getOwner();
|
|
248
|
+
if (!sharedConfig.hydrating) return compute(prev);
|
|
249
|
+
let initP;
|
|
250
|
+
if (sharedConfig.has(o.id)) initP = sharedConfig.load(o.id);
|
|
251
|
+
const init = initP?.v ?? initP;
|
|
252
|
+
return init != null ? (subFetch(compute, prev), init) : compute(prev);
|
|
253
|
+
}, value, options);
|
|
254
|
+
}
|
|
255
|
+
function hydratedCreateSignal(fn, second, third) {
|
|
256
|
+
if (typeof fn !== "function" || !sharedConfig.hydrating) return createSignal$1(fn, second, third);
|
|
257
|
+
markTopLevelSnapshotScope();
|
|
258
|
+
const ssrSource = third?.ssrSource;
|
|
259
|
+
if (ssrSource === "client") {
|
|
260
|
+
const [hydrated, setHydrated] = createSignal$1(false);
|
|
261
|
+
const sig = createSignal$1(prev => {
|
|
262
|
+
if (!hydrated()) return prev ?? second;
|
|
263
|
+
return fn(prev);
|
|
264
|
+
}, second, third);
|
|
265
|
+
setHydrated(true);
|
|
266
|
+
return sig;
|
|
267
|
+
}
|
|
268
|
+
if (ssrSource === "initial") {
|
|
269
|
+
return createSignal$1(prev => {
|
|
270
|
+
if (!sharedConfig.hydrating) return fn(prev);
|
|
271
|
+
subFetch(fn, prev);
|
|
272
|
+
return prev ?? second;
|
|
273
|
+
}, second, third);
|
|
274
|
+
}
|
|
275
|
+
const aiResult = hydrateSignalFromAsyncIterable(createSignal$1, fn, second, third);
|
|
276
|
+
if (aiResult !== null) return aiResult;
|
|
277
|
+
return createSignal$1(prev => {
|
|
278
|
+
if (!sharedConfig.hydrating) return fn(prev);
|
|
279
|
+
const o = getOwner();
|
|
280
|
+
let initP;
|
|
281
|
+
if (sharedConfig.has(o.id)) initP = sharedConfig.load(o.id);
|
|
282
|
+
const init = initP?.v ?? initP;
|
|
283
|
+
return init != null ? (subFetch(fn, prev), init) : fn(prev);
|
|
284
|
+
}, second, third);
|
|
285
|
+
}
|
|
286
|
+
function hydratedCreateErrorBoundary(fn, fallback) {
|
|
287
|
+
if (!sharedConfig.hydrating) return createErrorBoundary$1(fn, fallback);
|
|
288
|
+
markTopLevelSnapshotScope();
|
|
289
|
+
const parent = getOwner();
|
|
290
|
+
const expectedId = peekNextChildId(parent);
|
|
291
|
+
if (sharedConfig.has(expectedId)) {
|
|
292
|
+
const err = sharedConfig.load(expectedId);
|
|
293
|
+
if (err !== undefined) {
|
|
294
|
+
let hydrated = true;
|
|
295
|
+
return createErrorBoundary$1(() => {
|
|
296
|
+
if (hydrated) {
|
|
297
|
+
hydrated = false;
|
|
298
|
+
throw err;
|
|
299
|
+
}
|
|
300
|
+
return fn();
|
|
301
|
+
}, fallback);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
return createErrorBoundary$1(fn, fallback);
|
|
305
|
+
}
|
|
306
|
+
function hydratedCreateOptimistic(fn, second, third) {
|
|
307
|
+
if (typeof fn !== "function" || !sharedConfig.hydrating) return createOptimistic$1(fn, second, third);
|
|
308
|
+
markTopLevelSnapshotScope();
|
|
309
|
+
const ssrSource = third?.ssrSource;
|
|
310
|
+
if (ssrSource === "client") {
|
|
311
|
+
const [hydrated, setHydrated] = createSignal$1(false);
|
|
312
|
+
const sig = createOptimistic$1(prev => {
|
|
313
|
+
if (!hydrated()) return prev ?? second;
|
|
314
|
+
return fn(prev);
|
|
315
|
+
}, second, third);
|
|
316
|
+
setHydrated(true);
|
|
317
|
+
return sig;
|
|
318
|
+
}
|
|
319
|
+
if (ssrSource === "initial") {
|
|
320
|
+
return createOptimistic$1(prev => {
|
|
321
|
+
if (!sharedConfig.hydrating) return fn(prev);
|
|
322
|
+
subFetch(fn, prev);
|
|
323
|
+
return prev ?? second;
|
|
324
|
+
}, second, third);
|
|
325
|
+
}
|
|
326
|
+
const aiResult = hydrateSignalFromAsyncIterable(createOptimistic$1, fn, second, third);
|
|
327
|
+
if (aiResult !== null) return aiResult;
|
|
328
|
+
return createOptimistic$1(prev => {
|
|
329
|
+
const o = getOwner();
|
|
330
|
+
if (!sharedConfig.hydrating) return fn(prev);
|
|
331
|
+
let initP;
|
|
332
|
+
if (sharedConfig.has(o.id)) initP = sharedConfig.load(o.id);
|
|
333
|
+
const init = initP?.v ?? initP;
|
|
334
|
+
return init != null ? (subFetch(fn, prev), init) : fn(prev);
|
|
335
|
+
}, second, third);
|
|
336
|
+
}
|
|
337
|
+
function wrapStoreFn(fn, ssrSource) {
|
|
338
|
+
if (ssrSource === "initial") {
|
|
339
|
+
return draft => {
|
|
340
|
+
if (!sharedConfig.hydrating) return fn(draft);
|
|
341
|
+
subFetch(fn, draft);
|
|
342
|
+
return undefined;
|
|
343
|
+
};
|
|
344
|
+
}
|
|
345
|
+
return draft => {
|
|
346
|
+
const o = getOwner();
|
|
347
|
+
if (!sharedConfig.hydrating) return fn(draft);
|
|
348
|
+
let initP;
|
|
349
|
+
if (sharedConfig.has(o.id)) initP = sharedConfig.load(o.id);
|
|
350
|
+
const init = initP?.v ?? initP;
|
|
351
|
+
return init != null ? (subFetch(fn, draft), init) : fn(draft);
|
|
352
|
+
};
|
|
353
|
+
}
|
|
354
|
+
function hydratedCreateStore(first, second, third) {
|
|
355
|
+
if (typeof first !== "function" || !sharedConfig.hydrating) return createStore$1(first, second, third);
|
|
356
|
+
markTopLevelSnapshotScope();
|
|
357
|
+
const ssrSource = third?.ssrSource;
|
|
358
|
+
if (ssrSource === "client" || ssrSource === "initial") {
|
|
359
|
+
return createStore$1(second ?? {}, undefined, third);
|
|
360
|
+
}
|
|
361
|
+
const aiResult = hydrateStoreFromAsyncIterable(createStore$1, second ?? {}, third);
|
|
362
|
+
if (aiResult !== null) return aiResult;
|
|
363
|
+
return createStore$1(wrapStoreFn(first, ssrSource), second, third);
|
|
364
|
+
}
|
|
365
|
+
function hydratedCreateOptimisticStore(first, second, third) {
|
|
366
|
+
if (typeof first !== "function" || !sharedConfig.hydrating) return createOptimisticStore$1(first, second, third);
|
|
367
|
+
markTopLevelSnapshotScope();
|
|
368
|
+
const ssrSource = third?.ssrSource;
|
|
369
|
+
if (ssrSource === "client" || ssrSource === "initial") {
|
|
370
|
+
return createOptimisticStore$1(second ?? {}, undefined, third);
|
|
371
|
+
}
|
|
372
|
+
const aiResult = hydrateStoreFromAsyncIterable(createOptimisticStore$1, second ?? {}, third);
|
|
373
|
+
if (aiResult !== null) return aiResult;
|
|
374
|
+
return createOptimisticStore$1(wrapStoreFn(first, ssrSource), second, third);
|
|
375
|
+
}
|
|
376
|
+
function hydratedCreateProjection(fn, initialValue, options) {
|
|
377
|
+
if (!sharedConfig.hydrating) return createProjection$1(fn, initialValue, options);
|
|
378
|
+
markTopLevelSnapshotScope();
|
|
379
|
+
const ssrSource = options?.ssrSource;
|
|
380
|
+
if (ssrSource === "client" || ssrSource === "initial") {
|
|
381
|
+
return createProjection$1(draft => draft, initialValue, options);
|
|
382
|
+
}
|
|
383
|
+
const aiResult = hydrateStoreFromAsyncIterable(createStore$1, initialValue, options);
|
|
384
|
+
if (aiResult !== null) return aiResult[0];
|
|
385
|
+
return createProjection$1(wrapStoreFn(fn, ssrSource), initialValue, options);
|
|
386
|
+
}
|
|
387
|
+
function enableHydration() {
|
|
388
|
+
_createMemo = hydratedCreateMemo;
|
|
389
|
+
_createSignal = hydratedCreateSignal;
|
|
390
|
+
_createErrorBoundary = hydratedCreateErrorBoundary;
|
|
391
|
+
_createOptimistic = hydratedCreateOptimistic;
|
|
392
|
+
_createProjection = hydratedCreateProjection;
|
|
393
|
+
_createStore = hydratedCreateStore;
|
|
394
|
+
_createOptimisticStore = hydratedCreateOptimisticStore;
|
|
395
|
+
_hydratingValue = sharedConfig.hydrating;
|
|
396
|
+
_doneValue = sharedConfig.done;
|
|
397
|
+
Object.defineProperty(sharedConfig, "hydrating", {
|
|
398
|
+
get() {
|
|
399
|
+
return _hydratingValue;
|
|
400
|
+
},
|
|
401
|
+
set(v) {
|
|
402
|
+
const was = _hydratingValue;
|
|
403
|
+
_hydratingValue = v;
|
|
404
|
+
if (!was && v) {
|
|
405
|
+
_hydrationDone = false;
|
|
406
|
+
_doneValue = false;
|
|
407
|
+
_pendingBoundaries = 0;
|
|
408
|
+
setSnapshotCapture(true);
|
|
409
|
+
_snapshotRootOwner = null;
|
|
410
|
+
} else if (was && !v) {
|
|
411
|
+
if (_snapshotRootOwner) {
|
|
412
|
+
releaseSnapshotScope(_snapshotRootOwner);
|
|
413
|
+
_snapshotRootOwner = null;
|
|
414
|
+
}
|
|
415
|
+
checkHydrationComplete();
|
|
416
|
+
}
|
|
417
|
+
},
|
|
418
|
+
configurable: true,
|
|
419
|
+
enumerable: true
|
|
420
|
+
});
|
|
421
|
+
Object.defineProperty(sharedConfig, "done", {
|
|
422
|
+
get() {
|
|
423
|
+
return _doneValue;
|
|
424
|
+
},
|
|
425
|
+
set(v) {
|
|
426
|
+
_doneValue = v;
|
|
427
|
+
if (v) drainHydrationCallbacks();
|
|
428
|
+
},
|
|
429
|
+
configurable: true,
|
|
430
|
+
enumerable: true
|
|
431
|
+
});
|
|
432
|
+
}
|
|
433
|
+
const createMemo = (...args) => (_createMemo || createMemo$1)(...args);
|
|
434
|
+
const createSignal = (...args) => (_createSignal || createSignal$1)(...args);
|
|
435
|
+
const createErrorBoundary = (...args) => (_createErrorBoundary || createErrorBoundary$1)(...args);
|
|
436
|
+
const createOptimistic = (...args) => (_createOptimistic || createOptimistic$1)(...args);
|
|
437
|
+
const createProjection = (...args) => (_createProjection || createProjection$1)(...args);
|
|
438
|
+
const createStore = (...args) => (_createStore || createStore$1)(...args);
|
|
439
|
+
const createOptimisticStore = (...args) => (_createOptimisticStore || createOptimisticStore$1)(...args);
|
|
440
|
+
function loadModuleAssets(mapping) {
|
|
441
|
+
const hy = globalThis._$HY;
|
|
442
|
+
if (!hy) return;
|
|
443
|
+
if (!hy.modules) hy.modules = {};
|
|
444
|
+
if (!hy.loading) hy.loading = {};
|
|
445
|
+
const pending = [];
|
|
446
|
+
for (const moduleUrl in mapping) {
|
|
447
|
+
if (hy.modules[moduleUrl]) continue;
|
|
448
|
+
const entryUrl = mapping[moduleUrl];
|
|
449
|
+
if (!hy.loading[moduleUrl]) {
|
|
450
|
+
hy.loading[moduleUrl] = import(entryUrl).then(mod => {
|
|
451
|
+
hy.modules[moduleUrl] = mod;
|
|
452
|
+
});
|
|
453
|
+
}
|
|
454
|
+
pending.push(hy.loading[moduleUrl]);
|
|
455
|
+
}
|
|
456
|
+
return pending.length ? Promise.all(pending).then(() => {}) : undefined;
|
|
457
|
+
}
|
|
458
|
+
function createBoundaryTrigger() {
|
|
459
|
+
setSnapshotCapture(false);
|
|
460
|
+
const [s, set] = createSignal$1(undefined, {
|
|
461
|
+
equals: false
|
|
462
|
+
});
|
|
463
|
+
s();
|
|
464
|
+
setSnapshotCapture(true);
|
|
465
|
+
return set;
|
|
466
|
+
}
|
|
467
|
+
function resumeBoundaryHydration(o, id, set) {
|
|
468
|
+
_pendingBoundaries--;
|
|
469
|
+
if (isDisposed(o)) {
|
|
470
|
+
checkHydrationComplete();
|
|
471
|
+
return;
|
|
472
|
+
}
|
|
473
|
+
sharedConfig.gather(id);
|
|
474
|
+
_hydratingValue = true;
|
|
475
|
+
markSnapshotScope(o);
|
|
476
|
+
_snapshotRootOwner = o;
|
|
477
|
+
set();
|
|
478
|
+
flush();
|
|
479
|
+
_snapshotRootOwner = null;
|
|
480
|
+
_hydratingValue = false;
|
|
481
|
+
releaseSnapshotScope(o);
|
|
482
|
+
flush();
|
|
483
|
+
checkHydrationComplete();
|
|
484
|
+
}
|
|
83
485
|
function Loading(props) {
|
|
84
486
|
if (!sharedConfig.hydrating) return createLoadBoundary(() => props.children, () => props.fallback);
|
|
85
|
-
return createMemo(() => {
|
|
487
|
+
return createMemo$1(() => {
|
|
86
488
|
const o = getOwner();
|
|
87
489
|
const id = o.id;
|
|
490
|
+
let assetPromise;
|
|
491
|
+
if (sharedConfig.hydrating && sharedConfig.has(id + "_assets")) {
|
|
492
|
+
const mapping = sharedConfig.load(id + "_assets");
|
|
493
|
+
if (mapping && typeof mapping === "object") assetPromise = loadModuleAssets(mapping);
|
|
494
|
+
}
|
|
88
495
|
if (sharedConfig.hydrating && sharedConfig.has(id)) {
|
|
89
496
|
let ref = sharedConfig.load(id);
|
|
90
497
|
let p;
|
|
91
498
|
if (ref) {
|
|
92
|
-
if (typeof ref !== "object" || ref.s !==
|
|
499
|
+
if (typeof ref !== "object" || ref.s !== 1) p = ref;else sharedConfig.gather(id);
|
|
93
500
|
}
|
|
94
501
|
if (p) {
|
|
95
|
-
|
|
96
|
-
|
|
502
|
+
_pendingBoundaries++;
|
|
503
|
+
onCleanup(() => {
|
|
504
|
+
if (!isDisposed(o)) return;
|
|
505
|
+
sharedConfig.cleanupFragment?.(id);
|
|
97
506
|
});
|
|
98
|
-
|
|
507
|
+
const set = createBoundaryTrigger();
|
|
99
508
|
if (p !== "$$f") {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
509
|
+
const waitFor = assetPromise ? Promise.all([p, assetPromise]) : p;
|
|
510
|
+
waitFor.then(() => resumeBoundaryHydration(o, id, set), err => {
|
|
511
|
+
_pendingBoundaries--;
|
|
512
|
+
checkHydrationComplete();
|
|
513
|
+
runWithOwner(o, () => {
|
|
514
|
+
throw err;
|
|
515
|
+
});
|
|
516
|
+
});
|
|
517
|
+
} else {
|
|
518
|
+
const afterAssets = () => {
|
|
519
|
+
_pendingBoundaries--;
|
|
103
520
|
set();
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
}));
|
|
109
|
-
} else queueMicrotask(set);
|
|
521
|
+
checkHydrationComplete();
|
|
522
|
+
};
|
|
523
|
+
if (assetPromise) assetPromise.then(() => queueMicrotask(afterAssets));else queueMicrotask(afterAssets);
|
|
524
|
+
}
|
|
110
525
|
return props.fallback;
|
|
111
526
|
}
|
|
112
527
|
}
|
|
528
|
+
if (assetPromise) {
|
|
529
|
+
_pendingBoundaries++;
|
|
530
|
+
const set = createBoundaryTrigger();
|
|
531
|
+
assetPromise.then(() => resumeBoundaryHydration(o, id, set));
|
|
532
|
+
return undefined;
|
|
533
|
+
}
|
|
113
534
|
return createLoadBoundary(() => props.children, () => props.fallback);
|
|
114
535
|
});
|
|
115
536
|
}
|
|
116
537
|
|
|
117
|
-
function enableHydration() {
|
|
118
|
-
}
|
|
119
538
|
function createComponent(Comp, props) {
|
|
120
539
|
return devComponent(Comp, props || {});
|
|
121
540
|
}
|
|
122
|
-
function lazy(fn) {
|
|
541
|
+
function lazy(fn, moduleUrl) {
|
|
123
542
|
let comp;
|
|
124
543
|
let p;
|
|
125
544
|
const wrap = props => {
|
|
126
|
-
|
|
545
|
+
if (sharedConfig.hydrating && moduleUrl) {
|
|
546
|
+
const cached = globalThis._$HY?.modules?.[moduleUrl];
|
|
547
|
+
if (!cached) {
|
|
548
|
+
throw new Error(`lazy() module "${moduleUrl}" was not preloaded before hydration. ` + "Ensure it is inside a Loading boundary.");
|
|
549
|
+
}
|
|
550
|
+
comp = () => cached.default;
|
|
551
|
+
}
|
|
552
|
+
if (!comp) {
|
|
553
|
+
p || (p = fn());
|
|
554
|
+
p.then(mod => {
|
|
555
|
+
comp = () => mod.default;
|
|
556
|
+
});
|
|
557
|
+
comp = createMemo$1(() => p.then(mod => mod.default));
|
|
558
|
+
}
|
|
127
559
|
let Comp;
|
|
128
|
-
return createMemo(() => (Comp = comp()) ? untrack(() => {
|
|
560
|
+
return createMemo$1(() => (Comp = comp()) ? untrack(() => {
|
|
129
561
|
Object.assign(Comp, {
|
|
130
562
|
[$DEVCOMP]: true
|
|
131
563
|
});
|
|
@@ -148,6 +580,7 @@ function For(props) {
|
|
|
148
580
|
} : {
|
|
149
581
|
keyed: props.keyed
|
|
150
582
|
};
|
|
583
|
+
options.name = "<For>";
|
|
151
584
|
return mapArray(() => props.each, props.children, options);
|
|
152
585
|
}
|
|
153
586
|
function Repeat(props) {
|
|
@@ -155,26 +588,34 @@ function Repeat(props) {
|
|
|
155
588
|
fallback: () => props.fallback
|
|
156
589
|
} : {};
|
|
157
590
|
options.from = () => props.from;
|
|
591
|
+
options.name = "<Repeat>";
|
|
158
592
|
return repeat(() => props.count, index => typeof props.children === "function" ? props.children(index) : props.children, options);
|
|
159
593
|
}
|
|
160
594
|
function Show(props) {
|
|
161
595
|
const keyed = props.keyed;
|
|
162
|
-
const conditionValue = createMemo(() => props.when, undefined, {
|
|
596
|
+
const conditionValue = createMemo$1(() => props.when, undefined, {
|
|
163
597
|
name: "condition value"
|
|
164
598
|
} );
|
|
165
|
-
const condition = keyed ? conditionValue : createMemo(conditionValue, undefined, {
|
|
599
|
+
const condition = keyed ? conditionValue : createMemo$1(conditionValue, undefined, {
|
|
166
600
|
equals: (a, b) => !a === !b,
|
|
167
601
|
name: "condition"
|
|
168
602
|
} );
|
|
169
|
-
return createMemo(() => {
|
|
603
|
+
return createMemo$1(() => {
|
|
170
604
|
const c = condition();
|
|
171
605
|
if (c) {
|
|
172
606
|
const child = props.children;
|
|
173
607
|
const fn = typeof child === "function" && child.length > 0;
|
|
174
|
-
return fn ? untrack(() =>
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
608
|
+
return fn ? untrack(() => {
|
|
609
|
+
setStrictRead("<Show>");
|
|
610
|
+
try {
|
|
611
|
+
return child(() => {
|
|
612
|
+
if (!untrack(condition)) throw narrowedError("Show");
|
|
613
|
+
return conditionValue();
|
|
614
|
+
});
|
|
615
|
+
} finally {
|
|
616
|
+
setStrictRead(false);
|
|
617
|
+
}
|
|
618
|
+
}) : child;
|
|
178
619
|
}
|
|
179
620
|
return props.fallback;
|
|
180
621
|
}, undefined, {
|
|
@@ -183,17 +624,17 @@ function Show(props) {
|
|
|
183
624
|
}
|
|
184
625
|
function Switch(props) {
|
|
185
626
|
const chs = children(() => props.children);
|
|
186
|
-
const switchFunc = createMemo(() => {
|
|
627
|
+
const switchFunc = createMemo$1(() => {
|
|
187
628
|
const mps = chs.toArray();
|
|
188
629
|
let func = () => undefined;
|
|
189
630
|
for (let i = 0; i < mps.length; i++) {
|
|
190
631
|
const index = i;
|
|
191
632
|
const mp = mps[i];
|
|
192
633
|
const prevFunc = func;
|
|
193
|
-
const conditionValue = createMemo(() => prevFunc() ? undefined : mp.when, undefined, {
|
|
634
|
+
const conditionValue = createMemo$1(() => prevFunc() ? undefined : mp.when, undefined, {
|
|
194
635
|
name: "condition value"
|
|
195
636
|
} );
|
|
196
|
-
const condition = mp.keyed ? conditionValue : createMemo(conditionValue, undefined, {
|
|
637
|
+
const condition = mp.keyed ? conditionValue : createMemo$1(conditionValue, undefined, {
|
|
197
638
|
equals: (a, b) => !a === !b,
|
|
198
639
|
name: "condition"
|
|
199
640
|
} );
|
|
@@ -201,16 +642,23 @@ function Switch(props) {
|
|
|
201
642
|
}
|
|
202
643
|
return func;
|
|
203
644
|
});
|
|
204
|
-
return createMemo(() => {
|
|
645
|
+
return createMemo$1(() => {
|
|
205
646
|
const sel = switchFunc()();
|
|
206
647
|
if (!sel) return props.fallback;
|
|
207
648
|
const [index, conditionValue, mp] = sel;
|
|
208
649
|
const child = mp.children;
|
|
209
650
|
const fn = typeof child === "function" && child.length > 0;
|
|
210
|
-
return fn ? untrack(() =>
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
651
|
+
return fn ? untrack(() => {
|
|
652
|
+
setStrictRead("<Match>");
|
|
653
|
+
try {
|
|
654
|
+
return child(() => {
|
|
655
|
+
if (untrack(switchFunc)()?.[0] !== index) throw narrowedError("Match");
|
|
656
|
+
return conditionValue();
|
|
657
|
+
});
|
|
658
|
+
} finally {
|
|
659
|
+
setStrictRead(false);
|
|
660
|
+
}
|
|
661
|
+
}) : child;
|
|
214
662
|
}, undefined, {
|
|
215
663
|
name: "eval conditions"
|
|
216
664
|
} );
|
|
@@ -225,9 +673,6 @@ function Errored(props) {
|
|
|
225
673
|
return typeof f === "function" && f.length ? f(err, reset) : f;
|
|
226
674
|
});
|
|
227
675
|
}
|
|
228
|
-
function Boundary(props) {
|
|
229
|
-
return createBoundary(() => props.children, () => props.mode);
|
|
230
|
-
}
|
|
231
676
|
|
|
232
677
|
function ssrHandleError() {}
|
|
233
678
|
function ssrRunInScope() {}
|
|
@@ -240,4 +685,4 @@ if (globalThis) {
|
|
|
240
685
|
if (!globalThis.Solid$$) globalThis.Solid$$ = true;else console.warn("You appear to have multiple instances of Solid. This can lead to unexpected behavior.");
|
|
241
686
|
}
|
|
242
687
|
|
|
243
|
-
export { $DEVCOMP,
|
|
688
|
+
export { $DEVCOMP, DEV, Errored, For, Loading, Match, Repeat, Show, Switch, children, createComponent, createContext, createMemo, createOptimistic, createOptimisticStore, createProjection, createSignal, createStore, createUniqueId, enableHydration, lazy, sharedConfig, ssrHandleError, ssrRunInScope, useContext };
|