solid-js 1.9.3 → 2.0.0-experimental.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (76) hide show
  1. package/dist/dev.cjs +213 -1603
  2. package/dist/dev.js +159 -1749
  3. package/dist/server.cjs +88 -11
  4. package/dist/server.js +91 -11
  5. package/dist/solid.cjs +196 -1558
  6. package/dist/solid.js +139 -1682
  7. package/package.json +8 -154
  8. package/types/{render → client}/component.d.ts +0 -61
  9. package/types/client/core.d.ts +75 -0
  10. package/types/client/flow.d.ts +114 -0
  11. package/types/{render → client}/hydration.d.ts +0 -2
  12. package/types/{reactive → client}/observable.d.ts +1 -1
  13. package/types/index.d.ts +44 -55
  14. package/types/jsx.d.ts +1944 -174
  15. package/types/server/index.d.ts +1 -1
  16. package/types/server/reactive.d.ts +6 -1
  17. package/types/server/store.d.ts +6 -0
  18. package/h/dist/h.cjs +0 -115
  19. package/h/dist/h.js +0 -144
  20. package/h/jsx-dev-runtime/package.json +0 -8
  21. package/h/jsx-runtime/dist/jsx.cjs +0 -15
  22. package/h/jsx-runtime/dist/jsx.js +0 -10
  23. package/h/jsx-runtime/package.json +0 -8
  24. package/h/jsx-runtime/types/index.d.ts +0 -14
  25. package/h/jsx-runtime/types/jsx.d.ts +0 -2276
  26. package/h/package.json +0 -8
  27. package/h/types/hyperscript.d.ts +0 -20
  28. package/h/types/index.d.ts +0 -3
  29. package/html/dist/html.cjs +0 -583
  30. package/html/dist/html.js +0 -706
  31. package/html/package.json +0 -8
  32. package/html/types/index.d.ts +0 -3
  33. package/html/types/lit.d.ts +0 -60
  34. package/store/dist/dev.cjs +0 -454
  35. package/store/dist/dev.js +0 -525
  36. package/store/dist/server.cjs +0 -126
  37. package/store/dist/server.js +0 -126
  38. package/store/dist/store.cjs +0 -434
  39. package/store/dist/store.js +0 -499
  40. package/store/package.json +0 -46
  41. package/store/types/index.d.ts +0 -26
  42. package/store/types/modifiers.d.ts +0 -9
  43. package/store/types/mutable.d.ts +0 -8
  44. package/store/types/server.d.ts +0 -37
  45. package/store/types/store.d.ts +0 -263
  46. package/types/reactive/array.d.ts +0 -52
  47. package/types/reactive/scheduler.d.ts +0 -13
  48. package/types/reactive/signal.d.ts +0 -664
  49. package/types/render/Suspense.d.ts +0 -26
  50. package/types/render/flow.d.ts +0 -130
  51. package/types/render/index.d.ts +0 -4
  52. package/universal/dist/dev.cjs +0 -243
  53. package/universal/dist/dev.js +0 -257
  54. package/universal/dist/universal.cjs +0 -243
  55. package/universal/dist/universal.js +0 -257
  56. package/universal/package.json +0 -20
  57. package/universal/types/index.d.ts +0 -4
  58. package/universal/types/universal.d.ts +0 -29
  59. package/web/dist/dev.cjs +0 -804
  60. package/web/dist/dev.js +0 -1241
  61. package/web/dist/server.cjs +0 -793
  62. package/web/dist/server.js +0 -1214
  63. package/web/dist/web.cjs +0 -793
  64. package/web/dist/web.js +0 -1220
  65. package/web/package.json +0 -46
  66. package/web/storage/dist/storage.cjs +0 -12
  67. package/web/storage/dist/storage.js +0 -10
  68. package/web/storage/package.json +0 -15
  69. package/web/storage/types/index.d.ts +0 -2
  70. package/web/storage/types/index.js +0 -13
  71. package/web/types/client.d.ts +0 -79
  72. package/web/types/core.d.ts +0 -10
  73. package/web/types/index.d.ts +0 -54
  74. package/web/types/jsx.d.ts +0 -1
  75. package/web/types/server-mock.d.ts +0 -80
  76. package/web/types/server.d.ts +0 -177
