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