solid-js 2.0.0-beta.5 → 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 CHANGED
@@ -19,10 +19,10 @@ function useContext(context) {
19
19
  return signals.getContext(context);
20
20
  }
21
21
  function children(fn) {
22
- const c = signals.createMemo(fn, undefined, {
22
+ const c = signals.createMemo(fn, {
23
23
  lazy: true
24
24
  });
25
- const memo = signals.createMemo(() => signals.flatten(c()), undefined, {
25
+ const memo = signals.createMemo(() => signals.flatten(c()), {
26
26
  name: "children",
27
27
  lazy: true
28
28
  } );
@@ -35,9 +35,11 @@ function children(fn) {
35
35
  function devComponent(Comp, props) {
36
36
  return signals.createRoot(() => {
37
37
  const owner = signals.getOwner();
38
- owner._props = props;
39
- owner._name = Comp.name;
40
- owner._component = Comp;
38
+ owner._component = {
39
+ fn: Comp,
40
+ props,
41
+ name: Comp.name
42
+ };
41
43
  Object.assign(Comp, {
42
44
  [$DEVCOMP]: true
43
45
  });
@@ -46,12 +48,6 @@ function devComponent(Comp, props) {
46
48
  transparent: true
47
49
  });
48
50
  }
49
- function registerGraph(value) {
50
- const owner = signals.getOwner();
51
- if (!owner) return;
52
- if (owner.sourceMap) owner.sourceMap.push(value);else owner.sourceMap = [value];
53
- value.graph = owner;
54
- }
55
51
 
56
52
  const NoHydrateContext = {
57
53
  id: Symbol("NoHydrateContext"),
@@ -286,7 +282,7 @@ function wrapFirstYield(iterable, activate) {
286
282
  }
287
283
  };
288
284
  }
289
- function hydrateSignalFromAsyncIterable(coreFn, compute, value, options) {
285
+ function hydrateSignalFromAsyncIterable(coreFn, compute, options) {
290
286
  const parent = signals.getOwner();
291
287
  const expectedId = signals.peekNextChildId(parent);
292
288
  if (!sharedConfig.has(expectedId)) return null;
@@ -298,7 +294,7 @@ function hydrateSignalFromAsyncIterable(coreFn, compute, value, options) {
298
294
  return it;
299
295
  }
300
296
  };
301
- return coreFn(() => iterable, value, options);
297
+ return coreFn(() => iterable, options);
302
298
  }
303
299
  function hydrateStoreFromAsyncIterable(coreFn, initialValue, options) {
304
300
  const parent = signals.getOwner();
@@ -373,20 +369,20 @@ function hydrateStoreFromAsyncIterable(coreFn, initialValue, options) {
373
369
  };
374
370
  }, initialValue, options);
375
371
  }
376
- function hydratedCreateMemo(compute, value, options) {
372
+ function hydratedCreateMemo(compute, options) {
377
373
  if (!sharedConfig.hydrating || options?.transparent) {
378
- return signals.createMemo(compute, value, options);
374
+ return signals.createMemo(compute, options);
379
375
  }
380
376
  markTopLevelSnapshotScope();
381
377
  const ssrSource = options?.ssrSource;
382
378
  if (ssrSource === "client") {
383
379
  const [hydrated, setHydrated] = signals.createSignal(false, {
384
- pureWrite: true
380
+ ownedWrite: true
385
381
  });
386
382
  const memo = signals.createMemo(prev => {
387
- if (!hydrated()) return prev ?? value;
383
+ if (!hydrated()) return prev;
388
384
  return compute(prev);
389
- }, value, options);
385
+ }, options);
390
386
  setHydrated(true);
391
387
  return memo;
392
388
  }
@@ -394,25 +390,25 @@ function hydratedCreateMemo(compute, value, options) {
394
390
  return signals.createMemo(prev => {
395
391
  if (!sharedConfig.hydrating) return compute(prev);
396
392
  subFetch(compute, prev);
397
- return prev ?? value;
398
- }, value, options);
393
+ return prev;
394
+ }, options);
399
395
  }
400
- const aiResult = hydrateSignalFromAsyncIterable(signals.createMemo, compute, value, options);
396
+ const aiResult = hydrateSignalFromAsyncIterable(signals.createMemo, compute, options);
401
397
  if (aiResult !== null) return aiResult;
402
- return signals.createMemo(prev => readSerializedOrCompute(compute, prev), value, options);
398
+ return signals.createMemo(prev => readSerializedOrCompute(compute, prev), options);
403
399
  }
404
- function hydratedCreateSignal(fn, second, third) {
405
- if (typeof fn !== "function" || !sharedConfig.hydrating) return signals.createSignal(fn, second, third);
400
+ function hydratedCreateSignal(fn, second) {
401
+ if (typeof fn !== "function" || !sharedConfig.hydrating) return signals.createSignal(fn, second);
406
402
  markTopLevelSnapshotScope();
407
- const ssrSource = third?.ssrSource;
403
+ const ssrSource = second?.ssrSource;
408
404
  if (ssrSource === "client") {
409
405
  const [hydrated, setHydrated] = signals.createSignal(false, {
410
- pureWrite: true
406
+ ownedWrite: true
411
407
  });
412
408
  const sig = signals.createSignal(prev => {
413
- if (!hydrated()) return prev ?? second;
409
+ if (!hydrated()) return prev;
414
410
  return fn(prev);
415
- }, second, third);
411
+ }, second);
416
412
  setHydrated(true);
417
413
  return sig;
418
414
  }
@@ -420,12 +416,12 @@ function hydratedCreateSignal(fn, second, third) {
420
416
  return signals.createSignal(prev => {
421
417
  if (!sharedConfig.hydrating) return fn(prev);
422
418
  subFetch(fn, prev);
423
- return prev ?? second;
424
- }, second, third);
419
+ return prev;
420
+ }, second);
425
421
  }
