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/solid.cjs CHANGED
@@ -187,6 +187,67 @@ function applyPatches(target, patches) {
187
187
  function isAsyncIterable(v) {
188
188
  return v != null && typeof v[Symbol.asyncIterator] === "function";
189
189
  }
190
+ function createShadowDraft(realDraft) {
191
+ const shadow = JSON.parse(JSON.stringify(realDraft));
192
+ let useShadow = true;
193
+ return {
194
+ proxy: new Proxy(shadow, {
195
+ get(_, prop) {
196
+ return useShadow ? shadow[prop] : realDraft[prop];
197
+ },
198
+ set(_, prop, value) {
199
+ if (useShadow) {
200
+ shadow[prop] = value;
201
+ return true;
202
+ }
203
+ return Reflect.set(realDraft, prop, value);
204
+ },
205
+ deleteProperty(_, prop) {
206
+ if (useShadow) {
207
+ delete shadow[prop];
208
+ return true;
209
+ }
210
+ return Reflect.deleteProperty(realDraft, prop);
211
+ },
212
+ has(_, prop) {
213
+ return prop in (useShadow ? shadow : realDraft);
214
+ },
215
+ ownKeys() {
216
+ return Reflect.ownKeys(useShadow ? shadow : realDraft);
217
+ },
218
+ getOwnPropertyDescriptor(_, prop) {
219
+ return Object.getOwnPropertyDescriptor(useShadow ? shadow : realDraft, prop);
220
+ }
221
+ }),
222
+ activate() {
223
+ useShadow = false;
224
+ }
225
+ };
226
+ }
227
+ function wrapFirstYield(iterable, activate) {
228
+ const srcIt = iterable[Symbol.asyncIterator]();
229
+ let first = true;
230
+ return {
231
+ [Symbol.asyncIterator]() {
232
+ return {
233
+ next() {
234
+ const p = srcIt.next();
235
+ if (first) {
236
+ first = false;
237
+ return p.then(r => {
238
+ activate();
239
+ return r.done ? r : {
240
+ done: false,
241
+ value: undefined
242
+ };
243
+ });
244
+ }
245
+ return p;
246
+ }
247
+ };
248
+ }
249
+ };
250
+ }
190
251
  function hydrateSignalFromAsyncIterable(coreFn, compute, value, options) {
191
252
  const parent = signals.getOwner();
192
253
  const expectedId = signals.peekNextChildId(parent);
@@ -238,7 +299,11 @@ function hydrateStoreFromAsyncIterable(coreFn, initialValue, options) {
238
299
  next() {
239
300
  if (isFirst) {
240
301
  const r = srcIt.next();
241
- return r && typeof r.then === "function" ? r.then(process) : syncThenable(process(r));
302
+ return r && typeof r.then === "function" ? {
303
+ then(fn, rej) {
304
+ r.then(v => fn(process(v)), rej);
305
+ }
306
+ } : syncThenable(process(r));
242
307
  }
243
308
  if (buffered) {
244
309
  const b = buffered;
@@ -267,13 +332,15 @@ function hydrateStoreFromAsyncIterable(coreFn, initialValue, options) {
267
332
  }, initialValue, options);
268
333
  }
269
334
  function hydratedCreateMemo(compute, value, options) {
270
- if (!sharedConfig.hydrating) {
335
+ if (!sharedConfig.hydrating || options?.transparent) {
271
336
  return signals.createMemo(compute, value, options);
272
337
  }
273
338
  markTopLevelSnapshotScope();
274
339
  const ssrSource = options?.ssrSource;
275
340
  if (ssrSource === "client") {
276
- const [hydrated, setHydrated] = signals.createSignal(false);
341
+ const [hydrated, setHydrated] = signals.createSignal(false, {
342
+ pureWrite: true
343
+ });
277
344
  const memo = signals.createMemo(prev => {
278
345
  if (!hydrated()) return prev ?? value;
279
346
  return compute(prev);
@@ -304,7 +371,9 @@ function hydratedCreateSignal(fn, second, third) {
304
371
  markTopLevelSnapshotScope();
305
372
  const ssrSource = third?.ssrSource;
306
373
  if (ssrSource === "client") {
307
- const [hydrated, setHydrated] = signals.createSignal(false);
374
+ const [hydrated, setHydrated] = signals.createSignal(false, {
375
+ pureWrite: true
376
+ });
308
377
  const sig = signals.createSignal(prev => {
309
378
  if (!hydrated()) return prev ?? second;
310
379
  return fn(prev);
@@ -355,7 +424,9 @@ function hydratedCreateOptimistic(fn, second, third) {
355
424
  markTopLevelSnapshotScope();
356
425
  const ssrSource = third?.ssrSource;
357
426
  if (ssrSource === "client") {
358
- const [hydrated, setHydrated] = signals.createSignal(false);
427
+ const [hydrated, setHydrated] = signals.createSignal(false, {
428
+ pureWrite: true
429
+ });
359
430
  const sig = signals.createOptimistic(prev => {
360
431
  if (!hydrated()) return prev ?? second;
361
432
  return fn(prev);
@@ -381,14 +452,7 @@ function hydratedCreateOptimistic(fn, second, third) {
381
452
  return init != null ? (subFetch(fn, prev), init) : fn(prev);
382
453
  }, second, third);
383
454
  }
384
- function wrapStoreFn(fn, ssrSource) {
385
- if (ssrSource === "initial") {
386
- return draft => {
387
- if (!sharedConfig.hydrating) return fn(draft);
388
- subFetch(fn, draft);
389
- return undefined;
390
- };
391
- }
455
+ function wrapStoreFn(fn) {
392
456
  return draft => {
393
457
  const o = signals.getOwner();
394
458
  if (!sharedConfig.hydrating) return fn(draft);
@@ -398,46 +462,77 @@ function wrapStoreFn(fn, ssrSource) {
398
462
  return init != null ? (subFetch(fn, draft), init) : fn(draft);
399
463
  };
400
464
  }
465
+ function hydrateStoreLikeFn(coreFn, fn, initialValue, options, ssrSource) {
466
+ if (ssrSource === "client") {
467
+ const [hydrated, setHydrated] = signals.createSignal(false, {
468
+ pureWrite: true
469
+ });
470
+ const result = coreFn(draft => {
471
+ if (!hydrated()) return;
472
+ return fn(draft);
473
+ }, initialValue, options);
474
+ setHydrated(true);
475
+ return result;
476
+ }
477
+ if (ssrSource === "hybrid") {
478
+ const [hydrated, setHydrated] = signals.createSignal(false, {
479
+ pureWrite: true
480
+ });
481
+ const result = coreFn(draft => {
482
+ const o = signals.getOwner();
483
+ if (!hydrated()) {
484
+ if (sharedConfig.has(o.id)) {
485
+ const initP = sharedConfig.load(o.id);
486
+ const init = initP?.v ?? initP;
487
+ if (init != null) {
488
+ subFetch(fn, draft);
489
+ return init;
490
+ }
491
+ }
492
+ return fn(draft);
493
+ }
494
+ const {
495
+ proxy,
496
+ activate
497
+ } = createShadowDraft(draft);
498
+ const r = fn(proxy);
499
+ return isAsyncIterable(r) ? wrapFirstYield(r, activate) : r;
500
+ }, initialValue, options);
501
+ setHydrated(true);
502
+ return result;
503
+ }
504
+ const aiResult = hydrateStoreFromAsyncIterable(coreFn, initialValue, options);
505
+ if (aiResult !== null) return aiResult;
506
+ return coreFn(wrapStoreFn(fn), initialValue, options);
507
+ }
401
508
  function hydratedCreateStore(first, second, third) {
402
509
  if (typeof first !== "function" || !sharedConfig.hydrating) return signals.createStore(first, second, third);
403
510
  markTopLevelSnapshotScope();
404
511
  const ssrSource = third?.ssrSource;
405
- if (ssrSource === "client" || ssrSource === "initial") {
406
- return signals.createStore(second ?? {}, undefined, third);
407
- }
408
- const aiResult = hydrateStoreFromAsyncIterable(signals.createStore, second ?? {}, third);
409
- if (aiResult !== null) return aiResult;
410
- return signals.createStore(wrapStoreFn(first, ssrSource), second, third);
512
+ if (ssrSource === "initial") return signals.createStore(second ?? {}, undefined, third);
513
+ return hydrateStoreLikeFn(signals.createStore, first, second ?? {}, third, ssrSource);
411
514
  }
412
515
  function hydratedCreateOptimisticStore(first, second, third) {
413
516
  if (typeof first !== "function" || !sharedConfig.hydrating) return signals.createOptimisticStore(first, second, third);
414
517
  markTopLevelSnapshotScope();
415
518
  const ssrSource = third?.ssrSource;
416
- if (ssrSource === "client" || ssrSource === "initial") {
417
- return signals.createOptimisticStore(second ?? {}, undefined, third);
418
- }
419
- const aiResult = hydrateStoreFromAsyncIterable(signals.createOptimisticStore, second ?? {}, third);
420
- if (aiResult !== null) return aiResult;
421
- return signals.createOptimisticStore(wrapStoreFn(first, ssrSource), second, third);
519
+ if (ssrSource === "initial") return signals.createOptimisticStore(second ?? {}, undefined, third);
520
+ return hydrateStoreLikeFn(signals.createOptimisticStore, first, second ?? {}, third, ssrSource);
422
521
  }
423
522
  function hydratedCreateProjection(fn, initialValue, options) {
424
- if (!sharedConfig.hydrating) {
425
- return signals.createProjection(fn, initialValue, options);
426
- }
523
+ if (!sharedConfig.hydrating) return signals.createProjection(fn, initialValue, options);
427
524
  markTopLevelSnapshotScope();
428
525
  const ssrSource = options?.ssrSource;
429
- if (ssrSource === "client" || ssrSource === "initial") {
430
- return signals.createProjection(draft => draft, initialValue, options);
431
- }
432
- const aiResult = hydrateStoreFromAsyncIterable(signals.createProjection, initialValue, options);
433
- if (aiResult !== null) return aiResult;
434
- return signals.createProjection(wrapStoreFn(fn, ssrSource), initialValue, options);
526
+ if (ssrSource === "initial") return signals.createProjection(draft => draft, initialValue, options);
527
+ return hydrateStoreLikeFn(signals.createProjection, fn, initialValue, options, ssrSource);
435
528
  }
436
529
  function hydratedEffect(coreFn, compute, effectFn, value, options) {
437
530
  if (!sharedConfig.hydrating) return coreFn(compute, effectFn, value, options);
438
531
  const ssrSource = options?.ssrSource;
439
532
  if (ssrSource === "client") {
440
- const [hydrated, setHydrated] = signals.createSignal(false);
533
+ const [hydrated, setHydrated] = signals.createSignal(false, {
534
+ pureWrite: true
535
+ });
441
536
  let active = false;
442
537
  coreFn(prev => {
443
538
  if (!hydrated()) return value;
@@ -577,7 +672,10 @@ function resumeBoundaryHydration(o, id, set) {
577
672
  checkHydrationComplete();
578
673
  }
579
674
  function Loading(props) {
580
- if (!sharedConfig.hydrating) return signals.createLoadBoundary(() => props.children, () => props.fallback);
675
+ const onOpt = props.on ? {
676
+ on: () => props.on()
677
+ } : undefined;
678
+ if (!sharedConfig.hydrating) return signals.createLoadingBoundary(() => props.children, () => props.fallback, onOpt);
581
679
  return signals.createMemo(() => {
582
680
  const o = signals.getOwner();
583
681
  const id = o.id;
@@ -625,7 +723,8 @@ function Loading(props) {
625
723
  assetPromise.then(() => resumeBoundaryHydration(o, id, set));
626
724
  return undefined;
627
725
  }
628
- return signals.createLoadBoundary(() => props.children, () => props.fallback);
726
+ const boundary = signals.createLoadingBoundary(() => props.children, () => props.fallback, onOpt);
727
+ return boundary;
629
728
  });
630
729
  }
631
730
  function NoHydration(props) {
@@ -774,6 +873,14 @@ Object.defineProperty(exports, "action", {
774
873
  enumerable: true,
775
874
  get: function () { return signals.action; }
776
875
  });
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
+ });
777
884
  Object.defineProperty(exports, "createOwner", {
778
885
  enumerable: true,
779
886
  get: function () { return signals.createOwner; }
@@ -794,6 +901,14 @@ Object.defineProperty(exports, "deep", {
794
901
  enumerable: true,
795
902
  get: function () { return signals.deep; }
796
903
  });
904
+ Object.defineProperty(exports, "enableExternalSource", {
905
+ enumerable: true,
906
+ get: function () { return signals.enableExternalSource; }
907
+ });
908
+ Object.defineProperty(exports, "enforceLoadingBoundary", {
909
+ enumerable: true,
910
+ get: function () { return signals.enforceLoadingBoundary; }
911
+ });
797
912
  Object.defineProperty(exports, "flatten", {
798
913
  enumerable: true,
799
914
  get: function () { return signals.flatten; }
@@ -874,10 +989,6 @@ Object.defineProperty(exports, "runWithOwner", {
874
989
  enumerable: true,
875
990
  get: function () { return signals.runWithOwner; }
876
991
  });
877
- Object.defineProperty(exports, "setOnUnhandledAsync", {
878
- enumerable: true,
879
- get: function () { return signals.setOnUnhandledAsync; }
880
- });
881
992
  Object.defineProperty(exports, "snapshot", {
882
993
  enumerable: true,
883
994
  get: function () { return signals.snapshot; }
package/dist/solid.js CHANGED
@@ -1,5 +1,5 @@
1
- import { getContext, createMemo as createMemo$1, flatten, createRoot, setContext, createLoadBoundary, 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, 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, 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';
3
3
 
4
4
  const IS_DEV = false;
5
5
  const $DEVCOMP = Symbol(0);
@@ -186,6 +186,67 @@ function applyPatches(target, patches) {
186
186
  function isAsyncIterable(v) {
187
187
  return v != null && typeof v[Symbol.asyncIterator] === "function";
188
188
  }
189
+ function createShadowDraft(realDraft) {
190
+ const shadow = JSON.parse(JSON.stringify(realDraft));
191
+ let useShadow = true;
192
+ return {
193
+ proxy: new Proxy(shadow, {
194
+ get(_, prop) {
195
+ return useShadow ? shadow[prop] : realDraft[prop];
196
+ },
197
+ set(_, prop, value) {
198
+ if (useShadow) {
199
+ shadow[prop] = value;
200
+ return true;
201
+ }
202
+ return Reflect.set(realDraft, prop, value);
203
+ },
204
+ deleteProperty(_, prop) {
205
+ if (useShadow) {
206
+ delete shadow[prop];
207
+ return true;
208
+ }
209
+ return Reflect.deleteProperty(realDraft, prop);
210
+ },
211
+ has(_, prop) {
212
+ return prop in (useShadow ? shadow : realDraft);
213
+ },
214
+ ownKeys() {
215
+ return Reflect.ownKeys(useShadow ? shadow : realDraft);
216
+ },
217
+ getOwnPropertyDescriptor(_, prop) {
218
+ return Object.getOwnPropertyDescriptor(useShadow ? shadow : realDraft, prop);
219
+ }
220
+ }),
221
+ activate() {
222
+ useShadow = false;
223
+ }
224
+ };
225
+ }
226
+ function wrapFirstYield(iterable, activate) {
227
+ const srcIt = iterable[Symbol.asyncIterator]();
228
+ let first = true;
229
+ return {
230
+ [Symbol.asyncIterator]() {
231
+ return {
232
+ next() {
233
+ const p = srcIt.next();
234
+ if (first) {
235
+ first = false;
236
+ return p.then(r => {
237
+ activate();
238
+ return r.done ? r : {
239
+ done: false,
240
+ value: undefined
241
+ };
242
+ });
243
+ }
244
+ return p;
245
+ }
246
+ };
247
+ }
248
+ };
249
+ }
189
250
  function hydrateSignalFromAsyncIterable(coreFn, compute, value, options) {
190
251
  const parent = getOwner();
191
252
  const expectedId = peekNextChildId(parent);
@@ -237,7 +298,11 @@ function hydrateStoreFromAsyncIterable(coreFn, initialValue, options) {
237
298
  next() {
238
299
  if (isFirst) {
239
300
  const r = srcIt.next();
240
- return r && typeof r.then === "function" ? r.then(process) : syncThenable(process(r));
301
+ return r && typeof r.then === "function" ? {
302
+ then(fn, rej) {
303
+ r.then(v => fn(process(v)), rej);
304
+ }
305
+ } : syncThenable(process(r));
241
306
  }
242
307
  if (buffered) {
243
308
  const b = buffered;
@@ -266,13 +331,15 @@ function hydrateStoreFromAsyncIterable(coreFn, initialValue, options) {
266
331
  }, initialValue, options);
267
332
  }
268
333
  function hydratedCreateMemo(compute, value, options) {
269
- if (!sharedConfig.hydrating) {
334
+ if (!sharedConfig.hydrating || options?.transparent) {
270
335
  return createMemo$1(compute, value, options);
271
336
  }
272
337
  markTopLevelSnapshotScope();
273
338
  const ssrSource = options?.ssrSource;
274
339
  if (ssrSource === "client") {
275
- const [hydrated, setHydrated] = createSignal$1(false);
340
+ const [hydrated, setHydrated] = createSignal$1(false, {
341
+ pureWrite: true
342
+ });
276
343
  const memo = createMemo$1(prev => {
277
344
  if (!hydrated()) return prev ?? value;
278
345
  return compute(prev);
@@ -303,7 +370,9 @@ function hydratedCreateSignal(fn, second, third) {
303
370
  markTopLevelSnapshotScope();
304
371
  const ssrSource = third?.ssrSource;
305
372
  if (ssrSource === "client") {
306
- const [hydrated, setHydrated] = createSignal$1(false);
373
+ const [hydrated, setHydrated] = createSignal$1(false, {
374
+ pureWrite: true
375
+ });
307
376
  const sig = createSignal$1(prev => {
308
377
  if (!hydrated()) return prev ?? second;
309
378
  return fn(prev);
@@ -354,7 +423,9 @@ function hydratedCreateOptimistic(fn, second, third) {
354
423
  markTopLevelSnapshotScope();
355
424
  const ssrSource = third?.ssrSource;
356
425
  if (ssrSource === "client") {
357
- const [hydrated, setHydrated] = createSignal$1(false);
426
+ const [hydrated, setHydrated] = createSignal$1(false, {
427
+ pureWrite: true
428
+ });
358
429
  const sig = createOptimistic$1(prev => {
359
430
  if (!hydrated()) return prev ?? second;
360
431
  return fn(prev);
@@ -380,14 +451,7 @@ function hydratedCreateOptimistic(fn, second, third) {
380
451
  return init != null ? (subFetch(fn, prev), init) : fn(prev);
381
452
  }, second, third);
382
453
  }
383
- function wrapStoreFn(fn, ssrSource) {
384
- if (ssrSource === "initial") {
385
- return draft => {
386
- if (!sharedConfig.hydrating) return fn(draft);
387
- subFetch(fn, draft);
388
- return undefined;
389
- };
390
- }
454
+ function wrapStoreFn(fn) {
391
455
  return draft => {
392
456
  const o = getOwner();
393
457
  if (!sharedConfig.hydrating) return fn(draft);
@@ -397,46 +461,77 @@ function wrapStoreFn(fn, ssrSource) {
397
461
  return init != null ? (subFetch(fn, draft), init) : fn(draft);
398
462
  };
399
463
  }
464
+ function hydrateStoreLikeFn(coreFn, fn, initialValue, options, ssrSource) {
465
+ if (ssrSource === "client") {
466
+ const [hydrated, setHydrated] = createSignal$1(false, {
467
+ pureWrite: true
468
+ });
469
+ const result = coreFn(draft => {
470
+ if (!hydrated()) return;
471
+ return fn(draft);
472
+ }, initialValue, options);
473
+ setHydrated(true);
474
+ return result;
475
+ }
476
+ if (ssrSource === "hybrid") {
477
+ const [hydrated, setHydrated] = createSignal$1(false, {
478
+ pureWrite: true
479
+ });
480
+ const result = coreFn(draft => {
481
+ const o = getOwner();
482
+ if (!hydrated()) {
483
+ if (sharedConfig.has(o.id)) {
484
+ const initP = sharedConfig.load(o.id);
485
+ const init = initP?.v ?? initP;
486
+ if (init != null) {
487
+ subFetch(fn, draft);
488
+ return init;
489
+ }
490
+ }
491
+ return fn(draft);
492
+ }
493
+ const {
494
+ proxy,
495
+ activate
496
+ } = createShadowDraft(draft);
497
+ const r = fn(proxy);
498
+ return isAsyncIterable(r) ? wrapFirstYield(r, activate) : r;
499
+ }, initialValue, options);
500
+ setHydrated(true);
501
+ return result;
502
+ }
503
+ const aiResult = hydrateStoreFromAsyncIterable(coreFn, initialValue, options);
504
+ if (aiResult !== null) return aiResult;
505
+ return coreFn(wrapStoreFn(fn), initialValue, options);
506
+ }
400
507
  function hydratedCreateStore(first, second, third) {
401
508
  if (typeof first !== "function" || !sharedConfig.hydrating) return createStore$1(first, second, third);
402
509
  markTopLevelSnapshotScope();
403
510
  const ssrSource = third?.ssrSource;
404
- if (ssrSource === "client" || ssrSource === "initial") {
405
- return createStore$1(second ?? {}, undefined, third);
406
- }
407
- const aiResult = hydrateStoreFromAsyncIterable(createStore$1, second ?? {}, third);
408
- if (aiResult !== null) return aiResult;
409
- return createStore$1(wrapStoreFn(first, ssrSource), second, third);
511
+ if (ssrSource === "initial") return createStore$1(second ?? {}, undefined, third);
512
+ return hydrateStoreLikeFn(createStore$1, first, second ?? {}, third, ssrSource);
410
513
  }
411
514
  function hydratedCreateOptimisticStore(first, second, third) {
412
515
  if (typeof first !== "function" || !sharedConfig.hydrating) return createOptimisticStore$1(first, second, third);
413
516
  markTopLevelSnapshotScope();
414
517
  const ssrSource = third?.ssrSource;
415
- if (ssrSource === "client" || ssrSource === "initial") {
416
- return createOptimisticStore$1(second ?? {}, undefined, third);
417
- }
418
- const aiResult = hydrateStoreFromAsyncIterable(createOptimisticStore$1, second ?? {}, third);
419
- if (aiResult !== null) return aiResult;
420
- return createOptimisticStore$1(wrapStoreFn(first, ssrSource), second, third);
518
+ if (ssrSource === "initial") return createOptimisticStore$1(second ?? {}, undefined, third);
519
+ return hydrateStoreLikeFn(createOptimisticStore$1, first, second ?? {}, third, ssrSource);
421
520
  }
422
521
  function hydratedCreateProjection(fn, initialValue, options) {
423
- if (!sharedConfig.hydrating) {
424
- return createProjection$1(fn, initialValue, options);
425
- }
522
+ if (!sharedConfig.hydrating) return createProjection$1(fn, initialValue, options);
426
523
  markTopLevelSnapshotScope();
427
524
  const ssrSource = options?.ssrSource;
428
- if (ssrSource === "client" || ssrSource === "initial") {
429
- return createProjection$1(draft => draft, initialValue, options);
430
- }
431
- const aiResult = hydrateStoreFromAsyncIterable(createProjection$1, initialValue, options);
432
- if (aiResult !== null) return aiResult;
433
- return createProjection$1(wrapStoreFn(fn, ssrSource), initialValue, options);
525
+ if (ssrSource === "initial") return createProjection$1(draft => draft, initialValue, options);
526
+ return hydrateStoreLikeFn(createProjection$1, fn, initialValue, options, ssrSource);
434
527
  }
435
528
  function hydratedEffect(coreFn, compute, effectFn, value, options) {
436
529
  if (!sharedConfig.hydrating) return coreFn(compute, effectFn, value, options);
437
530
  const ssrSource = options?.ssrSource;
438
531
  if (ssrSource === "client") {
439
- const [hydrated, setHydrated] = createSignal$1(false);
532
+ const [hydrated, setHydrated] = createSignal$1(false, {
533
+ pureWrite: true
534
+ });
440
535
  let active = false;
441
536
  coreFn(prev => {
442
537
  if (!hydrated()) return value;
@@ -576,7 +671,10 @@ function resumeBoundaryHydration(o, id, set) {
576
671
  checkHydrationComplete();
577
672
  }
578
673
  function Loading(props) {
579
- if (!sharedConfig.hydrating) return createLoadBoundary(() => props.children, () => props.fallback);
674
+ const onOpt = props.on ? {
675
+ on: () => props.on()
676
+ } : undefined;
677
+ if (!sharedConfig.hydrating) return createLoadingBoundary(() => props.children, () => props.fallback, onOpt);
580
678
  return createMemo$1(() => {
581
679
  const o = getOwner();
582
680
  const id = o.id;
@@ -624,7 +722,8 @@ function Loading(props) {
624
722
  assetPromise.then(() => resumeBoundaryHydration(o, id, set));
625
723
  return undefined;
626
724
  }
627
- return createLoadBoundary(() => props.children, () => props.fallback);
725
+ const boundary = createLoadingBoundary(() => props.children, () => props.fallback, onOpt);
726
+ return boundary;
628
727
  });
629
728
  }
630
729
  function NoHydration(props) {
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.2",
4
+ "version": "2.0.0-beta.4",
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.12.0",
82
+ "@solidjs/signals": "^0.13.6",
83
83
  "csstype": "^3.1.0",
84
84
  "seroval": "~1.5.0",
85
85
  "seroval-plugins": "~1.5.0"
@@ -78,6 +78,7 @@ export declare const createEffect: typeof coreEffect;
78
78
  */
79
79
  export declare function Loading(props: {
80
80
  fallback?: JSX.Element;
81
+ on?: () => any;
81
82
  children: JSX.Element;
82
83
  }): JSX.Element;
83
84
  /**
package/types/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- export { $PROXY, $REFRESH, $TRACK, action, createOwner, createReaction, createRoot, createTrackedEffect, deep, flatten, flush, getNextChildId, getObserver, getOwner, isEqual, isRefreshing, isPending, isWrappable, mapArray, merge, omit, onCleanup, onSettled, latest, reconcile, refresh, repeat, resolve, NotReadyError, runWithOwner, setOnUnhandledAsync, snapshot, storePath, untrack } from "@solidjs/signals";
2
- export type { Accessor, ComputeFunction, EffectFunction, EffectOptions, Merge, NoInfer, NotWrappable, Omit, Owner, Signal, SignalOptions, Setter, Store, SolidStore, StoreNode, StoreSetter, StorePathRange, ArrayFilterFn, CustomPartial, Part, PathSetter } from "@solidjs/signals";
1
+ export { $PROXY, $REFRESH, $TRACK, action, createErrorBoundary, createLoadingBoundary, createOwner, createReaction, createRoot, createTrackedEffect, deep, flatten, flush, getNextChildId, getObserver, getOwner, isEqual, isRefreshing, isPending, isWrappable, mapArray, merge, omit, onCleanup, onSettled, latest, reconcile, refresh, repeat, resolve, NotReadyError, runWithOwner, enableExternalSource, enforceLoadingBoundary, snapshot, storePath, untrack } from "@solidjs/signals";
2
+ export type { Accessor, ComputeFunction, EffectFunction, EffectOptions, ExternalSource, ExternalSourceConfig, ExternalSourceFactory, Merge, NoInfer, NotWrappable, Omit, Owner, Signal, SignalOptions, Setter, Store, SolidStore, StoreNode, StoreSetter, StorePathRange, ArrayFilterFn, CustomPartial, Part, PathSetter } from "@solidjs/signals";
3
3
  export { $DEVCOMP, children, createContext, useContext } from "./client/core.js";
4
4
  export type { ChildrenReturn, Context, ContextProviderComponent, ResolvedChildren, ResolvedJSXElement } from "./client/core.js";
5
5
  export * from "./client/component.js";