@solidjs/web 2.0.0-experimental.3 → 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,78 +1,13 @@
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";
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';
31
5
 
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), {
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), {
76
11
  class: "className",
77
12
  formnovalidate: {
78
13
  $: "formNoValidate",
@@ -99,414 +34,36 @@ const PropAliases = /*#__PURE__*/ Object.assign(Object.create(null), {
99
34
  });
100
35
  function getPropAlias(prop, tagName) {
101
36
  const a = PropAliases[prop];
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
- ]);
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"]);
207
45
  const SVGNamespace = {
208
46
  xlink: "http://www.w3.org/1999/xlink",
209
47
  xml: "http://www.w3.org/XML/1998/namespace"
210
48
  };
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
- ]);
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());
492
52
 
493
- const ES2017FLAG = Feature.AggregateError | Feature.BigIntTypedArray;
494
- const GLOBAL_IDENTIFIER = "_$HY.r";
495
- 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
+ }) {
496
62
  return new Serializer({
497
63
  scopeId,
498
64
  plugins: [
499
- CustomEventPlugin,
500
- DOMExceptionPlugin,
501
- EventPlugin,
502
- FormDataPlugin,
503
- HeadersPlugin,
504
- ReadableStreamPlugin,
505
- RequestPlugin,
506
- ResponsePlugin,
507
- URLSearchParamsPlugin,
508
- URLPlugin
509
- ],
65
+ CustomEventPlugin, DOMExceptionPlugin, EventPlugin,
66
+ FormDataPlugin, HeadersPlugin, ReadableStreamPlugin, RequestPlugin, ResponsePlugin, URLSearchParamsPlugin, URLPlugin],
510
67
  globalIdentifier: GLOBAL_IDENTIFIER,
511
68
  disabledFeatures: ES2017FLAG,
512
69
  onData,
@@ -515,18 +72,22 @@ function createSerializer({ onData, onDone, scopeId, onError }) {
515
72
  });
516
73
  }
517
74
  function getLocalHeaderScript(id) {
518
- return getCrossReferenceHeader(id) + ";";
75
+ return getCrossReferenceHeader(id) + ';';
519
76
  }
520
77
 
