@solidjs/web 2.0.0-beta.1 → 2.0.0-beta.11
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/README.md +27 -4
- package/dist/dev.cjs +251 -106
- package/dist/dev.js +239 -102
- package/dist/server.cjs +391 -109
- package/dist/server.js +384 -105
- package/dist/web.cjs +237 -97
- package/dist/web.js +225 -93
- package/package.json +100 -33
- package/storage/package.json +8 -3
- package/storage/types/src/index.d.ts +147 -21
- package/storage/types/src/jsx.d.ts +29 -0
- package/storage/types/src/server-mock.d.ts +89 -0
- package/storage/types-cjs/index.d.cts +2 -0
- package/storage/types-cjs/package.json +3 -0
- package/storage/types-cjs/src/client.d.cts +1 -0
- package/storage/types-cjs/src/index.d.cts +171 -0
- package/storage/types-cjs/src/jsx.d.cts +29 -0
- package/storage/types-cjs/src/server-mock.d.cts +161 -0
- package/storage/types-cjs/storage/src/index.d.cts +2 -0
- package/types/client.d.ts +31 -15
- package/types/core.d.ts +3 -3
- package/types/index.d.ts +147 -21
- package/types/jsx-properties.d.ts +92 -0
- package/types/jsx.d.ts +4321 -1
- package/types/server-mock.d.ts +89 -0
- package/types/server.d.ts +36 -18
- package/types-cjs/client.d.cts +104 -0
- package/types-cjs/core.d.cts +3 -0
- package/types-cjs/index.d.cts +171 -0
- package/types-cjs/jsx-properties.d.cts +92 -0
- package/types-cjs/jsx.d.cts +4321 -0
- package/types-cjs/package.json +3 -0
- package/types-cjs/server-mock.d.cts +161 -0
- package/types-cjs/server.d.cts +174 -0
package/dist/server.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import { createRenderEffect, createMemo, sharedConfig, createRoot, ssrHandleError,
|
|
2
|
-
export { Errored, For, Hydration, Loading, Match, NoHydration, Repeat, Show, Switch, createComponent, getOwner,
|
|
1
|
+
import { createRenderEffect, createMemo, sharedConfig, createRoot, ssrHandleError, getOwner, runWithOwner, createComponent, omit, getNextChildId, createOwner } from 'solid-js';
|
|
2
|
+
export { Errored, For, Hydration, Loading, Match, NoHydration, Repeat, Reveal, Show, Switch, createComponent, getOwner, untrack } from 'solid-js';
|
|
3
3
|
import { Serializer, Feature, getCrossReferenceHeader } from 'seroval';
|
|
4
4
|
import { AbortSignalPlugin, CustomEventPlugin, DOMExceptionPlugin, EventPlugin, FormDataPlugin, HeadersPlugin, ReadableStreamPlugin, RequestPlugin, ResponsePlugin, URLSearchParamsPlugin, URLPlugin } from 'seroval-plugins/web';
|
|
5
5
|
|
|
6
|
-
const Properties = /*#__PURE__*/new Set([
|
|
7
|
-
"value", "checked", "selected", "muted"]);
|
|
8
6
|
const ChildProperties = /*#__PURE__*/new Set(["innerHTML", "textContent", "innerText", "children"]);
|
|
9
7
|
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"]);
|
|
10
8
|
const SVGElements = /*#__PURE__*/new Set([
|
|
@@ -12,22 +10,36 @@ const SVGElements = /*#__PURE__*/new Set([
|
|
|
12
10
|
"set", "stop",
|
|
13
11
|
"svg", "switch", "symbol", "text", "textPath",
|
|
14
12
|
"tref", "tspan", "use", "view", "vkern"]);
|
|
15
|
-
const
|
|
13
|
+
const MathMLElements = /*#__PURE__*/new Set(["annotation", "annotation-xml", "maction", "math", "menclose", "merror", "mfenced", "mfrac", "mi", "mmultiscripts", "mn", "mo", "mover", "mpadded", "mphantom", "mprescripts", "mroot", "mrow", "ms", "mspace", "msqrt", "mstyle", "msub", "msubsup", "msup", "mtable", "mtd", "mtext", "mtr", "munder", "munderover", "semantics"]);
|
|
14
|
+
const Namespaces = {
|
|
15
|
+
svg: "http://www.w3.org/2000/svg",
|
|
16
|
+
mathml: "http://www.w3.org/1998/Math/MathML",
|
|
16
17
|
xlink: "http://www.w3.org/1999/xlink",
|
|
17
18
|
xml: "http://www.w3.org/XML/1998/namespace"
|
|
18
19
|
};
|
|
20
|
+
const VoidElements = /*#__PURE__*/new Set(["area", "base", "br", "col", "embed", "hr", "img", "input", "link", "meta", "param", "source", "track", "wbr"]);
|
|
21
|
+
const RawTextElements = /*#__PURE__*/new Set(["style", "script", "noscript", "template", "textarea", "title"]);
|
|
19
22
|
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",
|
|
20
23
|
"webview",
|
|
21
24
|
"isindex", "listing", "multicol", "nextid", "noindex", "search"]);
|
|
22
25
|
|
|
23
|
-
const
|
|
24
|
-
transparent: true
|
|
25
|
-
|
|
26
|
-
|
|
26
|
+
const transparentOptions = {
|
|
27
|
+
transparent: true,
|
|
28
|
+
sync: true
|
|
29
|
+
};
|
|
30
|
+
const syncOptions = {
|
|
31
|
+
sync: true
|
|
32
|
+
};
|
|
33
|
+
const effect = (fn, effectFn, options) => createRenderEffect(fn, effectFn, options ? {
|
|
34
|
+
transparent: true,
|
|
35
|
+
sync: true,
|
|
36
|
+
...options
|
|
37
|
+
} : transparentOptions);
|
|
38
|
+
const memo = fn => createMemo(() => fn(), syncOptions);
|
|
27
39
|
|
|
28
|
-
const ES2017FLAG = Feature.AggregateError
|
|
29
|
-
|
|
30
|
-
const GLOBAL_IDENTIFIER =
|
|
40
|
+
const ES2017FLAG = Feature.AggregateError |
|
|
41
|
+
Feature.BigIntTypedArray;
|
|
42
|
+
const GLOBAL_IDENTIFIER = "_$HY.r";
|
|
31
43
|
function createSerializer({
|
|
32
44
|
onData,
|
|
33
45
|
onDone,
|
|
@@ -50,7 +62,7 @@ function createSerializer({
|
|
|
50
62
|
});
|
|
51
63
|
}
|
|
52
64
|
function getLocalHeaderScript(id) {
|
|
53
|
-
return getCrossReferenceHeader(id) +
|
|
65
|
+
return getCrossReferenceHeader(id) + ";";
|
|
54
66
|
}
|
|
55
67
|
|
|
56
68
|
function resolveAssets(moduleUrl, manifest) {
|
|
@@ -106,11 +118,11 @@ function createAssetTracking() {
|
|
|
106
118
|
currentBoundaryId = v;
|
|
107
119
|
},
|
|
108
120
|
registerModule(moduleUrl, entryUrl) {
|
|
109
|
-
|
|
110
|
-
let map = boundaryModules.get(
|
|
121
|
+
const id = currentBoundaryId || "";
|
|
122
|
+
let map = boundaryModules.get(id);
|
|
111
123
|
if (!map) {
|
|
112
124
|
map = {};
|
|
113
|
-
boundaryModules.set(
|
|
125
|
+
boundaryModules.set(id, map);
|
|
114
126
|
}
|
|
115
127
|
map[moduleUrl] = entryUrl;
|
|
116
128
|
},
|
|
@@ -138,7 +150,7 @@ function applyAssetTracking(context, tracking, manifest) {
|
|
|
138
150
|
if (manifest) context.resolveAssets = moduleUrl => resolveAssets(moduleUrl, manifest);
|
|
139
151
|
}
|
|
140
152
|
const VOID_ELEMENTS = /^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/i;
|
|
141
|
-
const REPLACE_SCRIPT = `function $df(e,n,o,t){if(n=document.getElementById(e)
|
|
153
|
+
const REPLACE_SCRIPT = `function $df(e,n,o,t){if(!(n=document.getElementById(e))||!(o=document.getElementById("pl-"+e)))return 0;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);return 1}function $dfl(e,o,n){if(!(o=document.getElementById("pl-"+e)))return 0;if(o._$fl)return 1;for(n=o.nextSibling;n;){if(8===n.nodeType&&n.nodeValue==="pl-"+e){o.parentNode&&o.parentNode.insertBefore(o.content.cloneNode(!0),n),o._$fl=1;return 1}n=n.nextSibling}return 0}function $dflj(e,i){for(i=0;i<e.length;i++)$dfl(e[i])}function $dfs(e,c,d){(_$HY.sc=_$HY.sc||{})[e]=c,d&&((_$HY.sd=_$HY.sd||{})[e]=1)}function $dfg(e,g,i,k){if(!(g=_$HY.sg&&_$HY.sg[e]))return;for(i=0;i<g.length;i++)if(_$HY.sc&&_$HY.sc[g[i]]>0)return;for(i=0;i<g.length;i++)k=g[i],delete _$HY.sg[k],$df(k)}function $dfc(e){if(--_$HY.sc[e]<=0){delete _$HY.sc[e],_$HY.sg&&_$HY.sg[e]?$dfg(e):!(_$HY.sd&&_$HY.sd[e])&&$df(e);_$HY.sd&&delete _$HY.sd[e]}}function $dfj(e,i,n){for(i=0;i<e.length;i++)if(_$HY.sc&&_$HY.sc[e[i]]>0){for(n=0;n<e.length;n++)(_$HY.sg=_$HY.sg||{})[e[n]]=e;return}for(i=0;i<e.length;i++)$df(e[i])}`;
|
|
142
154
|
function renderToString(code, options = {}) {
|
|
143
155
|
const {
|
|
144
156
|
renderId = "",
|
|
@@ -193,6 +205,7 @@ function renderToString(code, options = {}) {
|
|
|
193
205
|
}, {
|
|
194
206
|
id: renderId
|
|
195
207
|
});
|
|
208
|
+
serializeFragmentAssets("", tracking.boundaryModules, sharedConfig.context);
|
|
196
209
|
sharedConfig.context.noHydrate = true;
|
|
197
210
|
serializer.close();
|
|
198
211
|
html = injectAssets(sharedConfig.context.assets, html);
|
|
@@ -211,10 +224,12 @@ function renderToStream(code, options = {}) {
|
|
|
211
224
|
} = options;
|
|
212
225
|
let dispose;
|
|
213
226
|
const blockingPromises = new Set();
|
|
227
|
+
let headerEmitted = false;
|
|
214
228
|
const pushTask = task => {
|
|
215
229
|
if (noScripts) return;
|
|
216
|
-
if (!
|
|
217
|
-
|
|
230
|
+
if (!headerEmitted) {
|
|
231
|
+
headerEmitted = true;
|
|
232
|
+
tasks += getLocalHeaderScript(renderId);
|
|
218
233
|
}
|
|
219
234
|
tasks += task + ";";
|
|
220
235
|
if (!timer && firstFlushed) {
|
|
@@ -240,8 +255,15 @@ function renderToStream(code, options = {}) {
|
|
|
240
255
|
onDone,
|
|
241
256
|
onError: options.onError
|
|
242
257
|
});
|
|
258
|
+
let rootAssetsSerialized = false;
|
|
259
|
+
const serializeRootAssets = () => {
|
|
260
|
+
if (rootAssetsSerialized) return;
|
|
261
|
+
rootAssetsSerialized = true;
|
|
262
|
+
serializeFragmentAssets("", tracking.boundaryModules, context);
|
|
263
|
+
};
|
|
243
264
|
const flushEnd = () => {
|
|
244
265
|
if (!registry.size) {
|
|
266
|
+
serializeRootAssets();
|
|
245
267
|
queue(() => queue(() => serializer.flush()));
|
|
246
268
|
}
|
|
247
269
|
};
|
|
@@ -263,7 +285,29 @@ function renderToStream(code, options = {}) {
|
|
|
263
285
|
let shellCompleted = false;
|
|
264
286
|
let scriptFlushed = false;
|
|
265
287
|
let headStyles;
|
|
288
|
+
const revealGroups = new Map();
|
|
266
289
|
let timer = null;
|
|
290
|
+
const emitTask = task => {
|
|
291
|
+
pushTask(`${task}${!scriptFlushed ? ";" + REPLACE_SCRIPT : ""}`);
|
|
292
|
+
scriptFlushed = true;
|
|
293
|
+
};
|
|
294
|
+
function resolveRevealKeys(groupOrKeys, release, consume) {
|
|
295
|
+
if (Array.isArray(groupOrKeys)) return groupOrKeys.slice();
|
|
296
|
+
let group = revealGroups.get(groupOrKeys);
|
|
297
|
+
if (!group) {
|
|
298
|
+
if (!release) return;
|
|
299
|
+
group = {
|
|
300
|
+
order: [],
|
|
301
|
+
keys: new Set(),
|
|
302
|
+
released: true
|
|
303
|
+
};
|
|
304
|
+
revealGroups.set(groupOrKeys, group);
|
|
305
|
+
} else if (release) group.released = true;
|
|
306
|
+
if (!group.order.length) return;
|
|
307
|
+
const keys = group.order.slice();
|
|
308
|
+
if (consume) revealGroups.delete(groupOrKeys);
|
|
309
|
+
return keys;
|
|
310
|
+
}
|
|
267
311
|
let rootHoles = null;
|
|
268
312
|
let nextHoleId = 0;
|
|
269
313
|
let buffer = {
|
|
@@ -313,7 +357,26 @@ function renderToStream(code, options = {}) {
|
|
|
313
357
|
escape: escape,
|
|
314
358
|
resolve: resolveSSRNode,
|
|
315
359
|
ssr: ssr,
|
|
316
|
-
registerFragment(key) {
|
|
360
|
+
registerFragment(key, options) {
|
|
361
|
+
const revealGroup = options && options.revealGroup;
|
|
362
|
+
if (revealGroup) {
|
|
363
|
+
let group = revealGroups.get(revealGroup);
|
|
364
|
+
if (!group) {
|
|
365
|
+
group = {
|
|
366
|
+
order: [],
|
|
367
|
+
keys: new Set(),
|
|
368
|
+
released: false
|
|
369
|
+
};
|
|
370
|
+
revealGroups.set(revealGroup, group);
|
|
371
|
+
}
|
|
372
|
+
if (!group.keys.has(key)) {
|
|
373
|
+
group.keys.add(key);
|
|
374
|
+
group.order.push(key);
|
|
375
|
+
}
|
|
376
|
+
if (group.released) {
|
|
377
|
+
throw new Error("registerFragment() for reveal group '" + revealGroup + "' was called after revealFragments(). Ensure template payload is emitted before grouped reveal.");
|
|
378
|
+
}
|
|
379
|
+
}
|
|
317
380
|
if (!registry.has(key)) {
|
|
318
381
|
let resolve, reject;
|
|
319
382
|
const p = new Promise((r, rej) => (resolve = r, reject = rej));
|
|
@@ -323,7 +386,7 @@ function renderToStream(code, options = {}) {
|
|
|
323
386
|
queue(flushEnd);
|
|
324
387
|
}))
|
|
325
388
|
});
|
|
326
|
-
serializer.write(key, p);
|
|
389
|
+
serializer.write(key + "_fr", p);
|
|
327
390
|
}
|
|
328
391
|
return (value, error) => {
|
|
329
392
|
if (registry.has(key)) {
|
|
@@ -352,9 +415,9 @@ function renderToStream(code, options = {}) {
|
|
|
352
415
|
} else {
|
|
353
416
|
serializeFragmentAssets(key, tracking.boundaryModules, context);
|
|
354
417
|
const styles = collectStreamStyles(key, tracking, headStyles);
|
|
418
|
+
const deferActivation = !!revealGroup;
|
|
355
419
|
if (styles.length) {
|
|
356
|
-
|
|
357
|
-
scriptFlushed = true;
|
|
420
|
+
emitTask(`$dfs("${key}",${styles.length},${deferActivation ? 1 : 0})`);
|
|
358
421
|
writeTasks();
|
|
359
422
|
for (const url of styles) {
|
|
360
423
|
buffer.write(`<link rel="stylesheet" href="${url}" onload="$dfc('${key}')" onerror="$dfc('${key}')">`);
|
|
@@ -362,8 +425,9 @@ function renderToStream(code, options = {}) {
|
|
|
362
425
|
buffer.write(`<template id="${key}">${value !== undefined ? value : " "}</template>`);
|
|
363
426
|
} else {
|
|
364
427
|
buffer.write(`<template id="${key}">${value !== undefined ? value : " "}</template>`);
|
|
365
|
-
|
|
366
|
-
|
|
428
|
+
if (!deferActivation) {
|
|
429
|
+
emitTask(`$df("${key}")`);
|
|
430
|
+
}
|
|
367
431
|
}
|
|
368
432
|
item.resolve(error);
|
|
369
433
|
}
|
|
@@ -371,6 +435,16 @@ function renderToStream(code, options = {}) {
|
|
|
371
435
|
}
|
|
372
436
|
return firstFlushed;
|
|
373
437
|
};
|
|
438
|
+
},
|
|
439
|
+
revealFragments(groupOrKeys) {
|
|
440
|
+
const keys = resolveRevealKeys(groupOrKeys, true, true);
|
|
441
|
+
if (!keys) return;
|
|
442
|
+
emitTask(`$dfj(${JSON.stringify(keys)})`);
|
|
443
|
+
},
|
|
444
|
+
revealFallbacks(groupOrKeys) {
|
|
445
|
+
const keys = resolveRevealKeys(groupOrKeys, false, false);
|
|
446
|
+
if (!keys) return;
|
|
447
|
+
emitTask(`$dflj(${JSON.stringify(keys)})`);
|
|
374
448
|
}
|
|
375
449
|
};
|
|
376
450
|
applyAssetTracking(context, tracking, manifest);
|
|
@@ -397,13 +471,32 @@ function renderToStream(code, options = {}) {
|
|
|
397
471
|
function doShell() {
|
|
398
472
|
if (shellCompleted) return;
|
|
399
473
|
if (rootHoles) {
|
|
474
|
+
const pending = [];
|
|
400
475
|
for (const {
|
|
401
476
|
id,
|
|
402
477
|
fn
|
|
403
478
|
} of rootHoles) {
|
|
404
479
|
const marker = `<!--rh${id}-->`;
|
|
405
480
|
const res = resolveSSRNode(fn);
|
|
406
|
-
|
|
481
|
+
if (!res.h.length) {
|
|
482
|
+
html = html.replace(marker, res.t[0]);
|
|
483
|
+
} else {
|
|
484
|
+
let out = res.t[0];
|
|
485
|
+
for (let j = 0; j < res.h.length; j++) {
|
|
486
|
+
const newId = nextHoleId++;
|
|
487
|
+
pending.push({
|
|
488
|
+
id: newId,
|
|
489
|
+
fn: res.h[j]
|
|
490
|
+
});
|
|
491
|
+
out += `<!--rh${newId}-->` + res.t[j + 1];
|
|
492
|
+
}
|
|
493
|
+
html = html.replace(marker, out);
|
|
494
|
+
for (const p of res.p) blockingPromises.add(p);
|
|
495
|
+
}
|
|
496
|
+
}
|
|
497
|
+
if (pending.length) {
|
|
498
|
+
rootHoles = pending;
|
|
499
|
+
return;
|
|
407
500
|
}
|
|
408
501
|
rootHoles = null;
|
|
409
502
|
}
|
|
@@ -414,6 +507,7 @@ function renderToStream(code, options = {}) {
|
|
|
414
507
|
if (url.endsWith(".css")) headStyles.add(url);
|
|
415
508
|
}
|
|
416
509
|
html = injectPreloadLinks(tracking.emittedAssets, html);
|
|
510
|
+
serializeRootAssets();
|
|
417
511
|
if (tasks.length) html = injectScripts(html, tasks, nonce);
|
|
418
512
|
buffer.write(html);
|
|
419
513
|
tasks = "";
|
|
@@ -440,48 +534,56 @@ function renderToStream(code, options = {}) {
|
|
|
440
534
|
queue(flushEnd);
|
|
441
535
|
},
|
|
442
536
|
pipe(w) {
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
537
|
+
function flush() {
|
|
538
|
+
allSettled(blockingPromises).then(() => {
|
|
539
|
+
setTimeout(() => {
|
|
540
|
+
doShell();
|
|
541
|
+
if (!shellCompleted) return flush();
|
|
542
|
+
buffer = writable = w;
|
|
543
|
+
buffer.write(tmp);
|
|
544
|
+
firstFlushed = true;
|
|
545
|
+
if (completed) {
|
|
546
|
+
dispose();
|
|
547
|
+
writable.end();
|
|
548
|
+
} else flushEnd();
|
|
549
|
+
});
|
|
453
550
|
});
|
|
454
|
-
}
|
|
551
|
+
}
|
|
552
|
+
flush();
|
|
455
553
|
},
|
|
456
554
|
pipeTo(w) {
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
555
|
+
let resolve;
|
|
556
|
+
const p = new Promise(r => resolve = r);
|
|
557
|
+
function flush() {
|
|
558
|
+
allSettled(blockingPromises).then(() => {
|
|
559
|
+
setTimeout(() => {
|
|
560
|
+
doShell();
|
|
561
|
+
if (!shellCompleted) return flush();
|
|
562
|
+
const encoder = new TextEncoder();
|
|
563
|
+
const writer = w.getWriter();
|
|
564
|
+
writable = {
|
|
565
|
+
end() {
|
|
566
|
+
writer.releaseLock();
|
|
567
|
+
w.close().catch(() => {});
|
|
568
|
+
resolve();
|
|
569
|
+
}
|
|
570
|
+
};
|
|
571
|
+
buffer = {
|
|
572
|
+
write(payload) {
|
|
573
|
+
writer.write(encoder.encode(payload)).catch(() => {});
|
|
574
|
+
}
|
|
575
|
+
};
|
|
576
|
+
buffer.write(tmp);
|
|
577
|
+
firstFlushed = true;
|
|
578
|
+
if (completed) {
|
|
579
|
+
dispose();
|
|
580
|
+
writable.end();
|
|
581
|
+
} else flushEnd();
|
|
582
|
+
});
|
|
482
583
|
});
|
|
483
|
-
|
|
484
|
-
|
|
584
|
+
}
|
|
585
|
+
flush();
|
|
586
|
+
return p;
|
|
485
587
|
}
|
|
486
588
|
};
|
|
487
589
|
}
|
|
@@ -494,11 +596,149 @@ function HydrationScript(props) {
|
|
|
494
596
|
...props
|
|
495
597
|
}));
|
|
496
598
|
}
|
|
497
|
-
function
|
|
498
|
-
|
|
599
|
+
function ssrGroup(fn, n) {
|
|
600
|
+
fn.$g = n;
|
|
601
|
+
return fn;
|
|
602
|
+
}
|
|
603
|
+
function buildAsyncWrap(err, node) {
|
|
604
|
+
const p = ssrHandleError(err);
|
|
605
|
+
if (!p) return null;
|
|
606
|
+
const owner = getOwner();
|
|
499
607
|
return {
|
|
608
|
+
fn: owner ? () => runWithOwner(owner, node) : node,
|
|
609
|
+
p
|
|
610
|
+
};
|
|
611
|
+
}
|
|
612
|
+
function ssrFirstGroupHit(hole) {
|
|
613
|
+
try {
|
|
614
|
+
return hole();
|
|
615
|
+
} catch (err) {
|
|
616
|
+
return buildAsyncWrap(err, hole);
|
|
617
|
+
}
|
|
618
|
+
}
|
|
619
|
+
function mergeTemplateInto(result, node) {
|
|
620
|
+
result.t[result.t.length - 1] += node.t[0];
|
|
621
|
+
if (node.t.length > 1) {
|
|
622
|
+
result.t.push(...node.t.slice(1));
|
|
623
|
+
result.h.push(...node.h);
|
|
624
|
+
result.p.push(...node.p);
|
|
625
|
+
}
|
|
626
|
+
}
|
|
627
|
+
let _lastGroupFn = null;
|
|
628
|
+
let _lastGroupArr = null;
|
|
629
|
+
let _lastGroupErr = null;
|
|
630
|
+
function ssrGroupSlot(fn, idx) {
|
|
631
|
+
return () => {
|
|
632
|
+
if (idx > 0 && _lastGroupFn === fn) {
|
|
633
|
+
if (_lastGroupArr !== null) return _lastGroupArr[idx];
|
|
634
|
+
throw _lastGroupErr;
|
|
635
|
+
}
|
|
636
|
+
_lastGroupFn = fn;
|
|
637
|
+
_lastGroupArr = null;
|
|
638
|
+
_lastGroupErr = null;
|
|
639
|
+
try {
|
|
640
|
+
_lastGroupArr = fn();
|
|
641
|
+
return _lastGroupArr[idx];
|
|
642
|
+
} catch (err) {
|
|
643
|
+
_lastGroupErr = err;
|
|
644
|
+
throw err;
|
|
645
|
+
}
|
|
646
|
+
};
|
|
647
|
+
}
|
|
648
|
+
function ssr(t) {
|
|
649
|
+
const len = arguments.length;
|
|
650
|
+
if (len === 1) return {
|
|
500
651
|
t
|
|
501
652
|
};
|
|
653
|
+
let s = t[0];
|
|
654
|
+
let result = null;
|
|
655
|
+
let lastGroup = null;
|
|
656
|
+
let lastGroupVal = null;
|
|
657
|
+
let lastGroupIdx = 0;
|
|
658
|
+
for (let i = 1; i < len; i++) {
|
|
659
|
+
const hole = arguments[i];
|
|
660
|
+
const ht = typeof hole;
|
|
661
|
+
if (ht === "string") {
|
|
662
|
+
if (result === null) s += hole;else result.t[result.t.length - 1] += hole;
|
|
663
|
+
} else if (ht === "number") {
|
|
664
|
+
if (result === null) s += hole;else result.t[result.t.length - 1] += hole;
|
|
665
|
+
} else if (hole == null || ht === "boolean") ; else if (ht === "function" && hole.$g) {
|
|
666
|
+
let value;
|
|
667
|
+
let hasValue = false;
|
|
668
|
+
if (lastGroup !== hole) {
|
|
669
|
+
const r = ssrFirstGroupHit(hole);
|
|
670
|
+
if (r !== null) {
|
|
671
|
+
lastGroup = hole;
|
|
672
|
+
lastGroupVal = r;
|
|
673
|
+
lastGroupIdx = 0;
|
|
674
|
+
if (!Array.isArray(r) && result === null) {
|
|
675
|
+
result = {
|
|
676
|
+
t: [s],
|
|
677
|
+
h: [],
|
|
678
|
+
p: []
|
|
679
|
+
};
|
|
680
|
+
s = "";
|
|
681
|
+
}
|
|
682
|
+
}
|
|
683
|
+
}
|
|
684
|
+
if (lastGroup === hole) {
|
|
685
|
+
if (Array.isArray(lastGroupVal)) {
|
|
686
|
+
value = lastGroupVal[lastGroupIdx++];
|
|
687
|
+
hasValue = true;
|
|
688
|
+
} else {
|
|
689
|
+
result.h.push(ssrGroupSlot(lastGroupVal.fn, lastGroupIdx++));
|
|
690
|
+
result.p.push(lastGroupVal.p);
|
|
691
|
+
result.t.push("");
|
|
692
|
+
}
|
|
693
|
+
}
|
|
694
|
+
if (hasValue) {
|
|
695
|
+
const vt = typeof value;
|
|
696
|
+
if (vt === "string" || vt === "number") {
|
|
697
|
+
if (result === null) s += value;else result.t[result.t.length - 1] += value;
|
|
698
|
+
} else if (value == null || vt === "boolean") ; else if (result !== null) {
|
|
699
|
+
resolveSSRNode(value, result);
|
|
700
|
+
} else {
|
|
701
|
+
const rs = tryResolveString(value);
|
|
702
|
+
if (typeof rs === "string") {
|
|
703
|
+
s += rs;
|
|
704
|
+
} else {
|
|
705
|
+
result = {
|
|
706
|
+
t: [s],
|
|
707
|
+
h: [],
|
|
708
|
+
p: []
|
|
709
|
+
};
|
|
710
|
+
s = "";
|
|
711
|
+
if (rs.merge !== undefined) mergeTemplateInto(result, rs.merge);else resolveSSRNode(rs.bail, result);
|
|
712
|
+
}
|
|
713
|
+
}
|
|
714
|
+
}
|
|
715
|
+
} else if (result !== null) {
|
|
716
|
+
resolveSSRNode(hole, result);
|
|
717
|
+
} else {
|
|
718
|
+
const r = tryResolveString(hole);
|
|
719
|
+
if (typeof r === "string") {
|
|
720
|
+
s += r;
|
|
721
|
+
} else {
|
|
722
|
+
result = {
|
|
723
|
+
t: [s],
|
|
724
|
+
h: [],
|
|
725
|
+
p: []
|
|
726
|
+
};
|
|
727
|
+
s = "";
|
|
728
|
+
if (r.fn !== undefined) {
|
|
729
|
+
result.h.push(r.fn);
|
|
730
|
+
result.p.push(r.p);
|
|
731
|
+
result.t.push("");
|
|
732
|
+
} else if (r.merge !== undefined) mergeTemplateInto(result, r.merge);else resolveSSRNode(r.bail, result);
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
const next = t[i];
|
|
736
|
+
if (result === null) s += next;else result.t[result.t.length - 1] += next;
|
|
737
|
+
}
|
|
738
|
+
if (result === null) return {
|
|
739
|
+
t: s
|
|
740
|
+
};
|
|
741
|
+
return result;
|
|
502
742
|
}
|
|
503
743
|
function ssrClassName(value) {
|
|
504
744
|
if (!value) return "";
|
|
@@ -511,7 +751,7 @@ function ssrClassName(value) {
|
|
|
511
751
|
classValue = !!value[key];
|
|
512
752
|
if (!key || key === "undefined" || !classValue) continue;
|
|
513
753
|
i && (result += " ");
|
|
514
|
-
result += escape(key);
|
|
754
|
+
result += escape(key, true);
|
|
515
755
|
}
|
|
516
756
|
return result;
|
|
517
757
|
}
|
|
@@ -521,8 +761,8 @@ function ssrStyle(value) {
|
|
|
521
761
|
let result = "";
|
|
522
762
|
const k = Object.keys(value);
|
|
523
763
|
for (let i = 0; i < k.length; i++) {
|
|
524
|
-
const s = k[i];
|
|
525
|
-
const v = value[
|
|
764
|
+
const s = escape(k[i], true);
|
|
765
|
+
const v = value[k[i]];
|
|
526
766
|
if (v != undefined) {
|
|
527
767
|
if (i) result += ";";
|
|
528
768
|
const r = escape(v, true);
|
|
@@ -586,11 +826,21 @@ function escape(s, attr) {
|
|
|
586
826
|
if (attr && t === "boolean") return s;
|
|
587
827
|
return s;
|
|
588
828
|
}
|
|
829
|
+
const delimCode = attr ? 34 : 60;
|
|
830
|
+
const len = s.length;
|
|
831
|
+
for (let i = 0; i < len; i++) {
|
|
832
|
+
const c = s.charCodeAt(i);
|
|
833
|
+
if (c === 38 || c === delimCode) return escapeSlow(s, attr, i);
|
|
834
|
+
}
|
|
835
|
+
return s;
|
|
836
|
+
}
|
|
837
|
+
function escapeSlow(s, attr, start) {
|
|
589
838
|
const delim = attr ? '"' : "<";
|
|
839
|
+
const delimCode = attr ? 34 : 60;
|
|
590
840
|
const escDelim = attr ? """ : "<";
|
|
591
|
-
|
|
592
|
-
let
|
|
593
|
-
|
|
841
|
+
const c0 = s.charCodeAt(start);
|
|
842
|
+
let iDelim = c0 === delimCode ? start : s.indexOf(delim, start);
|
|
843
|
+
let iAmp = c0 === 38 ? start : s.indexOf("&", start);
|
|
594
844
|
let left = 0,
|
|
595
845
|
out = "";
|
|
596
846
|
while (iDelim >= 0 && iAmp >= 0) {
|
|
@@ -664,7 +914,7 @@ function generateHydrationScript({
|
|
|
664
914
|
eventNames = ["click", "input"],
|
|
665
915
|
nonce
|
|
666
916
|
} = {}) {
|
|
667
|
-
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('",
|
|
917
|
+
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-->`;
|
|
668
918
|
}
|
|
669
919
|
function queue(fn) {
|
|
670
920
|
return Promise.resolve().then(fn);
|
|
@@ -762,19 +1012,43 @@ function flattenClassList(list, result) {
|
|
|
762
1012
|
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;
|
|
763
1013
|
}
|
|
764
1014
|
}
|
|
765
|
-
function
|
|
766
|
-
t
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
1015
|
+
function tryResolveString(node) {
|
|
1016
|
+
const t = typeof node;
|
|
1017
|
+
if (t === "string") return node;
|
|
1018
|
+
if (t === "number") return "" + node;
|
|
1019
|
+
if (node == null || t === "boolean") return "";
|
|
1020
|
+
if (t === "object") {
|
|
1021
|
+
if (Array.isArray(node)) {
|
|
1022
|
+
let s = "";
|
|
1023
|
+
let prevNonObj = false;
|
|
1024
|
+
for (let i = 0, len = node.length; i < len; i++) {
|
|
1025
|
+
const item = node[i];
|
|
1026
|
+
const itemNonObj = item !== null && typeof item !== "object";
|
|
1027
|
+
if (prevNonObj && itemNonObj) s += "<!--!$-->";
|
|
1028
|
+
prevNonObj = itemNonObj;
|
|
1029
|
+
const r = tryResolveString(item);
|
|
1030
|
+
if (typeof r !== "string") return {
|
|
1031
|
+
bail: node
|
|
1032
|
+
};
|
|
1033
|
+
s += r;
|
|
1034
|
+
}
|
|
1035
|
+
return s;
|
|
1036
|
+
}
|
|
1037
|
+
if (node.h && node.h.length > 0) return {
|
|
1038
|
+
merge: node
|
|
1039
|
+
};
|
|
1040
|
+
return Array.isArray(node.t) ? node.t[0] : node.t;
|
|
775
1041
|
}
|
|
776
|
-
|
|
777
|
-
|
|
1042
|
+
if (t === "function") {
|
|
1043
|
+
let v;
|
|
1044
|
+
try {
|
|
1045
|
+
v = node();
|
|
1046
|
+
} catch (err) {
|
|
1047
|
+
return buildAsyncWrap(err, node) || "";
|
|
1048
|
+
}
|
|
1049
|
+
return tryResolveString(v);
|
|
1050
|
+
}
|
|
1051
|
+
return "";
|
|
778
1052
|
}
|
|
779
1053
|
function resolveSSRNode(node, result = {
|
|
780
1054
|
t: [""],
|
|
@@ -785,10 +1059,13 @@ function resolveSSRNode(node, result = {
|
|
|
785
1059
|
if (t === "string" || t === "number") {
|
|
786
1060
|
result.t[result.t.length - 1] += node;
|
|
787
1061
|
} else if (node == null || t === "boolean") ; else if (Array.isArray(node)) {
|
|
788
|
-
let
|
|
1062
|
+
let prevNonObj = false;
|
|
789
1063
|
for (let i = 0, len = node.length; i < len; i++) {
|
|
790
|
-
|
|
791
|
-
|
|
1064
|
+
const item = node[i];
|
|
1065
|
+
const itemNonObj = item !== null && typeof item !== "object";
|
|
1066
|
+
if (!top && prevNonObj && itemNonObj) result.t[result.t.length - 1] += `<!--!$-->`;
|
|
1067
|
+
prevNonObj = itemNonObj;
|
|
1068
|
+
resolveSSRNode(item, result);
|
|
792
1069
|
}
|
|
793
1070
|
} else if (t === "object") {
|
|
794
1071
|
if (node.h) {
|
|
@@ -803,10 +1080,10 @@ function resolveSSRNode(node, result = {
|
|
|
803
1080
|
try {
|
|
804
1081
|
resolveSSRNode(node(), result);
|
|
805
1082
|
} catch (err) {
|
|
806
|
-
const
|
|
807
|
-
if (
|
|
808
|
-
result.h.push(
|
|
809
|
-
result.p.push(p);
|
|
1083
|
+
const wrap = buildAsyncWrap(err, node);
|
|
1084
|
+
if (wrap) {
|
|
1085
|
+
result.h.push(wrap.fn);
|
|
1086
|
+
result.p.push(wrap.p);
|
|
810
1087
|
result.t.push("");
|
|
811
1088
|
}
|
|
812
1089
|
}
|
|
@@ -831,26 +1108,28 @@ function notSup() {
|
|
|
831
1108
|
|
|
832
1109
|
const isServer = true;
|
|
833
1110
|
const isDev = false;
|
|
834
|
-
function
|
|
1111
|
+
function dynamic(source) {
|
|
835
1112
|
const o = getOwner();
|
|
836
1113
|
if (o?.id != null) getNextChildId(o);
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
if (
|
|
843
|
-
return
|
|
1114
|
+
return props => {
|
|
1115
|
+
const memoOwner = createOwner();
|
|
1116
|
+
return runWithOwner(memoOwner, () => {
|
|
1117
|
+
const comp = source(),
|
|
1118
|
+
t = typeof comp;
|
|
1119
|
+
if (comp) {
|
|
1120
|
+
if (t === "function") return comp(props);else if (t === "string") {
|
|
1121
|
+
return ssrElement(comp, props, undefined, true);
|
|
1122
|
+
}
|
|
844
1123
|
}
|
|
845
|
-
}
|
|
846
|
-
}
|
|
1124
|
+
});
|
|
1125
|
+
};
|
|
847
1126
|
}
|
|
848
1127
|
function Dynamic(props) {
|
|
849
|
-
const
|
|
850
|
-
return
|
|
1128
|
+
const Comp = dynamic(() => props.component);
|
|
1129
|
+
return createComponent(Comp, omit(props, "component"));
|
|
851
1130
|
}
|
|
852
1131
|
function Portal(props) {
|
|
853
1132
|
throw new Error("Portal is not supported on the server");
|
|
854
1133
|
}
|
|
855
1134
|
|
|
856
|
-
export { ChildProperties, DOMElements, DelegatedEvents, Dynamic, HydrationScript, Portal,
|
|
1135
|
+
export { ChildProperties, DOMElements, DelegatedEvents, Dynamic, HydrationScript, MathMLElements, Namespaces, Portal, RawTextElements, RequestContext, SVGElements, VoidElements, notSup as addEventListener, applyRef, notSup as assign, notSup as className, notSup as delegateEvents, dynamic, notSup as dynamicProperty, effect, escape, generateHydrationScript, getAssets, getHydrationKey, notSup as getNextElement, notSup as getNextMarker, notSup as getNextMatch, getRequestEvent, notSup as hydrate, notSup as insert, isDev, isServer, memo, mergeProps, notSup as render, renderToStream, renderToString, renderToStringAsync, notSup as runHydrationEvents, notSup as setAttribute, notSup as setAttributeNS, notSup as setProperty, notSup as spread, ssr, ssrAttribute, ssrClassName, ssrElement, ssrGroup, ssrHydrationKey, ssrStyle, ssrStyleProperty, notSup as style, notSup as template, useAssets };
|