@solidjs/web 2.0.0-experimental.4 → 2.0.0-experimental.5

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