solid-js 2.0.0-beta.4 → 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/dev.cjs CHANGED
@@ -93,6 +93,7 @@ function drainHydrationCallbacks() {
93
93
  setTimeout(() => {
94
94
  if (sharedConfig.verifyHydration) sharedConfig.verifyHydration();
95
95
  if (globalThis._$HY) globalThis._$HY.done = true;
96
+ sharedConfig.registry?.clear();
96
97
  });
97
98
  }
98
99
  function checkHydrationComplete() {
@@ -110,23 +111,10 @@ let _createOptimisticStore;
110
111
  let _createRenderEffect;
111
112
  let _createEffect;
112
113
  class MockPromise {
113
- static all() {
114
- return new MockPromise();
115
- }
116
- static allSettled() {
117
- return new MockPromise();
118
- }
119
- static any() {
120
- return new MockPromise();
121
- }
122
- static race() {
123
- return new MockPromise();
124
- }
125
- static reject() {
126
- return new MockPromise();
127
- }
128
- static resolve() {
129
- return new MockPromise();
114
+ static {
115
+ for (const k of ["all", "allSettled", "any", "race", "reject", "resolve"]) {
116
+ MockPromise[k] = () => new MockPromise();
117
+ }
130
118
  }
131
119
  catch() {
132
120
  return new MockPromise();
@@ -161,6 +149,28 @@ function syncThenable(value) {
161
149
  }
162
150
  };
163
151
  }
152
+ const NO_HYDRATED_VALUE = Symbol("NO_HYDRATED_VALUE");
153
+ function readHydratedValue(initP, refresh) {
154
+ if (initP == null) return NO_HYDRATED_VALUE;
155
+ refresh();
156
+ if (typeof initP === "object" && initP.s === 2) throw initP.v;
157
+ return initP?.v ?? initP;
158
+ }
159
+ function readSerializedOrCompute(compute, prev) {
160
+ if (!sharedConfig.hydrating) return compute(prev);
161
+ const o = signals.getOwner();
162
+ let initP;
163
+ if (sharedConfig.has(o.id)) initP = sharedConfig.load(o.id);
164
+ const init = readHydratedValue(initP, () => subFetch(compute, prev));
165
+ return init !== NO_HYDRATED_VALUE ? init : compute(prev);
166
+ }
167
+ function forwardIteratorReturn(it, value) {
168
+ const returned = it.return?.(value);
169
+ return returned && typeof returned.then === "function" ? returned : syncThenable(returned ?? {
170
+ done: true,
171
+ value
172
+ });
173
+ }
164
174
  function normalizeIterator(it) {
165
175
  let first = true;
166
176
  let buffered = null;
@@ -187,6 +197,10 @@ function normalizeIterator(it) {
187
197
  latest = peek;
188
198
  }
189
199
  return Promise.resolve(latest);
200
+ },
201
+ return(value) {
202
+ buffered = null;
203
+ return forwardIteratorReturn(it, value);
190
204
  }
191
205
  };
192
206
  }
@@ -264,6 +278,9 @@ function wrapFirstYield(iterable, activate) {
264
278
  });
265
279
  }
266
280
  return p;
281
+ },
282
+ return(value) {
283
+ return forwardIteratorReturn(srcIt, value);
267
284
  }
268
285
  };
269
286
  }
@@ -346,6 +363,10 @@ function hydrateStoreFromAsyncIterable(coreFn, initialValue, options) {
346
363
  if (!r.done) result = process(r);
347
364
  }
348
365
  return Promise.resolve(result);
366
+ },
367
+ return(value) {
368
+ buffered = null;
369
+ return forwardIteratorReturn(srcIt, value);
349
370
  }
350
371
  };
351
372
  }
@@ -378,14 +399,7 @@ function hydratedCreateMemo(compute, value, options) {
378
399
  }
379
400
  const aiResult = hydrateSignalFromAsyncIterable(signals.createMemo, compute, value, options);
380
401
  if (aiResult !== null) return aiResult;
