solid-js 2.0.0-beta.6 → 2.0.0-beta.8
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 +66 -104
- package/dist/dev.js +66 -104
- package/dist/server.cjs +331 -132
- package/dist/server.js +331 -132
- package/dist/solid.cjs +66 -104
- package/dist/solid.js +66 -104
- package/package.json +78 -30
- package/types/client/flow.d.ts +34 -13
- package/types/client/hydration.d.ts +35 -9
- package/types/jsx-properties.d.ts +92 -0
- package/types/jsx.d.ts +390 -314
- package/types/server/flow.d.ts +40 -7
- package/types/server/hydration.d.ts +18 -1
- package/types/server/signals.d.ts +33 -15
- 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 +163 -0
- package/types-cjs/client/hydration.d.cts +121 -0
- package/types-cjs/index.d.cts +17 -0
- package/types-cjs/jsx-properties.d.cts +92 -0
- package/types-cjs/jsx.d.cts +4294 -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 +115 -0
- package/types-cjs/server/hydration.d.cts +63 -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 +87 -0
package/dist/dev.js
CHANGED
|
@@ -18,10 +18,10 @@ function useContext(context) {
|
|
|
18
18
|
return getContext(context);
|
|
19
19
|
}
|
|
20
20
|
function children(fn) {
|
|
21
|
-
const c = createMemo$1(fn,
|
|
21
|
+
const c = createMemo$1(fn, {
|
|
22
22
|
lazy: true
|
|
23
23
|
});
|
|
24
|
-
const memo = createMemo$1(() => flatten(c()),
|
|
24
|
+
const memo = createMemo$1(() => flatten(c()), {
|
|
25
25
|
name: "children",
|
|
26
26
|
lazy: true
|
|
27
27
|
} );
|
|
@@ -281,7 +281,7 @@ function wrapFirstYield(iterable, activate) {
|
|
|
281
281
|
}
|
|
282
282
|
};
|
|
283
283
|
}
|
|
284
|
-
function hydrateSignalFromAsyncIterable(coreFn, compute,
|
|
284
|
+
function hydrateSignalFromAsyncIterable(coreFn, compute, options) {
|
|
285
285
|
const parent = getOwner();
|
|
286
286
|
const expectedId = peekNextChildId(parent);
|
|
287
287
|
if (!sharedConfig.has(expectedId)) return null;
|
|
@@ -293,9 +293,12 @@ function hydrateSignalFromAsyncIterable(coreFn, compute, value, options) {
|
|
|
293
293
|
return it;
|
|
294
294
|
}
|
|
295
295
|
};
|
|
296
|
-
return coreFn(
|
|
296
|
+
return coreFn(prev => {
|
|
297
|
+
subFetch(compute, prev);
|
|
298
|
+
return iterable;
|
|
299
|
+
}, options);
|
|
297
300
|
}
|
|
298
|
-
function hydrateStoreFromAsyncIterable(coreFn, initialValue, options) {
|
|
301
|
+
function hydrateStoreFromAsyncIterable(coreFn, fn, initialValue, options) {
|
|
299
302
|
const parent = getOwner();
|
|
300
303
|
const expectedId = peekNextChildId(parent);
|
|
301
304
|
if (!sharedConfig.has(expectedId)) return null;
|
|
@@ -305,6 +308,10 @@ function hydrateStoreFromAsyncIterable(coreFn, initialValue, options) {
|
|
|
305
308
|
let isFirst = true;
|
|
306
309
|
let buffered = null;
|
|
307
310
|
return coreFn(draft => {
|
|
311
|
+
const {
|
|
312
|
+
proxy
|
|
313
|
+
} = createShadowDraft(draft);
|
|
314
|
+
subFetch(fn, proxy);
|
|
308
315
|
const process = res => {
|
|
309
316
|
if (res.done) return {
|
|
310
317
|
done: true,
|
|
@@ -312,11 +319,16 @@ function hydrateStoreFromAsyncIterable(coreFn, initialValue, options) {
|
|
|
312
319
|
};
|
|
313
320
|
if (isFirst) {
|
|
314
321
|
isFirst = false;
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
322
|
+
setSnapshotCapture(false);
|
|
323
|
+
try {
|
|
324
|
+
if (Array.isArray(res.value)) {
|
|
325
|
+
for (let i = 0; i < res.value.length; i++) draft[i] = res.value[i];
|
|
326
|
+
draft.length = res.value.length;
|
|
327
|
+
} else {
|
|
328
|
+
Object.assign(draft, res.value);
|
|
329
|
+
}
|
|
330
|
+
} finally {
|
|
331
|
+
setSnapshotCapture(true);
|
|
320
332
|
}
|
|
321
333
|
} else {
|
|
322
334
|
applyPatches(draft, res.value);
|
|
@@ -368,59 +380,45 @@ function hydrateStoreFromAsyncIterable(coreFn, initialValue, options) {
|
|
|
368
380
|
};
|
|
369
381
|
}, initialValue, options);
|
|
370
382
|
}
|
|
371
|
-
function hydratedCreateMemo(compute,
|
|
383
|
+
function hydratedCreateMemo(compute, options) {
|
|
372
384
|
if (!sharedConfig.hydrating || options?.transparent) {
|
|
373
|
-
return createMemo$1(compute,
|
|
385
|
+
return createMemo$1(compute, options);
|
|
374
386
|
}
|
|
375
387
|
markTopLevelSnapshotScope();
|
|
376
388
|
const ssrSource = options?.ssrSource;
|
|
377
389
|
if (ssrSource === "client") {
|
|
378
390
|
const [hydrated, setHydrated] = createSignal$1(false, {
|
|
379
|
-
|
|
391
|
+
ownedWrite: true
|
|
380
392
|
});
|
|
381
393
|
const memo = createMemo$1(prev => {
|
|
382
|
-
if (!hydrated()) return prev
|
|
394
|
+
if (!hydrated()) return prev;
|
|
383
395
|
return compute(prev);
|
|
384
|
-
},
|
|
396
|
+
}, options);
|
|
385
397
|
setHydrated(true);
|
|
386
398
|
return memo;
|
|
387
399
|
}
|
|
388
|
-
|
|
389
|
-
return createMemo$1(prev => {
|
|
390
|
-
if (!sharedConfig.hydrating) return compute(prev);
|
|
391
|
-
subFetch(compute, prev);
|
|
392
|
-
return prev ?? value;
|
|
393
|
-
}, value, options);
|
|
394
|
-
}
|
|
395
|
-
const aiResult = hydrateSignalFromAsyncIterable(createMemo$1, compute, value, options);
|
|
400
|
+
const aiResult = hydrateSignalFromAsyncIterable(createMemo$1, compute, options);
|
|
396
401
|
if (aiResult !== null) return aiResult;
|
|
397
|
-
return createMemo$1(prev => readSerializedOrCompute(compute, prev),
|
|
402
|
+
return createMemo$1(prev => readSerializedOrCompute(compute, prev), options);
|
|
398
403
|
}
|
|
399
|
-
function hydratedCreateSignal(fn, second
|
|
400
|
-
if (typeof fn !== "function" || !sharedConfig.hydrating) return createSignal$1(fn, second
|
|
404
|
+
function hydratedCreateSignal(fn, second) {
|
|
405
|
+
if (typeof fn !== "function" || !sharedConfig.hydrating) return createSignal$1(fn, second);
|
|
401
406
|
markTopLevelSnapshotScope();
|
|
402
|
-
const ssrSource =
|
|
407
|
+
const ssrSource = second?.ssrSource;
|
|
403
408
|
if (ssrSource === "client") {
|
|
404
409
|
const [hydrated, setHydrated] = createSignal$1(false, {
|
|
405
|
-
|
|
410
|
+
ownedWrite: true
|
|
406
411
|
});
|
|
407
412
|
const sig = createSignal$1(prev => {
|
|
408
|
-
if (!hydrated()) return prev
|
|
413
|
+
if (!hydrated()) return prev;
|
|
409
414
|
return fn(prev);
|
|
410
|
-
}, second
|
|
415
|
+
}, second);
|
|
411
416
|
setHydrated(true);
|
|
412
417
|
return sig;
|
|
413
418
|
}
|
|
414
|
-
|
|
415
|
-
return createSignal$1(prev => {
|
|
416
|
-
if (!sharedConfig.hydrating) return fn(prev);
|
|
417
|
-
subFetch(fn, prev);
|
|
418
|
-
return prev ?? second;
|
|
419
|
-
}, second, third);
|
|
420
|
-
}
|
|
421
|
-
const aiResult = hydrateSignalFromAsyncIterable(createSignal$1, fn, second, third);
|
|
419
|
+
const aiResult = hydrateSignalFromAsyncIterable(createSignal$1, fn, second);
|
|
422
420
|
if (aiResult !== null) return aiResult;
|
|
423
|
-
return createSignal$1(prev => readSerializedOrCompute(fn, prev), second
|
|
421
|
+
return createSignal$1(prev => readSerializedOrCompute(fn, prev), second);
|
|
424
422
|
}
|
|
425
423
|
function hydratedCreateErrorBoundary(fn, fallback) {
|
|
426
424
|
if (!sharedConfig.hydrating) return createErrorBoundary$1(fn, fallback);
|
|
@@ -442,31 +440,24 @@ function hydratedCreateErrorBoundary(fn, fallback) {
|
|
|
442
440
|
}
|
|
443
441
|
return createErrorBoundary$1(fn, fallback);
|
|
444
442
|
}
|
|
445
|
-
function hydratedCreateOptimistic(fn, second
|
|
446
|
-
if (typeof fn !== "function" || !sharedConfig.hydrating) return createOptimistic$1(fn, second
|
|
443
|
+
function hydratedCreateOptimistic(fn, second) {
|
|
444
|
+
if (typeof fn !== "function" || !sharedConfig.hydrating) return createOptimistic$1(fn, second);
|
|
447
445
|
markTopLevelSnapshotScope();
|
|
448
|
-
const ssrSource =
|
|
446
|
+
const ssrSource = second?.ssrSource;
|
|
449
447
|
if (ssrSource === "client") {
|
|
450
448
|
const [hydrated, setHydrated] = createSignal$1(false, {
|
|
451
|
-
|
|
449
|
+
ownedWrite: true
|
|
452
450
|
});
|
|
453
451
|
const sig = createOptimistic$1(prev => {
|
|
454
|
-
if (!hydrated()) return prev
|
|
452
|
+
if (!hydrated()) return prev;
|
|
455
453
|
return fn(prev);
|
|
456
|
-
}, second
|
|
454
|
+
}, second);
|
|
457
455
|
setHydrated(true);
|
|
458
456
|
return sig;
|
|
459
457
|
}
|
|
460
|
-
|
|
461
|
-
return createOptimistic$1(prev => {
|
|
462
|
-
if (!sharedConfig.hydrating) return fn(prev);
|
|
463
|
-
subFetch(fn, prev);
|
|
464
|
-
return prev ?? second;
|
|
465
|
-
}, second, third);
|
|
466
|
-
}
|
|
467
|
-
const aiResult = hydrateSignalFromAsyncIterable(createOptimistic$1, fn, second, third);
|
|
458
|
+
const aiResult = hydrateSignalFromAsyncIterable(createOptimistic$1, fn, second);
|
|
468
459
|
if (aiResult !== null) return aiResult;
|
|
469
|
-
return createOptimistic$1(prev => readSerializedOrCompute(fn, prev), second
|
|
460
|
+
return createOptimistic$1(prev => readSerializedOrCompute(fn, prev), second);
|
|
470
461
|
}
|
|
471
462
|
function wrapStoreFn(fn) {
|
|
472
463
|
return draft => readSerializedOrCompute(() => fn(draft), draft);
|
|
@@ -474,7 +465,7 @@ function wrapStoreFn(fn) {
|
|
|
474
465
|
function hydrateStoreLikeFn(coreFn, fn, initialValue, options, ssrSource) {
|
|
475
466
|
if (ssrSource === "client") {
|
|
476
467
|
const [hydrated, setHydrated] = createSignal$1(false, {
|
|
477
|
-
|
|
468
|
+
ownedWrite: true
|
|
478
469
|
});
|
|
479
470
|
const result = coreFn(draft => {
|
|
480
471
|
if (!hydrated()) return;
|
|
@@ -485,7 +476,7 @@ function hydrateStoreLikeFn(coreFn, fn, initialValue, options, ssrSource) {
|
|
|
485
476
|
}
|
|
486
477
|
if (ssrSource === "hybrid") {
|
|
487
478
|
const [hydrated, setHydrated] = createSignal$1(false, {
|
|
488
|
-
|
|
479
|
+
ownedWrite: true
|
|
489
480
|
});
|
|
490
481
|
const result = coreFn(draft => {
|
|
491
482
|
const o = getOwner();
|
|
@@ -507,7 +498,7 @@ function hydrateStoreLikeFn(coreFn, fn, initialValue, options, ssrSource) {
|
|
|
507
498
|
setHydrated(true);
|
|
508
499
|
return result;
|
|
509
500
|
}
|
|
510
|
-
const aiResult = hydrateStoreFromAsyncIterable(coreFn, initialValue, options);
|
|
501
|
+
const aiResult = hydrateStoreFromAsyncIterable(coreFn, fn, initialValue, options);
|
|
511
502
|
if (aiResult !== null) return aiResult;
|
|
512
503
|
return coreFn(wrapStoreFn(fn), initialValue, options);
|
|
513
504
|
}
|
|
@@ -515,58 +506,47 @@ function hydratedCreateStore(first, second, third) {
|
|
|
515
506
|
if (typeof first !== "function" || !sharedConfig.hydrating) return createStore$1(first, second, third);
|
|
516
507
|
markTopLevelSnapshotScope();
|
|
517
508
|
const ssrSource = third?.ssrSource;
|
|
518
|
-
if (ssrSource === "initial") return createStore$1(second ?? {}, undefined, third);
|
|
519
509
|
return hydrateStoreLikeFn(createStore$1, first, second ?? {}, third, ssrSource);
|
|
520
510
|
}
|
|
521
511
|
function hydratedCreateOptimisticStore(first, second, third) {
|
|
522
512
|
if (typeof first !== "function" || !sharedConfig.hydrating) return createOptimisticStore$1(first, second, third);
|
|
523
513
|
markTopLevelSnapshotScope();
|
|
524
514
|
const ssrSource = third?.ssrSource;
|
|
525
|
-
if (ssrSource === "initial") return createOptimisticStore$1(second ?? {}, undefined, third);
|
|
526
515
|
return hydrateStoreLikeFn(createOptimisticStore$1, first, second ?? {}, third, ssrSource);
|
|
527
516
|
}
|
|
528
517
|
function hydratedCreateProjection(fn, initialValue, options) {
|
|
529
518
|
if (!sharedConfig.hydrating) return createProjection$1(fn, initialValue, options);
|
|
530
519
|
markTopLevelSnapshotScope();
|
|
531
520
|
const ssrSource = options?.ssrSource;
|
|
532
|
-
if (ssrSource === "initial") return createProjection$1(draft => draft, initialValue, options);
|
|
533
521
|
return hydrateStoreLikeFn(createProjection$1, fn, initialValue, options, ssrSource);
|
|
534
522
|
}
|
|
535
|
-
function hydratedEffect(coreFn, compute, effectFn,
|
|
536
|
-
if (!sharedConfig.hydrating) return coreFn(compute, effectFn,
|
|
523
|
+
function hydratedEffect(coreFn, compute, effectFn, options) {
|
|
524
|
+
if (!sharedConfig.hydrating || options?.transparent) return coreFn(compute, effectFn, options);
|
|
537
525
|
const ssrSource = options?.ssrSource;
|
|
538
526
|
if (ssrSource === "client") {
|
|
539
527
|
const [hydrated, setHydrated] = createSignal$1(false, {
|
|
540
|
-
|
|
528
|
+
ownedWrite: true
|
|
541
529
|
});
|
|
542
530
|
let active = false;
|
|
543
531
|
coreFn(prev => {
|
|
544
|
-
if (!hydrated()) return
|
|
532
|
+
if (!hydrated()) return prev;
|
|
545
533
|
active = true;
|
|
546
534
|
return compute(prev);
|
|
547
535
|
}, (next, prev) => {
|
|
548
536
|
if (!active) return;
|
|
549
537
|
return effectFn(next, prev);
|
|
550
|
-
},
|
|
538
|
+
}, options);
|
|
551
539
|
setHydrated(true);
|
|
552
540
|
return;
|
|
553
541
|
}
|
|
554
|
-
if (ssrSource === "initial") {
|
|
555
|
-
coreFn(prev => {
|
|
556
|
-
if (!sharedConfig.hydrating) return compute(prev);
|
|
557
|
-
subFetch(compute, prev);
|
|
558
|
-
return prev ?? value;
|
|
559
|
-
}, effectFn, value, options);
|
|
560
|
-
return;
|
|
561
|
-
}
|
|
562
542
|
markTopLevelSnapshotScope();
|
|
563
|
-
coreFn(prev => readSerializedOrCompute(compute, prev), effectFn,
|
|
543
|
+
coreFn(prev => readSerializedOrCompute(compute, prev), effectFn, options);
|
|
564
544
|
}
|
|
565
|
-
function hydratedCreateRenderEffect(compute, effectFn,
|
|
566
|
-
return hydratedEffect(createRenderEffect$1, compute, effectFn,
|
|
545
|
+
function hydratedCreateRenderEffect(compute, effectFn, options) {
|
|
546
|
+
return hydratedEffect(createRenderEffect$1, compute, effectFn, options);
|
|
567
547
|
}
|
|
568
|
-
function hydratedCreateEffect(compute, effectFn,
|
|
569
|
-
return hydratedEffect(createEffect$1, compute, effectFn,
|
|
548
|
+
function hydratedCreateEffect(compute, effectFn, options) {
|
|
549
|
+
return hydratedEffect(createEffect$1, compute, effectFn, options);
|
|
570
550
|
}
|
|
571
551
|
function enableHydration() {
|
|
572
552
|
_createMemo = hydratedCreateMemo;
|
|
@@ -625,24 +605,6 @@ const createStore = (...args) => (_createStore || createStore$1)(...args);
|
|
|
625
605
|
const createOptimisticStore = (...args) => (_createOptimisticStore || createOptimisticStore$1)(...args);
|
|
626
606
|
const createRenderEffect = (...args) => (_createRenderEffect || createRenderEffect$1)(...args);
|
|
627
607
|
const createEffect = (...args) => (_createEffect || createEffect$1)(...args);
|
|
628
|
-
function loadModuleAssets(mapping) {
|
|
629
|
-
const hy = globalThis._$HY;
|
|
630
|
-
if (!hy) return;
|
|
631
|
-
if (!hy.modules) hy.modules = {};
|
|
632
|
-
if (!hy.loading) hy.loading = {};
|
|
633
|
-
const pending = [];
|
|
634
|
-
for (const moduleUrl in mapping) {
|
|
635
|
-
if (hy.modules[moduleUrl]) continue;
|
|
636
|
-
const entryUrl = mapping[moduleUrl];
|
|
637
|
-
if (!hy.loading[moduleUrl]) {
|
|
638
|
-
hy.loading[moduleUrl] = import(entryUrl).then(mod => {
|
|
639
|
-
hy.modules[moduleUrl] = mod;
|
|
640
|
-
});
|
|
641
|
-
}
|
|
642
|
-
pending.push(hy.loading[moduleUrl]);
|
|
643
|
-
}
|
|
644
|
-
return pending.length ? Promise.all(pending).then(() => {}) : undefined;
|
|
645
|
-
}
|
|
646
608
|
function createBoundaryTrigger() {
|
|
647
609
|
setSnapshotCapture(false);
|
|
648
610
|
const [s, set] = createSignal$1(undefined, {
|
|
@@ -711,7 +673,7 @@ function createLoadingBoundary(fn, fallback, options) {
|
|
|
711
673
|
let assetPromise;
|
|
712
674
|
if (sharedConfig.hydrating && sharedConfig.has(id + "_assets")) {
|
|
713
675
|
const mapping = sharedConfig.load(id + "_assets");
|
|
714
|
-
if (mapping && typeof mapping === "object") assetPromise = loadModuleAssets(mapping);
|
|
676
|
+
if (mapping && typeof mapping === "object") assetPromise = sharedConfig.loadModuleAssets?.(mapping);
|
|
715
677
|
}
|
|
716
678
|
if (sharedConfig.hydrating && sharedConfig.has(id)) {
|
|
717
679
|
const ref = sharedConfig.load(id);
|
|
@@ -830,10 +792,10 @@ function Repeat(props) {
|
|
|
830
792
|
}
|
|
831
793
|
function Show(props) {
|
|
832
794
|
const keyed = props.keyed;
|
|
833
|
-
const conditionValue = createMemo$1(() => props.when,
|
|
795
|
+
const conditionValue = createMemo$1(() => props.when, {
|
|
834
796
|
name: "condition value"
|
|
835
797
|
} );
|
|
836
|
-
const condition = keyed ? conditionValue : createMemo$1(conditionValue,
|
|
798
|
+
const condition = keyed ? conditionValue : createMemo$1(conditionValue, {
|
|
837
799
|
equals: (a, b) => !a === !b,
|
|
838
800
|
name: "condition"
|
|
839
801
|
} );
|
|
@@ -848,7 +810,7 @@ function Show(props) {
|
|
|
848
810
|
}), "<Show>") : child;
|
|
849
811
|
}
|
|
850
812
|
return props.fallback;
|
|
851
|
-
},
|
|
813
|
+
}, {
|
|
852
814
|
name: "value"
|
|
853
815
|
} );
|
|
854
816
|
}
|
|
@@ -861,10 +823,10 @@ function Switch(props) {
|
|
|
861
823
|
const index = i;
|
|
862
824
|
const mp = mps[i];
|
|
863
825
|
const prevFunc = func;
|
|
864
|
-
const conditionValue = createMemo$1(() => prevFunc() ? undefined : mp.when,
|
|
826
|
+
const conditionValue = createMemo$1(() => prevFunc() ? undefined : mp.when, {
|
|
865
827
|
name: "condition value"
|
|
866
828
|
} );
|
|
867
|
-
const condition = mp.keyed ? conditionValue : createMemo$1(conditionValue,
|
|
829
|
+
const condition = mp.keyed ? conditionValue : createMemo$1(conditionValue, {
|
|
868
830
|
equals: (a, b) => !a === !b,
|
|
869
831
|
name: "condition"
|
|
870
832
|
} );
|
|
@@ -882,7 +844,7 @@ function Switch(props) {
|
|
|
882
844
|
if (untrack(switchFunc)()?.[0] !== index) throw narrowedError("Match");
|
|
883
845
|
return conditionValue();
|
|
884
846
|
}), "<Match>") : child;
|
|
885
|
-
},
|
|
847
|
+
}, {
|
|
886
848
|
name: "eval conditions"
|
|
887
849
|
} );
|
|
888
850
|
}
|
|
@@ -904,7 +866,7 @@ function Loading(props) {
|
|
|
904
866
|
}
|
|
905
867
|
function Reveal(props) {
|
|
906
868
|
return createRevealOrder(() => props.children, {
|
|
907
|
-
|
|
869
|
+
order: () => props.order ?? "sequential",
|
|
908
870
|
collapsed: () => !!props.collapsed
|
|
909
871
|
});
|
|
910
872
|
}
|