@@ -1,1214 +0,0 @@
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";
31
-
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
- "className",
62
- "value",
63
- "readOnly",
64
- "formNoValidate",
65
- "isMap",
66
- "noModule",
67
- "playsInline",
68
- ...booleans
69
- ]);
70
- const ChildProperties = /*#__PURE__*/ new Set([
71
- "innerHTML",
72
- "textContent",
73
- "innerText",
74
- "children"
75
- ]);
76
- const Aliases = /*#__PURE__*/ Object.assign(Object.create(null), {
77
- className: "class",
78
- htmlFor: "for"
79
- });
80
- const PropAliases = /*#__PURE__*/ Object.assign(Object.create(null), {
81
- class: "className",
82
- formnovalidate: {
83
- $: "formNoValidate",
84
- BUTTON: 1,
85
- INPUT: 1
86
- },
87
- ismap: {
88
- $: "isMap",
89
- IMG: 1
90
- },
91
- nomodule: {
92
- $: "noModule",
93
- SCRIPT: 1
94
- },
95
- playsinline: {
96
- $: "playsInline",
97
- VIDEO: 1
98
- },
99
- readonly: {
100
- $: "readOnly",
101
- INPUT: 1,
102
- TEXTAREA: 1
103
- }
104
- });
105
- function getPropAlias(prop, tagName) {
106
- const a = PropAliases[prop];
107
- return typeof a === "object" ? (a[tagName] ? a["$"] : undefined) : a;
108
- }
109
- const DelegatedEvents = /*#__PURE__*/ new Set([
110
- "beforeinput",
111
- "click",
112
- "dblclick",
113
- "contextmenu",
114
- "focusin",
115
- "focusout",
116
- "input",
117
- "keydown",
118
- "keyup",
119
- "mousedown",
120
- "mousemove",
121
- "mouseout",
122
- "mouseover",
123
- "mouseup",
124
- "pointerdown",
125
- "pointermove",
126
- "pointerout",
127
- "pointerover",
128
- "pointerup",
129
- "touchend",
130
- "touchmove",
131
- "touchstart"
132
- ]);
133
- const SVGElements = /*#__PURE__*/ new Set([
134
- "altGlyph",
135
- "altGlyphDef",
136
- "altGlyphItem",
137
- "animate",
138
- "animateColor",
139
- "animateMotion",
140
- "animateTransform",
141
- "circle",
142
- "clipPath",
143
- "color-profile",
144
- "cursor",
145
- "defs",
146
- "desc",
147
- "ellipse",
148
- "feBlend",
149
- "feColorMatrix",
150
- "feComponentTransfer",
151
- "feComposite",
152
- "feConvolveMatrix",
153
- "feDiffuseLighting",
154
- "feDisplacementMap",
155
- "feDistantLight",
156
- "feDropShadow",
157
- "feFlood",
158
- "feFuncA",
159
- "feFuncB",
160
- "feFuncG",
161
- "feFuncR",
162
- "feGaussianBlur",
163
- "feImage",
164
- "feMerge",
165
- "feMergeNode",
166
- "feMorphology",
167
- "feOffset",
168
- "fePointLight",
169
- "feSpecularLighting",
170
- "feSpotLight",
171
- "feTile",
172
- "feTurbulence",
173
- "filter",
174
- "font",
175
- "font-face",
176
- "font-face-format",
177
- "font-face-name",
178
- "font-face-src",
179
- "font-face-uri",
180
- "foreignObject",
181
- "g",
182
- "glyph",
183
- "glyphRef",
184
- "hkern",
185
- "image",
186
- "line",
187
- "linearGradient",
188
- "marker",
189
- "mask",
190
- "metadata",
191
- "missing-glyph",
192
- "mpath",
193
- "path",
194
- "pattern",
195
- "polygon",
196
- "polyline",
197
- "radialGradient",
198
- "rect",
199
- "set",
200
- "stop",
201
- "svg",
202
- "switch",
203
- "symbol",
204
- "text",
205
- "textPath",
206
- "tref",
207
- "tspan",
208
- "use",
209
- "view",
210
- "vkern"
211
- ]);
212
- const SVGNamespace = {
213
- xlink: "http://www.w3.org/1999/xlink",
214
- xml: "http://www.w3.org/XML/1998/namespace"
215
- };
216
- const DOMElements = /*#__PURE__*/ new Set([
217
- "html",
218
- "base",
219
- "head",
220
- "link",
221
- "meta",
222
- "style",
223
- "title",
224
- "body",
225
- "address",
226
- "article",
227
- "aside",
228
- "footer",
229
- "header",
230
- "main",
231
- "nav",
232
- "section",
233
- "body",
234
- "blockquote",
235
- "dd",
236
- "div",
237
- "dl",
238
- "dt",
239
- "figcaption",
240
- "figure",
241
- "hr",
242
- "li",
243
- "ol",
244
- "p",
245
- "pre",
246
- "ul",
247
- "a",
248
- "abbr",
249
- "b",
250
- "bdi",
251
- "bdo",
252
- "br",
253
- "cite",
254
- "code",
255
- "data",
256
- "dfn",
257
- "em",
258
- "i",
259
- "kbd",
260
- "mark",
261
- "q",
262
- "rp",
263
- "rt",
264
- "ruby",
265
- "s",
266
- "samp",
267
- "small",
268
- "span",
269
- "strong",
270
- "sub",
271
- "sup",
272
- "time",
273
- "u",
274
- "var",
275
- "wbr",
276
- "area",
277
- "audio",
278
- "img",
279
- "map",
280
- "track",
281
- "video",
282
- "embed",
283
- "iframe",
284
- "object",
285
- "param",
286
- "picture",
287
- "portal",
288
- "source",
289
- "svg",
290
- "math",
291
- "canvas",
292
- "noscript",
293
- "script",
294
- "del",
295
- "ins",
296
- "caption",
297
- "col",
298
- "colgroup",
299
- "table",
300
- "tbody",
301
- "td",
302
- "tfoot",
303
- "th",
304
- "thead",
305
- "tr",
306
- "button",
307
- "datalist",
308
- "fieldset",
309
- "form",
310
- "input",
311
- "label",
312
- "legend",
313
- "meter",
314
- "optgroup",
315
- "option",
316
- "output",
317
- "progress",
318
- "select",
319
- "textarea",
320
- "details",
321
- "dialog",
322
- "menu",
323
- "summary",
324
- "details",
325
- "slot",
326
- "template",
327
- "acronym",
328
- "applet",
329
- "basefont",
330
- "bgsound",
331
- "big",
332
- "blink",
333
- "center",
334
- "content",
335
- "dir",
336
- "font",
337
- "frame",
338
- "frameset",
339
- "hgroup",
340
- "image",
341
- "keygen",
342
- "marquee",
343
- "menuitem",
344
- "nobr",
345
- "noembed",
346
- "noframes",
347
- "plaintext",
348
- "rb",
349
- "rtc",
350
- "shadow",
351
- "spacer",
352
- "strike",
353
- "tt",
354
- "xmp",
355
- "a",
356
- "abbr",
357
- "acronym",
358
- "address",
359
- "applet",
360
- "area",
361
- "article",
362
- "aside",
363
- "audio",
364
- "b",
365
- "base",
366
- "basefont",
367
- "bdi",
368
- "bdo",
369
- "bgsound",
370
- "big",
371
- "blink",
372
- "blockquote",
373
- "body",
374
- "br",
375
- "button",
376
- "canvas",
377
- "caption",
378
- "center",
379
- "cite",
380
- "code",
381
- "col",
382
- "colgroup",
383
- "content",
384
- "data",
385
- "datalist",
386
- "dd",
387
- "del",
388
- "details",
389
- "dfn",
390
- "dialog",
391
- "dir",
392
- "div",
393
- "dl",
394
- "dt",
395
- "em",
396
- "embed",
397
- "fieldset",
398
- "figcaption",
399
- "figure",
400
- "font",
401
- "footer",
402
- "form",
403
- "frame",
404
- "frameset",
405
- "head",
406
- "header",
407
- "hgroup",
408
- "hr",
409
- "html",
410
- "i",
411
- "iframe",
412
- "image",
413
- "img",
414
- "input",
415
- "ins",
416
- "kbd",
417
- "keygen",
418
- "label",
419
- "legend",
420
- "li",
421
- "link",
422
- "main",
423
- "map",
424
- "mark",
425
- "marquee",
426
- "menu",
427
- "menuitem",
428
- "meta",
429
- "meter",
430
- "nav",
431
- "nobr",
432
- "noembed",
433
- "noframes",
434
- "noscript",
435
- "object",
436
- "ol",
437
- "optgroup",
438
- "option",
439
- "output",
440
- "p",
441
- "param",
442
- "picture",
443
- "plaintext",
444
- "portal",
445
- "pre",
446
- "progress",
447
- "q",
448
- "rb",
449
- "rp",
450
- "rt",
451
- "rtc",
452
- "ruby",
453
- "s",
454
- "samp",
455
- "script",
456
- "section",
457
- "select",
458
- "shadow",
459
- "slot",
460
- "small",
461
- "source",
462
- "spacer",
463
- "span",
464
- "strike",
465
- "strong",
466
- "style",
467
- "sub",
468
- "summary",
469
- "sup",
470
- "table",
471
- "tbody",
472
- "td",
473
- "template",
474
- "textarea",
475
- "tfoot",
476
- "th",
477
- "thead",
478
- "time",
479
- "title",
480
- "tr",
481
- "track",
482
- "tt",
483
- "u",
484
- "ul",
485
- "var",
486
- "video",
487
- "wbr",
488
- "xmp",
489
- "input",
490
- "h1",
491
- "h2",
492
- "h3",
493
- "h4",
494
- "h5",
495
- "h6"
496
- ]);
497
-
498
- const ES2017FLAG = Feature.AggregateError | Feature.BigIntTypedArray;
499
- const GLOBAL_IDENTIFIER = "_$HY.r";
500
- function createSerializer({ onData, onDone, scopeId, onError }) {
501
- return new Serializer({
502
- scopeId,
503
- plugins: [
504
- CustomEventPlugin,
505
- DOMExceptionPlugin,
506
- EventPlugin,
507
- FormDataPlugin,
508
- HeadersPlugin,
509
- ReadableStreamPlugin,
510
- RequestPlugin,
511
- ResponsePlugin,
512
- URLSearchParamsPlugin,
513
- URLPlugin
514
- ],
515
- globalIdentifier: GLOBAL_IDENTIFIER,
516
- disabledFeatures: ES2017FLAG,
517
- onData,
518
- onDone,
519
- onError
520
- });
521
- }
522
- function getLocalHeaderScript(id) {
523
- return getCrossReferenceHeader(id) + ";";
524
- }
525
-
526
- const VOID_ELEMENTS =
527
- /^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/i;
528
- 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)}`;
529
- function renderToString(code, options = {}) {
530
- const { renderId } = options;
531
- let scripts = "";
532
- const serializer = createSerializer({
533
- scopeId: renderId,
534
- onData(script) {
535
- if (!scripts) {
536
- scripts = getLocalHeaderScript(renderId);
537
- }
538
- scripts += script + ";";
539
- },
540
- onError: options.onError
541
- });
542
- sharedConfig.context = {
543
- id: renderId || "",
544
- count: 0,
545
- suspense: {},
546
- lazy: {},
547
- assets: [],
548
- nonce: options.nonce,
549
- serialize(id, p) {
550
- !sharedConfig.context.noHydrate && serializer.write(id, p);
551
- },
552
- roots: 0,
553
- nextRoot() {
554
- return this.renderId + "i-" + this.roots++;
555
- }
556
- };
557
- let html = createRoot(d => {
558
- setTimeout(d);
559
- return resolveSSRNode(escape(code()));
560
- });
561
- sharedConfig.context.noHydrate = true;
562
- serializer.close();
563
- html = injectAssets(sharedConfig.context.assets, html);
564
- if (scripts.length) html = injectScripts(html, scripts, options.nonce);
565
- return html;
566
- }
567
- function renderToStringAsync(code, options = {}) {
568
- const { timeoutMs = 30000 } = options;
569
- let timeoutHandle;
570
- const timeout = new Promise((_, reject) => {
571
- timeoutHandle = setTimeout(() => reject("renderToString timed out"), timeoutMs);
572
- });
573
- return Promise.race([renderToStream(code, options), timeout]).then(html => {
574
- clearTimeout(timeoutHandle);
575
- return html;
576
- });
577
- }
578
- function renderToStream(code, options = {}) {
579
- let { nonce, onCompleteShell, onCompleteAll, renderId, noScripts } = options;
580
- let dispose;
581
- const blockingPromises = [];
582
- const pushTask = task => {
583
- if (noScripts) return;
584
- if (!tasks && !firstFlushed) {
585
- tasks = getLocalHeaderScript(renderId);
586
- }
587
- tasks += task + ";";
588
- if (!timer && firstFlushed) {
589
- timer = setTimeout(writeTasks);
590
- }
591
- };
592
- const onDone = () => {
593
- writeTasks();
594
- doShell();
595
- onCompleteAll &&
596
- onCompleteAll({
597
- write(v) {
598
- !completed && buffer.write(v);
599
- }
600
- });
601
- writable && writable.end();
602
- completed = true;
603
- if (firstFlushed) dispose();
604
- };
605
- const serializer = createSerializer({
606
- scopeId: options.renderId,
607
- onData: pushTask,
608
- onDone,
609
- onError: options.onError
610
- });
611
- const flushEnd = () => {
612
- if (!registry.size) {
613
- queue(() => queue(() => serializer.flush()));
614
- }
615
- };
616
- const registry = new Map();
617
- const writeTasks = () => {
618
- if (tasks.length && !completed && firstFlushed) {
619
- buffer.write(`<script${nonce ? ` nonce="${nonce}"` : ""}>${tasks}</script>`);
620
- tasks = "";
621
- }
622
- timer && clearTimeout(timer);
623
- timer = null;
624
- };
625
- let context;
626
- let writable;
627
- let tmp = "";
628
- let tasks = "";
629
- let firstFlushed = false;
630
- let completed = false;
631
- let shellCompleted = false;
632
- let scriptFlushed = false;
633
- let timer = null;
634
- let buffer = {
635
- write(payload) {
636
- tmp += payload;
637
- }
638
- };
639
- sharedConfig.context = context = {
640
- id: renderId || "",
641
- count: 0,
642
- async: true,
643
- resources: {},
644
- lazy: {},
645
- suspense: {},
646
- assets: [],
647
- nonce,
648
- block(p) {
649
- if (!firstFlushed) blockingPromises.push(p);
650
- },
651
- replace(id, payloadFn) {
652
- if (firstFlushed) return;
653
- const placeholder = `<!--!$${id}-->`;
654
- const first = html.indexOf(placeholder);
655
- if (first === -1) return;
656
- const last = html.indexOf(`<!--!$/${id}-->`, first + placeholder.length);
657
- html = html.replace(
658
- html.slice(first, last + placeholder.length + 1),
659
- resolveSSRNode(payloadFn())
660
- );
661
- },
662
- serialize(id, p, wait) {
663
- const serverOnly = sharedConfig.context.noHydrate;
664
- if (!firstFlushed && wait && typeof p === "object" && "then" in p) {
665
- blockingPromises.push(p);
666
- !serverOnly &&
667
- p
668
- .then(d => {
669
- serializer.write(id, d);
670
- })
671
- .catch(e => {
672
- serializer.write(id, e);
673
- });
674
- } else if (!serverOnly) serializer.write(id, p);
675
- },
676
- roots: 0,
677
- nextRoot() {
678
- return this.renderId + "i-" + this.roots++;
679
- },
680
- registerFragment(key) {
681
- if (!registry.has(key)) {
682
- let resolve, reject;
683
- const p = new Promise((r, rej) => ((resolve = r), (reject = rej)));
684
- registry.set(key, err =>
685
- queue(() =>
686
- queue(() => {
687
- err ? reject(err) : resolve(true);
688
- queue(flushEnd);
689
- })
690
- )
691
- );
692
- serializer.write(key, p);
693
- }
694
- return (value, error) => {
695
- if (registry.has(key)) {
696
- const resolve = registry.get(key);
697
- registry.delete(key);
698
- if (waitForFragments(registry, key)) {
699
- resolve();
700
- return;
701
- }
702
- if (!completed) {
703
- if (!firstFlushed) {
704
- queue(() => (html = replacePlaceholder(html, key, value !== undefined ? value : "")));
705
- resolve(error);
706
- } else {
707
- buffer.write(`<template id="${key}">${value !== undefined ? value : " "}</template>`);
708
- pushTask(`$df("${key}")${!scriptFlushed ? ";" + REPLACE_SCRIPT : ""}`);
709
- resolve(error);
710
- scriptFlushed = true;
711
- }
712
- }
713
- }
714
- return firstFlushed;
715
- };
716
- }
717
- };
718
- let html = createRoot(d => {
719
- dispose = d;
720
- return resolveSSRNode(escape(code()));
721
- });
722
- function doShell() {
723
- if (shellCompleted) return;
724
- sharedConfig.context = context;
725
- context.noHydrate = true;
726
- html = injectAssets(context.assets, html);
727
- if (tasks.length) html = injectScripts(html, tasks, nonce);
728
- buffer.write(html);
729
- tasks = "";
730
- onCompleteShell &&
731
- onCompleteShell({
732
- write(v) {
733
- !completed && buffer.write(v);
734
- }
735
- });
736
- shellCompleted = true;
737
- }
738
- return {
739
- then(fn) {
740
- function complete() {
741
- dispose();
742
- fn(tmp);
743
- }
744
- if (onCompleteAll) {
745
- let ogComplete = onCompleteAll;
746
- onCompleteAll = options => {
747
- ogComplete(options);
748
- complete();
749
- };
750
- } else onCompleteAll = complete;
751
- queue(flushEnd);
752
- },
753
- pipe(w) {
754
- allSettled(blockingPromises).then(() => {
755
- setTimeout(() => {
756
- doShell();
757
- buffer = writable = w;
758
- buffer.write(tmp);
759
- firstFlushed = true;
760
- if (completed) {
761
- dispose();
762
- writable.end();
763
- } else flushEnd();
764
- });
765
- });
766
- },
767
- pipeTo(w) {
768
- return allSettled(blockingPromises).then(() => {
769
- let resolve;
770
- const p = new Promise(r => (resolve = r));
771
- setTimeout(() => {
772
- doShell();
773
- const encoder = new TextEncoder();
774
- const writer = w.getWriter();
775
- writable = {
776
- end() {
777
- writer.releaseLock();
778
- w.close();
779
- resolve();
780
- }
781
- };
782
- buffer = {
783
- write(payload) {
784
- writer.write(encoder.encode(payload));
785
- }
786
- };
787
- buffer.write(tmp);
788
- firstFlushed = true;
789
- if (completed) {
790
- dispose();
791
- writable.end();
792
- } else flushEnd();
793
- });
794
- return p;
795
- });
796
- }
797
- };
798
- }
799
- function HydrationScript(props) {
800
- const { nonce } = sharedConfig.context;
801
- return ssr(
802
- generateHydrationScript({
803
- nonce,
804
- ...props
805
- })
806
- );
807
- }
808
- function ssr(t, ...nodes) {
809
- if (nodes.length) {
810
- let result = "";
811
- for (let i = 0; i < nodes.length; i++) {
812
- result += t[i];
813
- const node = nodes[i];
814
- if (node !== undefined) result += resolveSSRNode(node);
815
- }
816
- t = result + t[nodes.length];
817
- }
818
- return {
819
- t
820
- };
821
- }
822
- function ssrClassList(value) {
823
- if (!value) return "";
824
- let classKeys = Object.keys(value),
825
- result = "";
826
- for (let i = 0, len = classKeys.length; i < len; i++) {
827
- const key = classKeys[i],
828
- classValue = !!value[key];
829
- if (!key || key === "undefined" || !classValue) continue;
830
- i && (result += " ");
831
- result += escape(key);
832
- }
833
- return result;
834
- }
835
- function ssrStyle(value) {
836
- if (!value) return "";
837
- if (typeof value === "string") return escape(value, true);
838
- let result = "";
839
- const k = Object.keys(value);
840
- for (let i = 0; i < k.length; i++) {
841
- const s = k[i];
842
- const v = value[s];
843
- if (v != undefined) {
844
- if (i) result += ";";
845
- result += `${s}:${escape(v, true)}`;
846
- }
847
- }
848
- return result;
849
- }
850
- function ssrElement(tag, props, children, needsId) {
851
- if (props == null) props = {};
852
- else if (typeof props === "function") props = props();
853
- const skipChildren = VOID_ELEMENTS.test(tag);
854
- const keys = Object.keys(props);
855
- let result = `<${tag}${needsId ? ssrHydrationKey() : ""} `;
856
- let classResolved;
857
- for (let i = 0; i < keys.length; i++) {
858
- const prop = keys[i];
859
- if (ChildProperties.has(prop)) {
860
- if (children === undefined && !skipChildren)
861
- children = prop === "innerHTML" ? props[prop] : escape(props[prop]);
862
- continue;
863
- }
864
- const value = props[prop];
865
- if (prop === "style") {
866
- result += `style="${ssrStyle(value)}"`;
867
- } else if (prop === "class" || prop === "className" || prop === "classList") {
868
- if (classResolved) continue;
869
- let n;
870
- result += `class="${
871
- escape(((n = props.class) ? n + " " : "") + ((n = props.className) ? n + " " : ""), true) +
872
- ssrClassList(props.classList)
873
- }"`;
874
- classResolved = true;
875
- } else if (BooleanAttributes.has(prop)) {
876
- if (value) result += prop;
877
- else continue;
878
- } else if (
879
- value == undefined ||
880
- prop === "ref" ||
881
- prop.slice(0, 2) === "on" ||
882
- prop.slice(0, 5) === "prop:"
883
- ) {
884
- continue;
885
- } else if (prop.slice(0, 5) === "bool:") {
886
- if (!value) continue;
887
- result += escape(prop.slice(5));
888
- } else if (prop.slice(0, 5) === "attr:") {
889
- result += `${escape(prop.slice(5))}="${escape(value, true)}"`;
890
- } else {
891
- result += `${Aliases[prop] || escape(prop)}="${escape(value, true)}"`;
892
- }
893
- if (i !== keys.length - 1) result += " ";
894
- }
895
- if (skipChildren)
896
- return {
897
- t: result + "/>"
898
- };
899
- if (typeof children === "function") children = children();
900
- return {
901
- t: result + `>${resolveSSRNode(children, true)}</${tag}>`
902
- };
903
- }
904
- function ssrAttribute(key, value, isBoolean) {
905
- return isBoolean ? (value ? " " + key : "") : value != null ? ` ${key}="${value}"` : "";
906
- }
907
- function ssrHydrationKey() {
908
- const hk = getHydrationKey();
909
- return hk ? ` data-hk=${hk}` : "";
910
- }
911
- function escape(s, attr) {
912
- const t = typeof s;
913
- if (t !== "string") {
914
- if (!attr && t === "function") return escape(s());
915
- if (!attr && Array.isArray(s)) {
916
- for (let i = 0; i < s.length; i++) s[i] = escape(s[i]);
917
- return s;
918
- }
919
- if (attr && t === "boolean") return String(s);
920
- return s;
921
- }
922
- const delim = attr ? '"' : "<";
923
- const escDelim = attr ? "&quot;" : "&lt;";
924
- let iDelim = s.indexOf(delim);
925
- let iAmp = s.indexOf("&");
926
- if (iDelim < 0 && iAmp < 0) return s;
927
- let left = 0,
928
- out = "";
929
- while (iDelim >= 0 && iAmp >= 0) {
930
- if (iDelim < iAmp) {
931
- if (left < iDelim) out += s.substring(left, iDelim);
932
- out += escDelim;
933
- left = iDelim + 1;
934
- iDelim = s.indexOf(delim, left);
935
- } else {
936
- if (left < iAmp) out += s.substring(left, iAmp);
937
- out += "&amp;";
938
- left = iAmp + 1;
939
- iAmp = s.indexOf("&", left);
940
- }
941
- }
942
- if (iDelim >= 0) {
943
- do {
944
- if (left < iDelim) out += s.substring(left, iDelim);
945
- out += escDelim;
946
- left = iDelim + 1;
947
- iDelim = s.indexOf(delim, left);
948
- } while (iDelim >= 0);
949
- } else
950
- while (iAmp >= 0) {
951
- if (left < iAmp) out += s.substring(left, iAmp);
952
- out += "&amp;";
953
- left = iAmp + 1;
954
- iAmp = s.indexOf("&", left);
955
- }
956
- return left < s.length ? out + s.substring(left) : out;
957
- }
958
- function resolveSSRNode(node, top) {
959
- const t = typeof node;
960
- if (t === "string") return node;
961
- if (node == null || t === "boolean") return "";
962
- if (Array.isArray(node)) {
963
- let prev = {};
964
- let mapped = "";
965
- for (let i = 0, len = node.length; i < len; i++) {
966
- if (!top && typeof prev !== "object" && typeof node[i] !== "object") mapped += `<!--!$-->`;
967
- mapped += resolveSSRNode((prev = node[i]));
968
- }
969
- return mapped;
970
- }
971
- if (t === "object") return node.t;
972
- if (t === "function") return resolveSSRNode(node());
973
- return String(node);
974
- }
975
- function getHydrationKey() {
976
- const hydrate = sharedConfig.context;
977
- return hydrate && !hydrate.noHydrate && sharedConfig.getNextContextId();
978
- }
979
- function useAssets(fn) {
980
- sharedConfig.context.assets.push(() => resolveSSRNode(fn()));
981
- }
982
- function getAssets() {
983
- const assets = sharedConfig.context.assets;
984
- let out = "";
985
- for (let i = 0, len = assets.length; i < len; i++) out += assets[i]();
986
- return out;
987
- }
988
- function generateHydrationScript({ eventNames = ["click", "input"], nonce } = {}) {
989
- return `<script${
990
- nonce ? ` nonce="${nonce}"` : ""
991
- }>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(
992
- '", "'
993
- )}"].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-->`;
994
- }
995
- function Hydration(props) {
996
- if (!sharedConfig.context.noHydrate) return props.children;
997
- const context = sharedConfig.context;
998
- sharedConfig.context = {
999
- ...context,
1000
- count: 0,
1001
- id: sharedConfig.getNextContextId(),
1002
- noHydrate: false
1003
- };
1004
- const res = props.children;
1005
- sharedConfig.context = context;
1006
- return res;
1007
- }
1008
- function NoHydration(props) {
1009
- if (sharedConfig.context) sharedConfig.context.noHydrate = true;
1010
- return props.children;
1011
- }
1012
- function queue(fn) {
1013
- return Promise.resolve().then(fn);
1014
- }
1015
- function allSettled(promises) {
1016
- let length = promises.length;
1017
- return Promise.allSettled(promises).then(() => {
1018
- if (promises.length !== length) return allSettled(promises);
1019
- return;
1020
- });
1021
- }
1022
- function injectAssets(assets, html) {
1023
- if (!assets || !assets.length) return html;
1024
- let out = "";
1025
- for (let i = 0, len = assets.length; i < len; i++) out += assets[i]();
1026
- return html.replace(`</head>`, out + `</head>`);
1027
- }
1028
- function injectScripts(html, scripts, nonce) {
1029
- const tag = `<script${nonce ? ` nonce="${nonce}"` : ""}>${scripts}</script>`;
1030
- const index = html.indexOf("<!--xs-->");
1031
- if (index > -1) {
1032
- return html.slice(0, index) + tag + html.slice(index);
1033
- }
1034
- return html + tag;
1035
- }
1036
- function waitForFragments(registry, key) {
1037
- for (const k of [...registry.keys()].reverse()) {
1038
- if (key.startsWith(k)) return true;
1039
- }
1040
- return false;
1041
- }
1042
- function replacePlaceholder(html, key, value) {
1043
- const marker = `<template id="pl-${key}">`;
1044
- const close = `<!--pl-${key}-->`;
1045
- const first = html.indexOf(marker);
1046
- if (first === -1) return html;
1047
- const last = html.indexOf(close, first + marker.length);
1048
- return html.slice(0, first) + value + html.slice(last + close.length);
1049
- }
1050
- const RequestContext = Symbol();
1051
- function getRequestEvent() {
1052
- return globalThis[RequestContext]
1053
- ? globalThis[RequestContext].getStore() ||
1054
- (sharedConfig.context && sharedConfig.context.event) ||
1055
- console.log(
1056
- "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."
1057
- )
1058
- : undefined;
1059
- }
1060
- function Assets(props) {
1061
- useAssets(() => props.children);
1062
- }
1063
- function pipeToNodeWritable(code, writable, options = {}) {
1064
- if (options.onReady) {
1065
- options.onCompleteShell = ({ write }) => {
1066
- options.onReady({
1067
- write,
1068
- startWriting() {
1069
- stream.pipe(writable);
1070
- }
1071
- });
1072
- };
1073
- }
1074
- const stream = renderToStream(code, options);
1075
- if (!options.onReady) stream.pipe(writable);
1076
- }
1077
- function pipeToWritable(code, writable, options = {}) {
1078
- if (options.onReady) {
1079
- options.onCompleteShell = ({ write }) => {
1080
- options.onReady({
1081
- write,
1082
- startWriting() {
1083
- stream.pipeTo(writable);
1084
- }
1085
- });
1086
- };
1087
- }
1088
- const stream = renderToStream(code, options);
1089
- if (!options.onReady) stream.pipeTo(writable);
1090
- }
1091
- function ssrSpread(props, isSVG, skipChildren) {
1092
- let result = "";
1093
- if (props == null) return result;
1094
- if (typeof props === "function") props = props();
1095
- const keys = Object.keys(props);
1096
- let classResolved;
1097
- for (let i = 0; i < keys.length; i++) {
1098
- let prop = keys[i];
1099
- if (prop === "children") {
1100
- !skipChildren && console.warn(`SSR currently does not support spread children.`);
1101
- continue;
1102
- }
1103
- const value = props[prop];
1104
- if (prop === "style") {
1105
- result += `style="${ssrStyle(value)}"`;
1106
- } else if (prop === "class" || prop === "className" || prop === "classList") {
1107
- if (classResolved) continue;
1108
- let n;
1109
- result += `class="${(n = props.class) ? n + " " : ""}${
1110
- (n = props.className) ? n + " " : ""
1111
- }${ssrClassList(props.classList)}"`;
1112
- classResolved = true;
1113
- } else if (prop !== "value" && Properties.has(prop)) {
1114
- if (value) result += prop;
1115
- else continue;
1116
- } else if (
1117
- value == undefined ||
1118
- prop === "ref" ||
1119
- prop.slice(0, 2) === "on" ||
1120
- prop.slice(0, 5) === "prop:"
1121
- ) {
1122
- continue;
1123
- } else if (prop.slice(0, 5) === "bool:") {
1124
- if (!value) continue;
1125
- result += escape(prop.slice(5));
1126
- } else if (prop.slice(0, 5) === "attr:") {
1127
- result += `${escape(prop.slice(5))}="${escape(value, true)}"`;
1128
- } else {
1129
- result += `${Aliases[prop] || escape(prop)}="${escape(value, true)}"`;
1130
- }
1131
- if (i !== keys.length - 1) result += " ";
1132
- }
1133
- return result;
1134
- }
1135
- function notSup() {
1136
- throw new Error(
1137
- "Client-only API called on the server side. Run client-only code in onMount, or conditionally run client-only component with <Show>."
1138
- );
1139
- }
1140
-
1141
- const isServer = true;
1142
- const isDev = false;
1143
- function Dynamic(props) {
1144
- const [p, others] = splitProps(props, ["component"]);
1145
- const comp = p.component,
1146
- t = typeof comp;
1147
- if (comp) {
1148
- if (t === "function") return comp(others);
1149
- else if (t === "string") {
1150
- return ssrElement(comp, others, undefined, true);
1151
- }
1152
- }
1153
- }
1154
- function Portal(props) {
1155
- return "";
1156
- }
1157
-
1158
- export {
1159
- Aliases,
1160
- Assets,
1161
- ChildProperties,
1162
- DOMElements,
1163
- DelegatedEvents,
1164
- Dynamic,
1165
- Hydration,
1166
- HydrationScript,
1167
- NoHydration,
1168
- Portal,
1169
- Properties,
1170
- RequestContext,
1171
- SVGElements,
1172
- SVGNamespace,
1173
- notSup as addEventListener,
1174
- notSup as assign,
1175
- notSup as classList,
1176
- notSup as className,
1177
- notSup as delegateEvents,
1178
- notSup as dynamicProperty,
1179
- escape,
1180
- generateHydrationScript,
1181
- getAssets,
1182
- getHydrationKey,
1183
- notSup as getNextElement,
1184
- notSup as getNextMarker,
1185
- notSup as getNextMatch,
1186
- getPropAlias,
1187
- getRequestEvent,
1188
- notSup as hydrate,
1189
- notSup as insert,
1190
- isDev,
1191
- isServer,
1192
- pipeToNodeWritable,
1193
- pipeToWritable,
1194
- notSup as render,
1195
- renderToStream,
1196
- renderToString,
1197
- renderToStringAsync,
1198
- resolveSSRNode,
1199
- notSup as runHydrationEvents,
1200
- notSup as setAttribute,
1201
- notSup as setAttributeNS,
1202
- notSup as setProperty,
1203
- notSup as spread,
1204
- ssr,
1205
- ssrAttribute,
1206
- ssrClassList,
1207
- ssrElement,
1208
- ssrHydrationKey,
1209
- ssrSpread,
1210
- ssrStyle,
1211
- notSup as style,
1212
- notSup as template,
1213
- useAssets
1214
- };