381
- return signals.createMemo(prev => {
382
- const o = signals.getOwner();
383
- if (!sharedConfig.hydrating) return compute(prev);
384
- let initP;
385
- if (sharedConfig.has(o.id)) initP = sharedConfig.load(o.id);
386
- const init = initP?.v ?? initP;
387
- return init != null ? (subFetch(compute, prev), init) : compute(prev);
388
- }, value, options);
402
+ return signals.createMemo(prev => readSerializedOrCompute(compute, prev), value, options);
389
403
  }
390
404
  function hydratedCreateSignal(fn, second, third) {
391
405
  if (typeof fn !== "function" || !sharedConfig.hydrating) return signals.createSignal(fn, second, third);
@@ -411,14 +425,7 @@ function hydratedCreateSignal(fn, second, third) {
411
425
  }
412
426
  const aiResult = hydrateSignalFromAsyncIterable(signals.createSignal, fn, second, third);
413
427
  if (aiResult !== null) return aiResult;
414
- return signals.createSignal(prev => {
415
- if (!sharedConfig.hydrating) return fn(prev);
416
- const o = signals.getOwner();
417
- let initP;
418
- if (sharedConfig.has(o.id)) initP = sharedConfig.load(o.id);
419
- const init = initP?.v ?? initP;
420
- return init != null ? (subFetch(fn, prev), init) : fn(prev);
421
- }, second, third);
428
+ return signals.createSignal(prev => readSerializedOrCompute(fn, prev), second, third);
422
429
  }
423
430
  function hydratedCreateErrorBoundary(fn, fallback) {
424
431
  if (!sharedConfig.hydrating) return signals.createErrorBoundary(fn, fallback);
@@ -464,24 +471,10 @@ function hydratedCreateOptimistic(fn, second, third) {
464
471
  }
465
472
  const aiResult = hydrateSignalFromAsyncIterable(signals.createOptimistic, fn, second, third);
466
473
  if (aiResult !== null) return aiResult;
467
- return signals.createOptimistic(prev => {
468
- const o = signals.getOwner();
469
- if (!sharedConfig.hydrating) return fn(prev);
470
- let initP;
471
- if (sharedConfig.has(o.id)) initP = sharedConfig.load(o.id);
472
- const init = initP?.v ?? initP;
473
- return init != null ? (subFetch(fn, prev), init) : fn(prev);
474
- }, second, third);
474
+ return signals.createOptimistic(prev => readSerializedOrCompute(fn, prev), second, third);
475
475
  }
476
476
  function wrapStoreFn(fn) {
477
- return draft => {
478
- const o = signals.getOwner();
479
- if (!sharedConfig.hydrating) return fn(draft);
480
- let initP;
481
- if (sharedConfig.has(o.id)) initP = sharedConfig.load(o.id);
482
- const init = initP?.v ?? initP;
483
- return init != null ? (subFetch(fn, draft), init) : fn(draft);
484
- };
477
+ return draft => readSerializedOrCompute(() => fn(draft), draft);
485
478
  }
