solid-js 1.2.6 → 1.3.0-beta.3

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/server.js CHANGED
@@ -37,8 +37,15 @@ function createComputed(fn, value) {
37
37
  owner: Owner,
38
38
  context: null
39
39
  };
40
- fn(value);
41
- Owner = Owner.owner;
40
+ try {
41
+ fn(value);
42
+ } catch (err) {
43
+ const fns = lookup(Owner, ERROR);
44
+ if (!fns) throw err;
45
+ fns.forEach(f => f(err));
46
+ } finally {
47
+ Owner = Owner.owner;
48
+ }
42
49
  }
43
50
  const createRenderEffect = createComputed;
44
51
  function createEffect(fn, value) {}
@@ -47,8 +54,16 @@ function createMemo(fn, value) {
47
54
  owner: Owner,
48
55
  context: null
49
56
  };
50
- const v = fn(value);
51
- Owner = Owner.owner;
57
+ let v;
58
+ try {
59
+ v = fn(value);
60
+ } catch (err) {
61
+ const fns = lookup(Owner, ERROR);
62
+ if (!fns) throw err;
63
+ fns.forEach(f => f(err));
64
+ } finally {
65
+ Owner = Owner.owner;
66
+ }
52
67
  return () => v;
53
68
  }
54
69
  function createDeferred(source) {
@@ -215,7 +230,7 @@ function createUniqueId() {
215
230
  return `${ctx.id}${ctx.count++}`;
216
231
  }
217
232
  function createComponent(Comp, props) {
218
- if (sharedConfig.context) {
233
+ if (sharedConfig.context && !sharedConfig.context.noHydrate) {
219
234
  const c = sharedConfig.context;
220
235
  setHydrateContext(nextHydrateContext());
221
236
  const r = Comp(props);
@@ -286,7 +301,20 @@ function Match(props) {
286
301
  return props;
287
302
  }
288
303
  function ErrorBoundary(props) {
289
- return props.children;
304
+ let error, res;
305
+ const ctx = sharedConfig.context;
306
+ const id = ctx.id + ctx.count;
307
+ onError(err => error = err);
308
+ createMemo(() => res = props.children);
309
+ if (error) {
310
+ ctx.writeResource(id, error, true);
311
+ setHydrateContext({ ...ctx,
312
+ count: 0
313
+ });
314
+ const f = props.fallback;
315
+ return typeof f === "function" && f.length ? f(error, () => {}) : f;
316
+ }
317
+ return res;
290
318
  }
291
319
  const SuspenseContext = createContext();
292
320
  let resourceContext = null;
@@ -306,6 +334,7 @@ function createResource(fn, fetcher, options = {}) {
306
334
  let resource = {};
307
335
  let value = options.initialValue;
308
336
  let p;
337
+ let error;
309
338
  if (sharedConfig.context.async) {
310
339
  resource = sharedConfig.context.resources[id] || (sharedConfig.context.resources[id] = {});
311
340
  if (resource.ref) {
@@ -314,9 +343,10 @@ function createResource(fn, fetcher, options = {}) {
314
343
  }
315
344
  }
316
345
  const read = () => {
346
+ if (error) throw error;
317
347
  if (resourceContext && p) resourceContext.push(p);
318
348
  const resolved = sharedConfig.context.async && sharedConfig.context.resources[id].data;
319
- if (sharedConfig.context.async && !resolved) {
349
+ if (!resolved) {
320
350
  const ctx = useContext(SuspenseContext);
321
351
  if (ctx) {
322
352
  ctx.resources.set(id, read);
@@ -328,7 +358,7 @@ function createResource(fn, fetcher, options = {}) {
328
358
  read.loading = false;
329
359
  function load() {
330
360
  const ctx = sharedConfig.context;
331
- if (!ctx.async && !ctx.streaming) return;
361
+ if (!ctx.async) return read.loading = true;
332
362
  if (ctx.resources && id in ctx.resources && ctx.resources[id].data) {
333
363
  value = ctx.resources[id].data;
334
364
  return;
@@ -345,21 +375,18 @@ function createResource(fn, fetcher, options = {}) {
345
375
  }
346
376
  read.loading = true;
347
377
  if ("then" in p) {
348
- if (ctx.writeResource) {
349
- ctx.writeResource(id, p);
350
- p.then(v => {
351
- value = v;
352
- read.loading = false;
353
- p = null;
354
- });
355
- return;
356
- }
378
+ if (ctx.writeResource) ctx.writeResource(id, p);
357
379
  p.then(res => {
358
380
  read.loading = false;
359
381
  ctx.resources[id].data = res;
360
382
  p = null;
361
383
  notifySuspense(contexts);
362
384
  return res;
385
+ }).catch(err => {
386
+ read.loading = false;
387
+ error = err;
388
+ p = null;
389
+ notifySuspense(contexts);
363
390
  });
364
391
  return;
365
392
  }
@@ -388,7 +415,7 @@ function lazy(fn) {
388
415
  ctx.resources.set(id, track);
389
416
  contexts.add(ctx);
390
417
  }
391
- p.then(() => {
418
+ if (sharedConfig.context.async) p.then(() => {
392
419
  track.loading = false;
393
420
  notifySuspense(contexts);
394
421
  });
@@ -421,19 +448,15 @@ function useTransition() {
421
448
  function SuspenseList(props) {
422
449
  return props.children;
423
450
  }
424
- const SUSPENSE_GLOBAL = Symbol("suspense-global");
425
451
  function Suspense(props) {
452
+ let done;
426
453
  const ctx = sharedConfig.context;
427
- if (!ctx.async) return createComponent(() => {
428
- props.children;
429
- return props.fallback;
430
- }, {});
431
454
  const id = ctx.id + ctx.count;
432
- const done = ctx.async ? lookup(Owner, SUSPENSE_GLOBAL)(id) : () => {};
433
455
  const o = Owner;
434
456
  const value = ctx.suspense[id] || (ctx.suspense[id] = {
435
457
  resources: new Map(),
436
458
  completed: () => {
459
+ if (ctx.dataOnly) return done();
437
460
  const res = runSuspense();
438
461
  if (suspenseComplete(value)) {
439
462
  done(resolveSSRNode(res));
@@ -454,44 +477,29 @@ function Suspense(props) {
454
477
  });
455
478
  }
456
479
  const res = runSuspense();
457
- if (suspenseComplete(value)) {
458
- done();
459
- return res;
460
- }
461
- return sharedConfig.context.async ? {
462
- t: `<#${id}#>`
463
- } : props.fallback;
464
- }
465
- const SUSPENSE_REPLACE = /<#([\d.]+)#>/;
466
- function awaitSuspense(fn) {
467
- return new Promise(resolve => {
468
- const registry = new Set();
469
- const cache = Object.create(null);
470
- const res = createMemo(() => {
471
- Owner.context = {
472
- [SUSPENSE_GLOBAL]: getCallback
473
- };
474
- return fn();
475
- });
476
- if (!registry.size) resolve(res());
477
- function getCallback(key) {
478
- registry.add(key);
479
- return value => {
480
- if (value) cache[key] = value;
481
- registry.delete(key);
482
- if (!registry.size) Promise.resolve().then(() => {
483
- let source = resolveSSRNode(res());
484
- let final = "";
485
- let match;
486
- while (match = source.match(SUSPENSE_REPLACE)) {
487
- final += source.substring(0, match.index);
488
- source = cache[match[1]] + source.substring(match.index + match[0].length);
489
- }
490
- resolve(final + source);
491
- });
480
+ if (suspenseComplete(value)) return res;
481
+ onError(err => {
482
+ if (!done || !done(undefined, err)) throw err;
483
+ });
484
+ done = ctx.async ? ctx.registerFragment(id) : undefined;
485
+ if (ctx.streaming) {
486
+ if (!ctx.dataOnly) {
487
+ setHydrateContext(undefined);
488
+ const res = {
489
+ t: `<span id="pl${id}">${resolveSSRNode(props.fallback)}</span>`
492
490
  };
491
+ setHydrateContext(ctx);
492
+ return res;
493
493
  }
494
+ } else if (ctx.async) {
495
+ return {
496
+ t: `<![${id}]>`
497
+ };
498
+ }
499
+ setHydrateContext({ ...ctx,
500
+ count: 0
494
501
  });
502
+ return createComponent(() => props.fallback, {});
495
503
  }
496
504
 
497
- export { $PROXY, DEV, ErrorBoundary, For, Index, Match, Show, Suspense, SuspenseList, Switch, awaitSuspense, batch, children, createComponent, createComputed, createContext, createDeferred, createEffect, createMemo, createRenderEffect, createResource, createRoot, createSelector, createSignal, createUniqueId, enableScheduling, equalFn, from, getListener, getOwner, lazy, mapArray, mergeProps, observable, on, onCleanup, onError, onMount, requestCallback, runWithOwner, sharedConfig, splitProps, startTransition, untrack, useContext, useTransition };
505
+ export { $PROXY, DEV, ErrorBoundary, For, Index, Match, Show, Suspense, SuspenseList, Switch, batch, children, createComponent, createComputed, createContext, createDeferred, createEffect, createMemo, createRenderEffect, createResource, createRoot, createSelector, createSignal, createUniqueId, enableScheduling, equalFn, from, getListener, getOwner, lazy, mapArray, mergeProps, observable, on, onCleanup, onError, onMount, requestCallback, runWithOwner, sharedConfig, splitProps, startTransition, untrack, useContext, useTransition };
package/dist/solid.cjs CHANGED
@@ -184,12 +184,13 @@ function createSignal(value, options) {
184
184
  pending: NOTPENDING,
185
185
  comparator: options.equals || undefined
186
186
  };
187
- return [readSignal.bind(s), value => {
187
+ const setter = value => {
188
188
  if (typeof value === "function") {
189
189
  if (Transition && Transition.running && Transition.sources.has(s)) value = value(s.pending !== NOTPENDING ? s.pending : s.tValue);else value = value(s.pending !== NOTPENDING ? s.pending : s.value);
190
190
  }
191
191
  return writeSignal(s, value);
192
- }];
192
+ };
193
+ return [readSignal.bind(s), setter];
193
194
  }
194
195
  function createComputed(fn, value, options) {
195
196
  const c = createComputation(fn, value, true, STALE);
@@ -246,12 +247,7 @@ function createResource(source, fetcher, options) {
246
247
  dynamic = typeof source === "function";
247
248
  if (sharedConfig.context) {
248
249
  id = `${sharedConfig.context.id}${sharedConfig.context.count++}`;
249
- if (sharedConfig.context.loadResource) {
250
- initP = sharedConfig.context.loadResource(id);
251
- } else if (sharedConfig.resources && id && id in sharedConfig.resources) {
252
- initP = sharedConfig.resources[id];
253
- delete sharedConfig.resources[id];
254
- }
250
+ if (sharedConfig.load) initP = sharedConfig.load(id);
255
251
  }
256
252
  function loadEnd(p, v, e) {
257
253
  if (pr === p) {
@@ -355,7 +351,7 @@ function createSelector(source, fn = equalFn, options) {
355
351
  const subs = new Map();
356
352
  const node = createComputation(p => {
357
353
  const v = source();
358
- for (const key of subs.keys()) if (fn(key, v) || p !== undefined && fn(key, p)) {
354
+ for (const key of subs.keys()) if (fn(key, v) !== (p !== undefined && fn(key, p))) {
359
355
  const l = subs.get(key);
360
356
  for (const c of l.values()) {
361
357
  c.state = STALE;
@@ -406,7 +402,8 @@ function untrack(fn) {
406
402
  Listener = listener;
407
403
  return result;
408
404
  }
409
- function on(deps, fn, options) {
405
+ function on(deps, fn,
406
+ options) {
410
407
  const isArray = Array.isArray(deps);
411
408
  let prevInput;
412
409
  let defer = options && options.defer;
@@ -659,7 +656,7 @@ function runTop(node) {
659
656
  } else if (!runningTransition && node.state === PENDING || runningTransition && node.tState === PENDING) {
660
657
  const updates = Updates;
661
658
  Updates = null;
662
- lookDownstream(node);
659
+ lookDownstream(node, ancestors[0]);
663
660
  Updates = updates;
664
661
  }
665
662
  }
@@ -757,13 +754,15 @@ function runUserEffects(queue) {
757
754
  for (i = 0; i < userLength; i++) runTop(queue[i]);
758
755
  for (i = resume; i < queue.length; i++) runTop(queue[i]);
759
756
  }
760
- function lookDownstream(node) {
757
+ function lookDownstream(node, ignore) {
761
758
  node.state = 0;
762
759
  const runningTransition = Transition && Transition.running;
763
760
  for (let i = 0; i < node.sources.length; i += 1) {
764
761
  const source = node.sources[i];
765
762
  if (source.sources) {
766
- if (!runningTransition && source.state === STALE || runningTransition && source.tState === STALE) runTop(source);else if (!runningTransition && source.state === PENDING || runningTransition && source.tState === PENDING) lookDownstream(source);
763
+ if (!runningTransition && source.state === STALE || runningTransition && source.tState === STALE) {
764
+ if (source !== ignore) runTop(source);
765
+ } else if (!runningTransition && source.state === PENDING || runningTransition && source.tState === PENDING) lookDownstream(source, ignore);
767
766
  }
768
767
  }
769
768
  }
@@ -1161,7 +1160,7 @@ function lazy(fn) {
1161
1160
  let comp;
1162
1161
  const wrap = props => {
1163
1162
  const ctx = sharedConfig.context;
1164
- if (ctx && sharedConfig.resources) {
1163
+ if (ctx) {
1165
1164
  ctx.count++;
1166
1165
  const [s, set] = createSignal();
1167
1166
  fn().then(mod => {
@@ -1234,7 +1233,7 @@ function Switch(props) {
1234
1233
  }
1235
1234
  return [-1];
1236
1235
  }, undefined, {
1237
- equals: (a, b) => a && a[0] === b[0] && (strictEqual ? a[1] === b[1] : !a[1] === !b[1]) && a[2] === b[2]
1236
+ equals: (a, b) => a[0] === b[0] && (strictEqual ? a[1] === b[1] : !a[1] === !b[1]) && a[2] === b[2]
1238
1237
  });
1239
1238
  return createMemo(() => {
1240
1239
  const [index, when, cond] = evalConditions();
@@ -1247,7 +1246,11 @@ function Match(props) {
1247
1246
  return props;
1248
1247
  }
1249
1248
  function ErrorBoundary(props) {
1250
- const [errored, setErrored] = createSignal();
1249
+ let err = undefined;
1250
+ if (sharedConfig.context && sharedConfig.load) {
1251
+ err = sharedConfig.load(sharedConfig.context.id + sharedConfig.context.count);
1252
+ }
1253
+ const [errored, setErrored] = createSignal(err);
1251
1254
  let e;
1252
1255
  return createMemo(() => {
1253
1256
  if ((e = errored()) != null) {
@@ -1328,7 +1331,11 @@ function SuspenseList(props) {
1328
1331
  function Suspense(props) {
1329
1332
  let counter = 0,
1330
1333
  showContent,
1331
- showFallback;
1334
+ showFallback,
1335
+ ctx,
1336
+ waitingHydration,
1337
+ flicker,
1338
+ error;
1332
1339
  const [inFallback, setFallback] = createSignal(false),
1333
1340
  SuspenseContext = getSuspenseContext(),
1334
1341
  store = {
@@ -1343,6 +1350,25 @@ function Suspense(props) {
1343
1350
  resolved: false
1344
1351
  },
1345
1352
  owner = getOwner();
1353
+ if (sharedConfig.context) {
1354
+ const key = sharedConfig.context.id + sharedConfig.context.count;
1355
+ const p = sharedConfig.load(key);
1356
+ if (p) {
1357
+ const [s, set] = createSignal(undefined, {
1358
+ equals: false
1359
+ });
1360
+ flicker = s;
1361
+ p.then(err => {
1362
+ if (error = err) return set();
1363
+ sharedConfig.gather(key);
1364
+ waitingHydration = true;
1365
+ setHydrateContext(ctx);
1366
+ set();
1367
+ setHydrateContext(undefined);
1368
+ waitingHydration = false;
1369
+ });
1370
+ }
1371
+ }
1346
1372
  const listContext = useContext(SuspenseListContext);
1347
1373
  if (listContext) [showContent, showFallback] = listContext.register(store.inFallback);
1348
1374
  let dispose;
@@ -1350,28 +1376,36 @@ function Suspense(props) {
1350
1376
  return createComponent(SuspenseContext.Provider, {
1351
1377
  value: store,
1352
1378
  get children() {
1353
- const rendered = untrack(() => props.children);
1354
1379
  return createMemo(() => {
1355
- const inFallback = store.inFallback(),
1356
- visibleContent = showContent ? showContent() : true,
1357
- visibleFallback = showFallback ? showFallback() : true;
1358
- dispose && dispose();
1359
- if (!inFallback && visibleContent) {
1360
- store.resolved = true;
1361
- resumeEffects(store.effects);
1362
- return rendered;
1380
+ if (error) throw error;
1381
+ if (flicker) {
1382
+ ctx = sharedConfig.context;
1383
+ flicker();
1384
+ return flicker = undefined;
1363
1385
  }
1364
- if (!visibleFallback) return;
1365
- return createRoot(disposer => {
1366
- dispose = disposer;
1367
- return props.fallback;
1368
- }, owner);
1386
+ const rendered = untrack(() => props.children);
1387
+ return createMemo(() => {
1388
+ const inFallback = store.inFallback(),
1389
+ visibleContent = showContent ? showContent() : true,
1390
+ visibleFallback = showFallback ? showFallback() : true;
1391
+ dispose && dispose();
1392
+ if ((!inFallback || waitingHydration) && visibleContent) {
1393
+ store.resolved = true;
1394
+ resumeEffects(store.effects);
1395
+ return rendered;
1396
+ }
1397
+ if (!visibleFallback) return;
1398
+ return createRoot(disposer => {
1399
+ dispose = disposer;
1400
+ if (sharedConfig.context) sharedConfig.context.count = 0;
1401
+ return props.fallback;
1402
+ }, owner);
1403
+ });
1369
1404
  });
1370
1405
  }
1371
1406
  });
1372
1407
  }
1373
1408
 
1374
- function awaitSuspense() {}
1375
1409
  let DEV;
1376
1410
 
1377
1411
  exports.$PROXY = $PROXY;
@@ -1384,7 +1418,6 @@ exports.Show = Show;
1384
1418
  exports.Suspense = Suspense;
1385
1419
  exports.SuspenseList = SuspenseList;
1386
1420
  exports.Switch = Switch;
1387
- exports.awaitSuspense = awaitSuspense;
1388
1421
  exports.batch = batch;
1389
1422
  exports.cancelCallback = cancelCallback;
1390
1423
  exports.children = children;
package/dist/solid.js CHANGED
@@ -180,12 +180,13 @@ function createSignal(value, options) {
180
180
  pending: NOTPENDING,
181
181
  comparator: options.equals || undefined
182
182
  };
183
- return [readSignal.bind(s), value => {
183
+ const setter = value => {
184
184
  if (typeof value === "function") {
185
185
  if (Transition && Transition.running && Transition.sources.has(s)) value = value(s.pending !== NOTPENDING ? s.pending : s.tValue);else value = value(s.pending !== NOTPENDING ? s.pending : s.value);
186
186
  }
187
187
  return writeSignal(s, value);
188
- }];
188
+ };
189
+ return [readSignal.bind(s), setter];
189
190
  }
190
191
  function createComputed(fn, value, options) {
191
192
  const c = createComputation(fn, value, true, STALE);
@@ -242,12 +243,7 @@ function createResource(source, fetcher, options) {
242
243
  dynamic = typeof source === "function";
243
244
  if (sharedConfig.context) {
244
245
  id = `${sharedConfig.context.id}${sharedConfig.context.count++}`;
245
- if (sharedConfig.context.loadResource) {
246
- initP = sharedConfig.context.loadResource(id);
247
- } else if (sharedConfig.resources && id && id in sharedConfig.resources) {
248
- initP = sharedConfig.resources[id];
249
- delete sharedConfig.resources[id];
250
- }
246
+ if (sharedConfig.load) initP = sharedConfig.load(id);
251
247
  }
252
248
  function loadEnd(p, v, e) {
253
249
  if (pr === p) {
@@ -351,7 +347,7 @@ function createSelector(source, fn = equalFn, options) {
351
347
  const subs = new Map();
352
348
  const node = createComputation(p => {
353
349
  const v = source();
354
- for (const key of subs.keys()) if (fn(key, v) || p !== undefined && fn(key, p)) {
350
+ for (const key of subs.keys()) if (fn(key, v) !== (p !== undefined && fn(key, p))) {
355
351
  const l = subs.get(key);
356
352
  for (const c of l.values()) {
357
353
  c.state = STALE;
@@ -402,7 +398,8 @@ function untrack(fn) {
402
398
  Listener = listener;
403
399
  return result;
404
400
  }
405
- function on(deps, fn, options) {
401
+ function on(deps, fn,
402
+ options) {
406
403
  const isArray = Array.isArray(deps);
407
404
  let prevInput;
408
405
  let defer = options && options.defer;
@@ -655,7 +652,7 @@ function runTop(node) {
655
652
  } else if (!runningTransition && node.state === PENDING || runningTransition && node.tState === PENDING) {
656
653
  const updates = Updates;
657
654
  Updates = null;
658
- lookDownstream(node);
655
+ lookDownstream(node, ancestors[0]);
659
656
  Updates = updates;
660
657
  }
661
658
  }
@@ -753,13 +750,15 @@ function runUserEffects(queue) {
753
750
  for (i = 0; i < userLength; i++) runTop(queue[i]);
754
751
  for (i = resume; i < queue.length; i++) runTop(queue[i]);
755
752
  }
756
- function lookDownstream(node) {
753
+ function lookDownstream(node, ignore) {
757
754
  node.state = 0;
758
755
  const runningTransition = Transition && Transition.running;
759
756
  for (let i = 0; i < node.sources.length; i += 1) {
760
757
  const source = node.sources[i];
761
758
  if (source.sources) {
762
- if (!runningTransition && source.state === STALE || runningTransition && source.tState === STALE) runTop(source);else if (!runningTransition && source.state === PENDING || runningTransition && source.tState === PENDING) lookDownstream(source);
759
+ if (!runningTransition && source.state === STALE || runningTransition && source.tState === STALE) {
760
+ if (source !== ignore) runTop(source);
761
+ } else if (!runningTransition && source.state === PENDING || runningTransition && source.tState === PENDING) lookDownstream(source, ignore);
763
762
  }
764
763
  }
765
764
  }
@@ -1157,7 +1156,7 @@ function lazy(fn) {
1157
1156
  let comp;
1158
1157
  const wrap = props => {
1159
1158
  const ctx = sharedConfig.context;
1160
- if (ctx && sharedConfig.resources) {
1159
+ if (ctx) {
1161
1160
  ctx.count++;
1162
1161
  const [s, set] = createSignal();
1163
1162
  fn().then(mod => {
@@ -1230,7 +1229,7 @@ function Switch(props) {
1230
1229
  }
1231
1230
  return [-1];
1232
1231
  }, undefined, {
1233
- equals: (a, b) => a && a[0] === b[0] && (strictEqual ? a[1] === b[1] : !a[1] === !b[1]) && a[2] === b[2]
1232
+ equals: (a, b) => a[0] === b[0] && (strictEqual ? a[1] === b[1] : !a[1] === !b[1]) && a[2] === b[2]
1234
1233
  });
1235
1234
  return createMemo(() => {
1236
1235
  const [index, when, cond] = evalConditions();
@@ -1243,7 +1242,11 @@ function Match(props) {
1243
1242
  return props;
1244
1243
  }
1245
1244
  function ErrorBoundary(props) {
1246
- const [errored, setErrored] = createSignal();
1245
+ let err = undefined;
1246
+ if (sharedConfig.context && sharedConfig.load) {
1247
+ err = sharedConfig.load(sharedConfig.context.id + sharedConfig.context.count);
1248
+ }
1249
+ const [errored, setErrored] = createSignal(err);
1247
1250
  let e;
1248
1251
  return createMemo(() => {
1249
1252
  if ((e = errored()) != null) {
@@ -1324,7 +1327,11 @@ function SuspenseList(props) {
1324
1327
  function Suspense(props) {
1325
1328
  let counter = 0,
1326
1329
  showContent,
1327
- showFallback;
1330
+ showFallback,
1331
+ ctx,
1332
+ waitingHydration,
1333
+ flicker,
1334
+ error;
1328
1335
  const [inFallback, setFallback] = createSignal(false),
1329
1336
  SuspenseContext = getSuspenseContext(),
1330
1337
  store = {
@@ -1339,6 +1346,25 @@ function Suspense(props) {
1339
1346
  resolved: false
1340
1347
  },
1341
1348
  owner = getOwner();
1349
+ if (sharedConfig.context) {
1350
+ const key = sharedConfig.context.id + sharedConfig.context.count;
1351
+ const p = sharedConfig.load(key);
1352
+ if (p) {
1353
+ const [s, set] = createSignal(undefined, {
1354
+ equals: false
1355
+ });
1356
+ flicker = s;
1357
+ p.then(err => {
1358
+ if (error = err) return set();
1359
+ sharedConfig.gather(key);
1360
+ waitingHydration = true;
1361
+ setHydrateContext(ctx);
1362
+ set();
1363
+ setHydrateContext(undefined);
1364
+ waitingHydration = false;
1365
+ });
1366
+ }
1367
+ }
1342
1368
  const listContext = useContext(SuspenseListContext);
1343
1369
  if (listContext) [showContent, showFallback] = listContext.register(store.inFallback);
1344
1370
  let dispose;
@@ -1346,28 +1372,36 @@ function Suspense(props) {
1346
1372
  return createComponent(SuspenseContext.Provider, {
1347
1373
  value: store,
1348
1374
  get children() {
1349
- const rendered = untrack(() => props.children);
1350
1375
  return createMemo(() => {
1351
- const inFallback = store.inFallback(),
1352
- visibleContent = showContent ? showContent() : true,
1353
- visibleFallback = showFallback ? showFallback() : true;
1354
- dispose && dispose();
1355
- if (!inFallback && visibleContent) {
1356
- store.resolved = true;
1357
- resumeEffects(store.effects);
1358
- return rendered;
1376
+ if (error) throw error;
1377
+ if (flicker) {
1378
+ ctx = sharedConfig.context;
1379
+ flicker();
1380
+ return flicker = undefined;
1359
1381
  }
1360
- if (!visibleFallback) return;
1361
- return createRoot(disposer => {
1362
- dispose = disposer;
1363
- return props.fallback;
1364
- }, owner);
1382
+ const rendered = untrack(() => props.children);
1383
+ return createMemo(() => {
1384
+ const inFallback = store.inFallback(),
1385
+ visibleContent = showContent ? showContent() : true,
1386
+ visibleFallback = showFallback ? showFallback() : true;
1387
+ dispose && dispose();
1388
+ if ((!inFallback || waitingHydration) && visibleContent) {
1389
+ store.resolved = true;
1390
+ resumeEffects(store.effects);
1391
+ return rendered;
1392
+ }
1393
+ if (!visibleFallback) return;
1394
+ return createRoot(disposer => {
1395
+ dispose = disposer;
1396
+ if (sharedConfig.context) sharedConfig.context.count = 0;
1397
+ return props.fallback;
1398
+ }, owner);
1399
+ });
1365
1400
  });
1366
1401
  }
1367
1402
  });
1368
1403
  }
1369
1404
 
1370
- function awaitSuspense() {}
1371
1405
  let DEV;
1372
1406
 
1373
- export { $PROXY, DEV, ErrorBoundary, For, Index, Match, Show, Suspense, SuspenseList, Switch, awaitSuspense, batch, cancelCallback, children, createComponent, createComputed, createContext, createDeferred, createEffect, createMemo, createRenderEffect, createResource, createRoot, createSelector, createSignal, createUniqueId, enableScheduling, equalFn, from, getListener, getOwner, indexArray, lazy, mapArray, mergeProps, observable, on, onCleanup, onError, onMount, requestCallback, runWithOwner, sharedConfig, splitProps, startTransition, untrack, useContext, useTransition };
1407
+ export { $PROXY, DEV, ErrorBoundary, For, Index, Match, Show, Suspense, SuspenseList, Switch, batch, cancelCallback, children, createComponent, createComputed, createContext, createDeferred, createEffect, createMemo, createRenderEffect, createResource, createRoot, createSelector, createSignal, createUniqueId, enableScheduling, equalFn, from, getListener, getOwner, indexArray, lazy, mapArray, mergeProps, observable, on, onCleanup, onError, onMount, requestCallback, runWithOwner, sharedConfig, splitProps, startTransition, untrack, useContext, useTransition };
package/package.json CHANGED
@@ -1,10 +1,10 @@
1
1
  {
2
2
  "name": "solid-js",
3
3
  "description": "A declarative JavaScript library for building user interfaces.",
4
- "version": "1.2.6",
4
+ "version": "1.3.0-beta.3",
5
5
  "author": "Ryan Carniato",
6
6
  "license": "MIT",
7
- "homepage": "https://github.com/solidjs/solid#readme",
7
+ "homepage": "https://solidjs.com",
8
8
  "repository": {
9
9
  "type": "git",
10
10
  "url": "https://github.com/solidjs/solid"
@@ -132,5 +132,5 @@
132
132
  "compiler",
133
133
  "performance"
134
134
  ],
135
- "gitHead": "bbdf3c645de60be9ef569199c4357f2836024149"
135
+ "gitHead": "cc2f8e5d0a8916ee1d4512de541268d8dcd45032"
136
136
  }
package/types/index.d.ts CHANGED
@@ -7,7 +7,6 @@ export * from "./render";
7
7
  import type { JSX } from "./jsx";
8
8
  declare type JSXElement = JSX.Element;
9
9
  export type { JSXElement, JSX };
10
- export declare function awaitSuspense(): void;
11
10
  import { writeSignal, serializeGraph, registerGraph, hashValue } from "./reactive/signal";
12
11
  declare let DEV: {
13
12
  writeSignal: typeof writeSignal;