426
- const aiResult = hydrateSignalFromAsyncIterable(signals.createSignal, fn, second, third);
422
+ const aiResult = hydrateSignalFromAsyncIterable(signals.createSignal, fn, second);
427
423
  if (aiResult !== null) return aiResult;
428
- return signals.createSignal(prev => readSerializedOrCompute(fn, prev), second, third);
424
+ return signals.createSignal(prev => readSerializedOrCompute(fn, prev), second);
429
425
  }
430
426
  function hydratedCreateErrorBoundary(fn, fallback) {
431
427
  if (!sharedConfig.hydrating) return signals.createErrorBoundary(fn, fallback);
@@ -447,18 +443,18 @@ function hydratedCreateErrorBoundary(fn, fallback) {
447
443
  }
448
444
  return signals.createErrorBoundary(fn, fallback);
449
445
  }
450
- function hydratedCreateOptimistic(fn, second, third) {
451
- if (typeof fn !== "function" || !sharedConfig.hydrating) return signals.createOptimistic(fn, second, third);
446
+ function hydratedCreateOptimistic(fn, second) {
447
+ if (typeof fn !== "function" || !sharedConfig.hydrating) return signals.createOptimistic(fn, second);
452
448
  markTopLevelSnapshotScope();
453
- const ssrSource = third?.ssrSource;
449
+ const ssrSource = second?.ssrSource;
454
450
  if (ssrSource === "client") {
455
451
  const [hydrated, setHydrated] = signals.createSignal(false, {
456
- pureWrite: true
452
+ ownedWrite: true
457
453
  });
458
454
  const sig = signals.createOptimistic(prev => {
459
- if (!hydrated()) return prev ?? second;
455
+ if (!hydrated()) return prev;
460
456
  return fn(prev);
461
- }, second, third);
457
+ }, second);
462
458
  setHydrated(true);
463
459
  return sig;
464
460
  }
@@ -466,12 +462,12 @@ function hydratedCreateOptimistic(fn, second, third) {
466
462
  return signals.createOptimistic(prev => {
467
463
  if (!sharedConfig.hydrating) return fn(prev);
468
464
  subFetch(fn, prev);
469
- return prev ?? second;
470
- }, second, third);
465
+ return prev;
466
+ }, second);
471
467
  }
472
- const aiResult = hydrateSignalFromAsyncIterable(signals.createOptimistic, fn, second, third);
468
+ const aiResult = hydrateSignalFromAsyncIterable(signals.createOptimistic, fn, second);
473
469
  if (aiResult !== null) return aiResult;
