solid-js 2.0.0-beta.6 → 2.0.0-beta.7
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 +56 -74
- package/dist/dev.js +56 -74
- package/dist/server.cjs +209 -95
- package/dist/server.js +209 -95
- package/dist/solid.cjs +56 -74
- package/dist/solid.js +56 -74
- package/package.json +78 -30
- package/types/client/hydration.d.ts +4 -3
- package/types/jsx-properties.d.ts +95 -0
- package/types/jsx.d.ts +282 -237
- package/types/server/signals.d.ts +8 -10
- package/types-cjs/client/component.d.cts +75 -0
- package/types-cjs/client/core.d.cts +58 -0
- package/types-cjs/client/flow.d.cts +142 -0
- package/types-cjs/client/hydration.d.cts +96 -0
- package/types-cjs/index.d.cts +17 -0
- package/types-cjs/jsx-properties.d.cts +95 -0
- package/types-cjs/jsx.d.cts +4263 -0
- package/types-cjs/package.json +3 -0
- package/types-cjs/server/component.d.cts +67 -0
- package/types-cjs/server/core.d.cts +44 -0
- package/types-cjs/server/flow.d.cts +82 -0
- package/types-cjs/server/hydration.d.cts +46 -0
- package/types-cjs/server/index.d.cts +12 -0
- package/types-cjs/server/shared.d.cts +50 -0
- package/types-cjs/server/signals.d.cts +67 -0
package/dist/solid.cjs
CHANGED
|
@@ -20,10 +20,10 @@ function useContext(context) {
|
|
|
20
20
|
return signals.getContext(context);
|
|
21
21
|
}
|
|
22
22
|
function children(fn) {
|
|
23
|
-
const c = signals.createMemo(fn,
|
|
23
|
+
const c = signals.createMemo(fn, {
|
|
24
24
|
lazy: true
|
|
25
25
|
});
|
|
26
|
-
const memo = signals.createMemo(() => signals.flatten(c()),
|
|
26
|
+
const memo = signals.createMemo(() => signals.flatten(c()), {
|
|
27
27
|
lazy: true
|
|
28
28
|
});
|
|
29
29
|
memo.toArray = () => {
|
|
@@ -265,7 +265,7 @@ function wrapFirstYield(iterable, activate) {
|
|
|
265
265
|
}
|
|
266
266
|
};
|
|
267
267
|
}
|
|
268
|
-
function hydrateSignalFromAsyncIterable(coreFn, compute,
|
|
268
|
+
function hydrateSignalFromAsyncIterable(coreFn, compute, options) {
|
|
269
269
|
const parent = signals.getOwner();
|
|
270
270
|
const expectedId = signals.peekNextChildId(parent);
|
|
271
271
|
if (!sharedConfig.has(expectedId)) return null;
|
|
@@ -277,7 +277,7 @@ function hydrateSignalFromAsyncIterable(coreFn, compute, value, options) {
|
|
|
277
277
|
return it;
|
|
278
278
|
}
|
|
279
279
|
};
|
|
280
|
-
return coreFn(() => iterable,
|
|
280
|
+
return coreFn(() => iterable, options);
|
|
281
281
|
}
|
|
282
282
|
function hydrateStoreFromAsyncIterable(coreFn, initialValue, options) {
|
|
283
283
|
const parent = signals.getOwner();
|
|
@@ -352,20 +352,20 @@ function hydrateStoreFromAsyncIterable(coreFn, initialValue, options) {
|
|
|
352
352
|
};
|
|
353
353
|
}, initialValue, options);
|
|
354
354
|
}
|
|
355
|
-
function hydratedCreateMemo(compute,
|
|
355
|
+
function hydratedCreateMemo(compute, options) {
|
|
356
356
|
if (!sharedConfig.hydrating || options?.transparent) {
|
|
357
|
-
return signals.createMemo(compute,
|
|
357
|
+
return signals.createMemo(compute, options);
|
|
358
358
|
}
|
|
359
359
|
markTopLevelSnapshotScope();
|
|
360
360
|
const ssrSource = options?.ssrSource;
|
|
361
361
|
if (ssrSource === "client") {
|
|
362
362
|
const [hydrated, setHydrated] = signals.createSignal(false, {
|
|
363
|
-
|
|
363
|
+
ownedWrite: true
|
|
364
364
|
});
|
|
365
365
|
const memo = signals.createMemo(prev => {
|
|
366
|
-
if (!hydrated()) return prev
|
|
366
|
+
if (!hydrated()) return prev;
|
|
367
367
|
return compute(prev);
|
|
368
|
-
},
|
|
368
|
+
}, options);
|
|
369
369
|
setHydrated(true);
|
|
370
370
|
return memo;
|
|
371
371
|
}
|
|
@@ -373,25 +373,25 @@ function hydratedCreateMemo(compute, value, options) {
|
|
|
373
373
|
return signals.createMemo(prev => {
|
|
374
374
|
if (!sharedConfig.hydrating) return compute(prev);
|
|
375
375
|
subFetch(compute, prev);
|
|
376
|
-
return prev
|
|
377
|
-
},
|
|
376
|
+
return prev;
|
|
377
|
+
}, options);
|
|
378
378
|
}
|
|
379
|
-
const aiResult = hydrateSignalFromAsyncIterable(signals.createMemo, compute,
|
|
379
|
+
const aiResult = hydrateSignalFromAsyncIterable(signals.createMemo, compute, options);
|
|
380
380
|
if (aiResult !== null) return aiResult;
|
|
381
|
-
return signals.createMemo(prev => readSerializedOrCompute(compute, prev),
|
|
381
|
+
return signals.createMemo(prev => readSerializedOrCompute(compute, prev), options);
|
|
382
382
|
}
|
|
383
|
-
function hydratedCreateSignal(fn, second
|
|
384
|
-
if (typeof fn !== "function" || !sharedConfig.hydrating) return signals.createSignal(fn, second
|
|
383
|
+
function hydratedCreateSignal(fn, second) {
|
|
384
|
+
if (typeof fn !== "function" || !sharedConfig.hydrating) return signals.createSignal(fn, second);
|
|
385
385
|
markTopLevelSnapshotScope();
|
|
386
|
-
const ssrSource =
|
|
386
|
+
const ssrSource = second?.ssrSource;
|
|
387
387
|
if (ssrSource === "client") {
|
|
388
388
|
const [hydrated, setHydrated] = signals.createSignal(false, {
|
|
389
|
-
|
|
389
|
+
ownedWrite: true
|
|
390
390
|
});
|
|
391
391
|
const sig = signals.createSignal(prev => {
|
|
392
|
-
if (!hydrated()) return prev
|
|
392
|
+
if (!hydrated()) return prev;
|
|
393
393
|
return fn(prev);
|
|
394
|
-
}, second
|
|
394
|
+
}, second);
|
|
395
395
|
setHydrated(true);
|
|
396
396
|
return sig;
|
|
397
397
|
}
|
|
@@ -399,12 +399,12 @@ function hydratedCreateSignal(fn, second, third) {
|
|
|
399
399
|
return signals.createSignal(prev => {
|
|
400
400
|
if (!sharedConfig.hydrating) return fn(prev);
|
|
401
401
|
subFetch(fn, prev);
|
|
402
|
-
return prev
|
|
403
|
-
}, second
|
|
402
|
+
return prev;
|
|
403
|
+
}, second);
|
|
404
404
|
}
|
|
405
|
-
const aiResult = hydrateSignalFromAsyncIterable(signals.createSignal, fn, second
|
|
405
|
+
const aiResult = hydrateSignalFromAsyncIterable(signals.createSignal, fn, second);
|
|
406
406
|
if (aiResult !== null) return aiResult;
|
|
407
|
-
return signals.createSignal(prev => readSerializedOrCompute(fn, prev), second
|
|
407
|
+
return signals.createSignal(prev => readSerializedOrCompute(fn, prev), second);
|
|
408
408
|
}
|
|
409
409
|
function hydratedCreateErrorBoundary(fn, fallback) {
|
|
410
410
|
if (!sharedConfig.hydrating) return signals.createErrorBoundary(fn, fallback);
|
|
@@ -426,18 +426,18 @@ function hydratedCreateErrorBoundary(fn, fallback) {
|
|
|
426
426
|
}
|
|
427
427
|
return signals.createErrorBoundary(fn, fallback);
|
|
428
428
|
}
|
|
429
|
-
function hydratedCreateOptimistic(fn, second
|
|
430
|
-
if (typeof fn !== "function" || !sharedConfig.hydrating) return signals.createOptimistic(fn, second
|
|
429
|
+
function hydratedCreateOptimistic(fn, second) {
|
|
430
|
+
if (typeof fn !== "function" || !sharedConfig.hydrating) return signals.createOptimistic(fn, second);
|
|
431
431
|
markTopLevelSnapshotScope();
|
|
432
|
-
const ssrSource =
|
|
432
|
+
const ssrSource = second?.ssrSource;
|
|
433
433
|
if (ssrSource === "client") {
|
|
434
434
|
const [hydrated, setHydrated] = signals.createSignal(false, {
|
|
435
|
-
|
|
435
|
+
ownedWrite: true
|
|
436
436
|
});
|
|
437
437
|
const sig = signals.createOptimistic(prev => {
|
|
438
|
-
if (!hydrated()) return prev
|
|
438
|
+
if (!hydrated()) return prev;
|
|
439
439
|
return fn(prev);
|
|
440
|
-
}, second
|
|
440
|
+
}, second);
|
|
441
441
|
setHydrated(true);
|
|
442
442
|
return sig;
|
|
443
443
|
}
|
|
@@ -445,12 +445,12 @@ function hydratedCreateOptimistic(fn, second, third) {
|
|
|
445
445
|
return signals.createOptimistic(prev => {
|
|
446
446
|
if (!sharedConfig.hydrating) return fn(prev);
|
|
447
447
|
subFetch(fn, prev);
|
|
448
|
-
return prev
|
|
449
|
-
}, second
|
|
448
|
+
return prev;
|
|
449
|
+
}, second);
|
|
450
450
|
}
|
|
451
|
-
const aiResult = hydrateSignalFromAsyncIterable(signals.createOptimistic, fn, second
|
|
451
|
+
const aiResult = hydrateSignalFromAsyncIterable(signals.createOptimistic, fn, second);
|
|
452
452
|
if (aiResult !== null) return aiResult;
|
|
453
|
-
return signals.createOptimistic(prev => readSerializedOrCompute(fn, prev), second
|
|
453
|
+
return signals.createOptimistic(prev => readSerializedOrCompute(fn, prev), second);
|
|
454
454
|
}
|
|
455
455
|
function wrapStoreFn(fn) {
|
|
456
456
|
return draft => readSerializedOrCompute(() => fn(draft), draft);
|
|
@@ -458,7 +458,7 @@ function wrapStoreFn(fn) {
|
|
|
458
458
|
function hydrateStoreLikeFn(coreFn, fn, initialValue, options, ssrSource) {
|
|
459
459
|
if (ssrSource === "client") {
|
|
460
460
|
const [hydrated, setHydrated] = signals.createSignal(false, {
|
|
461
|
-
|
|
461
|
+
ownedWrite: true
|
|
462
462
|
});
|
|
463
463
|
const result = coreFn(draft => {
|
|
464
464
|
if (!hydrated()) return;
|
|
@@ -469,7 +469,7 @@ function hydrateStoreLikeFn(coreFn, fn, initialValue, options, ssrSource) {
|
|
|
469
469
|
}
|
|
470
470
|
if (ssrSource === "hybrid") {
|
|
471
471
|
const [hydrated, setHydrated] = signals.createSignal(false, {
|
|
472
|
-
|
|
472
|
+
ownedWrite: true
|
|
473
473
|
});
|
|
474
474
|
const result = coreFn(draft => {
|
|
475
475
|
const o = signals.getOwner();
|
|
@@ -499,14 +499,14 @@ function hydratedCreateStore(first, second, third) {
|
|
|
499
499
|
if (typeof first !== "function" || !sharedConfig.hydrating) return signals.createStore(first, second, third);
|
|
500
500
|
markTopLevelSnapshotScope();
|
|
501
501
|
const ssrSource = third?.ssrSource;
|
|
502
|
-
if (ssrSource === "initial") return signals.createStore(second ?? {}
|
|
502
|
+
if (ssrSource === "initial") return signals.createStore(second ?? {});
|
|
503
503
|
return hydrateStoreLikeFn(signals.createStore, first, second ?? {}, third, ssrSource);
|
|
504
504
|
}
|
|
505
505
|
function hydratedCreateOptimisticStore(first, second, third) {
|
|
506
506
|
if (typeof first !== "function" || !sharedConfig.hydrating) return signals.createOptimisticStore(first, second, third);
|
|
507
507
|
markTopLevelSnapshotScope();
|
|
508
508
|
const ssrSource = third?.ssrSource;
|
|
509
|
-
if (ssrSource === "initial") return signals.createOptimisticStore(second ?? {}
|
|
509
|
+
if (ssrSource === "initial") return signals.createOptimisticStore(second ?? {});
|
|
510
510
|
return hydrateStoreLikeFn(signals.createOptimisticStore, first, second ?? {}, third, ssrSource);
|
|
511
511
|
}
|
|
512
512
|
function hydratedCreateProjection(fn, initialValue, options) {
|
|
@@ -516,22 +516,22 @@ function hydratedCreateProjection(fn, initialValue, options) {
|
|
|
516
516
|
if (ssrSource === "initial") return signals.createProjection(draft => draft, initialValue, options);
|
|
517
517
|
return hydrateStoreLikeFn(signals.createProjection, fn, initialValue, options, ssrSource);
|
|
518
518
|
}
|
|
519
|
-
function hydratedEffect(coreFn, compute, effectFn,
|
|
520
|
-
if (!sharedConfig.hydrating) return coreFn(compute, effectFn,
|
|
519
|
+
function hydratedEffect(coreFn, compute, effectFn, options) {
|
|
520
|
+
if (!sharedConfig.hydrating || options?.transparent) return coreFn(compute, effectFn, options);
|
|
521
521
|
const ssrSource = options?.ssrSource;
|
|
522
522
|
if (ssrSource === "client") {
|
|
523
523
|
const [hydrated, setHydrated] = signals.createSignal(false, {
|
|
524
|
-
|
|
524
|
+
ownedWrite: true
|
|
525
525
|
});
|
|
526
526
|
let active = false;
|
|
527
527
|
coreFn(prev => {
|
|
528
|
-
if (!hydrated()) return
|
|
528
|
+
if (!hydrated()) return prev;
|
|
529
529
|
active = true;
|
|
530
530
|
return compute(prev);
|
|
531
531
|
}, (next, prev) => {
|
|
532
532
|
if (!active) return;
|
|
533
533
|
return effectFn(next, prev);
|
|
534
|
-
},
|
|
534
|
+
}, options);
|
|
535
535
|
setHydrated(true);
|
|
536
536
|
return;
|
|
537
537
|
}
|
|
@@ -539,18 +539,18 @@ function hydratedEffect(coreFn, compute, effectFn, value, options) {
|
|
|
539
539
|
coreFn(prev => {
|
|
540
540
|
if (!sharedConfig.hydrating) return compute(prev);
|
|
541
541
|
subFetch(compute, prev);
|
|
542
|
-
return prev
|
|
543
|
-
}, effectFn,
|
|
542
|
+
return prev;
|
|
543
|
+
}, effectFn, options);
|
|
544
544
|
return;
|
|
545
545
|
}
|
|
546
546
|
markTopLevelSnapshotScope();
|
|
547
|
-
coreFn(prev => readSerializedOrCompute(compute, prev), effectFn,
|
|
547
|
+
coreFn(prev => readSerializedOrCompute(compute, prev), effectFn, options);
|
|
548
548
|
}
|
|
549
|
-
function hydratedCreateRenderEffect(compute, effectFn,
|
|
550
|
-
return hydratedEffect(signals.createRenderEffect, compute, effectFn,
|
|
549
|
+
function hydratedCreateRenderEffect(compute, effectFn, options) {
|
|
550
|
+
return hydratedEffect(signals.createRenderEffect, compute, effectFn, options);
|
|
551
551
|
}
|
|
552
|
-
function hydratedCreateEffect(compute, effectFn,
|
|
553
|
-
return hydratedEffect(signals.createEffect, compute, effectFn,
|
|
552
|
+
function hydratedCreateEffect(compute, effectFn, options) {
|
|
553
|
+
return hydratedEffect(signals.createEffect, compute, effectFn, options);
|
|
554
554
|
}
|
|
555
555
|
function enableHydration() {
|
|
556
556
|
_createMemo = hydratedCreateMemo;
|
|
@@ -609,24 +609,6 @@ const createStore = (...args) => (_createStore || signals.createStore)(...args);
|
|
|
609
609
|
const createOptimisticStore = (...args) => (_createOptimisticStore || signals.createOptimisticStore)(...args);
|
|
610
610
|
const createRenderEffect = (...args) => (_createRenderEffect || signals.createRenderEffect)(...args);
|
|
611
611
|
const createEffect = (...args) => (_createEffect || signals.createEffect)(...args);
|
|
612
|
-
function loadModuleAssets(mapping) {
|
|
613
|
-
const hy = globalThis._$HY;
|
|
614
|
-
if (!hy) return;
|
|
615
|
-
if (!hy.modules) hy.modules = {};
|
|
616
|
-
if (!hy.loading) hy.loading = {};
|
|
617
|
-
const pending = [];
|
|
618
|
-
for (const moduleUrl in mapping) {
|
|
619
|
-
if (hy.modules[moduleUrl]) continue;
|
|
620
|
-
const entryUrl = mapping[moduleUrl];
|
|
621
|
-
if (!hy.loading[moduleUrl]) {
|
|
622
|
-
hy.loading[moduleUrl] = import(entryUrl).then(mod => {
|
|
623
|
-
hy.modules[moduleUrl] = mod;
|
|
624
|
-
});
|
|
625
|
-
}
|
|
626
|
-
pending.push(hy.loading[moduleUrl]);
|
|
627
|
-
}
|
|
628
|
-
return pending.length ? Promise.all(pending).then(() => {}) : undefined;
|
|
629
|
-
}
|
|
630
612
|
function createBoundaryTrigger() {
|
|
631
613
|
signals.setSnapshotCapture(false);
|
|
632
614
|
const [s, set] = signals.createSignal(undefined, {
|
|
@@ -695,7 +677,7 @@ function createLoadingBoundary(fn, fallback, options) {
|
|
|
695
677
|
let assetPromise;
|
|
696
678
|
if (sharedConfig.hydrating && sharedConfig.has(id + "_assets")) {
|
|
697
679
|
const mapping = sharedConfig.load(id + "_assets");
|
|
698
|
-
if (mapping && typeof mapping === "object") assetPromise = loadModuleAssets(mapping);
|
|
680
|
+
if (mapping && typeof mapping === "object") assetPromise = sharedConfig.loadModuleAssets?.(mapping);
|
|
699
681
|
}
|
|
700
682
|
if (sharedConfig.hydrating && sharedConfig.has(id)) {
|
|
701
683
|
const ref = sharedConfig.load(id);
|
|
@@ -809,8 +791,8 @@ function Repeat(props) {
|
|
|
809
791
|
}
|
|
810
792
|
function Show(props) {
|
|
811
793
|
const keyed = props.keyed;
|
|
812
|
-
const conditionValue = signals.createMemo(() => props.when, undefined
|
|
813
|
-
const condition = keyed ? conditionValue : signals.createMemo(conditionValue,
|
|
794
|
+
const conditionValue = signals.createMemo(() => props.when, undefined);
|
|
795
|
+
const condition = keyed ? conditionValue : signals.createMemo(conditionValue, {
|
|
814
796
|
equals: (a, b) => !a === !b
|
|
815
797
|
});
|
|
816
798
|
return signals.createMemo(() => {
|
|
@@ -824,7 +806,7 @@ function Show(props) {
|
|
|
824
806
|
}), IS_DEV) : child;
|
|
825
807
|
}
|
|
826
808
|
return props.fallback;
|
|
827
|
-
}, undefined
|
|
809
|
+
}, undefined);
|
|
828
810
|
}
|
|
829
811
|
function Switch(props) {
|
|
830
812
|
const chs = children(() => props.children);
|
|
@@ -835,8 +817,8 @@ function Switch(props) {
|
|
|
835
817
|
const index = i;
|
|
836
818
|
const mp = mps[i];
|
|
837
819
|
const prevFunc = func;
|
|
838
|
-
const conditionValue = signals.createMemo(() => prevFunc() ? undefined : mp.when, undefined
|
|
839
|
-
const condition = mp.keyed ? conditionValue : signals.createMemo(conditionValue,
|
|
820
|
+
const conditionValue = signals.createMemo(() => prevFunc() ? undefined : mp.when, undefined);
|
|
821
|
+
const condition = mp.keyed ? conditionValue : signals.createMemo(conditionValue, {
|
|
840
822
|
equals: (a, b) => !a === !b
|
|
841
823
|
});
|
|
842
824
|
func = () => prevFunc() || (condition() ? [index, conditionValue, mp] : undefined);
|
|
@@ -853,7 +835,7 @@ function Switch(props) {
|
|
|
853
835
|
if (signals.untrack(switchFunc)()?.[0] !== index) throw narrowedError("Match");
|
|
854
836
|
return conditionValue();
|
|
855
837
|
}), IS_DEV) : child;
|
|
856
|
-
}, undefined
|
|
838
|
+
}, undefined);
|
|
857
839
|
}
|
|
858
840
|
function Match(props) {
|
|
859
841
|
return props;
|
package/dist/solid.js
CHANGED
|
@@ -19,10 +19,10 @@ function useContext(context) {
|
|
|
19
19
|
return getContext(context);
|
|
20
20
|
}
|
|
21
21
|
function children(fn) {
|
|
22
|
-
const c = createMemo$1(fn,
|
|
22
|
+
const c = createMemo$1(fn, {
|
|
23
23
|
lazy: true
|
|
24
24
|
});
|
|
25
|
-
const memo = createMemo$1(() => flatten(c()),
|
|
25
|
+
const memo = createMemo$1(() => flatten(c()), {
|
|
26
26
|
lazy: true
|
|
27
27
|
});
|
|
28
28
|
memo.toArray = () => {
|
|
@@ -264,7 +264,7 @@ function wrapFirstYield(iterable, activate) {
|
|
|
264
264
|
}
|
|
265
265
|
};
|
|
266
266
|
}
|
|
267
|
-
function hydrateSignalFromAsyncIterable(coreFn, compute,
|
|
267
|
+
function hydrateSignalFromAsyncIterable(coreFn, compute, options) {
|
|
268
268
|
const parent = getOwner();
|
|
269
269
|
const expectedId = peekNextChildId(parent);
|
|
270
270
|
if (!sharedConfig.has(expectedId)) return null;
|
|
@@ -276,7 +276,7 @@ function hydrateSignalFromAsyncIterable(coreFn, compute, value, options) {
|
|
|
276
276
|
return it;
|
|
277
277
|
}
|
|
278
278
|
};
|
|
279
|
-
return coreFn(() => iterable,
|
|
279
|
+
return coreFn(() => iterable, options);
|
|
280
280
|
}
|
|
281
281
|
function hydrateStoreFromAsyncIterable(coreFn, initialValue, options) {
|
|
282
282
|
const parent = getOwner();
|
|
@@ -351,20 +351,20 @@ function hydrateStoreFromAsyncIterable(coreFn, initialValue, options) {
|
|
|
351
351
|
};
|
|
352
352
|
}, initialValue, options);
|
|
353
353
|
}
|
|
354
|
-
function hydratedCreateMemo(compute,
|
|
354
|
+
function hydratedCreateMemo(compute, options) {
|
|
355
355
|
if (!sharedConfig.hydrating || options?.transparent) {
|
|
356
|
-
return createMemo$1(compute,
|
|
356
|
+
return createMemo$1(compute, options);
|
|
357
357
|
}
|
|
358
358
|
markTopLevelSnapshotScope();
|
|
359
359
|
const ssrSource = options?.ssrSource;
|
|
360
360
|
if (ssrSource === "client") {
|
|
361
361
|
const [hydrated, setHydrated] = createSignal$1(false, {
|
|
362
|
-
|
|
362
|
+
ownedWrite: true
|
|
363
363
|
});
|
|
364
364
|
const memo = createMemo$1(prev => {
|
|
365
|
-
if (!hydrated()) return prev
|
|
365
|
+
if (!hydrated()) return prev;
|
|
366
366
|
return compute(prev);
|
|
367
|
-
},
|
|
367
|
+
}, options);
|
|
368
368
|
setHydrated(true);
|
|
369
369
|
return memo;
|
|
370
370
|
}
|
|
@@ -372,25 +372,25 @@ function hydratedCreateMemo(compute, value, options) {
|
|
|
372
372
|
return createMemo$1(prev => {
|
|
373
373
|
if (!sharedConfig.hydrating) return compute(prev);
|
|
374
374
|
subFetch(compute, prev);
|
|
375
|
-
return prev
|
|
376
|
-
},
|
|
375
|
+
return prev;
|
|
376
|
+
}, options);
|
|
377
377
|
}
|
|
378
|
-
const aiResult = hydrateSignalFromAsyncIterable(createMemo$1, compute,
|
|
378
|
+
const aiResult = hydrateSignalFromAsyncIterable(createMemo$1, compute, options);
|
|
379
379
|
if (aiResult !== null) return aiResult;
|
|
380
|
-
return createMemo$1(prev => readSerializedOrCompute(compute, prev),
|
|
380
|
+
return createMemo$1(prev => readSerializedOrCompute(compute, prev), options);
|
|
381
381
|
}
|
|
382
|
-
function hydratedCreateSignal(fn, second
|
|
383
|
-
if (typeof fn !== "function" || !sharedConfig.hydrating) return createSignal$1(fn, second
|
|
382
|
+
function hydratedCreateSignal(fn, second) {
|
|
383
|
+
if (typeof fn !== "function" || !sharedConfig.hydrating) return createSignal$1(fn, second);
|
|
384
384
|
markTopLevelSnapshotScope();
|
|
385
|
-
const ssrSource =
|
|
385
|
+
const ssrSource = second?.ssrSource;
|
|
386
386
|
if (ssrSource === "client") {
|
|
387
387
|
const [hydrated, setHydrated] = createSignal$1(false, {
|
|
388
|
-
|
|
388
|
+
ownedWrite: true
|
|
389
389
|
});
|
|
390
390
|
const sig = createSignal$1(prev => {
|
|
391
|
-
if (!hydrated()) return prev
|
|
391
|
+
if (!hydrated()) return prev;
|
|
392
392
|
return fn(prev);
|
|
393
|
-
}, second
|
|
393
|
+
}, second);
|
|
394
394
|
setHydrated(true);
|
|
395
395
|
return sig;
|
|
396
396
|
}
|
|
@@ -398,12 +398,12 @@ function hydratedCreateSignal(fn, second, third) {
|
|
|
398
398
|
return createSignal$1(prev => {
|
|
399
399
|
if (!sharedConfig.hydrating) return fn(prev);
|
|
400
400
|
subFetch(fn, prev);
|
|
401
|
-
return prev
|
|
402
|
-
}, second
|
|
401
|
+
return prev;
|
|
402
|
+
}, second);
|
|
403
403
|
}
|
|
404
|
-
const aiResult = hydrateSignalFromAsyncIterable(createSignal$1, fn, second
|
|
404
|
+
const aiResult = hydrateSignalFromAsyncIterable(createSignal$1, fn, second);
|
|
405
405
|
if (aiResult !== null) return aiResult;
|
|
406
|
-
return createSignal$1(prev => readSerializedOrCompute(fn, prev), second
|
|
406
|
+
return createSignal$1(prev => readSerializedOrCompute(fn, prev), second);
|
|
407
407
|
}
|
|
408
408
|
function hydratedCreateErrorBoundary(fn, fallback) {
|
|
409
409
|
if (!sharedConfig.hydrating) return createErrorBoundary$1(fn, fallback);
|
|
@@ -425,18 +425,18 @@ function hydratedCreateErrorBoundary(fn, fallback) {
|
|
|
425
425
|
}
|
|
426
426
|
return createErrorBoundary$1(fn, fallback);
|
|
427
427
|
}
|
|
428
|
-
function hydratedCreateOptimistic(fn, second
|
|
429
|
-
if (typeof fn !== "function" || !sharedConfig.hydrating) return createOptimistic$1(fn, second
|
|
428
|
+
function hydratedCreateOptimistic(fn, second) {
|
|
429
|
+
if (typeof fn !== "function" || !sharedConfig.hydrating) return createOptimistic$1(fn, second);
|
|
430
430
|
markTopLevelSnapshotScope();
|
|
431
|
-
const ssrSource =
|
|
431
|
+
const ssrSource = second?.ssrSource;
|
|
432
432
|
if (ssrSource === "client") {
|
|
433
433
|
const [hydrated, setHydrated] = createSignal$1(false, {
|
|
434
|
-
|
|
434
|
+
ownedWrite: true
|
|
435
435
|
});
|
|
436
436
|
const sig = createOptimistic$1(prev => {
|
|
437
|
-
if (!hydrated()) return prev
|
|
437
|
+
if (!hydrated()) return prev;
|
|
438
438
|
return fn(prev);
|
|
439
|
-
}, second
|
|
439
|
+
}, second);
|
|
440
440
|
setHydrated(true);
|
|
441
441
|
return sig;
|
|
442
442
|
}
|
|
@@ -444,12 +444,12 @@ function hydratedCreateOptimistic(fn, second, third) {
|
|
|
444
444
|
return createOptimistic$1(prev => {
|
|
445
445
|
if (!sharedConfig.hydrating) return fn(prev);
|
|
446
446
|
subFetch(fn, prev);
|
|
447
|
-
return prev
|
|
448
|
-
}, second
|
|
447
|
+
return prev;
|
|
448
|
+
}, second);
|
|
449
449
|
}
|
|
450
|
-
const aiResult = hydrateSignalFromAsyncIterable(createOptimistic$1, fn, second
|
|
450
|
+
const aiResult = hydrateSignalFromAsyncIterable(createOptimistic$1, fn, second);
|
|
451
451
|
if (aiResult !== null) return aiResult;
|
|
452
|
-
return createOptimistic$1(prev => readSerializedOrCompute(fn, prev), second
|
|
452
|
+
return createOptimistic$1(prev => readSerializedOrCompute(fn, prev), second);
|
|
453
453
|
}
|
|
454
454
|
function wrapStoreFn(fn) {
|
|
455
455
|
return draft => readSerializedOrCompute(() => fn(draft), draft);
|
|
@@ -457,7 +457,7 @@ function wrapStoreFn(fn) {
|
|
|
457
457
|
function hydrateStoreLikeFn(coreFn, fn, initialValue, options, ssrSource) {
|
|
458
458
|
if (ssrSource === "client") {
|
|
459
459
|
const [hydrated, setHydrated] = createSignal$1(false, {
|
|
460
|
-
|
|
460
|
+
ownedWrite: true
|
|
461
461
|
});
|
|
462
462
|
const result = coreFn(draft => {
|
|
463
463
|
if (!hydrated()) return;
|
|
@@ -468,7 +468,7 @@ function hydrateStoreLikeFn(coreFn, fn, initialValue, options, ssrSource) {
|
|
|
468
468
|
}
|
|
469
469
|
if (ssrSource === "hybrid") {
|
|
470
470
|
const [hydrated, setHydrated] = createSignal$1(false, {
|
|
471
|
-
|
|
471
|
+
ownedWrite: true
|
|
472
472
|
});
|
|
473
473
|
const result = coreFn(draft => {
|
|
474
474
|
const o = getOwner();
|
|
@@ -498,14 +498,14 @@ function hydratedCreateStore(first, second, third) {
|
|
|
498
498
|
if (typeof first !== "function" || !sharedConfig.hydrating) return createStore$1(first, second, third);
|
|
499
499
|
markTopLevelSnapshotScope();
|
|
500
500
|
const ssrSource = third?.ssrSource;
|
|
501
|
-
if (ssrSource === "initial") return createStore$1(second ?? {}
|
|
501
|
+
if (ssrSource === "initial") return createStore$1(second ?? {});
|
|
502
502
|
return hydrateStoreLikeFn(createStore$1, first, second ?? {}, third, ssrSource);
|
|
503
503
|
}
|
|
504
504
|
function hydratedCreateOptimisticStore(first, second, third) {
|
|
505
505
|
if (typeof first !== "function" || !sharedConfig.hydrating) return createOptimisticStore$1(first, second, third);
|
|
506
506
|
markTopLevelSnapshotScope();
|
|
507
507
|
const ssrSource = third?.ssrSource;
|
|
508
|
-
if (ssrSource === "initial") return createOptimisticStore$1(second ?? {}
|
|
508
|
+
if (ssrSource === "initial") return createOptimisticStore$1(second ?? {});
|
|
509
509
|
return hydrateStoreLikeFn(createOptimisticStore$1, first, second ?? {}, third, ssrSource);
|
|
510
510
|
}
|
|
511
511
|
function hydratedCreateProjection(fn, initialValue, options) {
|
|
@@ -515,22 +515,22 @@ function hydratedCreateProjection(fn, initialValue, options) {
|
|
|
515
515
|
if (ssrSource === "initial") return createProjection$1(draft => draft, initialValue, options);
|
|
516
516
|
return hydrateStoreLikeFn(createProjection$1, fn, initialValue, options, ssrSource);
|
|
517
517
|
}
|
|
518
|
-
function hydratedEffect(coreFn, compute, effectFn,
|
|
519
|
-
if (!sharedConfig.hydrating) return coreFn(compute, effectFn,
|
|
518
|
+
function hydratedEffect(coreFn, compute, effectFn, options) {
|
|
519
|
+
if (!sharedConfig.hydrating || options?.transparent) return coreFn(compute, effectFn, options);
|
|
520
520
|
const ssrSource = options?.ssrSource;
|
|
521
521
|
if (ssrSource === "client") {
|
|
522
522
|
const [hydrated, setHydrated] = createSignal$1(false, {
|
|
523
|
-
|
|
523
|
+
ownedWrite: true
|
|
524
524
|
});
|
|
525
525
|
let active = false;
|
|
526
526
|
coreFn(prev => {
|
|
527
|
-
if (!hydrated()) return
|
|
527
|
+
if (!hydrated()) return prev;
|
|
528
528
|
active = true;
|
|
529
529
|
return compute(prev);
|
|
530
530
|
}, (next, prev) => {
|
|
531
531
|
if (!active) return;
|
|
532
532
|
return effectFn(next, prev);
|
|
533
|
-
},
|
|
533
|
+
}, options);
|
|
534
534
|
setHydrated(true);
|
|
535
535
|
return;
|
|
536
536
|
}
|
|
@@ -538,18 +538,18 @@ function hydratedEffect(coreFn, compute, effectFn, value, options) {
|
|
|
538
538
|
coreFn(prev => {
|
|
539
539
|
if (!sharedConfig.hydrating) return compute(prev);
|
|
540
540
|
subFetch(compute, prev);
|
|
541
|
-
return prev
|
|
542
|
-
}, effectFn,
|
|
541
|
+
return prev;
|
|
542
|
+
}, effectFn, options);
|
|
543
543
|
return;
|
|
544
544
|
}
|
|
545
545
|
markTopLevelSnapshotScope();
|
|
546
|
-
coreFn(prev => readSerializedOrCompute(compute, prev), effectFn,
|
|
546
|
+
coreFn(prev => readSerializedOrCompute(compute, prev), effectFn, options);
|
|
547
547
|
}
|
|
548
|
-
function hydratedCreateRenderEffect(compute, effectFn,
|
|
549
|
-
return hydratedEffect(createRenderEffect$1, compute, effectFn,
|
|
548
|
+
function hydratedCreateRenderEffect(compute, effectFn, options) {
|
|
549
|
+
return hydratedEffect(createRenderEffect$1, compute, effectFn, options);
|
|
550
550
|
}
|
|
551
|
-
function hydratedCreateEffect(compute, effectFn,
|
|
552
|
-
return hydratedEffect(createEffect$1, compute, effectFn,
|
|
551
|
+
function hydratedCreateEffect(compute, effectFn, options) {
|
|
552
|
+
return hydratedEffect(createEffect$1, compute, effectFn, options);
|
|
553
553
|
}
|
|
554
554
|
function enableHydration() {
|
|
555
555
|
_createMemo = hydratedCreateMemo;
|
|
@@ -608,24 +608,6 @@ const createStore = (...args) => (_createStore || createStore$1)(...args);
|
|
|
608
608
|
const createOptimisticStore = (...args) => (_createOptimisticStore || createOptimisticStore$1)(...args);
|
|
609
609
|
const createRenderEffect = (...args) => (_createRenderEffect || createRenderEffect$1)(...args);
|
|
610
610
|
const createEffect = (...args) => (_createEffect || createEffect$1)(...args);
|
|
611
|
-
function loadModuleAssets(mapping) {
|
|
612
|
-
const hy = globalThis._$HY;
|
|
613
|
-
if (!hy) return;
|
|
614
|
-
if (!hy.modules) hy.modules = {};
|
|
615
|
-
if (!hy.loading) hy.loading = {};
|
|
616
|
-
const pending = [];
|
|
617
|
-
for (const moduleUrl in mapping) {
|
|
618
|
-
if (hy.modules[moduleUrl]) continue;
|
|
619
|
-
const entryUrl = mapping[moduleUrl];
|
|
620
|
-
if (!hy.loading[moduleUrl]) {
|
|
621
|
-
hy.loading[moduleUrl] = import(entryUrl).then(mod => {
|
|
622
|
-
hy.modules[moduleUrl] = mod;
|
|
623
|
-
});
|
|
624
|
-
}
|
|
625
|
-
pending.push(hy.loading[moduleUrl]);
|
|
626
|
-
}
|
|
627
|
-
return pending.length ? Promise.all(pending).then(() => {}) : undefined;
|
|
628
|
-
}
|
|
629
611
|
function createBoundaryTrigger() {
|
|
630
612
|
setSnapshotCapture(false);
|
|
631
613
|
const [s, set] = createSignal$1(undefined, {
|
|
@@ -694,7 +676,7 @@ function createLoadingBoundary(fn, fallback, options) {
|
|
|
694
676
|
let assetPromise;
|
|
695
677
|
if (sharedConfig.hydrating && sharedConfig.has(id + "_assets")) {
|
|
696
678
|
const mapping = sharedConfig.load(id + "_assets");
|
|
697
|
-
if (mapping && typeof mapping === "object") assetPromise = loadModuleAssets(mapping);
|
|
679
|
+
if (mapping && typeof mapping === "object") assetPromise = sharedConfig.loadModuleAssets?.(mapping);
|
|
698
680
|
}
|
|
699
681
|
if (sharedConfig.hydrating && sharedConfig.has(id)) {
|
|
700
682
|
const ref = sharedConfig.load(id);
|
|
@@ -808,8 +790,8 @@ function Repeat(props) {
|
|
|
808
790
|
}
|
|
809
791
|
function Show(props) {
|
|
810
792
|
const keyed = props.keyed;
|
|
811
|
-
const conditionValue = createMemo$1(() => props.when, undefined
|
|
812
|
-
const condition = keyed ? conditionValue : createMemo$1(conditionValue,
|
|
793
|
+
const conditionValue = createMemo$1(() => props.when, undefined);
|
|
794
|
+
const condition = keyed ? conditionValue : createMemo$1(conditionValue, {
|
|
813
795
|
equals: (a, b) => !a === !b
|
|
814
796
|
});
|
|
815
797
|
return createMemo$1(() => {
|
|
@@ -823,7 +805,7 @@ function Show(props) {
|
|
|
823
805
|
}), IS_DEV) : child;
|
|
824
806
|
}
|
|
825
807
|
return props.fallback;
|
|
826
|
-
}, undefined
|
|
808
|
+
}, undefined);
|
|
827
809
|
}
|
|
828
810
|
function Switch(props) {
|
|
829
811
|
const chs = children(() => props.children);
|
|
@@ -834,8 +816,8 @@ function Switch(props) {
|
|
|
834
816
|
const index = i;
|
|
835
817
|
const mp = mps[i];
|
|
836
818
|
const prevFunc = func;
|
|
837
|
-
const conditionValue = createMemo$1(() => prevFunc() ? undefined : mp.when, undefined
|
|
838
|
-
const condition = mp.keyed ? conditionValue : createMemo$1(conditionValue,
|
|
819
|
+
const conditionValue = createMemo$1(() => prevFunc() ? undefined : mp.when, undefined);
|
|
820
|
+
const condition = mp.keyed ? conditionValue : createMemo$1(conditionValue, {
|
|
839
821
|
equals: (a, b) => !a === !b
|
|
840
822
|
});
|
|
841
823
|
func = () => prevFunc() || (condition() ? [index, conditionValue, mp] : undefined);
|
|
@@ -852,7 +834,7 @@ function Switch(props) {
|
|
|
852
834
|
if (untrack(switchFunc)()?.[0] !== index) throw narrowedError("Match");
|
|
853
835
|
return conditionValue();
|
|
854
836
|
}), IS_DEV) : child;
|
|
855
|
-
}, undefined
|
|
837
|
+
}, undefined);
|
|
856
838
|
}
|
|
857
839
|
function Match(props) {
|
|
858
840
|
return props;
|