@solidjs/web 2.0.0-beta.2 → 2.0.0-beta.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/README.md +27 -4
  2. package/dist/dev.cjs +783 -223
  3. package/dist/dev.js +757 -217
  4. package/dist/server.cjs +742 -186
  5. package/dist/server.js +714 -183
  6. package/dist/web.cjs +772 -196
  7. package/dist/web.js +746 -190
  8. package/package.json +193 -38
  9. package/serialization/dist/serialization.cjs +83 -0
  10. package/serialization/dist/serialization.js +75 -0
  11. package/serialization/package.json +20 -0
  12. package/serialization/types/index.d.ts +139 -0
  13. package/serialization/types-cjs/index.d.cts +139 -0
  14. package/serialization/types-cjs/package.json +3 -0
  15. package/server-functions/dist/client.cjs +370 -0
  16. package/server-functions/dist/client.js +363 -0
  17. package/server-functions/dist/server.cjs +542 -0
  18. package/server-functions/dist/server.js +531 -0
  19. package/server-functions/package.json +30 -0
  20. package/storage/package.json +8 -3
  21. package/storage/types/index.d.ts +26 -0
  22. package/storage/types-cjs/index.d.cts +28 -0
  23. package/storage/types-cjs/package.json +3 -0
  24. package/types/client.d.ts +64 -21
  25. package/types/core.d.ts +3 -3
  26. package/types/index.d.ts +156 -24
  27. package/types/jsx-properties.d.ts +93 -0
  28. package/types/jsx.d.ts +4135 -1
  29. package/types/response.d.ts +93 -0
  30. package/types/serializer.d.ts +139 -0
  31. package/types/server-functions/client.d.ts +63 -0
  32. package/types/server-functions/server.d.ts +188 -0
  33. package/types/server-functions/shared.d.ts +171 -0
  34. package/types/server-mock.d.ts +89 -0
  35. package/types/server.d.ts +123 -28
  36. package/types-cjs/client.d.cts +131 -0
  37. package/types-cjs/core.d.cts +3 -0
  38. package/types-cjs/index.d.cts +178 -0
  39. package/types-cjs/jsx-properties.d.cts +93 -0
  40. package/types-cjs/jsx.d.cts +4135 -0
  41. package/types-cjs/package.json +3 -0
  42. package/types-cjs/response.d.cts +93 -0
  43. package/types-cjs/serializer.d.cts +139 -0
  44. package/types-cjs/server-functions/client.d.cts +63 -0
  45. package/types-cjs/server-functions/server.d.cts +188 -0
  46. package/types-cjs/server-functions/shared.d.cts +171 -0
  47. package/types-cjs/server-mock.d.cts +161 -0
  48. package/types-cjs/server.d.cts +251 -0
  49. package/storage/types/src/client.d.ts +0 -1
  50. package/storage/types/src/index.d.ts +0 -46
  51. package/storage/types/src/server-mock.d.ts +0 -72
  52. 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,76 @@ 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 HYDRATION_GLOBAL = "_$HY.r";
