@solidjs/web 2.0.0-rc.2 → 2.0.0-rc.20
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/README.md +1 -1
- package/dist/server.dev.js +5065 -0
- package/dist/server.js +1757 -355
- package/dist/{server.cjs → server.observe.js} +1951 -558
- package/dist/{dev.cjs → web.dev.js} +945 -550
- package/dist/web.js +635 -332
- package/dist/{dev.js → web.observe.js} +688 -403
- package/frames/dist/assets.js +92 -0
- package/frames/dist/client.dev.js +1296 -1198
- package/frames/dist/client.js +1128 -1191
- package/frames/dist/client.observe.js +2041 -0
- package/frames/dist/regions.js +171 -0
- package/frames/dist/server.dev.js +2549 -0
- package/frames/dist/server.js +1688 -3005
- package/frames/dist/server.observe.js +2548 -0
- package/frames/dist/trace.js +45 -0
- package/frames/dist/wire.js +594 -0
- package/frames/package.json +2 -25
- package/package.json +244 -256
- package/performance-tracks/dist/performance-tracks.dev.js +679 -0
- package/performance-tracks/dist/performance-tracks.js +6 -0
- package/performance-tracks/dist/performance-tracks.observe.js +667 -0
- package/performance-tracks/package.json +7 -0
- package/performance-tracks/types/index.d.ts +69 -0
- package/serialization/decode/package.json +2 -15
- package/serialization/dist/decode.js +121 -25
- package/serialization/dist/serialization.js +242 -88
- package/serialization/package.json +2 -15
- package/serialization/types/index.d.ts +85 -158
- package/serialization/types/serializer-decode.d.ts +173 -114
- package/serialization/types/serializer.d.ts +109 -0
- package/server-functions/dist/client.dev.js +1462 -0
- package/server-functions/dist/client.js +667 -165
- package/server-functions/dist/client.observe.js +1441 -0
- package/server-functions/dist/rich-args.js +84 -1
- package/server-functions/dist/server.dev.js +2714 -297
- package/server-functions/dist/server.js +2595 -271
- package/server-functions/dist/server.observe.js +3594 -0
- package/server-functions/package.json +2 -35
- package/server-functions/rich-args/package.json +2 -15
- package/skills/server-components/SKILL.md +117 -0
- package/storage/package.json +2 -15
- package/types/client.d.ts +342 -288
- package/types/constants.d.ts +22 -0
- package/types/cookies.d.ts +32 -84
- package/types/diagnostics.d.ts +80 -0
- package/types/frames/assets-tier.d.ts +78 -0
- package/types/frames/client.d.ts +40 -1
- package/types/frames/frame-client.d.ts +443 -280
- package/types/frames/frame-container-plugin.d.ts +64 -0
- package/types/frames/frame-morph.d.ts +29 -0
- package/types/frames/frame-sink.d.ts +141 -161
- package/types/frames/frame-transport.d.ts +263 -184
- package/types/frames/regions-tier.d.ts +60 -0
- package/types/frames/serializer-decode.d.ts +241 -0
- package/types/frames/serializer.d.ts +85 -158
- package/types/frames/server.d.ts +2 -2
- 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 +169 -0
- package/types/head.d.ts +20 -0
- package/types/index.d.ts +98 -81
- package/types/index.server.d.ts +159 -0
- package/types/jsx.d.ts +49 -44
- package/types/observe.d.ts +535 -0
- package/types/reconcile.d.ts +1 -0
- package/types/render.d.ts +11 -0
- package/types/request-error-hook.d.ts +5 -0
- package/types/response.d.ts +95 -147
- package/types/serializer-decode.d.ts +173 -114
- package/types/serializer.d.ts +85 -158
- package/types/server-functions/argument-codec.d.ts +30 -0
- package/types/server-functions/client.d.ts +238 -223
- package/types/server-functions/flash.d.ts +28 -30
- package/types/server-functions/registry.d.ts +105 -0
- package/types/server-functions/rich-args.d.ts +1 -10
- package/types/server-functions/server.d.ts +539 -531
- package/types/server-functions/shared.d.ts +398 -425
- package/types/server-functions/uploads.d.ts +50 -0
- package/types/server-mock.d.ts +120 -13
- package/types/server-observe.d.ts +86 -0
- package/types/server.d.ts +571 -422
- package/types/trace.d.ts +127 -0
- package/LICENSE +0 -21
- package/dist/web.cjs +0 -2033
- package/frames/dist/client.cjs +0 -2002
- package/frames/dist/client.dev.cjs +0 -2022
- package/frames/dist/server.cjs +0 -3877
- package/serialization/dist/decode.cjs +0 -139
- package/serialization/dist/serialization.cjs +0 -261
- package/serialization/types-cjs/index.d.cts +0 -182
- package/serialization/types-cjs/package.json +0 -3
- package/serialization/types-cjs/serializer-decode.d.cts +0 -182
- package/server-functions/dist/client.cjs +0 -834
- package/server-functions/dist/rich-args.cjs +0 -11
- package/server-functions/dist/server.cjs +0 -1242
- package/server-functions/dist/server.dev.cjs +0 -1242
- package/storage/dist/storage.cjs +0 -12
- package/storage/types-cjs/index.d.cts +0 -28
- package/storage/types-cjs/package.json +0 -3
- package/types/core.d.ts +0 -9
- package/types-cjs/client.d.cts +0 -337
- package/types-cjs/cookies.d.cts +0 -93
- package/types-cjs/core.d.cts +0 -9
- package/types-cjs/frames/client.d.cts +0 -36
- package/types-cjs/frames/frame-client.d.cts +0 -356
- package/types-cjs/frames/frame-sink.d.cts +0 -194
- package/types-cjs/frames/frame-transport.d.cts +0 -222
- package/types-cjs/frames/serializer.d.cts +0 -182
- package/types-cjs/frames/server.d.cts +0 -52
- package/types-cjs/index.d.cts +0 -244
- package/types-cjs/jsx-properties.d.cts +0 -93
- package/types-cjs/jsx.d.cts +0 -4159
- package/types-cjs/package.json +0 -3
- package/types-cjs/response.d.cts +0 -174
- package/types-cjs/serializer-decode.d.cts +0 -182
- package/types-cjs/serializer.d.cts +0 -182
- package/types-cjs/server-functions/client.d.cts +0 -262
- package/types-cjs/server-functions/flash.d.cts +0 -38
- package/types-cjs/server-functions/rich-args.d.cts +0 -10
- package/types-cjs/server-functions/server.d.cts +0 -681
- package/types-cjs/server-functions/shared.d.cts +0 -523
- package/types-cjs/server-mock.d.cts +0 -286
- package/types-cjs/server.d.cts +0 -544
package/dist/server.js
CHANGED
|
@@ -1,6 +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 {
|
|
1
|
+
import { createRenderEffect, createMemo, getOwner, createRoot, $PROXY, onCleanup, runWithOwner, createComponent, omit, getNextChildId } from 'solid-js';
|
|
2
|
+
export { Errored, For, Hydration, Loading, Match, NoHydration, Repeat, Reveal, Show, Switch, createComponent, dynamicComponent, getOwner, merge as mergeProps, untrack } from 'solid-js';
|
|
3
|
+
import { sharedConfig, ssrSanitizeError, beginEdgesRender, reportServerError, viewOf, sourceOwners, ssrHandleError, inServerComponentScope, creationStamp, dynamicCore, getProjectionTrace, shareAsyncIterable } from 'solid-js/internal';
|
|
4
|
+
export { ssrScope as scope } from 'solid-js/internal';
|
|
5
|
+
import { createStream, Feature, getCrossReferenceHeader, crossSerializeStream } from 'seroval';
|
|
4
6
|
import { AbortSignalPlugin, CustomEventPlugin, DOMExceptionPlugin, EventPlugin, FormDataPlugin, HeadersPlugin, ReadableStreamPlugin, RequestPlugin, ResponsePlugin, URLSearchParamsPlugin, URLPlugin } from 'seroval-plugins/web';
|
|
5
7
|
|
|
6
8
|
const DOMWithState = {
|
|
@@ -32,6 +34,7 @@ const DOMWithState = {
|
|
|
32
34
|
}
|
|
33
35
|
};
|
|
34
36
|
const ChildProperties = /*#__PURE__*/new Set(["innerHTML", "textContent", "innerText", "children"]);
|
|
37
|
+
const LinkAttributes = /*#__PURE__*/new Set(["href", "target", "rel", "download", "link", "aria-current"]);
|
|
35
38
|
const DelegatedEvents = /*#__PURE__*/new Set(["beforeinput", "click", "dblclick", "contextmenu", "focusin", "focusout", "input", "keydown", "keyup", "mousedown", "mousemove", "mouseout", "mouseover", "mouseup", "pointerdown", "pointermove", "pointerout", "pointerover", "pointerup", "touchend", "touchmove", "touchstart"]);
|
|
36
39
|
const SVGElements = /*#__PURE__*/new Set([
|
|
37
40
|
"altGlyph", "altGlyphDef", "altGlyphItem", "animate", "animateColor", "animateMotion", "animateTransform", "circle", "clipPath", "color-profile", "cursor", "defs", "desc", "ellipse", "feBlend", "feColorMatrix", "feComponentTransfer", "feComposite", "feConvolveMatrix", "feDiffuseLighting", "feDisplacementMap", "feDistantLight", "feDropShadow", "feFlood", "feFuncA", "feFuncB", "feFuncG", "feFuncR", "feGaussianBlur", "feImage", "feMerge", "feMergeNode", "feMorphology", "feOffset", "fePointLight", "feSpecularLighting", "feSpotLight", "feTile", "feTurbulence", "filter", "font", "font-face", "font-face-format", "font-face-name", "font-face-src", "font-face-uri", "foreignObject", "g", "glyph", "glyphRef", "hkern", "image", "line", "linearGradient", "marker", "mask", "metadata", "missing-glyph", "mpath", "path", "pattern", "polygon", "polyline", "radialGradient", "rect",
|
|
@@ -48,6 +51,19 @@ const Namespaces = {
|
|
|
48
51
|
const VoidElements = /*#__PURE__*/new Set(["area", "base", "br", "col", "embed", "hr", "img", "input", "link", "meta", "param", "source", "track", "wbr"]);
|
|
49
52
|
const RawTextElements = /*#__PURE__*/new Set(["style", "script", "noscript", "template", "textarea", "title"]);
|
|
50
53
|
const DOMElements = /*#__PURE__*/new Set(/*#__PURE__*/"a,abbr,acronym,address,applet,area,article,aside,audio,b,base,basefont,bdi,bdo,bgsound,big,blink,blockquote,body,br,button,canvas,caption,center,cite,code,col,colgroup,content,data,datalist,dd,del,details,dfn,dialog,dir,div,dl,dt,em,embed,fieldset,figcaption,figure,font,footer,form,frame,frameset,h1,h2,h3,h4,h5,h6,head,header,hgroup,hr,html,i,iframe,image,img,input,ins,isindex,kbd,keygen,label,legend,li,link,listing,main,map,mark,marquee,math,menu,menuitem,meta,meter,multicol,nav,nextid,nobr,noembed,noframes,noindex,noscript,object,ol,optgroup,option,output,p,param,picture,plaintext,portal,pre,progress,q,rb,rp,rt,rtc,ruby,s,samp,script,search,section,select,shadow,slot,small,source,spacer,span,strike,strong,style,sub,summary,sup,svg,table,tbody,td,template,textarea,tfoot,th,thead,time,title,tr,track,tt,u,ul,var,video,wbr,webview,xmp".split(","));
|
|
54
|
+
const COMPOSED_BODY_FRAMING = /*#__PURE__*/new Set(["content-length", "content-encoding", "transfer-encoding"]);
|
|
55
|
+
function isHttpNavigationTarget(target) {
|
|
56
|
+
try {
|
|
57
|
+
const protocol = new URL(target, "http://base.invalid").protocol;
|
|
58
|
+
return protocol === "http:" || protocol === "https:";
|
|
59
|
+
} catch {
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
function isEventName(name) {
|
|
64
|
+
let c;
|
|
65
|
+
return name.startsWith("on") && (c = name.charCodeAt(2)) > 64 && c < 91;
|
|
66
|
+
}
|
|
51
67
|
|
|
52
68
|
const transparentOptions = {
|
|
53
69
|
transparent: true,
|
|
@@ -56,14 +72,281 @@ const transparentOptions = {
|
|
|
56
72
|
const syncOptions = {
|
|
57
73
|
sync: true
|
|
58
74
|
};
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
75
|
+
function effect(fn, effectFn, options) {
|
|
76
|
+
const nodeOptions = options ? {
|
|
77
|
+
sync: true,
|
|
78
|
+
...options,
|
|
79
|
+
transparent: !options.scope
|
|
80
|
+
} : transparentOptions;
|
|
81
|
+
createRenderEffect(fn, effectFn, nodeOptions);
|
|
82
|
+
}
|
|
83
|
+
function memo(fn) {
|
|
84
|
+
return createMemo(() => fn(), syncOptions);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
const REQUEST_ERROR_HOOK = Symbol.for("solid-js/server/request-error-hook");
|
|
88
|
+
function hooks() {
|
|
89
|
+
const g = globalThis;
|
|
90
|
+
return g[REQUEST_ERROR_HOOK] || (g[REQUEST_ERROR_HOOK] = new WeakMap());
|
|
91
|
+
}
|
|
92
|
+
function setRequestErrorHook(event, hook) {
|
|
93
|
+
if (hook !== undefined) hooks().set(event, hook);
|
|
94
|
+
}
|
|
65
95
|
|
|
66
|
-
const
|
|
96
|
+
const TRACEPARENT = /^([0-9a-f]{2})-([0-9a-f]{32})-([0-9a-f]{16})-([0-9a-f]{2})(-.*)?$/;
|
|
97
|
+
const ZERO_TRACE = "00000000000000000000000000000000";
|
|
98
|
+
const ZERO_SPAN = "0000000000000000";
|
|
99
|
+
function parseTraceparent(value) {
|
|
100
|
+
if (!value) return undefined;
|
|
101
|
+
const m = TRACEPARENT.exec(value.trim());
|
|
102
|
+
if (!m) return undefined;
|
|
103
|
+
const [, version, traceId, parentId, flags, rest] = m;
|
|
104
|
+
if (version === "ff") return undefined;
|
|
105
|
+
if (version === "00" && rest !== undefined) return undefined;
|
|
106
|
+
if (traceId === ZERO_TRACE || parentId === ZERO_SPAN) return undefined;
|
|
107
|
+
return {
|
|
108
|
+
traceId,
|
|
109
|
+
parentId,
|
|
110
|
+
sampled: (parseInt(flags, 16) & 1) === 1
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
function randomHex(bytes) {
|
|
114
|
+
let out = "";
|
|
115
|
+
for (let i = 0; i < bytes; i += 4) out += (Math.random() * 0x100000000 >>> 0).toString(16).padStart(8, "0");
|
|
116
|
+
return out.length === bytes * 2 ? out : out.slice(0, bytes * 2);
|
|
117
|
+
}
|
|
118
|
+
function randomTraceId() {
|
|
119
|
+
let id = randomHex(16);
|
|
120
|
+
while (id === ZERO_TRACE) id = randomHex(16);
|
|
121
|
+
return id;
|
|
122
|
+
}
|
|
123
|
+
function randomSpanId() {
|
|
124
|
+
let id = randomHex(8);
|
|
125
|
+
while (id === ZERO_SPAN) id = randomHex(8);
|
|
126
|
+
return id;
|
|
127
|
+
}
|
|
128
|
+
function formatTraceparent(context) {
|
|
129
|
+
return `00-${context.traceId}-${context.spanId}-${context.sampled === true ? "01" : "00"}`;
|
|
130
|
+
}
|
|
131
|
+
const RECORDS_KEY = Symbol.for("@solidjs/web/trace/records");
|
|
132
|
+
function records() {
|
|
133
|
+
const g = globalThis;
|
|
134
|
+
return g[RECORDS_KEY] || (g[RECORDS_KEY] = new WeakMap());
|
|
135
|
+
}
|
|
136
|
+
function traceFor(key, request) {
|
|
137
|
+
const store = records();
|
|
138
|
+
let record = store.get(key);
|
|
139
|
+
if (record) return record;
|
|
140
|
+
const headers = request ? request.headers : undefined;
|
|
141
|
+
const incoming = headers ? parseTraceparent(headers.get("traceparent")) : undefined;
|
|
142
|
+
const context = {
|
|
143
|
+
traceId: incoming ? incoming.traceId : randomTraceId(),
|
|
144
|
+
spanId: randomSpanId(),
|
|
145
|
+
entries: {}
|
|
146
|
+
};
|
|
147
|
+
if (incoming) {
|
|
148
|
+
context.parentId = incoming.parentId;
|
|
149
|
+
context.sampled = incoming.sampled;
|
|
150
|
+
}
|
|
151
|
+
if (headers) {
|
|
152
|
+
const state = headers.get("tracestate");
|
|
153
|
+
if (state) context.state = state;
|
|
154
|
+
const baggage = headers.get("baggage");
|
|
155
|
+
if (baggage) context.baggage = baggage;
|
|
156
|
+
}
|
|
157
|
+
let answered = false;
|
|
158
|
+
context.entries.traceparent = formatTraceparent(context);
|
|
159
|
+
record = {
|
|
160
|
+
context,
|
|
161
|
+
emit: incoming !== undefined && incoming.sampled || answered,
|
|
162
|
+
timing: []
|
|
163
|
+
};
|
|
164
|
+
store.set(key, record);
|
|
165
|
+
return record;
|
|
166
|
+
}
|
|
167
|
+
function traceForEvent(event) {
|
|
168
|
+
return traceFor(event.request || event, event.request);
|
|
169
|
+
}
|
|
170
|
+
const TOKEN = /^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;
|
|
171
|
+
function splitServerTiming(value) {
|
|
172
|
+
const entries = [];
|
|
173
|
+
let start = 0;
|
|
174
|
+
let quoted = false;
|
|
175
|
+
for (let i = 0; i < value.length; i++) {
|
|
176
|
+
const c = value[i];
|
|
177
|
+
if (quoted) {
|
|
178
|
+
if (c === "\\") i++;else if (c === '"') quoted = false;
|
|
179
|
+
} else if (c === '"') quoted = true;else if (c === ",") {
|
|
180
|
+
entries.push(value.slice(start, i));
|
|
181
|
+
start = i + 1;
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
entries.push(value.slice(start));
|
|
185
|
+
return entries;
|
|
186
|
+
}
|
|
187
|
+
function metricName(entry) {
|
|
188
|
+
return entry.split(";")[0].trim().toLowerCase();
|
|
189
|
+
}
|
|
190
|
+
function namesOnServerTiming(headers) {
|
|
191
|
+
const names = new Set();
|
|
192
|
+
const existing = headers.get("server-timing");
|
|
193
|
+
if (existing) {
|
|
194
|
+
for (const entry of splitServerTiming(existing)) {
|
|
195
|
+
const name = metricName(entry);
|
|
196
|
+
if (name) names.add(name);
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
return names;
|
|
200
|
+
}
|
|
201
|
+
function quoteDesc(value) {
|
|
202
|
+
return value.replace(/[\x00-\x1f\x7f]/g, "").replace(/[^\x20-\x7e]/g, "?").replace(/[\\"]/g, m => "\\" + m);
|
|
203
|
+
}
|
|
204
|
+
function shellMs(record) {
|
|
205
|
+
return record.render !== undefined ? record.render.shellMs : undefined;
|
|
206
|
+
}
|
|
207
|
+
function hasServerTiming(record) {
|
|
208
|
+
return record.emit || record.timing.length > 0 || shellMs(record) !== undefined;
|
|
209
|
+
}
|
|
210
|
+
function appendTraceServerTiming(headers, record) {
|
|
211
|
+
if (record.emit) {
|
|
212
|
+
const entries = record.context.entries;
|
|
213
|
+
let present;
|
|
214
|
+
for (const name in entries) {
|
|
215
|
+
if (!TOKEN.test(name)) continue;
|
|
216
|
+
if (!present) present = namesOnServerTiming(headers);
|
|
217
|
+
if (present.has(name.toLowerCase())) continue;
|
|
218
|
+
headers.append("Server-Timing", `${name};desc="${quoteDesc(entries[name])}"`);
|
|
219
|
+
present.add(name.toLowerCase());
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
const shell = shellMs(record);
|
|
223
|
+
if (shell !== undefined) headers.append("Server-Timing", formatMetric("solid-shell", shell));
|
|
224
|
+
for (const work of record.timing) headers.append("Server-Timing", metricOf(work));
|
|
225
|
+
}
|
|
226
|
+
function metricOf(work) {
|
|
227
|
+
if (work.type === "invocation") return formatMetric("solid-invocation", work.event.durationMs, work.event.id);
|
|
228
|
+
const boundary = work.event;
|
|
229
|
+
return formatMetric("solid-boundary", boundary.durationMs, boundary.ownerPath !== undefined ? boundary.ownerPath.join(" > ") : boundary.id);
|
|
230
|
+
}
|
|
231
|
+
function formatMetric(name, dur, desc) {
|
|
232
|
+
let out = `${name};dur=${Math.round(dur * 10) / 10}`;
|
|
233
|
+
if (desc) out += `;desc="${quoteDesc(desc)}"`;
|
|
234
|
+
return out;
|
|
235
|
+
}
|
|
236
|
+
function mergeServerTiming(target, value) {
|
|
237
|
+
const present = namesOnServerTiming(target);
|
|
238
|
+
for (const entry of splitServerTiming(value)) {
|
|
239
|
+
const trimmed = entry.trim();
|
|
240
|
+
const name = metricName(trimmed);
|
|
241
|
+
if (!name || present.has(name)) continue;
|
|
242
|
+
target.append("Server-Timing", trimmed);
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
function escapeAttr(value) {
|
|
246
|
+
return value.replace(/[&"<>]/g, c => c === "&" ? "&" : c === '"' ? """ : c === "<" ? "<" : ">");
|
|
247
|
+
}
|
|
248
|
+
function traceMetaMarkup(record) {
|
|
249
|
+
if (!record.emit) return "";
|
|
250
|
+
let markup = "";
|
|
251
|
+
const entries = record.context.entries;
|
|
252
|
+
for (const name in entries) {
|
|
253
|
+
if (!TOKEN.test(name)) continue;
|
|
254
|
+
markup += `<meta name="${name}" content="${escapeAttr(entries[name])}">`;
|
|
255
|
+
}
|
|
256
|
+
return markup;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
const DESCEND = Symbol("descend");
|
|
260
|
+
const CYCLE = {};
|
|
261
|
+
const TRACK = 16;
|
|
262
|
+
function rewriteTree(value, visit, withPath) {
|
|
263
|
+
if (value === null || typeof value !== "object") return value;
|
|
264
|
+
const path = undefined;
|
|
265
|
+
const state = {
|
|
266
|
+
memo: undefined,
|
|
267
|
+
ancestors: undefined
|
|
268
|
+
};
|
|
269
|
+
try {
|
|
270
|
+
return cow(value, visit, path, 0, state);
|
|
271
|
+
} catch (err) {
|
|
272
|
+
if (err !== CYCLE) throw err;
|
|
273
|
+
}
|
|
274
|
+
return clone(value, visit, path, state.memo || (state.memo = new Map()));
|
|
275
|
+
}
|
|
276
|
+
function shape(value) {
|
|
277
|
+
return Array.isArray(value) ? 1 : Object.getPrototypeOf(value) === Object.prototype ? 2 : 0;
|
|
278
|
+
}
|
|
279
|
+
function cow(value, visit, path, depth, state) {
|
|
280
|
+
const memo = state.memo;
|
|
281
|
+
if (memo !== undefined && memo.has(value)) return memo.get(value);
|
|
282
|
+
const r = visit(value, path);
|
|
283
|
+
if (r !== DESCEND) {
|
|
284
|
+
if (r !== value) (memo || (state.memo = new Map())).set(value, r);
|
|
285
|
+
return r;
|
|
286
|
+
}
|
|
287
|
+
const s = shape(value);
|
|
288
|
+
if (s === 0) return value;
|
|
289
|
+
let ancestors;
|
|
290
|
+
if (depth >= TRACK) {
|
|
291
|
+
ancestors = state.ancestors || (state.ancestors = new Set());
|
|
292
|
+
if (ancestors.has(value)) throw CYCLE;
|
|
293
|
+
ancestors.add(value);
|
|
294
|
+
}
|
|
295
|
+
let out = value;
|
|
296
|
+
if (s === 1) {
|
|
297
|
+
for (let i = 0; i < value.length; i++) {
|
|
298
|
+
const c = value[i];
|
|
299
|
+
if (c === null || typeof c !== "object") continue;
|
|
300
|
+
const next = cow(c, visit, undefined , depth + 1, state);
|
|
301
|
+
if (next !== c) {
|
|
302
|
+
if (out === value) out = value.slice();
|
|
303
|
+
out[i] = next;
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
} else {
|
|
307
|
+
for (const k of Object.keys(value)) {
|
|
308
|
+
const c = value[k];
|
|
309
|
+
if (c === null || typeof c !== "object") continue;
|
|
310
|
+
const next = cow(c, visit, undefined , depth + 1, state);
|
|
311
|
+
if (next !== c) {
|
|
312
|
+
if (out === value) out = {
|
|
313
|
+
...value
|
|
314
|
+
};
|
|
315
|
+
out[k] = next;
|
|
316
|
+
}
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
if (ancestors !== undefined) ancestors.delete(value);
|
|
320
|
+
return out;
|
|
321
|
+
}
|
|
322
|
+
function clone(value, visit, path, memo) {
|
|
323
|
+
if (memo.has(value)) return memo.get(value);
|
|
324
|
+
const r = visit(value, path);
|
|
325
|
+
if (r !== DESCEND) {
|
|
326
|
+
memo.set(value, r);
|
|
327
|
+
return r;
|
|
328
|
+
}
|
|
329
|
+
const s = shape(value);
|
|
330
|
+
if (s === 0) return value;
|
|
331
|
+
const out = s === 1 ? value.slice() : {
|
|
332
|
+
...value
|
|
333
|
+
};
|
|
334
|
+
memo.set(value, out);
|
|
335
|
+
if (s === 1) {
|
|
336
|
+
for (let i = 0; i < value.length; i++) {
|
|
337
|
+
const c = value[i];
|
|
338
|
+
if (c !== null && typeof c === "object") out[i] = clone(c, visit, undefined , memo);
|
|
339
|
+
}
|
|
340
|
+
} else {
|
|
341
|
+
for (const k of Object.keys(value)) {
|
|
342
|
+
const c = value[k];
|
|
343
|
+
if (c !== null && typeof c === "object") out[k] = clone(c, visit, undefined , memo);
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
return out;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
const STATE = Symbol.for("solid.container-trace-state");
|
|
67
350
|
const state = globalThis[STATE] || (globalThis[STATE] = {
|
|
68
351
|
materialized: new WeakMap(),
|
|
69
352
|
materializedValues: new WeakSet()
|
|
@@ -71,14 +354,33 @@ const state = globalThis[STATE] || (globalThis[STATE] = {
|
|
|
71
354
|
function setContainerTraceResolver(fn) {
|
|
72
355
|
state.resolveTrace = fn;
|
|
73
356
|
}
|
|
357
|
+
function setAsyncIterableSharer(fn) {
|
|
358
|
+
state.shareIterable = fn;
|
|
359
|
+
}
|
|
74
360
|
function setContainerTraceStreamMint(fn) {
|
|
75
361
|
state.streamOf = fn;
|
|
76
362
|
}
|
|
77
|
-
const TRACE = Symbol.for("
|
|
78
|
-
function
|
|
363
|
+
const TRACE = Symbol.for("solid.container-trace");
|
|
364
|
+
function toBorderForm(value, envelopeContainers) {
|
|
365
|
+
if (value == null || typeof value !== "object") return value;
|
|
366
|
+
const share = state.shareIterable;
|
|
367
|
+
if (!share) return value;
|
|
368
|
+
return rewriteTree(value, v => {
|
|
369
|
+
if (share && isShareableIterable(v)) return share(v);
|
|
370
|
+
return DESCEND;
|
|
371
|
+
});
|
|
372
|
+
}
|
|
373
|
+
function isShareableIterable(value) {
|
|
374
|
+
try {
|
|
375
|
+
return typeof value[Symbol.asyncIterator] === "function" && !(typeof ReadableStream !== "undefined" && value instanceof ReadableStream);
|
|
376
|
+
} catch {
|
|
377
|
+
return false;
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
function materialize(marker, claiming) {
|
|
79
381
|
let value = state.materialized.get(marker.$tr);
|
|
80
382
|
if (value === undefined) {
|
|
81
|
-
value = state.materializeTrace(marker);
|
|
383
|
+
value = state.materializeTrace(marker, claiming);
|
|
82
384
|
state.materialized.set(marker.$tr, value);
|
|
83
385
|
if (value !== null && typeof value === "object") state.materializedValues.add(value);
|
|
84
386
|
}
|
|
@@ -93,7 +395,7 @@ function parseTrace(value, ctx) {
|
|
|
93
395
|
};
|
|
94
396
|
}
|
|
95
397
|
const ContainerTracePlugin = {
|
|
96
|
-
tag: "
|
|
398
|
+
tag: "solid/container-trace",
|
|
97
399
|
test(value) {
|
|
98
400
|
return value != null && typeof value === "object" && TRACE in value;
|
|
99
401
|
},
|
|
@@ -136,25 +438,101 @@ setContainerTraceStreamMint(iterable => {
|
|
|
136
438
|
})();
|
|
137
439
|
return stream;
|
|
138
440
|
});
|
|
139
|
-
const DEFAULT_WEB_PLUGINS = Object.freeze([AbortSignalPlugin,
|
|
441
|
+
const DEFAULT_WEB_PLUGINS = /* @__PURE__ */Object.freeze([AbortSignalPlugin,
|
|
140
442
|
CustomEventPlugin, DOMExceptionPlugin, EventPlugin,
|
|
141
443
|
FormDataPlugin, HeadersPlugin, ReadableStreamPlugin, RequestPlugin, ResponsePlugin, URLSearchParamsPlugin, URLPlugin,
|
|
142
444
|
ContainerTracePlugin]);
|
|
143
445
|
function resolveSerializerPlugins(customPlugins) {
|
|
144
446
|
return customPlugins ? [...customPlugins, ...DEFAULT_WEB_PLUGINS] : [...DEFAULT_WEB_PLUGINS];
|
|
145
447
|
}
|
|
146
|
-
Feature.RegExp;
|
|
147
448
|
|
|
148
|
-
const
|
|
149
|
-
const serializeOnlyDisabledFeatures =
|
|
449
|
+
const defaultDisabledFeatures = () => Feature.AggregateError | Feature.BigIntTypedArray;
|
|
450
|
+
const serializeOnlyDisabledFeatures = serializeErrorStacks => (process.env.NODE_ENV === "development" ) ? 0 : Feature.ErrorPrototypeStack;
|
|
150
451
|
const HYDRATION_GLOBAL = "_$HY.r";
|
|
151
|
-
function
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
452
|
+
function createKeyedSerializer(serialize, onError, onDone) {
|
|
453
|
+
const cancels = new Set();
|
|
454
|
+
let pendingWrites = 0;
|
|
455
|
+
let flushed = false;
|
|
456
|
+
let done = false;
|
|
457
|
+
let closed = false;
|
|
458
|
+
const maybeDone = () => {
|
|
459
|
+
if (flushed && pendingWrites === 0 && !done) {
|
|
460
|
+
done = true;
|
|
461
|
+
onDone && onDone();
|
|
462
|
+
}
|
|
463
|
+
};
|
|
464
|
+
return {
|
|
465
|
+
write(key, value) {
|
|
466
|
+
if (flushed) return;
|
|
467
|
+
pendingWrites++;
|
|
468
|
+
let settled = false;
|
|
469
|
+
let failed = false;
|
|
470
|
+
let started = false;
|
|
471
|
+
let cancel = null;
|
|
472
|
+
const settle = () => {
|
|
473
|
+
if (settled) return;
|
|
474
|
+
settled = true;
|
|
475
|
+
if (cancel) cancels.delete(cancel);
|
|
476
|
+
pendingWrites--;
|
|
477
|
+
maybeDone();
|
|
478
|
+
};
|
|
479
|
+
let stream;
|
|
480
|
+
try {
|
|
481
|
+
stream = serialize(key, value, {
|
|
482
|
+
onError: onError && (err => {
|
|
483
|
+
failed = true;
|
|
484
|
+
onError(err);
|
|
485
|
+
if (cancel) {
|
|
486
|
+
cancel();
|
|
487
|
+
settle();
|
|
488
|
+
}
|
|
489
|
+
}),
|
|
490
|
+
onDone: settle
|
|
491
|
+
}, initial => {
|
|
492
|
+
if (initial) started = true;
|
|
493
|
+
return !closed;
|
|
494
|
+
});
|
|
495
|
+
} catch (err) {
|
|
496
|
+
settle();
|
|
497
|
+
throw err;
|
|
498
|
+
}
|
|
499
|
+
if (settled) return;
|
|
500
|
+
if (closed || failed) {
|
|
501
|
+
stream();
|
|
502
|
+
settle();
|
|
503
|
+
return;
|
|
504
|
+
}
|
|
505
|
+
cancel = stream;
|
|
506
|
+
cancels.add(cancel);
|
|
507
|
+
},
|
|
508
|
+
flush() {
|
|
509
|
+
flushed = true;
|
|
510
|
+
maybeDone();
|
|
511
|
+
},
|
|
512
|
+
close() {
|
|
513
|
+
closed = flushed = true;
|
|
514
|
+
for (const cancel of cancels) cancel();
|
|
515
|
+
cancels.clear();
|
|
516
|
+
if (!done) {
|
|
517
|
+
done = true;
|
|
518
|
+
onDone && onDone();
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
};
|
|
157
522
|
}
|
|
523
|
+
const KEY_ESCAPES = {
|
|
524
|
+
'"': '\\"',
|
|
525
|
+
"\\": "\\\\",
|
|
526
|
+
"\n": "\\n",
|
|
527
|
+
"\r": "\\r",
|
|
528
|
+
"\b": "\\b",
|
|
529
|
+
"\t": "\\t",
|
|
530
|
+
"\f": "\\f",
|
|
531
|
+
"<": "\\x3C",
|
|
532
|
+
"\u2028": "\\u2028",
|
|
533
|
+
"\u2029": "\\u2029"
|
|
534
|
+
};
|
|
535
|
+
const serializeKey = key => ("" + key).replace(/["\\\n\r\b\t\f<\u2028\u2029]/g, c => KEY_ESCAPES[c]);
|
|
158
536
|
function createHydrationSerializer({
|
|
159
537
|
onData,
|
|
160
538
|
onDone,
|
|
@@ -162,31 +540,44 @@ function createHydrationSerializer({
|
|
|
162
540
|
onError,
|
|
163
541
|
plugins
|
|
164
542
|
}) {
|
|
165
|
-
|
|
543
|
+
const resolvedPlugins = resolveSerializerPlugins(plugins);
|
|
544
|
+
const disabledFeatures = defaultDisabledFeatures() | serializeOnlyDisabledFeatures();
|
|
545
|
+
const refs = new Map();
|
|
546
|
+
return createKeyedSerializer((key, value, callbacks, live) => crossSerializeStream(value, {
|
|
166
547
|
scopeId,
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
548
|
+
refs,
|
|
549
|
+
plugins: resolvedPlugins,
|
|
550
|
+
disabledFeatures,
|
|
551
|
+
onSerialize(data, initial) {
|
|
552
|
+
if (!live(initial)) return;
|
|
553
|
+
onData(initial ? HYDRATION_GLOBAL + '["' + serializeKey(key) + '"]=' + data : data);
|
|
554
|
+
},
|
|
555
|
+
...callbacks
|
|
556
|
+
}), onError, onDone);
|
|
173
557
|
}
|
|
174
558
|
function getLocalHeaderScript(id) {
|
|
175
559
|
return getCrossReferenceHeader(id) + ";";
|
|
176
560
|
}
|
|
177
561
|
|
|
178
562
|
const ENVELOPE = Symbol.for("solid.ResponseEnvelope");
|
|
179
|
-
|
|
180
|
-
const ResponseEnvelope =
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
563
|
+
let EnvelopeClass;
|
|
564
|
+
const ResponseEnvelope = function ResponseEnvelope(response, value) {
|
|
565
|
+
if (!EnvelopeClass) {
|
|
566
|
+
EnvelopeClass = class extends Response {
|
|
567
|
+
constructor(response, value) {
|
|
568
|
+
super(response ? response.body : null, response && {
|
|
569
|
+
status: response.status,
|
|
570
|
+
statusText: response.statusText,
|
|
571
|
+
headers: copyHeaders(response.headers)
|
|
572
|
+
});
|
|
573
|
+
this.response = response ? this : undefined;
|
|
574
|
+
this.value = value;
|
|
575
|
+
}
|
|
576
|
+
};
|
|
577
|
+
EnvelopeClass.prototype[ENVELOPE] = true;
|
|
186
578
|
}
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
})();
|
|
579
|
+
return new EnvelopeClass(response, value);
|
|
580
|
+
};
|
|
190
581
|
function isResponseEnvelope(value) {
|
|
191
582
|
return !!(value && typeof value === "object" && value[ENVELOPE]);
|
|
192
583
|
}
|
|
@@ -209,24 +600,38 @@ function isSafeError(value) {
|
|
|
209
600
|
return !!(value && (typeof value === "object" || typeof value === "function") && value[SAFE_ERROR]);
|
|
210
601
|
}
|
|
211
602
|
const REVALIDATE_HEADER = "X-Revalidate";
|
|
212
|
-
|
|
603
|
+
const REVALIDATE_ALL = "*";
|
|
604
|
+
const RESPONSE_HEADER_VALUE_LIMIT = 4096;
|
|
605
|
+
function copyHeaders(init) {
|
|
606
|
+
const source = init;
|
|
607
|
+
if (!source || !source.getSetCookie) return new Headers(init);
|
|
608
|
+
const headers = new Headers();
|
|
609
|
+
source.forEach((value, key) => {
|
|
610
|
+
if (key !== "set-cookie") headers.append(key, value);
|
|
611
|
+
});
|
|
612
|
+
for (const cookie of source.getSetCookie()) headers.append("Set-Cookie", cookie);
|
|
613
|
+
return headers;
|
|
614
|
+
}
|
|
615
|
+
function initWithRevalidate(init = {}) {
|
|
616
|
+
const resolved = typeof init === "number" ? {
|
|
617
|
+
status: init
|
|
618
|
+
} : init;
|
|
213
619
|
const {
|
|
214
620
|
revalidate,
|
|
215
621
|
...responseInit
|
|
216
|
-
} =
|
|
217
|
-
|
|
218
|
-
if (
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
});
|
|
223
|
-
for (const cookie of responseInit.headers.getSetCookie()) {
|
|
224
|
-
headers.append("Set-Cookie", cookie);
|
|
622
|
+
} = resolved;
|
|
623
|
+
const headers = copyHeaders(responseInit.headers);
|
|
624
|
+
if (revalidate !== undefined) {
|
|
625
|
+
const list = Array.isArray(revalidate) ? revalidate : [revalidate];
|
|
626
|
+
if (list.length > 1 && list.includes(REVALIDATE_ALL)) {
|
|
627
|
+
throw new TypeError(`revalidate names "${REVALIDATE_ALL}" alongside other keys; "${REVALIDATE_ALL}" already ` + `means every entry and stands alone — pass revalidate: "${REVALIDATE_ALL}" or the named keys.`);
|
|
225
628
|
}
|
|
226
|
-
|
|
227
|
-
|
|
629
|
+
const keys = list.join(",");
|
|
630
|
+
if (keys.length > RESPONSE_HEADER_VALUE_LIMIT) {
|
|
631
|
+
throw new TypeError(`revalidate names ${keys.length} characters of cache keys; past ` + `${RESPONSE_HEADER_VALUE_LIMIT} the ${REVALIDATE_HEADER} header would overflow ` + `receivers (an 8 KiB proxy buffer holds the whole header block) and the response ` + `dies at the socket after the mutation committed. Split the invalidation across ` + `calls or use coarser keys — a dropped key would be a silently stale cache, so ` + `the runtime refuses rather than trims.`);
|
|
632
|
+
}
|
|
633
|
+
headers.set(REVALIDATE_HEADER, keys);
|
|
228
634
|
}
|
|
229
|
-
revalidate !== undefined && headers.set(REVALIDATE_HEADER, revalidate.toString());
|
|
230
635
|
return {
|
|
231
636
|
responseInit,
|
|
232
637
|
headers
|
|
@@ -239,13 +644,17 @@ function redirect(url, init = 302) {
|
|
|
239
644
|
const {
|
|
240
645
|
responseInit,
|
|
241
646
|
headers
|
|
242
|
-
} = initWithRevalidate(
|
|
243
|
-
status: init
|
|
244
|
-
} : init);
|
|
647
|
+
} = initWithRevalidate(init);
|
|
245
648
|
if (responseInit.status === undefined) {
|
|
246
649
|
responseInit.status = 302;
|
|
247
650
|
}
|
|
248
|
-
|
|
651
|
+
const target = typeof url === "string" ? url : url[HREF];
|
|
652
|
+
const location = typeof target === "string" ? target : String(url);
|
|
653
|
+
const encoded = location.replace(/[^\x00-\x7f]/gu, encodeURIComponent);
|
|
654
|
+
if (encoded.length > RESPONSE_HEADER_VALUE_LIMIT) {
|
|
655
|
+
throw new TypeError(`redirect() target is ${encoded.length} characters; past ` + `${RESPONSE_HEADER_VALUE_LIMIT} the Location header (and the scripted transport's ` + `redirect header) would overflow receivers and the response dies at the socket. ` + `A target this size is usually unbounded input echoed into the url — carry the ` + `state server-side instead. Refused rather than trimmed: a cut target is a ` + `different address.`);
|
|
656
|
+
}
|
|
657
|
+
headers.set("Location", encoded);
|
|
249
658
|
return new Response(null, {
|
|
250
659
|
...responseInit,
|
|
251
660
|
headers
|
|
@@ -261,13 +670,26 @@ function reload(init = {}) {
|
|
|
261
670
|
headers
|
|
262
671
|
});
|
|
263
672
|
}
|
|
673
|
+
const NULL_BODY_STATUSES = new Set([204, 205, 304]);
|
|
264
674
|
function respond(value, init = {}) {
|
|
265
675
|
const {
|
|
266
676
|
responseInit,
|
|
267
677
|
headers
|
|
268
678
|
} = initWithRevalidate(init);
|
|
679
|
+
for (const header of COMPOSED_BODY_FRAMING) headers.delete(header);
|
|
680
|
+
if (NULL_BODY_STATUSES.has(responseInit.status)) {
|
|
681
|
+
return new ResponseEnvelope(new Response(null, {
|
|
682
|
+
...responseInit,
|
|
683
|
+
headers
|
|
684
|
+
}), value);
|
|
685
|
+
}
|
|
269
686
|
headers.set("Content-Type", "application/json");
|
|
270
|
-
return new ResponseEnvelope(new Response(
|
|
687
|
+
return new ResponseEnvelope(new Response(new ReadableStream({
|
|
688
|
+
pull(controller) {
|
|
689
|
+
controller.enqueue(new TextEncoder().encode(JSON.stringify(value)));
|
|
690
|
+
controller.close();
|
|
691
|
+
}
|
|
692
|
+
}), {
|
|
271
693
|
...responseInit,
|
|
272
694
|
headers
|
|
273
695
|
}), value);
|
|
@@ -316,6 +738,7 @@ function serializeCookie(name, value, options = {}) {
|
|
|
316
738
|
if (options.expires) cookie += `; Expires=${options.expires.toUTCString()}`;
|
|
317
739
|
if (options.httpOnly) cookie += "; HttpOnly";
|
|
318
740
|
if (options.secure) cookie += "; Secure";
|
|
741
|
+
if (options.partitioned) cookie += "; Partitioned";
|
|
319
742
|
if (options.sameSite) {
|
|
320
743
|
const sameSite = options.sameSite.toLowerCase();
|
|
321
744
|
cookie += `; SameSite=${sameSite === "none" ? "None" : sameSite === "strict" ? "Strict" : "Lax"}`;
|
|
@@ -323,7 +746,7 @@ function serializeCookie(name, value, options = {}) {
|
|
|
323
746
|
return cookie;
|
|
324
747
|
}
|
|
325
748
|
const FLASH_COOKIE = "flash";
|
|
326
|
-
const FLASH_MATCHER =
|
|
749
|
+
const FLASH_MATCHER = /(?:^|;\s*)flash=([^;]+)/;
|
|
327
750
|
function hasFlashCookie(cookieHeader) {
|
|
328
751
|
return !!cookieHeader && FLASH_MATCHER.test(cookieHeader);
|
|
329
752
|
}
|
|
@@ -333,6 +756,7 @@ function clearFlashCookie() {
|
|
|
333
756
|
|
|
334
757
|
const ERROR_HEADER = "X-Server-Function-Error";
|
|
335
758
|
const BODY_FORMAT_HEADER = "X-Server-Function-Format";
|
|
759
|
+
const REDIRECT_HEADER = "X-Server-Function-Redirect";
|
|
336
760
|
const SINGLE_FLIGHT_HEADER = "X-Single-Flight";
|
|
337
761
|
|
|
338
762
|
const HEAD_ELIGIBLE_TAGS = new Set(["title", "meta", "link", "style", "script", "base"]);
|
|
@@ -367,11 +791,28 @@ function classifyHeadTag(desc) {
|
|
|
367
791
|
resource: false
|
|
368
792
|
};
|
|
369
793
|
}
|
|
794
|
+
function qualifierValue(name, value) {
|
|
795
|
+
if (value == null || value === false) return null;
|
|
796
|
+
if (name === "imagesrcset" || name === "imagesizes") return typeof value === "string" && value !== "" ? value : null;
|
|
797
|
+
const v = value === true ? "" : String(value);
|
|
798
|
+
if (name === "as") return asciiLowerCase(v);
|
|
799
|
+
if (name !== "crossorigin") return v;
|
|
800
|
+
return v.length === 15 && v.toLowerCase() === "use-credentials" ? v.toLowerCase() : "anonymous";
|
|
801
|
+
}
|
|
802
|
+
function asciiLowerCase(value) {
|
|
803
|
+
return value.replace(/[A-Z]/g, c => String.fromCharCode(c.charCodeAt(0) + 32));
|
|
804
|
+
}
|
|
805
|
+
const JSON_SCRIPT_TYPE = /^(?:importmap|speculationrules)$|^[\t\n\r ]*(?:application\/json|text\/json|[\w!#$%&'*+.^`|~-]+\/[\w!#$%&'*+.^`|~-]*\+json)[\t\n\r ]*(?:;|$)/i;
|
|
806
|
+
function headBodyText(tag, props, text) {
|
|
807
|
+
return tag === "script" && JSON_SCRIPT_TYPE.test(String(props.type)) ? text.replace(/</g, "\\u003C") : text;
|
|
808
|
+
}
|
|
370
809
|
function resourceIdentity(tag, props) {
|
|
371
|
-
|
|
810
|
+
const url = String(props.href || props.src || "");
|
|
811
|
+
let id = "res:" + tag + ":" + (props.rel || "") + ":" + url.length + ":" + url;
|
|
372
812
|
for (let i = 0; i < RESOURCE_QUALIFIERS.length; i++) {
|
|
373
813
|
const q = RESOURCE_QUALIFIERS[i];
|
|
374
|
-
|
|
814
|
+
const value = qualifierValue(q, props[q]);
|
|
815
|
+
if (value !== null) id += ":" + q + "=" + value.length + ":" + value;
|
|
375
816
|
}
|
|
376
817
|
return id;
|
|
377
818
|
}
|
|
@@ -420,6 +861,7 @@ function resolveHead(groups) {
|
|
|
420
861
|
return winners;
|
|
421
862
|
}
|
|
422
863
|
|
|
864
|
+
const renderConfig = sharedConfig;
|
|
423
865
|
function joinAssetPath(base, file) {
|
|
424
866
|
if (/^(?:[a-z][a-z0-9+.-]*:)?\/\//i.test(file)) return file;
|
|
425
867
|
if (typeof base !== "string" || !base) base = "/";
|
|
@@ -433,6 +875,7 @@ function resolveAssets(moduleUrl, manifest) {
|
|
|
433
875
|
if (!entry) return null;
|
|
434
876
|
const css = [];
|
|
435
877
|
const js = [];
|
|
878
|
+
let preloads;
|
|
436
879
|
const visited = new Set();
|
|
437
880
|
const walk = key => {
|
|
438
881
|
if (visited.has(key)) return;
|
|
@@ -441,13 +884,34 @@ function resolveAssets(moduleUrl, manifest) {
|
|
|
441
884
|
if (!e) return;
|
|
442
885
|
js.push(joinAssetPath(base, e.file));
|
|
443
886
|
if (e.css) for (let i = 0; i < e.css.length; i++) css.push(joinAssetPath(base, e.css[i]));
|
|
887
|
+
if (e.preloads) {
|
|
888
|
+
for (let i = 0; i < e.preloads.length; i++) {
|
|
889
|
+
const link = e.preloads[i];
|
|
890
|
+
const href = link && typeof link.href === "string" && link.href;
|
|
891
|
+
const srcset = link && typeof link.imagesrcset === "string" && link.imagesrcset;
|
|
892
|
+
if (!href && !srcset) continue;
|
|
893
|
+
if (!preloads) preloads = [];
|
|
894
|
+
if (href) preloads.push({
|
|
895
|
+
...link,
|
|
896
|
+
href: joinAssetPath(base, href)
|
|
897
|
+
});else {
|
|
898
|
+
const {
|
|
899
|
+
href: bad,
|
|
900
|
+
...rest
|
|
901
|
+
} = link;
|
|
902
|
+
preloads.push(rest);
|
|
903
|
+
}
|
|
904
|
+
}
|
|
905
|
+
}
|
|
444
906
|
if (e.imports) for (let i = 0; i < e.imports.length; i++) walk(e.imports[i]);
|
|
445
907
|
};
|
|
446
908
|
walk(moduleUrl);
|
|
447
|
-
|
|
909
|
+
const assets = {
|
|
448
910
|
js,
|
|
449
911
|
css
|
|
450
912
|
};
|
|
913
|
+
if (preloads) assets.preloads = preloads;
|
|
914
|
+
return assets;
|
|
451
915
|
}
|
|
452
916
|
function registerEntryAssets(manifest) {
|
|
453
917
|
if (!manifest || typeof manifest === "function" || typeof manifest.resolve === "function") return;
|
|
@@ -457,6 +921,7 @@ function registerEntryAssets(manifest) {
|
|
|
457
921
|
if (manifest[key].isEntry) {
|
|
458
922
|
const assets = resolveAssets(key, manifest);
|
|
459
923
|
if (assets) {
|
|
924
|
+
if (assets.preloads) for (let i = 0; i < assets.preloads.length; i++) ctx.registerAsset("preload", assets.preloads[i]);
|
|
460
925
|
for (let i = 0; i < assets.css.length; i++) ctx.registerAsset("style", assets.css[i]);
|
|
461
926
|
for (let i = 1; i < assets.js.length; i++) ctx.registerAsset("module", assets.js[i]);
|
|
462
927
|
}
|
|
@@ -475,6 +940,7 @@ function createAssetTracking() {
|
|
|
475
940
|
boundaryStyles,
|
|
476
941
|
emittedAssets,
|
|
477
942
|
inlineStyles,
|
|
943
|
+
preloadLinks: null,
|
|
478
944
|
registerInlineStyle(desc) {
|
|
479
945
|
let entry = inlineStyles.get(desc.id);
|
|
480
946
|
if (!entry) {
|
|
@@ -549,6 +1015,7 @@ function applyAssetTracking(context, tracking, manifest, noScripts) {
|
|
|
549
1015
|
});
|
|
550
1016
|
context.registerModule = tracking.registerModule;
|
|
551
1017
|
context.getBoundaryModules = tracking.getBoundaryModules;
|
|
1018
|
+
context._lazyAssets = new Map();
|
|
552
1019
|
if (typeof manifest === "function") {
|
|
553
1020
|
context.resolveAssets = guard(manifest);
|
|
554
1021
|
} else if (manifest && typeof manifest.resolve === "function") {
|
|
@@ -566,6 +1033,82 @@ function isCssUrl(url) {
|
|
|
566
1033
|
const q = url.search(/[?#]/);
|
|
567
1034
|
return (q === -1 ? url : url.slice(0, q)).endsWith(".css");
|
|
568
1035
|
}
|
|
1036
|
+
const RESPONSIVE_ATTRIBUTES = ["imagesrcset", "imagesizes"];
|
|
1037
|
+
function isSetAttr(value) {
|
|
1038
|
+
return value != null && value !== false && value !== "";
|
|
1039
|
+
}
|
|
1040
|
+
const PRELOAD_LINK_ATTRIBUTES = ["type", "crossorigin", "integrity", "referrerpolicy", "fetchpriority", "media", "imagesrcset", "imagesizes"];
|
|
1041
|
+
function registerPreloadLink(tracking, headRegistry, link, nonce) {
|
|
1042
|
+
if (!link || typeof link !== "object") {
|
|
1043
|
+
return null;
|
|
1044
|
+
}
|
|
1045
|
+
if (typeof link.as !== "string") {
|
|
1046
|
+
return null;
|
|
1047
|
+
}
|
|
1048
|
+
const as = asciiLowerCase(link.as);
|
|
1049
|
+
let destination = null;
|
|
1050
|
+
switch (as) {
|
|
1051
|
+
case "script":
|
|
1052
|
+
case "style":
|
|
1053
|
+
destination = as;
|
|
1054
|
+
break;
|
|
1055
|
+
case "fetch":
|
|
1056
|
+
case "font":
|
|
1057
|
+
case "image":
|
|
1058
|
+
case "track":
|
|
1059
|
+
break;
|
|
1060
|
+
default:
|
|
1061
|
+
return null;
|
|
1062
|
+
}
|
|
1063
|
+
const responsive = as === "image";
|
|
1064
|
+
let srcset = null;
|
|
1065
|
+
let sizes = null;
|
|
1066
|
+
if (responsive) {
|
|
1067
|
+
for (const name of RESPONSIVE_ATTRIBUTES) {
|
|
1068
|
+
const value = link[name];
|
|
1069
|
+
if (!isSetAttr(value)) continue;
|
|
1070
|
+
if (typeof value !== "string") {
|
|
1071
|
+
continue;
|
|
1072
|
+
}
|
|
1073
|
+
if (name === "imagesrcset") srcset = value;else sizes = value;
|
|
1074
|
+
}
|
|
1075
|
+
}
|
|
1076
|
+
const href = typeof link.href === "string" && link.href ? link.href : null;
|
|
1077
|
+
if (!href && !srcset) {
|
|
1078
|
+
return null;
|
|
1079
|
+
}
|
|
1080
|
+
const props = {
|
|
1081
|
+
rel: "preload"
|
|
1082
|
+
};
|
|
1083
|
+
if (href) props.href = href;
|
|
1084
|
+
props.as = as;
|
|
1085
|
+
for (let i = 0; i < PRELOAD_LINK_ATTRIBUTES.length; i++) {
|
|
1086
|
+
const name = PRELOAD_LINK_ATTRIBUTES[i];
|
|
1087
|
+
if (RESPONSIVE_ATTRIBUTES.indexOf(name) !== -1) {
|
|
1088
|
+
const value = name === "imagesrcset" ? srcset : sizes;
|
|
1089
|
+
if (value !== null) props[name] = value;
|
|
1090
|
+
continue;
|
|
1091
|
+
}
|
|
1092
|
+
const value = link[name];
|
|
1093
|
+
if (value == null || value === false) continue;
|
|
1094
|
+
props[name] = value === true ? "" : String(value);
|
|
1095
|
+
}
|
|
1096
|
+
const identity = resourceIdentity("link", props);
|
|
1097
|
+
if (headRegistry.resources.has(identity)) return null;
|
|
1098
|
+
const attrs = headAttrRecord(props);
|
|
1099
|
+
const nonceValue = destination && nonce && nonce[destination];
|
|
1100
|
+
if (typeof nonceValue === "string" && nonceValue) attrs.nonce = nonceValue;
|
|
1101
|
+
const entry = {
|
|
1102
|
+
href: props.href,
|
|
1103
|
+
attrs,
|
|
1104
|
+
attrHtml: renderHeadAttrHtml(props) + nonceAttr(nonce, destination)
|
|
1105
|
+
};
|
|
1106
|
+
headRegistry.resources.add(identity);
|
|
1107
|
+
let links = tracking.preloadLinks;
|
|
1108
|
+
if (!links) tracking.preloadLinks = links = [];
|
|
1109
|
+
links.push(entry);
|
|
1110
|
+
return entry;
|
|
1111
|
+
}
|
|
569
1112
|
function createHeadRegistry() {
|
|
570
1113
|
return {
|
|
571
1114
|
pending: [],
|
|
@@ -816,7 +1359,7 @@ function headGroupSignature(winner) {
|
|
|
816
1359
|
}
|
|
817
1360
|
return sig;
|
|
818
1361
|
}
|
|
819
|
-
function renderShellHead(registry, nonce, isPendingFragment, noScripts) {
|
|
1362
|
+
function renderShellHead(registry, nonce, isPendingFragment, noScripts, traceMetas = "") {
|
|
820
1363
|
commitHeadBoundary(registry, "", isPendingFragment);
|
|
821
1364
|
registry.shellFlushed = true;
|
|
822
1365
|
const winners = resolveHead(registry.committed);
|
|
@@ -842,11 +1385,12 @@ function renderShellHead(registry, nonce, isPendingFragment, noScripts) {
|
|
|
842
1385
|
}
|
|
843
1386
|
return {
|
|
844
1387
|
prelude,
|
|
845
|
-
html: registry.eagerHtml + links + metas + others + scripts,
|
|
1388
|
+
html: registry.eagerHtml + links + metas + traceMetas + others + scripts,
|
|
846
1389
|
title,
|
|
847
1390
|
noScripts
|
|
848
1391
|
};
|
|
849
1392
|
}
|
|
1393
|
+
let headBodyHook;
|
|
850
1394
|
function flushHeadFragment(registry, boundary, nonce) {
|
|
851
1395
|
const groups = commitHeadBoundary(registry, boundary);
|
|
852
1396
|
if (!groups.length) return null;
|
|
@@ -870,7 +1414,7 @@ function flushHeadFragment(registry, boundary, nonce) {
|
|
|
870
1414
|
const t = winner.tags[i];
|
|
871
1415
|
const attrs = {};
|
|
872
1416
|
for (const name in t.props) {
|
|
873
|
-
if (name === "children" || name === "ref" || name
|
|
1417
|
+
if (name === "children" || name === "ref" || isEventName(name)) continue;
|
|
874
1418
|
if (!HEAD_ATTR_NAME.test(name)) {
|
|
875
1419
|
continue;
|
|
876
1420
|
}
|
|
@@ -884,7 +1428,7 @@ function flushHeadFragment(registry, boundary, nonce) {
|
|
|
884
1428
|
if (value) attrs.nonce = String(value);
|
|
885
1429
|
}
|
|
886
1430
|
const children = t.props.children;
|
|
887
|
-
ops.push(["a", identity, t.tag, attrs, children == null ? null : String(children)]);
|
|
1431
|
+
ops.push(["a", identity, t.tag, attrs, children == null ? null : headBodyHook ? headBodyHook(t.tag, t.props, String(children)) : String(children)]);
|
|
888
1432
|
}
|
|
889
1433
|
}
|
|
890
1434
|
return ops.length ? ops : null;
|
|
@@ -912,19 +1456,9 @@ function normalizeNonce(nonce) {
|
|
|
912
1456
|
}
|
|
913
1457
|
function destinationNonce(nonce, destination) {
|
|
914
1458
|
if (nonce == null) return undefined;
|
|
915
|
-
|
|
916
|
-
const value = nonce[destination];
|
|
1459
|
+
const value = typeof nonce === "string" ? nonce : nonce[destination];
|
|
917
1460
|
return typeof value === "string" && value ? value : undefined;
|
|
918
1461
|
}
|
|
919
|
-
function scriptNonce(nonce) {
|
|
920
|
-
return destinationNonce(nonce, "script");
|
|
921
|
-
}
|
|
922
|
-
function styleNonce(nonce) {
|
|
923
|
-
return destinationNonce(nonce, "style");
|
|
924
|
-
}
|
|
925
|
-
function asciiLowerCase(value) {
|
|
926
|
-
return value.replace(/[A-Z]/g, c => String.fromCharCode(c.charCodeAt(0) + 32));
|
|
927
|
-
}
|
|
928
1462
|
function hasNonceProp(props) {
|
|
929
1463
|
for (const name in props) if (name.length === 5 && asciiLowerCase(name) === "nonce" && props[name] != null) return true;
|
|
930
1464
|
return false;
|
|
@@ -962,7 +1496,7 @@ function nonceAttr(nonce, destination) {
|
|
|
962
1496
|
function renderHeadAttrHtml(props) {
|
|
963
1497
|
let attrs = "";
|
|
964
1498
|
for (const name in props) {
|
|
965
|
-
if (name === "children" || name === "ref" || name
|
|
1499
|
+
if (name === "children" || name === "ref" || isEventName(name)) continue;
|
|
966
1500
|
if (!HEAD_ATTR_NAME.test(name)) {
|
|
967
1501
|
continue;
|
|
968
1502
|
}
|
|
@@ -975,7 +1509,7 @@ function renderHeadAttrHtml(props) {
|
|
|
975
1509
|
function headAttrRecord(props, skipRelHref) {
|
|
976
1510
|
let attrs = null;
|
|
977
1511
|
for (const name in props) {
|
|
978
|
-
if (name === "children" || name === "ref" || name
|
|
1512
|
+
if (name === "children" || name === "ref" || isEventName(name)) continue;
|
|
979
1513
|
if ((name === "rel" || name === "href")) continue;
|
|
980
1514
|
if (!HEAD_ATTR_NAME.test(name)) continue;
|
|
981
1515
|
const v = props[name];
|
|
@@ -990,6 +1524,7 @@ function renderHeadTagMarkup(tag, props, identity, nonce) {
|
|
|
990
1524
|
if (nonce && !hasNonceProp(props)) attrs += nonceAttr(nonce, nonceDestination(tag, props));
|
|
991
1525
|
if (tag === "meta" || tag === "link" || tag === "base") return `<${tag}${attrs}>`;
|
|
992
1526
|
let body = props.children == null ? "" : String(props.children);
|
|
1527
|
+
if (headBodyHook) body = headBodyHook(tag, props, body);
|
|
993
1528
|
if (tag === "script") body = body.replace(/<\/(script)/gi, "<\\/$1");else if (tag === "style") body = escapeStyleContent(body);else body = escape(body);
|
|
994
1529
|
return `<${tag}${attrs}>${body}</${tag}>`;
|
|
995
1530
|
}
|
|
@@ -998,10 +1533,51 @@ function useHead(tags) {
|
|
|
998
1533
|
if (!ctx || !ctx.registerHeadTags) {
|
|
999
1534
|
return;
|
|
1000
1535
|
}
|
|
1536
|
+
headBodyHook = headBodyText;
|
|
1001
1537
|
ctx.registerHeadTags(tags);
|
|
1002
1538
|
}
|
|
1003
1539
|
const VOID_ELEMENTS = /^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/i;
|
|
1004
|
-
const
|
|
1540
|
+
const NOT_NAME = /[\0-\x20\x7F-\x9F"'<>/=]/;
|
|
1541
|
+
const TAG_START = /^[a-zA-Z]/;
|
|
1542
|
+
const tagInfos = /*#__PURE__*/new Map();
|
|
1543
|
+
function tagInfo(tag) {
|
|
1544
|
+
let info = tagInfos.get(tag);
|
|
1545
|
+
if (info === undefined) {
|
|
1546
|
+
if (!TAG_START.test(tag) || NOT_NAME.test(tag)) throw new Error(`"${tag}" is not a valid tag name`);
|
|
1547
|
+
let formDefaults, formAttributes;
|
|
1548
|
+
if (tag === "input" || tag === "option") {
|
|
1549
|
+
formDefaults = Object.create(null);
|
|
1550
|
+
formAttributes = Object.create(null);
|
|
1551
|
+
const state = DOMWithState[tag.toUpperCase()];
|
|
1552
|
+
for (const prop in state) {
|
|
1553
|
+
if (state[prop] === 2) {
|
|
1554
|
+
const attr = prop.slice(7).toLowerCase();
|
|
1555
|
+
formDefaults[attr] = prop;
|
|
1556
|
+
formAttributes[prop] = attr;
|
|
1557
|
+
}
|
|
1558
|
+
}
|
|
1559
|
+
}
|
|
1560
|
+
info = {
|
|
1561
|
+
open: "<" + tag,
|
|
1562
|
+
close: "</" + tag + ">",
|
|
1563
|
+
isVoid: VOID_ELEMENTS.test(tag),
|
|
1564
|
+
textarea: tag === "textarea",
|
|
1565
|
+
raw: tag === "script" || tag === "style",
|
|
1566
|
+
formDefaults,
|
|
1567
|
+
formAttributes
|
|
1568
|
+
};
|
|
1569
|
+
if (tagInfos.size < 512) tagInfos.set(tag, info);
|
|
1570
|
+
}
|
|
1571
|
+
return info;
|
|
1572
|
+
}
|
|
1573
|
+
const safeAttrNames = /*#__PURE__*/new Set();
|
|
1574
|
+
function isAttrName(prop) {
|
|
1575
|
+
if (safeAttrNames.has(prop)) return true;
|
|
1576
|
+
if (prop === "" || NOT_NAME.test(prop)) return false;
|
|
1577
|
+
if (safeAttrNames.size < 512) safeAttrNames.add(prop);
|
|
1578
|
+
return true;
|
|
1579
|
+
}
|
|
1580
|
+
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,(_$HY.v=_$HY.v||{})[e]=n.hasAttribute("e")?[...n.content.childNodes]:1,o.replaceWith(n.content),n.remove(),_$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)`;
|
|
1005
1581
|
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)}`;
|
|
1006
1582
|
function renderToString(code, options = {}) {
|
|
1007
1583
|
const {
|
|
@@ -1011,6 +1587,8 @@ function renderToString(code, options = {}) {
|
|
|
1011
1587
|
onHead
|
|
1012
1588
|
} = options;
|
|
1013
1589
|
const nonce = normalizeNonce(options.nonce);
|
|
1590
|
+
const requestEvent = peekRequestEvent();
|
|
1591
|
+
const errorScope = requestEvent || {};
|
|
1014
1592
|
let scripts = "";
|
|
1015
1593
|
const serializer = createHydrationSerializer({
|
|
1016
1594
|
scopeId: renderId,
|
|
@@ -1022,26 +1600,33 @@ function renderToString(code, options = {}) {
|
|
|
1022
1600
|
}
|
|
1023
1601
|
scripts += script + ";";
|
|
1024
1602
|
},
|
|
1025
|
-
onError: options.onError
|
|
1603
|
+
onError: serializerErrorHook(options.onError)
|
|
1026
1604
|
});
|
|
1027
1605
|
const tracking = createAssetTracking();
|
|
1028
1606
|
const headRegistry = createHeadRegistry();
|
|
1607
|
+
let closed = false;
|
|
1029
1608
|
sharedConfig.context = {
|
|
1030
1609
|
nonce: options.nonce,
|
|
1031
1610
|
escape: escape,
|
|
1032
1611
|
resolve: resolveSSRNode,
|
|
1033
1612
|
ssr: ssr,
|
|
1613
|
+
errorPolicy: options.onError,
|
|
1614
|
+
_errorScope: errorScope,
|
|
1034
1615
|
registerHeadTags(tags) {
|
|
1035
1616
|
registerHeadTags(headRegistry, sharedConfig.context, tracking, null, nonce, tags);
|
|
1036
1617
|
},
|
|
1037
1618
|
serialize(id, p) {
|
|
1038
|
-
if (
|
|
1619
|
+
if (closed) return;
|
|
1039
1620
|
if (p != null && typeof p === "object" && (typeof p.then === "function" || typeof p[Symbol.asyncIterator] === "function")) {
|
|
1040
1621
|
throw new Error("Cannot serialize async value in renderToString (id: " + id + "). " + "Use renderToStream for async data.");
|
|
1041
1622
|
}
|
|
1042
1623
|
serializer.write(id, p);
|
|
1043
1624
|
},
|
|
1044
1625
|
registerAsset(type, value) {
|
|
1626
|
+
if (type === "preload") {
|
|
1627
|
+
registerPreloadLink(tracking, headRegistry, value, nonce);
|
|
1628
|
+
return;
|
|
1629
|
+
}
|
|
1045
1630
|
if (type === "inline-style") {
|
|
1046
1631
|
tracking.registerInlineStyle(value);
|
|
1047
1632
|
return;
|
|
@@ -1059,18 +1644,50 @@ function renderToString(code, options = {}) {
|
|
|
1059
1644
|
};
|
|
1060
1645
|
applyAssetTracking(sharedConfig.context, tracking, manifest, noScripts);
|
|
1061
1646
|
registerEntryAssets(manifest);
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1647
|
+
const context = sharedConfig.context;
|
|
1648
|
+
context.writer = createHydrationWriter(context, () => !closed);
|
|
1649
|
+
if (requestEvent) setRequestErrorHook(requestEvent, options.onError);
|
|
1650
|
+
context.trace = requestEvent ? traceForEvent(requestEvent) : traceFor(context, undefined);
|
|
1651
|
+
const render = timeDocument(context, context.trace);
|
|
1652
|
+
let dispose;
|
|
1653
|
+
let rootOwner;
|
|
1654
|
+
let rendered = false;
|
|
1655
|
+
try {
|
|
1656
|
+
const html = createRoot(d => {
|
|
1657
|
+
dispose = d;
|
|
1658
|
+
rootOwner = claimRenderRoot(context);
|
|
1659
|
+
if (requestEvent) claimEventRender(requestEvent, context);
|
|
1660
|
+
return resolveSSRSync(escape(code()));
|
|
1661
|
+
}, {
|
|
1662
|
+
id: renderId
|
|
1663
|
+
});
|
|
1664
|
+
serializeFragmentAssets("", tracking.boundaryModules, sharedConfig.context, renderId);
|
|
1665
|
+
closed = true;
|
|
1666
|
+
serializer.close();
|
|
1667
|
+
const head = renderShellHead(headRegistry, nonce, null, noScripts, traceMetaMarkup(context.trace));
|
|
1668
|
+
const document = withShellEnd(assembleDocument(resolveSSRSelectValues(html), tracking.emittedAssets, tracking.preloadLinks, tracking.inlineStyles, scripts.length ? scripts : "", nonce, head, onHead), context, renderId, nonce, noScripts);
|
|
1669
|
+
if (render) render.shell();
|
|
1670
|
+
if (requestEvent && requestEvent.response) {
|
|
1671
|
+
commitResponseStub(requestEvent.response, {
|
|
1672
|
+
event: requestEvent
|
|
1673
|
+
});
|
|
1674
|
+
}
|
|
1675
|
+
rendered = true;
|
|
1676
|
+
return document;
|
|
1677
|
+
} catch (err) {
|
|
1678
|
+
reportServerError(err, {
|
|
1679
|
+
kind: "render",
|
|
1680
|
+
handling: "failed"
|
|
1681
|
+
}, null, options.onError, errorScope);
|
|
1682
|
+
throw err;
|
|
1683
|
+
} finally {
|
|
1684
|
+
if (render) settleRender(render, rootOwner, rendered ? "complete" : "error");
|
|
1685
|
+
context.trace = undefined;
|
|
1686
|
+
if (dispose) dispose();
|
|
1687
|
+
}
|
|
1073
1688
|
}
|
|
1689
|
+
const SHELL_ABANDONED = Symbol();
|
|
1690
|
+
const ABANDON_RENDER = Symbol();
|
|
1074
1691
|
function renderToStream(code, options = {}) {
|
|
1075
1692
|
let {
|
|
1076
1693
|
onCompleteShell,
|
|
@@ -1081,12 +1698,50 @@ function renderToStream(code, options = {}) {
|
|
|
1081
1698
|
onHead
|
|
1082
1699
|
} = options;
|
|
1083
1700
|
const nonce = normalizeNonce(options.nonce);
|
|
1701
|
+
const requestEvent = peekRequestEvent();
|
|
1702
|
+
if (requestEvent) setRequestErrorHook(requestEvent, options.onError);
|
|
1703
|
+
const errorScope = requestEvent || {};
|
|
1704
|
+
const reportFailure = (err, handling) => {
|
|
1705
|
+
reportServerError(err, {
|
|
1706
|
+
kind: "render",
|
|
1707
|
+
handling
|
|
1708
|
+
}, null, options.onError, errorScope);
|
|
1709
|
+
if (!options.onError && ambientServerErrorHook() === undefined) console.error(err);
|
|
1710
|
+
};
|
|
1084
1711
|
let dispose;
|
|
1085
1712
|
let dead = false;
|
|
1086
|
-
|
|
1713
|
+
let render;
|
|
1714
|
+
let rootOwner;
|
|
1715
|
+
let serializer;
|
|
1716
|
+
let disconnected = false;
|
|
1717
|
+
let failed = false;
|
|
1718
|
+
let onFailed;
|
|
1719
|
+
let onDisconnectedBeforeShell;
|
|
1720
|
+
const defuse = p => {
|
|
1721
|
+
if (p && typeof p.then === "function") p.then(undefined, () => {});
|
|
1722
|
+
};
|
|
1723
|
+
const abandonedSerializer = {
|
|
1724
|
+
write(_, value) {
|
|
1725
|
+
defuse(value);
|
|
1726
|
+
},
|
|
1727
|
+
flush() {},
|
|
1728
|
+
close() {}
|
|
1729
|
+
};
|
|
1730
|
+
const onFailure = complete => {
|
|
1731
|
+
if (failed) return complete(undefined);
|
|
1732
|
+
const prev = onFailed;
|
|
1733
|
+
onFailed = prev ? sink => {
|
|
1734
|
+
prev(sink);
|
|
1735
|
+
complete(sink);
|
|
1736
|
+
} : complete;
|
|
1737
|
+
};
|
|
1738
|
+
const abandon = (disconnect, quiet) => {
|
|
1087
1739
|
if (dead) return;
|
|
1088
1740
|
dead = true;
|
|
1089
1741
|
completed = true;
|
|
1742
|
+
if (disconnect) disconnected = true;
|
|
1743
|
+
if (render) settleRender(render, rootOwner, disconnect ? "abandoned" : "error");
|
|
1744
|
+
const sink = writable;
|
|
1090
1745
|
buffer = {
|
|
1091
1746
|
write() {}
|
|
1092
1747
|
};
|
|
@@ -1098,13 +1753,33 @@ function renderToStream(code, options = {}) {
|
|
|
1098
1753
|
dispose = () => {};
|
|
1099
1754
|
d();
|
|
1100
1755
|
}
|
|
1756
|
+
if (serializer && typeof serializer.close === "function") {
|
|
1757
|
+
try {
|
|
1758
|
+
serializer.close();
|
|
1759
|
+
} catch (err) {
|
|
1760
|
+
reportServerError(err, {
|
|
1761
|
+
kind: "render",
|
|
1762
|
+
handling: "serialize"
|
|
1763
|
+
}, null, options.onError, errorScope);
|
|
1764
|
+
}
|
|
1765
|
+
}
|
|
1766
|
+
serializer = abandonedSerializer;
|
|
1767
|
+
if (stubBatch) {
|
|
1768
|
+
for (const p of stubBatch.values()) defuse(p);
|
|
1769
|
+
stubBatch = null;
|
|
1770
|
+
}
|
|
1771
|
+
if (!disconnect) {
|
|
1772
|
+
failed = true;
|
|
1773
|
+
onFailed && onFailed(sink);
|
|
1774
|
+
} else if (!sink && onDisconnectedBeforeShell) onDisconnectedBeforeShell();
|
|
1101
1775
|
};
|
|
1102
1776
|
const failRender = err => {
|
|
1103
|
-
|
|
1104
|
-
options.onError ? options.onError(err) : console.error(err);
|
|
1105
|
-
} catch (_) {}
|
|
1777
|
+
reportFailure(err, "failed");
|
|
1106
1778
|
abandon();
|
|
1107
1779
|
};
|
|
1780
|
+
const failRootRender = err => {
|
|
1781
|
+
failRender(err);
|
|
1782
|
+
};
|
|
1108
1783
|
const coalesceWrites = (writeRaw, endRaw) => {
|
|
1109
1784
|
let buf = "";
|
|
1110
1785
|
let scheduled = false;
|
|
@@ -1133,39 +1808,43 @@ function renderToStream(code, options = {}) {
|
|
|
1133
1808
|
};
|
|
1134
1809
|
const guardSink = w => ({
|
|
1135
1810
|
write(payload) {
|
|
1136
|
-
if (
|
|
1811
|
+
if (disconnected) return;
|
|
1137
1812
|
try {
|
|
1138
1813
|
w.write(payload);
|
|
1139
1814
|
} catch (_) {
|
|
1140
|
-
abandon();
|
|
1815
|
+
abandon("sink");
|
|
1141
1816
|
}
|
|
1142
1817
|
},
|
|
1143
1818
|
end() {
|
|
1144
|
-
if (
|
|
1819
|
+
if (disconnected) return;
|
|
1145
1820
|
try {
|
|
1146
1821
|
w.end();
|
|
1147
1822
|
} catch (_) {
|
|
1148
|
-
abandon();
|
|
1823
|
+
abandon("sink");
|
|
1149
1824
|
}
|
|
1150
1825
|
}
|
|
1151
1826
|
});
|
|
1152
1827
|
const blockingPromises = new Set();
|
|
1153
1828
|
const canBatchStubs = !options.serializer && !options.sink;
|
|
1154
1829
|
let stubBatch = null;
|
|
1155
|
-
|
|
1830
|
+
let stableOrder = false;
|
|
1831
|
+
let parkedWrites = null;
|
|
1832
|
+
const byKey = (a, b) => a[0] < b[0] ? -1 : a[0] > b[0] ? 1 : 0;
|
|
1833
|
+
const write = (id, value) => {
|
|
1834
|
+
if (stableOrder && !dead) (parkedWrites ||= []).push([id, value]);else serializer.write(id, value);
|
|
1835
|
+
};
|
|
1836
|
+
const flushParkedWrites = () => {
|
|
1837
|
+
if (!parkedWrites) return;
|
|
1838
|
+
const writes = parkedWrites.sort(byKey);
|
|
1839
|
+
parkedWrites = null;
|
|
1840
|
+
for (let i = 0; i < writes.length; i++) serializer.write(writes[i][0], writes[i][1]);
|
|
1841
|
+
};
|
|
1156
1842
|
const flushStubBatch = () => {
|
|
1157
1843
|
if (!stubBatch) return;
|
|
1158
|
-
const
|
|
1844
|
+
const entries = [...stubBatch];
|
|
1159
1845
|
stubBatch = null;
|
|
1160
|
-
if (
|
|
1161
|
-
|
|
1162
|
-
serializer.write(id, p);
|
|
1163
|
-
return;
|
|
1164
|
-
}
|
|
1165
|
-
const obj = {};
|
|
1166
|
-
for (const [id, p] of batch) obj[id] = p;
|
|
1167
|
-
serializer.write(STUB_BATCH_KEY, obj);
|
|
1168
|
-
pushTask(`(b=>{for(var k in b)_$HY.r[k]=b[k];delete _$HY.r["${STUB_BATCH_KEY}"]})(_$HY.r["${STUB_BATCH_KEY}"])`);
|
|
1846
|
+
if (stableOrder) entries.sort(byKey);
|
|
1847
|
+
for (let i = 0; i < entries.length; i++) serializer.write(entries[i][0], entries[i][1]);
|
|
1169
1848
|
};
|
|
1170
1849
|
let headerEmitted = false;
|
|
1171
1850
|
const pushTask = task => {
|
|
@@ -1181,7 +1860,9 @@ function renderToStream(code, options = {}) {
|
|
|
1181
1860
|
}
|
|
1182
1861
|
};
|
|
1183
1862
|
const onDone = () => {
|
|
1863
|
+
if (dead) return;
|
|
1184
1864
|
writeTasks();
|
|
1865
|
+
lastBlockingSize = blockingPromises.size;
|
|
1185
1866
|
doShell();
|
|
1186
1867
|
onCompleteAll && onCompleteAll({
|
|
1187
1868
|
write(v) {
|
|
@@ -1190,6 +1871,7 @@ function renderToStream(code, options = {}) {
|
|
|
1190
1871
|
});
|
|
1191
1872
|
writable && writable.end();
|
|
1192
1873
|
completed = true;
|
|
1874
|
+
if (render) settleRender(render, rootOwner, "complete");
|
|
1193
1875
|
if (firstFlushed) dispose();
|
|
1194
1876
|
};
|
|
1195
1877
|
const sink = {
|
|
@@ -1199,6 +1881,7 @@ function renderToStream(code, options = {}) {
|
|
|
1199
1881
|
fragment(key, value, meta) {
|
|
1200
1882
|
const deferActivation = !!meta.revealGroup;
|
|
1201
1883
|
const styles = meta.styles;
|
|
1884
|
+
const tpl = `<template id="${key}"${meta.error ? " e" : ""}>${value}</template>`;
|
|
1202
1885
|
for (let i = 0; i < styles.inline.length; i++) {
|
|
1203
1886
|
buffer.write(renderInlineStyle(styles.inline[i], nonce));
|
|
1204
1887
|
}
|
|
@@ -1206,12 +1889,12 @@ function renderToStream(code, options = {}) {
|
|
|
1206
1889
|
const styleAttr = nonceAttr(nonce, "style");
|
|
1207
1890
|
emitTask(`$dfs("${key}",${styles.links.length},${deferActivation ? 1 : 0})`);
|
|
1208
1891
|
writeTasks();
|
|
1892
|
+
buffer.write(tpl);
|
|
1209
1893
|
for (const entry of styles.links) {
|
|
1210
|
-
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}">`);
|
|
1211
1895
|
}
|
|
1212
|
-
buffer.write(`<template id="${key}">${value}</template>`);
|
|
1213
1896
|
} else {
|
|
1214
|
-
buffer.write(
|
|
1897
|
+
buffer.write(tpl);
|
|
1215
1898
|
if (!deferActivation) {
|
|
1216
1899
|
emitTask(`$df("${key}")`);
|
|
1217
1900
|
}
|
|
@@ -1223,6 +1906,8 @@ function renderToStream(code, options = {}) {
|
|
|
1223
1906
|
asset(type, value) {
|
|
1224
1907
|
if (type === "module") {
|
|
1225
1908
|
buffer.write(`<link rel="modulepreload" href="${value}"${nonceAttr(nonce, "script")}>`);
|
|
1909
|
+
} else if (type === "preload") {
|
|
1910
|
+
buffer.write(`<link${value.attrHtml}>`);
|
|
1226
1911
|
} else if (type === "inline-style") {
|
|
1227
1912
|
buffer.write(renderInlineStyle(value, nonce));
|
|
1228
1913
|
} else if (type === "head-tag") {
|
|
@@ -1230,16 +1915,16 @@ function renderToStream(code, options = {}) {
|
|
|
1230
1915
|
}
|
|
1231
1916
|
},
|
|
1232
1917
|
shell(shellHtml, meta) {
|
|
1233
|
-
buffer.write(assembleDocument(shellHtml, meta.preloads, meta.inlineStyles, meta.tasks.length ? meta.tasks : "", nonce, meta.head, onHead));
|
|
1918
|
+
buffer.write(withShellEnd(assembleDocument(shellHtml, meta.preloads, meta.preloadLinks, meta.inlineStyles, meta.tasks.length ? meta.tasks : "", nonce, meta.head, onHead), context, renderId, nonce, noScripts));
|
|
1234
1919
|
},
|
|
1235
1920
|
...options.sink
|
|
1236
1921
|
};
|
|
1237
|
-
|
|
1922
|
+
serializer = (options.serializer || createHydrationSerializer)({
|
|
1238
1923
|
scopeId: options.renderId,
|
|
1239
1924
|
plugins: options.plugins,
|
|
1240
1925
|
onData: payload => sink.data(payload),
|
|
1241
1926
|
onDone,
|
|
1242
|
-
onError:
|
|
1927
|
+
onError: err => reportFailure(err, "serialize")
|
|
1243
1928
|
});
|
|
1244
1929
|
let rootAssetsSerialized = false;
|
|
1245
1930
|
const serializeRootAssets = () => {
|
|
@@ -1249,7 +1934,7 @@ function renderToStream(code, options = {}) {
|
|
|
1249
1934
|
};
|
|
1250
1935
|
let holds = 0;
|
|
1251
1936
|
const flushEnd = () => {
|
|
1252
|
-
if (!registry.size && !holds) {
|
|
1937
|
+
if (!registry.size && !holds && !rootHoles) {
|
|
1253
1938
|
serializeRootAssets();
|
|
1254
1939
|
queue(() => queue(() => {
|
|
1255
1940
|
if (context.live.end) {
|
|
@@ -1258,11 +1943,87 @@ function renderToStream(code, options = {}) {
|
|
|
1258
1943
|
end();
|
|
1259
1944
|
}
|
|
1260
1945
|
flushStubBatch();
|
|
1946
|
+
flushParkedWrites();
|
|
1261
1947
|
serializer.flush();
|
|
1262
1948
|
}));
|
|
1263
1949
|
}
|
|
1264
1950
|
};
|
|
1265
1951
|
const registry = new Map();
|
|
1952
|
+
const pendingSerialized = new Map();
|
|
1953
|
+
const guardedChannels = new WeakMap();
|
|
1954
|
+
const verdictNow = error => {
|
|
1955
|
+
throw ssrSanitizeError(error, null, undefined, undefined, errorScope);
|
|
1956
|
+
};
|
|
1957
|
+
const borderForm = value => toBorderForm(value);
|
|
1958
|
+
const guardIterable = iterable => ({
|
|
1959
|
+
[Symbol.asyncIterator]() {
|
|
1960
|
+
const iterator = iterable[Symbol.asyncIterator]();
|
|
1961
|
+
return {
|
|
1962
|
+
next: value => iterator.next(value).then(undefined, verdictNow),
|
|
1963
|
+
return: value => iterator.return ? iterator.return(value) : Promise.resolve({
|
|
1964
|
+
done: true,
|
|
1965
|
+
value
|
|
1966
|
+
}),
|
|
1967
|
+
throw: error => iterator.throw ? iterator.throw(error) : Promise.reject(error)
|
|
1968
|
+
};
|
|
1969
|
+
}
|
|
1970
|
+
});
|
|
1971
|
+
const guardStream = source => {
|
|
1972
|
+
const reader = source.getReader();
|
|
1973
|
+
return new ReadableStream({
|
|
1974
|
+
pull: c => reader.read().then(r => r.done ? c.close() : c.enqueue(r.value), e => {
|
|
1975
|
+
try {
|
|
1976
|
+
verdictNow(e);
|
|
1977
|
+
} catch (sanitized) {
|
|
1978
|
+
c.error(sanitized);
|
|
1979
|
+
}
|
|
1980
|
+
}),
|
|
1981
|
+
cancel: reason => reader.cancel(reason)
|
|
1982
|
+
});
|
|
1983
|
+
};
|
|
1984
|
+
const guardChannel = p => {
|
|
1985
|
+
if (!p || typeof p !== "object" || "__SEROVAL_STREAM__" in p) return p;
|
|
1986
|
+
let guarded = guardedChannels.get(p);
|
|
1987
|
+
if (guarded !== undefined) return guarded;
|
|
1988
|
+
if (typeof p.then === "function") {
|
|
1989
|
+
guarded = p.then(borderForm, verdictNow);
|
|
1990
|
+
} else if (typeof ReadableStream === "function" && p instanceof ReadableStream) {
|
|
1991
|
+
guarded = guardStream(p);
|
|
1992
|
+
} else {
|
|
1993
|
+
const border = borderForm(p);
|
|
1994
|
+
guarded = typeof border[Symbol.asyncIterator] === "function" ? guardIterable(border) : border;
|
|
1995
|
+
if (guarded === p) return p;
|
|
1996
|
+
}
|
|
1997
|
+
guardedChannels.set(p, guarded);
|
|
1998
|
+
return guarded;
|
|
1999
|
+
};
|
|
2000
|
+
const trackSerialized = (id, p) => {
|
|
2001
|
+
let settle;
|
|
2002
|
+
const raced = Promise.race([p, new Promise(r => settle = r)]);
|
|
2003
|
+
raced.catch(() => {});
|
|
2004
|
+
pendingSerialized.set(id, settle);
|
|
2005
|
+
const drop = () => pendingSerialized.delete(id);
|
|
2006
|
+
p.then(drop, drop);
|
|
2007
|
+
return raced;
|
|
2008
|
+
};
|
|
2009
|
+
const abandonSubtree = (key, error) => {
|
|
2010
|
+
if (key == null) return;
|
|
2011
|
+
for (const [k, entry] of registry) {
|
|
2012
|
+
if (k != null && k.length > key.length && k.startsWith(key)) {
|
|
2013
|
+
registry.delete(k);
|
|
2014
|
+
entry.resolve();
|
|
2015
|
+
}
|
|
2016
|
+
}
|
|
2017
|
+
const unregister = [];
|
|
2018
|
+
for (const [id, settle] of pendingSerialized) {
|
|
2019
|
+
if (id.startsWith(key)) {
|
|
2020
|
+
pendingSerialized.delete(id);
|
|
2021
|
+
settle();
|
|
2022
|
+
if (!stubBatch?.delete(id)) unregister.push(`delete _$HY.r[${JSON.stringify(id)}]`);
|
|
2023
|
+
}
|
|
2024
|
+
}
|
|
2025
|
+
if (unregister.length && !options.sink) pushTask(unregister.join(";"));
|
|
2026
|
+
};
|
|
1266
2027
|
const writeTasks = () => {
|
|
1267
2028
|
if (tasks.length && !completed && firstFlushed) {
|
|
1268
2029
|
buffer.write(`<script${nonceAttr(nonce, "script")}>${tasks}</script>`);
|
|
@@ -1304,6 +2065,12 @@ function renderToStream(code, options = {}) {
|
|
|
1304
2065
|
}
|
|
1305
2066
|
let rootHoles = null;
|
|
1306
2067
|
let nextHoleId = 0;
|
|
2068
|
+
let parkedInlines = null;
|
|
2069
|
+
function inlineFragment(key, value) {
|
|
2070
|
+
if (rootHoles && !html.includes(`<template id="pl-${key}">`)) {
|
|
2071
|
+
(parkedInlines ||= new Map()).set(key, value);
|
|
2072
|
+
} else html = replacePlaceholder(html, key, value);
|
|
2073
|
+
}
|
|
1307
2074
|
let buffer = {
|
|
1308
2075
|
write(payload) {
|
|
1309
2076
|
tmp += payload;
|
|
@@ -1320,6 +2087,8 @@ function renderToStream(code, options = {}) {
|
|
|
1320
2087
|
sharedConfig.context = context = {
|
|
1321
2088
|
async: true,
|
|
1322
2089
|
nonce: options.nonce,
|
|
2090
|
+
document: !options.sink,
|
|
2091
|
+
edges: !!options.plugins && options.plugins.some(p => p.tag === "solid/server-component"),
|
|
1323
2092
|
live: {},
|
|
1324
2093
|
registerHeadTags(tags) {
|
|
1325
2094
|
registerHeadTags(headRegistry, context, tracking,
|
|
@@ -1333,6 +2102,11 @@ function renderToStream(code, options = {}) {
|
|
|
1333
2102
|
}, nonce, tags);
|
|
1334
2103
|
},
|
|
1335
2104
|
registerAsset(type, value) {
|
|
2105
|
+
if (type === "preload") {
|
|
2106
|
+
const entry = registerPreloadLink(tracking, headRegistry, value, nonce);
|
|
2107
|
+
if (entry && firstFlushed) sink.asset("preload", entry);
|
|
2108
|
+
return;
|
|
2109
|
+
}
|
|
1336
2110
|
if (type === "inline-style") {
|
|
1337
2111
|
const entry = tracking.registerInlineStyle(value);
|
|
1338
2112
|
if (firstFlushed && !tracking.currentBoundaryId && !entry.emitted) {
|
|
@@ -1376,19 +2150,20 @@ function renderToStream(code, options = {}) {
|
|
|
1376
2150
|
html = html.slice(0, first) + resolveSSRSync(escape(payloadFn())) + html.slice(last + placeholder.length + 1);
|
|
1377
2151
|
},
|
|
1378
2152
|
serialize(id, p, deferStream) {
|
|
1379
|
-
|
|
1380
|
-
if (
|
|
1381
|
-
if (deferStream) {
|
|
2153
|
+
p = guardChannel(p);
|
|
2154
|
+
if (p && typeof p === "object" && typeof p.then === "function") {
|
|
2155
|
+
if (!firstFlushed && deferStream) {
|
|
1382
2156
|
blockingPromises.add(p);
|
|
1383
|
-
p.then(d =>
|
|
2157
|
+
p.then(d => write(id, d)).catch(e => write(id, e));
|
|
1384
2158
|
return;
|
|
1385
2159
|
}
|
|
1386
|
-
|
|
2160
|
+
p = trackSerialized(id, p);
|
|
2161
|
+
if (!firstFlushed && canBatchStubs && !shellCompleted && !dead) {
|
|
1387
2162
|
(stubBatch ||= new Map()).set(id, p);
|
|
1388
2163
|
return;
|
|
1389
2164
|
}
|
|
1390
2165
|
}
|
|
1391
|
-
|
|
2166
|
+
write(id, p);
|
|
1392
2167
|
},
|
|
1393
2168
|
escape: escape,
|
|
1394
2169
|
resolve: resolveSSRNode,
|
|
@@ -1416,19 +2191,26 @@ function renderToStream(code, options = {}) {
|
|
|
1416
2191
|
if (!registry.has(key)) {
|
|
1417
2192
|
let resolve, reject;
|
|
1418
2193
|
const p = new Promise((r, rej) => (resolve = r, reject = rej));
|
|
2194
|
+
defuse(p);
|
|
1419
2195
|
registry.set(key, {
|
|
1420
2196
|
resolve: err => queue(() => queue(() => {
|
|
1421
|
-
err ? reject(err) : resolve(true);
|
|
2197
|
+
err ? reject(ssrSanitizeError(err, null, undefined, undefined, errorScope)) : resolve(true);
|
|
1422
2198
|
queue(flushEnd);
|
|
1423
2199
|
}))
|
|
1424
2200
|
});
|
|
1425
|
-
if (canBatchStubs && !shellCompleted) (stubBatch ||= new Map()).set(key + "_fr", p);else
|
|
2201
|
+
if (canBatchStubs && !shellCompleted && !dead) (stubBatch ||= new Map()).set(key + "_fr", p);else write(key + "_fr", p);
|
|
1426
2202
|
}
|
|
1427
|
-
return (value, error) => {
|
|
2203
|
+
return (value, error, escaped) => {
|
|
1428
2204
|
if (registry.has(key)) {
|
|
1429
2205
|
const item = registry.get(key);
|
|
1430
2206
|
registry.delete(key);
|
|
1431
|
-
if (
|
|
2207
|
+
if (error) abandonSubtree(key);
|
|
2208
|
+
if (error && escaped) {
|
|
2209
|
+
const wire = ssrSanitizeError(error, null, undefined, undefined, errorScope);
|
|
2210
|
+
const message = wire instanceof Error ? wire.message : String(wire);
|
|
2211
|
+
if (sink.error) sink.error("", message);else if (context.live && context.live.error) context.live.error(escaped.frame, message);
|
|
2212
|
+
}
|
|
2213
|
+
if (item.children && !error) {
|
|
1432
2214
|
for (const k in item.children) {
|
|
1433
2215
|
value = replacePlaceholder(value, k, item.children[k]);
|
|
1434
2216
|
}
|
|
@@ -1447,7 +2229,7 @@ function renderToStream(code, options = {}) {
|
|
|
1447
2229
|
if (!completed) {
|
|
1448
2230
|
if (error) dropHeadBoundary(headRegistry, key);
|
|
1449
2231
|
if (!firstFlushed) {
|
|
1450
|
-
queue(() =>
|
|
2232
|
+
queue(() => inlineFragment(key, value !== undefined ? value : ""));
|
|
1451
2233
|
serializeFragmentAssets(key, tracking.boundaryModules, context);
|
|
1452
2234
|
item.resolve(error);
|
|
1453
2235
|
} else {
|
|
@@ -1455,10 +2237,10 @@ function renderToStream(code, options = {}) {
|
|
|
1455
2237
|
const styles = collectStreamStyles(key, tracking, headStyles);
|
|
1456
2238
|
const headOps = error ? null : flushHeadFragment(headRegistry, key, nonce);
|
|
1457
2239
|
if (headOps) emitHeadOps(key, headOps);
|
|
1458
|
-
sink.fragment(key, resolveSSRSelectValues(value !== undefined ? value : " "), {
|
|
2240
|
+
sink.fragment(key, resolveSSRSelectValues(value !== undefined ? value : error ? "" : " "), {
|
|
1459
2241
|
styles,
|
|
1460
2242
|
revealGroup,
|
|
1461
|
-
error
|
|
2243
|
+
error: error ? ssrSanitizeError(error, null, undefined, undefined, errorScope) : error
|
|
1462
2244
|
});
|
|
1463
2245
|
item.resolve(error);
|
|
1464
2246
|
}
|
|
@@ -1484,26 +2266,66 @@ function renderToStream(code, options = {}) {
|
|
|
1484
2266
|
};
|
|
1485
2267
|
applyAssetTracking(context, tracking, manifest, noScripts);
|
|
1486
2268
|
context.failRender = failRender;
|
|
2269
|
+
context.errorPolicy = options.onError;
|
|
2270
|
+
context._errorScope = errorScope;
|
|
2271
|
+
context.flushed = () => firstFlushed;
|
|
2272
|
+
context.trace = requestEvent ? traceForEvent(requestEvent) : traceFor(context, undefined);
|
|
2273
|
+
render = timeDocument(context, context.trace);
|
|
1487
2274
|
registerEntryAssets(manifest);
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
2275
|
+
context.writer = createHydrationWriter(context, () => !completed);
|
|
2276
|
+
const signal = options.signal;
|
|
2277
|
+
const onAbort = signal ? () => abandon("signal", !!(signal.reason && signal.reason.quiet === true)) : undefined;
|
|
2278
|
+
const endEdges = context.edges ? beginEdgesRender() : undefined;
|
|
2279
|
+
let html;
|
|
2280
|
+
try {
|
|
2281
|
+
html = createRoot(d => {
|
|
2282
|
+
dispose = () => {
|
|
2283
|
+
context.trace = undefined;
|
|
2284
|
+
if (onAbort) signal.removeEventListener("abort", onAbort);
|
|
2285
|
+
if (endEdges) endEdges();
|
|
2286
|
+
try {
|
|
2287
|
+
d();
|
|
2288
|
+
} catch (err) {
|
|
2289
|
+
reportFailure(err, "failed");
|
|
2290
|
+
}
|
|
2291
|
+
};
|
|
2292
|
+
rootOwner = claimRenderRoot(context);
|
|
2293
|
+
if (requestEvent) claimEventRender(requestEvent, context);
|
|
2294
|
+
let res;
|
|
2295
|
+
try {
|
|
2296
|
+
res = resolveSSRNode(escape(code()));
|
|
2297
|
+
} catch (err) {
|
|
2298
|
+
reportServerError(err, {
|
|
2299
|
+
kind: "render",
|
|
2300
|
+
handling: "failed"
|
|
2301
|
+
}, null, options.onError, errorScope);
|
|
2302
|
+
throw err;
|
|
2303
|
+
}
|
|
2304
|
+
if (!res.h.length) return res.t[0];
|
|
2305
|
+
rootHoles = [];
|
|
2306
|
+
let out = res.t[0];
|
|
2307
|
+
for (let i = 0; i < res.h.length; i++) {
|
|
2308
|
+
const id = nextHoleId++;
|
|
2309
|
+
rootHoles.push({
|
|
2310
|
+
id,
|
|
2311
|
+
fn: res.h[i]
|
|
2312
|
+
});
|
|
2313
|
+
out += `<!--rh${id}-->` + res.t[i + 1];
|
|
2314
|
+
}
|
|
2315
|
+
for (const p of res.p) blockingPromises.add(p);
|
|
2316
|
+
return out;
|
|
2317
|
+
}, {
|
|
2318
|
+
id: renderId
|
|
2319
|
+
});
|
|
2320
|
+
} catch (err) {
|
|
2321
|
+
if (endEdges) endEdges();
|
|
2322
|
+
throw err;
|
|
2323
|
+
}
|
|
2324
|
+
if (onAbort) {
|
|
2325
|
+
if (signal.aborted) onAbort();else signal.addEventListener("abort", onAbort, {
|
|
2326
|
+
once: true
|
|
2327
|
+
});
|
|
2328
|
+
}
|
|
1507
2329
|
function resolveRootHoles() {
|
|
1508
2330
|
if (!rootHoles) return true;
|
|
1509
2331
|
const pending = [];
|
|
@@ -1529,6 +2351,13 @@ function renderToStream(code, options = {}) {
|
|
|
1529
2351
|
for (const p of res.p) blockingPromises.add(p);
|
|
1530
2352
|
}
|
|
1531
2353
|
}
|
|
2354
|
+
if (parkedInlines) {
|
|
2355
|
+
for (const [key, value] of parkedInlines) {
|
|
2356
|
+
if (!html.includes(`<template id="pl-${key}">`)) continue;
|
|
2357
|
+
html = replacePlaceholder(html, key, value);
|
|
2358
|
+
parkedInlines.delete(key);
|
|
2359
|
+
}
|
|
2360
|
+
}
|
|
1532
2361
|
if (pending.length) {
|
|
1533
2362
|
rootHoles = pending;
|
|
1534
2363
|
return false;
|
|
@@ -1539,9 +2368,9 @@ function renderToStream(code, options = {}) {
|
|
|
1539
2368
|
function doShell() {
|
|
1540
2369
|
if (shellCompleted) return;
|
|
1541
2370
|
sharedConfig.context = context;
|
|
1542
|
-
|
|
2371
|
+
if (blockingPromises.size !== lastBlockingSize) return;
|
|
1543
2372
|
if (!resolveRootHoles()) return;
|
|
1544
|
-
if (blockingPromises.size !==
|
|
2373
|
+
if (blockingPromises.size !== lastBlockingSize) return;
|
|
1545
2374
|
if (!headShellReady(headRegistry, p => blockingPromises.add(p))) return;
|
|
1546
2375
|
headStyles = new Set();
|
|
1547
2376
|
for (const url of tracking.emittedAssets) {
|
|
@@ -1549,9 +2378,11 @@ function renderToStream(code, options = {}) {
|
|
|
1549
2378
|
}
|
|
1550
2379
|
serializeRootAssets();
|
|
1551
2380
|
flushStubBatch();
|
|
1552
|
-
const head = renderShellHead(headRegistry, nonce, k => registry.has(k), noScripts);
|
|
2381
|
+
const head = renderShellHead(headRegistry, nonce, k => registry.has(k), noScripts, traceMetaMarkup(context.trace));
|
|
2382
|
+
if (render) render.shell();
|
|
1553
2383
|
sink.shell(resolveSSRSelectValues(html), {
|
|
1554
2384
|
preloads: tracking.emittedAssets,
|
|
2385
|
+
preloadLinks: tracking.preloadLinks,
|
|
1555
2386
|
inlineStyles: tracking.inlineStyles,
|
|
1556
2387
|
tasks,
|
|
1557
2388
|
head
|
|
@@ -1568,21 +2399,30 @@ function renderToStream(code, options = {}) {
|
|
|
1568
2399
|
let lastBlockingSize = -1;
|
|
1569
2400
|
let lastRegistrySize = -1;
|
|
1570
2401
|
let drainTurn = 0;
|
|
1571
|
-
|
|
2402
|
+
let graced = false;
|
|
2403
|
+
const scheduleFlush = (fn, awaited) => {
|
|
1572
2404
|
const attempt = () => {
|
|
1573
|
-
flushStubBatch();
|
|
2405
|
+
if (!stableOrder) flushStubBatch();
|
|
1574
2406
|
if (registry.size !== lastRegistrySize || drainTurn++ < MIN_DRAIN_TURNS) {
|
|
1575
2407
|
if (registry.size !== lastRegistrySize) drainTurn = 0;
|
|
1576
2408
|
lastRegistrySize = registry.size;
|
|
1577
2409
|
queue(attempt);
|
|
1578
2410
|
return;
|
|
1579
2411
|
}
|
|
2412
|
+
if (!graced && registry.size) {
|
|
2413
|
+
graced = true;
|
|
2414
|
+
lastRegistrySize = -1;
|
|
2415
|
+
drainTurn = 0;
|
|
2416
|
+
deferFlush(attempt);
|
|
2417
|
+
return;
|
|
2418
|
+
}
|
|
1580
2419
|
fn();
|
|
1581
2420
|
};
|
|
1582
|
-
const progressed =
|
|
1583
|
-
lastBlockingSize =
|
|
2421
|
+
const progressed = awaited !== lastBlockingSize;
|
|
2422
|
+
lastBlockingSize = awaited;
|
|
1584
2423
|
lastRegistrySize = -1;
|
|
1585
2424
|
drainTurn = 0;
|
|
2425
|
+
graced = false;
|
|
1586
2426
|
progressed ? queue(attempt) : setTimeout(attempt);
|
|
1587
2427
|
};
|
|
1588
2428
|
let cachedReadable;
|
|
@@ -1596,15 +2436,21 @@ function renderToStream(code, options = {}) {
|
|
|
1596
2436
|
const pipeToImpl = w => {
|
|
1597
2437
|
let resolve;
|
|
1598
2438
|
const p = new Promise(r => resolve = r);
|
|
2439
|
+
onFailure(sink => {
|
|
2440
|
+
try {
|
|
2441
|
+
if (sink) sink.end();else w.close().catch(() => {});
|
|
2442
|
+
} catch (_) {}
|
|
2443
|
+
resolve();
|
|
2444
|
+
});
|
|
1599
2445
|
function flush() {
|
|
1600
|
-
allSettled(blockingPromises).then(
|
|
2446
|
+
allSettled(blockingPromises).then(awaited => {
|
|
1601
2447
|
scheduleFlush(() => {
|
|
1602
2448
|
if (dead) return resolve();
|
|
1603
2449
|
try {
|
|
1604
2450
|
doShell();
|
|
1605
2451
|
} catch (err) {
|
|
1606
|
-
|
|
1607
|
-
return
|
|
2452
|
+
failRootRender(err);
|
|
2453
|
+
return;
|
|
1608
2454
|
}
|
|
1609
2455
|
if (!shellCompleted) return flush();
|
|
1610
2456
|
const encoder = new TextEncoder();
|
|
@@ -1613,7 +2459,7 @@ function renderToStream(code, options = {}) {
|
|
|
1613
2459
|
let ended = false;
|
|
1614
2460
|
const failed = () => {
|
|
1615
2461
|
if (!ended) {
|
|
1616
|
-
abandon();
|
|
2462
|
+
abandon("consumer");
|
|
1617
2463
|
resolve();
|
|
1618
2464
|
}
|
|
1619
2465
|
};
|
|
@@ -1635,7 +2481,7 @@ function renderToStream(code, options = {}) {
|
|
|
1635
2481
|
dispose();
|
|
1636
2482
|
writable.end();
|
|
1637
2483
|
} else flushEnd();
|
|
1638
|
-
});
|
|
2484
|
+
}, awaited);
|
|
1639
2485
|
});
|
|
1640
2486
|
}
|
|
1641
2487
|
flush();
|
|
@@ -1643,8 +2489,15 @@ function renderToStream(code, options = {}) {
|
|
|
1643
2489
|
};
|
|
1644
2490
|
return {
|
|
1645
2491
|
then(onFulfilled, onRejected) {
|
|
2492
|
+
if (canBatchStubs) stableOrder = true;
|
|
2493
|
+
const freezeHead = () => {
|
|
2494
|
+
if (requestEvent && requestEvent.response) commitResponseStub(requestEvent.response, {
|
|
2495
|
+
event: requestEvent
|
|
2496
|
+
});
|
|
2497
|
+
};
|
|
1646
2498
|
const p = new Promise(resolve => {
|
|
1647
2499
|
function complete() {
|
|
2500
|
+
freezeHead();
|
|
1648
2501
|
dispose();
|
|
1649
2502
|
resolve(tmp);
|
|
1650
2503
|
}
|
|
@@ -1655,18 +2508,19 @@ function renderToStream(code, options = {}) {
|
|
|
1655
2508
|
complete();
|
|
1656
2509
|
};
|
|
1657
2510
|
} else onCompleteAll = complete;
|
|
2511
|
+
onFailure(() => resolve(tmp));
|
|
1658
2512
|
function flush() {
|
|
1659
|
-
allSettled(blockingPromises).then(
|
|
2513
|
+
allSettled(blockingPromises).then(awaited => {
|
|
1660
2514
|
scheduleFlush(() => {
|
|
2515
|
+
if (dead) return;
|
|
1661
2516
|
try {
|
|
1662
|
-
|
|
1663
|
-
if (!resolveRootHoles() || blockingPromises.size !== blockersBefore || !headShellReady(headRegistry, p => blockingPromises.add(p))) return flush();
|
|
2517
|
+
if (blockingPromises.size !== lastBlockingSize || !resolveRootHoles() || blockingPromises.size !== lastBlockingSize || !headShellReady(headRegistry, p => blockingPromises.add(p))) return flush();
|
|
1664
2518
|
} catch (err) {
|
|
1665
|
-
|
|
1666
|
-
return
|
|
2519
|
+
failRootRender(err);
|
|
2520
|
+
return;
|
|
1667
2521
|
}
|
|
1668
2522
|
queue(flushEnd);
|
|
1669
|
-
});
|
|
2523
|
+
}, awaited);
|
|
1670
2524
|
});
|
|
1671
2525
|
}
|
|
1672
2526
|
flush();
|
|
@@ -1675,17 +2529,24 @@ function renderToStream(code, options = {}) {
|
|
|
1675
2529
|
},
|
|
1676
2530
|
pipe(w) {
|
|
1677
2531
|
claimConsumer("pipe");
|
|
2532
|
+
const abandoned = w[SHELL_ABANDONED];
|
|
2533
|
+
onFailure(sink => {
|
|
2534
|
+
try {
|
|
2535
|
+
sink ? sink.end() : abandoned ? abandoned() : w.end();
|
|
2536
|
+
} catch (_) {}
|
|
2537
|
+
});
|
|
2538
|
+
if (abandoned) {
|
|
2539
|
+
w[ABANDON_RENDER] = abandon;
|
|
2540
|
+
if (disconnected) abandoned();else onDisconnectedBeforeShell = abandoned;
|
|
2541
|
+
}
|
|
1678
2542
|
function flush() {
|
|
1679
|
-
allSettled(blockingPromises).then(
|
|
2543
|
+
allSettled(blockingPromises).then(awaited => {
|
|
1680
2544
|
scheduleFlush(() => {
|
|
1681
2545
|
if (dead) return;
|
|
1682
2546
|
try {
|
|
1683
2547
|
doShell();
|
|
1684
2548
|
} catch (err) {
|
|
1685
|
-
|
|
1686
|
-
try {
|
|
1687
|
-
w.end();
|
|
1688
|
-
} catch (_) {}
|
|
2549
|
+
failRootRender(err);
|
|
1689
2550
|
return;
|
|
1690
2551
|
}
|
|
1691
2552
|
if (!shellCompleted) return flush();
|
|
@@ -1698,7 +2559,7 @@ function renderToStream(code, options = {}) {
|
|
|
1698
2559
|
dispose();
|
|
1699
2560
|
writable.end();
|
|
1700
2561
|
} else flushEnd();
|
|
1701
|
-
});
|
|
2562
|
+
}, awaited);
|
|
1702
2563
|
});
|
|
1703
2564
|
}
|
|
1704
2565
|
flush();
|
|
@@ -1719,11 +2580,15 @@ function renderToStream(code, options = {}) {
|
|
|
1719
2580
|
};
|
|
1720
2581
|
}
|
|
1721
2582
|
function HydrationScript(props) {
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
2583
|
+
if (sharedConfig.context) sharedConfig.context.bootstrap = true;
|
|
2584
|
+
const {
|
|
2585
|
+
eventNames,
|
|
2586
|
+
nonce
|
|
2587
|
+
} = {
|
|
2588
|
+
nonce: sharedConfig.context && sharedConfig.context.nonce,
|
|
1725
2589
|
...props
|
|
1726
|
-
}
|
|
2590
|
+
};
|
|
2591
|
+
return ssr(hydrationBootstrap(eventNames, destinationNonce(nonce, "script"), true));
|
|
1727
2592
|
}
|
|
1728
2593
|
function ssrGroup(fn, n) {
|
|
1729
2594
|
fn.$g = n;
|
|
@@ -1812,6 +2677,10 @@ function ssrGroupSlot(fn, idx) {
|
|
|
1812
2677
|
}
|
|
1813
2678
|
};
|
|
1814
2679
|
}
|
|
2680
|
+
function wireErrorMessage(err, scope) {
|
|
2681
|
+
const wire = ssrSanitizeError(err, null, undefined, undefined, scope);
|
|
2682
|
+
return String(wire && wire.message || wire);
|
|
2683
|
+
}
|
|
1815
2684
|
const holePositionCache = new WeakMap();
|
|
1816
2685
|
function holeContentPositions(t) {
|
|
1817
2686
|
let cached = holePositionCache.get(t);
|
|
@@ -1871,19 +2740,86 @@ function holeContentPositions(t) {
|
|
|
1871
2740
|
holePositionCache.set(t, cached);
|
|
1872
2741
|
return cached;
|
|
1873
2742
|
}
|
|
1874
|
-
function createLiveHoles(sink, scoped) {
|
|
2743
|
+
function createLiveHoles(sink, scoped, settled, errorScope) {
|
|
1875
2744
|
let nextId = 0;
|
|
1876
2745
|
const stamp = typeof creationStamp === "function" ? creationStamp : () => 0;
|
|
1877
2746
|
const inScope = scoped && typeof inServerComponentScope === "function" ? inServerComponentScope : null;
|
|
1878
|
-
const stripMarkers = html => html.replace(/<!--lh:\/?\d
|
|
2747
|
+
const stripMarkers = html => html.replace(/<!--lh:\/?\d+-->| data-lha="\d+"/g, "");
|
|
2748
|
+
const swept = (owner, ctx, fn) => {
|
|
2749
|
+
const prev = sharedConfig.context;
|
|
2750
|
+
sharedConfig.context = ctx;
|
|
2751
|
+
let dispose;
|
|
2752
|
+
let before;
|
|
2753
|
+
const run = () => createRoot(d => {
|
|
2754
|
+
dispose = d;
|
|
2755
|
+
before = stamp();
|
|
2756
|
+
return fn();
|
|
2757
|
+
}, {
|
|
2758
|
+
transparent: true
|
|
2759
|
+
});
|
|
2760
|
+
try {
|
|
2761
|
+
return owner ? runWithOwner(owner, run) : run();
|
|
2762
|
+
} finally {
|
|
2763
|
+
sharedConfig.context = prev;
|
|
2764
|
+
engine.sweptOwners = before !== undefined && stamp() !== before;
|
|
2765
|
+
if (dispose) dispose();
|
|
2766
|
+
}
|
|
2767
|
+
};
|
|
2768
|
+
const stripRow = html => html.replace(/<!--lh:\/?\d+-->| data-lha="\d+"|<!--lr-->/g, "");
|
|
2769
|
+
const rowsOf = v => Array.isArray(v) && v.$rows ? v : null;
|
|
2770
|
+
function holeValue(hole) {
|
|
2771
|
+
const b = hole.$lhBinding;
|
|
2772
|
+
if (b) {
|
|
2773
|
+
const v = hole();
|
|
2774
|
+
return b.fn && rowsOf(b.fn()) || v;
|
|
2775
|
+
}
|
|
2776
|
+
if (!hole.$fn) return hole();
|
|
2777
|
+
const v = hole.$fn();
|
|
2778
|
+
return rowsOf(v) || escape(v);
|
|
2779
|
+
}
|
|
2780
|
+
function resolveValue(value, res) {
|
|
2781
|
+
if (!Array.isArray(value) || !value.$rows) {
|
|
2782
|
+
resolveSSRNode(value, res);
|
|
2783
|
+
return null;
|
|
2784
|
+
}
|
|
2785
|
+
let rows = [];
|
|
2786
|
+
for (const row of value) {
|
|
2787
|
+
const r = resolveSSRNode(escape(row));
|
|
2788
|
+
res.t[res.t.length - 1] += "<!--lr-->" + r.t[0];
|
|
2789
|
+
if (r.h.length) {
|
|
2790
|
+
res.t.push(...r.t.slice(1));
|
|
2791
|
+
res.h.push(...r.h);
|
|
2792
|
+
res.p.push(...r.p);
|
|
2793
|
+
rows = null;
|
|
2794
|
+
} else if (rows) rows.push(engine.sweeping ? r.t[0] : stripRow(r.t[0]));
|
|
2795
|
+
}
|
|
2796
|
+
return rows;
|
|
2797
|
+
}
|
|
2798
|
+
function rowOps(last, rows) {
|
|
2799
|
+
const ops = [];
|
|
2800
|
+
const html = [];
|
|
2801
|
+
for (let i = 0; i < rows.length; i++) if (i >= last.length || rows[i] !== last[i]) {
|
|
2802
|
+
const patch = i < last.length ? rowPatch(last[i], rows[i]) : null;
|
|
2803
|
+
ops.push(patch ? [i, patch.p] : [i, rows[i]]);
|
|
2804
|
+
html.push(rows[i]);
|
|
2805
|
+
}
|
|
2806
|
+
if (ops.length >= rows.length) return null;
|
|
2807
|
+
return Object.defineProperty({
|
|
2808
|
+
n: rows.length,
|
|
2809
|
+
r: ops
|
|
2810
|
+
}, ROW_HTML, {
|
|
2811
|
+
value: html
|
|
2812
|
+
});
|
|
2813
|
+
}
|
|
1879
2814
|
function resolveHoleValue(hole) {
|
|
1880
2815
|
const result = {
|
|
1881
2816
|
t: [""],
|
|
1882
2817
|
h: [],
|
|
1883
|
-
p: []
|
|
2818
|
+
p: [],
|
|
2819
|
+
rows: null
|
|
1884
2820
|
};
|
|
1885
2821
|
try {
|
|
1886
|
-
|
|
2822
|
+
result.rows = resolveValue(holeValue(hole), result);
|
|
1887
2823
|
} catch (err) {
|
|
1888
2824
|
const wrap = buildAsyncWrap(err, hole);
|
|
1889
2825
|
if (!wrap) throw err;
|
|
@@ -1901,12 +2837,88 @@ function createLiveHoles(sink, scoped) {
|
|
|
1901
2837
|
}
|
|
1902
2838
|
b.children.length = 0;
|
|
1903
2839
|
}
|
|
2840
|
+
let tops = 0;
|
|
2841
|
+
const ids = new Map();
|
|
2842
|
+
const scopeFor = hole => {
|
|
2843
|
+
const p = engine.scope;
|
|
2844
|
+
return {
|
|
2845
|
+
id: undefined,
|
|
2846
|
+
p,
|
|
2847
|
+
i: p ? p.c++ : tops++,
|
|
2848
|
+
n: null,
|
|
2849
|
+
c: 0,
|
|
2850
|
+
h: hole
|
|
2851
|
+
};
|
|
2852
|
+
};
|
|
2853
|
+
const scopeId = s => s.id !== undefined ? s.id : s.id = s.p ? scopeId(s.p) + "." + s.i : String(s.i);
|
|
2854
|
+
const collect = (v, id, forget) => (v.occ || (v.occ = new Map())).set(id, forget);
|
|
2855
|
+
function rescope(b, hole, fn) {
|
|
2856
|
+
const prevScope = engine.scope;
|
|
2857
|
+
const prevVisit = engine.visit;
|
|
2858
|
+
engine.scope = {
|
|
2859
|
+
id: scopeId(b.scope),
|
|
2860
|
+
p: null,
|
|
2861
|
+
i: 0,
|
|
2862
|
+
n: null,
|
|
2863
|
+
c: 0,
|
|
2864
|
+
h: hole
|
|
2865
|
+
};
|
|
2866
|
+
const visit = engine.visit = {
|
|
2867
|
+
occ: null
|
|
2868
|
+
};
|
|
2869
|
+
try {
|
|
2870
|
+
return fn();
|
|
2871
|
+
} finally {
|
|
2872
|
+
engine.scope = prevScope;
|
|
2873
|
+
engine.visit = prevVisit;
|
|
2874
|
+
b.next = visit.occ;
|
|
2875
|
+
}
|
|
2876
|
+
}
|
|
2877
|
+
function settleOccurrences(b) {
|
|
2878
|
+
const occ = b.next;
|
|
2879
|
+
b.next = null;
|
|
2880
|
+
if (b.occ) for (const [id, forget] of b.occ) if (!occ || !occ.has(id)) forget();
|
|
2881
|
+
b.occ = occ;
|
|
2882
|
+
if (occ) for (let a = b.up; a; a = a.up) for (const [id, forget] of occ) collect(a, id, forget);
|
|
2883
|
+
}
|
|
2884
|
+
function leave(b, parent, scope, visit) {
|
|
2885
|
+
engine.parent = parent;
|
|
2886
|
+
engine.scope = scope;
|
|
2887
|
+
engine.visit = visit;
|
|
2888
|
+
if (visit && b.occ) for (const [id, forget] of b.occ) collect(visit, id, forget);
|
|
2889
|
+
}
|
|
1904
2890
|
const engine = {
|
|
1905
2891
|
suppressed: 0,
|
|
1906
2892
|
sweeping: false,
|
|
1907
2893
|
parent: null,
|
|
1908
|
-
recordStamp: 0,
|
|
1909
2894
|
gateHit: false,
|
|
2895
|
+
sweptOwners: false,
|
|
2896
|
+
scope: null,
|
|
2897
|
+
visit: null,
|
|
2898
|
+
dry: false,
|
|
2899
|
+
slotId(prop, given) {
|
|
2900
|
+
const s = engine.scope;
|
|
2901
|
+
if (!s) return given;
|
|
2902
|
+
const n = s.n || (s.n = Object.create(null));
|
|
2903
|
+
const i = n[prop] || 0;
|
|
2904
|
+
n[prop] = i + 1;
|
|
2905
|
+
const sid = scopeId(s);
|
|
2906
|
+
const at = sid + "." + i + "\0" + prop;
|
|
2907
|
+
if (given !== undefined) {
|
|
2908
|
+
ids.set(at, given);
|
|
2909
|
+
return given;
|
|
2910
|
+
}
|
|
2911
|
+
return ids.get(at) || `${prop}#~${sid}.${i}`;
|
|
2912
|
+
},
|
|
2913
|
+
seen(id, forget) {
|
|
2914
|
+
if (engine.visit) collect(engine.visit, id, forget);
|
|
2915
|
+
},
|
|
2916
|
+
nest(hole) {
|
|
2917
|
+
const s = engine.scope;
|
|
2918
|
+
if (!s || s.h === hole || hole.$lhSkip || inScope && !inScope()) return undefined;
|
|
2919
|
+
engine.scope = scopeFor(hole);
|
|
2920
|
+
return s;
|
|
2921
|
+
},
|
|
1910
2922
|
content(hole) {
|
|
1911
2923
|
if (hole.$lhSuppress) {
|
|
1912
2924
|
const r = {
|
|
@@ -1914,10 +2926,12 @@ function createLiveHoles(sink, scoped) {
|
|
|
1914
2926
|
h: [],
|
|
1915
2927
|
p: []
|
|
1916
2928
|
};
|
|
1917
|
-
|
|
1918
|
-
|
|
2929
|
+
let rows = null;
|
|
2930
|
+
const b = hole.$lhBinding;
|
|
2931
|
+
const run = () => {
|
|
2932
|
+
engine.suppressed++;
|
|
1919
2933
|
try {
|
|
1920
|
-
|
|
2934
|
+
rows = resolveValue(holeValue(hole), r);
|
|
1921
2935
|
} catch (err) {
|
|
1922
2936
|
const wrap = buildAsyncWrap(err, hole);
|
|
1923
2937
|
if (wrap) {
|
|
@@ -1925,45 +2939,53 @@ function createLiveHoles(sink, scoped) {
|
|
|
1925
2939
|
r.p.push(wrap.p);
|
|
1926
2940
|
r.t.push("");
|
|
1927
2941
|
}
|
|
2942
|
+
} finally {
|
|
2943
|
+
engine.suppressed--;
|
|
1928
2944
|
}
|
|
1929
|
-
}
|
|
1930
|
-
|
|
1931
|
-
}
|
|
1932
|
-
const b = hole.$lhBinding;
|
|
2945
|
+
};
|
|
2946
|
+
b && !engine.sweeping ? rescope(b, hole, run) : run();
|
|
1933
2947
|
if (b && !b.closed && !r.h.length && !engine.sweeping) {
|
|
1934
2948
|
b.last = stripMarkers(r.t[0]);
|
|
2949
|
+
b.rows = rows;
|
|
2950
|
+
settleOccurrences(b);
|
|
1935
2951
|
}
|
|
1936
2952
|
return r.h.length ? r : r.t[0];
|
|
1937
2953
|
}
|
|
1938
2954
|
if (engine.suppressed || engine.sweeping) return null;
|
|
1939
2955
|
if (hole.$lhSkip) return null;
|
|
1940
2956
|
if (inScope && !inScope()) return null;
|
|
1941
|
-
const recordsBefore = engine.recordStamp;
|
|
1942
2957
|
const ownersBefore = stamp();
|
|
1943
2958
|
const owner = getOwner();
|
|
2959
|
+
const holeCtx = sharedConfig.context;
|
|
1944
2960
|
const b = {
|
|
1945
2961
|
key: null,
|
|
1946
2962
|
children: [],
|
|
1947
2963
|
last: null,
|
|
2964
|
+
rows: null,
|
|
2965
|
+
fn: hole.$fn,
|
|
1948
2966
|
closed: false,
|
|
2967
|
+
scope: undefined,
|
|
2968
|
+
occ: null,
|
|
2969
|
+
next: null,
|
|
2970
|
+
up: engine.parent,
|
|
1949
2971
|
sweep() {
|
|
1950
2972
|
if (b.closed) return;
|
|
1951
2973
|
const prevSweeping = engine.sweeping;
|
|
1952
2974
|
engine.sweeping = true;
|
|
1953
|
-
engine.
|
|
1954
|
-
const sweepOwnersBefore = stamp();
|
|
2975
|
+
engine.dry = b.last === null;
|
|
1955
2976
|
let res;
|
|
1956
2977
|
try {
|
|
1957
|
-
res =
|
|
2978
|
+
res = rescope(b, hole, () => swept(owner, holeCtx, () => resolveHoleValue(hole)));
|
|
1958
2979
|
} catch (err) {
|
|
1959
2980
|
b.closed = true;
|
|
1960
2981
|
sink.closeBinding(b.key);
|
|
1961
|
-
sink.error(b.key,
|
|
2982
|
+
sink.error(b.key, wireErrorMessage(err, errorScope));
|
|
1962
2983
|
return;
|
|
1963
2984
|
} finally {
|
|
1964
2985
|
engine.sweeping = prevSweeping;
|
|
2986
|
+
engine.dry = false;
|
|
1965
2987
|
}
|
|
1966
|
-
if (engine.
|
|
2988
|
+
if (engine.sweptOwners && res.h.length) {
|
|
1967
2989
|
b.closed = true;
|
|
1968
2990
|
sink.closeBinding(b.key);
|
|
1969
2991
|
return;
|
|
@@ -1971,29 +2993,38 @@ function createLiveHoles(sink, scoped) {
|
|
|
1971
2993
|
if (res.h.length) return;
|
|
1972
2994
|
const html = res.t[0];
|
|
1973
2995
|
if (b.last === null || html === b.last) return;
|
|
2996
|
+
const ops = b.rows && res.rows && rowOps(b.rows, res.rows);
|
|
1974
2997
|
b.last = html;
|
|
2998
|
+
if (ops && !ops.r.length && ops.n === b.rows.length) return;
|
|
2999
|
+
b.rows = res.rows;
|
|
1975
3000
|
closeChildren(b);
|
|
1976
|
-
|
|
3001
|
+
settleOccurrences(b);
|
|
3002
|
+
sink.hole(b.key, html, ops && !html.includes("<!--slot:") ? ops : null);
|
|
1977
3003
|
}
|
|
1978
3004
|
};
|
|
1979
3005
|
if (engine.parent) engine.parent.children.push(b);
|
|
1980
3006
|
const prevParent = engine.parent;
|
|
3007
|
+
const prevScope = engine.scope;
|
|
3008
|
+
const prevVisit = engine.visit;
|
|
3009
|
+
const scope = b.scope = scopeFor(hole);
|
|
1981
3010
|
engine.parent = b;
|
|
3011
|
+
engine.scope = scope;
|
|
3012
|
+
engine.visit = b;
|
|
1982
3013
|
let value;
|
|
1983
3014
|
let escalated = null;
|
|
1984
3015
|
try {
|
|
1985
|
-
value = hole
|
|
3016
|
+
value = holeValue(hole);
|
|
1986
3017
|
} catch (err) {
|
|
1987
3018
|
const wrap = buildAsyncWrap(err, hole);
|
|
1988
3019
|
if (!wrap) {
|
|
1989
|
-
|
|
3020
|
+
leave(b, prevParent, prevScope, prevVisit);
|
|
1990
3021
|
closeChildren(b);
|
|
1991
3022
|
return "";
|
|
1992
3023
|
}
|
|
1993
3024
|
escalated = wrap;
|
|
1994
3025
|
}
|
|
1995
3026
|
if (!escalated && (typeof value === "function" && value.$lhSkip || value !== null && typeof value === "object" && value.$slot)) {
|
|
1996
|
-
|
|
3027
|
+
leave(b, prevParent, prevScope, prevVisit);
|
|
1997
3028
|
const r = {
|
|
1998
3029
|
t: [""],
|
|
1999
3030
|
h: [],
|
|
@@ -2008,6 +3039,7 @@ function createLiveHoles(sink, scoped) {
|
|
|
2008
3039
|
return r.h.length ? r : r.t[0];
|
|
2009
3040
|
}
|
|
2010
3041
|
let res;
|
|
3042
|
+
let rows = null;
|
|
2011
3043
|
if (escalated) {
|
|
2012
3044
|
closeChildren(b);
|
|
2013
3045
|
escalated.fn.$lhSuppress = true;
|
|
@@ -2024,23 +3056,25 @@ function createLiveHoles(sink, scoped) {
|
|
|
2024
3056
|
p: []
|
|
2025
3057
|
};
|
|
2026
3058
|
try {
|
|
2027
|
-
|
|
3059
|
+
rows = resolveValue(value, res);
|
|
2028
3060
|
} catch (_) {
|
|
2029
|
-
|
|
3061
|
+
leave(b, prevParent, prevScope, prevVisit);
|
|
2030
3062
|
closeChildren(b);
|
|
2031
3063
|
return "";
|
|
2032
3064
|
}
|
|
2033
3065
|
}
|
|
2034
|
-
|
|
2035
|
-
if (
|
|
3066
|
+
leave(b, prevParent, prevScope, prevVisit);
|
|
3067
|
+
if (stamp() !== ownersBefore) {
|
|
2036
3068
|
return res.h.length ? res : res.t[0];
|
|
2037
3069
|
}
|
|
3070
|
+
if (!res.h.length && settled && settled()) return res.t[0];
|
|
2038
3071
|
const id = nextId++;
|
|
2039
3072
|
const key = b.key = "lh:" + id;
|
|
2040
3073
|
const open = `<!--lh:${id}-->`;
|
|
2041
3074
|
const close = `<!--lh:/${id}-->`;
|
|
2042
3075
|
if (!res.h.length) {
|
|
2043
3076
|
b.last = stripMarkers(res.t[0]);
|
|
3077
|
+
b.rows = rows;
|
|
2044
3078
|
sink.openBinding(key, b);
|
|
2045
3079
|
return open + res.t[0] + close;
|
|
2046
3080
|
}
|
|
@@ -2058,10 +3092,11 @@ function createLiveHoles(sink, scoped) {
|
|
|
2058
3092
|
return nextId++;
|
|
2059
3093
|
},
|
|
2060
3094
|
active() {
|
|
2061
|
-
return !inScope || inScope();
|
|
3095
|
+
return (!inScope || inScope()) && !(settled && settled());
|
|
2062
3096
|
},
|
|
2063
3097
|
attr(cap) {
|
|
2064
3098
|
const owner = getOwner();
|
|
3099
|
+
const holeCtx = sharedConfig.context;
|
|
2065
3100
|
const b = {
|
|
2066
3101
|
key: "lha:" + cap.id,
|
|
2067
3102
|
children: [],
|
|
@@ -2070,9 +3105,10 @@ function createLiveHoles(sink, scoped) {
|
|
|
2070
3105
|
sweep() {
|
|
2071
3106
|
if (b.closed) return;
|
|
2072
3107
|
const prevSweeping = engine.sweeping;
|
|
3108
|
+
const prevScope = engine.scope;
|
|
2073
3109
|
engine.sweeping = true;
|
|
3110
|
+
engine.scope = null;
|
|
2074
3111
|
engine.gateHit = false;
|
|
2075
|
-
const sweepOwnersBefore = stamp();
|
|
2076
3112
|
let html = "";
|
|
2077
3113
|
try {
|
|
2078
3114
|
let group = null;
|
|
@@ -2097,17 +3133,23 @@ function createLiveHoles(sink, scoped) {
|
|
|
2097
3133
|
if (vt === "string" || vt === "number") html += v;
|
|
2098
3134
|
}
|
|
2099
3135
|
};
|
|
2100
|
-
|
|
3136
|
+
swept(owner, holeCtx, run);
|
|
2101
3137
|
} catch (err) {
|
|
2102
|
-
if (ssrHandleError(err, true))
|
|
3138
|
+
if (ssrHandleError(err, true)) {
|
|
3139
|
+
if (!engine.sweptOwners) return;
|
|
3140
|
+
b.closed = true;
|
|
3141
|
+
sink.closeBinding(b.key);
|
|
3142
|
+
return;
|
|
3143
|
+
}
|
|
2103
3144
|
b.closed = true;
|
|
2104
3145
|
sink.closeBinding(b.key);
|
|
2105
|
-
sink.error("lha:" + cap.id,
|
|
3146
|
+
sink.error("lha:" + cap.id, wireErrorMessage(err, errorScope));
|
|
2106
3147
|
return;
|
|
2107
3148
|
} finally {
|
|
2108
3149
|
engine.sweeping = prevSweeping;
|
|
3150
|
+
engine.scope = prevScope;
|
|
2109
3151
|
}
|
|
2110
|
-
if (engine.gateHit
|
|
3152
|
+
if (engine.gateHit) {
|
|
2111
3153
|
b.closed = true;
|
|
2112
3154
|
sink.closeBinding(b.key);
|
|
2113
3155
|
return;
|
|
@@ -2120,6 +3162,7 @@ function createLiveHoles(sink, scoped) {
|
|
|
2120
3162
|
sink.attr(String(cap.id), html, removed);
|
|
2121
3163
|
}
|
|
2122
3164
|
};
|
|
3165
|
+
if (sink.attrBaseline) sink.attrBaseline(b.key, cap.base);
|
|
2123
3166
|
sink.openBinding(b.key, b);
|
|
2124
3167
|
}
|
|
2125
3168
|
};
|
|
@@ -2132,6 +3175,71 @@ function attrNames(text) {
|
|
|
2132
3175
|
while (m = re.exec(text)) names.push(m[1]);
|
|
2133
3176
|
return names;
|
|
2134
3177
|
}
|
|
3178
|
+
const ROW_HTML = Symbol.for("solid.rowHtml");
|
|
3179
|
+
const ROW_TOKEN = /<(\/?)([a-zA-Z][^\s/>]*)((?:[^>"']|"[^"]*"|'[^']*')*)>|<!--([\s\S]*?)-->/g;
|
|
3180
|
+
const ROW_VOID = /^(?:area|base|br|col|embed|hr|img|input|link|meta|source|track|wbr)$/i;
|
|
3181
|
+
const ROW_FOREIGN = /^(?:svg|math)$/i;
|
|
3182
|
+
const ROW_RAW = /^(?:script|style|textarea|title|template)$/i;
|
|
3183
|
+
const ROW_KEY = /\s_key(?:="[^"]*")?(?![^\s/])/;
|
|
3184
|
+
const rowKey = attrs => (ROW_KEY.exec(attrs) || [""])[0];
|
|
3185
|
+
const ROW_ENTITY = /&(?:amp|lt|gt|quot|#39);/g;
|
|
3186
|
+
const ROW_ENTITIES = {
|
|
3187
|
+
"&": "&",
|
|
3188
|
+
"<": "<",
|
|
3189
|
+
">": ">",
|
|
3190
|
+
""": '"',
|
|
3191
|
+
"'": "'"
|
|
3192
|
+
};
|
|
3193
|
+
function rowText(text) {
|
|
3194
|
+
if (!text.includes("&")) return text;
|
|
3195
|
+
if (text.replace(ROW_ENTITY, "").includes("&")) return null;
|
|
3196
|
+
return text.replace(ROW_ENTITY, e => ROW_ENTITIES[e]);
|
|
3197
|
+
}
|
|
3198
|
+
const ROW_HASH_SEED = 0x811c9dc5;
|
|
3199
|
+
function rowPatch(a, b) {
|
|
3200
|
+
const ra = new RegExp(ROW_TOKEN);
|
|
3201
|
+
const rb = new RegExp(ROW_TOKEN);
|
|
3202
|
+
const p = [];
|
|
3203
|
+
const stack = [[-1, 0, false]];
|
|
3204
|
+
let el = -1;
|
|
3205
|
+
let h = ROW_HASH_SEED;
|
|
3206
|
+
let ia = 0;
|
|
3207
|
+
let ib = 0;
|
|
3208
|
+
for (;;) {
|
|
3209
|
+
const ma = ra.exec(a);
|
|
3210
|
+
const mb = rb.exec(b);
|
|
3211
|
+
const ta = a.slice(ia, ma ? ma.index : a.length);
|
|
3212
|
+
const tb = b.slice(ib, mb ? mb.index : b.length);
|
|
3213
|
+
const top = stack[stack.length - 1];
|
|
3214
|
+
if (ta !== tb) {
|
|
3215
|
+
const text = rowText(tb);
|
|
3216
|
+
if (text === null) return null;
|
|
3217
|
+
p.push([top[0], top[1], text]);
|
|
3218
|
+
}
|
|
3219
|
+
if (!ma || !mb) return !ma && !mb ? {
|
|
3220
|
+
p,
|
|
3221
|
+
h: h >>> 0
|
|
3222
|
+
} : null;
|
|
3223
|
+
ia = ra.lastIndex;
|
|
3224
|
+
ib = rb.lastIndex;
|
|
3225
|
+
if (ma[4] !== undefined || mb[4] !== undefined) {
|
|
3226
|
+
if (ma[4] !== mb[4]) return null;
|
|
3227
|
+
top[1]++;
|
|
3228
|
+
} else if (ma[1] !== mb[1] || ma[2] !== mb[2]) return null;else if (ROW_RAW.test(ma[2])) return null;else if (ma[1]) {
|
|
3229
|
+
if (stack.length === 1) return null;
|
|
3230
|
+
stack.pop();
|
|
3231
|
+
} else {
|
|
3232
|
+
el++;
|
|
3233
|
+
top[1]++;
|
|
3234
|
+
const foreign = top[2] || ROW_FOREIGN.test(ma[2]);
|
|
3235
|
+
if (ma[3] !== mb[3]) {
|
|
3236
|
+
if (foreign || rowKey(ma[3]) !== rowKey(mb[3])) return null;
|
|
3237
|
+
p.push([el, mb[3].replace(/\/$/, "")]);
|
|
3238
|
+
}
|
|
3239
|
+
if (!ROW_VOID.test(ma[2]) && !ma[3].endsWith("/")) stack.push([el, 0, foreign]);
|
|
3240
|
+
}
|
|
3241
|
+
}
|
|
3242
|
+
}
|
|
2135
3243
|
function ssr(t) {
|
|
2136
3244
|
const len = arguments.length;
|
|
2137
3245
|
if (len === 1) return {
|
|
@@ -2171,7 +3279,9 @@ function ssr(t) {
|
|
|
2171
3279
|
cap = {
|
|
2172
3280
|
id,
|
|
2173
3281
|
parts: [prefix],
|
|
2174
|
-
base: prefix
|
|
3282
|
+
base: prefix,
|
|
3283
|
+
at: lastOpen.seg,
|
|
3284
|
+
inject
|
|
2175
3285
|
};
|
|
2176
3286
|
return true;
|
|
2177
3287
|
};
|
|
@@ -2220,7 +3330,10 @@ function ssr(t) {
|
|
|
2220
3330
|
});
|
|
2221
3331
|
}
|
|
2222
3332
|
} else {
|
|
2223
|
-
cap
|
|
3333
|
+
if (cap) {
|
|
3334
|
+
result.t[cap.at] = result.t[cap.at].replace(cap.inject, "");
|
|
3335
|
+
cap = null;
|
|
3336
|
+
}
|
|
2224
3337
|
result.h.push(ssrGroupSlot(lastGroupVal.fn, lastGroupIdx++));
|
|
2225
3338
|
result.p.push(lastGroupVal.p);
|
|
2226
3339
|
result.t.push("");
|
|
@@ -2282,12 +3395,15 @@ function ssr(t) {
|
|
|
2282
3395
|
f: hole
|
|
2283
3396
|
});
|
|
2284
3397
|
} else {
|
|
3398
|
+
result.t[cap.at] = result.t[cap.at].replace(cap.inject, "");
|
|
2285
3399
|
cap = null;
|
|
2286
3400
|
}
|
|
2287
3401
|
}
|
|
2288
3402
|
} else {
|
|
2289
3403
|
const capturing = live && !hp.pos[i - 1] && captureStart();
|
|
3404
|
+
const scope = live && hp.pos[i - 1] && live.nest(hole);
|
|
2290
3405
|
const r = tryResolveFunctionHole(hole);
|
|
3406
|
+
if (scope) live.scope = scope;
|
|
2291
3407
|
if (typeof r === "string") {
|
|
2292
3408
|
s += r;
|
|
2293
3409
|
if (capturing) {
|
|
@@ -2297,7 +3413,10 @@ function ssr(t) {
|
|
|
2297
3413
|
});
|
|
2298
3414
|
}
|
|
2299
3415
|
} else {
|
|
2300
|
-
if (capturing)
|
|
3416
|
+
if (capturing) {
|
|
3417
|
+
s = s.replace(cap.inject, "");
|
|
3418
|
+
cap = null;
|
|
3419
|
+
}
|
|
2301
3420
|
result = {
|
|
2302
3421
|
t: [s],
|
|
2303
3422
|
h: [],
|
|
@@ -2358,16 +3477,17 @@ function ssr(t) {
|
|
|
2358
3477
|
return result;
|
|
2359
3478
|
}
|
|
2360
3479
|
function ssrClassName(value) {
|
|
3480
|
+
if (typeof value === "number") return "" + value;
|
|
2361
3481
|
if (!value) return "";
|
|
2362
3482
|
if (typeof value === "string") return escape(value, true);
|
|
2363
3483
|
value = classListToObject(value);
|
|
2364
3484
|
let classKeys = Object.keys(value),
|
|
2365
3485
|
result = "";
|
|
2366
3486
|
for (let i = 0, len = classKeys.length; i < len; i++) {
|
|
2367
|
-
const key = classKeys[i]
|
|
2368
|
-
|
|
3487
|
+
const key = classKeys[i];
|
|
3488
|
+
const classValue = value[key];
|
|
2369
3489
|
if (!key || key === "undefined" || !classValue) continue;
|
|
2370
|
-
|
|
3490
|
+
result && (result += " ");
|
|
2371
3491
|
result += escape(key, true);
|
|
2372
3492
|
}
|
|
2373
3493
|
return result;
|
|
@@ -2381,9 +3501,9 @@ function ssrStyle(value) {
|
|
|
2381
3501
|
const s = escape(k[i], true);
|
|
2382
3502
|
const v = value[k[i]];
|
|
2383
3503
|
if (v != undefined) {
|
|
2384
|
-
if (i) result += ";";
|
|
2385
3504
|
const r = escape(v, true);
|
|
2386
3505
|
if (r != undefined && r !== "undefined") {
|
|
3506
|
+
if (result) result += ";";
|
|
2387
3507
|
result += `${s}:${r}`;
|
|
2388
3508
|
}
|
|
2389
3509
|
}
|
|
@@ -2393,76 +3513,158 @@ function ssrStyle(value) {
|
|
|
2393
3513
|
function ssrStyleProperty(name, value) {
|
|
2394
3514
|
return value != null ? name + value : "";
|
|
2395
3515
|
}
|
|
2396
|
-
function
|
|
3516
|
+
function ssrStyleProperties(...entries) {
|
|
3517
|
+
let result = "";
|
|
3518
|
+
for (let i = 0; i < entries.length; i += 2) {
|
|
3519
|
+
const entry = ssrStyleProperty(entries[i], entries[i + 1]);
|
|
3520
|
+
if (entry) result = result ? result + ";" + entry : entry;
|
|
3521
|
+
}
|
|
3522
|
+
return result;
|
|
3523
|
+
}
|
|
3524
|
+
function ssrElement(tag, props, children, needsId, skip, attrs) {
|
|
2397
3525
|
const hk = needsId ? ssrHydrationKey() : "";
|
|
2398
|
-
if (
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
let
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
3526
|
+
if (typeof props === "function") props = props();
|
|
3527
|
+
let sources = null;
|
|
3528
|
+
let proxy = false;
|
|
3529
|
+
let viewKeys = null;
|
|
3530
|
+
let owners = null;
|
|
3531
|
+
const ctx = renderConfig.context;
|
|
3532
|
+
const link = tag === "a" && ctx !== undefined && ctx.linkClaim !== undefined ? {} : null;
|
|
3533
|
+
if (Array.isArray(props)) {
|
|
3534
|
+
let i = 0;
|
|
3535
|
+
for (; i < props.length; i++) {
|
|
3536
|
+
const s = props[i];
|
|
3537
|
+
if (s == null || typeof s === "function" || $PROXY in s) break;
|
|
2407
3538
|
}
|
|
2408
|
-
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
result += `class="${ssrClassName(value)}"`;
|
|
2413
|
-
} else if (value == undefined || prop === "ref" || prop.slice(0, 2) === "on" || prop.slice(0, 5) === "prop:") {
|
|
2414
|
-
continue;
|
|
2415
|
-
} else if (typeof value === "boolean") {
|
|
2416
|
-
if (!value) continue;
|
|
2417
|
-
result += escape(prop);
|
|
2418
|
-
} else {
|
|
2419
|
-
result += value === "" ? escape(prop) : `${escape(prop)}="${escape(value, true)}"`;
|
|
3539
|
+
if (i === props.length) sources = props;else {
|
|
3540
|
+
viewKeys = [];
|
|
3541
|
+
owners = [];
|
|
3542
|
+
collectSpreadSources(props, viewKeys, owners);
|
|
2420
3543
|
}
|
|
2421
|
-
|
|
3544
|
+
} else if (props == null) {
|
|
3545
|
+
props = {};
|
|
3546
|
+
} else if ($PROXY in props) {
|
|
3547
|
+
if (viewOf(props) !== undefined) {
|
|
3548
|
+
viewKeys = [];
|
|
3549
|
+
owners = [];
|
|
3550
|
+
sourceOwners(props, viewKeys, owners);
|
|
3551
|
+
} else proxy = true;
|
|
3552
|
+
}
|
|
3553
|
+
const info = tagInfo(tag);
|
|
3554
|
+
const skipChildren = info.isVoid;
|
|
3555
|
+
let result = info.open + hk;
|
|
3556
|
+
let childOwner = null;
|
|
3557
|
+
const last = sources === null ? 0 : sources.length - 1;
|
|
3558
|
+
let keysOf = null;
|
|
3559
|
+
if (sources !== null) {
|
|
3560
|
+
keysOf = new Array(last + 1);
|
|
3561
|
+
for (let s = 0; s <= last; s++) keysOf[s] = Object.keys(sources[s]);
|
|
2422
3562
|
}
|
|
3563
|
+
for (let s = 0; s <= last; s++) {
|
|
3564
|
+
const keys = owners !== null ? viewKeys : keysOf !== null ? keysOf[s] : proxy ? Reflect.ownKeys(props) : Object.keys(props);
|
|
3565
|
+
if (sources !== null) props = sources[s];
|
|
3566
|
+
nextKey: for (let i = 0; i < keys.length; i++) {
|
|
3567
|
+
let prop = keys[i];
|
|
3568
|
+
if (typeof prop !== "string" || skip !== undefined && skip(prop)) continue;
|
|
3569
|
+
if (owners !== null) props = owners[i];
|
|
3570
|
+
for (let j = s + 1; j <= last; j++) {
|
|
3571
|
+
if (keysOf[j].includes(prop)) continue nextKey;
|
|
3572
|
+
}
|
|
3573
|
+
if (info.textarea && (prop === "value" || prop === "defaultValue")) {
|
|
3574
|
+
const value = props[prop];
|
|
3575
|
+
if (value !== null) children = escape(value);
|
|
3576
|
+
continue;
|
|
3577
|
+
}
|
|
3578
|
+
if (ChildProperties.has(prop)) {
|
|
3579
|
+
if (children === undefined && childOwner === null && !skipChildren) {
|
|
3580
|
+
if (prop === "children") childOwner = props;else children = info.raw || prop === "innerHTML" ? props[prop] : escape(props[prop]);
|
|
3581
|
+
}
|
|
3582
|
+
continue;
|
|
3583
|
+
}
|
|
3584
|
+
const key = prop;
|
|
3585
|
+
if (info.formAttributes !== undefined) {
|
|
3586
|
+
prop = spreadFormAttribute(prop, info, keys, keysOf, skip);
|
|
3587
|
+
if (prop === undefined) continue;
|
|
3588
|
+
}
|
|
3589
|
+
const value = props[key];
|
|
3590
|
+
if (value == undefined || prop.startsWith("prop:") || prop === "ref" || isEventName(prop)) continue;
|
|
3591
|
+
if (link !== null && LinkAttributes.has(prop)) link[prop] = value;
|
|
3592
|
+
if (prop === "style") {
|
|
3593
|
+
result += ` style="${ssrStyle(value)}"`;
|
|
3594
|
+
} else if (prop === "class") {
|
|
3595
|
+
result += ` class="${ssrClassName(value)}"`;
|
|
3596
|
+
} else if (typeof value === "boolean") {
|
|
3597
|
+
if (value && isAttrName(prop)) result += ` ${prop}`;
|
|
3598
|
+
} else if (isAttrName(prop)) {
|
|
3599
|
+
result += value === "" ? ` ${prop}` : ` ${prop}="${escape(value, true)}"`;
|
|
3600
|
+
}
|
|
3601
|
+
}
|
|
3602
|
+
}
|
|
3603
|
+
if (attrs !== undefined) result += typeof attrs === "function" ? attrs() : attrs;
|
|
3604
|
+
if (link !== null && link.href !== undefined) result += ssrLinkClaim(link);
|
|
2423
3605
|
if (skipChildren) return {
|
|
2424
|
-
t: result + "/>"
|
|
3606
|
+
t: result + " />"
|
|
2425
3607
|
};
|
|
3608
|
+
if (childOwner !== null) children = info.raw ? childOwner.children : escape(childOwner.children);
|
|
2426
3609
|
if (typeof children === "function") children = children();
|
|
2427
|
-
|
|
3610
|
+
const ct = typeof children;
|
|
3611
|
+
if (ct === "string" || ct === "number") return {
|
|
3612
|
+
t: result + ">" + children + info.close
|
|
3613
|
+
};
|
|
3614
|
+
if (children == null || ct === "boolean") return {
|
|
3615
|
+
t: result + ">" + info.close
|
|
3616
|
+
};
|
|
3617
|
+
if (ct === "object" && !children.h && typeof children.t === "string") return {
|
|
3618
|
+
t: result + ">" + children.t + info.close
|
|
3619
|
+
};
|
|
3620
|
+
return ssr([result + ">", info.close], resolveSSRNode(children, undefined, true));
|
|
3621
|
+
}
|
|
3622
|
+
function collectSpreadSources(props, viewKeys, owners) {
|
|
3623
|
+
for (let i = 0; i < props.length; i++) {
|
|
3624
|
+
let s = props[i];
|
|
3625
|
+
if (typeof s === "function") s = s();
|
|
3626
|
+
if (s != null) sourceOwners(s, viewKeys, owners);
|
|
3627
|
+
}
|
|
3628
|
+
}
|
|
3629
|
+
function spreadFormAttribute(prop, info, keys, keysOf, skip) {
|
|
3630
|
+
const defaultProp = info.formDefaults[prop];
|
|
3631
|
+
if (defaultProp !== undefined && (skip === undefined || !skip(defaultProp))) {
|
|
3632
|
+
if (keysOf !== null) {
|
|
3633
|
+
for (let j = 0; j < keysOf.length; j++) {
|
|
3634
|
+
if (keysOf[j].includes(defaultProp)) return;
|
|
3635
|
+
}
|
|
3636
|
+
} else if (keys.includes(defaultProp)) return;
|
|
3637
|
+
}
|
|
3638
|
+
const attr = info.formAttributes[prop];
|
|
3639
|
+
if (attr !== undefined && skip !== undefined && skip(attr)) return;
|
|
3640
|
+
return attr === undefined ? prop : attr;
|
|
3641
|
+
}
|
|
3642
|
+
function ssrElementAttribute(key, value) {
|
|
3643
|
+
if (value == undefined) return "";
|
|
3644
|
+
if (key === "style" || key === "class") return ` ${key}="${key === "class" ? ssrClassName(value) : ssrStyle(value)}"`;
|
|
3645
|
+
if (typeof value === "boolean") return value ? ` ${key}` : "";
|
|
3646
|
+
return value === "" ? ` ${key}` : ` ${key}="${escape(value, true)}"`;
|
|
2428
3647
|
}
|
|
2429
3648
|
function ssrAttribute(key, value) {
|
|
2430
|
-
|
|
3649
|
+
if (typeof value === "string") return ` ${key}="${value}"`;
|
|
3650
|
+
if (value == null || value === false) return "";
|
|
3651
|
+
if (typeof value === "object") return ` ${key}="${escape(String(value), true)}"`;
|
|
3652
|
+
if (typeof value === "function") return ` ${key}="${escape(String(value), true)}"`;
|
|
3653
|
+
return value === true ? ` ${key}` : ` ${key}="${value}"`;
|
|
2431
3654
|
}
|
|
2432
3655
|
function ssrHydrationKey() {
|
|
2433
3656
|
const hk = getHydrationKey();
|
|
2434
3657
|
return hk ? ` _hk=${hk}` : "";
|
|
2435
3658
|
}
|
|
2436
|
-
|
|
2437
|
-
const
|
|
2438
|
-
|
|
2439
|
-
|
|
2440
|
-
function encodeClaimKey(key) {
|
|
2441
|
-
return String(key).replace(CLAIM_UNSAFE, c => encodeURIComponent(c));
|
|
2442
|
-
}
|
|
2443
|
-
function ssrClaim(map) {
|
|
2444
|
-
const mode = sharedConfig.context && sharedConfig.context.claims;
|
|
2445
|
-
if (!mode || mode === CLAIMS_DOCUMENT && !(typeof inServerComponentScope === "function" && inServerComponentScope())) {
|
|
2446
|
-
return "";
|
|
2447
|
-
}
|
|
2448
|
-
let out = "";
|
|
2449
|
-
for (const pos in map) {
|
|
2450
|
-
const value = map[pos];
|
|
2451
|
-
const list = Array.isArray(value) ? value : [value];
|
|
2452
|
-
for (const fn of list) {
|
|
2453
|
-
const prop = typeof fn === "function" && fn[CLAIM_PROP] || undefined;
|
|
2454
|
-
if (prop === undefined) {
|
|
2455
|
-
continue;
|
|
2456
|
-
}
|
|
2457
|
-
out += `${out ? "," : ""}${pos}=${encodeClaimKey(prop)}`;
|
|
2458
|
-
}
|
|
2459
|
-
}
|
|
2460
|
-
return out ? ` _bnd="${out}"` : "";
|
|
3659
|
+
function ssrLinkClaim(attrs) {
|
|
3660
|
+
const ctx = renderConfig.context;
|
|
3661
|
+
if (ctx === undefined || ctx.linkClaim === undefined || attrs["aria-current"] != null) return "";
|
|
3662
|
+
return ctx.linkClaim(attrs);
|
|
2461
3663
|
}
|
|
2462
3664
|
function decodeSSREntities(s) {
|
|
2463
3665
|
return s.indexOf("&") < 0 ? s : s.replace(/"/g, '"').replace(/</g, "<").replace(/&/g, "&");
|
|
2464
3666
|
}
|
|
2465
|
-
const SELECT_VALUE_ATTR = /\svalue
|
|
3667
|
+
const SELECT_VALUE_ATTR = /\svalue(?:="([^"]*)")?(?=[\s>]|$)/;
|
|
2466
3668
|
function tagEnd(html, i) {
|
|
2467
3669
|
for (let j = i + 1; j < html.length; j++) {
|
|
2468
3670
|
const c = html.charCodeAt(j);
|
|
@@ -2514,7 +3716,7 @@ function resolveSSRSelectValues(html) {
|
|
|
2514
3716
|
cand = html.indexOf("<select", e0 + 1);
|
|
2515
3717
|
continue;
|
|
2516
3718
|
}
|
|
2517
|
-
const bound = decodeSSREntities(m[1]);
|
|
3719
|
+
const bound = decodeSSREntities(m[1] ?? "");
|
|
2518
3720
|
const sel = {
|
|
2519
3721
|
values: /\smultiple(?=[\s>=])/.test(open) ? bound.split(",") : [bound],
|
|
2520
3722
|
strip: cand + m.index,
|
|
@@ -2551,7 +3753,7 @@ function resolveSSRSelectValues(html) {
|
|
|
2551
3753
|
const attrs = html.slice(i + 7, e);
|
|
2552
3754
|
if (/\sselected(?=[\s=]|$)/.test(attrs)) sel.defaulted = true;else {
|
|
2553
3755
|
const vm = SELECT_VALUE_ATTR.exec(attrs);
|
|
2554
|
-
const value = vm ? decodeSSREntities(vm[1]) : decodeSSREntities(optionText(html, e + 1)).replace(/\s+/g, " ").trim();
|
|
3756
|
+
const value = vm ? decodeSSREntities(vm[1] ?? "") : decodeSSREntities(optionText(html, e + 1)).replace(/\s+/g, " ").trim();
|
|
2555
3757
|
if (sel.values.includes(value)) sel.marks.push(e);
|
|
2556
3758
|
}
|
|
2557
3759
|
}
|
|
@@ -2570,10 +3772,13 @@ function escape(s, attr) {
|
|
|
2570
3772
|
if (!attr && Array.isArray(s)) {
|
|
2571
3773
|
const joined = tryJoinPlainSSRArray(s);
|
|
2572
3774
|
if (joined !== undefined) return joined;
|
|
3775
|
+
const src = s;
|
|
2573
3776
|
s = s.slice();
|
|
2574
3777
|
for (let i = 0; i < s.length; i++) s[i] = escape(s[i]);
|
|
3778
|
+
if (src.$slot) s.$slot = true;
|
|
2575
3779
|
return s;
|
|
2576
3780
|
}
|
|
3781
|
+
if (!attr && t === "function") return escapeLate(s);
|
|
2577
3782
|
if (attr) {
|
|
2578
3783
|
if (s == null || t === "boolean" || t === "number") return s;
|
|
2579
3784
|
return escape(String(s), attr);
|
|
@@ -2584,6 +3789,16 @@ function escape(s, attr) {
|
|
|
2584
3789
|
if (i < 0) return s;
|
|
2585
3790
|
return escapeSlow(s, attr, i);
|
|
2586
3791
|
}
|
|
3792
|
+
function escapeLate(fn) {
|
|
3793
|
+
if (fn.$esc) return fn;
|
|
3794
|
+
const w = () => escape(fn());
|
|
3795
|
+
w.$esc = true;
|
|
3796
|
+
w.$fn = fn;
|
|
3797
|
+
if (fn.$lhSkip) w.$lhSkip = true;
|
|
3798
|
+
if (fn.$lhSuppress) w.$lhSuppress = true;
|
|
3799
|
+
if (fn.$lhBinding) w.$lhBinding = fn.$lhBinding;
|
|
3800
|
+
return w;
|
|
3801
|
+
}
|
|
2587
3802
|
const ESCAPE_CONTENT = /[&<]/;
|
|
2588
3803
|
const ESCAPE_ATTR = /[&"<]/;
|
|
2589
3804
|
function escapeSlow(s, attr, start) {
|
|
@@ -2671,10 +3886,13 @@ function applyRef(r, element) {
|
|
|
2671
3886
|
Array.isArray(r) ? r.flat(Infinity).forEach(f => f && f(element)) : r(element);
|
|
2672
3887
|
}
|
|
2673
3888
|
function generateHydrationScript({
|
|
2674
|
-
eventNames
|
|
3889
|
+
eventNames,
|
|
2675
3890
|
nonce
|
|
2676
3891
|
} = {}) {
|
|
2677
|
-
return
|
|
3892
|
+
return hydrationBootstrap(eventNames, destinationNonce(nonce, "script"), false);
|
|
3893
|
+
}
|
|
3894
|
+
function hydrationBootstrap(eventNames = ["click", "input"], nonce, ledger) {
|
|
3895
|
+
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)}),${ledger ? "s:{}," : ""}fe(){}});</script><!--xs-->`;
|
|
2678
3896
|
}
|
|
2679
3897
|
function queue(fn) {
|
|
2680
3898
|
return Promise.resolve().then(fn);
|
|
@@ -2684,15 +3902,22 @@ function allSettled(promises) {
|
|
|
2684
3902
|
let size = promises.size;
|
|
2685
3903
|
return Promise.allSettled(promises).then(() => {
|
|
2686
3904
|
if (promises.size !== size) return allSettled(promises);
|
|
2687
|
-
return;
|
|
3905
|
+
return size;
|
|
2688
3906
|
});
|
|
2689
3907
|
}
|
|
2690
|
-
function
|
|
3908
|
+
function withShellEnd(html, context, renderId, nonce, noScripts) {
|
|
3909
|
+
if (noScripts || !context || !context.bootstrap) return html;
|
|
3910
|
+
const id = JSON.stringify(renderId).replace(/</g, "\\u003C");
|
|
3911
|
+
const marker = `<script${nonceAttr(nonce, "script")}>_$HY.s[${id}]=1,_$HY.sw&&_$HY.sw(${id})</script>`;
|
|
3912
|
+
const at = html.indexOf("</body>", html.length - 512);
|
|
3913
|
+
return at < 0 ? html + marker : html.slice(0, at) + marker + html.slice(at);
|
|
3914
|
+
}
|
|
3915
|
+
function assembleDocument(html, emittedAssets, preloadLinks, inlineStyles, scripts, nonce, headTags, onHead) {
|
|
2691
3916
|
const scriptTag = scripts ? `<script${nonceAttr(nonce, "script")}>${scripts}</script>` : "";
|
|
2692
3917
|
const title = headTags ? headTags.title : null;
|
|
2693
3918
|
let headTagsHtml = headTags ? headTags.html : "";
|
|
2694
3919
|
const headPrelude = headTags ? headTags.prelude : "";
|
|
2695
|
-
if (!onHead && title == null && !headTagsHtml && !headPrelude && !(emittedAssets && emittedAssets.size) && !(inlineStyles && inlineStyles.size)) {
|
|
3920
|
+
if (!onHead && title == null && !headTagsHtml && !headPrelude && !(emittedAssets && emittedAssets.size) && !preloadLinks && !(inlineStyles && inlineStyles.size)) {
|
|
2696
3921
|
if (!scriptTag) return html;
|
|
2697
3922
|
const xs = html.indexOf("<!--xs-->");
|
|
2698
3923
|
return xs === -1 ? html + scriptTag : html.slice(0, xs) + scriptTag + html.slice(xs);
|
|
@@ -2711,7 +3936,7 @@ function assembleDocument(html, emittedAssets, inlineStyles, scripts, nonce, hea
|
|
|
2711
3936
|
if (title != null) {
|
|
2712
3937
|
titleHtml = headTags.noScripts ? `<title data-dh="title">${escape(title)}</title>` : `<script${nonceAttr(nonce, "script")}>(function(x,t){(t=document.querySelector("title"))?(t.hasAttribute("data-dh")||t.setAttribute("data-dhf",t.textContent),t.textContent=x):(document.title=x,t=document.querySelector("title"));t&&t.setAttribute("data-dh","title")})(${JSON.stringify(title).replace(/</g, "\\u003C")})</script>`;
|
|
2713
3938
|
}
|
|
2714
|
-
onHead(headPrelude + headTagsHtml + titleHtml + renderHeadAssets(emittedAssets, inlineStyles, nonce));
|
|
3939
|
+
onHead(headPrelude + headTagsHtml + titleHtml + renderHeadAssets(emittedAssets, preloadLinks, inlineStyles, nonce));
|
|
2715
3940
|
}
|
|
2716
3941
|
if (!scriptTag) return html;
|
|
2717
3942
|
const xs = html.indexOf("<!--xs-->");
|
|
@@ -2731,13 +3956,13 @@ function assembleDocument(html, emittedAssets, inlineStyles, scripts, nonce, hea
|
|
|
2731
3956
|
headTagsHtml = `<title data-dh="title">${winner}</title>` + headTagsHtml;
|
|
2732
3957
|
}
|
|
2733
3958
|
}
|
|
2734
|
-
const head = headTagsHtml + renderHeadAssets(emittedAssets, inlineStyles, nonce);
|
|
3959
|
+
const head = headTagsHtml + renderHeadAssets(emittedAssets, preloadLinks, inlineStyles, nonce);
|
|
2735
3960
|
if (!scriptTag) return html.slice(0, headIdx) + head + html.slice(headIdx);
|
|
2736
3961
|
const xsIdx = html.indexOf("<!--xs-->");
|
|
2737
3962
|
if (xsIdx === -1) return html.slice(0, headIdx) + head + html.slice(headIdx) + scriptTag;
|
|
2738
3963
|
return xsIdx < headIdx ? html.slice(0, xsIdx) + scriptTag + html.slice(xsIdx, headIdx) + head + html.slice(headIdx) : html.slice(0, headIdx) + head + html.slice(headIdx, xsIdx) + scriptTag + html.slice(xsIdx);
|
|
2739
3964
|
}
|
|
2740
|
-
function renderHeadAssets(emittedAssets, inlineStyles, nonce) {
|
|
3965
|
+
function renderHeadAssets(emittedAssets, preloadLinks, inlineStyles, nonce) {
|
|
2741
3966
|
let head = "";
|
|
2742
3967
|
const styleAttr = nonceAttr(nonce, "style");
|
|
2743
3968
|
const scriptAttr = nonceAttr(nonce, "script");
|
|
@@ -2746,6 +3971,9 @@ function renderHeadAssets(emittedAssets, inlineStyles, nonce) {
|
|
|
2746
3971
|
head += isCssUrl(url) ? `<link rel="stylesheet" href="${url}"${styleAttr}>` : `<link rel="modulepreload" href="${url}"${scriptAttr}>`;
|
|
2747
3972
|
}
|
|
2748
3973
|
}
|
|
3974
|
+
if (preloadLinks) {
|
|
3975
|
+
for (const entry of preloadLinks) head += `<link${entry.attrHtml}>`;
|
|
3976
|
+
}
|
|
2749
3977
|
if (inlineStyles && inlineStyles.size) {
|
|
2750
3978
|
for (const entry of inlineStyles.values()) {
|
|
2751
3979
|
if (entry.emitted) continue;
|
|
@@ -2840,26 +4068,30 @@ function classListToObject(classList) {
|
|
|
2840
4068
|
function flattenClassList(list, result) {
|
|
2841
4069
|
for (let i = 0, len = list.length; i < len; i++) {
|
|
2842
4070
|
const item = list[i];
|
|
2843
|
-
if (Array.isArray(item)) flattenClassList(item, result);else if (typeof item === "object" && item != null) Object.assign(result, item);
|
|
4071
|
+
if (Array.isArray(item)) flattenClassList(item, result);else if (typeof item === "object" && item != null) Object.assign(result, item);
|
|
4072
|
+
else if (typeof item !== "boolean" && (item || item === 0)) result[item] = true;
|
|
2844
4073
|
}
|
|
2845
4074
|
}
|
|
2846
|
-
|
|
4075
|
+
let ssrTextTail = false;
|
|
4076
|
+
function tryResolveString(node, nested) {
|
|
4077
|
+
if (!nested) ssrTextTail = false;
|
|
2847
4078
|
const t = typeof node;
|
|
2848
|
-
if (t === "string")
|
|
2849
|
-
|
|
4079
|
+
if (t === "string" || t === "number") {
|
|
4080
|
+
const s = ssrTextTail ? "<!--!$-->" + node : "" + node;
|
|
4081
|
+
ssrTextTail = true;
|
|
4082
|
+
return s;
|
|
4083
|
+
}
|
|
2850
4084
|
if (node == null || t === "boolean") return "";
|
|
2851
4085
|
if (t === "object") {
|
|
2852
4086
|
if (Array.isArray(node)) {
|
|
2853
4087
|
const joined = tryJoinPlainSSRArray(node);
|
|
2854
|
-
if (joined !== undefined)
|
|
4088
|
+
if (joined !== undefined) {
|
|
4089
|
+
ssrTextTail = false;
|
|
4090
|
+
return joined;
|
|
4091
|
+
}
|
|
2855
4092
|
let s = "";
|
|
2856
|
-
let prevNonObj = false;
|
|
2857
4093
|
for (let i = 0, len = node.length; i < len; i++) {
|
|
2858
|
-
const
|
|
2859
|
-
const itemNonObj = item !== null && typeof item !== "object";
|
|
2860
|
-
if (prevNonObj && itemNonObj) s += "<!--!$-->";
|
|
2861
|
-
prevNonObj = itemNonObj;
|
|
2862
|
-
const r = tryResolveString(item);
|
|
4094
|
+
const r = tryResolveString(node[i], true);
|
|
2863
4095
|
if (typeof r !== "string") return {
|
|
2864
4096
|
bail: node
|
|
2865
4097
|
};
|
|
@@ -2873,6 +4105,7 @@ function tryResolveString(node) {
|
|
|
2873
4105
|
if (node.t === undefined) {
|
|
2874
4106
|
return "";
|
|
2875
4107
|
}
|
|
4108
|
+
ssrTextTail = false;
|
|
2876
4109
|
return Array.isArray(node.t) ? node.t[0] : node.t;
|
|
2877
4110
|
}
|
|
2878
4111
|
if (t === "function") {
|
|
@@ -2880,9 +4113,11 @@ function tryResolveString(node) {
|
|
|
2880
4113
|
try {
|
|
2881
4114
|
v = node();
|
|
2882
4115
|
} catch (err) {
|
|
2883
|
-
|
|
4116
|
+
const wrap = buildAsyncWrap(err, node);
|
|
4117
|
+
if (wrap) ssrTextTail = true;
|
|
4118
|
+
return wrap || "";
|
|
2884
4119
|
}
|
|
2885
|
-
return tryResolveString(v);
|
|
4120
|
+
return tryResolveString(v, true);
|
|
2886
4121
|
}
|
|
2887
4122
|
return "";
|
|
2888
4123
|
}
|
|
@@ -2890,21 +4125,19 @@ function resolveSSRNode(node, result = {
|
|
|
2890
4125
|
t: [""],
|
|
2891
4126
|
h: [],
|
|
2892
4127
|
p: []
|
|
2893
|
-
}, top) {
|
|
4128
|
+
}, top, nested) {
|
|
4129
|
+
if (!nested) ssrTextTail = false;
|
|
2894
4130
|
const t = typeof node;
|
|
2895
4131
|
if (t === "string" || t === "number") {
|
|
2896
|
-
result.t[result.t.length - 1] += node;
|
|
4132
|
+
result.t[result.t.length - 1] += ssrTextTail ? "<!--!$-->" + node : node;
|
|
4133
|
+
ssrTextTail = true;
|
|
2897
4134
|
} else if (node == null || t === "boolean") ; else if (Array.isArray(node)) {
|
|
2898
4135
|
const slotLive = node.$slot && sharedConfig.context && sharedConfig.context.liveHoles;
|
|
2899
4136
|
if (slotLive) slotLive.suppressed++;
|
|
2900
4137
|
try {
|
|
2901
|
-
let prevNonObj = false;
|
|
2902
4138
|
for (let i = 0, len = node.length; i < len; i++) {
|
|
2903
|
-
|
|
2904
|
-
|
|
2905
|
-
if (!top && prevNonObj && itemNonObj) result.t[result.t.length - 1] += `<!--!$-->`;
|
|
2906
|
-
prevNonObj = itemNonObj;
|
|
2907
|
-
resolveSSRNode(item, result);
|
|
4139
|
+
if (top) ssrTextTail = false;
|
|
4140
|
+
resolveSSRNode(node[i], result, false, true);
|
|
2908
4141
|
}
|
|
2909
4142
|
} finally {
|
|
2910
4143
|
if (slotLive) slotLive.suppressed--;
|
|
@@ -2917,24 +4150,34 @@ function resolveSSRNode(node, result = {
|
|
|
2917
4150
|
result.h.push(...node.h);
|
|
2918
4151
|
result.p.push(...node.p);
|
|
2919
4152
|
}
|
|
4153
|
+
ssrTextTail = false;
|
|
2920
4154
|
} else if (node.t !== undefined) {
|
|
2921
4155
|
result.t[result.t.length - 1] += node.t;
|
|
4156
|
+
ssrTextTail = false;
|
|
2922
4157
|
} else ;
|
|
2923
4158
|
} else if (t === "function") {
|
|
2924
4159
|
const live = sharedConfig.context && sharedConfig.context.liveHoles;
|
|
2925
4160
|
let liveNode = null;
|
|
2926
4161
|
if (live && (liveNode = live.content(node)) !== null) {
|
|
2927
|
-
if (typeof liveNode === "string")
|
|
4162
|
+
if (typeof liveNode === "string") {
|
|
4163
|
+
result.t[result.t.length - 1] += ssrTextTail ? "<!--!$-->" + liveNode : liveNode;
|
|
4164
|
+
ssrTextTail = true;
|
|
4165
|
+
} else resolveSSRNode(liveNode, result, false, true);
|
|
2928
4166
|
} else {
|
|
4167
|
+
const scope = live && live.nest(node);
|
|
2929
4168
|
try {
|
|
2930
|
-
resolveSSRNode(node(), result);
|
|
4169
|
+
resolveSSRNode(node(), result, false, true);
|
|
2931
4170
|
} catch (err) {
|
|
2932
4171
|
const wrap = buildAsyncWrap(err, node);
|
|
2933
4172
|
if (wrap) {
|
|
4173
|
+
if (ssrTextTail) result.t[result.t.length - 1] += "<!--!$-->";
|
|
2934
4174
|
result.h.push(wrap.fn);
|
|
2935
4175
|
result.p.push(wrap.p);
|
|
2936
4176
|
result.t.push("");
|
|
4177
|
+
ssrTextTail = true;
|
|
2937
4178
|
}
|
|
4179
|
+
} finally {
|
|
4180
|
+
if (scope) live.scope = scope;
|
|
2938
4181
|
}
|
|
2939
4182
|
}
|
|
2940
4183
|
}
|
|
@@ -2946,8 +4189,132 @@ function resolveSSRSync(node) {
|
|
|
2946
4189
|
throw new Error("This value cannot be rendered synchronously. Are you missing a boundary?");
|
|
2947
4190
|
}
|
|
2948
4191
|
const RequestContext = Symbol.for("solid.RequestContext");
|
|
4192
|
+
const ServerErrors = Symbol.for("solid-js/server/errors");
|
|
4193
|
+
function serializerErrorHook(hook) {
|
|
4194
|
+
return hook === undefined ? undefined : err => {
|
|
4195
|
+
reportServerError(err, {
|
|
4196
|
+
kind: "render",
|
|
4197
|
+
handling: "serialize"
|
|
4198
|
+
}, null, hook);
|
|
4199
|
+
};
|
|
4200
|
+
}
|
|
4201
|
+
function ambientServerErrorHook() {
|
|
4202
|
+
const slot = globalThis[ServerErrors];
|
|
4203
|
+
return slot === undefined ? undefined : slot.hook;
|
|
4204
|
+
}
|
|
4205
|
+
function configureServerErrors(config) {
|
|
4206
|
+
const g = globalThis;
|
|
4207
|
+
if (config && config.onError !== undefined && typeof config.onError !== "function") {
|
|
4208
|
+
throw new TypeError(`Invalid onError: expected a function, received ${typeof config.onError}.`);
|
|
4209
|
+
}
|
|
4210
|
+
(g[ServerErrors] ||= {}).hook = config ? config.onError : undefined;
|
|
4211
|
+
}
|
|
4212
|
+
function reportRequestFailure(error, event) {
|
|
4213
|
+
reportServerError(error, {
|
|
4214
|
+
kind: "request",
|
|
4215
|
+
handling: "failed",
|
|
4216
|
+
event
|
|
4217
|
+
}, null);
|
|
4218
|
+
if (ambientServerErrorHook() === undefined) console.error(error);
|
|
4219
|
+
}
|
|
2949
4220
|
function getRequestEvent() {
|
|
2950
|
-
|
|
4221
|
+
const store = globalThis[RequestContext];
|
|
4222
|
+
if (!store) return undefined;
|
|
4223
|
+
const event = store.getStore();
|
|
4224
|
+
if (event) return event;
|
|
4225
|
+
const ctx = renderContextOf(getOwner());
|
|
4226
|
+
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.");
|
|
4227
|
+
}
|
|
4228
|
+
const RENDER_ROOTS = Symbol.for("@solidjs/web/render-roots");
|
|
4229
|
+
function renderRoots() {
|
|
4230
|
+
const g = globalThis;
|
|
4231
|
+
return g[RENDER_ROOTS] || (g[RENDER_ROOTS] = new WeakMap());
|
|
4232
|
+
}
|
|
4233
|
+
function claimRenderRoot(context) {
|
|
4234
|
+
const owner = getOwner();
|
|
4235
|
+
const roots = renderRoots();
|
|
4236
|
+
roots.set(owner, context);
|
|
4237
|
+
onCleanup(() => roots.delete(owner));
|
|
4238
|
+
return owner;
|
|
4239
|
+
}
|
|
4240
|
+
function settleRender(render, root, outcome) {
|
|
4241
|
+
runWithOwner(root || null, () => render.settle(outcome));
|
|
4242
|
+
}
|
|
4243
|
+
const eventRenders = new WeakMap();
|
|
4244
|
+
function claimEventRender(event, context) {
|
|
4245
|
+
let renders = eventRenders.get(event);
|
|
4246
|
+
if (!renders) eventRenders.set(event, renders = new Set());
|
|
4247
|
+
renders.add(context);
|
|
4248
|
+
onCleanup(() => renders.delete(context));
|
|
4249
|
+
}
|
|
4250
|
+
function createHydrationWriter(context, isOpen) {
|
|
4251
|
+
const keys = new Set();
|
|
4252
|
+
return {
|
|
4253
|
+
async: !!context.async,
|
|
4254
|
+
write(key, value, options) {
|
|
4255
|
+
if (!isOpen() || keys.has(key)) return false;
|
|
4256
|
+
context.serialize(key, value, options && options.deferStream);
|
|
4257
|
+
keys.add(key);
|
|
4258
|
+
return true;
|
|
4259
|
+
}
|
|
4260
|
+
};
|
|
4261
|
+
}
|
|
4262
|
+
function getHydrationWriter() {
|
|
4263
|
+
const ctx = currentRenderContext();
|
|
4264
|
+
return ctx && ctx.writer;
|
|
4265
|
+
}
|
|
4266
|
+
function currentRenderContext() {
|
|
4267
|
+
let ctx = renderContextOf(getOwner());
|
|
4268
|
+
if (!ctx) {
|
|
4269
|
+
const event = peekRequestEvent();
|
|
4270
|
+
const renders = event && eventRenders.get(event);
|
|
4271
|
+
if (renders && renders.size === 1) for (const c of renders) ctx = c;
|
|
4272
|
+
}
|
|
4273
|
+
return ctx;
|
|
4274
|
+
}
|
|
4275
|
+
const LINK_STATE_RECORD = "links";
|
|
4276
|
+
function setLinkClaim(handler) {
|
|
4277
|
+
const ctx = currentRenderContext();
|
|
4278
|
+
if (!ctx) {
|
|
4279
|
+
return false;
|
|
4280
|
+
}
|
|
4281
|
+
ctx.linkClaim = handler;
|
|
4282
|
+
if (handler !== undefined) ctx.writer.write(LINK_STATE_RECORD, 1);
|
|
4283
|
+
return true;
|
|
4284
|
+
}
|
|
4285
|
+
function hasServerLinkState() {
|
|
4286
|
+
return false;
|
|
4287
|
+
}
|
|
4288
|
+
function takeHydrationValue(_key) {
|
|
4289
|
+
return undefined;
|
|
4290
|
+
}
|
|
4291
|
+
function renderContextOf(owner) {
|
|
4292
|
+
const roots = globalThis[RENDER_ROOTS];
|
|
4293
|
+
if (!roots) return undefined;
|
|
4294
|
+
for (; owner; owner = owner._parent) {
|
|
4295
|
+
const context = roots.get(owner);
|
|
4296
|
+
if (context) return context;
|
|
4297
|
+
}
|
|
4298
|
+
}
|
|
4299
|
+
function peekRequestEvent() {
|
|
4300
|
+
const store = globalThis[RequestContext];
|
|
4301
|
+
return store ? store.getStore() : undefined;
|
|
4302
|
+
}
|
|
4303
|
+
function timeDocument(context, trace, mode, requestEvent) {
|
|
4304
|
+
return undefined;
|
|
4305
|
+
}
|
|
4306
|
+
function getTraceContext() {
|
|
4307
|
+
const event = peekRequestEvent();
|
|
4308
|
+
if (event) return traceForEvent(event).context;
|
|
4309
|
+
const ctx = renderContextOf(getOwner());
|
|
4310
|
+
return ctx && ctx.trace ? ctx.trace.context : undefined;
|
|
4311
|
+
}
|
|
4312
|
+
function traceForStub(stub, event) {
|
|
4313
|
+
if (!event) {
|
|
4314
|
+
event = peekRequestEvent();
|
|
4315
|
+
if (!event || event.response !== stub) return undefined;
|
|
4316
|
+
}
|
|
4317
|
+
return traceForEvent(event);
|
|
2951
4318
|
}
|
|
2952
4319
|
function createResponseStub() {
|
|
2953
4320
|
return {
|
|
@@ -2966,15 +4333,20 @@ function createRequestEvent(request, init) {
|
|
|
2966
4333
|
};
|
|
2967
4334
|
}
|
|
2968
4335
|
function reportLostHeaderWrite(method, name) {
|
|
2969
|
-
const message = `Response header write dropped: headers.${method}(${JSON.stringify(String(name))}) ` + "ran after the response head was sent. Write headers before the shell flushes " + "(or before the handler returns).";
|
|
4336
|
+
const message = `[LATE_HEADER_WRITE] Response header write dropped: headers.${method}(${JSON.stringify(String(name))}) ` + "ran after the response head was sent. Write headers before the shell flushes " + "(or before the handler returns).";
|
|
2970
4337
|
console.error(message);
|
|
2971
4338
|
}
|
|
2972
4339
|
function commitResponseStub(stub, {
|
|
2973
|
-
allowLateLocation = false
|
|
4340
|
+
allowLateLocation = false,
|
|
4341
|
+
event
|
|
2974
4342
|
} = {}) {
|
|
2975
4343
|
if (!stub || stub.committed) return stub;
|
|
2976
|
-
stub.committed = true;
|
|
2977
4344
|
const headers = stub.headers;
|
|
4345
|
+
if (headers && typeof headers.append === "function") {
|
|
4346
|
+
const trace = traceForStub(stub, event);
|
|
4347
|
+
if (trace) appendTraceServerTiming(headers, trace);
|
|
4348
|
+
}
|
|
4349
|
+
stub.committed = true;
|
|
2978
4350
|
if (!headers || typeof headers.set !== "function") return stub;
|
|
2979
4351
|
for (const method of ["set", "append", "delete"]) {
|
|
2980
4352
|
const original = headers[method].bind(headers);
|
|
@@ -2995,7 +4367,7 @@ function getExpectedRedirectStatus(response) {
|
|
|
2995
4367
|
function mergeStubHeaders(target, stub) {
|
|
2996
4368
|
if (!stub) return target;
|
|
2997
4369
|
stub.headers.forEach((value, key) => {
|
|
2998
|
-
if (key !== "set-cookie") target.set(key, value);
|
|
4370
|
+
if (key === "server-timing") mergeServerTiming(target, value);else if (key !== "set-cookie") target.set(key, value);
|
|
2999
4371
|
});
|
|
3000
4372
|
const setCookies = stub.headers.getSetCookie ? stub.headers.getSetCookie() : [];
|
|
3001
4373
|
for (const cookie of setCookies) target.append("set-cookie", cookie);
|
|
@@ -3010,43 +4382,56 @@ function copyInitHeaders(init) {
|
|
|
3010
4382
|
for (const cookie of init.getSetCookie()) headers.append("Set-Cookie", cookie);
|
|
3011
4383
|
return headers;
|
|
3012
4384
|
}
|
|
3013
|
-
|
|
4385
|
+
let stubGapFillExcluded;
|
|
4386
|
+
function isStubGapFillExcluded(key) {
|
|
4387
|
+
return (stubGapFillExcluded ||= new Set([ERROR_HEADER, BODY_FORMAT_HEADER, SINGLE_FLIGHT_HEADER, REVALIDATE_HEADER, REDIRECT_HEADER, "Location",
|
|
4388
|
+
...COMPOSED_BODY_FRAMING].map(header => header.toLowerCase()))).has(key);
|
|
4389
|
+
}
|
|
3014
4390
|
function fillsStubGap(key, headers, response) {
|
|
3015
|
-
if (key === "set-cookie" ||
|
|
4391
|
+
if (key === "set-cookie" || isStubGapFillExcluded(key)) return false;
|
|
3016
4392
|
if (response.body === null && (key === "content-type" || key === "content-length")) return false;
|
|
3017
4393
|
return !headers.has(key);
|
|
3018
4394
|
}
|
|
3019
4395
|
function commitEventResponse(response, event = getRequestEvent()) {
|
|
3020
4396
|
const stub = event && event.response;
|
|
3021
|
-
if (!stub || !stub.headers || stub.committed)
|
|
3022
|
-
|
|
3023
|
-
|
|
3024
|
-
|
|
3025
|
-
stub.headers.forEach((value, key) => {
|
|
3026
|
-
if (fillsStubGap(key, response.headers, response)) hasGaps = true;
|
|
3027
|
-
});
|
|
3028
|
-
if (!cookies.length && !hasGaps) return response;
|
|
3029
|
-
try {
|
|
3030
|
-
for (const cookie of cookies) response.headers.append("Set-Cookie", cookie);
|
|
3031
|
-
stub.headers.forEach((value, key) => {
|
|
3032
|
-
if (fillsStubGap(key, response.headers, response)) response.headers.set(key, value);
|
|
3033
|
-
});
|
|
3034
|
-
return response;
|
|
3035
|
-
} catch {
|
|
4397
|
+
if (!stub || !stub.headers || stub.committed) {
|
|
4398
|
+
if (!event || stub) return response;
|
|
4399
|
+
const trace = traceForEvent(event);
|
|
4400
|
+
if (!hasServerTiming(trace)) return response;
|
|
3036
4401
|
const headers = copyInitHeaders(response.headers);
|
|
3037
|
-
|
|
3038
|
-
stub.headers.forEach((value, key) => {
|
|
3039
|
-
if (fillsStubGap(key, headers, response)) headers.set(key, value);
|
|
3040
|
-
});
|
|
4402
|
+
appendTraceServerTiming(headers, trace);
|
|
3041
4403
|
return new Response(response.body, {
|
|
3042
4404
|
status: response.status,
|
|
3043
4405
|
statusText: response.statusText,
|
|
3044
4406
|
headers
|
|
3045
4407
|
});
|
|
3046
4408
|
}
|
|
4409
|
+
const cookies = stub.headers.getSetCookie ? stub.headers.getSetCookie() : [];
|
|
4410
|
+
commitResponseStub(stub, {
|
|
4411
|
+
event
|
|
4412
|
+
});
|
|
4413
|
+
let hasGaps = false;
|
|
4414
|
+
stub.headers.forEach((value, key) => {
|
|
4415
|
+
if (fillsStubGap(key, response.headers, response)) hasGaps = true;
|
|
4416
|
+
});
|
|
4417
|
+
const timing = stub.headers.get("server-timing");
|
|
4418
|
+
const mergesTiming = timing !== null && response.headers.has("server-timing");
|
|
4419
|
+
if (!cookies.length && !hasGaps && !mergesTiming) return response;
|
|
4420
|
+
const headers = copyInitHeaders(response.headers);
|
|
4421
|
+
for (const cookie of cookies) headers.append("Set-Cookie", cookie);
|
|
4422
|
+
stub.headers.forEach((value, key) => {
|
|
4423
|
+
if (fillsStubGap(key, headers, response)) headers.set(key, value);
|
|
4424
|
+
});
|
|
4425
|
+
if (mergesTiming) mergeServerTiming(headers, timing);
|
|
4426
|
+
return new Response(response.body, {
|
|
4427
|
+
status: response.status,
|
|
4428
|
+
statusText: response.statusText,
|
|
4429
|
+
headers
|
|
4430
|
+
});
|
|
3047
4431
|
}
|
|
3048
4432
|
function deriveHead(stub, responseInit = {}) {
|
|
3049
4433
|
const headers = mergeStubHeaders(copyInitHeaders(responseInit.headers), stub);
|
|
4434
|
+
for (const header of COMPOSED_BODY_FRAMING) headers.delete(header);
|
|
3050
4435
|
const status = stub && stub.status || responseInit.status || 200;
|
|
3051
4436
|
const statusText = stub && stub.statusText || responseInit.statusText || undefined;
|
|
3052
4437
|
return {
|
|
@@ -3063,7 +4448,9 @@ function createSSRResponse(result, event, options = {}) {
|
|
|
3063
4448
|
} = options;
|
|
3064
4449
|
const nonce = normalizeNonce(options.nonce);
|
|
3065
4450
|
if (typeof result === "string") {
|
|
3066
|
-
if (stub) commitResponseStub(stub
|
|
4451
|
+
if (stub) commitResponseStub(stub, {
|
|
4452
|
+
event
|
|
4453
|
+
});
|
|
3067
4454
|
const head = deriveHead(stub, responseInit);
|
|
3068
4455
|
if (stub && stub.headers.get("Location")) {
|
|
3069
4456
|
return new Response(null, {
|
|
@@ -3093,12 +4480,13 @@ function createSSRResponse(result, event, options = {}) {
|
|
|
3093
4480
|
closed = true;
|
|
3094
4481
|
}
|
|
3095
4482
|
};
|
|
3096
|
-
|
|
4483
|
+
const sink = {
|
|
3097
4484
|
write(chunk) {
|
|
3098
4485
|
if (!flushed) {
|
|
3099
4486
|
flushed = true;
|
|
3100
4487
|
if (stub) commitResponseStub(stub, {
|
|
3101
|
-
allowLateLocation: true
|
|
4488
|
+
allowLateLocation: true,
|
|
4489
|
+
event
|
|
3102
4490
|
});
|
|
3103
4491
|
const head = deriveHead(stub, responseInit);
|
|
3104
4492
|
if (stub && stub.headers.get("Location")) {
|
|
@@ -3107,6 +4495,7 @@ function createSSRResponse(result, event, options = {}) {
|
|
|
3107
4495
|
status: getExpectedRedirectStatus(stub),
|
|
3108
4496
|
headers: head.headers
|
|
3109
4497
|
}));
|
|
4498
|
+
sink[ABANDON_RENDER]("redirect", true);
|
|
3110
4499
|
return;
|
|
3111
4500
|
}
|
|
3112
4501
|
if (!head.headers.has("content-type")) {
|
|
@@ -3117,7 +4506,9 @@ function createSSRResponse(result, event, options = {}) {
|
|
|
3117
4506
|
controller = c;
|
|
3118
4507
|
},
|
|
3119
4508
|
cancel() {
|
|
4509
|
+
if (closed) return;
|
|
3120
4510
|
closed = true;
|
|
4511
|
+
sink[ABANDON_RENDER]("consumer");
|
|
3121
4512
|
}
|
|
3122
4513
|
}), {
|
|
3123
4514
|
status: head.status,
|
|
@@ -3128,9 +4519,10 @@ function createSSRResponse(result, event, options = {}) {
|
|
|
3128
4519
|
enqueue(transformChunk ? transformChunk(chunk) : chunk);
|
|
3129
4520
|
},
|
|
3130
4521
|
end() {
|
|
4522
|
+
if (!flushed) sink.write("");
|
|
3131
4523
|
if (closed || !controller) return;
|
|
3132
4524
|
const location = stub && stub.headers.get("Location");
|
|
3133
|
-
if (location) {
|
|
4525
|
+
if (location && isHttpNavigationTarget(location)) {
|
|
3134
4526
|
const attr = nonceAttr(nonce, "script");
|
|
3135
4527
|
enqueue(`<script${attr}>window.location=${JSON.stringify(location).replace(/</g, "\\u003c")}</script>`);
|
|
3136
4528
|
}
|
|
@@ -3138,8 +4530,23 @@ function createSSRResponse(result, event, options = {}) {
|
|
|
3138
4530
|
try {
|
|
3139
4531
|
controller.close();
|
|
3140
4532
|
} catch {}
|
|
3141
|
-
}
|
|
3142
|
-
|
|
4533
|
+
},
|
|
4534
|
+
[SHELL_ABANDONED]() {
|
|
4535
|
+
if (flushed) return;
|
|
4536
|
+
flushed = closed = true;
|
|
4537
|
+
if (stub) commitResponseStub(stub, {
|
|
4538
|
+
event
|
|
4539
|
+
});
|
|
4540
|
+
const head = deriveHead(stub, responseInit);
|
|
4541
|
+
const status = stub && stub.headers.get("Location") ? getExpectedRedirectStatus(stub) : 500;
|
|
4542
|
+
resolve(new Response(null, {
|
|
4543
|
+
status,
|
|
4544
|
+
headers: head.headers
|
|
4545
|
+
}));
|
|
4546
|
+
},
|
|
4547
|
+
[ABANDON_RENDER]() {}
|
|
4548
|
+
};
|
|
4549
|
+
result.pipe(sink);
|
|
3143
4550
|
});
|
|
3144
4551
|
}
|
|
3145
4552
|
function composeMiddleware(middlewares) {
|
|
@@ -3164,30 +4571,20 @@ function claimElement(node) {
|
|
|
3164
4571
|
function claimElementTree(root) {
|
|
3165
4572
|
return root;
|
|
3166
4573
|
}
|
|
4574
|
+
function dispatchAsInteraction(_e, fn) {
|
|
4575
|
+
return fn();
|
|
4576
|
+
}
|
|
3167
4577
|
function notSup() {
|
|
3168
|
-
throw new Error("Client-only API called on the server side. Run client-only code in
|
|
4578
|
+
throw new Error("Client-only API called on the server side. Run client-only code in onSettled, or conditionally run client-only component with <Show>.");
|
|
3169
4579
|
}
|
|
3170
4580
|
|
|
3171
4581
|
setContainerTraceResolver(getProjectionTrace);
|
|
4582
|
+
setAsyncIterableSharer(shareAsyncIterable);
|
|
3172
4583
|
const isServer = true;
|
|
3173
4584
|
const isDev = false;
|
|
3174
|
-
|
|
3175
|
-
|
|
3176
|
-
|
|
3177
|
-
});
|
|
3178
|
-
return props => {
|
|
3179
|
-
return createMemo(() => {
|
|
3180
|
-
const c = cached();
|
|
3181
|
-
if (c) {
|
|
3182
|
-
if (typeof c === "function") return c(props);
|
|
3183
|
-
if (typeof c === "string") {
|
|
3184
|
-
return ssrElement(c, props, undefined, true);
|
|
3185
|
-
}
|
|
3186
|
-
}
|
|
3187
|
-
}, {
|
|
3188
|
-
sync: true
|
|
3189
|
-
});
|
|
3190
|
-
};
|
|
4585
|
+
const ssrTag = (tag, props) => ssrElement(tag, props, undefined, true);
|
|
4586
|
+
function dynamic(source, options) {
|
|
4587
|
+
return dynamicCore(source, options, ssrTag);
|
|
3191
4588
|
}
|
|
3192
4589
|
function Dynamic(props) {
|
|
3193
4590
|
const Comp = dynamic(() => props.component);
|
|
@@ -3209,6 +4606,11 @@ function registerClientOnlyPreload(moduleUrl) {
|
|
|
3209
4606
|
const css = assets.css[i];
|
|
3210
4607
|
if (typeof css === "string") registerAsset("style", css);else registerAsset("inline-style", css);
|
|
3211
4608
|
}
|
|
4609
|
+
if (assets.preloads) {
|
|
4610
|
+
for (let i = 0; i < assets.preloads.length; i++) {
|
|
4611
|
+
registerAsset("preload", assets.preloads[i]);
|
|
4612
|
+
}
|
|
4613
|
+
}
|
|
3212
4614
|
for (let i = 0; i < assets.js.length; i++) registerAsset("module", assets.js[i]);
|
|
3213
4615
|
};
|
|
3214
4616
|
const assets = resolve(moduleUrl);
|
|
@@ -3312,4 +4714,4 @@ function httpHeader(name, value, options) {
|
|
|
3312
4714
|
}
|
|
3313
4715
|
}
|
|
3314
4716
|
|
|
3315
|
-
export {
|
|
4717
|
+
export { 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, 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, 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, hasServerLinkState, httpHeader, httpStatus, notSup as hydrate, notSup as insert, isDev, isHref, isResponseEnvelope, isSafeError, isServer, isServerFunction, 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, serializeCookie, notSup as setAttribute, notSup as setAttributeNS, setLinkClaim, notSup as setProperty, notSup as setStatefulProperty, notSup as setStyleProperty, notSup as spread, ssr, ssrAttribute, ssrClassName, ssrElement, ssrElementAttribute, ssrGroup, ssrHydrationKey, ssrLinkClaim, ssrSelectValues, ssrStyle, ssrStyleProperties, ssrStyleProperty, notSup as style, takeHydrationValue, notSup as template, notSup as unregisterDelegatedContainer, notSup as unregisterDelegatedRoot, useHead };
|