@solidjs/web 2.0.0-beta.3 → 2.0.0-beta.31

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 (73) hide show
  1. package/README.md +27 -4
  2. package/dist/dev.cjs +1224 -205
  3. package/dist/dev.js +1188 -199
  4. package/dist/server.cjs +1429 -234
  5. package/dist/server.js +1391 -231
  6. package/dist/web.cjs +1207 -195
  7. package/dist/web.js +1171 -189
  8. package/frames/dist/client.cjs +1694 -0
  9. package/frames/dist/client.dev.cjs +1707 -0
  10. package/frames/dist/client.dev.js +1695 -0
  11. package/frames/dist/client.js +1682 -0
  12. package/frames/dist/server.cjs +2520 -0
  13. package/frames/dist/server.js +2508 -0
  14. package/frames/package.json +30 -0
  15. package/package.json +285 -37
  16. package/serialization/dist/serialization.cjs +169 -0
  17. package/serialization/dist/serialization.js +159 -0
  18. package/serialization/package.json +20 -0
  19. package/serialization/types/index.d.ts +157 -0
  20. package/serialization/types-cjs/index.d.cts +157 -0
  21. package/serialization/types-cjs/package.json +3 -0
  22. package/server-functions/dist/client.cjs +613 -0
  23. package/server-functions/dist/client.js +585 -0
  24. package/server-functions/dist/server.cjs +904 -0
  25. package/server-functions/dist/server.js +875 -0
  26. package/server-functions/package.json +30 -0
  27. package/storage/package.json +8 -3
  28. package/storage/types/index.d.ts +26 -0
  29. package/storage/types-cjs/index.d.cts +28 -0
  30. package/storage/types-cjs/package.json +3 -0
  31. package/types/client.d.ts +127 -21
  32. package/types/core.d.ts +4 -3
  33. package/types/frames/client.d.ts +22 -0
  34. package/types/frames/frame-client.d.ts +282 -0
  35. package/types/frames/frame-sink.d.ts +171 -0
  36. package/types/frames/frame-transport.d.ts +190 -0
  37. package/types/frames/serializer.d.ts +157 -0
  38. package/types/frames/server.d.ts +30 -0
  39. package/types/index.d.ts +211 -26
  40. package/types/jsx-properties.d.ts +93 -0
  41. package/types/jsx.d.ts +4150 -1
  42. package/types/response.d.ts +129 -0
  43. package/types/serializer.d.ts +157 -0
  44. package/types/server-functions/client.d.ts +200 -0
  45. package/types/server-functions/flash.d.ts +38 -0
  46. package/types/server-functions/server.d.ts +490 -0
  47. package/types/server-functions/shared.d.ts +445 -0
  48. package/types/server-mock.d.ts +93 -0
  49. package/types/server.d.ts +223 -28
  50. package/types-cjs/client.d.cts +194 -0
  51. package/types-cjs/core.d.cts +4 -0
  52. package/types-cjs/frames/client.d.cts +22 -0
  53. package/types-cjs/frames/frame-client.d.cts +282 -0
  54. package/types-cjs/frames/frame-sink.d.cts +171 -0
  55. package/types-cjs/frames/frame-transport.d.cts +190 -0
  56. package/types-cjs/frames/serializer.d.cts +157 -0
  57. package/types-cjs/frames/server.d.cts +30 -0
  58. package/types-cjs/index.d.cts +231 -0
  59. package/types-cjs/jsx-properties.d.cts +93 -0
  60. package/types-cjs/jsx.d.cts +4150 -0
  61. package/types-cjs/package.json +3 -0
  62. package/types-cjs/response.d.cts +129 -0
  63. package/types-cjs/serializer.d.cts +157 -0
  64. package/types-cjs/server-functions/client.d.cts +200 -0
  65. package/types-cjs/server-functions/flash.d.cts +38 -0
  66. package/types-cjs/server-functions/server.d.cts +490 -0
  67. package/types-cjs/server-functions/shared.d.cts +445 -0
  68. package/types-cjs/server-mock.d.cts +165 -0
  69. package/types-cjs/server.d.cts +351 -0
  70. package/storage/types/src/client.d.ts +0 -1
  71. package/storage/types/src/index.d.ts +0 -46
  72. package/storage/types/src/server-mock.d.ts +0 -72
  73. package/storage/types/storage/src/index.d.ts +0 -2
package/dist/server.cjs CHANGED
@@ -3,10 +3,35 @@
3
3
  var solidJs = require('solid-js');
4
4
  var seroval = require('seroval');
5
5
  var web = require('seroval-plugins/web');
6
- var signals = require('@solidjs/signals');
7
6
 
8
- const Properties = /*#__PURE__*/new Set([
9
- "value", "checked", "selected", "muted"]);
7
+ const DOMWithState = {
8
+ INPUT: {
9
+ value: 1,
10
+ defaultValue: 2,
11
+ checked: 1,
12
+ defaultChecked: 2
13
+ },
14
+ SELECT: {
15
+ value: 1
16
+ },
17
+ OPTION: {
18
+ value: 1,
19
+ selected: 1,
20
+ defaultSelected: 2
21
+ },
22
+ TEXTAREA: {
23
+ value: 1,
24
+ defaultValue: 2
25
+ },
26
+ VIDEO: {
27
+ muted: 1,
28
+ defaultMuted: 2
29
+ },
30
+ AUDIO: {
31
+ muted: 1,
32
+ defaultMuted: 2
33
+ }
34
+ };
10
35
  const ChildProperties = /*#__PURE__*/new Set(["innerHTML", "textContent", "innerText", "children"]);
11
36
  const DelegatedEvents = /*#__PURE__*/new Set(["beforeinput", "click", "dblclick", "contextmenu", "focusin", "focusout", "input", "keydown", "keyup", "mousedown", "mousemove", "mouseout", "mouseover", "mouseup", "pointerdown", "pointermove", "pointerout", "pointerover", "pointerup", "touchend", "touchmove", "touchstart"]);
