@solidjs/web 2.0.0-experimental.1 → 2.0.0-experimental.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/server.js CHANGED
@@ -1,41 +1,11 @@
1
- import { sharedConfig, createRoot, splitProps } from 'solid-js';
2
- export { ErrorBoundary, For, Index, Match, Show, Suspense, SuspenseList, Switch, createComponent, createRenderEffect as effect, getOwner, createMemo as memo, mergeProps, untrack } from 'solid-js';
1
+ import { createMemo, sharedConfig, createRoot, ssrHandleError, omit } from 'solid-js';
2
+ export { ErrorBoundary, For, Match, Repeat, Show, Suspense, Switch, createComponent, createRenderEffect as effect, getOwner, ssrRunInScope, untrack } from 'solid-js';
3
3
  import { Feature, Serializer, getCrossReferenceHeader } from 'seroval';
4
- import { CustomEventPlugin, DOMExceptionPlugin, EventPlugin, FormDataPlugin, HeadersPlugin, ReadableStreamPlugin, RequestPlugin, ResponsePlugin, URLSearchParamsPlugin, URLPlugin } from 'seroval-plugins/web';
4
+ import { AbortSignalPlugin, CustomEventPlugin, DOMExceptionPlugin, EventPlugin, FormDataPlugin, HeadersPlugin, ReadableStreamPlugin, RequestPlugin, ResponsePlugin, URLSearchParamsPlugin, URLPlugin } from 'seroval-plugins/web';
5
5
 
6
- const booleans = ["allowfullscreen", "async", "autofocus", "autoplay", "checked", "controls", "default", "disabled", "formnovalidate", "hidden", "indeterminate", "inert", "ismap", "loop", "multiple", "muted", "nomodule", "novalidate", "open", "playsinline", "readonly", "required", "reversed", "seamless", "selected"];
7
- const BooleanAttributes = /*#__PURE__*/new Set(booleans);
8
- const Properties = /*#__PURE__*/new Set(["value", "readOnly", "formNoValidate", "isMap", "noModule", "playsInline", ...booleans]);
6
+ const Properties = /*#__PURE__*/new Set([
7
+ "value", "checked", "selected", "muted"]);
9
8
  const ChildProperties = /*#__PURE__*/new Set(["innerHTML", "textContent", "innerText", "children"]);
10
- const PropAliases = /*#__PURE__*/Object.assign(Object.create(null), {
11
- class: "className",
12
- formnovalidate: {
13
- $: "formNoValidate",
14
- BUTTON: 1,
15
- INPUT: 1
16
- },
17
- ismap: {
18
- $: "isMap",
19
- IMG: 1
20
- },
21
- nomodule: {
22
- $: "noModule",
23
- SCRIPT: 1
24
- },
25
- playsinline: {
26
- $: "playsInline",
27
- VIDEO: 1
28
- },
29
- readonly: {
30
- $: "readOnly",
31
- INPUT: 1,
32
- TEXTAREA: 1
33
- }
34
- });
35
- function getPropAlias(prop, tagName) {
36
- const a = PropAliases[prop];
37
- return typeof a === "object" ? a[tagName] ? a["$"] : undefined : a;
38
- }
39
9
  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"]);
