@solidjs/web 2.0.0-experimental.14 → 2.0.0-experimental.16
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/dist/dev.cjs +114 -22
- package/dist/dev.js +112 -20
- package/dist/server.cjs +263 -41
- package/dist/server.js +265 -41
- package/dist/web.cjs +64 -18
- package/dist/web.js +62 -16
- package/package.json +5 -4
- 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 +23 -7
- package/types/core.d.ts +2 -1
- package/types/server-mock.d.ts +33 -1
- package/types/server.d.ts +23 -18
package/dist/server.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { createMemo, sharedConfig, createRoot, ssrHandleError, omit } from 'solid-js';
|
|
2
|
-
export { Errored, For, Loading, Match, Repeat, Show, Switch, createComponent,
|
|
3
|
-
import {
|
|
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
4
|
import { AbortSignalPlugin, CustomEventPlugin, DOMExceptionPlugin, EventPlugin, FormDataPlugin, HeadersPlugin, ReadableStreamPlugin, RequestPlugin, ResponsePlugin, URLSearchParamsPlugin, URLPlugin } from 'seroval-plugins/web';
|
|
5
5
|
|
|
6
6
|
const Properties = /*#__PURE__*/new Set([
|
|
@@ -20,6 +20,9 @@ const DOMElements = /*#__PURE__*/new Set(["html", "base", "head", "link", "meta"
|
|
|
20
20
|
"webview",
|
|
21
21
|
"isindex", "listing", "multicol", "nextid", "noindex", "search"]);
|
|
22
22
|
|
|
23
|
+
const effect = (fn, effectFn, initial) => createRenderEffect(fn, effectFn, initial, {
|
|
24
|
+
transparent: true
|
|
25
|
+
});
|
|
23
26
|
const memo = fn => createMemo(() => fn());
|
|
24
27
|
|
|
25
28
|
const ES2017FLAG = Feature.AggregateError
|
|
@@ -29,13 +32,16 @@ function createSerializer({
|
|
|
29
32
|
onData,
|
|
30
33
|
onDone,
|
|
31
34
|
scopeId,
|
|
32
|
-
onError
|
|
35
|
+
onError,
|
|
36
|
+
plugins: customPlugins
|
|
33
37
|
}) {
|
|
38
|
+
const defaultPlugins = [AbortSignalPlugin,
|
|
39
|
+
CustomEventPlugin, DOMExceptionPlugin, EventPlugin,
|
|
40
|
+
FormDataPlugin, HeadersPlugin, ReadableStreamPlugin, RequestPlugin, ResponsePlugin, URLSearchParamsPlugin, URLPlugin];
|
|
41
|
+
const allPlugins = customPlugins ? [...customPlugins, ...defaultPlugins] : defaultPlugins;
|
|
34
42
|
return new Serializer({
|
|
35
43
|
scopeId,
|
|
36
|
-
plugins:
|
|
37
|
-
CustomEventPlugin, DOMExceptionPlugin, EventPlugin,
|
|
38
|
-
FormDataPlugin, HeadersPlugin, ReadableStreamPlugin, RequestPlugin, ResponsePlugin, URLSearchParamsPlugin, URLPlugin],
|
|
44
|
+
plugins: allPlugins,
|
|
39
45
|
globalIdentifier: GLOBAL_IDENTIFIER,
|
|
40
46
|
disabledFeatures: ES2017FLAG,
|
|
41
47
|
onData,
|
|
@@ -47,17 +53,102 @@ function getLocalHeaderScript(id) {
|
|
|
47
53
|
return getCrossReferenceHeader(id) + ';';
|
|
48
54
|
}
|
|
49
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
|
+
}
|
|
50
139
|
const VOID_ELEMENTS = /^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/i;
|
|
51
|
-
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)}`;
|
|
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)}`;
|
|
52
141
|
function renderToString(code, options = {}) {
|
|
53
142
|
const {
|
|
54
143
|
renderId = "",
|
|
55
144
|
nonce,
|
|
56
|
-
noScripts
|
|
145
|
+
noScripts,
|
|
146
|
+
manifest
|
|
57
147
|
} = options;
|
|
58
148
|
let scripts = "";
|
|
59
149
|
const serializer = createSerializer({
|
|
60
150
|
scopeId: renderId,
|
|
151
|
+
plugins: options.plugins,
|
|
61
152
|
onData(script) {
|
|
62
153
|
if (noScripts) return;
|
|
63
154
|
if (!scripts) {
|
|
@@ -67,6 +158,7 @@ function renderToString(code, options = {}) {
|
|
|
67
158
|
},
|
|
68
159
|
onError: options.onError
|
|
69
160
|
});
|
|
161
|
+
const tracking = createAssetTracking();
|
|
70
162
|
sharedConfig.context = {
|
|
71
163
|
assets: [],
|
|
72
164
|
nonce,
|
|
@@ -74,9 +166,26 @@ function renderToString(code, options = {}) {
|
|
|
74
166
|
resolve: resolveSSRNode,
|
|
75
167
|
ssr: ssr,
|
|
76
168
|
serialize(id, p) {
|
|
77
|
-
|
|
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);
|
|
78
185
|
}
|
|
79
186
|
};
|
|
187
|
+
applyAssetTracking(sharedConfig.context, tracking, manifest);
|
|
188
|
+
registerEntryAssets(manifest);
|
|
80
189
|
let html = createRoot(d => {
|
|
81
190
|
setTimeout(d);
|
|
82
191
|
return resolveSSRSync(escape(code()));
|
|
@@ -86,6 +195,7 @@ function renderToString(code, options = {}) {
|
|
|
86
195
|
sharedConfig.context.noHydrate = true;
|
|
87
196
|
serializer.close();
|
|
88
197
|
html = injectAssets(sharedConfig.context.assets, html);
|
|
198
|
+
html = injectPreloadLinks(tracking.emittedAssets, html);
|
|
89
199
|
if (scripts.length) html = injectScripts(html, scripts, options.nonce);
|
|
90
200
|
return html;
|
|
91
201
|
}
|
|
@@ -95,10 +205,11 @@ function renderToStream(code, options = {}) {
|
|
|
95
205
|
onCompleteShell,
|
|
96
206
|
onCompleteAll,
|
|
97
207
|
renderId = "",
|
|
98
|
-
noScripts
|
|
208
|
+
noScripts,
|
|
209
|
+
manifest
|
|
99
210
|
} = options;
|
|
100
211
|
let dispose;
|
|
101
|
-
const blockingPromises =
|
|
212
|
+
const blockingPromises = new Set();
|
|
102
213
|
const pushTask = task => {
|
|
103
214
|
if (noScripts) return;
|
|
104
215
|
if (!tasks && !firstFlushed) {
|
|
@@ -123,6 +234,7 @@ function renderToStream(code, options = {}) {
|
|
|
123
234
|
};
|
|
124
235
|
const serializer = createSerializer({
|
|
125
236
|
scopeId: options.renderId,
|
|
237
|
+
plugins: options.plugins,
|
|
126
238
|
onData: pushTask,
|
|
127
239
|
onDone,
|
|
128
240
|
onError: options.onError
|
|
@@ -149,18 +261,38 @@ function renderToStream(code, options = {}) {
|
|
|
149
261
|
let completed = false;
|
|
150
262
|
let shellCompleted = false;
|
|
151
263
|
let scriptFlushed = false;
|
|
264
|
+
let headStyles;
|
|
152
265
|
let timer = null;
|
|
266
|
+
let rootHoles = null;
|
|
267
|
+
let nextHoleId = 0;
|
|
153
268
|
let buffer = {
|
|
154
269
|
write(payload) {
|
|
155
270
|
tmp += payload;
|
|
156
271
|
}
|
|
157
272
|
};
|
|
273
|
+
const tracking = createAssetTracking();
|
|
158
274
|
sharedConfig.context = context = {
|
|
159
275
|
async: true,
|
|
160
276
|
assets: [],
|
|
161
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
|
+
},
|
|
162
294
|
block(p) {
|
|
163
|
-
if (!firstFlushed) blockingPromises.
|
|
295
|
+
if (!firstFlushed) blockingPromises.add(p);
|
|
164
296
|
},
|
|
165
297
|
replace(id, payloadFn) {
|
|
166
298
|
if (firstFlushed) return;
|
|
@@ -170,16 +302,12 @@ function renderToStream(code, options = {}) {
|
|
|
170
302
|
const last = html.indexOf(`<!--!$/${id}-->`, first + placeholder.length);
|
|
171
303
|
html = html.slice(0, first) + resolveSSRSync(escape(payloadFn())) + html.slice(last + placeholder.length + 1);
|
|
172
304
|
},
|
|
173
|
-
serialize(id, p,
|
|
174
|
-
|
|
175
|
-
if (!firstFlushed &&
|
|
176
|
-
blockingPromises.
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
}).catch(e => {
|
|
180
|
-
serializer.write(id, e);
|
|
181
|
-
});
|
|
182
|
-
} else if (!serverOnly) serializer.write(id, p);
|
|
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);
|
|
183
311
|
},
|
|
184
312
|
escape: escape,
|
|
185
313
|
resolve: resolveSSRNode,
|
|
@@ -210,18 +338,33 @@ function renderToStream(code, options = {}) {
|
|
|
210
338
|
const parent = registry.get(parentKey);
|
|
211
339
|
parent.children ||= {};
|
|
212
340
|
parent.children[key] = value !== undefined ? value : "";
|
|
341
|
+
serializeFragmentAssets(key, tracking.boundaryModules, context);
|
|
342
|
+
propagateBoundaryStyles(key, parentKey, tracking);
|
|
213
343
|
item.resolve();
|
|
214
344
|
return;
|
|
215
345
|
}
|
|
216
346
|
if (!completed) {
|
|
217
347
|
if (!firstFlushed) {
|
|
218
348
|
queue(() => html = replacePlaceholder(html, key, value !== undefined ? value : ""));
|
|
349
|
+
serializeFragmentAssets(key, tracking.boundaryModules, context);
|
|
219
350
|
item.resolve(error);
|
|
220
351
|
} else {
|
|
221
|
-
|
|
222
|
-
|
|
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
|
+
}
|
|
223
367
|
item.resolve(error);
|
|
224
|
-
scriptFlushed = true;
|
|
225
368
|
}
|
|
226
369
|
}
|
|
227
370
|
}
|
|
@@ -229,16 +372,47 @@ function renderToStream(code, options = {}) {
|
|
|
229
372
|
};
|
|
230
373
|
}
|
|
231
374
|
};
|
|
375
|
+
applyAssetTracking(context, tracking, manifest);
|
|
376
|
+
registerEntryAssets(manifest);
|
|
232
377
|
let html = createRoot(d => {
|
|
233
378
|
dispose = d;
|
|
234
|
-
|
|
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;
|
|
235
393
|
}, {
|
|
236
394
|
id: renderId
|
|
237
395
|
});
|
|
238
396
|
function doShell() {
|
|
239
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
|
+
}
|
|
240
409
|
sharedConfig.context = context;
|
|
241
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);
|
|
242
416
|
if (tasks.length) html = injectScripts(html, tasks, nonce);
|
|
243
417
|
buffer.write(html);
|
|
244
418
|
tasks = "";
|
|
@@ -289,13 +463,13 @@ function renderToStream(code, options = {}) {
|
|
|
289
463
|
writable = {
|
|
290
464
|
end() {
|
|
291
465
|
writer.releaseLock();
|
|
292
|
-
w.close();
|
|
466
|
+
w.close().catch(() => {});
|
|
293
467
|
resolve();
|
|
294
468
|
}
|
|
295
469
|
};
|
|
296
470
|
buffer = {
|
|
297
471
|
write(payload) {
|
|
298
|
-
writer.write(encoder.encode(payload));
|
|
472
|
+
writer.write(encoder.encode(payload)).catch(() => {});
|
|
299
473
|
}
|
|
300
474
|
};
|
|
301
475
|
buffer.write(tmp);
|
|
@@ -473,6 +647,9 @@ function getHydrationKey() {
|
|
|
473
647
|
const hydrate = sharedConfig.context;
|
|
474
648
|
return hydrate && !hydrate.noHydrate && sharedConfig.getNextContextId();
|
|
475
649
|
}
|
|
650
|
+
function applyRef(r, element) {
|
|
651
|
+
Array.isArray(r) ? r.flat(Infinity).forEach(f => f && f(element)) : r(element);
|
|
652
|
+
}
|
|
476
653
|
function useAssets(fn) {
|
|
477
654
|
sharedConfig.context.assets.push(() => resolveSSRSync(escape(fn())));
|
|
478
655
|
}
|
|
@@ -513,9 +690,9 @@ function queue(fn) {
|
|
|
513
690
|
return Promise.resolve().then(fn);
|
|
514
691
|
}
|
|
515
692
|
function allSettled(promises) {
|
|
516
|
-
let
|
|
693
|
+
let size = promises.size;
|
|
517
694
|
return Promise.allSettled(promises).then(() => {
|
|
518
|
-
if (promises.
|
|
695
|
+
if (promises.size !== size) return allSettled(promises);
|
|
519
696
|
return;
|
|
520
697
|
});
|
|
521
698
|
}
|
|
@@ -527,6 +704,48 @@ function injectAssets(assets, html) {
|
|
|
527
704
|
if (index === -1) return html;
|
|
528
705
|
return html.slice(0, index) + out + html.slice(index);
|
|
529
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
|
+
}
|
|
530
749
|
function injectScripts(html, scripts, nonce) {
|
|
531
750
|
const tag = `<script${nonce ? ` nonce="${nonce}"` : ""}>${scripts}</script>`;
|
|
532
751
|
const index = html.indexOf("<!--xs-->");
|
|
@@ -617,14 +836,14 @@ function resolveSSRNode(node, result = {
|
|
|
617
836
|
function resolveSSRSync(node) {
|
|
618
837
|
const res = resolveSSRNode(node);
|
|
619
838
|
if (!res.h.length) return res.t[0];
|
|
620
|
-
throw new Error("This value cannot be rendered synchronously. Are you missing a
|
|
839
|
+
throw new Error("This value cannot be rendered synchronously. Are you missing a boundary?");
|
|
621
840
|
}
|
|
622
841
|
const RequestContext = Symbol();
|
|
623
842
|
function getRequestEvent() {
|
|
624
|
-
return globalThis[RequestContext] ? globalThis[RequestContext].getStore() || sharedConfig.context && sharedConfig.context.event || console.
|
|
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;
|
|
625
844
|
}
|
|
626
845
|
function renderToStringAsync(code, options = {}) {
|
|
627
|
-
return renderToStream(code, options).then(
|
|
846
|
+
return new Promise(resolve => renderToStream(code, options).then(resolve));
|
|
628
847
|
}
|
|
629
848
|
function notSup() {
|
|
630
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>.");
|
|
@@ -633,13 +852,18 @@ function notSup() {
|
|
|
633
852
|
const isServer = true;
|
|
634
853
|
const isDev = false;
|
|
635
854
|
function createDynamic(component, props) {
|
|
636
|
-
const
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
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
|
+
}
|
|
641
865
|
}
|
|
642
|
-
}
|
|
866
|
+
});
|
|
643
867
|
}
|
|
644
868
|
function Dynamic(props) {
|
|
645
869
|
const others = omit(props, "component");
|
|
@@ -649,4 +873,4 @@ function Portal(props) {
|
|
|
649
873
|
throw new Error("Portal is not supported on the server");
|
|
650
874
|
}
|
|
651
875
|
|
|
652
|
-
export { ChildProperties, DOMElements, DelegatedEvents, Dynamic, Hydration, HydrationScript, NoHydration, Portal, Properties, RequestContext, SVGElements, SVGNamespace, notSup as addEventListener, notSup as assign, notSup as className, createDynamic, notSup as delegateEvents, notSup as dynamicProperty, 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 };
|
|
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 };
|