69
+ const DEFAULT_WEB_PLUGINS = Object.freeze([web.AbortSignalPlugin,
70
+ web.CustomEventPlugin, web.DOMExceptionPlugin, web.EventPlugin,
71
+ web.FormDataPlugin, web.HeadersPlugin, web.ReadableStreamPlugin, web.RequestPlugin, web.ResponsePlugin, web.URLSearchParamsPlugin, web.URLPlugin]);
72
+ function resolveSerializerPlugins(customPlugins) {
73
+ return customPlugins ? [...customPlugins, ...DEFAULT_WEB_PLUGINS] : [...DEFAULT_WEB_PLUGINS];
74
+ }
75
+ function createSerializer(options) {
76
+ return new seroval.Serializer({
77
+ ...options,
78
+ plugins: resolveSerializerPlugins(options.plugins),
79
+ disabledFeatures: options.disabledFeatures === undefined ? DEFAULT_DISABLED_FEATURES : options.disabledFeatures
80
+ });
81
+ }
82
+ function createHydrationSerializer({
36
83
  onData,
37
84
  onDone,
38
85
  scopeId,
39
86
  onError,
40
- plugins: customPlugins
87
+ plugins
41
88
  }) {
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({
89
+ return createSerializer({
47
90
  scopeId,
48
- plugins: allPlugins,
49
- globalIdentifier: GLOBAL_IDENTIFIER,
50
- disabledFeatures: ES2017FLAG,
91
+ plugins,
92
+ globalIdentifier: HYDRATION_GLOBAL,
51
93
  onData,
52
94
  onDone,
53
95
  onError
54
96
  });
55
97
  }
56
98
  function getLocalHeaderScript(id) {
57
- return seroval.getCrossReferenceHeader(id) + ';';
99
+ return seroval.getCrossReferenceHeader(id) + ";";
58
100
  }
101
+ seroval.Feature.RegExp;
59
102
 
103
+ function joinAssetPath(base, file) {
104
+ if (/^(?:[a-z][a-z0-9+.-]*:)?\/\//i.test(file)) return file;
105
+ if (typeof base !== "string" || !base) base = "/";
106
+ if (base[base.length - 1] !== "/") base += "/";
107
+ return base + (file[0] === "/" ? file.slice(1) : file);
108
+ }
60
109
  function resolveAssets(moduleUrl, manifest) {
61
110
  if (!manifest) return null;
62
- const base = manifest._base || "/";
111
+ const base = manifest._base;
63
112
  const entry = manifest[moduleUrl];
64
113
  if (!entry) return null;
65
114
  const css = [];
@@ -70,8 +119,8 @@ function resolveAssets(moduleUrl, manifest) {
70
119
  visited.add(key);
71
120
  const e = manifest[key];
72
121
  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]);
122
+ js.push(joinAssetPath(base, e.file));
123
+ if (e.css) for (let i = 0; i < e.css.length; i++) css.push(joinAssetPath(base, e.css[i]));
75
124
  if (e.imports) for (let i = 0; i < e.imports.length; i++) walk(e.imports[i]);
76
125
  };
77
126
  walk(moduleUrl);
@@ -81,7 +130,7 @@ function resolveAssets(moduleUrl, manifest) {
81
130
  };
82
131
  }
83
132
  function registerEntryAssets(manifest) {
84
- if (!manifest) return;
133
+ if (!manifest || typeof manifest === "function" || typeof manifest.resolve === "function") return;
85
134
  const ctx = solidJs.sharedConfig.context;
86
135
  if (!ctx?.registerAsset) return;
87
136
  for (const key in manifest) {
@@ -98,25 +147,48 @@ function createAssetTracking() {
98
147
  const boundaryModules = new Map();
99
148
  const boundaryStyles = new Map();
100
149
  const emittedAssets = new Set();
150
+ const inlineStyles = new Map();
101
151
  let currentBoundaryId = null;
102
152
  return {
103
153
  boundaryModules,
104
154
  boundaryStyles,
105
155
  emittedAssets,
156
+ inlineStyles,
157
+ registerInlineStyle(desc) {
158
+ let entry = inlineStyles.get(desc.id);
159
+ if (!entry) {
160
+ entry = {
161
+ id: desc.id,
162
+ content: desc.content || "",
163
+ attrs: desc.attrs,
164
+ emitted: false
165
+ };
166
+ inlineStyles.set(desc.id, entry);
167
+ }
168
+ if (currentBoundaryId) {
169
+ let styles = boundaryStyles.get(currentBoundaryId);
170
+ if (!styles) {
171
+ styles = new Set();
172
+ boundaryStyles.set(currentBoundaryId, styles);
173
+ }
174
+ styles.add(entry);
175
+ }
176
+ return entry;
177
+ },
106
178
  get currentBoundaryId() {
107
179
  return currentBoundaryId;
108
180
  },
109
181
  set currentBoundaryId(v) {
110
182
  currentBoundaryId = v;
111
183
  },
112
- registerModule(moduleUrl, entryUrl) {
113
- if (!currentBoundaryId) return;
114
- let map = boundaryModules.get(currentBoundaryId);
184
+ registerModule(key, entryUrl) {
185
+ const id = currentBoundaryId || "";
186
+ let map = boundaryModules.get(id);
115
187
  if (!map) {
116
188
  map = {};
117
- boundaryModules.set(currentBoundaryId, map);
189
+ boundaryModules.set(id, map);
118
190
  }
119
- map[moduleUrl] = entryUrl;
191
+ map[key] = entryUrl;
120
192
  },
121
193
  getBoundaryModules(id) {
122
194
  return boundaryModules.get(id) || null;
@@ -139,10 +211,21 @@ function applyAssetTracking(context, tracking, manifest) {
139
211
  });
140
212
  context.registerModule = tracking.registerModule;
141
213
  context.getBoundaryModules = tracking.getBoundaryModules;
142
- if (manifest) context.resolveAssets = moduleUrl => resolveAssets(moduleUrl, manifest);
214
+ if (typeof manifest === "function") {
215
+ context.resolveAssets = manifest;
216
+ } else if (manifest && typeof manifest.resolve === "function") {
217
+ context.resolveAssets = key => manifest.resolve(key);
218
+ if (typeof manifest.resolveSync === "function") {
219
+ context.resolveAssetsSync = key => manifest.resolveSync(key);
220
+ }
221
+ } else if (manifest) {
222
+ const resolve = moduleUrl => resolveAssets(moduleUrl, manifest);
223
+ context.resolveAssets = resolve;
224
+ context.resolveAssetsSync = resolve;
225
+ }
143
226
  }
144
227
  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)}`;
228
+ const REPLACE_SCRIPT = `function $df(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;_$HY.done?o.remove():o.replaceWith(n.content),n.remove(),_$HY.fe(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])}`;
146
229
  function renderToString(code, options = {}) {
147
230
  const {
148
231
  renderId = "",
@@ -151,7 +234,7 @@ function renderToString(code, options = {}) {
151
234
  manifest
152
235
  } = options;
153
236
  let scripts = "";
154
- const serializer = createSerializer({
237
+ const serializer = createHydrationSerializer({
155
238
  scopeId: renderId,
156
239
  plugins: options.plugins,
157
240
  onData(script) {
@@ -177,16 +260,20 @@ function renderToString(code, options = {}) {
177
260
  }
178
261
  serializer.write(id, p);
179
262
  },
180
- registerAsset(type, url) {
263
+ registerAsset(type, value) {
264
+ if (type === "inline-style") {
265
+ tracking.registerInlineStyle(value);
266
+ return;
267
+ }
181
268
  if (tracking.currentBoundaryId && type === "style") {
182
269
  let styles = tracking.boundaryStyles.get(tracking.currentBoundaryId);
183
270
  if (!styles) {
184
271
  styles = new Set();
185
272
  tracking.boundaryStyles.set(tracking.currentBoundaryId, styles);
186
273
  }
187
- styles.add(url);
274
+ styles.add(value);
188
275
  }
189
- tracking.emittedAssets.add(url);
276
+ tracking.emittedAssets.add(value);
190
277
  }
191
278
  };
192
279
  applyAssetTracking(solidJs.sharedConfig.context, tracking, manifest);
@@ -197,10 +284,12 @@ function renderToString(code, options = {}) {
197
284
  }, {
198
285
  id: renderId
199
286
  });
287
+ serializeFragmentAssets("", tracking.boundaryModules, solidJs.sharedConfig.context);
200
288
  solidJs.sharedConfig.context.noHydrate = true;
201
289
  serializer.close();
202
290
  html = injectAssets(solidJs.sharedConfig.context.assets, html);
203
291
  html = injectPreloadLinks(tracking.emittedAssets, html);
292
+ html = injectInlineStyles(tracking.inlineStyles, html, nonce);
204
293
  if (scripts.length) html = injectScripts(html, scripts, options.nonce);
205
294
  return html;
206
295
  }
@@ -215,10 +304,12 @@ function renderToStream(code, options = {}) {
215
304
  } = options;
216
305
  let dispose;
217
306
  const blockingPromises = new Set();
307
+ let headerEmitted = false;
218
308
  const pushTask = task => {
219
309
  if (noScripts) return;
220
- if (!tasks && !firstFlushed) {
221
- tasks = getLocalHeaderScript(renderId);
310
+ if (!headerEmitted) {
311
+ headerEmitted = true;
312
+ tasks += getLocalHeaderScript(renderId);
222
313
  }
223
314
  tasks += task + ";";
224
315
  if (!timer && firstFlushed) {
@@ -237,15 +328,22 @@ function renderToStream(code, options = {}) {
237
328
  completed = true;
238
329
  if (firstFlushed) dispose();
239
330
  };
240
- const serializer = createSerializer({
331
+ const serializer = createHydrationSerializer({
241
332
  scopeId: options.renderId,
242
333
  plugins: options.plugins,
243
334
  onData: pushTask,
244
335
  onDone,
245
336
  onError: options.onError
246
337
  });
338
+ let rootAssetsSerialized = false;
339
+ const serializeRootAssets = () => {
340
+ if (rootAssetsSerialized) return;
341
+ rootAssetsSerialized = true;
342
+ serializeFragmentAssets("", tracking.boundaryModules, context);
343
+ };
247
344
  const flushEnd = () => {
248
345
  if (!registry.size) {
346
+ serializeRootAssets();
249
347
  queue(() => queue(() => serializer.flush()));
250
348
  }
251
349
  };
@@ -267,7 +365,29 @@ function renderToStream(code, options = {}) {
267
365
  let shellCompleted = false;
268
366
  let scriptFlushed = false;
269
367
  let headStyles;
368
+ const revealGroups = new Map();
270
369
  let timer = null;
370
+ const emitTask = task => {
371
+ pushTask(`${task}${!scriptFlushed ? ";" + REPLACE_SCRIPT : ""}`);
372
+ scriptFlushed = true;
373
+ };
374
+ function resolveRevealKeys(groupOrKeys, release, consume) {
375
+ if (Array.isArray(groupOrKeys)) return groupOrKeys.slice();
376
+ let group = revealGroups.get(groupOrKeys);
377
+ if (!group) {
378
+ if (!release) return;
379
+ group = {
380
+ order: [],
381
+ keys: new Set(),
382
+ released: true
383
+ };
384
+ revealGroups.set(groupOrKeys, group);
385
+ } else if (release) group.released = true;
386
+ if (!group.order.length) return;
387
+ const keys = group.order.slice();
388
+ if (consume) revealGroups.delete(groupOrKeys);
389
+ return keys;
390
+ }
271
391
  let rootHoles = null;
272
392
  let nextHoleId = 0;
273
393
  let buffer = {
@@ -280,19 +400,27 @@ function renderToStream(code, options = {}) {
280
400
  async: true,
281
401
  assets: [],
282
402
  nonce,
283
- registerAsset(type, url) {
403
+ registerAsset(type, value) {
404
+ if (type === "inline-style") {
405
+ const entry = tracking.registerInlineStyle(value);
406
+ if (firstFlushed && !tracking.currentBoundaryId && !entry.emitted) {
407
+ entry.emitted = true;
408
+ buffer.write(renderInlineStyle(entry, nonce));
409
+ }
410
+ return;
411
+ }
284
412
  if (tracking.currentBoundaryId && type === "style") {
285
413
  let styles = tracking.boundaryStyles.get(tracking.currentBoundaryId);
286
414
  if (!styles) {
287
415
  styles = new Set();
288
416
  tracking.boundaryStyles.set(tracking.currentBoundaryId, styles);
289
417
  }
290
- styles.add(url);
418
+ styles.add(value);
291
419
  }
292
- if (!tracking.emittedAssets.has(url)) {
293
- tracking.emittedAssets.add(url);
420
+ if (!tracking.emittedAssets.has(value)) {
421
+ tracking.emittedAssets.add(value);
294
422
  if (firstFlushed && type === "module") {
295
- buffer.write(`<link rel="modulepreload" href="${url}">`);
423
+ buffer.write(`<link rel="modulepreload" href="${value}">`);
296
424
  }
297
425
  }
298
426
  },
@@ -317,7 +445,26 @@ function renderToStream(code, options = {}) {
317
445
  escape: escape,
318
446
  resolve: resolveSSRNode,
319
447
  ssr: ssr,
320
- registerFragment(key) {
448
+ registerFragment(key, options) {
449
+ const revealGroup = options && options.revealGroup;
450
+ if (revealGroup) {
451
+ let group = revealGroups.get(revealGroup);
452
+ if (!group) {
453
+ group = {
454
+ order: [],
455
+ keys: new Set(),
456
+ released: false
457
+ };
458
+ revealGroups.set(revealGroup, group);
459
+ }
460
+ if (!group.keys.has(key)) {
461
+ group.keys.add(key);
462
+ group.order.push(key);
463
+ }
464
+ if (group.released) {
465
+ throw new Error("registerFragment() for reveal group '" + revealGroup + "' was called after revealFragments(). Ensure template payload is emitted before grouped reveal.");
466
+ }
467
+ }
321
468
  if (!registry.has(key)) {
322
469
  let resolve, reject;
323
470
  const p = new Promise((r, rej) => (resolve = r, reject = rej));
@@ -327,7 +474,7 @@ function renderToStream(code, options = {}) {
327
474
  queue(flushEnd);
328
475
  }))
329
476
  });
330
- serializer.write(key, p);
477
+ serializer.write(key + "_fr", p);
331
478
  }
332
479
  return (value, error) => {
333
480
  if (registry.has(key)) {
@@ -356,18 +503,22 @@ function renderToStream(code, options = {}) {
356
503
  } else {
357
504
  serializeFragmentAssets(key, tracking.boundaryModules, context);
358
505
  const styles = collectStreamStyles(key, tracking, headStyles);
359
- if (styles.length) {
360
- pushTask(`$dfs("${key}",${styles.length})${!scriptFlushed ? ";" + REPLACE_SCRIPT : ""}`);
361
- scriptFlushed = true;
506
+ const deferActivation = !!revealGroup;
507
+ for (let i = 0; i < styles.inline.length; i++) {
508
+ buffer.write(renderInlineStyle(styles.inline[i], nonce));
509
+ }
510
+ if (styles.links.length) {
511
+ emitTask(`$dfs("${key}",${styles.links.length},${deferActivation ? 1 : 0})`);
362
512
  writeTasks();
363
- for (const url of styles) {
513
+ for (const url of styles.links) {
364
514
  buffer.write(`<link rel="stylesheet" href="${url}" onload="$dfc('${key}')" onerror="$dfc('${key}')">`);
365
515
  }
366
516
  buffer.write(`<template id="${key}">${value !== undefined ? value : " "}</template>`);
367
517
  } else {
368
518
  buffer.write(`<template id="${key}">${value !== undefined ? value : " "}</template>`);
369
- pushTask(`$df("${key}")${!scriptFlushed ? ";" + REPLACE_SCRIPT : ""}`);
370
- scriptFlushed = true;
519
+ if (!deferActivation) {
520
+ emitTask(`$df("${key}")`);
521
+ }
371
522
  }
372
523
  item.resolve(error);
373
524
  }
@@ -375,6 +526,16 @@ function renderToStream(code, options = {}) {
375
526
  }
376
527
  return firstFlushed;
377
528
  };
529
+ },
530
+ revealFragments(groupOrKeys) {
531
+ const keys = resolveRevealKeys(groupOrKeys, true, true);
532
+ if (!keys) return;
533
+ emitTask(`$dfj(${JSON.stringify(keys)})`);
534
+ },
535
+ revealFallbacks(groupOrKeys) {
536
+ const keys = resolveRevealKeys(groupOrKeys, false, false);
537
+ if (!keys) return;
538
+ emitTask(`$dflj(${JSON.stringify(keys)})`);
378
539
  }
379
540
  };
380
541
  applyAssetTracking(context, tracking, manifest);
@@ -398,19 +559,41 @@ function renderToStream(code, options = {}) {
398
559
  }, {
399
560
  id: renderId
400
561
  });
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] : "");
562
+ function resolveRootHoles() {
563
+ if (!rootHoles) return true;
564
+ const pending = [];
565
+ for (const {
566
+ id,
567
+ fn
568
+ } of rootHoles) {
569
+ const marker = `<!--rh${id}-->`;
570
+ const res = resolveSSRNode(fn);
571
+ if (!res.h.length) {
572
+ html = html.replace(marker, res.t[0]);
573
+ } else {
574
+ let out = res.t[0];
575
+ for (let j = 0; j < res.h.length; j++) {
576
+ const newId = nextHoleId++;
577
+ pending.push({
578
+ id: newId,
579
+ fn: res.h[j]
580
+ });
581
+ out += `<!--rh${newId}-->` + res.t[j + 1];
582
+ }
583
+ html = html.replace(marker, out);
584
+ for (const p of res.p) blockingPromises.add(p);
411
585
  }
412
- rootHoles = null;
413
586
  }
587
+ if (pending.length) {
588
+ rootHoles = pending;
589
+ return false;
590
+ }
591
+ rootHoles = null;
592
+ return true;
593
+ }
594
+ function doShell() {
595
+ if (shellCompleted) return;
596
+ if (!resolveRootHoles()) return;
414
597
  solidJs.sharedConfig.context = context;
415
598
  html = injectAssets(context.assets, html);
416
599
  headStyles = new Set();
@@ -418,6 +601,8 @@ function renderToStream(code, options = {}) {
418
601
  if (url.endsWith(".css")) headStyles.add(url);
419
602
  }
420
603
  html = injectPreloadLinks(tracking.emittedAssets, html);
604
+ html = injectInlineStyles(tracking.inlineStyles, html, nonce);
605
+ serializeRootAssets();
421
606
  if (tasks.length) html = injectScripts(html, tasks, nonce);
422
607
  buffer.write(html);
423
608
  tasks = "";
@@ -441,51 +626,67 @@ function renderToStream(code, options = {}) {
441
626
  complete();
442
627
  };
443
628
  } else onCompleteAll = complete;
444
- queue(flushEnd);
629
+ function flush() {
630
+ allSettled(blockingPromises).then(() => {
631
+ setTimeout(() => {
632
+ if (!resolveRootHoles()) return flush();
633
+ queue(flushEnd);
634
+ });
635
+ });
636
+ }
637
+ flush();
445
638
  },
446
639
  pipe(w) {
447
- 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();
640
+ function flush() {
641
+ allSettled(blockingPromises).then(() => {
642
+ setTimeout(() => {
643
+ doShell();
644
+ if (!shellCompleted) return flush();
645
+ buffer = writable = w;
646
+ buffer.write(tmp);
647
+ firstFlushed = true;
648
+ if (completed) {
649
+ dispose();
650
+ writable.end();
651
+ } else flushEnd();
652
+ });
457
653
  });
458
- });
654
+ }
655
+ flush();
459
656
  },
460
657
  pipeTo(w) {
461
- return allSettled(blockingPromises).then(() => {
462
- let resolve;
463
- const p = new Promise(r => resolve = r);
464
- setTimeout(() => {
465
- doShell();
466
- const encoder = new TextEncoder();
467
- const writer = w.getWriter();
468
- writable = {
469
- end() {
470
- writer.releaseLock();
471
- w.close().catch(() => {});
472
- resolve();
473
- }
474
- };
475
- buffer = {
476
- write(payload) {
477
- writer.write(encoder.encode(payload)).catch(() => {});
478
- }
479
- };
480
- buffer.write(tmp);
481
- firstFlushed = true;
482
- if (completed) {
483
- dispose();
484
- writable.end();
485
- } else flushEnd();
658
+ let resolve;
659
+ const p = new Promise(r => resolve = r);
660
+ function flush() {
661
+ allSettled(blockingPromises).then(() => {
662
+ setTimeout(() => {
663
+ doShell();
664
+ if (!shellCompleted) return flush();
665
+ const encoder = new TextEncoder();
666
+ const writer = w.getWriter();
667
+ writable = {
668
+ end() {
669
+ writer.releaseLock();
670
+ w.close().catch(() => {});
671
+ resolve();
672
+ }
673
+ };
674
+ buffer = {
675
+ write(payload) {
676
+ writer.write(encoder.encode(payload)).catch(() => {});
677
+ }
678
+ };
679
+ buffer.write(tmp);
680
+ firstFlushed = true;
681
+ if (completed) {
682
+ dispose();
683
+ writable.end();
684
+ } else flushEnd();
685
+ });
486
686
  });
487
- return p;
488
- });
687
+ }
688
+ flush();
689
+ return p;
489
690
  }
490
691
  };
491
692
  }
@@ -498,11 +699,176 @@ function HydrationScript(props) {
498
699
  ...props
499
700
  }));
500
701
  }
501
- function ssr(t, ...nodes) {
502
- if (nodes.length) return resolveSSR(t, nodes);
702
+ function ssrGroup(fn, n) {
703
+ fn.$g = n;
704
+ return fn;
705
+ }
706
+ function buildAsyncWrap(err, node) {
707
+ const p = solidJs.ssrHandleError(err);
708
+ if (!p) return null;
709
+ const owner = solidJs.getOwner();
503
710
  return {
711
+ fn: owner ? () => solidJs.runWithOwner(owner, node) : node,
712
+ p
713
+ };
714
+ }
715
+ function ssrFirstGroupHit(hole) {
716
+ try {
717
+ return hole();
718
+ } catch (err) {
719
+ return buildAsyncWrap(err, hole);
720
+ }
721
+ }
722
+ function tryResolveFunctionHole(hole) {
723
+ let value;
724
+ try {
725
+ value = hole();
726
+ } catch (err) {
727
+ return buildAsyncWrap(err, hole) || "";
728
+ }
729
+ const t = typeof value;
730
+ if (t === "string") return value;
731
+ if (t === "number") return "" + value;
732
+ if (value == null || t === "boolean") return "";
733
+ return tryResolveString(value);
734
+ }
735
+ function mergeTemplateInto(result, node) {
736
+ result.t[result.t.length - 1] += node.t[0];
737
+ if (node.t.length > 1) {
738
+ result.t.push(...node.t.slice(1));
739
+ result.h.push(...node.h);
740
+ result.p.push(...node.p);
741
+ }
742
+ }
743
+ function appendResolvedNode(result, node) {
744
+ if (node.fn !== undefined) {
745
+ result.h.push(node.fn);
746
+ result.p.push(node.p);
747
+ result.t.push("");
748
+ } else if (node.merge !== undefined) mergeTemplateInto(result, node.merge);else resolveSSRNode(node.bail, result);
749
+ }
750
+ let _lastGroupFn = null;
751
+ let _lastGroupArr = null;
752
+ let _lastGroupErr = null;
753
+ function ssrGroupSlot(fn, idx) {
754
+ return () => {
755
+ if (idx > 0 && _lastGroupFn === fn) {
756
+ if (_lastGroupArr !== null) return _lastGroupArr[idx];
757
+ throw _lastGroupErr;
758
+ }
759
+ _lastGroupFn = fn;
760
+ _lastGroupArr = null;
761
+ _lastGroupErr = null;
762
+ try {
763
+ _lastGroupArr = fn();
764
+ return _lastGroupArr[idx];
765
+ } catch (err) {
766
+ _lastGroupErr = err;
767
+ throw err;
768
+ }
769
+ };
770
+ }
771
+ function ssr(t) {
772
+ const len = arguments.length;
773
+ if (len === 1) return {
504
774
  t
505
775
  };
776
+ let s = t[0];
777
+ let result = null;
778
+ let lastGroup = null;
779
+ let lastGroupVal = null;
780
+ let lastGroupIdx = 0;
781
+ for (let i = 1; i < len; i++) {
782
+ const hole = arguments[i];
783
+ const ht = typeof hole;
784
+ if (ht === "string") {
785
+ if (result === null) s += hole;else result.t[result.t.length - 1] += hole;
786
+ } else if (ht === "number") {
787
+ if (result === null) s += hole;else result.t[result.t.length - 1] += hole;
788
+ } else if (hole == null || ht === "boolean") ; else if (ht === "function" && hole.$g) {
789
+ let value;
790
+ let hasValue = false;
791
+ if (lastGroup !== hole) {
792
+ const r = ssrFirstGroupHit(hole);
793
+ if (r !== null) {
794
+ lastGroup = hole;
795
+ lastGroupVal = r;
796
+ lastGroupIdx = 0;
797
+ if (!Array.isArray(r) && result === null) {
798
+ result = {
799
+ t: [s],
800
+ h: [],
801
+ p: []
802
+ };
803
+ s = "";
804
+ }
805
+ }
806
+ }
807
+ if (lastGroup === hole) {
808
+ if (Array.isArray(lastGroupVal)) {
809
+ value = lastGroupVal[lastGroupIdx++];
810
+ hasValue = true;
811
+ } else {
812
+ result.h.push(ssrGroupSlot(lastGroupVal.fn, lastGroupIdx++));
813
+ result.p.push(lastGroupVal.p);
814
+ result.t.push("");
815
+ }
816
+ }
817
+ if (hasValue) {
818
+ const vt = typeof value;
819
+ if (vt === "string" || vt === "number") {
820
+ if (result === null) s += value;else result.t[result.t.length - 1] += value;
821
+ } else if (value == null || vt === "boolean") ; else if (result !== null) {
822
+ resolveSSRNode(value, result);
823
+ } else {
824
+ const rs = tryResolveString(value);
825
+ if (typeof rs === "string") {
826
+ s += rs;
827
+ } else {
828
+ result = {
829
+ t: [s],
830
+ h: [],
831
+ p: []
832
+ };
833
+ s = "";
834
+ if (rs.merge !== undefined) mergeTemplateInto(result, rs.merge);else resolveSSRNode(rs.bail, result);
835
+ }
836
+ }
837
+ }
838
+ } else if (result !== null) {
839
+ resolveSSRNode(hole, result);
840
+ } else if (ht === "function") {
841
+ const r = tryResolveFunctionHole(hole);
842
+ if (typeof r === "string") s += r;else {
843
+ result = {
844
+ t: [s],
845
+ h: [],
846
+ p: []
847
+ };
848
+ s = "";
849
+ appendResolvedNode(result, r);
850
+ }
851
+ } else {
852
+ const r = tryResolveString(hole);
853
+ if (typeof r === "string") {
854
+ s += r;
855
+ } else {
856
+ result = {
857
+ t: [s],
858
+ h: [],
859
+ p: []
860
+ };
861
+ s = "";
862
+ appendResolvedNode(result, r);
863
+ }
864
+ }
865
+ const next = t[i];
866
+ if (result === null) s += next;else result.t[result.t.length - 1] += next;
867
+ }
868
+ if (result === null) return {
869
+ t: s
870
+ };
871
+ return result;
506
872
  }
507
873
  function ssrClassName(value) {
508
874
  if (!value) return "";
@@ -515,7 +881,7 @@ function ssrClassName(value) {
515
881
  classValue = !!value[key];
516
882
  if (!key || key === "undefined" || !classValue) continue;
517
883
  i && (result += " ");
518
- result += escape(key);
884
+ result += escape(key, true);
519
885
  }
520
886
  return result;
521
887
  }
@@ -525,8 +891,8 @@ function ssrStyle(value) {
525
891
  let result = "";
526
892
  const k = Object.keys(value);
527
893
  for (let i = 0; i < k.length; i++) {
528
- const s = k[i];
529
- const v = value[s];
894
+ const s = escape(k[i], true);
895
+ const v = value[k[i]];
530
896
  if (v != undefined) {
531
897
  if (i) result += ";";
532
898
  const r = escape(v, true);
@@ -541,10 +907,11 @@ function ssrStyleProperty(name, value) {
541
907
  return value != null ? name + value : "";
542
908
  }
543
909
  function ssrElement(tag, props, children, needsId) {
910
+ const hk = needsId ? ssrHydrationKey() : "";
544
911
  if (props == null) props = {};else if (typeof props === "function") props = props();
545
912
  const skipChildren = VOID_ELEMENTS.test(tag);
546
913
  const keys = Object.keys(props);
547
- let result = `<${tag}${needsId ? ssrHydrationKey() : ""} `;
914
+ let result = `<${tag}${hk} `;
548
915
  for (let i = 0; i < keys.length; i++) {
549
916
  const prop = keys[i];
550
917
  if (ChildProperties.has(prop)) {
@@ -583,18 +950,33 @@ function escape(s, attr) {
583
950
  const t = typeof s;
584
951
  if (t !== "string") {
585
952
  if (!attr && Array.isArray(s)) {
953
+ const joined = tryJoinPlainSSRArray(s);
954
+ if (joined !== undefined) return joined;
586
955
  s = s.slice();
587
956
  for (let i = 0; i < s.length; i++) s[i] = escape(s[i]);
588
957
  return s;
589
958
  }
590
- if (attr && t === "boolean") return s;
959
+ if (attr) {
960
+ if (s == null || t === "boolean" || t === "number") return s;
961
+ return escape(String(s), attr);
962
+ }
591
963
  return s;
592
964
  }
965
+ const delimCode = attr ? 34 : 60;
966
+ const len = s.length;
967
+ for (let i = 0; i < len; i++) {
968
+ const c = s.charCodeAt(i);
969
+ if (c === 38 || c === delimCode) return escapeSlow(s, attr, i);
970
+ }
971
+ return s;
972
+ }
973
+ function escapeSlow(s, attr, start) {
593
974
  const delim = attr ? '"' : "<";
975
+ const delimCode = attr ? 34 : 60;
594
976
  const escDelim = attr ? "&quot;" : "&lt;";
595
- let iDelim = s.indexOf(delim);
596
- let iAmp = s.indexOf("&");
597
- if (iDelim < 0 && iAmp < 0) return s;
977
+ const c0 = s.charCodeAt(start);
978
+ let iDelim = c0 === delimCode ? start : s.indexOf(delim, start);
979
+ let iAmp = c0 === 38 ? start : s.indexOf("&", start);
598
980
  let left = 0,
599
981
  out = "";
600
982
  while (iDelim >= 0 && iAmp >= 0) {
@@ -625,28 +1007,17 @@ function escape(s, attr) {
625
1007
  }
626
1008
  return left < s.length ? out + s.substring(left) : out;
627
1009
  }
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
- }
1010
+ function tryJoinPlainSSRArray(nodes) {
1011
+ if (nodes.length === 0) return undefined;
1012
+ let out = "";
1013
+ for (let i = 0, len = nodes.length; i < len; i++) {
1014
+ const node = nodes[i];
1015
+ if (node == null || typeof node !== "object" || node.h || typeof node.t !== "string") {
1016
+ return undefined;
647
1017
  }
1018
+ out += node.t;
648
1019
  }
649
- return target;
1020
+ return out;
650
1021
  }
651
1022
  function getHydrationKey() {
652
1023
  const hydrate = solidJs.sharedConfig.context;
@@ -664,11 +1035,14 @@ function getAssets() {
664
1035
  for (let i = 0, len = assets.length; i < len; i++) out += assets[i]();
665
1036
  return out;
666
1037
  }
1038
+ function Assets(props) {
1039
+ useAssets(() => props.children);
1040
+ }
667
1041
  function generateHydrationScript({
668
1042
  eventNames = ["click", "input"],
669
1043
  nonce
670
1044
  } = {}) {
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-->`;
1045
+ 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
1046
  }
673
1047
  function queue(fn) {
674
1048
  return Promise.resolve().then(fn);
@@ -721,14 +1095,48 @@ function propagateBoundaryStyles(childKey, parentKey, tracking) {
721
1095
  }
722
1096
  function collectStreamStyles(key, tracking, headStyles) {
723
1097
  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);
1098
+ const links = [];
1099
+ const inline = [];
1100
+ if (!styles) return {
1101
+ links,
1102
+ inline
1103
+ };
1104
+ for (const entry of styles) {
1105
+ if (typeof entry === "string") {
1106
+ if (!headStyles || !headStyles.has(entry)) links.push(entry);
1107
+ } else if (!entry.emitted) {
1108
+ entry.emitted = true;
1109
+ inline.push(entry);
729
1110
  }
730
1111
  }
731
- return result;
1112
+ return {
1113
+ links,
1114
+ inline
1115
+ };
1116
+ }
1117
+ function escapeStyleContent(content) {
1118
+ return content.replace(/<\/(style)/gi, "<\\/$1");
1119
+ }
1120
+ function renderInlineStyle(entry, nonce) {
1121
+ let attrs = "";
1122
+ if (entry.attrs) {
1123
+ for (const name in entry.attrs) {
1124
+ attrs += ` ${name}="${escape(String(entry.attrs[name]), true)}"`;
1125
+ }
1126
+ }
1127
+ return `<style${nonce ? ` nonce="${nonce}"` : ""} data-asset="${escape(entry.id, true)}"${attrs}>${escapeStyleContent(entry.content)}</style>`;
1128
+ }
1129
+ function injectInlineStyles(inlineStyles, html, nonce) {
1130
+ if (!inlineStyles.size) return html;
1131
+ const index = html.indexOf("</head>");
1132
+ if (index === -1) return html;
1133
+ let out = "";
1134
+ for (const entry of inlineStyles.values()) {
1135
+ if (entry.emitted) continue;
1136
+ entry.emitted = true;
1137
+ out += renderInlineStyle(entry, nonce);
1138
+ }
1139
+ return out ? html.slice(0, index) + out + html.slice(index) : html;
732
1140
  }
733
1141
  function injectScripts(html, scripts, nonce) {
734
1142
  const tag = `<script${nonce ? ` nonce="${nonce}"` : ""}>${scripts}</script>`;
@@ -766,19 +1174,49 @@ function flattenClassList(list, result) {
766
1174
  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
1175
  }
768
1176
  }
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);
1177
+ function tryResolveString(node) {
1178
+ const t = typeof node;
1179
+ if (t === "string") return node;
1180
+ if (t === "number") return "" + node;
1181
+ if (node == null || t === "boolean") return "";
1182
+ if (t === "object") {
1183
+ if (Array.isArray(node)) {
1184
+ const joined = tryJoinPlainSSRArray(node);
1185
+ if (joined !== undefined) return joined;
1186
+ let s = "";
1187
+ let prevNonObj = false;
1188
+ for (let i = 0, len = node.length; i < len; i++) {
1189
+ const item = node[i];
1190
+ const itemNonObj = item !== null && typeof item !== "object";
1191
+ if (prevNonObj && itemNonObj) s += "<!--!$-->";
1192
+ prevNonObj = itemNonObj;
1193
+ const r = tryResolveString(item);
1194
+ if (typeof r !== "string") return {
1195
+ bail: node
1196
+ };
1197
+ s += r;
1198
+ }
1199
+ return s;
1200
+ }
1201
+ if (node.h && node.h.length > 0) return {
1202
+ merge: node
1203
+ };
1204
+ if (node.t === undefined) {
1205
+ console.warn(`Unrecognized value. Skipped inserting`, node);
1206
+ return "";
1207
+ }
1208
+ return Array.isArray(node.t) ? node.t[0] : node.t;
779
1209
  }
780
- result.t[result.t.length - 1] += template[template.length - 1];
781
- return result;
1210
+ if (t === "function") {
1211
+ let v;
1212
+ try {
1213
+ v = node();
1214
+ } catch (err) {
1215
+ return buildAsyncWrap(err, node) || "";
1216
+ }
1217
+ return tryResolveString(v);
1218
+ }
1219
+ return "";
782
1220
  }
