@solidjs/web 2.0.0-experimental.1 → 2.0.0-experimental.10
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 +56 -75
- package/dist/dev.js +56 -72
- package/dist/server.cjs +189 -152
- package/dist/server.js +183 -139
- package/dist/web.cjs +56 -75
- package/dist/web.js +56 -72
- package/package.json +3 -3
- package/types/client.d.ts +0 -2
- package/types/core.d.ts +2 -1
- package/types/index.d.ts +13 -0
- package/types/server.d.ts +0 -1
package/dist/server.cjs
CHANGED
|
@@ -4,39 +4,9 @@ var solidJs = require('solid-js');
|
|
|
4
4
|
var seroval = require('seroval');
|
|
5
5
|
var web = require('seroval-plugins/web');
|
|
6
6
|
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
const Properties = /*#__PURE__*/new Set(["value", "readOnly", "formNoValidate", "isMap", "noModule", "playsInline", ...booleans]);
|
|
7
|
+
const Properties = /*#__PURE__*/new Set([
|
|
8
|
+
"value", "checked", "selected", "muted"]);
|
|
10
9
|
const ChildProperties = /*#__PURE__*/new Set(["innerHTML", "textContent", "innerText", "children"]);
|
|
11
|
-
const PropAliases = /*#__PURE__*/Object.assign(Object.create(null), {
|
|
12
|
-
class: "className",
|
|
13
|
-
formnovalidate: {
|
|
14
|
-
$: "formNoValidate",
|
|
15
|
-
BUTTON: 1,
|
|
16
|
-
INPUT: 1
|
|
17
|
-
},
|
|
18
|
-
ismap: {
|
|
19
|
-
$: "isMap",
|
|
20
|
-
IMG: 1
|
|
21
|
-
},
|
|
22
|
-
nomodule: {
|
|
23
|
-
$: "noModule",
|
|
24
|
-
SCRIPT: 1
|
|
25
|
-
},
|
|
26
|
-
playsinline: {
|
|
27
|
-
$: "playsInline",
|
|
28
|
-
VIDEO: 1
|
|
29
|
-
},
|
|
30
|
-
readonly: {
|
|
31
|
-
$: "readOnly",
|
|
32
|
-
INPUT: 1,
|
|
33
|
-
TEXTAREA: 1
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
function getPropAlias(prop, tagName) {
|
|
37
|
-
const a = PropAliases[prop];
|
|
38
|
-
return typeof a === "object" ? a[tagName] ? a["$"] : undefined : a;
|
|
39
|
-
}
|
|
40
10
|
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"]);
|
|
41
11
|
const SVGElements = /*#__PURE__*/new Set([
|
|
42
12
|
"altGlyph", "altGlyphDef", "altGlyphItem", "animate", "animateColor", "animateMotion", "animateTransform", "circle", "clipPath", "color-profile", "cursor", "defs", "desc", "ellipse", "feBlend", "feColorMatrix", "feComponentTransfer", "feComposite", "feConvolveMatrix", "feDiffuseLighting", "feDisplacementMap", "feDistantLight", "feDropShadow", "feFlood", "feFuncA", "feFuncB", "feFuncG", "feFuncR", "feGaussianBlur", "feImage", "feMerge", "feMergeNode", "feMorphology", "feOffset", "fePointLight", "feSpecularLighting", "feSpotLight", "feTile", "feTurbulence", "filter", "font", "font-face", "font-face-format", "font-face-name", "font-face-src", "font-face-uri", "foreignObject", "g", "glyph", "glyphRef", "hkern", "image", "line", "linearGradient", "marker", "mask", "metadata", "missing-glyph", "mpath", "path", "pattern", "polygon", "polyline", "radialGradient", "rect",
|
|
@@ -47,7 +17,11 @@ const SVGNamespace = {
|
|
|
47
17
|
xlink: "http://www.w3.org/1999/xlink",
|
|
48
18
|
xml: "http://www.w3.org/XML/1998/namespace"
|
|
49
19
|
};
|
|
50
|
-
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
|
+
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",
|
|
21
|
+
"webview",
|
|
22
|
+
"isindex", "listing", "multicol", "nextid", "noindex", "search"]);
|
|
23
|
+
|
|
24
|
+
const memo = fn => solidJs.createMemo(() => fn());
|
|
51
25
|
|
|
52
26
|
const ES2017FLAG = seroval.Feature.AggregateError
|
|
53
27
|
| seroval.Feature.BigIntTypedArray;
|
|
@@ -60,7 +34,7 @@ function createSerializer({
|
|
|
60
34
|
}) {
|
|
61
35
|
return new seroval.Serializer({
|
|
62
36
|
scopeId,
|
|
63
|
-
plugins: [
|
|
37
|
+
plugins: [web.AbortSignalPlugin,
|
|
64
38
|
web.CustomEventPlugin, web.DOMExceptionPlugin, web.EventPlugin,
|
|
65
39
|
web.FormDataPlugin, web.HeadersPlugin, web.ReadableStreamPlugin, web.RequestPlugin, web.ResponsePlugin, web.URLSearchParamsPlugin, web.URLPlugin],
|
|
66
40
|
globalIdentifier: GLOBAL_IDENTIFIER,
|
|
@@ -78,12 +52,15 @@ const VOID_ELEMENTS = /^(?:area|base|br|col|embed|hr|img|input|keygen|link|menui
|
|
|
78
52
|
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)}`;
|
|
79
53
|
function renderToString(code, options = {}) {
|
|
80
54
|
const {
|
|
81
|
-
renderId
|
|
55
|
+
renderId = "",
|
|
56
|
+
nonce,
|
|
57
|
+
noScripts
|
|
82
58
|
} = options;
|
|
83
59
|
let scripts = "";
|
|
84
60
|
const serializer = createSerializer({
|
|
85
61
|
scopeId: renderId,
|
|
86
62
|
onData(script) {
|
|
63
|
+
if (noScripts) return;
|
|
87
64
|
if (!scripts) {
|
|
88
65
|
scripts = getLocalHeaderScript(renderId);
|
|
89
66
|
}
|
|
@@ -92,23 +69,20 @@ function renderToString(code, options = {}) {
|
|
|
92
69
|
onError: options.onError
|
|
93
70
|
});
|
|
94
71
|
solidJs.sharedConfig.context = {
|
|
95
|
-
id: renderId || "",
|
|
96
|
-
count: 0,
|
|
97
|
-
suspense: {},
|
|
98
|
-
lazy: {},
|
|
99
72
|
assets: [],
|
|
100
|
-
nonce
|
|
73
|
+
nonce,
|
|
74
|
+
escape: escape,
|
|
75
|
+
resolve: resolveSSRNode,
|
|
76
|
+
ssr: ssr,
|
|
101
77
|
serialize(id, p) {
|
|
102
78
|
!solidJs.sharedConfig.context.noHydrate && serializer.write(id, p);
|
|
103
|
-
},
|
|
104
|
-
roots: 0,
|
|
105
|
-
nextRoot() {
|
|
106
|
-
return this.renderId + "i-" + this.roots++;
|
|
107
79
|
}
|
|
108
80
|
};
|
|
109
81
|
let html = solidJs.createRoot(d => {
|
|
110
82
|
setTimeout(d);
|
|
111
|
-
return
|
|
83
|
+
return resolveSSRSync(escape(code()));
|
|
84
|
+
}, {
|
|
85
|
+
id: renderId
|
|
112
86
|
});
|
|
113
87
|
solidJs.sharedConfig.context.noHydrate = true;
|
|
114
88
|
serializer.close();
|
|
@@ -116,25 +90,12 @@ function renderToString(code, options = {}) {
|
|
|
116
90
|
if (scripts.length) html = injectScripts(html, scripts, options.nonce);
|
|
117
91
|
return html;
|
|
118
92
|
}
|
|
119
|
-
function renderToStringAsync(code, options = {}) {
|
|
120
|
-
const {
|
|
121
|
-
timeoutMs = 30000
|
|
122
|
-
} = options;
|
|
123
|
-
let timeoutHandle;
|
|
124
|
-
const timeout = new Promise((_, reject) => {
|
|
125
|
-
timeoutHandle = setTimeout(() => reject("renderToString timed out"), timeoutMs);
|
|
126
|
-
});
|
|
127
|
-
return Promise.race([renderToStream(code, options), timeout]).then(html => {
|
|
128
|
-
clearTimeout(timeoutHandle);
|
|
129
|
-
return html;
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
93
|
function renderToStream(code, options = {}) {
|
|
133
94
|
let {
|
|
134
95
|
nonce,
|
|
135
96
|
onCompleteShell,
|
|
136
97
|
onCompleteAll,
|
|
137
|
-
renderId,
|
|
98
|
+
renderId = "",
|
|
138
99
|
noScripts
|
|
139
100
|
} = options;
|
|
140
101
|
let dispose;
|
|
@@ -196,12 +157,7 @@ function renderToStream(code, options = {}) {
|
|
|
196
157
|
}
|
|
197
158
|
};
|
|
198
159
|
solidJs.sharedConfig.context = context = {
|
|
199
|
-
id: renderId || "",
|
|
200
|
-
count: 0,
|
|
201
160
|
async: true,
|
|
202
|
-
resources: {},
|
|
203
|
-
lazy: {},
|
|
204
|
-
suspense: {},
|
|
205
161
|
assets: [],
|
|
206
162
|
nonce,
|
|
207
163
|
block(p) {
|
|
@@ -213,7 +169,7 @@ function renderToStream(code, options = {}) {
|
|
|
213
169
|
const first = html.indexOf(placeholder);
|
|
214
170
|
if (first === -1) return;
|
|
215
171
|
const last = html.indexOf(`<!--!$/${id}-->`, first + placeholder.length);
|
|
216
|
-
html = html.slice(0, first) +
|
|
172
|
+
html = html.slice(0, first) + resolveSSRSync(escape(payloadFn())) + html.slice(last + placeholder.length + 1);
|
|
217
173
|
},
|
|
218
174
|
serialize(id, p, wait) {
|
|
219
175
|
const serverOnly = solidJs.sharedConfig.context.noHydrate;
|
|
@@ -226,36 +182,46 @@ function renderToStream(code, options = {}) {
|
|
|
226
182
|
});
|
|
227
183
|
} else if (!serverOnly) serializer.write(id, p);
|
|
228
184
|
},
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
},
|
|
185
|
+
escape: escape,
|
|
186
|
+
resolve: resolveSSRNode,
|
|
187
|
+
ssr: ssr,
|
|
233
188
|
registerFragment(key) {
|
|
234
189
|
if (!registry.has(key)) {
|
|
235
190
|
let resolve, reject;
|
|
236
191
|
const p = new Promise((r, rej) => (resolve = r, reject = rej));
|
|
237
|
-
registry.set(key,
|
|
238
|
-
err
|
|
239
|
-
|
|
240
|
-
|
|
192
|
+
registry.set(key, {
|
|
193
|
+
resolve: err => queue(() => queue(() => {
|
|
194
|
+
err ? reject(err) : resolve(true);
|
|
195
|
+
queue(flushEnd);
|
|
196
|
+
}))
|
|
197
|
+
});
|
|
241
198
|
serializer.write(key, p);
|
|
242
199
|
}
|
|
243
200
|
return (value, error) => {
|
|
244
201
|
if (registry.has(key)) {
|
|
245
|
-
const
|
|
202
|
+
const item = registry.get(key);
|
|
246
203
|
registry.delete(key);
|
|
247
|
-
if (
|
|
248
|
-
|
|
204
|
+
if (item.children) {
|
|
205
|
+
for (const k in item.children) {
|
|
206
|
+
value = replacePlaceholder(value, k, item.children[k]);
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
const parentKey = waitForFragments(registry, key);
|
|
210
|
+
if (parentKey) {
|
|
211
|
+
const parent = registry.get(parentKey);
|
|
212
|
+
parent.children ||= {};
|
|
213
|
+
parent.children[key] = value !== undefined ? value : "";
|
|
214
|
+
item.resolve();
|
|
249
215
|
return;
|
|
250
216
|
}
|
|
251
217
|
if (!completed) {
|
|
252
218
|
if (!firstFlushed) {
|
|
253
219
|
queue(() => html = replacePlaceholder(html, key, value !== undefined ? value : ""));
|
|
254
|
-
resolve(error);
|
|
220
|
+
item.resolve(error);
|
|
255
221
|
} else {
|
|
256
222
|
buffer.write(`<template id="${key}">${value !== undefined ? value : " "}</template>`);
|
|
257
223
|
pushTask(`$df("${key}")${!scriptFlushed ? ";" + REPLACE_SCRIPT : ""}`);
|
|
258
|
-
resolve(error);
|
|
224
|
+
item.resolve(error);
|
|
259
225
|
scriptFlushed = true;
|
|
260
226
|
}
|
|
261
227
|
}
|
|
@@ -266,12 +232,13 @@ function renderToStream(code, options = {}) {
|
|
|
266
232
|
};
|
|
267
233
|
let html = solidJs.createRoot(d => {
|
|
268
234
|
dispose = d;
|
|
269
|
-
return
|
|
235
|
+
return resolveSSRSync(escape(code()));
|
|
236
|
+
}, {
|
|
237
|
+
id: renderId
|
|
270
238
|
});
|
|
271
239
|
function doShell() {
|
|
272
240
|
if (shellCompleted) return;
|
|
273
241
|
solidJs.sharedConfig.context = context;
|
|
274
|
-
context.noHydrate = true;
|
|
275
242
|
html = injectAssets(context.assets, html);
|
|
276
243
|
if (tasks.length) html = injectScripts(html, tasks, nonce);
|
|
277
244
|
buffer.write(html);
|
|
@@ -354,21 +321,15 @@ function HydrationScript(props) {
|
|
|
354
321
|
}));
|
|
355
322
|
}
|
|
356
323
|
function ssr(t, ...nodes) {
|
|
357
|
-
if (nodes.length)
|
|
358
|
-
let result = "";
|
|
359
|
-
for (let i = 0; i < nodes.length; i++) {
|
|
360
|
-
result += t[i];
|
|
361
|
-
const node = nodes[i];
|
|
362
|
-
if (node !== undefined) result += resolveSSRNode(node);
|
|
363
|
-
}
|
|
364
|
-
t = result + t[nodes.length];
|
|
365
|
-
}
|
|
324
|
+
if (nodes.length) return resolveSSR(t, nodes);
|
|
366
325
|
return {
|
|
367
326
|
t
|
|
368
327
|
};
|
|
369
328
|
}
|
|
370
329
|
function ssrClassName(value) {
|
|
371
330
|
if (!value) return "";
|
|
331
|
+
if (typeof value === "string") return escape(value, true);
|
|
332
|
+
value = classListToObject(value);
|
|
372
333
|
let classKeys = Object.keys(value),
|
|
373
334
|
result = "";
|
|
374
335
|
for (let i = 0, len = classKeys.length; i < len; i++) {
|
|
@@ -390,11 +351,17 @@ function ssrStyle(value) {
|
|
|
390
351
|
const v = value[s];
|
|
391
352
|
if (v != undefined) {
|
|
392
353
|
if (i) result += ";";
|
|
393
|
-
|
|
354
|
+
const r = escape(v, true);
|
|
355
|
+
if (r != undefined && r !== "undefined") {
|
|
356
|
+
result += `${s}:${r}`;
|
|
357
|
+
}
|
|
394
358
|
}
|
|
395
359
|
}
|
|
396
360
|
return result;
|
|
397
361
|
}
|
|
362
|
+
function ssrStyleProperty(name, value) {
|
|
363
|
+
return value != null ? name + value : "";
|
|
364
|
+
}
|
|
398
365
|
function ssrElement(tag, props, children, needsId) {
|
|
399
366
|
if (props == null) props = {};else if (typeof props === "function") props = props();
|
|
400
367
|
const skipChildren = VOID_ELEMENTS.test(tag);
|
|
@@ -403,7 +370,7 @@ function ssrElement(tag, props, children, needsId) {
|
|
|
403
370
|
for (let i = 0; i < keys.length; i++) {
|
|
404
371
|
const prop = keys[i];
|
|
405
372
|
if (ChildProperties.has(prop)) {
|
|
406
|
-
if (children === undefined && !skipChildren) children = prop === "innerHTML" ? props[prop] : escape(props[prop]);
|
|
373
|
+
if (children === undefined && !skipChildren) children = tag === "script" || tag === "style" || prop === "innerHTML" ? props[prop] : escape(props[prop]);
|
|
407
374
|
continue;
|
|
408
375
|
}
|
|
409
376
|
const value = props[prop];
|
|
@@ -411,17 +378,13 @@ function ssrElement(tag, props, children, needsId) {
|
|
|
411
378
|
result += `style="${ssrStyle(value)}"`;
|
|
412
379
|
} else if (prop === "class") {
|
|
413
380
|
result += `class="${ssrClassName(value)}"`;
|
|
414
|
-
} else if (BooleanAttributes.has(prop)) {
|
|
415
|
-
if (value) result += prop;else continue;
|
|
416
381
|
} else if (value == undefined || prop === "ref" || prop.slice(0, 2) === "on" || prop.slice(0, 5) === "prop:") {
|
|
417
382
|
continue;
|
|
418
|
-
} else if (
|
|
383
|
+
} else if (typeof value === "boolean") {
|
|
419
384
|
if (!value) continue;
|
|
420
|
-
result += escape(prop
|
|
421
|
-
} else if (prop.slice(0, 5) === "attr:") {
|
|
422
|
-
result += `${escape(prop.slice(5))}="${escape(value, true)}"`;
|
|
385
|
+
result += escape(prop);
|
|
423
386
|
} else {
|
|
424
|
-
result +=
|
|
387
|
+
result += value === "" ? escape(prop) : `${escape(prop)}="${escape(value, true)}"`;
|
|
425
388
|
}
|
|
426
389
|
if (i !== keys.length - 1) result += " ";
|
|
427
390
|
}
|
|
@@ -429,26 +392,24 @@ function ssrElement(tag, props, children, needsId) {
|
|
|
429
392
|
t: result + "/>"
|
|
430
393
|
};
|
|
431
394
|
if (typeof children === "function") children = children();
|
|
432
|
-
return {
|
|
433
|
-
t: result + `>${resolveSSRNode(children, true)}</${tag}>`
|
|
434
|
-
};
|
|
395
|
+
return ssr([result + ">", `</${tag}>`], resolveSSRNode(children, undefined, true));
|
|
435
396
|
}
|
|
436
|
-
function ssrAttribute(key, value
|
|
437
|
-
return
|
|
397
|
+
function ssrAttribute(key, value) {
|
|
398
|
+
return value == null || value === false ? "" : value === true ? ` ${key}` : ` ${key}="${value}"`;
|
|
438
399
|
}
|
|
439
400
|
function ssrHydrationKey() {
|
|
440
401
|
const hk = getHydrationKey();
|
|
441
|
-
return hk ? `
|
|
402
|
+
return hk ? ` _hk=${hk}` : "";
|
|
442
403
|
}
|
|
443
404
|
function escape(s, attr) {
|
|
444
405
|
const t = typeof s;
|
|
445
406
|
if (t !== "string") {
|
|
446
|
-
if (!attr && t === "function") return escape(s());
|
|
447
407
|
if (!attr && Array.isArray(s)) {
|
|
408
|
+
s = s.slice();
|
|
448
409
|
for (let i = 0; i < s.length; i++) s[i] = escape(s[i]);
|
|
449
410
|
return s;
|
|
450
411
|
}
|
|
451
|
-
if (attr && t === "boolean") return
|
|
412
|
+
if (attr && t === "boolean") return s;
|
|
452
413
|
return s;
|
|
453
414
|
}
|
|
454
415
|
const delim = attr ? '"' : "<";
|
|
@@ -486,29 +447,35 @@ function escape(s, attr) {
|
|
|
486
447
|
}
|
|
487
448
|
return left < s.length ? out + s.substring(left) : out;
|
|
488
449
|
}
|
|
489
|
-
function
|
|
490
|
-
const
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
450
|
+
function mergeProps(...sources) {
|
|
451
|
+
const target = {};
|
|
452
|
+
for (let i = 0; i < sources.length; i++) {
|
|
453
|
+
let source = sources[i];
|
|
454
|
+
if (typeof source === "function") source = source();
|
|
455
|
+
if (source) {
|
|
456
|
+
const descriptors = Object.getOwnPropertyDescriptors(source);
|
|
457
|
+
for (const key in descriptors) {
|
|
458
|
+
if (key in target) continue;
|
|
459
|
+
Object.defineProperty(target, key, {
|
|
460
|
+
enumerable: true,
|
|
461
|
+
get() {
|
|
462
|
+
for (let i = sources.length - 1; i >= 0; i--) {
|
|
463
|
+
const v = (sources[i] || {})[key];
|
|
464
|
+
if (v !== undefined) return v;
|
|
465
|
+
}
|
|
466
|
+
}
|
|
467
|
+
});
|
|
468
|
+
}
|
|
499
469
|
}
|
|
500
|
-
return mapped;
|
|
501
470
|
}
|
|
502
|
-
|
|
503
|
-
if (t === "function") return resolveSSRNode(node());
|
|
504
|
-
return String(node);
|
|
471
|
+
return target;
|
|
505
472
|
}
|
|
506
473
|
function getHydrationKey() {
|
|
507
474
|
const hydrate = solidJs.sharedConfig.context;
|
|
508
475
|
return hydrate && !hydrate.noHydrate && solidJs.sharedConfig.getNextContextId();
|
|
509
476
|
}
|
|
510
477
|
function useAssets(fn) {
|
|
511
|
-
solidJs.sharedConfig.context.assets.push(() =>
|
|
478
|
+
solidJs.sharedConfig.context.assets.push(() => resolveSSRSync(escape(fn())));
|
|
512
479
|
}
|
|
513
480
|
function getAssets() {
|
|
514
481
|
const assets = solidJs.sharedConfig.context.assets;
|
|
@@ -520,15 +487,13 @@ function generateHydrationScript({
|
|
|
520
487
|
eventNames = ["click", "input"],
|
|
521
488
|
nonce
|
|
522
489
|
} = {}) {
|
|
523
|
-
return `<script${nonce ? ` nonce="${nonce}"` : ""}>window._$HY||(e=>{let t=e=>e&&e.hasAttribute&&(e.hasAttribute("
|
|
490
|
+
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-->`;
|
|
524
491
|
}
|
|
525
492
|
function Hydration(props) {
|
|
526
493
|
if (!solidJs.sharedConfig.context.noHydrate) return props.children;
|
|
527
494
|
const context = solidJs.sharedConfig.context;
|
|
528
495
|
solidJs.sharedConfig.context = {
|
|
529
496
|
...context,
|
|
530
|
-
count: 0,
|
|
531
|
-
id: solidJs.sharedConfig.getNextContextId(),
|
|
532
497
|
noHydrate: false
|
|
533
498
|
};
|
|
534
499
|
const res = props.children;
|
|
@@ -536,8 +501,14 @@ function Hydration(props) {
|
|
|
536
501
|
return res;
|
|
537
502
|
}
|
|
538
503
|
function NoHydration(props) {
|
|
539
|
-
|
|
540
|
-
|
|
504
|
+
let context = solidJs.sharedConfig.context;
|
|
505
|
+
if (context) solidJs.sharedConfig.context = {
|
|
506
|
+
...context,
|
|
507
|
+
noHydrate: true
|
|
508
|
+
};
|
|
509
|
+
const res = props.children;
|
|
510
|
+
if (context) solidJs.sharedConfig.context = context;
|
|
511
|
+
return res;
|
|
541
512
|
}
|
|
542
513
|
function queue(fn) {
|
|
543
514
|
return Promise.resolve().then(fn);
|
|
@@ -567,7 +538,7 @@ function injectScripts(html, scripts, nonce) {
|
|
|
567
538
|
}
|
|
568
539
|
function waitForFragments(registry, key) {
|
|
569
540
|
for (const k of [...registry.keys()].reverse()) {
|
|
570
|
-
if (key.startsWith(k)) return
|
|
541
|
+
if (key.startsWith(k)) return k;
|
|
571
542
|
}
|
|
572
543
|
return false;
|
|
573
544
|
}
|
|
@@ -579,12 +550,82 @@ function replacePlaceholder(html, key, value) {
|
|
|
579
550
|
const last = html.indexOf(close, first + marker.length);
|
|
580
551
|
return html.slice(0, first) + value + html.slice(last + close.length);
|
|
581
552
|
}
|
|
553
|
+
function classListToObject(classList) {
|
|
554
|
+
if (Array.isArray(classList)) {
|
|
555
|
+
const result = {};
|
|
556
|
+
flattenClassList(classList, result);
|
|
557
|
+
return result;
|
|
558
|
+
}
|
|
559
|
+
return classList;
|
|
560
|
+
}
|
|
561
|
+
function flattenClassList(list, result) {
|
|
562
|
+
for (let i = 0, len = list.length; i < len; i++) {
|
|
563
|
+
const item = list[i];
|
|
564
|
+
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;
|
|
565
|
+
}
|
|
566
|
+
}
|
|
567
|
+
function resolveSSR(template, holes, result = {
|
|
568
|
+
t: [""],
|
|
569
|
+
h: [],
|
|
570
|
+
p: []
|
|
571
|
+
}) {
|
|
572
|
+
for (let i = 0; i < holes.length; i++) {
|
|
573
|
+
const hole = holes[i];
|
|
574
|
+
result.t[result.t.length - 1] += template[i];
|
|
575
|
+
if (hole == null || hole === true || hole === false) continue;
|
|
576
|
+
resolveSSRNode(hole, result);
|
|
577
|
+
}
|
|
578
|
+
result.t[result.t.length - 1] += template[template.length - 1];
|
|
579
|
+
return result;
|
|
580
|
+
}
|
|
581
|
+
function resolveSSRNode(node, result = {
|
|
582
|
+
t: [""],
|
|
583
|
+
h: [],
|
|
584
|
+
p: []
|
|
585
|
+
}, top) {
|
|
586
|
+
const t = typeof node;
|
|
587
|
+
if (t === "string" || t === "number") {
|
|
588
|
+
result.t[result.t.length - 1] += node;
|
|
589
|
+
} else if (node == null || t === "boolean") ; else if (Array.isArray(node)) {
|
|
590
|
+
let prev = {};
|
|
591
|
+
for (let i = 0, len = node.length; i < len; i++) {
|
|
592
|
+
if (!top && typeof prev !== "object" && typeof node[i] !== "object") result.t[result.t.length - 1] += `<!--!$-->`;
|
|
593
|
+
resolveSSRNode(prev = node[i], result);
|
|
594
|
+
}
|
|
595
|
+
} else if (t === "object") {
|
|
596
|
+
if (node.h) {
|
|
597
|
+
result.t[result.t.length - 1] += node.t[0];
|
|
598
|
+
if (node.t.length > 1) {
|
|
599
|
+
result.t.push(...node.t.slice(1));
|
|
600
|
+
result.h.push(...node.h);
|
|
601
|
+
result.p.push(...node.p);
|
|
602
|
+
}
|
|
603
|
+
} else result.t[result.t.length - 1] += node.t;
|
|
604
|
+
} else if (t === "function") {
|
|
605
|
+
try {
|
|
606
|
+
resolveSSRNode(node(), result);
|
|
607
|
+
} catch (err) {
|
|
608
|
+
const p = solidJs.ssrHandleError(err);
|
|
609
|
+
if (p) {
|
|
610
|
+
result.h.push(node);
|
|
611
|
+
result.p.push(p);
|
|
612
|
+
result.t.push("");
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
return result;
|
|
617
|
+
}
|
|
618
|
+
function resolveSSRSync(node) {
|
|
619
|
+
const res = resolveSSRNode(node);
|
|
620
|
+
if (!res.h.length) return res.t[0];
|
|
621
|
+
throw new Error("This value cannot be rendered synchronously. Are you missing a Suspsense boundary?");
|
|
622
|
+
}
|
|
582
623
|
const RequestContext = Symbol();
|
|
583
624
|
function getRequestEvent() {
|
|
584
625
|
return globalThis[RequestContext] ? globalThis[RequestContext].getStore() || solidJs.sharedConfig.context && solidJs.sharedConfig.context.event || console.log("RequestEvent is missing. This is most likely due to accessing `getRequestEvent` non-managed async scope in a partially polyfilled environment. Try moving it above all `await` calls.") : undefined;
|
|
585
626
|
}
|
|
586
|
-
function
|
|
587
|
-
|
|
627
|
+
function renderToStringAsync(code, options = {}) {
|
|
628
|
+
return renderToStream(code, options).then(html => html);
|
|
588
629
|
}
|
|
589
630
|
function notSup() {
|
|
590
631
|
throw new Error("Client-only API called on the server side. Run client-only code in onMount, or conditionally run client-only component with <Show>.");
|
|
@@ -592,18 +633,21 @@ function notSup() {
|
|
|
592
633
|
|
|
593
634
|
const isServer = true;
|
|
594
635
|
const isDev = false;
|
|
595
|
-
function
|
|
596
|
-
const
|
|
597
|
-
const comp = p.component,
|
|
636
|
+
function createDynamic(component, props) {
|
|
637
|
+
const comp = component(),
|
|
598
638
|
t = typeof comp;
|
|
599
639
|
if (comp) {
|
|
600
|
-
if (t === "function") return comp(
|
|
601
|
-
return ssrElement(comp,
|
|
640
|
+
if (t === "function") return comp(props);else if (t === "string") {
|
|
641
|
+
return ssrElement(comp, props, undefined, true);
|
|
602
642
|
}
|
|
603
643
|
}
|
|
604
644
|
}
|
|
645
|
+
function Dynamic(props) {
|
|
646
|
+
const others = solidJs.omit(props, "component");
|
|
647
|
+
return createDynamic(() => props.component, others);
|
|
648
|
+
}
|
|
605
649
|
function Portal(props) {
|
|
606
|
-
|
|
650
|
+
throw new Error("Portal is not supported on the server");
|
|
607
651
|
}
|
|
608
652
|
|
|
609
653
|
Object.defineProperty(exports, "ErrorBoundary", {
|
|
@@ -614,14 +658,14 @@ Object.defineProperty(exports, "For", {
|
|
|
614
658
|
enumerable: true,
|
|
615
659
|
get: function () { return solidJs.For; }
|
|
616
660
|
});
|
|
617
|
-
Object.defineProperty(exports, "Index", {
|
|
618
|
-
enumerable: true,
|
|
619
|
-
get: function () { return solidJs.Index; }
|
|
620
|
-
});
|
|
621
661
|
Object.defineProperty(exports, "Match", {
|
|
622
662
|
enumerable: true,
|
|
623
663
|
get: function () { return solidJs.Match; }
|
|
624
664
|
});
|
|
665
|
+
Object.defineProperty(exports, "Repeat", {
|
|
666
|
+
enumerable: true,
|
|
667
|
+
get: function () { return solidJs.Repeat; }
|
|
668
|
+
});
|
|
625
669
|
Object.defineProperty(exports, "Show", {
|
|
626
670
|
enumerable: true,
|
|
627
671
|
get: function () { return solidJs.Show; }
|
|
@@ -630,10 +674,6 @@ Object.defineProperty(exports, "Suspense", {
|
|
|
630
674
|
enumerable: true,
|
|
631
675
|
get: function () { return solidJs.Suspense; }
|
|
632
676
|
});
|
|
633
|
-
Object.defineProperty(exports, "SuspenseList", {
|
|
634
|
-
enumerable: true,
|
|
635
|
-
get: function () { return solidJs.SuspenseList; }
|
|
636
|
-
});
|
|
637
677
|
Object.defineProperty(exports, "Switch", {
|
|
638
678
|
enumerable: true,
|
|
639
679
|
get: function () { return solidJs.Switch; }
|
|
@@ -650,19 +690,14 @@ Object.defineProperty(exports, "getOwner", {
|
|
|
650
690
|
enumerable: true,
|
|
651
691
|
get: function () { return solidJs.getOwner; }
|
|
652
692
|
});
|
|
653
|
-
Object.defineProperty(exports, "
|
|
654
|
-
enumerable: true,
|
|
655
|
-
get: function () { return solidJs.createMemo; }
|
|
656
|
-
});
|
|
657
|
-
Object.defineProperty(exports, "mergeProps", {
|
|
693
|
+
Object.defineProperty(exports, "ssrRunInScope", {
|
|
658
694
|
enumerable: true,
|
|
659
|
-
get: function () { return solidJs.
|
|
695
|
+
get: function () { return solidJs.ssrRunInScope; }
|
|
660
696
|
});
|
|
661
697
|
Object.defineProperty(exports, "untrack", {
|
|
662
698
|
enumerable: true,
|
|
663
699
|
get: function () { return solidJs.untrack; }
|
|
664
700
|
});
|
|
665
|
-
exports.Assets = Assets;
|
|
666
701
|
exports.ChildProperties = ChildProperties;
|
|
667
702
|
exports.DOMElements = DOMElements;
|
|
668
703
|
exports.DelegatedEvents = DelegatedEvents;
|
|
@@ -678,6 +713,7 @@ exports.SVGNamespace = SVGNamespace;
|
|
|
678
713
|
exports.addEventListener = notSup;
|
|
679
714
|
exports.assign = notSup;
|
|
680
715
|
exports.className = notSup;
|
|
716
|
+
exports.createDynamic = createDynamic;
|
|
681
717
|
exports.delegateEvents = notSup;
|
|
682
718
|
exports.dynamicProperty = notSup;
|
|
683
719
|
exports.escape = escape;
|
|
@@ -687,17 +723,17 @@ exports.getHydrationKey = getHydrationKey;
|
|
|
687
723
|
exports.getNextElement = notSup;
|
|
688
724
|
exports.getNextMarker = notSup;
|
|
689
725
|
exports.getNextMatch = notSup;
|
|
690
|
-
exports.getPropAlias = getPropAlias;
|
|
691
726
|
exports.getRequestEvent = getRequestEvent;
|
|
692
727
|
exports.hydrate = notSup;
|
|
693
728
|
exports.insert = notSup;
|
|
694
729
|
exports.isDev = isDev;
|
|
695
730
|
exports.isServer = isServer;
|
|
731
|
+
exports.memo = memo;
|
|
732
|
+
exports.mergeProps = mergeProps;
|
|
696
733
|
exports.render = notSup;
|
|
697
734
|
exports.renderToStream = renderToStream;
|
|
698
735
|
exports.renderToString = renderToString;
|
|
699
736
|
exports.renderToStringAsync = renderToStringAsync;
|
|
700
|
-
exports.resolveSSRNode = resolveSSRNode;
|
|
701
737
|
exports.runHydrationEvents = notSup;
|
|
702
738
|
exports.setAttribute = notSup;
|
|
703
739
|
exports.setAttributeNS = notSup;
|
|
@@ -709,6 +745,7 @@ exports.ssrClassName = ssrClassName;
|
|
|
709
745
|
exports.ssrElement = ssrElement;
|
|
710
746
|
exports.ssrHydrationKey = ssrHydrationKey;
|
|
711
747
|
exports.ssrStyle = ssrStyle;
|
|
748
|
+
exports.ssrStyleProperty = ssrStyleProperty;
|
|
712
749
|
exports.style = notSup;
|
|
713
750
|
exports.template = notSup;
|
|
714
751
|
exports.useAssets = useAssets;
|