solid-js 2.0.0-beta.3 → 2.0.0-beta.5

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/solid.cjs CHANGED
@@ -72,6 +72,7 @@ function drainHydrationCallbacks() {
72
72
  if (cbs) for (const cb of cbs) cb();
73
73
  setTimeout(() => {
74
74
  if (globalThis._$HY) globalThis._$HY.done = true;
75
+ sharedConfig.registry?.clear();
75
76
  });
76
77
  }
77
78
  function checkHydrationComplete() {
@@ -89,23 +90,10 @@ let _createOptimisticStore;
89
90
  let _createRenderEffect;
90
91
  let _createEffect;
91
92
  class MockPromise {
92
- static all() {
93
- return new MockPromise();
94
- }
95
- static allSettled() {
96
- return new MockPromise();
97
- }
98
- static any() {
99
- return new MockPromise();
100
- }
101
- static race() {
102
- return new MockPromise();
103
- }
104
- static reject() {
105
- return new MockPromise();
106
- }
107
- static resolve() {
108
- return new MockPromise();
93
+ static {
94
+ for (const k of ["all", "allSettled", "any", "race", "reject", "resolve"]) {
95
+ MockPromise[k] = () => new MockPromise();
96
+ }
109
97
  }
110
98
  catch() {
111
99
  return new MockPromise();
@@ -140,6 +128,28 @@ function syncThenable(value) {
140
128
  }
141
129
  };
142
130
  }
131
+ const NO_HYDRATED_VALUE = Symbol("NO_HYDRATED_VALUE");
132
+ function readHydratedValue(initP, refresh) {
133
+ if (initP == null) return NO_HYDRATED_VALUE;
134
+ refresh();
135
+ if (typeof initP === "object" && initP.s === 2) throw initP.v;
136
+ return initP?.v ?? initP;
137
+ }
138
+ function readSerializedOrCompute(compute, prev) {
139
+ if (!sharedConfig.hydrating) return compute(prev);
140
+ const o = signals.getOwner();
141
+ let initP;
142
+ if (sharedConfig.has(o.id)) initP = sharedConfig.load(o.id);
143
+ const init = readHydratedValue(initP, () => subFetch(compute, prev));
144
+ return init !== NO_HYDRATED_VALUE ? init : compute(prev);
145
+ }
146
+ function forwardIteratorReturn(it, value) {
147
+ const returned = it.return?.(value);
148
+ return returned && typeof returned.then === "function" ? returned : syncThenable(returned ?? {
149
+ done: true,
150
+ value
151
+ });
152
+ }
143
153
  function normalizeIterator(it) {
144
154
  let first = true;
145
155
  let buffered = null;
@@ -166,6 +176,10 @@ function normalizeIterator(it) {
166
176
  latest = peek;
167
177
  }
168
178
  return Promise.resolve(latest);
179
+ },
180
+ return(value) {
181
+ buffered = null;
182
+ return forwardIteratorReturn(it, value);
169
183
  }
170
184
  };
171
185
  }
@@ -243,6 +257,9 @@ function wrapFirstYield(iterable, activate) {
243
257
  });
244
258
  }
245
259
  return p;
260
+ },
261
+ return(value) {
262
+ return forwardIteratorReturn(srcIt, value);
246
263
  }
247
264
  };
248
265
  }
@@ -325,6 +342,10 @@ function hydrateStoreFromAsyncIterable(coreFn, initialValue, options) {
325
342
  if (!r.done) result = process(r);
326
343
  }
327
344
  return Promise.resolve(result);
345
+ },
346
+ return(value) {
347
+ buffered = null;
348
+ return forwardIteratorReturn(srcIt, value);
328
349
  }
329
350
  };
330
351
  }
@@ -357,14 +378,7 @@ function hydratedCreateMemo(compute, value, options) {
357
378
  }
358
379
  const aiResult = hydrateSignalFromAsyncIterable(signals.createMemo, compute, value, options);
359
380
  if (aiResult !== null) return aiResult;
