@solidjs/web 2.0.0-rc.5 → 2.0.0-rc.7

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.
Files changed (52) hide show
  1. package/dist/server.cjs +122 -38
  2. package/dist/server.dev.cjs +3794 -0
  3. package/dist/server.dev.js +3627 -0
  4. package/dist/server.js +123 -39
  5. package/dist/web.cjs +102 -366
  6. package/dist/{dev.cjs → web.dev.cjs} +153 -376
  7. package/dist/{dev.js → web.dev.js} +155 -374
  8. package/dist/web.js +104 -364
  9. package/frames/dist/client.cjs +11 -3
  10. package/frames/dist/client.dev.cjs +11 -3
  11. package/frames/dist/client.dev.js +11 -3
  12. package/frames/dist/client.js +11 -3
  13. package/frames/dist/server.cjs +320 -53
  14. package/frames/dist/server.dev.cjs +4584 -0
  15. package/frames/dist/server.dev.js +4571 -0
  16. package/frames/dist/server.js +320 -53
  17. package/frames/package.json +10 -0
  18. package/package.json +78 -8
  19. package/serialization/dist/decode.cjs +18 -4
  20. package/serialization/dist/decode.js +18 -4
  21. package/serialization/dist/serialization.cjs +18 -4
  22. package/serialization/dist/serialization.js +18 -4
  23. package/server-functions/dist/client.cjs +27 -16
  24. package/server-functions/dist/client.js +27 -16
  25. package/server-functions/dist/server.cjs +529 -131
  26. package/server-functions/dist/server.dev.cjs +536 -130
  27. package/server-functions/dist/server.dev.js +536 -130
  28. package/server-functions/dist/server.js +529 -131
  29. package/types/client.d.ts +1 -3
  30. package/types/constants.d.ts +3 -1
  31. package/types/frames/frame-client.d.ts +1 -1
  32. package/types/head.d.ts +3 -0
  33. package/types/index.d.ts +18 -7
  34. package/types/index.server.d.ts +31 -9
  35. package/types/render.d.ts +3 -1
  36. package/types/server-functions/flash.d.ts +12 -3
  37. package/types/server-functions/server.d.ts +100 -5
  38. package/types/server-mock.d.ts +43 -7
  39. package/types/server.d.ts +47 -5
  40. package/types-cjs/client.d.cts +1 -3
  41. package/types-cjs/constants.d.cts +3 -1
  42. package/types-cjs/frames/frame-client.d.cts +1 -1
  43. package/types-cjs/head.d.cts +3 -0
  44. package/types-cjs/index.d.cts +18 -7
  45. package/types-cjs/index.server.d.cts +31 -9
  46. package/types-cjs/render.d.cts +3 -1
  47. package/types-cjs/server-functions/flash.d.cts +12 -3
  48. package/types-cjs/server-functions/server.d.cts +100 -5
  49. package/types-cjs/server-mock.d.cts +43 -7
  50. package/types-cjs/server.d.cts +47 -5
  51. package/types/patch-driver.d.ts +0 -3
  52. package/types-cjs/patch-driver.d.cts +0 -3
package/dist/server.js CHANGED
@@ -1,4 +1,4 @@
1
- import { createRenderEffect, createMemo, sharedConfig, createRoot, inServerComponentScope, getOwner, ssrHandleError, creationStamp, runWithOwner, createComponent, omit, getNextChildId, onCleanup, getProjectionTrace } from 'solid-js';
1
+ import { createRenderEffect, createMemo, sharedConfig, createRoot, inServerComponentScope, getOwner, ssrHandleError, creationStamp, runWithOwner, createComponent, omit, getNextChildId, NotReadyError, onCleanup, getProjectionTrace } from 'solid-js';
2
2
  export { Errored, For, Hydration, Loading, Match, NoHydration, Repeat, Reveal, Show, Switch, createComponent, getOwner, merge as mergeProps, ssrScope as scope, sharedConfig, untrack } from 'solid-js';
3
3
  import { Feature, createStream, Serializer, getCrossReferenceHeader } from 'seroval';
4
4
  import { AbortSignalPlugin, CustomEventPlugin, DOMExceptionPlugin, EventPlugin, FormDataPlugin, HeadersPlugin, ReadableStreamPlugin, RequestPlugin, ResponsePlugin, URLSearchParamsPlugin, URLPlugin } from 'seroval-plugins/web';
