solid-js 1.2.2 → 1.3.0-beta.0

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
@@ -187,18 +187,21 @@ function createSignal(value, options) {
187
187
  comparator: options.equals || undefined
188
188
  };
189
189
  if (!options.internal) s.name = registerGraph(options.name || hashValue(value), s);
190
- return [readSignal.bind(s), value => {
190
+ const setter = value => {
191
191
  if (typeof value === "function") {
192
192
  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);
193
193
  }
194
194
  return writeSignal(s, value);
195
- }];
195
+ };
196
+ return [readSignal.bind(s), setter];
196
197
  }
197
198
  function createComputed(fn, value, options) {
198
- updateComputation(createComputation(fn, value, true, STALE, options ));
199
+ const c = createComputation(fn, value, true, STALE, options );
200
+ if (Scheduler && Transition && Transition.running) Updates.push(c);else updateComputation(c);
199
201
  }
200
202
  function createRenderEffect(fn, value, options) {
201
- updateComputation(createComputation(fn, value, false, STALE, options ));
203
+ const c = createComputation(fn, value, false, STALE, options );
204
+ if (Scheduler && Transition && Transition.running) Updates.push(c);else updateComputation(c);
202
205
  }
203
206
  function createEffect(fn, value, options) {
204
207
  runEffects = runUserEffects;
@@ -215,7 +218,10 @@ function createMemo(fn, value, options) {
215
218
  c.observers = null;
216
219
  c.observerSlots = null;
217
220
  c.comparator = options.equals || undefined;
218
- updateComputation(c);
221
+ if (Scheduler && Transition && Transition.running) {
222
+ c.tState = STALE;
223
+ Updates.push(c);
224
+ } else updateComputation(c);
219
225
  return readSignal.bind(c);
220
226
  }
221
227
  function createResource(source, fetcher, options) {
@@ -244,12 +250,7 @@ function createResource(source, fetcher, options) {
244
250
  dynamic = typeof source === "function";
245
251
  if (sharedConfig.context) {
246
252
  id = `${sharedConfig.context.id}${sharedConfig.context.count++}`;
247
- if (sharedConfig.context.loadResource) {
248
- initP = sharedConfig.context.loadResource(id);
249
- } else if (sharedConfig.resources && id && id in sharedConfig.resources) {
250
- initP = sharedConfig.resources[id];
251
- delete sharedConfig.resources[id];
252
- }
253
+ if (sharedConfig.load) initP = sharedConfig.load(id);
253
254
  }
254
255
  function loadEnd(p, v, e) {
255
256
  if (pr === p) {
@@ -404,7 +405,8 @@ function untrack(fn) {
404
405
  Listener = listener;
405
406
  return result;
406
407
  }
407
- function on(deps, fn, options) {
408
+ function on(deps, fn,
409
+ options) {
408
410
  const isArray = Array.isArray(deps);
409
411
  let prevInput;
410
412
  let defer = options && options.defer;
@@ -1207,6 +1209,9 @@ function splitProps(props, ...keys) {
1207
1209
  Object.defineProperty(clone, key, descriptors[key] ? descriptors[key] : {
1208
1210
  get() {
1209
1211
  return props[key];
1212
+ },
1213
+ set() {
1214
+ return true;
1210
1215
  }
1211
1216
  });
1212
1217
  }
@@ -1229,7 +1234,7 @@ function lazy(fn) {
1229
1234
  let comp;
1230
1235
  const wrap = props => {
1231
1236
  const ctx = sharedConfig.context;
1232
- if (ctx && sharedConfig.resources) {
1237
+ if (ctx) {
1233
1238
  ctx.count++;
1234
1239
  const [s, set] = createSignal();
1235
1240
  fn().then(mod => {
@@ -1302,7 +1307,7 @@ function Switch(props) {
1302
1307
  }
1303
1308
  return [-1];
1304
1309
  }, undefined, {
1305
- equals: (a, b) => a && a[0] === b[0] && (strictEqual ? a[1] === b[1] : !a[1] === !b[1]) && a[2] === b[2]
1310
+ equals: (a, b) => a[0] === b[0] && (strictEqual ? a[1] === b[1] : !a[1] === !b[1]) && a[2] === b[2]
1306
1311
  });
1307
1312
  return createMemo(() => {
1308
1313
  const [index, when, cond] = evalConditions();
@@ -1396,7 +1401,10 @@ function SuspenseList(props) {
1396
1401
  function Suspense(props) {
1397
1402
  let counter = 0,
1398
1403
  showContent,
1399
- showFallback;
1404
+ showFallback,
1405
+ ctx,
1406
+ waitingHydration,
1407
+ flicker;
1400
1408
  const [inFallback, setFallback] = createSignal(false),
1401
1409
  SuspenseContext = getSuspenseContext(),
1402
1410
  store = {
@@ -1409,30 +1417,62 @@ function Suspense(props) {
1409
1417
  inFallback,
1410
1418
  effects: [],
1411
1419
  resolved: false
1412
- };
1420
+ },
1421
+ owner = getOwner();
1422
+ if (sharedConfig.context && sharedConfig.load) {
1423
+ const key = sharedConfig.context.id + sharedConfig.context.count;
1424
+ const p = sharedConfig.load(key);
1425
+ if (p) {
1426
+ const [s, set] = createSignal(undefined, {
1427
+ equals: false
1428
+ });
1429
+ flicker = s;
1430
+ p.then(() => {
1431
+ sharedConfig.gather(key);
1432
+ waitingHydration = true;
1433
+ setHydrateContext(ctx);
1434
+ set();
1435
+ setHydrateContext(undefined);
1436
+ waitingHydration = false;
1437
+ });
1438
+ }
1439
+ }
1413
1440
  const listContext = useContext(SuspenseListContext);
1414
1441
  if (listContext) [showContent, showFallback] = listContext.register(store.inFallback);
1442
+ let dispose;
1443
+ onCleanup(() => dispose && dispose());
1415
1444
  return createComponent(SuspenseContext.Provider, {
1416
1445
  value: store,
1417
1446
  get children() {
1418
- const rendered = untrack(() => props.children);
1419
1447
  return createMemo(() => {
1420
- const inFallback = store.inFallback(),
1421
- visibleContent = showContent ? showContent() : true,
1422
- visibleFallback = showFallback ? showFallback() : true;
1423
- if (!inFallback && visibleContent) {
1424
- store.resolved = true;
1425
- resumeEffects(store.effects);
1426
- return rendered;
1448
+ if (flicker) {
1449
+ ctx = sharedConfig.context;
1450
+ flicker();
1451
+ return flicker = undefined;
1427
1452
  }
1428
- if (!visibleFallback) return;
1429
- return props.fallback;
1453
+ const rendered = untrack(() => props.children);
1454
+ return createMemo(() => {
1455
+ const inFallback = store.inFallback(),
1456
+ visibleContent = showContent ? showContent() : true,
1457
+ visibleFallback = showFallback ? showFallback() : true;
1458
+ dispose && dispose();
1459
+ if ((!inFallback || waitingHydration) && visibleContent) {
1460
+ store.resolved = true;
1461
+ resumeEffects(store.effects);
1462
+ return rendered;
1463
+ }
1464
+ if (!visibleFallback) return;
1465
+ return createRoot(disposer => {
1466
+ dispose = disposer;
1467
+ if (sharedConfig.context) sharedConfig.context.count = 0;
1468
+ return props.fallback;
1469
+ }, owner);
1470
+ });
1430
1471
  });
1431
1472
  }
1432
1473
  });
1433
1474
  }
1434
1475
 
1435
- function awaitSuspense() {}
1436
1476
  exports.DEV = void 0;
1437
1477
  {
1438
1478
  exports.DEV = {
@@ -1455,7 +1495,6 @@ exports.Show = Show;
1455
1495
  exports.Suspense = Suspense;
1456
1496
  exports.SuspenseList = SuspenseList;
1457
1497
  exports.Switch = Switch;
1458
- exports.awaitSuspense = awaitSuspense;
1459
1498
  exports.batch = batch;
1460
1499
  exports.cancelCallback = cancelCallback;
1461
1500
  exports.children = children;
package/dist/dev.js CHANGED
@@ -183,18 +183,21 @@ function createSignal(value, options) {
183
183
  comparator: options.equals || undefined
184
184
  };
185
185
  if (!options.internal) s.name = registerGraph(options.name || hashValue(value), s);
186
- return [readSignal.bind(s), value => {
186
+ const setter = value => {
187
187
  if (typeof value === "function") {
188
188
  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);
189
189
  }
190
190
  return writeSignal(s, value);
191
- }];
191
+ };
192
+ return [readSignal.bind(s), setter];
192
193
  }
193
194
  function createComputed(fn, value, options) {
194
- updateComputation(createComputation(fn, value, true, STALE, options ));
195
+ const c = createComputation(fn, value, true, STALE, options );
196
+ if (Scheduler && Transition && Transition.running) Updates.push(c);else updateComputation(c);
195
197
  }
196
198
  function createRenderEffect(fn, value, options) {
197
- updateComputation(createComputation(fn, value, false, STALE, options ));
199
+ const c = createComputation(fn, value, false, STALE, options );
200
+ if (Scheduler && Transition && Transition.running) Updates.push(c);else updateComputation(c);
198
201
  }
199
202
  function createEffect(fn, value, options) {
200
203
  runEffects = runUserEffects;
@@ -211,7 +214,10 @@ function createMemo(fn, value, options) {
211
214
  c.observers = null;
212
215
  c.observerSlots = null;
213
216
  c.comparator = options.equals || undefined;
214
- updateComputation(c);
217
+ if (Scheduler && Transition && Transition.running) {
218
+ c.tState = STALE;
219
+ Updates.push(c);
220
+ } else updateComputation(c);
215
221
  return readSignal.bind(c);
216
222
  }
217
223
  function createResource(source, fetcher, options) {
@@ -240,12 +246,7 @@ function createResource(source, fetcher, options) {
240
246
  dynamic = typeof source === "function";
241
247
  if (sharedConfig.context) {
242
248
  id = `${sharedConfig.context.id}${sharedConfig.context.count++}`;
243
- if (sharedConfig.context.loadResource) {
244
- initP = sharedConfig.context.loadResource(id);
245
- } else if (sharedConfig.resources && id && id in sharedConfig.resources) {
246
- initP = sharedConfig.resources[id];
247
- delete sharedConfig.resources[id];
248
- }
249
+ if (sharedConfig.load) initP = sharedConfig.load(id);
249
250
  }
250
251
  function loadEnd(p, v, e) {
251
252
  if (pr === p) {
@@ -400,7 +401,8 @@ function untrack(fn) {
400
401
  Listener = listener;
401
402
  return result;
402
403
  }
403
- function on(deps, fn, options) {
404
+ function on(deps, fn,
405
+ options) {
404
406
  const isArray = Array.isArray(deps);
405
407
  let prevInput;
406
408
  let defer = options && options.defer;
@@ -1203,6 +1205,9 @@ function splitProps(props, ...keys) {
1203
1205
  Object.defineProperty(clone, key, descriptors[key] ? descriptors[key] : {
1204
1206
  get() {
1205
1207
  return props[key];
1208
+ },
1209
+ set() {
1210
+ return true;
1206
1211
  }
1207
1212
  });
1208
1213
  }
@@ -1225,7 +1230,7 @@ function lazy(fn) {
1225
1230
  let comp;
1226
1231
  const wrap = props => {
1227
1232
  const ctx = sharedConfig.context;
1228
- if (ctx && sharedConfig.resources) {
1233
+ if (ctx) {
1229
1234
  ctx.count++;
1230
1235
  const [s, set] = createSignal();
1231
1236
  fn().then(mod => {
@@ -1298,7 +1303,7 @@ function Switch(props) {
1298
1303
  }
1299
1304
  return [-1];
1300
1305
  }, undefined, {
1301
- equals: (a, b) => a && a[0] === b[0] && (strictEqual ? a[1] === b[1] : !a[1] === !b[1]) && a[2] === b[2]
1306
+ equals: (a, b) => a[0] === b[0] && (strictEqual ? a[1] === b[1] : !a[1] === !b[1]) && a[2] === b[2]
1302
1307
  });
1303
1308
  return createMemo(() => {
1304
1309
  const [index, when, cond] = evalConditions();
@@ -1392,7 +1397,10 @@ function SuspenseList(props) {
1392
1397
  function Suspense(props) {
1393
1398
  let counter = 0,
1394
1399
  showContent,
1395
- showFallback;
1400
+ showFallback,
1401
+ ctx,
1402
+ waitingHydration,
1403
+ flicker;
1396
1404
  const [inFallback, setFallback] = createSignal(false),
1397
1405
  SuspenseContext = getSuspenseContext(),
1398
1406
  store = {
@@ -1405,30 +1413,62 @@ function Suspense(props) {
1405
1413
  inFallback,
1406
1414
  effects: [],
1407
1415
  resolved: false
1408
- };
1416
+ },
1417
+ owner = getOwner();
1418
+ if (sharedConfig.context && sharedConfig.load) {
1419
+ const key = sharedConfig.context.id + sharedConfig.context.count;
1420
+ const p = sharedConfig.load(key);
1421
+ if (p) {
1422
+ const [s, set] = createSignal(undefined, {
1423
+ equals: false
1424
+ });
1425
+ flicker = s;
1426
+ p.then(() => {
1427
+ sharedConfig.gather(key);
1428
+ waitingHydration = true;
1429
+ setHydrateContext(ctx);
1430
+ set();
1431
+ setHydrateContext(undefined);
1432
+ waitingHydration = false;
1433
+ });
1434
+ }
1435
+ }
1409
1436
  const listContext = useContext(SuspenseListContext);
1410
1437
  if (listContext) [showContent, showFallback] = listContext.register(store.inFallback);
1438
+ let dispose;
1439
+ onCleanup(() => dispose && dispose());
1411
1440
  return createComponent(SuspenseContext.Provider, {
1412
1441
  value: store,
1413
1442
  get children() {
1414
- const rendered = untrack(() => props.children);
1415
1443
  return createMemo(() => {
1416
- const inFallback = store.inFallback(),
1417
- visibleContent = showContent ? showContent() : true,
1418
- visibleFallback = showFallback ? showFallback() : true;
1419
- if (!inFallback && visibleContent) {
1420
- store.resolved = true;
1421
- resumeEffects(store.effects);
1422
- return rendered;
1444
+ if (flicker) {
1445
+ ctx = sharedConfig.context;
1446
+ flicker();
1447
+ return flicker = undefined;
1423
1448
  }
1424
- if (!visibleFallback) return;
1425
- return props.fallback;
1449
+ const rendered = untrack(() => props.children);
1450
+ return createMemo(() => {
1451
+ const inFallback = store.inFallback(),
1452
+ visibleContent = showContent ? showContent() : true,
1453
+ visibleFallback = showFallback ? showFallback() : true;
1454
+ dispose && dispose();
1455
+ if ((!inFallback || waitingHydration) && visibleContent) {
1456
+ store.resolved = true;
1457
+ resumeEffects(store.effects);
1458
+ return rendered;
1459
+ }
1460
+ if (!visibleFallback) return;
1461
+ return createRoot(disposer => {
1462
+ dispose = disposer;
1463
+ if (sharedConfig.context) sharedConfig.context.count = 0;
1464
+ return props.fallback;
1465
+ }, owner);
1466
+ });
1426
1467
  });
1427
1468
  }
1428
1469
  });
1429
1470
  }
1430
1471
 
1431
- function awaitSuspense() {}
1432
1472
  let DEV;
1433
1473
  {
1434
1474
  DEV = {
@@ -1442,4 +1482,4 @@ if (globalThis) {
1442
1482
  if (!globalThis.Solid$$) globalThis.Solid$$ = true;else console.warn("You appear to have multiple instances of Solid. This can lead to unexpected behavior.");
1443
1483
  }
1444
1484
 
1445
- 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 };
1485
+ 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/dist/server.cjs CHANGED
@@ -219,7 +219,7 @@ function createUniqueId() {
219
219
  return `${ctx.id}${ctx.count++}`;
220
220
  }
221
221
  function createComponent(Comp, props) {
222
- if (sharedConfig.context) {
222
+ if (sharedConfig.context && !sharedConfig.context.noHydrate) {
223
223
  const c = sharedConfig.context;
224
224
  setHydrateContext(nextHydrateContext());
225
225
  const r = Comp(props);
@@ -320,7 +320,7 @@ function createResource(fn, fetcher, options = {}) {
320
320
  const read = () => {
321
321
  if (resourceContext && p) resourceContext.push(p);
322
322
  const resolved = sharedConfig.context.async && sharedConfig.context.resources[id].data;
323
- if (sharedConfig.context.async && !resolved) {
323
+ if (!resolved) {
324
324
  const ctx = useContext(SuspenseContext);
325
325
  if (ctx) {
326
326
  ctx.resources.set(id, read);
@@ -332,7 +332,7 @@ function createResource(fn, fetcher, options = {}) {
332
332
  read.loading = false;
333
333
  function load() {
334
334
  const ctx = sharedConfig.context;
335
- if (!ctx.async && !ctx.streaming) return;
335
+ if (!ctx.async) return read.loading = true;
336
336
  if (ctx.resources && id in ctx.resources && ctx.resources[id].data) {
337
337
  value = ctx.resources[id].data;
338
338
  return;
@@ -349,15 +349,7 @@ function createResource(fn, fetcher, options = {}) {
349
349
  }
350
350
  read.loading = true;
351
351
  if ("then" in p) {
352
- if (ctx.writeResource) {
353
- ctx.writeResource(id, p);
354
- p.then(v => {
355
- value = v;
356
- read.loading = false;
357
- p = null;
358
- });
359
- return;
360
- }
352
+ if (ctx.writeResource) ctx.writeResource(id, p);
361
353
  p.then(res => {
362
354
  read.loading = false;
363
355
  ctx.resources[id].data = res;
@@ -392,7 +384,7 @@ function lazy(fn) {
392
384
  ctx.resources.set(id, track);
393
385
  contexts.add(ctx);
394
386
  }
395
- p.then(() => {
387
+ if (sharedConfig.context.async) p.then(() => {
396
388
  track.loading = false;
397
389
  notifySuspense(contexts);
398
390
  });
@@ -425,15 +417,10 @@ function useTransition() {
425
417
  function SuspenseList(props) {
426
418
  return props.children;
427
419
  }
428
- const SUSPENSE_GLOBAL = Symbol("suspense-global");
429
420
  function Suspense(props) {
430
421
  const ctx = sharedConfig.context;
431
- if (!ctx.async) return createComponent(() => {
432
- props.children;
433
- return props.fallback;
434
- }, {});
435
422
  const id = ctx.id + ctx.count;
436
- const done = ctx.async ? lookup(Owner, SUSPENSE_GLOBAL)(id) : () => {};
423
+ const done = ctx.async ? ctx.registerFragment(id) : () => {};
437
424
  const o = Owner;
438
425
  const value = ctx.suspense[id] || (ctx.suspense[id] = {
439
426
  resources: new Map(),
@@ -462,40 +449,23 @@ function Suspense(props) {
462
449
  done();
463
450
  return res;
464
451
  }
465
- return sharedConfig.context.async ? {
466
- t: `<#${id}#>`
467
- } : props.fallback;
468
- }
469
- const SUSPENSE_REPLACE = /<#([\d.]+)#>/;
470
- function awaitSuspense(fn) {
471
- return new Promise(resolve => {
472
- const registry = new Set();
473
- const cache = Object.create(null);
474
- const res = createMemo(() => {
475
- Owner.context = {
476
- [SUSPENSE_GLOBAL]: getCallback
477
- };
478
- return fn();
479
- });
480
- if (!registry.size) resolve(res());
481
- function getCallback(key) {
482
- registry.add(key);
483
- return value => {
484
- if (value) cache[key] = value;
485
- registry.delete(key);
486
- if (!registry.size) Promise.resolve().then(() => {
487
- let source = resolveSSRNode(res());
488
- let final = "";
489
- let match;
490
- while (match = source.match(SUSPENSE_REPLACE)) {
491
- final += source.substring(0, match.index);
492
- source = cache[match[1]] + source.substring(match.index + match[0].length);
493
- }
494
- resolve(final + source);
495
- });
452
+ if (sharedConfig.context.async) {
453
+ if (sharedConfig.context.streaming) {
454
+ setHydrateContext(undefined);
455
+ const res = {
456
+ t: `<span id="pl${id}">${resolveSSRNode(props.fallback)}</span>`
496
457
  };
458
+ setHydrateContext(ctx);
459
+ return res;
497
460
  }
461
+ return {
462
+ t: `<![${id}]>`
463
+ };
464
+ }
465
+ setHydrateContext({ ...ctx,
466
+ count: 0
498
467
  });
468
+ return createComponent(() => props.fallback, {});
499
469
  }
500
470
 
501
471
  exports.$PROXY = $PROXY;
@@ -508,7 +478,6 @@ exports.Show = Show;
508
478
  exports.Suspense = Suspense;
509
479
  exports.SuspenseList = SuspenseList;
510
480
  exports.Switch = Switch;
511
- exports.awaitSuspense = awaitSuspense;
512
481
  exports.batch = batch;
513
482
  exports.children = children;
514
483
  exports.createComponent = createComponent;
package/dist/server.js CHANGED
@@ -215,7 +215,7 @@ function createUniqueId() {
215
215
  return `${ctx.id}${ctx.count++}`;
216
216
  }
217
217
  function createComponent(Comp, props) {
218
- if (sharedConfig.context) {
218
+ if (sharedConfig.context && !sharedConfig.context.noHydrate) {
219
219
  const c = sharedConfig.context;
220
220
  setHydrateContext(nextHydrateContext());
221
221
  const r = Comp(props);
@@ -316,7 +316,7 @@ function createResource(fn, fetcher, options = {}) {
316
316
  const read = () => {
317
317
  if (resourceContext && p) resourceContext.push(p);
318
318
  const resolved = sharedConfig.context.async && sharedConfig.context.resources[id].data;
319
- if (sharedConfig.context.async && !resolved) {
319
+ if (!resolved) {
320
320
  const ctx = useContext(SuspenseContext);
321
321
  if (ctx) {
322
322
  ctx.resources.set(id, read);
@@ -328,7 +328,7 @@ function createResource(fn, fetcher, options = {}) {
328
328
  read.loading = false;
329
329
  function load() {
330
330
  const ctx = sharedConfig.context;
331
- if (!ctx.async && !ctx.streaming) return;
331
+ if (!ctx.async) return read.loading = true;
332
332
  if (ctx.resources && id in ctx.resources && ctx.resources[id].data) {
333
333
  value = ctx.resources[id].data;
334
334
  return;
@@ -345,15 +345,7 @@ function createResource(fn, fetcher, options = {}) {
345
345
  }
346
346
  read.loading = true;
347
347
  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
- }
348
+ if (ctx.writeResource) ctx.writeResource(id, p);
357
349
  p.then(res => {
358
350
  read.loading = false;
359
351
  ctx.resources[id].data = res;
@@ -388,7 +380,7 @@ function lazy(fn) {
388
380
  ctx.resources.set(id, track);
389
381
  contexts.add(ctx);
390
382
  }
391
- p.then(() => {
383
+ if (sharedConfig.context.async) p.then(() => {
392
384
  track.loading = false;
393
385
  notifySuspense(contexts);
394
386
  });
@@ -421,15 +413,10 @@ function useTransition() {
421
413
  function SuspenseList(props) {
422
414
  return props.children;
423
415
  }
424
- const SUSPENSE_GLOBAL = Symbol("suspense-global");
425
416
  function Suspense(props) {
426
417
  const ctx = sharedConfig.context;
427
- if (!ctx.async) return createComponent(() => {
428
- props.children;
429
- return props.fallback;
430
- }, {});
431
418
  const id = ctx.id + ctx.count;
432
- const done = ctx.async ? lookup(Owner, SUSPENSE_GLOBAL)(id) : () => {};
419
+ const done = ctx.async ? ctx.registerFragment(id) : () => {};
433
420
  const o = Owner;
434
421
  const value = ctx.suspense[id] || (ctx.suspense[id] = {
435
422
  resources: new Map(),
@@ -458,40 +445,23 @@ function Suspense(props) {
458
445
  done();
459
446
  return res;
460
447
  }
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
- });
448
+ if (sharedConfig.context.async) {
449
+ if (sharedConfig.context.streaming) {
450
+ setHydrateContext(undefined);
451
+ const res = {
452
+ t: `<span id="pl${id}">${resolveSSRNode(props.fallback)}</span>`
492
453
  };
454
+ setHydrateContext(ctx);
455
+ return res;
493
456
  }
457
+ return {
458
+ t: `<![${id}]>`
459
+ };
460
+ }
461
+ setHydrateContext({ ...ctx,
462
+ count: 0
494
463
  });
464
+ return createComponent(() => props.fallback, {});
495
465
  }
496
466
 
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 };
467
+ 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 };