521
- const VOID_ELEMENTS =
522
- /^(?: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;
523
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)}`;
524
80
  function renderToString(code, options = {}) {
525
- const { renderId } = options;
81
+ const {
82
+ renderId = "",
83
+ nonce,
84
+ noScripts
85
+ } = options;
526
86
  let scripts = "";
527
87
  const serializer = createSerializer({
528
88
  scopeId: renderId,
529
89
  onData(script) {
90
+ if (noScripts) return;
530
91
  if (!scripts) {
531
92
  scripts = getLocalHeaderScript(renderId);
532
93
  }
@@ -535,23 +96,22 @@ function renderToString(code, options = {}) {
535
96
  onError: options.onError
536
97
  });
537
98
  sharedConfig.context = {
538
- id: renderId || "",
539
- count: 0,
540
- suspense: {},
541
- lazy: {},
99
+ id: renderId,
100
+ resources: {},
542
101
  assets: [],
543
- nonce: options.nonce,
102
+ nonce,
103
+ resolve(value) {
104
+ return resolveSSRNode(escape(value));
105
+ },
544
106
  serialize(id, p) {
545
107
  !sharedConfig.context.noHydrate && serializer.write(id, p);
546
- },
547
- roots: 0,
548
- nextRoot() {
549
- return this.renderId + "i-" + this.roots++;
550
108
  }
551
109
  };
552
110
  let html = createRoot(d => {
553
111
  setTimeout(d);
554
112
  return resolveSSRNode(escape(code()));
113
+ }, {
114
+ id: renderId
555
115
  });
556
116
  sharedConfig.context.noHydrate = true;
557
117
  serializer.close();
@@ -559,19 +119,14 @@ function renderToString(code, options = {}) {
559
119
  if (scripts.length) html = injectScripts(html, scripts, options.nonce);
560
120
  return html;
561
121
  }
562
- function renderToStringAsync(code, options = {}) {
563
- const { timeoutMs = 30000 } = options;
564
- let timeoutHandle;
565
- const timeout = new Promise((_, reject) => {
566
- timeoutHandle = setTimeout(() => reject("renderToString timed out"), timeoutMs);
567
- });
568
- return Promise.race([renderToStream(code, options), timeout]).then(html => {
569
- clearTimeout(timeoutHandle);
570
- return html;
571
- });
572
- }
573
122
  function renderToStream(code, options = {}) {
574
- let { nonce, onCompleteShell, onCompleteAll, renderId, noScripts } = options;
123
+ let {
124
+ nonce,
125
+ onCompleteShell,
126
+ onCompleteAll,
127
+ renderId = "",
128
+ noScripts
129
+ } = options;
575
130
  let dispose;
576
131
  const blockingPromises = [];
577
132
  const pushTask = task => {
@@ -587,12 +142,11 @@ function renderToStream(code, options = {}) {
587
142
  const onDone = () => {
588
143
  writeTasks();
589
144
  doShell();
590
- onCompleteAll &&
591
- onCompleteAll({
592
- write(v) {
593
- !completed && buffer.write(v);
594
- }
595
- });
145
+ onCompleteAll && onCompleteAll({
146
+ write(v) {
147
+ !completed && buffer.write(v);
148
+ }
149
+ });
596
150
  writable && writable.end();
597
151
  completed = true;
598
152
  if (firstFlushed) dispose();
@@ -632,12 +186,9 @@ function renderToStream(code, options = {}) {
632
186
  }
633
187
  };
634
188
  sharedConfig.context = context = {
635
- id: renderId || "",
636
- count: 0,
189
+ id: renderId,
637
190
  async: true,
638
191
  resources: {},
639
- lazy: {},
640
- suspense: {},
641
192
  assets: [],
642
193
  nonce,
643
194
  block(p) {
@@ -649,41 +200,30 @@ function renderToStream(code, options = {}) {
649
200
  const first = html.indexOf(placeholder);
650
201
  if (first === -1) return;
651
202
  const last = html.indexOf(`<!--!$/${id}-->`, first + placeholder.length);
652
- html =
653
- html.slice(0, first) +
654
- resolveSSRNode(escape(payloadFn())) +
655
- html.slice(last + placeholder.length + 1);
203
+ html = html.slice(0, first) + resolveSSRNode(escape(payloadFn())) + html.slice(last + placeholder.length + 1);
656
204
  },
657
205
  serialize(id, p, wait) {
658
206
  const serverOnly = sharedConfig.context.noHydrate;
659
207
  if (!firstFlushed && wait && typeof p === "object" && "then" in p) {
660
208
  blockingPromises.push(p);
661
- !serverOnly &&
662
- p
663
- .then(d => {
664
- serializer.write(id, d);
665
- })
666
- .catch(e => {
667
- serializer.write(id, e);
668
- });
209
+ !serverOnly && p.then(d => {
210
+ serializer.write(id, d);
211
+ }).catch(e => {
212
+ serializer.write(id, e);
213
+ });
669
214
  } else if (!serverOnly) serializer.write(id, p);
670
215
  },
671
- roots: 0,
672
- nextRoot() {
673
- return this.renderId + "i-" + this.roots++;
216
+ resolve(value) {
217
+ return resolveSSRNode(escape(value));
674
218
  },
675
219
  registerFragment(key) {
676
220
  if (!registry.has(key)) {
677
221
  let resolve, reject;
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
- );
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
+ })));
687
227
  serializer.write(key, p);
688
228
  }
689
229
  return (value, error) => {
@@ -696,7 +236,7 @@ function renderToStream(code, options = {}) {
696
236
  }
697
237
  if (!completed) {
698
238
  if (!firstFlushed) {
699
- queue(() => (html = replacePlaceholder(html, key, value !== undefined ? value : "")));
239
+ queue(() => html = replacePlaceholder(html, key, value !== undefined ? value : ""));
700
240
  resolve(error);
701
241
  } else {
702
242
  buffer.write(`<template id="${key}">${value !== undefined ? value : " "}</template>`);
@@ -713,6 +253,8 @@ function renderToStream(code, options = {}) {
713
253
  let html = createRoot(d => {
714
254
  dispose = d;
715
255
  return resolveSSRNode(escape(code()));
256
+ }, {
257
+ id: renderId
716
258
  });
717
259
  function doShell() {
718
260
  if (shellCompleted) return;
@@ -722,12 +264,11 @@ function renderToStream(code, options = {}) {
722
264
  if (tasks.length) html = injectScripts(html, tasks, nonce);
723
265
  buffer.write(html);
724
266
  tasks = "";
725
- onCompleteShell &&
726
- onCompleteShell({
727
- write(v) {
728
- !completed && buffer.write(v);
729
- }
730
- });
267
+ onCompleteShell && onCompleteShell({
268
+ write(v) {
269
+ !completed && buffer.write(v);
270
+ }
271
+ });
731
272
  shellCompleted = true;
732
273
  }
733
274
  return {
@@ -762,7 +303,7 @@ function renderToStream(code, options = {}) {
762
303
  pipeTo(w) {
763
304
  return allSettled(blockingPromises).then(() => {
764
305
  let resolve;
765
- const p = new Promise(r => (resolve = r));
306
+ const p = new Promise(r => resolve = r);
766
307
  setTimeout(() => {
767
308
  doShell();
768
309
  const encoder = new TextEncoder();
@@ -792,13 +333,13 @@ function renderToStream(code, options = {}) {
792
333
  };
793
334
  }
794
335
  function HydrationScript(props) {
795
- const { nonce } = sharedConfig.context;
796
- return ssr(
797
- generateHydrationScript({
798
- nonce,
799
- ...props
800
- })
801
- );
336
+ const {
337
+ nonce
338
+ } = sharedConfig.context;
339
+ return ssr(generateHydrationScript({
340
+ nonce,
341
+ ...props
342
+ }));
802
343
  }
803
344
  function ssr(t, ...nodes) {
804
345
  if (nodes.length) {
@@ -845,19 +386,14 @@ function ssrStyle(value) {
845
386
  return result;
846
387
  }
847
388
  function ssrElement(tag, props, children, needsId) {
848
- if (props == null) props = {};
849
- else if (typeof props === "function") props = props();
389
+ if (props == null) props = {};else if (typeof props === "function") props = props();
850
390
  const skipChildren = VOID_ELEMENTS.test(tag);
851
391
  const keys = Object.keys(props);
852
392
  let result = `<${tag}${needsId ? ssrHydrationKey() : ""} `;
853
393
  for (let i = 0; i < keys.length; i++) {
854
394
  const prop = keys[i];
855
395
  if (ChildProperties.has(prop)) {
856
- if (children === undefined && !skipChildren)
857
- children =
858
- tag === "script" || tag === "style" || prop === "innerHTML"
859
- ? props[prop]
860
- : escape(props[prop]);
396
+ if (children === undefined && !skipChildren) children = tag === "script" || tag === "style" || prop === "innerHTML" ? props[prop] : escape(props[prop]);
861
397
  continue;
862
398
  }
863
399
  const value = props[prop];
@@ -866,14 +402,8 @@ function ssrElement(tag, props, children, needsId) {
866
402
  } else if (prop === "class") {
867
403
  result += `class="${ssrClassName(value)}"`;
868
404
  } else if (BooleanAttributes.has(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
- ) {
405
+ if (value) result += prop;else continue;
406
+ } else if (value == undefined || prop === "ref" || prop.slice(0, 2) === "on" || prop.slice(0, 5) === "prop:") {
877
407
  continue;
878
408
  } else if (prop.slice(0, 5) === "bool:") {
879
409
  if (!value) continue;
@@ -885,21 +415,20 @@ function ssrElement(tag, props, children, needsId) {
885
415
  }
886
416
  if (i !== keys.length - 1) result += " ";
887
417
  }
888
- if (skipChildren)
889
- return {
890
- t: result + "/>"
891
- };
418
+ if (skipChildren) return {
419
+ t: result + "/>"
420
+ };
892
421
  if (typeof children === "function") children = children();
893
422
  return {
894
423
  t: result + `>${resolveSSRNode(children, true)}</${tag}>`
895
424
  };
896
425
  }
897
426
  function ssrAttribute(key, value, isBoolean) {
898
- return isBoolean ? (value ? " " + key : "") : value != null ? ` ${key}="${value}"` : "";
427
+ return isBoolean ? value ? " " + key : "" : value != null ? ` ${key}="${value}"` : "";
899
428
  }
900
429
  function ssrHydrationKey() {
901
430
  const hk = getHydrationKey();
902
- return hk ? ` data-hk=${hk}` : "";
431
+ return hk ? ` _hk=${hk}` : "";
903
432
  }
904
433
  function escape(s, attr) {
905
434
  const t = typeof s;
@@ -939,13 +468,12 @@ function escape(s, attr) {
939
468
  left = iDelim + 1;
940
469
  iDelim = s.indexOf(delim, left);
941
470
  } while (iDelim >= 0);
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
- }
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
+ }
949
477
  return left < s.length ? out + s.substring(left) : out;
950
478
  }
951
479
  function resolveSSRNode(node, top) {
@@ -957,14 +485,43 @@ function resolveSSRNode(node, top) {
957
485
  let mapped = "";
958
486
  for (let i = 0, len = node.length; i < len; i++) {
959
487
  if (!top && typeof prev !== "object" && typeof node[i] !== "object") mapped += `<!--!$-->`;
960
- mapped += resolveSSRNode((prev = node[i]));
488
+ mapped += resolveSSRNode(prev = node[i]);
961
489
  }
962
490
  return mapped;
963
491
  }
964
492
  if (t === "object") return node.t;
965
- 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
+ }
966
500
  return String(node);
967
501
  }
502
+ function mergeProps(...sources) {
503
+ const target = {};
504
+ for (let i = 0; i < sources.length; i++) {
505
+ let source = sources[i];
506
+ if (typeof source === "function") source = source();
507
+ if (source) {
508
+ const descriptors = Object.getOwnPropertyDescriptors(source);
509
+ for (const key in descriptors) {
510
+ if (key in target) continue;
511
+ Object.defineProperty(target, key, {
512
+ enumerable: true,
513
+ get() {
514
+ for (let i = sources.length - 1; i >= 0; i--) {
515
+ const v = (sources[i] || {})[key];
516
+ if (v !== undefined) return v;
517
+ }
518
+ }
519
+ });
520
+ }
521
+ }
522
+ }
523
+ return target;
524
+ }
968
525
  function getHydrationKey() {
969
526
  const hydrate = sharedConfig.context;
970
527
  return hydrate && !hydrate.noHydrate && sharedConfig.getNextContextId();
@@ -978,12 +535,11 @@ function getAssets() {
978
535
  for (let i = 0, len = assets.length; i < len; i++) out += assets[i]();
979
536
  return out;
980
537
  }
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-->`;
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-->`;
987
543
  }
988
544
  function Hydration(props) {
989
545
  if (!sharedConfig.context.noHydrate) return props.children;
@@ -999,8 +555,14 @@ function Hydration(props) {
999
555
  return res;
1000
556
  }
1001
557
  function NoHydration(props) {
1002
- if (sharedConfig.context) sharedConfig.context.noHydrate = true;
1003
- 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;
1004
566
  }
1005
567
  function queue(fn) {
1006
568
  return Promise.resolve().then(fn);
@@ -1053,28 +615,18 @@ function classListToObject(classList) {
1053
615
  function flattenClassList(list, result) {
1054
616
  for (let i = 0, len = list.length; i < len; i++) {
1055
617
  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;
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;
1059
619
  }
1060
620
  }
1061
621
  const RequestContext = Symbol();
1062
622
  function getRequestEvent() {
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;
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;
1070
624
  }
1071
- function Assets(props) {
1072
- useAssets(() => props.children);
625
+ function renderToStringAsync(code, options = {}) {
626
+ return renderToStream(code, options).then(html => html);
1073
627
  }
1074
628
  function notSup() {
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
- );
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>.");
1078
630
  }
1079
631
 
1080
632
  const isServer = true;
@@ -1083,70 +635,17 @@ function createDynamic(component, props) {
1083
635
  const comp = component(),
1084
636
  t = typeof comp;
1085
637
  if (comp) {
1086
- if (t === "function") return comp(props);
1087
- else if (t === "string") {
638
+ if (t === "function") return comp(props);else if (t === "string") {
1088
639
  return ssrElement(comp, props, undefined, true);
1089
640
  }
1090
641
  }
1091
642
  }
1092
643
  function Dynamic(props) {
1093
- const [, others] = splitProps(props, ["component"]);
644
+ const others = omit(props, "component");
1094
645
  return createDynamic(() => props.component, others);
1095
646
  }
1096
647
  function Portal(props) {
1097
- return "";
648
+ throw new Error("Portal is not supported on the server");
1098
649
  }
1099
650
 
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
- };
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 };