486
479
  function hydrateStoreLikeFn(coreFn, fn, initialValue, options, ssrSource) {
487
480
  if (ssrSource === "client") {
@@ -504,11 +497,8 @@ function hydrateStoreLikeFn(coreFn, fn, initialValue, options, ssrSource) {
504
497
  if (!hydrated()) {
505
498
  if (sharedConfig.has(o.id)) {
506
499
  const initP = sharedConfig.load(o.id);
507
- const init = initP?.v ?? initP;
508
- if (init != null) {
509
- subFetch(fn, draft);
510
- return init;
511
- }
500
+ const init = readHydratedValue(initP, () => subFetch(fn, draft));
501
+ if (init !== NO_HYDRATED_VALUE) return init;
512
502
  }
513
503
  return fn(draft);
514
504
  }
@@ -575,14 +565,7 @@ function hydratedEffect(coreFn, compute, effectFn, value, options) {
575
565
  return;
576
566
  }
577
567
  markTopLevelSnapshotScope();
578
- coreFn(prev => {
579
- const o = signals.getOwner();
580
- if (!sharedConfig.hydrating) return compute(prev);
581
- let initP;
582
- if (sharedConfig.has(o.id)) initP = sharedConfig.load(o.id);
583
- const init = initP?.v ?? initP;
584
- return init != null ? (subFetch(compute, prev), init) : compute(prev);
585
- }, effectFn, value, options);
568
+ coreFn(prev => readSerializedOrCompute(compute, prev), effectFn, value, options);
586
569
  }
587
570
  function hydratedCreateRenderEffect(compute, effectFn, value, options) {
588
571
  return hydratedEffect(signals.createRenderEffect, compute, effectFn, value, options);
@@ -680,7 +663,7 @@ function resumeBoundaryHydration(o, id, set) {
680
663
  checkHydrationComplete();
681
664
  return;
682
665
  }
683
- sharedConfig.gather(id);
666
+ sharedConfig.gather?.(id);
684
667
  _hydratingValue = true;
685
668
  signals.markSnapshotScope(o);
686
669
  _snapshotRootOwner = o;
@@ -692,11 +675,9 @@ function resumeBoundaryHydration(o, id, set) {
692
675
  signals.flush();
693
676
  checkHydrationComplete();
694
677
  }
695
- function Loading(props) {
696
- const onOpt = props.on ? {
697
- on: () => props.on()
698
- } : undefined;
699
- if (!sharedConfig.hydrating) return signals.createLoadingBoundary(() => props.children, () => props.fallback, onOpt);
678
+ function createLoadingBoundary(fn, fallback, options) {
679
+ if (!sharedConfig.hydrating) return signals.createLoadingBoundary(fn, fallback, options);
680
+ let settledSerializationResumeQueued = false;
700
681
  return signals.createMemo(() => {
701
682
  const o = signals.getOwner();
702
683
  const id = o.id;
@@ -706,10 +687,26 @@ function Loading(props) {
706
687
  if (mapping && typeof mapping === "object") assetPromise = loadModuleAssets(mapping);
707
688
  }
708
689
  if (sharedConfig.hydrating && sharedConfig.has(id)) {
709
- let ref = sharedConfig.load(id);
690
+ const ref = sharedConfig.load(id);
710
691
  let p;
711
692
  if (ref) {
712
- if (typeof ref !== "object" || ref.s !== 1) p = ref;else sharedConfig.gather(id);
693
+ if (typeof ref !== "object" || ref.s == null) p = ref;else if (ref.s === 1 || ref.s === 2) sharedConfig.gather?.(id);else p = ref;
694
+ }
695
+ if (ref && typeof ref === "object" && ref.s === 1 && p == null && !settledSerializationResumeQueued) {
696
+ 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();
709
+ return fallback();
713
710
  }
714
711
  if (p) {
715
712
  _pendingBoundaries++;
@@ -720,12 +717,17 @@ function Loading(props) {
720
717
  const set = createBoundaryTrigger();
721
718
  if (p !== "$$f") {
722
719
  const waitFor = assetPromise ? Promise.all([p, assetPromise]) : p;
723
- waitFor.then(() => resumeBoundaryHydration(o, id, set), err => {
724
- _pendingBoundaries--;
725
- checkHydrationComplete();
726
- signals.runWithOwner(o, () => {
727
- throw err;
728
- });
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);
729
731
  });
730
732
  } else {
731
733
  const afterAssets = () => {
@@ -735,17 +737,16 @@ function Loading(props) {
735
737
  };
736
738
  if (assetPromise) assetPromise.then(() => queueMicrotask(afterAssets));else queueMicrotask(afterAssets);
737
739
  }
738
- return props.fallback;
740
+ return fallback();
739
741
  }
740
742
  }
741
- if (assetPromise) {
743
+ if (assetPromise && !sharedConfig.has(id)) {
742
744
  _pendingBoundaries++;
743
745
  const set = createBoundaryTrigger();
744
746
  assetPromise.then(() => resumeBoundaryHydration(o, id, set));
745
747
  return undefined;
746
748
  }
747
- const boundary = signals.createLoadingBoundary(() => props.children, () => props.fallback, onOpt);
748
- return boundary;
749
+ return signals.createLoadingBoundary(fn, fallback, options);
749
750
  });
750
751
  }
751
752
  function NoHydration(props) {
@@ -885,6 +886,12 @@ function Errored(props) {
885
886
  return typeof f === "function" && f.length ? f(err, reset) : f;
886
887
  });
887
888
  }
889
+ function Loading(props) {
890
+ const onOpt = "on" in props ? {
891
+ on: () => props.on
892
+ } : undefined;
893
+ return createLoadingBoundary(() => props.children, () => props.fallback, onOpt);
894
+ }
888
895
 
889
896
  function ssrHandleError() {}
890
897
  function ssrRunInScope() {}
@@ -917,14 +924,6 @@ Object.defineProperty(exports, "action", {
917
924
  enumerable: true,
918
925
  get: function () { return signals.action; }
919
926
  });
920
- Object.defineProperty(exports, "createErrorBoundary", {
921
- enumerable: true,
922
- get: function () { return signals.createErrorBoundary; }
923
- });
924
- Object.defineProperty(exports, "createLoadingBoundary", {
925
- enumerable: true,
926
- get: function () { return signals.createLoadingBoundary; }
927
- });
928
927
  Object.defineProperty(exports, "createOwner", {
929
928
  enumerable: true,
930
929
  get: function () { return signals.createOwner; }
@@ -1061,6 +1060,8 @@ exports.children = children;
1061
1060
  exports.createComponent = createComponent;
1062
1061
  exports.createContext = createContext;
1063
1062
  exports.createEffect = createEffect;
1063
+ exports.createErrorBoundary = createErrorBoundary;
1064
+ exports.createLoadingBoundary = createLoadingBoundary;
1064
1065
  exports.createMemo = createMemo;
1065
1066
  exports.createOptimistic = createOptimistic;
1066
1067
  exports.createOptimisticStore = createOptimisticStore;
package/dist/dev.js CHANGED
@@ -1,5 +1,5 @@
1
- import { getContext, createMemo as createMemo$1, flatten, getOwner, createRoot, setContext, untrack, createLoadingBoundary, 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, 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, getOwner, createRoot, setContext, untrack, createOwner, runWithOwner, createEffect as createEffect$1, createErrorBoundary as createErrorBoundary$1, createLoadingBoundary as createLoadingBoundary$1, 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, 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 $DEVCOMP = Symbol("COMPONENT_DEV" );
5
5
  function createContext(defaultValue, options) {
@@ -92,6 +92,7 @@ function drainHydrationCallbacks() {
92
92
  setTimeout(() => {
93
93
  if (sharedConfig.verifyHydration) sharedConfig.verifyHydration();
94
94
  if (globalThis._$HY) globalThis._$HY.done = true;
95
+ sharedConfig.registry?.clear();
95
96
  });
96
97
  }
97
98
  function checkHydrationComplete() {
@@ -109,23 +110,10 @@ let _createOptimisticStore;
109
110
  let _createRenderEffect;
110
111
  let _createEffect;
111
112
  class MockPromise {
112
- static all() {
113
- return new MockPromise();
114
- }
115
- static allSettled() {
116
- return new MockPromise();
117
- }
118
- static any() {
119
- return new MockPromise();
120
- }
121
- static race() {
122
- return new MockPromise();
123
- }
124
- static reject() {
125
- return new MockPromise();
126
- }
127
- static resolve() {
128
- return new MockPromise();
113
+ static {
114
+ for (const k of ["all", "allSettled", "any", "race", "reject", "resolve"]) {
115
+ MockPromise[k] = () => new MockPromise();
116
+ }
129
117
  }
130
118
  catch() {
131
119
  return new MockPromise();
@@ -160,6 +148,28 @@ function syncThenable(value) {
160
148
  }
161
149
  };
162
150
  }
151
+ const NO_HYDRATED_VALUE = Symbol("NO_HYDRATED_VALUE");
152
+ function readHydratedValue(initP, refresh) {
153
+ if (initP == null) return NO_HYDRATED_VALUE;
154
+ refresh();
155
+ if (typeof initP === "object" && initP.s === 2) throw initP.v;
156
+ return initP?.v ?? initP;
157
+ }
158
+ function readSerializedOrCompute(compute, prev) {
159
+ if (!sharedConfig.hydrating) return compute(prev);
160
+ const o = getOwner();
161
+ let initP;
162
+ if (sharedConfig.has(o.id)) initP = sharedConfig.load(o.id);
163
+ const init = readHydratedValue(initP, () => subFetch(compute, prev));
164
+ return init !== NO_HYDRATED_VALUE ? init : compute(prev);
165
+ }
166
+ function forwardIteratorReturn(it, value) {
167
+ const returned = it.return?.(value);
168
+ return returned && typeof returned.then === "function" ? returned : syncThenable(returned ?? {
169
+ done: true,
170
+ value
171
+ });
172
+ }
163
173
  function normalizeIterator(it) {
164
174
  let first = true;
165
175
  let buffered = null;
@@ -186,6 +196,10 @@ function normalizeIterator(it) {
186
196
  latest = peek;
187
197
  }
188
198
  return Promise.resolve(latest);
199
+ },
200
+ return(value) {
201
+ buffered = null;
202
+ return forwardIteratorReturn(it, value);
189
203
  }
190
204
  };
191
205
  }
@@ -263,6 +277,9 @@ function wrapFirstYield(iterable, activate) {
263
277
  });
264
278
  }
265
279
  return p;
280
+ },
281
+ return(value) {
282
+ return forwardIteratorReturn(srcIt, value);
266
283
  }
267
284
  };
268
285
  }
@@ -345,6 +362,10 @@ function hydrateStoreFromAsyncIterable(coreFn, initialValue, options) {
345
362
  if (!r.done) result = process(r);
346
363
  }
347
364
  return Promise.resolve(result);
365
+ },
366
+ return(value) {
367
+ buffered = null;
368
+ return forwardIteratorReturn(srcIt, value);
348
369
  }
349
370
  };
350
371
  }
@@ -377,14 +398,7 @@ function hydratedCreateMemo(compute, value, options) {
377
398
  }
378
399
  const aiResult = hydrateSignalFromAsyncIterable(createMemo$1, compute, value, options);
379
400
  if (aiResult !== null) return aiResult;
380
- return createMemo$1(prev => {
381
- const o = getOwner();
382
- if (!sharedConfig.hydrating) return compute(prev);
383
- let initP;
384
- if (sharedConfig.has(o.id)) initP = sharedConfig.load(o.id);
385
- const init = initP?.v ?? initP;
386
- return init != null ? (subFetch(compute, prev), init) : compute(prev);
387
- }, value, options);
401
+ return createMemo$1(prev => readSerializedOrCompute(compute, prev), value, options);
388
402
  }