@@ -48,6 +48,15 @@ const Namespaces = {
48
48
  const VoidElements = /*#__PURE__*/new Set(["area", "base", "br", "col", "embed", "hr", "img", "input", "link", "meta", "param", "source", "track", "wbr"]);
49
49
  const RawTextElements = /*#__PURE__*/new Set(["style", "script", "noscript", "template", "textarea", "title"]);
50
50
  const DOMElements = /*#__PURE__*/new Set(/*#__PURE__*/"a,abbr,acronym,address,applet,area,article,aside,audio,b,base,basefont,bdi,bdo,bgsound,big,blink,blockquote,body,br,button,canvas,caption,center,cite,code,col,colgroup,content,data,datalist,dd,del,details,dfn,dialog,dir,div,dl,dt,em,embed,fieldset,figcaption,figure,font,footer,form,frame,frameset,h1,h2,h3,h4,h5,h6,head,header,hgroup,hr,html,i,iframe,image,img,input,ins,isindex,kbd,keygen,label,legend,li,link,listing,main,map,mark,marquee,math,menu,menuitem,meta,meter,multicol,nav,nextid,nobr,noembed,noframes,noindex,noscript,object,ol,optgroup,option,output,p,param,picture,plaintext,portal,pre,progress,q,rb,rp,rt,rtc,ruby,s,samp,script,search,section,select,shadow,slot,small,source,spacer,span,strike,strong,style,sub,summary,sup,svg,table,tbody,td,template,textarea,tfoot,th,thead,time,title,tr,track,tt,u,ul,var,video,wbr,webview,xmp".split(","));
51
+ const COMPOSED_BODY_FRAMING = /*#__PURE__*/new Set(["content-length", "content-encoding", "transfer-encoding"]);
52
+ function isHttpNavigationTarget(target) {
53
+ try {
54
+ const protocol = new URL(target, "http://base.invalid").protocol;
55
+ return protocol === "http:" || protocol === "https:";
56
+ } catch {
57
+ return false;
58
+ }
59
+ }
51
60
 
52
61
  const transparentOptions = {
53
62
  transparent: true,
@@ -57,11 +66,12 @@ const syncOptions = {
57
66
  sync: true
58
67
  };
59
68
  function effect(fn, effectFn, options) {
60
- createRenderEffect(fn, effectFn, options ? {
69
+ const nodeOptions = options ? {
61
70
  sync: true,
62
71
  ...options,
63
72
  transparent: !options.scope
64
- } : transparentOptions);
73
+ } : transparentOptions;
74
+ createRenderEffect(fn, effectFn, nodeOptions);
65
75
  }
66
76
  function memo(fn) {
67
77
  return createMemo(() => fn(), syncOptions);
@@ -285,6 +295,7 @@ function respond(value, init = {}) {
285
295
  responseInit,
286
296
  headers
287
297
  } = initWithRevalidate(init);
298
+ for (const header of COMPOSED_BODY_FRAMING) headers.delete(header);
288
299
  if (NULL_BODY_STATUSES.has(responseInit.status)) {
289
300
  return new ResponseEnvelope(new Response(null, {
290
301
  ...responseInit,
@@ -394,12 +405,24 @@ function classifyHeadTag(desc) {
394
405
  resource: false
395
406
  };
396
407
  }
408
+ function qualifierValue(name, value) {
409
+ if (value == null || value === false) return null;
410
+ if (name === "imagesrcset" || name === "imagesizes") return typeof value === "string" && value !== "" ? value : null;
411
+ const v = value === true ? "" : String(value);
412
+ if (name === "as") return asciiLowerCase(v);
413
+ if (name !== "crossorigin") return v;
414
+ return v.length === 15 && v.toLowerCase() === "use-credentials" ? v.toLowerCase() : "anonymous";
415
+ }
416
+ function asciiLowerCase(value) {
417
+ return value.replace(/[A-Z]/g, c => String.fromCharCode(c.charCodeAt(0) + 32));
418
+ }
397
419
  function resourceIdentity(tag, props) {
398
- let id = "res:" + tag + ":" + (props.rel || "") + ":" + (props.href || props.src || "");
420
+ const url = String(props.href || props.src || "");
421
+ let id = "res:" + tag + ":" + (props.rel || "") + ":" + url.length + ":" + url;
399
422
  for (let i = 0; i < RESOURCE_QUALIFIERS.length; i++) {
400
423
  const q = RESOURCE_QUALIFIERS[i];
401
- const value = props[q];
402
- if (value != null) id += ":" + q + "=" + (value === true ? "" : value);
424
+ const value = qualifierValue(q, props[q]);
425
+ if (value !== null) id += ":" + q + "=" + value.length + ":" + value;
403
426
  }
404
427
  return id;
405
428
  }
@@ -473,12 +496,20 @@ function resolveAssets(moduleUrl, manifest) {
473
496
  if (e.preloads) {
474
497
  for (let i = 0; i < e.preloads.length; i++) {
475
498
  const link = e.preloads[i];
476
- if (!link || typeof link.href !== "string" || !link.href) continue;
499
+ const href = link && typeof link.href === "string" && link.href;
500
+ const srcset = link && typeof link.imagesrcset === "string" && link.imagesrcset;
501
+ if (!href && !srcset) continue;
477
502
  if (!preloads) preloads = [];
478
- preloads.push({
503
+ if (href) preloads.push({
479
504
  ...link,
480
- href: joinAssetPath(base, link.href)
481
- });
505
+ href: joinAssetPath(base, href)
506
+ });else {
507
+ const {
508
+ href: bad,
509
+ ...rest
510
+ } = link;
511
+ preloads.push(rest);
512
+ }
482
513
  }
483
514
  }
484
515
  if (e.imports) for (let i = 0; i < e.imports.length; i++) walk(e.imports[i]);
@@ -610,9 +641,13 @@ function isCssUrl(url) {
610
641
  const q = url.search(/[?#]/);
611
642
  return (q === -1 ? url : url.slice(0, q)).endsWith(".css");
612
643
  }
613
- const PRELOAD_LINK_ATTRIBUTES = ["type", "crossorigin", "integrity", "referrerpolicy", "fetchpriority", "media"];
644
+ const RESPONSIVE_ATTRIBUTES = ["imagesrcset", "imagesizes"];
645
+ function isSetAttr(value) {
646
+ return value != null && value !== false && value !== "";
647
+ }
648
+ const PRELOAD_LINK_ATTRIBUTES = ["type", "crossorigin", "integrity", "referrerpolicy", "fetchpriority", "media", "imagesrcset", "imagesizes"];
614
649
  function registerPreloadLink(tracking, headRegistry, link, nonce) {
615
- if (!link || typeof link !== "object" || typeof link.href !== "string" || !link.href) {
650
+ if (!link || typeof link !== "object") {
616
651
  return null;
617
652
  }
618
653
  if (typeof link.as !== "string") {
@@ -633,13 +668,35 @@ function registerPreloadLink(tracking, headRegistry, link, nonce) {
633
668
  default:
634
669
  return null;
635
670
  }
671
+ const responsive = as === "image";
672
+ let srcset = null;
673
+ let sizes = null;
674
+ if (responsive) {
675
+ for (const name of RESPONSIVE_ATTRIBUTES) {
676
+ const value = link[name];
677
+ if (!isSetAttr(value)) continue;
678
+ if (typeof value !== "string") {
679
+ continue;
680
+ }
681
+ if (name === "imagesrcset") srcset = value;else sizes = value;
682
+ }
683
+ }
684
+ const href = typeof link.href === "string" && link.href ? link.href : null;
685
+ if (!href && !srcset) {
686
+ return null;
687
+ }
636
688
  const props = {
637
- rel: "preload",
638
- href: link.href,
639
- as
689
+ rel: "preload"
640
690
  };
691
+ if (href) props.href = href;
692
+ props.as = as;
641
693
  for (let i = 0; i < PRELOAD_LINK_ATTRIBUTES.length; i++) {
642
694
  const name = PRELOAD_LINK_ATTRIBUTES[i];
695
+ if (RESPONSIVE_ATTRIBUTES.indexOf(name) !== -1) {
696
+ const value = name === "imagesrcset" ? srcset : sizes;
697
+ if (value !== null) props[name] = value;
698
+ continue;
699
+ }
643
700
  const value = link[name];
644
701
  if (value == null || value === false) continue;
645
702
  props[name] = value === true ? "" : String(value);
@@ -1016,9 +1073,6 @@ function scriptNonce(nonce) {
1016
1073
  function styleNonce(nonce) {
1017
1074
  return destinationNonce(nonce, "style");
1018
1075
  }
1019
- function asciiLowerCase(value) {
1020
- return value.replace(/[A-Z]/g, c => String.fromCharCode(c.charCodeAt(0) + 32));
1021
- }
1022
1076
  function hasNonceProp(props) {
1023
1077
  for (const name in props) if (name.length === 5 && asciiLowerCase(name) === "nonce" && props[name] != null) return true;
1024
1078
  return false;
@@ -1179,6 +1233,7 @@ function renderToStream(code, options = {}) {
1179
1233
  onHead
1180
1234
  } = options;
1181
1235
  const nonce = normalizeNonce(options.nonce);
1236
+ const requestEvent = peekRequestEvent();
1182
1237
  let dispose;
1183
1238
  let dead = false;
1184
1239
  const abandon = () => {
@@ -1280,6 +1335,7 @@ function renderToStream(code, options = {}) {
1280
1335
  };
1281
1336
  const onDone = () => {
1282
1337
  writeTasks();
1338
+ lastBlockingSize = blockingPromises.size;
1283
1339
  doShell();
1284
1340
  onCompleteAll && onCompleteAll({
1285
1341
  write(v) {
@@ -1669,9 +1725,9 @@ function renderToStream(code, options = {}) {
1669
1725
  function doShell() {
1670
1726
  if (shellCompleted) return;
1671
1727
  sharedConfig.context = context;
1672
- const blockersBefore = blockingPromises.size;
1728
+ if (blockingPromises.size !== lastBlockingSize) return;
1673
1729
  if (!resolveRootHoles()) return;
1674
- if (blockingPromises.size !== blockersBefore) return;
1730
+ if (blockingPromises.size !== lastBlockingSize) return;
1675
1731
  if (!headShellReady(headRegistry, p => blockingPromises.add(p))) return;
1676
1732
  headStyles = new Set();
1677
1733
  for (const url of tracking.emittedAssets) {
@@ -1699,7 +1755,7 @@ function renderToStream(code, options = {}) {
1699
1755
  let lastBlockingSize = -1;
1700
1756
  let lastRegistrySize = -1;
1701
1757
  let drainTurn = 0;
1702
- const scheduleFlush = fn => {
1758
+ const scheduleFlush = (fn, awaited) => {
1703
1759
  const attempt = () => {
1704
1760
  flushStubBatch();
1705
1761
  if (registry.size !== lastRegistrySize || drainTurn++ < MIN_DRAIN_TURNS) {
@@ -1710,8 +1766,8 @@ function renderToStream(code, options = {}) {
1710
1766
  }
1711
1767
  fn();
1712
1768
  };
1713
- const progressed = blockingPromises.size !== lastBlockingSize;
1714
- lastBlockingSize = blockingPromises.size;
1769
+ const progressed = awaited !== lastBlockingSize;
1770
+ lastBlockingSize = awaited;
1715
1771
  lastRegistrySize = -1;
1716
1772
  drainTurn = 0;
1717
1773
  progressed ? queue(attempt) : setTimeout(attempt);
@@ -1728,7 +1784,7 @@ function renderToStream(code, options = {}) {
1728
1784
  let resolve;
1729
1785
  const p = new Promise(r => resolve = r);
1730
1786
  function flush() {
1731
- allSettled(blockingPromises).then(() => {
1787
+ allSettled(blockingPromises).then(awaited => {
1732
1788
  scheduleFlush(() => {
1733
1789
  if (dead) return resolve();
1734
1790
  try {
@@ -1766,7 +1822,7 @@ function renderToStream(code, options = {}) {
1766
1822
  dispose();
1767
1823
  writable.end();
1768
1824
  } else flushEnd();
1769
- });
1825
+ }, awaited);
1770
1826
  });
1771
1827
  }
1772
1828
  flush();
@@ -1774,8 +1830,12 @@ function renderToStream(code, options = {}) {
1774
1830
  };
1775
1831
  return {
1776
1832
  then(onFulfilled, onRejected) {
1833
+ const freezeHead = () => {
1834
+ if (requestEvent && requestEvent.response) commitResponseStub(requestEvent.response);
1835
+ };
1777
1836
  const p = new Promise(resolve => {
1778
1837
  function complete() {
1838
+ freezeHead();
1779
1839
  dispose();
1780
1840
  resolve(tmp);
1781
1841
  }
@@ -1787,17 +1847,16 @@ function renderToStream(code, options = {}) {
1787
1847
  };
1788
1848
  } else onCompleteAll = complete;
1789
1849
  function flush() {
1790
- allSettled(blockingPromises).then(() => {
1850
+ allSettled(blockingPromises).then(awaited => {
1791
1851
  scheduleFlush(() => {
1792
1852
  try {
1793
- const blockersBefore = blockingPromises.size;
1794
- if (!resolveRootHoles() || blockingPromises.size !== blockersBefore || !headShellReady(headRegistry, p => blockingPromises.add(p))) return flush();
1853
+ if (blockingPromises.size !== lastBlockingSize || !resolveRootHoles() || blockingPromises.size !== lastBlockingSize || !headShellReady(headRegistry, p => blockingPromises.add(p))) return flush();
1795
1854
  } catch (err) {
1796
1855
  failRender(err);
1797
1856
  return resolve(tmp);
1798
1857
  }
1799
1858
  queue(flushEnd);
1800
- });
1859
+ }, awaited);
1801
1860
  });
1802
1861
  }
1803
1862
  flush();
@@ -1807,7 +1866,7 @@ function renderToStream(code, options = {}) {
1807
1866
  pipe(w) {
1808
1867
  claimConsumer("pipe");
1809
1868
  function flush() {
1810
- allSettled(blockingPromises).then(() => {
1869
+ allSettled(blockingPromises).then(awaited => {
1811
1870
  scheduleFlush(() => {
1812
1871
  if (dead) return;
1813
1872
  try {
@@ -1829,7 +1888,7 @@ function renderToStream(code, options = {}) {
1829
1888
  dispose();
1830
1889
  writable.end();
1831
1890
  } else flushEnd();
1832
- });
1891
+ }, awaited);
1833
1892
  });
1834
1893
  }
1835
1894
  flush();
@@ -2500,6 +2559,7 @@ function ssr(t) {
2500
2559
  return result;
2501
2560
  }
2502
2561
  function ssrClassName(value) {
2562
+ if (typeof value === "number") return "" + value;
2503
2563
  if (!value) return "";
2504
2564
  if (typeof value === "string") return escape(value, true);
2505
2565
  value = classListToObject(value);
@@ -2537,17 +2597,22 @@ function ssrStyleProperty(name, value) {
2537
2597
  }
2538
2598
  function ssrElement(tag, props, children, needsId) {
2539
2599
  const hk = needsId ? ssrHydrationKey() : "";
2540
- if (props == null) props = {};else if (typeof props === "function") props = props();
2600
+ if (typeof props === "function") props = props();
2601
+ if (props == null) props = {};
2541
2602
  const skipChildren = VOID_ELEMENTS.test(tag);
2542
2603
  const keys = Object.keys(props);
2543
2604
  let result = `<${tag}${hk} `;
2544
2605
  for (let i = 0; i < keys.length; i++) {
2545
2606
  const prop = keys[i];
2607
+ const value = props[prop];
2608
+ if (tag === "textarea" && (prop === "value" || prop === "defaultValue")) {
2609
+ if (value !== null) children = escape(value);
2610
+ continue;
2611
+ }
2546
2612
  if (ChildProperties.has(prop)) {
2547
2613
  if (children === undefined && !skipChildren) children = tag === "script" || tag === "style" || prop === "innerHTML" ? props[prop] : escape(props[prop]);
2548
2614
  continue;
2549
2615
  }
2550
- const value = props[prop];
2551
2616
  if (prop === "style") {
2552
2617
  result += `style="${ssrStyle(value)}"`;
2553
2618
  } else if (prop === "class") {
@@ -2826,7 +2891,7 @@ function allSettled(promises) {
2826
2891
  let size = promises.size;
2827
2892
  return Promise.allSettled(promises).then(() => {
2828
2893
  if (promises.size !== size) return allSettled(promises);
2829
- return;
2894
+ return size;
2830
2895
  });
2831
2896
  }
2832
2897
  function assembleDocument(html, emittedAssets, preloadLinks, inlineStyles, scripts, nonce, headTags, onHead) {
@@ -2985,7 +3050,8 @@ function classListToObject(classList) {
2985
3050
  function flattenClassList(list, result) {
2986
3051
  for (let i = 0, len = list.length; i < len; i++) {
2987
3052
  const item = list[i];
2988
- if (Array.isArray(item)) flattenClassList(item, result);else if (typeof item === "object" && item != null) Object.assign(result, item);else if (item || item === 0) result[item] = true;
3053
+ if (Array.isArray(item)) flattenClassList(item, result);else if (typeof item === "object" && item != null) Object.assign(result, item);
3054
+ else if (typeof item !== "boolean" && (item || item === 0)) result[item] = true;
2989
3055
  }
2990
3056
  }
2991
3057
  function tryResolveString(node) {
@@ -3094,6 +3160,10 @@ const RequestContext = Symbol.for("solid.RequestContext");
3094
3160
  function getRequestEvent() {
3095
3161
  return globalThis[RequestContext] ? globalThis[RequestContext].getStore() || sharedConfig.context && sharedConfig.context.event || console.warn("RequestEvent is missing. This is most likely due to accessing `getRequestEvent` non-managed async scope in a partially polyfilled environment. Try moving it above all `await` calls.") : undefined;
3096
3162
  }
3163
+ function peekRequestEvent() {
3164
+ const store = globalThis[RequestContext];
3165
+ return store ? store.getStore() : undefined;
3166
+ }
3097
3167
  function createResponseStub() {
3098
3168
  return {
3099
3169
  status: undefined,
@@ -3155,7 +3225,8 @@ function copyInitHeaders(init) {
3155
3225
  for (const cookie of init.getSetCookie()) headers.append("Set-Cookie", cookie);
3156
3226
  return headers;
3157
3227
  }
3158
- const STUB_GAP_FILL_EXCLUDED = /*#__PURE__*/new Set([ERROR_HEADER, BODY_FORMAT_HEADER, SINGLE_FLIGHT_HEADER, REVALIDATE_HEADER, REDIRECT_HEADER, "Location"].map(header => header.toLowerCase()));
3228
+ const STUB_GAP_FILL_EXCLUDED = /*#__PURE__*/new Set([ERROR_HEADER, BODY_FORMAT_HEADER, SINGLE_FLIGHT_HEADER, REVALIDATE_HEADER, REDIRECT_HEADER, "Location",
3229
+ ...COMPOSED_BODY_FRAMING].map(header => header.toLowerCase()));
3159
3230
  function fillsStubGap(key, headers, response) {
3160
3231
  if (key === "set-cookie" || STUB_GAP_FILL_EXCLUDED.has(key)) return false;
3161
3232
  if (response.body === null && (key === "content-type" || key === "content-length")) return false;
@@ -3184,6 +3255,7 @@ function commitEventResponse(response, event = getRequestEvent()) {
3184
3255
  }
3185
3256
  function deriveHead(stub, responseInit = {}) {
3186
3257
  const headers = mergeStubHeaders(copyInitHeaders(responseInit.headers), stub);
3258
+ for (const header of COMPOSED_BODY_FRAMING) headers.delete(header);
3187
3259
  const status = stub && stub.status || responseInit.status || 200;
3188
3260
  const statusText = stub && stub.statusText || responseInit.statusText || undefined;
3189
3261
  return {
@@ -3267,7 +3339,7 @@ function createSSRResponse(result, event, options = {}) {
3267
3339
  end() {
3268
3340
  if (closed || !controller) return;
3269
3341
  const location = stub && stub.headers.get("Location");
3270
- if (location) {
3342
+ if (location && isHttpNavigationTarget(location)) {
3271
3343
  const attr = nonceAttr(nonce, "script");
3272
3344
  enqueue(`<script${attr}>window.location=${JSON.stringify(location).replace(/</g, "\\u003c")}</script>`);
3273
3345
  }
@@ -3308,13 +3380,25 @@ function notSup() {
3308
3380
  setContainerTraceResolver(getProjectionTrace);
3309
3381
  const isServer = true;
3310
3382
  const isDev = false;
3311
- function dynamic(source) {
3383
+ function dynamic(source, options) {
3312
3384
  const cached = createMemo(source, {
3313
3385
  serialize: false
3314
3386
  });
3387
+ const deferStream = !!options?.deferStream;
3315
3388
  return props => {
3389
+ const ctx = sharedConfig.context;
3390
+ let gated = !deferStream || !ctx?.async;
3316
3391
  return createMemo(() => {
3317
- const c = cached();
3392
+ let c;
3393
+ try {
3394
+ c = cached();
3395
+ } catch (err) {
3396
+ if (!gated && err instanceof NotReadyError) {
3397
+ gated = true;
3398
+ ctx.block(Promise.resolve(err.source).then(() => {}, () => {}));
3399
+ }
3400
+ throw err;
3401
+ }
3318
3402
  if (c) {
3319
3403
  if (typeof c === "function") return c(props);
3320
3404
  if (typeof c === "string") {