@solidjs/web 2.0.0-rc.6 → 2.0.0-rc.8

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 (82) hide show
  1. package/dist/{server.cjs → server.dev.js} +274 -272
  2. package/dist/server.js +119 -36
  3. package/dist/{dev.js → web.dev.js} +131 -399
  4. package/dist/web.js +78 -388
  5. package/dist/{web.cjs → web.observe.js} +174 -622
  6. package/frames/dist/client.dev.js +11 -3
  7. package/frames/dist/client.js +11 -3
  8. package/frames/dist/{server.cjs → server.dev.js} +375 -125
  9. package/frames/dist/server.js +253 -32
  10. package/frames/package.json +7 -15
  11. package/package.json +88 -251
  12. package/serialization/decode/package.json +3 -9
  13. package/serialization/dist/decode.js +18 -4
  14. package/serialization/dist/serialization.js +18 -4
  15. package/serialization/package.json +3 -9
  16. package/serialization/types/serializer-decode.d.ts +49 -2
  17. package/server-functions/dist/client.js +13 -14
  18. package/server-functions/dist/server.dev.js +359 -85
  19. package/server-functions/dist/server.js +352 -86
  20. package/server-functions/package.json +6 -24
  21. package/server-functions/rich-args/package.json +3 -9
  22. package/storage/package.json +3 -9
  23. package/types/client.d.ts +17 -3
  24. package/types/frames/frame-client.d.ts +1 -1
  25. package/types/frames/serializer-decode.d.ts +49 -2
  26. package/types/head.d.ts +3 -0
  27. package/types/index.d.ts +18 -7
  28. package/types/index.server.d.ts +31 -9
  29. package/types/render.d.ts +3 -1
  30. package/types/serializer-decode.d.ts +49 -2
  31. package/types/server-functions/flash.d.ts +12 -3
  32. package/types/server-functions/server.d.ts +50 -3
  33. package/types/server-mock.d.ts +43 -7
  34. package/types/server.d.ts +48 -6
  35. package/dist/dev.cjs +0 -2590
  36. package/frames/dist/client.cjs +0 -2035
  37. package/frames/dist/client.dev.cjs +0 -2055
  38. package/serialization/dist/decode.cjs +0 -141
  39. package/serialization/dist/serialization.cjs +0 -261
  40. package/serialization/types-cjs/index.d.cts +0 -101
  41. package/serialization/types-cjs/package.json +0 -3
  42. package/serialization/types-cjs/serializer-decode.d.cts +0 -172
  43. package/serialization/types-cjs/serializer.d.cts +0 -101
  44. package/server-functions/dist/client.cjs +0 -1070
  45. package/server-functions/dist/rich-args.cjs +0 -11
  46. package/server-functions/dist/server.cjs +0 -2133
  47. package/server-functions/dist/server.dev.cjs +0 -2153
  48. package/storage/dist/storage.cjs +0 -12
  49. package/storage/types-cjs/index.d.cts +0 -28
  50. package/storage/types-cjs/package.json +0 -3
  51. package/types/patch-driver.d.ts +0 -3
  52. package/types-cjs/client.d.cts +0 -200
  53. package/types-cjs/constants.d.cts +0 -20
  54. package/types-cjs/cookies.d.cts +0 -41
  55. package/types-cjs/frames/client.d.cts +0 -36
  56. package/types-cjs/frames/frame-client.d.cts +0 -370
  57. package/types-cjs/frames/frame-container-plugin.d.cts +0 -71
  58. package/types-cjs/frames/frame-sink.d.cts +0 -92
  59. package/types-cjs/frames/frame-transport.d.cts +0 -189
  60. package/types-cjs/frames/serializer-decode.d.cts +0 -172
  61. package/types-cjs/frames/serializer.d.cts +0 -101
  62. package/types-cjs/frames/server.d.cts +0 -52
  63. package/types-cjs/head.d.cts +0 -16
  64. package/types-cjs/index.d.cts +0 -180
  65. package/types-cjs/index.server.d.cts +0 -125
  66. package/types-cjs/jsx-properties.d.cts +0 -93
  67. package/types-cjs/jsx.d.cts +0 -4146
  68. package/types-cjs/package.json +0 -3
  69. package/types-cjs/patch-driver.d.cts +0 -3
  70. package/types-cjs/reconcile.d.cts +0 -1
  71. package/types-cjs/render.d.cts +0 -4
  72. package/types-cjs/response.d.cts +0 -81
  73. package/types-cjs/serializer-decode.d.cts +0 -172
  74. package/types-cjs/serializer.d.cts +0 -101
  75. package/types-cjs/server-functions/client.d.cts +0 -184
  76. package/types-cjs/server-functions/flash.d.cts +0 -27
  77. package/types-cjs/server-functions/registry.d.cts +0 -100
  78. package/types-cjs/server-functions/rich-args.d.cts +0 -1
  79. package/types-cjs/server-functions/server.d.cts +0 -522
  80. package/types-cjs/server-functions/shared.d.cts +0 -283
  81. package/types-cjs/server-mock.d.cts +0 -301
  82. package/types-cjs/server.d.cts +0 -366
@@ -1,8 +1,6 @@
1
- 'use strict';
2
-
3
- var solidJs = require('solid-js');
4
- var seroval = require('seroval');
5
- var web = require('seroval-plugins/web');
1
+ import { sharedConfig, createRoot, ssrHandleError, getOwner, runWithOwner, inServerComponentScope, creationStamp, NoHydration, runInServerComponentScope, createMemo, Hydration, createOwner, getProjectionTrace } from 'solid-js';
2
+ import { Feature, createStream, toCrossJSONStream, Serializer, getCrossReferenceHeader } from 'seroval';
3
+ import { AbortSignalPlugin, CustomEventPlugin, DOMExceptionPlugin, EventPlugin, FormDataPlugin, HeadersPlugin, ReadableStreamPlugin, RequestPlugin, ResponsePlugin, URLSearchParamsPlugin, URLPlugin } from 'seroval-plugins/web';
6
4
 
7
5
  const STATE = Symbol.for("solid.container-trace-state");