40
10
  const SVGElements = /*#__PURE__*/new Set([
41
11
  "altGlyph", "altGlyphDef", "altGlyphItem", "animate", "animateColor", "animateMotion", "animateTransform", "circle", "clipPath", "color-profile", "cursor", "defs", "desc", "ellipse", "feBlend", "feColorMatrix", "feComponentTransfer", "feComposite", "feConvolveMatrix", "feDiffuseLighting", "feDisplacementMap", "feDistantLight", "feDropShadow", "feFlood", "feFuncA", "feFuncB", "feFuncG", "feFuncR", "feGaussianBlur", "feImage", "feMerge", "feMergeNode", "feMorphology", "feOffset", "fePointLight", "feSpecularLighting", "feSpotLight", "feTile", "feTurbulence", "filter", "font", "font-face", "font-face-format", "font-face-name", "font-face-src", "font-face-uri", "foreignObject", "g", "glyph", "glyphRef", "hkern", "image", "line", "linearGradient", "marker", "mask", "metadata", "missing-glyph", "mpath", "path", "pattern", "polygon", "polyline", "radialGradient", "rect",
@@ -46,7 +16,11 @@ const SVGNamespace = {
46
16
  xlink: "http://www.w3.org/1999/xlink",
47
17
  xml: "http://www.w3.org/XML/1998/namespace"
48
18
  };
49
- 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"]);
19
+ 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",
20
+ "webview",
21
+ "isindex", "listing", "multicol", "nextid", "noindex", "search"]);
22
+
23
+ const memo = fn => createMemo(() => fn());
50
24
 
51
25
  const ES2017FLAG = Feature.AggregateError
52
26
  | Feature.BigIntTypedArray;
