@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
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { createRenderEffect, createMemo, OBSERVE, 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';
|
|
6
|
+
import { AbortSignalPlugin, CustomEventPlugin, DOMExceptionPlugin, EventPlugin, FormDataPlugin, HeadersPlugin, ReadableStreamPlugin, RequestPlugin, ResponsePlugin, URLSearchParamsPlugin, URLPlugin } from 'seroval-plugins/web';
|
|
6
7
|
|
|
7
8
|
const DOMWithState = {
|
|
8
9
|
INPUT: {
|
|
@@ -33,6 +34,7 @@ const DOMWithState = {
|
|
|
33
34
|
}
|
|
34
35
|
};
|
|
35
36
|
const ChildProperties = /*#__PURE__*/new Set(["innerHTML", "textContent", "innerText", "children"]);
|
|
37
|
+
const LinkAttributes = /*#__PURE__*/new Set(["href", "target", "rel", "download", "link", "aria-current"]);
|
|
36
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"]);
|
|
37
39
|
const SVGElements = /*#__PURE__*/new Set([
|
|
38
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",
|
|
@@ -49,6 +51,19 @@ const Namespaces = {
|
|
|
49
51
|
const VoidElements = /*#__PURE__*/new Set(["area", "base", "br", "col", "embed", "hr", "img", "input", "link", "meta", "param", "source", "track", "wbr"]);
|
|
50
52
|
const RawTextElements = /*#__PURE__*/new Set(["style", "script", "noscript", "template", "textarea", "title"]);
|
|
51
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
|
+
}
|
|
52
67
|
|
|
53
68
|
const transparentOptions = {
|
|
54
69
|
transparent: true,
|
|
@@ -57,14 +72,365 @@ const transparentOptions = {
|
|
|
57
72
|
const syncOptions = {
|
|
58
73
|
sync: true
|
|
59
74
|
};
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
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
|
+
}
|
|
95
|
+
|
|
96
|
+
const PROVIDER = Symbol.for("solid-js/observe/server/provider");
|
|
97
|
+
function currentProvider() {
|
|
98
|
+
if (OBSERVE === undefined) return undefined;
|
|
99
|
+
const slot = OBSERVE.server.trace;
|
|
100
|
+
return slot && slot[PROVIDER];
|
|
101
|
+
}
|
|
102
|
+
const TRACEPARENT = /^([0-9a-f]{2})-([0-9a-f]{32})-([0-9a-f]{16})-([0-9a-f]{2})(-.*)?$/;
|
|
103
|
+
const ZERO_TRACE = "00000000000000000000000000000000";
|
|
104
|
+
const ZERO_SPAN = "0000000000000000";
|
|
105
|
+
function parseTraceparent(value) {
|
|
106
|
+
if (!value) return undefined;
|
|
107
|
+
const m = TRACEPARENT.exec(value.trim());
|
|
108
|
+
if (!m) return undefined;
|
|
109
|
+
const [, version, traceId, parentId, flags, rest] = m;
|
|
110
|
+
if (version === "ff") return undefined;
|
|
111
|
+
if (version === "00" && rest !== undefined) return undefined;
|
|
112
|
+
if (traceId === ZERO_TRACE || parentId === ZERO_SPAN) return undefined;
|
|
113
|
+
return {
|
|
114
|
+
traceId,
|
|
115
|
+
parentId,
|
|
116
|
+
sampled: (parseInt(flags, 16) & 1) === 1
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
function randomHex(bytes) {
|
|
120
|
+
let out = "";
|
|
121
|
+
for (let i = 0; i < bytes; i += 4) out += (Math.random() * 0x100000000 >>> 0).toString(16).padStart(8, "0");
|
|
122
|
+
return out.length === bytes * 2 ? out : out.slice(0, bytes * 2);
|
|
123
|
+
}
|
|
124
|
+
function randomTraceId() {
|
|
125
|
+
let id = randomHex(16);
|
|
126
|
+
while (id === ZERO_TRACE) id = randomHex(16);
|
|
127
|
+
return id;
|
|
128
|
+
}
|
|
129
|
+
function randomSpanId() {
|
|
130
|
+
let id = randomHex(8);
|
|
131
|
+
while (id === ZERO_SPAN) id = randomHex(8);
|
|
132
|
+
return id;
|
|
133
|
+
}
|
|
134
|
+
function formatTraceparent(context) {
|
|
135
|
+
return `00-${context.traceId}-${context.spanId}-${context.sampled === true ? "01" : "00"}`;
|
|
136
|
+
}
|
|
137
|
+
const RECORDS_KEY = Symbol.for("@solidjs/web/trace/records");
|
|
138
|
+
function records$1() {
|
|
139
|
+
const g = globalThis;
|
|
140
|
+
return g[RECORDS_KEY] || (g[RECORDS_KEY] = new WeakMap());
|
|
141
|
+
}
|
|
142
|
+
function traceFor(key, request) {
|
|
143
|
+
const store = records$1();
|
|
144
|
+
let record = store.get(key);
|
|
145
|
+
if (record) return record;
|
|
146
|
+
const headers = request ? request.headers : undefined;
|
|
147
|
+
const incoming = headers ? parseTraceparent(headers.get("traceparent")) : undefined;
|
|
148
|
+
const context = {
|
|
149
|
+
traceId: incoming ? incoming.traceId : randomTraceId(),
|
|
150
|
+
spanId: randomSpanId(),
|
|
151
|
+
entries: {}
|
|
152
|
+
};
|
|
153
|
+
if (incoming) {
|
|
154
|
+
context.parentId = incoming.parentId;
|
|
155
|
+
context.sampled = incoming.sampled;
|
|
156
|
+
}
|
|
157
|
+
if (headers) {
|
|
158
|
+
const state = headers.get("tracestate");
|
|
159
|
+
if (state) context.state = state;
|
|
160
|
+
const baggage = headers.get("baggage");
|
|
161
|
+
if (baggage) context.baggage = baggage;
|
|
162
|
+
}
|
|
163
|
+
let answered = false;
|
|
164
|
+
let providedEntries;
|
|
165
|
+
{
|
|
166
|
+
const provider = currentProvider();
|
|
167
|
+
if (provider) {
|
|
168
|
+
let answer;
|
|
169
|
+
try {
|
|
170
|
+
answer = provider(request);
|
|
171
|
+
} catch (error) {
|
|
172
|
+
console.error(error);
|
|
173
|
+
}
|
|
174
|
+
if (answer !== undefined && answer !== null) {
|
|
175
|
+
answered = true;
|
|
176
|
+
if (answer.traceId !== undefined) context.traceId = answer.traceId;
|
|
177
|
+
if (answer.spanId !== undefined) context.spanId = answer.spanId;
|
|
178
|
+
if (answer.parentId !== undefined) context.parentId = answer.parentId;
|
|
179
|
+
if (answer.sampled !== undefined) context.sampled = answer.sampled;
|
|
180
|
+
if (answer.state !== undefined) context.state = answer.state;
|
|
181
|
+
if (answer.baggage !== undefined) context.baggage = answer.baggage;
|
|
182
|
+
providedEntries = answer.entries;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
context.entries.traceparent = formatTraceparent(context);
|
|
187
|
+
if (providedEntries) Object.assign(context.entries, providedEntries);
|
|
188
|
+
record = {
|
|
189
|
+
context,
|
|
190
|
+
emit: incoming !== undefined && incoming.sampled || answered,
|
|
191
|
+
timing: []
|
|
192
|
+
};
|
|
193
|
+
store.set(key, record);
|
|
194
|
+
return record;
|
|
195
|
+
}
|
|
196
|
+
function traceForEvent(event) {
|
|
197
|
+
return traceFor(event.request || event, event.request);
|
|
198
|
+
}
|
|
199
|
+
const TOKEN = /^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;
|
|
200
|
+
function splitServerTiming(value) {
|
|
201
|
+
const entries = [];
|
|
202
|
+
let start = 0;
|
|
203
|
+
let quoted = false;
|
|
204
|
+
for (let i = 0; i < value.length; i++) {
|
|
205
|
+
const c = value[i];
|
|
206
|
+
if (quoted) {
|
|
207
|
+
if (c === "\\") i++;else if (c === '"') quoted = false;
|
|
208
|
+
} else if (c === '"') quoted = true;else if (c === ",") {
|
|
209
|
+
entries.push(value.slice(start, i));
|
|
210
|
+
start = i + 1;
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
entries.push(value.slice(start));
|
|
214
|
+
return entries;
|
|
215
|
+
}
|
|
216
|
+
function metricName(entry) {
|
|
217
|
+
return entry.split(";")[0].trim().toLowerCase();
|
|
218
|
+
}
|
|
219
|
+
function namesOnServerTiming(headers) {
|
|
220
|
+
const names = new Set();
|
|
221
|
+
const existing = headers.get("server-timing");
|
|
222
|
+
if (existing) {
|
|
223
|
+
for (const entry of splitServerTiming(existing)) {
|
|
224
|
+
const name = metricName(entry);
|
|
225
|
+
if (name) names.add(name);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
return names;
|
|
229
|
+
}
|
|
230
|
+
function quoteDesc(value) {
|
|
231
|
+
return value.replace(/[\x00-\x1f\x7f]/g, "").replace(/[^\x20-\x7e]/g, "?").replace(/[\\"]/g, m => "\\" + m);
|
|
232
|
+
}
|
|
233
|
+
function shellMs(record) {
|
|
234
|
+
return record.render !== undefined ? record.render.shellMs : undefined;
|
|
235
|
+
}
|
|
236
|
+
function hasServerTiming(record) {
|
|
237
|
+
return record.emit || record.timing.length > 0 || shellMs(record) !== undefined;
|
|
238
|
+
}
|
|
239
|
+
function appendTraceServerTiming(headers, record) {
|
|
240
|
+
if (record.emit) {
|
|
241
|
+
const entries = record.context.entries;
|
|
242
|
+
let present;
|
|
243
|
+
for (const name in entries) {
|
|
244
|
+
if (!TOKEN.test(name)) continue;
|
|
245
|
+
if (!present) present = namesOnServerTiming(headers);
|
|
246
|
+
if (present.has(name.toLowerCase())) continue;
|
|
247
|
+
headers.append("Server-Timing", `${name};desc="${quoteDesc(entries[name])}"`);
|
|
248
|
+
present.add(name.toLowerCase());
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
const shell = shellMs(record);
|
|
252
|
+
if (shell !== undefined) headers.append("Server-Timing", formatMetric("solid-shell", shell));
|
|
253
|
+
for (const work of record.timing) headers.append("Server-Timing", metricOf(work));
|
|
254
|
+
}
|
|
255
|
+
function metricOf(work) {
|
|
256
|
+
if (work.type === "invocation") return formatMetric("solid-invocation", work.event.durationMs, work.event.id);
|
|
257
|
+
const boundary = work.event;
|
|
258
|
+
return formatMetric("solid-boundary", boundary.durationMs, boundary.ownerPath !== undefined ? boundary.ownerPath.join(" > ") : boundary.id);
|
|
259
|
+
}
|
|
260
|
+
function formatMetric(name, dur, desc) {
|
|
261
|
+
let out = `${name};dur=${Math.round(dur * 10) / 10}`;
|
|
262
|
+
if (desc) out += `;desc="${quoteDesc(desc)}"`;
|
|
263
|
+
return out;
|
|
264
|
+
}
|
|
265
|
+
function mergeServerTiming(target, value) {
|
|
266
|
+
const present = namesOnServerTiming(target);
|
|
267
|
+
for (const entry of splitServerTiming(value)) {
|
|
268
|
+
const trimmed = entry.trim();
|
|
269
|
+
const name = metricName(trimmed);
|
|
270
|
+
if (!name || present.has(name)) continue;
|
|
271
|
+
target.append("Server-Timing", trimmed);
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
function escapeAttr(value) {
|
|
275
|
+
return value.replace(/[&"<>]/g, c => c === "&" ? "&" : c === '"' ? """ : c === "<" ? "<" : ">");
|
|
276
|
+
}
|
|
277
|
+
function traceMetaMarkup(record) {
|
|
278
|
+
if (!record.emit) return "";
|
|
279
|
+
let markup = "";
|
|
280
|
+
const entries = record.context.entries;
|
|
281
|
+
for (const name in entries) {
|
|
282
|
+
if (!TOKEN.test(name)) continue;
|
|
283
|
+
markup += `<meta name="${name}" content="${escapeAttr(entries[name])}">`;
|
|
284
|
+
}
|
|
285
|
+
return markup;
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
const RECORDS = Symbol.for("@solidjs/signals/observe/records");
|
|
289
|
+
function records() {
|
|
290
|
+
return globalThis[RECORDS];
|
|
291
|
+
}
|
|
66
292
|
|
|
67
|
-
|
|
293
|
+
function timesServerWork(type) {
|
|
294
|
+
const channel = records();
|
|
295
|
+
if (channel === undefined) return false;
|
|
296
|
+
return channel.observed(type);
|
|
297
|
+
}
|
|
298
|
+
function observeRender(trace, mode, event) {
|
|
299
|
+
if (!timesServerWork("render")) return undefined;
|
|
300
|
+
const record = {
|
|
301
|
+
mode,
|
|
302
|
+
at: performance.now(),
|
|
303
|
+
durationMs: 0,
|
|
304
|
+
boundaries: 0,
|
|
305
|
+
outcome: "complete"
|
|
306
|
+
};
|
|
307
|
+
trace.render = record;
|
|
308
|
+
let settled = false;
|
|
309
|
+
let route;
|
|
310
|
+
return {
|
|
311
|
+
shell() {
|
|
312
|
+
if (!settled && record.shellMs === undefined) record.shellMs = performance.now() - record.at;
|
|
313
|
+
},
|
|
314
|
+
boundary() {
|
|
315
|
+
if (!settled) record.boundaries++;
|
|
316
|
+
},
|
|
317
|
+
route(ref) {
|
|
318
|
+
if (!settled) route = ref;
|
|
319
|
+
},
|
|
320
|
+
settle(outcome) {
|
|
321
|
+
if (settled) return;
|
|
322
|
+
settled = true;
|
|
323
|
+
record.durationMs = performance.now() - record.at;
|
|
324
|
+
record.outcome = outcome;
|
|
325
|
+
if (route !== undefined) {
|
|
326
|
+
const r = {};
|
|
327
|
+
if (route.name !== undefined) r.name = route.name;
|
|
328
|
+
if (route.to !== undefined) r.to = route.to;
|
|
329
|
+
if (route.params !== undefined) r.params = route.params;
|
|
330
|
+
record.route = r;
|
|
331
|
+
}
|
|
332
|
+
const channel = records();
|
|
333
|
+
if (!channel.observed("render")) return;
|
|
334
|
+
const live = {
|
|
335
|
+
trace: trace.context
|
|
336
|
+
};
|
|
337
|
+
if (event !== undefined) live.event = event;
|
|
338
|
+
channel.emit("render", record, live);
|
|
339
|
+
}
|
|
340
|
+
};
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
const DESCEND = Symbol("descend");
|
|
344
|
+
const CYCLE = {};
|
|
345
|
+
const TRACK = 16;
|
|
346
|
+
function rewriteTree(value, visit, withPath) {
|
|
347
|
+
if (value === null || typeof value !== "object") return value;
|
|
348
|
+
const path = undefined;
|
|
349
|
+
const state = {
|
|
350
|
+
memo: undefined,
|
|
351
|
+
ancestors: undefined
|
|
352
|
+
};
|
|
353
|
+
try {
|
|
354
|
+
return cow(value, visit, path, 0, state);
|
|
355
|
+
} catch (err) {
|
|
356
|
+
if (err !== CYCLE) throw err;
|
|
357
|
+
}
|
|
358
|
+
return clone(value, visit, path, state.memo || (state.memo = new Map()));
|
|
359
|
+
}
|
|
360
|
+
function shape(value) {
|
|
361
|
+
return Array.isArray(value) ? 1 : Object.getPrototypeOf(value) === Object.prototype ? 2 : 0;
|
|
362
|
+
}
|
|
363
|
+
function cow(value, visit, path, depth, state) {
|
|
364
|
+
const memo = state.memo;
|
|
365
|
+
if (memo !== undefined && memo.has(value)) return memo.get(value);
|
|
366
|
+
const r = visit(value, path);
|
|
367
|
+
if (r !== DESCEND) {
|
|
368
|
+
if (r !== value) (memo || (state.memo = new Map())).set(value, r);
|
|
369
|
+
return r;
|
|
370
|
+
}
|
|
371
|
+
const s = shape(value);
|
|
372
|
+
if (s === 0) return value;
|
|
373
|
+
let ancestors;
|
|
374
|
+
if (depth >= TRACK) {
|
|
375
|
+
ancestors = state.ancestors || (state.ancestors = new Set());
|
|
376
|
+
if (ancestors.has(value)) throw CYCLE;
|
|
377
|
+
ancestors.add(value);
|
|
378
|
+
}
|
|
379
|
+
let out = value;
|
|
380
|
+
if (s === 1) {
|
|
381
|
+
for (let i = 0; i < value.length; i++) {
|
|
382
|
+
const c = value[i];
|
|
383
|
+
if (c === null || typeof c !== "object") continue;
|
|
384
|
+
const next = cow(c, visit, undefined , depth + 1, state);
|
|
385
|
+
if (next !== c) {
|
|
386
|
+
if (out === value) out = value.slice();
|
|
387
|
+
out[i] = next;
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
} else {
|
|
391
|
+
for (const k of Object.keys(value)) {
|
|
392
|
+
const c = value[k];
|
|
393
|
+
if (c === null || typeof c !== "object") continue;
|
|
394
|
+
const next = cow(c, visit, undefined , depth + 1, state);
|
|
395
|
+
if (next !== c) {
|
|
396
|
+
if (out === value) out = {
|
|
397
|
+
...value
|
|
398
|
+
};
|
|
399
|
+
out[k] = next;
|
|
400
|
+
}
|
|
401
|
+
}
|
|
402
|
+
}
|
|
403
|
+
if (ancestors !== undefined) ancestors.delete(value);
|
|
404
|
+
return out;
|
|
405
|
+
}
|
|
406
|
+
function clone(value, visit, path, memo) {
|
|
407
|
+
if (memo.has(value)) return memo.get(value);
|
|
408
|
+
const r = visit(value, path);
|
|
409
|
+
if (r !== DESCEND) {
|
|
410
|
+
memo.set(value, r);
|
|
411
|
+
return r;
|
|
412
|
+
}
|
|
413
|
+
const s = shape(value);
|
|
414
|
+
if (s === 0) return value;
|
|
415
|
+
const out = s === 1 ? value.slice() : {
|
|
416
|
+
...value
|
|
417
|
+
};
|
|
418
|
+
memo.set(value, out);
|
|
419
|
+
if (s === 1) {
|
|
420
|
+
for (let i = 0; i < value.length; i++) {
|
|
421
|
+
const c = value[i];
|
|
422
|
+
if (c !== null && typeof c === "object") out[i] = clone(c, visit, undefined , memo);
|
|
423
|
+
}
|
|
424
|
+
} else {
|
|
425
|
+
for (const k of Object.keys(value)) {
|
|
426
|
+
const c = value[k];
|
|
427
|
+
if (c !== null && typeof c === "object") out[k] = clone(c, visit, undefined , memo);
|
|
428
|
+
}
|
|
429
|
+
}
|
|
430
|
+
return out;
|
|
431
|
+
}
|
|
432
|
+
|
|
433
|
+
const STATE = Symbol.for("solid.container-trace-state");
|
|
68
434
|
const state = globalThis[STATE] || (globalThis[STATE] = {
|
|
69
435
|
materialized: new WeakMap(),
|
|
70
436
|
materializedValues: new WeakSet()
|
|
@@ -72,14 +438,33 @@ const state = globalThis[STATE] || (globalThis[STATE] = {
|
|
|
72
438
|
function setContainerTraceResolver(fn) {
|
|
73
439
|
state.resolveTrace = fn;
|
|
74
440
|
}
|
|
441
|
+
function setAsyncIterableSharer(fn) {
|
|
442
|
+
state.shareIterable = fn;
|
|
443
|
+
}
|
|
75
444
|
function setContainerTraceStreamMint(fn) {
|
|
76
445
|
state.streamOf = fn;
|
|
77
446
|
}
|
|
78
|
-
const TRACE = Symbol.for("
|
|
79
|
-
function
|
|
447
|
+
const TRACE = Symbol.for("solid.container-trace");
|
|
448
|
+
function toBorderForm(value, envelopeContainers) {
|
|
449
|
+
if (value == null || typeof value !== "object") return value;
|
|
450
|
+
const share = state.shareIterable;
|
|
451
|
+
if (!share) return value;
|
|
452
|
+
return rewriteTree(value, v => {
|
|
453
|
+
if (share && isShareableIterable(v)) return share(v);
|
|
454
|
+
return DESCEND;
|
|
455
|
+
});
|
|
456
|
+
}
|
|
457
|
+
function isShareableIterable(value) {
|
|
458
|
+
try {
|
|
459
|
+
return typeof value[Symbol.asyncIterator] === "function" && !(typeof ReadableStream !== "undefined" && value instanceof ReadableStream);
|
|
460
|
+
} catch {
|
|
461
|
+
return false;
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
function materialize(marker, claiming) {
|
|
80
465
|
let value = state.materialized.get(marker.$tr);
|
|
81
466
|
if (value === undefined) {
|
|
82
|
-
value = state.materializeTrace(marker);
|
|
467
|
+
value = state.materializeTrace(marker, claiming);
|
|
83
468
|
state.materialized.set(marker.$tr, value);
|
|
84
469
|
if (value !== null && typeof value === "object") state.materializedValues.add(value);
|
|
85
470
|
}
|
|
@@ -94,7 +479,7 @@ function parseTrace(value, ctx) {
|
|
|
94
479
|
};
|
|
95
480
|
}
|
|
96
481
|
const ContainerTracePlugin = {
|
|
97
|
-
tag: "
|
|
482
|
+
tag: "solid/container-trace",
|
|
98
483
|
test(value) {
|
|
99
484
|
return value != null && typeof value === "object" && TRACE in value;
|
|
100
485
|
},
|
|
@@ -126,7 +511,7 @@ const ContainerTracePlugin = {
|
|
|
126
511
|
};
|
|
127
512
|
|
|
128
513
|
setContainerTraceStreamMint(iterable => {
|
|
129
|
-
const stream =
|
|
514
|
+
const stream = createStream();
|
|
130
515
|
(async () => {
|
|
131
516
|
try {
|
|
132
517
|
for await (const value of iterable) stream.next(value);
|
|
@@ -137,25 +522,101 @@ setContainerTraceStreamMint(iterable => {
|
|
|
137
522
|
})();
|
|
138
523
|
return stream;
|
|
139
524
|
});
|
|
140
|
-
const DEFAULT_WEB_PLUGINS = Object.freeze([
|
|
141
|
-
|
|
142
|
-
|
|
525
|
+
const DEFAULT_WEB_PLUGINS = /* @__PURE__ */Object.freeze([AbortSignalPlugin,
|
|
526
|
+
CustomEventPlugin, DOMExceptionPlugin, EventPlugin,
|
|
527
|
+
FormDataPlugin, HeadersPlugin, ReadableStreamPlugin, RequestPlugin, ResponsePlugin, URLSearchParamsPlugin, URLPlugin,
|
|
143
528
|
ContainerTracePlugin]);
|
|
144
529
|
function resolveSerializerPlugins(customPlugins) {
|
|
145
530
|
return customPlugins ? [...customPlugins, ...DEFAULT_WEB_PLUGINS] : [...DEFAULT_WEB_PLUGINS];
|
|
146
531
|
}
|
|
147
|
-
seroval.Feature.RegExp;
|
|
148
532
|
|
|
149
|
-
const
|
|
150
|
-
const serializeOnlyDisabledFeatures =
|
|
533
|
+
const defaultDisabledFeatures = () => Feature.AggregateError | Feature.BigIntTypedArray;
|
|
534
|
+
const serializeOnlyDisabledFeatures = serializeErrorStacks => (process.env.NODE_ENV === "development" ) ? 0 : Feature.ErrorPrototypeStack;
|
|
151
535
|
const HYDRATION_GLOBAL = "_$HY.r";
|
|
152
|
-
function
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
536
|
+
function createKeyedSerializer(serialize, onError, onDone) {
|
|
537
|
+
const cancels = new Set();
|
|
538
|
+
let pendingWrites = 0;
|
|
539
|
+
let flushed = false;
|
|
540
|
+
let done = false;
|
|
541
|
+
let closed = false;
|
|
542
|
+
const maybeDone = () => {
|
|
543
|
+
if (flushed && pendingWrites === 0 && !done) {
|
|
544
|
+
done = true;
|
|
545
|
+
onDone && onDone();
|
|
546
|
+
}
|
|
547
|
+
};
|
|
548
|
+
return {
|
|
549
|
+
write(key, value) {
|
|
550
|
+
if (flushed) return;
|
|
551
|
+
pendingWrites++;
|
|
552
|
+
let settled = false;
|
|
553
|
+
let failed = false;
|
|
554
|
+
let started = false;
|
|
555
|
+
let cancel = null;
|
|
556
|
+
const settle = () => {
|
|
557
|
+
if (settled) return;
|
|
558
|
+
settled = true;
|
|
559
|
+
if (cancel) cancels.delete(cancel);
|
|
560
|
+
pendingWrites--;
|
|
561
|
+
maybeDone();
|
|
562
|
+
};
|
|
563
|
+
let stream;
|
|
564
|
+
try {
|
|
565
|
+
stream = serialize(key, value, {
|
|
566
|
+
onError: onError && (err => {
|
|
567
|
+
failed = true;
|
|
568
|
+
onError(err);
|
|
569
|
+
if (cancel) {
|
|
570
|
+
cancel();
|
|
571
|
+
settle();
|
|
572
|
+
}
|
|
573
|
+
}),
|
|
574
|
+
onDone: settle
|
|
575
|
+
}, initial => {
|
|
576
|
+
if (initial) started = true;
|
|
577
|
+
return !closed;
|
|
578
|
+
});
|
|
579
|
+
} catch (err) {
|
|
580
|
+
settle();
|
|
581
|
+
throw err;
|
|
582
|
+
}
|
|
583
|
+
if (settled) return;
|
|
584
|
+
if (closed || failed) {
|
|
585
|
+
stream();
|
|
586
|
+
settle();
|
|
587
|
+
return;
|
|
588
|
+
}
|
|
589
|
+
cancel = stream;
|
|
590
|
+
cancels.add(cancel);
|
|
591
|
+
},
|
|
592
|
+
flush() {
|
|
593
|
+
flushed = true;
|
|
594
|
+
maybeDone();
|
|
595
|
+
},
|
|
596
|
+
close() {
|
|
597
|
+
closed = flushed = true;
|
|
598
|
+
for (const cancel of cancels) cancel();
|
|
599
|
+
cancels.clear();
|
|
600
|
+
if (!done) {
|
|
601
|
+
done = true;
|
|
602
|
+
onDone && onDone();
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
};
|
|
158
606
|
}
|
|
607
|
+
const KEY_ESCAPES = {
|
|
608
|
+
'"': '\\"',
|
|
609
|
+
"\\": "\\\\",
|
|
610
|
+
"\n": "\\n",
|
|
611
|
+
"\r": "\\r",
|
|
612
|
+
"\b": "\\b",
|
|
613
|
+
"\t": "\\t",
|
|
614
|
+
"\f": "\\f",
|
|
615
|
+
"<": "\\x3C",
|
|
616
|
+
"\u2028": "\\u2028",
|
|
617
|
+
"\u2029": "\\u2029"
|
|
618
|
+
};
|
|
619
|
+
const serializeKey = key => ("" + key).replace(/["\\\n\r\b\t\f<\u2028\u2029]/g, c => KEY_ESCAPES[c]);
|
|
159
620
|
function createHydrationSerializer({
|
|
160
621
|
onData,
|
|
161
622
|
onDone,
|
|
@@ -163,31 +624,44 @@ function createHydrationSerializer({
|
|
|
163
624
|
onError,
|
|
164
625
|
plugins
|
|
165
626
|
}) {
|
|
166
|
-
|
|
627
|
+
const resolvedPlugins = resolveSerializerPlugins(plugins);
|
|
628
|
+
const disabledFeatures = defaultDisabledFeatures() | serializeOnlyDisabledFeatures();
|
|
629
|
+
const refs = new Map();
|
|
630
|
+
return createKeyedSerializer((key, value, callbacks, live) => crossSerializeStream(value, {
|
|
167
631
|
scopeId,
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
632
|
+
refs,
|
|
633
|
+
plugins: resolvedPlugins,
|
|
634
|
+
disabledFeatures,
|
|
635
|
+
onSerialize(data, initial) {
|
|
636
|
+
if (!live(initial)) return;
|
|
637
|
+
onData(initial ? HYDRATION_GLOBAL + '["' + serializeKey(key) + '"]=' + data : data);
|
|
638
|
+
},
|
|
639
|
+
...callbacks
|
|
640
|
+
}), onError, onDone);
|
|
174
641
|
}
|
|
175
642
|
function getLocalHeaderScript(id) {
|
|
176
|
-
return
|
|
643
|
+
return getCrossReferenceHeader(id) + ";";
|
|
177
644
|
}
|
|
178
645
|
|
|
179
646
|
const ENVELOPE = Symbol.for("solid.ResponseEnvelope");
|
|
180
|
-
|
|
181
|
-
const ResponseEnvelope =
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
647
|
+
let EnvelopeClass;
|
|
648
|
+
const ResponseEnvelope = function ResponseEnvelope(response, value) {
|
|
649
|
+
if (!EnvelopeClass) {
|
|
650
|
+
EnvelopeClass = class extends Response {
|
|
651
|
+
constructor(response, value) {
|
|
652
|
+
super(response ? response.body : null, response && {
|
|
653
|
+
status: response.status,
|
|
654
|
+
statusText: response.statusText,
|
|
655
|
+
headers: copyHeaders(response.headers)
|
|
656
|
+
});
|
|
657
|
+
this.response = response ? this : undefined;
|
|
658
|
+
this.value = value;
|
|
659
|
+
}
|
|
660
|
+
};
|
|
661
|
+
EnvelopeClass.prototype[ENVELOPE] = true;
|
|
187
662
|
}
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
})();
|
|
663
|
+
return new EnvelopeClass(response, value);
|
|
664
|
+
};
|
|
191
665
|
function isResponseEnvelope(value) {
|
|
192
666
|
return !!(value && typeof value === "object" && value[ENVELOPE]);
|
|
193
667
|
}
|
|
@@ -210,24 +684,38 @@ function isSafeError(value) {
|
|
|
210
684
|
return !!(value && (typeof value === "object" || typeof value === "function") && value[SAFE_ERROR]);
|
|
211
685
|
}
|
|
212
686
|
const REVALIDATE_HEADER = "X-Revalidate";
|
|
213
|
-
|
|
687
|
+
const REVALIDATE_ALL = "*";
|
|
688
|
+
const RESPONSE_HEADER_VALUE_LIMIT = 4096;
|
|
689
|
+
function copyHeaders(init) {
|
|
690
|
+
const source = init;
|
|
691
|
+
if (!source || !source.getSetCookie) return new Headers(init);
|
|
692
|
+
const headers = new Headers();
|
|
693
|
+
source.forEach((value, key) => {
|
|
694
|
+
if (key !== "set-cookie") headers.append(key, value);
|
|
695
|
+
});
|
|
696
|
+
for (const cookie of source.getSetCookie()) headers.append("Set-Cookie", cookie);
|
|
697
|
+
return headers;
|
|
698
|
+
}
|
|
699
|
+
function initWithRevalidate(init = {}) {
|
|
700
|
+
const resolved = typeof init === "number" ? {
|
|
701
|
+
status: init
|
|
702
|
+
} : init;
|
|
214
703
|
const {
|
|
215
704
|
revalidate,
|
|
216
705
|
...responseInit
|
|
217
|
-
} =
|
|
218
|
-
|
|
219
|
-
if (
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
});
|
|
224
|
-
for (const cookie of responseInit.headers.getSetCookie()) {
|
|
225
|
-
headers.append("Set-Cookie", cookie);
|
|
706
|
+
} = resolved;
|
|
707
|
+
const headers = copyHeaders(responseInit.headers);
|
|
708
|
+
if (revalidate !== undefined) {
|
|
709
|
+
const list = Array.isArray(revalidate) ? revalidate : [revalidate];
|
|
710
|
+
if (list.length > 1 && list.includes(REVALIDATE_ALL)) {
|
|
711
|
+
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.`);
|
|
226
712
|
}
|
|
227
|
-
|
|
228
|
-
|
|
713
|
+
const keys = list.join(",");
|
|
714
|
+
if (keys.length > RESPONSE_HEADER_VALUE_LIMIT) {
|
|
715
|
+
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.`);
|
|
716
|
+
}
|
|
717
|
+
headers.set(REVALIDATE_HEADER, keys);
|
|
229
718
|
}
|
|
230
|
-
revalidate !== undefined && headers.set(REVALIDATE_HEADER, revalidate.toString());
|
|
231
719
|
return {
|
|
232
720
|
responseInit,
|
|
233
721
|
headers
|
|
@@ -240,13 +728,17 @@ function redirect(url, init = 302) {
|
|
|
240
728
|
const {
|
|
241
729
|
responseInit,
|
|
242
730
|
headers
|
|
243
|
-
} = initWithRevalidate(
|
|
244
|
-
status: init
|
|
245
|
-
} : init);
|
|
731
|
+
} = initWithRevalidate(init);
|
|
246
732
|
if (responseInit.status === undefined) {
|
|
247
733
|
responseInit.status = 302;
|
|
248
734
|
}
|
|
249
|
-
|
|
735
|
+
const target = typeof url === "string" ? url : url[HREF];
|
|
736
|
+
const location = typeof target === "string" ? target : String(url);
|
|
737
|
+
const encoded = location.replace(/[^\x00-\x7f]/gu, encodeURIComponent);
|
|
738
|
+
if (encoded.length > RESPONSE_HEADER_VALUE_LIMIT) {
|
|
739
|
+
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.`);
|
|
740
|
+
}
|
|
741
|
+
headers.set("Location", encoded);
|
|
250
742
|
return new Response(null, {
|
|
251
743
|
...responseInit,
|
|
252
744
|
headers
|
|
@@ -262,13 +754,26 @@ function reload(init = {}) {
|
|
|
262
754
|
headers
|
|
263
755
|
});
|
|
264
756
|
}
|
|
757
|
+
const NULL_BODY_STATUSES = new Set([204, 205, 304]);
|
|
265
758
|
function respond(value, init = {}) {
|
|
266
759
|
const {
|
|
267
760
|
responseInit,
|
|
268
761
|
headers
|
|
269
762
|
} = initWithRevalidate(init);
|
|
763
|
+
for (const header of COMPOSED_BODY_FRAMING) headers.delete(header);
|
|
764
|
+
if (NULL_BODY_STATUSES.has(responseInit.status)) {
|
|
765
|
+
return new ResponseEnvelope(new Response(null, {
|
|
766
|
+
...responseInit,
|
|
767
|
+
headers
|
|
768
|
+
}), value);
|
|
769
|
+
}
|
|
270
770
|
headers.set("Content-Type", "application/json");
|
|
271
|
-
return new ResponseEnvelope(new Response(
|
|
771
|
+
return new ResponseEnvelope(new Response(new ReadableStream({
|
|
772
|
+
pull(controller) {
|
|
773
|
+
controller.enqueue(new TextEncoder().encode(JSON.stringify(value)));
|
|
774
|
+
controller.close();
|
|
775
|
+
}
|
|
776
|
+
}), {
|
|
272
777
|
...responseInit,
|
|
273
778
|
headers
|
|
274
779
|
}), value);
|
|
@@ -317,6 +822,7 @@ function serializeCookie(name, value, options = {}) {
|
|
|
317
822
|
if (options.expires) cookie += `; Expires=${options.expires.toUTCString()}`;
|
|
318
823
|
if (options.httpOnly) cookie += "; HttpOnly";
|
|
319
824
|
if (options.secure) cookie += "; Secure";
|
|
825
|
+
if (options.partitioned) cookie += "; Partitioned";
|
|
320
826
|
if (options.sameSite) {
|
|
321
827
|
const sameSite = options.sameSite.toLowerCase();
|
|
322
828
|
cookie += `; SameSite=${sameSite === "none" ? "None" : sameSite === "strict" ? "Strict" : "Lax"}`;
|
|
@@ -324,7 +830,7 @@ function serializeCookie(name, value, options = {}) {
|
|
|
324
830
|
return cookie;
|
|
325
831
|
}
|
|
326
832
|
const FLASH_COOKIE = "flash";
|
|
327
|
-
const FLASH_MATCHER =
|
|
833
|
+
const FLASH_MATCHER = /(?:^|;\s*)flash=([^;]+)/;
|
|
328
834
|
function hasFlashCookie(cookieHeader) {
|
|
329
835
|
return !!cookieHeader && FLASH_MATCHER.test(cookieHeader);
|
|
330
836
|
}
|
|
@@ -334,8 +840,21 @@ function clearFlashCookie() {
|
|
|
334
840
|
|
|
335
841
|
const ERROR_HEADER = "X-Server-Function-Error";
|
|
336
842
|
const BODY_FORMAT_HEADER = "X-Server-Function-Format";
|
|
843
|
+
const REDIRECT_HEADER = "X-Server-Function-Redirect";
|
|
337
844
|
const SINGLE_FLIGHT_HEADER = "X-Single-Flight";
|
|
338
845
|
|
|
846
|
+
function emitFinding(finding, subject = getOwner()) {
|
|
847
|
+
if (OBSERVE === undefined) return;
|
|
848
|
+
OBSERVE.diagnostics.emit(finding, subject);
|
|
849
|
+
}
|
|
850
|
+
function recordFinding(finding, subject = getOwner()) {
|
|
851
|
+
if (OBSERVE !== undefined) OBSERVE.diagnostics.emit(finding, subject);
|
|
852
|
+
}
|
|
853
|
+
function errorText(error) {
|
|
854
|
+
if (error instanceof Error) return error.message ? `${error.name}: ${error.message}` : error.name;
|
|
855
|
+
return String(error);
|
|
856
|
+
}
|
|
857
|
+
|
|
339
858
|
const HEAD_ELIGIBLE_TAGS = new Set(["title", "meta", "link", "style", "script", "base"]);
|
|
340
859
|
const HEAD_ATTR_NAME = /^[a-zA-Z_][a-zA-Z0-9_:.-]*$/;
|
|
341
860
|
const RESOURCE_LINK_RELS = new Set(["preload", "modulepreload", "prefetch", "preconnect", "dns-prefetch", "stylesheet"]);
|
|
@@ -368,11 +887,28 @@ function classifyHeadTag(desc) {
|
|
|
368
887
|
resource: false
|
|
369
888
|
};
|
|
370
889
|
}
|
|
890
|
+
function qualifierValue(name, value) {
|
|
891
|
+
if (value == null || value === false) return null;
|
|
892
|
+
if (name === "imagesrcset" || name === "imagesizes") return typeof value === "string" && value !== "" ? value : null;
|
|
893
|
+
const v = value === true ? "" : String(value);
|
|
894
|
+
if (name === "as") return asciiLowerCase(v);
|
|
895
|
+
if (name !== "crossorigin") return v;
|
|
896
|
+
return v.length === 15 && v.toLowerCase() === "use-credentials" ? v.toLowerCase() : "anonymous";
|
|
897
|
+
}
|
|
898
|
+
function asciiLowerCase(value) {
|
|
899
|
+
return value.replace(/[A-Z]/g, c => String.fromCharCode(c.charCodeAt(0) + 32));
|
|
900
|
+
}
|
|
901
|
+
const JSON_SCRIPT_TYPE = /^(?:importmap|speculationrules)$|^[\t\n\r ]*(?:application\/json|text\/json|[\w!#$%&'*+.^`|~-]+\/[\w!#$%&'*+.^`|~-]*\+json)[\t\n\r ]*(?:;|$)/i;
|
|
902
|
+
function headBodyText(tag, props, text) {
|
|
903
|
+
return tag === "script" && JSON_SCRIPT_TYPE.test(String(props.type)) ? text.replace(/</g, "\\u003C") : text;
|
|
904
|
+
}
|
|
371
905
|
function resourceIdentity(tag, props) {
|
|
372
|
-
|
|
906
|
+
const url = String(props.href || props.src || "");
|
|
907
|
+
let id = "res:" + tag + ":" + (props.rel || "") + ":" + url.length + ":" + url;
|
|
373
908
|
for (let i = 0; i < RESOURCE_QUALIFIERS.length; i++) {
|
|
374
909
|
const q = RESOURCE_QUALIFIERS[i];
|
|
375
|
-
|
|
910
|
+
const value = qualifierValue(q, props[q]);
|
|
911
|
+
if (value !== null) id += ":" + q + "=" + value.length + ":" + value;
|
|
376
912
|
}
|
|
377
913
|
return id;
|
|
378
914
|
}
|
|
@@ -421,6 +957,7 @@ function resolveHead(groups) {
|
|
|
421
957
|
return winners;
|
|
422
958
|
}
|
|
423
959
|
|
|
960
|
+
const renderConfig = sharedConfig;
|
|
424
961
|
function joinAssetPath(base, file) {
|
|
425
962
|
if (/^(?:[a-z][a-z0-9+.-]*:)?\/\//i.test(file)) return file;
|
|
426
963
|
if (typeof base !== "string" || !base) base = "/";
|
|
@@ -434,6 +971,7 @@ function resolveAssets(moduleUrl, manifest) {
|
|
|
434
971
|
if (!entry) return null;
|
|
435
972
|
const css = [];
|
|
436
973
|
const js = [];
|
|
974
|
+
let preloads;
|
|
437
975
|
const visited = new Set();
|
|
438
976
|
const walk = key => {
|
|
439
977
|
if (visited.has(key)) return;
|
|
@@ -442,22 +980,44 @@ function resolveAssets(moduleUrl, manifest) {
|
|
|
442
980
|
if (!e) return;
|
|
443
981
|
js.push(joinAssetPath(base, e.file));
|
|
444
982
|
if (e.css) for (let i = 0; i < e.css.length; i++) css.push(joinAssetPath(base, e.css[i]));
|
|
983
|
+
if (e.preloads) {
|
|
984
|
+
for (let i = 0; i < e.preloads.length; i++) {
|
|
985
|
+
const link = e.preloads[i];
|
|
986
|
+
const href = link && typeof link.href === "string" && link.href;
|
|
987
|
+
const srcset = link && typeof link.imagesrcset === "string" && link.imagesrcset;
|
|
988
|
+
if (!href && !srcset) continue;
|
|
989
|
+
if (!preloads) preloads = [];
|
|
990
|
+
if (href) preloads.push({
|
|
991
|
+
...link,
|
|
992
|
+
href: joinAssetPath(base, href)
|
|
993
|
+
});else {
|
|
994
|
+
const {
|
|
995
|
+
href: bad,
|
|
996
|
+
...rest
|
|
997
|
+
} = link;
|
|
998
|
+
preloads.push(rest);
|
|
999
|
+
}
|
|
1000
|
+
}
|
|
1001
|
+
}
|
|
445
1002
|
if (e.imports) for (let i = 0; i < e.imports.length; i++) walk(e.imports[i]);
|
|
446
1003
|
};
|
|
447
1004
|
walk(moduleUrl);
|
|
448
|
-
|
|
1005
|
+
const assets = {
|
|
449
1006
|
js,
|
|
450
1007
|
css
|
|
451
1008
|
};
|
|
1009
|
+
if (preloads) assets.preloads = preloads;
|
|
1010
|
+
return assets;
|
|
452
1011
|
}
|
|
453
1012
|
function registerEntryAssets(manifest) {
|
|
454
1013
|
if (!manifest || typeof manifest === "function" || typeof manifest.resolve === "function") return;
|
|
455
|
-
const ctx =
|
|
1014
|
+
const ctx = sharedConfig.context;
|
|
456
1015
|
if (!ctx?.registerAsset) return;
|
|
457
1016
|
for (const key in manifest) {
|
|
458
1017
|
if (manifest[key].isEntry) {
|
|
459
1018
|
const assets = resolveAssets(key, manifest);
|
|
460
1019
|
if (assets) {
|
|
1020
|
+
if (assets.preloads) for (let i = 0; i < assets.preloads.length; i++) ctx.registerAsset("preload", assets.preloads[i]);
|
|
461
1021
|
for (let i = 0; i < assets.css.length; i++) ctx.registerAsset("style", assets.css[i]);
|
|
462
1022
|
for (let i = 1; i < assets.js.length; i++) ctx.registerAsset("module", assets.js[i]);
|
|
463
1023
|
}
|
|
@@ -476,6 +1036,7 @@ function createAssetTracking() {
|
|
|
476
1036
|
boundaryStyles,
|
|
477
1037
|
emittedAssets,
|
|
478
1038
|
inlineStyles,
|
|
1039
|
+
preloadLinks: null,
|
|
479
1040
|
registerInlineStyle(desc) {
|
|
480
1041
|
let entry = inlineStyles.get(desc.id);
|
|
481
1042
|
if (!entry) {
|
|
@@ -550,6 +1111,7 @@ function applyAssetTracking(context, tracking, manifest, noScripts) {
|
|
|
550
1111
|
});
|
|
551
1112
|
context.registerModule = tracking.registerModule;
|
|
552
1113
|
context.getBoundaryModules = tracking.getBoundaryModules;
|
|
1114
|
+
context._lazyAssets = new Map();
|
|
553
1115
|
if (typeof manifest === "function") {
|
|
554
1116
|
context.resolveAssets = guard(manifest);
|
|
555
1117
|
} else if (manifest && typeof manifest.resolve === "function") {
|
|
@@ -567,6 +1129,82 @@ function isCssUrl(url) {
|
|
|
567
1129
|
const q = url.search(/[?#]/);
|
|
568
1130
|
return (q === -1 ? url : url.slice(0, q)).endsWith(".css");
|
|
569
1131
|
}
|
|
1132
|
+
const RESPONSIVE_ATTRIBUTES = ["imagesrcset", "imagesizes"];
|
|
1133
|
+
function isSetAttr(value) {
|
|
1134
|
+
return value != null && value !== false && value !== "";
|
|
1135
|
+
}
|
|
1136
|
+
const PRELOAD_LINK_ATTRIBUTES = ["type", "crossorigin", "integrity", "referrerpolicy", "fetchpriority", "media", "imagesrcset", "imagesizes"];
|
|
1137
|
+
function registerPreloadLink(tracking, headRegistry, link, nonce) {
|
|
1138
|
+
if (!link || typeof link !== "object") {
|
|
1139
|
+
return null;
|
|
1140
|
+
}
|
|
1141
|
+
if (typeof link.as !== "string") {
|
|
1142
|
+
return null;
|
|
1143
|
+
}
|
|
1144
|
+
const as = asciiLowerCase(link.as);
|
|
1145
|
+
let destination = null;
|
|
1146
|
+
switch (as) {
|
|
1147
|
+
case "script":
|
|
1148
|
+
case "style":
|
|
1149
|
+
destination = as;
|
|
1150
|
+
break;
|
|
1151
|
+
case "fetch":
|
|
1152
|
+
case "font":
|
|
1153
|
+
case "image":
|
|
1154
|
+
case "track":
|
|
1155
|
+
break;
|
|
1156
|
+
default:
|
|
1157
|
+
return null;
|
|
1158
|
+
}
|
|
1159
|
+
const responsive = as === "image";
|
|
1160
|
+
let srcset = null;
|
|
1161
|
+
let sizes = null;
|
|
1162
|
+
if (responsive) {
|
|
1163
|
+
for (const name of RESPONSIVE_ATTRIBUTES) {
|
|
1164
|
+
const value = link[name];
|
|
1165
|
+
if (!isSetAttr(value)) continue;
|
|
1166
|
+
if (typeof value !== "string") {
|
|
1167
|
+
continue;
|
|
1168
|
+
}
|
|
1169
|
+
if (name === "imagesrcset") srcset = value;else sizes = value;
|
|
1170
|
+
}
|
|
1171
|
+
}
|
|
1172
|
+
const href = typeof link.href === "string" && link.href ? link.href : null;
|
|
1173
|
+
if (!href && !srcset) {
|
|
1174
|
+
return null;
|
|
1175
|
+
}
|
|
1176
|
+
const props = {
|
|
1177
|
+
rel: "preload"
|
|
1178
|
+
};
|
|
1179
|
+
if (href) props.href = href;
|
|
1180
|
+
props.as = as;
|
|
1181
|
+
for (let i = 0; i < PRELOAD_LINK_ATTRIBUTES.length; i++) {
|
|
1182
|
+
const name = PRELOAD_LINK_ATTRIBUTES[i];
|
|
1183
|
+
if (RESPONSIVE_ATTRIBUTES.indexOf(name) !== -1) {
|
|
1184
|
+
const value = name === "imagesrcset" ? srcset : sizes;
|
|
1185
|
+
if (value !== null) props[name] = value;
|
|
1186
|
+
continue;
|
|
1187
|
+
}
|
|
1188
|
+
const value = link[name];
|
|
1189
|
+
if (value == null || value === false) continue;
|
|
1190
|
+
props[name] = value === true ? "" : String(value);
|
|
1191
|
+
}
|
|
1192
|
+
const identity = resourceIdentity("link", props);
|
|
1193
|
+
if (headRegistry.resources.has(identity)) return null;
|
|
1194
|
+
const attrs = headAttrRecord(props);
|
|
1195
|
+
const nonceValue = destination && nonce && nonce[destination];
|
|
1196
|
+
if (typeof nonceValue === "string" && nonceValue) attrs.nonce = nonceValue;
|
|
1197
|
+
const entry = {
|
|
1198
|
+
href: props.href,
|
|
1199
|
+
attrs,
|
|
1200
|
+
attrHtml: renderHeadAttrHtml(props) + nonceAttr(nonce, destination)
|
|
1201
|
+
};
|
|
1202
|
+
headRegistry.resources.add(identity);
|
|
1203
|
+
let links = tracking.preloadLinks;
|
|
1204
|
+
if (!links) tracking.preloadLinks = links = [];
|
|
1205
|
+
links.push(entry);
|
|
1206
|
+
return entry;
|
|
1207
|
+
}
|
|
570
1208
|
function createHeadRegistry() {
|
|
571
1209
|
return {
|
|
572
1210
|
pending: [],
|
|
@@ -591,7 +1229,7 @@ function registerHeadTags(registry, context, tracking, emitResource, nonce, tags
|
|
|
591
1229
|
return;
|
|
592
1230
|
}
|
|
593
1231
|
if (!Array.isArray(tags)) tags = [tags];
|
|
594
|
-
const probe =
|
|
1232
|
+
const probe = sharedConfig.context && sharedConfig.context._loadingPhase;
|
|
595
1233
|
let replaceable = null;
|
|
596
1234
|
for (let i = 0; i < tags.length; i++) {
|
|
597
1235
|
const desc = tags[i];
|
|
@@ -606,7 +1244,7 @@ function registerHeadTags(registry, context, tracking, emitResource, nonce, tags
|
|
|
606
1244
|
} : undefined);
|
|
607
1245
|
evalHeadValue(desc.key);
|
|
608
1246
|
} catch (err) {
|
|
609
|
-
if (
|
|
1247
|
+
if (ssrHandleError(err)) throw err;
|
|
610
1248
|
}
|
|
611
1249
|
}
|
|
612
1250
|
if (cls.resource) {
|
|
@@ -628,7 +1266,7 @@ function registerHeadTags(registry, context, tracking, emitResource, nonce, tags
|
|
|
628
1266
|
function headShellReady(registry, block) {
|
|
629
1267
|
let ready = true;
|
|
630
1268
|
const pends = err => {
|
|
631
|
-
const source =
|
|
1269
|
+
const source = ssrHandleError(err, true);
|
|
632
1270
|
if (!source) return false;
|
|
633
1271
|
block(source);
|
|
634
1272
|
ready = false;
|
|
@@ -677,9 +1315,9 @@ function emitHeadResource(registry, context, tracking, emitResource, nonce, desc
|
|
|
677
1315
|
rel
|
|
678
1316
|
} : undefined);
|
|
679
1317
|
} catch (err) {
|
|
680
|
-
const loadingPhase =
|
|
681
|
-
if (loadingPhase &&
|
|
682
|
-
if (!loadingPhase && !context._currentBoundaryId && !registry.shellFlushed && typeof context.block === "function" &&
|
|
1318
|
+
const loadingPhase = sharedConfig.context && sharedConfig.context._loadingPhase;
|
|
1319
|
+
if (loadingPhase && ssrHandleError(err)) throw err;
|
|
1320
|
+
if (!loadingPhase && !context._currentBoundaryId && !registry.shellFlushed && typeof context.block === "function" && ssrHandleError(err, true)) {
|
|
683
1321
|
registry.parkedResources.push({
|
|
684
1322
|
desc,
|
|
685
1323
|
rel,
|
|
@@ -817,7 +1455,7 @@ function headGroupSignature(winner) {
|
|
|
817
1455
|
}
|
|
818
1456
|
return sig;
|
|
819
1457
|
}
|
|
820
|
-
function renderShellHead(registry, nonce, isPendingFragment, noScripts) {
|
|
1458
|
+
function renderShellHead(registry, nonce, isPendingFragment, noScripts, traceMetas = "") {
|
|
821
1459
|
commitHeadBoundary(registry, "", isPendingFragment);
|
|
822
1460
|
registry.shellFlushed = true;
|
|
823
1461
|
const winners = resolveHead(registry.committed);
|
|
@@ -843,11 +1481,12 @@ function renderShellHead(registry, nonce, isPendingFragment, noScripts) {
|
|
|
843
1481
|
}
|
|
844
1482
|
return {
|
|
845
1483
|
prelude,
|
|
846
|
-
html: registry.eagerHtml + links + metas + others + scripts,
|
|
1484
|
+
html: registry.eagerHtml + links + metas + traceMetas + others + scripts,
|
|
847
1485
|
title,
|
|
848
1486
|
noScripts
|
|
849
1487
|
};
|
|
850
1488
|
}
|
|
1489
|
+
let headBodyHook;
|
|
851
1490
|
function flushHeadFragment(registry, boundary, nonce) {
|
|
852
1491
|
const groups = commitHeadBoundary(registry, boundary);
|
|
853
1492
|
if (!groups.length) return null;
|
|
@@ -871,7 +1510,7 @@ function flushHeadFragment(registry, boundary, nonce) {
|
|
|
871
1510
|
const t = winner.tags[i];
|
|
872
1511
|
const attrs = {};
|
|
873
1512
|
for (const name in t.props) {
|
|
874
|
-
if (name === "children" || name === "ref" || name
|
|
1513
|
+
if (name === "children" || name === "ref" || isEventName(name)) continue;
|
|
875
1514
|
if (!HEAD_ATTR_NAME.test(name)) {
|
|
876
1515
|
continue;
|
|
877
1516
|
}
|
|
@@ -885,7 +1524,7 @@ function flushHeadFragment(registry, boundary, nonce) {
|
|
|
885
1524
|
if (value) attrs.nonce = String(value);
|
|
886
1525
|
}
|
|
887
1526
|
const children = t.props.children;
|
|
888
|
-
ops.push(["a", identity, t.tag, attrs, children == null ? null : String(children)]);
|
|
1527
|
+
ops.push(["a", identity, t.tag, attrs, children == null ? null : headBodyHook ? headBodyHook(t.tag, t.props, String(children)) : String(children)]);
|
|
889
1528
|
}
|
|
890
1529
|
}
|
|
891
1530
|
return ops.length ? ops : null;
|
|
@@ -913,19 +1552,9 @@ function normalizeNonce(nonce) {
|
|
|
913
1552
|
}
|
|
914
1553
|
function destinationNonce(nonce, destination) {
|
|
915
1554
|
if (nonce == null) return undefined;
|
|
916
|
-
|
|
917
|
-
const value = nonce[destination];
|
|
1555
|
+
const value = typeof nonce === "string" ? nonce : nonce[destination];
|
|
918
1556
|
return typeof value === "string" && value ? value : undefined;
|
|
919
1557
|
}
|
|
920
|
-
function scriptNonce(nonce) {
|
|
921
|
-
return destinationNonce(nonce, "script");
|
|
922
|
-
}
|
|
923
|
-
function styleNonce(nonce) {
|
|
924
|
-
return destinationNonce(nonce, "style");
|
|
925
|
-
}
|
|
926
|
-
function asciiLowerCase(value) {
|
|
927
|
-
return value.replace(/[A-Z]/g, c => String.fromCharCode(c.charCodeAt(0) + 32));
|
|
928
|
-
}
|
|
929
1558
|
function hasNonceProp(props) {
|
|
930
1559
|
for (const name in props) if (name.length === 5 && asciiLowerCase(name) === "nonce" && props[name] != null) return true;
|
|
931
1560
|
return false;
|
|
@@ -963,7 +1592,7 @@ function nonceAttr(nonce, destination) {
|
|
|
963
1592
|
function renderHeadAttrHtml(props) {
|
|
964
1593
|
let attrs = "";
|
|
965
1594
|
for (const name in props) {
|
|
966
|
-
if (name === "children" || name === "ref" || name
|
|
1595
|
+
if (name === "children" || name === "ref" || isEventName(name)) continue;
|
|
967
1596
|
if (!HEAD_ATTR_NAME.test(name)) {
|
|
968
1597
|
continue;
|
|
969
1598
|
}
|
|
@@ -976,7 +1605,7 @@ function renderHeadAttrHtml(props) {
|
|
|
976
1605
|
function headAttrRecord(props, skipRelHref) {
|
|
977
1606
|
let attrs = null;
|
|
978
1607
|
for (const name in props) {
|
|
979
|
-
if (name === "children" || name === "ref" || name
|
|
1608
|
+
if (name === "children" || name === "ref" || isEventName(name)) continue;
|
|
980
1609
|
if ((name === "rel" || name === "href")) continue;
|
|
981
1610
|
if (!HEAD_ATTR_NAME.test(name)) continue;
|
|
982
1611
|
const v = props[name];
|
|
@@ -991,18 +1620,60 @@ function renderHeadTagMarkup(tag, props, identity, nonce) {
|
|
|
991
1620
|
if (nonce && !hasNonceProp(props)) attrs += nonceAttr(nonce, nonceDestination(tag, props));
|
|
992
1621
|
if (tag === "meta" || tag === "link" || tag === "base") return `<${tag}${attrs}>`;
|
|
993
1622
|
let body = props.children == null ? "" : String(props.children);
|
|
1623
|
+
if (headBodyHook) body = headBodyHook(tag, props, body);
|
|
994
1624
|
if (tag === "script") body = body.replace(/<\/(script)/gi, "<\\/$1");else if (tag === "style") body = escapeStyleContent(body);else body = escape(body);
|
|
995
1625
|
return `<${tag}${attrs}>${body}</${tag}>`;
|
|
996
1626
|
}
|
|
997
1627
|
function useHead(tags) {
|
|
998
|
-
const ctx =
|
|
1628
|
+
const ctx = sharedConfig.context;
|
|
999
1629
|
if (!ctx || !ctx.registerHeadTags) {
|
|
1000
1630
|
return;
|
|
1001
1631
|
}
|
|
1632
|
+
headBodyHook = headBodyText;
|
|
1002
1633
|
ctx.registerHeadTags(tags);
|
|
1003
1634
|
}
|
|
1004
1635
|
const VOID_ELEMENTS = /^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/i;
|
|
1005
|
-
const
|
|
1636
|
+
const NOT_NAME = /[\0-\x20\x7F-\x9F"'<>/=]/;
|
|
1637
|
+
const TAG_START = /^[a-zA-Z]/;
|
|
1638
|
+
const tagInfos = /*#__PURE__*/new Map();
|
|
1639
|
+
function tagInfo(tag) {
|
|
1640
|
+
let info = tagInfos.get(tag);
|
|
1641
|
+
if (info === undefined) {
|
|
1642
|
+
if (!TAG_START.test(tag) || NOT_NAME.test(tag)) throw new Error(`"${tag}" is not a valid tag name`);
|
|
1643
|
+
let formDefaults, formAttributes;
|
|
1644
|
+
if (tag === "input" || tag === "option") {
|
|
1645
|
+
formDefaults = Object.create(null);
|
|
1646
|
+
formAttributes = Object.create(null);
|
|
1647
|
+
const state = DOMWithState[tag.toUpperCase()];
|
|
1648
|
+
for (const prop in state) {
|
|
1649
|
+
if (state[prop] === 2) {
|
|
1650
|
+
const attr = prop.slice(7).toLowerCase();
|
|
1651
|
+
formDefaults[attr] = prop;
|
|
1652
|
+
formAttributes[prop] = attr;
|
|
1653
|
+
}
|
|
1654
|
+
}
|
|
1655
|
+
}
|
|
1656
|
+
info = {
|
|
1657
|
+
open: "<" + tag,
|
|
1658
|
+
close: "</" + tag + ">",
|
|
1659
|
+
isVoid: VOID_ELEMENTS.test(tag),
|
|
1660
|
+
textarea: tag === "textarea",
|
|
1661
|
+
raw: tag === "script" || tag === "style",
|
|
1662
|
+
formDefaults,
|
|
1663
|
+
formAttributes
|
|
1664
|
+
};
|
|
1665
|
+
if (tagInfos.size < 512) tagInfos.set(tag, info);
|
|
1666
|
+
}
|
|
1667
|
+
return info;
|
|
1668
|
+
}
|
|
1669
|
+
const safeAttrNames = /*#__PURE__*/new Set();
|
|
1670
|
+
function isAttrName(prop) {
|
|
1671
|
+
if (safeAttrNames.has(prop)) return true;
|
|
1672
|
+
if (prop === "" || NOT_NAME.test(prop)) return false;
|
|
1673
|
+
if (safeAttrNames.size < 512) safeAttrNames.add(prop);
|
|
1674
|
+
return true;
|
|
1675
|
+
}
|
|
1676
|
+
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)`;
|
|
1006
1677
|
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)}`;
|
|
1007
1678
|
function renderToString(code, options = {}) {
|
|
1008
1679
|
const {
|
|
@@ -1012,6 +1683,8 @@ function renderToString(code, options = {}) {
|
|
|
1012
1683
|
onHead
|
|
1013
1684
|
} = options;
|
|
1014
1685
|
const nonce = normalizeNonce(options.nonce);
|
|
1686
|
+
const requestEvent = peekRequestEvent();
|
|
1687
|
+
const errorScope = requestEvent || {};
|
|
1015
1688
|
let scripts = "";
|
|
1016
1689
|
const serializer = createHydrationSerializer({
|
|
1017
1690
|
scopeId: renderId,
|
|
@@ -1023,26 +1696,33 @@ function renderToString(code, options = {}) {
|
|
|
1023
1696
|
}
|
|
1024
1697
|
scripts += script + ";";
|
|
1025
1698
|
},
|
|
1026
|
-
onError: options.onError
|
|
1699
|
+
onError: serializerErrorHook(options.onError)
|
|
1027
1700
|
});
|
|
1028
1701
|
const tracking = createAssetTracking();
|
|
1029
1702
|
const headRegistry = createHeadRegistry();
|
|
1030
|
-
|
|
1703
|
+
let closed = false;
|
|
1704
|
+
sharedConfig.context = {
|
|
1031
1705
|
nonce: options.nonce,
|
|
1032
1706
|
escape: escape,
|
|
1033
1707
|
resolve: resolveSSRNode,
|
|
1034
1708
|
ssr: ssr,
|
|
1709
|
+
errorPolicy: options.onError,
|
|
1710
|
+
_errorScope: errorScope,
|
|
1035
1711
|
registerHeadTags(tags) {
|
|
1036
|
-
registerHeadTags(headRegistry,
|
|
1712
|
+
registerHeadTags(headRegistry, sharedConfig.context, tracking, null, nonce, tags);
|
|
1037
1713
|
},
|
|
1038
1714
|
serialize(id, p) {
|
|
1039
|
-
if (
|
|
1715
|
+
if (closed) return;
|
|
1040
1716
|
if (p != null && typeof p === "object" && (typeof p.then === "function" || typeof p[Symbol.asyncIterator] === "function")) {
|
|
1041
1717
|
throw new Error("Cannot serialize async value in renderToString (id: " + id + "). " + "Use renderToStream for async data.");
|
|
1042
1718
|
}
|
|
1043
1719
|
serializer.write(id, p);
|
|
1044
1720
|
},
|
|
1045
1721
|
registerAsset(type, value) {
|
|
1722
|
+
if (type === "preload") {
|
|
1723
|
+
registerPreloadLink(tracking, headRegistry, value, nonce);
|
|
1724
|
+
return;
|
|
1725
|
+
}
|
|
1046
1726
|
if (type === "inline-style") {
|
|
1047
1727
|
tracking.registerInlineStyle(value);
|
|
1048
1728
|
return;
|
|
@@ -1058,20 +1738,52 @@ function renderToString(code, options = {}) {
|
|
|
1058
1738
|
tracking.emittedAssets.add(value);
|
|
1059
1739
|
}
|
|
1060
1740
|
};
|
|
1061
|
-
applyAssetTracking(
|
|
1741
|
+
applyAssetTracking(sharedConfig.context, tracking, manifest, noScripts);
|
|
1062
1742
|
registerEntryAssets(manifest);
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1743
|
+
const context = sharedConfig.context;
|
|
1744
|
+
context.writer = createHydrationWriter(context, () => !closed);
|
|
1745
|
+
if (requestEvent) setRequestErrorHook(requestEvent, options.onError);
|
|
1746
|
+
context.trace = requestEvent ? traceForEvent(requestEvent) : traceFor(context, undefined);
|
|
1747
|
+
const render = timeDocument(context, context.trace, "string", requestEvent);
|
|
1748
|
+
let dispose;
|
|
1749
|
+
let rootOwner;
|
|
1750
|
+
let rendered = false;
|
|
1751
|
+
try {
|
|
1752
|
+
const html = createRoot(d => {
|
|
1753
|
+
dispose = d;
|
|
1754
|
+
rootOwner = claimRenderRoot(context);
|
|
1755
|
+
if (requestEvent) claimEventRender(requestEvent, context);
|
|
1756
|
+
return resolveSSRSync(escape(code()));
|
|
1757
|
+
}, {
|
|
1758
|
+
id: renderId
|
|
1759
|
+
});
|
|
1760
|
+
serializeFragmentAssets("", tracking.boundaryModules, sharedConfig.context, renderId);
|
|
1761
|
+
closed = true;
|
|
1762
|
+
serializer.close();
|
|
1763
|
+
const head = renderShellHead(headRegistry, nonce, null, noScripts, traceMetaMarkup(context.trace));
|
|
1764
|
+
const document = withShellEnd(assembleDocument(resolveSSRSelectValues(html), tracking.emittedAssets, tracking.preloadLinks, tracking.inlineStyles, scripts.length ? scripts : "", nonce, head, onHead), context, renderId, nonce, noScripts);
|
|
1765
|
+
if (render) render.shell();
|
|
1766
|
+
if (requestEvent && requestEvent.response) {
|
|
1767
|
+
commitResponseStub(requestEvent.response, {
|
|
1768
|
+
event: requestEvent
|
|
1769
|
+
});
|
|
1770
|
+
}
|
|
1771
|
+
rendered = true;
|
|
1772
|
+
return document;
|
|
1773
|
+
} catch (err) {
|
|
1774
|
+
reportServerError(err, {
|
|
1775
|
+
kind: "render",
|
|
1776
|
+
handling: "failed"
|
|
1777
|
+
}, null, options.onError, errorScope);
|
|
1778
|
+
throw err;
|
|
1779
|
+
} finally {
|
|
1780
|
+
if (render) settleRender(render, rootOwner, rendered ? "complete" : "error");
|
|
1781
|
+
context.trace = undefined;
|
|
1782
|
+
if (dispose) dispose();
|
|
1783
|
+
}
|
|
1074
1784
|
}
|
|
1785
|
+
const SHELL_ABANDONED = Symbol();
|
|
1786
|
+
const ABANDON_RENDER = Symbol();
|
|
1075
1787
|
function renderToStream(code, options = {}) {
|
|
1076
1788
|
let {
|
|
1077
1789
|
onCompleteShell,
|
|
@@ -1082,12 +1794,61 @@ function renderToStream(code, options = {}) {
|
|
|
1082
1794
|
onHead
|
|
1083
1795
|
} = options;
|
|
1084
1796
|
const nonce = normalizeNonce(options.nonce);
|
|
1797
|
+
const requestEvent = peekRequestEvent();
|
|
1798
|
+
if (requestEvent) setRequestErrorHook(requestEvent, options.onError);
|
|
1799
|
+
const errorScope = requestEvent || {};
|
|
1800
|
+
const reportFailure = (err, handling) => {
|
|
1801
|
+
reportServerError(err, {
|
|
1802
|
+
kind: "render",
|
|
1803
|
+
handling
|
|
1804
|
+
}, null, options.onError, errorScope);
|
|
1805
|
+
if (!options.onError && ambientServerErrorHook() === undefined) console.error(err);
|
|
1806
|
+
};
|
|
1085
1807
|
let dispose;
|
|
1086
1808
|
let dead = false;
|
|
1087
|
-
|
|
1809
|
+
let render;
|
|
1810
|
+
let rootOwner;
|
|
1811
|
+
let serializer;
|
|
1812
|
+
let disconnected = false;
|
|
1813
|
+
let failed = false;
|
|
1814
|
+
let onFailed;
|
|
1815
|
+
let onDisconnectedBeforeShell;
|
|
1816
|
+
const defuse = p => {
|
|
1817
|
+
if (p && typeof p.then === "function") p.then(undefined, () => {});
|
|
1818
|
+
};
|
|
1819
|
+
const abandonedSerializer = {
|
|
1820
|
+
write(_, value) {
|
|
1821
|
+
defuse(value);
|
|
1822
|
+
},
|
|
1823
|
+
flush() {},
|
|
1824
|
+
close() {}
|
|
1825
|
+
};
|
|
1826
|
+
const onFailure = complete => {
|
|
1827
|
+
if (failed) return complete(undefined);
|
|
1828
|
+
const prev = onFailed;
|
|
1829
|
+
onFailed = prev ? sink => {
|
|
1830
|
+
prev(sink);
|
|
1831
|
+
complete(sink);
|
|
1832
|
+
} : complete;
|
|
1833
|
+
};
|
|
1834
|
+
const abandon = (disconnect, quiet) => {
|
|
1088
1835
|
if (dead) return;
|
|
1836
|
+
if (disconnect && !quiet) emitFinding({
|
|
1837
|
+
code: "SSR_STREAM_ABANDONED",
|
|
1838
|
+
kind: "ssr",
|
|
1839
|
+
severity: "warn",
|
|
1840
|
+
message: `[SSR_STREAM_ABANDONED] The response stream was abandoned mid-render (${disconnect}) ` + `with ${registry.size} fragment(s) still pending; the render was torn down.`,
|
|
1841
|
+
data: {
|
|
1842
|
+
reason: disconnect,
|
|
1843
|
+
shellFlushed: firstFlushed,
|
|
1844
|
+
pendingFragments: registry.size
|
|
1845
|
+
}
|
|
1846
|
+
}, null);
|
|
1089
1847
|
dead = true;
|
|
1090
1848
|
completed = true;
|
|
1849
|
+
if (disconnect) disconnected = true;
|
|
1850
|
+
if (render) settleRender(render, rootOwner, disconnect ? "abandoned" : "error");
|
|
1851
|
+
const sink = writable;
|
|
1091
1852
|
buffer = {
|
|
1092
1853
|
write() {}
|
|
1093
1854
|
};
|
|
@@ -1099,13 +1860,43 @@ function renderToStream(code, options = {}) {
|
|
|
1099
1860
|
dispose = () => {};
|
|
1100
1861
|
d();
|
|
1101
1862
|
}
|
|
1863
|
+
if (serializer && typeof serializer.close === "function") {
|
|
1864
|
+
try {
|
|
1865
|
+
serializer.close();
|
|
1866
|
+
} catch (err) {
|
|
1867
|
+
reportServerError(err, {
|
|
1868
|
+
kind: "render",
|
|
1869
|
+
handling: "serialize"
|
|
1870
|
+
}, null, options.onError, errorScope);
|
|
1871
|
+
}
|
|
1872
|
+
}
|
|
1873
|
+
serializer = abandonedSerializer;
|
|
1874
|
+
if (stubBatch) {
|
|
1875
|
+
for (const p of stubBatch.values()) defuse(p);
|
|
1876
|
+
stubBatch = null;
|
|
1877
|
+
}
|
|
1878
|
+
if (!disconnect) {
|
|
1879
|
+
failed = true;
|
|
1880
|
+
onFailed && onFailed(sink);
|
|
1881
|
+
} else if (!sink && onDisconnectedBeforeShell) onDisconnectedBeforeShell();
|
|
1102
1882
|
};
|
|
1103
1883
|
const failRender = err => {
|
|
1104
|
-
|
|
1105
|
-
options.onError ? options.onError(err) : console.error(err);
|
|
1106
|
-
} catch (_) {}
|
|
1884
|
+
reportFailure(err, "failed");
|
|
1107
1885
|
abandon();
|
|
1108
1886
|
};
|
|
1887
|
+
const failRootRender = err => {
|
|
1888
|
+
emitFinding({
|
|
1889
|
+
code: "SSR_RENDER_ERROR_CONTAINED",
|
|
1890
|
+
kind: "ssr",
|
|
1891
|
+
severity: "error",
|
|
1892
|
+
message: `[SSR_RENDER_ERROR_CONTAINED] Render error outside any boundary — the request failed: ` + errorText(err),
|
|
1893
|
+
data: {
|
|
1894
|
+
handling: "failed",
|
|
1895
|
+
error: err
|
|
1896
|
+
}
|
|
1897
|
+
}, null);
|
|
1898
|
+
failRender(err);
|
|
1899
|
+
};
|
|
1109
1900
|
const coalesceWrites = (writeRaw, endRaw) => {
|
|
1110
1901
|
let buf = "";
|
|
1111
1902
|
let scheduled = false;
|
|
@@ -1134,39 +1925,43 @@ function renderToStream(code, options = {}) {
|
|
|
1134
1925
|
};
|
|
1135
1926
|
const guardSink = w => ({
|
|
1136
1927
|
write(payload) {
|
|
1137
|
-
if (
|
|
1928
|
+
if (disconnected) return;
|
|
1138
1929
|
try {
|
|
1139
1930
|
w.write(payload);
|
|
1140
1931
|
} catch (_) {
|
|
1141
|
-
abandon();
|
|
1932
|
+
abandon("sink");
|
|
1142
1933
|
}
|
|
1143
1934
|
},
|
|
1144
1935
|
end() {
|
|
1145
|
-
if (
|
|
1936
|
+
if (disconnected) return;
|
|
1146
1937
|
try {
|
|
1147
1938
|
w.end();
|
|
1148
1939
|
} catch (_) {
|
|
1149
|
-
abandon();
|
|
1940
|
+
abandon("sink");
|
|
1150
1941
|
}
|
|
1151
1942
|
}
|
|
1152
1943
|
});
|
|
1153
1944
|
const blockingPromises = new Set();
|
|
1154
1945
|
const canBatchStubs = !options.serializer && !options.sink;
|
|
1155
1946
|
let stubBatch = null;
|
|
1156
|
-
|
|
1947
|
+
let stableOrder = false;
|
|
1948
|
+
let parkedWrites = null;
|
|
1949
|
+
const byKey = (a, b) => a[0] < b[0] ? -1 : a[0] > b[0] ? 1 : 0;
|
|
1950
|
+
const write = (id, value) => {
|
|
1951
|
+
if (stableOrder && !dead) (parkedWrites ||= []).push([id, value]);else serializer.write(id, value);
|
|
1952
|
+
};
|
|
1953
|
+
const flushParkedWrites = () => {
|
|
1954
|
+
if (!parkedWrites) return;
|
|
1955
|
+
const writes = parkedWrites.sort(byKey);
|
|
1956
|
+
parkedWrites = null;
|
|
1957
|
+
for (let i = 0; i < writes.length; i++) serializer.write(writes[i][0], writes[i][1]);
|
|
1958
|
+
};
|
|
1157
1959
|
const flushStubBatch = () => {
|
|
1158
1960
|
if (!stubBatch) return;
|
|
1159
|
-
const
|
|
1961
|
+
const entries = [...stubBatch];
|
|
1160
1962
|
stubBatch = null;
|
|
1161
|
-
if (
|
|
1162
|
-
|
|
1163
|
-
serializer.write(id, p);
|
|
1164
|
-
return;
|
|
1165
|
-
}
|
|
1166
|
-
const obj = {};
|
|
1167
|
-
for (const [id, p] of batch) obj[id] = p;
|
|
1168
|
-
serializer.write(STUB_BATCH_KEY, obj);
|
|
1169
|
-
pushTask(`(b=>{for(var k in b)_$HY.r[k]=b[k];delete _$HY.r["${STUB_BATCH_KEY}"]})(_$HY.r["${STUB_BATCH_KEY}"])`);
|
|
1963
|
+
if (stableOrder) entries.sort(byKey);
|
|
1964
|
+
for (let i = 0; i < entries.length; i++) serializer.write(entries[i][0], entries[i][1]);
|
|
1170
1965
|
};
|
|
1171
1966
|
let headerEmitted = false;
|
|
1172
1967
|
const pushTask = task => {
|
|
@@ -1182,7 +1977,9 @@ function renderToStream(code, options = {}) {
|
|
|
1182
1977
|
}
|
|
1183
1978
|
};
|
|
1184
1979
|
const onDone = () => {
|
|
1980
|
+
if (dead) return;
|
|
1185
1981
|
writeTasks();
|
|
1982
|
+
lastBlockingSize = blockingPromises.size;
|
|
1186
1983
|
doShell();
|
|
1187
1984
|
onCompleteAll && onCompleteAll({
|
|
1188
1985
|
write(v) {
|
|
@@ -1191,6 +1988,7 @@ function renderToStream(code, options = {}) {
|
|
|
1191
1988
|
});
|
|
1192
1989
|
writable && writable.end();
|
|
1193
1990
|
completed = true;
|
|
1991
|
+
if (render) settleRender(render, rootOwner, "complete");
|
|
1194
1992
|
if (firstFlushed) dispose();
|
|
1195
1993
|
};
|
|
1196
1994
|
const sink = {
|
|
@@ -1200,6 +1998,7 @@ function renderToStream(code, options = {}) {
|
|
|
1200
1998
|
fragment(key, value, meta) {
|
|
1201
1999
|
const deferActivation = !!meta.revealGroup;
|
|
1202
2000
|
const styles = meta.styles;
|
|
2001
|
+
const tpl = `<template id="${key}"${meta.error ? " e" : ""}>${value}</template>`;
|
|
1203
2002
|
for (let i = 0; i < styles.inline.length; i++) {
|
|
1204
2003
|
buffer.write(renderInlineStyle(styles.inline[i], nonce));
|
|
1205
2004
|
}
|
|
@@ -1207,12 +2006,12 @@ function renderToStream(code, options = {}) {
|
|
|
1207
2006
|
const styleAttr = nonceAttr(nonce, "style");
|
|
1208
2007
|
emitTask(`$dfs("${key}",${styles.links.length},${deferActivation ? 1 : 0})`);
|
|
1209
2008
|
writeTasks();
|
|
2009
|
+
buffer.write(tpl);
|
|
1210
2010
|
for (const entry of styles.links) {
|
|
1211
|
-
buffer.write(typeof entry === "string" ? `<link rel="stylesheet" href="${entry}"${styleAttr}
|
|
2011
|
+
buffer.write(typeof entry === "string" ? `<link rel="stylesheet" href="${entry}"${styleAttr} data-dfc="${key}">` : `<link${entry.attrHtml}${styleAttr} data-dfc="${key}">`);
|
|
1212
2012
|
}
|
|
1213
|
-
buffer.write(`<template id="${key}">${value}</template>`);
|
|
1214
2013
|
} else {
|
|
1215
|
-
buffer.write(
|
|
2014
|
+
buffer.write(tpl);
|
|
1216
2015
|
if (!deferActivation) {
|
|
1217
2016
|
emitTask(`$df("${key}")`);
|
|
1218
2017
|
}
|
|
@@ -1224,6 +2023,8 @@ function renderToStream(code, options = {}) {
|
|
|
1224
2023
|
asset(type, value) {
|
|
1225
2024
|
if (type === "module") {
|
|
1226
2025
|
buffer.write(`<link rel="modulepreload" href="${value}"${nonceAttr(nonce, "script")}>`);
|
|
2026
|
+
} else if (type === "preload") {
|
|
2027
|
+
buffer.write(`<link${value.attrHtml}>`);
|
|
1227
2028
|
} else if (type === "inline-style") {
|
|
1228
2029
|
buffer.write(renderInlineStyle(value, nonce));
|
|
1229
2030
|
} else if (type === "head-tag") {
|
|
@@ -1231,16 +2032,16 @@ function renderToStream(code, options = {}) {
|
|
|
1231
2032
|
}
|
|
1232
2033
|
},
|
|
1233
2034
|
shell(shellHtml, meta) {
|
|
1234
|
-
buffer.write(assembleDocument(shellHtml, meta.preloads, meta.inlineStyles, meta.tasks.length ? meta.tasks : "", nonce, meta.head, onHead));
|
|
2035
|
+
buffer.write(withShellEnd(assembleDocument(shellHtml, meta.preloads, meta.preloadLinks, meta.inlineStyles, meta.tasks.length ? meta.tasks : "", nonce, meta.head, onHead), context, renderId, nonce, noScripts));
|
|
1235
2036
|
},
|
|
1236
2037
|
...options.sink
|
|
1237
2038
|
};
|
|
1238
|
-
|
|
2039
|
+
serializer = (options.serializer || createHydrationSerializer)({
|
|
1239
2040
|
scopeId: options.renderId,
|
|
1240
2041
|
plugins: options.plugins,
|
|
1241
2042
|
onData: payload => sink.data(payload),
|
|
1242
2043
|
onDone,
|
|
1243
|
-
onError:
|
|
2044
|
+
onError: err => reportFailure(err, "serialize")
|
|
1244
2045
|
});
|
|
1245
2046
|
let rootAssetsSerialized = false;
|
|
1246
2047
|
const serializeRootAssets = () => {
|
|
@@ -1250,7 +2051,7 @@ function renderToStream(code, options = {}) {
|
|
|
1250
2051
|
};
|
|
1251
2052
|
let holds = 0;
|
|
1252
2053
|
const flushEnd = () => {
|
|
1253
|
-
if (!registry.size && !holds) {
|
|
2054
|
+
if (!registry.size && !holds && !rootHoles) {
|
|
1254
2055
|
serializeRootAssets();
|
|
1255
2056
|
queue(() => queue(() => {
|
|
1256
2057
|
if (context.live.end) {
|
|
@@ -1259,11 +2060,103 @@ function renderToStream(code, options = {}) {
|
|
|
1259
2060
|
end();
|
|
1260
2061
|
}
|
|
1261
2062
|
flushStubBatch();
|
|
2063
|
+
flushParkedWrites();
|
|
1262
2064
|
serializer.flush();
|
|
1263
2065
|
}));
|
|
1264
2066
|
}
|
|
1265
2067
|
};
|
|
1266
2068
|
const registry = new Map();
|
|
2069
|
+
const pendingSerialized = new Map();
|
|
2070
|
+
const guardedChannels = new WeakMap();
|
|
2071
|
+
const verdictNow = error => {
|
|
2072
|
+
throw ssrSanitizeError(error, null, undefined, undefined, errorScope);
|
|
2073
|
+
};
|
|
2074
|
+
const borderForm = value => toBorderForm(value);
|
|
2075
|
+
const guardIterable = iterable => ({
|
|
2076
|
+
[Symbol.asyncIterator]() {
|
|
2077
|
+
const iterator = iterable[Symbol.asyncIterator]();
|
|
2078
|
+
return {
|
|
2079
|
+
next: value => iterator.next(value).then(undefined, verdictNow),
|
|
2080
|
+
return: value => iterator.return ? iterator.return(value) : Promise.resolve({
|
|
2081
|
+
done: true,
|
|
2082
|
+
value
|
|
2083
|
+
}),
|
|
2084
|
+
throw: error => iterator.throw ? iterator.throw(error) : Promise.reject(error)
|
|
2085
|
+
};
|
|
2086
|
+
}
|
|
2087
|
+
});
|
|
2088
|
+
const guardStream = source => {
|
|
2089
|
+
const reader = source.getReader();
|
|
2090
|
+
return new ReadableStream({
|
|
2091
|
+
pull: c => reader.read().then(r => r.done ? c.close() : c.enqueue(r.value), e => {
|
|
2092
|
+
try {
|
|
2093
|
+
verdictNow(e);
|
|
2094
|
+
} catch (sanitized) {
|
|
2095
|
+
c.error(sanitized);
|
|
2096
|
+
}
|
|
2097
|
+
}),
|
|
2098
|
+
cancel: reason => reader.cancel(reason)
|
|
2099
|
+
});
|
|
2100
|
+
};
|
|
2101
|
+
const guardChannel = p => {
|
|
2102
|
+
if (!p || typeof p !== "object" || "__SEROVAL_STREAM__" in p) return p;
|
|
2103
|
+
let guarded = guardedChannels.get(p);
|
|
2104
|
+
if (guarded !== undefined) return guarded;
|
|
2105
|
+
if (typeof p.then === "function") {
|
|
2106
|
+
guarded = p.then(borderForm, verdictNow);
|
|
2107
|
+
} else if (typeof ReadableStream === "function" && p instanceof ReadableStream) {
|
|
2108
|
+
guarded = guardStream(p);
|
|
2109
|
+
} else {
|
|
2110
|
+
const border = borderForm(p);
|
|
2111
|
+
guarded = typeof border[Symbol.asyncIterator] === "function" ? guardIterable(border) : border;
|
|
2112
|
+
if (guarded === p) return p;
|
|
2113
|
+
}
|
|
2114
|
+
guardedChannels.set(p, guarded);
|
|
2115
|
+
return guarded;
|
|
2116
|
+
};
|
|
2117
|
+
const trackSerialized = (id, p) => {
|
|
2118
|
+
let settle;
|
|
2119
|
+
const raced = Promise.race([p, new Promise(r => settle = r)]);
|
|
2120
|
+
raced.catch(() => {});
|
|
2121
|
+
pendingSerialized.set(id, settle);
|
|
2122
|
+
const drop = () => pendingSerialized.delete(id);
|
|
2123
|
+
p.then(drop, drop);
|
|
2124
|
+
return raced;
|
|
2125
|
+
};
|
|
2126
|
+
const abandonSubtree = (key, error) => {
|
|
2127
|
+
if (key == null) return;
|
|
2128
|
+
let fragments = 0;
|
|
2129
|
+
let serialized = 0;
|
|
2130
|
+
for (const [k, entry] of registry) {
|
|
2131
|
+
if (k != null && k.length > key.length && k.startsWith(key)) {
|
|
2132
|
+
registry.delete(k);
|
|
2133
|
+
entry.resolve();
|
|
2134
|
+
fragments++;
|
|
2135
|
+
}
|
|
2136
|
+
}
|
|
2137
|
+
const unregister = [];
|
|
2138
|
+
for (const [id, settle] of pendingSerialized) {
|
|
2139
|
+
if (id.startsWith(key)) {
|
|
2140
|
+
pendingSerialized.delete(id);
|
|
2141
|
+
settle();
|
|
2142
|
+
serialized++;
|
|
2143
|
+
if (!stubBatch?.delete(id)) unregister.push(`delete _$HY.r[${JSON.stringify(id)}]`);
|
|
2144
|
+
}
|
|
2145
|
+
}
|
|
2146
|
+
if (unregister.length && !options.sink) pushTask(unregister.join(";"));
|
|
2147
|
+
if ((fragments || serialized)) emitFinding({
|
|
2148
|
+
code: "SSR_SUBTREE_ABANDONED",
|
|
2149
|
+
kind: "ssr",
|
|
2150
|
+
severity: "warn",
|
|
2151
|
+
message: `[SSR_SUBTREE_ABANDONED] Fragment '${key}' failed with ${fragments} nested fragment(s) and ` + `${serialized} serialized value(s) still pending; the subtree was discarded and the client ` + `renders it from scratch.`,
|
|
2152
|
+
data: {
|
|
2153
|
+
fragment: key,
|
|
2154
|
+
fragments,
|
|
2155
|
+
serialized,
|
|
2156
|
+
error
|
|
2157
|
+
}
|
|
2158
|
+
}, null);
|
|
2159
|
+
};
|
|
1267
2160
|
const writeTasks = () => {
|
|
1268
2161
|
if (tasks.length && !completed && firstFlushed) {
|
|
1269
2162
|
buffer.write(`<script${nonceAttr(nonce, "script")}>${tasks}</script>`);
|
|
@@ -1305,6 +2198,12 @@ function renderToStream(code, options = {}) {
|
|
|
1305
2198
|
}
|
|
1306
2199
|
let rootHoles = null;
|
|
1307
2200
|
let nextHoleId = 0;
|
|
2201
|
+
let parkedInlines = null;
|
|
2202
|
+
function inlineFragment(key, value) {
|
|
2203
|
+
if (rootHoles && !html.includes(`<template id="pl-${key}">`)) {
|
|
2204
|
+
(parkedInlines ||= new Map()).set(key, value);
|
|
2205
|
+
} else html = replacePlaceholder(html, key, value);
|
|
2206
|
+
}
|
|
1308
2207
|
let buffer = {
|
|
1309
2208
|
write(payload) {
|
|
1310
2209
|
tmp += payload;
|
|
@@ -1318,9 +2217,11 @@ function renderToStream(code, options = {}) {
|
|
|
1318
2217
|
emitTask(`${!headScriptFlushed ? HEAD_SCRIPT : ""}(_$HY.hp=_$HY.hp||{})[${JSON.stringify(key)}]=${payload}`);
|
|
1319
2218
|
headScriptFlushed = true;
|
|
1320
2219
|
};
|
|
1321
|
-
|
|
2220
|
+
sharedConfig.context = context = {
|
|
1322
2221
|
async: true,
|
|
1323
2222
|
nonce: options.nonce,
|
|
2223
|
+
document: !options.sink,
|
|
2224
|
+
edges: !!options.plugins && options.plugins.some(p => p.tag === "solid/server-component"),
|
|
1324
2225
|
live: {},
|
|
1325
2226
|
registerHeadTags(tags) {
|
|
1326
2227
|
registerHeadTags(headRegistry, context, tracking,
|
|
@@ -1334,6 +2235,11 @@ function renderToStream(code, options = {}) {
|
|
|
1334
2235
|
}, nonce, tags);
|
|
1335
2236
|
},
|
|
1336
2237
|
registerAsset(type, value) {
|
|
2238
|
+
if (type === "preload") {
|
|
2239
|
+
const entry = registerPreloadLink(tracking, headRegistry, value, nonce);
|
|
2240
|
+
if (entry && firstFlushed) sink.asset("preload", entry);
|
|
2241
|
+
return;
|
|
2242
|
+
}
|
|
1337
2243
|
if (type === "inline-style") {
|
|
1338
2244
|
const entry = tracking.registerInlineStyle(value);
|
|
1339
2245
|
if (firstFlushed && !tracking.currentBoundaryId && !entry.emitted) {
|
|
@@ -1377,19 +2283,20 @@ function renderToStream(code, options = {}) {
|
|
|
1377
2283
|
html = html.slice(0, first) + resolveSSRSync(escape(payloadFn())) + html.slice(last + placeholder.length + 1);
|
|
1378
2284
|
},
|
|
1379
2285
|
serialize(id, p, deferStream) {
|
|
1380
|
-
|
|
1381
|
-
if (
|
|
1382
|
-
if (deferStream) {
|
|
2286
|
+
p = guardChannel(p);
|
|
2287
|
+
if (p && typeof p === "object" && typeof p.then === "function") {
|
|
2288
|
+
if (!firstFlushed && deferStream) {
|
|
1383
2289
|
blockingPromises.add(p);
|
|
1384
|
-
p.then(d =>
|
|
2290
|
+
p.then(d => write(id, d)).catch(e => write(id, e));
|
|
1385
2291
|
return;
|
|
1386
2292
|
}
|
|
1387
|
-
|
|
2293
|
+
p = trackSerialized(id, p);
|
|
2294
|
+
if (!firstFlushed && canBatchStubs && !shellCompleted && !dead) {
|
|
1388
2295
|
(stubBatch ||= new Map()).set(id, p);
|
|
1389
2296
|
return;
|
|
1390
2297
|
}
|
|
1391
2298
|
}
|
|
1392
|
-
|
|
2299
|
+
write(id, p);
|
|
1393
2300
|
},
|
|
1394
2301
|
escape: escape,
|
|
1395
2302
|
resolve: resolveSSRNode,
|
|
@@ -1417,19 +2324,26 @@ function renderToStream(code, options = {}) {
|
|
|
1417
2324
|
if (!registry.has(key)) {
|
|
1418
2325
|
let resolve, reject;
|
|
1419
2326
|
const p = new Promise((r, rej) => (resolve = r, reject = rej));
|
|
2327
|
+
defuse(p);
|
|
1420
2328
|
registry.set(key, {
|
|
1421
2329
|
resolve: err => queue(() => queue(() => {
|
|
1422
|
-
err ? reject(err) : resolve(true);
|
|
2330
|
+
err ? reject(ssrSanitizeError(err, null, undefined, undefined, errorScope)) : resolve(true);
|
|
1423
2331
|
queue(flushEnd);
|
|
1424
2332
|
}))
|
|
1425
2333
|
});
|
|
1426
|
-
if (canBatchStubs && !shellCompleted) (stubBatch ||= new Map()).set(key + "_fr", p);else
|
|
2334
|
+
if (canBatchStubs && !shellCompleted && !dead) (stubBatch ||= new Map()).set(key + "_fr", p);else write(key + "_fr", p);
|
|
1427
2335
|
}
|
|
1428
|
-
return (value, error) => {
|
|
2336
|
+
return (value, error, escaped) => {
|
|
1429
2337
|
if (registry.has(key)) {
|
|
1430
2338
|
const item = registry.get(key);
|
|
1431
2339
|
registry.delete(key);
|
|
1432
|
-
if (
|
|
2340
|
+
if (error) abandonSubtree(key, error);
|
|
2341
|
+
if (error && escaped) {
|
|
2342
|
+
const wire = ssrSanitizeError(error, null, undefined, undefined, errorScope);
|
|
2343
|
+
const message = wire instanceof Error ? wire.message : String(wire);
|
|
2344
|
+
if (sink.error) sink.error("", message);else if (context.live && context.live.error) context.live.error(escaped.frame, message);
|
|
2345
|
+
}
|
|
2346
|
+
if (item.children && !error) {
|
|
1433
2347
|
for (const k in item.children) {
|
|
1434
2348
|
value = replacePlaceholder(value, k, item.children[k]);
|
|
1435
2349
|
}
|
|
@@ -1448,7 +2362,7 @@ function renderToStream(code, options = {}) {
|
|
|
1448
2362
|
if (!completed) {
|
|
1449
2363
|
if (error) dropHeadBoundary(headRegistry, key);
|
|
1450
2364
|
if (!firstFlushed) {
|
|
1451
|
-
queue(() =>
|
|
2365
|
+
queue(() => inlineFragment(key, value !== undefined ? value : ""));
|
|
1452
2366
|
serializeFragmentAssets(key, tracking.boundaryModules, context);
|
|
1453
2367
|
item.resolve(error);
|
|
1454
2368
|
} else {
|
|
@@ -1456,10 +2370,10 @@ function renderToStream(code, options = {}) {
|
|
|
1456
2370
|
const styles = collectStreamStyles(key, tracking, headStyles);
|
|
1457
2371
|
const headOps = error ? null : flushHeadFragment(headRegistry, key, nonce);
|
|
1458
2372
|
if (headOps) emitHeadOps(key, headOps);
|
|
1459
|
-
sink.fragment(key, resolveSSRSelectValues(value !== undefined ? value : " "), {
|
|
2373
|
+
sink.fragment(key, resolveSSRSelectValues(value !== undefined ? value : error ? "" : " "), {
|
|
1460
2374
|
styles,
|
|
1461
2375
|
revealGroup,
|
|
1462
|
-
error
|
|
2376
|
+
error: error ? ssrSanitizeError(error, null, undefined, undefined, errorScope) : error
|
|
1463
2377
|
});
|
|
1464
2378
|
item.resolve(error);
|
|
1465
2379
|
}
|
|
@@ -1485,26 +2399,66 @@ function renderToStream(code, options = {}) {
|
|
|
1485
2399
|
};
|
|
1486
2400
|
applyAssetTracking(context, tracking, manifest, noScripts);
|
|
1487
2401
|
context.failRender = failRender;
|
|
2402
|
+
context.errorPolicy = options.onError;
|
|
2403
|
+
context._errorScope = errorScope;
|
|
2404
|
+
context.flushed = () => firstFlushed;
|
|
2405
|
+
context.trace = requestEvent ? traceForEvent(requestEvent) : traceFor(context, undefined);
|
|
2406
|
+
render = timeDocument(context, context.trace, "stream", requestEvent);
|
|
1488
2407
|
registerEntryAssets(manifest);
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
2408
|
+
context.writer = createHydrationWriter(context, () => !completed);
|
|
2409
|
+
const signal = options.signal;
|
|
2410
|
+
const onAbort = signal ? () => abandon("signal", !!(signal.reason && signal.reason.quiet === true)) : undefined;
|
|
2411
|
+
const endEdges = context.edges ? beginEdgesRender() : undefined;
|
|
2412
|
+
let html;
|
|
2413
|
+
try {
|
|
2414
|
+
html = createRoot(d => {
|
|
2415
|
+
dispose = () => {
|
|
2416
|
+
context.trace = undefined;
|
|
2417
|
+
if (onAbort) signal.removeEventListener("abort", onAbort);
|
|
2418
|
+
if (endEdges) endEdges();
|
|
2419
|
+
try {
|
|
2420
|
+
d();
|
|
2421
|
+
} catch (err) {
|
|
2422
|
+
reportFailure(err, "failed");
|
|
2423
|
+
}
|
|
2424
|
+
};
|
|
2425
|
+
rootOwner = claimRenderRoot(context);
|
|
2426
|
+
if (requestEvent) claimEventRender(requestEvent, context);
|
|
2427
|
+
let res;
|
|
2428
|
+
try {
|
|
2429
|
+
res = resolveSSRNode(escape(code()));
|
|
2430
|
+
} catch (err) {
|
|
2431
|
+
reportServerError(err, {
|
|
2432
|
+
kind: "render",
|
|
2433
|
+
handling: "failed"
|
|
2434
|
+
}, null, options.onError, errorScope);
|
|
2435
|
+
throw err;
|
|
2436
|
+
}
|
|
2437
|
+
if (!res.h.length) return res.t[0];
|
|
2438
|
+
rootHoles = [];
|
|
2439
|
+
let out = res.t[0];
|
|
2440
|
+
for (let i = 0; i < res.h.length; i++) {
|
|
2441
|
+
const id = nextHoleId++;
|
|
2442
|
+
rootHoles.push({
|
|
2443
|
+
id,
|
|
2444
|
+
fn: res.h[i]
|
|
2445
|
+
});
|
|
2446
|
+
out += `<!--rh${id}-->` + res.t[i + 1];
|
|
2447
|
+
}
|
|
2448
|
+
for (const p of res.p) blockingPromises.add(p);
|
|
2449
|
+
return out;
|
|
2450
|
+
}, {
|
|
2451
|
+
id: renderId
|
|
2452
|
+
});
|
|
2453
|
+
} catch (err) {
|
|
2454
|
+
if (endEdges) endEdges();
|
|
2455
|
+
throw err;
|
|
2456
|
+
}
|
|
2457
|
+
if (onAbort) {
|
|
2458
|
+
if (signal.aborted) onAbort();else signal.addEventListener("abort", onAbort, {
|
|
2459
|
+
once: true
|
|
2460
|
+
});
|
|
2461
|
+
}
|
|
1508
2462
|
function resolveRootHoles() {
|
|
1509
2463
|
if (!rootHoles) return true;
|
|
1510
2464
|
const pending = [];
|
|
@@ -1530,6 +2484,13 @@ function renderToStream(code, options = {}) {
|
|
|
1530
2484
|
for (const p of res.p) blockingPromises.add(p);
|
|
1531
2485
|
}
|
|
1532
2486
|
}
|
|
2487
|
+
if (parkedInlines) {
|
|
2488
|
+
for (const [key, value] of parkedInlines) {
|
|
2489
|
+
if (!html.includes(`<template id="pl-${key}">`)) continue;
|
|
2490
|
+
html = replacePlaceholder(html, key, value);
|
|
2491
|
+
parkedInlines.delete(key);
|
|
2492
|
+
}
|
|
2493
|
+
}
|
|
1533
2494
|
if (pending.length) {
|
|
1534
2495
|
rootHoles = pending;
|
|
1535
2496
|
return false;
|
|
@@ -1539,10 +2500,10 @@ function renderToStream(code, options = {}) {
|
|
|
1539
2500
|
}
|
|
1540
2501
|
function doShell() {
|
|
1541
2502
|
if (shellCompleted) return;
|
|
1542
|
-
|
|
1543
|
-
|
|
2503
|
+
sharedConfig.context = context;
|
|
2504
|
+
if (blockingPromises.size !== lastBlockingSize) return;
|
|
1544
2505
|
if (!resolveRootHoles()) return;
|
|
1545
|
-
if (blockingPromises.size !==
|
|
2506
|
+
if (blockingPromises.size !== lastBlockingSize) return;
|
|
1546
2507
|
if (!headShellReady(headRegistry, p => blockingPromises.add(p))) return;
|
|
1547
2508
|
headStyles = new Set();
|
|
1548
2509
|
for (const url of tracking.emittedAssets) {
|
|
@@ -1550,9 +2511,11 @@ function renderToStream(code, options = {}) {
|
|
|
1550
2511
|
}
|
|
1551
2512
|
serializeRootAssets();
|
|
1552
2513
|
flushStubBatch();
|
|
1553
|
-
const head = renderShellHead(headRegistry, nonce, k => registry.has(k), noScripts);
|
|
2514
|
+
const head = renderShellHead(headRegistry, nonce, k => registry.has(k), noScripts, traceMetaMarkup(context.trace));
|
|
2515
|
+
if (render) render.shell();
|
|
1554
2516
|
sink.shell(resolveSSRSelectValues(html), {
|
|
1555
2517
|
preloads: tracking.emittedAssets,
|
|
2518
|
+
preloadLinks: tracking.preloadLinks,
|
|
1556
2519
|
inlineStyles: tracking.inlineStyles,
|
|
1557
2520
|
tasks,
|
|
1558
2521
|
head
|
|
@@ -1569,21 +2532,30 @@ function renderToStream(code, options = {}) {
|
|
|
1569
2532
|
let lastBlockingSize = -1;
|
|
1570
2533
|
let lastRegistrySize = -1;
|
|
1571
2534
|
let drainTurn = 0;
|
|
1572
|
-
|
|
2535
|
+
let graced = false;
|
|
2536
|
+
const scheduleFlush = (fn, awaited) => {
|
|
1573
2537
|
const attempt = () => {
|
|
1574
|
-
flushStubBatch();
|
|
2538
|
+
if (!stableOrder) flushStubBatch();
|
|
1575
2539
|
if (registry.size !== lastRegistrySize || drainTurn++ < MIN_DRAIN_TURNS) {
|
|
1576
2540
|
if (registry.size !== lastRegistrySize) drainTurn = 0;
|
|
1577
2541
|
lastRegistrySize = registry.size;
|
|
1578
2542
|
queue(attempt);
|
|
1579
2543
|
return;
|
|
1580
2544
|
}
|
|
2545
|
+
if (!graced && registry.size) {
|
|
2546
|
+
graced = true;
|
|
2547
|
+
lastRegistrySize = -1;
|
|
2548
|
+
drainTurn = 0;
|
|
2549
|
+
deferFlush(attempt);
|
|
2550
|
+
return;
|
|
2551
|
+
}
|
|
1581
2552
|
fn();
|
|
1582
2553
|
};
|
|
1583
|
-
const progressed =
|
|
1584
|
-
lastBlockingSize =
|
|
2554
|
+
const progressed = awaited !== lastBlockingSize;
|
|
2555
|
+
lastBlockingSize = awaited;
|
|
1585
2556
|
lastRegistrySize = -1;
|
|
1586
2557
|
drainTurn = 0;
|
|
2558
|
+
graced = false;
|
|
1587
2559
|
progressed ? queue(attempt) : setTimeout(attempt);
|
|
1588
2560
|
};
|
|
1589
2561
|
let cachedReadable;
|
|
@@ -1597,15 +2569,21 @@ function renderToStream(code, options = {}) {
|
|
|
1597
2569
|
const pipeToImpl = w => {
|
|
1598
2570
|
let resolve;
|
|
1599
2571
|
const p = new Promise(r => resolve = r);
|
|
2572
|
+
onFailure(sink => {
|
|
2573
|
+
try {
|
|
2574
|
+
if (sink) sink.end();else w.close().catch(() => {});
|
|
2575
|
+
} catch (_) {}
|
|
2576
|
+
resolve();
|
|
2577
|
+
});
|
|
1600
2578
|
function flush() {
|
|
1601
|
-
allSettled(blockingPromises).then(
|
|
2579
|
+
allSettled(blockingPromises).then(awaited => {
|
|
1602
2580
|
scheduleFlush(() => {
|
|
1603
2581
|
if (dead) return resolve();
|
|
1604
2582
|
try {
|
|
1605
2583
|
doShell();
|
|
1606
2584
|
} catch (err) {
|
|
1607
|
-
|
|
1608
|
-
return
|
|
2585
|
+
failRootRender(err);
|
|
2586
|
+
return;
|
|
1609
2587
|
}
|
|
1610
2588
|
if (!shellCompleted) return flush();
|
|
1611
2589
|
const encoder = new TextEncoder();
|
|
@@ -1614,7 +2592,7 @@ function renderToStream(code, options = {}) {
|
|
|
1614
2592
|
let ended = false;
|
|
1615
2593
|
const failed = () => {
|
|
1616
2594
|
if (!ended) {
|
|
1617
|
-
abandon();
|
|
2595
|
+
abandon("consumer");
|
|
1618
2596
|
resolve();
|
|
1619
2597
|
}
|
|
1620
2598
|
};
|
|
@@ -1636,7 +2614,7 @@ function renderToStream(code, options = {}) {
|
|
|
1636
2614
|
dispose();
|
|
1637
2615
|
writable.end();
|
|
1638
2616
|
} else flushEnd();
|
|
1639
|
-
});
|
|
2617
|
+
}, awaited);
|
|
1640
2618
|
});
|
|
1641
2619
|
}
|
|
1642
2620
|
flush();
|
|
@@ -1644,8 +2622,15 @@ function renderToStream(code, options = {}) {
|
|
|
1644
2622
|
};
|
|
1645
2623
|
return {
|
|
1646
2624
|
then(onFulfilled, onRejected) {
|
|
2625
|
+
if (canBatchStubs) stableOrder = true;
|
|
2626
|
+
const freezeHead = () => {
|
|
2627
|
+
if (requestEvent && requestEvent.response) commitResponseStub(requestEvent.response, {
|
|
2628
|
+
event: requestEvent
|
|
2629
|
+
});
|
|
2630
|
+
};
|
|
1647
2631
|
const p = new Promise(resolve => {
|
|
1648
2632
|
function complete() {
|
|
2633
|
+
freezeHead();
|
|
1649
2634
|
dispose();
|
|
1650
2635
|
resolve(tmp);
|
|
1651
2636
|
}
|
|
@@ -1656,18 +2641,19 @@ function renderToStream(code, options = {}) {
|
|
|
1656
2641
|
complete();
|
|
1657
2642
|
};
|
|
1658
2643
|
} else onCompleteAll = complete;
|
|
2644
|
+
onFailure(() => resolve(tmp));
|
|
1659
2645
|
function flush() {
|
|
1660
|
-
allSettled(blockingPromises).then(
|
|
2646
|
+
allSettled(blockingPromises).then(awaited => {
|
|
1661
2647
|
scheduleFlush(() => {
|
|
2648
|
+
if (dead) return;
|
|
1662
2649
|
try {
|
|
1663
|
-
|
|
1664
|
-
if (!resolveRootHoles() || blockingPromises.size !== blockersBefore || !headShellReady(headRegistry, p => blockingPromises.add(p))) return flush();
|
|
2650
|
+
if (blockingPromises.size !== lastBlockingSize || !resolveRootHoles() || blockingPromises.size !== lastBlockingSize || !headShellReady(headRegistry, p => blockingPromises.add(p))) return flush();
|
|
1665
2651
|
} catch (err) {
|
|
1666
|
-
|
|
1667
|
-
return
|
|
2652
|
+
failRootRender(err);
|
|
2653
|
+
return;
|
|
1668
2654
|
}
|
|
1669
2655
|
queue(flushEnd);
|
|
1670
|
-
});
|
|
2656
|
+
}, awaited);
|
|
1671
2657
|
});
|
|
1672
2658
|
}
|
|
1673
2659
|
flush();
|
|
@@ -1676,17 +2662,24 @@ function renderToStream(code, options = {}) {
|
|
|
1676
2662
|
},
|
|
1677
2663
|
pipe(w) {
|
|
1678
2664
|
claimConsumer("pipe");
|
|
2665
|
+
const abandoned = w[SHELL_ABANDONED];
|
|
2666
|
+
onFailure(sink => {
|
|
2667
|
+
try {
|
|
2668
|
+
sink ? sink.end() : abandoned ? abandoned() : w.end();
|
|
2669
|
+
} catch (_) {}
|
|
2670
|
+
});
|
|
2671
|
+
if (abandoned) {
|
|
2672
|
+
w[ABANDON_RENDER] = abandon;
|
|
2673
|
+
if (disconnected) abandoned();else onDisconnectedBeforeShell = abandoned;
|
|
2674
|
+
}
|
|
1679
2675
|
function flush() {
|
|
1680
|
-
allSettled(blockingPromises).then(
|
|
2676
|
+
allSettled(blockingPromises).then(awaited => {
|
|
1681
2677
|
scheduleFlush(() => {
|
|
1682
2678
|
if (dead) return;
|
|
1683
2679
|
try {
|
|
1684
2680
|
doShell();
|
|
1685
2681
|
} catch (err) {
|
|
1686
|
-
|
|
1687
|
-
try {
|
|
1688
|
-
w.end();
|
|
1689
|
-
} catch (_) {}
|
|
2682
|
+
failRootRender(err);
|
|
1690
2683
|
return;
|
|
1691
2684
|
}
|
|
1692
2685
|
if (!shellCompleted) return flush();
|
|
@@ -1699,7 +2692,7 @@ function renderToStream(code, options = {}) {
|
|
|
1699
2692
|
dispose();
|
|
1700
2693
|
writable.end();
|
|
1701
2694
|
} else flushEnd();
|
|
1702
|
-
});
|
|
2695
|
+
}, awaited);
|
|
1703
2696
|
});
|
|
1704
2697
|
}
|
|
1705
2698
|
flush();
|
|
@@ -1720,25 +2713,29 @@ function renderToStream(code, options = {}) {
|
|
|
1720
2713
|
};
|
|
1721
2714
|
}
|
|
1722
2715
|
function HydrationScript(props) {
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
2716
|
+
if (sharedConfig.context) sharedConfig.context.bootstrap = true;
|
|
2717
|
+
const {
|
|
2718
|
+
eventNames,
|
|
2719
|
+
nonce
|
|
2720
|
+
} = {
|
|
2721
|
+
nonce: sharedConfig.context && sharedConfig.context.nonce,
|
|
1726
2722
|
...props
|
|
1727
|
-
}
|
|
2723
|
+
};
|
|
2724
|
+
return ssr(hydrationBootstrap(eventNames, destinationNonce(nonce, "script"), true));
|
|
1728
2725
|
}
|
|
1729
2726
|
function ssrGroup(fn, n) {
|
|
1730
2727
|
fn.$g = n;
|
|
1731
2728
|
return fn;
|
|
1732
2729
|
}
|
|
1733
2730
|
function buildAsyncWrap(err, node) {
|
|
1734
|
-
const p =
|
|
2731
|
+
const p = ssrHandleError(err);
|
|
1735
2732
|
if (!p) return null;
|
|
1736
2733
|
if (node.$rw) return {
|
|
1737
2734
|
fn: node,
|
|
1738
2735
|
p
|
|
1739
2736
|
};
|
|
1740
|
-
const owner =
|
|
1741
|
-
const live =
|
|
2737
|
+
const owner = getOwner();
|
|
2738
|
+
const live = sharedConfig.context && sharedConfig.context.liveHoles;
|
|
1742
2739
|
const suppress = node.$lhSuppress || live && (live.suppressed || live.sweeping);
|
|
1743
2740
|
if (!owner) {
|
|
1744
2741
|
if (suppress) node.$lhSuppress = true;
|
|
@@ -1747,7 +2744,7 @@ function buildAsyncWrap(err, node) {
|
|
|
1747
2744
|
p
|
|
1748
2745
|
};
|
|
1749
2746
|
}
|
|
1750
|
-
const fn = () =>
|
|
2747
|
+
const fn = () => runWithOwner(owner, node);
|
|
1751
2748
|
fn.$rw = true;
|
|
1752
2749
|
if (suppress) fn.$lhSuppress = true;
|
|
1753
2750
|
if (node.$lhSkip) fn.$lhSkip = true;
|
|
@@ -1813,6 +2810,10 @@ function ssrGroupSlot(fn, idx) {
|
|
|
1813
2810
|
}
|
|
1814
2811
|
};
|
|
1815
2812
|
}
|
|
2813
|
+
function wireErrorMessage(err, scope) {
|
|
2814
|
+
const wire = ssrSanitizeError(err, null, undefined, undefined, scope);
|
|
2815
|
+
return String(wire && wire.message || wire);
|
|
2816
|
+
}
|
|
1816
2817
|
const holePositionCache = new WeakMap();
|
|
1817
2818
|
function holeContentPositions(t) {
|
|
1818
2819
|
let cached = holePositionCache.get(t);
|
|
@@ -1872,19 +2873,86 @@ function holeContentPositions(t) {
|
|
|
1872
2873
|
holePositionCache.set(t, cached);
|
|
1873
2874
|
return cached;
|
|
1874
2875
|
}
|
|
1875
|
-
function createLiveHoles(sink, scoped) {
|
|
2876
|
+
function createLiveHoles(sink, scoped, settled, errorScope) {
|
|
1876
2877
|
let nextId = 0;
|
|
1877
|
-
const stamp = typeof
|
|
1878
|
-
const inScope = scoped && typeof
|
|
1879
|
-
const stripMarkers = html => html.replace(/<!--lh:\/?\d
|
|
2878
|
+
const stamp = typeof creationStamp === "function" ? creationStamp : () => 0;
|
|
2879
|
+
const inScope = scoped && typeof inServerComponentScope === "function" ? inServerComponentScope : null;
|
|
2880
|
+
const stripMarkers = html => html.replace(/<!--lh:\/?\d+-->| data-lha="\d+"/g, "");
|
|
2881
|
+
const swept = (owner, ctx, fn) => {
|
|
2882
|
+
const prev = sharedConfig.context;
|
|
2883
|
+
sharedConfig.context = ctx;
|
|
2884
|
+
let dispose;
|
|
2885
|
+
let before;
|
|
2886
|
+
const run = () => createRoot(d => {
|
|
2887
|
+
dispose = d;
|
|
2888
|
+
before = stamp();
|
|
2889
|
+
return fn();
|
|
2890
|
+
}, {
|
|
2891
|
+
transparent: true
|
|
2892
|
+
});
|
|
2893
|
+
try {
|
|
2894
|
+
return owner ? runWithOwner(owner, run) : run();
|
|
2895
|
+
} finally {
|
|
2896
|
+
sharedConfig.context = prev;
|
|
2897
|
+
engine.sweptOwners = before !== undefined && stamp() !== before;
|
|
2898
|
+
if (dispose) dispose();
|
|
2899
|
+
}
|
|
2900
|
+
};
|
|
2901
|
+
const stripRow = html => html.replace(/<!--lh:\/?\d+-->| data-lha="\d+"|<!--lr-->/g, "");
|
|
2902
|
+
const rowsOf = v => Array.isArray(v) && v.$rows ? v : null;
|
|
2903
|
+
function holeValue(hole) {
|
|
2904
|
+
const b = hole.$lhBinding;
|
|
2905
|
+
if (b) {
|
|
2906
|
+
const v = hole();
|
|
2907
|
+
return b.fn && rowsOf(b.fn()) || v;
|
|
2908
|
+
}
|
|
2909
|
+
if (!hole.$fn) return hole();
|
|
2910
|
+
const v = hole.$fn();
|
|
2911
|
+
return rowsOf(v) || escape(v);
|
|
2912
|
+
}
|
|
2913
|
+
function resolveValue(value, res) {
|
|
2914
|
+
if (!Array.isArray(value) || !value.$rows) {
|
|
2915
|
+
resolveSSRNode(value, res);
|
|
2916
|
+
return null;
|
|
2917
|
+
}
|
|
2918
|
+
let rows = [];
|
|
2919
|
+
for (const row of value) {
|
|
2920
|
+
const r = resolveSSRNode(escape(row));
|
|
2921
|
+
res.t[res.t.length - 1] += "<!--lr-->" + r.t[0];
|
|
2922
|
+
if (r.h.length) {
|
|
2923
|
+
res.t.push(...r.t.slice(1));
|
|
2924
|
+
res.h.push(...r.h);
|
|
2925
|
+
res.p.push(...r.p);
|
|
2926
|
+
rows = null;
|
|
2927
|
+
} else if (rows) rows.push(engine.sweeping ? r.t[0] : stripRow(r.t[0]));
|
|
2928
|
+
}
|
|
2929
|
+
return rows;
|
|
2930
|
+
}
|
|
2931
|
+
function rowOps(last, rows) {
|
|
2932
|
+
const ops = [];
|
|
2933
|
+
const html = [];
|
|
2934
|
+
for (let i = 0; i < rows.length; i++) if (i >= last.length || rows[i] !== last[i]) {
|
|
2935
|
+
const patch = i < last.length ? rowPatch(last[i], rows[i]) : null;
|
|
2936
|
+
ops.push(patch ? [i, patch.p] : [i, rows[i]]);
|
|
2937
|
+
html.push(rows[i]);
|
|
2938
|
+
}
|
|
2939
|
+
if (ops.length >= rows.length) return null;
|
|
2940
|
+
return Object.defineProperty({
|
|
2941
|
+
n: rows.length,
|
|
2942
|
+
r: ops
|
|
2943
|
+
}, ROW_HTML, {
|
|
2944
|
+
value: html
|
|
2945
|
+
});
|
|
2946
|
+
}
|
|
1880
2947
|
function resolveHoleValue(hole) {
|
|
1881
2948
|
const result = {
|
|
1882
2949
|
t: [""],
|
|
1883
2950
|
h: [],
|
|
1884
|
-
p: []
|
|
2951
|
+
p: [],
|
|
2952
|
+
rows: null
|
|
1885
2953
|
};
|
|
1886
2954
|
try {
|
|
1887
|
-
|
|
2955
|
+
result.rows = resolveValue(holeValue(hole), result);
|
|
1888
2956
|
} catch (err) {
|
|
1889
2957
|
const wrap = buildAsyncWrap(err, hole);
|
|
1890
2958
|
if (!wrap) throw err;
|
|
@@ -1902,12 +2970,88 @@ function createLiveHoles(sink, scoped) {
|
|
|
1902
2970
|
}
|
|
1903
2971
|
b.children.length = 0;
|
|
1904
2972
|
}
|
|
2973
|
+
let tops = 0;
|
|
2974
|
+
const ids = new Map();
|
|
2975
|
+
const scopeFor = hole => {
|
|
2976
|
+
const p = engine.scope;
|
|
2977
|
+
return {
|
|
2978
|
+
id: undefined,
|
|
2979
|
+
p,
|
|
2980
|
+
i: p ? p.c++ : tops++,
|
|
2981
|
+
n: null,
|
|
2982
|
+
c: 0,
|
|
2983
|
+
h: hole
|
|
2984
|
+
};
|
|
2985
|
+
};
|
|
2986
|
+
const scopeId = s => s.id !== undefined ? s.id : s.id = s.p ? scopeId(s.p) + "." + s.i : String(s.i);
|
|
2987
|
+
const collect = (v, id, forget) => (v.occ || (v.occ = new Map())).set(id, forget);
|
|
2988
|
+
function rescope(b, hole, fn) {
|
|
2989
|
+
const prevScope = engine.scope;
|
|
2990
|
+
const prevVisit = engine.visit;
|
|
2991
|
+
engine.scope = {
|
|
2992
|
+
id: scopeId(b.scope),
|
|
2993
|
+
p: null,
|
|
2994
|
+
i: 0,
|
|
2995
|
+
n: null,
|
|
2996
|
+
c: 0,
|
|
2997
|
+
h: hole
|
|
2998
|
+
};
|
|
2999
|
+
const visit = engine.visit = {
|
|
3000
|
+
occ: null
|
|
3001
|
+
};
|
|
3002
|
+
try {
|
|
3003
|
+
return fn();
|
|
3004
|
+
} finally {
|
|
3005
|
+
engine.scope = prevScope;
|
|
3006
|
+
engine.visit = prevVisit;
|
|
3007
|
+
b.next = visit.occ;
|
|
3008
|
+
}
|
|
3009
|
+
}
|
|
3010
|
+
function settleOccurrences(b) {
|
|
3011
|
+
const occ = b.next;
|
|
3012
|
+
b.next = null;
|
|
3013
|
+
if (b.occ) for (const [id, forget] of b.occ) if (!occ || !occ.has(id)) forget();
|
|
3014
|
+
b.occ = occ;
|
|
3015
|
+
if (occ) for (let a = b.up; a; a = a.up) for (const [id, forget] of occ) collect(a, id, forget);
|
|
3016
|
+
}
|
|
3017
|
+
function leave(b, parent, scope, visit) {
|
|
3018
|
+
engine.parent = parent;
|
|
3019
|
+
engine.scope = scope;
|
|
3020
|
+
engine.visit = visit;
|
|
3021
|
+
if (visit && b.occ) for (const [id, forget] of b.occ) collect(visit, id, forget);
|
|
3022
|
+
}
|
|
1905
3023
|
const engine = {
|
|
1906
3024
|
suppressed: 0,
|
|
1907
3025
|
sweeping: false,
|
|
1908
3026
|
parent: null,
|
|
1909
|
-
recordStamp: 0,
|
|
1910
3027
|
gateHit: false,
|
|
3028
|
+
sweptOwners: false,
|
|
3029
|
+
scope: null,
|
|
3030
|
+
visit: null,
|
|
3031
|
+
dry: false,
|
|
3032
|
+
slotId(prop, given) {
|
|
3033
|
+
const s = engine.scope;
|
|
3034
|
+
if (!s) return given;
|
|
3035
|
+
const n = s.n || (s.n = Object.create(null));
|
|
3036
|
+
const i = n[prop] || 0;
|
|
3037
|
+
n[prop] = i + 1;
|
|
3038
|
+
const sid = scopeId(s);
|
|
3039
|
+
const at = sid + "." + i + "\0" + prop;
|
|
3040
|
+
if (given !== undefined) {
|
|
3041
|
+
ids.set(at, given);
|
|
3042
|
+
return given;
|
|
3043
|
+
}
|
|
3044
|
+
return ids.get(at) || `${prop}#~${sid}.${i}`;
|
|
3045
|
+
},
|
|
3046
|
+
seen(id, forget) {
|
|
3047
|
+
if (engine.visit) collect(engine.visit, id, forget);
|
|
3048
|
+
},
|
|
3049
|
+
nest(hole) {
|
|
3050
|
+
const s = engine.scope;
|
|
3051
|
+
if (!s || s.h === hole || hole.$lhSkip || inScope && !inScope()) return undefined;
|
|
3052
|
+
engine.scope = scopeFor(hole);
|
|
3053
|
+
return s;
|
|
3054
|
+
},
|
|
1911
3055
|
content(hole) {
|
|
1912
3056
|
if (hole.$lhSuppress) {
|
|
1913
3057
|
const r = {
|
|
@@ -1915,10 +3059,12 @@ function createLiveHoles(sink, scoped) {
|
|
|
1915
3059
|
h: [],
|
|
1916
3060
|
p: []
|
|
1917
3061
|
};
|
|
1918
|
-
|
|
1919
|
-
|
|
3062
|
+
let rows = null;
|
|
3063
|
+
const b = hole.$lhBinding;
|
|
3064
|
+
const run = () => {
|
|
3065
|
+
engine.suppressed++;
|
|
1920
3066
|
try {
|
|
1921
|
-
|
|
3067
|
+
rows = resolveValue(holeValue(hole), r);
|
|
1922
3068
|
} catch (err) {
|
|
1923
3069
|
const wrap = buildAsyncWrap(err, hole);
|
|
1924
3070
|
if (wrap) {
|
|
@@ -1926,45 +3072,53 @@ function createLiveHoles(sink, scoped) {
|
|
|
1926
3072
|
r.p.push(wrap.p);
|
|
1927
3073
|
r.t.push("");
|
|
1928
3074
|
}
|
|
3075
|
+
} finally {
|
|
3076
|
+
engine.suppressed--;
|
|
1929
3077
|
}
|
|
1930
|
-
}
|
|
1931
|
-
|
|
1932
|
-
}
|
|
1933
|
-
const b = hole.$lhBinding;
|
|
3078
|
+
};
|
|
3079
|
+
b && !engine.sweeping ? rescope(b, hole, run) : run();
|
|
1934
3080
|
if (b && !b.closed && !r.h.length && !engine.sweeping) {
|
|
1935
3081
|
b.last = stripMarkers(r.t[0]);
|
|
3082
|
+
b.rows = rows;
|
|
3083
|
+
settleOccurrences(b);
|
|
1936
3084
|
}
|
|
1937
3085
|
return r.h.length ? r : r.t[0];
|
|
1938
3086
|
}
|
|
1939
3087
|
if (engine.suppressed || engine.sweeping) return null;
|
|
1940
3088
|
if (hole.$lhSkip) return null;
|
|
1941
3089
|
if (inScope && !inScope()) return null;
|
|
1942
|
-
const recordsBefore = engine.recordStamp;
|
|
1943
3090
|
const ownersBefore = stamp();
|
|
1944
|
-
const owner =
|
|
3091
|
+
const owner = getOwner();
|
|
3092
|
+
const holeCtx = sharedConfig.context;
|
|
1945
3093
|
const b = {
|
|
1946
3094
|
key: null,
|
|
1947
3095
|
children: [],
|
|
1948
3096
|
last: null,
|
|
3097
|
+
rows: null,
|
|
3098
|
+
fn: hole.$fn,
|
|
1949
3099
|
closed: false,
|
|
3100
|
+
scope: undefined,
|
|
3101
|
+
occ: null,
|
|
3102
|
+
next: null,
|
|
3103
|
+
up: engine.parent,
|
|
1950
3104
|
sweep() {
|
|
1951
3105
|
if (b.closed) return;
|
|
1952
3106
|
const prevSweeping = engine.sweeping;
|
|
1953
3107
|
engine.sweeping = true;
|
|
1954
|
-
engine.
|
|
1955
|
-
const sweepOwnersBefore = stamp();
|
|
3108
|
+
engine.dry = b.last === null;
|
|
1956
3109
|
let res;
|
|
1957
3110
|
try {
|
|
1958
|
-
res =
|
|
3111
|
+
res = rescope(b, hole, () => swept(owner, holeCtx, () => resolveHoleValue(hole)));
|
|
1959
3112
|
} catch (err) {
|
|
1960
3113
|
b.closed = true;
|
|
1961
3114
|
sink.closeBinding(b.key);
|
|
1962
|
-
sink.error(b.key,
|
|
3115
|
+
sink.error(b.key, wireErrorMessage(err, errorScope));
|
|
1963
3116
|
return;
|
|
1964
3117
|
} finally {
|
|
1965
3118
|
engine.sweeping = prevSweeping;
|
|
3119
|
+
engine.dry = false;
|
|
1966
3120
|
}
|
|
1967
|
-
if (engine.
|
|
3121
|
+
if (engine.sweptOwners && res.h.length) {
|
|
1968
3122
|
b.closed = true;
|
|
1969
3123
|
sink.closeBinding(b.key);
|
|
1970
3124
|
return;
|
|
@@ -1972,29 +3126,38 @@ function createLiveHoles(sink, scoped) {
|
|
|
1972
3126
|
if (res.h.length) return;
|
|
1973
3127
|
const html = res.t[0];
|
|
1974
3128
|
if (b.last === null || html === b.last) return;
|
|
3129
|
+
const ops = b.rows && res.rows && rowOps(b.rows, res.rows);
|
|
1975
3130
|
b.last = html;
|
|
3131
|
+
if (ops && !ops.r.length && ops.n === b.rows.length) return;
|
|
3132
|
+
b.rows = res.rows;
|
|
1976
3133
|
closeChildren(b);
|
|
1977
|
-
|
|
3134
|
+
settleOccurrences(b);
|
|
3135
|
+
sink.hole(b.key, html, ops && !html.includes("<!--slot:") ? ops : null);
|
|
1978
3136
|
}
|
|
1979
3137
|
};
|
|
1980
3138
|
if (engine.parent) engine.parent.children.push(b);
|
|
1981
3139
|
const prevParent = engine.parent;
|
|
3140
|
+
const prevScope = engine.scope;
|
|
3141
|
+
const prevVisit = engine.visit;
|
|
3142
|
+
const scope = b.scope = scopeFor(hole);
|
|
1982
3143
|
engine.parent = b;
|
|
3144
|
+
engine.scope = scope;
|
|
3145
|
+
engine.visit = b;
|
|
1983
3146
|
let value;
|
|
1984
3147
|
let escalated = null;
|
|
1985
3148
|
try {
|
|
1986
|
-
value = hole
|
|
3149
|
+
value = holeValue(hole);
|
|
1987
3150
|
} catch (err) {
|
|
1988
3151
|
const wrap = buildAsyncWrap(err, hole);
|
|
1989
3152
|
if (!wrap) {
|
|
1990
|
-
|
|
3153
|
+
leave(b, prevParent, prevScope, prevVisit);
|
|
1991
3154
|
closeChildren(b);
|
|
1992
3155
|
return "";
|
|
1993
3156
|
}
|
|
1994
3157
|
escalated = wrap;
|
|
1995
3158
|
}
|
|
1996
3159
|
if (!escalated && (typeof value === "function" && value.$lhSkip || value !== null && typeof value === "object" && value.$slot)) {
|
|
1997
|
-
|
|
3160
|
+
leave(b, prevParent, prevScope, prevVisit);
|
|
1998
3161
|
const r = {
|
|
1999
3162
|
t: [""],
|
|
2000
3163
|
h: [],
|
|
@@ -2009,6 +3172,7 @@ function createLiveHoles(sink, scoped) {
|
|
|
2009
3172
|
return r.h.length ? r : r.t[0];
|
|
2010
3173
|
}
|
|
2011
3174
|
let res;
|
|
3175
|
+
let rows = null;
|
|
2012
3176
|
if (escalated) {
|
|
2013
3177
|
closeChildren(b);
|
|
2014
3178
|
escalated.fn.$lhSuppress = true;
|
|
@@ -2025,23 +3189,25 @@ function createLiveHoles(sink, scoped) {
|
|
|
2025
3189
|
p: []
|
|
2026
3190
|
};
|
|
2027
3191
|
try {
|
|
2028
|
-
|
|
3192
|
+
rows = resolveValue(value, res);
|
|
2029
3193
|
} catch (_) {
|
|
2030
|
-
|
|
3194
|
+
leave(b, prevParent, prevScope, prevVisit);
|
|
2031
3195
|
closeChildren(b);
|
|
2032
3196
|
return "";
|
|
2033
3197
|
}
|
|
2034
3198
|
}
|
|
2035
|
-
|
|
2036
|
-
if (
|
|
3199
|
+
leave(b, prevParent, prevScope, prevVisit);
|
|
3200
|
+
if (stamp() !== ownersBefore) {
|
|
2037
3201
|
return res.h.length ? res : res.t[0];
|
|
2038
3202
|
}
|
|
3203
|
+
if (!res.h.length && settled && settled()) return res.t[0];
|
|
2039
3204
|
const id = nextId++;
|
|
2040
3205
|
const key = b.key = "lh:" + id;
|
|
2041
3206
|
const open = `<!--lh:${id}-->`;
|
|
2042
3207
|
const close = `<!--lh:/${id}-->`;
|
|
2043
3208
|
if (!res.h.length) {
|
|
2044
3209
|
b.last = stripMarkers(res.t[0]);
|
|
3210
|
+
b.rows = rows;
|
|
2045
3211
|
sink.openBinding(key, b);
|
|
2046
3212
|
return open + res.t[0] + close;
|
|
2047
3213
|
}
|
|
@@ -2059,10 +3225,11 @@ function createLiveHoles(sink, scoped) {
|
|
|
2059
3225
|
return nextId++;
|
|
2060
3226
|
},
|
|
2061
3227
|
active() {
|
|
2062
|
-
return !inScope || inScope();
|
|
3228
|
+
return (!inScope || inScope()) && !(settled && settled());
|
|
2063
3229
|
},
|
|
2064
3230
|
attr(cap) {
|
|
2065
|
-
const owner =
|
|
3231
|
+
const owner = getOwner();
|
|
3232
|
+
const holeCtx = sharedConfig.context;
|
|
2066
3233
|
const b = {
|
|
2067
3234
|
key: "lha:" + cap.id,
|
|
2068
3235
|
children: [],
|
|
@@ -2071,9 +3238,10 @@ function createLiveHoles(sink, scoped) {
|
|
|
2071
3238
|
sweep() {
|
|
2072
3239
|
if (b.closed) return;
|
|
2073
3240
|
const prevSweeping = engine.sweeping;
|
|
3241
|
+
const prevScope = engine.scope;
|
|
2074
3242
|
engine.sweeping = true;
|
|
3243
|
+
engine.scope = null;
|
|
2075
3244
|
engine.gateHit = false;
|
|
2076
|
-
const sweepOwnersBefore = stamp();
|
|
2077
3245
|
let html = "";
|
|
2078
3246
|
try {
|
|
2079
3247
|
let group = null;
|
|
@@ -2098,17 +3266,23 @@ function createLiveHoles(sink, scoped) {
|
|
|
2098
3266
|
if (vt === "string" || vt === "number") html += v;
|
|
2099
3267
|
}
|
|
2100
3268
|
};
|
|
2101
|
-
|
|
3269
|
+
swept(owner, holeCtx, run);
|
|
2102
3270
|
} catch (err) {
|
|
2103
|
-
if (
|
|
3271
|
+
if (ssrHandleError(err, true)) {
|
|
3272
|
+
if (!engine.sweptOwners) return;
|
|
3273
|
+
b.closed = true;
|
|
3274
|
+
sink.closeBinding(b.key);
|
|
3275
|
+
return;
|
|
3276
|
+
}
|
|
2104
3277
|
b.closed = true;
|
|
2105
3278
|
sink.closeBinding(b.key);
|
|
2106
|
-
sink.error("lha:" + cap.id,
|
|
3279
|
+
sink.error("lha:" + cap.id, wireErrorMessage(err, errorScope));
|
|
2107
3280
|
return;
|
|
2108
3281
|
} finally {
|
|
2109
3282
|
engine.sweeping = prevSweeping;
|
|
3283
|
+
engine.scope = prevScope;
|
|
2110
3284
|
}
|
|
2111
|
-
if (engine.gateHit
|
|
3285
|
+
if (engine.gateHit) {
|
|
2112
3286
|
b.closed = true;
|
|
2113
3287
|
sink.closeBinding(b.key);
|
|
2114
3288
|
return;
|
|
@@ -2121,6 +3295,7 @@ function createLiveHoles(sink, scoped) {
|
|
|
2121
3295
|
sink.attr(String(cap.id), html, removed);
|
|
2122
3296
|
}
|
|
2123
3297
|
};
|
|
3298
|
+
if (sink.attrBaseline) sink.attrBaseline(b.key, cap.base);
|
|
2124
3299
|
sink.openBinding(b.key, b);
|
|
2125
3300
|
}
|
|
2126
3301
|
};
|
|
@@ -2133,6 +3308,71 @@ function attrNames(text) {
|
|
|
2133
3308
|
while (m = re.exec(text)) names.push(m[1]);
|
|
2134
3309
|
return names;
|
|
2135
3310
|
}
|
|
3311
|
+
const ROW_HTML = Symbol.for("solid.rowHtml");
|
|
3312
|
+
const ROW_TOKEN = /<(\/?)([a-zA-Z][^\s/>]*)((?:[^>"']|"[^"]*"|'[^']*')*)>|<!--([\s\S]*?)-->/g;
|
|
3313
|
+
const ROW_VOID = /^(?:area|base|br|col|embed|hr|img|input|link|meta|source|track|wbr)$/i;
|
|
3314
|
+
const ROW_FOREIGN = /^(?:svg|math)$/i;
|
|
3315
|
+
const ROW_RAW = /^(?:script|style|textarea|title|template)$/i;
|
|
3316
|
+
const ROW_KEY = /\s_key(?:="[^"]*")?(?![^\s/])/;
|
|
3317
|
+
const rowKey = attrs => (ROW_KEY.exec(attrs) || [""])[0];
|
|
3318
|
+
const ROW_ENTITY = /&(?:amp|lt|gt|quot|#39);/g;
|
|
3319
|
+
const ROW_ENTITIES = {
|
|
3320
|
+
"&": "&",
|
|
3321
|
+
"<": "<",
|
|
3322
|
+
">": ">",
|
|
3323
|
+
""": '"',
|
|
3324
|
+
"'": "'"
|
|
3325
|
+
};
|
|
3326
|
+
function rowText(text) {
|
|
3327
|
+
if (!text.includes("&")) return text;
|
|
3328
|
+
if (text.replace(ROW_ENTITY, "").includes("&")) return null;
|
|
3329
|
+
return text.replace(ROW_ENTITY, e => ROW_ENTITIES[e]);
|
|
3330
|
+
}
|
|
3331
|
+
const ROW_HASH_SEED = 0x811c9dc5;
|
|
3332
|
+
function rowPatch(a, b) {
|
|
3333
|
+
const ra = new RegExp(ROW_TOKEN);
|
|
3334
|
+
const rb = new RegExp(ROW_TOKEN);
|
|
3335
|
+
const p = [];
|
|
3336
|
+
const stack = [[-1, 0, false]];
|
|
3337
|
+
let el = -1;
|
|
3338
|
+
let h = ROW_HASH_SEED;
|
|
3339
|
+
let ia = 0;
|
|
3340
|
+
let ib = 0;
|
|
3341
|
+
for (;;) {
|
|
3342
|
+
const ma = ra.exec(a);
|
|
3343
|
+
const mb = rb.exec(b);
|
|
3344
|
+
const ta = a.slice(ia, ma ? ma.index : a.length);
|
|
3345
|
+
const tb = b.slice(ib, mb ? mb.index : b.length);
|
|
3346
|
+
const top = stack[stack.length - 1];
|
|
3347
|
+
if (ta !== tb) {
|
|
3348
|
+
const text = rowText(tb);
|
|
3349
|
+
if (text === null) return null;
|
|
3350
|
+
p.push([top[0], top[1], text]);
|
|
3351
|
+
}
|
|
3352
|
+
if (!ma || !mb) return !ma && !mb ? {
|
|
3353
|
+
p,
|
|
3354
|
+
h: h >>> 0
|
|
3355
|
+
} : null;
|
|
3356
|
+
ia = ra.lastIndex;
|
|
3357
|
+
ib = rb.lastIndex;
|
|
3358
|
+
if (ma[4] !== undefined || mb[4] !== undefined) {
|
|
3359
|
+
if (ma[4] !== mb[4]) return null;
|
|
3360
|
+
top[1]++;
|
|
3361
|
+
} 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]) {
|
|
3362
|
+
if (stack.length === 1) return null;
|
|
3363
|
+
stack.pop();
|
|
3364
|
+
} else {
|
|
3365
|
+
el++;
|
|
3366
|
+
top[1]++;
|
|
3367
|
+
const foreign = top[2] || ROW_FOREIGN.test(ma[2]);
|
|
3368
|
+
if (ma[3] !== mb[3]) {
|
|
3369
|
+
if (foreign || rowKey(ma[3]) !== rowKey(mb[3])) return null;
|
|
3370
|
+
p.push([el, mb[3].replace(/\/$/, "")]);
|
|
3371
|
+
}
|
|
3372
|
+
if (!ROW_VOID.test(ma[2]) && !ma[3].endsWith("/")) stack.push([el, 0, foreign]);
|
|
3373
|
+
}
|
|
3374
|
+
}
|
|
3375
|
+
}
|
|
2136
3376
|
function ssr(t) {
|
|
2137
3377
|
const len = arguments.length;
|
|
2138
3378
|
if (len === 1) return {
|
|
@@ -2143,7 +3383,7 @@ function ssr(t) {
|
|
|
2143
3383
|
let lastGroup = null;
|
|
2144
3384
|
let lastGroupVal = null;
|
|
2145
3385
|
let lastGroupIdx = 0;
|
|
2146
|
-
const live =
|
|
3386
|
+
const live = sharedConfig.context && sharedConfig.context.liveHoles;
|
|
2147
3387
|
const hp = live ? holeContentPositions(t) : null;
|
|
2148
3388
|
let lastOpen = null;
|
|
2149
3389
|
let cap = null;
|
|
@@ -2172,7 +3412,9 @@ function ssr(t) {
|
|
|
2172
3412
|
cap = {
|
|
2173
3413
|
id,
|
|
2174
3414
|
parts: [prefix],
|
|
2175
|
-
base: prefix
|
|
3415
|
+
base: prefix,
|
|
3416
|
+
at: lastOpen.seg,
|
|
3417
|
+
inject
|
|
2176
3418
|
};
|
|
2177
3419
|
return true;
|
|
2178
3420
|
};
|
|
@@ -2221,7 +3463,10 @@ function ssr(t) {
|
|
|
2221
3463
|
});
|
|
2222
3464
|
}
|
|
2223
3465
|
} else {
|
|
2224
|
-
cap
|
|
3466
|
+
if (cap) {
|
|
3467
|
+
result.t[cap.at] = result.t[cap.at].replace(cap.inject, "");
|
|
3468
|
+
cap = null;
|
|
3469
|
+
}
|
|
2225
3470
|
result.h.push(ssrGroupSlot(lastGroupVal.fn, lastGroupIdx++));
|
|
2226
3471
|
result.p.push(lastGroupVal.p);
|
|
2227
3472
|
result.t.push("");
|
|
@@ -2283,12 +3528,15 @@ function ssr(t) {
|
|
|
2283
3528
|
f: hole
|
|
2284
3529
|
});
|
|
2285
3530
|
} else {
|
|
3531
|
+
result.t[cap.at] = result.t[cap.at].replace(cap.inject, "");
|
|
2286
3532
|
cap = null;
|
|
2287
3533
|
}
|
|
2288
3534
|
}
|
|
2289
3535
|
} else {
|
|
2290
3536
|
const capturing = live && !hp.pos[i - 1] && captureStart();
|
|
3537
|
+
const scope = live && hp.pos[i - 1] && live.nest(hole);
|
|
2291
3538
|
const r = tryResolveFunctionHole(hole);
|
|
3539
|
+
if (scope) live.scope = scope;
|
|
2292
3540
|
if (typeof r === "string") {
|
|
2293
3541
|
s += r;
|
|
2294
3542
|
if (capturing) {
|
|
@@ -2298,7 +3546,10 @@ function ssr(t) {
|
|
|
2298
3546
|
});
|
|
2299
3547
|
}
|
|
2300
3548
|
} else {
|
|
2301
|
-
if (capturing)
|
|
3549
|
+
if (capturing) {
|
|
3550
|
+
s = s.replace(cap.inject, "");
|
|
3551
|
+
cap = null;
|
|
3552
|
+
}
|
|
2302
3553
|
result = {
|
|
2303
3554
|
t: [s],
|
|
2304
3555
|
h: [],
|
|
@@ -2359,16 +3610,17 @@ function ssr(t) {
|
|
|
2359
3610
|
return result;
|
|
2360
3611
|
}
|
|
2361
3612
|
function ssrClassName(value) {
|
|
3613
|
+
if (typeof value === "number") return "" + value;
|
|
2362
3614
|
if (!value) return "";
|
|
2363
3615
|
if (typeof value === "string") return escape(value, true);
|
|
2364
3616
|
value = classListToObject(value);
|
|
2365
3617
|
let classKeys = Object.keys(value),
|
|
2366
3618
|
result = "";
|
|
2367
3619
|
for (let i = 0, len = classKeys.length; i < len; i++) {
|
|
2368
|
-
const key = classKeys[i]
|
|
2369
|
-
|
|
3620
|
+
const key = classKeys[i];
|
|
3621
|
+
const classValue = value[key];
|
|
2370
3622
|
if (!key || key === "undefined" || !classValue) continue;
|
|
2371
|
-
|
|
3623
|
+
result && (result += " ");
|
|
2372
3624
|
result += escape(key, true);
|
|
2373
3625
|
}
|
|
2374
3626
|
return result;
|
|
@@ -2382,9 +3634,9 @@ function ssrStyle(value) {
|
|
|
2382
3634
|
const s = escape(k[i], true);
|
|
2383
3635
|
const v = value[k[i]];
|
|
2384
3636
|
if (v != undefined) {
|
|
2385
|
-
if (i) result += ";";
|
|
2386
3637
|
const r = escape(v, true);
|
|
2387
3638
|
if (r != undefined && r !== "undefined") {
|
|
3639
|
+
if (result) result += ";";
|
|
2388
3640
|
result += `${s}:${r}`;
|
|
2389
3641
|
}
|
|
2390
3642
|
}
|
|
@@ -2394,76 +3646,158 @@ function ssrStyle(value) {
|
|
|
2394
3646
|
function ssrStyleProperty(name, value) {
|
|
2395
3647
|
return value != null ? name + value : "";
|
|
2396
3648
|
}
|
|
2397
|
-
function
|
|
3649
|
+
function ssrStyleProperties(...entries) {
|
|
3650
|
+
let result = "";
|
|
3651
|
+
for (let i = 0; i < entries.length; i += 2) {
|
|
3652
|
+
const entry = ssrStyleProperty(entries[i], entries[i + 1]);
|
|
3653
|
+
if (entry) result = result ? result + ";" + entry : entry;
|
|
3654
|
+
}
|
|
3655
|
+
return result;
|
|
3656
|
+
}
|
|
3657
|
+
function ssrElement(tag, props, children, needsId, skip, attrs) {
|
|
2398
3658
|
const hk = needsId ? ssrHydrationKey() : "";
|
|
2399
|
-
if (
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
let
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
-
|
|
2407
|
-
|
|
3659
|
+
if (typeof props === "function") props = props();
|
|
3660
|
+
let sources = null;
|
|
3661
|
+
let proxy = false;
|
|
3662
|
+
let viewKeys = null;
|
|
3663
|
+
let owners = null;
|
|
3664
|
+
const ctx = renderConfig.context;
|
|
3665
|
+
const link = tag === "a" && ctx !== undefined && ctx.linkClaim !== undefined ? {} : null;
|
|
3666
|
+
if (Array.isArray(props)) {
|
|
3667
|
+
let i = 0;
|
|
3668
|
+
for (; i < props.length; i++) {
|
|
3669
|
+
const s = props[i];
|
|
3670
|
+
if (s == null || typeof s === "function" || $PROXY in s) break;
|
|
2408
3671
|
}
|
|
2409
|
-
|
|
2410
|
-
|
|
2411
|
-
|
|
2412
|
-
|
|
2413
|
-
|
|
2414
|
-
|
|
2415
|
-
|
|
2416
|
-
|
|
2417
|
-
|
|
2418
|
-
|
|
2419
|
-
|
|
2420
|
-
|
|
3672
|
+
if (i === props.length) sources = props;else {
|
|
3673
|
+
viewKeys = [];
|
|
3674
|
+
owners = [];
|
|
3675
|
+
collectSpreadSources(props, viewKeys, owners);
|
|
3676
|
+
}
|
|
3677
|
+
} else if (props == null) {
|
|
3678
|
+
props = {};
|
|
3679
|
+
} else if ($PROXY in props) {
|
|
3680
|
+
if (viewOf(props) !== undefined) {
|
|
3681
|
+
viewKeys = [];
|
|
3682
|
+
owners = [];
|
|
3683
|
+
sourceOwners(props, viewKeys, owners);
|
|
3684
|
+
} else proxy = true;
|
|
3685
|
+
}
|
|
3686
|
+
const info = tagInfo(tag);
|
|
3687
|
+
const skipChildren = info.isVoid;
|
|
3688
|
+
let result = info.open + hk;
|
|
3689
|
+
let childOwner = null;
|
|
3690
|
+
const last = sources === null ? 0 : sources.length - 1;
|
|
3691
|
+
let keysOf = null;
|
|
3692
|
+
if (sources !== null) {
|
|
3693
|
+
keysOf = new Array(last + 1);
|
|
3694
|
+
for (let s = 0; s <= last; s++) keysOf[s] = Object.keys(sources[s]);
|
|
3695
|
+
}
|
|
3696
|
+
for (let s = 0; s <= last; s++) {
|
|
3697
|
+
const keys = owners !== null ? viewKeys : keysOf !== null ? keysOf[s] : proxy ? Reflect.ownKeys(props) : Object.keys(props);
|
|
3698
|
+
if (sources !== null) props = sources[s];
|
|
3699
|
+
nextKey: for (let i = 0; i < keys.length; i++) {
|
|
3700
|
+
let prop = keys[i];
|
|
3701
|
+
if (typeof prop !== "string" || skip !== undefined && skip(prop)) continue;
|
|
3702
|
+
if (owners !== null) props = owners[i];
|
|
3703
|
+
for (let j = s + 1; j <= last; j++) {
|
|
3704
|
+
if (keysOf[j].includes(prop)) continue nextKey;
|
|
3705
|
+
}
|
|
3706
|
+
if (info.textarea && (prop === "value" || prop === "defaultValue")) {
|
|
3707
|
+
const value = props[prop];
|
|
3708
|
+
if (value !== null) children = escape(value);
|
|
3709
|
+
continue;
|
|
3710
|
+
}
|
|
3711
|
+
if (ChildProperties.has(prop)) {
|
|
3712
|
+
if (children === undefined && childOwner === null && !skipChildren) {
|
|
3713
|
+
if (prop === "children") childOwner = props;else children = info.raw || prop === "innerHTML" ? props[prop] : escape(props[prop]);
|
|
3714
|
+
}
|
|
3715
|
+
continue;
|
|
3716
|
+
}
|
|
3717
|
+
const key = prop;
|
|
3718
|
+
if (info.formAttributes !== undefined) {
|
|
3719
|
+
prop = spreadFormAttribute(prop, info, keys, keysOf, skip);
|
|
3720
|
+
if (prop === undefined) continue;
|
|
3721
|
+
}
|
|
3722
|
+
const value = props[key];
|
|
3723
|
+
if (value == undefined || prop.startsWith("prop:") || prop === "ref" || isEventName(prop)) continue;
|
|
3724
|
+
if (link !== null && LinkAttributes.has(prop)) link[prop] = value;
|
|
3725
|
+
if (prop === "style") {
|
|
3726
|
+
result += ` style="${ssrStyle(value)}"`;
|
|
3727
|
+
} else if (prop === "class") {
|
|
3728
|
+
result += ` class="${ssrClassName(value)}"`;
|
|
3729
|
+
} else if (typeof value === "boolean") {
|
|
3730
|
+
if (value && isAttrName(prop)) result += ` ${prop}`;
|
|
3731
|
+
} else if (isAttrName(prop)) {
|
|
3732
|
+
result += value === "" ? ` ${prop}` : ` ${prop}="${escape(value, true)}"`;
|
|
3733
|
+
}
|
|
2421
3734
|
}
|
|
2422
|
-
if (i !== keys.length - 1) result += " ";
|
|
2423
3735
|
}
|
|
3736
|
+
if (attrs !== undefined) result += typeof attrs === "function" ? attrs() : attrs;
|
|
3737
|
+
if (link !== null && link.href !== undefined) result += ssrLinkClaim(link);
|
|
2424
3738
|
if (skipChildren) return {
|
|
2425
|
-
t: result + "/>"
|
|
3739
|
+
t: result + " />"
|
|
2426
3740
|
};
|
|
3741
|
+
if (childOwner !== null) children = info.raw ? childOwner.children : escape(childOwner.children);
|
|
2427
3742
|
if (typeof children === "function") children = children();
|
|
2428
|
-
|
|
3743
|
+
const ct = typeof children;
|
|
3744
|
+
if (ct === "string" || ct === "number") return {
|
|
3745
|
+
t: result + ">" + children + info.close
|
|
3746
|
+
};
|
|
3747
|
+
if (children == null || ct === "boolean") return {
|
|
3748
|
+
t: result + ">" + info.close
|
|
3749
|
+
};
|
|
3750
|
+
if (ct === "object" && !children.h && typeof children.t === "string") return {
|
|
3751
|
+
t: result + ">" + children.t + info.close
|
|
3752
|
+
};
|
|
3753
|
+
return ssr([result + ">", info.close], resolveSSRNode(children, undefined, true));
|
|
3754
|
+
}
|
|
3755
|
+
function collectSpreadSources(props, viewKeys, owners) {
|
|
3756
|
+
for (let i = 0; i < props.length; i++) {
|
|
3757
|
+
let s = props[i];
|
|
3758
|
+
if (typeof s === "function") s = s();
|
|
3759
|
+
if (s != null) sourceOwners(s, viewKeys, owners);
|
|
3760
|
+
}
|
|
3761
|
+
}
|
|
3762
|
+
function spreadFormAttribute(prop, info, keys, keysOf, skip) {
|
|
3763
|
+
const defaultProp = info.formDefaults[prop];
|
|
3764
|
+
if (defaultProp !== undefined && (skip === undefined || !skip(defaultProp))) {
|
|
3765
|
+
if (keysOf !== null) {
|
|
3766
|
+
for (let j = 0; j < keysOf.length; j++) {
|
|
3767
|
+
if (keysOf[j].includes(defaultProp)) return;
|
|
3768
|
+
}
|
|
3769
|
+
} else if (keys.includes(defaultProp)) return;
|
|
3770
|
+
}
|
|
3771
|
+
const attr = info.formAttributes[prop];
|
|
3772
|
+
if (attr !== undefined && skip !== undefined && skip(attr)) return;
|
|
3773
|
+
return attr === undefined ? prop : attr;
|
|
3774
|
+
}
|
|
3775
|
+
function ssrElementAttribute(key, value) {
|
|
3776
|
+
if (value == undefined) return "";
|
|
3777
|
+
if (key === "style" || key === "class") return ` ${key}="${key === "class" ? ssrClassName(value) : ssrStyle(value)}"`;
|
|
3778
|
+
if (typeof value === "boolean") return value ? ` ${key}` : "";
|
|
3779
|
+
return value === "" ? ` ${key}` : ` ${key}="${escape(value, true)}"`;
|
|
2429
3780
|
}
|
|
2430
3781
|
function ssrAttribute(key, value) {
|
|
2431
|
-
|
|
3782
|
+
if (typeof value === "string") return ` ${key}="${value}"`;
|
|
3783
|
+
if (value == null || value === false) return "";
|
|
3784
|
+
if (typeof value === "object") return ` ${key}="${escape(String(value), true)}"`;
|
|
3785
|
+
if (typeof value === "function") return ` ${key}="${escape(String(value), true)}"`;
|
|
3786
|
+
return value === true ? ` ${key}` : ` ${key}="${value}"`;
|
|
2432
3787
|
}
|
|
2433
3788
|
function ssrHydrationKey() {
|
|
2434
3789
|
const hk = getHydrationKey();
|
|
2435
3790
|
return hk ? ` _hk=${hk}` : "";
|
|
2436
3791
|
}
|
|
2437
|
-
|
|
2438
|
-
const
|
|
2439
|
-
|
|
2440
|
-
|
|
2441
|
-
function encodeClaimKey(key) {
|
|
2442
|
-
return String(key).replace(CLAIM_UNSAFE, c => encodeURIComponent(c));
|
|
2443
|
-
}
|
|
2444
|
-
function ssrClaim(map) {
|
|
2445
|
-
const mode = solidJs.sharedConfig.context && solidJs.sharedConfig.context.claims;
|
|
2446
|
-
if (!mode || mode === CLAIMS_DOCUMENT && !(typeof solidJs.inServerComponentScope === "function" && solidJs.inServerComponentScope())) {
|
|
2447
|
-
return "";
|
|
2448
|
-
}
|
|
2449
|
-
let out = "";
|
|
2450
|
-
for (const pos in map) {
|
|
2451
|
-
const value = map[pos];
|
|
2452
|
-
const list = Array.isArray(value) ? value : [value];
|
|
2453
|
-
for (const fn of list) {
|
|
2454
|
-
const prop = typeof fn === "function" && fn[CLAIM_PROP] || undefined;
|
|
2455
|
-
if (prop === undefined) {
|
|
2456
|
-
continue;
|
|
2457
|
-
}
|
|
2458
|
-
out += `${out ? "," : ""}${pos}=${encodeClaimKey(prop)}`;
|
|
2459
|
-
}
|
|
2460
|
-
}
|
|
2461
|
-
return out ? ` _bnd="${out}"` : "";
|
|
3792
|
+
function ssrLinkClaim(attrs) {
|
|
3793
|
+
const ctx = renderConfig.context;
|
|
3794
|
+
if (ctx === undefined || ctx.linkClaim === undefined || attrs["aria-current"] != null) return "";
|
|
3795
|
+
return ctx.linkClaim(attrs);
|
|
2462
3796
|
}
|
|
2463
3797
|
function decodeSSREntities(s) {
|
|
2464
3798
|
return s.indexOf("&") < 0 ? s : s.replace(/"/g, '"').replace(/</g, "<").replace(/&/g, "&");
|
|
2465
3799
|
}
|
|
2466
|
-
const SELECT_VALUE_ATTR = /\svalue
|
|
3800
|
+
const SELECT_VALUE_ATTR = /\svalue(?:="([^"]*)")?(?=[\s>]|$)/;
|
|
2467
3801
|
function tagEnd(html, i) {
|
|
2468
3802
|
for (let j = i + 1; j < html.length; j++) {
|
|
2469
3803
|
const c = html.charCodeAt(j);
|
|
@@ -2515,7 +3849,7 @@ function resolveSSRSelectValues(html) {
|
|
|
2515
3849
|
cand = html.indexOf("<select", e0 + 1);
|
|
2516
3850
|
continue;
|
|
2517
3851
|
}
|
|
2518
|
-
const bound = decodeSSREntities(m[1]);
|
|
3852
|
+
const bound = decodeSSREntities(m[1] ?? "");
|
|
2519
3853
|
const sel = {
|
|
2520
3854
|
values: /\smultiple(?=[\s>=])/.test(open) ? bound.split(",") : [bound],
|
|
2521
3855
|
strip: cand + m.index,
|
|
@@ -2552,7 +3886,7 @@ function resolveSSRSelectValues(html) {
|
|
|
2552
3886
|
const attrs = html.slice(i + 7, e);
|
|
2553
3887
|
if (/\sselected(?=[\s=]|$)/.test(attrs)) sel.defaulted = true;else {
|
|
2554
3888
|
const vm = SELECT_VALUE_ATTR.exec(attrs);
|
|
2555
|
-
const value = vm ? decodeSSREntities(vm[1]) : decodeSSREntities(optionText(html, e + 1)).replace(/\s+/g, " ").trim();
|
|
3889
|
+
const value = vm ? decodeSSREntities(vm[1] ?? "") : decodeSSREntities(optionText(html, e + 1)).replace(/\s+/g, " ").trim();
|
|
2556
3890
|
if (sel.values.includes(value)) sel.marks.push(e);
|
|
2557
3891
|
}
|
|
2558
3892
|
}
|
|
@@ -2571,10 +3905,13 @@ function escape(s, attr) {
|
|
|
2571
3905
|
if (!attr && Array.isArray(s)) {
|
|
2572
3906
|
const joined = tryJoinPlainSSRArray(s);
|
|
2573
3907
|
if (joined !== undefined) return joined;
|
|
3908
|
+
const src = s;
|
|
2574
3909
|
s = s.slice();
|
|
2575
3910
|
for (let i = 0; i < s.length; i++) s[i] = escape(s[i]);
|
|
3911
|
+
if (src.$slot) s.$slot = true;
|
|
2576
3912
|
return s;
|
|
2577
3913
|
}
|
|
3914
|
+
if (!attr && t === "function") return escapeLate(s);
|
|
2578
3915
|
if (attr) {
|
|
2579
3916
|
if (s == null || t === "boolean" || t === "number") return s;
|
|
2580
3917
|
return escape(String(s), attr);
|
|
@@ -2585,6 +3922,16 @@ function escape(s, attr) {
|
|
|
2585
3922
|
if (i < 0) return s;
|
|
2586
3923
|
return escapeSlow(s, attr, i);
|
|
2587
3924
|
}
|
|
3925
|
+
function escapeLate(fn) {
|
|
3926
|
+
if (fn.$esc) return fn;
|
|
3927
|
+
const w = () => escape(fn());
|
|
3928
|
+
w.$esc = true;
|
|
3929
|
+
w.$fn = fn;
|
|
3930
|
+
if (fn.$lhSkip) w.$lhSkip = true;
|
|
3931
|
+
if (fn.$lhSuppress) w.$lhSuppress = true;
|
|
3932
|
+
if (fn.$lhBinding) w.$lhBinding = fn.$lhBinding;
|
|
3933
|
+
return w;
|
|
3934
|
+
}
|
|
2588
3935
|
const ESCAPE_CONTENT = /[&<]/;
|
|
2589
3936
|
const ESCAPE_ATTR = /[&"<]/;
|
|
2590
3937
|
function escapeSlow(s, attr, start) {
|
|
@@ -2665,17 +4012,20 @@ function tryJoinPlainSSRArray(nodes) {
|
|
|
2665
4012
|
return out;
|
|
2666
4013
|
}
|
|
2667
4014
|
function getHydrationKey() {
|
|
2668
|
-
const hydrate =
|
|
2669
|
-
return hydrate &&
|
|
4015
|
+
const hydrate = sharedConfig.context;
|
|
4016
|
+
return hydrate && sharedConfig.getNextContextId();
|
|
2670
4017
|
}
|
|
2671
4018
|
function applyRef(r, element) {
|
|
2672
4019
|
Array.isArray(r) ? r.flat(Infinity).forEach(f => f && f(element)) : r(element);
|
|
2673
4020
|
}
|
|
2674
4021
|
function generateHydrationScript({
|
|
2675
|
-
eventNames
|
|
4022
|
+
eventNames,
|
|
2676
4023
|
nonce
|
|
2677
4024
|
} = {}) {
|
|
2678
|
-
return
|
|
4025
|
+
return hydrationBootstrap(eventNames, destinationNonce(nonce, "script"), false);
|
|
4026
|
+
}
|
|
4027
|
+
function hydrationBootstrap(eventNames = ["click", "input"], nonce, ledger) {
|
|
4028
|
+
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-->`;
|
|
2679
4029
|
}
|
|
2680
4030
|
function queue(fn) {
|
|
2681
4031
|
return Promise.resolve().then(fn);
|
|
@@ -2685,15 +4035,22 @@ function allSettled(promises) {
|
|
|
2685
4035
|
let size = promises.size;
|
|
2686
4036
|
return Promise.allSettled(promises).then(() => {
|
|
2687
4037
|
if (promises.size !== size) return allSettled(promises);
|
|
2688
|
-
return;
|
|
4038
|
+
return size;
|
|
2689
4039
|
});
|
|
2690
4040
|
}
|
|
2691
|
-
function
|
|
4041
|
+
function withShellEnd(html, context, renderId, nonce, noScripts) {
|
|
4042
|
+
if (noScripts || !context || !context.bootstrap) return html;
|
|
4043
|
+
const id = JSON.stringify(renderId).replace(/</g, "\\u003C");
|
|
4044
|
+
const marker = `<script${nonceAttr(nonce, "script")}>_$HY.s[${id}]=1,_$HY.sw&&_$HY.sw(${id})</script>`;
|
|
4045
|
+
const at = html.indexOf("</body>", html.length - 512);
|
|
4046
|
+
return at < 0 ? html + marker : html.slice(0, at) + marker + html.slice(at);
|
|
4047
|
+
}
|
|
4048
|
+
function assembleDocument(html, emittedAssets, preloadLinks, inlineStyles, scripts, nonce, headTags, onHead) {
|
|
2692
4049
|
const scriptTag = scripts ? `<script${nonceAttr(nonce, "script")}>${scripts}</script>` : "";
|
|
2693
4050
|
const title = headTags ? headTags.title : null;
|
|
2694
4051
|
let headTagsHtml = headTags ? headTags.html : "";
|
|
2695
4052
|
const headPrelude = headTags ? headTags.prelude : "";
|
|
2696
|
-
if (!onHead && title == null && !headTagsHtml && !headPrelude && !(emittedAssets && emittedAssets.size) && !(inlineStyles && inlineStyles.size)) {
|
|
4053
|
+
if (!onHead && title == null && !headTagsHtml && !headPrelude && !(emittedAssets && emittedAssets.size) && !preloadLinks && !(inlineStyles && inlineStyles.size)) {
|
|
2697
4054
|
if (!scriptTag) return html;
|
|
2698
4055
|
const xs = html.indexOf("<!--xs-->");
|
|
2699
4056
|
return xs === -1 ? html + scriptTag : html.slice(0, xs) + scriptTag + html.slice(xs);
|
|
@@ -2712,7 +4069,7 @@ function assembleDocument(html, emittedAssets, inlineStyles, scripts, nonce, hea
|
|
|
2712
4069
|
if (title != null) {
|
|
2713
4070
|
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>`;
|
|
2714
4071
|
}
|
|
2715
|
-
onHead(headPrelude + headTagsHtml + titleHtml + renderHeadAssets(emittedAssets, inlineStyles, nonce));
|
|
4072
|
+
onHead(headPrelude + headTagsHtml + titleHtml + renderHeadAssets(emittedAssets, preloadLinks, inlineStyles, nonce));
|
|
2716
4073
|
}
|
|
2717
4074
|
if (!scriptTag) return html;
|
|
2718
4075
|
const xs = html.indexOf("<!--xs-->");
|
|
@@ -2732,13 +4089,13 @@ function assembleDocument(html, emittedAssets, inlineStyles, scripts, nonce, hea
|
|
|
2732
4089
|
headTagsHtml = `<title data-dh="title">${winner}</title>` + headTagsHtml;
|
|
2733
4090
|
}
|
|
2734
4091
|
}
|
|
2735
|
-
const head = headTagsHtml + renderHeadAssets(emittedAssets, inlineStyles, nonce);
|
|
4092
|
+
const head = headTagsHtml + renderHeadAssets(emittedAssets, preloadLinks, inlineStyles, nonce);
|
|
2736
4093
|
if (!scriptTag) return html.slice(0, headIdx) + head + html.slice(headIdx);
|
|
2737
4094
|
const xsIdx = html.indexOf("<!--xs-->");
|
|
2738
4095
|
if (xsIdx === -1) return html.slice(0, headIdx) + head + html.slice(headIdx) + scriptTag;
|
|
2739
4096
|
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);
|
|
2740
4097
|
}
|
|
2741
|
-
function renderHeadAssets(emittedAssets, inlineStyles, nonce) {
|
|
4098
|
+
function renderHeadAssets(emittedAssets, preloadLinks, inlineStyles, nonce) {
|
|
2742
4099
|
let head = "";
|
|
2743
4100
|
const styleAttr = nonceAttr(nonce, "style");
|
|
2744
4101
|
const scriptAttr = nonceAttr(nonce, "script");
|
|
@@ -2747,6 +4104,9 @@ function renderHeadAssets(emittedAssets, inlineStyles, nonce) {
|
|
|
2747
4104
|
head += isCssUrl(url) ? `<link rel="stylesheet" href="${url}"${styleAttr}>` : `<link rel="modulepreload" href="${url}"${scriptAttr}>`;
|
|
2748
4105
|
}
|
|
2749
4106
|
}
|
|
4107
|
+
if (preloadLinks) {
|
|
4108
|
+
for (const entry of preloadLinks) head += `<link${entry.attrHtml}>`;
|
|
4109
|
+
}
|
|
2750
4110
|
if (inlineStyles && inlineStyles.size) {
|
|
2751
4111
|
for (const entry of inlineStyles.values()) {
|
|
2752
4112
|
if (entry.emitted) continue;
|
|
@@ -2841,26 +4201,30 @@ function classListToObject(classList) {
|
|
|
2841
4201
|
function flattenClassList(list, result) {
|
|
2842
4202
|
for (let i = 0, len = list.length; i < len; i++) {
|
|
2843
4203
|
const item = list[i];
|
|
2844
|
-
if (Array.isArray(item)) flattenClassList(item, result);else if (typeof item === "object" && item != null) Object.assign(result, item);
|
|
4204
|
+
if (Array.isArray(item)) flattenClassList(item, result);else if (typeof item === "object" && item != null) Object.assign(result, item);
|
|
4205
|
+
else if (typeof item !== "boolean" && (item || item === 0)) result[item] = true;
|
|
2845
4206
|
}
|
|
2846
4207
|
}
|
|
2847
|
-
|
|
4208
|
+
let ssrTextTail = false;
|
|
4209
|
+
function tryResolveString(node, nested) {
|
|
4210
|
+
if (!nested) ssrTextTail = false;
|
|
2848
4211
|
const t = typeof node;
|
|
2849
|
-
if (t === "string")
|
|
2850
|
-
|
|
4212
|
+
if (t === "string" || t === "number") {
|
|
4213
|
+
const s = ssrTextTail ? "<!--!$-->" + node : "" + node;
|
|
4214
|
+
ssrTextTail = true;
|
|
4215
|
+
return s;
|
|
4216
|
+
}
|
|
2851
4217
|
if (node == null || t === "boolean") return "";
|
|
2852
4218
|
if (t === "object") {
|
|
2853
4219
|
if (Array.isArray(node)) {
|
|
2854
4220
|
const joined = tryJoinPlainSSRArray(node);
|
|
2855
|
-
if (joined !== undefined)
|
|
4221
|
+
if (joined !== undefined) {
|
|
4222
|
+
ssrTextTail = false;
|
|
4223
|
+
return joined;
|
|
4224
|
+
}
|
|
2856
4225
|
let s = "";
|
|
2857
|
-
let prevNonObj = false;
|
|
2858
4226
|
for (let i = 0, len = node.length; i < len; i++) {
|
|
2859
|
-
const
|
|
2860
|
-
const itemNonObj = item !== null && typeof item !== "object";
|
|
2861
|
-
if (prevNonObj && itemNonObj) s += "<!--!$-->";
|
|
2862
|
-
prevNonObj = itemNonObj;
|
|
2863
|
-
const r = tryResolveString(item);
|
|
4227
|
+
const r = tryResolveString(node[i], true);
|
|
2864
4228
|
if (typeof r !== "string") return {
|
|
2865
4229
|
bail: node
|
|
2866
4230
|
};
|
|
@@ -2874,6 +4238,7 @@ function tryResolveString(node) {
|
|
|
2874
4238
|
if (node.t === undefined) {
|
|
2875
4239
|
return "";
|
|
2876
4240
|
}
|
|
4241
|
+
ssrTextTail = false;
|
|
2877
4242
|
return Array.isArray(node.t) ? node.t[0] : node.t;
|
|
2878
4243
|
}
|
|
2879
4244
|
if (t === "function") {
|
|
@@ -2881,9 +4246,11 @@ function tryResolveString(node) {
|
|
|
2881
4246
|
try {
|
|
2882
4247
|
v = node();
|
|
2883
4248
|
} catch (err) {
|
|
2884
|
-
|
|
4249
|
+
const wrap = buildAsyncWrap(err, node);
|
|
4250
|
+
if (wrap) ssrTextTail = true;
|
|
4251
|
+
return wrap || "";
|
|
2885
4252
|
}
|
|
2886
|
-
return tryResolveString(v);
|
|
4253
|
+
return tryResolveString(v, true);
|
|
2887
4254
|
}
|
|
2888
4255
|
return "";
|
|
2889
4256
|
}
|
|
@@ -2891,21 +4258,19 @@ function resolveSSRNode(node, result = {
|
|
|
2891
4258
|
t: [""],
|
|
2892
4259
|
h: [],
|
|
2893
4260
|
p: []
|
|
2894
|
-
}, top) {
|
|
4261
|
+
}, top, nested) {
|
|
4262
|
+
if (!nested) ssrTextTail = false;
|
|
2895
4263
|
const t = typeof node;
|
|
2896
4264
|
if (t === "string" || t === "number") {
|
|
2897
|
-
result.t[result.t.length - 1] += node;
|
|
4265
|
+
result.t[result.t.length - 1] += ssrTextTail ? "<!--!$-->" + node : node;
|
|
4266
|
+
ssrTextTail = true;
|
|
2898
4267
|
} else if (node == null || t === "boolean") ; else if (Array.isArray(node)) {
|
|
2899
|
-
const slotLive = node.$slot &&
|
|
4268
|
+
const slotLive = node.$slot && sharedConfig.context && sharedConfig.context.liveHoles;
|
|
2900
4269
|
if (slotLive) slotLive.suppressed++;
|
|
2901
4270
|
try {
|
|
2902
|
-
let prevNonObj = false;
|
|
2903
4271
|
for (let i = 0, len = node.length; i < len; i++) {
|
|
2904
|
-
|
|
2905
|
-
|
|
2906
|
-
if (!top && prevNonObj && itemNonObj) result.t[result.t.length - 1] += `<!--!$-->`;
|
|
2907
|
-
prevNonObj = itemNonObj;
|
|
2908
|
-
resolveSSRNode(item, result);
|
|
4272
|
+
if (top) ssrTextTail = false;
|
|
4273
|
+
resolveSSRNode(node[i], result, false, true);
|
|
2909
4274
|
}
|
|
2910
4275
|
} finally {
|
|
2911
4276
|
if (slotLive) slotLive.suppressed--;
|
|
@@ -2918,24 +4283,34 @@ function resolveSSRNode(node, result = {
|
|
|
2918
4283
|
result.h.push(...node.h);
|
|
2919
4284
|
result.p.push(...node.p);
|
|
2920
4285
|
}
|
|
4286
|
+
ssrTextTail = false;
|
|
2921
4287
|
} else if (node.t !== undefined) {
|
|
2922
4288
|
result.t[result.t.length - 1] += node.t;
|
|
4289
|
+
ssrTextTail = false;
|
|
2923
4290
|
} else ;
|
|
2924
4291
|
} else if (t === "function") {
|
|
2925
|
-
const live =
|
|
4292
|
+
const live = sharedConfig.context && sharedConfig.context.liveHoles;
|
|
2926
4293
|
let liveNode = null;
|
|
2927
4294
|
if (live && (liveNode = live.content(node)) !== null) {
|
|
2928
|
-
if (typeof liveNode === "string")
|
|
4295
|
+
if (typeof liveNode === "string") {
|
|
4296
|
+
result.t[result.t.length - 1] += ssrTextTail ? "<!--!$-->" + liveNode : liveNode;
|
|
4297
|
+
ssrTextTail = true;
|
|
4298
|
+
} else resolveSSRNode(liveNode, result, false, true);
|
|
2929
4299
|
} else {
|
|
4300
|
+
const scope = live && live.nest(node);
|
|
2930
4301
|
try {
|
|
2931
|
-
resolveSSRNode(node(), result);
|
|
4302
|
+
resolveSSRNode(node(), result, false, true);
|
|
2932
4303
|
} catch (err) {
|
|
2933
4304
|
const wrap = buildAsyncWrap(err, node);
|
|
2934
4305
|
if (wrap) {
|
|
4306
|
+
if (ssrTextTail) result.t[result.t.length - 1] += "<!--!$-->";
|
|
2935
4307
|
result.h.push(wrap.fn);
|
|
2936
4308
|
result.p.push(wrap.p);
|
|
2937
4309
|
result.t.push("");
|
|
4310
|
+
ssrTextTail = true;
|
|
2938
4311
|
}
|
|
4312
|
+
} finally {
|
|
4313
|
+
if (scope) live.scope = scope;
|
|
2939
4314
|
}
|
|
2940
4315
|
}
|
|
2941
4316
|
}
|
|
@@ -2947,8 +4322,144 @@ function resolveSSRSync(node) {
|
|
|
2947
4322
|
throw new Error("This value cannot be rendered synchronously. Are you missing a boundary?");
|
|
2948
4323
|
}
|
|
2949
4324
|
const RequestContext = Symbol.for("solid.RequestContext");
|
|
4325
|
+
const ServerErrors = Symbol.for("solid-js/server/errors");
|
|
4326
|
+
function serializerErrorHook(hook) {
|
|
4327
|
+
return hook === undefined ? undefined : err => {
|
|
4328
|
+
reportServerError(err, {
|
|
4329
|
+
kind: "render",
|
|
4330
|
+
handling: "serialize"
|
|
4331
|
+
}, null, hook);
|
|
4332
|
+
};
|
|
4333
|
+
}
|
|
4334
|
+
function ambientServerErrorHook() {
|
|
4335
|
+
const slot = globalThis[ServerErrors];
|
|
4336
|
+
return slot === undefined ? undefined : slot.hook;
|
|
4337
|
+
}
|
|
4338
|
+
function configureServerErrors(config) {
|
|
4339
|
+
const g = globalThis;
|
|
4340
|
+
if (config && config.onError !== undefined && typeof config.onError !== "function") {
|
|
4341
|
+
throw new TypeError(`Invalid onError: expected a function, received ${typeof config.onError}.`);
|
|
4342
|
+
}
|
|
4343
|
+
(g[ServerErrors] ||= {}).hook = config ? config.onError : undefined;
|
|
4344
|
+
}
|
|
4345
|
+
function reportRequestFailure(error, event) {
|
|
4346
|
+
reportServerError(error, {
|
|
4347
|
+
kind: "request",
|
|
4348
|
+
handling: "failed",
|
|
4349
|
+
event
|
|
4350
|
+
}, null);
|
|
4351
|
+
if (ambientServerErrorHook() === undefined) console.error(error);
|
|
4352
|
+
}
|
|
2950
4353
|
function getRequestEvent() {
|
|
2951
|
-
|
|
4354
|
+
const store = globalThis[RequestContext];
|
|
4355
|
+
if (!store) return undefined;
|
|
4356
|
+
const event = store.getStore();
|
|
4357
|
+
if (event) return event;
|
|
4358
|
+
const ctx = renderContextOf(getOwner());
|
|
4359
|
+
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.");
|
|
4360
|
+
}
|
|
4361
|
+
const RENDER_ROOTS = Symbol.for("@solidjs/web/render-roots");
|
|
4362
|
+
function renderRoots() {
|
|
4363
|
+
const g = globalThis;
|
|
4364
|
+
return g[RENDER_ROOTS] || (g[RENDER_ROOTS] = new WeakMap());
|
|
4365
|
+
}
|
|
4366
|
+
function claimRenderRoot(context) {
|
|
4367
|
+
const owner = getOwner();
|
|
4368
|
+
const roots = renderRoots();
|
|
4369
|
+
roots.set(owner, context);
|
|
4370
|
+
onCleanup(() => roots.delete(owner));
|
|
4371
|
+
return owner;
|
|
4372
|
+
}
|
|
4373
|
+
function settleRender(render, root, outcome) {
|
|
4374
|
+
runWithOwner(root || null, () => render.settle(outcome));
|
|
4375
|
+
}
|
|
4376
|
+
const eventRenders = new WeakMap();
|
|
4377
|
+
function claimEventRender(event, context) {
|
|
4378
|
+
let renders = eventRenders.get(event);
|
|
4379
|
+
if (!renders) eventRenders.set(event, renders = new Set());
|
|
4380
|
+
renders.add(context);
|
|
4381
|
+
onCleanup(() => renders.delete(context));
|
|
4382
|
+
}
|
|
4383
|
+
function createHydrationWriter(context, isOpen) {
|
|
4384
|
+
const keys = new Set();
|
|
4385
|
+
return {
|
|
4386
|
+
async: !!context.async,
|
|
4387
|
+
write(key, value, options) {
|
|
4388
|
+
if (!isOpen() || keys.has(key)) return false;
|
|
4389
|
+
context.serialize(key, value, options && options.deferStream);
|
|
4390
|
+
keys.add(key);
|
|
4391
|
+
return true;
|
|
4392
|
+
}
|
|
4393
|
+
};
|
|
4394
|
+
}
|
|
4395
|
+
function getHydrationWriter() {
|
|
4396
|
+
const ctx = currentRenderContext();
|
|
4397
|
+
return ctx && ctx.writer;
|
|
4398
|
+
}
|
|
4399
|
+
function currentRenderContext() {
|
|
4400
|
+
let ctx = renderContextOf(getOwner());
|
|
4401
|
+
if (!ctx) {
|
|
4402
|
+
const event = peekRequestEvent();
|
|
4403
|
+
const renders = event && eventRenders.get(event);
|
|
4404
|
+
if (renders && renders.size === 1) for (const c of renders) ctx = c;
|
|
4405
|
+
}
|
|
4406
|
+
return ctx;
|
|
4407
|
+
}
|
|
4408
|
+
const LINK_STATE_RECORD = "links";
|
|
4409
|
+
function setLinkClaim(handler) {
|
|
4410
|
+
const ctx = currentRenderContext();
|
|
4411
|
+
if (!ctx) {
|
|
4412
|
+
return false;
|
|
4413
|
+
}
|
|
4414
|
+
ctx.linkClaim = handler;
|
|
4415
|
+
if (handler !== undefined) ctx.writer.write(LINK_STATE_RECORD, 1);
|
|
4416
|
+
return true;
|
|
4417
|
+
}
|
|
4418
|
+
function hasServerLinkState() {
|
|
4419
|
+
return false;
|
|
4420
|
+
}
|
|
4421
|
+
function takeHydrationValue(_key) {
|
|
4422
|
+
return undefined;
|
|
4423
|
+
}
|
|
4424
|
+
function renderContextOf(owner) {
|
|
4425
|
+
const roots = globalThis[RENDER_ROOTS];
|
|
4426
|
+
if (!roots) return undefined;
|
|
4427
|
+
for (; owner; owner = owner._parent) {
|
|
4428
|
+
const context = roots.get(owner);
|
|
4429
|
+
if (context) return context;
|
|
4430
|
+
}
|
|
4431
|
+
}
|
|
4432
|
+
function peekRequestEvent() {
|
|
4433
|
+
const store = globalThis[RequestContext];
|
|
4434
|
+
return store ? store.getStore() : undefined;
|
|
4435
|
+
}
|
|
4436
|
+
function timeDocument(context, trace, mode, requestEvent) {
|
|
4437
|
+
if (records() === undefined) return undefined;
|
|
4438
|
+
const render = observeRender(trace, mode, requestEvent);
|
|
4439
|
+
if (render) context._declareRoute = ref => render.route(ref);
|
|
4440
|
+
if (timesServerWork("boundary")) {
|
|
4441
|
+
context._recordBoundary = event => {
|
|
4442
|
+
trace.timing.push({
|
|
4443
|
+
type: "boundary",
|
|
4444
|
+
event
|
|
4445
|
+
});
|
|
4446
|
+
if (render) render.boundary();
|
|
4447
|
+
};
|
|
4448
|
+
}
|
|
4449
|
+
return render;
|
|
4450
|
+
}
|
|
4451
|
+
function getTraceContext() {
|
|
4452
|
+
const event = peekRequestEvent();
|
|
4453
|
+
if (event) return traceForEvent(event).context;
|
|
4454
|
+
const ctx = renderContextOf(getOwner());
|
|
4455
|
+
return ctx && ctx.trace ? ctx.trace.context : undefined;
|
|
4456
|
+
}
|
|
4457
|
+
function traceForStub(stub, event) {
|
|
4458
|
+
if (!event) {
|
|
4459
|
+
event = peekRequestEvent();
|
|
4460
|
+
if (!event || event.response !== stub) return undefined;
|
|
4461
|
+
}
|
|
4462
|
+
return traceForEvent(event);
|
|
2952
4463
|
}
|
|
2953
4464
|
function createResponseStub() {
|
|
2954
4465
|
return {
|
|
@@ -2967,15 +4478,30 @@ function createRequestEvent(request, init) {
|
|
|
2967
4478
|
};
|
|
2968
4479
|
}
|
|
2969
4480
|
function reportLostHeaderWrite(method, name) {
|
|
2970
|
-
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).";
|
|
4481
|
+
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).";
|
|
4482
|
+
recordFinding({
|
|
4483
|
+
code: "LATE_HEADER_WRITE",
|
|
4484
|
+
kind: "head",
|
|
4485
|
+
severity: "error",
|
|
4486
|
+
message,
|
|
4487
|
+
data: {
|
|
4488
|
+
method,
|
|
4489
|
+
name: String(name)
|
|
4490
|
+
}
|
|
4491
|
+
});
|
|
2971
4492
|
console.error(message);
|
|
2972
4493
|
}
|
|
2973
4494
|
function commitResponseStub(stub, {
|
|
2974
|
-
allowLateLocation = false
|
|
4495
|
+
allowLateLocation = false,
|
|
4496
|
+
event
|
|
2975
4497
|
} = {}) {
|
|
2976
4498
|
if (!stub || stub.committed) return stub;
|
|
2977
|
-
stub.committed = true;
|
|
2978
4499
|
const headers = stub.headers;
|
|
4500
|
+
if (headers && typeof headers.append === "function") {
|
|
4501
|
+
const trace = traceForStub(stub, event);
|
|
4502
|
+
if (trace) appendTraceServerTiming(headers, trace);
|
|
4503
|
+
}
|
|
4504
|
+
stub.committed = true;
|
|
2979
4505
|
if (!headers || typeof headers.set !== "function") return stub;
|
|
2980
4506
|
for (const method of ["set", "append", "delete"]) {
|
|
2981
4507
|
const original = headers[method].bind(headers);
|
|
@@ -2996,7 +4522,7 @@ function getExpectedRedirectStatus(response) {
|
|
|
2996
4522
|
function mergeStubHeaders(target, stub) {
|
|
2997
4523
|
if (!stub) return target;
|
|
2998
4524
|
stub.headers.forEach((value, key) => {
|
|
2999
|
-
if (key !== "set-cookie") target.set(key, value);
|
|
4525
|
+
if (key === "server-timing") mergeServerTiming(target, value);else if (key !== "set-cookie") target.set(key, value);
|
|
3000
4526
|
});
|
|
3001
4527
|
const setCookies = stub.headers.getSetCookie ? stub.headers.getSetCookie() : [];
|
|
3002
4528
|
for (const cookie of setCookies) target.append("set-cookie", cookie);
|
|
@@ -3011,43 +4537,56 @@ function copyInitHeaders(init) {
|
|
|
3011
4537
|
for (const cookie of init.getSetCookie()) headers.append("Set-Cookie", cookie);
|
|
3012
4538
|
return headers;
|
|
3013
4539
|
}
|
|
3014
|
-
|
|
4540
|
+
let stubGapFillExcluded;
|
|
4541
|
+
function isStubGapFillExcluded(key) {
|
|
4542
|
+
return (stubGapFillExcluded ||= new Set([ERROR_HEADER, BODY_FORMAT_HEADER, SINGLE_FLIGHT_HEADER, REVALIDATE_HEADER, REDIRECT_HEADER, "Location",
|
|
4543
|
+
...COMPOSED_BODY_FRAMING].map(header => header.toLowerCase()))).has(key);
|
|
4544
|
+
}
|
|
3015
4545
|
function fillsStubGap(key, headers, response) {
|
|
3016
|
-
if (key === "set-cookie" ||
|
|
4546
|
+
if (key === "set-cookie" || isStubGapFillExcluded(key)) return false;
|
|
3017
4547
|
if (response.body === null && (key === "content-type" || key === "content-length")) return false;
|
|
3018
4548
|
return !headers.has(key);
|
|
3019
4549
|
}
|
|
3020
4550
|
function commitEventResponse(response, event = getRequestEvent()) {
|
|
3021
4551
|
const stub = event && event.response;
|
|
3022
|
-
if (!stub || !stub.headers || stub.committed)
|
|
3023
|
-
|
|
3024
|
-
|
|
3025
|
-
|
|
3026
|
-
stub.headers.forEach((value, key) => {
|
|
3027
|
-
if (fillsStubGap(key, response.headers, response)) hasGaps = true;
|
|
3028
|
-
});
|
|
3029
|
-
if (!cookies.length && !hasGaps) return response;
|
|
3030
|
-
try {
|
|
3031
|
-
for (const cookie of cookies) response.headers.append("Set-Cookie", cookie);
|
|
3032
|
-
stub.headers.forEach((value, key) => {
|
|
3033
|
-
if (fillsStubGap(key, response.headers, response)) response.headers.set(key, value);
|
|
3034
|
-
});
|
|
3035
|
-
return response;
|
|
3036
|
-
} catch {
|
|
4552
|
+
if (!stub || !stub.headers || stub.committed) {
|
|
4553
|
+
if (!event || stub) return response;
|
|
4554
|
+
const trace = traceForEvent(event);
|
|
4555
|
+
if (!hasServerTiming(trace)) return response;
|
|
3037
4556
|
const headers = copyInitHeaders(response.headers);
|
|
3038
|
-
|
|
3039
|
-
stub.headers.forEach((value, key) => {
|
|
3040
|
-
if (fillsStubGap(key, headers, response)) headers.set(key, value);
|
|
3041
|
-
});
|
|
4557
|
+
appendTraceServerTiming(headers, trace);
|
|
3042
4558
|
return new Response(response.body, {
|
|
3043
4559
|
status: response.status,
|
|
3044
4560
|
statusText: response.statusText,
|
|
3045
4561
|
headers
|
|
3046
4562
|
});
|
|
3047
4563
|
}
|
|
4564
|
+
const cookies = stub.headers.getSetCookie ? stub.headers.getSetCookie() : [];
|
|
4565
|
+
commitResponseStub(stub, {
|
|
4566
|
+
event
|
|
4567
|
+
});
|
|
4568
|
+
let hasGaps = false;
|
|
4569
|
+
stub.headers.forEach((value, key) => {
|
|
4570
|
+
if (fillsStubGap(key, response.headers, response)) hasGaps = true;
|
|
4571
|
+
});
|
|
4572
|
+
const timing = stub.headers.get("server-timing");
|
|
4573
|
+
const mergesTiming = timing !== null && response.headers.has("server-timing");
|
|
4574
|
+
if (!cookies.length && !hasGaps && !mergesTiming) return response;
|
|
4575
|
+
const headers = copyInitHeaders(response.headers);
|
|
4576
|
+
for (const cookie of cookies) headers.append("Set-Cookie", cookie);
|
|
4577
|
+
stub.headers.forEach((value, key) => {
|
|
4578
|
+
if (fillsStubGap(key, headers, response)) headers.set(key, value);
|
|
4579
|
+
});
|
|
4580
|
+
if (mergesTiming) mergeServerTiming(headers, timing);
|
|
4581
|
+
return new Response(response.body, {
|
|
4582
|
+
status: response.status,
|
|
4583
|
+
statusText: response.statusText,
|
|
4584
|
+
headers
|
|
4585
|
+
});
|
|
3048
4586
|
}
|
|
3049
4587
|
function deriveHead(stub, responseInit = {}) {
|
|
3050
4588
|
const headers = mergeStubHeaders(copyInitHeaders(responseInit.headers), stub);
|
|
4589
|
+
for (const header of COMPOSED_BODY_FRAMING) headers.delete(header);
|
|
3051
4590
|
const status = stub && stub.status || responseInit.status || 200;
|
|
3052
4591
|
const statusText = stub && stub.statusText || responseInit.statusText || undefined;
|
|
3053
4592
|
return {
|
|
@@ -3064,7 +4603,9 @@ function createSSRResponse(result, event, options = {}) {
|
|
|
3064
4603
|
} = options;
|
|
3065
4604
|
const nonce = normalizeNonce(options.nonce);
|
|
3066
4605
|
if (typeof result === "string") {
|
|
3067
|
-
if (stub) commitResponseStub(stub
|
|
4606
|
+
if (stub) commitResponseStub(stub, {
|
|
4607
|
+
event
|
|
4608
|
+
});
|
|
3068
4609
|
const head = deriveHead(stub, responseInit);
|
|
3069
4610
|
if (stub && stub.headers.get("Location")) {
|
|
3070
4611
|
return new Response(null, {
|
|
@@ -3094,12 +4635,13 @@ function createSSRResponse(result, event, options = {}) {
|
|
|
3094
4635
|
closed = true;
|
|
3095
4636
|
}
|
|
3096
4637
|
};
|
|
3097
|
-
|
|
4638
|
+
const sink = {
|
|
3098
4639
|
write(chunk) {
|
|
3099
4640
|
if (!flushed) {
|
|
3100
4641
|
flushed = true;
|
|
3101
4642
|
if (stub) commitResponseStub(stub, {
|
|
3102
|
-
allowLateLocation: true
|
|
4643
|
+
allowLateLocation: true,
|
|
4644
|
+
event
|
|
3103
4645
|
});
|
|
3104
4646
|
const head = deriveHead(stub, responseInit);
|
|
3105
4647
|
if (stub && stub.headers.get("Location")) {
|
|
@@ -3108,6 +4650,7 @@ function createSSRResponse(result, event, options = {}) {
|
|
|
3108
4650
|
status: getExpectedRedirectStatus(stub),
|
|
3109
4651
|
headers: head.headers
|
|
3110
4652
|
}));
|
|
4653
|
+
sink[ABANDON_RENDER]("redirect", true);
|
|
3111
4654
|
return;
|
|
3112
4655
|
}
|
|
3113
4656
|
if (!head.headers.has("content-type")) {
|
|
@@ -3118,7 +4661,9 @@ function createSSRResponse(result, event, options = {}) {
|
|
|
3118
4661
|
controller = c;
|
|
3119
4662
|
},
|
|
3120
4663
|
cancel() {
|
|
4664
|
+
if (closed) return;
|
|
3121
4665
|
closed = true;
|
|
4666
|
+
sink[ABANDON_RENDER]("consumer");
|
|
3122
4667
|
}
|
|
3123
4668
|
}), {
|
|
3124
4669
|
status: head.status,
|
|
@@ -3129,9 +4674,10 @@ function createSSRResponse(result, event, options = {}) {
|
|
|
3129
4674
|
enqueue(transformChunk ? transformChunk(chunk) : chunk);
|
|
3130
4675
|
},
|
|
3131
4676
|
end() {
|
|
4677
|
+
if (!flushed) sink.write("");
|
|
3132
4678
|
if (closed || !controller) return;
|
|
3133
4679
|
const location = stub && stub.headers.get("Location");
|
|
3134
|
-
if (location) {
|
|
4680
|
+
if (location && isHttpNavigationTarget(location)) {
|
|
3135
4681
|
const attr = nonceAttr(nonce, "script");
|
|
3136
4682
|
enqueue(`<script${attr}>window.location=${JSON.stringify(location).replace(/</g, "\\u003c")}</script>`);
|
|
3137
4683
|
}
|
|
@@ -3139,8 +4685,23 @@ function createSSRResponse(result, event, options = {}) {
|
|
|
3139
4685
|
try {
|
|
3140
4686
|
controller.close();
|
|
3141
4687
|
} catch {}
|
|
3142
|
-
}
|
|
3143
|
-
|
|
4688
|
+
},
|
|
4689
|
+
[SHELL_ABANDONED]() {
|
|
4690
|
+
if (flushed) return;
|
|
4691
|
+
flushed = closed = true;
|
|
4692
|
+
if (stub) commitResponseStub(stub, {
|
|
4693
|
+
event
|
|
4694
|
+
});
|
|
4695
|
+
const head = deriveHead(stub, responseInit);
|
|
4696
|
+
const status = stub && stub.headers.get("Location") ? getExpectedRedirectStatus(stub) : 500;
|
|
4697
|
+
resolve(new Response(null, {
|
|
4698
|
+
status,
|
|
4699
|
+
headers: head.headers
|
|
4700
|
+
}));
|
|
4701
|
+
},
|
|
4702
|
+
[ABANDON_RENDER]() {}
|
|
4703
|
+
};
|
|
4704
|
+
result.pipe(sink);
|
|
3144
4705
|
});
|
|
3145
4706
|
}
|
|
3146
4707
|
function composeMiddleware(middlewares) {
|
|
@@ -3165,42 +4726,32 @@ function claimElement(node) {
|
|
|
3165
4726
|
function claimElementTree(root) {
|
|
3166
4727
|
return root;
|
|
3167
4728
|
}
|
|
4729
|
+
function dispatchAsInteraction(_e, fn) {
|
|
4730
|
+
return fn();
|
|
4731
|
+
}
|
|
3168
4732
|
function notSup() {
|
|
3169
|
-
throw new Error("Client-only API called on the server side. Run client-only code in
|
|
4733
|
+
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>.");
|
|
3170
4734
|
}
|
|
3171
4735
|
|
|
3172
|
-
setContainerTraceResolver(
|
|
4736
|
+
setContainerTraceResolver(getProjectionTrace);
|
|
4737
|
+
setAsyncIterableSharer(shareAsyncIterable);
|
|
3173
4738
|
const isServer = true;
|
|
3174
4739
|
const isDev = false;
|
|
3175
|
-
|
|
3176
|
-
|
|
3177
|
-
|
|
3178
|
-
});
|
|
3179
|
-
return props => {
|
|
3180
|
-
return solidJs.createMemo(() => {
|
|
3181
|
-
const c = cached();
|
|
3182
|
-
if (c) {
|
|
3183
|
-
if (typeof c === "function") return c(props);
|
|
3184
|
-
if (typeof c === "string") {
|
|
3185
|
-
return ssrElement(c, props, undefined, true);
|
|
3186
|
-
}
|
|
3187
|
-
}
|
|
3188
|
-
}, {
|
|
3189
|
-
sync: true
|
|
3190
|
-
});
|
|
3191
|
-
};
|
|
4740
|
+
const ssrTag = (tag, props) => ssrElement(tag, props, undefined, true);
|
|
4741
|
+
function dynamic(source, options) {
|
|
4742
|
+
return dynamicCore(source, options, ssrTag);
|
|
3192
4743
|
}
|
|
3193
4744
|
function Dynamic(props) {
|
|
3194
4745
|
const Comp = dynamic(() => props.component);
|
|
3195
|
-
return
|
|
4746
|
+
return createComponent(Comp, omit(props, "component"));
|
|
3196
4747
|
}
|
|
3197
4748
|
function Portal(props) {
|
|
3198
|
-
const o =
|
|
3199
|
-
if (o?.id != null)
|
|
4749
|
+
const o = getOwner();
|
|
4750
|
+
if (o?.id != null) getNextChildId(o);
|
|
3200
4751
|
return undefined;
|
|
3201
4752
|
}
|
|
3202
4753
|
function registerClientOnlyPreload(moduleUrl) {
|
|
3203
|
-
const ctx =
|
|
4754
|
+
const ctx = sharedConfig.context;
|
|
3204
4755
|
if (!ctx?.registerAsset || !ctx.resolveAssets) return;
|
|
3205
4756
|
const registerAsset = ctx.registerAsset;
|
|
3206
4757
|
const resolve = ctx.resolveAssets;
|
|
@@ -3210,6 +4761,11 @@ function registerClientOnlyPreload(moduleUrl) {
|
|
|
3210
4761
|
const css = assets.css[i];
|
|
3211
4762
|
if (typeof css === "string") registerAsset("style", css);else registerAsset("inline-style", css);
|
|
3212
4763
|
}
|
|
4764
|
+
if (assets.preloads) {
|
|
4765
|
+
for (let i = 0; i < assets.preloads.length; i++) {
|
|
4766
|
+
registerAsset("preload", assets.preloads[i]);
|
|
4767
|
+
}
|
|
4768
|
+
}
|
|
3213
4769
|
for (let i = 0; i < assets.js.length; i++) registerAsset("module", assets.js[i]);
|
|
3214
4770
|
};
|
|
3215
4771
|
const assets = resolve(moduleUrl);
|
|
@@ -3232,7 +4788,7 @@ function registerClientOnlyPreload(moduleUrl) {
|
|
|
3232
4788
|
function clientOnly(_fn, _options = {}, moduleUrl) {
|
|
3233
4789
|
return props => {
|
|
3234
4790
|
if (moduleUrl) registerClientOnlyPreload(moduleUrl);
|
|
3235
|
-
return
|
|
4791
|
+
return createMemo(() => props.fallback);
|
|
3236
4792
|
};
|
|
3237
4793
|
}
|
|
3238
4794
|
const statusLedgers = /* @__PURE__ */new WeakMap();
|
|
@@ -3259,7 +4815,7 @@ function httpStatus(code, text) {
|
|
|
3259
4815
|
ledger.live.push(declaration);
|
|
3260
4816
|
response.status = code;
|
|
3261
4817
|
response.statusText = text;
|
|
3262
|
-
|
|
4818
|
+
onCleanup(() => {
|
|
3263
4819
|
if (response.committed) return;
|
|
3264
4820
|
const index = ledger.live.indexOf(declaration);
|
|
3265
4821
|
if (index < 0) return;
|
|
@@ -3294,7 +4850,7 @@ function httpHeader(name, value, options) {
|
|
|
3294
4850
|
};
|
|
3295
4851
|
ledger.live.push(declaration);
|
|
3296
4852
|
if (declaration.append) headers.append(name, value);else headers.set(name, value);
|
|
3297
|
-
|
|
4853
|
+
onCleanup(() => {
|
|
3298
4854
|
if (response.committed) return;
|
|
3299
4855
|
const index = ledger.live.indexOf(declaration);
|
|
3300
4856
|
if (index < 0) return;
|
|
@@ -3313,167 +4869,4 @@ function httpHeader(name, value, options) {
|
|
|
3313
4869
|
}
|
|
3314
4870
|
}
|
|
3315
4871
|
|
|
3316
|
-
|
|
3317
|
-
enumerable: true,
|
|
3318
|
-
get: function () { return solidJs.Errored; }
|
|
3319
|
-
});
|
|
3320
|
-
Object.defineProperty(exports, "For", {
|
|
3321
|
-
enumerable: true,
|
|
3322
|
-
get: function () { return solidJs.For; }
|
|
3323
|
-
});
|
|
3324
|
-
Object.defineProperty(exports, "Hydration", {
|
|
3325
|
-
enumerable: true,
|
|
3326
|
-
get: function () { return solidJs.Hydration; }
|
|
3327
|
-
});
|
|
3328
|
-
Object.defineProperty(exports, "Loading", {
|
|
3329
|
-
enumerable: true,
|
|
3330
|
-
get: function () { return solidJs.Loading; }
|
|
3331
|
-
});
|
|
3332
|
-
Object.defineProperty(exports, "Match", {
|
|
3333
|
-
enumerable: true,
|
|
3334
|
-
get: function () { return solidJs.Match; }
|
|
3335
|
-
});
|
|
3336
|
-
Object.defineProperty(exports, "NoHydration", {
|
|
3337
|
-
enumerable: true,
|
|
3338
|
-
get: function () { return solidJs.NoHydration; }
|
|
3339
|
-
});
|
|
3340
|
-
Object.defineProperty(exports, "Repeat", {
|
|
3341
|
-
enumerable: true,
|
|
3342
|
-
get: function () { return solidJs.Repeat; }
|
|
3343
|
-
});
|
|
3344
|
-
Object.defineProperty(exports, "Reveal", {
|
|
3345
|
-
enumerable: true,
|
|
3346
|
-
get: function () { return solidJs.Reveal; }
|
|
3347
|
-
});
|
|
3348
|
-
Object.defineProperty(exports, "Show", {
|
|
3349
|
-
enumerable: true,
|
|
3350
|
-
get: function () { return solidJs.Show; }
|
|
3351
|
-
});
|
|
3352
|
-
Object.defineProperty(exports, "Switch", {
|
|
3353
|
-
enumerable: true,
|
|
3354
|
-
get: function () { return solidJs.Switch; }
|
|
3355
|
-
});
|
|
3356
|
-
Object.defineProperty(exports, "createComponent", {
|
|
3357
|
-
enumerable: true,
|
|
3358
|
-
get: function () { return solidJs.createComponent; }
|
|
3359
|
-
});
|
|
3360
|
-
Object.defineProperty(exports, "getOwner", {
|
|
3361
|
-
enumerable: true,
|
|
3362
|
-
get: function () { return solidJs.getOwner; }
|
|
3363
|
-
});
|
|
3364
|
-
Object.defineProperty(exports, "mergeProps", {
|
|
3365
|
-
enumerable: true,
|
|
3366
|
-
get: function () { return solidJs.merge; }
|
|
3367
|
-
});
|
|
3368
|
-
Object.defineProperty(exports, "scope", {
|
|
3369
|
-
enumerable: true,
|
|
3370
|
-
get: function () { return solidJs.ssrScope; }
|
|
3371
|
-
});
|
|
3372
|
-
Object.defineProperty(exports, "sharedConfig", {
|
|
3373
|
-
enumerable: true,
|
|
3374
|
-
get: function () { return solidJs.sharedConfig; }
|
|
3375
|
-
});
|
|
3376
|
-
Object.defineProperty(exports, "untrack", {
|
|
3377
|
-
enumerable: true,
|
|
3378
|
-
get: function () { return solidJs.untrack; }
|
|
3379
|
-
});
|
|
3380
|
-
exports.CLAIMS_DOCUMENT = CLAIMS_DOCUMENT;
|
|
3381
|
-
exports.CLAIMS_STREAM = CLAIMS_STREAM;
|
|
3382
|
-
exports.CLAIM_PROP = CLAIM_PROP;
|
|
3383
|
-
exports.ChildProperties = ChildProperties;
|
|
3384
|
-
exports.DOMElements = DOMElements;
|
|
3385
|
-
exports.DOMWithState = DOMWithState;
|
|
3386
|
-
exports.DelegatedEvents = DelegatedEvents;
|
|
3387
|
-
exports.Dynamic = Dynamic;
|
|
3388
|
-
exports.HREF = HREF;
|
|
3389
|
-
exports.HydrationScript = HydrationScript;
|
|
3390
|
-
exports.MathMLElements = MathMLElements;
|
|
3391
|
-
exports.Namespaces = Namespaces;
|
|
3392
|
-
exports.Portal = Portal;
|
|
3393
|
-
exports.REVALIDATE_HEADER = REVALIDATE_HEADER;
|
|
3394
|
-
exports.RawTextElements = RawTextElements;
|
|
3395
|
-
exports.RequestContext = RequestContext;
|
|
3396
|
-
exports.ResponseEnvelope = ResponseEnvelope;
|
|
3397
|
-
exports.SAFE_ERROR = SAFE_ERROR;
|
|
3398
|
-
exports.SVGElements = SVGElements;
|
|
3399
|
-
exports.VoidElements = VoidElements;
|
|
3400
|
-
exports.acquireAsset = notSup;
|
|
3401
|
-
exports.addEvent = notSup;
|
|
3402
|
-
exports.applyRef = applyRef;
|
|
3403
|
-
exports.assign = notSup;
|
|
3404
|
-
exports.claimElement = claimElement;
|
|
3405
|
-
exports.claimElementTree = claimElementTree;
|
|
3406
|
-
exports.className = notSup;
|
|
3407
|
-
exports.clearFlashCookie = clearFlashCookie;
|
|
3408
|
-
exports.clientOnly = clientOnly;
|
|
3409
|
-
exports.commitEventResponse = commitEventResponse;
|
|
3410
|
-
exports.commitResponseStub = commitResponseStub;
|
|
3411
|
-
exports.composeMiddleware = composeMiddleware;
|
|
3412
|
-
exports.createLiveHoles = createLiveHoles;
|
|
3413
|
-
exports.createRequestEvent = createRequestEvent;
|
|
3414
|
-
exports.createResponseStub = createResponseStub;
|
|
3415
|
-
exports.createSSRResponse = createSSRResponse;
|
|
3416
|
-
exports.delegateEvents = notSup;
|
|
3417
|
-
exports.dynamic = dynamic;
|
|
3418
|
-
exports.dynamicProperty = notSup;
|
|
3419
|
-
exports.effect = effect;
|
|
3420
|
-
exports.escape = escape;
|
|
3421
|
-
exports.generateHydrationScript = generateHydrationScript;
|
|
3422
|
-
exports.getDelegatedRoot = notSup;
|
|
3423
|
-
exports.getExpectedRedirectStatus = getExpectedRedirectStatus;
|
|
3424
|
-
exports.getHydrationKey = getHydrationKey;
|
|
3425
|
-
exports.getNextElement = notSup;
|
|
3426
|
-
exports.getNextMarker = notSup;
|
|
3427
|
-
exports.getNextMatch = notSup;
|
|
3428
|
-
exports.getRequestEvent = getRequestEvent;
|
|
3429
|
-
exports.getServerFunctionMetadata = getServerFunctionMetadata;
|
|
3430
|
-
exports.getServerFunctionRPC = getServerFunctionRPC;
|
|
3431
|
-
exports.hasFlashCookie = hasFlashCookie;
|
|
3432
|
-
exports.httpHeader = httpHeader;
|
|
3433
|
-
exports.httpStatus = httpStatus;
|
|
3434
|
-
exports.hydrate = notSup;
|
|
3435
|
-
exports.insert = notSup;
|
|
3436
|
-
exports.isDev = isDev;
|
|
3437
|
-
exports.isHref = isHref;
|
|
3438
|
-
exports.isResponseEnvelope = isResponseEnvelope;
|
|
3439
|
-
exports.isSafeError = isSafeError;
|
|
3440
|
-
exports.isServer = isServer;
|
|
3441
|
-
exports.isServerFunction = isServerFunction;
|
|
3442
|
-
exports.markSafeError = markSafeError;
|
|
3443
|
-
exports.memo = memo;
|
|
3444
|
-
exports.parseCookieHeader = parseCookieHeader;
|
|
3445
|
-
exports.redirect = redirect;
|
|
3446
|
-
exports.ref = notSup;
|
|
3447
|
-
exports.registerDelegatedContainer = notSup;
|
|
3448
|
-
exports.registerDelegatedRoot = notSup;
|
|
3449
|
-
exports.registerElementClaim = registerElementClaim;
|
|
3450
|
-
exports.reload = reload;
|
|
3451
|
-
exports.render = notSup;
|
|
3452
|
-
exports.renderToStream = renderToStream;
|
|
3453
|
-
exports.renderToString = renderToString;
|
|
3454
|
-
exports.resolveSSRSelectValues = resolveSSRSelectValues;
|
|
3455
|
-
exports.respond = respond;
|
|
3456
|
-
exports.runHydrationEvents = notSup;
|
|
3457
|
-
exports.scriptNonce = scriptNonce;
|
|
3458
|
-
exports.serializeCookie = serializeCookie;
|
|
3459
|
-
exports.setAttribute = notSup;
|
|
3460
|
-
exports.setAttributeNS = notSup;
|
|
3461
|
-
exports.setProperty = notSup;
|
|
3462
|
-
exports.setStyleProperty = notSup;
|
|
3463
|
-
exports.spread = notSup;
|
|
3464
|
-
exports.ssr = ssr;
|
|
3465
|
-
exports.ssrAttribute = ssrAttribute;
|
|
3466
|
-
exports.ssrClaim = ssrClaim;
|
|
3467
|
-
exports.ssrClassName = ssrClassName;
|
|
3468
|
-
exports.ssrElement = ssrElement;
|
|
3469
|
-
exports.ssrGroup = ssrGroup;
|
|
3470
|
-
exports.ssrHydrationKey = ssrHydrationKey;
|
|
3471
|
-
exports.ssrSelectValues = ssrSelectValues;
|
|
3472
|
-
exports.ssrStyle = ssrStyle;
|
|
3473
|
-
exports.ssrStyleProperty = ssrStyleProperty;
|
|
3474
|
-
exports.style = notSup;
|
|
3475
|
-
exports.styleNonce = styleNonce;
|
|
3476
|
-
exports.template = notSup;
|
|
3477
|
-
exports.unregisterDelegatedContainer = notSup;
|
|
3478
|
-
exports.unregisterDelegatedRoot = notSup;
|
|
3479
|
-
exports.useHead = useHead;
|
|
4872
|
+
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 };
|