389
403
  function hydratedCreateSignal(fn, second, third) {
390
404
  if (typeof fn !== "function" || !sharedConfig.hydrating) return createSignal$1(fn, second, third);
@@ -410,14 +424,7 @@ function hydratedCreateSignal(fn, second, third) {
410
424
  }
411
425
  const aiResult = hydrateSignalFromAsyncIterable(createSignal$1, fn, second, third);
412
426
  if (aiResult !== null) return aiResult;
413
- return createSignal$1(prev => {
414
- if (!sharedConfig.hydrating) return fn(prev);
415
- const o = getOwner();
416
- let initP;
417
- if (sharedConfig.has(o.id)) initP = sharedConfig.load(o.id);
418
- const init = initP?.v ?? initP;
419
- return init != null ? (subFetch(fn, prev), init) : fn(prev);
420
- }, second, third);
427
+ return createSignal$1(prev => readSerializedOrCompute(fn, prev), second, third);
421
428
  }
422
429
  function hydratedCreateErrorBoundary(fn, fallback) {
423
430
  if (!sharedConfig.hydrating) return createErrorBoundary$1(fn, fallback);
@@ -463,24 +470,10 @@ function hydratedCreateOptimistic(fn, second, third) {
463
470
  }
464
471
  const aiResult = hydrateSignalFromAsyncIterable(createOptimistic$1, fn, second, third);
465
472
  if (aiResult !== null) return aiResult;
466
- return createOptimistic$1(prev => {
467
- const o = getOwner();
468
- if (!sharedConfig.hydrating) return fn(prev);
469
- let initP;
470
- if (sharedConfig.has(o.id)) initP = sharedConfig.load(o.id);
471
- const init = initP?.v ?? initP;
472
- return init != null ? (subFetch(fn, prev), init) : fn(prev);
473
- }, second, third);
473
+ return createOptimistic$1(prev => readSerializedOrCompute(fn, prev), second, third);
474
474
  }