@@ -59,7 +33,7 @@ function createSerializer({
59
33
  }) {
60
34
  return new Serializer({
61
35
  scopeId,
62
- plugins: [
36
+ plugins: [AbortSignalPlugin,
63
37
  CustomEventPlugin, DOMExceptionPlugin, EventPlugin,
64
38
  FormDataPlugin, HeadersPlugin, ReadableStreamPlugin, RequestPlugin, ResponsePlugin, URLSearchParamsPlugin, URLPlugin],
65
39
  globalIdentifier: GLOBAL_IDENTIFIER,
@@ -77,12 +51,15 @@ const VOID_ELEMENTS = /^(?:area|base|br|col|embed|hr|img|input|keygen|link|menui
77
51
  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)}`;
78
52
  function renderToString(code, options = {}) {
79
53
  const {
80
- renderId
54
+ renderId = "",
55
+ nonce,
56
+ noScripts
81
57
  } = options;
82
58
  let scripts = "";
83
59
  const serializer = createSerializer({
84
60
  scopeId: renderId,
85
61
  onData(script) {
62
+ if (noScripts) return;
86
63
  if (!scripts) {
87
64
  scripts = getLocalHeaderScript(renderId);
88
65
  }
@@ -91,23 +68,20 @@ function renderToString(code, options = {}) {
91
68
  onError: options.onError
92
69
  });
93
70
  sharedConfig.context = {
94
- id: renderId || "",
95
- count: 0,
96
- suspense: {},
97
- lazy: {},
98
71
  assets: [],
99
- nonce: options.nonce,
72
+ nonce,
73
+ escape: escape,
74
+ resolve: resolveSSRNode,
75
+ ssr: ssr,
100
76
  serialize(id, p) {
101
77
  !sharedConfig.context.noHydrate && serializer.write(id, p);
102
- },
103
- roots: 0,
104
- nextRoot() {
105
- return this.renderId + "i-" + this.roots++;
106
78
  }
107
79
  };
108
80
  let html = createRoot(d => {
109
81
  setTimeout(d);
110
- return resolveSSRNode(escape(code()));
82
+ return resolveSSRSync(escape(code()));
83
+ }, {
84
+ id: renderId
111
85
  });
112
86
  sharedConfig.context.noHydrate = true;
113
87
  serializer.close();
@@ -115,25 +89,12 @@ function renderToString(code, options = {}) {
115
89
  if (scripts.length) html = injectScripts(html, scripts, options.nonce);
116
90
  return html;
117
91
  }
118
- function renderToStringAsync(code, options = {}) {
119
- const {
120
- timeoutMs = 30000
121
- } = options;
122
- let timeoutHandle;
123
- const timeout = new Promise((_, reject) => {
124
- timeoutHandle = setTimeout(() => reject("renderToString timed out"), timeoutMs);
125
- });
126
- return Promise.race([renderToStream(code, options), timeout]).then(html => {
127
- clearTimeout(timeoutHandle);
128
- return html;
129
- });
130
- }
131
92
  function renderToStream(code, options = {}) {
132
93
  let {
133
94
  nonce,
134
95
  onCompleteShell,
135
96
  onCompleteAll,
136
- renderId,
97
+ renderId = "",
137
98
  noScripts
138
99
  } = options;
139
100
  let dispose;
@@ -195,12 +156,7 @@ function renderToStream(code, options = {}) {
195
156
  }
196
157
  };
197
158
  sharedConfig.context = context = {
198
- id: renderId || "",
199
- count: 0,
200
159
  async: true,
201
- resources: {},
202
- lazy: {},
203
- suspense: {},
204
160
  assets: [],
205
161
  nonce,
206
162
  block(p) {
@@ -212,7 +168,7 @@ function renderToStream(code, options = {}) {
212
168
  const first = html.indexOf(placeholder);
213
169
  if (first === -1) return;
214
170
  const last = html.indexOf(`<!--!$/${id}-->`, first + placeholder.length);
215
- html = html.slice(0, first) + resolveSSRNode(escape(payloadFn())) + html.slice(last + placeholder.length + 1);
171
+ html = html.slice(0, first) + resolveSSRSync(escape(payloadFn())) + html.slice(last + placeholder.length + 1);
216
172
  },
217
173
  serialize(id, p, wait) {
218
174
  const serverOnly = sharedConfig.context.noHydrate;
@@ -225,36 +181,46 @@ function renderToStream(code, options = {}) {
225
181
  });
226
182
  } else if (!serverOnly) serializer.write(id, p);
227
183
  },
228
- roots: 0,
229
- nextRoot() {
230
- return this.renderId + "i-" + this.roots++;
231
- },
184
+ escape: escape,
185
+ resolve: resolveSSRNode,
186
+ ssr: ssr,
232
187
  registerFragment(key) {
233
188
  if (!registry.has(key)) {
234
189
  let resolve, reject;
235
190
  const p = new Promise((r, rej) => (resolve = r, reject = rej));
236
- registry.set(key, err => queue(() => queue(() => {
237
- err ? reject(err) : resolve(true);
238
- queue(flushEnd);
239
- })));
191
+ registry.set(key, {
192
+ resolve: err => queue(() => queue(() => {
193
+ err ? reject(err) : resolve(true);
194
+ queue(flushEnd);
195
+ }))
196
+ });
240
197
  serializer.write(key, p);
241
198
  }
242
199
  return (value, error) => {
243
200
  if (registry.has(key)) {
244
- const resolve = registry.get(key);
201
+ const item = registry.get(key);
245
202
  registry.delete(key);
246
- if (waitForFragments(registry, key)) {
247
- resolve();
203
+ if (item.children) {
204
+ for (const k in item.children) {
205
+ value = replacePlaceholder(value, k, item.children[k]);
206
+ }
207
+ }
208
+ const parentKey = waitForFragments(registry, key);
209
+ if (parentKey) {
210
+ const parent = registry.get(parentKey);
211
+ parent.children ||= {};
212
+ parent.children[key] = value !== undefined ? value : "";
213
+ item.resolve();
248
214
  return;
249
215
  }
250
216
  if (!completed) {
251
217
  if (!firstFlushed) {
252
218
  queue(() => html = replacePlaceholder(html, key, value !== undefined ? value : ""));
253
- resolve(error);
219
+ item.resolve(error);
254
220
  } else {
255
221
  buffer.write(`<template id="${key}">${value !== undefined ? value : " "}</template>`);
256
222
  pushTask(`$df("${key}")${!scriptFlushed ? ";" + REPLACE_SCRIPT : ""}`);
257
- resolve(error);
223
+ item.resolve(error);
258
224
  scriptFlushed = true;
259
225
  }
260
226
  }
@@ -265,12 +231,13 @@ function renderToStream(code, options = {}) {
265
231
  };
266
232
  let html = createRoot(d => {
267
233
  dispose = d;
268
- return resolveSSRNode(escape(code()));
234
+ return resolveSSRSync(escape(code()));
235
+ }, {
236
+ id: renderId
269
237
  });
270
238
  function doShell() {
271
239
  if (shellCompleted) return;
272
240
  sharedConfig.context = context;
273
- context.noHydrate = true;
274
241
  html = injectAssets(context.assets, html);
275
242
  if (tasks.length) html = injectScripts(html, tasks, nonce);
276
243
  buffer.write(html);
@@ -353,21 +320,15 @@ function HydrationScript(props) {
353
320
  }));
354
321
  }
355
322
  function ssr(t, ...nodes) {
356
- if (nodes.length) {
357
- let result = "";
358
- for (let i = 0; i < nodes.length; i++) {
359
- result += t[i];
360
- const node = nodes[i];
361
- if (node !== undefined) result += resolveSSRNode(node);
362
- }
363
- t = result + t[nodes.length];
364
- }
323
+ if (nodes.length) return resolveSSR(t, nodes);
365
324
  return {
366
325
  t
367
326
  };
368
327
  }
369
328
  function ssrClassName(value) {
370
329
  if (!value) return "";
330
+ if (typeof value === "string") return escape(value, true);
331
+ value = classListToObject(value);
371
332
  let classKeys = Object.keys(value),
372
333
  result = "";
373
334
  for (let i = 0, len = classKeys.length; i < len; i++) {
@@ -389,11 +350,17 @@ function ssrStyle(value) {
389
350
  const v = value[s];
390
351
  if (v != undefined) {
391
352
  if (i) result += ";";
392
- result += `${s}:${escape(v, true)}`;
353
+ const r = escape(v, true);
354
+ if (r != undefined && r !== "undefined") {
355
+ result += `${s}:${r}`;
356
+ }
393
357
  }
394
358
  }
395
359
  return result;
396
360
  }
361
+ function ssrStyleProperty(name, value) {
362
+ return value != null ? name + value : "";
363
+ }
397
364
  function ssrElement(tag, props, children, needsId) {
398
365
  if (props == null) props = {};else if (typeof props === "function") props = props();
399
366
  const skipChildren = VOID_ELEMENTS.test(tag);
@@ -402,7 +369,7 @@ function ssrElement(tag, props, children, needsId) {
402
369
  for (let i = 0; i < keys.length; i++) {
403
370
  const prop = keys[i];
404
371
  if (ChildProperties.has(prop)) {
405
- if (children === undefined && !skipChildren) children = prop === "innerHTML" ? props[prop] : escape(props[prop]);
372
+ if (children === undefined && !skipChildren) children = tag === "script" || tag === "style" || prop === "innerHTML" ? props[prop] : escape(props[prop]);
406
373
  continue;
407
374
  }
408
375
  const value = props[prop];
@@ -410,17 +377,13 @@ function ssrElement(tag, props, children, needsId) {
410
377
  result += `style="${ssrStyle(value)}"`;
411
378
  } else if (prop === "class") {
412
379
  result += `class="${ssrClassName(value)}"`;
413
- } else if (BooleanAttributes.has(prop)) {
414
- if (value) result += prop;else continue;
415
380
  } else if (value == undefined || prop === "ref" || prop.slice(0, 2) === "on" || prop.slice(0, 5) === "prop:") {
416
381
  continue;
417
- } else if (prop.slice(0, 5) === "bool:") {
382
+ } else if (typeof value === "boolean") {
418
383
  if (!value) continue;
419
- result += escape(prop.slice(5));
420
- } else if (prop.slice(0, 5) === "attr:") {
421
- result += `${escape(prop.slice(5))}="${escape(value, true)}"`;
384
+ result += escape(prop);
422
385
  } else {
423
- result += `${Aliases[prop] || escape(prop)}="${escape(value, true)}"`;
386
+ result += value === "" ? escape(prop) : `${escape(prop)}="${escape(value, true)}"`;
424
387
  }
425
388
  if (i !== keys.length - 1) result += " ";
426
389
  }
@@ -428,26 +391,24 @@ function ssrElement(tag, props, children, needsId) {
428
391
  t: result + "/>"
429
392
  };
430
393
  if (typeof children === "function") children = children();
431
- return {
432
- t: result + `>${resolveSSRNode(children, true)}</${tag}>`
433
- };
394
+ return ssr([result + ">", `</${tag}>`], resolveSSRNode(children, undefined, true));
434
395
  }
435
- function ssrAttribute(key, value, isBoolean) {
436
- return isBoolean ? value ? " " + key : "" : value != null ? ` ${key}="${value}"` : "";
396
+ function ssrAttribute(key, value) {
397
+ return value == null || value === false ? "" : value === true ? ` ${key}` : ` ${key}="${value}"`;
437
398
  }
438
399
  function ssrHydrationKey() {
439
400
  const hk = getHydrationKey();
440
- return hk ? ` data-hk=${hk}` : "";
401
+ return hk ? ` _hk=${hk}` : "";
441
402
  }
442
403
  function escape(s, attr) {
443
404
  const t = typeof s;
444
405
  if (t !== "string") {
445
- if (!attr && t === "function") return escape(s());
446
406
  if (!attr && Array.isArray(s)) {
407
+ s = s.slice();
447
408
  for (let i = 0; i < s.length; i++) s[i] = escape(s[i]);
448
409
  return s;
449
410
  }
450
- if (attr && t === "boolean") return String(s);
411
+ if (attr && t === "boolean") return s;
451
412
  return s;
452
413
  }
453
414
  const delim = attr ? '"' : "<";
@@ -485,29 +446,35 @@ function escape(s, attr) {
485
446
  }
486
447
  return left < s.length ? out + s.substring(left) : out;
487
448
  }
488
- function resolveSSRNode(node, top) {
489
- const t = typeof node;
490
- if (t === "string") return node;
491
- if (node == null || t === "boolean") return "";
492
- if (Array.isArray(node)) {
493
- let prev = {};
494
- let mapped = "";
495
- for (let i = 0, len = node.length; i < len; i++) {
496
- if (!top && typeof prev !== "object" && typeof node[i] !== "object") mapped += `<!--!$-->`;
497
- mapped += resolveSSRNode(prev = node[i]);
449
+ function mergeProps(...sources) {
450
+ const target = {};
451
+ for (let i = 0; i < sources.length; i++) {
452
+ let source = sources[i];
453
+ if (typeof source === "function") source = source();
454
+ if (source) {
455
+ const descriptors = Object.getOwnPropertyDescriptors(source);
456
+ for (const key in descriptors) {
457
+ if (key in target) continue;
458
+ Object.defineProperty(target, key, {
459
+ enumerable: true,
460
+ get() {
461
+ for (let i = sources.length - 1; i >= 0; i--) {
462
+ const v = (sources[i] || {})[key];
463
+ if (v !== undefined) return v;
464
+ }
465
+ }
466
+ });
467
+ }
498
468
  }
499
- return mapped;
500
469
  }
501
- if (t === "object") return node.t;
502
- if (t === "function") return resolveSSRNode(node());
503
- return String(node);
470
+ return target;
504
471
  }
505
472
  function getHydrationKey() {
506
473
  const hydrate = sharedConfig.context;
507
474
  return hydrate && !hydrate.noHydrate && sharedConfig.getNextContextId();
508
475
  }
509
476
  function useAssets(fn) {
510
- sharedConfig.context.assets.push(() => resolveSSRNode(escape(fn())));
477
+ sharedConfig.context.assets.push(() => resolveSSRSync(escape(fn())));
511
478
  }
512
479
  function getAssets() {
513
480
  const assets = sharedConfig.context.assets;
@@ -519,15 +486,13 @@ function generateHydrationScript({
519
486
  eventNames = ["click", "input"],
520
487
  nonce
521
488
  } = {}) {
522
- return `<script${nonce ? ` nonce="${nonce}"` : ""}>window._$HY||(e=>{let t=e=>e&&e.hasAttribute&&(e.hasAttribute("data-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-->`;
489
+ 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-->`;
523
490
  }
524
491
  function Hydration(props) {
525
492
  if (!sharedConfig.context.noHydrate) return props.children;
526
493
  const context = sharedConfig.context;
527
494
  sharedConfig.context = {
528
495
  ...context,
529
- count: 0,
530
- id: sharedConfig.getNextContextId(),
531
496
  noHydrate: false
532
497
  };
533
498
  const res = props.children;
@@ -535,8 +500,14 @@ function Hydration(props) {
535
500
  return res;
536
501
  }
537
502
  function NoHydration(props) {
538
- if (sharedConfig.context) sharedConfig.context.noHydrate = true;
539
- return props.children;
503
+ let context = sharedConfig.context;
504
+ if (context) sharedConfig.context = {
505
+ ...context,
506
+ noHydrate: true
507
+ };
508
+ const res = props.children;
509
+ if (context) sharedConfig.context = context;
510
+ return res;
540
511
  }
541
512
  function queue(fn) {
542
513
  return Promise.resolve().then(fn);
@@ -566,7 +537,7 @@ function injectScripts(html, scripts, nonce) {
566
537
  }
567
538
  function waitForFragments(registry, key) {
568
539
  for (const k of [...registry.keys()].reverse()) {
569
- if (key.startsWith(k)) return true;
540
+ if (key.startsWith(k)) return k;
570
541
  }
571
542
  return false;
572
543
  }
@@ -578,12 +549,82 @@ function replacePlaceholder(html, key, value) {
578
549
  const last = html.indexOf(close, first + marker.length);
579
550
  return html.slice(0, first) + value + html.slice(last + close.length);
580
551
  }
552
+ function classListToObject(classList) {
553
+ if (Array.isArray(classList)) {
554
+ const result = {};
555
+ flattenClassList(classList, result);
556
+ return result;
557
+ }
558
+ return classList;
559
+ }
560
+ function flattenClassList(list, result) {
561
+ for (let i = 0, len = list.length; i < len; i++) {
562
+ const item = list[i];
563
+ 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;
564
+ }
565
+ }
566
+ function resolveSSR(template, holes, result = {
567
+ t: [""],
568
+ h: [],
569
+ p: []
570
+ }) {
571
+ for (let i = 0; i < holes.length; i++) {
572
+ const hole = holes[i];
573
+ result.t[result.t.length - 1] += template[i];
574
+ if (hole == null || hole === true || hole === false) continue;
575
+ resolveSSRNode(hole, result);
576
+ }
577
+ result.t[result.t.length - 1] += template[template.length - 1];
578
+ return result;
579
+ }
580
+ function resolveSSRNode(node, result = {
581
+ t: [""],
582
+ h: [],
583
+ p: []
584
+ }, top) {
585
+ const t = typeof node;
586
+ if (t === "string" || t === "number") {
587
+ result.t[result.t.length - 1] += node;
588
+ } else if (node == null || t === "boolean") ; else if (Array.isArray(node)) {
589
+ let prev = {};
590
+ for (let i = 0, len = node.length; i < len; i++) {
591
+ if (!top && typeof prev !== "object" && typeof node[i] !== "object") result.t[result.t.length - 1] += `<!--!$-->`;
592
+ resolveSSRNode(prev = node[i], result);
593
+ }
594
+ } else if (t === "object") {
595
+ if (node.h) {
596
+ result.t[result.t.length - 1] += node.t[0];
597
+ if (node.t.length > 1) {
598
+ result.t.push(...node.t.slice(1));
599
+ result.h.push(...node.h);
600
+ result.p.push(...node.p);
601
+ }
602
+ } else result.t[result.t.length - 1] += node.t;
603
+ } else if (t === "function") {
604
+ try {
605
+ resolveSSRNode(node(), result);
606
+ } catch (err) {
607
+ const p = ssrHandleError(err);
608
+ if (p) {
609
+ result.h.push(node);
610
+ result.p.push(p);
611
+ result.t.push("");
612
+ }
613
+ }
614
+ }
615
+ return result;
616
+ }
617
+ function resolveSSRSync(node) {
618
+ const res = resolveSSRNode(node);
619
+ if (!res.h.length) return res.t[0];
620
+ throw new Error("This value cannot be rendered synchronously. Are you missing a Suspsense boundary?");
621
+ }
581
622
  const RequestContext = Symbol();
582
623
  function getRequestEvent() {
583
624
  return globalThis[RequestContext] ? globalThis[RequestContext].getStore() || sharedConfig.context && sharedConfig.context.event || console.log("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;
584
625
  }
585
- function Assets(props) {
586
- useAssets(() => props.children);
626
+ function renderToStringAsync(code, options = {}) {
627
+ return renderToStream(code, options).then(html => html);
587
628
  }
588
629
  function notSup() {
589
630
  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>.");
@@ -591,18 +632,21 @@ function notSup() {
591
632
 
592
633
  const isServer = true;
593
634
  const isDev = false;
594
- function Dynamic(props) {
595
- const [p, others] = splitProps(props, ["component"]);
596
- const comp = p.component,
635
+ function createDynamic(component, props) {
636
+ const comp = component(),
597
637
  t = typeof comp;
598
638
  if (comp) {
599
- if (t === "function") return comp(others);else if (t === "string") {
600
- return ssrElement(comp, others, undefined, true);
639
+ if (t === "function") return comp(props);else if (t === "string") {
640
+ return ssrElement(comp, props, undefined, true);
601
641
  }
602
642
  }
603
643
  }
644
+ function Dynamic(props) {
645
+ const others = omit(props, "component");
646
+ return createDynamic(() => props.component, others);
647
+ }
604
648
  function Portal(props) {
605
- return "";
649
+ throw new Error("Portal is not supported on the server");
606
650
  }
607
651
 
608
- export { Assets, ChildProperties, DOMElements, DelegatedEvents, Dynamic, Hydration, HydrationScript, NoHydration, Portal, Properties, RequestContext, SVGElements, SVGNamespace, notSup as addEventListener, notSup as assign, notSup as className, notSup as delegateEvents, notSup as dynamicProperty, escape, generateHydrationScript, getAssets, getHydrationKey, notSup as getNextElement, notSup as getNextMarker, notSup as getNextMatch, getPropAlias, getRequestEvent, notSup as hydrate, notSup as insert, isDev, isServer, notSup as render, renderToStream, renderToString, renderToStringAsync, resolveSSRNode, notSup as runHydrationEvents, notSup as setAttribute, notSup as setAttributeNS, notSup as setProperty, notSup as spread, ssr, ssrAttribute, ssrClassName, ssrElement, ssrHydrationKey, ssrStyle, notSup as style, notSup as template, useAssets };
652
+ export { ChildProperties, DOMElements, DelegatedEvents, Dynamic, Hydration, HydrationScript, NoHydration, Portal, Properties, RequestContext, SVGElements, SVGNamespace, notSup as addEventListener, notSup as assign, notSup as className, createDynamic, notSup as delegateEvents, notSup as dynamicProperty, escape, generateHydrationScript, getAssets, getHydrationKey, notSup as getNextElement, notSup as getNextMarker, notSup as getNextMatch, getRequestEvent, notSup as hydrate, notSup as insert, isDev, isServer, memo, mergeProps, notSup as render, renderToStream, renderToString, renderToStringAsync, notSup as runHydrationEvents, notSup as setAttribute, notSup as setAttributeNS, notSup as setProperty, notSup as spread, ssr, ssrAttribute, ssrClassName, ssrElement, ssrHydrationKey, ssrStyle, ssrStyleProperty, notSup as style, notSup as template, useAssets };