12
37
  const SVGElements = /*#__PURE__*/new Set([
@@ -14,52 +39,163 @@ const SVGElements = /*#__PURE__*/new Set([
14
39
  "set", "stop",
15
40
  "svg", "switch", "symbol", "text", "textPath",
16
41
  "tref", "tspan", "use", "view", "vkern"]);
17
- const SVGNamespace = {
42
+ const MathMLElements = /*#__PURE__*/new Set(["annotation", "annotation-xml", "maction", "math", "menclose", "merror", "mfenced", "mfrac", "mi", "mmultiscripts", "mn", "mo", "mover", "mpadded", "mphantom", "mprescripts", "mroot", "mrow", "ms", "mspace", "msqrt", "mstyle", "msub", "msubsup", "msup", "mtable", "mtd", "mtext", "mtr", "munder", "munderover", "semantics"]);
43
+ const Namespaces = {
44
+ svg: "http://www.w3.org/2000/svg",
45
+ mathml: "http://www.w3.org/1998/Math/MathML",
18
46
  xlink: "http://www.w3.org/1999/xlink",
19
47
  xml: "http://www.w3.org/XML/1998/namespace"
20
48
  };
21
- const DOMElements = /*#__PURE__*/new Set(["html", "base", "head", "link", "meta", "style", "title", "body", "address", "article", "aside", "footer", "header", "main", "nav", "section", "body", "blockquote", "dd", "div", "dl", "dt", "figcaption", "figure", "hr", "li", "ol", "p", "pre", "ul", "a", "abbr", "b", "bdi", "bdo", "br", "cite", "code", "data", "dfn", "em", "i", "kbd", "mark", "q", "rp", "rt", "ruby", "s", "samp", "small", "span", "strong", "sub", "sup", "time", "u", "var", "wbr", "area", "audio", "img", "map", "track", "video", "embed", "iframe", "object", "param", "picture", "portal", "source", "svg", "math", "canvas", "noscript", "script", "del", "ins", "caption", "col", "colgroup", "table", "tbody", "td", "tfoot", "th", "thead", "tr", "button", "datalist", "fieldset", "form", "input", "label", "legend", "meter", "optgroup", "option", "output", "progress", "select", "textarea", "details", "dialog", "menu", "summary", "details", "slot", "template", "acronym", "applet", "basefont", "bgsound", "big", "blink", "center", "content", "dir", "font", "frame", "frameset", "hgroup", "image", "keygen", "marquee", "menuitem", "nobr", "noembed", "noframes", "plaintext", "rb", "rtc", "shadow", "spacer", "strike", "tt", "xmp", "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", "head", "header", "hgroup", "hr", "html", "i", "iframe", "image", "img", "input", "ins", "kbd", "keygen", "label", "legend", "li", "link", "main", "map", "mark", "marquee", "menu", "menuitem", "meta", "meter", "nav", "nobr", "noembed", "noframes", "noscript", "object", "ol", "optgroup", "option", "output", "p", "param", "picture", "plaintext", "portal", "pre", "progress", "q", "rb", "rp", "rt", "rtc", "ruby", "s", "samp", "script", "section", "select", "shadow", "slot", "small", "source", "spacer", "span", "strike", "strong", "style", "sub", "summary", "sup", "table", "tbody", "td", "template", "textarea", "tfoot", "th", "thead", "time", "title", "tr", "track", "tt", "u", "ul", "var", "video", "wbr", "xmp", "input", "h1", "h2", "h3", "h4", "h5", "h6",
22
- "webview",
23
- "isindex", "listing", "multicol", "nextid", "noindex", "search"]);
49
+ const VoidElements = /*#__PURE__*/new Set(["area", "base", "br", "col", "embed", "hr", "img", "input", "link", "meta", "param", "source", "track", "wbr"]);
50
+ const RawTextElements = /*#__PURE__*/new Set(["style", "script", "noscript", "template", "textarea", "title"]);
51
+ 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(","));
24
52
 
25
- const effect = (fn, effectFn, initial) => solidJs.createRenderEffect(fn, effectFn, initial, {
26
- transparent: true
27
- });
28
- const memo = (fn, transparent) => transparent ? fn.$r ? fn : signals.createMemo(() => fn(), undefined, {
29
- transparent: true
30
- }) : solidJs.createMemo(() => fn());
53
+ const transparentOptions = {
54
+ transparent: true,
55
+ sync: true
56
+ };
57
+ const syncOptions = {
58
+ sync: true
59
+ };
60
+ const effect = (fn, effectFn, options) => solidJs.createRenderEffect(fn, effectFn, options ? {
61
+ sync: true,
62
+ ...options,
63
+ transparent: !options.scope
64
+ } : transparentOptions);
65
+ const memo = fn => solidJs.createMemo(() => fn(), syncOptions);
31
66
 
32
- const ES2017FLAG = seroval.Feature.AggregateError
33
- | seroval.Feature.BigIntTypedArray;
34
- const GLOBAL_IDENTIFIER = '_$HY.r';
35
- function createSerializer({
67
+ const DEFAULT_DISABLED_FEATURES = seroval.Feature.AggregateError | seroval.Feature.BigIntTypedArray;
68
+ const serializeOnlyDisabledFeatures = () => process.env.NODE_ENV === "development" ? 0 : seroval.Feature.ErrorPrototypeStack;
69
+ const HYDRATION_GLOBAL = "_$HY.r";
70
+ const DEFAULT_WEB_PLUGINS = Object.freeze([web.AbortSignalPlugin,
71
+ web.CustomEventPlugin, web.DOMExceptionPlugin, web.EventPlugin,
72
+ web.FormDataPlugin, web.HeadersPlugin, web.ReadableStreamPlugin, web.RequestPlugin, web.ResponsePlugin, web.URLSearchParamsPlugin, web.URLPlugin]);
73
+ function resolveSerializerPlugins(customPlugins) {
74
+ return customPlugins ? [...customPlugins, ...DEFAULT_WEB_PLUGINS] : [...DEFAULT_WEB_PLUGINS];
75
+ }
76
+ function createSerializer(options) {
77
+ return new seroval.Serializer({
78
+ ...options,
79
+ plugins: resolveSerializerPlugins(options.plugins),
80
+ disabledFeatures: (options.disabledFeatures === undefined ? DEFAULT_DISABLED_FEATURES : options.disabledFeatures) | serializeOnlyDisabledFeatures()
81
+ });
82
+ }
83
+ function createHydrationSerializer({
36
84
  onData,
37
85
  onDone,
38
86
  scopeId,
39
87
  onError,
40
- plugins: customPlugins
88
+ plugins
41
89
  }) {
42
- const defaultPlugins = [web.AbortSignalPlugin,
43
- web.CustomEventPlugin, web.DOMExceptionPlugin, web.EventPlugin,
44
- web.FormDataPlugin, web.HeadersPlugin, web.ReadableStreamPlugin, web.RequestPlugin, web.ResponsePlugin, web.URLSearchParamsPlugin, web.URLPlugin];
45
- const allPlugins = customPlugins ? [...customPlugins, ...defaultPlugins] : defaultPlugins;
46
- return new seroval.Serializer({
90
+ return createSerializer({
47
91
  scopeId,
48
- plugins: allPlugins,
49
- globalIdentifier: GLOBAL_IDENTIFIER,
50
- disabledFeatures: ES2017FLAG,
92
+ plugins,
93
+ globalIdentifier: HYDRATION_GLOBAL,
51
94
  onData,
52
95
  onDone,
53
96
  onError
54
97
  });
55
98
  }
56
99
  function getLocalHeaderScript(id) {
57
- return seroval.getCrossReferenceHeader(id) + ';';
100
+ return seroval.getCrossReferenceHeader(id) + ";";
58
101
  }
102
+ seroval.Feature.RegExp;
59
103
 
104
+ const HEAD_ELIGIBLE_TAGS = new Set(["title", "meta", "link", "style", "script", "base"]);
105
+ const HEAD_ATTR_NAME = /^[a-zA-Z_][a-zA-Z0-9_:.-]*$/;
106
+ const RESOURCE_LINK_RELS = new Set(["preload", "modulepreload", "prefetch", "preconnect", "dns-prefetch", "stylesheet"]);
107
+ const RESOURCE_QUALIFIERS = ["as", "crossorigin", "type", "media", "imagesrcset", "imagesizes"];
108
+ const STYLESHEET_FETCH_META = new Set(["crossorigin", "integrity", "referrerpolicy", "fetchpriority"]);
109
+ function evalHeadValue(v) {
110
+ return typeof v === "function" ? v() : v;
111
+ }
112
+ function evalHeadProps(props, presets) {
113
+ const out = {};
114
+ for (const name in props) out[name] = presets && name in presets ? presets[name] : evalHeadValue(props[name]);
115
+ return out;
116
+ }
117
+ function classifyHeadTag(desc) {
118
+ const tag = desc.tag;
119
+ if (tag === "link") {
120
+ const rel = evalHeadValue(desc.props && desc.props.rel);
121
+ return {
122
+ resource: RESOURCE_LINK_RELS.has(rel),
123
+ rel
124
+ };
125
+ }
126
+ if (tag === "style") return {
127
+ resource: !!(desc.props && "href" in desc.props)
128
+ };
129
+ if (tag === "script") return {
130
+ resource: !!(desc.props && "src" in desc.props)
131
+ };
132
+ return {
133
+ resource: false
134
+ };
135
+ }
136
+ function resourceIdentity(tag, props) {
137
+ let id = "res:" + tag + ":" + (props.rel || "") + ":" + (props.href || props.src || "");
138
+ for (let i = 0; i < RESOURCE_QUALIFIERS.length; i++) {
139
+ const q = RESOURCE_QUALIFIERS[i];
140
+ if (props[q] != null) id += ":" + q + "=" + props[q];
141
+ }
142
+ return id;
143
+ }
144
+ function replaceableIdentity(tag, props, key, unique) {
145
+ if (tag === "title") return "title";
146
+ if (tag === "base") return "base";
147
+ if (tag === "meta" && props.charset != null) return "charset";
148
+ if (key != null) return tag + ":key:" + key;
149
+ if (tag === "meta") {
150
+ for (const ns of ["name", "property", "http-equiv"]) if (props[ns] != null) return "meta:" + ns + ":" + props[ns] + (props.media != null ? ":media=" + props.media : "");
151
+ return unique;
152
+ }
153
+ if (tag === "link") {
154
+ const rel = props.rel || "";
155
+ if (rel === "icon" || rel === "apple-touch-icon") return "link:" + rel + (props.sizes != null ? ":sizes=" + props.sizes : "") + (props.type != null ? ":type=" + props.type : "");
156
+ return "link:" + rel + ":" + (props.href || "");
157
+ }
158
+ return unique;
159
+ }
160
+ function resolveHead(groups) {
161
+ const winners = new Map();
162
+ const sorted = groups.slice().sort((a, b) => a.seq - b.seq);
163
+ for (let i = 0; i < sorted.length; i++) {
164
+ const group = sorted[i];
165
+ const byIdentity = new Map();
166
+ for (let j = 0; j < group.tags.length; j++) {
167
+ const t = group.tags[j];
168
+ let list = byIdentity.get(t.identity);
169
+ if (!list) byIdentity.set(t.identity, list = []);
170
+ list.push(t);
171
+ }
172
+ for (const [identity, tags] of byIdentity) {
173
+ if (identity === "title") {
174
+ if (tags.length > 1) console.warn("Multiple <title> tags in one head group; the last one wins.");
175
+ winners.set(identity, {
176
+ seq: group.seq,
177
+ tags: [tags[tags.length - 1]]
178
+ });
179
+ } else {
180
+ winners.set(identity, {
181
+ seq: group.seq,
182
+ tags
183
+ });
184
+ }
185
+ }
186
+ }
187
+ return winners;
188
+ }
189
+
190
+ function joinAssetPath(base, file) {
191
+ if (/^(?:[a-z][a-z0-9+.-]*:)?\/\//i.test(file)) return file;
192
+ if (typeof base !== "string" || !base) base = "/";
193
+ if (base[base.length - 1] !== "/") base += "/";
194
+ return base + (file[0] === "/" ? file.slice(1) : file);
195
+ }
60
196
  function resolveAssets(moduleUrl, manifest) {
61
197
  if (!manifest) return null;
62
- const base = manifest._base || "/";
198
+ const base = manifest._base;
63
199
  const entry = manifest[moduleUrl];
64
200
  if (!entry) return null;
65
201
  const css = [];
@@ -70,8 +206,8 @@ function resolveAssets(moduleUrl, manifest) {
70
206
  visited.add(key);
71
207
  const e = manifest[key];
72
208
  if (!e) return;
73
- js.push(base + e.file);
74
- if (e.css) for (let i = 0; i < e.css.length; i++) css.push(base + e.css[i]);
209
+ js.push(joinAssetPath(base, e.file));
210
+ if (e.css) for (let i = 0; i < e.css.length; i++) css.push(joinAssetPath(base, e.css[i]));
75
211
  if (e.imports) for (let i = 0; i < e.imports.length; i++) walk(e.imports[i]);
76
212
  };
77
213
  walk(moduleUrl);
@@ -81,7 +217,7 @@ function resolveAssets(moduleUrl, manifest) {
81
217
  };
82
218
  }
83
219
  function registerEntryAssets(manifest) {
84
- if (!manifest) return;
220
+ if (!manifest || typeof manifest === "function" || typeof manifest.resolve === "function") return;
85
221
  const ctx = solidJs.sharedConfig.context;
86
222
  if (!ctx?.registerAsset) return;
87
223
  for (const key in manifest) {
@@ -98,25 +234,48 @@ function createAssetTracking() {
98
234
  const boundaryModules = new Map();
99
235
  const boundaryStyles = new Map();
100
236
  const emittedAssets = new Set();
237
+ const inlineStyles = new Map();
101
238
  let currentBoundaryId = null;
102
239
  return {
103
240
  boundaryModules,
104
241
  boundaryStyles,
105
242
  emittedAssets,
243
+ inlineStyles,
244
+ registerInlineStyle(desc) {
245
+ let entry = inlineStyles.get(desc.id);
246
+ if (!entry) {
247
+ entry = {
248
+ id: desc.id,
249
+ content: desc.content || "",
250
+ attrs: desc.attrs,
251
+ emitted: false
252
+ };
253
+ inlineStyles.set(desc.id, entry);
254
+ }
255
+ if (currentBoundaryId) {
256
+ let styles = boundaryStyles.get(currentBoundaryId);
257
+ if (!styles) {
258
+ styles = new Set();
259
+ boundaryStyles.set(currentBoundaryId, styles);
260
+ }
261
+ styles.add(entry);
262
+ }
263
+ return entry;
264
+ },
106
265
  get currentBoundaryId() {
107
266
  return currentBoundaryId;
108
267
  },
109
268
  set currentBoundaryId(v) {
110
269
  currentBoundaryId = v;
111
270
  },
112
- registerModule(moduleUrl, entryUrl) {
113
- if (!currentBoundaryId) return;
114
- let map = boundaryModules.get(currentBoundaryId);
271
+ registerModule(key, entryUrl) {
272
+ const id = currentBoundaryId || "";
273
+ let map = boundaryModules.get(id);
115
274
  if (!map) {
116
275
  map = {};
117
- boundaryModules.set(currentBoundaryId, map);
276
+ boundaryModules.set(id, map);
118
277
  }
119
- map[moduleUrl] = entryUrl;
278
+ map[key] = entryUrl;
120
279
  },
121
280
  getBoundaryModules(id) {
122
281
  return boundaryModules.get(id) || null;
@@ -126,7 +285,24 @@ function createAssetTracking() {
126
285
  }
127
286
  };
128
287
  }
129
- function applyAssetTracking(context, tracking, manifest) {
288
+ function warnUnresolvedModuleAssets(moduleUrl, warned) {
289
+ if (warned.has(moduleUrl)) return;
290
+ warned.add(moduleUrl);
291
+ console.error(`Asset manifest returned no client assets for module "${moduleUrl}". ` + "If this module is a server-rendered lazy() component, its entry will be missing from " + "the serialized hydration asset map, the client will be unable to preload it, and " + "hydration will fail with 'lazy() module \"…\" was not preloaded before hydration'. " + "This means the integration's asset resolver (dev manifest bridge or build client " + "manifest) failed to answer for this module — check the integration's server logs, " + "restart the dev server, or verify the module is included in the client build.");
292
+ }
293
+ function guardResolvedAssets(moduleUrl, result, warned) {
294
+ if (result && typeof result.then === "function") {
295
+ return result.then(assets => {
296
+ if (!assets || !assets.js || !assets.js.length) warnUnresolvedModuleAssets(moduleUrl, warned);
297
+ return assets;
298
+ });
299
+ }
300
+ if (!result || !result.js || !result.js.length) warnUnresolvedModuleAssets(moduleUrl, warned);
301
+ return result;
302
+ }
303
+ function applyAssetTracking(context, tracking, manifest, noScripts) {
304
+ const warned = new Set();
305
+ const guard = noScripts ? resolve => resolve : resolve => moduleUrl => guardResolvedAssets(moduleUrl, resolve(moduleUrl), warned);
130
306
  Object.defineProperty(context, "_currentBoundaryId", {
131
307
  get() {
132
308
  return tracking.currentBoundaryId;
@@ -139,19 +315,329 @@ function applyAssetTracking(context, tracking, manifest) {
139
315
  });
140
316
  context.registerModule = tracking.registerModule;
141
317
  context.getBoundaryModules = tracking.getBoundaryModules;
142
- if (manifest) context.resolveAssets = moduleUrl => resolveAssets(moduleUrl, manifest);
318
+ if (typeof manifest === "function") {
319
+ context.resolveAssets = guard(manifest);
320
+ } else if (manifest && typeof manifest.resolve === "function") {
321
+ context.resolveAssets = guard(key => manifest.resolve(key));
322
+ if (typeof manifest.resolveSync === "function") {
323
+ context.resolveAssetsSync = key => manifest.resolveSync(key);
324
+ }
325
+ } else if (manifest) {
326
+ const resolve = moduleUrl => resolveAssets(moduleUrl, manifest);
327
+ context.resolveAssets = guard(resolve);
328
+ context.resolveAssetsSync = resolve;
329
+ }
330
+ }
331
+ function isCssUrl(url) {
332
+ const q = url.search(/[?#]/);
333
+ return (q === -1 ? url : url.slice(0, q)).endsWith(".css");
334
+ }
335
+ function createHeadRegistry() {
336
+ return {
337
+ pending: [],
338
+ committed: [],
339
+ seq: 0,
340
+ uniq: 0,
341
+ resources: new Set(),
342
+ eagerHtml: "",
343
+ flushed: null,
344
+ shellFlushed: false
345
+ };
346
+ }
347
+ function registerHeadTags(registry, context, tracking, emitResource, nonce, tags) {
348
+ const boundary = context._currentBoundaryId || "";
349
+ if (typeof tags === "function") {
350
+ registry.pending.push({
351
+ boundary,
352
+ list: tags,
353
+ resource: (desc, rel) => emitHeadResource(registry, context, tracking, emitResource, nonce, desc, rel)
354
+ });
355
+ return;
356
+ }
357
+ if (!Array.isArray(tags)) tags = [tags];
358
+ let replaceable = null;
359
+ for (let i = 0; i < tags.length; i++) {
360
+ const desc = tags[i];
361
+ if (!desc || !HEAD_ELIGIBLE_TAGS.has(desc.tag)) {
362
+ console.warn(`useHead: ignoring non-head tag`, desc);
363
+ continue;
364
+ }
365
+ const cls = classifyHeadTag(desc);
366
+ if (cls.resource) {
367
+ emitHeadResource(registry, context, tracking, emitResource, nonce, desc, cls.rel);
368
+ } else {
369
+ (replaceable || (replaceable = [])).push(cls.rel !== undefined ? {
370
+ tag: desc.tag,
371
+ props: desc.props,
372
+ key: desc.key,
373
+ rel: cls.rel
374
+ } : desc);
375
+ }
376
+ }
377
+ if (replaceable) registry.pending.push({
378
+ boundary,
379
+ tags: replaceable
380
+ });
381
+ }
382
+ function emitHeadResource(registry, context, tracking, emitResource, nonce, desc, rel) {
383
+ let props;
384
+ try {
385
+ props = evalHeadProps(desc.props || {}, rel !== undefined ? {
386
+ rel
387
+ } : undefined);
388
+ } catch (err) {
389
+ console.warn(`useHead: error evaluating resource tag props`, err);
390
+ return;
391
+ }
392
+ const identity = resourceIdentity(desc.tag, props);
393
+ if (registry.resources.has(identity)) return;
394
+ registry.resources.add(identity);
395
+ if (desc.tag === "link" && (rel === "stylesheet" || rel === "modulepreload")) {
396
+ let plain = true;
397
+ let gateable = rel === "stylesheet";
398
+ for (const name in props) {
399
+ if (name === "rel" || name === "href") continue;
400
+ plain = false;
401
+ if (!STYLESHEET_FETCH_META.has(name)) gateable = false;
402
+ }
403
+ if (plain && props.href != null) {
404
+ const isCss = isCssUrl(props.href);
405
+ if (rel === "stylesheet" ? isCss : !isCss) {
406
+ context.registerAsset(rel === "stylesheet" ? "style" : "module", props.href);
407
+ return;
408
+ }
409
+ }
410
+ if (gateable && props.href != null) {
411
+ const attrHtml = renderHeadAttrHtml(props);
412
+ const entry = {
413
+ href: props.href,
414
+ attrHtml,
415
+ attrs: headAttrRecord(props)
416
+ };
417
+ if (tracking.currentBoundaryId) {
418
+ let styles = tracking.boundaryStyles.get(tracking.currentBoundaryId);
419
+ if (!styles) tracking.boundaryStyles.set(tracking.currentBoundaryId, styles = new Set());
420
+ styles.add(entry);
421
+ }
422
+ const markup = `<link${attrHtml}>`;
423
+ if (emitResource) emitResource(markup, entry);else {
424
+ registry.eagerHtml += markup;
425
+ entry.emitted = true;
426
+ }
427
+ return;
428
+ }
429
+ }
430
+ const url = props.href || props.src;
431
+ if (url != null && tracking.emittedAssets.has(url)) return;
432
+ const markup = renderHeadTagMarkup(desc.tag, props, null, nonce);
433
+ if (emitResource) emitResource(markup);else registry.eagerHtml += markup;
434
+ }
435
+ function commitHeadBoundary(registry, boundary, isPendingFragment) {
436
+ const keep = [];
437
+ const groups = [];
438
+ for (let i = 0; i < registry.pending.length; i++) {
439
+ const reg = registry.pending[i];
440
+ const mine = boundary === "" ? !(isPendingFragment && reg.boundary !== "" && isPendingFragment(reg.boundary)) : reg.boundary === boundary;
441
+ if (!mine) {
442
+ keep.push(reg);
443
+ continue;
444
+ }
445
+ let descs = reg.tags;
446
+ if (reg.list) {
447
+ let resolved;
448
+ try {
449
+ resolved = reg.list();
450
+ } catch (err) {
451
+ console.warn(`useHead: error evaluating head group membership`, err);
452
+ continue;
453
+ }
454
+ if (!Array.isArray(resolved)) resolved = [resolved];
455
+ descs = [];
456
+ for (let j = 0; j < resolved.length; j++) {
457
+ const desc = resolved[j];
458
+ if (!desc || !HEAD_ELIGIBLE_TAGS.has(desc.tag)) {
459
+ console.warn(`useHead: ignoring non-head tag`, desc);
460
+ continue;
461
+ }
462
+ const cls = classifyHeadTag(desc);
463
+ if (cls.resource) {
464
+ reg.resource(desc, cls.rel);
465
+ } else {
466
+ descs.push(cls.rel !== undefined ? {
467
+ tag: desc.tag,
468
+ props: desc.props,
469
+ key: desc.key,
470
+ rel: cls.rel
471
+ } : desc);
472
+ }
473
+ }
474
+ }
475
+ const tags = [];
476
+ for (let j = 0; j < descs.length; j++) {
477
+ const desc = descs[j];
478
+ let props, key;
479
+ try {
480
+ props = evalHeadProps(desc.props || {}, desc.rel !== undefined ? {
481
+ rel: desc.rel
482
+ } : undefined);
483
+ key = evalHeadValue(desc.key);
484
+ } catch (err) {
485
+ console.warn(`useHead: error evaluating tag props`, err);
486
+ continue;
487
+ }
488
+ const identity = replaceableIdentity(desc.tag, props, key, "u:" + registry.uniq++);
489
+ if ((identity === "base" || identity === "charset") && registry.shellFlushed) {
490
+ console.warn(`useHead: <${desc.tag}> (${identity}) registered after shell flush is ignored`);
491
+ continue;
492
+ }
493
+ tags.push({
494
+ tag: desc.tag,
495
+ props,
496
+ identity
497
+ });
498
+ }
499
+ if (tags.length) groups.push({
500
+ seq: registry.seq++,
501
+ tags
502
+ });
503
+ }
504
+ registry.pending = keep;
505
+ for (let i = 0; i < groups.length; i++) registry.committed.push(groups[i]);
506
+ return groups;
507
+ }
508
+ function adoptHeadBoundary(registry, childKey, parentKey) {
509
+ for (let i = 0; i < registry.pending.length; i++) {
510
+ if (registry.pending[i].boundary === childKey) registry.pending[i].boundary = parentKey;
511
+ }
512
+ }
513
+ function dropHeadBoundary(registry, boundary) {
514
+ registry.pending = registry.pending.filter(reg => reg.boundary !== boundary);
515
+ }
516
+ function headGroupSignature(winner) {
517
+ let sig = "" + winner.seq;
518
+ for (let i = 0; i < winner.tags.length; i++) {
519
+ const t = winner.tags[i];
520
+ sig += "|" + t.tag + JSON.stringify(t.props);
521
+ }
522
+ return sig;
523
+ }
524
+ function renderShellHead(registry, nonce, isPendingFragment) {
525
+ commitHeadBoundary(registry, "", isPendingFragment);
526
+ registry.shellFlushed = true;
527
+ const winners = resolveHead(registry.committed);
528
+ registry.flushed = new Map();
529
+ let prelude = "";
530
+ let links = "";
531
+ let metas = "";
532
+ let others = "";
533
+ let scripts = "";
534
+ for (const [identity, winner] of winners) {
535
+ registry.flushed.set(identity, headGroupSignature(winner));
536
+ for (let i = 0; i < winner.tags.length; i++) {
537
+ const t = winner.tags[i];
538
+ const markup = renderHeadTagMarkup(t.tag, t.props, identity, nonce);
539
+ if (identity === "charset" || identity === "base") prelude += markup;else if (t.tag === "link" || t.tag === "style") links += markup;else if (t.tag === "meta") metas += markup;else if (t.tag === "script") scripts += markup;else others += markup;
540
+ }
541
+ }
542
+ return {
543
+ prelude,
544
+ html: registry.eagerHtml + links + metas + others + scripts
545
+ };
546
+ }
547
+ function flushHeadFragment(registry, boundary) {
548
+ const groups = commitHeadBoundary(registry, boundary);
549
+ if (!groups.length) return null;
550
+ const winners = resolveHead(registry.committed);
551
+ const affected = new Set();
552
+ for (let i = 0; i < groups.length; i++) for (let j = 0; j < groups[i].tags.length; j++) affected.add(groups[i].tags[j].identity);
553
+ const ops = [];
554
+ for (const identity of affected) {
555
+ const winner = winners.get(identity);
556
+ const sig = headGroupSignature(winner);
557
+ if (registry.flushed.get(identity) === sig) continue;
558
+ const existed = registry.flushed.has(identity);
559
+ registry.flushed.set(identity, sig);
560
+ if (identity === "title") {
561
+ const children = winner.tags[0].props.children;
562
+ ops.push(["t", children == null ? "" : String(children)]);
563
+ continue;
564
+ }
565
+ if (existed) ops.push(["r", identity]);
566
+ for (let i = 0; i < winner.tags.length; i++) {
567
+ const t = winner.tags[i];
568
+ const attrs = {};
569
+ for (const name in t.props) {
570
+ if (name === "children" || name === "ref" || name.slice(0, 2) === "on") continue;
571
+ if (!HEAD_ATTR_NAME.test(name)) {
572
+ console.warn(`useHead: ignoring invalid attribute name "${name}"`);
573
+ continue;
574
+ }
575
+ const v = t.props[name];
576
+ if (v == null || v === false) continue;
577
+ attrs[name] = v === true ? "" : String(v);
578
+ }
579
+ const children = t.props.children;
580
+ ops.push(["a", identity, t.tag, attrs, children == null ? null : String(children)]);
581
+ }
582
+ }
583
+ return ops.length ? ops : null;
584
+ }
585
+ function renderHeadAttrHtml(props) {
586
+ let attrs = "";
587
+ for (const name in props) {
588
+ if (name === "children" || name === "ref" || name.slice(0, 2) === "on") continue;
589
+ if (!HEAD_ATTR_NAME.test(name)) {
590
+ console.warn(`useHead: ignoring invalid attribute name "${name}"`);
591
+ continue;
592
+ }
593
+ const v = props[name];
594
+ if (v == null || v === false) continue;
595
+ attrs += v === true ? ` ${name}` : ` ${name}="${escape(String(v), true)}"`;
596
+ }
597
+ return attrs;
598
+ }
599
+ function headAttrRecord(props, skipRelHref) {
600
+ let attrs = null;
601
+ for (const name in props) {
602
+ if (name === "children" || name === "ref" || name.slice(0, 2) === "on") continue;
603
+ if ((name === "rel" || name === "href")) continue;
604
+ if (!HEAD_ATTR_NAME.test(name)) continue;
605
+ const v = props[name];
606
+ if (v == null || v === false) continue;
607
+ (attrs || (attrs = {}))[name] = v === true ? "" : String(v);
608
+ }
609
+ return attrs;
610
+ }
611
+ function renderHeadTagMarkup(tag, props, identity, nonce) {
612
+ let attrs = renderHeadAttrHtml(props);
613
+ if (identity != null) attrs += ` data-dh="${escape(identity, true)}"`;
614
+ if (nonce && (tag === "script" || tag === "style")) attrs += ` nonce="${nonce}"`;
615
+ if (tag === "meta" || tag === "link" || tag === "base") return `<${tag}${attrs}>`;
616
+ let body = props.children == null ? "" : String(props.children);
617
+ if (tag === "script") body = body.replace(/<\/(script)/gi, "<\\/$1");else if (tag === "style") body = escapeStyleContent(body);else body = escape(body);
618
+ return `<${tag}${attrs}>${body}</${tag}>`;
619
+ }
620
+ function useHead(tags) {
621
+ const ctx = solidJs.sharedConfig.context;
622
+ if (!ctx || !ctx.registerHeadTags) {
623
+ console.warn("useHead() called outside of a server render; registration ignored.");
624
+ return;
625
+ }
626
+ ctx.registerHeadTags(tags);
143
627
  }
144
628
  const VOID_ELEMENTS = /^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/i;
145
- const REPLACE_SCRIPT = `function $df(e,n,o,t){if(n=document.getElementById(e),o=document.getElementById("pl-"+e)){for(;o&&8!==o.nodeType&&o.nodeValue!=="pl-"+e;)t=o.nextSibling,o.remove(),o=t;_$HY.done?o.remove():o.replaceWith(n.content)}n.remove(),_$HY.fe(e)}function $dfs(e,c){(_$HY.sc=_$HY.sc||{})[e]=c}function $dfc(e){if(--_$HY.sc[e]<=0)delete _$HY.sc[e],$df(e)}`;
629
+ const REPLACE_SCRIPT = `function $df(e){return _$HY.f?_$HY.f(e):$dfr(e)}function $dfr(e,n,o,t){if(!(n=document.getElementById(e)))return 0;if(!(o=document.getElementById("pl-"+e)))return(_$HY.dq=_$HY.dq||{})[e]=1,0;for(;o&&(8!==o.nodeType||o.nodeValue!=="pl-"+e);)t=o.nextSibling,o.remove(),o=t;t=o.parentNode,o.replaceWith(n.content),n.remove(),(_$HY.v=_$HY.v||{})[e]=1,_$HY.fe(e,t),_$HY.hp&&_$HY.hp[e]&&($dh(_$HY.hp[e]),delete _$HY.hp[e]),$dfd();return 1}function $dfl(e,o,n){if(!(o=document.getElementById("pl-"+e)))return(_$HY.dlq=_$HY.dlq||{})[e]=1,0;if(o._$fl)return 1;for(n=o.nextSibling;n;){if(8===n.nodeType&&n.nodeValue==="pl-"+e){o.parentNode&&o.parentNode.insertBefore(o.content.cloneNode(!0),n),o._$fl=1,$dfd();return 1}n=n.nextSibling}return 0}function $dflj(e,i){for(i=0;i<e.length;i++)$dfl(e[i])}function $dfd(e,i){if(e=_$HY.dq){_$HY.dq=0;for(i in e)$df(i)}if(e=_$HY.dlq){_$HY.dlq=0;for(i in e)$dfl(i)}}function $dfs(e,c,d){(_$HY.sc=_$HY.sc||{})[e]=c,d&&((_$HY.sd=_$HY.sd||{})[e]=1)}function $dfg(e,g,i,k){if(!(g=_$HY.sg&&_$HY.sg[e]))return;for(i=0;i<g.length;i++)if(_$HY.sc&&_$HY.sc[g[i]]>0)return;for(i=0;i<g.length;i++)k=g[i],delete _$HY.sg[k],$df(k)}function $dfc(e){if(--_$HY.sc[e]<=0){delete _$HY.sc[e],_$HY.sg&&_$HY.sg[e]?$dfg(e):!(_$HY.sd&&_$HY.sd[e])&&$df(e);_$HY.sd&&delete _$HY.sd[e]}}function $dfj(e,i,n){for(i=0;i<e.length;i++)if(_$HY.sc&&_$HY.sc[e[i]]>0){for(n=0;n<e.length;n++)(_$HY.sg=_$HY.sg||{})[e[n]]=e;return}for(i=0;i<e.length;i++)$df(e[i])}`;
630
+ const HEAD_SCRIPT = `function $dha(o,i,e,n){for(i=0;i<o.length;i++)e=o[i],"t"==e[0]?((n=document.querySelector("title"))||(n=document.createElement("title"),document.head.appendChild(n)),n.textContent=e[1],n.setAttribute("data-dh","title")):"r"==e[0]?$dhr(e[1]):(n=document.createElement(e[2]),Object.keys(e[3]).forEach(function(a){n.setAttribute(a,e[3][a])}),null!=e[4]&&(n.textContent=e[4]),n.setAttribute("data-dh",e[1]),document.head.appendChild(n))}function $dhr(v,l,i){for(l=document.head.querySelectorAll("[data-dh]"),i=0;i<l.length;i++)l[i].getAttribute("data-dh")==v&&l[i].remove()}function $dh(o){_$HY.h?_$HY.h(o):$dha(o)}`;
146
631
  function renderToString(code, options = {}) {
147
632
  const {
148
633
  renderId = "",
149
634
  nonce,
150
635
  noScripts,
151
- manifest
636
+ manifest,
637
+ onHead
152
638
  } = options;
153
639
  let scripts = "";
154
- const serializer = createSerializer({
640
+ const serializer = createHydrationSerializer({
155
641
  scopeId: renderId,
156
642
  plugins: options.plugins,
157
643
  onData(script) {
@@ -164,12 +650,16 @@ function renderToString(code, options = {}) {
164
650
  onError: options.onError
165
651
  });
166
652
  const tracking = createAssetTracking();
653
+ const headRegistry = createHeadRegistry();
167
654
  solidJs.sharedConfig.context = {
168
655
  assets: [],
169
656
  nonce,
170
657
  escape: escape,
171
658
  resolve: resolveSSRNode,
172
659
  ssr: ssr,
660
+ registerHeadTags(tags) {
661
+ registerHeadTags(headRegistry, solidJs.sharedConfig.context, tracking, null, nonce, tags);
662
+ },
173
663
  serialize(id, p) {
174
664
  if (solidJs.sharedConfig.context.noHydrate) return;
175
665
  if (p != null && typeof p === "object" && (typeof p.then === "function" || typeof p[Symbol.asyncIterator] === "function")) {
@@ -177,19 +667,23 @@ function renderToString(code, options = {}) {
177
667
  }
178
668
  serializer.write(id, p);
179
669
  },
180
- registerAsset(type, url) {
670
+ registerAsset(type, value) {
671
+ if (type === "inline-style") {
672
+ tracking.registerInlineStyle(value);
673
+ return;
674
+ }
181
675
  if (tracking.currentBoundaryId && type === "style") {
182
676
  let styles = tracking.boundaryStyles.get(tracking.currentBoundaryId);
183
677
  if (!styles) {
184
678
  styles = new Set();
185
679
  tracking.boundaryStyles.set(tracking.currentBoundaryId, styles);
186
680
  }
187
- styles.add(url);
681
+ styles.add(value);
188
682
  }
189
- tracking.emittedAssets.add(url);
683
+ tracking.emittedAssets.add(value);
190
684
  }
191
685
  };
192
- applyAssetTracking(solidJs.sharedConfig.context, tracking, manifest);
686
+ applyAssetTracking(solidJs.sharedConfig.context, tracking, manifest, noScripts);
193
687
  registerEntryAssets(manifest);
194
688
  let html = solidJs.createRoot(d => {
195
689
  setTimeout(d);
@@ -197,12 +691,12 @@ function renderToString(code, options = {}) {
197
691
  }, {
198
692
  id: renderId
199
693
  });
694
+ serializeFragmentAssets("", tracking.boundaryModules, solidJs.sharedConfig.context);
200
695
  solidJs.sharedConfig.context.noHydrate = true;
201
696
  serializer.close();
202
- html = injectAssets(solidJs.sharedConfig.context.assets, html);
203
- html = injectPreloadLinks(tracking.emittedAssets, html);
204
- if (scripts.length) html = injectScripts(html, scripts, options.nonce);
205
- return html;
697
+ const assetsHtml = resolveAssetsHtml(solidJs.sharedConfig.context.assets);
698
+ const head = renderShellHead(headRegistry, nonce, null);
699
+ return assembleDocument(html, assetsHtml, tracking.emittedAssets, tracking.inlineStyles, scripts.length ? scripts : "", nonce, head, onHead);
206
700
  }
207
701
  function renderToStream(code, options = {}) {
208
702
  let {
@@ -211,18 +705,57 @@ function renderToStream(code, options = {}) {
211
705
  onCompleteAll,
212
706
  renderId = "",
213
707
  noScripts,
214
- manifest
708
+ manifest,
709
+ onHead
215
710
  } = options;
216
711
  let dispose;
712
+ let dead = false;
713
+ const abandon = () => {
714
+ if (dead) return;
715
+ dead = true;
716
+ completed = true;
717
+ buffer = {
718
+ write() {}
719
+ };
720
+ writable = {
721
+ end() {}
722
+ };
723
+ if (dispose) {
724
+ const d = dispose;
725
+ dispose = () => {};
726
+ d();
727
+ }
728
+ };
729
+ const guardSink = w => ({
730
+ write(payload) {
731
+ if (dead) return;
732
+ try {
733
+ w.write(payload);
734
+ } catch (_) {
735
+ abandon();
736
+ }
737
+ },
738
+ end() {
739
+ if (dead) return;
740
+ try {
741
+ w.end();
742
+ } catch (_) {
743
+ abandon();
744
+ }
745
+ }
746
+ });
217
747
  const blockingPromises = new Set();
748
+ let headerEmitted = false;
218
749
  const pushTask = task => {
219
750
  if (noScripts) return;
220
- if (!tasks && !firstFlushed) {
221
- tasks = getLocalHeaderScript(renderId);
751
+ if (!headerEmitted) {
752
+ headerEmitted = true;
753
+ tasks += getLocalHeaderScript(renderId);
222
754
  }
223
755
  tasks += task + ";";
224
756
  if (!timer && firstFlushed) {
225
- timer = setTimeout(writeTasks);
757
+ timer = true;
758
+ queue(() => queue(writeTasks));
226
759
  }
227
760
  };
228
761
  const onDone = () => {
@@ -237,15 +770,63 @@ function renderToStream(code, options = {}) {
237
770
  completed = true;
238
771
  if (firstFlushed) dispose();
239
772
  };
240
- const serializer = createSerializer({
773
+ const sink = {
774
+ data(payload) {
775
+ pushTask(payload);
776
+ },
777
+ fragment(key, value, meta) {
778
+ const deferActivation = !!meta.revealGroup;
779
+ const styles = meta.styles;
780
+ for (let i = 0; i < styles.inline.length; i++) {
781
+ buffer.write(renderInlineStyle(styles.inline[i], nonce));
782
+ }
783
+ if (styles.links.length) {
784
+ emitTask(`$dfs("${key}",${styles.links.length},${deferActivation ? 1 : 0})`);
785
+ writeTasks();
786
+ for (const entry of styles.links) {
787
+ buffer.write(typeof entry === "string" ? `<link rel="stylesheet" href="${entry}" onload="$dfc('${key}')" onerror="$dfc('${key}')">` : `<link${entry.attrHtml} onload="$dfc('${key}')" onerror="$dfc('${key}')">`);
788
+ }
789
+ buffer.write(`<template id="${key}">${value}</template>`);
790
+ } else {
791
+ buffer.write(`<template id="${key}">${value}</template>`);
792
+ if (!deferActivation) {
793
+ emitTask(`$df("${key}")`);
794
+ }
795
+ }
796
+ },
797
+ reveal(keys, meta) {
798
+ emitTask(`${meta.fallback ? "$dflj" : "$dfj"}(${JSON.stringify(keys)})`);
799
+ },
800
+ asset(type, value) {
801
+ if (type === "module") {
802
+ buffer.write(`<link rel="modulepreload" href="${value}">`);
803
+ } else if (type === "inline-style") {
804
+ buffer.write(renderInlineStyle(value, nonce));
805
+ } else if (type === "head-tag") {
806
+ buffer.write(value);
807
+ }
808
+ },
809
+ shell(shellHtml, meta) {
810
+ buffer.write(assembleDocument(shellHtml, meta.assets, meta.preloads, meta.inlineStyles, meta.tasks.length ? meta.tasks : "", nonce, meta.head, onHead));
811
+ },
812
+ ...options.sink
813
+ };
814
+ const serializer = (options.serializer || createHydrationSerializer)({
241
815
  scopeId: options.renderId,
242
816
  plugins: options.plugins,
243
- onData: pushTask,
817
+ onData: payload => sink.data(payload),
244
818
  onDone,
245
819
  onError: options.onError
246
820
  });
821
+ let rootAssetsSerialized = false;
822
+ const serializeRootAssets = () => {
823
+ if (rootAssetsSerialized) return;
824
+ rootAssetsSerialized = true;
825
+ serializeFragmentAssets("", tracking.boundaryModules, context);
826
+ };
247
827
  const flushEnd = () => {
248
828
  if (!registry.size) {
829
+ serializeRootAssets();
249
830
  queue(() => queue(() => serializer.flush()));
250
831
  }
251
832
  };
@@ -255,7 +836,6 @@ function renderToStream(code, options = {}) {
255
836
  buffer.write(`<script${nonce ? ` nonce="${nonce}"` : ""}>${tasks}</script>`);
256
837
  tasks = "";
257
838
  }
258
- timer && clearTimeout(timer);
259
839
  timer = null;
260
840
  };
261
841
  let context;
@@ -267,7 +847,29 @@ function renderToStream(code, options = {}) {
267
847
  let shellCompleted = false;
268
848
  let scriptFlushed = false;
269
849
  let headStyles;
850
+ const revealGroups = new Map();
270
851
  let timer = null;
852
+ const emitTask = task => {
853
+ pushTask(`${task}${!scriptFlushed ? ";" + REPLACE_SCRIPT : ""}`);
854
+ scriptFlushed = true;
855
+ };
856
+ function resolveRevealKeys(groupOrKeys, release, consume) {
857
+ if (Array.isArray(groupOrKeys)) return groupOrKeys.slice();
858
+ let group = revealGroups.get(groupOrKeys);
859
+ if (!group) {
860
+ if (!release) return;
861
+ group = {
862
+ order: [],
863
+ keys: new Set(),
864
+ released: true
865
+ };
866
+ revealGroups.set(groupOrKeys, group);
867
+ } else if (release) group.released = true;
868
+ if (!group.order.length) return;
869
+ const keys = group.order.slice();
870
+ if (consume) revealGroups.delete(groupOrKeys);
871
+ return keys;
872
+ }
271
873
  let rootHoles = null;
272
874
  let nextHoleId = 0;
273
875
  let buffer = {
@@ -276,24 +878,48 @@ function renderToStream(code, options = {}) {
276
878
  }
277
879
  };
278
880
  const tracking = createAssetTracking();
881
+ const headRegistry = createHeadRegistry();
882
+ let headScriptFlushed = false;
883
+ const emitHeadOps = (key, ops) => {
884
+ const payload = JSON.stringify(ops).replace(/</g, "\\u003C");
885
+ emitTask(`${!headScriptFlushed ? HEAD_SCRIPT : ""}(_$HY.hp=_$HY.hp||{})[${JSON.stringify(key)}]=${payload}`);
886
+ headScriptFlushed = true;
887
+ };
279
888
  solidJs.sharedConfig.context = context = {
280
889
  async: true,
281
890
  assets: [],
282
891
  nonce,
283
- registerAsset(type, url) {
892
+ registerHeadTags(tags) {
893
+ registerHeadTags(headRegistry, context, tracking,
894
+ (markup, gateEntry) => {
895
+ if (!firstFlushed) {
896
+ headRegistry.eagerHtml += markup;
897
+ if (gateEntry) gateEntry.emitted = true;
898
+ } else if (!gateEntry || !tracking.currentBoundaryId) {
899
+ sink.asset("head-tag", markup);
900
+ }
901
+ }, nonce, tags);
902
+ },
903
+ registerAsset(type, value) {
904
+ if (type === "inline-style") {
905
+ const entry = tracking.registerInlineStyle(value);
906
+ if (firstFlushed && !tracking.currentBoundaryId && !entry.emitted) {
907
+ entry.emitted = true;
908
+ sink.asset("inline-style", entry);
909
+ }
910
+ return;
911
+ }
284
912
  if (tracking.currentBoundaryId && type === "style") {
285
913
  let styles = tracking.boundaryStyles.get(tracking.currentBoundaryId);
286
914
  if (!styles) {
287
915
  styles = new Set();
288
916
  tracking.boundaryStyles.set(tracking.currentBoundaryId, styles);
289
917
  }
290
- styles.add(url);
918
+ styles.add(value);
291
919
  }
292
- if (!tracking.emittedAssets.has(url)) {
293
- tracking.emittedAssets.add(url);
294
- if (firstFlushed && type === "module") {
295
- buffer.write(`<link rel="modulepreload" href="${url}">`);
296
- }
920
+ if (!tracking.emittedAssets.has(value)) {
921
+ tracking.emittedAssets.add(value);
922
+ if (firstFlushed) sink.asset(type, value);
297
923
  }
298
924
  },
299
925
  block(p) {
@@ -317,7 +943,26 @@ function renderToStream(code, options = {}) {
317
943
  escape: escape,
318
944
  resolve: resolveSSRNode,
319
945
  ssr: ssr,
320
- registerFragment(key) {
946
+ registerFragment(key, options) {
947
+ const revealGroup = options && options.revealGroup;
948
+ if (revealGroup) {
949
+ let group = revealGroups.get(revealGroup);
950
+ if (!group) {
951
+ group = {
952
+ order: [],
953
+ keys: new Set(),
954
+ released: false
955
+ };
956
+ revealGroups.set(revealGroup, group);
957
+ }
958
+ if (!group.keys.has(key)) {
959
+ group.keys.add(key);
960
+ group.order.push(key);
961
+ }
962
+ if (group.released) {
963
+ throw new Error("registerFragment() for reveal group '" + revealGroup + "' was called after revealFragments(). Ensure template payload is emitted before grouped reveal.");
964
+ }
965
+ }
321
966
  if (!registry.has(key)) {
322
967
  let resolve, reject;
323
968
  const p = new Promise((r, rej) => (resolve = r, reject = rej));
@@ -327,7 +972,7 @@ function renderToStream(code, options = {}) {
327
972
  queue(flushEnd);
328
973
  }))
329
974
  });
330
- serializer.write(key, p);
975
+ serializer.write(key + "_fr", p);
331
976
  }
332
977
  return (value, error) => {
333
978
  if (registry.has(key)) {
@@ -345,10 +990,12 @@ function renderToStream(code, options = {}) {
345
990
  parent.children[key] = value !== undefined ? value : "";
346
991
  serializeFragmentAssets(key, tracking.boundaryModules, context);
347
992
  propagateBoundaryStyles(key, parentKey, tracking);
993
+ adoptHeadBoundary(headRegistry, key, parentKey);
348
994
  item.resolve();
349
995
  return;
350
996
  }
351
997
  if (!completed) {
998
+ if (error) dropHeadBoundary(headRegistry, key);
352
999
  if (!firstFlushed) {
353
1000
  queue(() => html = replacePlaceholder(html, key, value !== undefined ? value : ""));
354
1001
  serializeFragmentAssets(key, tracking.boundaryModules, context);
@@ -356,28 +1003,36 @@ function renderToStream(code, options = {}) {
356
1003
  } else {
357
1004
  serializeFragmentAssets(key, tracking.boundaryModules, context);
358
1005
  const styles = collectStreamStyles(key, tracking, headStyles);
359
- if (styles.length) {
360
- pushTask(`$dfs("${key}",${styles.length})${!scriptFlushed ? ";" + REPLACE_SCRIPT : ""}`);
361
- scriptFlushed = true;
362
- writeTasks();
363
- for (const url of styles) {
364
- buffer.write(`<link rel="stylesheet" href="${url}" onload="$dfc('${key}')" onerror="$dfc('${key}')">`);
365
- }
366
- buffer.write(`<template id="${key}">${value !== undefined ? value : " "}</template>`);
367
- } else {
368
- buffer.write(`<template id="${key}">${value !== undefined ? value : " "}</template>`);
369
- pushTask(`$df("${key}")${!scriptFlushed ? ";" + REPLACE_SCRIPT : ""}`);
370
- scriptFlushed = true;
371
- }
1006
+ const headOps = error ? null : flushHeadFragment(headRegistry, key);
1007
+ if (headOps) emitHeadOps(key, headOps);
1008
+ sink.fragment(key, value !== undefined ? value : " ", {
1009
+ styles,
1010
+ revealGroup,
1011
+ error
1012
+ });
372
1013
  item.resolve(error);
373
1014
  }
374
1015
  }
375
1016
  }
376
1017
  return firstFlushed;
377
1018
  };
1019
+ },
1020
+ revealFragments(groupOrKeys) {
1021
+ const keys = resolveRevealKeys(groupOrKeys, true, true);
1022
+ if (!keys) return;
1023
+ sink.reveal(keys, {
1024
+ fallback: false
1025
+ });
1026
+ },
1027
+ revealFallbacks(groupOrKeys) {
1028
+ const keys = resolveRevealKeys(groupOrKeys, false, false);
1029
+ if (!keys) return;
1030
+ sink.reveal(keys, {
1031
+ fallback: true
1032
+ });
378
1033
  }
379
1034
  };
380
- applyAssetTracking(context, tracking, manifest);
1035
+ applyAssetTracking(context, tracking, manifest, noScripts);
381
1036
  registerEntryAssets(manifest);
382
1037
  let html = solidJs.createRoot(d => {
383
1038
  dispose = d;
@@ -398,28 +1053,56 @@ function renderToStream(code, options = {}) {
398
1053
  }, {
399
1054
  id: renderId
400
1055
  });
401
- function doShell() {
402
- if (shellCompleted) return;
403
- if (rootHoles) {
404
- for (const {
405
- id,
406
- fn
407
- } of rootHoles) {
408
- const marker = `<!--rh${id}-->`;
409
- const res = resolveSSRNode(fn);
410
- html = html.replace(marker, !res.h.length ? res.t[0] : "");
1056
+ function resolveRootHoles() {
1057
+ if (!rootHoles) return true;
1058
+ const pending = [];
1059
+ for (const {
1060
+ id,
1061
+ fn
1062
+ } of rootHoles) {
1063
+ const marker = `<!--rh${id}-->`;
1064
+ const res = resolveSSRNode(fn);
1065
+ if (!res.h.length) {
1066
+ html = html.replace(marker, res.t[0]);
1067
+ } else {
1068
+ let out = res.t[0];
1069
+ for (let j = 0; j < res.h.length; j++) {
1070
+ const newId = nextHoleId++;
1071
+ pending.push({
1072
+ id: newId,
1073
+ fn: res.h[j]
1074
+ });
1075
+ out += `<!--rh${newId}-->` + res.t[j + 1];
1076
+ }
1077
+ html = html.replace(marker, out);
1078
+ for (const p of res.p) blockingPromises.add(p);
411
1079
  }
412
- rootHoles = null;
413
1080
  }
1081
+ if (pending.length) {
1082
+ rootHoles = pending;
1083
+ return false;
1084
+ }
1085
+ rootHoles = null;
1086
+ return true;
1087
+ }
1088
+ function doShell() {
1089
+ if (shellCompleted) return;
414
1090
  solidJs.sharedConfig.context = context;
415
- html = injectAssets(context.assets, html);
1091
+ if (!resolveRootHoles()) return;
1092
+ const assetsHtml = resolveAssetsHtml(context.assets);
416
1093
  headStyles = new Set();
417
1094
  for (const url of tracking.emittedAssets) {
418
- if (url.endsWith(".css")) headStyles.add(url);
1095
+ if (isCssUrl(url)) headStyles.add(url);
419
1096
  }
420
- html = injectPreloadLinks(tracking.emittedAssets, html);
421
- if (tasks.length) html = injectScripts(html, tasks, nonce);
422
- buffer.write(html);
1097
+ serializeRootAssets();
1098
+ const head = renderShellHead(headRegistry, nonce, k => registry.has(k));
1099
+ sink.shell(html, {
1100
+ assets: assetsHtml,
1101
+ preloads: tracking.emittedAssets,
1102
+ inlineStyles: tracking.inlineStyles,
1103
+ tasks,
1104
+ head
1105
+ });
423
1106
  tasks = "";
424
1107
  onCompleteShell && onCompleteShell({
425
1108
  write(v) {
@@ -428,53 +1111,67 @@ function renderToStream(code, options = {}) {
428
1111
  });
429
1112
  shellCompleted = true;
430
1113
  }
431
- return {
432
- then(fn) {
433
- function complete() {
434
- dispose();
435
- fn(tmp);
1114
+ const MIN_DRAIN_TURNS = 8;
1115
+ let lastBlockingSize = -1;
1116
+ let lastRegistrySize = -1;
1117
+ let drainTurn = 0;
1118
+ const scheduleFlush = fn => {
1119
+ const attempt = () => {
1120
+ if (registry.size !== lastRegistrySize || drainTurn++ < MIN_DRAIN_TURNS) {
1121
+ if (registry.size !== lastRegistrySize) drainTurn = 0;
1122
+ lastRegistrySize = registry.size;
1123
+ queue(attempt);
1124
+ return;
436
1125
  }
437
- if (onCompleteAll) {
438
- let ogComplete = onCompleteAll;
439
- onCompleteAll = options => {
440
- ogComplete(options);
441
- complete();
442
- };
443
- } else onCompleteAll = complete;
444
- queue(flushEnd);
445
- },
446
- pipe(w) {
1126
+ fn();
1127
+ };
1128
+ const progressed = blockingPromises.size !== lastBlockingSize;
1129
+ lastBlockingSize = blockingPromises.size;
1130
+ lastRegistrySize = -1;
1131
+ drainTurn = 0;
1132
+ progressed ? queue(attempt) : setTimeout(attempt);
1133
+ };
1134
+ let cachedReadable;
1135
+ let consumer;
1136
+ const claimConsumer = name => {
1137
+ if (consumer && consumer !== name) {
1138
+ throw new Error(`renderToStream result was already consumed via \`${consumer}\`; cannot also consume it via \`${name}\`. Use exactly one of \`pipe\`, \`pipeTo\`, or \`readable\`.`);
1139
+ }
1140
+ consumer = name;
1141
+ };
1142
+ const pipeToImpl = w => {
1143
+ let resolve;
1144
+ const p = new Promise(r => resolve = r);
1145
+ function flush() {
447
1146
  allSettled(blockingPromises).then(() => {
448
- setTimeout(() => {
449
- doShell();
450
- buffer = writable = w;
451
- buffer.write(tmp);
452
- firstFlushed = true;
453
- if (completed) {
454
- dispose();
455
- writable.end();
456
- } else flushEnd();
457
- });
458
- });
459
- },
460
- pipeTo(w) {
461
- return allSettled(blockingPromises).then(() => {
462
- let resolve;
463
- const p = new Promise(r => resolve = r);
464
- setTimeout(() => {
1147
+ scheduleFlush(() => {
1148
+ if (dead) return resolve();
465
1149
  doShell();
1150
+ if (!shellCompleted) return flush();
466
1151
  const encoder = new TextEncoder();
467
1152
  const writer = w.getWriter();
1153
+ let pendingWrites = Promise.resolve();
1154
+ let ended = false;
1155
+ const failed = () => {
1156
+ if (!ended) {
1157
+ abandon();
1158
+ resolve();
1159
+ }
1160
+ };
1161
+ writer.closed && writer.closed.catch(failed);
468
1162
  writable = {
469
1163
  end() {
470
- writer.releaseLock();
471
- w.close().catch(() => {});
472
- resolve();
1164
+ pendingWrites.then(() => {
1165
+ ended = true;
1166
+ writer.releaseLock();
1167
+ w.close().catch(() => {});
1168
+ resolve();
1169
+ });
473
1170
  }
474
1171
  };
475
1172
  buffer = {
476
1173
  write(payload) {
477
- writer.write(encoder.encode(payload)).catch(() => {});
1174
+ pendingWrites = pendingWrites.then(() => writer.write(encoder.encode(payload))).catch(failed);
478
1175
  }
479
1176
  };
480
1177
  buffer.write(tmp);
@@ -484,9 +1181,67 @@ function renderToStream(code, options = {}) {
484
1181
  writable.end();
485
1182
  } else flushEnd();
486
1183
  });
487
- return p;
488
1184
  });
489
1185
  }
1186
+ flush();
1187
+ return p;
1188
+ };
1189
+ return {
1190
+ then(fn) {
1191
+ function complete() {
1192
+ dispose();
1193
+ fn(tmp);
1194
+ }
1195
+ if (onCompleteAll) {
1196
+ let ogComplete = onCompleteAll;
1197
+ onCompleteAll = options => {
1198
+ ogComplete(options);
1199
+ complete();
1200
+ };
1201
+ } else onCompleteAll = complete;
1202
+ function flush() {
1203
+ allSettled(blockingPromises).then(() => {
1204
+ scheduleFlush(() => {
1205
+ if (!resolveRootHoles()) return flush();
1206
+ queue(flushEnd);
1207
+ });
1208
+ });
1209
+ }
1210
+ flush();
1211
+ },
1212
+ pipe(w) {
1213
+ claimConsumer("pipe");
1214
+ function flush() {
1215
+ allSettled(blockingPromises).then(() => {
1216
+ scheduleFlush(() => {
1217
+ if (dead) return;
1218
+ doShell();
1219
+ if (!shellCompleted) return flush();
1220
+ buffer = writable = guardSink(w);
1221
+ buffer.write(tmp);
1222
+ firstFlushed = true;
1223
+ if (completed) {
1224
+ dispose();
1225
+ writable.end();
1226
+ } else flushEnd();
1227
+ });
1228
+ });
1229
+ }
1230
+ flush();
1231
+ },
1232
+ pipeTo(w) {
1233
+ claimConsumer("pipeTo");
1234
+ return pipeToImpl(w);
1235
+ },
1236
+ get readable() {
1237
+ claimConsumer("readable");
1238
+ if (!cachedReadable) {
1239
+ const t = new TransformStream();
1240
+ pipeToImpl(t.writable);
1241
+ cachedReadable = t.readable;
1242
+ }
1243
+ return cachedReadable;
1244
+ }
490
1245
  };
491
1246
  }
492
1247
  function HydrationScript(props) {
@@ -498,11 +1253,176 @@ function HydrationScript(props) {
498
1253
  ...props
499
1254
  }));
500
1255
  }
501
- function ssr(t, ...nodes) {
502
- if (nodes.length) return resolveSSR(t, nodes);
1256
+ function ssrGroup(fn, n) {
1257
+ fn.$g = n;
1258
+ return fn;
1259
+ }
1260
+ function buildAsyncWrap(err, node) {
1261
+ const p = solidJs.ssrHandleError(err);
1262
+ if (!p) return null;
1263
+ const owner = solidJs.getOwner();
503
1264
  return {
1265
+ fn: owner ? () => solidJs.runWithOwner(owner, node) : node,
1266
+ p
1267
+ };
1268
+ }
1269
+ function ssrFirstGroupHit(hole) {
1270
+ try {
1271
+ return hole();
1272
+ } catch (err) {
1273
+ return buildAsyncWrap(err, hole);
1274
+ }
1275
+ }
1276
+ function tryResolveFunctionHole(hole) {
1277
+ let value;
1278
+ try {
1279
+ value = hole();
1280
+ } catch (err) {
1281
+ return buildAsyncWrap(err, hole) || "";
1282
+ }
1283
+ const t = typeof value;
1284
+ if (t === "string") return value;
1285
+ if (t === "number") return "" + value;
1286
+ if (value == null || t === "boolean") return "";
1287
+ return tryResolveString(value);
1288
+ }
1289
+ function mergeTemplateInto(result, node) {
1290
+ result.t[result.t.length - 1] += node.t[0];
1291
+ if (node.t.length > 1) {
1292
+ result.t.push(...node.t.slice(1));
1293
+ result.h.push(...node.h);
1294
+ result.p.push(...node.p);
1295
+ }
1296
+ }
1297
+ function appendResolvedNode(result, node) {
1298
+ if (node.fn !== undefined) {
1299
+ result.h.push(node.fn);
1300
+ result.p.push(node.p);
1301
+ result.t.push("");
1302
+ } else if (node.merge !== undefined) mergeTemplateInto(result, node.merge);else resolveSSRNode(node.bail, result);
1303
+ }
1304
+ let _lastGroupFn = null;
1305
+ let _lastGroupArr = null;
1306
+ let _lastGroupErr = null;
1307
+ function ssrGroupSlot(fn, idx) {
1308
+ return () => {
1309
+ if (idx > 0 && _lastGroupFn === fn) {
1310
+ if (_lastGroupArr !== null) return _lastGroupArr[idx];
1311
+ throw _lastGroupErr;
1312
+ }
1313
+ _lastGroupFn = fn;
1314
+ _lastGroupArr = null;
1315
+ _lastGroupErr = null;
1316
+ try {
1317
+ _lastGroupArr = fn();
1318
+ return _lastGroupArr[idx];
1319
+ } catch (err) {
1320
+ _lastGroupErr = err;
1321
+ throw err;
1322
+ }
1323
+ };
1324
+ }
1325
+ function ssr(t) {
1326
+ const len = arguments.length;
1327
+ if (len === 1) return {
504
1328
  t
505
1329
  };
1330
+ let s = t[0];
1331
+ let result = null;
1332
+ let lastGroup = null;
1333
+ let lastGroupVal = null;
1334
+ let lastGroupIdx = 0;
1335
+ for (let i = 1; i < len; i++) {
1336
+ const hole = arguments[i];
1337
+ const ht = typeof hole;
1338
+ if (ht === "string") {
1339
+ if (result === null) s += hole;else result.t[result.t.length - 1] += hole;
1340
+ } else if (ht === "number") {
1341
+ if (result === null) s += hole;else result.t[result.t.length - 1] += hole;
1342
+ } else if (hole == null || ht === "boolean") ; else if (ht === "function" && hole.$g) {
1343
+ let value;
1344
+ let hasValue = false;
1345
+ if (lastGroup !== hole) {
1346
+ const r = ssrFirstGroupHit(hole);
1347
+ if (r !== null) {
1348
+ lastGroup = hole;
1349
+ lastGroupVal = r;
1350
+ lastGroupIdx = 0;
1351
+ if (!Array.isArray(r) && result === null) {
1352
+ result = {
1353
+ t: [s],
1354
+ h: [],
1355
+ p: []
1356
+ };
1357
+ s = "";
1358
+ }
1359
+ }
1360
+ }
1361
+ if (lastGroup === hole) {
1362
+ if (Array.isArray(lastGroupVal)) {
1363
+ value = lastGroupVal[lastGroupIdx++];
1364
+ hasValue = true;
1365
+ } else {
1366
+ result.h.push(ssrGroupSlot(lastGroupVal.fn, lastGroupIdx++));
1367
+ result.p.push(lastGroupVal.p);
1368
+ result.t.push("");
1369
+ }
1370
+ }
1371
+ if (hasValue) {
1372
+ const vt = typeof value;
1373
+ if (vt === "string" || vt === "number") {
1374
+ if (result === null) s += value;else result.t[result.t.length - 1] += value;
1375
+ } else if (value == null || vt === "boolean") ; else if (result !== null) {
1376
+ resolveSSRNode(value, result);
1377
+ } else {
1378
+ const rs = tryResolveString(value);
1379
+ if (typeof rs === "string") {
1380
+ s += rs;
1381
+ } else {
1382
+ result = {
1383
+ t: [s],
1384
+ h: [],
1385
+ p: []
1386
+ };
1387
+ s = "";
1388
+ if (rs.merge !== undefined) mergeTemplateInto(result, rs.merge);else resolveSSRNode(rs.bail, result);
1389
+ }
1390
+ }
1391
+ }
1392
+ } else if (result !== null) {
1393
+ resolveSSRNode(hole, result);
1394
+ } else if (ht === "function") {
1395
+ const r = tryResolveFunctionHole(hole);
1396
+ if (typeof r === "string") s += r;else {
1397
+ result = {
1398
+ t: [s],
1399
+ h: [],
1400
+ p: []
1401
+ };
1402
+ s = "";
1403
+ appendResolvedNode(result, r);
1404
+ }
1405
+ } else {
1406
+ const r = tryResolveString(hole);
1407
+ if (typeof r === "string") {
1408
+ s += r;
1409
+ } else {
1410
+ result = {
1411
+ t: [s],
1412
+ h: [],
1413
+ p: []
1414
+ };
1415
+ s = "";
1416
+ appendResolvedNode(result, r);
1417
+ }
1418
+ }
1419
+ const next = t[i];
1420
+ if (result === null) s += next;else result.t[result.t.length - 1] += next;
1421
+ }
1422
+ if (result === null) return {
1423
+ t: s
1424
+ };
1425
+ return result;
506
1426
  }
507
1427
  function ssrClassName(value) {
508
1428
  if (!value) return "";
@@ -515,7 +1435,7 @@ function ssrClassName(value) {
515
1435
  classValue = !!value[key];
516
1436
  if (!key || key === "undefined" || !classValue) continue;
517
1437
  i && (result += " ");
518
- result += escape(key);
1438
+ result += escape(key, true);
519
1439
  }
520
1440
  return result;
521
1441
  }
@@ -525,8 +1445,8 @@ function ssrStyle(value) {
525
1445
  let result = "";
526
1446
  const k = Object.keys(value);
527
1447
  for (let i = 0; i < k.length; i++) {
528
- const s = k[i];
529
- const v = value[s];
1448
+ const s = escape(k[i], true);
1449
+ const v = value[k[i]];
530
1450
  if (v != undefined) {
531
1451
  if (i) result += ";";
532
1452
  const r = escape(v, true);
@@ -541,10 +1461,11 @@ function ssrStyleProperty(name, value) {
541
1461
  return value != null ? name + value : "";
542
1462
  }
543
1463
  function ssrElement(tag, props, children, needsId) {
1464
+ const hk = needsId ? ssrHydrationKey() : "";
544
1465
  if (props == null) props = {};else if (typeof props === "function") props = props();
545
1466
  const skipChildren = VOID_ELEMENTS.test(tag);
546
1467
  const keys = Object.keys(props);
547
- let result = `<${tag}${needsId ? ssrHydrationKey() : ""} `;
1468
+ let result = `<${tag}${hk} `;
548
1469
  for (let i = 0; i < keys.length; i++) {
549
1470
  const prop = keys[i];
550
1471
  if (ChildProperties.has(prop)) {
@@ -583,18 +1504,31 @@ function escape(s, attr) {
583
1504
  const t = typeof s;
584
1505
  if (t !== "string") {
585
1506
  if (!attr && Array.isArray(s)) {
1507
+ const joined = tryJoinPlainSSRArray(s);
1508
+ if (joined !== undefined) return joined;
586
1509
  s = s.slice();
587
1510
  for (let i = 0; i < s.length; i++) s[i] = escape(s[i]);
588
1511
  return s;
589
1512
  }
590
- if (attr && t === "boolean") return s;
1513
+ if (attr) {
1514
+ if (s == null || t === "boolean" || t === "number") return s;
1515
+ return escape(String(s), attr);
1516
+ }
591
1517
  return s;
592
1518
  }
1519
+ const i = s.search(attr ? ESCAPE_ATTR : ESCAPE_CONTENT);
1520
+ if (i < 0) return s;
1521
+ return escapeSlow(s, attr, i);
1522
+ }
1523
+ const ESCAPE_CONTENT = /[&<]/;
1524
+ const ESCAPE_ATTR = /[&"]/;
1525
+ function escapeSlow(s, attr, start) {
593
1526
  const delim = attr ? '"' : "<";
1527
+ const delimCode = attr ? 34 : 60;
594
1528
  const escDelim = attr ? "&quot;" : "&lt;";
595
- let iDelim = s.indexOf(delim);
596
- let iAmp = s.indexOf("&");
597
- if (iDelim < 0 && iAmp < 0) return s;
1529
+ const c0 = s.charCodeAt(start);
1530
+ let iDelim = c0 === delimCode ? start : s.indexOf(delim, start);
1531
+ let iAmp = c0 === 38 ? start : s.indexOf("&", start);
598
1532
  let left = 0,
599
1533
  out = "";
600
1534
  while (iDelim >= 0 && iAmp >= 0) {
@@ -625,28 +1559,17 @@ function escape(s, attr) {
625
1559
  }
626
1560
  return left < s.length ? out + s.substring(left) : out;
627
1561
  }
628
- function mergeProps(...sources) {
629
- const target = {};
630
- for (let i = 0; i < sources.length; i++) {
631
- let source = sources[i];
632
- if (typeof source === "function") source = source();
633
- if (source) {
634
- const descriptors = Object.getOwnPropertyDescriptors(source);
635
- for (const key in descriptors) {
636
- if (key in target) continue;
637
- Object.defineProperty(target, key, {
638
- enumerable: true,
639
- get() {
640
- for (let i = sources.length - 1; i >= 0; i--) {
641
- const v = (sources[i] || {})[key];
642
- if (v !== undefined) return v;
643
- }
644
- }
645
- });
646
- }
1562
+ function tryJoinPlainSSRArray(nodes) {
1563
+ if (nodes.length === 0) return undefined;
1564
+ let out = "";
1565
+ for (let i = 0, len = nodes.length; i < len; i++) {
1566
+ const node = nodes[i];
1567
+ if (node == null || typeof node !== "object" || node.h || typeof node.t !== "string") {
1568
+ return undefined;
647
1569
  }
1570
+ out += node.t;
648
1571
  }
649
- return target;
1572
+ return out;
650
1573
  }
651
1574
  function getHydrationKey() {
652
1575
  const hydrate = solidJs.sharedConfig.context;
@@ -664,11 +1587,14 @@ function getAssets() {
664
1587
  for (let i = 0, len = assets.length; i < len; i++) out += assets[i]();
665
1588
  return out;
666
1589
  }
1590
+ function Assets(props) {
1591
+ useAssets(() => props.children);
1592
+ }
667
1593
  function generateHydrationScript({
668
1594
  eventNames = ["click", "input"],
669
1595
  nonce
670
1596
  } = {}) {
671
- return `<script${nonce ? ` nonce="${nonce}"` : ""}>window._$HY||(e=>{let t=e=>e&&e.hasAttribute&&(e.hasAttribute("_hk")?e:t(e.host&&e.host.nodeType?e.host:e.parentNode));["${eventNames.join('", "')}"].forEach((o=>document.addEventListener(o,(o=>{if(!e.events)return;let s=t(o.composedPath&&o.composedPath()[0]||o.target);s&&!e.completed.has(s)&&e.events.push([s,o])}))))})(_$HY={events:[],completed:new WeakSet,r:{},fe(){}});</script><!--xs-->`;
1597
+ return `<script${nonce ? ` nonce="${nonce}"` : ""}>window._$HY||(e=>{let t=e=>e&&e.hasAttribute&&(e.hasAttribute("_hk")?e:t(e.host&&e.host.nodeType?e.host:e.parentNode));["${eventNames.join('","')}"].forEach((o=>document.addEventListener(o,(o=>{if(!e.events)return;let s=t(o.composedPath&&o.composedPath()[0]||o.target);s&&!e.completed.has(s)&&e.events.push([s,o])}))))})(_$HY={events:[],completed:new WeakSet,r:{},fe(){}});</script><!--xs-->`;
672
1598
  }
673
1599
  function queue(fn) {
674
1600
  return Promise.resolve().then(fn);
@@ -680,27 +1606,58 @@ function allSettled(promises) {
680
1606
  return;
681
1607
  });
682
1608
  }
683
- function injectAssets(assets, html) {
684
- if (!assets || !assets.length) return html;
1609
+ function resolveAssetsHtml(assets) {
1610
+ if (!assets || !assets.length) return "";
685
1611
  let out = "";
686
1612
  for (let i = 0, len = assets.length; i < len; i++) out += assets[i]();
687
- const index = html.indexOf("</head>");
688
- if (index === -1) return html;
689
- return html.slice(0, index) + out + html.slice(index);
1613
+ return out;
690
1614
  }
691
- function injectPreloadLinks(emittedAssets, html, nonce) {
692
- if (!emittedAssets.size) return html;
693
- let links = "";
694
- for (const url of emittedAssets) {
695
- if (url.endsWith(".css")) {
696
- links += `<link rel="stylesheet" href="${url}">`;
697
- } else {
698
- links += `<link rel="modulepreload" href="${url}">`;
1615
+ function assembleDocument(html, assetsHtml, emittedAssets, inlineStyles, scripts, nonce, headTags, onHead) {
1616
+ const scriptTag = scripts ? `<script${nonce ? ` nonce="${nonce}"` : ""}>${scripts}</script>` : "";
1617
+ const headTagsHtml = headTags ? headTags.html : "";
1618
+ const headPrelude = headTags ? headTags.prelude : "";
1619
+ if (!onHead && !assetsHtml && !headTagsHtml && !headPrelude && !(emittedAssets && emittedAssets.size) && !(inlineStyles && inlineStyles.size)) {
1620
+ if (!scriptTag) return html;
1621
+ const xs = html.indexOf("<!--xs-->");
1622
+ return xs === -1 ? html + scriptTag : html.slice(0, xs) + scriptTag + html.slice(xs);
1623
+ }
1624
+ if (headPrelude) {
1625
+ const open = html.match(/<head(?:\s[^>]*)?>/);
1626
+ if (open) {
1627
+ const at = open.index + open[0].length;
1628
+ html = html.slice(0, at) + headPrelude + html.slice(at);
1629
+ }
1630
+ }
1631
+ const headIdx = html.indexOf("</head>");
1632
+ if (headIdx === -1) {
1633
+ if (onHead) {
1634
+ onHead(headPrelude + headTagsHtml + (assetsHtml || "") + renderHeadAssets(emittedAssets, inlineStyles, nonce));
1635
+ }
1636
+ if (!scriptTag) return html;
1637
+ const xs = html.indexOf("<!--xs-->");
1638
+ return xs === -1 ? html + scriptTag : html.slice(0, xs) + scriptTag + html.slice(xs);
1639
+ }
1640
+ const head = headTagsHtml + (assetsHtml || "") + renderHeadAssets(emittedAssets, inlineStyles, nonce);
1641
+ if (!scriptTag) return html.slice(0, headIdx) + head + html.slice(headIdx);
1642
+ const xsIdx = html.indexOf("<!--xs-->");
1643
+ if (xsIdx === -1) return html.slice(0, headIdx) + head + html.slice(headIdx) + scriptTag;
1644
+ return xsIdx < headIdx ? html.slice(0, xsIdx) + scriptTag + html.slice(xsIdx, headIdx) + head + html.slice(headIdx) : html.slice(0, headIdx) + head + html.slice(headIdx, xsIdx) + scriptTag + html.slice(xsIdx);
1645
+ }
1646
+ function renderHeadAssets(emittedAssets, inlineStyles, nonce) {
1647
+ let head = "";
1648
+ if (emittedAssets && emittedAssets.size) {
1649
+ for (const url of emittedAssets) {
1650
+ head += isCssUrl(url) ? `<link rel="stylesheet" href="${url}">` : `<link rel="modulepreload" href="${url}">`;
1651
+ }
1652
+ }
1653
+ if (inlineStyles && inlineStyles.size) {
1654
+ for (const entry of inlineStyles.values()) {
1655
+ if (entry.emitted) continue;
1656
+ entry.emitted = true;
1657
+ head += renderInlineStyle(entry, nonce);
699
1658
  }
700
1659
  }
701
- const index = html.indexOf("</head>");
702
- if (index === -1) return html;
703
- return html.slice(0, index) + links + html.slice(index);
1660
+ return head;
704
1661
  }
705
1662
  function serializeFragmentAssets(key, boundaryModules, context) {
706
1663
  const map = boundaryModules.get(key);
@@ -721,22 +1678,41 @@ function propagateBoundaryStyles(childKey, parentKey, tracking) {
721
1678
  }
722
1679
  function collectStreamStyles(key, tracking, headStyles) {
723
1680
  const styles = tracking.getBoundaryStyles(key);
724
- if (!styles) return [];
725
- const result = [];
726
- for (const url of styles) {
727
- if (!headStyles || !headStyles.has(url)) {
728
- result.push(url);
1681
+ const links = [];
1682
+ const inline = [];
1683
+ if (!styles) return {
1684
+ links,
1685
+ inline
1686
+ };
1687
+ for (const entry of styles) {
1688
+ if (typeof entry === "string") {
1689
+ if (!headStyles || !headStyles.has(entry)) links.push(entry);
1690
+ } else if (entry.emitted) {
1691
+ continue;
1692
+ } else if (entry.attrHtml !== undefined) {
1693
+ entry.emitted = true;
1694
+ links.push(entry);
1695
+ } else {
1696
+ entry.emitted = true;
1697
+ inline.push(entry);
729
1698
  }
730
1699
  }
731
- return result;
1700
+ return {
1701
+ links,
1702
+ inline
1703
+ };
732
1704
  }
733
- function injectScripts(html, scripts, nonce) {
734
- const tag = `<script${nonce ? ` nonce="${nonce}"` : ""}>${scripts}</script>`;
735
- const index = html.indexOf("<!--xs-->");
736
- if (index > -1) {
737
- return html.slice(0, index) + tag + html.slice(index);
1705
+ function escapeStyleContent(content) {
1706
+ return content.replace(/<\/(style)/gi, "<\\/$1");
1707
+ }
1708
+ function renderInlineStyle(entry, nonce) {
1709
+ let attrs = "";
1710
+ if (entry.attrs) {
1711
+ for (const name in entry.attrs) {
1712
+ attrs += ` ${name}="${escape(String(entry.attrs[name]), true)}"`;
1713
+ }
738
1714
  }
739
- return html + tag;
1715
+ return `<style${nonce ? ` nonce="${nonce}"` : ""} data-asset="${escape(entry.id, true)}"${attrs}>${escapeStyleContent(entry.content)}</style>`;
740
1716
  }
741
1717
  function waitForFragments(registry, key) {
742
1718
  for (const k of [...registry.keys()].reverse()) {
@@ -766,19 +1742,49 @@ function flattenClassList(list, result) {
766
1742
  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;
767
1743
  }
768
1744
  }
769
- function resolveSSR(template, holes, result = {
770
- t: [""],
771
- h: [],
772
- p: []
773
- }) {
774
- for (let i = 0; i < holes.length; i++) {
775
- const hole = holes[i];
776
- result.t[result.t.length - 1] += template[i];
777
- if (hole == null || hole === true || hole === false) continue;
778
- resolveSSRNode(hole, result);
1745
+ function tryResolveString(node) {
1746
+ const t = typeof node;
1747
+ if (t === "string") return node;
1748
+ if (t === "number") return "" + node;
1749
+ if (node == null || t === "boolean") return "";
1750
+ if (t === "object") {
1751
+ if (Array.isArray(node)) {
1752
+ const joined = tryJoinPlainSSRArray(node);
1753
+ if (joined !== undefined) return joined;
1754
+ let s = "";
1755
+ let prevNonObj = false;
1756
+ for (let i = 0, len = node.length; i < len; i++) {
1757
+ const item = node[i];
1758
+ const itemNonObj = item !== null && typeof item !== "object";
1759
+ if (prevNonObj && itemNonObj) s += "<!--!$-->";
1760
+ prevNonObj = itemNonObj;
1761
+ const r = tryResolveString(item);
1762
+ if (typeof r !== "string") return {
1763
+ bail: node
1764
+ };
1765
+ s += r;
1766
+ }
1767
+ return s;
1768
+ }
1769
+ if (node.h && node.h.length > 0) return {
1770
+ merge: node
1771
+ };
1772
+ if (node.t === undefined) {
1773
+ console.warn(`Unrecognized value. Skipped inserting`, node);
1774
+ return "";
1775
+ }
1776
+ return Array.isArray(node.t) ? node.t[0] : node.t;
779
1777
  }
780
- result.t[result.t.length - 1] += template[template.length - 1];
781
- return result;
1778
+ if (t === "function") {
1779
+ let v;
1780
+ try {
1781
+ v = node();
1782
+ } catch (err) {
1783
+ return buildAsyncWrap(err, node) || "";
1784
+ }
1785
+ return tryResolveString(v);
1786
+ }
1787
+ return "";
782
1788
  }
783
1789
  function resolveSSRNode(node, result = {
784
1790
  t: [""],
@@ -789,10 +1795,13 @@ function resolveSSRNode(node, result = {
789
1795
  if (t === "string" || t === "number") {
790
1796
  result.t[result.t.length - 1] += node;
791
1797
  } else if (node == null || t === "boolean") ; else if (Array.isArray(node)) {
792
- let prev = {};
1798
+ let prevNonObj = false;
793
1799
  for (let i = 0, len = node.length; i < len; i++) {
794
- if (!top && typeof prev !== "object" && typeof node[i] !== "object") result.t[result.t.length - 1] += `<!--!$-->`;
795
- resolveSSRNode(prev = node[i], result);
1800
+ const item = node[i];
1801
+ const itemNonObj = item !== null && typeof item !== "object";
1802
+ if (!top && prevNonObj && itemNonObj) result.t[result.t.length - 1] += `<!--!$-->`;
1803
+ prevNonObj = itemNonObj;
1804
+ resolveSSRNode(item, result);
796
1805
  }
797
1806
  } else if (t === "object") {
798
1807
  if (node.h) {
@@ -802,15 +1811,17 @@ function resolveSSRNode(node, result = {
802
1811
  result.h.push(...node.h);
803
1812
  result.p.push(...node.p);
804
1813
  }
805
- } else result.t[result.t.length - 1] += node.t;
1814
+ } else if (node.t !== undefined) {
1815
+ result.t[result.t.length - 1] += node.t;
1816
+ } else console.warn(`Unrecognized value. Skipped inserting`, node);
806
1817
  } else if (t === "function") {
807
1818
  try {
808
1819
  resolveSSRNode(node(), result);
809
1820
  } catch (err) {
810
- const p = solidJs.ssrHandleError(err);
811
- if (p) {
812
- result.h.push(node);
813
- result.p.push(p);
1821
+ const wrap = buildAsyncWrap(err, node);
1822
+ if (wrap) {
1823
+ result.h.push(wrap.fn);
1824
+ result.p.push(wrap.p);
814
1825
  result.t.push("");
815
1826
  }
816
1827
  }
@@ -822,39 +1833,188 @@ function resolveSSRSync(node) {
822
1833
  if (!res.h.length) return res.t[0];
823
1834
  throw new Error("This value cannot be rendered synchronously. Are you missing a boundary?");
824
1835
  }
825
- const RequestContext = Symbol();
1836
+ const RequestContext = Symbol.for("solid.RequestContext");
826
1837
  function getRequestEvent() {
827
1838
  return globalThis[RequestContext] ? globalThis[RequestContext].getStore() || solidJs.sharedConfig.context && solidJs.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;
828
1839
  }
829
1840
  function renderToStringAsync(code, options = {}) {
830
1841
  return new Promise(resolve => renderToStream(code, options).then(resolve));
831
1842
  }
1843
+ function registerElementClaim() {
1844
+ return noopCleanup;
1845
+ }
1846
+ function noopCleanup() {}
1847
+ function claimElement(node) {
1848
+ return node;
1849
+ }
1850
+ function claimElementTree(root) {
1851
+ return root;
1852
+ }
832
1853
  function notSup() {
833
1854
  throw new Error("Client-only API called on the server side. Run client-only code in onMount, or conditionally run client-only component with <Show>.");
834
1855
  }
835
1856
 
1857
+ const ENVELOPE = Symbol.for("solid.ResponseEnvelope");
1858
+ class ResponseEnvelope {
1859
+ constructor(response, value) {
1860
+ this.response = response;
1861
+ this.value = value;
1862
+ }
1863
+ }
1864
+ ResponseEnvelope.prototype[ENVELOPE] = true;
1865
+ function isResponseEnvelope(value) {
1866
+ return !!(value && typeof value === "object" && value[ENVELOPE]);
1867
+ }
1868
+ const HREF = Symbol.for("solid.Href");
1869
+ function isHref(value) {
1870
+ return !!(value && (typeof value === "object" || typeof value === "function") && value[HREF]);
1871
+ }
1872
+ const REVALIDATE_HEADER = "X-Revalidate";
1873
+ function initWithRevalidate(init) {
1874
+ const {
1875
+ revalidate,
1876
+ ...responseInit
1877
+ } = init;
1878
+ const headers = new Headers(responseInit.headers);
1879
+ revalidate !== undefined && headers.set(REVALIDATE_HEADER, revalidate.toString());
1880
+ return {
1881
+ responseInit,
1882
+ headers
1883
+ };
1884
+ }
1885
+ function redirect(url, init = 302) {
1886
+ if (typeof url !== "string" && !isHref(url)) {
1887
+ throw new TypeError("redirect() expects a string URL or an Href-branded value (Symbol.for('solid.Href')).");
1888
+ }
1889
+ const {
1890
+ responseInit,
1891
+ headers
1892
+ } = initWithRevalidate(typeof init === "number" ? {
1893
+ status: init
1894
+ } : init);
1895
+ if (responseInit.status === undefined) {
1896
+ responseInit.status = 302;
1897
+ }
1898
+ headers.set("Location", String(url));
1899
+ return new Response(null, {
1900
+ ...responseInit,
1901
+ headers
1902
+ });
1903
+ }
1904
+ function reload(init = {}) {
1905
+ const {
1906
+ responseInit,
1907
+ headers
1908
+ } = initWithRevalidate(init);
1909
+ return new Response(null, {
1910
+ ...responseInit,
1911
+ headers
1912
+ });
1913
+ }
1914
+ function respond(value, init = {}) {
1915
+ const {
1916
+ responseInit,
1917
+ headers
1918
+ } = initWithRevalidate(init);
1919
+ headers.set("Content-Type", "application/json");
1920
+ return new ResponseEnvelope(new Response(JSON.stringify(value), {
1921
+ ...responseInit,
1922
+ headers
1923
+ }), value);
1924
+ }
1925
+
836
1926
  const isServer = true;
837
1927
  const isDev = false;
838
- function createDynamic(component, props) {
839
- const o = solidJs.getOwner();
840
- if (o?.id != null) solidJs.getNextChildId(o);
841
- const memoOwner = solidJs.createOwner();
842
- return solidJs.runWithOwner(memoOwner, () => {
843
- const comp = component(),
844
- t = typeof comp;
845
- if (comp) {
846
- if (t === "function") return comp(props);else if (t === "string") {
847
- return ssrElement(comp, props, undefined, true);
848
- }
849
- }
1928
+ function dynamic(source) {
1929
+ const cached = solidJs.createMemo(source, {
1930
+ serialize: false
850
1931
  });
1932
+ return props => {
1933
+ return solidJs.createMemo(() => {
1934
+ const c = cached();
1935
+ if (c) {
1936
+ if (typeof c === "function") return c(props);
1937
+ if (typeof c === "string") {
1938
+ return ssrElement(c, props, undefined, true);
1939
+ }
1940
+ }
1941
+ }, {
1942
+ sync: true
1943
+ });
1944
+ };
851
1945
  }
852
1946
  function Dynamic(props) {
853
- const others = solidJs.omit(props, "component");
854
- return createDynamic(() => props.component, others);
1947
+ const Comp = dynamic(() => props.component);
1948
+ return solidJs.createComponent(Comp, solidJs.omit(props, "component"));
855
1949
  }
856
1950
  function Portal(props) {
857
- throw new Error("Portal is not supported on the server");
1951
+ const o = solidJs.getOwner();
1952
+ if (o?.id != null) solidJs.getNextChildId(o);
1953
+ return undefined;
1954
+ }
1955
+ function registerClientOnlyPreload(moduleUrl) {
1956
+ const ctx = solidJs.sharedConfig.context;
1957
+ if (!ctx?.registerAsset || !ctx.resolveAssets) return;
1958
+ const registerAsset = ctx.registerAsset;
1959
+ const resolve = ctx.resolveAssets;
1960
+ const apply = assets => {
1961
+ if (!assets) return;
1962
+ for (let i = 0; i < assets.css.length; i++) {
1963
+ const css = assets.css[i];
1964
+ if (typeof css === "string") registerAsset("style", css);else registerAsset("inline-style", css);
1965
+ }
1966
+ for (let i = 0; i < assets.js.length; i++) registerAsset("module", assets.js[i]);
1967
+ };
1968
+ const assets = resolve(moduleUrl);
1969
+ if (assets && typeof assets.then === "function") {
1970
+ const boundary = ctx._currentBoundaryId;
1971
+ assets.then(resolved => {
1972
+ const current = ctx._currentBoundaryId;
1973
+ ctx._currentBoundaryId = boundary;
1974
+ try {
1975
+ apply(resolved);
1976
+ } finally {
1977
+ ctx._currentBoundaryId = current;
1978
+ }
1979
+ },
1980
+ () => {});
1981
+ } else {
1982
+ apply(assets);
1983
+ }
1984
+ }
1985
+ function clientOnly(_fn, _options = {}, moduleUrl) {
1986
+ return props => {
1987
+ if (moduleUrl) registerClientOnlyPreload(moduleUrl);
1988
+ return solidJs.createMemo(() => props.fallback);
1989
+ };
1990
+ }
1991
+ function httpStatus(code, text) {
1992
+ const event = getRequestEvent();
1993
+ const response = event && event.response;
1994
+ if (response && !response.committed) {
1995
+ const prevStatus = response.status;
1996
+ const prevStatusText = response.statusText;
1997
+ response.status = code;
1998
+ response.statusText = text;
1999
+ solidJs.onCleanup(() => {
2000
+ if (response.committed) return;
2001
+ response.status = prevStatus;
2002
+ response.statusText = prevStatusText;
2003
+ });
2004
+ }
2005
+ }
2006
+ function httpHeader(name, value, options) {
2007
+ const event = getRequestEvent();
2008
+ const response = event && event.response;
2009
+ if (response && !response.committed) {
2010
+ const headers = response.headers;
2011
+ const prev = headers.get(name);
2012
+ if (options && options.append) headers.append(name, value);else headers.set(name, value);
2013
+ solidJs.onCleanup(() => {
2014
+ if (response.committed) return;
2015
+ if (prev === null) headers.delete(name);else headers.set(name, prev);
2016
+ });
2017
+ }
858
2018
  }
859
2019
 
860
2020
  Object.defineProperty(exports, "Errored", {
@@ -885,6 +2045,10 @@ Object.defineProperty(exports, "Repeat", {
885
2045
  enumerable: true,
886
2046
  get: function () { return solidJs.Repeat; }
887
2047
  });
2048
+ Object.defineProperty(exports, "Reveal", {
2049
+ enumerable: true,
2050
+ get: function () { return solidJs.Reveal; }
2051
+ });
888
2052
  Object.defineProperty(exports, "Show", {
889
2053
  enumerable: true,
890
2054
  get: function () { return solidJs.Show; }
@@ -901,62 +2065,93 @@ Object.defineProperty(exports, "getOwner", {
901
2065
  enumerable: true,
902
2066
  get: function () { return solidJs.getOwner; }
903
2067
  });
904
- Object.defineProperty(exports, "ssrRunInScope", {
2068
+ Object.defineProperty(exports, "mergeProps", {
2069
+ enumerable: true,
2070
+ get: function () { return solidJs.merge; }
2071
+ });
2072
+ Object.defineProperty(exports, "scope", {
905
2073
  enumerable: true,
906
- get: function () { return solidJs.ssrRunInScope; }
2074
+ get: function () { return solidJs.ssrScope; }
907
2075
  });
908
2076
  Object.defineProperty(exports, "untrack", {
909
2077
  enumerable: true,
910
2078
  get: function () { return solidJs.untrack; }
911
2079
  });
2080
+ exports.Assets = Assets;
912
2081
  exports.ChildProperties = ChildProperties;
913
2082
  exports.DOMElements = DOMElements;
2083
+ exports.DOMWithState = DOMWithState;
914
2084
  exports.DelegatedEvents = DelegatedEvents;
915
2085
  exports.Dynamic = Dynamic;
2086
+ exports.HREF = HREF;
916
2087
  exports.HydrationScript = HydrationScript;
2088
+ exports.MathMLElements = MathMLElements;
2089
+ exports.Namespaces = Namespaces;
917
2090
  exports.Portal = Portal;
918
- exports.Properties = Properties;
2091
+ exports.REVALIDATE_HEADER = REVALIDATE_HEADER;
2092
+ exports.RawTextElements = RawTextElements;
919
2093
  exports.RequestContext = RequestContext;
2094
+ exports.ResponseEnvelope = ResponseEnvelope;
920
2095
  exports.SVGElements = SVGElements;
921
- exports.SVGNamespace = SVGNamespace;
922
- exports.addEventListener = notSup;
2096
+ exports.VoidElements = VoidElements;
2097
+ exports.acquireAsset = notSup;
2098
+ exports.addEvent = notSup;
923
2099
  exports.applyRef = applyRef;
924
2100
  exports.assign = notSup;
2101
+ exports.claimElement = claimElement;
2102
+ exports.claimElementTree = claimElementTree;
925
2103
  exports.className = notSup;
926
- exports.createDynamic = createDynamic;
2104
+ exports.clientOnly = clientOnly;
927
2105
  exports.delegateEvents = notSup;
2106
+ exports.dynamic = dynamic;
928
2107
  exports.dynamicProperty = notSup;
929
2108
  exports.effect = effect;
930
2109
  exports.escape = escape;
931
2110
  exports.generateHydrationScript = generateHydrationScript;
932
2111
  exports.getAssets = getAssets;
2112
+ exports.getDelegatedRoot = notSup;
933
2113
  exports.getHydrationKey = getHydrationKey;
934
2114
  exports.getNextElement = notSup;
935
2115
  exports.getNextMarker = notSup;
936
2116
  exports.getNextMatch = notSup;
937
2117
  exports.getRequestEvent = getRequestEvent;
2118
+ exports.httpHeader = httpHeader;
2119
+ exports.httpStatus = httpStatus;
938
2120
  exports.hydrate = notSup;
939
2121
  exports.insert = notSup;
940
2122
  exports.isDev = isDev;
2123
+ exports.isHref = isHref;
2124
+ exports.isResponseEnvelope = isResponseEnvelope;
941
2125
  exports.isServer = isServer;
942
2126
  exports.memo = memo;
943
- exports.mergeProps = mergeProps;
2127
+ exports.redirect = redirect;
2128
+ exports.ref = notSup;
2129
+ exports.registerDelegatedContainer = notSup;
2130
+ exports.registerDelegatedRoot = notSup;
2131
+ exports.registerElementClaim = registerElementClaim;
2132
+ exports.reload = reload;
944
2133
  exports.render = notSup;
945
2134
  exports.renderToStream = renderToStream;
946
2135
  exports.renderToString = renderToString;
947
2136
  exports.renderToStringAsync = renderToStringAsync;
2137
+ exports.respond = respond;
948
2138
  exports.runHydrationEvents = notSup;
949
2139
  exports.setAttribute = notSup;
950
2140
  exports.setAttributeNS = notSup;
951
2141
  exports.setProperty = notSup;
2142
+ exports.setStyleProperty = notSup;
952
2143
  exports.spread = notSup;
953
2144
  exports.ssr = ssr;
954
2145
  exports.ssrAttribute = ssrAttribute;
955
2146
  exports.ssrClassName = ssrClassName;
956
2147
  exports.ssrElement = ssrElement;
2148
+ exports.ssrGroup = ssrGroup;
957
2149
  exports.ssrHydrationKey = ssrHydrationKey;
958
2150
  exports.ssrStyle = ssrStyle;
959
2151
  exports.ssrStyleProperty = ssrStyleProperty;
960
2152
  exports.style = notSup;
961
2153
  exports.template = notSup;
2154
+ exports.unregisterDelegatedContainer = notSup;
2155
+ exports.unregisterDelegatedRoot = notSup;
962
2156
  exports.useAssets = useAssets;
2157
+ exports.useHead = useHead;