solid-js 2.0.0-experimental.14 → 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 +429 -41
- package/dist/dev.js +427 -27
- package/dist/server.cjs +335 -43
- package/dist/server.js +336 -45
- package/dist/solid.cjs +415 -40
- package/dist/solid.js +413 -26
- package/package.json +2 -2
- package/types/client/component.d.ts +1 -1
- package/types/client/hydration.d.ts +34 -2
- package/types/server/component.d.ts +6 -2
- package/types/server/index.d.ts +2 -2
- package/types/server/shared.d.ts +22 -1
- package/types/server/signals.d.ts +8 -2
package/dist/dev.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { getContext, createMemo as createMemo$1, flatten, createRoot, setContext,
|
|
2
|
-
export { $PROXY, $TRACK, NotReadyError, 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) {
|
|
@@ -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) {
|
|
@@ -59,8 +66,44 @@ const sharedConfig = {
|
|
|
59
66
|
return getNextChildId(o);
|
|
60
67
|
}
|
|
61
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;
|
|
62
100
|
let _createMemo;
|
|
63
101
|
let _createSignal;
|
|
102
|
+
let _createErrorBoundary;
|
|
103
|
+
let _createOptimistic;
|
|
104
|
+
let _createProjection;
|
|
105
|
+
let _createStore;
|
|
106
|
+
let _createOptimisticStore;
|
|
64
107
|
class MockPromise {
|
|
65
108
|
static all() {
|
|
66
109
|
return new MockPromise();
|
|
@@ -96,14 +139,110 @@ function subFetch(fn, prev) {
|
|
|
96
139
|
try {
|
|
97
140
|
window.fetch = () => new MockPromise();
|
|
98
141
|
Promise = MockPromise;
|
|
99
|
-
|
|
142
|
+
const result = fn(prev);
|
|
143
|
+
if (result && typeof result[Symbol.asyncIterator] === "function") {
|
|
144
|
+
result[Symbol.asyncIterator]().next();
|
|
145
|
+
}
|
|
146
|
+
return result;
|
|
100
147
|
} finally {
|
|
101
148
|
window.fetch = ogFetch;
|
|
102
149
|
Promise = ogPromise;
|
|
103
150
|
}
|
|
104
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
|
+
}
|
|
105
224
|
function hydratedCreateMemo(compute, value, options) {
|
|
106
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;
|
|
107
246
|
return createMemo$1(prev => {
|
|
108
247
|
const o = getOwner();
|
|
109
248
|
if (!sharedConfig.hydrating) return compute(prev);
|
|
@@ -115,6 +254,26 @@ function hydratedCreateMemo(compute, value, options) {
|
|
|
115
254
|
}
|
|
116
255
|
function hydratedCreateSignal(fn, second, third) {
|
|
117
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;
|
|
118
277
|
return createSignal$1(prev => {
|
|
119
278
|
if (!sharedConfig.hydrating) return fn(prev);
|
|
120
279
|
const o = getOwner();
|
|
@@ -124,17 +283,215 @@ function hydratedCreateSignal(fn, second, third) {
|
|
|
124
283
|
return init != null ? (subFetch(fn, prev), init) : fn(prev);
|
|
125
284
|
}, second, third);
|
|
126
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
|
+
}
|
|
127
387
|
function enableHydration() {
|
|
128
388
|
_createMemo = hydratedCreateMemo;
|
|
129
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
|
+
});
|
|
130
432
|
}
|
|
131
433
|
const createMemo = (...args) => (_createMemo || createMemo$1)(...args);
|
|
132
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
|
+
}
|
|
133
485
|
function Loading(props) {
|
|
134
486
|
if (!sharedConfig.hydrating) return createLoadBoundary(() => props.children, () => props.fallback);
|
|
135
487
|
return createMemo$1(() => {
|
|
136
488
|
const o = getOwner();
|
|
137
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
|
+
}
|
|
138
495
|
if (sharedConfig.hydrating && sharedConfig.has(id)) {
|
|
139
496
|
let ref = sharedConfig.load(id);
|
|
140
497
|
let p;
|
|
@@ -142,24 +499,38 @@ function Loading(props) {
|
|
|
142
499
|
if (typeof ref !== "object" || ref.s !== 1) p = ref;else sharedConfig.gather(id);
|
|
143
500
|
}
|
|
144
501
|
if (p) {
|
|
145
|
-
|
|
146
|
-
|
|
502
|
+
_pendingBoundaries++;
|
|
503
|
+
onCleanup(() => {
|
|
504
|
+
if (!isDisposed(o)) return;
|
|
505
|
+
sharedConfig.cleanupFragment?.(id);
|
|
147
506
|
});
|
|
148
|
-
|
|
507
|
+
const set = createBoundaryTrigger();
|
|
149
508
|
if (p !== "$$f") {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
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--;
|
|
153
520
|
set();
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
}));
|
|
159
|
-
} else queueMicrotask(set);
|
|
521
|
+
checkHydrationComplete();
|
|
522
|
+
};
|
|
523
|
+
if (assetPromise) assetPromise.then(() => queueMicrotask(afterAssets));else queueMicrotask(afterAssets);
|
|
524
|
+
}
|
|
160
525
|
return props.fallback;
|
|
161
526
|
}
|
|
162
527
|
}
|
|
528
|
+
if (assetPromise) {
|
|
529
|
+
_pendingBoundaries++;
|
|
530
|
+
const set = createBoundaryTrigger();
|
|
531
|
+
assetPromise.then(() => resumeBoundaryHydration(o, id, set));
|
|
532
|
+
return undefined;
|
|
533
|
+
}
|
|
163
534
|
return createLoadBoundary(() => props.children, () => props.fallback);
|
|
164
535
|
});
|
|
165
536
|
}
|
|
@@ -167,11 +538,24 @@ function Loading(props) {
|
|
|
167
538
|
function createComponent(Comp, props) {
|
|
168
539
|
return devComponent(Comp, props || {});
|
|
169
540
|
}
|
|
170
|
-
function lazy(fn) {
|
|
541
|
+
function lazy(fn, moduleUrl) {
|
|
171
542
|
let comp;
|
|
172
543
|
let p;
|
|
173
544
|
const wrap = props => {
|
|
174
|
-
|
|
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
|
+
}
|
|
175
559
|
let Comp;
|
|
176
560
|
return createMemo$1(() => (Comp = comp()) ? untrack(() => {
|
|
177
561
|
Object.assign(Comp, {
|
|
@@ -196,6 +580,7 @@ function For(props) {
|
|
|
196
580
|
} : {
|
|
197
581
|
keyed: props.keyed
|
|
198
582
|
};
|
|
583
|
+
options.name = "<For>";
|
|
199
584
|
return mapArray(() => props.each, props.children, options);
|
|
200
585
|
}
|
|
201
586
|
function Repeat(props) {
|
|
@@ -203,6 +588,7 @@ function Repeat(props) {
|
|
|
203
588
|
fallback: () => props.fallback
|
|
204
589
|
} : {};
|
|
205
590
|
options.from = () => props.from;
|
|
591
|
+
options.name = "<Repeat>";
|
|
206
592
|
return repeat(() => props.count, index => typeof props.children === "function" ? props.children(index) : props.children, options);
|
|
207
593
|
}
|
|
208
594
|
function Show(props) {
|
|
@@ -219,10 +605,17 @@ function Show(props) {
|
|
|
219
605
|
if (c) {
|
|
220
606
|
const child = props.children;
|
|
221
607
|
const fn = typeof child === "function" && child.length > 0;
|
|
222
|
-
return fn ? untrack(() =>
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
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;
|
|
226
619
|
}
|
|
227
620
|
return props.fallback;
|
|
228
621
|
}, undefined, {
|
|
@@ -255,10 +648,17 @@ function Switch(props) {
|
|
|
255
648
|
const [index, conditionValue, mp] = sel;
|
|
256
649
|
const child = mp.children;
|
|
257
650
|
const fn = typeof child === "function" && child.length > 0;
|
|
258
|
-
return fn ? untrack(() =>
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
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;
|
|
262
662
|
}, undefined, {
|
|
263
663
|
name: "eval conditions"
|
|
264
664
|
} );
|
|
@@ -285,4 +685,4 @@ if (globalThis) {
|
|
|
285
685
|
if (!globalThis.Solid$$) globalThis.Solid$$ = true;else console.warn("You appear to have multiple instances of Solid. This can lead to unexpected behavior.");
|
|
286
686
|
}
|
|
287
687
|
|
|
288
|
-
export { $DEVCOMP, DEV, Errored, For, Loading, Match, Repeat, Show, Switch, children, createComponent, createContext, createMemo, createSignal, createUniqueId, enableHydration, lazy, sharedConfig, ssrHandleError, ssrRunInScope, useContext };
|
|
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 };
|