360
- return signals.createMemo(prev => {
361
- const o = signals.getOwner();
362
- if (!sharedConfig.hydrating) return compute(prev);
363
- let initP;
364
- if (sharedConfig.has(o.id)) initP = sharedConfig.load(o.id);
365
- const init = initP?.v ?? initP;
366
- return init != null ? (subFetch(compute, prev), init) : compute(prev);
367
- }, value, options);
381
+ return signals.createMemo(prev => readSerializedOrCompute(compute, prev), value, options);
368
382
  }
369
383
  function hydratedCreateSignal(fn, second, third) {
370
384
  if (typeof fn !== "function" || !sharedConfig.hydrating) return signals.createSignal(fn, second, third);
@@ -390,14 +404,7 @@ function hydratedCreateSignal(fn, second, third) {
390
404
  }
391
405
  const aiResult = hydrateSignalFromAsyncIterable(signals.createSignal, fn, second, third);
392
406
  if (aiResult !== null) return aiResult;
393
- return signals.createSignal(prev => {
394
- if (!sharedConfig.hydrating) return fn(prev);
395
- const o = signals.getOwner();
396
- let initP;
397
- if (sharedConfig.has(o.id)) initP = sharedConfig.load(o.id);
398
- const init = initP?.v ?? initP;
399
- return init != null ? (subFetch(fn, prev), init) : fn(prev);
400
- }, second, third);
407
+ return signals.createSignal(prev => readSerializedOrCompute(fn, prev), second, third);
401
408
  }
402
409
  function hydratedCreateErrorBoundary(fn, fallback) {
403
410
  if (!sharedConfig.hydrating) return signals.createErrorBoundary(fn, fallback);
@@ -443,24 +450,10 @@ function hydratedCreateOptimistic(fn, second, third) {
443
450
  }
444
451
  const aiResult = hydrateSignalFromAsyncIterable(signals.createOptimistic, fn, second, third);
445
452
  if (aiResult !== null) return aiResult;
446
- return signals.createOptimistic(prev => {
447
- const o = signals.getOwner();
448
- if (!sharedConfig.hydrating) return fn(prev);
449
- let initP;
450
- if (sharedConfig.has(o.id)) initP = sharedConfig.load(o.id);
451
- const init = initP?.v ?? initP;
452
- return init != null ? (subFetch(fn, prev), init) : fn(prev);
453
- }, second, third);
453
+ return signals.createOptimistic(prev => readSerializedOrCompute(fn, prev), second, third);
454
454
  }
455
455
  function wrapStoreFn(fn) {
456
- return draft => {
457
- const o = signals.getOwner();
458
- if (!sharedConfig.hydrating) return fn(draft);
459
- let initP;
460
- if (sharedConfig.has(o.id)) initP = sharedConfig.load(o.id);
461
- const init = initP?.v ?? initP;
462
- return init != null ? (subFetch(fn, draft), init) : fn(draft);
463
- };
456
+ return draft => readSerializedOrCompute(() => fn(draft), draft);
464
457
  }
