@solidjs/web 2.0.0-rc.11 → 2.0.0-rc.14
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/server.dev.js +705 -151
- package/dist/server.js +604 -123
- package/dist/server.observe.js +617 -124
- package/dist/web.dev.js +102 -41
- package/dist/web.js +75 -37
- package/dist/web.observe.js +75 -39
- package/frames/dist/assets.js +92 -0
- package/frames/dist/bind.dev.js +326 -0
- package/frames/dist/bind.js +295 -0
- package/frames/dist/client.dev.js +693 -919
- package/frames/dist/client.js +636 -917
- package/frames/dist/client.observe.js +637 -917
- package/frames/dist/regions.js +130 -0
- package/frames/dist/server.dev.js +607 -212
- package/frames/dist/server.js +554 -212
- package/frames/dist/server.observe.js +554 -212
- package/frames/dist/trace.js +42 -0
- package/frames/dist/wire.js +133 -0
- package/package.json +30 -3
- package/performance-tracks/dist/performance-tracks.dev.js +2 -1
- package/performance-tracks/dist/performance-tracks.observe.js +2 -1
- package/performance-tracks/types/index.d.ts +8 -6
- package/serialization/dist/decode.js +37 -8
- package/serialization/dist/serialization.js +39 -10
- package/serialization/types/serializer-decode.d.ts +24 -2
- package/server-functions/dist/client.dev.js +178 -72
- package/server-functions/dist/client.js +99 -61
- package/server-functions/dist/client.observe.js +178 -72
- package/server-functions/dist/server.dev.js +117 -56
- package/server-functions/dist/server.js +117 -56
- package/server-functions/dist/server.observe.js +117 -56
- package/skills/server-components/SKILL.md +228 -0
- package/types/client.d.ts +37 -2
- package/types/constants.d.ts +2 -1
- package/types/diagnostics.d.ts +8 -0
- package/types/frames/assets-tier.d.ts +78 -0
- package/types/frames/bind-tier.d.ts +60 -0
- package/types/frames/client.d.ts +37 -3
- package/types/frames/frame-client.d.ts +249 -96
- package/types/frames/frame-container-plugin.d.ts +2 -10
- package/types/frames/frame-sink.d.ts +33 -0
- package/types/frames/frame-transport.d.ts +66 -18
- package/types/frames/regions-tier.d.ts +45 -0
- package/types/frames/serializer-decode.d.ts +24 -2
- package/types/frames/server.d.ts +53 -1
- package/types/frames/trace-tier.d.ts +2 -0
- package/types/frames/tree-rewrite.d.ts +39 -0
- package/types/frames/wire-tier.d.ts +116 -0
- package/types/index.d.ts +38 -0
- package/types/index.server.d.ts +10 -1
- package/types/jsx.d.ts +11 -1
- package/types/observe.d.ts +182 -12
- package/types/request-error-hook.d.ts +5 -0
- package/types/serializer-decode.d.ts +24 -2
- package/types/server-functions/client.d.ts +26 -0
- package/types/server-functions/registry.d.ts +4 -1
- package/types/server-functions/shared.d.ts +12 -8
- package/types/server-mock.d.ts +13 -1
- package/types/server-observe.d.ts +8 -0
- package/types/server.d.ts +125 -12
package/dist/server.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { createRenderEffect, createMemo,
|
|
2
|
-
export { Errored, For, Hydration, Loading, Match, NoHydration, Repeat, Reveal, Show, Switch, createComponent, getOwner, merge as mergeProps,
|
|
3
|
-
import {
|
|
4
|
-
export { ssrScope as scope } from 'solid-js/internal';
|
|
5
|
-
import {
|
|
1
|
+
import { createRenderEffect, createMemo, getOwner, createRoot, $PROXY, onCleanup, runWithOwner, createComponent, omit, getNextChildId, untrack, NotReadyError } from 'solid-js';
|
|
2
|
+
export { Errored, For, Hydration, Loading, Match, NoHydration, Repeat, Reveal, Show, Switch, createComponent, getOwner, merge as mergeProps, untrack } from 'solid-js';
|
|
3
|
+
import { sharedConfig, ssrSanitizeError, reportServerError, viewOf, sourceOwners, ssrHandleError, inServerComponentScope, creationStamp, getProjectionTrace, shareAsyncIterable } from 'solid-js/internal';
|
|
4
|
+
export { ssrScope as scope, sharedConfig } from 'solid-js/internal';
|
|
5
|
+
import { createStream, Serializer, getCrossReferenceHeader, Feature } from 'seroval';
|
|
6
6
|
import { AbortSignalPlugin, CustomEventPlugin, DOMExceptionPlugin, EventPlugin, FormDataPlugin, HeadersPlugin, ReadableStreamPlugin, RequestPlugin, ResponsePlugin, URLSearchParamsPlugin, URLPlugin } from 'seroval-plugins/web';
|
|
7
7
|
|
|
8
8
|
const DOMWithState = {
|
|
@@ -59,6 +59,10 @@ function isHttpNavigationTarget(target) {
|
|
|
59
59
|
return false;
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
|
+
function isEventName(name) {
|
|
63
|
+
let c;
|
|
64
|
+
return name.startsWith("on") && (c = name.charCodeAt(2)) > 64 && c < 91;
|
|
65
|
+
}
|
|
62
66
|
|
|
63
67
|
const transparentOptions = {
|
|
64
68
|
transparent: true,
|
|
@@ -79,6 +83,15 @@ function memo(fn) {
|
|
|
79
83
|
return createMemo(() => fn(), syncOptions);
|
|
80
84
|
}
|
|
81
85
|
|
|
86
|
+
const REQUEST_ERROR_HOOK = Symbol.for("solid-js/server/request-error-hook");
|
|
87
|
+
function hooks() {
|
|
88
|
+
const g = globalThis;
|
|
89
|
+
return g[REQUEST_ERROR_HOOK] || (g[REQUEST_ERROR_HOOK] = new WeakMap());
|
|
90
|
+
}
|
|
91
|
+
function setRequestErrorHook(event, hook) {
|
|
92
|
+
if (hook !== undefined) hooks().set(event, hook);
|
|
93
|
+
}
|
|
94
|
+
|
|
82
95
|
const TRACEPARENT = /^([0-9a-f]{2})-([0-9a-f]{32})-([0-9a-f]{16})-([0-9a-f]{2})(-.*)?$/;
|
|
83
96
|
const ZERO_TRACE = "00000000000000000000000000000000";
|
|
84
97
|
const ZERO_SPAN = "0000000000000000";
|
|
@@ -244,6 +257,96 @@ function traceMetaMarkup(record) {
|
|
|
244
257
|
return markup;
|
|
245
258
|
}
|
|
246
259
|
|
|
260
|
+
const DESCEND = Symbol("descend");
|
|
261
|
+
const CYCLE = {};
|
|
262
|
+
const TRACK = 16;
|
|
263
|
+
function rewriteTree(value, visit, withPath) {
|
|
264
|
+
if (value === null || typeof value !== "object") return value;
|
|
265
|
+
const path = undefined;
|
|
266
|
+
const state = {
|
|
267
|
+
memo: undefined,
|
|
268
|
+
ancestors: undefined
|
|
269
|
+
};
|
|
270
|
+
try {
|
|
271
|
+
return cow(value, visit, path, 0, state);
|
|
272
|
+
} catch (err) {
|
|
273
|
+
if (err !== CYCLE) throw err;
|
|
274
|
+
}
|
|
275
|
+
return clone(value, visit, path, state.memo || (state.memo = new Map()));
|
|
276
|
+
}
|
|
277
|
+
function shape(value) {
|
|
278
|
+
return Array.isArray(value) ? 1 : Object.getPrototypeOf(value) === Object.prototype ? 2 : 0;
|
|
279
|
+
}
|
|
280
|
+
function cow(value, visit, path, depth, state) {
|
|
281
|
+
const memo = state.memo;
|
|
282
|
+
if (memo !== undefined && memo.has(value)) return memo.get(value);
|
|
283
|
+
const r = visit(value, path);
|
|
284
|
+
if (r !== DESCEND) {
|
|
285
|
+
if (r !== value) (memo || (state.memo = new Map())).set(value, r);
|
|
286
|
+
return r;
|
|
287
|
+
}
|
|
288
|
+
const s = shape(value);
|
|
289
|
+
if (s === 0) return value;
|
|
290
|
+
let ancestors;
|
|
291
|
+
if (depth >= TRACK) {
|
|
292
|
+
ancestors = state.ancestors || (state.ancestors = new Set());
|
|
293
|
+
if (ancestors.has(value)) throw CYCLE;
|
|
294
|
+
ancestors.add(value);
|
|
295
|
+
}
|
|
296
|
+
let out = value;
|
|
297
|
+
if (s === 1) {
|
|
298
|
+
for (let i = 0; i < value.length; i++) {
|
|
299
|
+
const c = value[i];
|
|
300
|
+
if (c === null || typeof c !== "object") continue;
|
|
301
|
+
const next = cow(c, visit, undefined , depth + 1, state);
|
|
302
|
+
if (next !== c) {
|
|
303
|
+
if (out === value) out = value.slice();
|
|
304
|
+
out[i] = next;
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
} else {
|
|
308
|
+
for (const k of Object.keys(value)) {
|
|
309
|
+
const c = value[k];
|
|
310
|
+
if (c === null || typeof c !== "object") continue;
|
|
311
|
+
const next = cow(c, visit, undefined , depth + 1, state);
|
|
312
|
+
if (next !== c) {
|
|
313
|
+
if (out === value) out = {
|
|
314
|
+
...value
|
|
315
|
+
};
|
|
316
|
+
out[k] = next;
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
if (ancestors !== undefined) ancestors.delete(value);
|
|
321
|
+
return out;
|
|
322
|
+
}
|
|
323
|
+
function clone(value, visit, path, memo) {
|
|
324
|
+
if (memo.has(value)) return memo.get(value);
|
|
325
|
+
const r = visit(value, path);
|
|
326
|
+
if (r !== DESCEND) {
|
|
327
|
+
memo.set(value, r);
|
|
328
|
+
return r;
|
|
329
|
+
}
|
|
330
|
+
const s = shape(value);
|
|
331
|
+
if (s === 0) return value;
|
|
332
|
+
const out = s === 1 ? value.slice() : {
|
|
333
|
+
...value
|
|
334
|
+
};
|
|
335
|
+
memo.set(value, out);
|
|
336
|
+
if (s === 1) {
|
|
337
|
+
for (let i = 0; i < value.length; i++) {
|
|
338
|
+
const c = value[i];
|
|
339
|
+
if (c !== null && typeof c === "object") out[i] = clone(c, visit, undefined , memo);
|
|
340
|
+
}
|
|
341
|
+
} else {
|
|
342
|
+
for (const k of Object.keys(value)) {
|
|
343
|
+
const c = value[k];
|
|
344
|
+
if (c !== null && typeof c === "object") out[k] = clone(c, visit, undefined , memo);
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
return out;
|
|
348
|
+
}
|
|
349
|
+
|
|
247
350
|
const STATE = Symbol.for("solid.container-trace-state");
|
|
248
351
|
const state = globalThis[STATE] || (globalThis[STATE] = {
|
|
249
352
|
materialized: new WeakMap(),
|
|
@@ -263,32 +366,10 @@ function toBorderForm(value, envelopeContainers) {
|
|
|
263
366
|
if (value == null || typeof value !== "object") return value;
|
|
264
367
|
const share = state.shareIterable;
|
|
265
368
|
if (!share) return value;
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
const next = toBorderForm(value[i]);
|
|
271
|
-
if (next !== value[i]) {
|
|
272
|
-
if (out === value) out = value.slice();
|
|
273
|
-
out[i] = next;
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
return out;
|
|
277
|
-
}
|
|
278
|
-
if (Object.getPrototypeOf(value) === Object.prototype) {
|
|
279
|
-
let out = value;
|
|
280
|
-
for (const key of Object.keys(value)) {
|
|
281
|
-
const next = toBorderForm(value[key]);
|
|
282
|
-
if (next !== value[key]) {
|
|
283
|
-
if (out === value) out = {
|
|
284
|
-
...value
|
|
285
|
-
};
|
|
286
|
-
out[key] = next;
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
return out;
|
|
290
|
-
}
|
|
291
|
-
return value;
|
|
369
|
+
return rewriteTree(value, v => {
|
|
370
|
+
if (share && isShareableIterable(v)) return share(v);
|
|
371
|
+
return DESCEND;
|
|
372
|
+
});
|
|
292
373
|
}
|
|
293
374
|
function isShareableIterable(value) {
|
|
294
375
|
try {
|
|
@@ -299,10 +380,10 @@ function isShareableIterable(value) {
|
|
|
299
380
|
return false;
|
|
300
381
|
}
|
|
301
382
|
}
|
|
302
|
-
function materialize(marker) {
|
|
383
|
+
function materialize(marker, claiming) {
|
|
303
384
|
let value = state.materialized.get(marker.$tr);
|
|
304
385
|
if (value === undefined) {
|
|
305
|
-
value = state.materializeTrace(marker);
|
|
386
|
+
value = state.materializeTrace(marker, claiming);
|
|
306
387
|
state.materialized.set(marker.$tr, value);
|
|
307
388
|
if (value !== null && typeof value === "object") state.materializedValues.add(value);
|
|
308
389
|
}
|
|
@@ -360,23 +441,22 @@ setContainerTraceStreamMint(iterable => {
|
|
|
360
441
|
})();
|
|
361
442
|
return stream;
|
|
362
443
|
});
|
|
363
|
-
const DEFAULT_WEB_PLUGINS = Object.freeze([AbortSignalPlugin,
|
|
444
|
+
const DEFAULT_WEB_PLUGINS = /* @__PURE__ */Object.freeze([AbortSignalPlugin,
|
|
364
445
|
CustomEventPlugin, DOMExceptionPlugin, EventPlugin,
|
|
365
446
|
FormDataPlugin, HeadersPlugin, ReadableStreamPlugin, RequestPlugin, ResponsePlugin, URLSearchParamsPlugin, URLPlugin,
|
|
366
447
|
ContainerTracePlugin]);
|
|
367
448
|
function resolveSerializerPlugins(customPlugins) {
|
|
368
449
|
return customPlugins ? [...customPlugins, ...DEFAULT_WEB_PLUGINS] : [...DEFAULT_WEB_PLUGINS];
|
|
369
450
|
}
|
|
370
|
-
Feature.RegExp;
|
|
371
451
|
|
|
372
|
-
const
|
|
452
|
+
const defaultDisabledFeatures = () => Feature.AggregateError | Feature.BigIntTypedArray;
|
|
373
453
|
const serializeOnlyDisabledFeatures = serializeErrorStacks => (serializeErrorStacks === undefined ? process.env.NODE_ENV === "development" : serializeErrorStacks) ? 0 : Feature.ErrorPrototypeStack;
|
|
374
454
|
const HYDRATION_GLOBAL = "_$HY.r";
|
|
375
455
|
function createSerializer(options) {
|
|
376
456
|
return new Serializer({
|
|
377
457
|
...options,
|
|
378
458
|
plugins: resolveSerializerPlugins(options.plugins),
|
|
379
|
-
disabledFeatures: (options.disabledFeatures === undefined ?
|
|
459
|
+
disabledFeatures: (options.disabledFeatures === undefined ? defaultDisabledFeatures() : options.disabledFeatures) | serializeOnlyDisabledFeatures(options.serializeErrorStacks)
|
|
380
460
|
});
|
|
381
461
|
}
|
|
382
462
|
function createHydrationSerializer({
|
|
@@ -575,7 +655,7 @@ function serializeCookie(name, value, options = {}) {
|
|
|
575
655
|
return cookie;
|
|
576
656
|
}
|
|
577
657
|
const FLASH_COOKIE = "flash";
|
|
578
|
-
const FLASH_MATCHER =
|
|
658
|
+
const FLASH_MATCHER = /(?:^|;\s*)flash=([^;]+)/;
|
|
579
659
|
function hasFlashCookie(cookieHeader) {
|
|
580
660
|
return !!cookieHeader && FLASH_MATCHER.test(cookieHeader);
|
|
581
661
|
}
|
|
@@ -587,7 +667,6 @@ const ERROR_HEADER = "X-Server-Function-Error";
|
|
|
587
667
|
const BODY_FORMAT_HEADER = "X-Server-Function-Format";
|
|
588
668
|
const REDIRECT_HEADER = "X-Server-Function-Redirect";
|
|
589
669
|
const SINGLE_FLIGHT_HEADER = "X-Single-Flight";
|
|
590
|
-
new TextEncoder().encode(":\n\n");
|
|
591
670
|
|
|
592
671
|
const HEAD_ELIGIBLE_TAGS = new Set(["title", "meta", "link", "style", "script", "base"]);
|
|
593
672
|
const HEAD_ATTR_NAME = /^[a-zA-Z_][a-zA-Z0-9_:.-]*$/;
|
|
@@ -687,6 +766,7 @@ function resolveHead(groups) {
|
|
|
687
766
|
return winners;
|
|
688
767
|
}
|
|
689
768
|
|
|
769
|
+
const renderConfig = sharedConfig;
|
|
690
770
|
function joinAssetPath(base, file) {
|
|
691
771
|
if (/^(?:[a-z][a-z0-9+.-]*:)?\/\//i.test(file)) return file;
|
|
692
772
|
if (typeof base !== "string" || !base) base = "/";
|
|
@@ -840,6 +920,7 @@ function applyAssetTracking(context, tracking, manifest, noScripts) {
|
|
|
840
920
|
});
|
|
841
921
|
context.registerModule = tracking.registerModule;
|
|
842
922
|
context.getBoundaryModules = tracking.getBoundaryModules;
|
|
923
|
+
context._lazyAssets = new Map();
|
|
843
924
|
if (typeof manifest === "function") {
|
|
844
925
|
context.resolveAssets = guard(manifest);
|
|
845
926
|
} else if (manifest && typeof manifest.resolve === "function") {
|
|
@@ -1237,7 +1318,7 @@ function flushHeadFragment(registry, boundary, nonce) {
|
|
|
1237
1318
|
const t = winner.tags[i];
|
|
1238
1319
|
const attrs = {};
|
|
1239
1320
|
for (const name in t.props) {
|
|
1240
|
-
if (name === "children" || name === "ref" || name
|
|
1321
|
+
if (name === "children" || name === "ref" || isEventName(name)) continue;
|
|
1241
1322
|
if (!HEAD_ATTR_NAME.test(name)) {
|
|
1242
1323
|
continue;
|
|
1243
1324
|
}
|
|
@@ -1326,7 +1407,7 @@ function nonceAttr(nonce, destination) {
|
|
|
1326
1407
|
function renderHeadAttrHtml(props) {
|
|
1327
1408
|
let attrs = "";
|
|
1328
1409
|
for (const name in props) {
|
|
1329
|
-
if (name === "children" || name === "ref" || name
|
|
1410
|
+
if (name === "children" || name === "ref" || isEventName(name)) continue;
|
|
1330
1411
|
if (!HEAD_ATTR_NAME.test(name)) {
|
|
1331
1412
|
continue;
|
|
1332
1413
|
}
|
|
@@ -1339,7 +1420,7 @@ function renderHeadAttrHtml(props) {
|
|
|
1339
1420
|
function headAttrRecord(props, skipRelHref) {
|
|
1340
1421
|
let attrs = null;
|
|
1341
1422
|
for (const name in props) {
|
|
1342
|
-
if (name === "children" || name === "ref" || name
|
|
1423
|
+
if (name === "children" || name === "ref" || isEventName(name)) continue;
|
|
1343
1424
|
if ((name === "rel" || name === "href")) continue;
|
|
1344
1425
|
if (!HEAD_ATTR_NAME.test(name)) continue;
|
|
1345
1426
|
const v = props[name];
|
|
@@ -1365,10 +1446,13 @@ function useHead(tags) {
|
|
|
1365
1446
|
ctx.registerHeadTags(tags);
|
|
1366
1447
|
}
|
|
1367
1448
|
const VOID_ELEMENTS = /^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/i;
|
|
1449
|
+
const NOT_NAME = /[\0-\x20\x7F-\x9F"'<>/=]/;
|
|
1450
|
+
const TAG_START = /^[a-zA-Z]/;
|
|
1368
1451
|
const tagInfos = /*#__PURE__*/new Map();
|
|
1369
1452
|
function tagInfo(tag) {
|
|
1370
1453
|
let info = tagInfos.get(tag);
|
|
1371
1454
|
if (info === undefined) {
|
|
1455
|
+
if (!TAG_START.test(tag) || NOT_NAME.test(tag)) throw new Error(`"${tag}" is not a valid tag name`);
|
|
1372
1456
|
info = {
|
|
1373
1457
|
open: "<" + tag,
|
|
1374
1458
|
close: "</" + tag + ">",
|
|
@@ -1381,13 +1465,13 @@ function tagInfo(tag) {
|
|
|
1381
1465
|
return info;
|
|
1382
1466
|
}
|
|
1383
1467
|
const safeAttrNames = /*#__PURE__*/new Set();
|
|
1384
|
-
function
|
|
1385
|
-
if (safeAttrNames.has(prop)) return
|
|
1386
|
-
|
|
1387
|
-
if (
|
|
1388
|
-
return
|
|
1468
|
+
function isAttrName(prop) {
|
|
1469
|
+
if (safeAttrNames.has(prop)) return true;
|
|
1470
|
+
if (prop === "" || NOT_NAME.test(prop)) return false;
|
|
1471
|
+
if (safeAttrNames.size < 512) safeAttrNames.add(prop);
|
|
1472
|
+
return true;
|
|
1389
1473
|
}
|
|
1390
|
-
const REPLACE_SCRIPT = `function $df(e){return _$HY.f?_$HY.f(e):$dfr(e)}function $dfr(e,n,o,t){if(!(n=document.getElementById(e)))return 0;if(!(o=document.getElementById("pl-"+e)))return(_$HY.dq=_$HY.dq||{})[e]=1,0;for(;o&&(8!==o.nodeType||o.nodeValue!=="pl-"+e);)t=o.nextSibling,o.remove(),o=t;t=o.parentNode,o.replaceWith(n.content),n.remove(),(_$HY.v=_$HY.v||{})[e]=1,_$HY.fe(e,t),_$HY.hp&&_$HY.hp[e]&&($dh(_$HY.hp[e]),delete _$HY.hp[e]),$dfd();return 1}function $dfl(e,o,n){if(!(o=document.getElementById("pl-"+e)))return(_$HY.dlq=_$HY.dlq||{})[e]=1,0;if(o._$fl)return 1;for(n=o.nextSibling;n;){if(8===n.nodeType&&n.nodeValue==="pl-"+e){o.parentNode&&o.parentNode.insertBefore(o.content.cloneNode(!0),n),o._$fl=1,$dfd();return 1}n=n.nextSibling}return 0}function $dflj(e,i){for(i=0;i<e.length;i++)$dfl(e[i])}function $dfd(e,i){if(e=_$HY.dq){_$HY.dq=0;for(i in e)$df(i)}if(e=_$HY.dlq){_$HY.dlq=0;for(i in e)$dfl(i)}}function $dfs(e,c,d){(_$HY.sc=_$HY.sc||{})[e]=c,d&&((_$HY.sd=_$HY.sd||{})[e]=1)}function $dfg(e,g,i,k){if(!(g=_$HY.sg&&_$HY.sg[e]))return;for(i=0;i<g.length;i++)if(_$HY.sc&&_$HY.sc[g[i]]>0)return;for(i=0;i<g.length;i++)k=g[i],delete _$HY.sg[k],$df(k)}function $dfc(e){if(--_$HY.sc[e]<=0){delete _$HY.sc[e],_$HY.sg&&_$HY.sg[e]?$dfg(e):!(_$HY.sd&&_$HY.sd[e])&&$df(e);_$HY.sd&&delete _$HY.sd[e]}}function $dfj(e,i,n){for(i=0;i<e.length;i++)if(_$HY.sc&&_$HY.sc[e[i]]>0){for(n=0;n<e.length;n++)(_$HY.sg=_$HY.sg||{})[e[n]]=e;return}for(i=0;i<e.length;i++)$df(e[i])}`;
|
|
1474
|
+
const REPLACE_SCRIPT = `function $df(e){return _$HY.f?_$HY.f(e):$dfr(e)}function $dfr(e,n,o,t){if(!(n=document.getElementById(e)))return 0;if(!(o=document.getElementById("pl-"+e)))return(_$HY.dq=_$HY.dq||{})[e]=1,0;for(;o&&(8!==o.nodeType||o.nodeValue!=="pl-"+e);)t=o.nextSibling,o.remove(),o=t;t=o.parentNode,o.replaceWith(n.content),n.remove(),(_$HY.v=_$HY.v||{})[e]=1,_$HY.fe(e,t),_$HY.hp&&_$HY.hp[e]&&($dh(_$HY.hp[e]),delete _$HY.hp[e]),$dfd();return 1}function $dfl(e,o,n){if(!(o=document.getElementById("pl-"+e)))return(_$HY.dlq=_$HY.dlq||{})[e]=1,0;if(o._$fl)return 1;for(n=o.nextSibling;n;){if(8===n.nodeType&&n.nodeValue==="pl-"+e){o.parentNode&&o.parentNode.insertBefore(o.content.cloneNode(!0),n),o._$fl=1,$dfd();return 1}n=n.nextSibling}return 0}function $dflj(e,i){for(i=0;i<e.length;i++)$dfl(e[i])}function $dfd(e,i){if(e=_$HY.dq){_$HY.dq=0;for(i in e)$df(i)}if(e=_$HY.dlq){_$HY.dlq=0;for(i in e)$dfl(i)}}function $dfs(e,c,d){(_$HY.sc=_$HY.sc||{})[e]=c,d&&((_$HY.sd=_$HY.sd||{})[e]=1)}function $dfg(e,g,i,k){if(!(g=_$HY.sg&&_$HY.sg[e]))return;for(i=0;i<g.length;i++)if(_$HY.sc&&_$HY.sc[g[i]]>0)return;for(i=0;i<g.length;i++)k=g[i],delete _$HY.sg[k],$df(k)}function $dfc(e){if(--_$HY.sc[e]<=0){delete _$HY.sc[e],_$HY.sg&&_$HY.sg[e]?$dfg(e):!(_$HY.sd&&_$HY.sd[e])&&$df(e);_$HY.sd&&delete _$HY.sd[e]}}function $dfj(e,i,n){for(i=0;i<e.length;i++)if(_$HY.sc&&_$HY.sc[e[i]]>0){for(n=0;n<e.length;n++)(_$HY.sg=_$HY.sg||{})[e[n]]=e;return}for(i=0;i<e.length;i++)$df(e[i])}function $dfe(e,t,k){(t=e.target)&&t.getAttribute&&!t._$dc&&(k=t.getAttribute("data-dfc"))&&(t._$dc=1,$dfc(k))}document.addEventListener("load",$dfe,!0);document.addEventListener("error",$dfe,!0)`;
|
|
1391
1475
|
const HEAD_SCRIPT = `function $dha(o,i,e,n){for(i=0;i<o.length;i++)e=o[i],"t"==e[0]?((n=document.querySelector("title"))?n.hasAttribute("data-dh")||n.setAttribute("data-dhf",n.textContent):(n=document.createElement("title"),document.head.appendChild(n)),n.textContent=e[1],n.setAttribute("data-dh","title")):"r"==e[0]?$dhr(e[1]):(n=document.createElement(e[2]),Object.keys(e[3]).forEach(function(a){n.setAttribute(a,e[3][a])}),null!=e[4]&&(n.textContent=e[4]),n.setAttribute("data-dh",e[1]),document.head.appendChild(n))}function $dhr(v,l,i){for(l=document.head.querySelectorAll("[data-dh]"),i=0;i<l.length;i++)l[i].getAttribute("data-dh")==v&&l[i].remove()}function $dh(o){_$HY.h?_$HY.h(o):$dha(o)}`;
|
|
1392
1476
|
function renderToString(code, options = {}) {
|
|
1393
1477
|
const {
|
|
@@ -1412,6 +1496,7 @@ function renderToString(code, options = {}) {
|
|
|
1412
1496
|
});
|
|
1413
1497
|
const tracking = createAssetTracking();
|
|
1414
1498
|
const headRegistry = createHeadRegistry();
|
|
1499
|
+
let closed = false;
|
|
1415
1500
|
sharedConfig.context = {
|
|
1416
1501
|
nonce: options.nonce,
|
|
1417
1502
|
escape: escape,
|
|
@@ -1422,7 +1507,7 @@ function renderToString(code, options = {}) {
|
|
|
1422
1507
|
registerHeadTags(headRegistry, sharedConfig.context, tracking, null, nonce, tags);
|
|
1423
1508
|
},
|
|
1424
1509
|
serialize(id, p) {
|
|
1425
|
-
if (
|
|
1510
|
+
if (closed) return;
|
|
1426
1511
|
if (p != null && typeof p === "object" && (typeof p.then === "function" || typeof p[Symbol.asyncIterator] === "function")) {
|
|
1427
1512
|
throw new Error("Cannot serialize async value in renderToString (id: " + id + "). " + "Use renderToStream for async data.");
|
|
1428
1513
|
}
|
|
@@ -1451,20 +1536,25 @@ function renderToString(code, options = {}) {
|
|
|
1451
1536
|
applyAssetTracking(sharedConfig.context, tracking, manifest, noScripts);
|
|
1452
1537
|
registerEntryAssets(manifest);
|
|
1453
1538
|
const context = sharedConfig.context;
|
|
1539
|
+
context.writer = createHydrationWriter(context, () => !closed);
|
|
1454
1540
|
const requestEvent = peekRequestEvent();
|
|
1541
|
+
if (requestEvent) setRequestErrorHook(requestEvent, options.onError);
|
|
1455
1542
|
context.trace = requestEvent ? traceForEvent(requestEvent) : traceFor(context, undefined);
|
|
1456
1543
|
const render = timeDocument(context, context.trace);
|
|
1457
1544
|
let dispose;
|
|
1545
|
+
let rootOwner;
|
|
1458
1546
|
let rendered = false;
|
|
1459
1547
|
try {
|
|
1460
1548
|
const html = createRoot(d => {
|
|
1461
1549
|
dispose = d;
|
|
1550
|
+
rootOwner = claimRenderRoot(context);
|
|
1551
|
+
if (requestEvent) claimEventRender(requestEvent, context);
|
|
1462
1552
|
return resolveSSRSync(escape(code()));
|
|
1463
1553
|
}, {
|
|
1464
1554
|
id: renderId
|
|
1465
1555
|
});
|
|
1466
1556
|
serializeFragmentAssets("", tracking.boundaryModules, sharedConfig.context, renderId);
|
|
1467
|
-
|
|
1557
|
+
closed = true;
|
|
1468
1558
|
serializer.close();
|
|
1469
1559
|
const head = renderShellHead(headRegistry, nonce, null, noScripts, traceMetaMarkup(context.trace));
|
|
1470
1560
|
const document = assembleDocument(resolveSSRSelectValues(html), tracking.emittedAssets, tracking.preloadLinks, tracking.inlineStyles, scripts.length ? scripts : "", nonce, head, onHead);
|
|
@@ -1476,12 +1566,20 @@ function renderToString(code, options = {}) {
|
|
|
1476
1566
|
}
|
|
1477
1567
|
rendered = true;
|
|
1478
1568
|
return document;
|
|
1569
|
+
} catch (err) {
|
|
1570
|
+
reportServerError(err, {
|
|
1571
|
+
kind: "render",
|
|
1572
|
+
handling: "failed"
|
|
1573
|
+
}, null, options.onError);
|
|
1574
|
+
throw err;
|
|
1479
1575
|
} finally {
|
|
1480
|
-
if (render) render
|
|
1576
|
+
if (render) settleRender(render, rootOwner, rendered ? "complete" : "error");
|
|
1481
1577
|
context.trace = undefined;
|
|
1482
1578
|
if (dispose) dispose();
|
|
1483
1579
|
}
|
|
1484
1580
|
}
|
|
1581
|
+
const SHELL_ABANDONED = Symbol();
|
|
1582
|
+
const ABANDON_RENDER = Symbol();
|
|
1485
1583
|
function renderToStream(code, options = {}) {
|
|
1486
1584
|
let {
|
|
1487
1585
|
onCompleteShell,
|
|
@@ -1493,13 +1591,16 @@ function renderToStream(code, options = {}) {
|
|
|
1493
1591
|
} = options;
|
|
1494
1592
|
const nonce = normalizeNonce(options.nonce);
|
|
1495
1593
|
const requestEvent = peekRequestEvent();
|
|
1594
|
+
if (requestEvent) setRequestErrorHook(requestEvent, options.onError);
|
|
1496
1595
|
let dispose;
|
|
1497
1596
|
let dead = false;
|
|
1498
1597
|
let render;
|
|
1598
|
+
let rootOwner;
|
|
1499
1599
|
let serializer;
|
|
1500
1600
|
let disconnected = false;
|
|
1501
1601
|
let failed = false;
|
|
1502
1602
|
let onFailed;
|
|
1603
|
+
let onDisconnectedBeforeShell;
|
|
1503
1604
|
const defuse = p => {
|
|
1504
1605
|
if (p && typeof p.then === "function") p.then(undefined, () => {});
|
|
1505
1606
|
};
|
|
@@ -1518,12 +1619,12 @@ function renderToStream(code, options = {}) {
|
|
|
1518
1619
|
complete(sink);
|
|
1519
1620
|
} : complete;
|
|
1520
1621
|
};
|
|
1521
|
-
const abandon = disconnect => {
|
|
1622
|
+
const abandon = (disconnect, quiet) => {
|
|
1522
1623
|
if (dead) return;
|
|
1523
1624
|
dead = true;
|
|
1524
1625
|
completed = true;
|
|
1525
1626
|
if (disconnect) disconnected = true;
|
|
1526
|
-
if (render) render
|
|
1627
|
+
if (render) settleRender(render, rootOwner, disconnect ? "abandoned" : "error");
|
|
1527
1628
|
const sink = writable;
|
|
1528
1629
|
buffer = {
|
|
1529
1630
|
write() {}
|
|
@@ -1554,13 +1655,13 @@ function renderToStream(code, options = {}) {
|
|
|
1554
1655
|
if (!disconnect) {
|
|
1555
1656
|
failed = true;
|
|
1556
1657
|
onFailed && onFailed(sink);
|
|
1557
|
-
}
|
|
1658
|
+
} else if (!sink && onDisconnectedBeforeShell) onDisconnectedBeforeShell();
|
|
1558
1659
|
};
|
|
1559
1660
|
const failRender = err => {
|
|
1560
1661
|
reportServerError(err, {
|
|
1561
1662
|
kind: "render",
|
|
1562
1663
|
handling: "failed"
|
|
1563
|
-
}, null);
|
|
1664
|
+
}, null, options.onError);
|
|
1564
1665
|
if (!options.onError && ambientServerErrorHook() === undefined) console.error(err);
|
|
1565
1666
|
abandon();
|
|
1566
1667
|
};
|
|
@@ -1654,7 +1755,7 @@ function renderToStream(code, options = {}) {
|
|
|
1654
1755
|
});
|
|
1655
1756
|
writable && writable.end();
|
|
1656
1757
|
completed = true;
|
|
1657
|
-
if (render) render
|
|
1758
|
+
if (render) settleRender(render, rootOwner, "complete");
|
|
1658
1759
|
if (firstFlushed) dispose();
|
|
1659
1760
|
};
|
|
1660
1761
|
const sink = {
|
|
@@ -1671,10 +1772,10 @@ function renderToStream(code, options = {}) {
|
|
|
1671
1772
|
const styleAttr = nonceAttr(nonce, "style");
|
|
1672
1773
|
emitTask(`$dfs("${key}",${styles.links.length},${deferActivation ? 1 : 0})`);
|
|
1673
1774
|
writeTasks();
|
|
1775
|
+
buffer.write(`<template id="${key}">${value}</template>`);
|
|
1674
1776
|
for (const entry of styles.links) {
|
|
1675
|
-
buffer.write(typeof entry === "string" ? `<link rel="stylesheet" href="${entry}"${styleAttr}
|
|
1777
|
+
buffer.write(typeof entry === "string" ? `<link rel="stylesheet" href="${entry}"${styleAttr} data-dfc="${key}">` : `<link${entry.attrHtml}${styleAttr} data-dfc="${key}">`);
|
|
1676
1778
|
}
|
|
1677
|
-
buffer.write(`<template id="${key}">${value}</template>`);
|
|
1678
1779
|
} else {
|
|
1679
1780
|
buffer.write(`<template id="${key}">${value}</template>`);
|
|
1680
1781
|
if (!deferActivation) {
|
|
@@ -1716,7 +1817,7 @@ function renderToStream(code, options = {}) {
|
|
|
1716
1817
|
};
|
|
1717
1818
|
let holds = 0;
|
|
1718
1819
|
const flushEnd = () => {
|
|
1719
|
-
if (!registry.size && !holds) {
|
|
1820
|
+
if (!registry.size && !holds && !rootHoles) {
|
|
1720
1821
|
serializeRootAssets();
|
|
1721
1822
|
queue(() => queue(() => {
|
|
1722
1823
|
if (context.live.end) {
|
|
@@ -1842,6 +1943,12 @@ function renderToStream(code, options = {}) {
|
|
|
1842
1943
|
}
|
|
1843
1944
|
let rootHoles = null;
|
|
1844
1945
|
let nextHoleId = 0;
|
|
1946
|
+
let parkedInlines = null;
|
|
1947
|
+
function inlineFragment(key, value) {
|
|
1948
|
+
if (rootHoles && !html.includes(`<template id="pl-${key}">`)) {
|
|
1949
|
+
(parkedInlines ||= new Map()).set(key, value);
|
|
1950
|
+
} else html = replacePlaceholder(html, key, value);
|
|
1951
|
+
}
|
|
1845
1952
|
let buffer = {
|
|
1846
1953
|
write(payload) {
|
|
1847
1954
|
tmp += payload;
|
|
@@ -1920,7 +2027,6 @@ function renderToStream(code, options = {}) {
|
|
|
1920
2027
|
html = html.slice(0, first) + resolveSSRSync(escape(payloadFn())) + html.slice(last + placeholder.length + 1);
|
|
1921
2028
|
},
|
|
1922
2029
|
serialize(id, p, deferStream) {
|
|
1923
|
-
if (sharedConfig.context.noHydrate) return;
|
|
1924
2030
|
p = guardChannel(p);
|
|
1925
2031
|
if (p && typeof p === "object" && typeof p.then === "function") {
|
|
1926
2032
|
if (!firstFlushed && deferStream) {
|
|
@@ -1971,11 +2077,16 @@ function renderToStream(code, options = {}) {
|
|
|
1971
2077
|
});
|
|
1972
2078
|
if (canBatchStubs && !shellCompleted && !dead) (stubBatch ||= new Map()).set(key + "_fr", p);else serializer.write(key + "_fr", p);
|
|
1973
2079
|
}
|
|
1974
|
-
return (value, error) => {
|
|
2080
|
+
return (value, error, escaped) => {
|
|
1975
2081
|
if (registry.has(key)) {
|
|
1976
2082
|
const item = registry.get(key);
|
|
1977
2083
|
registry.delete(key);
|
|
1978
2084
|
if (error) abandonSubtree(key);
|
|
2085
|
+
if (error && escaped) {
|
|
2086
|
+
const wire = ssrSanitizeError(error, null);
|
|
2087
|
+
const message = wire instanceof Error ? wire.message : String(wire);
|
|
2088
|
+
if (sink.error) sink.error("", message);else if (context.live && context.live.error) context.live.error(escaped.frame, message);
|
|
2089
|
+
}
|
|
1979
2090
|
if (item.children && !error) {
|
|
1980
2091
|
for (const k in item.children) {
|
|
1981
2092
|
value = replacePlaceholder(value, k, item.children[k]);
|
|
@@ -1995,7 +2106,7 @@ function renderToStream(code, options = {}) {
|
|
|
1995
2106
|
if (!completed) {
|
|
1996
2107
|
if (error) dropHeadBoundary(headRegistry, key);
|
|
1997
2108
|
if (!firstFlushed) {
|
|
1998
|
-
queue(() =>
|
|
2109
|
+
queue(() => inlineFragment(key, value !== undefined ? value : ""));
|
|
1999
2110
|
serializeFragmentAssets(key, tracking.boundaryModules, context);
|
|
2000
2111
|
item.resolve(error);
|
|
2001
2112
|
} else {
|
|
@@ -2037,15 +2148,27 @@ function renderToStream(code, options = {}) {
|
|
|
2037
2148
|
context.trace = requestEvent ? traceForEvent(requestEvent) : traceFor(context, undefined);
|
|
2038
2149
|
render = timeDocument(context, context.trace);
|
|
2039
2150
|
registerEntryAssets(manifest);
|
|
2151
|
+
context.writer = createHydrationWriter(context, () => !completed);
|
|
2040
2152
|
const signal = options.signal;
|
|
2041
|
-
const onAbort = signal ? () => abandon("signal") : undefined;
|
|
2153
|
+
const onAbort = signal ? () => abandon("signal", !!(signal.reason && signal.reason.quiet === true)) : undefined;
|
|
2042
2154
|
let html = createRoot(d => {
|
|
2043
2155
|
dispose = () => {
|
|
2044
2156
|
context.trace = undefined;
|
|
2045
2157
|
if (onAbort) signal.removeEventListener("abort", onAbort);
|
|
2046
2158
|
d();
|
|
2047
2159
|
};
|
|
2048
|
-
|
|
2160
|
+
rootOwner = claimRenderRoot(context);
|
|
2161
|
+
if (requestEvent) claimEventRender(requestEvent, context);
|
|
2162
|
+
let res;
|
|
2163
|
+
try {
|
|
2164
|
+
res = resolveSSRNode(escape(code()));
|
|
2165
|
+
} catch (err) {
|
|
2166
|
+
reportServerError(err, {
|
|
2167
|
+
kind: "render",
|
|
2168
|
+
handling: "failed"
|
|
2169
|
+
}, null, options.onError);
|
|
2170
|
+
throw err;
|
|
2171
|
+
}
|
|
2049
2172
|
if (!res.h.length) return res.t[0];
|
|
2050
2173
|
rootHoles = [];
|
|
2051
2174
|
let out = res.t[0];
|
|
@@ -2092,6 +2215,13 @@ function renderToStream(code, options = {}) {
|
|
|
2092
2215
|
for (const p of res.p) blockingPromises.add(p);
|
|
2093
2216
|
}
|
|
2094
2217
|
}
|
|
2218
|
+
if (parkedInlines) {
|
|
2219
|
+
for (const [key, value] of parkedInlines) {
|
|
2220
|
+
if (!html.includes(`<template id="pl-${key}">`)) continue;
|
|
2221
|
+
html = replacePlaceholder(html, key, value);
|
|
2222
|
+
parkedInlines.delete(key);
|
|
2223
|
+
}
|
|
2224
|
+
}
|
|
2095
2225
|
if (pending.length) {
|
|
2096
2226
|
rootHoles = pending;
|
|
2097
2227
|
return false;
|
|
@@ -2253,11 +2383,16 @@ function renderToStream(code, options = {}) {
|
|
|
2253
2383
|
},
|
|
2254
2384
|
pipe(w) {
|
|
2255
2385
|
claimConsumer("pipe");
|
|
2386
|
+
const abandoned = w[SHELL_ABANDONED];
|
|
2256
2387
|
onFailure(sink => {
|
|
2257
2388
|
try {
|
|
2258
|
-
sink ? sink.end() : w.end();
|
|
2389
|
+
sink ? sink.end() : abandoned ? abandoned() : w.end();
|
|
2259
2390
|
} catch (_) {}
|
|
2260
2391
|
});
|
|
2392
|
+
if (abandoned) {
|
|
2393
|
+
w[ABANDON_RENDER] = abandon;
|
|
2394
|
+
if (disconnected) abandoned();else onDisconnectedBeforeShell = abandoned;
|
|
2395
|
+
}
|
|
2261
2396
|
function flush() {
|
|
2262
2397
|
allSettled(blockingPromises).then(awaited => {
|
|
2263
2398
|
scheduleFlush(() => {
|
|
@@ -2957,14 +3092,16 @@ function ssrClassName(value) {
|
|
|
2957
3092
|
if (typeof value === "number") return "" + value;
|
|
2958
3093
|
if (!value) return "";
|
|
2959
3094
|
if (typeof value === "string") return escape(value, true);
|
|
3095
|
+
if (isSlotValue(value)) return "";
|
|
2960
3096
|
value = classListToObject(value);
|
|
2961
3097
|
let classKeys = Object.keys(value),
|
|
2962
3098
|
result = "";
|
|
2963
3099
|
for (let i = 0, len = classKeys.length; i < len; i++) {
|
|
2964
|
-
const key = classKeys[i]
|
|
2965
|
-
|
|
3100
|
+
const key = classKeys[i];
|
|
3101
|
+
let classValue = value[key];
|
|
3102
|
+
if (isSlotValue(classValue)) classValue = slotValueInline();
|
|
2966
3103
|
if (!key || key === "undefined" || !classValue) continue;
|
|
2967
|
-
|
|
3104
|
+
result && (result += " ");
|
|
2968
3105
|
result += escape(key, true);
|
|
2969
3106
|
}
|
|
2970
3107
|
return result;
|
|
@@ -2972,15 +3109,17 @@ function ssrClassName(value) {
|
|
|
2972
3109
|
function ssrStyle(value) {
|
|
2973
3110
|
if (!value) return "";
|
|
2974
3111
|
if (typeof value === "string") return escape(value, true);
|
|
3112
|
+
if (isSlotValue(value)) return "";
|
|
2975
3113
|
let result = "";
|
|
2976
3114
|
const k = Object.keys(value);
|
|
2977
3115
|
for (let i = 0; i < k.length; i++) {
|
|
2978
3116
|
const s = escape(k[i], true);
|
|
2979
|
-
|
|
3117
|
+
let v = value[k[i]];
|
|
3118
|
+
if (isSlotValue(v)) v = slotValueInline();
|
|
2980
3119
|
if (v != undefined) {
|
|
2981
|
-
if (i) result += ";";
|
|
2982
3120
|
const r = escape(v, true);
|
|
2983
3121
|
if (r != undefined && r !== "undefined") {
|
|
3122
|
+
if (result) result += ";";
|
|
2984
3123
|
result += `${s}:${r}`;
|
|
2985
3124
|
}
|
|
2986
3125
|
}
|
|
@@ -2988,28 +3127,39 @@ function ssrStyle(value) {
|
|
|
2988
3127
|
return result;
|
|
2989
3128
|
}
|
|
2990
3129
|
function ssrStyleProperty(name, value) {
|
|
3130
|
+
if (isSlotValue(value)) value = slotValueInline();
|
|
2991
3131
|
return value != null ? name + value : "";
|
|
2992
3132
|
}
|
|
2993
|
-
function
|
|
3133
|
+
function ssrStyleProperties(...entries) {
|
|
3134
|
+
let result = "";
|
|
3135
|
+
for (let i = 0; i < entries.length; i += 2) {
|
|
3136
|
+
const entry = ssrStyleProperty(entries[i], entries[i + 1]);
|
|
3137
|
+
if (entry) result = result ? result + ";" + entry : entry;
|
|
3138
|
+
}
|
|
3139
|
+
return result;
|
|
3140
|
+
}
|
|
3141
|
+
function ssrElement(tag, props, children, needsId, skip, attrs, claims) {
|
|
2994
3142
|
const hk = needsId ? ssrHydrationKey() : "";
|
|
2995
3143
|
if (typeof props === "function") props = props();
|
|
2996
3144
|
let sources = null;
|
|
2997
3145
|
let proxy = false;
|
|
2998
3146
|
let viewKeys = null;
|
|
2999
3147
|
let owners = null;
|
|
3148
|
+
let ownerIndex = null;
|
|
3149
|
+
const ctx = renderConfig.context;
|
|
3150
|
+
const slots = ctx !== undefined && ctx.claims !== undefined;
|
|
3000
3151
|
if (Array.isArray(props)) {
|
|
3001
|
-
|
|
3002
|
-
|
|
3003
|
-
|
|
3004
|
-
|
|
3005
|
-
|
|
3006
|
-
|
|
3007
|
-
|
|
3008
|
-
|
|
3009
|
-
|
|
3010
|
-
|
|
3011
|
-
|
|
3012
|
-
if (s != null) sourceOwners(s, viewKeys, owners);
|
|
3152
|
+
if (slots && props.$slot === true) props = slotSpreadSource();else {
|
|
3153
|
+
let i = 0;
|
|
3154
|
+
for (; i < props.length; i++) {
|
|
3155
|
+
const s = props[i];
|
|
3156
|
+
if (s == null || typeof s === "function" || $PROXY in s || slots && s.$slot === true) break;
|
|
3157
|
+
}
|
|
3158
|
+
if (i === props.length) sources = props;else {
|
|
3159
|
+
viewKeys = [];
|
|
3160
|
+
owners = [];
|
|
3161
|
+
if (slots) ownerIndex = [];
|
|
3162
|
+
collectSpreadSources(tag, props, viewKeys, owners, slots, ownerIndex);
|
|
3013
3163
|
}
|
|
3014
3164
|
}
|
|
3015
3165
|
} else if (props == null) {
|
|
@@ -3020,10 +3170,14 @@ function ssrElement(tag, props, children, needsId, skip, attrs) {
|
|
|
3020
3170
|
owners = [];
|
|
3021
3171
|
sourceOwners(props, viewKeys, owners);
|
|
3022
3172
|
} else proxy = true;
|
|
3173
|
+
} else if (slots && props.$slot === true) {
|
|
3174
|
+
props = slotSpreadSource();
|
|
3023
3175
|
}
|
|
3024
3176
|
const info = tagInfo(tag);
|
|
3025
3177
|
const skipChildren = info.isVoid;
|
|
3026
3178
|
let result = info.open + hk;
|
|
3179
|
+
let behaviors = null;
|
|
3180
|
+
let childOwner = null;
|
|
3027
3181
|
const last = sources === null ? 0 : sources.length - 1;
|
|
3028
3182
|
let keysOf = null;
|
|
3029
3183
|
if (sources !== null) {
|
|
@@ -3046,28 +3200,42 @@ function ssrElement(tag, props, children, needsId, skip, attrs) {
|
|
|
3046
3200
|
continue;
|
|
3047
3201
|
}
|
|
3048
3202
|
if (ChildProperties.has(prop)) {
|
|
3049
|
-
if (children === undefined &&
|
|
3203
|
+
if (children === undefined && childOwner === null && !skipChildren) {
|
|
3204
|
+
if (prop === "children") childOwner = props;else children = info.raw || prop === "innerHTML" ? props[prop] : escape(props[prop]);
|
|
3205
|
+
}
|
|
3050
3206
|
continue;
|
|
3051
3207
|
}
|
|
3052
3208
|
const value = props[prop];
|
|
3053
|
-
if (value == undefined
|
|
3209
|
+
if (value == undefined) {
|
|
3210
|
+
if (slots && claims !== undefined && (prop === "ref" || isEventName(prop))) behaviors = spreadBehaviorPosition(behaviors, prop, value, ctx.claims, ownerIndex !== null ? ownerIndex[i] : s, true);
|
|
3211
|
+
continue;
|
|
3212
|
+
}
|
|
3213
|
+
if (prop.startsWith("prop:")) {
|
|
3214
|
+
continue;
|
|
3215
|
+
}
|
|
3216
|
+
if (prop === "ref" || isEventName(prop)) {
|
|
3217
|
+
if (slots) behaviors = spreadBehaviorPosition(behaviors, prop, value, ctx.claims, ownerIndex !== null ? ownerIndex[i] : s, claims !== undefined);
|
|
3054
3218
|
continue;
|
|
3219
|
+
}
|
|
3220
|
+
if (slots && typeof value === "object") {
|
|
3221
|
+
result += spreadObjectAttribute(prop, value);
|
|
3055
3222
|
} else if (prop === "style") {
|
|
3056
3223
|
result += ` style="${ssrStyle(value)}"`;
|
|
3057
3224
|
} else if (prop === "class") {
|
|
3058
3225
|
result += ` class="${ssrClassName(value)}"`;
|
|
3059
3226
|
} else if (typeof value === "boolean") {
|
|
3060
|
-
if (
|
|
3061
|
-
|
|
3062
|
-
|
|
3063
|
-
result += value === "" ? ` ${attrName(prop)}` : ` ${attrName(prop)}="${escape(value, true)}"`;
|
|
3227
|
+
if (value && isAttrName(prop)) result += ` ${prop}`;
|
|
3228
|
+
} else if (isAttrName(prop)) {
|
|
3229
|
+
result += value === "" ? ` ${prop}` : ` ${prop}="${escape(value, true)}"`;
|
|
3064
3230
|
}
|
|
3065
3231
|
}
|
|
3066
3232
|
}
|
|
3233
|
+
if (slots && (behaviors !== null || claims !== undefined)) result += spreadBehaviorMarkers(behaviors, claims, ctx.claims);
|
|
3067
3234
|
if (attrs !== undefined) result += typeof attrs === "function" ? attrs() : attrs;
|
|
3068
3235
|
if (skipChildren) return {
|
|
3069
3236
|
t: result + " />"
|
|
3070
3237
|
};
|
|
3238
|
+
if (childOwner !== null) children = info.raw ? childOwner.children : escape(childOwner.children);
|
|
3071
3239
|
if (typeof children === "function") children = children();
|
|
3072
3240
|
const ct = typeof children;
|
|
3073
3241
|
if (ct === "string" || ct === "number") return {
|
|
@@ -3083,43 +3251,251 @@ function ssrElement(tag, props, children, needsId, skip, attrs) {
|
|
|
3083
3251
|
}
|
|
3084
3252
|
function ssrElementAttribute(key, value) {
|
|
3085
3253
|
if (value == undefined) return "";
|
|
3086
|
-
if (key === "style"
|
|
3087
|
-
|
|
3254
|
+
if (key === "style" || key === "class") {
|
|
3255
|
+
return typeof value === "object" ? slotClassOrStyle(key, value) : ` ${key}="${key === "class" ? ssrClassName(value) : ssrStyle(value)}"`;
|
|
3256
|
+
}
|
|
3257
|
+
if (isSlotValue(value)) return slotAttribute(key, value);
|
|
3088
3258
|
if (typeof value === "boolean") return value ? ` ${key}` : "";
|
|
3089
3259
|
return value === "" ? ` ${key}` : ` ${key}="${escape(value, true)}"`;
|
|
3090
3260
|
}
|
|
3091
3261
|
function ssrAttribute(key, value) {
|
|
3092
|
-
|
|
3262
|
+
if (typeof value === "string") return ` ${key}="${value}"`;
|
|
3263
|
+
if (value == null || value === false) return "";
|
|
3264
|
+
if (typeof value === "object") {
|
|
3265
|
+
return isSlotValue(value) ? slotAttribute(key, value) : ` ${key}="${escape(String(value), true)}"`;
|
|
3266
|
+
}
|
|
3267
|
+
if (typeof value === "function") return ` ${key}="${escape(String(value), true)}"`;
|
|
3268
|
+
return value === true ? ` ${key}` : ` ${key}="${value}"`;
|
|
3093
3269
|
}
|
|
3094
3270
|
function ssrHydrationKey() {
|
|
3095
3271
|
const hk = getHydrationKey();
|
|
3096
3272
|
return hk ? ` _hk=${hk}` : "";
|
|
3097
3273
|
}
|
|
3098
|
-
const CLAIM_PROP = /*#__PURE__*/Symbol.for("solid.claim-prop");
|
|
3099
3274
|
const CLAIMS_STREAM = 1;
|
|
3100
3275
|
const CLAIMS_DOCUMENT = 2;
|
|
3101
|
-
const
|
|
3102
|
-
|
|
3103
|
-
|
|
3276
|
+
const SLOT_VALUE = /*#__PURE__*/Symbol.for("solid.slot-value");
|
|
3277
|
+
const SLOT_MARKER = "_s:";
|
|
3278
|
+
const SLOT_FACE_STREAM = 0;
|
|
3279
|
+
const SLOT_FACE_DATA = 1;
|
|
3280
|
+
const SLOT_FACE_MARKUP = 2;
|
|
3281
|
+
function isSlotValue(value) {
|
|
3282
|
+
return value !== null && typeof value === "object" && value[SLOT_VALUE] !== undefined;
|
|
3283
|
+
}
|
|
3284
|
+
function slotValue(occurrence, key, value, face) {
|
|
3285
|
+
const sv = {
|
|
3286
|
+
[SLOT_VALUE]: occurrence,
|
|
3287
|
+
k: key,
|
|
3288
|
+
v: value,
|
|
3289
|
+
f: face
|
|
3290
|
+
};
|
|
3291
|
+
Object.defineProperty(sv, Symbol.toPrimitive, {
|
|
3292
|
+
value: hint => slotValueString()
|
|
3293
|
+
});
|
|
3294
|
+
Object.defineProperty(sv, "toString", {
|
|
3295
|
+
value: () => slotValueString()
|
|
3296
|
+
});
|
|
3297
|
+
Object.defineProperty(sv, "w", {
|
|
3298
|
+
value: () => slotText(sv)
|
|
3299
|
+
});
|
|
3300
|
+
return sv;
|
|
3301
|
+
}
|
|
3302
|
+
function slotValueString(sv, reason) {
|
|
3303
|
+
return "";
|
|
3304
|
+
}
|
|
3305
|
+
function slotText(sv) {
|
|
3306
|
+
const v = sv.f === SLOT_FACE_DATA ? sv.v : undefined;
|
|
3307
|
+
const text = typeof v === "string" || typeof v === "number" ? escape("" + v) : "";
|
|
3308
|
+
return `<!--${SLOT_MARKER}t=${slotEntry(sv)}-->${text}<!--/${SLOT_MARKER}t-->`;
|
|
3309
|
+
}
|
|
3310
|
+
function slotValueInline(kind, sv) {
|
|
3311
|
+
return undefined;
|
|
3312
|
+
}
|
|
3313
|
+
const SLOT_KEY_UNSAFE = /[^A-Za-z0-9_.!~*'()-]/g;
|
|
3314
|
+
function encodeSlotKey(key) {
|
|
3315
|
+
return String(key).replace(SLOT_KEY_UNSAFE, c => encodeURIComponent(c));
|
|
3316
|
+
}
|
|
3317
|
+
function slotEntry(sv, name) {
|
|
3318
|
+
return `${sv[SLOT_VALUE]}:${encodeSlotKey(sv.k)}${name !== undefined ? "=" + encodeSlotKey(name) : ""}`;
|
|
3319
|
+
}
|
|
3320
|
+
function slotMarker(position, entries) {
|
|
3321
|
+
return ` ${SLOT_MARKER}${position}="${entries}"`;
|
|
3322
|
+
}
|
|
3323
|
+
function eventSlotStamp(mode) {
|
|
3324
|
+
return mode === CLAIMS_DOCUMENT ? " _hk" : "";
|
|
3325
|
+
}
|
|
3326
|
+
function slotAttribute(key, sv) {
|
|
3327
|
+
let out = "";
|
|
3328
|
+
if (sv.f === SLOT_FACE_DATA) {
|
|
3329
|
+
const v = sv.v;
|
|
3330
|
+
if (v != null && v !== false) {
|
|
3331
|
+
out = v === true || v === "" ? ` ${key}` : ` ${key}="${escape(String(v), true)}"`;
|
|
3332
|
+
}
|
|
3333
|
+
}
|
|
3334
|
+
return out + slotMarker(key, slotEntry(sv));
|
|
3335
|
+
}
|
|
3336
|
+
function slotClassOrStyle(key, value) {
|
|
3337
|
+
const isClass = key === "class";
|
|
3338
|
+
if (isSlotValue(value)) {
|
|
3339
|
+
let out = "";
|
|
3340
|
+
if (value.f === SLOT_FACE_DATA && value.v != null) {
|
|
3341
|
+
out = ` ${key}="${isClass ? ssrClassName(value.v) : ssrStyle(value.v)}"`;
|
|
3342
|
+
}
|
|
3343
|
+
return out + slotMarker(key, slotEntry(value));
|
|
3344
|
+
}
|
|
3345
|
+
if (typeof value === "object" && value !== null) {
|
|
3346
|
+
const obj = isClass ? classListToObject(value) : value;
|
|
3347
|
+
let entries = "";
|
|
3348
|
+
let inner = "";
|
|
3349
|
+
for (const name of Object.keys(obj)) {
|
|
3350
|
+
let v = obj[name];
|
|
3351
|
+
if (isSlotValue(v)) {
|
|
3352
|
+
entries += (entries ? "," : "") + slotEntry(v, name);
|
|
3353
|
+
v = v.f === SLOT_FACE_DATA ? v.v : undefined;
|
|
3354
|
+
}
|
|
3355
|
+
if (isClass) {
|
|
3356
|
+
if (!name || name === "undefined" || !v) continue;
|
|
3357
|
+
inner += (inner ? " " : "") + escape(name, true);
|
|
3358
|
+
} else if (v != undefined) {
|
|
3359
|
+
const r = escape(v, true);
|
|
3360
|
+
if (r != undefined && r !== "undefined") {
|
|
3361
|
+
inner += (inner ? ";" : "") + `${escape(name, true)}:${r}`;
|
|
3362
|
+
}
|
|
3363
|
+
}
|
|
3364
|
+
}
|
|
3365
|
+
if (entries === "") return ` ${key}="${inner}"`;
|
|
3366
|
+
return (inner ? ` ${key}="${inner}"` : "") + slotMarker(key, entries);
|
|
3367
|
+
}
|
|
3368
|
+
return ` ${key}="${isClass ? ssrClassName(value) : ssrStyle(value)}"`;
|
|
3369
|
+
}
|
|
3370
|
+
function eventPosition(prop) {
|
|
3371
|
+
return prop.slice(2).toLowerCase();
|
|
3372
|
+
}
|
|
3373
|
+
function spreadBehaviorPosition(behaviors, prop, value, mode, index, settle) {
|
|
3374
|
+
if (!isAttrName(prop)) return behaviors;
|
|
3375
|
+
const pos = prop === "ref" ? "ref" : eventPosition(prop);
|
|
3376
|
+
const entries = value == null ? "" : claimEntries(pos, value);
|
|
3377
|
+
if (!settle) {
|
|
3378
|
+
if (entries) (behaviors ||= new Map()).set(pos, entries);
|
|
3379
|
+
return behaviors;
|
|
3380
|
+
}
|
|
3381
|
+
behaviors ||= new Map();
|
|
3382
|
+
const b = behaviors.get(pos);
|
|
3383
|
+
if (b === undefined) behaviors.set(pos, {
|
|
3384
|
+
e: entries,
|
|
3385
|
+
at: index
|
|
3386
|
+
});else {
|
|
3387
|
+
b.e = entries;
|
|
3388
|
+
b.at = index;
|
|
3389
|
+
}
|
|
3390
|
+
return behaviors;
|
|
3391
|
+
}
|
|
3392
|
+
function spreadBehaviorMarkers(behaviors, claims, mode) {
|
|
3393
|
+
if (claims !== undefined) {
|
|
3394
|
+
const segments = claims();
|
|
3395
|
+
for (const k in segments) {
|
|
3396
|
+
const map = segments[k];
|
|
3397
|
+
for (const pos in map) {
|
|
3398
|
+
const value = map[pos];
|
|
3399
|
+
behaviors ||= new Map();
|
|
3400
|
+
const b = behaviors.get(pos);
|
|
3401
|
+
if (pos === "ref") {
|
|
3402
|
+
if (value == null) continue;
|
|
3403
|
+
const entries = claimEntries("ref", value);
|
|
3404
|
+
if (!entries) continue;
|
|
3405
|
+
if (b === undefined) behaviors.set("ref", {
|
|
3406
|
+
e: entries,
|
|
3407
|
+
at: -1
|
|
3408
|
+
});else b.e = b.e ? b.e + "," + entries : entries;
|
|
3409
|
+
continue;
|
|
3410
|
+
}
|
|
3411
|
+
if (b !== undefined && b.at >= +k) continue;
|
|
3412
|
+
const entries = value == null ? "" : claimEntries(pos, value);
|
|
3413
|
+
if (b === undefined) behaviors.set(pos, {
|
|
3414
|
+
e: entries,
|
|
3415
|
+
at: -1
|
|
3416
|
+
});else b.e = entries;
|
|
3417
|
+
}
|
|
3418
|
+
}
|
|
3419
|
+
}
|
|
3420
|
+
let out = "";
|
|
3421
|
+
let events = false;
|
|
3422
|
+
if (behaviors !== null) {
|
|
3423
|
+
for (const [pos, b] of behaviors) {
|
|
3424
|
+
const e = claims === undefined ? b : b.e;
|
|
3425
|
+
if (!e) continue;
|
|
3426
|
+
if (pos === "ref") out += slotMarker("ref", e);else {
|
|
3427
|
+
out += slotMarker("on:" + pos, e);
|
|
3428
|
+
events = true;
|
|
3429
|
+
}
|
|
3430
|
+
}
|
|
3431
|
+
}
|
|
3432
|
+
return events ? out + eventSlotStamp(mode) : out;
|
|
3433
|
+
}
|
|
3434
|
+
function collectSpreadSources(tag, props, viewKeys, owners, slots, ownerIndex) {
|
|
3435
|
+
for (let i = 0; i < props.length; i++) {
|
|
3436
|
+
let s = props[i];
|
|
3437
|
+
if (typeof s === "function") s = s();
|
|
3438
|
+
if (s != null) {
|
|
3439
|
+
if (slots && !($PROXY in s) && s.$slot === true) s = slotSpreadSource();
|
|
3440
|
+
if (ownerIndex === null) sourceOwners(s, viewKeys, owners);else {
|
|
3441
|
+
const ks = [];
|
|
3442
|
+
const os = [];
|
|
3443
|
+
sourceOwners(s, ks, os);
|
|
3444
|
+
for (let j = 0; j < ks.length; j++) {
|
|
3445
|
+
const at = viewKeys.indexOf(ks[j]);
|
|
3446
|
+
if (at !== -1) {
|
|
3447
|
+
viewKeys.splice(at, 1);
|
|
3448
|
+
owners.splice(at, 1);
|
|
3449
|
+
ownerIndex.splice(at, 1);
|
|
3450
|
+
}
|
|
3451
|
+
viewKeys.push(ks[j]);
|
|
3452
|
+
owners.push(os[j]);
|
|
3453
|
+
ownerIndex.push(i);
|
|
3454
|
+
}
|
|
3455
|
+
}
|
|
3456
|
+
}
|
|
3457
|
+
}
|
|
3458
|
+
}
|
|
3459
|
+
function spreadObjectAttribute(prop, value) {
|
|
3460
|
+
if (prop === "style" || prop === "class") return slotClassOrStyle(prop, value);
|
|
3461
|
+
if (!isAttrName(prop)) return "";
|
|
3462
|
+
if (value[SLOT_VALUE] !== undefined) return slotAttribute(prop, value);
|
|
3463
|
+
return ` ${prop}="${escape(value, true)}"`;
|
|
3464
|
+
}
|
|
3465
|
+
function slotSpreadSource(tag, source) {
|
|
3466
|
+
return {};
|
|
3104
3467
|
}
|
|
3105
3468
|
function ssrClaim(map) {
|
|
3106
3469
|
const mode = sharedConfig.context && sharedConfig.context.claims;
|
|
3107
|
-
if (!mode
|
|
3108
|
-
return "";
|
|
3109
|
-
}
|
|
3470
|
+
if (!mode) return "";
|
|
3110
3471
|
let out = "";
|
|
3472
|
+
let events = false;
|
|
3111
3473
|
for (const pos in map) {
|
|
3112
|
-
const
|
|
3113
|
-
|
|
3114
|
-
|
|
3115
|
-
|
|
3116
|
-
|
|
3117
|
-
continue;
|
|
3118
|
-
}
|
|
3119
|
-
out += `${out ? "," : ""}${pos}=${encodeClaimKey(prop)}`;
|
|
3474
|
+
const entries = claimEntries(pos, map[pos]);
|
|
3475
|
+
if (!entries) continue;
|
|
3476
|
+
if (pos === "ref") out += slotMarker("ref", entries);else {
|
|
3477
|
+
out += slotMarker("on:" + pos, entries);
|
|
3478
|
+
events = true;
|
|
3120
3479
|
}
|
|
3121
3480
|
}
|
|
3122
|
-
return
|
|
3481
|
+
return events ? out + eventSlotStamp(mode) : out;
|
|
3482
|
+
}
|
|
3483
|
+
function claimEntries(pos, value, mode) {
|
|
3484
|
+
if (Array.isArray(value) && pos !== "ref") {
|
|
3485
|
+
return "";
|
|
3486
|
+
}
|
|
3487
|
+
if (Array.isArray(value)) {
|
|
3488
|
+
let entries = "";
|
|
3489
|
+
for (const v of value) {
|
|
3490
|
+
const inner = claimEntries(pos, v);
|
|
3491
|
+
if (inner) entries += (entries ? "," : "") + inner;
|
|
3492
|
+
}
|
|
3493
|
+
return entries;
|
|
3494
|
+
}
|
|
3495
|
+
if (isSlotValue(value)) {
|
|
3496
|
+
return slotEntry(value);
|
|
3497
|
+
}
|
|
3498
|
+
return "";
|
|
3123
3499
|
}
|
|
3124
3500
|
function decodeSSREntities(s) {
|
|
3125
3501
|
return s.indexOf("&") < 0 ? s : s.replace(/"/g, '"').replace(/</g, "<").replace(/&/g, "&");
|
|
@@ -3241,6 +3617,7 @@ function escape(s, attr) {
|
|
|
3241
3617
|
if (!attr && t === "function") return escapeLate(s);
|
|
3242
3618
|
if (attr) {
|
|
3243
3619
|
if (s == null || t === "boolean" || t === "number") return s;
|
|
3620
|
+
if (t === "object" && s[SLOT_VALUE] !== undefined) return s;
|
|
3244
3621
|
return escape(String(s), attr);
|
|
3245
3622
|
}
|
|
3246
3623
|
return s;
|
|
@@ -3348,7 +3725,7 @@ function generateHydrationScript({
|
|
|
3348
3725
|
eventNames = ["click", "input"],
|
|
3349
3726
|
nonce
|
|
3350
3727
|
} = {}) {
|
|
3351
|
-
return `<script${nonce ? ` nonce="${escape(String(nonce), true)}"` : ""}>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-->`;
|
|
3728
|
+
return `<script${nonce ? ` nonce="${escape(String(nonce), true)}"` : ""}>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:new Proxy({},{set:(r,k,v)=>(v instanceof Promise&&v.catch(()=>{}),r[k]=v,!0)}),fe(){}});</script><!--xs-->`;
|
|
3352
3729
|
}
|
|
3353
3730
|
function queue(fn) {
|
|
3354
3731
|
return Promise.resolve().then(fn);
|
|
@@ -3551,6 +3928,10 @@ function tryResolveString(node, nested) {
|
|
|
3551
3928
|
if (node.h && node.h.length > 0) return {
|
|
3552
3929
|
merge: node
|
|
3553
3930
|
};
|
|
3931
|
+
if (node[SLOT_VALUE] !== undefined) {
|
|
3932
|
+
ssrTextTail = false;
|
|
3933
|
+
return node.w();
|
|
3934
|
+
}
|
|
3554
3935
|
if (node.t === undefined) {
|
|
3555
3936
|
return "";
|
|
3556
3937
|
}
|
|
@@ -3603,6 +3984,9 @@ function resolveSSRNode(node, result = {
|
|
|
3603
3984
|
} else if (node.t !== undefined) {
|
|
3604
3985
|
result.t[result.t.length - 1] += node.t;
|
|
3605
3986
|
ssrTextTail = false;
|
|
3987
|
+
} else if (node[SLOT_VALUE] !== undefined) {
|
|
3988
|
+
result.t[result.t.length - 1] += node.w();
|
|
3989
|
+
ssrTextTail = false;
|
|
3606
3990
|
} else ;
|
|
3607
3991
|
} else if (t === "function") {
|
|
3608
3992
|
const live = sharedConfig.context && sharedConfig.context.liveHoles;
|
|
@@ -3641,7 +4025,7 @@ function serializerErrorHook(hook) {
|
|
|
3641
4025
|
reportServerError(err, {
|
|
3642
4026
|
kind: "render",
|
|
3643
4027
|
handling: "serialize"
|
|
3644
|
-
}, null);
|
|
4028
|
+
}, null, hook);
|
|
3645
4029
|
};
|
|
3646
4030
|
}
|
|
3647
4031
|
function ambientServerErrorHook() {
|
|
@@ -3655,8 +4039,75 @@ function configureServerErrors(config) {
|
|
|
3655
4039
|
}
|
|
3656
4040
|
(g[ServerErrors] ||= {}).hook = config ? config.onError : undefined;
|
|
3657
4041
|
}
|
|
4042
|
+
function reportRequestFailure(error, event) {
|
|
4043
|
+
reportServerError(error, {
|
|
4044
|
+
kind: "request",
|
|
4045
|
+
handling: "failed",
|
|
4046
|
+
event
|
|
4047
|
+
}, null);
|
|
4048
|
+
if (ambientServerErrorHook() === undefined) console.error(error);
|
|
4049
|
+
}
|
|
3658
4050
|
function getRequestEvent() {
|
|
3659
|
-
|
|
4051
|
+
const store = globalThis[RequestContext];
|
|
4052
|
+
if (!store) return undefined;
|
|
4053
|
+
const event = store.getStore();
|
|
4054
|
+
if (event) return event;
|
|
4055
|
+
const ctx = renderContextOf(getOwner());
|
|
4056
|
+
return ctx && ctx.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.");
|
|
4057
|
+
}
|
|
4058
|
+
const RENDER_ROOTS = Symbol.for("@solidjs/web/render-roots");
|
|
4059
|
+
function renderRoots() {
|
|
4060
|
+
const g = globalThis;
|
|
4061
|
+
return g[RENDER_ROOTS] || (g[RENDER_ROOTS] = new WeakMap());
|
|
4062
|
+
}
|
|
4063
|
+
function claimRenderRoot(context) {
|
|
4064
|
+
const owner = getOwner();
|
|
4065
|
+
const roots = renderRoots();
|
|
4066
|
+
roots.set(owner, context);
|
|
4067
|
+
onCleanup(() => roots.delete(owner));
|
|
4068
|
+
return owner;
|
|
4069
|
+
}
|
|
4070
|
+
function settleRender(render, root, outcome) {
|
|
4071
|
+
runWithOwner(root || null, () => render.settle(outcome));
|
|
4072
|
+
}
|
|
4073
|
+
const eventRenders = new WeakMap();
|
|
4074
|
+
function claimEventRender(event, context) {
|
|
4075
|
+
let renders = eventRenders.get(event);
|
|
4076
|
+
if (!renders) eventRenders.set(event, renders = new Set());
|
|
4077
|
+
renders.add(context);
|
|
4078
|
+
onCleanup(() => renders.delete(context));
|
|
4079
|
+
}
|
|
4080
|
+
function createHydrationWriter(context, isOpen) {
|
|
4081
|
+
const keys = new Set();
|
|
4082
|
+
return {
|
|
4083
|
+
async: !!context.async,
|
|
4084
|
+
write(key, value, options) {
|
|
4085
|
+
if (!isOpen() || keys.has(key)) return false;
|
|
4086
|
+
context.serialize(key, value, options && options.deferStream);
|
|
4087
|
+
keys.add(key);
|
|
4088
|
+
return true;
|
|
4089
|
+
}
|
|
4090
|
+
};
|
|
4091
|
+
}
|
|
4092
|
+
function getHydrationWriter() {
|
|
4093
|
+
let ctx = renderContextOf(getOwner());
|
|
4094
|
+
if (!ctx) {
|
|
4095
|
+
const event = peekRequestEvent();
|
|
4096
|
+
const renders = event && eventRenders.get(event);
|
|
4097
|
+
if (renders && renders.size === 1) for (const c of renders) ctx = c;
|
|
4098
|
+
}
|
|
4099
|
+
return ctx && ctx.writer;
|
|
4100
|
+
}
|
|
4101
|
+
function takeHydrationValue(_key) {
|
|
4102
|
+
return undefined;
|
|
4103
|
+
}
|
|
4104
|
+
function renderContextOf(owner) {
|
|
4105
|
+
const roots = globalThis[RENDER_ROOTS];
|
|
4106
|
+
if (!roots) return undefined;
|
|
4107
|
+
for (; owner; owner = owner._parent) {
|
|
4108
|
+
const context = roots.get(owner);
|
|
4109
|
+
if (context) return context;
|
|
4110
|
+
}
|
|
3660
4111
|
}
|
|
3661
4112
|
function peekRequestEvent() {
|
|
3662
4113
|
const store = globalThis[RequestContext];
|
|
@@ -3668,7 +4119,7 @@ function timeDocument(context, trace, mode, requestEvent) {
|
|
|
3668
4119
|
function getTraceContext() {
|
|
3669
4120
|
const event = peekRequestEvent();
|
|
3670
4121
|
if (event) return traceForEvent(event).context;
|
|
3671
|
-
const ctx =
|
|
4122
|
+
const ctx = renderContextOf(getOwner());
|
|
3672
4123
|
return ctx && ctx.trace ? ctx.trace.context : undefined;
|
|
3673
4124
|
}
|
|
3674
4125
|
function traceForStub(stub, event) {
|
|
@@ -3744,10 +4195,13 @@ function copyInitHeaders(init) {
|
|
|
3744
4195
|
for (const cookie of init.getSetCookie()) headers.append("Set-Cookie", cookie);
|
|
3745
4196
|
return headers;
|
|
3746
4197
|
}
|
|
3747
|
-
|
|
3748
|
-
|
|
4198
|
+
let stubGapFillExcluded;
|
|
4199
|
+
function isStubGapFillExcluded(key) {
|
|
4200
|
+
return (stubGapFillExcluded ||= new Set([ERROR_HEADER, BODY_FORMAT_HEADER, SINGLE_FLIGHT_HEADER, REVALIDATE_HEADER, REDIRECT_HEADER, "Location",
|
|
4201
|
+
...COMPOSED_BODY_FRAMING].map(header => header.toLowerCase()))).has(key);
|
|
4202
|
+
}
|
|
3749
4203
|
function fillsStubGap(key, headers, response) {
|
|
3750
|
-
if (key === "set-cookie" ||
|
|
4204
|
+
if (key === "set-cookie" || isStubGapFillExcluded(key)) return false;
|
|
3751
4205
|
if (response.body === null && (key === "content-type" || key === "content-length")) return false;
|
|
3752
4206
|
return !headers.has(key);
|
|
3753
4207
|
}
|
|
@@ -3839,7 +4293,7 @@ function createSSRResponse(result, event, options = {}) {
|
|
|
3839
4293
|
closed = true;
|
|
3840
4294
|
}
|
|
3841
4295
|
};
|
|
3842
|
-
|
|
4296
|
+
const sink = {
|
|
3843
4297
|
write(chunk) {
|
|
3844
4298
|
if (!flushed) {
|
|
3845
4299
|
flushed = true;
|
|
@@ -3854,6 +4308,7 @@ function createSSRResponse(result, event, options = {}) {
|
|
|
3854
4308
|
status: getExpectedRedirectStatus(stub),
|
|
3855
4309
|
headers: head.headers
|
|
3856
4310
|
}));
|
|
4311
|
+
sink[ABANDON_RENDER]("redirect", true);
|
|
3857
4312
|
return;
|
|
3858
4313
|
}
|
|
3859
4314
|
if (!head.headers.has("content-type")) {
|
|
@@ -3864,7 +4319,9 @@ function createSSRResponse(result, event, options = {}) {
|
|
|
3864
4319
|
controller = c;
|
|
3865
4320
|
},
|
|
3866
4321
|
cancel() {
|
|
4322
|
+
if (closed) return;
|
|
3867
4323
|
closed = true;
|
|
4324
|
+
sink[ABANDON_RENDER]("consumer");
|
|
3868
4325
|
}
|
|
3869
4326
|
}), {
|
|
3870
4327
|
status: head.status,
|
|
@@ -3875,6 +4332,7 @@ function createSSRResponse(result, event, options = {}) {
|
|
|
3875
4332
|
enqueue(transformChunk ? transformChunk(chunk) : chunk);
|
|
3876
4333
|
},
|
|
3877
4334
|
end() {
|
|
4335
|
+
if (!flushed) sink.write("");
|
|
3878
4336
|
if (closed || !controller) return;
|
|
3879
4337
|
const location = stub && stub.headers.get("Location");
|
|
3880
4338
|
if (location && isHttpNavigationTarget(location)) {
|
|
@@ -3885,8 +4343,23 @@ function createSSRResponse(result, event, options = {}) {
|
|
|
3885
4343
|
try {
|
|
3886
4344
|
controller.close();
|
|
3887
4345
|
} catch {}
|
|
3888
|
-
}
|
|
3889
|
-
|
|
4346
|
+
},
|
|
4347
|
+
[SHELL_ABANDONED]() {
|
|
4348
|
+
if (flushed) return;
|
|
4349
|
+
flushed = closed = true;
|
|
4350
|
+
if (stub) commitResponseStub(stub, {
|
|
4351
|
+
event
|
|
4352
|
+
});
|
|
4353
|
+
const head = deriveHead(stub, responseInit);
|
|
4354
|
+
const status = stub && stub.headers.get("Location") ? getExpectedRedirectStatus(stub) : 500;
|
|
4355
|
+
resolve(new Response(null, {
|
|
4356
|
+
status,
|
|
4357
|
+
headers: head.headers
|
|
4358
|
+
}));
|
|
4359
|
+
},
|
|
4360
|
+
[ABANDON_RENDER]() {}
|
|
4361
|
+
};
|
|
4362
|
+
result.pipe(sink);
|
|
3890
4363
|
});
|
|
3891
4364
|
}
|
|
3892
4365
|
function composeMiddleware(middlewares) {
|
|
@@ -3911,6 +4384,9 @@ function claimElement(node) {
|
|
|
3911
4384
|
function claimElementTree(root) {
|
|
3912
4385
|
return root;
|
|
3913
4386
|
}
|
|
4387
|
+
function dispatchAsInteraction(_e, fn) {
|
|
4388
|
+
return fn();
|
|
4389
|
+
}
|
|
3914
4390
|
function notSup() {
|
|
3915
4391
|
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>.");
|
|
3916
4392
|
}
|
|
@@ -3920,10 +4396,17 @@ setAsyncIterableSharer(shareAsyncIterable);
|
|
|
3920
4396
|
const isServer = true;
|
|
3921
4397
|
const isDev = false;
|
|
3922
4398
|
function dynamic(source, options) {
|
|
4399
|
+
return dynamicCore(source, options, ssrTag);
|
|
4400
|
+
}
|
|
4401
|
+
function dynamicComponent(source, options) {
|
|
4402
|
+
return dynamicCore(source, options);
|
|
4403
|
+
}
|
|
4404
|
+
const ssrTag = (tag, props) => ssrElement(tag, props, undefined, true);
|
|
4405
|
+
function dynamicCore(source, options, tagArm) {
|
|
3923
4406
|
if (options?.static) {
|
|
3924
4407
|
const component = untrack(source);
|
|
3925
4408
|
if (typeof component === "function") return props => component(props);
|
|
3926
|
-
if (typeof component === "string") return props =>
|
|
4409
|
+
if (typeof component === "string" && tagArm) return props => tagArm(component, props);
|
|
3927
4410
|
return () => undefined;
|
|
3928
4411
|
}
|
|
3929
4412
|
const cached = createMemo(() => {
|
|
@@ -3969,9 +4452,7 @@ function dynamic(source, options) {
|
|
|
3969
4452
|
const c = value();
|
|
3970
4453
|
if (c) {
|
|
3971
4454
|
if (typeof c === "function") return c(props);
|
|
3972
|
-
if (typeof c === "string")
|
|
3973
|
-
return ssrElement(c, props, undefined, true);
|
|
3974
|
-
}
|
|
4455
|
+
if (typeof c === "string" && tagArm) return tagArm(c, props);
|
|
3975
4456
|
}
|
|
3976
4457
|
}, {
|
|
3977
4458
|
sync: true
|
|
@@ -4113,4 +4594,4 @@ function httpHeader(name, value, options) {
|
|
|
4113
4594
|
}
|
|
4114
4595
|
}
|
|
4115
4596
|
|
|
4116
|
-
export { CLAIMS_DOCUMENT, CLAIMS_STREAM,
|
|
4597
|
+
export { CLAIMS_DOCUMENT, CLAIMS_STREAM, ChildProperties, DOMElements, DOMWithState, DelegatedEvents, Dynamic, HREF, HydrationScript, MathMLElements, NULL_BODY_STATUSES, Namespaces, Portal, RESPONSE_HEADER_VALUE_LIMIT, REVALIDATE_ALL, REVALIDATE_HEADER, RawTextElements, RequestContext, ResponseEnvelope, SAFE_ERROR, SLOT_FACE_DATA, SLOT_FACE_MARKUP, SLOT_FACE_STREAM, SLOT_MARKER, SLOT_VALUE, SVGElements, VoidElements, notSup as acquireAsset, notSup as addEvent, applyRef, notSup as assign, claimElement, claimElementTree, notSup as className, clearFlashCookie, clientOnly, commitEventResponse, commitResponseStub, composeMiddleware, configureServerErrors, createLiveHoles, createRequestEvent, createResponseStub, createSSRResponse, notSup as delegateEvents, dispatchAsInteraction, dynamic, dynamicComponent, notSup as dynamicProperty, effect, escape, generateHydrationScript, notSup as getDelegatedRoot, getExpectedRedirectStatus, getHydrationKey, getHydrationWriter, notSup as getNextElement, notSup as getNextMarker, notSup as getNextMatch, getRequestEvent, getServerFunctionMetadata, getServerFunctionRPC, getTraceContext, hasFlashCookie, httpHeader, httpStatus, notSup as hydrate, notSup as insert, isDev, isHref, isResponseEnvelope, isSafeError, isServer, isServerFunction, isSlotValue, markSafeError, memo, parseCookieHeader, notSup as readShallow, redirect, notSup as ref, notSup as registerDelegatedContainer, notSup as registerDelegatedRoot, registerElementClaim, reload, notSup as render, renderToStream, renderToString, reportRequestFailure, resolveSSRNode, resolveSSRSelectValues, respond, notSup as runHydrationEvents, scriptNonce, serializeCookie, notSup as setAttribute, notSup as setAttributeNS, notSup as setProperty, notSup as setStyleProperty, slotValue, notSup as spread, ssr, ssrAttribute, ssrClaim, ssrClassName, ssrElement, ssrElementAttribute, ssrGroup, ssrHydrationKey, ssrSelectValues, ssrStyle, ssrStyleProperties, ssrStyleProperty, notSup as style, styleNonce, takeHydrationValue, notSup as template, notSup as unregisterDelegatedContainer, notSup as unregisterDelegatedRoot, useHead };
|