solid-js 1.2.3 → 1.3.0-beta.1

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) {
@@ -353,7 +354,7 @@ function createSelector(source, fn = equalFn, options) {
353
354
  const subs = new Map();
354
355
  const node = createComputation(p => {
355
356
  const v = source();
356
- for (const key of subs.keys()) if (fn(key, v) || p !== undefined && fn(key, p)) {
357
+ for (const key of subs.keys()) if (fn(key, v) !== (p !== undefined && fn(key, p))) {
357
358
  const l = subs.get(key);
358
359
  for (const c of l.values()) {
359
360
  c.state = STALE;
@@ -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;
@@ -706,7 +708,7 @@ function runTop(node) {
706
708
  } else if (!runningTransition && node.state === PENDING || runningTransition && node.tState === PENDING) {
707
709
  const updates = Updates;
708
710
  Updates = null;
709
- lookDownstream(node);
711
+ lookDownstream(node, ancestors[0]);
710
712
  Updates = updates;
711
713
  }
712
714
  }
@@ -805,13 +807,15 @@ function runUserEffects(queue) {
805
807
  for (i = 0; i < userLength; i++) runTop(queue[i]);
806
808
  for (i = resume; i < queue.length; i++) runTop(queue[i]);
807
809
  }
808
- function lookDownstream(node) {
810
+ function lookDownstream(node, ignore) {
809
811
  node.state = 0;
810
812
  const runningTransition = Transition && Transition.running;
811
813
  for (let i = 0; i < node.sources.length; i += 1) {
812
814
  const source = node.sources[i];
813
815
  if (source.sources) {
814
- if (!runningTransition && source.state === STALE || runningTransition && source.tState === STALE) runTop(source);else if (!runningTransition && source.state === PENDING || runningTransition && source.tState === PENDING) lookDownstream(source);
816
+ if (!runningTransition && source.state === STALE || runningTransition && source.tState === STALE) {
817
+ if (source !== ignore) runTop(source);
818
+ } else if (!runningTransition && source.state === PENDING || runningTransition && source.tState === PENDING) lookDownstream(source, ignore);
815
819
  }
816
820
  }
817
821
  }
@@ -1207,6 +1211,9 @@ function splitProps(props, ...keys) {
1207
1211
  Object.defineProperty(clone, key, descriptors[key] ? descriptors[key] : {
1208
1212
  get() {
1209
1213
  return props[key];
1214
+ },
1215
+ set() {
1216
+ return true;
1210
1217
  }
1211
1218
  });
1212
1219
  }
@@ -1229,7 +1236,7 @@ function lazy(fn) {
1229
1236
  let comp;
1230
1237
  const wrap = props => {
1231
1238
  const ctx = sharedConfig.context;
1232
- if (ctx && sharedConfig.resources) {
1239
+ if (ctx) {
1233
1240
  ctx.count++;
1234
1241
  const [s, set] = createSignal();
1235
1242
  fn().then(mod => {
@@ -1302,7 +1309,7 @@ function Switch(props) {
1302
1309
  }
1303
1310
  return [-1];
1304
1311
  }, undefined, {
1305
- equals: (a, b) => a && a[0] === b[0] && (strictEqual ? a[1] === b[1] : !a[1] === !b[1]) && a[2] === b[2]
1312
+ equals: (a, b) => a[0] === b[0] && (strictEqual ? a[1] === b[1] : !a[1] === !b[1]) && a[2] === b[2]
1306
1313
  });
1307
1314
  return createMemo(() => {
1308
1315
  const [index, when, cond] = evalConditions();
@@ -1396,7 +1403,10 @@ function SuspenseList(props) {
1396
1403
  function Suspense(props) {
1397
1404
  let counter = 0,
1398
1405
  showContent,
1399
- showFallback;
1406
+ showFallback,
1407
+ ctx,
1408
+ waitingHydration,
1409
+ flicker;
1400
1410
  const [inFallback, setFallback] = createSignal(false),
1401
1411
  SuspenseContext = getSuspenseContext(),
1402
1412
  store = {
@@ -1411,6 +1421,24 @@ function Suspense(props) {
1411
1421
  resolved: false
1412
1422
  },
1413
1423
  owner = getOwner();
1424
+ if (sharedConfig.context && sharedConfig.load) {
1425
+ const key = sharedConfig.context.id + sharedConfig.context.count;
1426
+ const p = sharedConfig.load(key);
1427
+ if (p) {
1428
+ const [s, set] = createSignal(undefined, {
1429
+ equals: false
1430
+ });
1431
+ flicker = s;
1432
+ p.then(() => {
1433
+ sharedConfig.gather(key);
1434
+ waitingHydration = true;
1435
+ setHydrateContext(ctx);
1436
+ set();
1437
+ setHydrateContext(undefined);
1438
+ waitingHydration = false;
1439
+ });
1440
+ }
1441
+ }
1414
1442
  const listContext = useContext(SuspenseListContext);
1415
1443
  if (listContext) [showContent, showFallback] = listContext.register(store.inFallback);
1416
1444
  let dispose;
@@ -1418,28 +1446,35 @@ function Suspense(props) {
1418
1446
  return createComponent(SuspenseContext.Provider, {
1419
1447
  value: store,
1420
1448
  get children() {
1421
- const rendered = untrack(() => props.children);
1422
1449
  return createMemo(() => {
1423
- const inFallback = store.inFallback(),
1424
- visibleContent = showContent ? showContent() : true,
1425
- visibleFallback = showFallback ? showFallback() : true;
1426
- dispose && dispose();
1427
- if (!inFallback && visibleContent) {
1428
- store.resolved = true;
1429
- resumeEffects(store.effects);
1430
- return rendered;
1450
+ if (flicker) {
1451
+ ctx = sharedConfig.context;
1452
+ flicker();
1453
+ return flicker = undefined;
1431
1454
  }
1432
- if (!visibleFallback) return;
1433
- return createRoot(disposer => {
1434
- dispose = disposer;
1435
- return props.fallback;
1436
- }, owner);
1455
+ const rendered = untrack(() => props.children);
1456
+ return createMemo(() => {
1457
+ const inFallback = store.inFallback(),
1458
+ visibleContent = showContent ? showContent() : true,
1459
+ visibleFallback = showFallback ? showFallback() : true;
1460
+ dispose && dispose();
1461
+ if ((!inFallback || waitingHydration) && visibleContent) {
1462
+ store.resolved = true;
1463
+ resumeEffects(store.effects);
1464
+ return rendered;
1465
+ }
1466
+ if (!visibleFallback) return;
1467
+ return createRoot(disposer => {
1468
+ dispose = disposer;
1469
+ if (sharedConfig.context) sharedConfig.context.count = 0;
1470
+ return props.fallback;
1471
+ }, owner);
1472
+ });
1437
1473
  });
1438
1474
  }
1439
1475
  });
1440
1476
  }
1441
1477
 
1442
- function awaitSuspense() {}
1443
1478
  exports.DEV = void 0;
1444
1479
  {
1445
1480
  exports.DEV = {
@@ -1462,7 +1497,6 @@ exports.Show = Show;
1462
1497
  exports.Suspense = Suspense;
1463
1498
  exports.SuspenseList = SuspenseList;
1464
1499
  exports.Switch = Switch;
1465
- exports.awaitSuspense = awaitSuspense;
1466
1500
  exports.batch = batch;
1467
1501
  exports.cancelCallback = cancelCallback;
1468
1502
  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) {
@@ -349,7 +350,7 @@ function createSelector(source, fn = equalFn, options) {
349
350
  const subs = new Map();
350
351
  const node = createComputation(p => {
351
352
  const v = source();
352
- for (const key of subs.keys()) if (fn(key, v) || p !== undefined && fn(key, p)) {
353
+ for (const key of subs.keys()) if (fn(key, v) !== (p !== undefined && fn(key, p))) {
353
354
  const l = subs.get(key);
354
355
  for (const c of l.values()) {
355
356
  c.state = STALE;
@@ -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;
@@ -702,7 +704,7 @@ function runTop(node) {
702
704
  } else if (!runningTransition && node.state === PENDING || runningTransition && node.tState === PENDING) {
703
705
  const updates = Updates;
704
706
  Updates = null;
705
- lookDownstream(node);
707
+ lookDownstream(node, ancestors[0]);
706
708
  Updates = updates;
707
709
  }
708
710
  }
@@ -801,13 +803,15 @@ function runUserEffects(queue) {
801
803
  for (i = 0; i < userLength; i++) runTop(queue[i]);
802
804
  for (i = resume; i < queue.length; i++) runTop(queue[i]);
803
805
  }
804
- function lookDownstream(node) {
806
+ function lookDownstream(node, ignore) {
805
807
  node.state = 0;
806
808
  const runningTransition = Transition && Transition.running;
807
809
  for (let i = 0; i < node.sources.length; i += 1) {
808
810
  const source = node.sources[i];
809
811
  if (source.sources) {
810
- if (!runningTransition && source.state === STALE || runningTransition && source.tState === STALE) runTop(source);else if (!runningTransition && source.state === PENDING || runningTransition && source.tState === PENDING) lookDownstream(source);
812
+ if (!runningTransition && source.state === STALE || runningTransition && source.tState === STALE) {
813
+ if (source !== ignore) runTop(source);
814
+ } else if (!runningTransition && source.state === PENDING || runningTransition && source.tState === PENDING) lookDownstream(source, ignore);
811
815
  }
812
816
  }
813
817
  }
@@ -1203,6 +1207,9 @@ function splitProps(props, ...keys) {
1203
1207
  Object.defineProperty(clone, key, descriptors[key] ? descriptors[key] : {
1204
1208
  get() {
1205
1209
  return props[key];
1210
+ },
1211
+ set() {
1212
+ return true;
1206
1213
  }
1207
1214
  });
1208
1215
  }
@@ -1225,7 +1232,7 @@ function lazy(fn) {
1225
1232
  let comp;
1226
1233
  const wrap = props => {
1227
1234
  const ctx = sharedConfig.context;
1228
- if (ctx && sharedConfig.resources) {
1235
+ if (ctx) {
1229
1236
  ctx.count++;
1230
1237
  const [s, set] = createSignal();
1231
1238
  fn().then(mod => {
@@ -1298,7 +1305,7 @@ function Switch(props) {
1298
1305
  }
1299
1306
  return [-1];
1300
1307
  }, undefined, {
1301
- equals: (a, b) => a && a[0] === b[0] && (strictEqual ? a[1] === b[1] : !a[1] === !b[1]) && a[2] === b[2]
1308
+ equals: (a, b) => a[0] === b[0] && (strictEqual ? a[1] === b[1] : !a[1] === !b[1]) && a[2] === b[2]
1302
1309
  });
1303
1310
  return createMemo(() => {
1304
1311
  const [index, when, cond] = evalConditions();
@@ -1392,7 +1399,10 @@ function SuspenseList(props) {
1392
1399
  function Suspense(props) {
1393
1400
  let counter = 0,
1394
1401
  showContent,
1395
- showFallback;
1402
+ showFallback,
1403
+ ctx,
1404
+ waitingHydration,
1405
+ flicker;
1396
1406
  const [inFallback, setFallback] = createSignal(false),
1397
1407
  SuspenseContext = getSuspenseContext(),
1398
1408
  store = {
@@ -1407,6 +1417,24 @@ function Suspense(props) {
1407
1417
  resolved: false
1408
1418
  },
1409
1419
  owner = getOwner();
1420
+ if (sharedConfig.context && sharedConfig.load) {
1421
+ const key = sharedConfig.context.id + sharedConfig.context.count;
1422
+ const p = sharedConfig.load(key);
1423
+ if (p) {
1424
+ const [s, set] = createSignal(undefined, {
1425
+ equals: false
1426
+ });
1427
+ flicker = s;
1428
+ p.then(() => {
1429
+ sharedConfig.gather(key);
1430
+ waitingHydration = true;
1431
+ setHydrateContext(ctx);
1432
+ set();
1433
+ setHydrateContext(undefined);
1434
+ waitingHydration = false;
1435
+ });
1436
+ }
1437
+ }
1410
1438
  const listContext = useContext(SuspenseListContext);
1411
1439
  if (listContext) [showContent, showFallback] = listContext.register(store.inFallback);
1412
1440
  let dispose;
@@ -1414,28 +1442,35 @@ function Suspense(props) {
1414
1442
  return createComponent(SuspenseContext.Provider, {
1415
1443
  value: store,
1416
1444
  get children() {
1417
- const rendered = untrack(() => props.children);
1418
1445
  return createMemo(() => {
1419
- const inFallback = store.inFallback(),
1420
- visibleContent = showContent ? showContent() : true,
1421
- visibleFallback = showFallback ? showFallback() : true;
1422
- dispose && dispose();
1423
- if (!inFallback && visibleContent) {
1424
- store.resolved = true;
1425
- resumeEffects(store.effects);
1426
- return rendered;
1446
+ if (flicker) {
1447
+ ctx = sharedConfig.context;
1448
+ flicker();
1449
+ return flicker = undefined;
1427
1450
  }
1428
- if (!visibleFallback) return;
1429
- return createRoot(disposer => {
1430
- dispose = disposer;
1431
- return props.fallback;
1432
- }, owner);
1451
+ const rendered = untrack(() => props.children);
1452
+ return createMemo(() => {
1453
+ const inFallback = store.inFallback(),
1454
+ visibleContent = showContent ? showContent() : true,
1455
+ visibleFallback = showFallback ? showFallback() : true;
1456
+ dispose && dispose();
1457
+ if ((!inFallback || waitingHydration) && visibleContent) {
1458
+ store.resolved = true;
1459
+ resumeEffects(store.effects);
1460
+ return rendered;
1461
+ }
1462
+ if (!visibleFallback) return;
1463
+ return createRoot(disposer => {
1464
+ dispose = disposer;
1465
+ if (sharedConfig.context) sharedConfig.context.count = 0;
1466
+ return props.fallback;
1467
+ }, owner);
1468
+ });
1433
1469
  });
1434
1470
  }
1435
1471
  });
1436
1472
  }
1437
1473
 
1438
- function awaitSuspense() {}
1439
1474
  let DEV;
1440
1475
  {
1441
1476
  DEV = {
@@ -1449,4 +1484,4 @@ if (globalThis) {
1449
1484
  if (!globalThis.Solid$$) globalThis.Solid$$ = true;else console.warn("You appear to have multiple instances of Solid. This can lead to unexpected behavior.");
1450
1485
  }
1451
1486
 
1452
- 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 };
1487
+ 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;