@solidjs/web 2.0.0-rc.1 → 2.0.0-rc.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/server.dev.js +4472 -0
- package/dist/server.js +1301 -251
- package/dist/{server.cjs → server.observe.js} +1501 -452
- package/dist/{dev.cjs → web.dev.js} +699 -360
- package/dist/web.js +454 -139
- package/dist/{dev.js → web.observe.js} +505 -211
- package/frames/dist/client.dev.js +463 -71
- package/frames/dist/client.js +363 -70
- package/frames/dist/{client.dev.cjs → client.observe.js} +486 -133
- package/frames/dist/server.dev.js +1713 -0
- package/frames/dist/server.js +552 -2583
- package/frames/dist/server.observe.js +1713 -0
- package/frames/package.json +2 -25
- package/package.json +214 -255
- package/performance-tracks/dist/performance-tracks.dev.js +678 -0
- package/performance-tracks/dist/performance-tracks.js +6 -0
- package/performance-tracks/dist/performance-tracks.observe.js +666 -0
- package/performance-tracks/package.json +7 -0
- package/performance-tracks/types/index.d.ts +67 -0
- package/serialization/decode/package.json +2 -15
- package/serialization/dist/decode.js +92 -15
- package/serialization/dist/serialization.js +103 -23
- package/serialization/package.json +2 -15
- package/serialization/types/index.d.ts +76 -157
- package/serialization/types/serializer-decode.d.ts +149 -112
- package/serialization/types/serializer.d.ts +101 -0
- package/server-functions/dist/client.dev.js +1364 -0
- package/server-functions/dist/client.js +611 -97
- package/server-functions/dist/client.observe.js +1343 -0
- package/server-functions/dist/server.dev.js +2138 -202
- package/server-functions/dist/server.js +2042 -199
- package/server-functions/dist/server.observe.js +3043 -0
- package/server-functions/package.json +2 -35
- package/server-functions/rich-args/package.json +2 -15
- package/storage/package.json +2 -15
- package/types/client.d.ts +193 -288
- package/types/constants.d.ts +20 -0
- package/types/cookies.d.ts +32 -84
- package/types/diagnostics.d.ts +56 -0
- package/types/frames/client.d.ts +1 -1
- package/types/frames/frame-client.d.ts +323 -259
- package/types/frames/frame-container-plugin.d.ts +72 -0
- package/types/frames/frame-sink.d.ts +101 -158
- package/types/frames/frame-transport.d.ts +192 -190
- package/types/frames/serializer-decode.d.ts +219 -0
- package/types/frames/serializer.d.ts +76 -157
- package/types/frames/server.d.ts +1 -1
- package/types/head.d.ts +19 -0
- package/types/index.d.ts +52 -80
- package/types/index.server.d.ts +174 -0
- package/types/jsx.d.ts +33 -35
- package/types/observe.d.ts +358 -0
- package/types/reconcile.d.ts +1 -0
- package/types/render.d.ts +9 -0
- package/types/response.d.ts +75 -150
- package/types/serializer-decode.d.ts +149 -112
- package/types/serializer.d.ts +76 -157
- package/types/server-functions/client.d.ts +192 -194
- package/types/server-functions/flash.d.ts +28 -30
- package/types/server-functions/registry.d.ts +102 -0
- package/types/server-functions/rich-args.d.ts +1 -10
- package/types/server-functions/server.d.ts +511 -475
- package/types/server-functions/shared.d.ts +366 -425
- package/types/server-mock.d.ts +110 -13
- package/types/server-observe.d.ts +77 -0
- package/types/server.d.ts +425 -425
- package/types/trace.d.ts +127 -0
- package/LICENSE +0 -21
- package/dist/web.cjs +0 -2008
- package/frames/dist/client.cjs +0 -1916
- package/frames/dist/server.cjs +0 -3756
- package/serialization/dist/decode.cjs +0 -122
- package/serialization/dist/serialization.cjs +0 -244
- 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 -793
- package/server-functions/dist/rich-args.cjs +0 -11
- package/server-functions/dist/server.cjs +0 -1171
- package/server-functions/dist/server.dev.cjs +0 -1171
- 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 -6
- package/types-cjs/client.d.cts +0 -337
- package/types-cjs/cookies.d.cts +0 -93
- package/types-cjs/core.d.cts +0 -6
- package/types-cjs/frames/client.d.cts +0 -36
- package/types-cjs/frames/frame-client.d.cts +0 -338
- 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 -231
- 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 -616
- package/types-cjs/server-functions/shared.d.cts +0 -523
- package/types-cjs/server-mock.d.cts +0 -277
- package/types-cjs/server.d.cts +0 -523
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import { createRenderEffect, createMemo, OBSERVE, getOwner, sharedConfig, createRoot, $PROXY, runWithOwner, createComponent, omit, getNextChildId, untrack, NotReadyError, onCleanup } from 'solid-js';
|
|
2
|
+
export { Errored, For, Hydration, Loading, Match, NoHydration, Repeat, Reveal, Show, Switch, createComponent, getOwner, merge as mergeProps, sharedConfig, untrack } from 'solid-js';
|
|
3
|
+
import { inServerComponentScope, sourceOwners, viewOf, reportServerError, ssrHandleError, creationStamp, ssrSanitizeError, getProjectionTrace, shareAsyncIterable } from 'solid-js/internal';
|
|
4
|
+
export { ssrScope as scope } from 'solid-js/internal';
|
|
5
|
+
import { Feature, createStream, Serializer, getCrossReferenceHeader } 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: {
|
|
@@ -49,6 +50,15 @@ const Namespaces = {
|
|
|
49
50
|
const VoidElements = /*#__PURE__*/new Set(["area", "base", "br", "col", "embed", "hr", "img", "input", "link", "meta", "param", "source", "track", "wbr"]);
|
|
50
51
|
const RawTextElements = /*#__PURE__*/new Set(["style", "script", "noscript", "template", "textarea", "title"]);
|
|
51
52
|
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(","));
|
|
53
|
+
const COMPOSED_BODY_FRAMING = /*#__PURE__*/new Set(["content-length", "content-encoding", "transfer-encoding"]);
|
|
54
|
+
function isHttpNavigationTarget(target) {
|
|
55
|
+
try {
|
|
56
|
+
const protocol = new URL(target, "http://base.invalid").protocol;
|
|
57
|
+
return protocol === "http:" || protocol === "https:";
|
|
58
|
+
} catch {
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
}
|
|
52
62
|
|
|
53
63
|
const transparentOptions = {
|
|
54
64
|
transparent: true,
|
|
@@ -57,14 +67,257 @@ const transparentOptions = {
|
|
|
57
67
|
const syncOptions = {
|
|
58
68
|
sync: true
|
|
59
69
|
};
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
70
|
+
function effect(fn, effectFn, options) {
|
|
71
|
+
const nodeOptions = options ? {
|
|
72
|
+
sync: true,
|
|
73
|
+
...options,
|
|
74
|
+
transparent: !options.scope
|
|
75
|
+
} : transparentOptions;
|
|
76
|
+
createRenderEffect(fn, effectFn, nodeOptions);
|
|
77
|
+
}
|
|
78
|
+
function memo(fn) {
|
|
79
|
+
return createMemo(() => fn(), syncOptions);
|
|
80
|
+
}
|
|
66
81
|
|
|
67
|
-
const
|
|
82
|
+
const PROVIDER = Symbol.for("solid-js/observe/server/provider");
|
|
83
|
+
function currentProvider() {
|
|
84
|
+
if (OBSERVE === undefined) return undefined;
|
|
85
|
+
const slot = OBSERVE.server.trace;
|
|
86
|
+
return slot && slot[PROVIDER];
|
|
87
|
+
}
|
|
88
|
+
const TRACEPARENT = /^([0-9a-f]{2})-([0-9a-f]{32})-([0-9a-f]{16})-([0-9a-f]{2})(-.*)?$/;
|
|
89
|
+
const ZERO_TRACE = "00000000000000000000000000000000";
|
|
90
|
+
const ZERO_SPAN = "0000000000000000";
|
|
91
|
+
function parseTraceparent(value) {
|
|
92
|
+
if (!value) return undefined;
|
|
93
|
+
const m = TRACEPARENT.exec(value.trim());
|
|
94
|
+
if (!m) return undefined;
|
|
95
|
+
const [, version, traceId, parentId, flags, rest] = m;
|
|
96
|
+
if (version === "ff") return undefined;
|
|
97
|
+
if (version === "00" && rest !== undefined) return undefined;
|
|
98
|
+
if (traceId === ZERO_TRACE || parentId === ZERO_SPAN) return undefined;
|
|
99
|
+
return {
|
|
100
|
+
traceId,
|
|
101
|
+
parentId,
|
|
102
|
+
sampled: (parseInt(flags, 16) & 1) === 1
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
function randomHex(bytes) {
|
|
106
|
+
const buffer = new Uint8Array(bytes);
|
|
107
|
+
crypto.getRandomValues(buffer);
|
|
108
|
+
let out = "";
|
|
109
|
+
for (let i = 0; i < buffer.length; i++) out += (buffer[i] < 16 ? "0" : "") + buffer[i].toString(16);
|
|
110
|
+
return out;
|
|
111
|
+
}
|
|
112
|
+
function randomTraceId() {
|
|
113
|
+
let id = randomHex(16);
|
|
114
|
+
while (id === ZERO_TRACE) id = randomHex(16);
|
|
115
|
+
return id;
|
|
116
|
+
}
|
|
117
|
+
function randomSpanId() {
|
|
118
|
+
let id = randomHex(8);
|
|
119
|
+
while (id === ZERO_SPAN) id = randomHex(8);
|
|
120
|
+
return id;
|
|
121
|
+
}
|
|
122
|
+
function formatTraceparent(context) {
|
|
123
|
+
return `00-${context.traceId}-${context.spanId}-${context.sampled === true ? "01" : "00"}`;
|
|
124
|
+
}
|
|
125
|
+
const RECORDS_KEY = Symbol.for("@solidjs/web/trace/records");
|
|
126
|
+
function records$1() {
|
|
127
|
+
const g = globalThis;
|
|
128
|
+
return g[RECORDS_KEY] || (g[RECORDS_KEY] = new WeakMap());
|
|
129
|
+
}
|
|
130
|
+
function traceFor(key, request) {
|
|
131
|
+
const store = records$1();
|
|
132
|
+
let record = store.get(key);
|
|
133
|
+
if (record) return record;
|
|
134
|
+
const headers = request ? request.headers : undefined;
|
|
135
|
+
const incoming = headers ? parseTraceparent(headers.get("traceparent")) : undefined;
|
|
136
|
+
const context = {
|
|
137
|
+
traceId: incoming ? incoming.traceId : randomTraceId(),
|
|
138
|
+
spanId: randomSpanId(),
|
|
139
|
+
entries: {}
|
|
140
|
+
};
|
|
141
|
+
if (incoming) {
|
|
142
|
+
context.parentId = incoming.parentId;
|
|
143
|
+
context.sampled = incoming.sampled;
|
|
144
|
+
}
|
|
145
|
+
if (headers) {
|
|
146
|
+
const state = headers.get("tracestate");
|
|
147
|
+
if (state) context.state = state;
|
|
148
|
+
const baggage = headers.get("baggage");
|
|
149
|
+
if (baggage) context.baggage = baggage;
|
|
150
|
+
}
|
|
151
|
+
let answered = false;
|
|
152
|
+
let providedEntries;
|
|
153
|
+
{
|
|
154
|
+
const provider = currentProvider();
|
|
155
|
+
if (provider) {
|
|
156
|
+
let answer;
|
|
157
|
+
try {
|
|
158
|
+
answer = provider(request);
|
|
159
|
+
} catch (error) {
|
|
160
|
+
console.error(error);
|
|
161
|
+
}
|
|
162
|
+
if (answer !== undefined && answer !== null) {
|
|
163
|
+
answered = true;
|
|
164
|
+
if (answer.traceId !== undefined) context.traceId = answer.traceId;
|
|
165
|
+
if (answer.spanId !== undefined) context.spanId = answer.spanId;
|
|
166
|
+
if (answer.parentId !== undefined) context.parentId = answer.parentId;
|
|
167
|
+
if (answer.sampled !== undefined) context.sampled = answer.sampled;
|
|
168
|
+
if (answer.state !== undefined) context.state = answer.state;
|
|
169
|
+
if (answer.baggage !== undefined) context.baggage = answer.baggage;
|
|
170
|
+
providedEntries = answer.entries;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
context.entries.traceparent = formatTraceparent(context);
|
|
175
|
+
if (providedEntries) Object.assign(context.entries, providedEntries);
|
|
176
|
+
record = {
|
|
177
|
+
context,
|
|
178
|
+
emit: incoming !== undefined && incoming.sampled || answered,
|
|
179
|
+
timing: []
|
|
180
|
+
};
|
|
181
|
+
store.set(key, record);
|
|
182
|
+
return record;
|
|
183
|
+
}
|
|
184
|
+
function traceForEvent(event) {
|
|
185
|
+
return traceFor(event.request || event, event.request);
|
|
186
|
+
}
|
|
187
|
+
const TOKEN = /^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;
|
|
188
|
+
function splitServerTiming(value) {
|
|
189
|
+
const entries = [];
|
|
190
|
+
let start = 0;
|
|
191
|
+
let quoted = false;
|
|
192
|
+
for (let i = 0; i < value.length; i++) {
|
|
193
|
+
const c = value[i];
|
|
194
|
+
if (quoted) {
|
|
195
|
+
if (c === "\\") i++;else if (c === '"') quoted = false;
|
|
196
|
+
} else if (c === '"') quoted = true;else if (c === ",") {
|
|
197
|
+
entries.push(value.slice(start, i));
|
|
198
|
+
start = i + 1;
|
|
199
|
+
}
|
|
200
|
+
}
|
|
201
|
+
entries.push(value.slice(start));
|
|
202
|
+
return entries;
|
|
203
|
+
}
|
|
204
|
+
function metricName(entry) {
|
|
205
|
+
return entry.split(";")[0].trim().toLowerCase();
|
|
206
|
+
}
|
|
207
|
+
function namesOnServerTiming(headers) {
|
|
208
|
+
const names = new Set();
|
|
209
|
+
const existing = headers.get("server-timing");
|
|
210
|
+
if (existing) {
|
|
211
|
+
for (const entry of splitServerTiming(existing)) {
|
|
212
|
+
const name = metricName(entry);
|
|
213
|
+
if (name) names.add(name);
|
|
214
|
+
}
|
|
215
|
+
}
|
|
216
|
+
return names;
|
|
217
|
+
}
|
|
218
|
+
function quoteDesc(value) {
|
|
219
|
+
return value.replace(/[\x00-\x1f\x7f]/g, "").replace(/[^\x20-\x7e]/g, "?").replace(/[\\"]/g, m => "\\" + m);
|
|
220
|
+
}
|
|
221
|
+
function shellMs(record) {
|
|
222
|
+
return record.render !== undefined ? record.render.shellMs : undefined;
|
|
223
|
+
}
|
|
224
|
+
function hasServerTiming(record) {
|
|
225
|
+
return record.emit || record.timing.length > 0 || shellMs(record) !== undefined;
|
|
226
|
+
}
|
|
227
|
+
function appendTraceServerTiming(headers, record) {
|
|
228
|
+
if (record.emit) {
|
|
229
|
+
const entries = record.context.entries;
|
|
230
|
+
let present;
|
|
231
|
+
for (const name in entries) {
|
|
232
|
+
if (!TOKEN.test(name)) continue;
|
|
233
|
+
if (!present) present = namesOnServerTiming(headers);
|
|
234
|
+
if (present.has(name.toLowerCase())) continue;
|
|
235
|
+
headers.append("Server-Timing", `${name};desc="${quoteDesc(entries[name])}"`);
|
|
236
|
+
present.add(name.toLowerCase());
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
const shell = shellMs(record);
|
|
240
|
+
if (shell !== undefined) headers.append("Server-Timing", formatMetric("solid-shell", shell));
|
|
241
|
+
for (const work of record.timing) headers.append("Server-Timing", metricOf(work));
|
|
242
|
+
}
|
|
243
|
+
function metricOf(work) {
|
|
244
|
+
if (work.type === "invocation") return formatMetric("solid-invocation", work.event.durationMs, work.event.id);
|
|
245
|
+
const boundary = work.event;
|
|
246
|
+
return formatMetric("solid-boundary", boundary.durationMs, boundary.ownerPath !== undefined ? boundary.ownerPath.join(" > ") : boundary.id);
|
|
247
|
+
}
|
|
248
|
+
function formatMetric(name, dur, desc) {
|
|
249
|
+
let out = `${name};dur=${Math.round(dur * 10) / 10}`;
|
|
250
|
+
if (desc) out += `;desc="${quoteDesc(desc)}"`;
|
|
251
|
+
return out;
|
|
252
|
+
}
|
|
253
|
+
function mergeServerTiming(target, value) {
|
|
254
|
+
const present = namesOnServerTiming(target);
|
|
255
|
+
for (const entry of splitServerTiming(value)) {
|
|
256
|
+
const trimmed = entry.trim();
|
|
257
|
+
const name = metricName(trimmed);
|
|
258
|
+
if (!name || present.has(name)) continue;
|
|
259
|
+
target.append("Server-Timing", trimmed);
|
|
260
|
+
}
|
|
261
|
+
}
|
|
262
|
+
function escapeAttr(value) {
|
|
263
|
+
return value.replace(/[&"<>]/g, c => c === "&" ? "&" : c === '"' ? """ : c === "<" ? "<" : ">");
|
|
264
|
+
}
|
|
265
|
+
function traceMetaMarkup(record) {
|
|
266
|
+
if (!record.emit) return "";
|
|
267
|
+
let markup = "";
|
|
268
|
+
const entries = record.context.entries;
|
|
269
|
+
for (const name in entries) {
|
|
270
|
+
if (!TOKEN.test(name)) continue;
|
|
271
|
+
markup += `<meta name="${name}" content="${escapeAttr(entries[name])}">`;
|
|
272
|
+
}
|
|
273
|
+
return markup;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
const RECORDS = Symbol.for("@solidjs/signals/observe/records");
|
|
277
|
+
function records() {
|
|
278
|
+
return globalThis[RECORDS];
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
function timesServerWork(type) {
|
|
282
|
+
const channel = records();
|
|
283
|
+
if (channel === undefined) return false;
|
|
284
|
+
return channel.observed(type);
|
|
285
|
+
}
|
|
286
|
+
function observeRender(trace, mode, event) {
|
|
287
|
+
if (!timesServerWork("render")) return undefined;
|
|
288
|
+
const record = {
|
|
289
|
+
mode,
|
|
290
|
+
at: performance.now(),
|
|
291
|
+
durationMs: 0,
|
|
292
|
+
boundaries: 0,
|
|
293
|
+
outcome: "complete"
|
|
294
|
+
};
|
|
295
|
+
trace.render = record;
|
|
296
|
+
let settled = false;
|
|
297
|
+
return {
|
|
298
|
+
shell() {
|
|
299
|
+
if (!settled && record.shellMs === undefined) record.shellMs = performance.now() - record.at;
|
|
300
|
+
},
|
|
301
|
+
boundary() {
|
|
302
|
+
if (!settled) record.boundaries++;
|
|
303
|
+
},
|
|
304
|
+
settle(outcome) {
|
|
305
|
+
if (settled) return;
|
|
306
|
+
settled = true;
|
|
307
|
+
record.durationMs = performance.now() - record.at;
|
|
308
|
+
record.outcome = outcome;
|
|
309
|
+
const channel = records();
|
|
310
|
+
if (!channel.observed("render")) return;
|
|
311
|
+
const live = {
|
|
312
|
+
trace: trace.context
|
|
313
|
+
};
|
|
314
|
+
if (event !== undefined) live.event = event;
|
|
315
|
+
channel.emit("render", record, live);
|
|
316
|
+
}
|
|
317
|
+
};
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
const STATE = Symbol.for("solid.container-trace-state");
|
|
68
321
|
const state = globalThis[STATE] || (globalThis[STATE] = {
|
|
69
322
|
materialized: new WeakMap(),
|
|
70
323
|
materializedValues: new WeakSet()
|
|
@@ -72,7 +325,53 @@ const state = globalThis[STATE] || (globalThis[STATE] = {
|
|
|
72
325
|
function setContainerTraceResolver(fn) {
|
|
73
326
|
state.resolveTrace = fn;
|
|
74
327
|
}
|
|
75
|
-
|
|
328
|
+
function setAsyncIterableSharer(fn) {
|
|
329
|
+
state.shareIterable = fn;
|
|
330
|
+
}
|
|
331
|
+
function setContainerTraceStreamMint(fn) {
|
|
332
|
+
state.streamOf = fn;
|
|
333
|
+
}
|
|
334
|
+
const TRACE = Symbol.for("solid.container-trace");
|
|
335
|
+
function toBorderForm(value, envelopeContainers) {
|
|
336
|
+
if (value == null || typeof value !== "object") return value;
|
|
337
|
+
const share = state.shareIterable;
|
|
338
|
+
if (!share) return value;
|
|
339
|
+
if (share && isShareableIterable(value)) return share(value);
|
|
340
|
+
if (Array.isArray(value)) {
|
|
341
|
+
let out = value;
|
|
342
|
+
for (let i = 0; i < value.length; i++) {
|
|
343
|
+
const next = toBorderForm(value[i]);
|
|
344
|
+
if (next !== value[i]) {
|
|
345
|
+
if (out === value) out = value.slice();
|
|
346
|
+
out[i] = next;
|
|
347
|
+
}
|
|
348
|
+
}
|
|
349
|
+
return out;
|
|
350
|
+
}
|
|
351
|
+
if (Object.getPrototypeOf(value) === Object.prototype) {
|
|
352
|
+
let out = value;
|
|
353
|
+
for (const key of Object.keys(value)) {
|
|
354
|
+
const next = toBorderForm(value[key]);
|
|
355
|
+
if (next !== value[key]) {
|
|
356
|
+
if (out === value) out = {
|
|
357
|
+
...value
|
|
358
|
+
};
|
|
359
|
+
out[key] = next;
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
return out;
|
|
363
|
+
}
|
|
364
|
+
return value;
|
|
365
|
+
}
|
|
366
|
+
function isShareableIterable(value) {
|
|
367
|
+
try {
|
|
368
|
+
if (value.__SEROVAL_STREAM__ === true) return false;
|
|
369
|
+
if (typeof ReadableStream !== "undefined" && value instanceof ReadableStream) return false;
|
|
370
|
+
return typeof value[Symbol.asyncIterator] === "function";
|
|
371
|
+
} catch {
|
|
372
|
+
return false;
|
|
373
|
+
}
|
|
374
|
+
}
|
|
76
375
|
function materialize(marker) {
|
|
77
376
|
let value = state.materialized.get(marker.$tr);
|
|
78
377
|
if (value === undefined) {
|
|
@@ -84,13 +383,14 @@ function materialize(marker) {
|
|
|
84
383
|
}
|
|
85
384
|
function parseTrace(value, ctx) {
|
|
86
385
|
const trace = value[TRACE];
|
|
386
|
+
const sub = trace.subscribe();
|
|
87
387
|
return {
|
|
88
388
|
a: trace.array ? 1 : 0,
|
|
89
|
-
i: ctx.parse(
|
|
389
|
+
i: ctx.parse(state.streamOf ? state.streamOf(sub) : sub)
|
|
90
390
|
};
|
|
91
391
|
}
|
|
92
392
|
const ContainerTracePlugin = {
|
|
93
|
-
tag: "
|
|
393
|
+
tag: "solid/container-trace",
|
|
94
394
|
test(value) {
|
|
95
395
|
return value != null && typeof value === "object" && TRACE in value;
|
|
96
396
|
},
|
|
@@ -100,9 +400,10 @@ const ContainerTracePlugin = {
|
|
|
100
400
|
},
|
|
101
401
|
async async(value, ctx) {
|
|
102
402
|
const trace = value[TRACE];
|
|
403
|
+
const sub = trace.subscribe();
|
|
103
404
|
return {
|
|
104
405
|
a: trace.array ? 1 : 0,
|
|
105
|
-
i: await ctx.parse(
|
|
406
|
+
i: await ctx.parse(state.streamOf ? state.streamOf(sub) : sub)
|
|
106
407
|
};
|
|
107
408
|
},
|
|
108
409
|
stream: parseTrace
|
|
@@ -120,23 +421,35 @@ const ContainerTracePlugin = {
|
|
|
120
421
|
}
|
|
121
422
|
};
|
|
122
423
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
424
|
+
setContainerTraceStreamMint(iterable => {
|
|
425
|
+
const stream = createStream();
|
|
426
|
+
(async () => {
|
|
427
|
+
try {
|
|
428
|
+
for await (const value of iterable) stream.next(value);
|
|
429
|
+
stream.return(undefined);
|
|
430
|
+
} catch (error) {
|
|
431
|
+
stream.throw(error);
|
|
432
|
+
}
|
|
433
|
+
})();
|
|
434
|
+
return stream;
|
|
435
|
+
});
|
|
436
|
+
const DEFAULT_WEB_PLUGINS = Object.freeze([AbortSignalPlugin,
|
|
437
|
+
CustomEventPlugin, DOMExceptionPlugin, EventPlugin,
|
|
438
|
+
FormDataPlugin, HeadersPlugin, ReadableStreamPlugin, RequestPlugin, ResponsePlugin, URLSearchParamsPlugin, URLPlugin,
|
|
126
439
|
ContainerTracePlugin]);
|
|
127
440
|
function resolveSerializerPlugins(customPlugins) {
|
|
128
441
|
return customPlugins ? [...customPlugins, ...DEFAULT_WEB_PLUGINS] : [...DEFAULT_WEB_PLUGINS];
|
|
129
442
|
}
|
|
130
|
-
|
|
443
|
+
Feature.RegExp;
|
|
131
444
|
|
|
132
|
-
const DEFAULT_DISABLED_FEATURES =
|
|
133
|
-
const serializeOnlyDisabledFeatures =
|
|
445
|
+
const DEFAULT_DISABLED_FEATURES = Feature.AggregateError | Feature.BigIntTypedArray;
|
|
446
|
+
const serializeOnlyDisabledFeatures = serializeErrorStacks => (serializeErrorStacks === undefined ? process.env.NODE_ENV === "development" : serializeErrorStacks) ? 0 : Feature.ErrorPrototypeStack;
|
|
134
447
|
const HYDRATION_GLOBAL = "_$HY.r";
|
|
135
448
|
function createSerializer(options) {
|
|
136
|
-
return new
|
|
449
|
+
return new Serializer({
|
|
137
450
|
...options,
|
|
138
451
|
plugins: resolveSerializerPlugins(options.plugins),
|
|
139
|
-
disabledFeatures: (options.disabledFeatures === undefined ? DEFAULT_DISABLED_FEATURES : options.disabledFeatures) | serializeOnlyDisabledFeatures()
|
|
452
|
+
disabledFeatures: (options.disabledFeatures === undefined ? DEFAULT_DISABLED_FEATURES : options.disabledFeatures) | serializeOnlyDisabledFeatures(options.serializeErrorStacks)
|
|
140
453
|
});
|
|
141
454
|
}
|
|
142
455
|
function createHydrationSerializer({
|
|
@@ -156,7 +469,7 @@ function createHydrationSerializer({
|
|
|
156
469
|
});
|
|
157
470
|
}
|
|
158
471
|
function getLocalHeaderScript(id) {
|
|
159
|
-
return
|
|
472
|
+
return getCrossReferenceHeader(id) + ";";
|
|
160
473
|
}
|
|
161
474
|
|
|
162
475
|
const ENVELOPE = Symbol.for("solid.ResponseEnvelope");
|
|
@@ -193,11 +506,16 @@ function isSafeError(value) {
|
|
|
193
506
|
return !!(value && (typeof value === "object" || typeof value === "function") && value[SAFE_ERROR]);
|
|
194
507
|
}
|
|
195
508
|
const REVALIDATE_HEADER = "X-Revalidate";
|
|
196
|
-
|
|
509
|
+
const REVALIDATE_ALL = "*";
|
|
510
|
+
const RESPONSE_HEADER_VALUE_LIMIT = 4096;
|
|
511
|
+
function initWithRevalidate(init = {}) {
|
|
512
|
+
const resolved = typeof init === "number" ? {
|
|
513
|
+
status: init
|
|
514
|
+
} : init;
|
|
197
515
|
const {
|
|
198
516
|
revalidate,
|
|
199
517
|
...responseInit
|
|
200
|
-
} =
|
|
518
|
+
} = resolved;
|
|
201
519
|
let headers;
|
|
202
520
|
if (responseInit.headers && responseInit.headers.getSetCookie) {
|
|
203
521
|
headers = new Headers();
|
|
@@ -210,7 +528,17 @@ function initWithRevalidate(init) {
|
|
|
210
528
|
} else {
|
|
211
529
|
headers = new Headers(responseInit.headers);
|
|
212
530
|
}
|
|
213
|
-
revalidate !== undefined
|
|
531
|
+
if (revalidate !== undefined) {
|
|
532
|
+
const list = Array.isArray(revalidate) ? revalidate : [revalidate];
|
|
533
|
+
if (list.length > 1 && list.includes(REVALIDATE_ALL)) {
|
|
534
|
+
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.`);
|
|
535
|
+
}
|
|
536
|
+
const keys = list.join(",");
|
|
537
|
+
if (keys.length > RESPONSE_HEADER_VALUE_LIMIT) {
|
|
538
|
+
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.`);
|
|
539
|
+
}
|
|
540
|
+
headers.set(REVALIDATE_HEADER, keys);
|
|
541
|
+
}
|
|
214
542
|
return {
|
|
215
543
|
responseInit,
|
|
216
544
|
headers
|
|
@@ -223,13 +551,17 @@ function redirect(url, init = 302) {
|
|
|
223
551
|
const {
|
|
224
552
|
responseInit,
|
|
225
553
|
headers
|
|
226
|
-
} = initWithRevalidate(
|
|
227
|
-
status: init
|
|
228
|
-
} : init);
|
|
554
|
+
} = initWithRevalidate(init);
|
|
229
555
|
if (responseInit.status === undefined) {
|
|
230
556
|
responseInit.status = 302;
|
|
231
557
|
}
|
|
232
|
-
|
|
558
|
+
const target = typeof url === "string" ? url : url[HREF];
|
|
559
|
+
const location = typeof target === "string" ? target : String(url);
|
|
560
|
+
const encoded = location.replace(/[^\x00-\x7f]/gu, encodeURIComponent);
|
|
561
|
+
if (encoded.length > RESPONSE_HEADER_VALUE_LIMIT) {
|
|
562
|
+
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.`);
|
|
563
|
+
}
|
|
564
|
+
headers.set("Location", encoded);
|
|
233
565
|
return new Response(null, {
|
|
234
566
|
...responseInit,
|
|
235
567
|
headers
|
|
@@ -245,11 +577,19 @@ function reload(init = {}) {
|
|
|
245
577
|
headers
|
|
246
578
|
});
|
|
247
579
|
}
|
|
580
|
+
const NULL_BODY_STATUSES = new Set([204, 205, 304]);
|
|
248
581
|
function respond(value, init = {}) {
|
|
249
582
|
const {
|
|
250
583
|
responseInit,
|
|
251
584
|
headers
|
|
252
585
|
} = initWithRevalidate(init);
|
|
586
|
+
for (const header of COMPOSED_BODY_FRAMING) headers.delete(header);
|
|
587
|
+
if (NULL_BODY_STATUSES.has(responseInit.status)) {
|
|
588
|
+
return new ResponseEnvelope(new Response(null, {
|
|
589
|
+
...responseInit,
|
|
590
|
+
headers
|
|
591
|
+
}), value);
|
|
592
|
+
}
|
|
253
593
|
headers.set("Content-Type", "application/json");
|
|
254
594
|
return new ResponseEnvelope(new Response(JSON.stringify(value), {
|
|
255
595
|
...responseInit,
|
|
@@ -300,6 +640,7 @@ function serializeCookie(name, value, options = {}) {
|
|
|
300
640
|
if (options.expires) cookie += `; Expires=${options.expires.toUTCString()}`;
|
|
301
641
|
if (options.httpOnly) cookie += "; HttpOnly";
|
|
302
642
|
if (options.secure) cookie += "; Secure";
|
|
643
|
+
if (options.partitioned) cookie += "; Partitioned";
|
|
303
644
|
if (options.sameSite) {
|
|
304
645
|
const sameSite = options.sameSite.toLowerCase();
|
|
305
646
|
cookie += `; SameSite=${sameSite === "none" ? "None" : sameSite === "strict" ? "Strict" : "Lax"}`;
|
|
@@ -317,7 +658,21 @@ function clearFlashCookie() {
|
|
|
317
658
|
|
|
318
659
|
const ERROR_HEADER = "X-Server-Function-Error";
|
|
319
660
|
const BODY_FORMAT_HEADER = "X-Server-Function-Format";
|
|
661
|
+
const REDIRECT_HEADER = "X-Server-Function-Redirect";
|
|
320
662
|
const SINGLE_FLIGHT_HEADER = "X-Single-Flight";
|
|
663
|
+
new TextEncoder().encode(":\n\n");
|
|
664
|
+
|
|
665
|
+
function emitFinding(finding, subject = getOwner()) {
|
|
666
|
+
if (OBSERVE === undefined) return;
|
|
667
|
+
OBSERVE.diagnostics.emit(finding, subject);
|
|
668
|
+
}
|
|
669
|
+
function recordFinding(finding, subject = getOwner()) {
|
|
670
|
+
if (OBSERVE !== undefined) OBSERVE.diagnostics.emit(finding, subject);
|
|
671
|
+
}
|
|
672
|
+
function errorText(error) {
|
|
673
|
+
if (error instanceof Error) return error.message ? `${error.name}: ${error.message}` : error.name;
|
|
674
|
+
return String(error);
|
|
675
|
+
}
|
|
321
676
|
|
|
322
677
|
const HEAD_ELIGIBLE_TAGS = new Set(["title", "meta", "link", "style", "script", "base"]);
|
|
323
678
|
const HEAD_ATTR_NAME = /^[a-zA-Z_][a-zA-Z0-9_:.-]*$/;
|
|
@@ -351,11 +706,24 @@ function classifyHeadTag(desc) {
|
|
|
351
706
|
resource: false
|
|
352
707
|
};
|
|
353
708
|
}
|
|
709
|
+
function qualifierValue(name, value) {
|
|
710
|
+
if (value == null || value === false) return null;
|
|
711
|
+
if (name === "imagesrcset" || name === "imagesizes") return typeof value === "string" && value !== "" ? value : null;
|
|
712
|
+
const v = value === true ? "" : String(value);
|
|
713
|
+
if (name === "as") return asciiLowerCase(v);
|
|
714
|
+
if (name !== "crossorigin") return v;
|
|
715
|
+
return v.length === 15 && v.toLowerCase() === "use-credentials" ? v.toLowerCase() : "anonymous";
|
|
716
|
+
}
|
|
717
|
+
function asciiLowerCase(value) {
|
|
718
|
+
return value.replace(/[A-Z]/g, c => String.fromCharCode(c.charCodeAt(0) + 32));
|
|
719
|
+
}
|
|
354
720
|
function resourceIdentity(tag, props) {
|
|
355
|
-
|
|
721
|
+
const url = String(props.href || props.src || "");
|
|
722
|
+
let id = "res:" + tag + ":" + (props.rel || "") + ":" + url.length + ":" + url;
|
|
356
723
|
for (let i = 0; i < RESOURCE_QUALIFIERS.length; i++) {
|
|
357
724
|
const q = RESOURCE_QUALIFIERS[i];
|
|
358
|
-
|
|
725
|
+
const value = qualifierValue(q, props[q]);
|
|
726
|
+
if (value !== null) id += ":" + q + "=" + value.length + ":" + value;
|
|
359
727
|
}
|
|
360
728
|
return id;
|
|
361
729
|
}
|
|
@@ -417,6 +785,7 @@ function resolveAssets(moduleUrl, manifest) {
|
|
|
417
785
|
if (!entry) return null;
|
|
418
786
|
const css = [];
|
|
419
787
|
const js = [];
|
|
788
|
+
let preloads;
|
|
420
789
|
const visited = new Set();
|
|
421
790
|
const walk = key => {
|
|
422
791
|
if (visited.has(key)) return;
|
|
@@ -425,23 +794,46 @@ function resolveAssets(moduleUrl, manifest) {
|
|
|
425
794
|
if (!e) return;
|
|
426
795
|
js.push(joinAssetPath(base, e.file));
|
|
427
796
|
if (e.css) for (let i = 0; i < e.css.length; i++) css.push(joinAssetPath(base, e.css[i]));
|
|
797
|
+
if (e.preloads) {
|
|
798
|
+
for (let i = 0; i < e.preloads.length; i++) {
|
|
799
|
+
const link = e.preloads[i];
|
|
800
|
+
const href = link && typeof link.href === "string" && link.href;
|
|
801
|
+
const srcset = link && typeof link.imagesrcset === "string" && link.imagesrcset;
|
|
802
|
+
if (!href && !srcset) continue;
|
|
803
|
+
if (!preloads) preloads = [];
|
|
804
|
+
if (href) preloads.push({
|
|
805
|
+
...link,
|
|
806
|
+
href: joinAssetPath(base, href)
|
|
807
|
+
});else {
|
|
808
|
+
const {
|
|
809
|
+
href: bad,
|
|
810
|
+
...rest
|
|
811
|
+
} = link;
|
|
812
|
+
preloads.push(rest);
|
|
813
|
+
}
|
|
814
|
+
}
|
|
815
|
+
}
|
|
428
816
|
if (e.imports) for (let i = 0; i < e.imports.length; i++) walk(e.imports[i]);
|
|
429
817
|
};
|
|
430
818
|
walk(moduleUrl);
|
|
431
|
-
|
|
819
|
+
const assets = {
|
|
432
820
|
js,
|
|
433
821
|
css
|
|
434
822
|
};
|
|
823
|
+
if (preloads) assets.preloads = preloads;
|
|
824
|
+
return assets;
|
|
435
825
|
}
|
|
436
826
|
function registerEntryAssets(manifest) {
|
|
437
827
|
if (!manifest || typeof manifest === "function" || typeof manifest.resolve === "function") return;
|
|
438
|
-
const ctx =
|
|
828
|
+
const ctx = sharedConfig.context;
|
|
439
829
|
if (!ctx?.registerAsset) return;
|
|
440
830
|
for (const key in manifest) {
|
|
441
831
|
if (manifest[key].isEntry) {
|
|
442
832
|
const assets = resolveAssets(key, manifest);
|
|
443
833
|
if (assets) {
|
|
834
|
+
if (assets.preloads) for (let i = 0; i < assets.preloads.length; i++) ctx.registerAsset("preload", assets.preloads[i]);
|
|
444
835
|
for (let i = 0; i < assets.css.length; i++) ctx.registerAsset("style", assets.css[i]);
|
|
836
|
+
for (let i = 1; i < assets.js.length; i++) ctx.registerAsset("module", assets.js[i]);
|
|
445
837
|
}
|
|
446
838
|
return;
|
|
447
839
|
}
|
|
@@ -458,6 +850,7 @@ function createAssetTracking() {
|
|
|
458
850
|
boundaryStyles,
|
|
459
851
|
emittedAssets,
|
|
460
852
|
inlineStyles,
|
|
853
|
+
preloadLinks: null,
|
|
461
854
|
registerInlineStyle(desc) {
|
|
462
855
|
let entry = inlineStyles.get(desc.id);
|
|
463
856
|
if (!entry) {
|
|
@@ -549,6 +942,82 @@ function isCssUrl(url) {
|
|
|
549
942
|
const q = url.search(/[?#]/);
|
|
550
943
|
return (q === -1 ? url : url.slice(0, q)).endsWith(".css");
|
|
551
944
|
}
|
|
945
|
+
const RESPONSIVE_ATTRIBUTES = ["imagesrcset", "imagesizes"];
|
|
946
|
+
function isSetAttr(value) {
|
|
947
|
+
return value != null && value !== false && value !== "";
|
|
948
|
+
}
|
|
949
|
+
const PRELOAD_LINK_ATTRIBUTES = ["type", "crossorigin", "integrity", "referrerpolicy", "fetchpriority", "media", "imagesrcset", "imagesizes"];
|
|
950
|
+
function registerPreloadLink(tracking, headRegistry, link, nonce) {
|
|
951
|
+
if (!link || typeof link !== "object") {
|
|
952
|
+
return null;
|
|
953
|
+
}
|
|
954
|
+
if (typeof link.as !== "string") {
|
|
955
|
+
return null;
|
|
956
|
+
}
|
|
957
|
+
const as = asciiLowerCase(link.as);
|
|
958
|
+
let destination = null;
|
|
959
|
+
switch (as) {
|
|
960
|
+
case "script":
|
|
961
|
+
case "style":
|
|
962
|
+
destination = as;
|
|
963
|
+
break;
|
|
964
|
+
case "fetch":
|
|
965
|
+
case "font":
|
|
966
|
+
case "image":
|
|
967
|
+
case "track":
|
|
968
|
+
break;
|
|
969
|
+
default:
|
|
970
|
+
return null;
|
|
971
|
+
}
|
|
972
|
+
const responsive = as === "image";
|
|
973
|
+
let srcset = null;
|
|
974
|
+
let sizes = null;
|
|
975
|
+
if (responsive) {
|
|
976
|
+
for (const name of RESPONSIVE_ATTRIBUTES) {
|
|
977
|
+
const value = link[name];
|
|
978
|
+
if (!isSetAttr(value)) continue;
|
|
979
|
+
if (typeof value !== "string") {
|
|
980
|
+
continue;
|
|
981
|
+
}
|
|
982
|
+
if (name === "imagesrcset") srcset = value;else sizes = value;
|
|
983
|
+
}
|
|
984
|
+
}
|
|
985
|
+
const href = typeof link.href === "string" && link.href ? link.href : null;
|
|
986
|
+
if (!href && !srcset) {
|
|
987
|
+
return null;
|
|
988
|
+
}
|
|
989
|
+
const props = {
|
|
990
|
+
rel: "preload"
|
|
991
|
+
};
|
|
992
|
+
if (href) props.href = href;
|
|
993
|
+
props.as = as;
|
|
994
|
+
for (let i = 0; i < PRELOAD_LINK_ATTRIBUTES.length; i++) {
|
|
995
|
+
const name = PRELOAD_LINK_ATTRIBUTES[i];
|
|
996
|
+
if (RESPONSIVE_ATTRIBUTES.indexOf(name) !== -1) {
|
|
997
|
+
const value = name === "imagesrcset" ? srcset : sizes;
|
|
998
|
+
if (value !== null) props[name] = value;
|
|
999
|
+
continue;
|
|
1000
|
+
}
|
|
1001
|
+
const value = link[name];
|
|
1002
|
+
if (value == null || value === false) continue;
|
|
1003
|
+
props[name] = value === true ? "" : String(value);
|
|
1004
|
+
}
|
|
1005
|
+
const identity = resourceIdentity("link", props);
|
|
1006
|
+
if (headRegistry.resources.has(identity)) return null;
|
|
1007
|
+
const attrs = headAttrRecord(props);
|
|
1008
|
+
const nonceValue = destination && nonce && nonce[destination];
|
|
1009
|
+
if (typeof nonceValue === "string" && nonceValue) attrs.nonce = nonceValue;
|
|
1010
|
+
const entry = {
|
|
1011
|
+
href: props.href,
|
|
1012
|
+
attrs,
|
|
1013
|
+
attrHtml: renderHeadAttrHtml(props) + nonceAttr(nonce, destination)
|
|
1014
|
+
};
|
|
1015
|
+
headRegistry.resources.add(identity);
|
|
1016
|
+
let links = tracking.preloadLinks;
|
|
1017
|
+
if (!links) tracking.preloadLinks = links = [];
|
|
1018
|
+
links.push(entry);
|
|
1019
|
+
return entry;
|
|
1020
|
+
}
|
|
552
1021
|
function createHeadRegistry() {
|
|
553
1022
|
return {
|
|
554
1023
|
pending: [],
|
|
@@ -573,7 +1042,7 @@ function registerHeadTags(registry, context, tracking, emitResource, nonce, tags
|
|
|
573
1042
|
return;
|
|
574
1043
|
}
|
|
575
1044
|
if (!Array.isArray(tags)) tags = [tags];
|
|
576
|
-
const probe =
|
|
1045
|
+
const probe = sharedConfig.context && sharedConfig.context._loadingPhase;
|
|
577
1046
|
let replaceable = null;
|
|
578
1047
|
for (let i = 0; i < tags.length; i++) {
|
|
579
1048
|
const desc = tags[i];
|
|
@@ -588,7 +1057,7 @@ function registerHeadTags(registry, context, tracking, emitResource, nonce, tags
|
|
|
588
1057
|
} : undefined);
|
|
589
1058
|
evalHeadValue(desc.key);
|
|
590
1059
|
} catch (err) {
|
|
591
|
-
if (
|
|
1060
|
+
if (ssrHandleError(err)) throw err;
|
|
592
1061
|
}
|
|
593
1062
|
}
|
|
594
1063
|
if (cls.resource) {
|
|
@@ -610,7 +1079,7 @@ function registerHeadTags(registry, context, tracking, emitResource, nonce, tags
|
|
|
610
1079
|
function headShellReady(registry, block) {
|
|
611
1080
|
let ready = true;
|
|
612
1081
|
const pends = err => {
|
|
613
|
-
const source =
|
|
1082
|
+
const source = ssrHandleError(err, true);
|
|
614
1083
|
if (!source) return false;
|
|
615
1084
|
block(source);
|
|
616
1085
|
ready = false;
|
|
@@ -659,9 +1128,9 @@ function emitHeadResource(registry, context, tracking, emitResource, nonce, desc
|
|
|
659
1128
|
rel
|
|
660
1129
|
} : undefined);
|
|
661
1130
|
} catch (err) {
|
|
662
|
-
const loadingPhase =
|
|
663
|
-
if (loadingPhase &&
|
|
664
|
-
if (!loadingPhase && !context._currentBoundaryId && !registry.shellFlushed && typeof context.block === "function" &&
|
|
1131
|
+
const loadingPhase = sharedConfig.context && sharedConfig.context._loadingPhase;
|
|
1132
|
+
if (loadingPhase && ssrHandleError(err)) throw err;
|
|
1133
|
+
if (!loadingPhase && !context._currentBoundaryId && !registry.shellFlushed && typeof context.block === "function" && ssrHandleError(err, true)) {
|
|
665
1134
|
registry.parkedResources.push({
|
|
666
1135
|
desc,
|
|
667
1136
|
rel,
|
|
@@ -701,7 +1170,7 @@ function emitHeadResource(registry, context, tracking, emitResource, nonce, desc
|
|
|
701
1170
|
if (!styles) tracking.boundaryStyles.set(tracking.currentBoundaryId, styles = new Set());
|
|
702
1171
|
styles.add(entry);
|
|
703
1172
|
}
|
|
704
|
-
const markup = `<link${attrHtml}>`;
|
|
1173
|
+
const markup = `<link${attrHtml}${nonceAttr(nonce, "style")}>`;
|
|
705
1174
|
if (emitResource) emitResource(markup, entry);else {
|
|
706
1175
|
registry.eagerHtml += markup;
|
|
707
1176
|
entry.emitted = true;
|
|
@@ -799,7 +1268,7 @@ function headGroupSignature(winner) {
|
|
|
799
1268
|
}
|
|
800
1269
|
return sig;
|
|
801
1270
|
}
|
|
802
|
-
function renderShellHead(registry, nonce, isPendingFragment) {
|
|
1271
|
+
function renderShellHead(registry, nonce, isPendingFragment, noScripts, traceMetas = "") {
|
|
803
1272
|
commitHeadBoundary(registry, "", isPendingFragment);
|
|
804
1273
|
registry.shellFlushed = true;
|
|
805
1274
|
const winners = resolveHead(registry.committed);
|
|
@@ -809,8 +1278,14 @@ function renderShellHead(registry, nonce, isPendingFragment) {
|
|
|
809
1278
|
let metas = "";
|
|
810
1279
|
let others = "";
|
|
811
1280
|
let scripts = "";
|
|
1281
|
+
let title = null;
|
|
812
1282
|
for (const [identity, winner] of winners) {
|
|
813
1283
|
registry.flushed.set(identity, headGroupSignature(winner));
|
|
1284
|
+
if (identity === "title") {
|
|
1285
|
+
const children = winner.tags[0].props.children;
|
|
1286
|
+
title = children == null ? "" : String(children);
|
|
1287
|
+
continue;
|
|
1288
|
+
}
|
|
814
1289
|
for (let i = 0; i < winner.tags.length; i++) {
|
|
815
1290
|
const t = winner.tags[i];
|
|
816
1291
|
const markup = renderHeadTagMarkup(t.tag, t.props, identity, nonce);
|
|
@@ -819,10 +1294,12 @@ function renderShellHead(registry, nonce, isPendingFragment) {
|
|
|
819
1294
|
}
|
|
820
1295
|
return {
|
|
821
1296
|
prelude,
|
|
822
|
-
html: registry.eagerHtml + links + metas + others + scripts
|
|
1297
|
+
html: registry.eagerHtml + links + metas + traceMetas + others + scripts,
|
|
1298
|
+
title,
|
|
1299
|
+
noScripts
|
|
823
1300
|
};
|
|
824
1301
|
}
|
|
825
|
-
function flushHeadFragment(registry, boundary) {
|
|
1302
|
+
function flushHeadFragment(registry, boundary, nonce) {
|
|
826
1303
|
const groups = commitHeadBoundary(registry, boundary);
|
|
827
1304
|
if (!groups.length) return null;
|
|
828
1305
|
const winners = resolveHead(registry.committed);
|
|
@@ -853,12 +1330,84 @@ function flushHeadFragment(registry, boundary) {
|
|
|
853
1330
|
if (v == null || v === false) continue;
|
|
854
1331
|
attrs[name] = v === true ? "" : String(v);
|
|
855
1332
|
}
|
|
1333
|
+
if (nonce && !hasNonceProp(t.props)) {
|
|
1334
|
+
const destination = nonceDestination(t.tag, t.props);
|
|
1335
|
+
const value = destination && nonce[destination];
|
|
1336
|
+
if (value) attrs.nonce = String(value);
|
|
1337
|
+
}
|
|
856
1338
|
const children = t.props.children;
|
|
857
1339
|
ops.push(["a", identity, t.tag, attrs, children == null ? null : String(children)]);
|
|
858
1340
|
}
|
|
859
1341
|
}
|
|
860
1342
|
return ops.length ? ops : null;
|
|
861
1343
|
}
|
|
1344
|
+
function normalizeNonce(nonce) {
|
|
1345
|
+
if (nonce == null) return undefined;
|
|
1346
|
+
if (typeof nonce === "string") {
|
|
1347
|
+
const attr = nonce ? ` nonce="${escape(nonce, true)}"` : "";
|
|
1348
|
+
return {
|
|
1349
|
+
script: nonce,
|
|
1350
|
+
style: nonce,
|
|
1351
|
+
scriptAttr: attr,
|
|
1352
|
+
styleAttr: attr
|
|
1353
|
+
};
|
|
1354
|
+
}
|
|
1355
|
+
const script = nonce.script;
|
|
1356
|
+
const style = nonce.style;
|
|
1357
|
+
if (!script && !style) return undefined;
|
|
1358
|
+
return {
|
|
1359
|
+
script,
|
|
1360
|
+
style,
|
|
1361
|
+
scriptAttr: typeof script === "string" && script ? ` nonce="${escape(script, true)}"` : "",
|
|
1362
|
+
styleAttr: typeof style === "string" && style ? ` nonce="${escape(style, true)}"` : ""
|
|
1363
|
+
};
|
|
1364
|
+
}
|
|
1365
|
+
function destinationNonce(nonce, destination) {
|
|
1366
|
+
if (nonce == null) return undefined;
|
|
1367
|
+
if (typeof nonce === "string") return nonce || undefined;
|
|
1368
|
+
const value = nonce[destination];
|
|
1369
|
+
return typeof value === "string" && value ? value : undefined;
|
|
1370
|
+
}
|
|
1371
|
+
function scriptNonce(nonce) {
|
|
1372
|
+
return destinationNonce(nonce, "script");
|
|
1373
|
+
}
|
|
1374
|
+
function styleNonce(nonce) {
|
|
1375
|
+
return destinationNonce(nonce, "style");
|
|
1376
|
+
}
|
|
1377
|
+
function hasNonceProp(props) {
|
|
1378
|
+
for (const name in props) if (name.length === 5 && asciiLowerCase(name) === "nonce" && props[name] != null) return true;
|
|
1379
|
+
return false;
|
|
1380
|
+
}
|
|
1381
|
+
function nonceDestination(tag, props) {
|
|
1382
|
+
if (tag === "script") return "script";
|
|
1383
|
+
if (tag === "style") return "style";
|
|
1384
|
+
if (tag !== "link") return null;
|
|
1385
|
+
const rel = props.rel;
|
|
1386
|
+
if (typeof rel !== "string") return null;
|
|
1387
|
+
const rels = asciiLowerCase(rel).split(/[\t\n\f\r ]+/);
|
|
1388
|
+
if (rels.includes("stylesheet")) return "style";
|
|
1389
|
+
const isModulePreload = rels.includes("modulepreload");
|
|
1390
|
+
if (!isModulePreload && !rels.includes("preload")) return null;
|
|
1391
|
+
const as = typeof props.as === "string" ? asciiLowerCase(props.as) : "";
|
|
1392
|
+
if (as === "style") return "style";
|
|
1393
|
+
if (as === "script") return "script";
|
|
1394
|
+
if (!isModulePreload) return null;
|
|
1395
|
+
switch (as) {
|
|
1396
|
+
case "fetch":
|
|
1397
|
+
case "font":
|
|
1398
|
+
case "image":
|
|
1399
|
+
case "json":
|
|
1400
|
+
case "text":
|
|
1401
|
+
case "track":
|
|
1402
|
+
return null;
|
|
1403
|
+
default:
|
|
1404
|
+
return "script";
|
|
1405
|
+
}
|
|
1406
|
+
}
|
|
1407
|
+
function nonceAttr(nonce, destination) {
|
|
1408
|
+
if (!nonce || !destination) return "";
|
|
1409
|
+
return destination === "script" ? nonce.scriptAttr : nonce.styleAttr;
|
|
1410
|
+
}
|
|
862
1411
|
function renderHeadAttrHtml(props) {
|
|
863
1412
|
let attrs = "";
|
|
864
1413
|
for (const name in props) {
|
|
@@ -887,30 +1436,52 @@ function headAttrRecord(props, skipRelHref) {
|
|
|
887
1436
|
function renderHeadTagMarkup(tag, props, identity, nonce) {
|
|
888
1437
|
let attrs = renderHeadAttrHtml(props);
|
|
889
1438
|
if (identity != null) attrs += ` data-dh="${escape(identity, true)}"`;
|
|
890
|
-
if (nonce && (
|
|
1439
|
+
if (nonce && !hasNonceProp(props)) attrs += nonceAttr(nonce, nonceDestination(tag, props));
|
|
891
1440
|
if (tag === "meta" || tag === "link" || tag === "base") return `<${tag}${attrs}>`;
|
|
892
1441
|
let body = props.children == null ? "" : String(props.children);
|
|
893
1442
|
if (tag === "script") body = body.replace(/<\/(script)/gi, "<\\/$1");else if (tag === "style") body = escapeStyleContent(body);else body = escape(body);
|
|
894
1443
|
return `<${tag}${attrs}>${body}</${tag}>`;
|
|
895
1444
|
}
|
|
896
1445
|
function useHead(tags) {
|
|
897
|
-
const ctx =
|
|
1446
|
+
const ctx = sharedConfig.context;
|
|
898
1447
|
if (!ctx || !ctx.registerHeadTags) {
|
|
899
1448
|
return;
|
|
900
1449
|
}
|
|
901
1450
|
ctx.registerHeadTags(tags);
|
|
902
1451
|
}
|
|
903
1452
|
const VOID_ELEMENTS = /^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/i;
|
|
1453
|
+
const tagInfos = /*#__PURE__*/new Map();
|
|
1454
|
+
function tagInfo(tag) {
|
|
1455
|
+
let info = tagInfos.get(tag);
|
|
1456
|
+
if (info === undefined) {
|
|
1457
|
+
info = {
|
|
1458
|
+
open: "<" + tag,
|
|
1459
|
+
close: "</" + tag + ">",
|
|
1460
|
+
isVoid: VOID_ELEMENTS.test(tag),
|
|
1461
|
+
textarea: tag === "textarea",
|
|
1462
|
+
raw: tag === "script" || tag === "style"
|
|
1463
|
+
};
|
|
1464
|
+
if (tagInfos.size < 512) tagInfos.set(tag, info);
|
|
1465
|
+
}
|
|
1466
|
+
return info;
|
|
1467
|
+
}
|
|
1468
|
+
const safeAttrNames = /*#__PURE__*/new Set();
|
|
1469
|
+
function attrName(prop) {
|
|
1470
|
+
if (safeAttrNames.has(prop)) return prop;
|
|
1471
|
+
const escaped = escape(prop);
|
|
1472
|
+
if (escaped === prop && safeAttrNames.size < 512) safeAttrNames.add(prop);
|
|
1473
|
+
return escaped;
|
|
1474
|
+
}
|
|
904
1475
|
const REPLACE_SCRIPT = `function $df(e){return _$HY.f?_$HY.f(e):$dfr(e)}function $dfr(e,n,o,t){if(!(n=document.getElementById(e)))return 0;if(!(o=document.getElementById("pl-"+e)))return(_$HY.dq=_$HY.dq||{})[e]=1,0;for(;o&&(8!==o.nodeType||o.nodeValue!=="pl-"+e);)t=o.nextSibling,o.remove(),o=t;t=o.parentNode,o.replaceWith(n.content),n.remove(),(_$HY.v=_$HY.v||{})[e]=1,_$HY.fe(e,t),_$HY.hp&&_$HY.hp[e]&&($dh(_$HY.hp[e]),delete _$HY.hp[e]),$dfd();return 1}function $dfl(e,o,n){if(!(o=document.getElementById("pl-"+e)))return(_$HY.dlq=_$HY.dlq||{})[e]=1,0;if(o._$fl)return 1;for(n=o.nextSibling;n;){if(8===n.nodeType&&n.nodeValue==="pl-"+e){o.parentNode&&o.parentNode.insertBefore(o.content.cloneNode(!0),n),o._$fl=1,$dfd();return 1}n=n.nextSibling}return 0}function $dflj(e,i){for(i=0;i<e.length;i++)$dfl(e[i])}function $dfd(e,i){if(e=_$HY.dq){_$HY.dq=0;for(i in e)$df(i)}if(e=_$HY.dlq){_$HY.dlq=0;for(i in e)$dfl(i)}}function $dfs(e,c,d){(_$HY.sc=_$HY.sc||{})[e]=c,d&&((_$HY.sd=_$HY.sd||{})[e]=1)}function $dfg(e,g,i,k){if(!(g=_$HY.sg&&_$HY.sg[e]))return;for(i=0;i<g.length;i++)if(_$HY.sc&&_$HY.sc[g[i]]>0)return;for(i=0;i<g.length;i++)k=g[i],delete _$HY.sg[k],$df(k)}function $dfc(e){if(--_$HY.sc[e]<=0){delete _$HY.sc[e],_$HY.sg&&_$HY.sg[e]?$dfg(e):!(_$HY.sd&&_$HY.sd[e])&&$df(e);_$HY.sd&&delete _$HY.sd[e]}}function $dfj(e,i,n){for(i=0;i<e.length;i++)if(_$HY.sc&&_$HY.sc[e[i]]>0){for(n=0;n<e.length;n++)(_$HY.sg=_$HY.sg||{})[e[n]]=e;return}for(i=0;i<e.length;i++)$df(e[i])}`;
|
|
905
|
-
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=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)}`;
|
|
1476
|
+
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)}`;
|
|
906
1477
|
function renderToString(code, options = {}) {
|
|
907
1478
|
const {
|
|
908
1479
|
renderId = "",
|
|
909
|
-
nonce,
|
|
910
1480
|
noScripts,
|
|
911
1481
|
manifest,
|
|
912
1482
|
onHead
|
|
913
1483
|
} = options;
|
|
1484
|
+
const nonce = normalizeNonce(options.nonce);
|
|
914
1485
|
let scripts = "";
|
|
915
1486
|
const serializer = createHydrationSerializer({
|
|
916
1487
|
scopeId: renderId,
|
|
@@ -922,26 +1493,31 @@ function renderToString(code, options = {}) {
|
|
|
922
1493
|
}
|
|
923
1494
|
scripts += script + ";";
|
|
924
1495
|
},
|
|
925
|
-
onError: options.onError
|
|
1496
|
+
onError: serializerErrorHook(options.onError)
|
|
926
1497
|
});
|
|
927
1498
|
const tracking = createAssetTracking();
|
|
928
1499
|
const headRegistry = createHeadRegistry();
|
|
929
|
-
|
|
930
|
-
nonce,
|
|
1500
|
+
sharedConfig.context = {
|
|
1501
|
+
nonce: options.nonce,
|
|
931
1502
|
escape: escape,
|
|
932
1503
|
resolve: resolveSSRNode,
|
|
933
1504
|
ssr: ssr,
|
|
1505
|
+
errorPolicy: options.onError,
|
|
934
1506
|
registerHeadTags(tags) {
|
|
935
|
-
registerHeadTags(headRegistry,
|
|
1507
|
+
registerHeadTags(headRegistry, sharedConfig.context, tracking, null, nonce, tags);
|
|
936
1508
|
},
|
|
937
1509
|
serialize(id, p) {
|
|
938
|
-
if (
|
|
1510
|
+
if (sharedConfig.context.noHydrate) return;
|
|
939
1511
|
if (p != null && typeof p === "object" && (typeof p.then === "function" || typeof p[Symbol.asyncIterator] === "function")) {
|
|
940
1512
|
throw new Error("Cannot serialize async value in renderToString (id: " + id + "). " + "Use renderToStream for async data.");
|
|
941
1513
|
}
|
|
942
1514
|
serializer.write(id, p);
|
|
943
1515
|
},
|
|
944
1516
|
registerAsset(type, value) {
|
|
1517
|
+
if (type === "preload") {
|
|
1518
|
+
registerPreloadLink(tracking, headRegistry, value, nonce);
|
|
1519
|
+
return;
|
|
1520
|
+
}
|
|
945
1521
|
if (type === "inline-style") {
|
|
946
1522
|
tracking.registerInlineStyle(value);
|
|
947
1523
|
return;
|
|
@@ -957,23 +1533,42 @@ function renderToString(code, options = {}) {
|
|
|
957
1533
|
tracking.emittedAssets.add(value);
|
|
958
1534
|
}
|
|
959
1535
|
};
|
|
960
|
-
applyAssetTracking(
|
|
1536
|
+
applyAssetTracking(sharedConfig.context, tracking, manifest, noScripts);
|
|
961
1537
|
registerEntryAssets(manifest);
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
1538
|
+
const context = sharedConfig.context;
|
|
1539
|
+
const requestEvent = peekRequestEvent();
|
|
1540
|
+
context.trace = requestEvent ? traceForEvent(requestEvent) : traceFor(context, undefined);
|
|
1541
|
+
const render = timeDocument(context, context.trace, "string", requestEvent);
|
|
1542
|
+
let dispose;
|
|
1543
|
+
let rendered = false;
|
|
1544
|
+
try {
|
|
1545
|
+
const html = createRoot(d => {
|
|
1546
|
+
dispose = d;
|
|
1547
|
+
return resolveSSRSync(escape(code()));
|
|
1548
|
+
}, {
|
|
1549
|
+
id: renderId
|
|
1550
|
+
});
|
|
1551
|
+
serializeFragmentAssets("", tracking.boundaryModules, sharedConfig.context, renderId);
|
|
1552
|
+
sharedConfig.context.noHydrate = true;
|
|
1553
|
+
serializer.close();
|
|
1554
|
+
const head = renderShellHead(headRegistry, nonce, null, noScripts, traceMetaMarkup(context.trace));
|
|
1555
|
+
const document = assembleDocument(resolveSSRSelectValues(html), tracking.emittedAssets, tracking.preloadLinks, tracking.inlineStyles, scripts.length ? scripts : "", nonce, head, onHead);
|
|
1556
|
+
if (render) render.shell();
|
|
1557
|
+
if (requestEvent && requestEvent.response) {
|
|
1558
|
+
commitResponseStub(requestEvent.response, {
|
|
1559
|
+
event: requestEvent
|
|
1560
|
+
});
|
|
1561
|
+
}
|
|
1562
|
+
rendered = true;
|
|
1563
|
+
return document;
|
|
1564
|
+
} finally {
|
|
1565
|
+
if (render) render.settle(rendered ? "complete" : "error");
|
|
1566
|
+
context.trace = undefined;
|
|
1567
|
+
if (dispose) dispose();
|
|
1568
|
+
}
|
|
973
1569
|
}
|
|
974
1570
|
function renderToStream(code, options = {}) {
|
|
975
1571
|
let {
|
|
976
|
-
nonce,
|
|
977
1572
|
onCompleteShell,
|
|
978
1573
|
onCompleteAll,
|
|
979
1574
|
renderId = "",
|
|
@@ -981,12 +1576,51 @@ function renderToStream(code, options = {}) {
|
|
|
981
1576
|
manifest,
|
|
982
1577
|
onHead
|
|
983
1578
|
} = options;
|
|
1579
|
+
const nonce = normalizeNonce(options.nonce);
|
|
1580
|
+
const requestEvent = peekRequestEvent();
|
|
984
1581
|
let dispose;
|
|
985
1582
|
let dead = false;
|
|
986
|
-
|
|
1583
|
+
let render;
|
|
1584
|
+
let serializer;
|
|
1585
|
+
let disconnected = false;
|
|
1586
|
+
let failed = false;
|
|
1587
|
+
let onFailed;
|
|
1588
|
+
const defuse = p => {
|
|
1589
|
+
if (p && typeof p.then === "function") p.then(undefined, () => {});
|
|
1590
|
+
};
|
|
1591
|
+
const abandonedSerializer = {
|
|
1592
|
+
write(_, value) {
|
|
1593
|
+
defuse(value);
|
|
1594
|
+
},
|
|
1595
|
+
flush() {},
|
|
1596
|
+
close() {}
|
|
1597
|
+
};
|
|
1598
|
+
const onFailure = complete => {
|
|
1599
|
+
if (failed) return complete(undefined);
|
|
1600
|
+
const prev = onFailed;
|
|
1601
|
+
onFailed = prev ? sink => {
|
|
1602
|
+
prev(sink);
|
|
1603
|
+
complete(sink);
|
|
1604
|
+
} : complete;
|
|
1605
|
+
};
|
|
1606
|
+
const abandon = disconnect => {
|
|
987
1607
|
if (dead) return;
|
|
1608
|
+
if (disconnect) emitFinding({
|
|
1609
|
+
code: "SSR_STREAM_ABANDONED",
|
|
1610
|
+
kind: "ssr",
|
|
1611
|
+
severity: "warn",
|
|
1612
|
+
message: `[SSR_STREAM_ABANDONED] The response stream was abandoned mid-render (${disconnect}) ` + `with ${registry.size} fragment(s) still pending; the render was torn down.`,
|
|
1613
|
+
data: {
|
|
1614
|
+
reason: disconnect,
|
|
1615
|
+
shellFlushed: firstFlushed,
|
|
1616
|
+
pendingFragments: registry.size
|
|
1617
|
+
}
|
|
1618
|
+
}, null);
|
|
988
1619
|
dead = true;
|
|
989
1620
|
completed = true;
|
|
1621
|
+
if (disconnect) disconnected = true;
|
|
1622
|
+
if (render) render.settle(disconnect ? "abandoned" : "error");
|
|
1623
|
+
const sink = writable;
|
|
990
1624
|
buffer = {
|
|
991
1625
|
write() {}
|
|
992
1626
|
};
|
|
@@ -998,32 +1632,109 @@ function renderToStream(code, options = {}) {
|
|
|
998
1632
|
dispose = () => {};
|
|
999
1633
|
d();
|
|
1000
1634
|
}
|
|
1635
|
+
if (serializer && typeof serializer.close === "function") {
|
|
1636
|
+
try {
|
|
1637
|
+
serializer.close();
|
|
1638
|
+
} catch (err) {
|
|
1639
|
+
reportServerError(err, {
|
|
1640
|
+
kind: "render",
|
|
1641
|
+
handling: "serialize"
|
|
1642
|
+
}, null, options.onError);
|
|
1643
|
+
}
|
|
1644
|
+
}
|
|
1645
|
+
serializer = abandonedSerializer;
|
|
1646
|
+
if (stubBatch) {
|
|
1647
|
+
for (const p of stubBatch.values()) defuse(p);
|
|
1648
|
+
stubBatch = null;
|
|
1649
|
+
}
|
|
1650
|
+
if (!disconnect) {
|
|
1651
|
+
failed = true;
|
|
1652
|
+
onFailed && onFailed(sink);
|
|
1653
|
+
}
|
|
1001
1654
|
};
|
|
1002
1655
|
const failRender = err => {
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1656
|
+
reportServerError(err, {
|
|
1657
|
+
kind: "render",
|
|
1658
|
+
handling: "failed"
|
|
1659
|
+
}, null);
|
|
1660
|
+
if (!options.onError && ambientServerErrorHook() === undefined) console.error(err);
|
|
1006
1661
|
abandon();
|
|
1007
1662
|
};
|
|
1663
|
+
const failRootRender = err => {
|
|
1664
|
+
emitFinding({
|
|
1665
|
+
code: "SSR_RENDER_ERROR_CONTAINED",
|
|
1666
|
+
kind: "ssr",
|
|
1667
|
+
severity: "error",
|
|
1668
|
+
message: `[SSR_RENDER_ERROR_CONTAINED] Render error outside any boundary — the request failed: ` + errorText(err),
|
|
1669
|
+
data: {
|
|
1670
|
+
handling: "failed",
|
|
1671
|
+
error: err
|
|
1672
|
+
}
|
|
1673
|
+
}, null);
|
|
1674
|
+
failRender(err);
|
|
1675
|
+
};
|
|
1676
|
+
const coalesceWrites = (writeRaw, endRaw) => {
|
|
1677
|
+
let buf = "";
|
|
1678
|
+
let scheduled = false;
|
|
1679
|
+
const flush = () => {
|
|
1680
|
+
scheduled = false;
|
|
1681
|
+
if (!buf) return;
|
|
1682
|
+
const out = buf;
|
|
1683
|
+
buf = "";
|
|
1684
|
+
writeRaw(out);
|
|
1685
|
+
};
|
|
1686
|
+
return {
|
|
1687
|
+
write(payload) {
|
|
1688
|
+
buf += payload;
|
|
1689
|
+
if (buf.length >= 16384) return flush();
|
|
1690
|
+
if (!scheduled) {
|
|
1691
|
+
scheduled = true;
|
|
1692
|
+
deferFlush(flush);
|
|
1693
|
+
}
|
|
1694
|
+
},
|
|
1695
|
+
flush,
|
|
1696
|
+
end() {
|
|
1697
|
+
flush();
|
|
1698
|
+
endRaw();
|
|
1699
|
+
}
|
|
1700
|
+
};
|
|
1701
|
+
};
|
|
1008
1702
|
const guardSink = w => ({
|
|
1009
1703
|
write(payload) {
|
|
1010
|
-
if (
|
|
1704
|
+
if (disconnected) return;
|
|
1011
1705
|
try {
|
|
1012
1706
|
w.write(payload);
|
|
1013
1707
|
} catch (_) {
|
|
1014
|
-
abandon();
|
|
1708
|
+
abandon("sink");
|
|
1015
1709
|
}
|
|
1016
1710
|
},
|
|
1017
1711
|
end() {
|
|
1018
|
-
if (
|
|
1712
|
+
if (disconnected) return;
|
|
1019
1713
|
try {
|
|
1020
1714
|
w.end();
|
|
1021
1715
|
} catch (_) {
|
|
1022
|
-
abandon();
|
|
1716
|
+
abandon("sink");
|
|
1023
1717
|
}
|
|
1024
1718
|
}
|
|
1025
1719
|
});
|
|
1026
1720
|
const blockingPromises = new Set();
|
|
1721
|
+
const canBatchStubs = !options.serializer && !options.sink;
|
|
1722
|
+
let stubBatch = null;
|
|
1723
|
+
const STUB_BATCH_KEY = "$B";
|
|
1724
|
+
const flushStubBatch = () => {
|
|
1725
|
+
if (!stubBatch) return;
|
|
1726
|
+
const batch = stubBatch;
|
|
1727
|
+
stubBatch = null;
|
|
1728
|
+
if (batch.size === 1) {
|
|
1729
|
+
const [id, p] = batch.entries().next().value;
|
|
1730
|
+
serializer.write(id, p);
|
|
1731
|
+
return;
|
|
1732
|
+
}
|
|
1733
|
+
const obj = {};
|
|
1734
|
+
for (const [id, p] of batch) obj[id] = p;
|
|
1735
|
+
serializer.write(STUB_BATCH_KEY, obj);
|
|
1736
|
+
pushTask(`(b=>{for(var k in b)_$HY.r[k]=b[k];delete _$HY.r["${STUB_BATCH_KEY}"]})(_$HY.r["${STUB_BATCH_KEY}"])`);
|
|
1737
|
+
};
|
|
1027
1738
|
let headerEmitted = false;
|
|
1028
1739
|
const pushTask = task => {
|
|
1029
1740
|
if (noScripts) return;
|
|
@@ -1038,7 +1749,9 @@ function renderToStream(code, options = {}) {
|
|
|
1038
1749
|
}
|
|
1039
1750
|
};
|
|
1040
1751
|
const onDone = () => {
|
|
1752
|
+
if (dead) return;
|
|
1041
1753
|
writeTasks();
|
|
1754
|
+
lastBlockingSize = blockingPromises.size;
|
|
1042
1755
|
doShell();
|
|
1043
1756
|
onCompleteAll && onCompleteAll({
|
|
1044
1757
|
write(v) {
|
|
@@ -1047,6 +1760,7 @@ function renderToStream(code, options = {}) {
|
|
|
1047
1760
|
});
|
|
1048
1761
|
writable && writable.end();
|
|
1049
1762
|
completed = true;
|
|
1763
|
+
if (render) render.settle("complete");
|
|
1050
1764
|
if (firstFlushed) dispose();
|
|
1051
1765
|
};
|
|
1052
1766
|
const sink = {
|
|
@@ -1060,10 +1774,11 @@ function renderToStream(code, options = {}) {
|
|
|
1060
1774
|
buffer.write(renderInlineStyle(styles.inline[i], nonce));
|
|
1061
1775
|
}
|
|
1062
1776
|
if (styles.links.length) {
|
|
1777
|
+
const styleAttr = nonceAttr(nonce, "style");
|
|
1063
1778
|
emitTask(`$dfs("${key}",${styles.links.length},${deferActivation ? 1 : 0})`);
|
|
1064
1779
|
writeTasks();
|
|
1065
1780
|
for (const entry of styles.links) {
|
|
1066
|
-
buffer.write(typeof entry === "string" ? `<link rel="stylesheet" href="${entry}" onload="$dfc('${key}')" onerror="$dfc('${key}')">` : `<link${entry.attrHtml} onload="$dfc('${key}')" onerror="$dfc('${key}')">`);
|
|
1781
|
+
buffer.write(typeof entry === "string" ? `<link rel="stylesheet" href="${entry}"${styleAttr} onload="$dfc('${key}')" onerror="$dfc('${key}')">` : `<link${entry.attrHtml}${styleAttr} onload="$dfc('${key}')" onerror="$dfc('${key}')">`);
|
|
1067
1782
|
}
|
|
1068
1783
|
buffer.write(`<template id="${key}">${value}</template>`);
|
|
1069
1784
|
} else {
|
|
@@ -1078,7 +1793,9 @@ function renderToStream(code, options = {}) {
|
|
|
1078
1793
|
},
|
|
1079
1794
|
asset(type, value) {
|
|
1080
1795
|
if (type === "module") {
|
|
1081
|
-
buffer.write(`<link rel="modulepreload" href="${value}">`);
|
|
1796
|
+
buffer.write(`<link rel="modulepreload" href="${value}"${nonceAttr(nonce, "script")}>`);
|
|
1797
|
+
} else if (type === "preload") {
|
|
1798
|
+
buffer.write(`<link${value.attrHtml}>`);
|
|
1082
1799
|
} else if (type === "inline-style") {
|
|
1083
1800
|
buffer.write(renderInlineStyle(value, nonce));
|
|
1084
1801
|
} else if (type === "head-tag") {
|
|
@@ -1086,16 +1803,16 @@ function renderToStream(code, options = {}) {
|
|
|
1086
1803
|
}
|
|
1087
1804
|
},
|
|
1088
1805
|
shell(shellHtml, meta) {
|
|
1089
|
-
buffer.write(assembleDocument(shellHtml, meta.preloads, meta.inlineStyles, meta.tasks.length ? meta.tasks : "", nonce, meta.head, onHead));
|
|
1806
|
+
buffer.write(assembleDocument(shellHtml, meta.preloads, meta.preloadLinks, meta.inlineStyles, meta.tasks.length ? meta.tasks : "", nonce, meta.head, onHead));
|
|
1090
1807
|
},
|
|
1091
1808
|
...options.sink
|
|
1092
1809
|
};
|
|
1093
|
-
|
|
1810
|
+
serializer = (options.serializer || createHydrationSerializer)({
|
|
1094
1811
|
scopeId: options.renderId,
|
|
1095
1812
|
plugins: options.plugins,
|
|
1096
1813
|
onData: payload => sink.data(payload),
|
|
1097
1814
|
onDone,
|
|
1098
|
-
onError: options.onError
|
|
1815
|
+
onError: serializerErrorHook(options.onError)
|
|
1099
1816
|
});
|
|
1100
1817
|
let rootAssetsSerialized = false;
|
|
1101
1818
|
const serializeRootAssets = () => {
|
|
@@ -1113,14 +1830,102 @@ function renderToStream(code, options = {}) {
|
|
|
1113
1830
|
context.live.end = null;
|
|
1114
1831
|
end();
|
|
1115
1832
|
}
|
|
1833
|
+
flushStubBatch();
|
|
1116
1834
|
serializer.flush();
|
|
1117
1835
|
}));
|
|
1118
1836
|
}
|
|
1119
1837
|
};
|
|
1120
1838
|
const registry = new Map();
|
|
1839
|
+
const pendingSerialized = new Map();
|
|
1840
|
+
const guardedChannels = new WeakMap();
|
|
1841
|
+
const verdictNow = error => {
|
|
1842
|
+
throw ssrSanitizeError(error, null);
|
|
1843
|
+
};
|
|
1844
|
+
const borderForm = value => toBorderForm(value);
|
|
1845
|
+
const guardIterable = iterable => ({
|
|
1846
|
+
[Symbol.asyncIterator]() {
|
|
1847
|
+
const iterator = iterable[Symbol.asyncIterator]();
|
|
1848
|
+
return {
|
|
1849
|
+
next: value => iterator.next(value).then(undefined, verdictNow),
|
|
1850
|
+
return: value => iterator.return ? iterator.return(value) : Promise.resolve({
|
|
1851
|
+
done: true,
|
|
1852
|
+
value
|
|
1853
|
+
}),
|
|
1854
|
+
throw: error => iterator.throw ? iterator.throw(error) : Promise.reject(error)
|
|
1855
|
+
};
|
|
1856
|
+
}
|
|
1857
|
+
});
|
|
1858
|
+
const guardStream = source => {
|
|
1859
|
+
const reader = source.getReader();
|
|
1860
|
+
return new ReadableStream({
|
|
1861
|
+
pull: c => reader.read().then(r => r.done ? c.close() : c.enqueue(r.value), e => {
|
|
1862
|
+
try {
|
|
1863
|
+
verdictNow(e);
|
|
1864
|
+
} catch (sanitized) {
|
|
1865
|
+
c.error(sanitized);
|
|
1866
|
+
}
|
|
1867
|
+
}),
|
|
1868
|
+
cancel: reason => reader.cancel(reason)
|
|
1869
|
+
});
|
|
1870
|
+
};
|
|
1871
|
+
const guardChannel = p => {
|
|
1872
|
+
if (!p || typeof p !== "object" || "__SEROVAL_STREAM__" in p) return p;
|
|
1873
|
+
let guarded = guardedChannels.get(p);
|
|
1874
|
+
if (guarded !== undefined) return guarded;
|
|
1875
|
+
if (typeof p.then === "function") {
|
|
1876
|
+
guarded = p.then(borderForm, verdictNow);
|
|
1877
|
+
} else if (typeof ReadableStream === "function" && p instanceof ReadableStream) {
|
|
1878
|
+
guarded = guardStream(p);
|
|
1879
|
+
} else {
|
|
1880
|
+
const border = borderForm(p);
|
|
1881
|
+
guarded = typeof border[Symbol.asyncIterator] === "function" ? guardIterable(border) : border;
|
|
1882
|
+
if (guarded === p) return p;
|
|
1883
|
+
}
|
|
1884
|
+
guardedChannels.set(p, guarded);
|
|
1885
|
+
return guarded;
|
|
1886
|
+
};
|
|
1887
|
+
const trackSerialized = (id, p) => {
|
|
1888
|
+
let settle;
|
|
1889
|
+
const raced = Promise.race([p, new Promise(r => settle = r)]);
|
|
1890
|
+
raced.catch(() => {});
|
|
1891
|
+
pendingSerialized.set(id, settle);
|
|
1892
|
+
const drop = () => pendingSerialized.delete(id);
|
|
1893
|
+
p.then(drop, drop);
|
|
1894
|
+
return raced;
|
|
1895
|
+
};
|
|
1896
|
+
const abandonSubtree = (key, error) => {
|
|
1897
|
+
let fragments = 0;
|
|
1898
|
+
let serialized = 0;
|
|
1899
|
+
for (const [k, entry] of registry) {
|
|
1900
|
+
if (k.length > key.length && k.startsWith(key)) {
|
|
1901
|
+
registry.delete(k);
|
|
1902
|
+
entry.resolve();
|
|
1903
|
+
fragments++;
|
|
1904
|
+
}
|
|
1905
|
+
}
|
|
1906
|
+
for (const [id, settle] of pendingSerialized) {
|
|
1907
|
+
if (id.startsWith(key)) {
|
|
1908
|
+
pendingSerialized.delete(id);
|
|
1909
|
+
settle();
|
|
1910
|
+
serialized++;
|
|
1911
|
+
}
|
|
1912
|
+
}
|
|
1913
|
+
if ((fragments || serialized)) emitFinding({
|
|
1914
|
+
code: "SSR_SUBTREE_ABANDONED",
|
|
1915
|
+
kind: "ssr",
|
|
1916
|
+
severity: "warn",
|
|
1917
|
+
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.`,
|
|
1918
|
+
data: {
|
|
1919
|
+
fragment: key,
|
|
1920
|
+
fragments,
|
|
1921
|
+
serialized,
|
|
1922
|
+
error
|
|
1923
|
+
}
|
|
1924
|
+
}, null);
|
|
1925
|
+
};
|
|
1121
1926
|
const writeTasks = () => {
|
|
1122
1927
|
if (tasks.length && !completed && firstFlushed) {
|
|
1123
|
-
buffer.write(`<script${nonce
|
|
1928
|
+
buffer.write(`<script${nonceAttr(nonce, "script")}>${tasks}</script>`);
|
|
1124
1929
|
tasks = "";
|
|
1125
1930
|
}
|
|
1126
1931
|
timer = null;
|
|
@@ -1172,9 +1977,10 @@ function renderToStream(code, options = {}) {
|
|
|
1172
1977
|
emitTask(`${!headScriptFlushed ? HEAD_SCRIPT : ""}(_$HY.hp=_$HY.hp||{})[${JSON.stringify(key)}]=${payload}`);
|
|
1173
1978
|
headScriptFlushed = true;
|
|
1174
1979
|
};
|
|
1175
|
-
|
|
1980
|
+
sharedConfig.context = context = {
|
|
1176
1981
|
async: true,
|
|
1177
|
-
nonce,
|
|
1982
|
+
nonce: options.nonce,
|
|
1983
|
+
document: !options.sink,
|
|
1178
1984
|
live: {},
|
|
1179
1985
|
registerHeadTags(tags) {
|
|
1180
1986
|
registerHeadTags(headRegistry, context, tracking,
|
|
@@ -1188,6 +1994,11 @@ function renderToStream(code, options = {}) {
|
|
|
1188
1994
|
}, nonce, tags);
|
|
1189
1995
|
},
|
|
1190
1996
|
registerAsset(type, value) {
|
|
1997
|
+
if (type === "preload") {
|
|
1998
|
+
const entry = registerPreloadLink(tracking, headRegistry, value, nonce);
|
|
1999
|
+
if (entry && firstFlushed) sink.asset("preload", entry);
|
|
2000
|
+
return;
|
|
2001
|
+
}
|
|
1191
2002
|
if (type === "inline-style") {
|
|
1192
2003
|
const entry = tracking.registerInlineStyle(value);
|
|
1193
2004
|
if (firstFlushed && !tracking.currentBoundaryId && !entry.emitted) {
|
|
@@ -1231,11 +2042,21 @@ function renderToStream(code, options = {}) {
|
|
|
1231
2042
|
html = html.slice(0, first) + resolveSSRSync(escape(payloadFn())) + html.slice(last + placeholder.length + 1);
|
|
1232
2043
|
},
|
|
1233
2044
|
serialize(id, p, deferStream) {
|
|
1234
|
-
if (
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
2045
|
+
if (sharedConfig.context.noHydrate) return;
|
|
2046
|
+
p = guardChannel(p);
|
|
2047
|
+
if (p && typeof p === "object" && typeof p.then === "function") {
|
|
2048
|
+
if (!firstFlushed && deferStream) {
|
|
2049
|
+
blockingPromises.add(p);
|
|
2050
|
+
p.then(d => serializer.write(id, d)).catch(e => serializer.write(id, e));
|
|
2051
|
+
return;
|
|
2052
|
+
}
|
|
2053
|
+
p = trackSerialized(id, p);
|
|
2054
|
+
if (!firstFlushed && canBatchStubs && !shellCompleted && !dead) {
|
|
2055
|
+
(stubBatch ||= new Map()).set(id, p);
|
|
2056
|
+
return;
|
|
2057
|
+
}
|
|
2058
|
+
}
|
|
2059
|
+
serializer.write(id, p);
|
|
1239
2060
|
},
|
|
1240
2061
|
escape: escape,
|
|
1241
2062
|
resolve: resolveSSRNode,
|
|
@@ -1263,19 +2084,21 @@ function renderToStream(code, options = {}) {
|
|
|
1263
2084
|
if (!registry.has(key)) {
|
|
1264
2085
|
let resolve, reject;
|
|
1265
2086
|
const p = new Promise((r, rej) => (resolve = r, reject = rej));
|
|
2087
|
+
defuse(p);
|
|
1266
2088
|
registry.set(key, {
|
|
1267
2089
|
resolve: err => queue(() => queue(() => {
|
|
1268
|
-
err ? reject(err) : resolve(true);
|
|
2090
|
+
err ? reject(ssrSanitizeError(err, null)) : resolve(true);
|
|
1269
2091
|
queue(flushEnd);
|
|
1270
2092
|
}))
|
|
1271
2093
|
});
|
|
1272
|
-
serializer.write(key + "_fr", p);
|
|
2094
|
+
if (canBatchStubs && !shellCompleted && !dead) (stubBatch ||= new Map()).set(key + "_fr", p);else serializer.write(key + "_fr", p);
|
|
1273
2095
|
}
|
|
1274
2096
|
return (value, error) => {
|
|
1275
2097
|
if (registry.has(key)) {
|
|
1276
2098
|
const item = registry.get(key);
|
|
1277
2099
|
registry.delete(key);
|
|
1278
|
-
if (
|
|
2100
|
+
if (error) abandonSubtree(key, error);
|
|
2101
|
+
if (item.children && !error) {
|
|
1279
2102
|
for (const k in item.children) {
|
|
1280
2103
|
value = replacePlaceholder(value, k, item.children[k]);
|
|
1281
2104
|
}
|
|
@@ -1300,12 +2123,12 @@ function renderToStream(code, options = {}) {
|
|
|
1300
2123
|
} else {
|
|
1301
2124
|
serializeFragmentAssets(key, tracking.boundaryModules, context);
|
|
1302
2125
|
const styles = collectStreamStyles(key, tracking, headStyles);
|
|
1303
|
-
const headOps = error ? null : flushHeadFragment(headRegistry, key);
|
|
2126
|
+
const headOps = error ? null : flushHeadFragment(headRegistry, key, nonce);
|
|
1304
2127
|
if (headOps) emitHeadOps(key, headOps);
|
|
1305
2128
|
sink.fragment(key, resolveSSRSelectValues(value !== undefined ? value : " "), {
|
|
1306
2129
|
styles,
|
|
1307
2130
|
revealGroup,
|
|
1308
|
-
error
|
|
2131
|
+
error: error ? ssrSanitizeError(error, null) : error
|
|
1309
2132
|
});
|
|
1310
2133
|
item.resolve(error);
|
|
1311
2134
|
}
|
|
@@ -1331,9 +2154,19 @@ function renderToStream(code, options = {}) {
|
|
|
1331
2154
|
};
|
|
1332
2155
|
applyAssetTracking(context, tracking, manifest, noScripts);
|
|
1333
2156
|
context.failRender = failRender;
|
|
2157
|
+
context.errorPolicy = options.onError;
|
|
2158
|
+
context.flushed = () => firstFlushed;
|
|
2159
|
+
context.trace = requestEvent ? traceForEvent(requestEvent) : traceFor(context, undefined);
|
|
2160
|
+
render = timeDocument(context, context.trace, "stream", requestEvent);
|
|
1334
2161
|
registerEntryAssets(manifest);
|
|
1335
|
-
|
|
1336
|
-
|
|
2162
|
+
const signal = options.signal;
|
|
2163
|
+
const onAbort = signal ? () => abandon("signal") : undefined;
|
|
2164
|
+
let html = createRoot(d => {
|
|
2165
|
+
dispose = () => {
|
|
2166
|
+
context.trace = undefined;
|
|
2167
|
+
if (onAbort) signal.removeEventListener("abort", onAbort);
|
|
2168
|
+
d();
|
|
2169
|
+
};
|
|
1337
2170
|
const res = resolveSSRNode(escape(code()));
|
|
1338
2171
|
if (!res.h.length) return res.t[0];
|
|
1339
2172
|
rootHoles = [];
|
|
@@ -1351,6 +2184,11 @@ function renderToStream(code, options = {}) {
|
|
|
1351
2184
|
}, {
|
|
1352
2185
|
id: renderId
|
|
1353
2186
|
});
|
|
2187
|
+
if (onAbort) {
|
|
2188
|
+
if (signal.aborted) onAbort();else signal.addEventListener("abort", onAbort, {
|
|
2189
|
+
once: true
|
|
2190
|
+
});
|
|
2191
|
+
}
|
|
1354
2192
|
function resolveRootHoles() {
|
|
1355
2193
|
if (!rootHoles) return true;
|
|
1356
2194
|
const pending = [];
|
|
@@ -1385,17 +2223,22 @@ function renderToStream(code, options = {}) {
|
|
|
1385
2223
|
}
|
|
1386
2224
|
function doShell() {
|
|
1387
2225
|
if (shellCompleted) return;
|
|
1388
|
-
|
|
2226
|
+
sharedConfig.context = context;
|
|
2227
|
+
if (blockingPromises.size !== lastBlockingSize) return;
|
|
1389
2228
|
if (!resolveRootHoles()) return;
|
|
2229
|
+
if (blockingPromises.size !== lastBlockingSize) return;
|
|
1390
2230
|
if (!headShellReady(headRegistry, p => blockingPromises.add(p))) return;
|
|
1391
2231
|
headStyles = new Set();
|
|
1392
2232
|
for (const url of tracking.emittedAssets) {
|
|
1393
2233
|
if (isCssUrl(url)) headStyles.add(url);
|
|
1394
2234
|
}
|
|
1395
2235
|
serializeRootAssets();
|
|
1396
|
-
|
|
2236
|
+
flushStubBatch();
|
|
2237
|
+
const head = renderShellHead(headRegistry, nonce, k => registry.has(k), noScripts, traceMetaMarkup(context.trace));
|
|
2238
|
+
if (render) render.shell();
|
|
1397
2239
|
sink.shell(resolveSSRSelectValues(html), {
|
|
1398
2240
|
preloads: tracking.emittedAssets,
|
|
2241
|
+
preloadLinks: tracking.preloadLinks,
|
|
1399
2242
|
inlineStyles: tracking.inlineStyles,
|
|
1400
2243
|
tasks,
|
|
1401
2244
|
head
|
|
@@ -1412,8 +2255,9 @@ function renderToStream(code, options = {}) {
|
|
|
1412
2255
|
let lastBlockingSize = -1;
|
|
1413
2256
|
let lastRegistrySize = -1;
|
|
1414
2257
|
let drainTurn = 0;
|
|
1415
|
-
const scheduleFlush = fn => {
|
|
2258
|
+
const scheduleFlush = (fn, awaited) => {
|
|
1416
2259
|
const attempt = () => {
|
|
2260
|
+
flushStubBatch();
|
|
1417
2261
|
if (registry.size !== lastRegistrySize || drainTurn++ < MIN_DRAIN_TURNS) {
|
|
1418
2262
|
if (registry.size !== lastRegistrySize) drainTurn = 0;
|
|
1419
2263
|
lastRegistrySize = registry.size;
|
|
@@ -1422,8 +2266,8 @@ function renderToStream(code, options = {}) {
|
|
|
1422
2266
|
}
|
|
1423
2267
|
fn();
|
|
1424
2268
|
};
|
|
1425
|
-
const progressed =
|
|
1426
|
-
lastBlockingSize =
|
|
2269
|
+
const progressed = awaited !== lastBlockingSize;
|
|
2270
|
+
lastBlockingSize = awaited;
|
|
1427
2271
|
lastRegistrySize = -1;
|
|
1428
2272
|
drainTurn = 0;
|
|
1429
2273
|
progressed ? queue(attempt) : setTimeout(attempt);
|
|
@@ -1439,15 +2283,21 @@ function renderToStream(code, options = {}) {
|
|
|
1439
2283
|
const pipeToImpl = w => {
|
|
1440
2284
|
let resolve;
|
|
1441
2285
|
const p = new Promise(r => resolve = r);
|
|
2286
|
+
onFailure(sink => {
|
|
2287
|
+
try {
|
|
2288
|
+
if (sink) sink.end();else w.close().catch(() => {});
|
|
2289
|
+
} catch (_) {}
|
|
2290
|
+
resolve();
|
|
2291
|
+
});
|
|
1442
2292
|
function flush() {
|
|
1443
|
-
allSettled(blockingPromises).then(
|
|
2293
|
+
allSettled(blockingPromises).then(awaited => {
|
|
1444
2294
|
scheduleFlush(() => {
|
|
1445
2295
|
if (dead) return resolve();
|
|
1446
2296
|
try {
|
|
1447
2297
|
doShell();
|
|
1448
2298
|
} catch (err) {
|
|
1449
|
-
|
|
1450
|
-
return
|
|
2299
|
+
failRootRender(err);
|
|
2300
|
+
return;
|
|
1451
2301
|
}
|
|
1452
2302
|
if (!shellCompleted) return flush();
|
|
1453
2303
|
const encoder = new TextEncoder();
|
|
@@ -1456,33 +2306,29 @@ function renderToStream(code, options = {}) {
|
|
|
1456
2306
|
let ended = false;
|
|
1457
2307
|
const failed = () => {
|
|
1458
2308
|
if (!ended) {
|
|
1459
|
-
abandon();
|
|
2309
|
+
abandon("consumer");
|
|
1460
2310
|
resolve();
|
|
1461
2311
|
}
|
|
1462
2312
|
};
|
|
1463
2313
|
writer.closed && writer.closed.catch(failed);
|
|
1464
|
-
writable = {
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
}
|
|
1473
|
-
};
|
|
1474
|
-
buffer = {
|
|
1475
|
-
write(payload) {
|
|
1476
|
-
pendingWrites = pendingWrites.then(() => writer.write(encoder.encode(payload))).catch(failed);
|
|
1477
|
-
}
|
|
1478
|
-
};
|
|
2314
|
+
buffer = writable = coalesceWrites(payload => {
|
|
2315
|
+
pendingWrites = pendingWrites.then(() => writer.write(encoder.encode(payload))).catch(failed);
|
|
2316
|
+
}, () => {
|
|
2317
|
+
pendingWrites.then(() => {
|
|
2318
|
+
ended = true;
|
|
2319
|
+
writer.releaseLock();
|
|
2320
|
+
w.close().catch(() => {});
|
|
2321
|
+
resolve();
|
|
2322
|
+
});
|
|
2323
|
+
});
|
|
1479
2324
|
buffer.write(tmp);
|
|
2325
|
+
buffer.flush();
|
|
1480
2326
|
firstFlushed = true;
|
|
1481
2327
|
if (completed) {
|
|
1482
2328
|
dispose();
|
|
1483
2329
|
writable.end();
|
|
1484
2330
|
} else flushEnd();
|
|
1485
|
-
});
|
|
2331
|
+
}, awaited);
|
|
1486
2332
|
});
|
|
1487
2333
|
}
|
|
1488
2334
|
flush();
|
|
@@ -1490,8 +2336,14 @@ function renderToStream(code, options = {}) {
|
|
|
1490
2336
|
};
|
|
1491
2337
|
return {
|
|
1492
2338
|
then(onFulfilled, onRejected) {
|
|
2339
|
+
const freezeHead = () => {
|
|
2340
|
+
if (requestEvent && requestEvent.response) commitResponseStub(requestEvent.response, {
|
|
2341
|
+
event: requestEvent
|
|
2342
|
+
});
|
|
2343
|
+
};
|
|
1493
2344
|
const p = new Promise(resolve => {
|
|
1494
2345
|
function complete() {
|
|
2346
|
+
freezeHead();
|
|
1495
2347
|
dispose();
|
|
1496
2348
|
resolve(tmp);
|
|
1497
2349
|
}
|
|
@@ -1502,17 +2354,19 @@ function renderToStream(code, options = {}) {
|
|
|
1502
2354
|
complete();
|
|
1503
2355
|
};
|
|
1504
2356
|
} else onCompleteAll = complete;
|
|
2357
|
+
onFailure(() => resolve(tmp));
|
|
1505
2358
|
function flush() {
|
|
1506
|
-
allSettled(blockingPromises).then(
|
|
2359
|
+
allSettled(blockingPromises).then(awaited => {
|
|
1507
2360
|
scheduleFlush(() => {
|
|
2361
|
+
if (dead) return;
|
|
1508
2362
|
try {
|
|
1509
|
-
if (!resolveRootHoles() || !headShellReady(headRegistry, p => blockingPromises.add(p))) return flush();
|
|
2363
|
+
if (blockingPromises.size !== lastBlockingSize || !resolveRootHoles() || blockingPromises.size !== lastBlockingSize || !headShellReady(headRegistry, p => blockingPromises.add(p))) return flush();
|
|
1510
2364
|
} catch (err) {
|
|
1511
|
-
|
|
1512
|
-
return
|
|
2365
|
+
failRootRender(err);
|
|
2366
|
+
return;
|
|
1513
2367
|
}
|
|
1514
2368
|
queue(flushEnd);
|
|
1515
|
-
});
|
|
2369
|
+
}, awaited);
|
|
1516
2370
|
});
|
|
1517
2371
|
}
|
|
1518
2372
|
flush();
|
|
@@ -1521,28 +2375,32 @@ function renderToStream(code, options = {}) {
|
|
|
1521
2375
|
},
|
|
1522
2376
|
pipe(w) {
|
|
1523
2377
|
claimConsumer("pipe");
|
|
2378
|
+
onFailure(sink => {
|
|
2379
|
+
try {
|
|
2380
|
+
sink ? sink.end() : w.end();
|
|
2381
|
+
} catch (_) {}
|
|
2382
|
+
});
|
|
1524
2383
|
function flush() {
|
|
1525
|
-
allSettled(blockingPromises).then(
|
|
2384
|
+
allSettled(blockingPromises).then(awaited => {
|
|
1526
2385
|
scheduleFlush(() => {
|
|
1527
2386
|
if (dead) return;
|
|
1528
2387
|
try {
|
|
1529
2388
|
doShell();
|
|
1530
2389
|
} catch (err) {
|
|
1531
|
-
|
|
1532
|
-
try {
|
|
1533
|
-
w.end();
|
|
1534
|
-
} catch (_) {}
|
|
2390
|
+
failRootRender(err);
|
|
1535
2391
|
return;
|
|
1536
2392
|
}
|
|
1537
2393
|
if (!shellCompleted) return flush();
|
|
1538
|
-
|
|
2394
|
+
const sink = guardSink(w);
|
|
2395
|
+
buffer = writable = coalesceWrites(sink.write, sink.end);
|
|
1539
2396
|
buffer.write(tmp);
|
|
2397
|
+
buffer.flush();
|
|
1540
2398
|
firstFlushed = true;
|
|
1541
2399
|
if (completed) {
|
|
1542
2400
|
dispose();
|
|
1543
2401
|
writable.end();
|
|
1544
2402
|
} else flushEnd();
|
|
1545
|
-
});
|
|
2403
|
+
}, awaited);
|
|
1546
2404
|
});
|
|
1547
2405
|
}
|
|
1548
2406
|
flush();
|
|
@@ -1563,9 +2421,7 @@ function renderToStream(code, options = {}) {
|
|
|
1563
2421
|
};
|
|
1564
2422
|
}
|
|
1565
2423
|
function HydrationScript(props) {
|
|
1566
|
-
const
|
|
1567
|
-
nonce
|
|
1568
|
-
} = solidJs.sharedConfig.context;
|
|
2424
|
+
const nonce = scriptNonce(sharedConfig.context && sharedConfig.context.nonce);
|
|
1569
2425
|
return ssr(generateHydrationScript({
|
|
1570
2426
|
nonce,
|
|
1571
2427
|
...props
|
|
@@ -1576,14 +2432,14 @@ function ssrGroup(fn, n) {
|
|
|
1576
2432
|
return fn;
|
|
1577
2433
|
}
|
|
1578
2434
|
function buildAsyncWrap(err, node) {
|
|
1579
|
-
const p =
|
|
2435
|
+
const p = ssrHandleError(err);
|
|
1580
2436
|
if (!p) return null;
|
|
1581
2437
|
if (node.$rw) return {
|
|
1582
2438
|
fn: node,
|
|
1583
2439
|
p
|
|
1584
2440
|
};
|
|
1585
|
-
const owner =
|
|
1586
|
-
const live =
|
|
2441
|
+
const owner = getOwner();
|
|
2442
|
+
const live = sharedConfig.context && sharedConfig.context.liveHoles;
|
|
1587
2443
|
const suppress = node.$lhSuppress || live && (live.suppressed || live.sweeping);
|
|
1588
2444
|
if (!owner) {
|
|
1589
2445
|
if (suppress) node.$lhSuppress = true;
|
|
@@ -1592,7 +2448,7 @@ function buildAsyncWrap(err, node) {
|
|
|
1592
2448
|
p
|
|
1593
2449
|
};
|
|
1594
2450
|
}
|
|
1595
|
-
const fn = () =>
|
|
2451
|
+
const fn = () => runWithOwner(owner, node);
|
|
1596
2452
|
fn.$rw = true;
|
|
1597
2453
|
if (suppress) fn.$lhSuppress = true;
|
|
1598
2454
|
if (node.$lhSkip) fn.$lhSkip = true;
|
|
@@ -1658,6 +2514,10 @@ function ssrGroupSlot(fn, idx) {
|
|
|
1658
2514
|
}
|
|
1659
2515
|
};
|
|
1660
2516
|
}
|
|
2517
|
+
function wireErrorMessage(err) {
|
|
2518
|
+
const wire = ssrSanitizeError(err, null);
|
|
2519
|
+
return String(wire && wire.message || wire);
|
|
2520
|
+
}
|
|
1661
2521
|
const holePositionCache = new WeakMap();
|
|
1662
2522
|
function holeContentPositions(t) {
|
|
1663
2523
|
let cached = holePositionCache.get(t);
|
|
@@ -1719,9 +2579,18 @@ function holeContentPositions(t) {
|
|
|
1719
2579
|
}
|
|
1720
2580
|
function createLiveHoles(sink, scoped) {
|
|
1721
2581
|
let nextId = 0;
|
|
1722
|
-
const stamp = typeof
|
|
1723
|
-
const inScope = scoped && typeof
|
|
2582
|
+
const stamp = typeof creationStamp === "function" ? creationStamp : () => 0;
|
|
2583
|
+
const inScope = scoped && typeof inServerComponentScope === "function" ? inServerComponentScope : null;
|
|
1724
2584
|
const stripMarkers = html => html.replace(/<!--lh:\/?\d+-->/g, "");
|
|
2585
|
+
const swept = (owner, ctx, fn) => {
|
|
2586
|
+
const prev = sharedConfig.context;
|
|
2587
|
+
sharedConfig.context = ctx;
|
|
2588
|
+
try {
|
|
2589
|
+
return owner ? runWithOwner(owner, fn) : fn();
|
|
2590
|
+
} finally {
|
|
2591
|
+
sharedConfig.context = prev;
|
|
2592
|
+
}
|
|
2593
|
+
};
|
|
1725
2594
|
function resolveHoleValue(hole) {
|
|
1726
2595
|
const result = {
|
|
1727
2596
|
t: [""],
|
|
@@ -1786,7 +2655,8 @@ function createLiveHoles(sink, scoped) {
|
|
|
1786
2655
|
if (inScope && !inScope()) return null;
|
|
1787
2656
|
const recordsBefore = engine.recordStamp;
|
|
1788
2657
|
const ownersBefore = stamp();
|
|
1789
|
-
const owner =
|
|
2658
|
+
const owner = getOwner();
|
|
2659
|
+
const holeCtx = sharedConfig.context;
|
|
1790
2660
|
const b = {
|
|
1791
2661
|
key: null,
|
|
1792
2662
|
children: [],
|
|
@@ -1800,11 +2670,11 @@ function createLiveHoles(sink, scoped) {
|
|
|
1800
2670
|
const sweepOwnersBefore = stamp();
|
|
1801
2671
|
let res;
|
|
1802
2672
|
try {
|
|
1803
|
-
res =
|
|
2673
|
+
res = swept(owner, holeCtx, () => resolveHoleValue(hole));
|
|
1804
2674
|
} catch (err) {
|
|
1805
2675
|
b.closed = true;
|
|
1806
2676
|
sink.closeBinding(b.key);
|
|
1807
|
-
sink.error(b.key,
|
|
2677
|
+
sink.error(b.key, wireErrorMessage(err));
|
|
1808
2678
|
return;
|
|
1809
2679
|
} finally {
|
|
1810
2680
|
engine.sweeping = prevSweeping;
|
|
@@ -1907,7 +2777,8 @@ function createLiveHoles(sink, scoped) {
|
|
|
1907
2777
|
return !inScope || inScope();
|
|
1908
2778
|
},
|
|
1909
2779
|
attr(cap) {
|
|
1910
|
-
const owner =
|
|
2780
|
+
const owner = getOwner();
|
|
2781
|
+
const holeCtx = sharedConfig.context;
|
|
1911
2782
|
const b = {
|
|
1912
2783
|
key: "lha:" + cap.id,
|
|
1913
2784
|
children: [],
|
|
@@ -1943,12 +2814,12 @@ function createLiveHoles(sink, scoped) {
|
|
|
1943
2814
|
if (vt === "string" || vt === "number") html += v;
|
|
1944
2815
|
}
|
|
1945
2816
|
};
|
|
1946
|
-
|
|
2817
|
+
swept(owner, holeCtx, run);
|
|
1947
2818
|
} catch (err) {
|
|
1948
|
-
if (
|
|
2819
|
+
if (ssrHandleError(err, true)) return;
|
|
1949
2820
|
b.closed = true;
|
|
1950
2821
|
sink.closeBinding(b.key);
|
|
1951
|
-
sink.error("lha:" + cap.id,
|
|
2822
|
+
sink.error("lha:" + cap.id, wireErrorMessage(err));
|
|
1952
2823
|
return;
|
|
1953
2824
|
} finally {
|
|
1954
2825
|
engine.sweeping = prevSweeping;
|
|
@@ -1966,6 +2837,7 @@ function createLiveHoles(sink, scoped) {
|
|
|
1966
2837
|
sink.attr(String(cap.id), html, removed);
|
|
1967
2838
|
}
|
|
1968
2839
|
};
|
|
2840
|
+
if (sink.attrBaseline) sink.attrBaseline(b.key, cap.base);
|
|
1969
2841
|
sink.openBinding(b.key, b);
|
|
1970
2842
|
}
|
|
1971
2843
|
};
|
|
@@ -1988,7 +2860,7 @@ function ssr(t) {
|
|
|
1988
2860
|
let lastGroup = null;
|
|
1989
2861
|
let lastGroupVal = null;
|
|
1990
2862
|
let lastGroupIdx = 0;
|
|
1991
|
-
const live =
|
|
2863
|
+
const live = sharedConfig.context && sharedConfig.context.liveHoles;
|
|
1992
2864
|
const hp = live ? holeContentPositions(t) : null;
|
|
1993
2865
|
let lastOpen = null;
|
|
1994
2866
|
let cap = null;
|
|
@@ -2204,6 +3076,7 @@ function ssr(t) {
|
|
|
2204
3076
|
return result;
|
|
2205
3077
|
}
|
|
2206
3078
|
function ssrClassName(value) {
|
|
3079
|
+
if (typeof value === "number") return "" + value;
|
|
2207
3080
|
if (!value) return "";
|
|
2208
3081
|
if (typeof value === "string") return escape(value, true);
|
|
2209
3082
|
value = classListToObject(value);
|
|
@@ -2239,38 +3112,103 @@ function ssrStyle(value) {
|
|
|
2239
3112
|
function ssrStyleProperty(name, value) {
|
|
2240
3113
|
return value != null ? name + value : "";
|
|
2241
3114
|
}
|
|
2242
|
-
function ssrElement(tag, props, children, needsId) {
|
|
3115
|
+
function ssrElement(tag, props, children, needsId, skip, attrs) {
|
|
2243
3116
|
const hk = needsId ? ssrHydrationKey() : "";
|
|
2244
|
-
if (
|
|
2245
|
-
|
|
2246
|
-
|
|
2247
|
-
let
|
|
2248
|
-
|
|
2249
|
-
|
|
2250
|
-
|
|
2251
|
-
|
|
2252
|
-
|
|
3117
|
+
if (typeof props === "function") props = props();
|
|
3118
|
+
let sources = null;
|
|
3119
|
+
let proxy = false;
|
|
3120
|
+
let viewKeys = null;
|
|
3121
|
+
let owners = null;
|
|
3122
|
+
if (Array.isArray(props)) {
|
|
3123
|
+
let i = 0;
|
|
3124
|
+
for (; i < props.length; i++) {
|
|
3125
|
+
const s = props[i];
|
|
3126
|
+
if (s == null || typeof s === "function" || $PROXY in s) break;
|
|
2253
3127
|
}
|
|
2254
|
-
|
|
2255
|
-
|
|
2256
|
-
|
|
2257
|
-
|
|
2258
|
-
|
|
2259
|
-
|
|
2260
|
-
|
|
2261
|
-
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
|
|
2265
|
-
|
|
3128
|
+
if (i === props.length) sources = props;else {
|
|
3129
|
+
viewKeys = [];
|
|
3130
|
+
owners = [];
|
|
3131
|
+
for (let i = 0; i < props.length; i++) {
|
|
3132
|
+
let s = props[i];
|
|
3133
|
+
if (typeof s === "function") s = s();
|
|
3134
|
+
if (s != null) sourceOwners(s, viewKeys, owners);
|
|
3135
|
+
}
|
|
3136
|
+
}
|
|
3137
|
+
} else if (props == null) {
|
|
3138
|
+
props = {};
|
|
3139
|
+
} else if ($PROXY in props) {
|
|
3140
|
+
if (viewOf(props) !== undefined) {
|
|
3141
|
+
viewKeys = [];
|
|
3142
|
+
owners = [];
|
|
3143
|
+
sourceOwners(props, viewKeys, owners);
|
|
3144
|
+
} else proxy = true;
|
|
3145
|
+
}
|
|
3146
|
+
const info = tagInfo(tag);
|
|
3147
|
+
const skipChildren = info.isVoid;
|
|
3148
|
+
let result = info.open + hk;
|
|
3149
|
+
const last = sources === null ? 0 : sources.length - 1;
|
|
3150
|
+
let keysOf = null;
|
|
3151
|
+
if (sources !== null) {
|
|
3152
|
+
keysOf = new Array(last + 1);
|
|
3153
|
+
for (let s = 0; s <= last; s++) keysOf[s] = Object.keys(sources[s]);
|
|
3154
|
+
}
|
|
3155
|
+
for (let s = 0; s <= last; s++) {
|
|
3156
|
+
const keys = owners !== null ? viewKeys : keysOf !== null ? keysOf[s] : proxy ? Reflect.ownKeys(props) : Object.keys(props);
|
|
3157
|
+
if (sources !== null) props = sources[s];
|
|
3158
|
+
nextKey: for (let i = 0; i < keys.length; i++) {
|
|
3159
|
+
const prop = keys[i];
|
|
3160
|
+
if (typeof prop !== "string" || skip !== undefined && skip(prop)) continue;
|
|
3161
|
+
if (owners !== null) props = owners[i];
|
|
3162
|
+
for (let j = s + 1; j <= last; j++) {
|
|
3163
|
+
if (keysOf[j].includes(prop)) continue nextKey;
|
|
3164
|
+
}
|
|
3165
|
+
if (info.textarea && (prop === "value" || prop === "defaultValue")) {
|
|
3166
|
+
const value = props[prop];
|
|
3167
|
+
if (value !== null) children = escape(value);
|
|
3168
|
+
continue;
|
|
3169
|
+
}
|
|
3170
|
+
if (ChildProperties.has(prop)) {
|
|
3171
|
+
if (children === undefined && !skipChildren) children = info.raw || prop === "innerHTML" ? props[prop] : escape(props[prop]);
|
|
3172
|
+
continue;
|
|
3173
|
+
}
|
|
3174
|
+
const value = props[prop];
|
|
3175
|
+
if (value == undefined || prop === "ref" || prop.startsWith("on") || prop.startsWith("prop:")) {
|
|
3176
|
+
continue;
|
|
3177
|
+
} else if (prop === "style") {
|
|
3178
|
+
result += ` style="${ssrStyle(value)}"`;
|
|
3179
|
+
} else if (prop === "class") {
|
|
3180
|
+
result += ` class="${ssrClassName(value)}"`;
|
|
3181
|
+
} else if (typeof value === "boolean") {
|
|
3182
|
+
if (!value) continue;
|
|
3183
|
+
result += ` ${attrName(prop)}`;
|
|
3184
|
+
} else {
|
|
3185
|
+
result += value === "" ? ` ${attrName(prop)}` : ` ${attrName(prop)}="${escape(value, true)}"`;
|
|
3186
|
+
}
|
|
2266
3187
|
}
|
|
2267
|
-
if (i !== keys.length - 1) result += " ";
|
|
2268
3188
|
}
|
|
3189
|
+
if (attrs !== undefined) result += typeof attrs === "function" ? attrs() : attrs;
|
|
2269
3190
|
if (skipChildren) return {
|
|
2270
|
-
t: result + "/>"
|
|
3191
|
+
t: result + " />"
|
|
2271
3192
|
};
|
|
2272
3193
|
if (typeof children === "function") children = children();
|
|
2273
|
-
|
|
3194
|
+
const ct = typeof children;
|
|
3195
|
+
if (ct === "string" || ct === "number") return {
|
|
3196
|
+
t: result + ">" + children + info.close
|
|
3197
|
+
};
|
|
3198
|
+
if (children == null || ct === "boolean") return {
|
|
3199
|
+
t: result + ">" + info.close
|
|
3200
|
+
};
|
|
3201
|
+
if (ct === "object" && !children.h && typeof children.t === "string") return {
|
|
3202
|
+
t: result + ">" + children.t + info.close
|
|
3203
|
+
};
|
|
3204
|
+
return ssr([result + ">", info.close], resolveSSRNode(children, undefined, true));
|
|
3205
|
+
}
|
|
3206
|
+
function ssrElementAttribute(key, value) {
|
|
3207
|
+
if (value == undefined) return "";
|
|
3208
|
+
if (key === "style") return ` style="${ssrStyle(value)}"`;
|
|
3209
|
+
if (key === "class") return ` class="${ssrClassName(value)}"`;
|
|
3210
|
+
if (typeof value === "boolean") return value ? ` ${key}` : "";
|
|
3211
|
+
return value === "" ? ` ${key}` : ` ${key}="${escape(value, true)}"`;
|
|
2274
3212
|
}
|
|
2275
3213
|
function ssrAttribute(key, value) {
|
|
2276
3214
|
return value == null || value === false ? "" : value === true ? ` ${key}` : ` ${key}="${value}"`;
|
|
@@ -2279,10 +3217,36 @@ function ssrHydrationKey() {
|
|
|
2279
3217
|
const hk = getHydrationKey();
|
|
2280
3218
|
return hk ? ` _hk=${hk}` : "";
|
|
2281
3219
|
}
|
|
3220
|
+
const CLAIM_PROP = /*#__PURE__*/Symbol.for("solid.claim-prop");
|
|
3221
|
+
const CLAIMS_STREAM = 1;
|
|
3222
|
+
const CLAIMS_DOCUMENT = 2;
|
|
3223
|
+
const CLAIM_UNSAFE = /[^A-Za-z0-9_.!~*'()-]/g;
|
|
3224
|
+
function encodeClaimKey(key) {
|
|
3225
|
+
return String(key).replace(CLAIM_UNSAFE, c => encodeURIComponent(c));
|
|
3226
|
+
}
|
|
3227
|
+
function ssrClaim(map) {
|
|
3228
|
+
const mode = sharedConfig.context && sharedConfig.context.claims;
|
|
3229
|
+
if (!mode || mode === CLAIMS_DOCUMENT && !(typeof inServerComponentScope === "function" && inServerComponentScope())) {
|
|
3230
|
+
return "";
|
|
3231
|
+
}
|
|
3232
|
+
let out = "";
|
|
3233
|
+
for (const pos in map) {
|
|
3234
|
+
const value = map[pos];
|
|
3235
|
+
const list = Array.isArray(value) ? value : [value];
|
|
3236
|
+
for (const fn of list) {
|
|
3237
|
+
const prop = typeof fn === "function" && fn[CLAIM_PROP] || undefined;
|
|
3238
|
+
if (prop === undefined) {
|
|
3239
|
+
continue;
|
|
3240
|
+
}
|
|
3241
|
+
out += `${out ? "," : ""}${pos}=${encodeClaimKey(prop)}`;
|
|
3242
|
+
}
|
|
3243
|
+
}
|
|
3244
|
+
return out ? ` _bnd="${out}"` : "";
|
|
3245
|
+
}
|
|
2282
3246
|
function decodeSSREntities(s) {
|
|
2283
3247
|
return s.indexOf("&") < 0 ? s : s.replace(/"/g, '"').replace(/</g, "<").replace(/&/g, "&");
|
|
2284
3248
|
}
|
|
2285
|
-
const SELECT_VALUE_ATTR = /\svalue
|
|
3249
|
+
const SELECT_VALUE_ATTR = /\svalue(?:="([^"]*)")?(?=[\s>]|$)/;
|
|
2286
3250
|
function tagEnd(html, i) {
|
|
2287
3251
|
for (let j = i + 1; j < html.length; j++) {
|
|
2288
3252
|
const c = html.charCodeAt(j);
|
|
@@ -2311,22 +3275,49 @@ function tagIs(html, i, name) {
|
|
|
2311
3275
|
const c = html.charCodeAt(i + 1 + name.length);
|
|
2312
3276
|
return c === 32 || c === 62 || c === 9 || c === 10 || c === 13;
|
|
2313
3277
|
}
|
|
3278
|
+
let selectValuesActive = false;
|
|
3279
|
+
function ssrSelectValues() {
|
|
3280
|
+
selectValuesActive = true;
|
|
3281
|
+
}
|
|
2314
3282
|
function resolveSSRSelectValues(html) {
|
|
2315
|
-
if (
|
|
3283
|
+
if (!selectValuesActive) return html;
|
|
3284
|
+
let cand = html.indexOf("<select");
|
|
3285
|
+
if (cand < 0) return html;
|
|
2316
3286
|
let out = "";
|
|
2317
3287
|
let idx = 0;
|
|
2318
|
-
|
|
2319
|
-
|
|
2320
|
-
|
|
2321
|
-
|
|
2322
|
-
|
|
2323
|
-
|
|
2324
|
-
|
|
2325
|
-
|
|
2326
|
-
|
|
2327
|
-
|
|
2328
|
-
|
|
2329
|
-
|
|
3288
|
+
while (cand >= 0) {
|
|
3289
|
+
if (!tagIs(html, cand, "select")) {
|
|
3290
|
+
cand = html.indexOf("<select", cand + 7);
|
|
3291
|
+
continue;
|
|
3292
|
+
}
|
|
3293
|
+
const e0 = tagEnd(html, cand);
|
|
3294
|
+
if (e0 < 0) break;
|
|
3295
|
+
const open = html.slice(cand, e0 + 1);
|
|
3296
|
+
const m = SELECT_VALUE_ATTR.exec(open);
|
|
3297
|
+
if (!m) {
|
|
3298
|
+
cand = html.indexOf("<select", e0 + 1);
|
|
3299
|
+
continue;
|
|
3300
|
+
}
|
|
3301
|
+
const bound = decodeSSREntities(m[1] ?? "");
|
|
3302
|
+
const sel = {
|
|
3303
|
+
values: /\smultiple(?=[\s>=])/.test(open) ? bound.split(",") : [bound],
|
|
3304
|
+
strip: cand + m.index,
|
|
3305
|
+
stripEnd: cand + m.index + m[0].length,
|
|
3306
|
+
body: e0 + 1,
|
|
3307
|
+
marks: [],
|
|
3308
|
+
defaulted: false
|
|
3309
|
+
};
|
|
3310
|
+
let committed = false;
|
|
3311
|
+
let i = html.indexOf("<", e0 + 1);
|
|
3312
|
+
while (i >= 0) {
|
|
3313
|
+
let e;
|
|
3314
|
+
if (html.charCodeAt(i + 1) === 33) {
|
|
3315
|
+
e = html.charCodeAt(i + 2) === 45 ? html.indexOf("-->", i) : html.indexOf(">", i);
|
|
3316
|
+
if (e < 0) break;
|
|
3317
|
+
if (html.charCodeAt(i + 2) === 45) e += 2;
|
|
3318
|
+
} else {
|
|
3319
|
+
e = tagEnd(html, i);
|
|
3320
|
+
if (e < 0) break;
|
|
2330
3321
|
if (html.startsWith("</select>", i)) {
|
|
2331
3322
|
out += html.slice(idx, sel.strip) + html.slice(sel.stripEnd, sel.body);
|
|
2332
3323
|
let seg = sel.body;
|
|
@@ -2338,32 +3329,23 @@ function resolveSSRSelectValues(html) {
|
|
|
2338
3329
|
}
|
|
2339
3330
|
out += html.slice(seg, i);
|
|
2340
3331
|
idx = i;
|
|
2341
|
-
|
|
3332
|
+
committed = true;
|
|
3333
|
+
break;
|
|
2342
3334
|
} else if (tagIs(html, i, "option")) {
|
|
2343
3335
|
const attrs = html.slice(i + 7, e);
|
|
2344
3336
|
if (/\sselected(?=[\s=]|$)/.test(attrs)) sel.defaulted = true;else {
|
|
2345
3337
|
const vm = SELECT_VALUE_ATTR.exec(attrs);
|
|
2346
|
-
const value = vm ? decodeSSREntities(vm[1]) : decodeSSREntities(optionText(html, e + 1)).replace(/\s+/g, " ").trim();
|
|
3338
|
+
const value = vm ? decodeSSREntities(vm[1] ?? "") : decodeSSREntities(optionText(html, e + 1)).replace(/\s+/g, " ").trim();
|
|
2347
3339
|
if (sel.values.includes(value)) sel.marks.push(e);
|
|
2348
3340
|
}
|
|
2349
3341
|
}
|
|
2350
|
-
} else if (tagIs(html, i, "select")) {
|
|
2351
|
-
const m = SELECT_VALUE_ATTR.exec(html.slice(i, e + 1));
|
|
2352
|
-
if (m) {
|
|
2353
|
-
const bound = decodeSSREntities(m[1]);
|
|
2354
|
-
sel = {
|
|
2355
|
-
values: /\smultiple(?=[\s>=])/.test(html.slice(i, e + 1)) ? bound.split(",") : [bound],
|
|
2356
|
-
strip: i + m.index,
|
|
2357
|
-
stripEnd: i + m.index + m[0].length,
|
|
2358
|
-
body: e + 1,
|
|
2359
|
-
marks: [],
|
|
2360
|
-
defaulted: false
|
|
2361
|
-
};
|
|
2362
|
-
}
|
|
2363
3342
|
}
|
|
3343
|
+
i = html.indexOf("<", e + 1);
|
|
2364
3344
|
}
|
|
2365
|
-
|
|
3345
|
+
if (!committed) break;
|
|
3346
|
+
cand = html.indexOf("<select", idx);
|
|
2366
3347
|
}
|
|
3348
|
+
if (idx === 0) return html;
|
|
2367
3349
|
return out + html.slice(idx);
|
|
2368
3350
|
}
|
|
2369
3351
|
function escape(s, attr) {
|
|
@@ -2372,10 +3354,13 @@ function escape(s, attr) {
|
|
|
2372
3354
|
if (!attr && Array.isArray(s)) {
|
|
2373
3355
|
const joined = tryJoinPlainSSRArray(s);
|
|
2374
3356
|
if (joined !== undefined) return joined;
|
|
3357
|
+
const src = s;
|
|
2375
3358
|
s = s.slice();
|
|
2376
3359
|
for (let i = 0; i < s.length; i++) s[i] = escape(s[i]);
|
|
3360
|
+
if (src.$slot) s.$slot = true;
|
|
2377
3361
|
return s;
|
|
2378
3362
|
}
|
|
3363
|
+
if (!attr && t === "function") return escapeLate(s);
|
|
2379
3364
|
if (attr) {
|
|
2380
3365
|
if (s == null || t === "boolean" || t === "number") return s;
|
|
2381
3366
|
return escape(String(s), attr);
|
|
@@ -2386,23 +3371,30 @@ function escape(s, attr) {
|
|
|
2386
3371
|
if (i < 0) return s;
|
|
2387
3372
|
return escapeSlow(s, attr, i);
|
|
2388
3373
|
}
|
|
3374
|
+
function escapeLate(fn) {
|
|
3375
|
+
if (fn.$esc) return fn;
|
|
3376
|
+
const w = () => escape(fn());
|
|
3377
|
+
w.$esc = true;
|
|
3378
|
+
if (fn.$lhSkip) w.$lhSkip = true;
|
|
3379
|
+
if (fn.$lhSuppress) w.$lhSuppress = true;
|
|
3380
|
+
if (fn.$lhBinding) w.$lhBinding = fn.$lhBinding;
|
|
3381
|
+
return w;
|
|
3382
|
+
}
|
|
2389
3383
|
const ESCAPE_CONTENT = /[&<]/;
|
|
2390
|
-
const ESCAPE_ATTR = /[&"]/;
|
|
3384
|
+
const ESCAPE_ATTR = /[&"<]/;
|
|
2391
3385
|
function escapeSlow(s, attr, start) {
|
|
2392
|
-
|
|
2393
|
-
const delimCode = attr ? 34 : 60;
|
|
2394
|
-
const escDelim = attr ? """ : "<";
|
|
3386
|
+
if (attr) return escapeAttrSlow(s, start);
|
|
2395
3387
|
const c0 = s.charCodeAt(start);
|
|
2396
|
-
let iDelim = c0 ===
|
|
3388
|
+
let iDelim = c0 === 60 ? start : s.indexOf("<", start);
|
|
2397
3389
|
let iAmp = c0 === 38 ? start : s.indexOf("&", start);
|
|
2398
3390
|
let left = 0,
|
|
2399
3391
|
out = "";
|
|
2400
3392
|
while (iDelim >= 0 && iAmp >= 0) {
|
|
2401
3393
|
if (iDelim < iAmp) {
|
|
2402
3394
|
if (left < iDelim) out += s.substring(left, iDelim);
|
|
2403
|
-
out +=
|
|
3395
|
+
out += "<";
|
|
2404
3396
|
left = iDelim + 1;
|
|
2405
|
-
iDelim = s.indexOf(
|
|
3397
|
+
iDelim = s.indexOf("<", left);
|
|
2406
3398
|
} else {
|
|
2407
3399
|
if (left < iAmp) out += s.substring(left, iAmp);
|
|
2408
3400
|
out += "&";
|
|
@@ -2413,9 +3405,9 @@ function escapeSlow(s, attr, start) {
|
|
|
2413
3405
|
if (iDelim >= 0) {
|
|
2414
3406
|
do {
|
|
2415
3407
|
if (left < iDelim) out += s.substring(left, iDelim);
|
|
2416
|
-
out +=
|
|
3408
|
+
out += "<";
|
|
2417
3409
|
left = iDelim + 1;
|
|
2418
|
-
iDelim = s.indexOf(
|
|
3410
|
+
iDelim = s.indexOf("<", left);
|
|
2419
3411
|
} while (iDelim >= 0);
|
|
2420
3412
|
} else while (iAmp >= 0) {
|
|
2421
3413
|
if (left < iAmp) out += s.substring(left, iAmp);
|
|
@@ -2425,6 +3417,36 @@ function escapeSlow(s, attr, start) {
|
|
|
2425
3417
|
}
|
|
2426
3418
|
return left < s.length ? out + s.substring(left) : out;
|
|
2427
3419
|
}
|
|
3420
|
+
function escapeAttrSlow(s, start) {
|
|
3421
|
+
const c0 = s.charCodeAt(start);
|
|
3422
|
+
let iQuot = c0 === 34 ? start : s.indexOf('"', start);
|
|
3423
|
+
let iAmp = c0 === 38 ? start : s.indexOf("&", start);
|
|
3424
|
+
let iLt = c0 === 60 ? start : s.indexOf("<", start);
|
|
3425
|
+
let left = 0,
|
|
3426
|
+
out = "";
|
|
3427
|
+
for (;;) {
|
|
3428
|
+
let i = -1,
|
|
3429
|
+
ent;
|
|
3430
|
+
if (iQuot >= 0) {
|
|
3431
|
+
i = iQuot;
|
|
3432
|
+
ent = """;
|
|
3433
|
+
}
|
|
3434
|
+
if (iAmp >= 0 && (i < 0 || iAmp < i)) {
|
|
3435
|
+
i = iAmp;
|
|
3436
|
+
ent = "&";
|
|
3437
|
+
}
|
|
3438
|
+
if (iLt >= 0 && (i < 0 || iLt < i)) {
|
|
3439
|
+
i = iLt;
|
|
3440
|
+
ent = "<";
|
|
3441
|
+
}
|
|
3442
|
+
if (i < 0) break;
|
|
3443
|
+
if (left < i) out += s.substring(left, i);
|
|
3444
|
+
out += ent;
|
|
3445
|
+
left = i + 1;
|
|
3446
|
+
if (i === iQuot) iQuot = s.indexOf('"', left);else if (i === iAmp) iAmp = s.indexOf("&", left);else iLt = s.indexOf("<", left);
|
|
3447
|
+
}
|
|
3448
|
+
return left < s.length ? out + s.substring(left) : out;
|
|
3449
|
+
}
|
|
2428
3450
|
function tryJoinPlainSSRArray(nodes) {
|
|
2429
3451
|
if (nodes.length === 0) return undefined;
|
|
2430
3452
|
let out = "";
|
|
@@ -2438,8 +3460,8 @@ function tryJoinPlainSSRArray(nodes) {
|
|
|
2438
3460
|
return out;
|
|
2439
3461
|
}
|
|
2440
3462
|
function getHydrationKey() {
|
|
2441
|
-
const hydrate =
|
|
2442
|
-
return hydrate &&
|
|
3463
|
+
const hydrate = sharedConfig.context;
|
|
3464
|
+
return hydrate && sharedConfig.getNextContextId();
|
|
2443
3465
|
}
|
|
2444
3466
|
function applyRef(r, element) {
|
|
2445
3467
|
Array.isArray(r) ? r.flat(Infinity).forEach(f => f && f(element)) : r(element);
|
|
@@ -2448,23 +3470,25 @@ function generateHydrationScript({
|
|
|
2448
3470
|
eventNames = ["click", "input"],
|
|
2449
3471
|
nonce
|
|
2450
3472
|
} = {}) {
|
|
2451
|
-
return `<script${nonce ? ` nonce="${nonce}"` : ""}>window._$HY||(e=>{let t=e=>e&&e.hasAttribute&&(e.hasAttribute("_hk")?e:t(e.host&&e.host.nodeType?e.host:e.parentNode));["${eventNames.join('","')}"].forEach((o=>document.addEventListener(o,(o=>{if(!e.events)return;let s=t(o.composedPath&&o.composedPath()[0]||o.target);s&&!e.completed.has(s)&&e.events.push([s,o])}))))})(_$HY={events:[],completed:new WeakSet,r:{},fe(){}});</script><!--xs-->`;
|
|
3473
|
+
return `<script${nonce ? ` nonce="${escape(String(nonce), true)}"` : ""}>window._$HY||(e=>{let t=e=>e&&e.hasAttribute&&(e.hasAttribute("_hk")?e:t(e.host&&e.host.nodeType?e.host:e.parentNode));["${eventNames.join('","')}"].forEach((o=>document.addEventListener(o,(o=>{if(!e.events)return;let s=t(o.composedPath&&o.composedPath()[0]||o.target);s&&!e.completed.has(s)&&e.events.push([s,o])}))))})(_$HY={events:[],completed:new WeakSet,r:{},fe(){}});</script><!--xs-->`;
|
|
2452
3474
|
}
|
|
2453
3475
|
function queue(fn) {
|
|
2454
3476
|
return Promise.resolve().then(fn);
|
|
2455
3477
|
}
|
|
3478
|
+
const deferFlush = typeof setImmediate === "function" ? setImmediate : fn => setTimeout(fn, 0);
|
|
2456
3479
|
function allSettled(promises) {
|
|
2457
3480
|
let size = promises.size;
|
|
2458
3481
|
return Promise.allSettled(promises).then(() => {
|
|
2459
3482
|
if (promises.size !== size) return allSettled(promises);
|
|
2460
|
-
return;
|
|
3483
|
+
return size;
|
|
2461
3484
|
});
|
|
2462
3485
|
}
|
|
2463
|
-
function assembleDocument(html, emittedAssets, inlineStyles, scripts, nonce, headTags, onHead) {
|
|
2464
|
-
const scriptTag = scripts ? `<script${nonce
|
|
2465
|
-
const
|
|
3486
|
+
function assembleDocument(html, emittedAssets, preloadLinks, inlineStyles, scripts, nonce, headTags, onHead) {
|
|
3487
|
+
const scriptTag = scripts ? `<script${nonceAttr(nonce, "script")}>${scripts}</script>` : "";
|
|
3488
|
+
const title = headTags ? headTags.title : null;
|
|
3489
|
+
let headTagsHtml = headTags ? headTags.html : "";
|
|
2466
3490
|
const headPrelude = headTags ? headTags.prelude : "";
|
|
2467
|
-
if (!onHead && !headTagsHtml && !headPrelude && !(emittedAssets && emittedAssets.size) && !(inlineStyles && inlineStyles.size)) {
|
|
3491
|
+
if (!onHead && title == null && !headTagsHtml && !headPrelude && !(emittedAssets && emittedAssets.size) && !preloadLinks && !(inlineStyles && inlineStyles.size)) {
|
|
2468
3492
|
if (!scriptTag) return html;
|
|
2469
3493
|
const xs = html.indexOf("<!--xs-->");
|
|
2470
3494
|
return xs === -1 ? html + scriptTag : html.slice(0, xs) + scriptTag + html.slice(xs);
|
|
@@ -2476,28 +3500,51 @@ function assembleDocument(html, emittedAssets, inlineStyles, scripts, nonce, hea
|
|
|
2476
3500
|
html = html.slice(0, at) + headPrelude + html.slice(at);
|
|
2477
3501
|
}
|
|
2478
3502
|
}
|
|
2479
|
-
|
|
3503
|
+
let headIdx = html.indexOf("</head>");
|
|
2480
3504
|
if (headIdx === -1) {
|
|
2481
3505
|
if (onHead) {
|
|
2482
|
-
|
|
3506
|
+
let titleHtml = "";
|
|
3507
|
+
if (title != null) {
|
|
3508
|
+
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>`;
|
|
3509
|
+
}
|
|
3510
|
+
onHead(headPrelude + headTagsHtml + titleHtml + renderHeadAssets(emittedAssets, preloadLinks, inlineStyles, nonce));
|
|
2483
3511
|
}
|
|
2484
3512
|
if (!scriptTag) return html;
|
|
2485
3513
|
const xs = html.indexOf("<!--xs-->");
|
|
2486
3514
|
return xs === -1 ? html + scriptTag : html.slice(0, xs) + scriptTag + html.slice(xs);
|
|
2487
3515
|
}
|
|
2488
|
-
|
|
3516
|
+
if (title != null) {
|
|
3517
|
+
const winner = escape(title);
|
|
3518
|
+
const open = html.match(/<head(?:\s[^>]*)?>/);
|
|
3519
|
+
const from = open ? open.index + open[0].length : 0;
|
|
3520
|
+
const m = /<title(\s[^>]*)?>([\s\S]*?)<\/title>/.exec(html.slice(from, headIdx));
|
|
3521
|
+
if (m) {
|
|
3522
|
+
const at = from + m.index;
|
|
3523
|
+
const stash = m[2].replace(/"/g, """);
|
|
3524
|
+
html = html.slice(0, at) + `<title${m[1] || ""} data-dh="title" data-dhf="${stash}">${winner}</title>` + html.slice(at + m[0].length);
|
|
3525
|
+
headIdx = html.indexOf("</head>");
|
|
3526
|
+
} else {
|
|
3527
|
+
headTagsHtml = `<title data-dh="title">${winner}</title>` + headTagsHtml;
|
|
3528
|
+
}
|
|
3529
|
+
}
|
|
3530
|
+
const head = headTagsHtml + renderHeadAssets(emittedAssets, preloadLinks, inlineStyles, nonce);
|
|
2489
3531
|
if (!scriptTag) return html.slice(0, headIdx) + head + html.slice(headIdx);
|
|
2490
3532
|
const xsIdx = html.indexOf("<!--xs-->");
|
|
2491
3533
|
if (xsIdx === -1) return html.slice(0, headIdx) + head + html.slice(headIdx) + scriptTag;
|
|
2492
3534
|
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);
|
|
2493
3535
|
}
|
|
2494
|
-
function renderHeadAssets(emittedAssets, inlineStyles, nonce) {
|
|
3536
|
+
function renderHeadAssets(emittedAssets, preloadLinks, inlineStyles, nonce) {
|
|
2495
3537
|
let head = "";
|
|
3538
|
+
const styleAttr = nonceAttr(nonce, "style");
|
|
3539
|
+
const scriptAttr = nonceAttr(nonce, "script");
|
|
2496
3540
|
if (emittedAssets && emittedAssets.size) {
|
|
2497
3541
|
for (const url of emittedAssets) {
|
|
2498
|
-
head += isCssUrl(url) ? `<link rel="stylesheet" href="${url}">` : `<link rel="modulepreload" href="${url}">`;
|
|
3542
|
+
head += isCssUrl(url) ? `<link rel="stylesheet" href="${url}"${styleAttr}>` : `<link rel="modulepreload" href="${url}"${scriptAttr}>`;
|
|
2499
3543
|
}
|
|
2500
3544
|
}
|
|
3545
|
+
if (preloadLinks) {
|
|
3546
|
+
for (const entry of preloadLinks) head += `<link${entry.attrHtml}>`;
|
|
3547
|
+
}
|
|
2501
3548
|
if (inlineStyles && inlineStyles.size) {
|
|
2502
3549
|
for (const entry of inlineStyles.values()) {
|
|
2503
3550
|
if (entry.emitted) continue;
|
|
@@ -2557,12 +3604,15 @@ function escapeStyleContent(content) {
|
|
|
2557
3604
|
}
|
|
2558
3605
|
function renderInlineStyle(entry, nonce) {
|
|
2559
3606
|
let attrs = "";
|
|
3607
|
+
let hasNonce = false;
|
|
2560
3608
|
if (entry.attrs) {
|
|
2561
3609
|
for (const name in entry.attrs) {
|
|
3610
|
+
if (name.length === 5 && asciiLowerCase(name) === "nonce") hasNonce = true;
|
|
2562
3611
|
attrs += ` ${name}="${escape(String(entry.attrs[name]), true)}"`;
|
|
2563
3612
|
}
|
|
2564
3613
|
}
|
|
2565
|
-
|
|
3614
|
+
const nonceHtml = hasNonce ? "" : nonceAttr(nonce, "style");
|
|
3615
|
+
return `<style${nonceHtml} data-asset="${escape(entry.id, true)}"${attrs}>${escapeStyleContent(entry.content)}</style>`;
|
|
2566
3616
|
}
|
|
2567
3617
|
function waitForFragments(registry, key) {
|
|
2568
3618
|
for (const k of [...registry.keys()].reverse()) {
|
|
@@ -2589,26 +3639,30 @@ function classListToObject(classList) {
|
|
|
2589
3639
|
function flattenClassList(list, result) {
|
|
2590
3640
|
for (let i = 0, len = list.length; i < len; i++) {
|
|
2591
3641
|
const item = list[i];
|
|
2592
|
-
if (Array.isArray(item)) flattenClassList(item, result);else if (typeof item === "object" && item != null) Object.assign(result, item);
|
|
3642
|
+
if (Array.isArray(item)) flattenClassList(item, result);else if (typeof item === "object" && item != null) Object.assign(result, item);
|
|
3643
|
+
else if (typeof item !== "boolean" && (item || item === 0)) result[item] = true;
|
|
2593
3644
|
}
|
|
2594
3645
|
}
|
|
2595
|
-
|
|
3646
|
+
let ssrTextTail = false;
|
|
3647
|
+
function tryResolveString(node, nested) {
|
|
3648
|
+
if (!nested) ssrTextTail = false;
|
|
2596
3649
|
const t = typeof node;
|
|
2597
|
-
if (t === "string")
|
|
2598
|
-
|
|
3650
|
+
if (t === "string" || t === "number") {
|
|
3651
|
+
const s = ssrTextTail ? "<!--!$-->" + node : "" + node;
|
|
3652
|
+
ssrTextTail = true;
|
|
3653
|
+
return s;
|
|
3654
|
+
}
|
|
2599
3655
|
if (node == null || t === "boolean") return "";
|
|
2600
3656
|
if (t === "object") {
|
|
2601
3657
|
if (Array.isArray(node)) {
|
|
2602
3658
|
const joined = tryJoinPlainSSRArray(node);
|
|
2603
|
-
if (joined !== undefined)
|
|
3659
|
+
if (joined !== undefined) {
|
|
3660
|
+
ssrTextTail = false;
|
|
3661
|
+
return joined;
|
|
3662
|
+
}
|
|
2604
3663
|
let s = "";
|
|
2605
|
-
let prevNonObj = false;
|
|
2606
3664
|
for (let i = 0, len = node.length; i < len; i++) {
|
|
2607
|
-
const
|
|
2608
|
-
const itemNonObj = item !== null && typeof item !== "object";
|
|
2609
|
-
if (prevNonObj && itemNonObj) s += "<!--!$-->";
|
|
2610
|
-
prevNonObj = itemNonObj;
|
|
2611
|
-
const r = tryResolveString(item);
|
|
3665
|
+
const r = tryResolveString(node[i], true);
|
|
2612
3666
|
if (typeof r !== "string") return {
|
|
2613
3667
|
bail: node
|
|
2614
3668
|
};
|
|
@@ -2622,6 +3676,7 @@ function tryResolveString(node) {
|
|
|
2622
3676
|
if (node.t === undefined) {
|
|
2623
3677
|
return "";
|
|
2624
3678
|
}
|
|
3679
|
+
ssrTextTail = false;
|
|
2625
3680
|
return Array.isArray(node.t) ? node.t[0] : node.t;
|
|
2626
3681
|
}
|
|
2627
3682
|
if (t === "function") {
|
|
@@ -2629,9 +3684,11 @@ function tryResolveString(node) {
|
|
|
2629
3684
|
try {
|
|
2630
3685
|
v = node();
|
|
2631
3686
|
} catch (err) {
|
|
2632
|
-
|
|
3687
|
+
const wrap = buildAsyncWrap(err, node);
|
|
3688
|
+
if (wrap) ssrTextTail = true;
|
|
3689
|
+
return wrap || "";
|
|
2633
3690
|
}
|
|
2634
|
-
return tryResolveString(v);
|
|
3691
|
+
return tryResolveString(v, true);
|
|
2635
3692
|
}
|
|
2636
3693
|
return "";
|
|
2637
3694
|
}
|
|
@@ -2639,21 +3696,19 @@ function resolveSSRNode(node, result = {
|
|
|
2639
3696
|
t: [""],
|
|
2640
3697
|
h: [],
|
|
2641
3698
|
p: []
|
|
2642
|
-
}, top) {
|
|
3699
|
+
}, top, nested) {
|
|
3700
|
+
if (!nested) ssrTextTail = false;
|
|
2643
3701
|
const t = typeof node;
|
|
2644
3702
|
if (t === "string" || t === "number") {
|
|
2645
|
-
result.t[result.t.length - 1] += node;
|
|
3703
|
+
result.t[result.t.length - 1] += ssrTextTail ? "<!--!$-->" + node : node;
|
|
3704
|
+
ssrTextTail = true;
|
|
2646
3705
|
} else if (node == null || t === "boolean") ; else if (Array.isArray(node)) {
|
|
2647
|
-
const slotLive = node.$slot &&
|
|
3706
|
+
const slotLive = node.$slot && sharedConfig.context && sharedConfig.context.liveHoles;
|
|
2648
3707
|
if (slotLive) slotLive.suppressed++;
|
|
2649
3708
|
try {
|
|
2650
|
-
let prevNonObj = false;
|
|
2651
3709
|
for (let i = 0, len = node.length; i < len; i++) {
|
|
2652
|
-
|
|
2653
|
-
|
|
2654
|
-
if (!top && prevNonObj && itemNonObj) result.t[result.t.length - 1] += `<!--!$-->`;
|
|
2655
|
-
prevNonObj = itemNonObj;
|
|
2656
|
-
resolveSSRNode(item, result);
|
|
3710
|
+
if (top) ssrTextTail = false;
|
|
3711
|
+
resolveSSRNode(node[i], result, false, true);
|
|
2657
3712
|
}
|
|
2658
3713
|
} finally {
|
|
2659
3714
|
if (slotLive) slotLive.suppressed--;
|
|
@@ -2666,23 +3721,30 @@ function resolveSSRNode(node, result = {
|
|
|
2666
3721
|
result.h.push(...node.h);
|
|
2667
3722
|
result.p.push(...node.p);
|
|
2668
3723
|
}
|
|
3724
|
+
ssrTextTail = false;
|
|
2669
3725
|
} else if (node.t !== undefined) {
|
|
2670
3726
|
result.t[result.t.length - 1] += node.t;
|
|
3727
|
+
ssrTextTail = false;
|
|
2671
3728
|
} else ;
|
|
2672
3729
|
} else if (t === "function") {
|
|
2673
|
-
const live =
|
|
3730
|
+
const live = sharedConfig.context && sharedConfig.context.liveHoles;
|
|
2674
3731
|
let liveNode = null;
|
|
2675
3732
|
if (live && (liveNode = live.content(node)) !== null) {
|
|
2676
|
-
if (typeof liveNode === "string")
|
|
3733
|
+
if (typeof liveNode === "string") {
|
|
3734
|
+
result.t[result.t.length - 1] += ssrTextTail ? "<!--!$-->" + liveNode : liveNode;
|
|
3735
|
+
ssrTextTail = true;
|
|
3736
|
+
} else resolveSSRNode(liveNode, result, false, true);
|
|
2677
3737
|
} else {
|
|
2678
3738
|
try {
|
|
2679
|
-
resolveSSRNode(node(), result);
|
|
3739
|
+
resolveSSRNode(node(), result, false, true);
|
|
2680
3740
|
} catch (err) {
|
|
2681
3741
|
const wrap = buildAsyncWrap(err, node);
|
|
2682
3742
|
if (wrap) {
|
|
3743
|
+
if (ssrTextTail) result.t[result.t.length - 1] += "<!--!$-->";
|
|
2683
3744
|
result.h.push(wrap.fn);
|
|
2684
3745
|
result.p.push(wrap.p);
|
|
2685
3746
|
result.t.push("");
|
|
3747
|
+
ssrTextTail = true;
|
|
2686
3748
|
}
|
|
2687
3749
|
}
|
|
2688
3750
|
}
|
|
@@ -2695,8 +3757,59 @@ function resolveSSRSync(node) {
|
|
|
2695
3757
|
throw new Error("This value cannot be rendered synchronously. Are you missing a boundary?");
|
|
2696
3758
|
}
|
|
2697
3759
|
const RequestContext = Symbol.for("solid.RequestContext");
|
|
3760
|
+
const ServerErrors = Symbol.for("solid-js/server/errors");
|
|
3761
|
+
function serializerErrorHook(hook) {
|
|
3762
|
+
return hook === undefined ? undefined : err => {
|
|
3763
|
+
reportServerError(err, {
|
|
3764
|
+
kind: "render",
|
|
3765
|
+
handling: "serialize"
|
|
3766
|
+
}, null);
|
|
3767
|
+
};
|
|
3768
|
+
}
|
|
3769
|
+
function ambientServerErrorHook() {
|
|
3770
|
+
const slot = globalThis[ServerErrors];
|
|
3771
|
+
return slot === undefined ? undefined : slot.hook;
|
|
3772
|
+
}
|
|
3773
|
+
function configureServerErrors(config) {
|
|
3774
|
+
const g = globalThis;
|
|
3775
|
+
if (config && config.onError !== undefined && typeof config.onError !== "function") {
|
|
3776
|
+
throw new TypeError(`Invalid onError: expected a function, received ${typeof config.onError}.`);
|
|
3777
|
+
}
|
|
3778
|
+
(g[ServerErrors] ||= {}).hook = config ? config.onError : undefined;
|
|
3779
|
+
}
|
|
2698
3780
|
function getRequestEvent() {
|
|
2699
|
-
return globalThis[RequestContext] ? globalThis[RequestContext].getStore() ||
|
|
3781
|
+
return globalThis[RequestContext] ? globalThis[RequestContext].getStore() || sharedConfig.context && sharedConfig.context.event || console.warn("RequestEvent is missing. This is most likely due to accessing `getRequestEvent` non-managed async scope in a partially polyfilled environment. Try moving it above all `await` calls.") : undefined;
|
|
3782
|
+
}
|
|
3783
|
+
function peekRequestEvent() {
|
|
3784
|
+
const store = globalThis[RequestContext];
|
|
3785
|
+
return store ? store.getStore() : undefined;
|
|
3786
|
+
}
|
|
3787
|
+
function timeDocument(context, trace, mode, requestEvent) {
|
|
3788
|
+
if (records() === undefined) return undefined;
|
|
3789
|
+
const render = observeRender(trace, mode, requestEvent);
|
|
3790
|
+
if (timesServerWork("boundary")) {
|
|
3791
|
+
context._recordBoundary = event => {
|
|
3792
|
+
trace.timing.push({
|
|
3793
|
+
type: "boundary",
|
|
3794
|
+
event
|
|
3795
|
+
});
|
|
3796
|
+
if (render) render.boundary();
|
|
3797
|
+
};
|
|
3798
|
+
}
|
|
3799
|
+
return render;
|
|
3800
|
+
}
|
|
3801
|
+
function getTraceContext() {
|
|
3802
|
+
const event = peekRequestEvent();
|
|
3803
|
+
if (event) return traceForEvent(event).context;
|
|
3804
|
+
const ctx = sharedConfig.context;
|
|
3805
|
+
return ctx && ctx.trace ? ctx.trace.context : undefined;
|
|
3806
|
+
}
|
|
3807
|
+
function traceForStub(stub, event) {
|
|
3808
|
+
if (!event) {
|
|
3809
|
+
event = peekRequestEvent();
|
|
3810
|
+
if (!event || event.response !== stub) return undefined;
|
|
3811
|
+
}
|
|
3812
|
+
return traceForEvent(event);
|
|
2700
3813
|
}
|
|
2701
3814
|
function createResponseStub() {
|
|
2702
3815
|
return {
|
|
@@ -2715,15 +3828,30 @@ function createRequestEvent(request, init) {
|
|
|
2715
3828
|
};
|
|
2716
3829
|
}
|
|
2717
3830
|
function reportLostHeaderWrite(method, name) {
|
|
2718
|
-
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).";
|
|
3831
|
+
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).";
|
|
3832
|
+
recordFinding({
|
|
3833
|
+
code: "LATE_HEADER_WRITE",
|
|
3834
|
+
kind: "head",
|
|
3835
|
+
severity: "error",
|
|
3836
|
+
message,
|
|
3837
|
+
data: {
|
|
3838
|
+
method,
|
|
3839
|
+
name: String(name)
|
|
3840
|
+
}
|
|
3841
|
+
});
|
|
2719
3842
|
console.error(message);
|
|
2720
3843
|
}
|
|
2721
3844
|
function commitResponseStub(stub, {
|
|
2722
|
-
allowLateLocation = false
|
|
3845
|
+
allowLateLocation = false,
|
|
3846
|
+
event
|
|
2723
3847
|
} = {}) {
|
|
2724
3848
|
if (!stub || stub.committed) return stub;
|
|
2725
|
-
stub.committed = true;
|
|
2726
3849
|
const headers = stub.headers;
|
|
3850
|
+
if (headers && typeof headers.append === "function") {
|
|
3851
|
+
const trace = traceForStub(stub, event);
|
|
3852
|
+
if (trace) appendTraceServerTiming(headers, trace);
|
|
3853
|
+
}
|
|
3854
|
+
stub.committed = true;
|
|
2727
3855
|
if (!headers || typeof headers.set !== "function") return stub;
|
|
2728
3856
|
for (const method of ["set", "append", "delete"]) {
|
|
2729
3857
|
const original = headers[method].bind(headers);
|
|
@@ -2744,7 +3872,7 @@ function getExpectedRedirectStatus(response) {
|
|
|
2744
3872
|
function mergeStubHeaders(target, stub) {
|
|
2745
3873
|
if (!stub) return target;
|
|
2746
3874
|
stub.headers.forEach((value, key) => {
|
|
2747
|
-
if (key !== "set-cookie") target.set(key, value);
|
|
3875
|
+
if (key === "server-timing") mergeServerTiming(target, value);else if (key !== "set-cookie") target.set(key, value);
|
|
2748
3876
|
});
|
|
2749
3877
|
const setCookies = stub.headers.getSetCookie ? stub.headers.getSetCookie() : [];
|
|
2750
3878
|
for (const cookie of setCookies) target.append("set-cookie", cookie);
|
|
@@ -2759,7 +3887,8 @@ function copyInitHeaders(init) {
|
|
|
2759
3887
|
for (const cookie of init.getSetCookie()) headers.append("Set-Cookie", cookie);
|
|
2760
3888
|
return headers;
|
|
2761
3889
|
}
|
|
2762
|
-
const STUB_GAP_FILL_EXCLUDED = /*#__PURE__*/new Set([ERROR_HEADER, BODY_FORMAT_HEADER, SINGLE_FLIGHT_HEADER, REVALIDATE_HEADER, "Location"
|
|
3890
|
+
const STUB_GAP_FILL_EXCLUDED = /*#__PURE__*/new Set([ERROR_HEADER, BODY_FORMAT_HEADER, SINGLE_FLIGHT_HEADER, REVALIDATE_HEADER, REDIRECT_HEADER, "Location",
|
|
3891
|
+
...COMPOSED_BODY_FRAMING].map(header => header.toLowerCase()));
|
|
2763
3892
|
function fillsStubGap(key, headers, response) {
|
|
2764
3893
|
if (key === "set-cookie" || STUB_GAP_FILL_EXCLUDED.has(key)) return false;
|
|
2765
3894
|
if (response.body === null && (key === "content-type" || key === "content-length")) return false;
|
|
@@ -2767,35 +3896,44 @@ function fillsStubGap(key, headers, response) {
|
|
|
2767
3896
|
}
|
|
2768
3897
|
function commitEventResponse(response, event = getRequestEvent()) {
|
|
2769
3898
|
const stub = event && event.response;
|
|
2770
|
-
if (!stub || !stub.headers || stub.committed)
|
|
2771
|
-
|
|
2772
|
-
|
|
2773
|
-
|
|
2774
|
-
stub.headers.forEach((value, key) => {
|
|
2775
|
-
if (fillsStubGap(key, response.headers, response)) hasGaps = true;
|
|
2776
|
-
});
|
|
2777
|
-
if (!cookies.length && !hasGaps) return response;
|
|
2778
|
-
try {
|
|
2779
|
-
for (const cookie of cookies) response.headers.append("Set-Cookie", cookie);
|
|
2780
|
-
stub.headers.forEach((value, key) => {
|
|
2781
|
-
if (fillsStubGap(key, response.headers, response)) response.headers.set(key, value);
|
|
2782
|
-
});
|
|
2783
|
-
return response;
|
|
2784
|
-
} catch {
|
|
3899
|
+
if (!stub || !stub.headers || stub.committed) {
|
|
3900
|
+
if (!event || stub) return response;
|
|
3901
|
+
const trace = traceForEvent(event);
|
|
3902
|
+
if (!hasServerTiming(trace)) return response;
|
|
2785
3903
|
const headers = copyInitHeaders(response.headers);
|
|
2786
|
-
|
|
2787
|
-
stub.headers.forEach((value, key) => {
|
|
2788
|
-
if (fillsStubGap(key, headers, response)) headers.set(key, value);
|
|
2789
|
-
});
|
|
3904
|
+
appendTraceServerTiming(headers, trace);
|
|
2790
3905
|
return new Response(response.body, {
|
|
2791
3906
|
status: response.status,
|
|
2792
3907
|
statusText: response.statusText,
|
|
2793
3908
|
headers
|
|
2794
3909
|
});
|
|
2795
3910
|
}
|
|
3911
|
+
const cookies = stub.headers.getSetCookie ? stub.headers.getSetCookie() : [];
|
|
3912
|
+
commitResponseStub(stub, {
|
|
3913
|
+
event
|
|
3914
|
+
});
|
|
3915
|
+
let hasGaps = false;
|
|
3916
|
+
stub.headers.forEach((value, key) => {
|
|
3917
|
+
if (fillsStubGap(key, response.headers, response)) hasGaps = true;
|
|
3918
|
+
});
|
|
3919
|
+
const timing = stub.headers.get("server-timing");
|
|
3920
|
+
const mergesTiming = timing !== null && response.headers.has("server-timing");
|
|
3921
|
+
if (!cookies.length && !hasGaps && !mergesTiming) return response;
|
|
3922
|
+
const headers = copyInitHeaders(response.headers);
|
|
3923
|
+
for (const cookie of cookies) headers.append("Set-Cookie", cookie);
|
|
3924
|
+
stub.headers.forEach((value, key) => {
|
|
3925
|
+
if (fillsStubGap(key, headers, response)) headers.set(key, value);
|
|
3926
|
+
});
|
|
3927
|
+
if (mergesTiming) mergeServerTiming(headers, timing);
|
|
3928
|
+
return new Response(response.body, {
|
|
3929
|
+
status: response.status,
|
|
3930
|
+
statusText: response.statusText,
|
|
3931
|
+
headers
|
|
3932
|
+
});
|
|
2796
3933
|
}
|
|
2797
3934
|
function deriveHead(stub, responseInit = {}) {
|
|
2798
3935
|
const headers = mergeStubHeaders(copyInitHeaders(responseInit.headers), stub);
|
|
3936
|
+
for (const header of COMPOSED_BODY_FRAMING) headers.delete(header);
|
|
2799
3937
|
const status = stub && stub.status || responseInit.status || 200;
|
|
2800
3938
|
const statusText = stub && stub.statusText || responseInit.statusText || undefined;
|
|
2801
3939
|
return {
|
|
@@ -2804,18 +3942,17 @@ function deriveHead(stub, responseInit = {}) {
|
|
|
2804
3942
|
headers
|
|
2805
3943
|
};
|
|
2806
3944
|
}
|
|
2807
|
-
function escapeAttribute(value) {
|
|
2808
|
-
return value.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<");
|
|
2809
|
-
}
|
|
2810
3945
|
function createSSRResponse(result, event, options = {}) {
|
|
2811
3946
|
const stub = event && event.response;
|
|
2812
3947
|
const {
|
|
2813
3948
|
responseInit,
|
|
2814
|
-
nonce,
|
|
2815
3949
|
transformChunk
|
|
2816
3950
|
} = options;
|
|
3951
|
+
const nonce = normalizeNonce(options.nonce);
|
|
2817
3952
|
if (typeof result === "string") {
|
|
2818
|
-
if (stub) commitResponseStub(stub
|
|
3953
|
+
if (stub) commitResponseStub(stub, {
|
|
3954
|
+
event
|
|
3955
|
+
});
|
|
2819
3956
|
const head = deriveHead(stub, responseInit);
|
|
2820
3957
|
if (stub && stub.headers.get("Location")) {
|
|
2821
3958
|
return new Response(null, {
|
|
@@ -2850,7 +3987,8 @@ function createSSRResponse(result, event, options = {}) {
|
|
|
2850
3987
|
if (!flushed) {
|
|
2851
3988
|
flushed = true;
|
|
2852
3989
|
if (stub) commitResponseStub(stub, {
|
|
2853
|
-
allowLateLocation: true
|
|
3990
|
+
allowLateLocation: true,
|
|
3991
|
+
event
|
|
2854
3992
|
});
|
|
2855
3993
|
const head = deriveHead(stub, responseInit);
|
|
2856
3994
|
if (stub && stub.headers.get("Location")) {
|
|
@@ -2882,8 +4020,8 @@ function createSSRResponse(result, event, options = {}) {
|
|
|
2882
4020
|
end() {
|
|
2883
4021
|
if (closed || !controller) return;
|
|
2884
4022
|
const location = stub && stub.headers.get("Location");
|
|
2885
|
-
if (location) {
|
|
2886
|
-
const attr =
|
|
4023
|
+
if (location && isHttpNavigationTarget(location)) {
|
|
4024
|
+
const attr = nonceAttr(nonce, "script");
|
|
2887
4025
|
enqueue(`<script${attr}>window.location=${JSON.stringify(location).replace(/</g, "\\u003c")}</script>`);
|
|
2888
4026
|
}
|
|
2889
4027
|
closed = true;
|
|
@@ -2920,16 +4058,58 @@ function notSup() {
|
|
|
2920
4058
|
throw new Error("Client-only API called on the server side. Run client-only code in onMount, or conditionally run client-only component with <Show>.");
|
|
2921
4059
|
}
|
|
2922
4060
|
|
|
2923
|
-
setContainerTraceResolver(
|
|
4061
|
+
setContainerTraceResolver(getProjectionTrace);
|
|
4062
|
+
setAsyncIterableSharer(shareAsyncIterable);
|
|
2924
4063
|
const isServer = true;
|
|
2925
4064
|
const isDev = false;
|
|
2926
|
-
function dynamic(source) {
|
|
2927
|
-
|
|
2928
|
-
|
|
4065
|
+
function dynamic(source, options) {
|
|
4066
|
+
if (options?.static) {
|
|
4067
|
+
const component = untrack(source);
|
|
4068
|
+
if (typeof component === "function") return props => component(props);
|
|
4069
|
+
if (typeof component === "string") return props => ssrElement(component, props, undefined, true);
|
|
4070
|
+
return () => undefined;
|
|
4071
|
+
}
|
|
4072
|
+
const cached = createMemo(() => {
|
|
4073
|
+
const next = source();
|
|
4074
|
+
if (!next || typeof next.then !== "function") return next;
|
|
4075
|
+
return {
|
|
4076
|
+
[FLIGHT]: next
|
|
4077
|
+
};
|
|
2929
4078
|
});
|
|
4079
|
+
const deferStream = !!options?.deferStream;
|
|
2930
4080
|
return props => {
|
|
2931
|
-
|
|
2932
|
-
|
|
4081
|
+
const ctx = sharedConfig.context;
|
|
4082
|
+
let gated = !deferStream || !ctx?.async;
|
|
4083
|
+
const value = createMemo(() => {
|
|
4084
|
+
let c;
|
|
4085
|
+
try {
|
|
4086
|
+
c = cached();
|
|
4087
|
+
} catch (err) {
|
|
4088
|
+
if (!gated && err instanceof NotReadyError && !err.source?.$clientHole) {
|
|
4089
|
+
gated = true;
|
|
4090
|
+
ctx.block(Promise.resolve(err.source).then(() => {}, () => {}));
|
|
4091
|
+
}
|
|
4092
|
+
throw err;
|
|
4093
|
+
}
|
|
4094
|
+
if (!c || !c[FLIGHT]) return c;
|
|
4095
|
+
const next = c[FLIGHT];
|
|
4096
|
+
return {
|
|
4097
|
+
then: (onFulfilled, onRejected) => next.then(resolved => {
|
|
4098
|
+
let landed;
|
|
4099
|
+
try {
|
|
4100
|
+
landed = classifyLanding(resolved);
|
|
4101
|
+
} catch (err) {
|
|
4102
|
+
if (onRejected) return onRejected(err);
|
|
4103
|
+
throw err;
|
|
4104
|
+
}
|
|
4105
|
+
return onFulfilled ? onFulfilled(landed) : landed;
|
|
4106
|
+
}, onRejected)
|
|
4107
|
+
};
|
|
4108
|
+
}, {
|
|
4109
|
+
deferStream
|
|
4110
|
+
});
|
|
4111
|
+
return createMemo(() => {
|
|
4112
|
+
const c = value();
|
|
2933
4113
|
if (c) {
|
|
2934
4114
|
if (typeof c === "function") return c(props);
|
|
2935
4115
|
if (typeof c === "string") {
|
|
@@ -2941,17 +4121,33 @@ function dynamic(source) {
|
|
|
2941
4121
|
});
|
|
2942
4122
|
};
|
|
2943
4123
|
}
|
|
4124
|
+
const FLIGHT = Symbol("solid.dynamic-flight");
|
|
4125
|
+
const SERVER_COMPONENT = Symbol.for("solid.server-component");
|
|
4126
|
+
function classifyLanding(resolved) {
|
|
4127
|
+
if (typeof resolved !== "function" || SERVER_COMPONENT in resolved) return resolved;
|
|
4128
|
+
const message = "[DYNAMIC_ASYNC_COMPONENT] An async dynamic() source resolved to a client component function";
|
|
4129
|
+
recordFinding({
|
|
4130
|
+
code: "DYNAMIC_ASYNC_COMPONENT",
|
|
4131
|
+
kind: "ssr",
|
|
4132
|
+
severity: "error",
|
|
4133
|
+
message,
|
|
4134
|
+
data: {
|
|
4135
|
+
component: resolved.name || undefined
|
|
4136
|
+
}
|
|
4137
|
+
}, null);
|
|
4138
|
+
throw new Error(message);
|
|
4139
|
+
}
|
|
2944
4140
|
function Dynamic(props) {
|
|
2945
4141
|
const Comp = dynamic(() => props.component);
|
|
2946
|
-
return
|
|
4142
|
+
return createComponent(Comp, omit(props, "component"));
|
|
2947
4143
|
}
|
|
2948
4144
|
function Portal(props) {
|
|
2949
|
-
const o =
|
|
2950
|
-
if (o?.id != null)
|
|
4145
|
+
const o = getOwner();
|
|
4146
|
+
if (o?.id != null) getNextChildId(o);
|
|
2951
4147
|
return undefined;
|
|
2952
4148
|
}
|
|
2953
4149
|
function registerClientOnlyPreload(moduleUrl) {
|
|
2954
|
-
const ctx =
|
|
4150
|
+
const ctx = sharedConfig.context;
|
|
2955
4151
|
if (!ctx?.registerAsset || !ctx.resolveAssets) return;
|
|
2956
4152
|
const registerAsset = ctx.registerAsset;
|
|
2957
4153
|
const resolve = ctx.resolveAssets;
|
|
@@ -2961,6 +4157,11 @@ function registerClientOnlyPreload(moduleUrl) {
|
|
|
2961
4157
|
const css = assets.css[i];
|
|
2962
4158
|
if (typeof css === "string") registerAsset("style", css);else registerAsset("inline-style", css);
|
|
2963
4159
|
}
|
|
4160
|
+
if (assets.preloads) {
|
|
4161
|
+
for (let i = 0; i < assets.preloads.length; i++) {
|
|
4162
|
+
registerAsset("preload", assets.preloads[i]);
|
|
4163
|
+
}
|
|
4164
|
+
}
|
|
2964
4165
|
for (let i = 0; i < assets.js.length; i++) registerAsset("module", assets.js[i]);
|
|
2965
4166
|
};
|
|
2966
4167
|
const assets = resolve(moduleUrl);
|
|
@@ -2983,7 +4184,7 @@ function registerClientOnlyPreload(moduleUrl) {
|
|
|
2983
4184
|
function clientOnly(_fn, _options = {}, moduleUrl) {
|
|
2984
4185
|
return props => {
|
|
2985
4186
|
if (moduleUrl) registerClientOnlyPreload(moduleUrl);
|
|
2986
|
-
return
|
|
4187
|
+
return createMemo(() => props.fallback);
|
|
2987
4188
|
};
|
|
2988
4189
|
}
|
|
2989
4190
|
const statusLedgers = /* @__PURE__ */new WeakMap();
|
|
@@ -3010,7 +4211,7 @@ function httpStatus(code, text) {
|
|
|
3010
4211
|
ledger.live.push(declaration);
|
|
3011
4212
|
response.status = code;
|
|
3012
4213
|
response.statusText = text;
|
|
3013
|
-
|
|
4214
|
+
onCleanup(() => {
|
|
3014
4215
|
if (response.committed) return;
|
|
3015
4216
|
const index = ledger.live.indexOf(declaration);
|
|
3016
4217
|
if (index < 0) return;
|
|
@@ -3045,7 +4246,7 @@ function httpHeader(name, value, options) {
|
|
|
3045
4246
|
};
|
|
3046
4247
|
ledger.live.push(declaration);
|
|
3047
4248
|
if (declaration.append) headers.append(name, value);else headers.set(name, value);
|
|
3048
|
-
|
|
4249
|
+
onCleanup(() => {
|
|
3049
4250
|
if (response.committed) return;
|
|
3050
4251
|
const index = ledger.live.indexOf(declaration);
|
|
3051
4252
|
if (index < 0) return;
|
|
@@ -3064,156 +4265,4 @@ function httpHeader(name, value, options) {
|
|
|
3064
4265
|
}
|
|
3065
4266
|
}
|
|
3066
4267
|
|
|
3067
|
-
|
|
3068
|
-
enumerable: true,
|
|
3069
|
-
get: function () { return solidJs.Errored; }
|
|
3070
|
-
});
|
|
3071
|
-
Object.defineProperty(exports, "For", {
|
|
3072
|
-
enumerable: true,
|
|
3073
|
-
get: function () { return solidJs.For; }
|
|
3074
|
-
});
|
|
3075
|
-
Object.defineProperty(exports, "Hydration", {
|
|
3076
|
-
enumerable: true,
|
|
3077
|
-
get: function () { return solidJs.Hydration; }
|
|
3078
|
-
});
|
|
3079
|
-
Object.defineProperty(exports, "Loading", {
|
|
3080
|
-
enumerable: true,
|
|
3081
|
-
get: function () { return solidJs.Loading; }
|
|
3082
|
-
});
|
|
3083
|
-
Object.defineProperty(exports, "Match", {
|
|
3084
|
-
enumerable: true,
|
|
3085
|
-
get: function () { return solidJs.Match; }
|
|
3086
|
-
});
|
|
3087
|
-
Object.defineProperty(exports, "NoHydration", {
|
|
3088
|
-
enumerable: true,
|
|
3089
|
-
get: function () { return solidJs.NoHydration; }
|
|
3090
|
-
});
|
|
3091
|
-
Object.defineProperty(exports, "Repeat", {
|
|
3092
|
-
enumerable: true,
|
|
3093
|
-
get: function () { return solidJs.Repeat; }
|
|
3094
|
-
});
|
|
3095
|
-
Object.defineProperty(exports, "Reveal", {
|
|
3096
|
-
enumerable: true,
|
|
3097
|
-
get: function () { return solidJs.Reveal; }
|
|
3098
|
-
});
|
|
3099
|
-
Object.defineProperty(exports, "Show", {
|
|
3100
|
-
enumerable: true,
|
|
3101
|
-
get: function () { return solidJs.Show; }
|
|
3102
|
-
});
|
|
3103
|
-
Object.defineProperty(exports, "Switch", {
|
|
3104
|
-
enumerable: true,
|
|
3105
|
-
get: function () { return solidJs.Switch; }
|
|
3106
|
-
});
|
|
3107
|
-
Object.defineProperty(exports, "createComponent", {
|
|
3108
|
-
enumerable: true,
|
|
3109
|
-
get: function () { return solidJs.createComponent; }
|
|
3110
|
-
});
|
|
3111
|
-
Object.defineProperty(exports, "getOwner", {
|
|
3112
|
-
enumerable: true,
|
|
3113
|
-
get: function () { return solidJs.getOwner; }
|
|
3114
|
-
});
|
|
3115
|
-
Object.defineProperty(exports, "mergeProps", {
|
|
3116
|
-
enumerable: true,
|
|
3117
|
-
get: function () { return solidJs.merge; }
|
|
3118
|
-
});
|
|
3119
|
-
Object.defineProperty(exports, "scope", {
|
|
3120
|
-
enumerable: true,
|
|
3121
|
-
get: function () { return solidJs.ssrScope; }
|
|
3122
|
-
});
|
|
3123
|
-
Object.defineProperty(exports, "untrack", {
|
|
3124
|
-
enumerable: true,
|
|
3125
|
-
get: function () { return solidJs.untrack; }
|
|
3126
|
-
});
|
|
3127
|
-
exports.ChildProperties = ChildProperties;
|
|
3128
|
-
exports.DOMElements = DOMElements;
|
|
3129
|
-
exports.DOMWithState = DOMWithState;
|
|
3130
|
-
exports.DelegatedEvents = DelegatedEvents;
|
|
3131
|
-
exports.Dynamic = Dynamic;
|
|
3132
|
-
exports.HREF = HREF;
|
|
3133
|
-
exports.HydrationScript = HydrationScript;
|
|
3134
|
-
exports.MathMLElements = MathMLElements;
|
|
3135
|
-
exports.Namespaces = Namespaces;
|
|
3136
|
-
exports.Portal = Portal;
|
|
3137
|
-
exports.REVALIDATE_HEADER = REVALIDATE_HEADER;
|
|
3138
|
-
exports.RawTextElements = RawTextElements;
|
|
3139
|
-
exports.RequestContext = RequestContext;
|
|
3140
|
-
exports.ResponseEnvelope = ResponseEnvelope;
|
|
3141
|
-
exports.SAFE_ERROR = SAFE_ERROR;
|
|
3142
|
-
exports.SVGElements = SVGElements;
|
|
3143
|
-
exports.VoidElements = VoidElements;
|
|
3144
|
-
exports.acquireAsset = notSup;
|
|
3145
|
-
exports.addEvent = notSup;
|
|
3146
|
-
exports.applyRef = applyRef;
|
|
3147
|
-
exports.assign = notSup;
|
|
3148
|
-
exports.claimElement = claimElement;
|
|
3149
|
-
exports.claimElementTree = claimElementTree;
|
|
3150
|
-
exports.className = notSup;
|
|
3151
|
-
exports.clearFlashCookie = clearFlashCookie;
|
|
3152
|
-
exports.clientOnly = clientOnly;
|
|
3153
|
-
exports.commitEventResponse = commitEventResponse;
|
|
3154
|
-
exports.commitResponseStub = commitResponseStub;
|
|
3155
|
-
exports.composeMiddleware = composeMiddleware;
|
|
3156
|
-
exports.createLiveHoles = createLiveHoles;
|
|
3157
|
-
exports.createRequestEvent = createRequestEvent;
|
|
3158
|
-
exports.createResponseStub = createResponseStub;
|
|
3159
|
-
exports.createSSRResponse = createSSRResponse;
|
|
3160
|
-
exports.delegateEvents = notSup;
|
|
3161
|
-
exports.dynamic = dynamic;
|
|
3162
|
-
exports.dynamicProperty = notSup;
|
|
3163
|
-
exports.effect = effect;
|
|
3164
|
-
exports.escape = escape;
|
|
3165
|
-
exports.generateHydrationScript = generateHydrationScript;
|
|
3166
|
-
exports.getDelegatedRoot = notSup;
|
|
3167
|
-
exports.getExpectedRedirectStatus = getExpectedRedirectStatus;
|
|
3168
|
-
exports.getHydrationKey = getHydrationKey;
|
|
3169
|
-
exports.getNextElement = notSup;
|
|
3170
|
-
exports.getNextMarker = notSup;
|
|
3171
|
-
exports.getNextMatch = notSup;
|
|
3172
|
-
exports.getRequestEvent = getRequestEvent;
|
|
3173
|
-
exports.getServerFunctionMetadata = getServerFunctionMetadata;
|
|
3174
|
-
exports.getServerFunctionRPC = getServerFunctionRPC;
|
|
3175
|
-
exports.hasFlashCookie = hasFlashCookie;
|
|
3176
|
-
exports.httpHeader = httpHeader;
|
|
3177
|
-
exports.httpStatus = httpStatus;
|
|
3178
|
-
exports.hydrate = notSup;
|
|
3179
|
-
exports.insert = notSup;
|
|
3180
|
-
exports.isDev = isDev;
|
|
3181
|
-
exports.isHref = isHref;
|
|
3182
|
-
exports.isResponseEnvelope = isResponseEnvelope;
|
|
3183
|
-
exports.isSafeError = isSafeError;
|
|
3184
|
-
exports.isServer = isServer;
|
|
3185
|
-
exports.isServerFunction = isServerFunction;
|
|
3186
|
-
exports.markSafeError = markSafeError;
|
|
3187
|
-
exports.memo = memo;
|
|
3188
|
-
exports.parseCookieHeader = parseCookieHeader;
|
|
3189
|
-
exports.redirect = redirect;
|
|
3190
|
-
exports.ref = notSup;
|
|
3191
|
-
exports.registerDelegatedContainer = notSup;
|
|
3192
|
-
exports.registerDelegatedRoot = notSup;
|
|
3193
|
-
exports.registerElementClaim = registerElementClaim;
|
|
3194
|
-
exports.reload = reload;
|
|
3195
|
-
exports.render = notSup;
|
|
3196
|
-
exports.renderToStream = renderToStream;
|
|
3197
|
-
exports.renderToString = renderToString;
|
|
3198
|
-
exports.resolveSSRSelectValues = resolveSSRSelectValues;
|
|
3199
|
-
exports.respond = respond;
|
|
3200
|
-
exports.runHydrationEvents = notSup;
|
|
3201
|
-
exports.serializeCookie = serializeCookie;
|
|
3202
|
-
exports.setAttribute = notSup;
|
|
3203
|
-
exports.setAttributeNS = notSup;
|
|
3204
|
-
exports.setProperty = notSup;
|
|
3205
|
-
exports.setStyleProperty = notSup;
|
|
3206
|
-
exports.spread = notSup;
|
|
3207
|
-
exports.ssr = ssr;
|
|
3208
|
-
exports.ssrAttribute = ssrAttribute;
|
|
3209
|
-
exports.ssrClassName = ssrClassName;
|
|
3210
|
-
exports.ssrElement = ssrElement;
|
|
3211
|
-
exports.ssrGroup = ssrGroup;
|
|
3212
|
-
exports.ssrHydrationKey = ssrHydrationKey;
|
|
3213
|
-
exports.ssrStyle = ssrStyle;
|
|
3214
|
-
exports.ssrStyleProperty = ssrStyleProperty;
|
|
3215
|
-
exports.style = notSup;
|
|
3216
|
-
exports.template = notSup;
|
|
3217
|
-
exports.unregisterDelegatedContainer = notSup;
|
|
3218
|
-
exports.unregisterDelegatedRoot = notSup;
|
|
3219
|
-
exports.useHead = useHead;
|
|
4268
|
+
export { CLAIMS_DOCUMENT, CLAIMS_STREAM, CLAIM_PROP, 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, dynamic, notSup as dynamicProperty, effect, escape, generateHydrationScript, notSup as getDelegatedRoot, getExpectedRedirectStatus, getHydrationKey, notSup as getNextElement, notSup as getNextMarker, notSup as getNextMatch, getRequestEvent, getServerFunctionMetadata, getServerFunctionRPC, getTraceContext, hasFlashCookie, httpHeader, httpStatus, notSup as hydrate, notSup as insert, isDev, isHref, isResponseEnvelope, isSafeError, isServer, isServerFunction, markSafeError, memo, parseCookieHeader, notSup as readShallow, redirect, notSup as ref, notSup as registerDelegatedContainer, notSup as registerDelegatedRoot, registerElementClaim, reload, notSup as render, renderToStream, renderToString, resolveSSRNode, resolveSSRSelectValues, respond, notSup as runHydrationEvents, scriptNonce, serializeCookie, notSup as setAttribute, notSup as setAttributeNS, notSup as setProperty, notSup as setStyleProperty, notSup as spread, ssr, ssrAttribute, ssrClaim, ssrClassName, ssrElement, ssrElementAttribute, ssrGroup, ssrHydrationKey, ssrSelectValues, ssrStyle, ssrStyleProperty, notSup as style, styleNonce, notSup as template, notSup as unregisterDelegatedContainer, notSup as unregisterDelegatedRoot, useHead };
|