@solidjs/web 2.0.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +7 -0
- package/dist/dev.cjs +805 -0
- package/dist/dev.js +707 -0
- package/dist/server.cjs +973 -0
- package/dist/server.js +876 -0
- package/dist/web.cjs +748 -0
- package/dist/web.js +650 -0
- package/package.json +98 -0
- package/storage/dist/storage.cjs +12 -0
- package/storage/dist/storage.js +10 -0
- package/storage/package.json +15 -0
- package/storage/types/index.d.ts +2 -0
- package/storage/types/src/client.d.ts +1 -0
- package/storage/types/src/index.d.ts +45 -0
- package/storage/types/src/server-mock.d.ts +72 -0
- package/storage/types/storage/src/index.d.ts +2 -0
- package/types/client.d.ts +90 -0
- package/types/core.d.ts +3 -0
- package/types/index.d.ts +45 -0
- package/types/jsx.d.ts +1 -0
- package/types/server-mock.d.ts +72 -0
- package/types/server.d.ts +155 -0
package/dist/server.js
ADDED
|
@@ -0,0 +1,876 @@
|
|
|
1
|
+
import { createRenderEffect, createMemo, sharedConfig, createRoot, ssrHandleError, omit, getOwner, getNextChildId, createOwner, runWithOwner } from 'solid-js';
|
|
2
|
+
export { Errored, For, Loading, Match, Repeat, Show, Switch, createComponent, getOwner, ssrRunInScope, untrack } from 'solid-js';
|
|
3
|
+
import { Serializer, Feature, getCrossReferenceHeader } from 'seroval';
|
|
4
|
+
import { AbortSignalPlugin, CustomEventPlugin, DOMExceptionPlugin, EventPlugin, FormDataPlugin, HeadersPlugin, ReadableStreamPlugin, RequestPlugin, ResponsePlugin, URLSearchParamsPlugin, URLPlugin } from 'seroval-plugins/web';
|
|
5
|
+
|
|
6
|
+
const Properties = /*#__PURE__*/new Set([
|
|
7
|
+
"value", "checked", "selected", "muted"]);
|
|
8
|
+
const ChildProperties = /*#__PURE__*/new Set(["innerHTML", "textContent", "innerText", "children"]);
|
|
9
|
+
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
|
+
const SVGElements = /*#__PURE__*/new Set([
|
|
11
|
+
"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",
|
|
12
|
+
"set", "stop",
|
|
13
|
+
"svg", "switch", "symbol", "text", "textPath",
|
|
14
|
+
"tref", "tspan", "use", "view", "vkern"]);
|
|
15
|
+
const SVGNamespace = {
|
|
16
|
+
xlink: "http://www.w3.org/1999/xlink",
|
|
17
|
+
xml: "http://www.w3.org/XML/1998/namespace"
|
|
18
|
+
};
|
|
19
|
+
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
|
+
"webview",
|
|
21
|
+
"isindex", "listing", "multicol", "nextid", "noindex", "search"]);
|
|
22
|
+
|
|
23
|
+
const effect = (fn, effectFn, initial) => createRenderEffect(fn, effectFn, initial, {
|
|
24
|
+
transparent: true
|
|
25
|
+
});
|
|
26
|
+
const memo = fn => createMemo(() => fn());
|
|
27
|
+
|
|
28
|
+
const ES2017FLAG = Feature.AggregateError
|
|
29
|
+
| Feature.BigIntTypedArray;
|
|
30
|
+
const GLOBAL_IDENTIFIER = '_$HY.r';
|
|
31
|
+
function createSerializer({
|
|
32
|
+
onData,
|
|
33
|
+
onDone,
|
|
34
|
+
scopeId,
|
|
35
|
+
onError,
|
|
36
|
+
plugins: customPlugins
|
|
37
|
+
}) {
|
|
38
|
+
const defaultPlugins = [AbortSignalPlugin,
|
|
39
|
+
CustomEventPlugin, DOMExceptionPlugin, EventPlugin,
|
|
40
|
+
FormDataPlugin, HeadersPlugin, ReadableStreamPlugin, RequestPlugin, ResponsePlugin, URLSearchParamsPlugin, URLPlugin];
|
|
41
|
+
const allPlugins = customPlugins ? [...customPlugins, ...defaultPlugins] : defaultPlugins;
|
|
42
|
+
return new Serializer({
|
|
43
|
+
scopeId,
|
|
44
|
+
plugins: allPlugins,
|
|
45
|
+
globalIdentifier: GLOBAL_IDENTIFIER,
|
|
46
|
+
disabledFeatures: ES2017FLAG,
|
|
47
|
+
onData,
|
|
48
|
+
onDone,
|
|
49
|
+
onError
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
function getLocalHeaderScript(id) {
|
|
53
|
+
return getCrossReferenceHeader(id) + ';';
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function resolveAssets(moduleUrl, manifest) {
|
|
57
|
+
if (!manifest) return null;
|
|
58
|
+
const entry = manifest[moduleUrl];
|
|
59
|
+
if (!entry) return null;
|
|
60
|
+
const css = [];
|
|
61
|
+
const js = [];
|
|
62
|
+
const visited = new Set();
|
|
63
|
+
const walk = key => {
|
|
64
|
+
if (visited.has(key)) return;
|
|
65
|
+
visited.add(key);
|
|
66
|
+
const e = manifest[key];
|
|
67
|
+
if (!e) return;
|
|
68
|
+
js.push(e.file);
|
|
69
|
+
if (e.css) for (let i = 0; i < e.css.length; i++) css.push(e.css[i]);
|
|
70
|
+
if (e.imports) for (let i = 0; i < e.imports.length; i++) walk(e.imports[i]);
|
|
71
|
+
};
|
|
72
|
+
walk(moduleUrl);
|
|
73
|
+
return {
|
|
74
|
+
js,
|
|
75
|
+
css
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
function registerEntryAssets(manifest) {
|
|
79
|
+
if (!manifest) return;
|
|
80
|
+
const ctx = sharedConfig.context;
|
|
81
|
+
if (!ctx?.registerAsset) return;
|
|
82
|
+
for (const key in manifest) {
|
|
83
|
+
if (manifest[key].isEntry) {
|
|
84
|
+
const assets = resolveAssets(key, manifest);
|
|
85
|
+
if (assets) {
|
|
86
|
+
for (let i = 0; i < assets.css.length; i++) ctx.registerAsset("style", assets.css[i]);
|
|
87
|
+
}
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
function createAssetTracking() {
|
|
93
|
+
const boundaryModules = new Map();
|
|
94
|
+
const boundaryStyles = new Map();
|
|
95
|
+
const emittedAssets = new Set();
|
|
96
|
+
let currentBoundaryId = null;
|
|
97
|
+
return {
|
|
98
|
+
boundaryModules,
|
|
99
|
+
boundaryStyles,
|
|
100
|
+
emittedAssets,
|
|
101
|
+
get currentBoundaryId() {
|
|
102
|
+
return currentBoundaryId;
|
|
103
|
+
},
|
|
104
|
+
set currentBoundaryId(v) {
|
|
105
|
+
currentBoundaryId = v;
|
|
106
|
+
},
|
|
107
|
+
registerModule(moduleUrl, entryUrl) {
|
|
108
|
+
if (!currentBoundaryId) return;
|
|
109
|
+
let map = boundaryModules.get(currentBoundaryId);
|
|
110
|
+
if (!map) {
|
|
111
|
+
map = {};
|
|
112
|
+
boundaryModules.set(currentBoundaryId, map);
|
|
113
|
+
}
|
|
114
|
+
map[moduleUrl] = entryUrl;
|
|
115
|
+
},
|
|
116
|
+
getBoundaryModules(id) {
|
|
117
|
+
return boundaryModules.get(id) || null;
|
|
118
|
+
},
|
|
119
|
+
getBoundaryStyles(id) {
|
|
120
|
+
return boundaryStyles.get(id) || null;
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
function applyAssetTracking(context, tracking, manifest) {
|
|
125
|
+
Object.defineProperty(context, "_currentBoundaryId", {
|
|
126
|
+
get() {
|
|
127
|
+
return tracking.currentBoundaryId;
|
|
128
|
+
},
|
|
129
|
+
set(v) {
|
|
130
|
+
tracking.currentBoundaryId = v;
|
|
131
|
+
},
|
|
132
|
+
configurable: true,
|
|
133
|
+
enumerable: true
|
|
134
|
+
});
|
|
135
|
+
context.registerModule = tracking.registerModule;
|
|
136
|
+
context.getBoundaryModules = tracking.getBoundaryModules;
|
|
137
|
+
if (manifest) context.resolveAssets = moduleUrl => resolveAssets(moduleUrl, manifest);
|
|
138
|
+
}
|
|
139
|
+
const VOID_ELEMENTS = /^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/i;
|
|
140
|
+
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)}function $dfs(e,c){(_$HY.sc=_$HY.sc||{})[e]=c}function $dfc(e){if(--_$HY.sc[e]<=0)delete _$HY.sc[e],$df(e)}`;
|
|
141
|
+
function renderToString(code, options = {}) {
|
|
142
|
+
const {
|
|
143
|
+
renderId = "",
|
|
144
|
+
nonce,
|
|
145
|
+
noScripts,
|
|
146
|
+
manifest
|
|
147
|
+
} = options;
|
|
148
|
+
let scripts = "";
|
|
149
|
+
const serializer = createSerializer({
|
|
150
|
+
scopeId: renderId,
|
|
151
|
+
plugins: options.plugins,
|
|
152
|
+
onData(script) {
|
|
153
|
+
if (noScripts) return;
|
|
154
|
+
if (!scripts) {
|
|
155
|
+
scripts = getLocalHeaderScript(renderId);
|
|
156
|
+
}
|
|
157
|
+
scripts += script + ";";
|
|
158
|
+
},
|
|
159
|
+
onError: options.onError
|
|
160
|
+
});
|
|
161
|
+
const tracking = createAssetTracking();
|
|
162
|
+
sharedConfig.context = {
|
|
163
|
+
assets: [],
|
|
164
|
+
nonce,
|
|
165
|
+
escape: escape,
|
|
166
|
+
resolve: resolveSSRNode,
|
|
167
|
+
ssr: ssr,
|
|
168
|
+
serialize(id, p) {
|
|
169
|
+
if (sharedConfig.context.noHydrate) return;
|
|
170
|
+
if (p != null && typeof p === "object" && (typeof p.then === "function" || typeof p[Symbol.asyncIterator] === "function")) {
|
|
171
|
+
throw new Error("Cannot serialize async value in renderToString (id: " + id + "). " + "Use renderToStream for async data.");
|
|
172
|
+
}
|
|
173
|
+
serializer.write(id, p);
|
|
174
|
+
},
|
|
175
|
+
registerAsset(type, url) {
|
|
176
|
+
if (tracking.currentBoundaryId && type === "style") {
|
|
177
|
+
let styles = tracking.boundaryStyles.get(tracking.currentBoundaryId);
|
|
178
|
+
if (!styles) {
|
|
179
|
+
styles = new Set();
|
|
180
|
+
tracking.boundaryStyles.set(tracking.currentBoundaryId, styles);
|
|
181
|
+
}
|
|
182
|
+
styles.add(url);
|
|
183
|
+
}
|
|
184
|
+
tracking.emittedAssets.add(url);
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
applyAssetTracking(sharedConfig.context, tracking, manifest);
|
|
188
|
+
registerEntryAssets(manifest);
|
|
189
|
+
let html = createRoot(d => {
|
|
190
|
+
setTimeout(d);
|
|
191
|
+
return resolveSSRSync(escape(code()));
|
|
192
|
+
}, {
|
|
193
|
+
id: renderId
|
|
194
|
+
});
|
|
195
|
+
sharedConfig.context.noHydrate = true;
|
|
196
|
+
serializer.close();
|
|
197
|
+
html = injectAssets(sharedConfig.context.assets, html);
|
|
198
|
+
html = injectPreloadLinks(tracking.emittedAssets, html);
|
|
199
|
+
if (scripts.length) html = injectScripts(html, scripts, options.nonce);
|
|
200
|
+
return html;
|
|
201
|
+
}
|
|
202
|
+
function renderToStream(code, options = {}) {
|
|
203
|
+
let {
|
|
204
|
+
nonce,
|
|
205
|
+
onCompleteShell,
|
|
206
|
+
onCompleteAll,
|
|
207
|
+
renderId = "",
|
|
208
|
+
noScripts,
|
|
209
|
+
manifest
|
|
210
|
+
} = options;
|
|
211
|
+
let dispose;
|
|
212
|
+
const blockingPromises = new Set();
|
|
213
|
+
const pushTask = task => {
|
|
214
|
+
if (noScripts) return;
|
|
215
|
+
if (!tasks && !firstFlushed) {
|
|
216
|
+
tasks = getLocalHeaderScript(renderId);
|
|
217
|
+
}
|
|
218
|
+
tasks += task + ";";
|
|
219
|
+
if (!timer && firstFlushed) {
|
|
220
|
+
timer = setTimeout(writeTasks);
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
const onDone = () => {
|
|
224
|
+
writeTasks();
|
|
225
|
+
doShell();
|
|
226
|
+
onCompleteAll && onCompleteAll({
|
|
227
|
+
write(v) {
|
|
228
|
+
!completed && buffer.write(v);
|
|
229
|
+
}
|
|
230
|
+
});
|
|
231
|
+
writable && writable.end();
|
|
232
|
+
completed = true;
|
|
233
|
+
if (firstFlushed) dispose();
|
|
234
|
+
};
|
|
235
|
+
const serializer = createSerializer({
|
|
236
|
+
scopeId: options.renderId,
|
|
237
|
+
plugins: options.plugins,
|
|
238
|
+
onData: pushTask,
|
|
239
|
+
onDone,
|
|
240
|
+
onError: options.onError
|
|
241
|
+
});
|
|
242
|
+
const flushEnd = () => {
|
|
243
|
+
if (!registry.size) {
|
|
244
|
+
queue(() => queue(() => serializer.flush()));
|
|
245
|
+
}
|
|
246
|
+
};
|
|
247
|
+
const registry = new Map();
|
|
248
|
+
const writeTasks = () => {
|
|
249
|
+
if (tasks.length && !completed && firstFlushed) {
|
|
250
|
+
buffer.write(`<script${nonce ? ` nonce="${nonce}"` : ""}>${tasks}</script>`);
|
|
251
|
+
tasks = "";
|
|
252
|
+
}
|
|
253
|
+
timer && clearTimeout(timer);
|
|
254
|
+
timer = null;
|
|
255
|
+
};
|
|
256
|
+
let context;
|
|
257
|
+
let writable;
|
|
258
|
+
let tmp = "";
|
|
259
|
+
let tasks = "";
|
|
260
|
+
let firstFlushed = false;
|
|
261
|
+
let completed = false;
|
|
262
|
+
let shellCompleted = false;
|
|
263
|
+
let scriptFlushed = false;
|
|
264
|
+
let headStyles;
|
|
265
|
+
let timer = null;
|
|
266
|
+
let rootHoles = null;
|
|
267
|
+
let nextHoleId = 0;
|
|
268
|
+
let buffer = {
|
|
269
|
+
write(payload) {
|
|
270
|
+
tmp += payload;
|
|
271
|
+
}
|
|
272
|
+
};
|
|
273
|
+
const tracking = createAssetTracking();
|
|
274
|
+
sharedConfig.context = context = {
|
|
275
|
+
async: true,
|
|
276
|
+
assets: [],
|
|
277
|
+
nonce,
|
|
278
|
+
registerAsset(type, url) {
|
|
279
|
+
if (tracking.currentBoundaryId && type === "style") {
|
|
280
|
+
let styles = tracking.boundaryStyles.get(tracking.currentBoundaryId);
|
|
281
|
+
if (!styles) {
|
|
282
|
+
styles = new Set();
|
|
283
|
+
tracking.boundaryStyles.set(tracking.currentBoundaryId, styles);
|
|
284
|
+
}
|
|
285
|
+
styles.add(url);
|
|
286
|
+
}
|
|
287
|
+
if (!tracking.emittedAssets.has(url)) {
|
|
288
|
+
tracking.emittedAssets.add(url);
|
|
289
|
+
if (firstFlushed && type === "module") {
|
|
290
|
+
buffer.write(`<link rel="modulepreload" href="${url}">`);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
},
|
|
294
|
+
block(p) {
|
|
295
|
+
if (!firstFlushed) blockingPromises.add(p);
|
|
296
|
+
},
|
|
297
|
+
replace(id, payloadFn) {
|
|
298
|
+
if (firstFlushed) return;
|
|
299
|
+
const placeholder = `<!--!$${id}-->`;
|
|
300
|
+
const first = html.indexOf(placeholder);
|
|
301
|
+
if (first === -1) return;
|
|
302
|
+
const last = html.indexOf(`<!--!$/${id}-->`, first + placeholder.length);
|
|
303
|
+
html = html.slice(0, first) + resolveSSRSync(escape(payloadFn())) + html.slice(last + placeholder.length + 1);
|
|
304
|
+
},
|
|
305
|
+
serialize(id, p, deferStream) {
|
|
306
|
+
if (sharedConfig.context.noHydrate) return;
|
|
307
|
+
if (!firstFlushed && deferStream && typeof p === "object" && "then" in p) {
|
|
308
|
+
blockingPromises.add(p);
|
|
309
|
+
p.then(d => serializer.write(id, d)).catch(e => serializer.write(id, e));
|
|
310
|
+
} else serializer.write(id, p);
|
|
311
|
+
},
|
|
312
|
+
escape: escape,
|
|
313
|
+
resolve: resolveSSRNode,
|
|
314
|
+
ssr: ssr,
|
|
315
|
+
registerFragment(key) {
|
|
316
|
+
if (!registry.has(key)) {
|
|
317
|
+
let resolve, reject;
|
|
318
|
+
const p = new Promise((r, rej) => (resolve = r, reject = rej));
|
|
319
|
+
registry.set(key, {
|
|
320
|
+
resolve: err => queue(() => queue(() => {
|
|
321
|
+
err ? reject(err) : resolve(true);
|
|
322
|
+
queue(flushEnd);
|
|
323
|
+
}))
|
|
324
|
+
});
|
|
325
|
+
serializer.write(key, p);
|
|
326
|
+
}
|
|
327
|
+
return (value, error) => {
|
|
328
|
+
if (registry.has(key)) {
|
|
329
|
+
const item = registry.get(key);
|
|
330
|
+
registry.delete(key);
|
|
331
|
+
if (item.children) {
|
|
332
|
+
for (const k in item.children) {
|
|
333
|
+
value = replacePlaceholder(value, k, item.children[k]);
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
const parentKey = waitForFragments(registry, key);
|
|
337
|
+
if (parentKey) {
|
|
338
|
+
const parent = registry.get(parentKey);
|
|
339
|
+
parent.children ||= {};
|
|
340
|
+
parent.children[key] = value !== undefined ? value : "";
|
|
341
|
+
serializeFragmentAssets(key, tracking.boundaryModules, context);
|
|
342
|
+
propagateBoundaryStyles(key, parentKey, tracking);
|
|
343
|
+
item.resolve();
|
|
344
|
+
return;
|
|
345
|
+
}
|
|
346
|
+
if (!completed) {
|
|
347
|
+
if (!firstFlushed) {
|
|
348
|
+
queue(() => html = replacePlaceholder(html, key, value !== undefined ? value : ""));
|
|
349
|
+
serializeFragmentAssets(key, tracking.boundaryModules, context);
|
|
350
|
+
item.resolve(error);
|
|
351
|
+
} else {
|
|
352
|
+
serializeFragmentAssets(key, tracking.boundaryModules, context);
|
|
353
|
+
const styles = collectStreamStyles(key, tracking, headStyles);
|
|
354
|
+
if (styles.length) {
|
|
355
|
+
pushTask(`$dfs("${key}",${styles.length})${!scriptFlushed ? ";" + REPLACE_SCRIPT : ""}`);
|
|
356
|
+
scriptFlushed = true;
|
|
357
|
+
writeTasks();
|
|
358
|
+
for (const url of styles) {
|
|
359
|
+
buffer.write(`<link rel="stylesheet" href="${url}" onload="$dfc('${key}')" onerror="$dfc('${key}')">`);
|
|
360
|
+
}
|
|
361
|
+
buffer.write(`<template id="${key}">${value !== undefined ? value : " "}</template>`);
|
|
362
|
+
} else {
|
|
363
|
+
buffer.write(`<template id="${key}">${value !== undefined ? value : " "}</template>`);
|
|
364
|
+
pushTask(`$df("${key}")${!scriptFlushed ? ";" + REPLACE_SCRIPT : ""}`);
|
|
365
|
+
scriptFlushed = true;
|
|
366
|
+
}
|
|
367
|
+
item.resolve(error);
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
}
|
|
371
|
+
return firstFlushed;
|
|
372
|
+
};
|
|
373
|
+
}
|
|
374
|
+
};
|
|
375
|
+
applyAssetTracking(context, tracking, manifest);
|
|
376
|
+
registerEntryAssets(manifest);
|
|
377
|
+
let html = createRoot(d => {
|
|
378
|
+
dispose = d;
|
|
379
|
+
const res = resolveSSRNode(escape(code()));
|
|
380
|
+
if (!res.h.length) return res.t[0];
|
|
381
|
+
rootHoles = [];
|
|
382
|
+
let out = res.t[0];
|
|
383
|
+
for (let i = 0; i < res.h.length; i++) {
|
|
384
|
+
const id = nextHoleId++;
|
|
385
|
+
rootHoles.push({
|
|
386
|
+
id,
|
|
387
|
+
fn: res.h[i]
|
|
388
|
+
});
|
|
389
|
+
out += `<!--rh${id}-->` + res.t[i + 1];
|
|
390
|
+
}
|
|
391
|
+
for (const p of res.p) blockingPromises.add(p);
|
|
392
|
+
return out;
|
|
393
|
+
}, {
|
|
394
|
+
id: renderId
|
|
395
|
+
});
|
|
396
|
+
function doShell() {
|
|
397
|
+
if (shellCompleted) return;
|
|
398
|
+
if (rootHoles) {
|
|
399
|
+
for (const {
|
|
400
|
+
id,
|
|
401
|
+
fn
|
|
402
|
+
} of rootHoles) {
|
|
403
|
+
const marker = `<!--rh${id}-->`;
|
|
404
|
+
const res = resolveSSRNode(fn);
|
|
405
|
+
html = html.replace(marker, !res.h.length ? res.t[0] : "");
|
|
406
|
+
}
|
|
407
|
+
rootHoles = null;
|
|
408
|
+
}
|
|
409
|
+
sharedConfig.context = context;
|
|
410
|
+
html = injectAssets(context.assets, html);
|
|
411
|
+
headStyles = new Set();
|
|
412
|
+
for (const url of tracking.emittedAssets) {
|
|
413
|
+
if (url.endsWith(".css")) headStyles.add(url);
|
|
414
|
+
}
|
|
415
|
+
html = injectPreloadLinks(tracking.emittedAssets, html);
|
|
416
|
+
if (tasks.length) html = injectScripts(html, tasks, nonce);
|
|
417
|
+
buffer.write(html);
|
|
418
|
+
tasks = "";
|
|
419
|
+
onCompleteShell && onCompleteShell({
|
|
420
|
+
write(v) {
|
|
421
|
+
!completed && buffer.write(v);
|
|
422
|
+
}
|
|
423
|
+
});
|
|
424
|
+
shellCompleted = true;
|
|
425
|
+
}
|
|
426
|
+
return {
|
|
427
|
+
then(fn) {
|
|
428
|
+
function complete() {
|
|
429
|
+
dispose();
|
|
430
|
+
fn(tmp);
|
|
431
|
+
}
|
|
432
|
+
if (onCompleteAll) {
|
|
433
|
+
let ogComplete = onCompleteAll;
|
|
434
|
+
onCompleteAll = options => {
|
|
435
|
+
ogComplete(options);
|
|
436
|
+
complete();
|
|
437
|
+
};
|
|
438
|
+
} else onCompleteAll = complete;
|
|
439
|
+
queue(flushEnd);
|
|
440
|
+
},
|
|
441
|
+
pipe(w) {
|
|
442
|
+
allSettled(blockingPromises).then(() => {
|
|
443
|
+
setTimeout(() => {
|
|
444
|
+
doShell();
|
|
445
|
+
buffer = writable = w;
|
|
446
|
+
buffer.write(tmp);
|
|
447
|
+
firstFlushed = true;
|
|
448
|
+
if (completed) {
|
|
449
|
+
dispose();
|
|
450
|
+
writable.end();
|
|
451
|
+
} else flushEnd();
|
|
452
|
+
});
|
|
453
|
+
});
|
|
454
|
+
},
|
|
455
|
+
pipeTo(w) {
|
|
456
|
+
return allSettled(blockingPromises).then(() => {
|
|
457
|
+
let resolve;
|
|
458
|
+
const p = new Promise(r => resolve = r);
|
|
459
|
+
setTimeout(() => {
|
|
460
|
+
doShell();
|
|
461
|
+
const encoder = new TextEncoder();
|
|
462
|
+
const writer = w.getWriter();
|
|
463
|
+
writable = {
|
|
464
|
+
end() {
|
|
465
|
+
writer.releaseLock();
|
|
466
|
+
w.close().catch(() => {});
|
|
467
|
+
resolve();
|
|
468
|
+
}
|
|
469
|
+
};
|
|
470
|
+
buffer = {
|
|
471
|
+
write(payload) {
|
|
472
|
+
writer.write(encoder.encode(payload)).catch(() => {});
|
|
473
|
+
}
|
|
474
|
+
};
|
|
475
|
+
buffer.write(tmp);
|
|
476
|
+
firstFlushed = true;
|
|
477
|
+
if (completed) {
|
|
478
|
+
dispose();
|
|
479
|
+
writable.end();
|
|
480
|
+
} else flushEnd();
|
|
481
|
+
});
|
|
482
|
+
return p;
|
|
483
|
+
});
|
|
484
|
+
}
|
|
485
|
+
};
|
|
486
|
+
}
|
|
487
|
+
function HydrationScript(props) {
|
|
488
|
+
const {
|
|
489
|
+
nonce
|
|
490
|
+
} = sharedConfig.context;
|
|
491
|
+
return ssr(generateHydrationScript({
|
|
492
|
+
nonce,
|
|
493
|
+
...props
|
|
494
|
+
}));
|
|
495
|
+
}
|
|
496
|
+
function ssr(t, ...nodes) {
|
|
497
|
+
if (nodes.length) return resolveSSR(t, nodes);
|
|
498
|
+
return {
|
|
499
|
+
t
|
|
500
|
+
};
|
|
501
|
+
}
|
|
502
|
+
function ssrClassName(value) {
|
|
503
|
+
if (!value) return "";
|
|
504
|
+
if (typeof value === "string") return escape(value, true);
|
|
505
|
+
value = classListToObject(value);
|
|
506
|
+
let classKeys = Object.keys(value),
|
|
507
|
+
result = "";
|
|
508
|
+
for (let i = 0, len = classKeys.length; i < len; i++) {
|
|
509
|
+
const key = classKeys[i],
|
|
510
|
+
classValue = !!value[key];
|
|
511
|
+
if (!key || key === "undefined" || !classValue) continue;
|
|
512
|
+
i && (result += " ");
|
|
513
|
+
result += escape(key);
|
|
514
|
+
}
|
|
515
|
+
return result;
|
|
516
|
+
}
|
|
517
|
+
function ssrStyle(value) {
|
|
518
|
+
if (!value) return "";
|
|
519
|
+
if (typeof value === "string") return escape(value, true);
|
|
520
|
+
let result = "";
|
|
521
|
+
const k = Object.keys(value);
|
|
522
|
+
for (let i = 0; i < k.length; i++) {
|
|
523
|
+
const s = k[i];
|
|
524
|
+
const v = value[s];
|
|
525
|
+
if (v != undefined) {
|
|
526
|
+
if (i) result += ";";
|
|
527
|
+
const r = escape(v, true);
|
|
528
|
+
if (r != undefined && r !== "undefined") {
|
|
529
|
+
result += `${s}:${r}`;
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
return result;
|
|
534
|
+
}
|
|
535
|
+
function ssrStyleProperty(name, value) {
|
|
536
|
+
return value != null ? name + value : "";
|
|
537
|
+
}
|
|
538
|
+
function ssrElement(tag, props, children, needsId) {
|
|
539
|
+
if (props == null) props = {};else if (typeof props === "function") props = props();
|
|
540
|
+
const skipChildren = VOID_ELEMENTS.test(tag);
|
|
541
|
+
const keys = Object.keys(props);
|
|
542
|
+
let result = `<${tag}${needsId ? ssrHydrationKey() : ""} `;
|
|
543
|
+
for (let i = 0; i < keys.length; i++) {
|
|
544
|
+
const prop = keys[i];
|
|
545
|
+
if (ChildProperties.has(prop)) {
|
|
546
|
+
if (children === undefined && !skipChildren) children = tag === "script" || tag === "style" || prop === "innerHTML" ? props[prop] : escape(props[prop]);
|
|
547
|
+
continue;
|
|
548
|
+
}
|
|
549
|
+
const value = props[prop];
|
|
550
|
+
if (prop === "style") {
|
|
551
|
+
result += `style="${ssrStyle(value)}"`;
|
|
552
|
+
} else if (prop === "class") {
|
|
553
|
+
result += `class="${ssrClassName(value)}"`;
|
|
554
|
+
} else if (value == undefined || prop === "ref" || prop.slice(0, 2) === "on" || prop.slice(0, 5) === "prop:") {
|
|
555
|
+
continue;
|
|
556
|
+
} else if (typeof value === "boolean") {
|
|
557
|
+
if (!value) continue;
|
|
558
|
+
result += escape(prop);
|
|
559
|
+
} else {
|
|
560
|
+
result += value === "" ? escape(prop) : `${escape(prop)}="${escape(value, true)}"`;
|
|
561
|
+
}
|
|
562
|
+
if (i !== keys.length - 1) result += " ";
|
|
563
|
+
}
|
|
564
|
+
if (skipChildren) return {
|
|
565
|
+
t: result + "/>"
|
|
566
|
+
};
|
|
567
|
+
if (typeof children === "function") children = children();
|
|
568
|
+
return ssr([result + ">", `</${tag}>`], resolveSSRNode(children, undefined, true));
|
|
569
|
+
}
|
|
570
|
+
function ssrAttribute(key, value) {
|
|
571
|
+
return value == null || value === false ? "" : value === true ? ` ${key}` : ` ${key}="${value}"`;
|
|
572
|
+
}
|
|
573
|
+
function ssrHydrationKey() {
|
|
574
|
+
const hk = getHydrationKey();
|
|
575
|
+
return hk ? ` _hk=${hk}` : "";
|
|
576
|
+
}
|
|
577
|
+
function escape(s, attr) {
|
|
578
|
+
const t = typeof s;
|
|
579
|
+
if (t !== "string") {
|
|
580
|
+
if (!attr && Array.isArray(s)) {
|
|
581
|
+
s = s.slice();
|
|
582
|
+
for (let i = 0; i < s.length; i++) s[i] = escape(s[i]);
|
|
583
|
+
return s;
|
|
584
|
+
}
|
|
585
|
+
if (attr && t === "boolean") return s;
|
|
586
|
+
return s;
|
|
587
|
+
}
|
|
588
|
+
const delim = attr ? '"' : "<";
|
|
589
|
+
const escDelim = attr ? """ : "<";
|
|
590
|
+
let iDelim = s.indexOf(delim);
|
|
591
|
+
let iAmp = s.indexOf("&");
|
|
592
|
+
if (iDelim < 0 && iAmp < 0) return s;
|
|
593
|
+
let left = 0,
|
|
594
|
+
out = "";
|
|
595
|
+
while (iDelim >= 0 && iAmp >= 0) {
|
|
596
|
+
if (iDelim < iAmp) {
|
|
597
|
+
if (left < iDelim) out += s.substring(left, iDelim);
|
|
598
|
+
out += escDelim;
|
|
599
|
+
left = iDelim + 1;
|
|
600
|
+
iDelim = s.indexOf(delim, left);
|
|
601
|
+
} else {
|
|
602
|
+
if (left < iAmp) out += s.substring(left, iAmp);
|
|
603
|
+
out += "&";
|
|
604
|
+
left = iAmp + 1;
|
|
605
|
+
iAmp = s.indexOf("&", left);
|
|
606
|
+
}
|
|
607
|
+
}
|
|
608
|
+
if (iDelim >= 0) {
|
|
609
|
+
do {
|
|
610
|
+
if (left < iDelim) out += s.substring(left, iDelim);
|
|
611
|
+
out += escDelim;
|
|
612
|
+
left = iDelim + 1;
|
|
613
|
+
iDelim = s.indexOf(delim, left);
|
|
614
|
+
} while (iDelim >= 0);
|
|
615
|
+
} else while (iAmp >= 0) {
|
|
616
|
+
if (left < iAmp) out += s.substring(left, iAmp);
|
|
617
|
+
out += "&";
|
|
618
|
+
left = iAmp + 1;
|
|
619
|
+
iAmp = s.indexOf("&", left);
|
|
620
|
+
}
|
|
621
|
+
return left < s.length ? out + s.substring(left) : out;
|
|
622
|
+
}
|
|
623
|
+
function mergeProps(...sources) {
|
|
624
|
+
const target = {};
|
|
625
|
+
for (let i = 0; i < sources.length; i++) {
|
|
626
|
+
let source = sources[i];
|
|
627
|
+
if (typeof source === "function") source = source();
|
|
628
|
+
if (source) {
|
|
629
|
+
const descriptors = Object.getOwnPropertyDescriptors(source);
|
|
630
|
+
for (const key in descriptors) {
|
|
631
|
+
if (key in target) continue;
|
|
632
|
+
Object.defineProperty(target, key, {
|
|
633
|
+
enumerable: true,
|
|
634
|
+
get() {
|
|
635
|
+
for (let i = sources.length - 1; i >= 0; i--) {
|
|
636
|
+
const v = (sources[i] || {})[key];
|
|
637
|
+
if (v !== undefined) return v;
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
});
|
|
641
|
+
}
|
|
642
|
+
}
|
|
643
|
+
}
|
|
644
|
+
return target;
|
|
645
|
+
}
|
|
646
|
+
function getHydrationKey() {
|
|
647
|
+
const hydrate = sharedConfig.context;
|
|
648
|
+
return hydrate && !hydrate.noHydrate && sharedConfig.getNextContextId();
|
|
649
|
+
}
|
|
650
|
+
function applyRef(r, element) {
|
|
651
|
+
Array.isArray(r) ? r.flat(Infinity).forEach(f => f && f(element)) : r(element);
|
|
652
|
+
}
|
|
653
|
+
function useAssets(fn) {
|
|
654
|
+
sharedConfig.context.assets.push(() => resolveSSRSync(escape(fn())));
|
|
655
|
+
}
|
|
656
|
+
function getAssets() {
|
|
657
|
+
const assets = sharedConfig.context.assets;
|
|
658
|
+
let out = "";
|
|
659
|
+
for (let i = 0, len = assets.length; i < len; i++) out += assets[i]();
|
|
660
|
+
return out;
|
|
661
|
+
}
|
|
662
|
+
function generateHydrationScript({
|
|
663
|
+
eventNames = ["click", "input"],
|
|
664
|
+
nonce
|
|
665
|
+
} = {}) {
|
|
666
|
+
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-->`;
|
|
667
|
+
}
|
|
668
|
+
function Hydration(props) {
|
|
669
|
+
if (!sharedConfig.context.noHydrate) return props.children;
|
|
670
|
+
const context = sharedConfig.context;
|
|
671
|
+
sharedConfig.context = {
|
|
672
|
+
...context,
|
|
673
|
+
noHydrate: false
|
|
674
|
+
};
|
|
675
|
+
const res = props.children;
|
|
676
|
+
sharedConfig.context = context;
|
|
677
|
+
return res;
|
|
678
|
+
}
|
|
679
|
+
function NoHydration(props) {
|
|
680
|
+
let context = sharedConfig.context;
|
|
681
|
+
if (context) sharedConfig.context = {
|
|
682
|
+
...context,
|
|
683
|
+
noHydrate: true
|
|
684
|
+
};
|
|
685
|
+
const res = props.children;
|
|
686
|
+
if (context) sharedConfig.context = context;
|
|
687
|
+
return res;
|
|
688
|
+
}
|
|
689
|
+
function queue(fn) {
|
|
690
|
+
return Promise.resolve().then(fn);
|
|
691
|
+
}
|
|
692
|
+
function allSettled(promises) {
|
|
693
|
+
let size = promises.size;
|
|
694
|
+
return Promise.allSettled(promises).then(() => {
|
|
695
|
+
if (promises.size !== size) return allSettled(promises);
|
|
696
|
+
return;
|
|
697
|
+
});
|
|
698
|
+
}
|
|
699
|
+
function injectAssets(assets, html) {
|
|
700
|
+
if (!assets || !assets.length) return html;
|
|
701
|
+
let out = "";
|
|
702
|
+
for (let i = 0, len = assets.length; i < len; i++) out += assets[i]();
|
|
703
|
+
const index = html.indexOf("</head>");
|
|
704
|
+
if (index === -1) return html;
|
|
705
|
+
return html.slice(0, index) + out + html.slice(index);
|
|
706
|
+
}
|
|
707
|
+
function injectPreloadLinks(emittedAssets, html, nonce) {
|
|
708
|
+
if (!emittedAssets.size) return html;
|
|
709
|
+
let links = "";
|
|
710
|
+
for (const url of emittedAssets) {
|
|
711
|
+
if (url.endsWith(".css")) {
|
|
712
|
+
links += `<link rel="stylesheet" href="${url}">`;
|
|
713
|
+
} else {
|
|
714
|
+
links += `<link rel="modulepreload" href="${url}">`;
|
|
715
|
+
}
|
|
716
|
+
}
|
|
717
|
+
const index = html.indexOf("</head>");
|
|
718
|
+
if (index === -1) return html;
|
|
719
|
+
return html.slice(0, index) + links + html.slice(index);
|
|
720
|
+
}
|
|
721
|
+
function serializeFragmentAssets(key, boundaryModules, context) {
|
|
722
|
+
const map = boundaryModules.get(key);
|
|
723
|
+
if (!map || !Object.keys(map).length) return;
|
|
724
|
+
context.serialize(key + "_assets", map);
|
|
725
|
+
}
|
|
726
|
+
function propagateBoundaryStyles(childKey, parentKey, tracking) {
|
|
727
|
+
const childStyles = tracking.getBoundaryStyles(childKey);
|
|
728
|
+
if (!childStyles) return;
|
|
729
|
+
let parentStyles = tracking.boundaryStyles.get(parentKey);
|
|
730
|
+
if (!parentStyles) {
|
|
731
|
+
parentStyles = new Set();
|
|
732
|
+
tracking.boundaryStyles.set(parentKey, parentStyles);
|
|
733
|
+
}
|
|
734
|
+
for (const url of childStyles) {
|
|
735
|
+
parentStyles.add(url);
|
|
736
|
+
}
|
|
737
|
+
}
|
|
738
|
+
function collectStreamStyles(key, tracking, headStyles) {
|
|
739
|
+
const styles = tracking.getBoundaryStyles(key);
|
|
740
|
+
if (!styles) return [];
|
|
741
|
+
const result = [];
|
|
742
|
+
for (const url of styles) {
|
|
743
|
+
if (!headStyles || !headStyles.has(url)) {
|
|
744
|
+
result.push(url);
|
|
745
|
+
}
|
|
746
|
+
}
|
|
747
|
+
return result;
|
|
748
|
+
}
|
|
749
|
+
function injectScripts(html, scripts, nonce) {
|
|
750
|
+
const tag = `<script${nonce ? ` nonce="${nonce}"` : ""}>${scripts}</script>`;
|
|
751
|
+
const index = html.indexOf("<!--xs-->");
|
|
752
|
+
if (index > -1) {
|
|
753
|
+
return html.slice(0, index) + tag + html.slice(index);
|
|
754
|
+
}
|
|
755
|
+
return html + tag;
|
|
756
|
+
}
|
|
757
|
+
function waitForFragments(registry, key) {
|
|
758
|
+
for (const k of [...registry.keys()].reverse()) {
|
|
759
|
+
if (key.startsWith(k)) return k;
|
|
760
|
+
}
|
|
761
|
+
return false;
|
|
762
|
+
}
|
|
763
|
+
function replacePlaceholder(html, key, value) {
|
|
764
|
+
const marker = `<template id="pl-${key}">`;
|
|
765
|
+
const close = `<!--pl-${key}-->`;
|
|
766
|
+
const first = html.indexOf(marker);
|
|
767
|
+
if (first === -1) return html;
|
|
768
|
+
const last = html.indexOf(close, first + marker.length);
|
|
769
|
+
return html.slice(0, first) + value + html.slice(last + close.length);
|
|
770
|
+
}
|
|
771
|
+
function classListToObject(classList) {
|
|
772
|
+
if (Array.isArray(classList)) {
|
|
773
|
+
const result = {};
|
|
774
|
+
flattenClassList(classList, result);
|
|
775
|
+
return result;
|
|
776
|
+
}
|
|
777
|
+
return classList;
|
|
778
|
+
}
|
|
779
|
+
function flattenClassList(list, result) {
|
|
780
|
+
for (let i = 0, len = list.length; i < len; i++) {
|
|
781
|
+
const item = list[i];
|
|
782
|
+
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;
|
|
783
|
+
}
|
|
784
|
+
}
|
|
785
|
+
function resolveSSR(template, holes, result = {
|
|
786
|
+
t: [""],
|
|
787
|
+
h: [],
|
|
788
|
+
p: []
|
|
789
|
+
}) {
|
|
790
|
+
for (let i = 0; i < holes.length; i++) {
|
|
791
|
+
const hole = holes[i];
|
|
792
|
+
result.t[result.t.length - 1] += template[i];
|
|
793
|
+
if (hole == null || hole === true || hole === false) continue;
|
|
794
|
+
resolveSSRNode(hole, result);
|
|
795
|
+
}
|
|
796
|
+
result.t[result.t.length - 1] += template[template.length - 1];
|
|
797
|
+
return result;
|
|
798
|
+
}
|
|
799
|
+
function resolveSSRNode(node, result = {
|
|
800
|
+
t: [""],
|
|
801
|
+
h: [],
|
|
802
|
+
p: []
|
|
803
|
+
}, top) {
|
|
804
|
+
const t = typeof node;
|
|
805
|
+
if (t === "string" || t === "number") {
|
|
806
|
+
result.t[result.t.length - 1] += node;
|
|
807
|
+
} else if (node == null || t === "boolean") ; else if (Array.isArray(node)) {
|
|
808
|
+
let prev = {};
|
|
809
|
+
for (let i = 0, len = node.length; i < len; i++) {
|
|
810
|
+
if (!top && typeof prev !== "object" && typeof node[i] !== "object") result.t[result.t.length - 1] += `<!--!$-->`;
|
|
811
|
+
resolveSSRNode(prev = node[i], result);
|
|
812
|
+
}
|
|
813
|
+
} else if (t === "object") {
|
|
814
|
+
if (node.h) {
|
|
815
|
+
result.t[result.t.length - 1] += node.t[0];
|
|
816
|
+
if (node.t.length > 1) {
|
|
817
|
+
result.t.push(...node.t.slice(1));
|
|
818
|
+
result.h.push(...node.h);
|
|
819
|
+
result.p.push(...node.p);
|
|
820
|
+
}
|
|
821
|
+
} else result.t[result.t.length - 1] += node.t;
|
|
822
|
+
} else if (t === "function") {
|
|
823
|
+
try {
|
|
824
|
+
resolveSSRNode(node(), result);
|
|
825
|
+
} catch (err) {
|
|
826
|
+
const p = ssrHandleError(err);
|
|
827
|
+
if (p) {
|
|
828
|
+
result.h.push(node);
|
|
829
|
+
result.p.push(p);
|
|
830
|
+
result.t.push("");
|
|
831
|
+
}
|
|
832
|
+
}
|
|
833
|
+
}
|
|
834
|
+
return result;
|
|
835
|
+
}
|
|
836
|
+
function resolveSSRSync(node) {
|
|
837
|
+
const res = resolveSSRNode(node);
|
|
838
|
+
if (!res.h.length) return res.t[0];
|
|
839
|
+
throw new Error("This value cannot be rendered synchronously. Are you missing a boundary?");
|
|
840
|
+
}
|
|
841
|
+
const RequestContext = Symbol();
|
|
842
|
+
function getRequestEvent() {
|
|
843
|
+
return globalThis[RequestContext] ? globalThis[RequestContext].getStore() || sharedConfig.context && sharedConfig.context.event || console.warn("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;
|
|
844
|
+
}
|
|
845
|
+
function renderToStringAsync(code, options = {}) {
|
|
846
|
+
return new Promise(resolve => renderToStream(code, options).then(resolve));
|
|
847
|
+
}
|
|
848
|
+
function notSup() {
|
|
849
|
+
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>.");
|
|
850
|
+
}
|
|
851
|
+
|
|
852
|
+
const isServer = true;
|
|
853
|
+
const isDev = false;
|
|
854
|
+
function createDynamic(component, props) {
|
|
855
|
+
const o = getOwner();
|
|
856
|
+
if (o?.id != null) getNextChildId(o);
|
|
857
|
+
const memoOwner = createOwner();
|
|
858
|
+
return runWithOwner(memoOwner, () => {
|
|
859
|
+
const comp = component(),
|
|
860
|
+
t = typeof comp;
|
|
861
|
+
if (comp) {
|
|
862
|
+
if (t === "function") return comp(props);else if (t === "string") {
|
|
863
|
+
return ssrElement(comp, props, undefined, true);
|
|
864
|
+
}
|
|
865
|
+
}
|
|
866
|
+
});
|
|
867
|
+
}
|
|
868
|
+
function Dynamic(props) {
|
|
869
|
+
const others = omit(props, "component");
|
|
870
|
+
return createDynamic(() => props.component, others);
|
|
871
|
+
}
|
|
872
|
+
function Portal(props) {
|
|
873
|
+
throw new Error("Portal is not supported on the server");
|
|
874
|
+
}
|
|
875
|
+
|
|
876
|
+
export { ChildProperties, DOMElements, DelegatedEvents, Dynamic, Hydration, HydrationScript, NoHydration, Portal, Properties, RequestContext, SVGElements, SVGNamespace, notSup as addEventListener, applyRef, notSup as assign, notSup as className, createDynamic, notSup as delegateEvents, 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, ssrHydrationKey, ssrStyle, ssrStyleProperty, notSup as style, notSup as template, useAssets };
|