solid-js 1.5.0-beta.1 → 1.5.0-beta.2

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
@@ -153,7 +153,6 @@ let Transition = null;
153
153
  let Scheduler = null;
154
154
  let ExternalSourceFactory = null;
155
155
  let Listener = null;
156
- let Pending = null;
157
156
  let Updates = null;
158
157
  let Effects = null;
159
158
  let ExecCount = 0;
@@ -243,18 +242,19 @@ function createMemo(fn, value, options) {
243
242
  } else updateComputation(c);
244
243
  return readSignal.bind(c);
245
244
  }
246
- function createResource(source, fetcher, options) {
247
- if (arguments.length === 2) {
248
- if (typeof fetcher === "object") {
249
- options = fetcher;
250
- fetcher = source;
251
- source = true;
252
- }
253
- } else if (arguments.length === 1) {
254
- fetcher = source;
245
+ function createResource(pSource, pFetcher, pOptions) {
246
+ let source;
247
+ let fetcher;
248
+ let options;
249
+ if (arguments.length === 2 && typeof pFetcher === "object" || arguments.length === 1) {
255
250
  source = true;
251
+ fetcher = pSource;
252
+ options = pFetcher || {};
253
+ } else {
254
+ source = pSource;
255
+ fetcher = pFetcher;
256
+ options = pOptions || {};
256
257
  }
257
- options || (options = {});
258
258
  let err = undefined,
259
259
  pr = null,
260
260
  initP = NO_INIT,
@@ -300,7 +300,7 @@ function createResource(source, fetcher, options) {
300
300
  function completeLoad(v, success) {
301
301
  !success && (err = castError(v));
302
302
  runUpdates(() => {
303
- setValue(() => success ? v : undefined);
303
+ setValue(() => v);
304
304
  setState(success ? "ready" : "error");
305
305
  for (const c of contexts.keys()) c.decrement();
306
306
  contexts.clear();
@@ -324,7 +324,7 @@ function createResource(source, fetcher, options) {
324
324
  return v;
325
325
  }
326
326
  function load(refetching = true) {
327
- if (refetching && scheduled) return;
327
+ if (refetching !== false && scheduled) return;
328
328
  scheduled = false;
329
329
  err = undefined;
330
330
  const lookup = dynamic ? dynamic() : source;
@@ -424,18 +424,7 @@ function createSelector(source, fn = equalFn, options) {
424
424
  };
425
425
  }
426
426
  function batch(fn) {
427
- if (Pending) return fn();
428
- let result;
429
- const q = Pending = [];
430
- try {
431
- result = fn();
432
- } finally {
433
- Pending = null;
434
- }
435
- runUpdates(() => {
436
- for (let i = 0; i < q.length; i += 1) notifySignal(q[i]);
437
- }, false);
438
- return result;
427
+ return runUpdates(fn, false);
439
428
  }
440
429
  function untrack(fn) {
441
430
  let result,
@@ -623,10 +612,12 @@ function enableExternalSource(factory) {
623
612
  function readSignal() {
624
613
  const runningTransition = Transition && Transition.running;
625
614
  if (this.sources && (!runningTransition && this.state || runningTransition && this.tState)) {
626
- const updates = Updates;
627
- Updates = null;
628
- !runningTransition && this.state === STALE || runningTransition && this.tState === STALE ? updateComputation(this) : lookUpstream(this);
629
- Updates = updates;
615
+ if (!runningTransition && this.state === STALE || runningTransition && this.tState === STALE) updateComputation(this);else {
616
+ const updates = Updates;
617
+ Updates = null;
618
+ runUpdates(() => lookUpstream(this), false);
619
+ Updates = updates;
620
+ }
630
621
  }
631
622
  if (Listener) {
632
623
  const sSlot = this.observers ? this.observers.length : 0;
@@ -659,30 +650,27 @@ function writeSignal(node, value, isComp) {
659
650
  }
660
651
  if (!TransitionRunning) node.value = value;
661
652
  } else node.value = value;
662
- if (Pending) Pending.push(node);else notifySignal(node);
663
- }
664
- return value;
665
- }
666
- function notifySignal(node) {
667
- if (node.observers && node.observers.length) {
668
- runUpdates(() => {
669
- for (let i = 0; i < node.observers.length; i += 1) {
670
- const o = node.observers[i];
671
- const TransitionRunning = Transition && Transition.running;
672
- if (TransitionRunning && Transition.disposed.has(o)) continue;
673
- if (TransitionRunning && !o.tState || !TransitionRunning && !o.state) {
674
- if (o.pure) Updates.push(o);else Effects.push(o);
675
- if (o.observers) markDownstream(o);
653
+ if (node.observers && node.observers.length) {
654
+ runUpdates(() => {
655
+ for (let i = 0; i < node.observers.length; i += 1) {
656
+ const o = node.observers[i];
657
+ const TransitionRunning = Transition && Transition.running;
658
+ if (TransitionRunning && Transition.disposed.has(o)) continue;
659
+ if (TransitionRunning && !o.tState || !TransitionRunning && !o.state) {
660
+ if (o.pure) Updates.push(o);else Effects.push(o);
661
+ if (o.observers) markDownstream(o);
662
+ }
663
+ if (TransitionRunning) o.tState = STALE;else o.state = STALE;
676
664
  }
677
- if (TransitionRunning) o.tState = STALE;else o.state = STALE;
678
- }
679
- if (Updates.length > 10e5) {
680
- Updates = [];
681
- if ("_SOLID_DEV_") throw new Error("Potential Infinite Loop Detected.");
682
- throw new Error();
683
- }
684
- }, false);
665
+ if (Updates.length > 10e5) {
666
+ Updates = [];
667
+ if ("_SOLID_DEV_") throw new Error("Potential Infinite Loop Detected.");
668
+ throw new Error();
669
+ }
670
+ }, false);
671
+ }
685
672
  }
673
+ return value;
686
674
  }
687
675
  function updateComputation(node) {
688
676
  if (!node.fn) return;
@@ -708,6 +696,7 @@ function runComputation(node, value, time) {
708
696
  try {
709
697
  nextValue = node.fn(value);
710
698
  } catch (err) {
699
+ if (node.pure) Transition && Transition.running ? node.tState = STALE : node.state = STALE;
711
700
  handleError(err);
712
701
  }
713
702
  if (!node.updatedAt || node.updatedAt <= time) {
@@ -785,7 +774,7 @@ function runTop(node) {
785
774
  } else if (!runningTransition && node.state === PENDING || runningTransition && node.tState === PENDING) {
786
775
  const updates = Updates;
787
776
  Updates = null;
788
- lookUpstream(node, ancestors[0]);
777
+ runUpdates(() => lookUpstream(node, ancestors[0]), false);
789
778
  Updates = updates;
790
779
  }
791
780
  }
@@ -1026,7 +1015,7 @@ function observable(input) {
1026
1015
  };
1027
1016
  }
1028
1017
  const dispose = createRoot(disposer => {
1029
- createComputed(() => {
1018
+ createEffect(() => {
1030
1019
  const v = input();
1031
1020
  untrack(() => handler(v));
1032
1021
  });
@@ -1434,7 +1423,9 @@ function ErrorBoundary(props) {
1434
1423
  if (e = errored()) {
1435
1424
  const f = props.fallback;
1436
1425
  if ((typeof f !== "function" || f.length == 0)) console.error(e);
1437
- return typeof f === "function" && f.length ? untrack(() => f(e, setErrored)) : f;
1426
+ const res = typeof f === "function" && f.length ? untrack(() => f(e, () => setErrored())) : f;
1427
+ onError(setErrored);
1428
+ return res;
1438
1429
  }
1439
1430
  onError(setErrored);
1440
1431
  return props.children;
@@ -1530,25 +1521,22 @@ function Suspense(props) {
1530
1521
  if (sharedConfig.context && sharedConfig.load) {
1531
1522
  const key = sharedConfig.context.id + sharedConfig.context.count;
1532
1523
  let ref = sharedConfig.load(key);
1533
- if (ref) {
1534
- p = ref[0];
1535
- if (p === "$$$") sharedConfig.gather(key);else {
1536
- if (typeof p !== "object" || !("then" in p)) p = Promise.resolve(p);
1537
- const [s, set] = createSignal(undefined, {
1538
- equals: false
1539
- });
1540
- flicker = s;
1541
- p.then(err => {
1542
- if (err !== "$$$" || sharedConfig.done) {
1543
- err !== "$$$" && (error = err);
1544
- return set();
1545
- }
1546
- sharedConfig.gather(key);
1547
- setHydrateContext(ctx);
1548
- set();
1549
- setHydrateContext();
1550
- });
1551
- }
1524
+ if (ref && (p = ref[0]) && p !== "$$f") {
1525
+ if (typeof p !== "object" || !("then" in p)) p = Promise.resolve(p);
1526
+ const [s, set] = createSignal(undefined, {
1527
+ equals: false
1528
+ });
1529
+ flicker = s;
1530
+ p.then(err => {
1531
+ if (err || sharedConfig.done) {
1532
+ err && (error = err);
1533
+ return set();
1534
+ }
1535
+ sharedConfig.gather(key);
1536
+ setHydrateContext(ctx);
1537
+ set();
1538
+ setHydrateContext();
1539
+ });
1552
1540
  }
1553
1541
  }
1554
1542
  const listContext = useContext(SuspenseListContext);
@@ -1565,14 +1553,14 @@ function Suspense(props) {
1565
1553
  flicker();
1566
1554
  return flicker = undefined;
1567
1555
  }
1568
- if (ctx && !p) setHydrateContext();
1556
+ if (ctx && p === "$$f") setHydrateContext();
1569
1557
  const rendered = createMemo(() => props.children);
1570
1558
  return createMemo(() => {
1571
1559
  const inFallback = store.inFallback(),
1572
1560
  visibleContent = showContent ? showContent() : true,
1573
1561
  visibleFallback = showFallback ? showFallback() : true;
1574
1562
  dispose && dispose();
1575
- if ((!inFallback || p) && visibleContent) {
1563
+ if ((!inFallback || p && p !== "$$f") && visibleContent) {
1576
1564
  store.resolved = true;
1577
1565
  ctx = p = undefined;
1578
1566
  resumeEffects(store.effects);
package/dist/dev.js CHANGED
@@ -149,7 +149,6 @@ let Transition = null;
149
149
  let Scheduler = null;
150
150
  let ExternalSourceFactory = null;
151
151
  let Listener = null;
152
- let Pending = null;
153
152
  let Updates = null;
154
153
  let Effects = null;
155
154
  let ExecCount = 0;
@@ -239,18 +238,19 @@ function createMemo(fn, value, options) {
239
238
  } else updateComputation(c);
240
239
  return readSignal.bind(c);
241
240
  }
242
- function createResource(source, fetcher, options) {
243
- if (arguments.length === 2) {
244
- if (typeof fetcher === "object") {
245
- options = fetcher;
246
- fetcher = source;
247
- source = true;
248
- }
249
- } else if (arguments.length === 1) {
250
- fetcher = source;
241
+ function createResource(pSource, pFetcher, pOptions) {
242
+ let source;
243
+ let fetcher;
244
+ let options;
245
+ if (arguments.length === 2 && typeof pFetcher === "object" || arguments.length === 1) {
251
246
  source = true;
247
+ fetcher = pSource;
248
+ options = pFetcher || {};
249
+ } else {
250
+ source = pSource;
251
+ fetcher = pFetcher;
252
+ options = pOptions || {};
252
253
  }
253
- options || (options = {});
254
254
  let err = undefined,
255
255
  pr = null,
256
256
  initP = NO_INIT,
@@ -296,7 +296,7 @@ function createResource(source, fetcher, options) {
296
296
  function completeLoad(v, success) {
297
297
  !success && (err = castError(v));
298
298
  runUpdates(() => {
299
- setValue(() => success ? v : undefined);
299
+ setValue(() => v);
300
300
  setState(success ? "ready" : "error");
301
301
  for (const c of contexts.keys()) c.decrement();
302
302
  contexts.clear();
@@ -320,7 +320,7 @@ function createResource(source, fetcher, options) {
320
320
  return v;
321
321
  }
322
322
  function load(refetching = true) {
323
- if (refetching && scheduled) return;
323
+ if (refetching !== false && scheduled) return;
324
324
  scheduled = false;
325
325
  err = undefined;
326
326
  const lookup = dynamic ? dynamic() : source;
@@ -420,18 +420,7 @@ function createSelector(source, fn = equalFn, options) {
420
420
  };
421
421
  }
422
422
  function batch(fn) {
423
- if (Pending) return fn();
424
- let result;
425
- const q = Pending = [];
426
- try {
427
- result = fn();
428
- } finally {
429
- Pending = null;
430
- }
431
- runUpdates(() => {
432
- for (let i = 0; i < q.length; i += 1) notifySignal(q[i]);
433
- }, false);
434
- return result;
423
+ return runUpdates(fn, false);
435
424
  }
436
425
  function untrack(fn) {
437
426
  let result,
@@ -619,10 +608,12 @@ function enableExternalSource(factory) {
619
608
  function readSignal() {
620
609
  const runningTransition = Transition && Transition.running;
621
610
  if (this.sources && (!runningTransition && this.state || runningTransition && this.tState)) {
622
- const updates = Updates;
623
- Updates = null;
624
- !runningTransition && this.state === STALE || runningTransition && this.tState === STALE ? updateComputation(this) : lookUpstream(this);
625
- Updates = updates;
611
+ if (!runningTransition && this.state === STALE || runningTransition && this.tState === STALE) updateComputation(this);else {
612
+ const updates = Updates;
613
+ Updates = null;
614
+ runUpdates(() => lookUpstream(this), false);
615
+ Updates = updates;
616
+ }
626
617
  }
627
618
  if (Listener) {
628
619
  const sSlot = this.observers ? this.observers.length : 0;
@@ -655,30 +646,27 @@ function writeSignal(node, value, isComp) {
655
646
  }
656
647
  if (!TransitionRunning) node.value = value;
657
648
  } else node.value = value;
658
- if (Pending) Pending.push(node);else notifySignal(node);
659
- }
660
- return value;
661
- }
662
- function notifySignal(node) {
663
- if (node.observers && node.observers.length) {
664
- runUpdates(() => {
665
- for (let i = 0; i < node.observers.length; i += 1) {
666
- const o = node.observers[i];
667
- const TransitionRunning = Transition && Transition.running;
668
- if (TransitionRunning && Transition.disposed.has(o)) continue;
669
- if (TransitionRunning && !o.tState || !TransitionRunning && !o.state) {
670
- if (o.pure) Updates.push(o);else Effects.push(o);
671
- if (o.observers) markDownstream(o);
649
+ if (node.observers && node.observers.length) {
650
+ runUpdates(() => {
651
+ for (let i = 0; i < node.observers.length; i += 1) {
652
+ const o = node.observers[i];
653
+ const TransitionRunning = Transition && Transition.running;
654
+ if (TransitionRunning && Transition.disposed.has(o)) continue;
655
+ if (TransitionRunning && !o.tState || !TransitionRunning && !o.state) {
656
+ if (o.pure) Updates.push(o);else Effects.push(o);
657
+ if (o.observers) markDownstream(o);
658
+ }
659
+ if (TransitionRunning) o.tState = STALE;else o.state = STALE;
672
660
  }
673
- if (TransitionRunning) o.tState = STALE;else o.state = STALE;
674
- }
675
- if (Updates.length > 10e5) {
676
- Updates = [];
677
- if ("_SOLID_DEV_") throw new Error("Potential Infinite Loop Detected.");
678
- throw new Error();
679
- }
680
- }, false);
661
+ if (Updates.length > 10e5) {
662
+ Updates = [];
663
+ if ("_SOLID_DEV_") throw new Error("Potential Infinite Loop Detected.");
664
+ throw new Error();
665
+ }
666
+ }, false);
667
+ }
681
668
  }
669
+ return value;
682
670
  }
683
671
  function updateComputation(node) {
684
672
  if (!node.fn) return;
@@ -704,6 +692,7 @@ function runComputation(node, value, time) {
704
692
  try {
705
693
  nextValue = node.fn(value);
706
694
  } catch (err) {
695
+ if (node.pure) Transition && Transition.running ? node.tState = STALE : node.state = STALE;
707
696
  handleError(err);
708
697
  }
709
698
  if (!node.updatedAt || node.updatedAt <= time) {
@@ -781,7 +770,7 @@ function runTop(node) {
781
770
  } else if (!runningTransition && node.state === PENDING || runningTransition && node.tState === PENDING) {
782
771
  const updates = Updates;
783
772
  Updates = null;
784
- lookUpstream(node, ancestors[0]);
773
+ runUpdates(() => lookUpstream(node, ancestors[0]), false);
785
774
  Updates = updates;
786
775
  }
787
776
  }
@@ -1022,7 +1011,7 @@ function observable(input) {
1022
1011
  };
1023
1012
  }
1024
1013
  const dispose = createRoot(disposer => {
1025
- createComputed(() => {
1014
+ createEffect(() => {
1026
1015
  const v = input();
1027
1016
  untrack(() => handler(v));
1028
1017
  });
@@ -1430,7 +1419,9 @@ function ErrorBoundary(props) {
1430
1419
  if (e = errored()) {
1431
1420
  const f = props.fallback;
1432
1421
  if ((typeof f !== "function" || f.length == 0)) console.error(e);
1433
- return typeof f === "function" && f.length ? untrack(() => f(e, setErrored)) : f;
1422
+ const res = typeof f === "function" && f.length ? untrack(() => f(e, () => setErrored())) : f;
1423
+ onError(setErrored);
1424
+ return res;
1434
1425
  }
1435
1426
  onError(setErrored);
1436
1427
  return props.children;
@@ -1526,25 +1517,22 @@ function Suspense(props) {
1526
1517
  if (sharedConfig.context && sharedConfig.load) {
1527
1518
  const key = sharedConfig.context.id + sharedConfig.context.count;
1528
1519
  let ref = sharedConfig.load(key);
1529
- if (ref) {
1530
- p = ref[0];
1531
- if (p === "$$$") sharedConfig.gather(key);else {
1532
- if (typeof p !== "object" || !("then" in p)) p = Promise.resolve(p);
1533
- const [s, set] = createSignal(undefined, {
1534
- equals: false
1535
- });
1536
- flicker = s;
1537
- p.then(err => {
1538
- if (err !== "$$$" || sharedConfig.done) {
1539
- err !== "$$$" && (error = err);
1540
- return set();
1541
- }
1542
- sharedConfig.gather(key);
1543
- setHydrateContext(ctx);
1544
- set();
1545
- setHydrateContext();
1546
- });
1547
- }
1520
+ if (ref && (p = ref[0]) && p !== "$$f") {
1521
+ if (typeof p !== "object" || !("then" in p)) p = Promise.resolve(p);
1522
+ const [s, set] = createSignal(undefined, {
1523
+ equals: false
1524
+ });
1525
+ flicker = s;
1526
+ p.then(err => {
1527
+ if (err || sharedConfig.done) {
1528
+ err && (error = err);
1529
+ return set();
1530
+ }
1531
+ sharedConfig.gather(key);
1532
+ setHydrateContext(ctx);
1533
+ set();
1534
+ setHydrateContext();
1535
+ });
1548
1536
  }
1549
1537
  }
1550
1538
  const listContext = useContext(SuspenseListContext);
@@ -1561,14 +1549,14 @@ function Suspense(props) {
1561
1549
  flicker();
1562
1550
  return flicker = undefined;
1563
1551
  }
1564
- if (ctx && !p) setHydrateContext();
1552
+ if (ctx && p === "$$f") setHydrateContext();
1565
1553
  const rendered = createMemo(() => props.children);
1566
1554
  return createMemo(() => {
1567
1555
  const inFallback = store.inFallback(),
1568
1556
  visibleContent = showContent ? showContent() : true,
1569
1557
  visibleFallback = showFallback ? showFallback() : true;
1570
1558
  dispose && dispose();
1571
- if ((!inFallback || p) && visibleContent) {
1559
+ if ((!inFallback || p && p !== "$$f") && visibleContent) {
1572
1560
  store.resolved = true;
1573
1561
  ctx = p = undefined;
1574
1562
  resumeEffects(store.effects);
package/dist/server.cjs CHANGED
@@ -151,6 +151,8 @@ function runWithOwner(o, fn) {
151
151
  Owner = o;
152
152
  try {
153
153
  return fn();
154
+ } catch (err) {
155
+ handleError(err);
154
156
  } finally {
155
157
  Owner = prev;
156
158
  }
@@ -196,31 +198,33 @@ function mapArray(list, mapFn, options = {}) {
196
198
  } else if (options.fallback) s = [options.fallback()];
197
199
  return () => s;
198
200
  }
199
- function getSymbol() {
200
- const SymbolCopy = Symbol;
201
- return SymbolCopy.observable || "@@observable";
202
- }
203
201
  function observable(input) {
204
- const $$observable = getSymbol();
205
202
  return {
206
203
  subscribe(observer) {
207
204
  if (!(observer instanceof Object) || observer == null) {
208
205
  throw new TypeError("Expected the observer to be an object.");
209
206
  }
210
- const handler = "next" in observer ? observer.next : observer;
211
- let complete = false;
212
- createComputed(() => {
213
- if (complete) return;
214
- const v = input();
215
- handler(v);
207
+ const handler = typeof observer === "function" ? observer : observer.next && observer.next.bind(observer);
208
+ if (!handler) {
209
+ return {
210
+ unsubscribe() {}
211
+ };
212
+ }
213
+ const dispose = createRoot(disposer => {
214
+ createEffect(() => {
215
+ const v = input();
216
+ untrack(() => handler(v));
217
+ });
218
+ return disposer;
216
219
  });
220
+ if (getOwner()) onCleanup(dispose);
217
221
  return {
218
222
  unsubscribe() {
219
- complete = true;
223
+ dispose();
220
224
  }
221
225
  };
222
226
  },
223
- [$$observable]() {
227
+ [Symbol.observable || "@@observable"]() {
224
228
  return this;
225
229
  }
226
230
  };
@@ -338,18 +342,13 @@ function Match(props) {
338
342
  }
339
343
  function resetErrorBoundaries() {}
340
344
  function ErrorBoundary(props) {
341
- let error, res, clean;
345
+ let error,
346
+ res,
347
+ clean,
348
+ sync = true;
342
349
  const ctx = sharedConfig.context;
343
350
  const id = ctx.id + ctx.count;
344
- onError(err => error = err);
345
- onCleanup(() => cleanNode(clean));
346
- createMemo(() => {
347
- Owner.context = {
348
- [BRANCH]: clean = {}
349
- };
350
- return res = props.children;
351
- });
352
- if (error) {
351
+ function displayFallback() {
353
352
  cleanNode(clean);
354
353
  ctx.writeResource(id, error, true);
355
354
  setHydrateContext({ ...ctx,
@@ -358,7 +357,23 @@ function ErrorBoundary(props) {
358
357
  const f = props.fallback;
359
358
  return typeof f === "function" && f.length ? f(error, () => {}) : f;
360
359
  }
361
- return res;
360
+ onError(err => {
361
+ error = err;
362
+ !sync && ctx.replace("e" + id, displayFallback);
363
+ sync = true;
364
+ });
365
+ onCleanup(() => cleanNode(clean));
366
+ createMemo(() => {
367
+ Owner.context = {
368
+ [BRANCH]: clean = {}
369
+ };
370
+ return res = props.children;
371
+ });
372
+ if (error) return displayFallback();
373
+ sync = false;
374
+ return {
375
+ t: `<!e${id}>${resolveSSRNode(res)}<!/e${id}>`
376
+ };
362
377
  }
363
378
  const SuspenseContext = createContext();
364
379
  let resourceContext = null;
@@ -465,6 +480,7 @@ function lazy(fn) {
465
480
  return p;
466
481
  };
467
482
  const contexts = new Set();
483
+ setTimeout(load);
468
484
  const wrap = props => {
469
485
  load();
470
486
  const id = sharedConfig.context.id.slice(0, -1);
@@ -488,10 +504,11 @@ function lazy(fn) {
488
504
  return wrap;
489
505
  }
490
506
  function suspenseComplete(c) {
507
+ if (c.complete) return true;
491
508
  for (const r of c.resources.values()) {
492
509
  if (r.loading) return false;
493
510
  }
494
- return true;
511
+ return c.complete = true;
495
512
  }
496
513
  function notifySuspense(contexts) {
497
514
  for (const c of contexts) {
@@ -518,9 +535,11 @@ function Suspense(props) {
518
535
  const ctx = sharedConfig.context;
519
536
  const id = ctx.id + ctx.count;
520
537
  const o = Owner;
521
- if (o.context) o.context[BRANCH] = clean = {};else o.context = {
522
- [BRANCH]: clean = {}
523
- };
538
+ if (o) {
539
+ if (o.context) o.context[BRANCH] = clean = {};else o.context = {
540
+ [BRANCH]: clean = {}
541
+ };
542
+ }
524
543
  const value = ctx.suspense[id] || (ctx.suspense[id] = {
525
544
  resources: new Map(),
526
545
  completed: () => {
@@ -528,7 +547,8 @@ function Suspense(props) {
528
547
  if (suspenseComplete(value)) {
529
548
  done(resolveSSRNode(res));
530
549
  }
531
- }
550
+ },
551
+ complete: false
532
552
  });
533
553
  function runSuspense() {
534
554
  setHydrateContext({ ...ctx,
@@ -538,19 +558,20 @@ function Suspense(props) {
538
558
  return createComponent(SuspenseContext.Provider, {
539
559
  value,
540
560
  get children() {
541
- cleanNode(clean);
561
+ clean && cleanNode(clean);
542
562
  return props.children;
543
563
  }
544
564
  });
545
565
  });
546
566
  }
547
567
  const res = runSuspense();
548
- if (suspenseComplete(value)) {
549
- ctx.writeResource(id, "$$$");
550
- return res;
551
- }
568
+ if (suspenseComplete(value)) return res;
552
569
  onError(err => {
553
- if (!done || !done(undefined, err)) throw err;
570
+ if (!done || !done(undefined, err)) {
571
+ if (o) runWithOwner(o.owner, () => {
572
+ throw err;
573
+ });else throw err;
574
+ }
554
575
  });
555
576
  done = ctx.async ? ctx.registerFragment(id) : undefined;
556
577
  if (ctx.async) {
@@ -565,6 +586,7 @@ function Suspense(props) {
565
586
  count: 0,
566
587
  id: ctx.id + "0.f"
567
588
  });
589
+ ctx.writeResource(id, "$$f");
568
590
  return props.fallback;
569
591
  }
570
592