475
475
  function wrapStoreFn(fn) {
476
- return draft => {
477
- const o = getOwner();
478
- if (!sharedConfig.hydrating) return fn(draft);
479
- let initP;
480
- if (sharedConfig.has(o.id)) initP = sharedConfig.load(o.id);
481
- const init = initP?.v ?? initP;
482
- return init != null ? (subFetch(fn, draft), init) : fn(draft);
483
- };
476
+ return draft => readSerializedOrCompute(() => fn(draft), draft);
484
477
  }
485
478
  function hydrateStoreLikeFn(coreFn, fn, initialValue, options, ssrSource) {
486
479
  if (ssrSource === "client") {
@@ -503,11 +496,8 @@ function hydrateStoreLikeFn(coreFn, fn, initialValue, options, ssrSource) {
503
496
  if (!hydrated()) {
504
497
  if (sharedConfig.has(o.id)) {
505
498
  const initP = sharedConfig.load(o.id);
506
- const init = initP?.v ?? initP;
507
- if (init != null) {
508
- subFetch(fn, draft);
509
- return init;
510
- }
499
+ const init = readHydratedValue(initP, () => subFetch(fn, draft));
500
+ if (init !== NO_HYDRATED_VALUE) return init;
511
501
  }
512
502
  return fn(draft);
513
503
  }
@@ -574,14 +564,7 @@ function hydratedEffect(coreFn, compute, effectFn, value, options) {
574
564
  return;
575
565
  }
576
566
  markTopLevelSnapshotScope();
577
- coreFn(prev => {
578
- const o = getOwner();
579
- if (!sharedConfig.hydrating) return compute(prev);
580
- let initP;
581
- if (sharedConfig.has(o.id)) initP = sharedConfig.load(o.id);
582
- const init = initP?.v ?? initP;
583
- return init != null ? (subFetch(compute, prev), init) : compute(prev);
584
- }, effectFn, value, options);
567
+ coreFn(prev => readSerializedOrCompute(compute, prev), effectFn, value, options);
585
568
  }
586
569
  function hydratedCreateRenderEffect(compute, effectFn, value, options) {
587
570
  return hydratedEffect(createRenderEffect$1, compute, effectFn, value, options);
@@ -679,7 +662,7 @@ function resumeBoundaryHydration(o, id, set) {
679
662
  checkHydrationComplete();
680
663
  return;
681
664
  }
682
- sharedConfig.gather(id);
665
+ sharedConfig.gather?.(id);
683
666
  _hydratingValue = true;
684
667
  markSnapshotScope(o);
685
668
  _snapshotRootOwner = o;
@@ -691,11 +674,9 @@ function resumeBoundaryHydration(o, id, set) {
691
674
  flush();
692
675
  checkHydrationComplete();
693
676
  }
694
- function Loading(props) {
695
- const onOpt = props.on ? {
696
- on: () => props.on()
697
- } : undefined;
698
- if (!sharedConfig.hydrating) return createLoadingBoundary(() => props.children, () => props.fallback, onOpt);
677
+ function createLoadingBoundary(fn, fallback, options) {
678
+ if (!sharedConfig.hydrating) return createLoadingBoundary$1(fn, fallback, options);
679
+ let settledSerializationResumeQueued = false;
699
680
  return createMemo$1(() => {
700
681
  const o = getOwner();
701
682
  const id = o.id;
@@ -705,10 +686,26 @@ function Loading(props) {
705
686
  if (mapping && typeof mapping === "object") assetPromise = loadModuleAssets(mapping);
706
687
  }
707
688
  if (sharedConfig.hydrating && sharedConfig.has(id)) {
708
- let ref = sharedConfig.load(id);
689
+ const ref = sharedConfig.load(id);
709
690
  let p;
710
691
  if (ref) {
711
- if (typeof ref !== "object" || ref.s !== 1) p = ref;else sharedConfig.gather(id);
692
+ if (typeof ref !== "object" || ref.s == null) p = ref;else if (ref.s === 1 || ref.s === 2) sharedConfig.gather?.(id);else p = ref;
693
+ }
694
+ if (ref && typeof ref === "object" && ref.s === 1 && p == null && !settledSerializationResumeQueued) {
695
+ settledSerializationResumeQueued = true;
696
+ _pendingBoundaries++;
697
+ onCleanup(() => {
698
+ if (!isDisposed(o)) return;
699
+ sharedConfig.cleanupFragment?.(id);
700
+ });
701
+ const set = createBoundaryTrigger();
702
+ const scheduleResume = () => queueMicrotask(() => resumeBoundaryHydration(o, id, set));
703
+ if (assetPromise) {
704
+ assetPromise.then(scheduleResume);
705
+ return undefined;
706
+ }
707
+ scheduleResume();
708
+ return fallback();
712
709
  }
713
710
  if (p) {
714
711
  _pendingBoundaries++;
@@ -719,12 +716,17 @@ function Loading(props) {
719
716
  const set = createBoundaryTrigger();
720
717
  if (p !== "$$f") {
721
718
  const waitFor = assetPromise ? Promise.all([p, assetPromise]) : p;
722
- waitFor.then(() => resumeBoundaryHydration(o, id, set), err => {
723
- _pendingBoundaries--;
724
- checkHydrationComplete();
725
- runWithOwner(o, () => {
726
- throw err;
727
- });
719
+ waitFor.then(() => {
720
+ if (p && typeof p === "object") {
721
+ p.s = 1;
722
+ }
723
+ resumeBoundaryHydration(o, id, set);
724
+ }, err => {
725
+ if (p && typeof p === "object") {
726
+ p.s = 2;
727
+ p.v = err;
728
+ }
729
+ resumeBoundaryHydration(o, id, set);
728
730
  });
729
731
  } else {
730
732
  const afterAssets = () => {
@@ -734,17 +736,16 @@ function Loading(props) {
734
736
  };
735
737
  if (assetPromise) assetPromise.then(() => queueMicrotask(afterAssets));else queueMicrotask(afterAssets);
736
738
  }
737
- return props.fallback;
739
+ return fallback();
738
740
  }
739
741
  }
740
- if (assetPromise) {
742
+ if (assetPromise && !sharedConfig.has(id)) {
741
743
  _pendingBoundaries++;
742
744
  const set = createBoundaryTrigger();
743
745
  assetPromise.then(() => resumeBoundaryHydration(o, id, set));
744
746
  return undefined;
745
747
  }
746
- const boundary = createLoadingBoundary(() => props.children, () => props.fallback, onOpt);
747
- return boundary;
748
+ return createLoadingBoundary$1(fn, fallback, options);
748
749
  });
749
750
  }
750
751
  function NoHydration(props) {
@@ -884,6 +885,12 @@ function Errored(props) {
884
885
  return typeof f === "function" && f.length ? f(err, reset) : f;
885
886
  });
886
887
  }
888
+ function Loading(props) {
889
+ const onOpt = "on" in props ? {
890
+ on: () => props.on
891
+ } : undefined;
892
+ return createLoadingBoundary(() => props.children, () => props.fallback, onOpt);
893
+ }
887
894
 
888
895
  function ssrHandleError() {}
889
896
  function ssrRunInScope() {}
@@ -896,4 +903,4 @@ if (globalThis) {
896
903
  if (!globalThis.Solid$$) globalThis.Solid$$ = true;else console.warn("You appear to have multiple instances of Solid. This can lead to unexpected behavior.");
897
904
  }
898
905
 
899
- 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 };
906
+ 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 };