@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.observe.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { createRenderEffect, createMemo, OBSERVE, getOwner,
|
|
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, OBSERVE, 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 PROVIDER = Symbol.for("solid-js/observe/server/provider");
|
|
83
96
|
function currentProvider() {
|
|
84
97
|
if (OBSERVE === undefined) return undefined;
|
|
@@ -294,6 +307,7 @@ function observeRender(trace, mode, event) {
|
|
|
294
307
|
};
|
|
295
308
|
trace.render = record;
|
|
296
309
|
let settled = false;
|
|
310
|
+
let route;
|
|
297
311
|
return {
|
|
298
312
|
shell() {
|
|
299
313
|
if (!settled && record.shellMs === undefined) record.shellMs = performance.now() - record.at;
|
|
@@ -301,11 +315,21 @@ function observeRender(trace, mode, event) {
|
|
|
301
315
|
boundary() {
|
|
302
316
|
if (!settled) record.boundaries++;
|
|
303
317
|
},
|
|
318
|
+
route(ref) {
|
|
319
|
+
if (!settled) route = ref;
|
|
320
|
+
},
|
|
304
321
|
settle(outcome) {
|
|
305
322
|
if (settled) return;
|
|
306
323
|
settled = true;
|
|
307
324
|
record.durationMs = performance.now() - record.at;
|
|
308
325
|
record.outcome = outcome;
|
|
326
|
+
if (route !== undefined) {
|
|
327
|
+
const r = {};
|
|
328
|
+
if (route.name !== undefined) r.name = route.name;
|
|
329
|
+
if (route.to !== undefined) r.to = route.to;
|
|
330
|
+
if (route.params !== undefined) r.params = route.params;
|
|
331
|
+
record.route = r;
|
|
332
|
+
}
|
|
309
333
|
const channel = records();
|
|
310
334
|
if (!channel.observed("render")) return;
|
|
311
335
|
const live = {
|
|
@@ -317,6 +341,96 @@ function observeRender(trace, mode, event) {
|
|
|
317
341
|
};
|
|
318
342
|
}
|
|
319
343
|
|
|
344
|
+
const DESCEND = Symbol("descend");
|
|
345
|
+
const CYCLE = {};
|
|
346
|
+
const TRACK = 16;
|
|
347
|
+
function rewriteTree(value, visit, withPath) {
|
|
348
|
+
if (value === null || typeof value !== "object") return value;
|
|
349
|
+
const path = undefined;
|
|
350
|
+
const state = {
|
|
351
|
+
memo: undefined,
|
|
352
|
+
ancestors: undefined
|
|
353
|
+
};
|
|
354
|
+
try {
|
|
355
|
+
return cow(value, visit, path, 0, state);
|
|
356
|
+
} catch (err) {
|
|
357
|
+
if (err !== CYCLE) throw err;
|
|
358
|
+
}
|
|
359
|
+
return clone(value, visit, path, state.memo || (state.memo = new Map()));
|
|
360
|
+
}
|
|
361
|
+
function shape(value) {
|
|
362
|
+
return Array.isArray(value) ? 1 : Object.getPrototypeOf(value) === Object.prototype ? 2 : 0;
|
|
363
|
+
}
|
|
364
|
+
function cow(value, visit, path, depth, state) {
|
|
365
|
+
const memo = state.memo;
|
|
366
|
+
if (memo !== undefined && memo.has(value)) return memo.get(value);
|
|
367
|
+
const r = visit(value, path);
|
|
368
|
+
if (r !== DESCEND) {
|
|
369
|
+
if (r !== value) (memo || (state.memo = new Map())).set(value, r);
|
|
370
|
+
return r;
|
|
371
|
+
}
|
|
372
|
+
const s = shape(value);
|
|
373
|
+
if (s === 0) return value;
|
|
374
|
+
let ancestors;
|
|
375
|
+
if (depth >= TRACK) {
|
|
376
|
+
ancestors = state.ancestors || (state.ancestors = new Set());
|
|
377
|
+
if (ancestors.has(value)) throw CYCLE;
|
|
378
|
+
ancestors.add(value);
|
|
379
|
+
}
|
|
380
|
+
let out = value;
|
|
381
|
+
if (s === 1) {
|
|
382
|
+
for (let i = 0; i < value.length; i++) {
|
|
383
|
+
const c = value[i];
|
|
384
|
+
if (c === null || typeof c !== "object") continue;
|
|
385
|
+
const next = cow(c, visit, undefined , depth + 1, state);
|
|
386
|
+
if (next !== c) {
|
|
387
|
+
if (out === value) out = value.slice();
|
|
388
|
+
out[i] = next;
|
|
389
|
+
}
|
|
390
|
+
}
|
|
391
|
+
} else {
|
|
392
|
+
for (const k of Object.keys(value)) {
|
|
393
|
+
const c = value[k];
|
|
394
|
+
if (c === null || typeof c !== "object") continue;
|
|
395
|
+
const next = cow(c, visit, undefined , depth + 1, state);
|
|
396
|
+
if (next !== c) {
|
|
397
|
+
if (out === value) out = {
|
|
398
|
+
...value
|
|
399
|
+
};
|
|
400
|
+
out[k] = next;
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
}
|
|
404
|
+
if (ancestors !== undefined) ancestors.delete(value);
|
|
405
|
+
return out;
|
|
406
|
+
}
|
|
407
|
+
function clone(value, visit, path, memo) {
|
|
408
|
+
if (memo.has(value)) return memo.get(value);
|
|
409
|
+
const r = visit(value, path);
|
|
410
|
+
if (r !== DESCEND) {
|
|
411
|
+
memo.set(value, r);
|
|
412
|
+
return r;
|
|
413
|
+
}
|
|
414
|
+
const s = shape(value);
|
|
415
|
+
if (s === 0) return value;
|
|
416
|
+
const out = s === 1 ? value.slice() : {
|
|
417
|
+
...value
|
|
418
|
+
};
|
|
419
|
+
memo.set(value, out);
|
|
420
|
+
if (s === 1) {
|
|
421
|
+
for (let i = 0; i < value.length; i++) {
|
|
422
|
+
const c = value[i];
|
|
423
|
+
if (c !== null && typeof c === "object") out[i] = clone(c, visit, undefined , memo);
|
|
424
|
+
}
|
|
425
|
+
} else {
|
|
426
|
+
for (const k of Object.keys(value)) {
|
|
427
|
+
const c = value[k];
|
|
428
|
+
if (c !== null && typeof c === "object") out[k] = clone(c, visit, undefined , memo);
|
|
429
|
+
}
|
|
430
|
+
}
|
|
431
|
+
return out;
|
|
432
|
+
}
|
|
433
|
+
|
|
320
434
|
const STATE = Symbol.for("solid.container-trace-state");
|
|
321
435
|
const state = globalThis[STATE] || (globalThis[STATE] = {
|
|
322
436
|
materialized: new WeakMap(),
|
|
@@ -336,32 +450,10 @@ function toBorderForm(value, envelopeContainers) {
|
|
|
336
450
|
if (value == null || typeof value !== "object") return value;
|
|
337
451
|
const share = state.shareIterable;
|
|
338
452
|
if (!share) return value;
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
const next = toBorderForm(value[i]);
|
|
344
|
-
if (next !== value[i]) {
|
|
345
|
-
if (out === value) out = value.slice();
|
|
346
|
-
out[i] = next;
|
|
347
|
-
}
|
|
348
|
-
}
|
|
349
|
-
return out;
|
|
350
|
-
}
|
|
351
|
-
if (Object.getPrototypeOf(value) === Object.prototype) {
|
|
352
|
-
let out = value;
|
|
353
|
-
for (const key of Object.keys(value)) {
|
|
354
|
-
const next = toBorderForm(value[key]);
|
|
355
|
-
if (next !== value[key]) {
|
|
356
|
-
if (out === value) out = {
|
|
357
|
-
...value
|
|
358
|
-
};
|
|
359
|
-
out[key] = next;
|
|
360
|
-
}
|
|
361
|
-
}
|
|
362
|
-
return out;
|
|
363
|
-
}
|
|
364
|
-
return value;
|
|
453
|
+
return rewriteTree(value, v => {
|
|
454
|
+
if (share && isShareableIterable(v)) return share(v);
|
|
455
|
+
return DESCEND;
|
|
456
|
+
});
|
|
365
457
|
}
|
|
366
458
|
function isShareableIterable(value) {
|
|
367
459
|
try {
|
|
@@ -372,10 +464,10 @@ function isShareableIterable(value) {
|
|
|
372
464
|
return false;
|
|
373
465
|
}
|
|
374
466
|
}
|
|
375
|
-
function materialize(marker) {
|
|
467
|
+
function materialize(marker, claiming) {
|
|
376
468
|
let value = state.materialized.get(marker.$tr);
|
|
377
469
|
if (value === undefined) {
|
|
378
|
-
value = state.materializeTrace(marker);
|
|
470
|
+
value = state.materializeTrace(marker, claiming);
|
|
379
471
|
state.materialized.set(marker.$tr, value);
|
|
380
472
|
if (value !== null && typeof value === "object") state.materializedValues.add(value);
|
|
381
473
|
}
|
|
@@ -433,23 +525,22 @@ setContainerTraceStreamMint(iterable => {
|
|
|
433
525
|
})();
|
|
434
526
|
return stream;
|
|
435
527
|
});
|
|
436
|
-
const DEFAULT_WEB_PLUGINS = Object.freeze([AbortSignalPlugin,
|
|
528
|
+
const DEFAULT_WEB_PLUGINS = /* @__PURE__ */Object.freeze([AbortSignalPlugin,
|
|
437
529
|
CustomEventPlugin, DOMExceptionPlugin, EventPlugin,
|
|
438
530
|
FormDataPlugin, HeadersPlugin, ReadableStreamPlugin, RequestPlugin, ResponsePlugin, URLSearchParamsPlugin, URLPlugin,
|
|
439
531
|
ContainerTracePlugin]);
|
|
440
532
|
function resolveSerializerPlugins(customPlugins) {
|
|
441
533
|
return customPlugins ? [...customPlugins, ...DEFAULT_WEB_PLUGINS] : [...DEFAULT_WEB_PLUGINS];
|
|
442
534
|
}
|
|
443
|
-
Feature.RegExp;
|
|
444
535
|
|
|
445
|
-
const
|
|
536
|
+
const defaultDisabledFeatures = () => Feature.AggregateError | Feature.BigIntTypedArray;
|
|
446
537
|
const serializeOnlyDisabledFeatures = serializeErrorStacks => (serializeErrorStacks === undefined ? process.env.NODE_ENV === "development" : serializeErrorStacks) ? 0 : Feature.ErrorPrototypeStack;
|
|
447
538
|
const HYDRATION_GLOBAL = "_$HY.r";
|
|
448
539
|
function createSerializer(options) {
|
|
449
540
|
return new Serializer({
|
|
450
541
|
...options,
|
|
451
542
|
plugins: resolveSerializerPlugins(options.plugins),
|
|
452
|
-
disabledFeatures: (options.disabledFeatures === undefined ?
|
|
543
|
+
disabledFeatures: (options.disabledFeatures === undefined ? defaultDisabledFeatures() : options.disabledFeatures) | serializeOnlyDisabledFeatures(options.serializeErrorStacks)
|
|
453
544
|
});
|
|
454
545
|
}
|
|
455
546
|
function createHydrationSerializer({
|
|
@@ -648,7 +739,7 @@ function serializeCookie(name, value, options = {}) {
|
|
|
648
739
|
return cookie;
|
|
649
740
|
}
|
|
650
741
|
const FLASH_COOKIE = "flash";
|
|
651
|
-
const FLASH_MATCHER =
|
|
742
|
+
const FLASH_MATCHER = /(?:^|;\s*)flash=([^;]+)/;
|
|
652
743
|
function hasFlashCookie(cookieHeader) {
|
|
653
744
|
return !!cookieHeader && FLASH_MATCHER.test(cookieHeader);
|
|
654
745
|
}
|
|
@@ -660,7 +751,6 @@ const ERROR_HEADER = "X-Server-Function-Error";
|
|
|
660
751
|
const BODY_FORMAT_HEADER = "X-Server-Function-Format";
|
|
661
752
|
const REDIRECT_HEADER = "X-Server-Function-Redirect";
|
|
662
753
|
const SINGLE_FLIGHT_HEADER = "X-Single-Flight";
|
|
663
|
-
new TextEncoder().encode(":\n\n");
|
|
664
754
|
|
|
665
755
|
function emitFinding(finding, subject = getOwner()) {
|
|
666
756
|
if (OBSERVE === undefined) return;
|
|
@@ -772,6 +862,7 @@ function resolveHead(groups) {
|
|
|
772
862
|
return winners;
|
|
773
863
|
}
|
|
774
864
|
|
|
865
|
+
const renderConfig = sharedConfig;
|
|
775
866
|
function joinAssetPath(base, file) {
|
|
776
867
|
if (/^(?:[a-z][a-z0-9+.-]*:)?\/\//i.test(file)) return file;
|
|
777
868
|
if (typeof base !== "string" || !base) base = "/";
|
|
@@ -925,6 +1016,7 @@ function applyAssetTracking(context, tracking, manifest, noScripts) {
|
|
|
925
1016
|
});
|
|
926
1017
|
context.registerModule = tracking.registerModule;
|
|
927
1018
|
context.getBoundaryModules = tracking.getBoundaryModules;
|
|
1019
|
+
context._lazyAssets = new Map();
|
|
928
1020
|
if (typeof manifest === "function") {
|
|
929
1021
|
context.resolveAssets = guard(manifest);
|
|
930
1022
|
} else if (manifest && typeof manifest.resolve === "function") {
|
|
@@ -1322,7 +1414,7 @@ function flushHeadFragment(registry, boundary, nonce) {
|
|
|
1322
1414
|
const t = winner.tags[i];
|
|
1323
1415
|
const attrs = {};
|
|
1324
1416
|
for (const name in t.props) {
|
|
1325
|
-
if (name === "children" || name === "ref" || name
|
|
1417
|
+
if (name === "children" || name === "ref" || isEventName(name)) continue;
|
|
1326
1418
|
if (!HEAD_ATTR_NAME.test(name)) {
|
|
1327
1419
|
continue;
|
|
1328
1420
|
}
|
|
@@ -1411,7 +1503,7 @@ function nonceAttr(nonce, destination) {
|
|
|
1411
1503
|
function renderHeadAttrHtml(props) {
|
|
1412
1504
|
let attrs = "";
|
|
1413
1505
|
for (const name in props) {
|
|
1414
|
-
if (name === "children" || name === "ref" || name
|
|
1506
|
+
if (name === "children" || name === "ref" || isEventName(name)) continue;
|
|
1415
1507
|
if (!HEAD_ATTR_NAME.test(name)) {
|
|
1416
1508
|
continue;
|
|
1417
1509
|
}
|
|
@@ -1424,7 +1516,7 @@ function renderHeadAttrHtml(props) {
|
|
|
1424
1516
|
function headAttrRecord(props, skipRelHref) {
|
|
1425
1517
|
let attrs = null;
|
|
1426
1518
|
for (const name in props) {
|
|
1427
|
-
if (name === "children" || name === "ref" || name
|
|
1519
|
+
if (name === "children" || name === "ref" || isEventName(name)) continue;
|
|
1428
1520
|
if ((name === "rel" || name === "href")) continue;
|
|
1429
1521
|
if (!HEAD_ATTR_NAME.test(name)) continue;
|
|
1430
1522
|
const v = props[name];
|
|
@@ -1450,10 +1542,13 @@ function useHead(tags) {
|
|
|
1450
1542
|
ctx.registerHeadTags(tags);
|
|
1451
1543
|
}
|
|
1452
1544
|
const VOID_ELEMENTS = /^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/i;
|
|
1545
|
+
const NOT_NAME = /[\0-\x20\x7F-\x9F"'<>/=]/;
|
|
1546
|
+
const TAG_START = /^[a-zA-Z]/;
|
|
1453
1547
|
const tagInfos = /*#__PURE__*/new Map();
|
|
1454
1548
|
function tagInfo(tag) {
|
|
1455
1549
|
let info = tagInfos.get(tag);
|
|
1456
1550
|
if (info === undefined) {
|
|
1551
|
+
if (!TAG_START.test(tag) || NOT_NAME.test(tag)) throw new Error(`"${tag}" is not a valid tag name`);
|
|
1457
1552
|
info = {
|
|
1458
1553
|
open: "<" + tag,
|
|
1459
1554
|
close: "</" + tag + ">",
|
|
@@ -1466,13 +1561,13 @@ function tagInfo(tag) {
|
|
|
1466
1561
|
return info;
|
|
1467
1562
|
}
|
|
1468
1563
|
const safeAttrNames = /*#__PURE__*/new Set();
|
|
1469
|
-
function
|
|
1470
|
-
if (safeAttrNames.has(prop)) return
|
|
1471
|
-
|
|
1472
|
-
if (
|
|
1473
|
-
return
|
|
1564
|
+
function isAttrName(prop) {
|
|
1565
|
+
if (safeAttrNames.has(prop)) return true;
|
|
1566
|
+
if (prop === "" || NOT_NAME.test(prop)) return false;
|
|
1567
|
+
if (safeAttrNames.size < 512) safeAttrNames.add(prop);
|
|
1568
|
+
return true;
|
|
1474
1569
|
}
|
|
1475
|
-
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])}`;
|
|
1570
|
+
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)`;
|
|
1476
1571
|
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)}`;
|
|
1477
1572
|
function renderToString(code, options = {}) {
|
|
1478
1573
|
const {
|
|
@@ -1497,6 +1592,7 @@ function renderToString(code, options = {}) {
|
|
|
1497
1592
|
});
|
|
1498
1593
|
const tracking = createAssetTracking();
|
|
1499
1594
|
const headRegistry = createHeadRegistry();
|
|
1595
|
+
let closed = false;
|
|
1500
1596
|
sharedConfig.context = {
|
|
1501
1597
|
nonce: options.nonce,
|
|
1502
1598
|
escape: escape,
|
|
@@ -1507,7 +1603,7 @@ function renderToString(code, options = {}) {
|
|
|
1507
1603
|
registerHeadTags(headRegistry, sharedConfig.context, tracking, null, nonce, tags);
|
|
1508
1604
|
},
|
|
1509
1605
|
serialize(id, p) {
|
|
1510
|
-
if (
|
|
1606
|
+
if (closed) return;
|
|
1511
1607
|
if (p != null && typeof p === "object" && (typeof p.then === "function" || typeof p[Symbol.asyncIterator] === "function")) {
|
|
1512
1608
|
throw new Error("Cannot serialize async value in renderToString (id: " + id + "). " + "Use renderToStream for async data.");
|
|
1513
1609
|
}
|
|
@@ -1536,20 +1632,25 @@ function renderToString(code, options = {}) {
|
|
|
1536
1632
|
applyAssetTracking(sharedConfig.context, tracking, manifest, noScripts);
|
|
1537
1633
|
registerEntryAssets(manifest);
|
|
1538
1634
|
const context = sharedConfig.context;
|
|
1635
|
+
context.writer = createHydrationWriter(context, () => !closed);
|
|
1539
1636
|
const requestEvent = peekRequestEvent();
|
|
1637
|
+
if (requestEvent) setRequestErrorHook(requestEvent, options.onError);
|
|
1540
1638
|
context.trace = requestEvent ? traceForEvent(requestEvent) : traceFor(context, undefined);
|
|
1541
1639
|
const render = timeDocument(context, context.trace, "string", requestEvent);
|
|
1542
1640
|
let dispose;
|
|
1641
|
+
let rootOwner;
|
|
1543
1642
|
let rendered = false;
|
|
1544
1643
|
try {
|
|
1545
1644
|
const html = createRoot(d => {
|
|
1546
1645
|
dispose = d;
|
|
1646
|
+
rootOwner = claimRenderRoot(context);
|
|
1647
|
+
if (requestEvent) claimEventRender(requestEvent, context);
|
|
1547
1648
|
return resolveSSRSync(escape(code()));
|
|
1548
1649
|
}, {
|
|
1549
1650
|
id: renderId
|
|
1550
1651
|
});
|
|
1551
1652
|
serializeFragmentAssets("", tracking.boundaryModules, sharedConfig.context, renderId);
|
|
1552
|
-
|
|
1653
|
+
closed = true;
|
|
1553
1654
|
serializer.close();
|
|
1554
1655
|
const head = renderShellHead(headRegistry, nonce, null, noScripts, traceMetaMarkup(context.trace));
|
|
1555
1656
|
const document = assembleDocument(resolveSSRSelectValues(html), tracking.emittedAssets, tracking.preloadLinks, tracking.inlineStyles, scripts.length ? scripts : "", nonce, head, onHead);
|
|
@@ -1561,12 +1662,20 @@ function renderToString(code, options = {}) {
|
|
|
1561
1662
|
}
|
|
1562
1663
|
rendered = true;
|
|
1563
1664
|
return document;
|
|
1665
|
+
} catch (err) {
|
|
1666
|
+
reportServerError(err, {
|
|
1667
|
+
kind: "render",
|
|
1668
|
+
handling: "failed"
|
|
1669
|
+
}, null, options.onError);
|
|
1670
|
+
throw err;
|
|
1564
1671
|
} finally {
|
|
1565
|
-
if (render) render
|
|
1672
|
+
if (render) settleRender(render, rootOwner, rendered ? "complete" : "error");
|
|
1566
1673
|
context.trace = undefined;
|
|
1567
1674
|
if (dispose) dispose();
|
|
1568
1675
|
}
|
|
1569
1676
|
}
|
|
1677
|
+
const SHELL_ABANDONED = Symbol();
|
|
1678
|
+
const ABANDON_RENDER = Symbol();
|
|
1570
1679
|
function renderToStream(code, options = {}) {
|
|
1571
1680
|
let {
|
|
1572
1681
|
onCompleteShell,
|
|
@@ -1578,13 +1687,16 @@ function renderToStream(code, options = {}) {
|
|
|
1578
1687
|
} = options;
|
|
1579
1688
|
const nonce = normalizeNonce(options.nonce);
|
|
1580
1689
|
const requestEvent = peekRequestEvent();
|
|
1690
|
+
if (requestEvent) setRequestErrorHook(requestEvent, options.onError);
|
|
1581
1691
|
let dispose;
|
|
1582
1692
|
let dead = false;
|
|
1583
1693
|
let render;
|
|
1694
|
+
let rootOwner;
|
|
1584
1695
|
let serializer;
|
|
1585
1696
|
let disconnected = false;
|
|
1586
1697
|
let failed = false;
|
|
1587
1698
|
let onFailed;
|
|
1699
|
+
let onDisconnectedBeforeShell;
|
|
1588
1700
|
const defuse = p => {
|
|
1589
1701
|
if (p && typeof p.then === "function") p.then(undefined, () => {});
|
|
1590
1702
|
};
|
|
@@ -1603,9 +1715,9 @@ function renderToStream(code, options = {}) {
|
|
|
1603
1715
|
complete(sink);
|
|
1604
1716
|
} : complete;
|
|
1605
1717
|
};
|
|
1606
|
-
const abandon = disconnect => {
|
|
1718
|
+
const abandon = (disconnect, quiet) => {
|
|
1607
1719
|
if (dead) return;
|
|
1608
|
-
if (disconnect) emitFinding({
|
|
1720
|
+
if (disconnect && !quiet) emitFinding({
|
|
1609
1721
|
code: "SSR_STREAM_ABANDONED",
|
|
1610
1722
|
kind: "ssr",
|
|
1611
1723
|
severity: "warn",
|
|
@@ -1619,7 +1731,7 @@ function renderToStream(code, options = {}) {
|
|
|
1619
1731
|
dead = true;
|
|
1620
1732
|
completed = true;
|
|
1621
1733
|
if (disconnect) disconnected = true;
|
|
1622
|
-
if (render) render
|
|
1734
|
+
if (render) settleRender(render, rootOwner, disconnect ? "abandoned" : "error");
|
|
1623
1735
|
const sink = writable;
|
|
1624
1736
|
buffer = {
|
|
1625
1737
|
write() {}
|
|
@@ -1650,13 +1762,13 @@ function renderToStream(code, options = {}) {
|
|
|
1650
1762
|
if (!disconnect) {
|
|
1651
1763
|
failed = true;
|
|
1652
1764
|
onFailed && onFailed(sink);
|
|
1653
|
-
}
|
|
1765
|
+
} else if (!sink && onDisconnectedBeforeShell) onDisconnectedBeforeShell();
|
|
1654
1766
|
};
|
|
1655
1767
|
const failRender = err => {
|
|
1656
1768
|
reportServerError(err, {
|
|
1657
1769
|
kind: "render",
|
|
1658
1770
|
handling: "failed"
|
|
1659
|
-
}, null);
|
|
1771
|
+
}, null, options.onError);
|
|
1660
1772
|
if (!options.onError && ambientServerErrorHook() === undefined) console.error(err);
|
|
1661
1773
|
abandon();
|
|
1662
1774
|
};
|
|
@@ -1760,7 +1872,7 @@ function renderToStream(code, options = {}) {
|
|
|
1760
1872
|
});
|
|
1761
1873
|
writable && writable.end();
|
|
1762
1874
|
completed = true;
|
|
1763
|
-
if (render) render
|
|
1875
|
+
if (render) settleRender(render, rootOwner, "complete");
|
|
1764
1876
|
if (firstFlushed) dispose();
|
|
1765
1877
|
};
|
|
1766
1878
|
const sink = {
|
|
@@ -1777,10 +1889,10 @@ function renderToStream(code, options = {}) {
|
|
|
1777
1889
|
const styleAttr = nonceAttr(nonce, "style");
|
|
1778
1890
|
emitTask(`$dfs("${key}",${styles.links.length},${deferActivation ? 1 : 0})`);
|
|
1779
1891
|
writeTasks();
|
|
1892
|
+
buffer.write(`<template id="${key}">${value}</template>`);
|
|
1780
1893
|
for (const entry of styles.links) {
|
|
1781
|
-
buffer.write(typeof entry === "string" ? `<link rel="stylesheet" href="${entry}"${styleAttr}
|
|
1894
|
+
buffer.write(typeof entry === "string" ? `<link rel="stylesheet" href="${entry}"${styleAttr} data-dfc="${key}">` : `<link${entry.attrHtml}${styleAttr} data-dfc="${key}">`);
|
|
1782
1895
|
}
|
|
1783
|
-
buffer.write(`<template id="${key}">${value}</template>`);
|
|
1784
1896
|
} else {
|
|
1785
1897
|
buffer.write(`<template id="${key}">${value}</template>`);
|
|
1786
1898
|
if (!deferActivation) {
|
|
@@ -1822,7 +1934,7 @@ function renderToStream(code, options = {}) {
|
|
|
1822
1934
|
};
|
|
1823
1935
|
let holds = 0;
|
|
1824
1936
|
const flushEnd = () => {
|
|
1825
|
-
if (!registry.size && !holds) {
|
|
1937
|
+
if (!registry.size && !holds && !rootHoles) {
|
|
1826
1938
|
serializeRootAssets();
|
|
1827
1939
|
queue(() => queue(() => {
|
|
1828
1940
|
if (context.live.end) {
|
|
@@ -1964,6 +2076,12 @@ function renderToStream(code, options = {}) {
|
|
|
1964
2076
|
}
|
|
1965
2077
|
let rootHoles = null;
|
|
1966
2078
|
let nextHoleId = 0;
|
|
2079
|
+
let parkedInlines = null;
|
|
2080
|
+
function inlineFragment(key, value) {
|
|
2081
|
+
if (rootHoles && !html.includes(`<template id="pl-${key}">`)) {
|
|
2082
|
+
(parkedInlines ||= new Map()).set(key, value);
|
|
2083
|
+
} else html = replacePlaceholder(html, key, value);
|
|
2084
|
+
}
|
|
1967
2085
|
let buffer = {
|
|
1968
2086
|
write(payload) {
|
|
1969
2087
|
tmp += payload;
|
|
@@ -2042,7 +2160,6 @@ function renderToStream(code, options = {}) {
|
|
|
2042
2160
|
html = html.slice(0, first) + resolveSSRSync(escape(payloadFn())) + html.slice(last + placeholder.length + 1);
|
|
2043
2161
|
},
|
|
2044
2162
|
serialize(id, p, deferStream) {
|
|
2045
|
-
if (sharedConfig.context.noHydrate) return;
|
|
2046
2163
|
p = guardChannel(p);
|
|
2047
2164
|
if (p && typeof p === "object" && typeof p.then === "function") {
|
|
2048
2165
|
if (!firstFlushed && deferStream) {
|
|
@@ -2093,11 +2210,16 @@ function renderToStream(code, options = {}) {
|
|
|
2093
2210
|
});
|
|
2094
2211
|
if (canBatchStubs && !shellCompleted && !dead) (stubBatch ||= new Map()).set(key + "_fr", p);else serializer.write(key + "_fr", p);
|
|
2095
2212
|
}
|
|
2096
|
-
return (value, error) => {
|
|
2213
|
+
return (value, error, escaped) => {
|
|
2097
2214
|
if (registry.has(key)) {
|
|
2098
2215
|
const item = registry.get(key);
|
|
2099
2216
|
registry.delete(key);
|
|
2100
2217
|
if (error) abandonSubtree(key, error);
|
|
2218
|
+
if (error && escaped) {
|
|
2219
|
+
const wire = ssrSanitizeError(error, null);
|
|
2220
|
+
const message = wire instanceof Error ? wire.message : String(wire);
|
|
2221
|
+
if (sink.error) sink.error("", message);else if (context.live && context.live.error) context.live.error(escaped.frame, message);
|
|
2222
|
+
}
|
|
2101
2223
|
if (item.children && !error) {
|
|
2102
2224
|
for (const k in item.children) {
|
|
2103
2225
|
value = replacePlaceholder(value, k, item.children[k]);
|
|
@@ -2117,7 +2239,7 @@ function renderToStream(code, options = {}) {
|
|
|
2117
2239
|
if (!completed) {
|
|
2118
2240
|
if (error) dropHeadBoundary(headRegistry, key);
|
|
2119
2241
|
if (!firstFlushed) {
|
|
2120
|
-
queue(() =>
|
|
2242
|
+
queue(() => inlineFragment(key, value !== undefined ? value : ""));
|
|
2121
2243
|
serializeFragmentAssets(key, tracking.boundaryModules, context);
|
|
2122
2244
|
item.resolve(error);
|
|
2123
2245
|
} else {
|
|
@@ -2159,15 +2281,27 @@ function renderToStream(code, options = {}) {
|
|
|
2159
2281
|
context.trace = requestEvent ? traceForEvent(requestEvent) : traceFor(context, undefined);
|
|
2160
2282
|
render = timeDocument(context, context.trace, "stream", requestEvent);
|
|
2161
2283
|
registerEntryAssets(manifest);
|
|
2284
|
+
context.writer = createHydrationWriter(context, () => !completed);
|
|
2162
2285
|
const signal = options.signal;
|
|
2163
|
-
const onAbort = signal ? () => abandon("signal") : undefined;
|
|
2286
|
+
const onAbort = signal ? () => abandon("signal", !!(signal.reason && signal.reason.quiet === true)) : undefined;
|
|
2164
2287
|
let html = createRoot(d => {
|
|
2165
2288
|
dispose = () => {
|
|
2166
2289
|
context.trace = undefined;
|
|
2167
2290
|
if (onAbort) signal.removeEventListener("abort", onAbort);
|
|
2168
2291
|
d();
|
|
2169
2292
|
};
|
|
2170
|
-
|
|
2293
|
+
rootOwner = claimRenderRoot(context);
|
|
2294
|
+
if (requestEvent) claimEventRender(requestEvent, context);
|
|
2295
|
+
let res;
|
|
2296
|
+
try {
|
|
2297
|
+
res = resolveSSRNode(escape(code()));
|
|
2298
|
+
} catch (err) {
|
|
2299
|
+
reportServerError(err, {
|
|
2300
|
+
kind: "render",
|
|
2301
|
+
handling: "failed"
|
|
2302
|
+
}, null, options.onError);
|
|
2303
|
+
throw err;
|
|
2304
|
+
}
|
|
2171
2305
|
if (!res.h.length) return res.t[0];
|
|
2172
2306
|
rootHoles = [];
|
|
2173
2307
|
let out = res.t[0];
|
|
@@ -2214,6 +2348,13 @@ function renderToStream(code, options = {}) {
|
|
|
2214
2348
|
for (const p of res.p) blockingPromises.add(p);
|
|
2215
2349
|
}
|
|
2216
2350
|
}
|
|
2351
|
+
if (parkedInlines) {
|
|
2352
|
+
for (const [key, value] of parkedInlines) {
|
|
2353
|
+
if (!html.includes(`<template id="pl-${key}">`)) continue;
|
|
2354
|
+
html = replacePlaceholder(html, key, value);
|
|
2355
|
+
parkedInlines.delete(key);
|
|
2356
|
+
}
|
|
2357
|
+
}
|
|
2217
2358
|
if (pending.length) {
|
|
2218
2359
|
rootHoles = pending;
|
|
2219
2360
|
return false;
|
|
@@ -2375,11 +2516,16 @@ function renderToStream(code, options = {}) {
|
|
|
2375
2516
|
},
|
|
2376
2517
|
pipe(w) {
|
|
2377
2518
|
claimConsumer("pipe");
|
|
2519
|
+
const abandoned = w[SHELL_ABANDONED];
|
|
2378
2520
|
onFailure(sink => {
|
|
2379
2521
|
try {
|
|
2380
|
-
sink ? sink.end() : w.end();
|
|
2522
|
+
sink ? sink.end() : abandoned ? abandoned() : w.end();
|
|
2381
2523
|
} catch (_) {}
|
|
2382
2524
|
});
|
|
2525
|
+
if (abandoned) {
|
|
2526
|
+
w[ABANDON_RENDER] = abandon;
|
|
2527
|
+
if (disconnected) abandoned();else onDisconnectedBeforeShell = abandoned;
|
|
2528
|
+
}
|
|
2383
2529
|
function flush() {
|
|
2384
2530
|
allSettled(blockingPromises).then(awaited => {
|
|
2385
2531
|
scheduleFlush(() => {
|
|
@@ -3079,14 +3225,16 @@ function ssrClassName(value) {
|
|
|
3079
3225
|
if (typeof value === "number") return "" + value;
|
|
3080
3226
|
if (!value) return "";
|
|
3081
3227
|
if (typeof value === "string") return escape(value, true);
|
|
3228
|
+
if (isSlotValue(value)) return "";
|
|
3082
3229
|
value = classListToObject(value);
|
|
3083
3230
|
let classKeys = Object.keys(value),
|
|
3084
3231
|
result = "";
|
|
3085
3232
|
for (let i = 0, len = classKeys.length; i < len; i++) {
|
|
3086
|
-
const key = classKeys[i]
|
|
3087
|
-
|
|
3233
|
+
const key = classKeys[i];
|
|
3234
|
+
let classValue = value[key];
|
|
3235
|
+
if (isSlotValue(classValue)) classValue = slotValueInline();
|
|
3088
3236
|
if (!key || key === "undefined" || !classValue) continue;
|
|
3089
|
-
|
|
3237
|
+
result && (result += " ");
|
|
3090
3238
|
result += escape(key, true);
|
|
3091
3239
|
}
|
|
3092
3240
|
return result;
|
|
@@ -3094,15 +3242,17 @@ function ssrClassName(value) {
|
|
|
3094
3242
|
function ssrStyle(value) {
|
|
3095
3243
|
if (!value) return "";
|
|
3096
3244
|
if (typeof value === "string") return escape(value, true);
|
|
3245
|
+
if (isSlotValue(value)) return "";
|
|
3097
3246
|
let result = "";
|
|
3098
3247
|
const k = Object.keys(value);
|
|
3099
3248
|
for (let i = 0; i < k.length; i++) {
|
|
3100
3249
|
const s = escape(k[i], true);
|
|
3101
|
-
|
|
3250
|
+
let v = value[k[i]];
|
|
3251
|
+
if (isSlotValue(v)) v = slotValueInline();
|
|
3102
3252
|
if (v != undefined) {
|
|
3103
|
-
if (i) result += ";";
|
|
3104
3253
|
const r = escape(v, true);
|
|
3105
3254
|
if (r != undefined && r !== "undefined") {
|
|
3255
|
+
if (result) result += ";";
|
|
3106
3256
|
result += `${s}:${r}`;
|
|
3107
3257
|
}
|
|
3108
3258
|
}
|
|
@@ -3110,28 +3260,39 @@ function ssrStyle(value) {
|
|
|
3110
3260
|
return result;
|
|
3111
3261
|
}
|
|
3112
3262
|
function ssrStyleProperty(name, value) {
|
|
3263
|
+
if (isSlotValue(value)) value = slotValueInline();
|
|
3113
3264
|
return value != null ? name + value : "";
|
|
3114
3265
|
}
|
|
3115
|
-
function
|
|
3266
|
+
function ssrStyleProperties(...entries) {
|
|
3267
|
+
let result = "";
|
|
3268
|
+
for (let i = 0; i < entries.length; i += 2) {
|
|
3269
|
+
const entry = ssrStyleProperty(entries[i], entries[i + 1]);
|
|
3270
|
+
if (entry) result = result ? result + ";" + entry : entry;
|
|
3271
|
+
}
|
|
3272
|
+
return result;
|
|
3273
|
+
}
|
|
3274
|
+
function ssrElement(tag, props, children, needsId, skip, attrs, claims) {
|
|
3116
3275
|
const hk = needsId ? ssrHydrationKey() : "";
|
|
3117
3276
|
if (typeof props === "function") props = props();
|
|
3118
3277
|
let sources = null;
|
|
3119
3278
|
let proxy = false;
|
|
3120
3279
|
let viewKeys = null;
|
|
3121
3280
|
let owners = null;
|
|
3281
|
+
let ownerIndex = null;
|
|
3282
|
+
const ctx = renderConfig.context;
|
|
3283
|
+
const slots = ctx !== undefined && ctx.claims !== undefined;
|
|
3122
3284
|
if (Array.isArray(props)) {
|
|
3123
|
-
|
|
3124
|
-
|
|
3125
|
-
|
|
3126
|
-
|
|
3127
|
-
|
|
3128
|
-
|
|
3129
|
-
|
|
3130
|
-
|
|
3131
|
-
|
|
3132
|
-
|
|
3133
|
-
|
|
3134
|
-
if (s != null) sourceOwners(s, viewKeys, owners);
|
|
3285
|
+
if (slots && props.$slot === true) props = slotSpreadSource();else {
|
|
3286
|
+
let i = 0;
|
|
3287
|
+
for (; i < props.length; i++) {
|
|
3288
|
+
const s = props[i];
|
|
3289
|
+
if (s == null || typeof s === "function" || $PROXY in s || slots && s.$slot === true) break;
|
|
3290
|
+
}
|
|
3291
|
+
if (i === props.length) sources = props;else {
|
|
3292
|
+
viewKeys = [];
|
|
3293
|
+
owners = [];
|
|
3294
|
+
if (slots) ownerIndex = [];
|
|
3295
|
+
collectSpreadSources(tag, props, viewKeys, owners, slots, ownerIndex);
|
|
3135
3296
|
}
|
|
3136
3297
|
}
|
|
3137
3298
|
} else if (props == null) {
|
|
@@ -3142,10 +3303,14 @@ function ssrElement(tag, props, children, needsId, skip, attrs) {
|
|
|
3142
3303
|
owners = [];
|
|
3143
3304
|
sourceOwners(props, viewKeys, owners);
|
|
3144
3305
|
} else proxy = true;
|
|
3306
|
+
} else if (slots && props.$slot === true) {
|
|
3307
|
+
props = slotSpreadSource();
|
|
3145
3308
|
}
|
|
3146
3309
|
const info = tagInfo(tag);
|
|
3147
3310
|
const skipChildren = info.isVoid;
|
|
3148
3311
|
let result = info.open + hk;
|
|
3312
|
+
let behaviors = null;
|
|
3313
|
+
let childOwner = null;
|
|
3149
3314
|
const last = sources === null ? 0 : sources.length - 1;
|
|
3150
3315
|
let keysOf = null;
|
|
3151
3316
|
if (sources !== null) {
|
|
@@ -3168,28 +3333,42 @@ function ssrElement(tag, props, children, needsId, skip, attrs) {
|
|
|
3168
3333
|
continue;
|
|
3169
3334
|
}
|
|
3170
3335
|
if (ChildProperties.has(prop)) {
|
|
3171
|
-
if (children === undefined &&
|
|
3336
|
+
if (children === undefined && childOwner === null && !skipChildren) {
|
|
3337
|
+
if (prop === "children") childOwner = props;else children = info.raw || prop === "innerHTML" ? props[prop] : escape(props[prop]);
|
|
3338
|
+
}
|
|
3172
3339
|
continue;
|
|
3173
3340
|
}
|
|
3174
3341
|
const value = props[prop];
|
|
3175
|
-
if (value == undefined
|
|
3342
|
+
if (value == undefined) {
|
|
3343
|
+
if (slots && claims !== undefined && (prop === "ref" || isEventName(prop))) behaviors = spreadBehaviorPosition(behaviors, prop, value, ctx.claims, ownerIndex !== null ? ownerIndex[i] : s, true);
|
|
3344
|
+
continue;
|
|
3345
|
+
}
|
|
3346
|
+
if (prop.startsWith("prop:")) {
|
|
3176
3347
|
continue;
|
|
3348
|
+
}
|
|
3349
|
+
if (prop === "ref" || isEventName(prop)) {
|
|
3350
|
+
if (slots) behaviors = spreadBehaviorPosition(behaviors, prop, value, ctx.claims, ownerIndex !== null ? ownerIndex[i] : s, claims !== undefined);
|
|
3351
|
+
continue;
|
|
3352
|
+
}
|
|
3353
|
+
if (slots && typeof value === "object") {
|
|
3354
|
+
result += spreadObjectAttribute(prop, value);
|
|
3177
3355
|
} else if (prop === "style") {
|
|
3178
3356
|
result += ` style="${ssrStyle(value)}"`;
|
|
3179
3357
|
} else if (prop === "class") {
|
|
3180
3358
|
result += ` class="${ssrClassName(value)}"`;
|
|
3181
3359
|
} else if (typeof value === "boolean") {
|
|
3182
|
-
if (
|
|
3183
|
-
|
|
3184
|
-
|
|
3185
|
-
result += value === "" ? ` ${attrName(prop)}` : ` ${attrName(prop)}="${escape(value, true)}"`;
|
|
3360
|
+
if (value && isAttrName(prop)) result += ` ${prop}`;
|
|
3361
|
+
} else if (isAttrName(prop)) {
|
|
3362
|
+
result += value === "" ? ` ${prop}` : ` ${prop}="${escape(value, true)}"`;
|
|
3186
3363
|
}
|
|
3187
3364
|
}
|
|
3188
3365
|
}
|
|
3366
|
+
if (slots && (behaviors !== null || claims !== undefined)) result += spreadBehaviorMarkers(behaviors, claims, ctx.claims);
|
|
3189
3367
|
if (attrs !== undefined) result += typeof attrs === "function" ? attrs() : attrs;
|
|
3190
3368
|
if (skipChildren) return {
|
|
3191
3369
|
t: result + " />"
|
|
3192
3370
|
};
|
|
3371
|
+
if (childOwner !== null) children = info.raw ? childOwner.children : escape(childOwner.children);
|
|
3193
3372
|
if (typeof children === "function") children = children();
|
|
3194
3373
|
const ct = typeof children;
|
|
3195
3374
|
if (ct === "string" || ct === "number") return {
|
|
@@ -3205,43 +3384,251 @@ function ssrElement(tag, props, children, needsId, skip, attrs) {
|
|
|
3205
3384
|
}
|
|
3206
3385
|
function ssrElementAttribute(key, value) {
|
|
3207
3386
|
if (value == undefined) return "";
|
|
3208
|
-
if (key === "style"
|
|
3209
|
-
|
|
3387
|
+
if (key === "style" || key === "class") {
|
|
3388
|
+
return typeof value === "object" ? slotClassOrStyle(key, value) : ` ${key}="${key === "class" ? ssrClassName(value) : ssrStyle(value)}"`;
|
|
3389
|
+
}
|
|
3390
|
+
if (isSlotValue(value)) return slotAttribute(key, value);
|
|
3210
3391
|
if (typeof value === "boolean") return value ? ` ${key}` : "";
|
|
3211
3392
|
return value === "" ? ` ${key}` : ` ${key}="${escape(value, true)}"`;
|
|
3212
3393
|
}
|
|
3213
3394
|
function ssrAttribute(key, value) {
|
|
3214
|
-
|
|
3395
|
+
if (typeof value === "string") return ` ${key}="${value}"`;
|
|
3396
|
+
if (value == null || value === false) return "";
|
|
3397
|
+
if (typeof value === "object") {
|
|
3398
|
+
return isSlotValue(value) ? slotAttribute(key, value) : ` ${key}="${escape(String(value), true)}"`;
|
|
3399
|
+
}
|
|
3400
|
+
if (typeof value === "function") return ` ${key}="${escape(String(value), true)}"`;
|
|
3401
|
+
return value === true ? ` ${key}` : ` ${key}="${value}"`;
|
|
3215
3402
|
}
|
|
3216
3403
|
function ssrHydrationKey() {
|
|
3217
3404
|
const hk = getHydrationKey();
|
|
3218
3405
|
return hk ? ` _hk=${hk}` : "";
|
|
3219
3406
|
}
|
|
3220
|
-
const CLAIM_PROP = /*#__PURE__*/Symbol.for("solid.claim-prop");
|
|
3221
3407
|
const CLAIMS_STREAM = 1;
|
|
3222
3408
|
const CLAIMS_DOCUMENT = 2;
|
|
3223
|
-
const
|
|
3224
|
-
|
|
3225
|
-
|
|
3409
|
+
const SLOT_VALUE = /*#__PURE__*/Symbol.for("solid.slot-value");
|
|
3410
|
+
const SLOT_MARKER = "_s:";
|
|
3411
|
+
const SLOT_FACE_STREAM = 0;
|
|
3412
|
+
const SLOT_FACE_DATA = 1;
|
|
3413
|
+
const SLOT_FACE_MARKUP = 2;
|
|
3414
|
+
function isSlotValue(value) {
|
|
3415
|
+
return value !== null && typeof value === "object" && value[SLOT_VALUE] !== undefined;
|
|
3416
|
+
}
|
|
3417
|
+
function slotValue(occurrence, key, value, face) {
|
|
3418
|
+
const sv = {
|
|
3419
|
+
[SLOT_VALUE]: occurrence,
|
|
3420
|
+
k: key,
|
|
3421
|
+
v: value,
|
|
3422
|
+
f: face
|
|
3423
|
+
};
|
|
3424
|
+
Object.defineProperty(sv, Symbol.toPrimitive, {
|
|
3425
|
+
value: hint => slotValueString()
|
|
3426
|
+
});
|
|
3427
|
+
Object.defineProperty(sv, "toString", {
|
|
3428
|
+
value: () => slotValueString()
|
|
3429
|
+
});
|
|
3430
|
+
Object.defineProperty(sv, "w", {
|
|
3431
|
+
value: () => slotText(sv)
|
|
3432
|
+
});
|
|
3433
|
+
return sv;
|
|
3434
|
+
}
|
|
3435
|
+
function slotValueString(sv, reason) {
|
|
3436
|
+
return "";
|
|
3437
|
+
}
|
|
3438
|
+
function slotText(sv) {
|
|
3439
|
+
const v = sv.f === SLOT_FACE_DATA ? sv.v : undefined;
|
|
3440
|
+
const text = typeof v === "string" || typeof v === "number" ? escape("" + v) : "";
|
|
3441
|
+
return `<!--${SLOT_MARKER}t=${slotEntry(sv)}-->${text}<!--/${SLOT_MARKER}t-->`;
|
|
3442
|
+
}
|
|
3443
|
+
function slotValueInline(kind, sv) {
|
|
3444
|
+
return undefined;
|
|
3445
|
+
}
|
|
3446
|
+
const SLOT_KEY_UNSAFE = /[^A-Za-z0-9_.!~*'()-]/g;
|
|
3447
|
+
function encodeSlotKey(key) {
|
|
3448
|
+
return String(key).replace(SLOT_KEY_UNSAFE, c => encodeURIComponent(c));
|
|
3449
|
+
}
|
|
3450
|
+
function slotEntry(sv, name) {
|
|
3451
|
+
return `${sv[SLOT_VALUE]}:${encodeSlotKey(sv.k)}${name !== undefined ? "=" + encodeSlotKey(name) : ""}`;
|
|
3452
|
+
}
|
|
3453
|
+
function slotMarker(position, entries) {
|
|
3454
|
+
return ` ${SLOT_MARKER}${position}="${entries}"`;
|
|
3455
|
+
}
|
|
3456
|
+
function eventSlotStamp(mode) {
|
|
3457
|
+
return mode === CLAIMS_DOCUMENT ? " _hk" : "";
|
|
3458
|
+
}
|
|
3459
|
+
function slotAttribute(key, sv) {
|
|
3460
|
+
let out = "";
|
|
3461
|
+
if (sv.f === SLOT_FACE_DATA) {
|
|
3462
|
+
const v = sv.v;
|
|
3463
|
+
if (v != null && v !== false) {
|
|
3464
|
+
out = v === true || v === "" ? ` ${key}` : ` ${key}="${escape(String(v), true)}"`;
|
|
3465
|
+
}
|
|
3466
|
+
}
|
|
3467
|
+
return out + slotMarker(key, slotEntry(sv));
|
|
3468
|
+
}
|
|
3469
|
+
function slotClassOrStyle(key, value) {
|
|
3470
|
+
const isClass = key === "class";
|
|
3471
|
+
if (isSlotValue(value)) {
|
|
3472
|
+
let out = "";
|
|
3473
|
+
if (value.f === SLOT_FACE_DATA && value.v != null) {
|
|
3474
|
+
out = ` ${key}="${isClass ? ssrClassName(value.v) : ssrStyle(value.v)}"`;
|
|
3475
|
+
}
|
|
3476
|
+
return out + slotMarker(key, slotEntry(value));
|
|
3477
|
+
}
|
|
3478
|
+
if (typeof value === "object" && value !== null) {
|
|
3479
|
+
const obj = isClass ? classListToObject(value) : value;
|
|
3480
|
+
let entries = "";
|
|
3481
|
+
let inner = "";
|
|
3482
|
+
for (const name of Object.keys(obj)) {
|
|
3483
|
+
let v = obj[name];
|
|
3484
|
+
if (isSlotValue(v)) {
|
|
3485
|
+
entries += (entries ? "," : "") + slotEntry(v, name);
|
|
3486
|
+
v = v.f === SLOT_FACE_DATA ? v.v : undefined;
|
|
3487
|
+
}
|
|
3488
|
+
if (isClass) {
|
|
3489
|
+
if (!name || name === "undefined" || !v) continue;
|
|
3490
|
+
inner += (inner ? " " : "") + escape(name, true);
|
|
3491
|
+
} else if (v != undefined) {
|
|
3492
|
+
const r = escape(v, true);
|
|
3493
|
+
if (r != undefined && r !== "undefined") {
|
|
3494
|
+
inner += (inner ? ";" : "") + `${escape(name, true)}:${r}`;
|
|
3495
|
+
}
|
|
3496
|
+
}
|
|
3497
|
+
}
|
|
3498
|
+
if (entries === "") return ` ${key}="${inner}"`;
|
|
3499
|
+
return (inner ? ` ${key}="${inner}"` : "") + slotMarker(key, entries);
|
|
3500
|
+
}
|
|
3501
|
+
return ` ${key}="${isClass ? ssrClassName(value) : ssrStyle(value)}"`;
|
|
3502
|
+
}
|
|
3503
|
+
function eventPosition(prop) {
|
|
3504
|
+
return prop.slice(2).toLowerCase();
|
|
3505
|
+
}
|
|
3506
|
+
function spreadBehaviorPosition(behaviors, prop, value, mode, index, settle) {
|
|
3507
|
+
if (!isAttrName(prop)) return behaviors;
|
|
3508
|
+
const pos = prop === "ref" ? "ref" : eventPosition(prop);
|
|
3509
|
+
const entries = value == null ? "" : claimEntries(pos, value);
|
|
3510
|
+
if (!settle) {
|
|
3511
|
+
if (entries) (behaviors ||= new Map()).set(pos, entries);
|
|
3512
|
+
return behaviors;
|
|
3513
|
+
}
|
|
3514
|
+
behaviors ||= new Map();
|
|
3515
|
+
const b = behaviors.get(pos);
|
|
3516
|
+
if (b === undefined) behaviors.set(pos, {
|
|
3517
|
+
e: entries,
|
|
3518
|
+
at: index
|
|
3519
|
+
});else {
|
|
3520
|
+
b.e = entries;
|
|
3521
|
+
b.at = index;
|
|
3522
|
+
}
|
|
3523
|
+
return behaviors;
|
|
3524
|
+
}
|
|
3525
|
+
function spreadBehaviorMarkers(behaviors, claims, mode) {
|
|
3526
|
+
if (claims !== undefined) {
|
|
3527
|
+
const segments = claims();
|
|
3528
|
+
for (const k in segments) {
|
|
3529
|
+
const map = segments[k];
|
|
3530
|
+
for (const pos in map) {
|
|
3531
|
+
const value = map[pos];
|
|
3532
|
+
behaviors ||= new Map();
|
|
3533
|
+
const b = behaviors.get(pos);
|
|
3534
|
+
if (pos === "ref") {
|
|
3535
|
+
if (value == null) continue;
|
|
3536
|
+
const entries = claimEntries("ref", value);
|
|
3537
|
+
if (!entries) continue;
|
|
3538
|
+
if (b === undefined) behaviors.set("ref", {
|
|
3539
|
+
e: entries,
|
|
3540
|
+
at: -1
|
|
3541
|
+
});else b.e = b.e ? b.e + "," + entries : entries;
|
|
3542
|
+
continue;
|
|
3543
|
+
}
|
|
3544
|
+
if (b !== undefined && b.at >= +k) continue;
|
|
3545
|
+
const entries = value == null ? "" : claimEntries(pos, value);
|
|
3546
|
+
if (b === undefined) behaviors.set(pos, {
|
|
3547
|
+
e: entries,
|
|
3548
|
+
at: -1
|
|
3549
|
+
});else b.e = entries;
|
|
3550
|
+
}
|
|
3551
|
+
}
|
|
3552
|
+
}
|
|
3553
|
+
let out = "";
|
|
3554
|
+
let events = false;
|
|
3555
|
+
if (behaviors !== null) {
|
|
3556
|
+
for (const [pos, b] of behaviors) {
|
|
3557
|
+
const e = claims === undefined ? b : b.e;
|
|
3558
|
+
if (!e) continue;
|
|
3559
|
+
if (pos === "ref") out += slotMarker("ref", e);else {
|
|
3560
|
+
out += slotMarker("on:" + pos, e);
|
|
3561
|
+
events = true;
|
|
3562
|
+
}
|
|
3563
|
+
}
|
|
3564
|
+
}
|
|
3565
|
+
return events ? out + eventSlotStamp(mode) : out;
|
|
3566
|
+
}
|
|
3567
|
+
function collectSpreadSources(tag, props, viewKeys, owners, slots, ownerIndex) {
|
|
3568
|
+
for (let i = 0; i < props.length; i++) {
|
|
3569
|
+
let s = props[i];
|
|
3570
|
+
if (typeof s === "function") s = s();
|
|
3571
|
+
if (s != null) {
|
|
3572
|
+
if (slots && !($PROXY in s) && s.$slot === true) s = slotSpreadSource();
|
|
3573
|
+
if (ownerIndex === null) sourceOwners(s, viewKeys, owners);else {
|
|
3574
|
+
const ks = [];
|
|
3575
|
+
const os = [];
|
|
3576
|
+
sourceOwners(s, ks, os);
|
|
3577
|
+
for (let j = 0; j < ks.length; j++) {
|
|
3578
|
+
const at = viewKeys.indexOf(ks[j]);
|
|
3579
|
+
if (at !== -1) {
|
|
3580
|
+
viewKeys.splice(at, 1);
|
|
3581
|
+
owners.splice(at, 1);
|
|
3582
|
+
ownerIndex.splice(at, 1);
|
|
3583
|
+
}
|
|
3584
|
+
viewKeys.push(ks[j]);
|
|
3585
|
+
owners.push(os[j]);
|
|
3586
|
+
ownerIndex.push(i);
|
|
3587
|
+
}
|
|
3588
|
+
}
|
|
3589
|
+
}
|
|
3590
|
+
}
|
|
3591
|
+
}
|
|
3592
|
+
function spreadObjectAttribute(prop, value) {
|
|
3593
|
+
if (prop === "style" || prop === "class") return slotClassOrStyle(prop, value);
|
|
3594
|
+
if (!isAttrName(prop)) return "";
|
|
3595
|
+
if (value[SLOT_VALUE] !== undefined) return slotAttribute(prop, value);
|
|
3596
|
+
return ` ${prop}="${escape(value, true)}"`;
|
|
3597
|
+
}
|
|
3598
|
+
function slotSpreadSource(tag, source) {
|
|
3599
|
+
return {};
|
|
3226
3600
|
}
|
|
3227
3601
|
function ssrClaim(map) {
|
|
3228
3602
|
const mode = sharedConfig.context && sharedConfig.context.claims;
|
|
3229
|
-
if (!mode
|
|
3230
|
-
return "";
|
|
3231
|
-
}
|
|
3603
|
+
if (!mode) return "";
|
|
3232
3604
|
let out = "";
|
|
3605
|
+
let events = false;
|
|
3233
3606
|
for (const pos in map) {
|
|
3234
|
-
const
|
|
3235
|
-
|
|
3236
|
-
|
|
3237
|
-
|
|
3238
|
-
|
|
3239
|
-
continue;
|
|
3240
|
-
}
|
|
3241
|
-
out += `${out ? "," : ""}${pos}=${encodeClaimKey(prop)}`;
|
|
3607
|
+
const entries = claimEntries(pos, map[pos]);
|
|
3608
|
+
if (!entries) continue;
|
|
3609
|
+
if (pos === "ref") out += slotMarker("ref", entries);else {
|
|
3610
|
+
out += slotMarker("on:" + pos, entries);
|
|
3611
|
+
events = true;
|
|
3242
3612
|
}
|
|
3243
3613
|
}
|
|
3244
|
-
return
|
|
3614
|
+
return events ? out + eventSlotStamp(mode) : out;
|
|
3615
|
+
}
|
|
3616
|
+
function claimEntries(pos, value, mode) {
|
|
3617
|
+
if (Array.isArray(value) && pos !== "ref") {
|
|
3618
|
+
return "";
|
|
3619
|
+
}
|
|
3620
|
+
if (Array.isArray(value)) {
|
|
3621
|
+
let entries = "";
|
|
3622
|
+
for (const v of value) {
|
|
3623
|
+
const inner = claimEntries(pos, v);
|
|
3624
|
+
if (inner) entries += (entries ? "," : "") + inner;
|
|
3625
|
+
}
|
|
3626
|
+
return entries;
|
|
3627
|
+
}
|
|
3628
|
+
if (isSlotValue(value)) {
|
|
3629
|
+
return slotEntry(value);
|
|
3630
|
+
}
|
|
3631
|
+
return "";
|
|
3245
3632
|
}
|
|
3246
3633
|
function decodeSSREntities(s) {
|
|
3247
3634
|
return s.indexOf("&") < 0 ? s : s.replace(/"/g, '"').replace(/</g, "<").replace(/&/g, "&");
|
|
@@ -3363,6 +3750,7 @@ function escape(s, attr) {
|
|
|
3363
3750
|
if (!attr && t === "function") return escapeLate(s);
|
|
3364
3751
|
if (attr) {
|
|
3365
3752
|
if (s == null || t === "boolean" || t === "number") return s;
|
|
3753
|
+
if (t === "object" && s[SLOT_VALUE] !== undefined) return s;
|
|
3366
3754
|
return escape(String(s), attr);
|
|
3367
3755
|
}
|
|
3368
3756
|
return s;
|
|
@@ -3470,7 +3858,7 @@ function generateHydrationScript({
|
|
|
3470
3858
|
eventNames = ["click", "input"],
|
|
3471
3859
|
nonce
|
|
3472
3860
|
} = {}) {
|
|
3473
|
-
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-->`;
|
|
3861
|
+
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-->`;
|
|
3474
3862
|
}
|
|
3475
3863
|
function queue(fn) {
|
|
3476
3864
|
return Promise.resolve().then(fn);
|
|
@@ -3673,6 +4061,10 @@ function tryResolveString(node, nested) {
|
|
|
3673
4061
|
if (node.h && node.h.length > 0) return {
|
|
3674
4062
|
merge: node
|
|
3675
4063
|
};
|
|
4064
|
+
if (node[SLOT_VALUE] !== undefined) {
|
|
4065
|
+
ssrTextTail = false;
|
|
4066
|
+
return node.w();
|
|
4067
|
+
}
|
|
3676
4068
|
if (node.t === undefined) {
|
|
3677
4069
|
return "";
|
|
3678
4070
|
}
|
|
@@ -3725,6 +4117,9 @@ function resolveSSRNode(node, result = {
|
|
|
3725
4117
|
} else if (node.t !== undefined) {
|
|
3726
4118
|
result.t[result.t.length - 1] += node.t;
|
|
3727
4119
|
ssrTextTail = false;
|
|
4120
|
+
} else if (node[SLOT_VALUE] !== undefined) {
|
|
4121
|
+
result.t[result.t.length - 1] += node.w();
|
|
4122
|
+
ssrTextTail = false;
|
|
3728
4123
|
} else ;
|
|
3729
4124
|
} else if (t === "function") {
|
|
3730
4125
|
const live = sharedConfig.context && sharedConfig.context.liveHoles;
|
|
@@ -3763,7 +4158,7 @@ function serializerErrorHook(hook) {
|
|
|
3763
4158
|
reportServerError(err, {
|
|
3764
4159
|
kind: "render",
|
|
3765
4160
|
handling: "serialize"
|
|
3766
|
-
}, null);
|
|
4161
|
+
}, null, hook);
|
|
3767
4162
|
};
|
|
3768
4163
|
}
|
|
3769
4164
|
function ambientServerErrorHook() {
|
|
@@ -3777,8 +4172,75 @@ function configureServerErrors(config) {
|
|
|
3777
4172
|
}
|
|
3778
4173
|
(g[ServerErrors] ||= {}).hook = config ? config.onError : undefined;
|
|
3779
4174
|
}
|
|
4175
|
+
function reportRequestFailure(error, event) {
|
|
4176
|
+
reportServerError(error, {
|
|
4177
|
+
kind: "request",
|
|
4178
|
+
handling: "failed",
|
|
4179
|
+
event
|
|
4180
|
+
}, null);
|
|
4181
|
+
if (ambientServerErrorHook() === undefined) console.error(error);
|
|
4182
|
+
}
|
|
3780
4183
|
function getRequestEvent() {
|
|
3781
|
-
|
|
4184
|
+
const store = globalThis[RequestContext];
|
|
4185
|
+
if (!store) return undefined;
|
|
4186
|
+
const event = store.getStore();
|
|
4187
|
+
if (event) return event;
|
|
4188
|
+
const ctx = renderContextOf(getOwner());
|
|
4189
|
+
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.");
|
|
4190
|
+
}
|
|
4191
|
+
const RENDER_ROOTS = Symbol.for("@solidjs/web/render-roots");
|
|
4192
|
+
function renderRoots() {
|
|
4193
|
+
const g = globalThis;
|
|
4194
|
+
return g[RENDER_ROOTS] || (g[RENDER_ROOTS] = new WeakMap());
|
|
4195
|
+
}
|
|
4196
|
+
function claimRenderRoot(context) {
|
|
4197
|
+
const owner = getOwner();
|
|
4198
|
+
const roots = renderRoots();
|
|
4199
|
+
roots.set(owner, context);
|
|
4200
|
+
onCleanup(() => roots.delete(owner));
|
|
4201
|
+
return owner;
|
|
4202
|
+
}
|
|
4203
|
+
function settleRender(render, root, outcome) {
|
|
4204
|
+
runWithOwner(root || null, () => render.settle(outcome));
|
|
4205
|
+
}
|
|
4206
|
+
const eventRenders = new WeakMap();
|
|
4207
|
+
function claimEventRender(event, context) {
|
|
4208
|
+
let renders = eventRenders.get(event);
|
|
4209
|
+
if (!renders) eventRenders.set(event, renders = new Set());
|
|
4210
|
+
renders.add(context);
|
|
4211
|
+
onCleanup(() => renders.delete(context));
|
|
4212
|
+
}
|
|
4213
|
+
function createHydrationWriter(context, isOpen) {
|
|
4214
|
+
const keys = new Set();
|
|
4215
|
+
return {
|
|
4216
|
+
async: !!context.async,
|
|
4217
|
+
write(key, value, options) {
|
|
4218
|
+
if (!isOpen() || keys.has(key)) return false;
|
|
4219
|
+
context.serialize(key, value, options && options.deferStream);
|
|
4220
|
+
keys.add(key);
|
|
4221
|
+
return true;
|
|
4222
|
+
}
|
|
4223
|
+
};
|
|
4224
|
+
}
|
|
4225
|
+
function getHydrationWriter() {
|
|
4226
|
+
let ctx = renderContextOf(getOwner());
|
|
4227
|
+
if (!ctx) {
|
|
4228
|
+
const event = peekRequestEvent();
|
|
4229
|
+
const renders = event && eventRenders.get(event);
|
|
4230
|
+
if (renders && renders.size === 1) for (const c of renders) ctx = c;
|
|
4231
|
+
}
|
|
4232
|
+
return ctx && ctx.writer;
|
|
4233
|
+
}
|
|
4234
|
+
function takeHydrationValue(_key) {
|
|
4235
|
+
return undefined;
|
|
4236
|
+
}
|
|
4237
|
+
function renderContextOf(owner) {
|
|
4238
|
+
const roots = globalThis[RENDER_ROOTS];
|
|
4239
|
+
if (!roots) return undefined;
|
|
4240
|
+
for (; owner; owner = owner._parent) {
|
|
4241
|
+
const context = roots.get(owner);
|
|
4242
|
+
if (context) return context;
|
|
4243
|
+
}
|
|
3782
4244
|
}
|
|
3783
4245
|
function peekRequestEvent() {
|
|
3784
4246
|
const store = globalThis[RequestContext];
|
|
@@ -3787,6 +4249,7 @@ function peekRequestEvent() {
|
|
|
3787
4249
|
function timeDocument(context, trace, mode, requestEvent) {
|
|
3788
4250
|
if (records() === undefined) return undefined;
|
|
3789
4251
|
const render = observeRender(trace, mode, requestEvent);
|
|
4252
|
+
if (render) context._declareRoute = ref => render.route(ref);
|
|
3790
4253
|
if (timesServerWork("boundary")) {
|
|
3791
4254
|
context._recordBoundary = event => {
|
|
3792
4255
|
trace.timing.push({
|
|
@@ -3801,7 +4264,7 @@ function timeDocument(context, trace, mode, requestEvent) {
|
|
|
3801
4264
|
function getTraceContext() {
|
|
3802
4265
|
const event = peekRequestEvent();
|
|
3803
4266
|
if (event) return traceForEvent(event).context;
|
|
3804
|
-
const ctx =
|
|
4267
|
+
const ctx = renderContextOf(getOwner());
|
|
3805
4268
|
return ctx && ctx.trace ? ctx.trace.context : undefined;
|
|
3806
4269
|
}
|
|
3807
4270
|
function traceForStub(stub, event) {
|
|
@@ -3887,10 +4350,13 @@ function copyInitHeaders(init) {
|
|
|
3887
4350
|
for (const cookie of init.getSetCookie()) headers.append("Set-Cookie", cookie);
|
|
3888
4351
|
return headers;
|
|
3889
4352
|
}
|
|
3890
|
-
|
|
3891
|
-
|
|
4353
|
+
let stubGapFillExcluded;
|
|
4354
|
+
function isStubGapFillExcluded(key) {
|
|
4355
|
+
return (stubGapFillExcluded ||= new Set([ERROR_HEADER, BODY_FORMAT_HEADER, SINGLE_FLIGHT_HEADER, REVALIDATE_HEADER, REDIRECT_HEADER, "Location",
|
|
4356
|
+
...COMPOSED_BODY_FRAMING].map(header => header.toLowerCase()))).has(key);
|
|
4357
|
+
}
|
|
3892
4358
|
function fillsStubGap(key, headers, response) {
|
|
3893
|
-
if (key === "set-cookie" ||
|
|
4359
|
+
if (key === "set-cookie" || isStubGapFillExcluded(key)) return false;
|
|
3894
4360
|
if (response.body === null && (key === "content-type" || key === "content-length")) return false;
|
|
3895
4361
|
return !headers.has(key);
|
|
3896
4362
|
}
|
|
@@ -3982,7 +4448,7 @@ function createSSRResponse(result, event, options = {}) {
|
|
|
3982
4448
|
closed = true;
|
|
3983
4449
|
}
|
|
3984
4450
|
};
|
|
3985
|
-
|
|
4451
|
+
const sink = {
|
|
3986
4452
|
write(chunk) {
|
|
3987
4453
|
if (!flushed) {
|
|
3988
4454
|
flushed = true;
|
|
@@ -3997,6 +4463,7 @@ function createSSRResponse(result, event, options = {}) {
|
|
|
3997
4463
|
status: getExpectedRedirectStatus(stub),
|
|
3998
4464
|
headers: head.headers
|
|
3999
4465
|
}));
|
|
4466
|
+
sink[ABANDON_RENDER]("redirect", true);
|
|
4000
4467
|
return;
|
|
4001
4468
|
}
|
|
4002
4469
|
if (!head.headers.has("content-type")) {
|
|
@@ -4007,7 +4474,9 @@ function createSSRResponse(result, event, options = {}) {
|
|
|
4007
4474
|
controller = c;
|
|
4008
4475
|
},
|
|
4009
4476
|
cancel() {
|
|
4477
|
+
if (closed) return;
|
|
4010
4478
|
closed = true;
|
|
4479
|
+
sink[ABANDON_RENDER]("consumer");
|
|
4011
4480
|
}
|
|
4012
4481
|
}), {
|
|
4013
4482
|
status: head.status,
|
|
@@ -4018,6 +4487,7 @@ function createSSRResponse(result, event, options = {}) {
|
|
|
4018
4487
|
enqueue(transformChunk ? transformChunk(chunk) : chunk);
|
|
4019
4488
|
},
|
|
4020
4489
|
end() {
|
|
4490
|
+
if (!flushed) sink.write("");
|
|
4021
4491
|
if (closed || !controller) return;
|
|
4022
4492
|
const location = stub && stub.headers.get("Location");
|
|
4023
4493
|
if (location && isHttpNavigationTarget(location)) {
|
|
@@ -4028,8 +4498,23 @@ function createSSRResponse(result, event, options = {}) {
|
|
|
4028
4498
|
try {
|
|
4029
4499
|
controller.close();
|
|
4030
4500
|
} catch {}
|
|
4031
|
-
}
|
|
4032
|
-
|
|
4501
|
+
},
|
|
4502
|
+
[SHELL_ABANDONED]() {
|
|
4503
|
+
if (flushed) return;
|
|
4504
|
+
flushed = closed = true;
|
|
4505
|
+
if (stub) commitResponseStub(stub, {
|
|
4506
|
+
event
|
|
4507
|
+
});
|
|
4508
|
+
const head = deriveHead(stub, responseInit);
|
|
4509
|
+
const status = stub && stub.headers.get("Location") ? getExpectedRedirectStatus(stub) : 500;
|
|
4510
|
+
resolve(new Response(null, {
|
|
4511
|
+
status,
|
|
4512
|
+
headers: head.headers
|
|
4513
|
+
}));
|
|
4514
|
+
},
|
|
4515
|
+
[ABANDON_RENDER]() {}
|
|
4516
|
+
};
|
|
4517
|
+
result.pipe(sink);
|
|
4033
4518
|
});
|
|
4034
4519
|
}
|
|
4035
4520
|
function composeMiddleware(middlewares) {
|
|
@@ -4054,6 +4539,9 @@ function claimElement(node) {
|
|
|
4054
4539
|
function claimElementTree(root) {
|
|
4055
4540
|
return root;
|
|
4056
4541
|
}
|
|
4542
|
+
function dispatchAsInteraction(_e, fn) {
|
|
4543
|
+
return fn();
|
|
4544
|
+
}
|
|
4057
4545
|
function notSup() {
|
|
4058
4546
|
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>.");
|
|
4059
4547
|
}
|
|
@@ -4063,10 +4551,17 @@ setAsyncIterableSharer(shareAsyncIterable);
|
|
|
4063
4551
|
const isServer = true;
|
|
4064
4552
|
const isDev = false;
|
|
4065
4553
|
function dynamic(source, options) {
|
|
4554
|
+
return dynamicCore(source, options, ssrTag);
|
|
4555
|
+
}
|
|
4556
|
+
function dynamicComponent(source, options) {
|
|
4557
|
+
return dynamicCore(source, options);
|
|
4558
|
+
}
|
|
4559
|
+
const ssrTag = (tag, props) => ssrElement(tag, props, undefined, true);
|
|
4560
|
+
function dynamicCore(source, options, tagArm) {
|
|
4066
4561
|
if (options?.static) {
|
|
4067
4562
|
const component = untrack(source);
|
|
4068
4563
|
if (typeof component === "function") return props => component(props);
|
|
4069
|
-
if (typeof component === "string") return props =>
|
|
4564
|
+
if (typeof component === "string" && tagArm) return props => tagArm(component, props);
|
|
4070
4565
|
return () => undefined;
|
|
4071
4566
|
}
|
|
4072
4567
|
const cached = createMemo(() => {
|
|
@@ -4112,9 +4607,7 @@ function dynamic(source, options) {
|
|
|
4112
4607
|
const c = value();
|
|
4113
4608
|
if (c) {
|
|
4114
4609
|
if (typeof c === "function") return c(props);
|
|
4115
|
-
if (typeof c === "string")
|
|
4116
|
-
return ssrElement(c, props, undefined, true);
|
|
4117
|
-
}
|
|
4610
|
+
if (typeof c === "string" && tagArm) return tagArm(c, props);
|
|
4118
4611
|
}
|
|
4119
4612
|
}, {
|
|
4120
4613
|
sync: true
|
|
@@ -4265,4 +4758,4 @@ function httpHeader(name, value, options) {
|
|
|
4265
4758
|
}
|
|
4266
4759
|
}
|
|
4267
4760
|
|
|
4268
|
-
export { CLAIMS_DOCUMENT, CLAIMS_STREAM,
|
|
4761
|
+
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 };
|