solid-js 1.3.0-beta.8 → 1.3.0-rc.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
@@ -236,8 +236,14 @@ function createResource(source, fetcher, options) {
236
236
  fetcher = source;
237
237
  source = true;
238
238
  }
239
+ options ||= {};
240
+ if (options.globalRefetch !== false) {
241
+ Resources || (Resources = new Set());
242
+ Resources.add(load);
243
+ onCleanup(() => Resources.delete(load));
244
+ }
239
245
  const contexts = new Set(),
240
- [s, set] = createSignal((options || {}).initialValue),
246
+ [s, set] = createSignal(options.initialValue),
241
247
  [track, trigger] = createSignal(undefined, {
242
248
  equals: false
243
249
  }),
@@ -251,14 +257,16 @@ function createResource(source, fetcher, options) {
251
257
  dynamic = typeof source === "function";
252
258
  if (sharedConfig.context) {
253
259
  id = `${sharedConfig.context.id}${sharedConfig.context.count++}`;
254
- ({ ...sharedConfig.context
255
- });
256
260
  if (sharedConfig.load) initP = sharedConfig.load(id);
257
261
  }
258
- function loadEnd(p, v, e) {
262
+ function loadEnd(p, v, e, key) {
259
263
  if (pr === p) {
260
- setError(err = e);
261
264
  pr = null;
265
+ if (initP && p === initP && options.onHydrated) options.onHydrated(key, {
266
+ value: v
267
+ });
268
+ initP = null;
269
+ setError(err = e);
262
270
  if (Transition && p && loadedUnderTransition) {
263
271
  Transition.promises.delete(p);
264
272
  loadedUnderTransition = false;
@@ -299,7 +307,7 @@ function createResource(source, fetcher, options) {
299
307
  }
300
308
  return v;
301
309
  }
302
- function load() {
310
+ function load(refetching = true) {
303
311
  setError(err = undefined);
304
312
  const lookup = dynamic ? source() : source;
305
313
  loadedUnderTransition = Transition && Transition.running;
@@ -308,18 +316,20 @@ function createResource(source, fetcher, options) {
308
316
  return;
309
317
  }
310
318
  if (Transition && pr) Transition.promises.delete(pr);
311
- const p = initP || untrack(() => fetcher(lookup, s));
312
- initP = null;
319
+ const p = initP || untrack(() => fetcher(lookup, {
320
+ value: s(),
321
+ refetching
322
+ }));
313
323
  if (typeof p !== "object" || !("then" in p)) {
314
324
  loadEnd(pr, p);
315
- return;
325
+ return p;
316
326
  }
317
327
  pr = p;
318
328
  batch(() => {
319
329
  setLoading(true);
320
330
  trigger();
321
331
  });
322
- p.then(v => loadEnd(p, v), e => loadEnd(p, e, e));
332
+ return p.then(v => loadEnd(p, v, undefined, lookup), e => loadEnd(p, e, e));
323
333
  }
324
334
  Object.defineProperties(read, {
325
335
  loading: {
@@ -333,12 +343,16 @@ function createResource(source, fetcher, options) {
333
343
  }
334
344
  }
335
345
  });
336
- if (dynamic) createComputed(load);else load();
346
+ if (dynamic) createComputed(() => load(false));else load(false);
337
347
  return [read, {
338
348
  refetch: load,
339
349
  mutate: set
340
350
  }];
341
351
  }
352
+ let Resources;
353
+ function refetchResources(info) {
354
+ Resources && Resources.forEach(fn => fn(info));
355
+ }
342
356
  function createDeferred(source, options) {
343
357
  let t,
344
358
  timeout = options ? options.timeoutMs : undefined;
@@ -459,28 +473,27 @@ function runWithOwner(o, fn) {
459
473
  function enableScheduling(scheduler = requestCallback) {
460
474
  Scheduler = scheduler;
461
475
  }
462
- function startTransition(fn, cb) {
476
+ function startTransition(fn) {
463
477
  if (Transition && Transition.running) {
464
478
  fn();
465
- cb && Transition.cb.push(cb);
466
- return;
479
+ return Transition.done;
467
480
  }
468
- queueMicrotask(() => {
481
+ return Promise.resolve().then(() => {
482
+ let t;
469
483
  if (Scheduler || SuspenseContext) {
470
- Transition || (Transition = {
484
+ t = Transition || (Transition = {
471
485
  sources: new Set(),
472
486
  effects: [],
473
487
  promises: new Set(),
474
488
  disposed: new Set(),
475
489
  queue: new Set(),
476
- running: true,
477
- cb: []
490
+ running: true
478
491
  });
479
- cb && Transition.cb.push(cb);
480
- Transition.running = true;
492
+ t.done ||= new Promise(res => t.resolve = res);
493
+ t.running = true;
481
494
  }
482
495
  batch(fn);
483
- if (!Scheduler && !SuspenseContext && cb) cb();
496
+ return t ? t.done : undefined;
484
497
  });
485
498
  }
486
499
  function useTransition() {
@@ -709,7 +722,7 @@ function createComputation(fn, init, pure, state = STALE, options) {
709
722
  });
710
723
  const ordinary = ExternalSourceFactory(c.fn, trigger);
711
724
  onCleanup(() => ordinary.dispose());
712
- const triggerInTransition = () => startTransition(trigger, () => inTransition.dispose());
725
+ const triggerInTransition = () => startTransition(trigger).then(() => inTransition.dispose());
713
726
  const inTransition = ExternalSourceFactory(c.fn, triggerInTransition);
714
727
  c.fn = x => {
715
728
  track();
@@ -767,7 +780,7 @@ function completeUpdates(wait) {
767
780
  Updates = null;
768
781
  }
769
782
  if (wait) return;
770
- let cbs;
783
+ let res;
771
784
  if (Transition && Transition.running) {
772
785
  if (Transition.promises.size || Transition.queue.size) {
773
786
  Transition.running = false;
@@ -777,7 +790,7 @@ function completeUpdates(wait) {
777
790
  return;
778
791
  }
779
792
  const sources = Transition.sources;
780
- cbs = Transition.cb;
793
+ res = Transition.resolve;
781
794
  Effects.forEach(e => {
782
795
  "tState" in e && (e.state = e.tState);
783
796
  delete e.tState;
@@ -804,7 +817,7 @@ function completeUpdates(wait) {
804
817
  Effects = null;
805
818
  globalThis._$afterUpdate && globalThis._$afterUpdate();
806
819
  }
807
- if (cbs) cbs.forEach(cb => cb());
820
+ if (res) res();
808
821
  }
809
822
  function runQueue(queue) {
810
823
  for (let i = 0; i < queue.length; i++) runTop(queue[i]);
@@ -1287,7 +1300,9 @@ function lazy(fn) {
1287
1300
  });
1288
1301
  comp = s;
1289
1302
  } else if (!comp) {
1290
- const [s] = createResource(() => (p || (p = fn())).then(mod => mod.default));
1303
+ const [s] = createResource(() => (p || (p = fn())).then(mod => mod.default), {
1304
+ globalRefetch: false
1305
+ });
1291
1306
  comp = s;
1292
1307
  } else {
1293
1308
  const c = comp();
@@ -1450,7 +1465,7 @@ function Suspense(props) {
1450
1465
  showContent,
1451
1466
  showFallback,
1452
1467
  ctx,
1453
- waitingHydration,
1468
+ p,
1454
1469
  flicker,
1455
1470
  error;
1456
1471
  const [inFallback, setFallback] = createSignal(false),
@@ -1469,21 +1484,22 @@ function Suspense(props) {
1469
1484
  owner = getOwner();
1470
1485
  if (sharedConfig.context) {
1471
1486
  const key = sharedConfig.context.id + sharedConfig.context.count;
1472
- const p = sharedConfig.load(key);
1487
+ p = sharedConfig.load(key);
1473
1488
  if (p) {
1474
- const [s, set] = createSignal(undefined, {
1475
- equals: false
1476
- });
1477
- flicker = s;
1478
- p.then(err => {
1479
- if (error = err) return set();
1480
- sharedConfig.gather(key);
1481
- waitingHydration = true;
1482
- setHydrateContext(ctx);
1483
- set();
1484
- setHydrateContext();
1485
- waitingHydration = false;
1486
- });
1489
+ if (typeof p !== "object" || !("then" in p)) error = p;else {
1490
+ const [s, set] = createSignal(undefined, {
1491
+ equals: false
1492
+ });
1493
+ flicker = s;
1494
+ p.then(err => {
1495
+ if (error = err) return set();
1496
+ sharedConfig.gather(key);
1497
+ setHydrateContext(ctx);
1498
+ set();
1499
+ setHydrateContext();
1500
+ p = undefined;
1501
+ });
1502
+ }
1487
1503
  }
1488
1504
  }
1489
1505
  const listContext = useContext(SuspenseListContext);
@@ -1495,18 +1511,19 @@ function Suspense(props) {
1495
1511
  get children() {
1496
1512
  return createMemo(() => {
1497
1513
  if (error) throw error;
1514
+ ctx = sharedConfig.context;
1498
1515
  if (flicker) {
1499
- ctx = sharedConfig.context;
1500
1516
  flicker();
1501
1517
  return flicker = undefined;
1502
1518
  }
1519
+ if (ctx && p === undefined) setHydrateContext();
1503
1520
  const rendered = untrack(() => props.children);
1504
1521
  return createMemo(() => {
1505
1522
  const inFallback = store.inFallback(),
1506
1523
  visibleContent = showContent ? showContent() : true,
1507
1524
  visibleFallback = showFallback ? showFallback() : true;
1508
1525
  dispose && dispose();
1509
- if ((!inFallback || waitingHydration) && visibleContent) {
1526
+ if ((!inFallback || p !== undefined) && visibleContent) {
1510
1527
  store.resolved = true;
1511
1528
  resumeEffects(store.effects);
1512
1529
  return rendered;
@@ -1514,10 +1531,13 @@ function Suspense(props) {
1514
1531
  if (!visibleFallback) return;
1515
1532
  return createRoot(disposer => {
1516
1533
  dispose = disposer;
1517
- if (sharedConfig.context) setHydrateContext({
1518
- id: sharedConfig.context.id + "f",
1519
- count: 0
1520
- });
1534
+ if (ctx) {
1535
+ setHydrateContext({
1536
+ id: ctx.id + "f",
1537
+ count: 0
1538
+ });
1539
+ ctx = undefined;
1540
+ }
1521
1541
  return props.fallback;
1522
1542
  }, owner);
1523
1543
  });
@@ -1579,6 +1599,7 @@ exports.on = on;
1579
1599
  exports.onCleanup = onCleanup;
1580
1600
  exports.onError = onError;
1581
1601
  exports.onMount = onMount;
1602
+ exports.refetchResources = refetchResources;
1582
1603
  exports.requestCallback = requestCallback;
1583
1604
  exports.runWithOwner = runWithOwner;
1584
1605
  exports.sharedConfig = sharedConfig;
package/dist/dev.js CHANGED
@@ -232,8 +232,14 @@ function createResource(source, fetcher, options) {
232
232
  fetcher = source;
233
233
  source = true;
234
234
  }
235
+ options ||= {};
236
+ if (options.globalRefetch !== false) {
237
+ Resources || (Resources = new Set());
238
+ Resources.add(load);
239
+ onCleanup(() => Resources.delete(load));
240
+ }
235
241
  const contexts = new Set(),
236
- [s, set] = createSignal((options || {}).initialValue),
242
+ [s, set] = createSignal(options.initialValue),
237
243
  [track, trigger] = createSignal(undefined, {
238
244
  equals: false
239
245
  }),
@@ -247,14 +253,16 @@ function createResource(source, fetcher, options) {
247
253
  dynamic = typeof source === "function";
248
254
  if (sharedConfig.context) {
249
255
  id = `${sharedConfig.context.id}${sharedConfig.context.count++}`;
250
- ({ ...sharedConfig.context
251
- });
252
256
  if (sharedConfig.load) initP = sharedConfig.load(id);
253
257
  }
254
- function loadEnd(p, v, e) {
258
+ function loadEnd(p, v, e, key) {
255
259
  if (pr === p) {
256
- setError(err = e);
257
260
  pr = null;
261
+ if (initP && p === initP && options.onHydrated) options.onHydrated(key, {
262
+ value: v
263
+ });
264
+ initP = null;
265
+ setError(err = e);
258
266
  if (Transition && p && loadedUnderTransition) {
259
267
  Transition.promises.delete(p);
260
268
  loadedUnderTransition = false;
@@ -295,7 +303,7 @@ function createResource(source, fetcher, options) {
295
303
  }
296
304
  return v;
297
305
  }
298
- function load() {
306
+ function load(refetching = true) {
299
307
  setError(err = undefined);
300
308
  const lookup = dynamic ? source() : source;
301
309
  loadedUnderTransition = Transition && Transition.running;
@@ -304,18 +312,20 @@ function createResource(source, fetcher, options) {
304
312
  return;
305
313
  }
306
314
  if (Transition && pr) Transition.promises.delete(pr);
307
- const p = initP || untrack(() => fetcher(lookup, s));
308
- initP = null;
315
+ const p = initP || untrack(() => fetcher(lookup, {
316
+ value: s(),
317
+ refetching
318
+ }));
309
319
  if (typeof p !== "object" || !("then" in p)) {
310
320
  loadEnd(pr, p);
311
- return;
321
+ return p;
312
322
  }
313
323
  pr = p;
314
324
  batch(() => {
315
325
  setLoading(true);
316
326
  trigger();
317
327
  });
318
- p.then(v => loadEnd(p, v), e => loadEnd(p, e, e));
328
+ return p.then(v => loadEnd(p, v, undefined, lookup), e => loadEnd(p, e, e));
319
329
  }
320
330
  Object.defineProperties(read, {
321
331
  loading: {
@@ -329,12 +339,16 @@ function createResource(source, fetcher, options) {
329
339
  }
330
340
  }
331
341
  });
332
- if (dynamic) createComputed(load);else load();
342
+ if (dynamic) createComputed(() => load(false));else load(false);
333
343
  return [read, {
334
344
  refetch: load,
335
345
  mutate: set
336
346
  }];
337
347
  }
348
+ let Resources;
349
+ function refetchResources(info) {
350
+ Resources && Resources.forEach(fn => fn(info));
351
+ }
338
352
  function createDeferred(source, options) {
339
353
  let t,
340
354
  timeout = options ? options.timeoutMs : undefined;
@@ -455,28 +469,27 @@ function runWithOwner(o, fn) {
455
469
  function enableScheduling(scheduler = requestCallback) {
456
470
  Scheduler = scheduler;
457
471
  }
458
- function startTransition(fn, cb) {
472
+ function startTransition(fn) {
459
473
  if (Transition && Transition.running) {
460
474
  fn();
461
- cb && Transition.cb.push(cb);
462
- return;
475
+ return Transition.done;
463
476
  }
464
- queueMicrotask(() => {
477
+ return Promise.resolve().then(() => {
478
+ let t;
465
479
  if (Scheduler || SuspenseContext) {
466
- Transition || (Transition = {
480
+ t = Transition || (Transition = {
467
481
  sources: new Set(),
468
482
  effects: [],
469
483
  promises: new Set(),
470
484
  disposed: new Set(),
471
485
  queue: new Set(),
472
- running: true,
473
- cb: []
486
+ running: true
474
487
  });
475
- cb && Transition.cb.push(cb);
476
- Transition.running = true;
488
+ t.done ||= new Promise(res => t.resolve = res);
489
+ t.running = true;
477
490
  }
478
491
  batch(fn);
479
- if (!Scheduler && !SuspenseContext && cb) cb();
492
+ return t ? t.done : undefined;
480
493
  });
481
494
  }
482
495
  function useTransition() {
@@ -705,7 +718,7 @@ function createComputation(fn, init, pure, state = STALE, options) {
705
718
  });
706
719
  const ordinary = ExternalSourceFactory(c.fn, trigger);
707
720
  onCleanup(() => ordinary.dispose());
708
- const triggerInTransition = () => startTransition(trigger, () => inTransition.dispose());
721
+ const triggerInTransition = () => startTransition(trigger).then(() => inTransition.dispose());
709
722
  const inTransition = ExternalSourceFactory(c.fn, triggerInTransition);
710
723
  c.fn = x => {
711
724
  track();
@@ -763,7 +776,7 @@ function completeUpdates(wait) {
763
776
  Updates = null;
764
777
  }
765
778
  if (wait) return;
766
- let cbs;
779
+ let res;
767
780
  if (Transition && Transition.running) {
768
781
  if (Transition.promises.size || Transition.queue.size) {
769
782
  Transition.running = false;
@@ -773,7 +786,7 @@ function completeUpdates(wait) {
773
786
  return;
774
787
  }
775
788
  const sources = Transition.sources;
776
- cbs = Transition.cb;
789
+ res = Transition.resolve;
777
790
  Effects.forEach(e => {
778
791
  "tState" in e && (e.state = e.tState);
779
792
  delete e.tState;
@@ -800,7 +813,7 @@ function completeUpdates(wait) {
800
813
  Effects = null;
801
814
  globalThis._$afterUpdate && globalThis._$afterUpdate();
802
815
  }
803
- if (cbs) cbs.forEach(cb => cb());
816
+ if (res) res();
804
817
  }
805
818
  function runQueue(queue) {
806
819
  for (let i = 0; i < queue.length; i++) runTop(queue[i]);
@@ -1283,7 +1296,9 @@ function lazy(fn) {
1283
1296
  });
1284
1297
  comp = s;
1285
1298
  } else if (!comp) {
1286
- const [s] = createResource(() => (p || (p = fn())).then(mod => mod.default));
1299
+ const [s] = createResource(() => (p || (p = fn())).then(mod => mod.default), {
1300
+ globalRefetch: false
1301
+ });
1287
1302
  comp = s;
1288
1303
  } else {
1289
1304
  const c = comp();
@@ -1446,7 +1461,7 @@ function Suspense(props) {
1446
1461
  showContent,
1447
1462
  showFallback,
1448
1463
  ctx,
1449
- waitingHydration,
1464
+ p,
1450
1465
  flicker,
1451
1466
  error;
1452
1467
  const [inFallback, setFallback] = createSignal(false),
@@ -1465,21 +1480,22 @@ function Suspense(props) {
1465
1480
  owner = getOwner();
1466
1481
  if (sharedConfig.context) {
1467
1482
  const key = sharedConfig.context.id + sharedConfig.context.count;
1468
- const p = sharedConfig.load(key);
1483
+ p = sharedConfig.load(key);
1469
1484
  if (p) {
1470
- const [s, set] = createSignal(undefined, {
1471
- equals: false
1472
- });
1473
- flicker = s;
1474
- p.then(err => {
1475
- if (error = err) return set();
1476
- sharedConfig.gather(key);
1477
- waitingHydration = true;
1478
- setHydrateContext(ctx);
1479
- set();
1480
- setHydrateContext();
1481
- waitingHydration = false;
1482
- });
1485
+ if (typeof p !== "object" || !("then" in p)) error = p;else {
1486
+ const [s, set] = createSignal(undefined, {
1487
+ equals: false
1488
+ });
1489
+ flicker = s;
1490
+ p.then(err => {
1491
+ if (error = err) return set();
1492
+ sharedConfig.gather(key);
1493
+ setHydrateContext(ctx);
1494
+ set();
1495
+ setHydrateContext();
1496
+ p = undefined;
1497
+ });
1498
+ }
1483
1499
  }
1484
1500
  }
1485
1501
  const listContext = useContext(SuspenseListContext);
@@ -1491,18 +1507,19 @@ function Suspense(props) {
1491
1507
  get children() {
1492
1508
  return createMemo(() => {
1493
1509
  if (error) throw error;
1510
+ ctx = sharedConfig.context;
1494
1511
  if (flicker) {
1495
- ctx = sharedConfig.context;
1496
1512
  flicker();
1497
1513
  return flicker = undefined;
1498
1514
  }
1515
+ if (ctx && p === undefined) setHydrateContext();
1499
1516
  const rendered = untrack(() => props.children);
1500
1517
  return createMemo(() => {
1501
1518
  const inFallback = store.inFallback(),
1502
1519
  visibleContent = showContent ? showContent() : true,
1503
1520
  visibleFallback = showFallback ? showFallback() : true;
1504
1521
  dispose && dispose();
1505
- if ((!inFallback || waitingHydration) && visibleContent) {
1522
+ if ((!inFallback || p !== undefined) && visibleContent) {
1506
1523
  store.resolved = true;
1507
1524
  resumeEffects(store.effects);
1508
1525
  return rendered;
@@ -1510,10 +1527,13 @@ function Suspense(props) {
1510
1527
  if (!visibleFallback) return;
1511
1528
  return createRoot(disposer => {
1512
1529
  dispose = disposer;
1513
- if (sharedConfig.context) setHydrateContext({
1514
- id: sharedConfig.context.id + "f",
1515
- count: 0
1516
- });
1530
+ if (ctx) {
1531
+ setHydrateContext({
1532
+ id: ctx.id + "f",
1533
+ count: 0
1534
+ });
1535
+ ctx = undefined;
1536
+ }
1517
1537
  return props.fallback;
1518
1538
  }, owner);
1519
1539
  });
@@ -1535,4 +1555,4 @@ if (globalThis) {
1535
1555
  if (!globalThis.Solid$$) globalThis.Solid$$ = true;else console.warn("You appear to have multiple instances of Solid. This can lead to unexpected behavior.");
1536
1556
  }
1537
1557
 
1538
- 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, enableExternalSource, enableHydration, enableScheduling, equalFn, from, getListener, getOwner, indexArray, lazy, mapArray, mergeProps, observable, on, onCleanup, onError, onMount, requestCallback, runWithOwner, sharedConfig, splitProps, startTransition, untrack, useContext, useTransition };
1558
+ 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, enableExternalSource, enableHydration, enableScheduling, equalFn, from, getListener, getOwner, indexArray, lazy, mapArray, mergeProps, observable, on, onCleanup, onError, onMount, refetchResources, requestCallback, runWithOwner, sharedConfig, splitProps, startTransition, untrack, useContext, useTransition };
package/dist/server.cjs CHANGED
@@ -381,7 +381,7 @@ function createResource(fn, fetcher, options = {}) {
381
381
  read.loading = true;
382
382
  if ("then" in p) {
383
383
  if (ctx.writeResource) ctx.writeResource(id, p);
384
- p.then(res => {
384
+ return p.then(res => {
385
385
  read.loading = false;
386
386
  ctx.resources[id].data = res;
387
387
  p = null;
@@ -393,10 +393,10 @@ function createResource(fn, fetcher, options = {}) {
393
393
  p = null;
394
394
  notifySuspense(contexts);
395
395
  });
396
- return;
397
396
  }
398
397
  ctx.resources[id].data = p;
399
398
  p = null;
399
+ return ctx.resources[id].data;
400
400
  }
401
401
  load();
402
402
  return resource.ref = [read, {
@@ -442,6 +442,7 @@ function notifySuspense(contexts) {
442
442
  contexts.clear();
443
443
  }
444
444
  function enableScheduling() {}
445
+ function enableHydration() {}
445
446
  function startTransition(fn) {
446
447
  fn();
447
448
  }
@@ -461,7 +462,6 @@ function Suspense(props) {
461
462
  const value = ctx.suspense[id] || (ctx.suspense[id] = {
462
463
  resources: new Map(),
463
464
  completed: () => {
464
- if (ctx.dataOnly) return done();
465
465
  const res = runSuspense();
466
466
  if (suspenseComplete(value)) {
467
467
  done(resolveSSRNode(res));
@@ -482,20 +482,21 @@ function Suspense(props) {
482
482
  });
483
483
  }
484
484
  const res = runSuspense();
485
- if (suspenseComplete(value)) return res;
485
+ if (suspenseComplete(value)) {
486
+ ctx.writeResource(id, null);
487
+ return res;
488
+ }
486
489
  onError(err => {
487
490
  if (!done || !done(undefined, err)) throw err;
488
491
  });
489
492
  done = ctx.async ? ctx.registerFragment(id) : undefined;
490
493
  if (ctx.streaming) {
491
- if (!ctx.dataOnly) {
492
- setHydrateContext(undefined);
493
- const res = {
494
- t: `<span id="pl${id}">${resolveSSRNode(props.fallback)}</span>`
495
- };
496
- setHydrateContext(ctx);
497
- return res;
498
- }
494
+ setHydrateContext(undefined);
495
+ const res = {
496
+ t: `<span id="pl${id}">${resolveSSRNode(props.fallback)}</span>`
497
+ };
498
+ setHydrateContext(ctx);
499
+ return res;
499
500
  } else if (ctx.async) {
500
501
  return {
501
502
  t: `<![${id}]>`
@@ -533,6 +534,7 @@ exports.createSelector = createSelector;
533
534
  exports.createSignal = createSignal;
534
535
  exports.createUniqueId = createUniqueId;
535
536
  exports.enableExternalSource = enableExternalSource;
537
+ exports.enableHydration = enableHydration;
536
538
  exports.enableScheduling = enableScheduling;
537
539
  exports.equalFn = equalFn;
538
540
  exports.from = from;
package/dist/server.js CHANGED
@@ -377,7 +377,7 @@ function createResource(fn, fetcher, options = {}) {
377
377
  read.loading = true;
378
378
  if ("then" in p) {
379
379
  if (ctx.writeResource) ctx.writeResource(id, p);
380
- p.then(res => {
380
+ return p.then(res => {
381
381
  read.loading = false;
382
382
  ctx.resources[id].data = res;
383
383
  p = null;
@@ -389,10 +389,10 @@ function createResource(fn, fetcher, options = {}) {
389
389
  p = null;
390
390
  notifySuspense(contexts);
391
391
  });
392
- return;
393
392
  }
394
393
  ctx.resources[id].data = p;
395
394
  p = null;
395
+ return ctx.resources[id].data;
396
396
  }
397
397
  load();
398
398
  return resource.ref = [read, {
@@ -438,6 +438,7 @@ function notifySuspense(contexts) {
438
438
  contexts.clear();
439
439
  }
440
440
  function enableScheduling() {}
441
+ function enableHydration() {}
441
442
  function startTransition(fn) {
442
443
  fn();
443
444
  }
@@ -457,7 +458,6 @@ function Suspense(props) {
457
458
  const value = ctx.suspense[id] || (ctx.suspense[id] = {
458
459
  resources: new Map(),
459
460
  completed: () => {
460
- if (ctx.dataOnly) return done();
461
461
  const res = runSuspense();
462
462
  if (suspenseComplete(value)) {
463
463
  done(resolveSSRNode(res));
@@ -478,20 +478,21 @@ function Suspense(props) {
478
478
  });
479
479
  }
480
480
  const res = runSuspense();
481
- if (suspenseComplete(value)) return res;
481
+ if (suspenseComplete(value)) {
482
+ ctx.writeResource(id, null);
483
+ return res;
484
+ }
482
485
  onError(err => {
483
486
  if (!done || !done(undefined, err)) throw err;
484
487
  });
485
488
  done = ctx.async ? ctx.registerFragment(id) : undefined;
486
489
  if (ctx.streaming) {
487
- if (!ctx.dataOnly) {
488
- setHydrateContext(undefined);
489
- const res = {
490
- t: `<span id="pl${id}">${resolveSSRNode(props.fallback)}</span>`
491
- };
492
- setHydrateContext(ctx);
493
- return res;
494
- }
490
+ setHydrateContext(undefined);
491
+ const res = {
492
+ t: `<span id="pl${id}">${resolveSSRNode(props.fallback)}</span>`
493
+ };
494
+ setHydrateContext(ctx);
495
+ return res;
495
496
  } else if (ctx.async) {
496
497
  return {
497
498
  t: `<![${id}]>`
@@ -504,4 +505,4 @@ function Suspense(props) {
504
505
  return props.fallback;
505
506
  }
506
507
 
507
- 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, enableExternalSource, enableScheduling, equalFn, from, getListener, getOwner, lazy, mapArray, mergeProps, observable, on, onCleanup, onError, onMount, requestCallback, runWithOwner, sharedConfig, splitProps, startTransition, untrack, useContext, useTransition };
508
+ 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, enableExternalSource, enableHydration, enableScheduling, equalFn, from, getListener, getOwner, lazy, mapArray, mergeProps, observable, on, onCleanup, onError, onMount, requestCallback, runWithOwner, sharedConfig, splitProps, startTransition, untrack, useContext, useTransition };