465
458
  function hydrateStoreLikeFn(coreFn, fn, initialValue, options, ssrSource) {
466
459
  if (ssrSource === "client") {
@@ -483,11 +476,8 @@ function hydrateStoreLikeFn(coreFn, fn, initialValue, options, ssrSource) {
483
476
  if (!hydrated()) {
484
477
  if (sharedConfig.has(o.id)) {
485
478
  const initP = sharedConfig.load(o.id);
486
- const init = initP?.v ?? initP;
487
- if (init != null) {
488
- subFetch(fn, draft);
489
- return init;
490
- }
479
+ const init = readHydratedValue(initP, () => subFetch(fn, draft));
480
+ if (init !== NO_HYDRATED_VALUE) return init;
491
481
  }
492
482
  return fn(draft);
493
483
  }
@@ -554,14 +544,7 @@ function hydratedEffect(coreFn, compute, effectFn, value, options) {
554
544
  return;
555
545
  }
556
546
  markTopLevelSnapshotScope();
557
- coreFn(prev => {
558
- const o = signals.getOwner();
559
- if (!sharedConfig.hydrating) return compute(prev);
560
- let initP;
561
- if (sharedConfig.has(o.id)) initP = sharedConfig.load(o.id);
562
- const init = initP?.v ?? initP;
563
- return init != null ? (subFetch(compute, prev), init) : compute(prev);
564
- }, effectFn, value, options);
547
+ coreFn(prev => readSerializedOrCompute(compute, prev), effectFn, value, options);
565
548
  }
566
549
  function hydratedCreateRenderEffect(compute, effectFn, value, options) {
567
550
  return hydratedEffect(signals.createRenderEffect, compute, effectFn, value, options);
@@ -659,23 +642,21 @@ function resumeBoundaryHydration(o, id, set) {
659
642
  checkHydrationComplete();
660
643
  return;
661
644
  }
662
- sharedConfig.gather(id);
645
+ sharedConfig.gather?.(id);
663
646
  _hydratingValue = true;
664
647
  signals.markSnapshotScope(o);
665
648
  _snapshotRootOwner = o;
666
649
  set();
667
650
  signals.flush();
668
651
  _snapshotRootOwner = null;
652
+ _hydratingValue = false;
669
653
  signals.releaseSnapshotScope(o);
670
654
  signals.flush();
671
- _hydratingValue = false;
672
655
  checkHydrationComplete();
673
656
  }
674
- function Loading(props) {
675
- const onOpt = props.on ? {
676
- on: () => props.on()
677
- } : undefined;
678
- if (!sharedConfig.hydrating) return signals.createLoadingBoundary(() => props.children, () => props.fallback, onOpt);
657
+ function createLoadingBoundary(fn, fallback, options) {
658
+ if (!sharedConfig.hydrating) return signals.createLoadingBoundary(fn, fallback, options);
659
+ let settledSerializationResumeQueued = false;
679
660
  return signals.createMemo(() => {
680
661
  const o = signals.getOwner();
681
662
  const id = o.id;
@@ -685,10 +666,26 @@ function Loading(props) {
685
666
  if (mapping && typeof mapping === "object") assetPromise = loadModuleAssets(mapping);
686
667
  }
687
668
  if (sharedConfig.hydrating && sharedConfig.has(id)) {
688
- let ref = sharedConfig.load(id);
669
+ const ref = sharedConfig.load(id);
689
670
  let p;
690
671
  if (ref) {
691
- if (typeof ref !== "object" || ref.s !== 1) p = ref;else sharedConfig.gather(id);
672
+ if (typeof ref !== "object" || ref.s == null) p = ref;else if (ref.s === 1 || ref.s === 2) sharedConfig.gather?.(id);else p = ref;
673
+ }
674
+ if (ref && typeof ref === "object" && ref.s === 1 && p == null && !settledSerializationResumeQueued) {
675
+ settledSerializationResumeQueued = true;
676
+ _pendingBoundaries++;
677
+ signals.onCleanup(() => {
678
+ if (!signals.isDisposed(o)) return;
679
+ sharedConfig.cleanupFragment?.(id);
680
+ });
681
+ const set = createBoundaryTrigger();
682
+ const scheduleResume = () => queueMicrotask(() => resumeBoundaryHydration(o, id, set));
683
+ if (assetPromise) {
684
+ assetPromise.then(scheduleResume);
685
+ return undefined;
686
+ }
687
+ scheduleResume();
688
+ return fallback();
692
689
  }
693
690
  if (p) {
694
691
  _pendingBoundaries++;
@@ -699,12 +696,17 @@ function Loading(props) {
699
696
  const set = createBoundaryTrigger();
700
697
  if (p !== "$$f") {
701
698
  const waitFor = assetPromise ? Promise.all([p, assetPromise]) : p;
702
- waitFor.then(() => resumeBoundaryHydration(o, id, set), err => {
703
- _pendingBoundaries--;
704
- checkHydrationComplete();
705
- signals.runWithOwner(o, () => {
706
- throw err;
707
- });
699
+ waitFor.then(() => {
700
+ if (p && typeof p === "object") {
701
+ p.s = 1;
702
+ }
703
+ resumeBoundaryHydration(o, id, set);
704
+ }, err => {
705
+ if (p && typeof p === "object") {
706
+ p.s = 2;
707
+ p.v = err;
708
+ }
709
+ resumeBoundaryHydration(o, id, set);
708
710
  });
709
711
  } else {
710
712
  const afterAssets = () => {
@@ -714,17 +716,16 @@ function Loading(props) {
714
716
  };
715
717
  if (assetPromise) assetPromise.then(() => queueMicrotask(afterAssets));else queueMicrotask(afterAssets);
716
718
  }
717
- return props.fallback;
719
+ return fallback();
718
720
  }
719
721
  }
720
- if (assetPromise) {
722
+ if (assetPromise && !sharedConfig.has(id)) {
721
723
  _pendingBoundaries++;
722
724
  const set = createBoundaryTrigger();
723
725
  assetPromise.then(() => resumeBoundaryHydration(o, id, set));
724
726
  return undefined;
725
727
  }
726
- const boundary = signals.createLoadingBoundary(() => props.children, () => props.fallback, onOpt);
727
- return boundary;
728
+ return signals.createLoadingBoundary(fn, fallback, options);
728
729
  });
729
730
  }
730
731
  function NoHydration(props) {
@@ -848,6 +849,12 @@ function Errored(props) {
848
849
  return typeof f === "function" && f.length ? f(err, reset) : f;
849
850
  });
850
851
  }
852
+ function Loading(props) {
853
+ const onOpt = "on" in props ? {
854
+ on: () => props.on
855
+ } : undefined;
856
+ return createLoadingBoundary(() => props.children, () => props.fallback, onOpt);
857
+ }
851
858
 
852
859
  function ssrHandleError() {}
853
860
  function ssrRunInScope() {}
@@ -873,14 +880,6 @@ Object.defineProperty(exports, "action", {
873
880
  enumerable: true,
874
881
  get: function () { return signals.action; }
875
882
  });
876
- Object.defineProperty(exports, "createErrorBoundary", {
877
- enumerable: true,
878
- get: function () { return signals.createErrorBoundary; }
879
- });
880
- Object.defineProperty(exports, "createLoadingBoundary", {
881
- enumerable: true,
882
- get: function () { return signals.createLoadingBoundary; }
883
- });
884
883
  Object.defineProperty(exports, "createOwner", {
885
884
  enumerable: true,
886
885
  get: function () { return signals.createOwner; }
@@ -1017,6 +1016,8 @@ exports.children = children;
1017
1016
  exports.createComponent = createComponent;
1018
1017
  exports.createContext = createContext;
1019
1018
  exports.createEffect = createEffect;
1019
+ exports.createErrorBoundary = createErrorBoundary;
1020
+ exports.createLoadingBoundary = createLoadingBoundary;
1020
1021
  exports.createMemo = createMemo;
1021
1022
  exports.createOptimistic = createOptimistic;
1022
1023
  exports.createOptimisticStore = createOptimisticStore;
package/dist/solid.js CHANGED
@@ -1,5 +1,5 @@
1
- import { getContext, createMemo as createMemo$1, flatten, createRoot, setContext, createLoadingBoundary, getOwner, onCleanup, isDisposed, runWithOwner, createOwner, createEffect as createEffect$1, createOptimistic as createOptimistic$1, createOptimisticStore as createOptimisticStore$1, createProjection as createProjection$1, createRenderEffect as createRenderEffect$1, createSignal as createSignal$1, createStore as createStore$1, setSnapshotCapture, releaseSnapshotScope, getNextChildId, createErrorBoundary as createErrorBoundary$1, markSnapshotScope, flush, clearSnapshots, peekNextChildId, untrack, mapArray, repeat } from '@solidjs/signals';
2
- export { $PROXY, $REFRESH, $TRACK, NotReadyError, action, createErrorBoundary, createLoadingBoundary, createOwner, createReaction, createRoot, createTrackedEffect, deep, enableExternalSource, enforceLoadingBoundary, flatten, flush, getNextChildId, getObserver, getOwner, isEqual, isPending, isRefreshing, isWrappable, latest, mapArray, merge, omit, onCleanup, onSettled, reconcile, refresh, repeat, resolve, runWithOwner, snapshot, storePath, untrack } from '@solidjs/signals';
1
+ import { getContext, createMemo as createMemo$1, flatten, createRoot, setContext, createOwner, runWithOwner, createEffect as createEffect$1, createErrorBoundary as createErrorBoundary$1, createLoadingBoundary as createLoadingBoundary$1, getOwner, onCleanup, isDisposed, createOptimistic as createOptimistic$1, createOptimisticStore as createOptimisticStore$1, createProjection as createProjection$1, createRenderEffect as createRenderEffect$1, createSignal as createSignal$1, createStore as createStore$1, setSnapshotCapture, releaseSnapshotScope, getNextChildId, markSnapshotScope, flush, peekNextChildId, clearSnapshots, untrack, mapArray, repeat } from '@solidjs/signals';
2
+ export { $PROXY, $REFRESH, $TRACK, NotReadyError, action, createOwner, createReaction, createRoot, createTrackedEffect, deep, enableExternalSource, enforceLoadingBoundary, flatten, flush, getNextChildId, getObserver, getOwner, isEqual, isPending, isRefreshing, isWrappable, latest, mapArray, merge, omit, onCleanup, onSettled, reconcile, refresh, repeat, resolve, runWithOwner, snapshot, storePath, untrack } from '@solidjs/signals';
3
3
 
4
4
  const IS_DEV = false;
5
5
  const $DEVCOMP = Symbol(0);
@@ -71,6 +71,7 @@ function drainHydrationCallbacks() {
71
71
  if (cbs) for (const cb of cbs) cb();
72
72
  setTimeout(() => {
73
73
  if (globalThis._$HY) globalThis._$HY.done = true;
74
+ sharedConfig.registry?.clear();
74
75
  });
75
76
  }
76
77
  function checkHydrationComplete() {
@@ -88,23 +89,10 @@ let _createOptimisticStore;
88
89
  let _createRenderEffect;
89
90
  let _createEffect;
90
91
  class MockPromise {
91
- static all() {
92
- return new MockPromise();
93
- }
94
- static allSettled() {
95
- return new MockPromise();
96
- }
97
- static any() {
98
- return new MockPromise();
99
- }
100
- static race() {
101
- return new MockPromise();
102
- }
103
- static reject() {
104
- return new MockPromise();
105
- }
106
- static resolve() {
107
- return new MockPromise();
92
+ static {
93
+ for (const k of ["all", "allSettled", "any", "race", "reject", "resolve"]) {
94
+ MockPromise[k] = () => new MockPromise();
95
+ }
108
96
  }
109
97
  catch() {
110
98
  return new MockPromise();
@@ -139,6 +127,28 @@ function syncThenable(value) {
139
127
  }
140
128
  };
141
129
  }
130
+ const NO_HYDRATED_VALUE = Symbol("NO_HYDRATED_VALUE");
131
+ function readHydratedValue(initP, refresh) {
132
+ if (initP == null) return NO_HYDRATED_VALUE;
133
+ refresh();
134
+ if (typeof initP === "object" && initP.s === 2) throw initP.v;
135
+ return initP?.v ?? initP;
136
+ }
137
+ function readSerializedOrCompute(compute, prev) {
138
+ if (!sharedConfig.hydrating) return compute(prev);
139
+ const o = getOwner();
140
+ let initP;
141
+ if (sharedConfig.has(o.id)) initP = sharedConfig.load(o.id);
142
+ const init = readHydratedValue(initP, () => subFetch(compute, prev));
143
+ return init !== NO_HYDRATED_VALUE ? init : compute(prev);
144
+ }
145
+ function forwardIteratorReturn(it, value) {
146
+ const returned = it.return?.(value);
147
+ return returned && typeof returned.then === "function" ? returned : syncThenable(returned ?? {
148
+ done: true,
149
+ value
150
+ });
151
+ }
142
152
  function normalizeIterator(it) {
143
153
  let first = true;
144
154
  let buffered = null;
@@ -165,6 +175,10 @@ function normalizeIterator(it) {
165
175
  latest = peek;
166
176
  }
167
177
  return Promise.resolve(latest);
178
+ },
179
+ return(value) {
180
+ buffered = null;
181
+ return forwardIteratorReturn(it, value);
168
182
  }
169
183
  };
170
184
  }
@@ -242,6 +256,9 @@ function wrapFirstYield(iterable, activate) {
242
256
  });
243
257
  }
244
258
  return p;
259
+ },
260
+ return(value) {
261
+ return forwardIteratorReturn(srcIt, value);
245
262
  }
246
263
  };
247
264
  }
@@ -324,6 +341,10 @@ function hydrateStoreFromAsyncIterable(coreFn, initialValue, options) {
324
341
  if (!r.done) result = process(r);
325
342
  }
326
343
  return Promise.resolve(result);
344
+ },
345
+ return(value) {
346
+ buffered = null;
347
+ return forwardIteratorReturn(srcIt, value);
327
348
  }
328
349
  };
329
350
  }
@@ -356,14 +377,7 @@ function hydratedCreateMemo(compute, value, options) {
356
377
  }
357
378
  const aiResult = hydrateSignalFromAsyncIterable(createMemo$1, compute, value, options);
358
379
  if (aiResult !== null) return aiResult;
359
- return createMemo$1(prev => {
360
- const o = getOwner();
361
- if (!sharedConfig.hydrating) return compute(prev);
362
- let initP;
363
- if (sharedConfig.has(o.id)) initP = sharedConfig.load(o.id);
364
- const init = initP?.v ?? initP;
365
- return init != null ? (subFetch(compute, prev), init) : compute(prev);
366
- }, value, options);
380
+ return createMemo$1(prev => readSerializedOrCompute(compute, prev), value, options);
367
381
  }
