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

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,13 +1,78 @@
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';
3
- import { Feature, Serializer, getCrossReferenceHeader } from 'seroval';
4
- import { CustomEventPlugin, DOMExceptionPlugin, EventPlugin, FormDataPlugin, HeadersPlugin, ReadableStreamPlugin, RequestPlugin, ResponsePlugin, URLSearchParamsPlugin, URLPlugin } from 'seroval-plugins/web';
1
+ import { sharedConfig, createRoot, splitProps } from "solid-js";
2
+ export {
3
+ ErrorBoundary,
4
+ For,
5
+ Index,
6
+ Match,
7
+ Show,
8
+ Suspense,
9
+ SuspenseList,
10
+ Switch,
11
+ createComponent,
12
+ createRenderEffect as effect,
13
+ getOwner,
14
+ createMemo as memo,
15
+ mergeProps,
16
+ untrack
17
+ } from "solid-js";
18
+ import { Feature, Serializer, getCrossReferenceHeader } from "seroval";
19
+ import {
20
+ CustomEventPlugin,
21
+ DOMExceptionPlugin,
22
+ EventPlugin,
23
+ FormDataPlugin,
24
+ HeadersPlugin,
25
+ ReadableStreamPlugin,
26
+ RequestPlugin,
27
+ ResponsePlugin,
28
+ URLSearchParamsPlugin,
29
+ URLPlugin
30
+ } from "seroval-plugins/web";
5
31
 
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]);
9
- const ChildProperties = /*#__PURE__*/new Set(["innerHTML", "textContent", "innerText", "children"]);
10
- const PropAliases = /*#__PURE__*/Object.assign(Object.create(null), {
32
+ const booleans = [
33
+ "allowfullscreen",
34
+ "async",
35
+ "autofocus",
36
+ "autoplay",
37
+ "checked",
38
+ "controls",
39
+ "default",
40
+ "disabled",
41
+ "formnovalidate",
42
+ "hidden",
43
+ "indeterminate",
44
+ "inert",
45
+ "ismap",
46
+ "loop",
47
+ "multiple",
48
+ "muted",
49
+ "nomodule",
50
+ "novalidate",
51
+ "open",
52
+ "playsinline",
53
+ "readonly",
54
+ "required",
55
+ "reversed",
56
+ "seamless",
57
+ "selected"
58
+ ];
59
+ const BooleanAttributes = /*#__PURE__*/ new Set(booleans);
60
+ const Properties = /*#__PURE__*/ new Set([
61
+ "value",
62
+ "readOnly",
63
+ "formNoValidate",
64
+ "isMap",
65
+ "noModule",
66
+ "playsInline",
67
+ ...booleans
68
+ ]);
69
+ const ChildProperties = /*#__PURE__*/ new Set([
70
+ "innerHTML",
71
+ "textContent",
72
+ "innerText",
73
+ "children"
74
+ ]);
75
+ const PropAliases = /*#__PURE__*/ Object.assign(Object.create(null), {
11
76
  class: "className",
12
77
  formnovalidate: {
13
78
  $: "formNoValidate",
@@ -34,34 +99,414 @@ const PropAliases = /*#__PURE__*/Object.assign(Object.create(null), {
34
99
  });
35
100
  function getPropAlias(prop, tagName) {
36
101
  const a = PropAliases[prop];
37
- return typeof a === "object" ? a[tagName] ? a["$"] : undefined : a;
38
- }
39
- 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
- const SVGElements = /*#__PURE__*/new Set([
41
- "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",
42
- "set", "stop",
43
- "svg", "switch", "symbol", "text", "textPath",
44
- "tref", "tspan", "use", "view", "vkern"]);
102
+ return typeof a === "object" ? (a[tagName] ? a["$"] : undefined) : a;
103
+ }
104
+ const DelegatedEvents = /*#__PURE__*/ new Set([
105
+ "beforeinput",
106
+ "click",
107
+ "dblclick",
108
+ "contextmenu",
109
+ "focusin",
110
+ "focusout",
111
+ "input",
112
+ "keydown",
113
+ "keyup",
114
+ "mousedown",
115
+ "mousemove",
116
+ "mouseout",
117
+ "mouseover",
118
+ "mouseup",
119
+ "pointerdown",
120
+ "pointermove",
121
+ "pointerout",
122
+ "pointerover",
123
+ "pointerup",
124
+ "touchend",
125
+ "touchmove",
126
+ "touchstart"
127
+ ]);
128
+ const SVGElements = /*#__PURE__*/ new Set([
129
+ "altGlyph",
130
+ "altGlyphDef",
131
+ "altGlyphItem",
132
+ "animate",
133
+ "animateColor",
134
+ "animateMotion",
135
+ "animateTransform",
136
+ "circle",
137
+ "clipPath",
138
+ "color-profile",
139
+ "cursor",
140
+ "defs",
141
+ "desc",
142
+ "ellipse",
143
+ "feBlend",
144
+ "feColorMatrix",
145
+ "feComponentTransfer",
146
+ "feComposite",
147
+ "feConvolveMatrix",
148
+ "feDiffuseLighting",
149
+ "feDisplacementMap",
150
+ "feDistantLight",
151
+ "feDropShadow",
152
+ "feFlood",
153
+ "feFuncA",
154
+ "feFuncB",
155
+ "feFuncG",
156
+ "feFuncR",
157
+ "feGaussianBlur",
158
+ "feImage",
159
+ "feMerge",
160
+ "feMergeNode",
161
+ "feMorphology",
162
+ "feOffset",
163
+ "fePointLight",
164
+ "feSpecularLighting",
165
+ "feSpotLight",
166
+ "feTile",
167
+ "feTurbulence",
168
+ "filter",
169
+ "font",
170
+ "font-face",
171
+ "font-face-format",
172
+ "font-face-name",
173
+ "font-face-src",
174
+ "font-face-uri",
175
+ "foreignObject",
176
+ "g",
177
+ "glyph",
178
+ "glyphRef",
179
+ "hkern",
180
+ "image",
181
+ "line",
182
+ "linearGradient",
183
+ "marker",
184
+ "mask",
185
+ "metadata",
186
+ "missing-glyph",
187
+ "mpath",
188
+ "path",
189
+ "pattern",
190
+ "polygon",
191
+ "polyline",
192
+ "radialGradient",
193
+ "rect",
194
+ "set",
195
+ "stop",
196
+ "svg",
197
+ "switch",
198
+ "symbol",
199
+ "text",
200
+ "textPath",
201
+ "tref",
202
+ "tspan",
203
+ "use",
204
+ "view",
205
+ "vkern"
206
+ ]);
45
207
  const SVGNamespace = {
46
208
  xlink: "http://www.w3.org/1999/xlink",
47
209
  xml: "http://www.w3.org/XML/1998/namespace"
48
210
  };
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"]);
211
+ const DOMElements = /*#__PURE__*/ new Set([
212
+ "html",
213
+ "base",
214
+ "head",
215
+ "link",
216
+ "meta",
217
+ "style",
218
+ "title",
219
+ "body",
220
+ "address",
221
+ "article",
222
+ "aside",
223
+ "footer",
224
+ "header",
225
+ "main",
226
+ "nav",
227
+ "section",
228
+ "body",
229
+ "blockquote",
230
+ "dd",
231
+ "div",
232
+ "dl",
233
+ "dt",
234
+ "figcaption",
235
+ "figure",
236
+ "hr",
237
+ "li",
238
+ "ol",
239
+ "p",
240
+ "pre",
241
+ "ul",
242
+ "a",
243
+ "abbr",
244
+ "b",
245
+ "bdi",
246
+ "bdo",
247
+ "br",
248
+ "cite",
249
+ "code",
250
+ "data",
251
+ "dfn",
252
+ "em",
253
+ "i",
254
+ "kbd",
255
+ "mark",
256
+ "q",
257
+ "rp",
258
+ "rt",
259
+ "ruby",
260
+ "s",
261
+ "samp",
262
+ "small",
263
+ "span",
264
+ "strong",
265
+ "sub",
266
+ "sup",
267
+ "time",
268
+ "u",
269
+ "var",
270
+ "wbr",
271
+ "area",
272
+ "audio",
273
+ "img",
274
+ "map",
275
+ "track",
276
+ "video",
277
+ "embed",
278
+ "iframe",
279
+ "object",
280
+ "param",
281
+ "picture",
282
+ "portal",
283
+ "source",
284
+ "svg",
285
+ "math",
286
+ "canvas",
287
+ "noscript",
288
+ "script",
289
+ "del",
290
+ "ins",
291
+ "caption",
292
+ "col",
293
+ "colgroup",
294
+ "table",
295
+ "tbody",
296
+ "td",
297
+ "tfoot",
298
+ "th",
299
+ "thead",
300
+ "tr",
301
+ "button",
302
+ "datalist",
303
+ "fieldset",
304
+ "form",
305
+ "input",
306
+ "label",
307
+ "legend",
308
+ "meter",
309
+ "optgroup",
310
+ "option",
311
+ "output",
312
+ "progress",
313
+ "select",
314
+ "textarea",
315
+ "details",
316
+ "dialog",
317
+ "menu",
318
+ "summary",
319
+ "details",
320
+ "slot",
321
+ "template",
322
+ "acronym",
323
+ "applet",
324
+ "basefont",
325
+ "bgsound",
326
+ "big",
327
+ "blink",
328
+ "center",
329
+ "content",
330
+ "dir",
331
+ "font",
332
+ "frame",
333
+ "frameset",
334
+ "hgroup",
335
+ "image",
336
+ "keygen",
337
+ "marquee",
338
+ "menuitem",
339
+ "nobr",
340
+ "noembed",
341
+ "noframes",
342
+ "plaintext",
343
+ "rb",
344
+ "rtc",
345
+ "shadow",
346
+ "spacer",
347
+ "strike",
348
+ "tt",
349
+ "xmp",
350
+ "a",
351
+ "abbr",
352
+ "acronym",
353
+ "address",
354
+ "applet",
355
+ "area",
356
+ "article",
357
+ "aside",
358
+ "audio",
359
+ "b",
360
+ "base",
361
+ "basefont",
362
+ "bdi",
363
+ "bdo",
364
+ "bgsound",
365
+ "big",
366
+ "blink",
367
+ "blockquote",
368
+ "body",
369
+ "br",
370
+ "button",
371
+ "canvas",
372
+ "caption",
373
+ "center",
374
+ "cite",
375
+ "code",
376
+ "col",
377
+ "colgroup",
378
+ "content",
379
+ "data",
380
+ "datalist",
381
+ "dd",
382
+ "del",
383
+ "details",
384
+ "dfn",
385
+ "dialog",
386
+ "dir",
387
+ "div",
388
+ "dl",
389
+ "dt",
390
+ "em",
391
+ "embed",
392
+ "fieldset",
393
+ "figcaption",
394
+ "figure",
395
+ "font",
396
+ "footer",
397
+ "form",
398
+ "frame",
399
+ "frameset",
400
+ "head",
401
+ "header",
402
+ "hgroup",
403
+ "hr",
404
+ "html",
405
+ "i",
406
+ "iframe",
407
+ "image",
408
+ "img",
409
+ "input",
410
+ "ins",
411
+ "kbd",
412
+ "keygen",
413
+ "label",
414
+ "legend",
415
+ "li",
416
+ "link",
417
+ "main",
418
+ "map",
419
+ "mark",
420
+ "marquee",
421
+ "menu",
422
+ "menuitem",
423
+ "meta",
424
+ "meter",
425
+ "nav",
426
+ "nobr",
427
+ "noembed",
428
+ "noframes",
429
+ "noscript",
430
+ "object",
431
+ "ol",
432
+ "optgroup",
433
+ "option",
434
+ "output",
435
+ "p",
436
+ "param",
437
+ "picture",
438
+ "plaintext",
439
+ "portal",
440
+ "pre",
441
+ "progress",
442
+ "q",
443
+ "rb",
444
+ "rp",
445
+ "rt",
446
+ "rtc",
447
+ "ruby",
448
+ "s",
449
+ "samp",
450
+ "script",
451
+ "section",
452
+ "select",
453
+ "shadow",
454
+ "slot",
455
+ "small",
456
+ "source",
457
+ "spacer",
458
+ "span",
459
+ "strike",
460
+ "strong",
461
+ "style",
462
+ "sub",
463
+ "summary",
464
+ "sup",
465
+ "table",
466
+ "tbody",
467
+ "td",
468
+ "template",
469
+ "textarea",
470
+ "tfoot",
471
+ "th",
472
+ "thead",
473
+ "time",
474
+ "title",
475
+ "tr",
476
+ "track",
477
+ "tt",
478
+ "u",
479
+ "ul",
480
+ "var",
481
+ "video",
482
+ "wbr",
483
+ "xmp",
484
+ "input",
485
+ "h1",
486
+ "h2",
487
+ "h3",
488
+ "h4",
489
+ "h5",
490
+ "h6"
491
+ ]);
50
492
 
51
- const ES2017FLAG = Feature.AggregateError
52
- | Feature.BigIntTypedArray;
53
- const GLOBAL_IDENTIFIER = '_$HY.r';
54
- function createSerializer({
55
- onData,
56
- onDone,
57
- scopeId,
58
- onError
59
- }) {
493
+ const ES2017FLAG = Feature.AggregateError | Feature.BigIntTypedArray;
494
+ const GLOBAL_IDENTIFIER = "_$HY.r";
495
+ function createSerializer({ onData, onDone, scopeId, onError }) {
60
496
  return new Serializer({
61
497
  scopeId,
62
498
  plugins: [
63
- CustomEventPlugin, DOMExceptionPlugin, EventPlugin,
64
- FormDataPlugin, HeadersPlugin, ReadableStreamPlugin, RequestPlugin, ResponsePlugin, URLSearchParamsPlugin, URLPlugin],
499
+ CustomEventPlugin,
500
+ DOMExceptionPlugin,
501
+ EventPlugin,
502
+ FormDataPlugin,
503
+ HeadersPlugin,
504
+ ReadableStreamPlugin,
505
+ RequestPlugin,
506
+ ResponsePlugin,
507
+ URLSearchParamsPlugin,
508
+ URLPlugin
509
+ ],
65
510
  globalIdentifier: GLOBAL_IDENTIFIER,
66
511
  disabledFeatures: ES2017FLAG,
67
512
  onData,
@@ -70,15 +515,14 @@ function createSerializer({
70
515
  });
71
516
  }
72
517
  function getLocalHeaderScript(id) {
73
- return getCrossReferenceHeader(id) + ';';
518
+ return getCrossReferenceHeader(id) + ";";
74
519
  }
75
520
 
76
- const VOID_ELEMENTS = /^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/i;
521
+ const VOID_ELEMENTS =
522
+ /^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/i;
77
523
  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
524
  function renderToString(code, options = {}) {
79
- const {
80
- renderId
81
- } = options;
525
+ const { renderId } = options;
82
526
  let scripts = "";
83
527
  const serializer = createSerializer({
84
528
  scopeId: renderId,
@@ -116,9 +560,7 @@ function renderToString(code, options = {}) {
116
560
  return html;
117
561
  }
118
562
  function renderToStringAsync(code, options = {}) {
119
- const {
120
- timeoutMs = 30000
121
- } = options;
563
+ const { timeoutMs = 30000 } = options;
122
564
  let timeoutHandle;
123
565
  const timeout = new Promise((_, reject) => {
124
566
  timeoutHandle = setTimeout(() => reject("renderToString timed out"), timeoutMs);
@@ -129,13 +571,7 @@ function renderToStringAsync(code, options = {}) {
129
571
  });
130
572
  }
131
573
  function renderToStream(code, options = {}) {
132
- let {
133
- nonce,
134
- onCompleteShell,
135
- onCompleteAll,
136
- renderId,
137
- noScripts
138
- } = options;
574
+ let { nonce, onCompleteShell, onCompleteAll, renderId, noScripts } = options;
139
575
  let dispose;
140
576
  const blockingPromises = [];
141
577
  const pushTask = task => {
@@ -151,11 +587,12 @@ function renderToStream(code, options = {}) {
151
587
  const onDone = () => {
152
588
  writeTasks();
153
589
  doShell();
154
- onCompleteAll && onCompleteAll({
155
- write(v) {
156
- !completed && buffer.write(v);
157
- }
158
- });
590
+ onCompleteAll &&
591
+ onCompleteAll({
592
+ write(v) {
593
+ !completed && buffer.write(v);
594
+ }
595
+ });
159
596
  writable && writable.end();
160
597
  completed = true;
161
598
  if (firstFlushed) dispose();
@@ -212,17 +649,23 @@ function renderToStream(code, options = {}) {
212
649
  const first = html.indexOf(placeholder);
213
650
  if (first === -1) return;
214
651
  const last = html.indexOf(`<!--!$/${id}-->`, first + placeholder.length);
215
- html = html.slice(0, first) + resolveSSRNode(escape(payloadFn())) + html.slice(last + placeholder.length + 1);
652
+ html =
653
+ html.slice(0, first) +
654
+ resolveSSRNode(escape(payloadFn())) +
655
+ html.slice(last + placeholder.length + 1);
216
656
  },
217
657
  serialize(id, p, wait) {
218
658
  const serverOnly = sharedConfig.context.noHydrate;
219
659
  if (!firstFlushed && wait && typeof p === "object" && "then" in p) {
220
660
  blockingPromises.push(p);
221
- !serverOnly && p.then(d => {
222
- serializer.write(id, d);
223
- }).catch(e => {
224
- serializer.write(id, e);
225
- });
661
+ !serverOnly &&
662
+ p
663
+ .then(d => {
664
+ serializer.write(id, d);
665
+ })
666
+ .catch(e => {
667
+ serializer.write(id, e);
668
+ });
226
669
  } else if (!serverOnly) serializer.write(id, p);
227
670
  },
228
671
  roots: 0,
@@ -232,11 +675,15 @@ function renderToStream(code, options = {}) {
232
675
  registerFragment(key) {
233
676
  if (!registry.has(key)) {
234
677
  let resolve, reject;
235
- 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
- })));
678
+ const p = new Promise((r, rej) => ((resolve = r), (reject = rej)));
679
+ registry.set(key, err =>
680
+ queue(() =>
681
+ queue(() => {
682
+ err ? reject(err) : resolve(true);
683
+ queue(flushEnd);
684
+ })
685
+ )
686
+ );
240
687
  serializer.write(key, p);
241
688
  }
242
689
  return (value, error) => {
@@ -249,7 +696,7 @@ function renderToStream(code, options = {}) {
249
696
  }
250
697
  if (!completed) {
251
698
  if (!firstFlushed) {
252
- queue(() => html = replacePlaceholder(html, key, value !== undefined ? value : ""));
699
+ queue(() => (html = replacePlaceholder(html, key, value !== undefined ? value : "")));
253
700
  resolve(error);
254
701
  } else {
255
702
  buffer.write(`<template id="${key}">${value !== undefined ? value : " "}</template>`);
@@ -275,11 +722,12 @@ function renderToStream(code, options = {}) {
275
722
  if (tasks.length) html = injectScripts(html, tasks, nonce);
276
723
  buffer.write(html);
277
724
  tasks = "";
278
- onCompleteShell && onCompleteShell({
279
- write(v) {
280
- !completed && buffer.write(v);
281
- }
282
- });
725
+ onCompleteShell &&
726
+ onCompleteShell({
727
+ write(v) {
728
+ !completed && buffer.write(v);
729
+ }
730
+ });
283
731
  shellCompleted = true;
284
732
  }
285
733
  return {
@@ -314,7 +762,7 @@ function renderToStream(code, options = {}) {
314
762
  pipeTo(w) {
315
763
  return allSettled(blockingPromises).then(() => {
316
764
  let resolve;
317
- const p = new Promise(r => resolve = r);
765
+ const p = new Promise(r => (resolve = r));
318
766
  setTimeout(() => {
319
767
  doShell();
320
768
  const encoder = new TextEncoder();
@@ -344,13 +792,13 @@ function renderToStream(code, options = {}) {
344
792
  };
345
793
  }
346
794
  function HydrationScript(props) {
347
- const {
348
- nonce
349
- } = sharedConfig.context;
350
- return ssr(generateHydrationScript({
351
- nonce,
352
- ...props
353
- }));
795
+ const { nonce } = sharedConfig.context;
796
+ return ssr(
797
+ generateHydrationScript({
798
+ nonce,
799
+ ...props
800
+ })
801
+ );
354
802
  }
355
803
  function ssr(t, ...nodes) {
356
804
  if (nodes.length) {
@@ -368,6 +816,8 @@ function ssr(t, ...nodes) {
368
816
  }
369
817
  function ssrClassName(value) {
370
818
  if (!value) return "";
819
+ if (typeof value === "string") return escape(value, true);
820
+ value = classListToObject(value);
371
821
  let classKeys = Object.keys(value),
372
822
  result = "";
373
823
  for (let i = 0, len = classKeys.length; i < len; i++) {
@@ -395,14 +845,19 @@ function ssrStyle(value) {
395
845
  return result;
396
846
  }
397
847
  function ssrElement(tag, props, children, needsId) {
398
- if (props == null) props = {};else if (typeof props === "function") props = props();
848
+ if (props == null) props = {};
849
+ else if (typeof props === "function") props = props();
399
850
  const skipChildren = VOID_ELEMENTS.test(tag);
400
851
  const keys = Object.keys(props);
401
852
  let result = `<${tag}${needsId ? ssrHydrationKey() : ""} `;
402
853
  for (let i = 0; i < keys.length; i++) {
403
854
  const prop = keys[i];
404
855
  if (ChildProperties.has(prop)) {
405
- if (children === undefined && !skipChildren) children = prop === "innerHTML" ? props[prop] : escape(props[prop]);
856
+ if (children === undefined && !skipChildren)
857
+ children =
858
+ tag === "script" || tag === "style" || prop === "innerHTML"
859
+ ? props[prop]
860
+ : escape(props[prop]);
406
861
  continue;
407
862
  }
408
863
  const value = props[prop];
@@ -411,8 +866,14 @@ function ssrElement(tag, props, children, needsId) {
411
866
  } else if (prop === "class") {
412
867
  result += `class="${ssrClassName(value)}"`;
413
868
  } else if (BooleanAttributes.has(prop)) {
414
- if (value) result += prop;else continue;
415
- } else if (value == undefined || prop === "ref" || prop.slice(0, 2) === "on" || prop.slice(0, 5) === "prop:") {
869
+ if (value) result += prop;
870
+ else continue;
871
+ } else if (
872
+ value == undefined ||
873
+ prop === "ref" ||
874
+ prop.slice(0, 2) === "on" ||
875
+ prop.slice(0, 5) === "prop:"
876
+ ) {
416
877
  continue;
417
878
  } else if (prop.slice(0, 5) === "bool:") {
418
879
  if (!value) continue;
@@ -420,20 +881,21 @@ function ssrElement(tag, props, children, needsId) {
420
881
  } else if (prop.slice(0, 5) === "attr:") {
421
882
  result += `${escape(prop.slice(5))}="${escape(value, true)}"`;
422
883
  } else {
423
- result += `${Aliases[prop] || escape(prop)}="${escape(value, true)}"`;
884
+ result += `${escape(prop)}="${escape(value, true)}"`;
424
885
  }
425
886
  if (i !== keys.length - 1) result += " ";
426
887
  }
427
- if (skipChildren) return {
428
- t: result + "/>"
429
- };
888
+ if (skipChildren)
889
+ return {
890
+ t: result + "/>"
891
+ };
430
892
  if (typeof children === "function") children = children();
431
893
  return {
432
894
  t: result + `>${resolveSSRNode(children, true)}</${tag}>`
433
895
  };
434
896
  }
435
897
  function ssrAttribute(key, value, isBoolean) {
436
- return isBoolean ? value ? " " + key : "" : value != null ? ` ${key}="${value}"` : "";
898
+ return isBoolean ? (value ? " " + key : "") : value != null ? ` ${key}="${value}"` : "";
437
899
  }
438
900
  function ssrHydrationKey() {
439
901
  const hk = getHydrationKey();
@@ -477,12 +939,13 @@ function escape(s, attr) {
477
939
  left = iDelim + 1;
478
940
  iDelim = s.indexOf(delim, left);
479
941
  } while (iDelim >= 0);
480
- } else while (iAmp >= 0) {
481
- if (left < iAmp) out += s.substring(left, iAmp);
482
- out += "&amp;";
483
- left = iAmp + 1;
484
- iAmp = s.indexOf("&", left);
485
- }
942
+ } else
943
+ while (iAmp >= 0) {
944
+ if (left < iAmp) out += s.substring(left, iAmp);
945
+ out += "&amp;";
946
+ left = iAmp + 1;
947
+ iAmp = s.indexOf("&", left);
948
+ }
486
949
  return left < s.length ? out + s.substring(left) : out;
487
950
  }
488
951
  function resolveSSRNode(node, top) {
@@ -494,7 +957,7 @@ function resolveSSRNode(node, top) {
494
957
  let mapped = "";
495
958
  for (let i = 0, len = node.length; i < len; i++) {
496
959
  if (!top && typeof prev !== "object" && typeof node[i] !== "object") mapped += `<!--!$-->`;
497
- mapped += resolveSSRNode(prev = node[i]);
960
+ mapped += resolveSSRNode((prev = node[i]));
498
961
  }
499
962
  return mapped;
500
963
  }
@@ -515,11 +978,12 @@ function getAssets() {
515
978
  for (let i = 0, len = assets.length; i < len; i++) out += assets[i]();
516
979
  return out;
517
980
  }
518
- function generateHydrationScript({
519
- eventNames = ["click", "input"],
520
- nonce
521
- } = {}) {
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-->`;
981
+ function generateHydrationScript({ eventNames = ["click", "input"], nonce } = {}) {
982
+ return `<script${
983
+ nonce ? ` nonce="${nonce}"` : ""
984
+ }>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(
985
+ '", "'
986
+ )}"].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
987
  }
524
988
  function Hydration(props) {
525
989
  if (!sharedConfig.context.noHydrate) return props.children;
@@ -578,31 +1042,111 @@ function replacePlaceholder(html, key, value) {
578
1042
  const last = html.indexOf(close, first + marker.length);
579
1043
  return html.slice(0, first) + value + html.slice(last + close.length);
580
1044
  }
1045
+ function classListToObject(classList) {
1046
+ if (Array.isArray(classList)) {
1047
+ const result = {};
1048
+ flattenClassList(classList, result);
1049
+ return result;
1050
+ }
1051
+ return classList;
1052
+ }
1053
+ function flattenClassList(list, result) {
1054
+ for (let i = 0, len = list.length; i < len; i++) {
1055
+ const item = list[i];
1056
+ if (Array.isArray(item)) flattenClassList(item, result);
1057
+ else if (typeof item === "object" && item != null) Object.assign(result, item);
1058
+ else if (item || item === 0) result[item] = true;
1059
+ }
1060
+ }
581
1061
  const RequestContext = Symbol();
582
1062
  function getRequestEvent() {
583
- 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;
1063
+ return globalThis[RequestContext]
1064
+ ? globalThis[RequestContext].getStore() ||
1065
+ (sharedConfig.context && sharedConfig.context.event) ||
1066
+ console.log(
1067
+ "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."
1068
+ )
1069
+ : undefined;
584
1070
  }
585
1071
  function Assets(props) {
586
1072
  useAssets(() => props.children);
587
1073
  }
588
1074
  function notSup() {
589
- 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>.");
1075
+ throw new Error(
1076
+ "Client-only API called on the server side. Run client-only code in onMount, or conditionally run client-only component with <Show>."
1077
+ );
590
1078
  }
591
1079
 
592
1080
  const isServer = true;
593
1081
  const isDev = false;
594
- function Dynamic(props) {
595
- const [p, others] = splitProps(props, ["component"]);
596
- const comp = p.component,
1082
+ function createDynamic(component, props) {
1083
+ const comp = component(),
597
1084
  t = typeof comp;
598
1085
  if (comp) {
599
- if (t === "function") return comp(others);else if (t === "string") {
600
- return ssrElement(comp, others, undefined, true);
1086
+ if (t === "function") return comp(props);
1087
+ else if (t === "string") {
1088
+ return ssrElement(comp, props, undefined, true);
601
1089
  }
602
1090
  }
603
1091
  }
1092
+ function Dynamic(props) {
1093
+ const [, others] = splitProps(props, ["component"]);
1094
+ return createDynamic(() => props.component, others);
1095
+ }
604
1096
  function Portal(props) {
605
1097
  return "";
606
1098
  }
607
1099
 
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 };
1100
+ export {
1101
+ Assets,
1102
+ ChildProperties,
1103
+ DOMElements,
1104
+ DelegatedEvents,
1105
+ Dynamic,
1106
+ Hydration,
1107
+ HydrationScript,
1108
+ NoHydration,
1109
+ Portal,
1110
+ Properties,
1111
+ RequestContext,
1112
+ SVGElements,
1113
+ SVGNamespace,
1114
+ notSup as addEventListener,
1115
+ notSup as assign,
1116
+ notSup as className,
1117
+ createDynamic,
1118
+ notSup as delegateEvents,
1119
+ notSup as dynamicProperty,
1120
+ escape,
1121
+ generateHydrationScript,
1122
+ getAssets,
1123
+ getHydrationKey,
1124
+ notSup as getNextElement,
1125
+ notSup as getNextMarker,
1126
+ notSup as getNextMatch,
1127
+ getPropAlias,
1128
+ getRequestEvent,
1129
+ notSup as hydrate,
1130
+ notSup as insert,
1131
+ isDev,
1132
+ isServer,
1133
+ notSup as render,
1134
+ renderToStream,
1135
+ renderToString,
1136
+ renderToStringAsync,
1137
+ resolveSSRNode,
1138
+ notSup as runHydrationEvents,
1139
+ notSup as setAttribute,
1140
+ notSup as setAttributeNS,
1141
+ notSup as setProperty,
1142
+ notSup as spread,
1143
+ ssr,
1144
+ ssrAttribute,
1145
+ ssrClassName,
1146
+ ssrElement,
1147
+ ssrHydrationKey,
1148
+ ssrStyle,
1149
+ notSup as style,
1150
+ notSup as template,
1151
+ useAssets
1152
+ };