783
1221
  function resolveSSRNode(node, result = {
784
1222
  t: [""],
@@ -789,10 +1227,13 @@ function resolveSSRNode(node, result = {
789
1227
  if (t === "string" || t === "number") {
790
1228
  result.t[result.t.length - 1] += node;
791
1229
  } else if (node == null || t === "boolean") ; else if (Array.isArray(node)) {
792
- let prev = {};
1230
+ let prevNonObj = false;
793
1231
  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);
1232
+ const item = node[i];
1233
+ const itemNonObj = item !== null && typeof item !== "object";
1234
+ if (!top && prevNonObj && itemNonObj) result.t[result.t.length - 1] += `<!--!$-->`;
1235
+ prevNonObj = itemNonObj;
1236
+ resolveSSRNode(item, result);
796
1237
  }
797
1238
  } else if (t === "object") {
798
1239
  if (node.h) {
@@ -802,15 +1243,17 @@ function resolveSSRNode(node, result = {
802
1243
  result.h.push(...node.h);
803
1244
  result.p.push(...node.p);
804
1245
  }
805
- } else result.t[result.t.length - 1] += node.t;
1246
+ } else if (node.t !== undefined) {
1247
+ result.t[result.t.length - 1] += node.t;
1248
+ } else console.warn(`Unrecognized value. Skipped inserting`, node);
806
1249
  } else if (t === "function") {
807
1250
  try {
808
1251
  resolveSSRNode(node(), result);
809
1252
  } catch (err) {
810
- const p = solidJs.ssrHandleError(err);
811
- if (p) {
812
- result.h.push(node);
813
- result.p.push(p);
1253
+ const wrap = buildAsyncWrap(err, node);
1254
+ if (wrap) {
1255
+ result.h.push(wrap.fn);
1256
+ result.p.push(wrap.p);
814
1257
  result.t.push("");
815
1258
  }
816
1259
  }
@@ -822,7 +1265,7 @@ function resolveSSRSync(node) {
822
1265
  if (!res.h.length) return res.t[0];
823
1266
  throw new Error("This value cannot be rendered synchronously. Are you missing a boundary?");
824
1267
  }
825
- const RequestContext = Symbol();
1268
+ const RequestContext = Symbol.for("solid.RequestContext");
826
1269
  function getRequestEvent() {
827
1270
  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
1271
  }
@@ -833,28 +1276,116 @@ function notSup() {
833
1276
  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
1277
  }
835
1278
 
1279
+ const ENVELOPE = Symbol.for("solid.ResponseEnvelope");
1280
+ class ResponseEnvelope {
1281
+ constructor(response, value) {
1282
+ this.response = response;
1283
+ this.value = value;
1284
+ }
1285
+ }
1286
+ ResponseEnvelope.prototype[ENVELOPE] = true;
1287
+ function isResponseEnvelope(value) {
1288
+ return !!(value && typeof value === "object" && value[ENVELOPE]);
1289
+ }
1290
+ function initWithRevalidate(init) {
1291
+ const {
1292
+ revalidate,
1293
+ ...responseInit
1294
+ } = init;
1295
+ const headers = new Headers(responseInit.headers);
1296
+ revalidate !== undefined && headers.set("X-Revalidate", revalidate.toString());
1297
+ return {
1298
+ responseInit,
1299
+ headers
1300
+ };
1301
+ }
1302
+ function redirect(url, init = 302) {
1303
+ const {
1304
+ responseInit,
1305
+ headers
1306
+ } = initWithRevalidate(typeof init === "number" ? {
1307
+ status: init
1308
+ } : init);
1309
+ if (responseInit.status === undefined) {
1310
+ responseInit.status = 302;
1311
+ }
1312
+ headers.set("Location", url);
1313
+ return new Response(null, {
1314
+ ...responseInit,
1315
+ headers
1316
+ });
1317
+ }
1318
+ function reload(init = {}) {
1319
+ const {
1320
+ responseInit,
1321
+ headers
1322
+ } = initWithRevalidate(init);
1323
+ return new Response(null, {
1324
+ ...responseInit,
1325
+ headers
1326
+ });
1327
+ }
1328
+ function respond(value, init = {}) {
1329
+ const {
1330
+ responseInit,
1331
+ headers
1332
+ } = initWithRevalidate(init);
1333
+ headers.set("Content-Type", "application/json");
1334
+ return new ResponseEnvelope(new Response(JSON.stringify(value), {
1335
+ ...responseInit,
1336
+ headers
1337
+ }), value);
1338
+ }
1339
+
836
1340
  const isServer = true;
837
1341
  const isDev = false;
838
- function createDynamic(component, props) {
1342
+ function dynamic(source) {
839
1343
  const o = solidJs.getOwner();
840
1344
  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
- }
1345
+ return props => {
1346
+ const comp = source();
1347
+ let p;
1348
+ let settled = false;
1349
+ let value;
1350
+ let error;
1351
+ if (comp && typeof comp.then === "function") {
1352
+ p = comp;
1353
+ p.then(v => {
1354
+ value = v;
1355
+ settled = true;
1356
+ }, err => {
1357
+ error = err;
1358
+ settled = true;
1359
+ });
1360
+ const ctx = solidJs.sharedConfig.context;
1361
+ if (ctx?.async) ctx.block(p.then(() => {}, () => {}));
849
1362
  }
850
- });
1363
+ return solidJs.createMemo(() => {
1364
+ let c = comp;
1365
+ if (p) {
1366
+ if (!settled) throw new solidJs.NotReadyError(p);
1367
+ if (error) throw error;
1368
+ c = value;
1369
+ }
1370
+ if (c) {
1371
+ if (typeof c === "function") return c(props);
1372
+ if (typeof c === "string") {
1373
+ return ssrElement(c, props, undefined, true);
1374
+ }
1375
+ }
1376
+ }, {
1377
+ sync: true
1378
+ });
1379
+ };
851
1380
  }
852
1381
  function Dynamic(props) {
853
- const others = solidJs.omit(props, "component");
854
- return createDynamic(() => props.component, others);
1382
+ const Comp = dynamic(() => props.component);
1383
+ return solidJs.createComponent(Comp, solidJs.omit(props, "component"));
855
1384
  }
856
1385
  function Portal(props) {
857
- throw new Error("Portal is not supported on the server");
1386
+ const o = solidJs.getOwner();
1387
+ if (o?.id != null) solidJs.getNextChildId(o);
1388
+ return undefined;
858
1389
  }
859
1390
 
860
1391
  Object.defineProperty(exports, "Errored", {
@@ -885,6 +1416,10 @@ Object.defineProperty(exports, "Repeat", {
885
1416
  enumerable: true,
886
1417
  get: function () { return solidJs.Repeat; }
887
1418
  });
1419
+ Object.defineProperty(exports, "Reveal", {
1420
+ enumerable: true,
1421
+ get: function () { return solidJs.Reveal; }
1422
+ });
888
1423
  Object.defineProperty(exports, "Show", {
889
1424
  enumerable: true,
890
1425
  get: function () { return solidJs.Show; }
@@ -901,35 +1436,46 @@ Object.defineProperty(exports, "getOwner", {
901
1436
  enumerable: true,
902
1437
  get: function () { return solidJs.getOwner; }
903
1438
  });
904
- Object.defineProperty(exports, "ssrRunInScope", {
1439
+ Object.defineProperty(exports, "mergeProps", {
1440
+ enumerable: true,
1441
+ get: function () { return solidJs.merge; }
1442
+ });
1443
+ Object.defineProperty(exports, "scope", {
905
1444
  enumerable: true,
906
- get: function () { return solidJs.ssrRunInScope; }
1445
+ get: function () { return solidJs.ssrScope; }
907
1446
  });
908
1447
  Object.defineProperty(exports, "untrack", {
909
1448
  enumerable: true,
910
1449
  get: function () { return solidJs.untrack; }
911
1450
  });
1451
+ exports.Assets = Assets;
912
1452
  exports.ChildProperties = ChildProperties;
913
1453
  exports.DOMElements = DOMElements;
1454
+ exports.DOMWithState = DOMWithState;
914
1455
  exports.DelegatedEvents = DelegatedEvents;
915
1456
  exports.Dynamic = Dynamic;
916
1457
  exports.HydrationScript = HydrationScript;
1458
+ exports.MathMLElements = MathMLElements;
1459
+ exports.Namespaces = Namespaces;
917
1460
  exports.Portal = Portal;
918
- exports.Properties = Properties;
1461
+ exports.RawTextElements = RawTextElements;
919
1462
  exports.RequestContext = RequestContext;
1463
+ exports.ResponseEnvelope = ResponseEnvelope;
920
1464
  exports.SVGElements = SVGElements;
921
- exports.SVGNamespace = SVGNamespace;
922
- exports.addEventListener = notSup;
1465
+ exports.VoidElements = VoidElements;
1466
+ exports.acquireAsset = notSup;
1467
+ exports.addEvent = notSup;
923
1468
  exports.applyRef = applyRef;
924
1469
  exports.assign = notSup;
925
1470
  exports.className = notSup;
926
- exports.createDynamic = createDynamic;
927
1471
  exports.delegateEvents = notSup;
1472
+ exports.dynamic = dynamic;
928
1473
  exports.dynamicProperty = notSup;
929
1474
  exports.effect = effect;
930
1475
  exports.escape = escape;
931
1476
  exports.generateHydrationScript = generateHydrationScript;
932
1477
  exports.getAssets = getAssets;
1478
+ exports.getDelegatedRoot = notSup;
933
1479
  exports.getHydrationKey = getHydrationKey;
934
1480
  exports.getNextElement = notSup;
935
1481
  exports.getNextMarker = notSup;
@@ -938,25 +1484,35 @@ exports.getRequestEvent = getRequestEvent;
938
1484
  exports.hydrate = notSup;
939
1485
  exports.insert = notSup;
940
1486
  exports.isDev = isDev;
1487
+ exports.isResponseEnvelope = isResponseEnvelope;
941
1488
  exports.isServer = isServer;
942
1489
  exports.memo = memo;
943
- exports.mergeProps = mergeProps;
1490
+ exports.redirect = redirect;
1491
+ exports.ref = notSup;
1492
+ exports.registerDelegatedContainer = notSup;
1493
+ exports.registerDelegatedRoot = notSup;
1494
+ exports.reload = reload;
944
1495
  exports.render = notSup;
945
1496
  exports.renderToStream = renderToStream;
946
1497
  exports.renderToString = renderToString;
947
1498
  exports.renderToStringAsync = renderToStringAsync;
1499
+ exports.respond = respond;
948
1500
  exports.runHydrationEvents = notSup;
949
1501
  exports.setAttribute = notSup;
950
1502
  exports.setAttributeNS = notSup;
951
1503
  exports.setProperty = notSup;
1504
+ exports.setStyleProperty = notSup;
952
1505
  exports.spread = notSup;
953
1506
  exports.ssr = ssr;
954
1507
  exports.ssrAttribute = ssrAttribute;
955
1508
  exports.ssrClassName = ssrClassName;
956
1509
  exports.ssrElement = ssrElement;
1510
+ exports.ssrGroup = ssrGroup;
957
1511
  exports.ssrHydrationKey = ssrHydrationKey;
958
1512
  exports.ssrStyle = ssrStyle;
959
1513
  exports.ssrStyleProperty = ssrStyleProperty;
960
1514
  exports.style = notSup;
961
1515
  exports.template = notSup;
1516
+ exports.unregisterDelegatedContainer = notSup;
1517
+ exports.unregisterDelegatedRoot = notSup;
962
1518
  exports.useAssets = useAssets;