368
382
  function hydratedCreateSignal(fn, second, third) {
369
383
  if (typeof fn !== "function" || !sharedConfig.hydrating) return createSignal$1(fn, second, third);
@@ -389,14 +403,7 @@ function hydratedCreateSignal(fn, second, third) {
389
403
  }
390
404
  const aiResult = hydrateSignalFromAsyncIterable(createSignal$1, fn, second, third);
391
405
  if (aiResult !== null) return aiResult;
392
- return createSignal$1(prev => {
393
- if (!sharedConfig.hydrating) return fn(prev);
394
- const o = getOwner();
395
- let initP;
396
- if (sharedConfig.has(o.id)) initP = sharedConfig.load(o.id);
397
- const init = initP?.v ?? initP;
398
- return init != null ? (subFetch(fn, prev), init) : fn(prev);
399
- }, second, third);
406
+ return createSignal$1(prev => readSerializedOrCompute(fn, prev), second, third);
400
407
  }
401
408
  function hydratedCreateErrorBoundary(fn, fallback) {
402
409
  if (!sharedConfig.hydrating) return createErrorBoundary$1(fn, fallback);
@@ -442,24 +449,10 @@ function hydratedCreateOptimistic(fn, second, third) {
442
449
  }
443
450
  const aiResult = hydrateSignalFromAsyncIterable(createOptimistic$1, fn, second, third);
444
451
  if (aiResult !== null) return aiResult;
445
- return createOptimistic$1(prev => {
446
- const o = getOwner();
447
- if (!sharedConfig.hydrating) return fn(prev);
448
- let initP;
449
- if (sharedConfig.has(o.id)) initP = sharedConfig.load(o.id);
450
- const init = initP?.v ?? initP;
451
- return init != null ? (subFetch(fn, prev), init) : fn(prev);
452
- }, second, third);
452
+ return createOptimistic$1(prev => readSerializedOrCompute(fn, prev), second, third);
453
453
  }
