solid-js 2.0.0-beta.2 → 2.0.0-beta.4

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
@@ -208,6 +208,67 @@ function applyPatches(target, patches) {
208
208
  function isAsyncIterable(v) {
209
209
  return v != null && typeof v[Symbol.asyncIterator] === "function";
210
210
  }
211
+ function createShadowDraft(realDraft) {
212
+ const shadow = JSON.parse(JSON.stringify(realDraft));
213
+ let useShadow = true;
214
+ return {
215
+ proxy: new Proxy(shadow, {
216
+ get(_, prop) {
217
+ return useShadow ? shadow[prop] : realDraft[prop];
218
+ },
219
+ set(_, prop, value) {
220
+ if (useShadow) {
221
+ shadow[prop] = value;
222
+ return true;
223
+ }
224
+ return Reflect.set(realDraft, prop, value);
225
+ },
226
+ deleteProperty(_, prop) {
227
+ if (useShadow) {
228
+ delete shadow[prop];
229
+ return true;
230
+ }
231
+ return Reflect.deleteProperty(realDraft, prop);
232
+ },
233
+ has(_, prop) {
234
+ return prop in (useShadow ? shadow : realDraft);
235
+ },
236
+ ownKeys() {
237
+ return Reflect.ownKeys(useShadow ? shadow : realDraft);
238
+ },
239
+ getOwnPropertyDescriptor(_, prop) {
240
+ return Object.getOwnPropertyDescriptor(useShadow ? shadow : realDraft, prop);
241
+ }
242
+ }),
243
+ activate() {
244
+ useShadow = false;
245
+ }
246
+ };
247
+ }
248
+ function wrapFirstYield(iterable, activate) {
249
+ const srcIt = iterable[Symbol.asyncIterator]();
250
+ let first = true;
251
+ return {
252
+ [Symbol.asyncIterator]() {
253
+ return {
254
+ next() {
255
+ const p = srcIt.next();
256
+ if (first) {
257
+ first = false;
258
+ return p.then(r => {
259
+ activate();
260
+ return r.done ? r : {
261
+ done: false,
262
+ value: undefined
263
+ };
264
+ });
265
+ }
266
+ return p;
267
+ }
268
+ };
269
+ }
270
+ };
271
+ }
211
272
  function hydrateSignalFromAsyncIterable(coreFn, compute, value, options) {
212
273
  const parent = signals.getOwner();
213
274
  const expectedId = signals.peekNextChildId(parent);
@@ -259,7 +320,11 @@ function hydrateStoreFromAsyncIterable(coreFn, initialValue, options) {
259
320
  next() {
260
321
  if (isFirst) {
261
322
  const r = srcIt.next();
262
- return r && typeof r.then === "function" ? r.then(process) : syncThenable(process(r));
323
+ return r && typeof r.then === "function" ? {
324
+ then(fn, rej) {
325
+ r.then(v => fn(process(v)), rej);
326
+ }
327
+ } : syncThenable(process(r));
263
328
  }
264
329
  if (buffered) {
265
330
  const b = buffered;
@@ -288,13 +353,15 @@ function hydrateStoreFromAsyncIterable(coreFn, initialValue, options) {
288
353
  }, initialValue, options);
289
354
  }
290
355
  function hydratedCreateMemo(compute, value, options) {
291
- if (!sharedConfig.hydrating) {
356
+ if (!sharedConfig.hydrating || options?.transparent) {
292
357
  return signals.createMemo(compute, value, options);
293
358
  }
294
359
  markTopLevelSnapshotScope();
295
360
  const ssrSource = options?.ssrSource;
296
361
  if (ssrSource === "client") {
297
- const [hydrated, setHydrated] = signals.createSignal(false);
362
+ const [hydrated, setHydrated] = signals.createSignal(false, {
363
+ pureWrite: true
364
+ });
298
365
  const memo = signals.createMemo(prev => {
299
366
  if (!hydrated()) return prev ?? value;
300
367
  return compute(prev);
@@ -325,7 +392,9 @@ function hydratedCreateSignal(fn, second, third) {
325
392
  markTopLevelSnapshotScope();
326
393
  const ssrSource = third?.ssrSource;
327
394
  if (ssrSource === "client") {
328
- const [hydrated, setHydrated] = signals.createSignal(false);
395
+ const [hydrated, setHydrated] = signals.createSignal(false, {
396
+ pureWrite: true
397
+ });
329
398
  const sig = signals.createSignal(prev => {
330
399
  if (!hydrated()) return prev ?? second;
331
400
  return fn(prev);
@@ -376,7 +445,9 @@ function hydratedCreateOptimistic(fn, second, third) {
376
445
  markTopLevelSnapshotScope();
377
446
  const ssrSource = third?.ssrSource;
378
447
  if (ssrSource === "client") {
379
- const [hydrated, setHydrated] = signals.createSignal(false);
448
+ const [hydrated, setHydrated] = signals.createSignal(false, {
449
+ pureWrite: true
450
+ });
380
451
  const sig = signals.createOptimistic(prev => {
381
452
  if (!hydrated()) return prev ?? second;
382
453
  return fn(prev);
@@ -402,14 +473,7 @@ function hydratedCreateOptimistic(fn, second, third) {
402
473
  return init != null ? (subFetch(fn, prev), init) : fn(prev);
403
474
  }, second, third);
404
475
  }
405
- function wrapStoreFn(fn, ssrSource) {
406
- if (ssrSource === "initial") {
407
- return draft => {
408
- if (!sharedConfig.hydrating) return fn(draft);
409
- subFetch(fn, draft);
410
- return undefined;
411
- };
412
- }
476
+ function wrapStoreFn(fn) {
413
477
  return draft => {
414
478
  const o = signals.getOwner();
415
479
  if (!sharedConfig.hydrating) return fn(draft);
@@ -419,46 +483,77 @@ function wrapStoreFn(fn, ssrSource) {
419
483
  return init != null ? (subFetch(fn, draft), init) : fn(draft);
420
484
  };
421
485
  }
486
+ function hydrateStoreLikeFn(coreFn, fn, initialValue, options, ssrSource) {
487
+ if (ssrSource === "client") {
488
+ const [hydrated, setHydrated] = signals.createSignal(false, {
489
+ pureWrite: true
490
+ });
491
+ const result = coreFn(draft => {
492
+ if (!hydrated()) return;
493
+ return fn(draft);
494
+ }, initialValue, options);
495
+ setHydrated(true);
496
+ return result;
497
+ }
498
+ if (ssrSource === "hybrid") {
499
+ const [hydrated, setHydrated] = signals.createSignal(false, {
500
+ pureWrite: true
501
+ });
502
+ const result = coreFn(draft => {
503
+ const o = signals.getOwner();
504
+ if (!hydrated()) {
505
+ if (sharedConfig.has(o.id)) {
506
+ const initP = sharedConfig.load(o.id);
507
+ const init = initP?.v ?? initP;
508
+ if (init != null) {
509
+ subFetch(fn, draft);
510
+ return init;
511
+ }
512
+ }
513
+ return fn(draft);
514
+ }
515
+ const {
516
+ proxy,
517
+ activate
518
+ } = createShadowDraft(draft);
519
+ const r = fn(proxy);
520
+ return isAsyncIterable(r) ? wrapFirstYield(r, activate) : r;
521
+ }, initialValue, options);
522
+ setHydrated(true);
523
+ return result;
524
+ }
525
+ const aiResult = hydrateStoreFromAsyncIterable(coreFn, initialValue, options);
526
+ if (aiResult !== null) return aiResult;
527
+ return coreFn(wrapStoreFn(fn), initialValue, options);
528
+ }
422
529
  function hydratedCreateStore(first, second, third) {
423
530
  if (typeof first !== "function" || !sharedConfig.hydrating) return signals.createStore(first, second, third);
424
531
  markTopLevelSnapshotScope();
425
532
  const ssrSource = third?.ssrSource;
426
- if (ssrSource === "client" || ssrSource === "initial") {
427
- return signals.createStore(second ?? {}, undefined, third);
428
- }
429
- const aiResult = hydrateStoreFromAsyncIterable(signals.createStore, second ?? {}, third);
430
- if (aiResult !== null) return aiResult;
431
- return signals.createStore(wrapStoreFn(first, ssrSource), second, third);
533
+ if (ssrSource === "initial") return signals.createStore(second ?? {}, undefined, third);
534
+ return hydrateStoreLikeFn(signals.createStore, first, second ?? {}, third, ssrSource);
432
535
  }
433
536
  function hydratedCreateOptimisticStore(first, second, third) {
434
537
  if (typeof first !== "function" || !sharedConfig.hydrating) return signals.createOptimisticStore(first, second, third);
435
538
  markTopLevelSnapshotScope();
436
539
  const ssrSource = third?.ssrSource;
437
- if (ssrSource === "client" || ssrSource === "initial") {
438
- return signals.createOptimisticStore(second ?? {}, undefined, third);
439
- }
440
- const aiResult = hydrateStoreFromAsyncIterable(signals.createOptimisticStore, second ?? {}, third);
441
- if (aiResult !== null) return aiResult;
442
- return signals.createOptimisticStore(wrapStoreFn(first, ssrSource), second, third);
540
+ if (ssrSource === "initial") return signals.createOptimisticStore(second ?? {}, undefined, third);
541
+ return hydrateStoreLikeFn(signals.createOptimisticStore, first, second ?? {}, third, ssrSource);
443
542
  }
444
543
  function hydratedCreateProjection(fn, initialValue, options) {
445
- if (!sharedConfig.hydrating) {
446
- return signals.createProjection(fn, initialValue, options);
447
- }
544
+ if (!sharedConfig.hydrating) return signals.createProjection(fn, initialValue, options);
448
545
  markTopLevelSnapshotScope();
449
546
  const ssrSource = options?.ssrSource;
450
- if (ssrSource === "client" || ssrSource === "initial") {
451
- return signals.createProjection(draft => draft, initialValue, options);
452
- }
453
- const aiResult = hydrateStoreFromAsyncIterable(signals.createProjection, initialValue, options);
454
- if (aiResult !== null) return aiResult;
455
- return signals.createProjection(wrapStoreFn(fn, ssrSource), initialValue, options);
547
+ if (ssrSource === "initial") return signals.createProjection(draft => draft, initialValue, options);
548
+ return hydrateStoreLikeFn(signals.createProjection, fn, initialValue, options, ssrSource);
456
549
  }
457
550
  function hydratedEffect(coreFn, compute, effectFn, value, options) {
458
551
  if (!sharedConfig.hydrating) return coreFn(compute, effectFn, value, options);
459
552
  const ssrSource = options?.ssrSource;
460
553
  if (ssrSource === "client") {
461
- const [hydrated, setHydrated] = signals.createSignal(false);
554
+ const [hydrated, setHydrated] = signals.createSignal(false, {
555
+ pureWrite: true
556
+ });
462
557
  let active = false;
463
558
  coreFn(prev => {
464
559
  if (!hydrated()) return value;
@@ -598,7 +693,10 @@ function resumeBoundaryHydration(o, id, set) {
598
693
  checkHydrationComplete();
599
694
  }
600
695
  function Loading(props) {
601
- if (!sharedConfig.hydrating) return signals.createLoadBoundary(() => props.children, () => props.fallback);
696
+ const onOpt = props.on ? {
697
+ on: () => props.on()
698
+ } : undefined;
699
+ if (!sharedConfig.hydrating) return signals.createLoadingBoundary(() => props.children, () => props.fallback, onOpt);
602
700
  return signals.createMemo(() => {
603
701
  const o = signals.getOwner();
604
702
  const id = o.id;
@@ -646,7 +744,8 @@ function Loading(props) {
646
744
  assetPromise.then(() => resumeBoundaryHydration(o, id, set));
647
745
  return undefined;
648
746
  }
649
- return signals.createLoadBoundary(() => props.children, () => props.fallback);
747
+ const boundary = signals.createLoadingBoundary(() => props.children, () => props.fallback, onOpt);
748
+ return boundary;
650
749
  });
651
750
  }
652
751
  function NoHydration(props) {
@@ -818,6 +917,14 @@ Object.defineProperty(exports, "action", {
818
917
  enumerable: true,
819
918
  get: function () { return signals.action; }
820
919
  });
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
+ });
821
928
  Object.defineProperty(exports, "createOwner", {
822
929
  enumerable: true,
823
930
  get: function () { return signals.createOwner; }
@@ -838,6 +945,14 @@ Object.defineProperty(exports, "deep", {
838
945
  enumerable: true,
839
946
  get: function () { return signals.deep; }
840
947
  });
948
+ Object.defineProperty(exports, "enableExternalSource", {
949
+ enumerable: true,
950
+ get: function () { return signals.enableExternalSource; }
951
+ });
952
+ Object.defineProperty(exports, "enforceLoadingBoundary", {
953
+ enumerable: true,
954
+ get: function () { return signals.enforceLoadingBoundary; }
955
+ });
841
956
  Object.defineProperty(exports, "flatten", {
842
957
  enumerable: true,
843
958
  get: function () { return signals.flatten; }
@@ -918,10 +1033,6 @@ Object.defineProperty(exports, "runWithOwner", {
918
1033
  enumerable: true,
919
1034
  get: function () { return signals.runWithOwner; }
920
1035
  });
921
- Object.defineProperty(exports, "setOnUnhandledAsync", {
922
- enumerable: true,
923
- get: function () { return signals.setOnUnhandledAsync; }
924
- });
925
1036
  Object.defineProperty(exports, "snapshot", {
926
1037
  enumerable: true,
927
1038
  get: function () { return signals.snapshot; }
package/dist/dev.js CHANGED
@@ -1,5 +1,5 @@
1
- import { getContext, createMemo as createMemo$1, flatten, getOwner, createRoot, setContext, untrack, createLoadBoundary, 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, createOwner, createReaction, createRoot, createTrackedEffect, deep, flatten, flush, getNextChildId, getObserver, getOwner, isEqual, isPending, isRefreshing, isWrappable, latest, mapArray, merge, omit, onCleanup, onSettled, reconcile, refresh, repeat, resolve, runWithOwner, setOnUnhandledAsync, snapshot, storePath, untrack } from '@solidjs/signals';
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';
3
3
 
4
4
  const $DEVCOMP = Symbol("COMPONENT_DEV" );
5
5
  function createContext(defaultValue, options) {
@@ -207,6 +207,67 @@ function applyPatches(target, patches) {
207
207
  function isAsyncIterable(v) {
208
208
  return v != null && typeof v[Symbol.asyncIterator] === "function";
209
209
  }
210
+ function createShadowDraft(realDraft) {
211
+ const shadow = JSON.parse(JSON.stringify(realDraft));
212
+ let useShadow = true;
213
+ return {
214
+ proxy: new Proxy(shadow, {
215
+ get(_, prop) {
216
+ return useShadow ? shadow[prop] : realDraft[prop];
217
+ },
218
+ set(_, prop, value) {
219
+ if (useShadow) {
220
+ shadow[prop] = value;
221
+ return true;
222
+ }
223
+ return Reflect.set(realDraft, prop, value);
224
+ },
225
+ deleteProperty(_, prop) {
226
+ if (useShadow) {
227
+ delete shadow[prop];
228
+ return true;
229
+ }
230
+ return Reflect.deleteProperty(realDraft, prop);
231
+ },
232
+ has(_, prop) {
233
+ return prop in (useShadow ? shadow : realDraft);
234
+ },
235
+ ownKeys() {
236
+ return Reflect.ownKeys(useShadow ? shadow : realDraft);
237
+ },
238
+ getOwnPropertyDescriptor(_, prop) {
239
+ return Object.getOwnPropertyDescriptor(useShadow ? shadow : realDraft, prop);
240
+ }
241
+ }),
242
+ activate() {
243
+ useShadow = false;
244
+ }
245
+ };
246
+ }
247
+ function wrapFirstYield(iterable, activate) {
248
+ const srcIt = iterable[Symbol.asyncIterator]();
249
+ let first = true;
250
+ return {
251
+ [Symbol.asyncIterator]() {
252
+ return {
253
+ next() {
254
+ const p = srcIt.next();
255
+ if (first) {
256
+ first = false;
257
+ return p.then(r => {
258
+ activate();
259
+ return r.done ? r : {
260
+ done: false,
261
+ value: undefined
262
+ };
263
+ });
264
+ }
265
+ return p;
266
+ }
267
+ };
268
+ }
269
+ };
270
+ }
210
271
  function hydrateSignalFromAsyncIterable(coreFn, compute, value, options) {
211
272
  const parent = getOwner();
212
273
  const expectedId = peekNextChildId(parent);
@@ -258,7 +319,11 @@ function hydrateStoreFromAsyncIterable(coreFn, initialValue, options) {
258
319
  next() {
259
320
  if (isFirst) {
260
321
  const r = srcIt.next();
261
- return r && typeof r.then === "function" ? r.then(process) : syncThenable(process(r));
322
+ return r && typeof r.then === "function" ? {
323
+ then(fn, rej) {
324
+ r.then(v => fn(process(v)), rej);
325
+ }
326
+ } : syncThenable(process(r));
262
327
  }
263
328
  if (buffered) {
264
329
  const b = buffered;
@@ -287,13 +352,15 @@ function hydrateStoreFromAsyncIterable(coreFn, initialValue, options) {
287
352
  }, initialValue, options);
288
353
  }
289
354
  function hydratedCreateMemo(compute, value, options) {
290
- if (!sharedConfig.hydrating) {
355
+ if (!sharedConfig.hydrating || options?.transparent) {
291
356
  return createMemo$1(compute, value, options);
292
357
  }
293
358
  markTopLevelSnapshotScope();
294
359
  const ssrSource = options?.ssrSource;
295
360
  if (ssrSource === "client") {
296
- const [hydrated, setHydrated] = createSignal$1(false);
361
+ const [hydrated, setHydrated] = createSignal$1(false, {
362
+ pureWrite: true
363
+ });
297
364
  const memo = createMemo$1(prev => {
298
365
  if (!hydrated()) return prev ?? value;
299
366
  return compute(prev);
@@ -324,7 +391,9 @@ function hydratedCreateSignal(fn, second, third) {
324
391
  markTopLevelSnapshotScope();
325
392
  const ssrSource = third?.ssrSource;
326
393
  if (ssrSource === "client") {
327
- const [hydrated, setHydrated] = createSignal$1(false);
394
+ const [hydrated, setHydrated] = createSignal$1(false, {
395
+ pureWrite: true
396
+ });
328
397
  const sig = createSignal$1(prev => {
329
398
  if (!hydrated()) return prev ?? second;
330
399
  return fn(prev);
@@ -375,7 +444,9 @@ function hydratedCreateOptimistic(fn, second, third) {
375
444
  markTopLevelSnapshotScope();
376
445
  const ssrSource = third?.ssrSource;
377
446
  if (ssrSource === "client") {
378
- const [hydrated, setHydrated] = createSignal$1(false);
447
+ const [hydrated, setHydrated] = createSignal$1(false, {
448
+ pureWrite: true
449
+ });
379
450
  const sig = createOptimistic$1(prev => {
380
451
  if (!hydrated()) return prev ?? second;
381
452
  return fn(prev);
@@ -401,14 +472,7 @@ function hydratedCreateOptimistic(fn, second, third) {
401
472
  return init != null ? (subFetch(fn, prev), init) : fn(prev);
402
473
  }, second, third);
403
474
  }
404
- function wrapStoreFn(fn, ssrSource) {
405
- if (ssrSource === "initial") {
406
- return draft => {
407
- if (!sharedConfig.hydrating) return fn(draft);
408
- subFetch(fn, draft);
409
- return undefined;
410
- };
411
- }
475
+ function wrapStoreFn(fn) {
412
476
  return draft => {
413
477
  const o = getOwner();
414
478
  if (!sharedConfig.hydrating) return fn(draft);
@@ -418,46 +482,77 @@ function wrapStoreFn(fn, ssrSource) {
418
482
  return init != null ? (subFetch(fn, draft), init) : fn(draft);
419
483
  };
420
484
  }
485
+ function hydrateStoreLikeFn(coreFn, fn, initialValue, options, ssrSource) {
486
+ if (ssrSource === "client") {
487
+ const [hydrated, setHydrated] = createSignal$1(false, {
488
+ pureWrite: true
489
+ });
490
+ const result = coreFn(draft => {
491
+ if (!hydrated()) return;
492
+ return fn(draft);
493
+ }, initialValue, options);
494
+ setHydrated(true);
495
+ return result;
496
+ }
497
+ if (ssrSource === "hybrid") {
498
+ const [hydrated, setHydrated] = createSignal$1(false, {
499
+ pureWrite: true
500
+ });
501
+ const result = coreFn(draft => {
502
+ const o = getOwner();
503
+ if (!hydrated()) {
504
+ if (sharedConfig.has(o.id)) {
505
+ const initP = sharedConfig.load(o.id);
506
+ const init = initP?.v ?? initP;
507
+ if (init != null) {
508
+ subFetch(fn, draft);
509
+ return init;
510
+ }
511
+ }
512
+ return fn(draft);
513
+ }
514
+ const {
515
+ proxy,
516
+ activate
517
+ } = createShadowDraft(draft);
518
+ const r = fn(proxy);
519
+ return isAsyncIterable(r) ? wrapFirstYield(r, activate) : r;
520
+ }, initialValue, options);
521
+ setHydrated(true);
522
+ return result;
523
+ }
524
+ const aiResult = hydrateStoreFromAsyncIterable(coreFn, initialValue, options);
525
+ if (aiResult !== null) return aiResult;
526
+ return coreFn(wrapStoreFn(fn), initialValue, options);
527
+ }
421
528
  function hydratedCreateStore(first, second, third) {
422
529
  if (typeof first !== "function" || !sharedConfig.hydrating) return createStore$1(first, second, third);
423
530
  markTopLevelSnapshotScope();
424
531
  const ssrSource = third?.ssrSource;
425
- if (ssrSource === "client" || ssrSource === "initial") {
426
- return createStore$1(second ?? {}, undefined, third);
427
- }
428
- const aiResult = hydrateStoreFromAsyncIterable(createStore$1, second ?? {}, third);
429
- if (aiResult !== null) return aiResult;
430
- return createStore$1(wrapStoreFn(first, ssrSource), second, third);
532
+ if (ssrSource === "initial") return createStore$1(second ?? {}, undefined, third);
533
+ return hydrateStoreLikeFn(createStore$1, first, second ?? {}, third, ssrSource);
431
534
  }
432
535
  function hydratedCreateOptimisticStore(first, second, third) {
433
536
  if (typeof first !== "function" || !sharedConfig.hydrating) return createOptimisticStore$1(first, second, third);
434
537
  markTopLevelSnapshotScope();
435
538
  const ssrSource = third?.ssrSource;
436
- if (ssrSource === "client" || ssrSource === "initial") {
437
- return createOptimisticStore$1(second ?? {}, undefined, third);
438
- }
439
- const aiResult = hydrateStoreFromAsyncIterable(createOptimisticStore$1, second ?? {}, third);
440
- if (aiResult !== null) return aiResult;
441
- return createOptimisticStore$1(wrapStoreFn(first, ssrSource), second, third);
539
+ if (ssrSource === "initial") return createOptimisticStore$1(second ?? {}, undefined, third);
540
+ return hydrateStoreLikeFn(createOptimisticStore$1, first, second ?? {}, third, ssrSource);
442
541
  }
443
542
  function hydratedCreateProjection(fn, initialValue, options) {
444
- if (!sharedConfig.hydrating) {
445
- return createProjection$1(fn, initialValue, options);
446
- }
543
+ if (!sharedConfig.hydrating) return createProjection$1(fn, initialValue, options);
447
544
  markTopLevelSnapshotScope();
448
545
  const ssrSource = options?.ssrSource;
449
- if (ssrSource === "client" || ssrSource === "initial") {
450
- return createProjection$1(draft => draft, initialValue, options);
451
- }
452
- const aiResult = hydrateStoreFromAsyncIterable(createProjection$1, initialValue, options);
453
- if (aiResult !== null) return aiResult;
454
- return createProjection$1(wrapStoreFn(fn, ssrSource), initialValue, options);
546
+ if (ssrSource === "initial") return createProjection$1(draft => draft, initialValue, options);
547
+ return hydrateStoreLikeFn(createProjection$1, fn, initialValue, options, ssrSource);
455
548
  }
456
549
  function hydratedEffect(coreFn, compute, effectFn, value, options) {
457
550
  if (!sharedConfig.hydrating) return coreFn(compute, effectFn, value, options);
458
551
  const ssrSource = options?.ssrSource;
459
552
  if (ssrSource === "client") {
460
- const [hydrated, setHydrated] = createSignal$1(false);
553
+ const [hydrated, setHydrated] = createSignal$1(false, {
554
+ pureWrite: true
555
+ });
461
556
  let active = false;
462
557
  coreFn(prev => {
463
558
  if (!hydrated()) return value;
@@ -597,7 +692,10 @@ function resumeBoundaryHydration(o, id, set) {
597
692
  checkHydrationComplete();
598
693
  }
599
694
  function Loading(props) {
600
- if (!sharedConfig.hydrating) return createLoadBoundary(() => props.children, () => props.fallback);
695
+ const onOpt = props.on ? {
696
+ on: () => props.on()
697
+ } : undefined;
698
+ if (!sharedConfig.hydrating) return createLoadingBoundary(() => props.children, () => props.fallback, onOpt);
601
699
  return createMemo$1(() => {
602
700
  const o = getOwner();
603
701
  const id = o.id;
@@ -645,7 +743,8 @@ function Loading(props) {
645
743
  assetPromise.then(() => resumeBoundaryHydration(o, id, set));
646
744
  return undefined;
647
745
  }
648
- return createLoadBoundary(() => props.children, () => props.fallback);
746
+ const boundary = createLoadingBoundary(() => props.children, () => props.fallback, onOpt);
747
+ return boundary;
649
748
  });
650
749
  }
651
750
  function NoHydration(props) {
package/dist/server.cjs CHANGED
@@ -493,7 +493,7 @@ function createErrorBoundary(fn, fallback) {
493
493
  return () => result;
494
494
  });
495
495
  }
496
- function createLoadBoundary(fn, fallback) {
496
+ function createLoadingBoundary(fn, fallback, options) {
497
497
  try {
498
498
  const result = fn();
499
499
  return () => result;
@@ -701,7 +701,7 @@ function ssrHandleError(err) {
701
701
  function Loading(props) {
702
702
  const ctx = sharedConfig.context;
703
703
  if (!ctx) {
704
- return createLoadBoundary(() => props.children, () => props.fallback);
704
+ return createLoadingBoundary(() => props.children, () => props.fallback);
705
705
  }
706
706
  const o = signals.createOwner();
707
707
  const id = o.id;
@@ -814,6 +814,14 @@ Object.defineProperty(exports, "createRoot", {
814
814
  enumerable: true,
815
815
  get: function () { return signals.createRoot; }
816
816
  });
817
+ Object.defineProperty(exports, "enableExternalSource", {
818
+ enumerable: true,
819
+ get: function () { return signals.enableExternalSource; }
820
+ });
821
+ Object.defineProperty(exports, "enforceLoadingBoundary", {
822
+ enumerable: true,
823
+ get: function () { return signals.enforceLoadingBoundary; }
824
+ });
817
825
  Object.defineProperty(exports, "flatten", {
818
826
  enumerable: true,
819
827
  get: function () { return signals.flatten; }
@@ -850,10 +858,6 @@ Object.defineProperty(exports, "runWithOwner", {
850
858
  enumerable: true,
851
859
  get: function () { return signals.runWithOwner; }
852
860
  });
853
- Object.defineProperty(exports, "setOnUnhandledAsync", {
854
- enumerable: true,
855
- get: function () { return signals.setOnUnhandledAsync; }
856
- });
857
861
  Object.defineProperty(exports, "snapshot", {
858
862
  enumerable: true,
859
863
  get: function () { return signals.snapshot; }
@@ -880,6 +884,8 @@ exports.createComponent = createComponent;
880
884
  exports.createContext = createContext;
881
885
  exports.createDeepProxy = createDeepProxy;
882
886
  exports.createEffect = createEffect;
887
+ exports.createErrorBoundary = createErrorBoundary;
888
+ exports.createLoadingBoundary = createLoadingBoundary;
883
889
  exports.createMemo = createMemo;
884
890
  exports.createOptimistic = createOptimistic;
885
891
  exports.createOptimisticStore = createOptimisticStore;
package/dist/server.js CHANGED
@@ -1,5 +1,5 @@
1
- import { getOwner, getContext, getNextChildId, createOwner, runWithOwner, onCleanup, NotReadyError, isWrappable, setContext, flatten, createRoot } from '@solidjs/signals';
2
- export { $PROXY, $REFRESH, $TRACK, NotReadyError, createOwner, createRoot, flatten, getNextChildId, getOwner, isEqual, isWrappable, merge, omit, onCleanup, runWithOwner, setOnUnhandledAsync, snapshot, storePath } from '@solidjs/signals';
1
+ import { getOwner, getContext, getNextChildId, createOwner, runWithOwner, setContext, NotReadyError, onCleanup, isWrappable, flatten, createRoot } from '@solidjs/signals';
2
+ export { $PROXY, $REFRESH, $TRACK, NotReadyError, createOwner, createRoot, enableExternalSource, enforceLoadingBoundary, flatten, getNextChildId, getOwner, isEqual, isWrappable, merge, omit, onCleanup, runWithOwner, snapshot, storePath } from '@solidjs/signals';
3
3
 
4
4
  const NoHydrateContext = {
5
5
  id: Symbol("NoHydrateContext"),
@@ -492,7 +492,7 @@ function createErrorBoundary(fn, fallback) {
492
492
  return () => result;
493
493
  });
494
494
  }
495
- function createLoadBoundary(fn, fallback) {
495
+ function createLoadingBoundary(fn, fallback, options) {
496
496
  try {
497
497
  const result = fn();
498
498
  return () => result;
@@ -700,7 +700,7 @@ function ssrHandleError(err) {
700
700
  function Loading(props) {
701
701
  const ctx = sharedConfig.context;
702
702
  if (!ctx) {
703
- return createLoadBoundary(() => props.children, () => props.fallback);
703
+ return createLoadingBoundary(() => props.children, () => props.fallback);
704
704
  }
705
705
  const o = createOwner();
706
706
  const id = o.id;
@@ -789,4 +789,4 @@ function Hydration(props) {
789
789
 
790
790
  const DEV = undefined;
791
791
 
792
- export { $DEVCOMP, DEV, Errored, For, Hydration, Loading, Match, NoHydrateContext, NoHydration, Repeat, Show, Switch, action, children, createComponent, createContext, createDeepProxy, createEffect, createMemo, createOptimistic, createOptimisticStore, createProjection, createReaction, createRenderEffect, createSignal, createStore, createTrackedEffect, createUniqueId, deep, enableHydration, flush, getObserver, isPending, isRefreshing, latest, lazy, mapArray, onSettled, reconcile, refresh, repeat, resolve, sharedConfig, ssrHandleError, ssrRunInScope, untrack, useContext };
792
+ export { $DEVCOMP, DEV, Errored, For, Hydration, Loading, Match, NoHydrateContext, NoHydration, Repeat, Show, Switch, action, children, createComponent, createContext, createDeepProxy, createEffect, createErrorBoundary, createLoadingBoundary, createMemo, createOptimistic, createOptimisticStore, createProjection, createReaction, createRenderEffect, createSignal, createStore, createTrackedEffect, createUniqueId, deep, enableHydration, flush, getObserver, isPending, isRefreshing, latest, lazy, mapArray, onSettled, reconcile, refresh, repeat, resolve, sharedConfig, ssrHandleError, ssrRunInScope, untrack, useContext };