474
- return signals.createOptimistic(prev => readSerializedOrCompute(fn, prev), second, third);
470
+ return signals.createOptimistic(prev => readSerializedOrCompute(fn, prev), second);
475
471
  }
476
472
  function wrapStoreFn(fn) {
477
473
  return draft => readSerializedOrCompute(() => fn(draft), draft);
@@ -479,7 +475,7 @@ function wrapStoreFn(fn) {
479
475
  function hydrateStoreLikeFn(coreFn, fn, initialValue, options, ssrSource) {
480
476
  if (ssrSource === "client") {
481
477
  const [hydrated, setHydrated] = signals.createSignal(false, {
482
- pureWrite: true
478
+ ownedWrite: true
483
479
  });
484
480
  const result = coreFn(draft => {
485
481
  if (!hydrated()) return;
@@ -490,7 +486,7 @@ function hydrateStoreLikeFn(coreFn, fn, initialValue, options, ssrSource) {
490
486
  }
491
487
  if (ssrSource === "hybrid") {
492
488
  const [hydrated, setHydrated] = signals.createSignal(false, {
493
- pureWrite: true
489
+ ownedWrite: true
494
490
  });
495
491
  const result = coreFn(draft => {
496
492
  const o = signals.getOwner();
@@ -520,14 +516,14 @@ function hydratedCreateStore(first, second, third) {
520
516
  if (typeof first !== "function" || !sharedConfig.hydrating) return signals.createStore(first, second, third);
521
517
  markTopLevelSnapshotScope();
522
518
  const ssrSource = third?.ssrSource;
523
- if (ssrSource === "initial") return signals.createStore(second ?? {}, undefined, third);
519
+ if (ssrSource === "initial") return signals.createStore(second ?? {});
524
520
  return hydrateStoreLikeFn(signals.createStore, first, second ?? {}, third, ssrSource);
525
521
  }
526
522
  function hydratedCreateOptimisticStore(first, second, third) {
527
523
  if (typeof first !== "function" || !sharedConfig.hydrating) return signals.createOptimisticStore(first, second, third);
528
524
  markTopLevelSnapshotScope();
529
525
  const ssrSource = third?.ssrSource;
530
- if (ssrSource === "initial") return signals.createOptimisticStore(second ?? {}, undefined, third);
526
+ if (ssrSource === "initial") return signals.createOptimisticStore(second ?? {});
531
527
  return hydrateStoreLikeFn(signals.createOptimisticStore, first, second ?? {}, third, ssrSource);
532
528
  }
533
529
  function hydratedCreateProjection(fn, initialValue, options) {
@@ -537,22 +533,22 @@ function hydratedCreateProjection(fn, initialValue, options) {
537
533
  if (ssrSource === "initial") return signals.createProjection(draft => draft, initialValue, options);
538
534
  return hydrateStoreLikeFn(signals.createProjection, fn, initialValue, options, ssrSource);
539
535
  }
540
- function hydratedEffect(coreFn, compute, effectFn, value, options) {
541
- if (!sharedConfig.hydrating) return coreFn(compute, effectFn, value, options);
536
+ function hydratedEffect(coreFn, compute, effectFn, options) {
537
+ if (!sharedConfig.hydrating || options?.transparent) return coreFn(compute, effectFn, options);
542
538
  const ssrSource = options?.ssrSource;
543
539
  if (ssrSource === "client") {
544
540
  const [hydrated, setHydrated] = signals.createSignal(false, {
545
- pureWrite: true
541
+ ownedWrite: true
546
542
  });
547
543
  let active = false;
548
544
  coreFn(prev => {
549
- if (!hydrated()) return value;
545
+ if (!hydrated()) return prev;
550
546
  active = true;
551
547
  return compute(prev);
552
548
  }, (next, prev) => {
553
549
  if (!active) return;
554
550
  return effectFn(next, prev);
555
- }, value, options);
551
+ }, options);
556
552
  setHydrated(true);
557
553
  return;
558
554
  }
@@ -560,18 +556,18 @@ function hydratedEffect(coreFn, compute, effectFn, value, options) {
560
556
  coreFn(prev => {
561
557
  if (!sharedConfig.hydrating) return compute(prev);
562
558
  subFetch(compute, prev);
563
- return prev ?? value;
564
- }, effectFn, value, options);
559
+ return prev;
560
+ }, effectFn, options);
565
561
  return;
566
562
  }
567
563
  markTopLevelSnapshotScope();
568
- coreFn(prev => readSerializedOrCompute(compute, prev), effectFn, value, options);
564
+ coreFn(prev => readSerializedOrCompute(compute, prev), effectFn, options);
569
565
  }
570
- function hydratedCreateRenderEffect(compute, effectFn, value, options) {
571
- return hydratedEffect(signals.createRenderEffect, compute, effectFn, value, options);
566
+ function hydratedCreateRenderEffect(compute, effectFn, options) {
567
+ return hydratedEffect(signals.createRenderEffect, compute, effectFn, options);
572
568
  }
573
- function hydratedCreateEffect(compute, effectFn, value, options) {
574
- return hydratedEffect(signals.createEffect, compute, effectFn, value, options);
569
+ function hydratedCreateEffect(compute, effectFn, options) {
570
+ return hydratedEffect(signals.createEffect, compute, effectFn, options);
575
571
  }
576
572
  function enableHydration() {
577
573
  _createMemo = hydratedCreateMemo;
@@ -630,24 +626,6 @@ const createStore = (...args) => (_createStore || signals.createStore)(...args);
630
626
  const createOptimisticStore = (...args) => (_createOptimisticStore || signals.createOptimisticStore)(...args);
631
627
  const createRenderEffect = (...args) => (_createRenderEffect || signals.createRenderEffect)(...args);
632
628
  const createEffect = (...args) => (_createEffect || signals.createEffect)(...args);
633
- function loadModuleAssets(mapping) {
634
- const hy = globalThis._$HY;
635
- if (!hy) return;
636
- if (!hy.modules) hy.modules = {};
637
- if (!hy.loading) hy.loading = {};
638
- const pending = [];
639
- for (const moduleUrl in mapping) {
640
- if (hy.modules[moduleUrl]) continue;
641
- const entryUrl = mapping[moduleUrl];
642
- if (!hy.loading[moduleUrl]) {
643
- hy.loading[moduleUrl] = import(entryUrl).then(mod => {
644
- hy.modules[moduleUrl] = mod;
645
- });
646
- }
647
- pending.push(hy.loading[moduleUrl]);
648
- }
649
- return pending.length ? Promise.all(pending).then(() => {}) : undefined;
650
- }
651
629
  function createBoundaryTrigger() {
652
630
  signals.setSnapshotCapture(false);
653
631
  const [s, set] = signals.createSignal(undefined, {
@@ -675,6 +653,38 @@ function resumeBoundaryHydration(o, id, set) {
675
653
  signals.flush();
676
654
  checkHydrationComplete();
677
655
  }
656
+ function initBoundaryResume(o, id) {
657
+ _pendingBoundaries++;
658
+ signals.onCleanup(() => {
659
+ if (!signals.isDisposed(o)) return;
660
+ sharedConfig.cleanupFragment?.(id);
661
+ });
662
+ const set = createBoundaryTrigger();
663
+ return [set, () => resumeBoundaryHydration(o, id, set)];
664
+ }
665
+ function waitAndResume(p, resume, assetPromise) {
666
+ const waitFor = assetPromise ? Promise.all([p, assetPromise]) : p;
667
+ waitFor.then(() => {
668
+ if (p && typeof p === "object") p.s = 1;
669
+ resume();
670
+ }, err => {
671
+ if (p && typeof p === "object") {
672
+ p.s = 2;
673
+ p.v = err;
674
+ }
675
+ resume();
676
+ });
677
+ }
678
+ function scheduleResumeAfterAssets(id, resume, assetPromise) {
679
+ sharedConfig.gather?.(id);
680
+ const doResume = () => queueMicrotask(resume);
681
+ if (assetPromise) {
682
+ assetPromise.then(doResume);
683
+ return true;
684
+ }
685
+ doResume();
686
+ return false;
687
+ }
678
688
  function createLoadingBoundary(fn, fallback, options) {
679
689
  if (!sharedConfig.hydrating) return signals.createLoadingBoundary(fn, fallback, options);
680
690
  let settledSerializationResumeQueued = false;
@@ -684,7 +694,7 @@ function createLoadingBoundary(fn, fallback, options) {
684
694
  let assetPromise;
685
695
  if (sharedConfig.hydrating && sharedConfig.has(id + "_assets")) {
686
696
  const mapping = sharedConfig.load(id + "_assets");
687
- if (mapping && typeof mapping === "object") assetPromise = loadModuleAssets(mapping);
697
+ if (mapping && typeof mapping === "object") assetPromise = sharedConfig.loadModuleAssets?.(mapping);
688
698
  }
689
699
  if (sharedConfig.hydrating && sharedConfig.has(id)) {
690
700
  const ref = sharedConfig.load(id);
@@ -694,41 +704,14 @@ function createLoadingBoundary(fn, fallback, options) {
694
704
  }
695
705
  if (ref && typeof ref === "object" && ref.s === 1 && p == null && !settledSerializationResumeQueued) {
696
706
  settledSerializationResumeQueued = true;
697
- _pendingBoundaries++;
698
- signals.onCleanup(() => {
699
- if (!signals.isDisposed(o)) return;
700
- sharedConfig.cleanupFragment?.(id);
701
- });
702
- const set = createBoundaryTrigger();
703
- const scheduleResume = () => queueMicrotask(() => resumeBoundaryHydration(o, id, set));
704
- if (assetPromise) {
705
- assetPromise.then(scheduleResume);
706
- return undefined;
707
- }
708
- scheduleResume();
707
+ const [, resume] = initBoundaryResume(o, id);
708
+ if (scheduleResumeAfterAssets(id, resume, assetPromise)) return undefined;
709
709
  return fallback();
710
710
  }
711
711
  if (p) {
712
- _pendingBoundaries++;
713
- signals.onCleanup(() => {
714
- if (!signals.isDisposed(o)) return;
715
- sharedConfig.cleanupFragment?.(id);
716
- });
717
- const set = createBoundaryTrigger();
712
+ const [set, resume] = initBoundaryResume(o, id);
718
713
  if (p !== "$$f") {
719
- const waitFor = assetPromise ? Promise.all([p, assetPromise]) : p;
720
- waitFor.then(() => {
721
- if (p && typeof p === "object") {
722
- p.s = 1;
723
- }
724
- resumeBoundaryHydration(o, id, set);
725
- }, err => {
726
- if (p && typeof p === "object") {
727
- p.s = 2;
728
- p.v = err;
729
- }
730
- resumeBoundaryHydration(o, id, set);
731
- });
714
+ waitAndResume(p, resume, assetPromise);
732
715
  } else {
733
716
  const afterAssets = () => {
734
717
  _pendingBoundaries--;
@@ -740,10 +723,20 @@ function createLoadingBoundary(fn, fallback, options) {
740
723
  return fallback();
741
724
  }
742
725
  }
726
+ if (sharedConfig.hydrating && sharedConfig.has(id + "_fr") && !settledSerializationResumeQueued) {
727
+ settledSerializationResumeQueued = true;
728
+ const fr = sharedConfig.load(id + "_fr");
729
+ const [, resume] = initBoundaryResume(o, id);
730
+ if (fr && typeof fr === "object" && (fr.s === 1 || fr.s === 2)) {
731
+ if (scheduleResumeAfterAssets(id, resume, assetPromise)) return undefined;
732
+ return fallback();
733
+ }
734
+ waitAndResume(fr, resume, assetPromise);
735
+ return fallback();
736
+ }
743
737
  if (assetPromise && !sharedConfig.has(id)) {
744
- _pendingBoundaries++;
745
- const set = createBoundaryTrigger();
746
- assetPromise.then(() => resumeBoundaryHydration(o, id, set));
738
+ const [, resume] = initBoundaryResume(o, id);
739
+ assetPromise.then(resume);
747
740
  return undefined;
748
741
  }
749
742
  return signals.createLoadingBoundary(fn, fallback, options);
@@ -820,10 +813,10 @@ function Repeat(props) {
820
813
  }
821
814
  function Show(props) {
822
815
  const keyed = props.keyed;
823
- const conditionValue = signals.createMemo(() => props.when, undefined, {
816
+ const conditionValue = signals.createMemo(() => props.when, {
824
817
  name: "condition value"
825
818
  } );
826
- const condition = keyed ? conditionValue : signals.createMemo(conditionValue, undefined, {
819
+ const condition = keyed ? conditionValue : signals.createMemo(conditionValue, {
827
820
  equals: (a, b) => !a === !b,
828
821
  name: "condition"
829
822
  } );
@@ -838,7 +831,7 @@ function Show(props) {
838
831
  }), "<Show>") : child;
839
832
  }
840
833
  return props.fallback;
841
- }, undefined, {
834
+ }, {
842
835
  name: "value"
843
836
  } );
844
837
  }
@@ -851,10 +844,10 @@ function Switch(props) {
851
844
  const index = i;
852
845
  const mp = mps[i];
853
846
  const prevFunc = func;
854
- const conditionValue = signals.createMemo(() => prevFunc() ? undefined : mp.when, undefined, {
847
+ const conditionValue = signals.createMemo(() => prevFunc() ? undefined : mp.when, {
855
848
  name: "condition value"
856
849
  } );
857
- const condition = mp.keyed ? conditionValue : signals.createMemo(conditionValue, undefined, {
850
+ const condition = mp.keyed ? conditionValue : signals.createMemo(conditionValue, {
858
851
  equals: (a, b) => !a === !b,
859
852
  name: "condition"
860
853
  } );
@@ -872,7 +865,7 @@ function Switch(props) {
872
865
  if (signals.untrack(switchFunc)()?.[0] !== index) throw narrowedError("Match");
873
866
  return conditionValue();
874
867
  }), "<Match>") : child;
875
- }, undefined, {
868
+ }, {
876
869
  name: "eval conditions"
877
870
  } );
878
871
  }
@@ -892,14 +885,16 @@ function Loading(props) {
892
885
  } : undefined;
893
886
  return createLoadingBoundary(() => props.children, () => props.fallback, onOpt);
894
887
  }
888
+ function Reveal(props) {
889
+ return signals.createRevealOrder(() => props.children, {
890
+ together: () => !!props.together,
891
+ collapsed: () => !!props.collapsed
892
+ });
893
+ }
895
894
 
896
895
  function ssrHandleError() {}
897
896
  function ssrRunInScope() {}
898
- const DevHooks = {};
899
- const DEV = {
900
- hooks: DevHooks,
901
- registerGraph
902
- } ;
897
+ const DEV = signals.DEV ;
903
898
  if (globalThis) {
904
899
  if (!globalThis.Solid$$) globalThis.Solid$$ = true;else console.warn("You appear to have multiple instances of Solid. This can lead to unexpected behavior.");
905
900
  }
@@ -932,6 +927,10 @@ Object.defineProperty(exports, "createReaction", {
932
927
  enumerable: true,
933
928
  get: function () { return signals.createReaction; }
934
929
  });
930
+ Object.defineProperty(exports, "createRevealOrder", {
931
+ enumerable: true,
932
+ get: function () { return signals.createRevealOrder; }
933
+ });
935
934
  Object.defineProperty(exports, "createRoot", {
936
935
  enumerable: true,
937
936
  get: function () { return signals.createRoot; }
@@ -972,6 +971,10 @@ Object.defineProperty(exports, "getOwner", {
972
971
  enumerable: true,
973
972
  get: function () { return signals.getOwner; }
974
973
  });
974
+ Object.defineProperty(exports, "isDisposed", {
975
+ enumerable: true,
976
+ get: function () { return signals.isDisposed; }
977
+ });
975
978
  Object.defineProperty(exports, "isEqual", {
976
979
  enumerable: true,
977
980
  get: function () { return signals.isEqual; }
@@ -1054,6 +1057,7 @@ exports.Match = Match;
1054
1057
  exports.NoHydrateContext = NoHydrateContext;
1055
1058
  exports.NoHydration = NoHydration;
1056
1059
  exports.Repeat = Repeat;
1060
+ exports.Reveal = Reveal;
1057
1061
  exports.Show = Show;
1058
1062
  exports.Switch = Switch;
1059
1063
  exports.children = children;