454
454
  function wrapStoreFn(fn) {
455
- return draft => {
456
- const o = getOwner();
457
- if (!sharedConfig.hydrating) return fn(draft);
458
- let initP;
459
- if (sharedConfig.has(o.id)) initP = sharedConfig.load(o.id);
460
- const init = initP?.v ?? initP;
461
- return init != null ? (subFetch(fn, draft), init) : fn(draft);
462
- };
455
+ return draft => readSerializedOrCompute(() => fn(draft), draft);
463
456
  }
464
457
  function hydrateStoreLikeFn(coreFn, fn, initialValue, options, ssrSource) {
465
458
  if (ssrSource === "client") {
@@ -482,11 +475,8 @@ function hydrateStoreLikeFn(coreFn, fn, initialValue, options, ssrSource) {
482
475
  if (!hydrated()) {
483
476
  if (sharedConfig.has(o.id)) {
484
477
  const initP = sharedConfig.load(o.id);
485
- const init = initP?.v ?? initP;
486
- if (init != null) {
487
- subFetch(fn, draft);
488
- return init;
489
- }
478
+ const init = readHydratedValue(initP, () => subFetch(fn, draft));
479
+ if (init !== NO_HYDRATED_VALUE) return init;
490
480
  }
491
481
  return fn(draft);
492
482
  }
@@ -553,14 +543,7 @@ function hydratedEffect(coreFn, compute, effectFn, value, options) {
553
543
  return;
554
544
  }
555
545
  markTopLevelSnapshotScope();
556
- coreFn(prev => {
557
- const o = getOwner();
558
- if (!sharedConfig.hydrating) return compute(prev);
559
- let initP;
560
- if (sharedConfig.has(o.id)) initP = sharedConfig.load(o.id);
561
- const init = initP?.v ?? initP;
562
- return init != null ? (subFetch(compute, prev), init) : compute(prev);
563
- }, effectFn, value, options);
546
+ coreFn(prev => readSerializedOrCompute(compute, prev), effectFn, value, options);
564
547
  }
565
548
  function hydratedCreateRenderEffect(compute, effectFn, value, options) {
566
549
  return hydratedEffect(createRenderEffect$1, compute, effectFn, value, options);
@@ -658,23 +641,21 @@ function resumeBoundaryHydration(o, id, set) {
658
641
  checkHydrationComplete();
659
642
  return;
660
643
  }
661
- sharedConfig.gather(id);
644
+ sharedConfig.gather?.(id);
662
645
  _hydratingValue = true;
663
646
  markSnapshotScope(o);
664
647
  _snapshotRootOwner = o;
665
648
  set();
666
649
  flush();
667
650
  _snapshotRootOwner = null;
651
+ _hydratingValue = false;
668
652
  releaseSnapshotScope(o);
669
653
  flush();
670
- _hydratingValue = false;
671
654
  checkHydrationComplete();
672
655
  }
673
- function Loading(props) {
674
- const onOpt = props.on ? {
675
- on: () => props.on()
676
- } : undefined;
677
- if (!sharedConfig.hydrating) return createLoadingBoundary(() => props.children, () => props.fallback, onOpt);
656
+ function createLoadingBoundary(fn, fallback, options) {
657
+ if (!sharedConfig.hydrating) return createLoadingBoundary$1(fn, fallback, options);
658
+ let settledSerializationResumeQueued = false;
678
659
  return createMemo$1(() => {
679
660
  const o = getOwner();
680
661
  const id = o.id;
@@ -684,10 +665,26 @@ function Loading(props) {
684
665
  if (mapping && typeof mapping === "object") assetPromise = loadModuleAssets(mapping);
685
666
  }
686
667
  if (sharedConfig.hydrating && sharedConfig.has(id)) {
687
- let ref = sharedConfig.load(id);
668
+ const ref = sharedConfig.load(id);
688
669
  let p;
689
670
  if (ref) {
690
- if (typeof ref !== "object" || ref.s !== 1) p = ref;else sharedConfig.gather(id);
671
+ if (typeof ref !== "object" || ref.s == null) p = ref;else if (ref.s === 1 || ref.s === 2) sharedConfig.gather?.(id);else p = ref;
672
+ }
673
+ if (ref && typeof ref === "object" && ref.s === 1 && p == null && !settledSerializationResumeQueued) {
674
+ settledSerializationResumeQueued = true;
675
+ _pendingBoundaries++;
676
+ onCleanup(() => {
677
+ if (!isDisposed(o)) return;
678
+ sharedConfig.cleanupFragment?.(id);
679
+ });
680
+ const set = createBoundaryTrigger();
681
+ const scheduleResume = () => queueMicrotask(() => resumeBoundaryHydration(o, id, set));
682
+ if (assetPromise) {
683
+ assetPromise.then(scheduleResume);
684
+ return undefined;
685
+ }
686
+ scheduleResume();
687
+ return fallback();
691
688
  }
692
689
  if (p) {
693
690
  _pendingBoundaries++;
@@ -698,12 +695,17 @@ function Loading(props) {
698
695
  const set = createBoundaryTrigger();
699
696
  if (p !== "$$f") {
700
697
  const waitFor = assetPromise ? Promise.all([p, assetPromise]) : p;
701
- waitFor.then(() => resumeBoundaryHydration(o, id, set), err => {
702
- _pendingBoundaries--;
703
- checkHydrationComplete();
704
- runWithOwner(o, () => {
705
- throw err;
706
- });
698
+ waitFor.then(() => {
699
+ if (p && typeof p === "object") {
700
+ p.s = 1;
701
+ }
702
+ resumeBoundaryHydration(o, id, set);
703
+ }, err => {
704
+ if (p && typeof p === "object") {
705
+ p.s = 2;
706
+ p.v = err;
707
+ }
708
+ resumeBoundaryHydration(o, id, set);
707
709
  });
708
710
  } else {
709
711
  const afterAssets = () => {
@@ -713,17 +715,16 @@ function Loading(props) {
713
715
  };
714
716
  if (assetPromise) assetPromise.then(() => queueMicrotask(afterAssets));else queueMicrotask(afterAssets);
715
717
  }
716
- return props.fallback;
718
+ return fallback();
717
719
  }
718
720
  }
719
- if (assetPromise) {
721
+ if (assetPromise && !sharedConfig.has(id)) {
720
722
  _pendingBoundaries++;
721
723
  const set = createBoundaryTrigger();
722
724
  assetPromise.then(() => resumeBoundaryHydration(o, id, set));
723
725
  return undefined;
724
726
  }
725
- const boundary = createLoadingBoundary(() => props.children, () => props.fallback, onOpt);
726
- return boundary;
727
+ return createLoadingBoundary$1(fn, fallback, options);
727
728
  });
728
729
  }
729
730
  function NoHydration(props) {
@@ -847,9 +848,15 @@ function Errored(props) {
847
848
  return typeof f === "function" && f.length ? f(err, reset) : f;
848
849
  });
849
850
  }
851
+ function Loading(props) {
852
+ const onOpt = "on" in props ? {
853
+ on: () => props.on
854
+ } : undefined;
855
+ return createLoadingBoundary(() => props.children, () => props.fallback, onOpt);
856
+ }
850
857
 
851
858
  function ssrHandleError() {}
852
859
  function ssrRunInScope() {}
853
860
  const DEV = undefined;
854
861
 
855
- export { $DEVCOMP, DEV, Errored, For, Hydration, Loading, Match, NoHydrateContext, NoHydration, Repeat, Show, Switch, children, createComponent, createContext, createEffect, createMemo, createOptimistic, createOptimisticStore, createProjection, createRenderEffect, createSignal, createStore, createUniqueId, enableHydration, lazy, sharedConfig, ssrHandleError, ssrRunInScope, useContext };
862
+ export { $DEVCOMP, DEV, Errored, For, Hydration, Loading, Match, NoHydrateContext, NoHydration, Repeat, Show, Switch, children, createComponent, createContext, createEffect, createErrorBoundary, createLoadingBoundary, createMemo, createOptimistic, createOptimisticStore, createProjection, createRenderEffect, createSignal, createStore, createUniqueId, enableHydration, lazy, sharedConfig, ssrHandleError, ssrRunInScope, useContext };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "solid-js",
3
3
  "description": "A declarative JavaScript library for building user interfaces.",
4
- "version": "2.0.0-beta.3",
4
+ "version": "2.0.0-beta.5",
5
5
  "author": "Ryan Carniato",
6
6
  "license": "MIT",
7
7
  "homepage": "https://solidjs.com",
@@ -79,7 +79,7 @@
79
79
  "performance"
80
80
  ],
81
81
  "dependencies": {
82
- "@solidjs/signals": "^0.13.3",
82
+ "@solidjs/signals": "^0.13.9",
83
83
  "csstype": "^3.1.0",
84
84
  "seroval": "~1.5.0",
85
85
  "seroval-plugins": "~1.5.0"