8
6
  const state = globalThis[STATE] || (globalThis[STATE] = {
@@ -104,7 +102,7 @@ const ContainerTracePlugin = {
104
102
  const COMPOSED_BODY_FRAMING = /*#__PURE__*/new Set(["content-length", "content-encoding", "transfer-encoding"]);
105
103
 
106
104
  setContainerTraceStreamMint(iterable => {
107
- const stream = seroval.createStream();
105
+ const stream = createStream();
108
106
  (async () => {
109
107
  try {
110
108
  for await (const value of iterable) stream.next(value);
@@ -115,14 +113,14 @@ setContainerTraceStreamMint(iterable => {
115
113
  })();
116
114
  return stream;
117
115
  });
118
- const DEFAULT_WEB_PLUGINS = Object.freeze([web.AbortSignalPlugin,
119
- web.CustomEventPlugin, web.DOMExceptionPlugin, web.EventPlugin,
120
- web.FormDataPlugin, web.HeadersPlugin, web.ReadableStreamPlugin, web.RequestPlugin, web.ResponsePlugin, web.URLSearchParamsPlugin, web.URLPlugin,
116
+ const DEFAULT_WEB_PLUGINS = Object.freeze([AbortSignalPlugin,
117
+ CustomEventPlugin, DOMExceptionPlugin, EventPlugin,
118
+ FormDataPlugin, HeadersPlugin, ReadableStreamPlugin, RequestPlugin, ResponsePlugin, URLSearchParamsPlugin, URLPlugin,
121
119
  ContainerTracePlugin]);
122
120
  function resolveSerializerPlugins(customPlugins) {
123
121
  return customPlugins ? [...customPlugins, ...DEFAULT_WEB_PLUGINS] : [...DEFAULT_WEB_PLUGINS];
124
122
  }
125
- const JSON_CODEC_DISABLED_FEATURES = seroval.Feature.RegExp;
123
+ const JSON_CODEC_DISABLED_FEATURES = Feature.RegExp;
126
124
  const JSON_CODEC_DEPTH_LIMIT = 64;
127
125
  function resolveCodecOptions({
128
126
  plugins,
@@ -138,11 +136,11 @@ function resolveCodecOptions({
138
136
  };
139
137
  }
140
138
 
141
- const DEFAULT_DISABLED_FEATURES = seroval.Feature.AggregateError | seroval.Feature.BigIntTypedArray;
142
- const serializeOnlyDisabledFeatures = serializeErrorStacks => (serializeErrorStacks === undefined ? process.env.NODE_ENV === "development" : serializeErrorStacks) ? 0 : seroval.Feature.ErrorPrototypeStack;
139
+ const DEFAULT_DISABLED_FEATURES = Feature.AggregateError | Feature.BigIntTypedArray;
140
+ const serializeOnlyDisabledFeatures = serializeErrorStacks => (serializeErrorStacks === undefined ? process.env.NODE_ENV === "development" : serializeErrorStacks) ? 0 : Feature.ErrorPrototypeStack;
143
141
  const HYDRATION_GLOBAL = "_$HY.r";
144
142
  function createSerializer(options) {
145
- return new seroval.Serializer({
143
+ return new Serializer({
146
144
  ...options,
147
145
  plugins: resolveSerializerPlugins(options.plugins),
148
146
  disabledFeatures: (options.disabledFeatures === undefined ? DEFAULT_DISABLED_FEATURES : options.disabledFeatures) | serializeOnlyDisabledFeatures(options.serializeErrorStacks)
@@ -165,7 +163,7 @@ function createHydrationSerializer({
165
163
  });
166
164
  }
167
165
  function getLocalHeaderScript(id) {
168
- return seroval.getCrossReferenceHeader(id) + ";";
166
+ return getCrossReferenceHeader(id) + ";";
169
167
  }
170
168
  function createJSONSerializer({
171
169
  onData,
@@ -199,7 +197,7 @@ function createJSONSerializer({
199
197
  pendingWrites++;
200
198
  let settled = false;
201
199
  let cancel = null;
202
- const stream = seroval.toCrossJSONStream(value, {
200
+ const stream = toCrossJSONStream(value, {
203
201
  refs,
204
202
  plugins: resolved.plugins,
205
203
  disabledFeatures: resolved.disabledFeatures | serializeOnlyDisabledFeatures(resolved.serializeErrorStacks),
@@ -239,10 +237,6 @@ const ENVELOPE = Symbol.for("solid.ResponseEnvelope");
239
237
  function isResponseEnvelope(value) {
240
238
  return !!(value && typeof value === "object" && value[ENVELOPE]);
241
239
  }
242
- const SAFE_ERROR = Symbol.for("solid.SafeError");
243
- function isSafeError(value) {
244
- return !!(value && (typeof value === "object" || typeof value === "function") && value[SAFE_ERROR]);
245
- }
246
240
  const REVALIDATE_HEADER = "X-Revalidate";
247
241
 
248
242
  function frameAddress(id, args) {
@@ -293,6 +287,18 @@ const ERROR_HEADER = "X-Server-Function-Error";
293
287
  const BODY_FORMAT_HEADER = "X-Server-Function-Format";
294
288
  const REDIRECT_HEADER = "X-Server-Function-Redirect";
295
289
  const SINGLE_FLIGHT_HEADER = "X-Single-Flight";
290
+ const BodyFormat = {
291
+ Serialized: "0",
292
+ String: "1",
293
+ FormData: "2",
294
+ URLSearchParams: "3",
295
+ Blob: "4",
296
+ File: "5",
297
+ ArrayBuffer: "6",
298
+ Uint8Array: "7",
299
+ Json: "8",
300
+ Void: "9"
301
+ };
296
302
  function createChunk(data) {
297
303
  const encoder = new TextEncoder();
298
304
  const encodeData = encoder.encode(data);
@@ -428,12 +434,24 @@ function classifyHeadTag(desc) {
428
434
  resource: false
429
435
  };
430
436
  }
437
+ function qualifierValue(name, value) {
438
+ if (value == null || value === false) return null;
439
+ if (name === "imagesrcset" || name === "imagesizes") return typeof value === "string" && value !== "" ? value : null;
440
+ const v = value === true ? "" : String(value);
441
+ if (name === "as") return asciiLowerCase(v);
442
+ if (name !== "crossorigin") return v;
443
+ return v.length === 15 && v.toLowerCase() === "use-credentials" ? v.toLowerCase() : "anonymous";
444
+ }
445
+ function asciiLowerCase(value) {
446
+ return value.replace(/[A-Z]/g, c => String.fromCharCode(c.charCodeAt(0) + 32));
447
+ }
431
448
  function resourceIdentity(tag, props) {
432
- let id = "res:" + tag + ":" + (props.rel || "") + ":" + (props.href || props.src || "");
449
+ const url = String(props.href || props.src || "");
450
+ let id = "res:" + tag + ":" + (props.rel || "") + ":" + url.length + ":" + url;
433
451
  for (let i = 0; i < RESOURCE_QUALIFIERS.length; i++) {
434
452
  const q = RESOURCE_QUALIFIERS[i];
435
- const value = props[q];
436
- if (value != null) id += ":" + q + "=" + (value === true ? "" : value);
453
+ const value = qualifierValue(q, props[q]);
454
+ if (value !== null) id += ":" + q + "=" + value.length + ":" + value;
437
455
  }
438
456
  return id;
439
457
  }
@@ -467,6 +485,7 @@ function resolveHead(groups) {
467
485
  }
468
486
  for (const [identity, tags] of byIdentity) {
469
487
  if (identity === "title") {
488
+ if (tags.length > 1) console.warn("Multiple <title> tags in one head group; the last one wins.");
470
489
  winners.set(identity, {
471
490
  seq: group.seq,
472
491
  tags: [tags[tags.length - 1]]
@@ -488,6 +507,32 @@ function joinAssetPath(base, file) {
488
507
  if (base[base.length - 1] !== "/") base += "/";
489
508
  return base + (file[0] === "/" ? file.slice(1) : file);
490
509
  }
510
+ function eachCandidate(srcset, visit) {
511
+ let i = 0;
512
+ const n = srcset.length;
513
+ while (i < n) {
514
+ while (i < n && /[\s,]/.test(srcset[i])) i++;
515
+ const start = i;
516
+ while (i < n && !/\s/.test(srcset[i])) i++;
517
+ if (i === start) return false;
518
+ const raw = srcset.slice(start, i);
519
+ const url = raw.replace(/,+$/, "");
520
+ let descriptors = "";
521
+ if (url === raw) {
522
+ const from = i;
523
+ while (i < n && srcset[i] !== ",") i++;
524
+ descriptors = srcset.slice(from, i);
525
+ }
526
+ if (url && visit(url, descriptors)) return true;
527
+ }
528
+ return false;
529
+ }
530
+ function hasRelativeCandidate(srcset) {
531
+ return eachCandidate(srcset, url => !/^(?:[a-zA-Z][a-zA-Z0-9+.-]*:|\/)/.test(url));
532
+ }
533
+ function hasWidthDescriptor(srcset) {
534
+ return eachCandidate(srcset, (_, descriptors) => /(?:^|\s)\d+(?:\.\d+)?w(?=\s|$)/.test(descriptors));
535
+ }
491
536
  function resolveAssets(moduleUrl, manifest) {
492
537
  if (!manifest) return null;
493
538
  const base = manifest._base;
@@ -507,12 +552,22 @@ function resolveAssets(moduleUrl, manifest) {
507
552
  if (e.preloads) {
508
553
  for (let i = 0; i < e.preloads.length; i++) {
509
554
  const link = e.preloads[i];
510
- if (!link || typeof link.href !== "string" || !link.href) continue;
555
+ const href = link && typeof link.href === "string" && link.href;
556
+ const srcset = link && typeof link.imagesrcset === "string" && link.imagesrcset;
557
+ if (!href && !srcset) continue;
511
558
  if (!preloads) preloads = [];
512
- preloads.push({
559
+ if (href) preloads.push({
513
560
  ...link,
514
- href: joinAssetPath(base, link.href)
515
- });
561
+ href: joinAssetPath(base, href)
562
+ });else {
563
+ const {
564
+ href: bad,
565
+ ...rest
566
+ } = link;
567
+ if (bad !== undefined) console.warn("Preload href must be a non-empty string; dropping it.", bad);
568
+ preloads.push(rest);
569
+ }
570
+ if (srcset && hasRelativeCandidate(srcset)) console.warn("imagesrcset candidates are not joined with the manifest base — they resolve " + "against the document URL, so a relative candidate points somewhere else " + "than the joined href; the integration should emit resolved URLs.", srcset);
516
571
  }
517
572
  }
518
573
  if (e.imports) for (let i = 0; i < e.imports.length; i++) walk(e.imports[i]);
@@ -527,7 +582,7 @@ function resolveAssets(moduleUrl, manifest) {
527
582
  }
528
583
  function registerEntryAssets(manifest) {
529
584
  if (!manifest || typeof manifest === "function" || typeof manifest.resolve === "function") return;
530
- const ctx = solidJs.sharedConfig.context;
585
+ const ctx = sharedConfig.context;
531
586
  if (!ctx?.registerAsset) return;
532
587
  for (const key in manifest) {
533
588
  if (manifest[key].isEntry) {
@@ -644,12 +699,18 @@ function isCssUrl(url) {
644
699
  const q = url.search(/[?#]/);
645
700
  return (q === -1 ? url : url.slice(0, q)).endsWith(".css");
646
701
  }
647
- const PRELOAD_LINK_ATTRIBUTES = ["type", "crossorigin", "integrity", "referrerpolicy", "fetchpriority", "media"];
702
+ const RESPONSIVE_ATTRIBUTES = ["imagesrcset", "imagesizes"];
703
+ function isSetAttr(value) {
704
+ return value != null && value !== false && value !== "";
705
+ }
706
+ const PRELOAD_LINK_ATTRIBUTES = ["type", "crossorigin", "integrity", "referrerpolicy", "fetchpriority", "media", "imagesrcset", "imagesizes"];
648
707
  function registerPreloadLink(tracking, headRegistry, link, nonce) {
649
- if (!link || typeof link !== "object" || typeof link.href !== "string" || !link.href) {
708
+ if (!link || typeof link !== "object") {
709
+ console.warn('registerAsset("preload") requires a descriptor object.', link);
650
710
  return null;
651
711
  }
652
712
  if (typeof link.as !== "string") {
713
+ console.warn('registerAsset("preload") requires an as destination.');
653
714
  return null;
654
715
  }
655
716
  const as = asciiLowerCase(link.as);
@@ -665,21 +726,50 @@ function registerPreloadLink(tracking, headRegistry, link, nonce) {
665
726
  case "track":
666
727
  break;
667
728
  default:
729
+ console.warn(`registerAsset("preload") received an unsupported as destination "${link.as}".`);
668
730
  return null;
669
731
  }
732
+ const responsive = as === "image";
733
+ if (!responsive && (isSetAttr(link.imagesrcset) || isSetAttr(link.imagesizes))) console.warn('registerAsset("preload") only supports imagesrcset and imagesizes with as="image".');
734
+ let srcset = null;
735
+ let sizes = null;
736
+ if (responsive) {
737
+ for (const name of RESPONSIVE_ATTRIBUTES) {
738
+ const value = link[name];
739
+ if (!isSetAttr(value)) continue;
740
+ if (typeof value !== "string") {
741
+ console.warn(`registerAsset("preload") expects a string ${name}.`);
742
+ continue;
743
+ }
744
+ if (name === "imagesrcset") srcset = value;else sizes = value;
745
+ }
746
+ }
747
+ const href = typeof link.href === "string" && link.href ? link.href : null;
748
+ if (!href && link.href != null && link.href !== false) console.warn("Preload href must be a non-empty string; dropping it.", link.href);
749
+ if (!href && !srcset) {
750
+ console.warn('registerAsset("preload") requires a non-empty string href or imagesrcset.');
751
+ return null;
752
+ }
753
+ if (srcset && !sizes && hasWidthDescriptor(srcset)) console.warn("imagesrcset uses a width descriptor, so imagesizes is required; without it the " + "source size defaults to 100vw and the preload may not match the image.", srcset);
670
754
  const props = {
671
- rel: "preload",
672
- href: link.href,
673
- as
755
+ rel: "preload"
674
756
  };
757
+ if (href) props.href = href;
758
+ props.as = as;
675
759
  for (let i = 0; i < PRELOAD_LINK_ATTRIBUTES.length; i++) {
676
760
  const name = PRELOAD_LINK_ATTRIBUTES[i];
761
+ if (RESPONSIVE_ATTRIBUTES.indexOf(name) !== -1) {
762
+ const value = name === "imagesrcset" ? srcset : sizes;
763
+ if (value !== null) props[name] = value;
764
+ continue;
765
+ }
677
766
  const value = link[name];
678
767
  if (value == null || value === false) continue;
679
768
  props[name] = value === true ? "" : String(value);
680
769
  }
681
770
  const identity = resourceIdentity("link", props);
682
771
  if (headRegistry.resources.has(identity)) return null;
772
+ if (props.crossorigin == null && (as === "font" || as === "fetch")) console.warn(`registerAsset("preload") with as="${as}" has no crossorigin and may not match the eventual request.`);
683
773
  const attrs = headAttrRecord(props);
684
774
  const nonceValue = destination && nonce && nonce[destination];
685
775
  if (typeof nonceValue === "string" && nonceValue) attrs.nonce = nonceValue;
@@ -718,11 +808,12 @@ function registerHeadTags(registry, context, tracking, emitResource, nonce, tags
718
808
  return;
719
809
  }
720
810
  if (!Array.isArray(tags)) tags = [tags];
721
- const probe = solidJs.sharedConfig.context && solidJs.sharedConfig.context._loadingPhase;
811
+ const probe = sharedConfig.context && sharedConfig.context._loadingPhase;
722
812
  let replaceable = null;
723
813
  for (let i = 0; i < tags.length; i++) {
724
814
  const desc = tags[i];
725
815
  if (!desc || !HEAD_ELIGIBLE_TAGS.has(desc.tag)) {
816
+ console.warn(`useHead: ignoring non-head tag`, desc);
726
817
  continue;
727
818
  }
728
819
  const cls = classifyHeadTag(desc);
@@ -733,7 +824,7 @@ function registerHeadTags(registry, context, tracking, emitResource, nonce, tags
733
824
  } : undefined);
734
825
  evalHeadValue(desc.key);
735
826
  } catch (err) {
736
- if (solidJs.ssrHandleError(err)) throw err;
827
+ if (ssrHandleError(err)) throw err;
737
828
  }
738
829
  }
739
830
  if (cls.resource) {
@@ -755,7 +846,7 @@ function registerHeadTags(registry, context, tracking, emitResource, nonce, tags
755
846
  function headShellReady(registry, block) {
756
847
  let ready = true;
757
848
  const pends = err => {
758
- const source = solidJs.ssrHandleError(err, true);
849
+ const source = ssrHandleError(err, true);
759
850
  if (!source) return false;
760
851
  block(source);
761
852
  ready = false;
@@ -774,6 +865,7 @@ function headShellReady(registry, block) {
774
865
  } : undefined);
775
866
  } catch (err) {
776
867
  if (pends(err)) continue;
868
+ console.warn(`useHead: error evaluating resource tag props`, err);
777
869
  parked.splice(i, 1);
778
870
  continue;
779
871
  }
@@ -804,9 +896,9 @@ function emitHeadResource(registry, context, tracking, emitResource, nonce, desc
804
896
  rel
805
897
  } : undefined);
806
898
  } catch (err) {
807
- const loadingPhase = solidJs.sharedConfig.context && solidJs.sharedConfig.context._loadingPhase;
808
- if (loadingPhase && solidJs.ssrHandleError(err)) throw err;
809
- if (!loadingPhase && !context._currentBoundaryId && !registry.shellFlushed && typeof context.block === "function" && solidJs.ssrHandleError(err, true)) {
899
+ const loadingPhase = sharedConfig.context && sharedConfig.context._loadingPhase;
900
+ if (loadingPhase && ssrHandleError(err)) throw err;
901
+ if (!loadingPhase && !context._currentBoundaryId && !registry.shellFlushed && typeof context.block === "function" && ssrHandleError(err, true)) {
810
902
  registry.parkedResources.push({
811
903
  desc,
812
904
  rel,
@@ -814,6 +906,7 @@ function emitHeadResource(registry, context, tracking, emitResource, nonce, desc
814
906
  });
815
907
  return;
816
908
  }
909
+ console.warn(`useHead: error evaluating resource tag props`, err);
817
910
  return;
818
911
  }
819
912
  const identity = resourceIdentity(desc.tag, props);
@@ -875,6 +968,7 @@ function commitHeadBoundary(registry, boundary, isPendingFragment) {
875
968
  try {
876
969
  resolved = reg.list();
877
970
  } catch (err) {
971
+ console.warn(`useHead: error evaluating head group membership`, err);
878
972
  continue;
879
973
  }
880
974
  if (!Array.isArray(resolved)) resolved = [resolved];
@@ -882,6 +976,7 @@ function commitHeadBoundary(registry, boundary, isPendingFragment) {
882
976
  for (let j = 0; j < resolved.length; j++) {
883
977
  const desc = resolved[j];
884
978
  if (!desc || !HEAD_ELIGIBLE_TAGS.has(desc.tag)) {
979
+ console.warn(`useHead: ignoring non-head tag`, desc);
885
980
  continue;
886
981
  }
887
982
  const cls = classifyHeadTag(desc);
@@ -907,10 +1002,12 @@ function commitHeadBoundary(registry, boundary, isPendingFragment) {
907
1002
  } : undefined);
908
1003
  key = evalHeadValue(desc.key);
909
1004
  } catch (err) {
1005
+ console.warn(`useHead: error evaluating tag props`, err);
910
1006
  continue;
911
1007
  }
912
1008
  const identity = replaceableIdentity(desc.tag, props, key, "u:" + registry.uniq++);
913
1009
  if ((identity === "base" || identity === "charset") && registry.shellFlushed) {
1010
+ console.warn(`useHead: <${desc.tag}> (${identity}) registered after shell flush is ignored`);
914
1011
  continue;
915
1012
  }
916
1013
  tags.push({
@@ -1000,6 +1097,7 @@ function flushHeadFragment(registry, boundary, nonce) {
1000
1097
  for (const name in t.props) {
1001
1098
  if (name === "children" || name === "ref" || name.slice(0, 2) === "on") continue;
1002
1099
  if (!HEAD_ATTR_NAME.test(name)) {
1100
+ console.warn(`useHead: ignoring invalid attribute name "${name}"`);
1003
1101
  continue;
1004
1102
  }
1005
1103
  const v = t.props[name];
@@ -1038,9 +1136,6 @@ function normalizeNonce(nonce) {
1038
1136
  styleAttr: typeof style === "string" && style ? ` nonce="${escape(style, true)}"` : ""
1039
1137
  };
1040
1138
  }
1041
- function asciiLowerCase(value) {
1042
- return value.replace(/[A-Z]/g, c => String.fromCharCode(c.charCodeAt(0) + 32));
1043
- }
1044
1139
  function hasNonceProp(props) {
1045
1140
  for (const name in props) if (name.length === 5 && asciiLowerCase(name) === "nonce" && props[name] != null) return true;
1046
1141
  return false;
@@ -1080,6 +1175,7 @@ function renderHeadAttrHtml(props) {
1080
1175
  for (const name in props) {
1081
1176
  if (name === "children" || name === "ref" || name.slice(0, 2) === "on") continue;
1082
1177
  if (!HEAD_ATTR_NAME.test(name)) {
1178
+ console.warn(`useHead: ignoring invalid attribute name "${name}"`);
1083
1179
  continue;
1084
1180
  }
1085
1181
  const v = props[name];
@@ -1121,6 +1217,7 @@ function renderToStream(code, options = {}) {
1121
1217
  onHead
1122
1218
  } = options;
1123
1219
  const nonce = normalizeNonce(options.nonce);
1220
+ const requestEvent = peekRequestEvent();
1124
1221
  let dispose;
1125
1222
  let dead = false;
1126
1223
  const abandon = () => {
@@ -1222,6 +1319,7 @@ function renderToStream(code, options = {}) {
1222
1319
  };
1223
1320
  const onDone = () => {
1224
1321
  writeTasks();
1322
+ lastBlockingSize = blockingPromises.size;
1225
1323
  doShell();
1226
1324
  onCompleteAll && onCompleteAll({
1227
1325
  write(v) {
@@ -1382,7 +1480,7 @@ function renderToStream(code, options = {}) {
1382
1480
  emitTask(`${!headScriptFlushed ? HEAD_SCRIPT : ""}(_$HY.hp=_$HY.hp||{})[${JSON.stringify(key)}]=${payload}`);
1383
1481
  headScriptFlushed = true;
1384
1482
  };
1385
- solidJs.sharedConfig.context = context = {
1483
+ sharedConfig.context = context = {
1386
1484
  async: true,
1387
1485
  nonce: options.nonce,
1388
1486
  live: {},
@@ -1446,7 +1544,7 @@ function renderToStream(code, options = {}) {
1446
1544
  html = html.slice(0, first) + resolveSSRSync(escape(payloadFn())) + html.slice(last + placeholder.length + 1);
1447
1545
  },
1448
1546
  serialize(id, p, deferStream) {
1449
- if (solidJs.sharedConfig.context.noHydrate) return;
1547
+ if (sharedConfig.context.noHydrate) return;
1450
1548
  if (p && typeof p === "object" && typeof p.then === "function") {
1451
1549
  if (!firstFlushed && deferStream) {
1452
1550
  blockingPromises.add(p);
@@ -1557,7 +1655,7 @@ function renderToStream(code, options = {}) {
1557
1655
  applyAssetTracking(context, tracking, manifest, noScripts);
1558
1656
  context.failRender = failRender;
1559
1657
  registerEntryAssets(manifest);
1560
- let html = solidJs.createRoot(d => {
1658
+ let html = createRoot(d => {
1561
1659
  dispose = d;
1562
1660
  const res = resolveSSRNode(escape(code()));
1563
1661
  if (!res.h.length) return res.t[0];
@@ -1610,10 +1708,10 @@ function renderToStream(code, options = {}) {
1610
1708
  }
1611
1709
  function doShell() {
1612
1710
  if (shellCompleted) return;
1613
- solidJs.sharedConfig.context = context;
1614
- const blockersBefore = blockingPromises.size;
1711
+ sharedConfig.context = context;
1712
+ if (blockingPromises.size !== lastBlockingSize) return;
1615
1713
  if (!resolveRootHoles()) return;
1616
- if (blockingPromises.size !== blockersBefore) return;
1714
+ if (blockingPromises.size !== lastBlockingSize) return;
1617
1715
  if (!headShellReady(headRegistry, p => blockingPromises.add(p))) return;
1618
1716
  headStyles = new Set();
1619
1717
  for (const url of tracking.emittedAssets) {
@@ -1641,7 +1739,7 @@ function renderToStream(code, options = {}) {
1641
1739
  let lastBlockingSize = -1;
1642
1740
  let lastRegistrySize = -1;
1643
1741
  let drainTurn = 0;
1644
- const scheduleFlush = fn => {
1742
+ const scheduleFlush = (fn, awaited) => {
1645
1743
  const attempt = () => {
1646
1744
  flushStubBatch();
1647
1745
  if (registry.size !== lastRegistrySize || drainTurn++ < MIN_DRAIN_TURNS) {
@@ -1652,8 +1750,8 @@ function renderToStream(code, options = {}) {
1652
1750
  }
1653
1751
  fn();
1654
1752
  };
1655
- const progressed = blockingPromises.size !== lastBlockingSize;
1656
- lastBlockingSize = blockingPromises.size;
1753
+ const progressed = awaited !== lastBlockingSize;
1754
+ lastBlockingSize = awaited;
1657
1755
  lastRegistrySize = -1;
1658
1756
  drainTurn = 0;
1659
1757
  progressed ? queue(attempt) : setTimeout(attempt);
@@ -1670,7 +1768,7 @@ function renderToStream(code, options = {}) {
1670
1768
  let resolve;
1671
1769
  const p = new Promise(r => resolve = r);
1672
1770
  function flush() {
1673
- allSettled(blockingPromises).then(() => {
1771
+ allSettled(blockingPromises).then(awaited => {
1674
1772
  scheduleFlush(() => {
1675
1773
  if (dead) return resolve();
1676
1774
  try {
@@ -1708,7 +1806,7 @@ function renderToStream(code, options = {}) {
1708
1806
  dispose();
1709
1807
  writable.end();
1710
1808
  } else flushEnd();
1711
- });
1809
+ }, awaited);
1712
1810
  });
1713
1811
  }
1714
1812
  flush();
@@ -1716,8 +1814,12 @@ function renderToStream(code, options = {}) {
1716
1814
  };
1717
1815
  return {
1718
1816
  then(onFulfilled, onRejected) {
1817
+ const freezeHead = () => {
1818
+ if (requestEvent && requestEvent.response) commitResponseStub(requestEvent.response);
1819
+ };
1719
1820
  const p = new Promise(resolve => {
1720
1821
  function complete() {
1822
+ freezeHead();
1721
1823
  dispose();
1722
1824
  resolve(tmp);
1723
1825
  }
@@ -1729,17 +1831,16 @@ function renderToStream(code, options = {}) {
1729
1831
  };
1730
1832
  } else onCompleteAll = complete;
1731
1833
  function flush() {
1732
- allSettled(blockingPromises).then(() => {
1834
+ allSettled(blockingPromises).then(awaited => {
1733
1835
  scheduleFlush(() => {
1734
1836
  try {
1735
- const blockersBefore = blockingPromises.size;
1736
- if (!resolveRootHoles() || blockingPromises.size !== blockersBefore || !headShellReady(headRegistry, p => blockingPromises.add(p))) return flush();
1837
+ if (blockingPromises.size !== lastBlockingSize || !resolveRootHoles() || blockingPromises.size !== lastBlockingSize || !headShellReady(headRegistry, p => blockingPromises.add(p))) return flush();
1737
1838
  } catch (err) {
1738
1839
  failRender(err);
1739
1840
  return resolve(tmp);
1740
1841
  }
1741
1842
  queue(flushEnd);
1742
- });
1843
+ }, awaited);
1743
1844
  });
1744
1845
  }
1745
1846
  flush();
@@ -1749,7 +1850,7 @@ function renderToStream(code, options = {}) {
1749
1850
  pipe(w) {
1750
1851
  claimConsumer("pipe");
1751
1852
  function flush() {
1752
- allSettled(blockingPromises).then(() => {
1853
+ allSettled(blockingPromises).then(awaited => {
1753
1854
  scheduleFlush(() => {
1754
1855
  if (dead) return;
1755
1856
  try {
@@ -1771,7 +1872,7 @@ function renderToStream(code, options = {}) {
1771
1872
  dispose();
1772
1873
  writable.end();
1773
1874
  } else flushEnd();
1774
- });
1875
+ }, awaited);
1775
1876
  });
1776
1877
  }
1777
1878
  flush();
@@ -1792,14 +1893,14 @@ function renderToStream(code, options = {}) {
1792
1893
  };
1793
1894
  }
1794
1895
  function buildAsyncWrap(err, node) {
1795
- const p = solidJs.ssrHandleError(err);
1896
+ const p = ssrHandleError(err);
1796
1897
  if (!p) return null;
1797
1898
  if (node.$rw) return {
1798
1899
  fn: node,
1799
1900
  p
1800
1901
  };
1801
- const owner = solidJs.getOwner();
1802
- const live = solidJs.sharedConfig.context && solidJs.sharedConfig.context.liveHoles;
1902
+ const owner = getOwner();
1903
+ const live = sharedConfig.context && sharedConfig.context.liveHoles;
1803
1904
  const suppress = node.$lhSuppress || live && (live.suppressed || live.sweeping);
1804
1905
  if (!owner) {
1805
1906
  if (suppress) node.$lhSuppress = true;
@@ -1808,7 +1909,7 @@ function buildAsyncWrap(err, node) {
1808
1909
  p
1809
1910
  };
1810
1911
  }
1811
- const fn = () => solidJs.runWithOwner(owner, node);
1912
+ const fn = () => runWithOwner(owner, node);
1812
1913
  fn.$rw = true;
1813
1914
  if (suppress) fn.$lhSuppress = true;
1814
1915
  if (node.$lhSkip) fn.$lhSkip = true;
@@ -1935,16 +2036,16 @@ function holeContentPositions(t) {
1935
2036
  }
1936
2037
  function createLiveHoles(sink, scoped) {
1937
2038
  let nextId = 0;
1938
- const stamp = typeof solidJs.creationStamp === "function" ? solidJs.creationStamp : () => 0;
1939
- const inScope = scoped && typeof solidJs.inServerComponentScope === "function" ? solidJs.inServerComponentScope : null;
2039
+ const stamp = typeof creationStamp === "function" ? creationStamp : () => 0;
2040
+ const inScope = scoped && typeof inServerComponentScope === "function" ? inServerComponentScope : null;
1940
2041
  const stripMarkers = html => html.replace(/<!--lh:\/?\d+-->/g, "");
1941
2042
  const swept = (owner, ctx, fn) => {
1942
- const prev = solidJs.sharedConfig.context;
1943
- solidJs.sharedConfig.context = ctx;
2043
+ const prev = sharedConfig.context;
2044
+ sharedConfig.context = ctx;
1944
2045
  try {
1945
- return owner ? solidJs.runWithOwner(owner, fn) : fn();
2046
+ return owner ? runWithOwner(owner, fn) : fn();
1946
2047
  } finally {
1947
- solidJs.sharedConfig.context = prev;
2048
+ sharedConfig.context = prev;
1948
2049
  }
1949
2050
  };
1950
2051
  function resolveHoleValue(hole) {
@@ -2011,8 +2112,8 @@ function createLiveHoles(sink, scoped) {
2011
2112
  if (inScope && !inScope()) return null;
2012
2113
  const recordsBefore = engine.recordStamp;
2013
2114
  const ownersBefore = stamp();
2014
- const owner = solidJs.getOwner();
2015
- const holeCtx = solidJs.sharedConfig.context;
2115
+ const owner = getOwner();
2116
+ const holeCtx = sharedConfig.context;
2016
2117
  const b = {
2017
2118
  key: null,
2018
2119
  children: [],
@@ -2133,8 +2234,8 @@ function createLiveHoles(sink, scoped) {
2133
2234
  return !inScope || inScope();
2134
2235
  },
2135
2236
  attr(cap) {
2136
- const owner = solidJs.getOwner();
2137
- const holeCtx = solidJs.sharedConfig.context;
2237
+ const owner = getOwner();
2238
+ const holeCtx = sharedConfig.context;
2138
2239
  const b = {
2139
2240
  key: "lha:" + cap.id,
2140
2241
  children: [],
@@ -2172,7 +2273,7 @@ function createLiveHoles(sink, scoped) {
2172
2273
  };
2173
2274
  swept(owner, holeCtx, run);
2174
2275
  } catch (err) {
2175
- if (solidJs.ssrHandleError(err, true)) return;
2276
+ if (ssrHandleError(err, true)) return;
2176
2277
  b.closed = true;
2177
2278
  sink.closeBinding(b.key);
2178
2279
  sink.error("lha:" + cap.id, String(err && err.message || err));
@@ -2215,7 +2316,7 @@ function ssr(t) {
2215
2316
  let lastGroup = null;
2216
2317
  let lastGroupVal = null;
2217
2318
  let lastGroupIdx = 0;
2218
- const live = solidJs.sharedConfig.context && solidJs.sharedConfig.context.liveHoles;
2319
+ const live = sharedConfig.context && sharedConfig.context.liveHoles;
2219
2320
  const hp = live ? holeContentPositions(t) : null;
2220
2321
  let lastOpen = null;
2221
2322
  let cap = null;
@@ -2442,10 +2543,13 @@ function escape(s, attr) {
2442
2543
  if (!attr && Array.isArray(s)) {
2443
2544
  const joined = tryJoinPlainSSRArray(s);
2444
2545
  if (joined !== undefined) return joined;
2546
+ const src = s;
2445
2547
  s = s.slice();
2446
2548
  for (let i = 0; i < s.length; i++) s[i] = escape(s[i]);
2549
+ if (src.$slot) s.$slot = true;
2447
2550
  return s;
2448
2551
  }
2552
+ if (!attr && t === "function") return escapeLate(s);
2449
2553
  if (attr) {
2450
2554
  if (s == null || t === "boolean" || t === "number") return s;
2451
2555
  return escape(String(s), attr);
@@ -2456,6 +2560,15 @@ function escape(s, attr) {
2456
2560
  if (i < 0) return s;
2457
2561
  return escapeSlow(s, attr, i);
2458
2562
  }
2563
+ function escapeLate(fn) {
2564
+ if (fn.$esc) return fn;
2565
+ const w = () => escape(fn());
2566
+ w.$esc = true;
2567
+ if (fn.$lhSkip) w.$lhSkip = true;
2568
+ if (fn.$lhSuppress) w.$lhSuppress = true;
2569
+ if (fn.$lhBinding) w.$lhBinding = fn.$lhBinding;
2570
+ return w;
2571
+ }
2459
2572
  const ESCAPE_CONTENT = /[&<]/;
2460
2573
  const ESCAPE_ATTR = /[&"<]/;
2461
2574
  function escapeSlow(s, attr, start) {
@@ -2543,7 +2656,7 @@ function allSettled(promises) {
2543
2656
  let size = promises.size;
2544
2657
  return Promise.allSettled(promises).then(() => {
2545
2658
  if (promises.size !== size) return allSettled(promises);
2546
- return;
2659
+ return size;
2547
2660
  });
2548
2661
  }
2549
2662
  function assembleDocument(html, emittedAssets, preloadLinks, inlineStyles, scripts, nonce, headTags, onHead) {
@@ -2719,6 +2832,7 @@ function tryResolveString(node) {
2719
2832
  merge: node
2720
2833
  };
2721
2834
  if (node.t === undefined) {
2835
+ console.warn(`Unrecognized value. Skipped inserting`, node);
2722
2836
  return "";
2723
2837
  }
2724
2838
  return Array.isArray(node.t) ? node.t[0] : node.t;
@@ -2743,7 +2857,7 @@ function resolveSSRNode(node, result = {
2743
2857
  if (t === "string" || t === "number") {
2744
2858
  result.t[result.t.length - 1] += node;
2745
2859
  } else if (node == null || t === "boolean") ; else if (Array.isArray(node)) {
2746
- const slotLive = node.$slot && solidJs.sharedConfig.context && solidJs.sharedConfig.context.liveHoles;
2860
+ const slotLive = node.$slot && sharedConfig.context && sharedConfig.context.liveHoles;
2747
2861
  if (slotLive) slotLive.suppressed++;
2748
2862
  try {
2749
2863
  let prevNonObj = false;
@@ -2767,9 +2881,9 @@ function resolveSSRNode(node, result = {
2767
2881
  }
2768
2882
  } else if (node.t !== undefined) {
2769
2883
  result.t[result.t.length - 1] += node.t;
2770
- } else ;
2884
+ } else console.warn(`Unrecognized value. Skipped inserting`, node);
2771
2885
  } else if (t === "function") {
2772
- const live = solidJs.sharedConfig.context && solidJs.sharedConfig.context.liveHoles;
2886
+ const live = sharedConfig.context && sharedConfig.context.liveHoles;
2773
2887
  let liveNode = null;
2774
2888
  if (live && (liveNode = live.content(node)) !== null) {
2775
2889
  if (typeof liveNode === "string") result.t[result.t.length - 1] += liveNode;else resolveSSRNode(liveNode, result);
@@ -2793,10 +2907,145 @@ function resolveSSRSync(node) {
2793
2907
  if (!res.h.length) return res.t[0];
2794
2908
  throw new Error("This value cannot be rendered synchronously. Are you missing a boundary?");
2795
2909
  }
2910
+ const RequestContext = Symbol.for("solid.RequestContext");
2911
+ function peekRequestEvent() {
2912
+ const store = globalThis[RequestContext];
2913
+ return store ? store.getStore() : undefined;
2914
+ }
2915
+ function reportLostHeaderWrite(method, name) {
2916
+ const message = `Response header write dropped: headers.${method}(${JSON.stringify(String(name))}) ` + "ran after the response head was sent. Write headers before the shell flushes " + "(or before the handler returns).";
2917
+ throw new Error(message);
2918
+ }
2919
+ function commitResponseStub(stub, {
2920
+ allowLateLocation = false
2921
+ } = {}) {
2922
+ if (!stub || stub.committed) return stub;
2923
+ stub.committed = true;
2924
+ const headers = stub.headers;
2925
+ if (!headers || typeof headers.set !== "function") return stub;
2926
+ for (const method of ["set", "append", "delete"]) {
2927
+ const original = headers[method].bind(headers);
2928
+ headers[method] = function (name, ...rest) {
2929
+ if (allowLateLocation && method === "set" && String(name).toLowerCase() === "location") {
2930
+ return original(name, ...rest);
2931
+ }
2932
+ reportLostHeaderWrite(method, name);
2933
+ };
2934
+ }
2935
+ return stub;
2936
+ }
2796
2937
  /*#__PURE__*/new Set([ERROR_HEADER, BODY_FORMAT_HEADER, SINGLE_FLIGHT_HEADER, REVALIDATE_HEADER, REDIRECT_HEADER, "Location",
2797
2938
  ...COMPOSED_BODY_FRAMING].map(header => header.toLowerCase()));
2798
2939
 
2799
2940
  function scopeDeferredResult(value, scope) {
2941
+ const bound = bindDeferredBody(value, scope);
2942
+ if (bound !== value || value === null || typeof value !== "object") return bound;
2943
+ return scopeDeferredContents(value, scope);
2944
+ }
2945
+ class ScopeFrame {
2946
+ constructor(value, next, keys, descriptors) {
2947
+ this.value = value;
2948
+ this.next = next;
2949
+ this.keys = keys;
2950
+ this.descriptors = descriptors;
2951
+ this.i = 0;
2952
+ this.changed = false;
2953
+ }
2954
+ }
2955
+ function enterScopeCarrier(value, state) {
2956
+ if (value === null || typeof value !== "object" && typeof value !== "function") return value;
2957
+ if (state.seen.has(value)) {
2958
+ state.cyclic.add(value);
2959
+ return state.seen.get(value);
2960
+ }
2961
+ const bound = bindDeferredBody(value, state.scope);
2962
+ if (bound !== value) {
2963
+ state.seen.set(value, bound);
2964
+ return bound;
2965
+ }
2966
+ if (typeof value !== "object") return value;
2967
+ if (Array.isArray(value)) {
2968
+ if (Object.isFrozen(value)) {
2969
+ state.seen.set(value, value);
2970
+ return value;
2971
+ }
2972
+ const next = value.slice();
2973
+ state.seen.set(value, next);
2974
+ return new ScopeFrame(value, next, null, null);
2975
+ }
2976
+ const prototype = Object.getPrototypeOf(value);
2977
+ if (prototype !== Object.prototype && prototype !== null || Object.isFrozen(value)) {
2978
+ state.seen.set(value, value);
2979
+ return value;
2980
+ }
2981
+ const descriptors = Object.getOwnPropertyDescriptors(value);
2982
+ const next = Object.create(prototype, descriptors);
2983
+ state.seen.set(value, next);
2984
+ return new ScopeFrame(value, next, Object.keys(value), descriptors);
2985
+ }
2986
+ function scopeDeferredContents(root, scope) {
2987
+ const state = {
2988
+ seen: new Map(),
2989
+ cyclic: new Set(),
2990
+ scope
2991
+ };
2992
+ const entered = enterScopeCarrier(root, state);
2993
+ if (!(entered instanceof ScopeFrame)) return entered;
2994
+ const stack = [entered];
2995
+ let delivered = NOTHING;
2996
+ for (;;) {
2997
+ const top = stack[stack.length - 1];
2998
+ const length = top.keys ? top.keys.length : top.value.length;
2999
+ let pushed = null;
3000
+ while (top.i < length) {
3001
+ const i = top.i;
3002
+ let original;
3003
+ let writable = true;
3004
+ if (top.keys) {
3005
+ const descriptor = top.descriptors[top.keys[i]];
3006
+ writable = "value" in descriptor && descriptor.writable === true;
3007
+ original = writable ? descriptor.value : undefined;
3008
+ } else {
3009
+ original = top.value[i];
3010
+ }
3011
+ if (!writable) {
3012
+ top.i++;
3013
+ continue;
3014
+ }
3015
+ let bound;
3016
+ if (delivered !== NOTHING) {
3017
+ bound = delivered;
3018
+ delivered = NOTHING;
3019
+ } else {
3020
+ bound = enterScopeCarrier(original, state);
3021
+ if (bound instanceof ScopeFrame) {
3022
+ pushed = bound;
3023
+ break;
3024
+ }
3025
+ }
3026
+ if (bound !== original) {
3027
+ if (top.keys) top.next[top.keys[i]] = bound;else top.next[i] = bound;
3028
+ top.changed = true;
3029
+ }
3030
+ top.i++;
3031
+ }
3032
+ if (pushed !== null) {
3033
+ stack.push(pushed);
3034
+ continue;
3035
+ }
3036
+ stack.pop();
3037
+ let out;
3038
+ if (top.changed || state.cyclic.has(top.value)) {
3039
+ out = top.next;
3040
+ } else {
3041
+ state.seen.set(top.value, top.value);
3042
+ out = top.value;
3043
+ }
3044
+ if (stack.length === 0) return out;
3045
+ delivered = out;
3046
+ }
3047
+ }
3048
+ function bindDeferredBody(value, scope) {
2800
3049
  if (value === null || typeof value !== "object" && typeof value !== "function") return value;
2801
3050
  const promised = scope(() => nativePromise(value));
2802
3051
  if (promised) {
@@ -2842,10 +3091,18 @@ function scopeDeferredResult(value, scope) {
2842
3091
  }
2843
3092
  return value;
2844
3093
  }
3094
+ function processState(key, create) {
3095
+ const slot = Symbol.for(key);
3096
+ return globalThis[slot] || (globalThis[slot] = create());
3097
+ }
3098
+ processState("solid.ServerFunctionRegistrations", () => new Map());
3099
+ processState("solid.ServerFunctionMethods", () => new Map());
3100
+ processState("solid.ServerFunctionReferenceBindings", () => new WeakMap());
2845
3101
  const INVOCATIONS = new WeakMap();
2846
3102
  function getEventServerFunctionInvocation(event) {
2847
3103
  return event && INVOCATIONS.get(event);
2848
3104
  }
3105
+ new Set(Object.values(BodyFormat));
2849
3106
  function guardFailures(value, state) {
2850
3107
  if (!state) state = {
2851
3108
  seen: new WeakMap(),
@@ -3070,7 +3327,7 @@ function enterGuard(value, state) {
3070
3327
  return new Frame(SET, value, next, [...value], null);
3071
3328
  }
3072
3329
  const prototype = Object.getPrototypeOf(value);
3073
- if (prototype !== Object.prototype && prototype !== null) {
3330
+ if (prototype !== Object.prototype && prototype !== null && !(value instanceof Error)) {
3074
3331
  state.seen.set(value, value);
3075
3332
  return value;
3076
3333
  }
@@ -3081,17 +3338,19 @@ function enterGuard(value, state) {
3081
3338
  }
3082
3339
  const next = Object.create(prototype, descriptors);
3083
3340
  state.seen.set(value, next);
3084
- return new Frame(OBJECT, value, next, Object.keys(value), descriptors);
3341
+ const children = !(value instanceof Error) ? Object.keys(value) : Object.getOwnPropertyNames(value).filter(key => {
3342
+ const descriptor = descriptors[key];
3343
+ return descriptor.enumerable || "value" in descriptor;
3344
+ });
3345
+ return new Frame(OBJECT, value, next, children, descriptors);
3085
3346
  }
3086
3347
  function keepGuarded(value, next, changed, state) {
3087
3348
  if (changed || state.cyclic.has(value)) return next;
3088
3349
  state.seen.set(value, value);
3089
3350
  return value;
3090
3351
  }
3091
- const GENERIC_SERVER_ERROR_MESSAGE = "Internal Server Error";
3092
3352
  function sanitizeServerError(value) {
3093
- if (isSafeError(value)) return value;
3094
- return new Error(GENERIC_SERVER_ERROR_MESSAGE);
3353
+ return value;
3095
3354
  }
3096
3355
  function nativePromise(value) {
3097
3356
  if (value instanceof Promise) return value;
@@ -3151,27 +3410,29 @@ function flightCodec(codec) {
3151
3410
  };
3152
3411
  }
3153
3412
 
3154
- const runWithHydrationScope = (id, fn) => solidJs.runWithOwner(solidJs.createOwner({
3413
+ const runWithHydrationScope = (id, fn) => runWithOwner(createOwner({
3155
3414
  id
3156
3415
  }), fn);
3157
- const ssrAsyncValue = value => solidJs.createMemo(() => value, {
3416
+ const ssrAsyncValue = value => createMemo(() => value, {
3158
3417
  serialize: false
3159
3418
  });
3160
- const scopeStamp = typeof solidJs.creationStamp === "function" ? solidJs.creationStamp : () => 0;
3419
+ const scopeStamp = typeof creationStamp === "function" ? creationStamp : () => 0;
3161
3420
  function serverOwned(render) {
3162
- return solidJs.NoHydration ? solidJs.NoHydration({
3421
+ return NoHydration ? NoHydration({
3163
3422
  get children() {
3164
3423
  return render();
3165
3424
  }
3166
3425
  }) : render();
3167
3426
  }
3168
3427
  function serverComponentScope(render) {
3169
- return solidJs.runInServerComponentScope ? solidJs.runInServerComponentScope(render) : render();
3428
+ return runInServerComponentScope ? runInServerComponentScope(render) : render();
3170
3429
  }
3171
3430
  function wirePreload(entry) {
3172
- return {
3431
+ return entry.href ? {
3173
3432
  href: entry.href,
3174
3433
  attrs: entry.attrs
3434
+ } : {
3435
+ attrs: entry.attrs
3175
3436
  };
3176
3437
  }
3177
3438
  const SERVER_COMPONENT_BOOTSTRAP_EXPR = "(self._$SC||(self._$SC={c:{},a:{},r(i,a){a&&(this.a[a]=i,this.reg&&this.reg(a,i));return this.c[i]||(this.c[i]=(p,b)=>self._$SC.impl(i,p,b))}}))";
@@ -3452,7 +3713,7 @@ function renderServerComponent(component, options = {}) {
3452
3713
  return frameStream((sink, frame) => {
3453
3714
  const props = createSlotProps(sink, frame);
3454
3715
  return () => {
3455
- const ctx = solidJs.sharedConfig.context;
3716
+ const ctx = sharedConfig.context;
3456
3717
  if (ctx) {
3457
3718
  ctx.commit = sink.commit;
3458
3719
  ctx.commitEpoch = () => sink.epoch;
@@ -3568,7 +3829,7 @@ function tapFirstYield(iterable) {
3568
3829
  };
3569
3830
  }
3570
3831
  function suppressedFill(render) {
3571
- const live = solidJs.sharedConfig.context && solidJs.sharedConfig.context.liveHoles;
3832
+ const live = sharedConfig.context && sharedConfig.context.liveHoles;
3572
3833
  if (!live) return render();
3573
3834
  live.suppressed++;
3574
3835
  try {
@@ -3589,16 +3850,16 @@ function createDocumentSlotProps(clientProps, frameId) {
3589
3850
  r.$slot = true;
3590
3851
  return r;
3591
3852
  };
3592
- const zoneOwner = solidJs.getOwner ? solidJs.getOwner() : null;
3853
+ const zoneOwner = getOwner ? getOwner() : null;
3593
3854
  const scoped = (occurrence, render) => {
3594
3855
  const id = `sc-${frameId}-${occurrence}-`;
3595
- const run = () => solidJs.Hydration ? solidJs.Hydration({
3856
+ const run = () => Hydration ? Hydration({
3596
3857
  id,
3597
3858
  get children() {
3598
3859
  return render();
3599
3860
  }
3600
3861
  }) : runWithHydrationScope(id, render);
3601
- return zoneOwner ? solidJs.runWithOwner(zoneOwner, run) : run();
3862
+ return zoneOwner ? runWithOwner(zoneOwner, run) : run();
3602
3863
  };
3603
3864
  return new Proxy(Object.create(null), {
3604
3865
  has() {
@@ -3621,7 +3882,7 @@ function createDocumentSlotProps(clientProps, frameId) {
3621
3882
  const slot = clientProps[prop];
3622
3883
  if (typeof slot !== "function") return range(occurrence, undefined);
3623
3884
  const resolved = {};
3624
- const liveArgs = solidJs.sharedConfig.context && solidJs.sharedConfig.context.live && solidJs.sharedConfig.context.live.args;
3885
+ const liveArgs = sharedConfig.context && sharedConfig.context.live && sharedConfig.context.live.args;
3625
3886
  const vals = {};
3626
3887
  const evals = {};
3627
3888
  const states = {};
@@ -3651,7 +3912,7 @@ function createDocumentSlotProps(clientProps, frameId) {
3651
3912
  last: value
3652
3913
  };
3653
3914
  } catch (err) {
3654
- const blocked = solidJs.ssrHandleError && solidJs.ssrHandleError(err);
3915
+ const blocked = ssrHandleError && ssrHandleError(err);
3655
3916
  if (!blocked) throw err;
3656
3917
  const state = states[key] = {
3657
3918
  settled: false,
@@ -3713,7 +3974,7 @@ function createDocumentSlotProps(clientProps, frameId) {
3713
3974
  }
3714
3975
  const out = suppressedFill(() => scoped(occurrence, () => range(occurrence, slot(resolved))));
3715
3976
  const unused = regions.filter(r => !r.used);
3716
- if (solidJs.sharedConfig.context) {
3977
+ if (sharedConfig.context) {
3717
3978
  const args = {};
3718
3979
  for (const key of Object.keys(vals)) {
3719
3980
  const value = vals[key];
@@ -3727,12 +3988,12 @@ function createDocumentSlotProps(clientProps, frameId) {
3727
3988
  if (!isContainerTraced(value) && isServerContent(value)) continue;
3728
3989
  args[key] = envelopeContainerTraces(value);
3729
3990
  }
3730
- solidJs.sharedConfig.context.serialize(`sc:slot:${frameId}:${occurrence}`, {
3991
+ sharedConfig.context.serialize(`sc:slot:${frameId}:${occurrence}`, {
3731
3992
  ...args
3732
3993
  });
3733
3994
  for (const region of unused) {
3734
3995
  region.locked = true;
3735
- solidJs.sharedConfig.context.serialize(`sc:region:${region.childId}`, resolveRegionHtml(solidJs.sharedConfig.context, region.value));
3996
+ sharedConfig.context.serialize(`sc:region:${region.childId}`, resolveRegionHtml(sharedConfig.context, region.value));
3736
3997
  }
3737
3998
  if (liveArgs) {
3738
3999
  for (const key of Object.keys(evals)) {
@@ -3761,7 +4022,7 @@ function createDocumentSlotProps(clientProps, frameId) {
3761
4022
  const FRAME_TAG = "solid-frame";
3762
4023
  const FRAME_ID_ATTR = "data-fid";
3763
4024
  function frameElementOpen(id) {
3764
- const escaped = solidJs.sharedConfig.context ? solidJs.sharedConfig.context.escape(String(id), true) : String(id);
4025
+ const escaped = sharedConfig.context ? sharedConfig.context.escape(String(id), true) : String(id);
3765
4026
  return `<${FRAME_TAG} ${FRAME_ID_ATTR}="${escaped}" style="display:contents">`;
3766
4027
  }
3767
4028
  const FRAME_ELEMENT_CLOSE = `</${FRAME_TAG}>`;
@@ -3882,8 +4143,8 @@ function frameTransformDirectResult(value, {
3882
4143
  t: frameElementOpen(id)
3883
4144
  },
3884
4145
  serverOwned(() => {
3885
- armDocumentLiveHoles(solidJs.sharedConfig.context);
3886
- solidJs.sharedConfig.context.claims = CLAIMS_DOCUMENT;
4146
+ armDocumentLiveHoles(sharedConfig.context);
4147
+ sharedConfig.context.claims = CLAIMS_DOCUMENT;
3887
4148
  const slotProps = createDocumentSlotProps(props, id);
3888
4149
  return serverComponentScope(() => component(slotProps));
3889
4150
  }), {
@@ -3928,11 +4189,11 @@ function contentArgError(key, occurrence) {
3928
4189
  return new Error("Async slot arg resolved to JSX (arg '" + key + "' of " + occurrence + "). Async args must resolve to serializable values; render async content through a boundary instead.");
3929
4190
  }
3930
4191
  function retryArgUntilSettled(evaluate, blocked, key, occurrence, onSettle) {
3931
- const owner = solidJs.getOwner();
4192
+ const owner = getOwner();
3932
4193
  return new Promise((resolve, reject) => {
3933
4194
  const retry = () => {
3934
4195
  try {
3935
- const value = owner ? solidJs.runWithOwner(owner, evaluate) : evaluate();
4196
+ const value = owner ? runWithOwner(owner, evaluate) : evaluate();
3936
4197
  if (isServerContent(value)) {
3937
4198
  reject(contentArgError(key, occurrence));
3938
4199
  return;
@@ -3940,7 +4201,7 @@ function retryArgUntilSettled(evaluate, blocked, key, occurrence, onSettle) {
3940
4201
  if (onSettle) onSettle(value);
3941
4202
  resolve(value);
3942
4203
  } catch (err) {
3943
- const next = solidJs.ssrHandleError && solidJs.ssrHandleError(err);
4204
+ const next = ssrHandleError && ssrHandleError(err);
3944
4205
  if (next) next.then(retry, retry);else reject(err);
3945
4206
  }
3946
4207
  };
@@ -3948,16 +4209,16 @@ function retryArgUntilSettled(evaluate, blocked, key, occurrence, onSettle) {
3948
4209
  });
3949
4210
  }
3950
4211
  function openArgBinding(sink, ledgerKey, occurrence, key, evaluate, state, emit) {
3951
- const owner = solidJs.getOwner();
4212
+ const owner = getOwner();
3952
4213
  sink.openBinding(ledgerKey, {
3953
4214
  sweep() {
3954
4215
  if (!state.settled) return;
3955
4216
  let value;
3956
4217
  const stampBefore = scopeStamp();
3957
4218
  try {
3958
- value = owner ? solidJs.runWithOwner(owner, evaluate) : evaluate();
4219
+ value = owner ? runWithOwner(owner, evaluate) : evaluate();
3959
4220
  } catch (err) {
3960
- const blocked = solidJs.ssrHandleError && solidJs.ssrHandleError(err);
4221
+ const blocked = ssrHandleError && ssrHandleError(err);
3961
4222
  if (!blocked) {
3962
4223
  sink.closeBinding(ledgerKey);
3963
4224
  emit(Promise.reject(err instanceof Error ? err : new Error(String(err))));
@@ -4006,7 +4267,7 @@ function createSlotProps(sink, frame) {
4006
4267
  if (callArgs.length === 0 || callArgs[0] === undefined) {
4007
4268
  return slotRange(prop);
4008
4269
  }
4009
- const live = solidJs.sharedConfig.context && solidJs.sharedConfig.context.liveHoles;
4270
+ const live = sharedConfig.context && sharedConfig.context.liveHoles;
4010
4271
  if (live) {
4011
4272
  if (live.sweeping) {
4012
4273
  live.gateHit = true;
@@ -4024,7 +4285,7 @@ function createSlotProps(sink, frame) {
4024
4285
  for (const key of Object.keys(raw)) {
4025
4286
  if (key === "$key") continue;
4026
4287
  const childId = `${frame.id}.${occurrence}.${key}`;
4027
- const ctx = solidJs.sharedConfig.context;
4288
+ const ctx = sharedConfig.context;
4028
4289
  const origRegister = ctx.registerFragment;
4029
4290
  ctx.registerFragment = (fragKey, fragOptions) => {
4030
4291
  sink.tagRegion(fragKey, childId);
@@ -4050,7 +4311,7 @@ function createSlotProps(sink, frame) {
4050
4311
  }
4051
4312
  }
4052
4313
  } catch (err) {
4053
- const blocked = solidJs.ssrHandleError && solidJs.ssrHandleError(err);
4314
+ const blocked = ssrHandleError && ssrHandleError(err);
4054
4315
  if (!blocked) throw err;
4055
4316
  state = {
4056
4317
  settled: false,
@@ -4103,7 +4364,7 @@ function createSlotProps(sink, frame) {
4103
4364
  sink.slot(occurrence, {
4104
4365
  ...args
4105
4366
  });
4106
- const ctx = solidJs.sharedConfig.context;
4367
+ const ctx = sharedConfig.context;
4107
4368
  for (const b of opened) {
4108
4369
  const key = b.key;
4109
4370
  const ledgerKey = `${occurrence}:${key}`;
@@ -4321,20 +4582,9 @@ function frameFlightResponse({
4321
4582
  });
4322
4583
  }
4323
4584
 
4324
- setContainerTraceResolver(solidJs.getProjectionTrace);
4585
+ setContainerTraceResolver(getProjectionTrace);
4325
4586
  function asyncArg(value) {
4326
4587
  return value;
4327
4588
  }
4328
4589
 
4329
- exports.FRAME_STREAM_HEADER = FRAME_STREAM_HEADER;
4330
- exports.SERVER_COMPONENT_BOOTSTRAP = SERVER_COMPONENT_BOOTSTRAP;
4331
- exports.ServerComponentPlugin = ServerComponentPlugin;
4332
- exports.asyncArg = asyncArg;
4333
- exports.createFrameSink = createFrameSink;
4334
- exports.frameTransformDirectResult = frameTransformDirectResult;
4335
- exports.frameTransformFlightResult = frameTransformFlightResult;
4336
- exports.frameTransformResult = frameTransformResult;
4337
- exports.isFrameStreamResponse = isFrameStreamResponse;
4338
- exports.renderServerComponent = renderServerComponent;
4339
- exports.renderToFrameStream = renderToFrameStream;
4340
- exports.serverComponentResponse = serverComponentResponse;
4590
+ export { FRAME_STREAM_HEADER, SERVER_COMPONENT_BOOTSTRAP, ServerComponentPlugin, asyncArg, createFrameSink, frameTransformDirectResult, frameTransformFlightResult, frameTransformResult, isFrameStreamResponse, renderServerComponent, renderToFrameStream, serverComponentResponse };