@solidjs/web 2.0.0-beta.30 → 2.0.0-beta.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -6
- package/dist/dev.cjs +284 -82
- package/dist/dev.js +271 -79
- package/dist/server.cjs +555 -135
- package/dist/server.js +544 -132
- package/dist/web.cjs +281 -79
- package/dist/web.js +268 -76
- package/frames/dist/client.cjs +413 -360
- package/frames/dist/client.dev.cjs +413 -360
- package/frames/dist/client.dev.js +414 -361
- package/frames/dist/client.js +414 -361
- package/frames/dist/server.cjs +604 -199
- package/frames/dist/server.js +605 -201
- package/package.json +56 -6
- package/serialization/dist/serialization.cjs +8 -0
- package/serialization/dist/serialization.js +1 -0
- package/serialization/types/index.d.ts +173 -6
- package/serialization/types-cjs/index.d.cts +173 -6
- package/server-functions/dist/client.cjs +46 -9
- package/server-functions/dist/client.js +47 -11
- package/server-functions/dist/rich-args.cjs +11 -0
- package/server-functions/dist/rich-args.js +9 -0
- package/server-functions/dist/server.cjs +275 -126
- package/server-functions/dist/server.dev.cjs +1053 -0
- package/server-functions/dist/server.dev.js +1021 -0
- package/server-functions/dist/server.js +273 -127
- package/server-functions/package.json +10 -0
- package/server-functions/rich-args/package.json +20 -0
- package/storage/types/index.d.ts +1 -1
- package/storage/types-cjs/index.d.cts +1 -1
- package/types/client.d.ts +134 -11
- package/types/core.d.ts +3 -1
- package/types/frames/client.d.ts +24 -8
- package/types/frames/frame-client.d.ts +49 -7
- package/types/frames/frame-sink.d.ts +32 -6
- package/types/frames/frame-transport.d.ts +88 -62
- package/types/frames/serializer.d.ts +173 -6
- package/types/frames/server.d.ts +22 -0
- package/types/index.d.ts +2 -3
- package/types/jsx.d.ts +3 -3
- package/types/response.d.ts +45 -0
- package/types/serializer.d.ts +173 -6
- package/types/server-functions/client.d.ts +1 -0
- package/types/server-functions/rich-args.d.ts +10 -0
- package/types/server-functions/server.d.ts +98 -0
- package/types/server-functions/shared.d.ts +22 -0
- package/types/server-mock.d.ts +171 -59
- package/types/server.d.ts +196 -42
- package/types-cjs/client.d.cts +134 -11
- package/types-cjs/core.d.cts +3 -1
- package/types-cjs/frames/client.d.cts +24 -8
- package/types-cjs/frames/frame-client.d.cts +49 -7
- package/types-cjs/frames/frame-sink.d.cts +32 -6
- package/types-cjs/frames/frame-transport.d.cts +88 -62
- package/types-cjs/frames/serializer.d.cts +173 -6
- package/types-cjs/frames/server.d.cts +22 -0
- package/types-cjs/index.d.cts +2 -3
- package/types-cjs/jsx.d.cts +3 -3
- package/types-cjs/response.d.cts +45 -0
- package/types-cjs/serializer.d.cts +173 -6
- package/types-cjs/server-functions/client.d.cts +1 -0
- package/types-cjs/server-functions/rich-args.d.cts +10 -0
- package/types-cjs/server-functions/server.d.cts +98 -0
- package/types-cjs/server-functions/shared.d.cts +22 -0
- package/types-cjs/server-mock.d.cts +171 -59
- package/types-cjs/server.d.cts +196 -42
package/dist/server.js
CHANGED
|
@@ -100,9 +100,144 @@ function getLocalHeaderScript(id) {
|
|
|
100
100
|
}
|
|
101
101
|
Feature.RegExp;
|
|
102
102
|
|
|
103
|
+
const ENVELOPE = Symbol.for("solid.ResponseEnvelope");
|
|
104
|
+
class ResponseEnvelope {
|
|
105
|
+
constructor(response, value) {
|
|
106
|
+
this.response = response;
|
|
107
|
+
this.value = value;
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
ResponseEnvelope.prototype[ENVELOPE] = true;
|
|
111
|
+
function isResponseEnvelope(value) {
|
|
112
|
+
return !!(value && typeof value === "object" && value[ENVELOPE]);
|
|
113
|
+
}
|
|
114
|
+
const HREF = Symbol.for("solid.Href");
|
|
115
|
+
function isHref(value) {
|
|
116
|
+
return !!(value && (typeof value === "object" || typeof value === "function") && value[HREF]);
|
|
117
|
+
}
|
|
118
|
+
const SAFE_ERROR = Symbol.for("solid.SafeError");
|
|
119
|
+
function markSafeError(error) {
|
|
120
|
+
if (error && (typeof error === "object" || typeof error === "function")) {
|
|
121
|
+
Object.defineProperty(error, SAFE_ERROR, {
|
|
122
|
+
value: true,
|
|
123
|
+
enumerable: false,
|
|
124
|
+
configurable: true
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
return error;
|
|
128
|
+
}
|
|
129
|
+
function isSafeError(value) {
|
|
130
|
+
return !!(value && (typeof value === "object" || typeof value === "function") && value[SAFE_ERROR]);
|
|
131
|
+
}
|
|
132
|
+
const REVALIDATE_HEADER = "X-Revalidate";
|
|
133
|
+
function initWithRevalidate(init) {
|
|
134
|
+
const {
|
|
135
|
+
revalidate,
|
|
136
|
+
...responseInit
|
|
137
|
+
} = init;
|
|
138
|
+
let headers;
|
|
139
|
+
if (responseInit.headers && responseInit.headers.getSetCookie) {
|
|
140
|
+
headers = new Headers();
|
|
141
|
+
responseInit.headers.forEach((value, key) => {
|
|
142
|
+
if (key !== "set-cookie") headers.append(key, value);
|
|
143
|
+
});
|
|
144
|
+
for (const cookie of responseInit.headers.getSetCookie()) {
|
|
145
|
+
headers.append("Set-Cookie", cookie);
|
|
146
|
+
}
|
|
147
|
+
} else {
|
|
148
|
+
headers = new Headers(responseInit.headers);
|
|
149
|
+
}
|
|
150
|
+
revalidate !== undefined && headers.set(REVALIDATE_HEADER, revalidate.toString());
|
|
151
|
+
return {
|
|
152
|
+
responseInit,
|
|
153
|
+
headers
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
function redirect(url, init = 302) {
|
|
157
|
+
if (typeof url !== "string" && !isHref(url)) {
|
|
158
|
+
throw new TypeError("redirect() expects a string URL or an Href-branded value (Symbol.for('solid.Href')).");
|
|
159
|
+
}
|
|
160
|
+
const {
|
|
161
|
+
responseInit,
|
|
162
|
+
headers
|
|
163
|
+
} = initWithRevalidate(typeof init === "number" ? {
|
|
164
|
+
status: init
|
|
165
|
+
} : init);
|
|
166
|
+
if (responseInit.status === undefined) {
|
|
167
|
+
responseInit.status = 302;
|
|
168
|
+
}
|
|
169
|
+
headers.set("Location", String(url));
|
|
170
|
+
return new Response(null, {
|
|
171
|
+
...responseInit,
|
|
172
|
+
headers
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
function reload(init = {}) {
|
|
176
|
+
const {
|
|
177
|
+
responseInit,
|
|
178
|
+
headers
|
|
179
|
+
} = initWithRevalidate(init);
|
|
180
|
+
return new Response(null, {
|
|
181
|
+
...responseInit,
|
|
182
|
+
headers
|
|
183
|
+
});
|
|
184
|
+
}
|
|
185
|
+
function respond(value, init = {}) {
|
|
186
|
+
const {
|
|
187
|
+
responseInit,
|
|
188
|
+
headers
|
|
189
|
+
} = initWithRevalidate(init);
|
|
190
|
+
headers.set("Content-Type", "application/json");
|
|
191
|
+
return new ResponseEnvelope(new Response(JSON.stringify(value), {
|
|
192
|
+
...responseInit,
|
|
193
|
+
headers
|
|
194
|
+
}), value);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
const ERROR_HEADER = "X-Server-Function-Error";
|
|
198
|
+
const BODY_FORMAT_HEADER = "X-Server-Function-Format";
|
|
199
|
+
const SINGLE_FLIGHT_HEADER = "X-Single-Flight";
|
|
200
|
+
|
|
201
|
+
function parseCookieHeader(header) {
|
|
202
|
+
const cookies = {};
|
|
203
|
+
if (!header) return cookies;
|
|
204
|
+
for (const part of header.split(";")) {
|
|
205
|
+
const eq = part.indexOf("=");
|
|
206
|
+
if (eq < 0) continue;
|
|
207
|
+
const name = decodeSafe(part.slice(0, eq).trim());
|
|
208
|
+
let value = part.slice(eq + 1).trim();
|
|
209
|
+
if (value.length > 1 && value[0] === '"' && value[value.length - 1] === '"') {
|
|
210
|
+
value = value.slice(1, -1);
|
|
211
|
+
}
|
|
212
|
+
cookies[name] = decodeSafe(value);
|
|
213
|
+
}
|
|
214
|
+
return cookies;
|
|
215
|
+
}
|
|
216
|
+
function decodeSafe(text) {
|
|
217
|
+
try {
|
|
218
|
+
return decodeURIComponent(text);
|
|
219
|
+
} catch {
|
|
220
|
+
return text;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
function serializeCookie(name, value, options = {}) {
|
|
224
|
+
let cookie = `${encodeURIComponent(name)}=${encodeURIComponent(value)}`;
|
|
225
|
+
cookie += `; Path=${options.path === undefined ? "/" : options.path}`;
|
|
226
|
+
if (options.domain) cookie += `; Domain=${options.domain}`;
|
|
227
|
+
if (options.maxAge !== undefined) cookie += `; Max-Age=${Math.trunc(options.maxAge)}`;
|
|
228
|
+
if (options.expires) cookie += `; Expires=${options.expires.toUTCString()}`;
|
|
229
|
+
if (options.httpOnly) cookie += "; HttpOnly";
|
|
230
|
+
if (options.secure) cookie += "; Secure";
|
|
231
|
+
if (options.sameSite) {
|
|
232
|
+
const sameSite = options.sameSite.toLowerCase();
|
|
233
|
+
cookie += `; SameSite=${sameSite === "none" ? "None" : sameSite === "strict" ? "Strict" : "Lax"}`;
|
|
234
|
+
}
|
|
235
|
+
return cookie;
|
|
236
|
+
}
|
|
237
|
+
|
|
103
238
|
const HEAD_ELIGIBLE_TAGS = new Set(["title", "meta", "link", "style", "script", "base"]);
|
|
104
239
|
const HEAD_ATTR_NAME = /^[a-zA-Z_][a-zA-Z0-9_:.-]*$/;
|
|
105
|
-
const RESOURCE_LINK_RELS = new Set(["preload", "modulepreload", "prefetch", "preconnect", "dns-prefetch", "
|
|
240
|
+
const RESOURCE_LINK_RELS = new Set(["preload", "modulepreload", "prefetch", "preconnect", "dns-prefetch", "stylesheet"]);
|
|
106
241
|
const RESOURCE_QUALIFIERS = ["as", "crossorigin", "type", "media", "imagesrcset", "imagesizes"];
|
|
107
242
|
const STYLESHEET_FETCH_META = new Set(["crossorigin", "integrity", "referrerpolicy", "fetchpriority"]);
|
|
108
243
|
function evalHeadValue(v) {
|
|
@@ -146,12 +281,14 @@ function replaceableIdentity(tag, props, key, unique) {
|
|
|
146
281
|
if (tag === "meta" && props.charset != null) return "charset";
|
|
147
282
|
if (key != null) return tag + ":key:" + key;
|
|
148
283
|
if (tag === "meta") {
|
|
149
|
-
if (props
|
|
150
|
-
if (props.property != null) return "meta:property:" + props.property;
|
|
151
|
-
if (props["http-equiv"] != null) return "meta:http-equiv:" + props["http-equiv"];
|
|
284
|
+
for (const ns of ["name", "property", "http-equiv"]) if (props[ns] != null) return "meta:" + ns + ":" + props[ns] + (props.media != null ? ":media=" + props.media : "");
|
|
152
285
|
return unique;
|
|
153
286
|
}
|
|
154
|
-
if (tag === "link")
|
|
287
|
+
if (tag === "link") {
|
|
288
|
+
const rel = props.rel || "";
|
|
289
|
+
if (rel === "icon" || rel === "apple-touch-icon") return "link:" + rel + (props.sizes != null ? ":sizes=" + props.sizes : "") + (props.type != null ? ":type=" + props.type : "");
|
|
290
|
+
return "link:" + rel + ":" + (props.href || "");
|
|
291
|
+
}
|
|
155
292
|
return unique;
|
|
156
293
|
}
|
|
157
294
|
function resolveHead(groups) {
|
|
@@ -338,11 +475,22 @@ function createHeadRegistry() {
|
|
|
338
475
|
resources: new Set(),
|
|
339
476
|
eagerHtml: "",
|
|
340
477
|
flushed: null,
|
|
341
|
-
shellFlushed: false
|
|
478
|
+
shellFlushed: false,
|
|
479
|
+
parkedResources: []
|
|
342
480
|
};
|
|
343
481
|
}
|
|
344
482
|
function registerHeadTags(registry, context, tracking, emitResource, nonce, tags) {
|
|
345
483
|
const boundary = context._currentBoundaryId || "";
|
|
484
|
+
if (typeof tags === "function") {
|
|
485
|
+
registry.pending.push({
|
|
486
|
+
boundary,
|
|
487
|
+
list: tags,
|
|
488
|
+
resource: (desc, rel) => emitHeadResource(registry, context, tracking, emitResource, nonce, desc, rel)
|
|
489
|
+
});
|
|
490
|
+
return;
|
|
491
|
+
}
|
|
492
|
+
if (!Array.isArray(tags)) tags = [tags];
|
|
493
|
+
const probe = sharedConfig.context && sharedConfig.context._loadingPhase;
|
|
346
494
|
let replaceable = null;
|
|
347
495
|
for (let i = 0; i < tags.length; i++) {
|
|
348
496
|
const desc = tags[i];
|
|
@@ -351,6 +499,16 @@ function registerHeadTags(registry, context, tracking, emitResource, nonce, tags
|
|
|
351
499
|
continue;
|
|
352
500
|
}
|
|
353
501
|
const cls = classifyHeadTag(desc);
|
|
502
|
+
if (probe && !cls.resource) {
|
|
503
|
+
try {
|
|
504
|
+
evalHeadProps(desc.props || {}, cls.rel !== undefined ? {
|
|
505
|
+
rel: cls.rel
|
|
506
|
+
} : undefined);
|
|
507
|
+
evalHeadValue(desc.key);
|
|
508
|
+
} catch (err) {
|
|
509
|
+
if (ssrHandleError(err)) throw err;
|
|
510
|
+
}
|
|
511
|
+
}
|
|
354
512
|
if (cls.resource) {
|
|
355
513
|
emitHeadResource(registry, context, tracking, emitResource, nonce, desc, cls.rel);
|
|
356
514
|
} else {
|
|
@@ -367,6 +525,52 @@ function registerHeadTags(registry, context, tracking, emitResource, nonce, tags
|
|
|
367
525
|
tags: replaceable
|
|
368
526
|
});
|
|
369
527
|
}
|
|
528
|
+
function headShellReady(registry, block) {
|
|
529
|
+
let ready = true;
|
|
530
|
+
const pends = err => {
|
|
531
|
+
const source = ssrHandleError(err, true);
|
|
532
|
+
if (!source) return false;
|
|
533
|
+
block(source);
|
|
534
|
+
ready = false;
|
|
535
|
+
return true;
|
|
536
|
+
};
|
|
537
|
+
const parked = registry.parkedResources;
|
|
538
|
+
for (let i = parked.length - 1; i >= 0; i--) {
|
|
539
|
+
const {
|
|
540
|
+
desc,
|
|
541
|
+
rel,
|
|
542
|
+
emit
|
|
543
|
+
} = parked[i];
|
|
544
|
+
try {
|
|
545
|
+
evalHeadProps(desc.props || {}, rel !== undefined ? {
|
|
546
|
+
rel
|
|
547
|
+
} : undefined);
|
|
548
|
+
} catch (err) {
|
|
549
|
+
if (pends(err)) continue;
|
|
550
|
+
console.warn(`useHead: error evaluating resource tag props`, err);
|
|
551
|
+
parked.splice(i, 1);
|
|
552
|
+
continue;
|
|
553
|
+
}
|
|
554
|
+
parked.splice(i, 1);
|
|
555
|
+
emit();
|
|
556
|
+
}
|
|
557
|
+
for (let i = 0; i < registry.pending.length; i++) {
|
|
558
|
+
const reg = registry.pending[i];
|
|
559
|
+
if (reg.boundary !== "" || reg.list) continue;
|
|
560
|
+
for (let j = 0; j < reg.tags.length; j++) {
|
|
561
|
+
const desc = reg.tags[j];
|
|
562
|
+
try {
|
|
563
|
+
evalHeadProps(desc.props || {}, desc.rel !== undefined ? {
|
|
564
|
+
rel: desc.rel
|
|
565
|
+
} : undefined);
|
|
566
|
+
evalHeadValue(desc.key);
|
|
567
|
+
} catch (err) {
|
|
568
|
+
pends(err);
|
|
569
|
+
}
|
|
570
|
+
}
|
|
571
|
+
}
|
|
572
|
+
return ready;
|
|
573
|
+
}
|
|
370
574
|
function emitHeadResource(registry, context, tracking, emitResource, nonce, desc, rel) {
|
|
371
575
|
let props;
|
|
372
576
|
try {
|
|
@@ -374,6 +578,16 @@ function emitHeadResource(registry, context, tracking, emitResource, nonce, desc
|
|
|
374
578
|
rel
|
|
375
579
|
} : undefined);
|
|
376
580
|
} catch (err) {
|
|
581
|
+
const loadingPhase = sharedConfig.context && sharedConfig.context._loadingPhase;
|
|
582
|
+
if (loadingPhase && ssrHandleError(err)) throw err;
|
|
583
|
+
if (!loadingPhase && !context._currentBoundaryId && !registry.shellFlushed && typeof context.block === "function" && ssrHandleError(err, true)) {
|
|
584
|
+
registry.parkedResources.push({
|
|
585
|
+
desc,
|
|
586
|
+
rel,
|
|
587
|
+
emit: () => emitHeadResource(registry, context, tracking, emitResource, nonce, desc, rel)
|
|
588
|
+
});
|
|
589
|
+
return;
|
|
590
|
+
}
|
|
377
591
|
console.warn(`useHead: error evaluating resource tag props`, err);
|
|
378
592
|
return;
|
|
379
593
|
}
|
|
@@ -430,9 +644,39 @@ function commitHeadBoundary(registry, boundary, isPendingFragment) {
|
|
|
430
644
|
keep.push(reg);
|
|
431
645
|
continue;
|
|
432
646
|
}
|
|
647
|
+
let descs = reg.tags;
|
|
648
|
+
if (reg.list) {
|
|
649
|
+
let resolved;
|
|
650
|
+
try {
|
|
651
|
+
resolved = reg.list();
|
|
652
|
+
} catch (err) {
|
|
653
|
+
console.warn(`useHead: error evaluating head group membership`, err);
|
|
654
|
+
continue;
|
|
655
|
+
}
|
|
656
|
+
if (!Array.isArray(resolved)) resolved = [resolved];
|
|
657
|
+
descs = [];
|
|
658
|
+
for (let j = 0; j < resolved.length; j++) {
|
|
659
|
+
const desc = resolved[j];
|
|
660
|
+
if (!desc || !HEAD_ELIGIBLE_TAGS.has(desc.tag)) {
|
|
661
|
+
console.warn(`useHead: ignoring non-head tag`, desc);
|
|
662
|
+
continue;
|
|
663
|
+
}
|
|
664
|
+
const cls = classifyHeadTag(desc);
|
|
665
|
+
if (cls.resource) {
|
|
666
|
+
reg.resource(desc, cls.rel);
|
|
667
|
+
} else {
|
|
668
|
+
descs.push(cls.rel !== undefined ? {
|
|
669
|
+
tag: desc.tag,
|
|
670
|
+
props: desc.props,
|
|
671
|
+
key: desc.key,
|
|
672
|
+
rel: cls.rel
|
|
673
|
+
} : desc);
|
|
674
|
+
}
|
|
675
|
+
}
|
|
676
|
+
}
|
|
433
677
|
const tags = [];
|
|
434
|
-
for (let j = 0; j <
|
|
435
|
-
const desc =
|
|
678
|
+
for (let j = 0; j < descs.length; j++) {
|
|
679
|
+
const desc = descs[j];
|
|
436
680
|
let props, key;
|
|
437
681
|
try {
|
|
438
682
|
props = evalHeadProps(desc.props || {}, desc.rel !== undefined ? {
|
|
@@ -581,10 +825,10 @@ function useHead(tags) {
|
|
|
581
825
|
console.warn("useHead() called outside of a server render; registration ignored.");
|
|
582
826
|
return;
|
|
583
827
|
}
|
|
584
|
-
ctx.registerHeadTags(
|
|
828
|
+
ctx.registerHeadTags(tags);
|
|
585
829
|
}
|
|
586
830
|
const VOID_ELEMENTS = /^(?:area|base|br|col|embed|hr|img|input|keygen|link|menuitem|meta|param|source|track|wbr)$/i;
|
|
587
|
-
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.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])}`;
|
|
831
|
+
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])}`;
|
|
588
832
|
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)}`;
|
|
589
833
|
function renderToString(code, options = {}) {
|
|
590
834
|
const {
|
|
@@ -610,7 +854,6 @@ function renderToString(code, options = {}) {
|
|
|
610
854
|
const tracking = createAssetTracking();
|
|
611
855
|
const headRegistry = createHeadRegistry();
|
|
612
856
|
sharedConfig.context = {
|
|
613
|
-
assets: [],
|
|
614
857
|
nonce,
|
|
615
858
|
escape: escape,
|
|
616
859
|
resolve: resolveSSRNode,
|
|
@@ -652,9 +895,8 @@ function renderToString(code, options = {}) {
|
|
|
652
895
|
serializeFragmentAssets("", tracking.boundaryModules, sharedConfig.context);
|
|
653
896
|
sharedConfig.context.noHydrate = true;
|
|
654
897
|
serializer.close();
|
|
655
|
-
const assetsHtml = resolveAssetsHtml(sharedConfig.context.assets);
|
|
656
898
|
const head = renderShellHead(headRegistry, nonce, null);
|
|
657
|
-
return assembleDocument(html,
|
|
899
|
+
return assembleDocument(html, tracking.emittedAssets, tracking.inlineStyles, scripts.length ? scripts : "", nonce, head, onHead);
|
|
658
900
|
}
|
|
659
901
|
function renderToStream(code, options = {}) {
|
|
660
902
|
let {
|
|
@@ -667,6 +909,41 @@ function renderToStream(code, options = {}) {
|
|
|
667
909
|
onHead
|
|
668
910
|
} = options;
|
|
669
911
|
let dispose;
|
|
912
|
+
let dead = false;
|
|
913
|
+
const abandon = () => {
|
|
914
|
+
if (dead) return;
|
|
915
|
+
dead = true;
|
|
916
|
+
completed = true;
|
|
917
|
+
buffer = {
|
|
918
|
+
write() {}
|
|
919
|
+
};
|
|
920
|
+
writable = {
|
|
921
|
+
end() {}
|
|
922
|
+
};
|
|
923
|
+
if (dispose) {
|
|
924
|
+
const d = dispose;
|
|
925
|
+
dispose = () => {};
|
|
926
|
+
d();
|
|
927
|
+
}
|
|
928
|
+
};
|
|
929
|
+
const guardSink = w => ({
|
|
930
|
+
write(payload) {
|
|
931
|
+
if (dead) return;
|
|
932
|
+
try {
|
|
933
|
+
w.write(payload);
|
|
934
|
+
} catch (_) {
|
|
935
|
+
abandon();
|
|
936
|
+
}
|
|
937
|
+
},
|
|
938
|
+
end() {
|
|
939
|
+
if (dead) return;
|
|
940
|
+
try {
|
|
941
|
+
w.end();
|
|
942
|
+
} catch (_) {
|
|
943
|
+
abandon();
|
|
944
|
+
}
|
|
945
|
+
}
|
|
946
|
+
});
|
|
670
947
|
const blockingPromises = new Set();
|
|
671
948
|
let headerEmitted = false;
|
|
672
949
|
const pushTask = task => {
|
|
@@ -730,7 +1007,7 @@ function renderToStream(code, options = {}) {
|
|
|
730
1007
|
}
|
|
731
1008
|
},
|
|
732
1009
|
shell(shellHtml, meta) {
|
|
733
|
-
buffer.write(assembleDocument(shellHtml, meta.
|
|
1010
|
+
buffer.write(assembleDocument(shellHtml, meta.preloads, meta.inlineStyles, meta.tasks.length ? meta.tasks : "", nonce, meta.head, onHead));
|
|
734
1011
|
},
|
|
735
1012
|
...options.sink
|
|
736
1013
|
};
|
|
@@ -810,7 +1087,6 @@ function renderToStream(code, options = {}) {
|
|
|
810
1087
|
};
|
|
811
1088
|
sharedConfig.context = context = {
|
|
812
1089
|
async: true,
|
|
813
|
-
assets: [],
|
|
814
1090
|
nonce,
|
|
815
1091
|
registerHeadTags(tags) {
|
|
816
1092
|
registerHeadTags(headRegistry, context, tracking,
|
|
@@ -1010,9 +1286,9 @@ function renderToStream(code, options = {}) {
|
|
|
1010
1286
|
}
|
|
1011
1287
|
function doShell() {
|
|
1012
1288
|
if (shellCompleted) return;
|
|
1013
|
-
if (!resolveRootHoles()) return;
|
|
1014
1289
|
sharedConfig.context = context;
|
|
1015
|
-
|
|
1290
|
+
if (!resolveRootHoles()) return;
|
|
1291
|
+
if (!headShellReady(headRegistry, p => blockingPromises.add(p))) return;
|
|
1016
1292
|
headStyles = new Set();
|
|
1017
1293
|
for (const url of tracking.emittedAssets) {
|
|
1018
1294
|
if (isCssUrl(url)) headStyles.add(url);
|
|
@@ -1020,7 +1296,6 @@ function renderToStream(code, options = {}) {
|
|
|
1020
1296
|
serializeRootAssets();
|
|
1021
1297
|
const head = renderShellHead(headRegistry, nonce, k => registry.has(k));
|
|
1022
1298
|
sink.shell(html, {
|
|
1023
|
-
assets: assetsHtml,
|
|
1024
1299
|
preloads: tracking.emittedAssets,
|
|
1025
1300
|
inlineStyles: tracking.inlineStyles,
|
|
1026
1301
|
tasks,
|
|
@@ -1068,14 +1343,24 @@ function renderToStream(code, options = {}) {
|
|
|
1068
1343
|
function flush() {
|
|
1069
1344
|
allSettled(blockingPromises).then(() => {
|
|
1070
1345
|
scheduleFlush(() => {
|
|
1346
|
+
if (dead) return resolve();
|
|
1071
1347
|
doShell();
|
|
1072
1348
|
if (!shellCompleted) return flush();
|
|
1073
1349
|
const encoder = new TextEncoder();
|
|
1074
1350
|
const writer = w.getWriter();
|
|
1075
1351
|
let pendingWrites = Promise.resolve();
|
|
1352
|
+
let ended = false;
|
|
1353
|
+
const failed = () => {
|
|
1354
|
+
if (!ended) {
|
|
1355
|
+
abandon();
|
|
1356
|
+
resolve();
|
|
1357
|
+
}
|
|
1358
|
+
};
|
|
1359
|
+
writer.closed && writer.closed.catch(failed);
|
|
1076
1360
|
writable = {
|
|
1077
1361
|
end() {
|
|
1078
1362
|
pendingWrites.then(() => {
|
|
1363
|
+
ended = true;
|
|
1079
1364
|
writer.releaseLock();
|
|
1080
1365
|
w.close().catch(() => {});
|
|
1081
1366
|
resolve();
|
|
@@ -1084,7 +1369,7 @@ function renderToStream(code, options = {}) {
|
|
|
1084
1369
|
};
|
|
1085
1370
|
buffer = {
|
|
1086
1371
|
write(payload) {
|
|
1087
|
-
pendingWrites = pendingWrites.then(() => writer.write(encoder.encode(payload))).catch(
|
|
1372
|
+
pendingWrites = pendingWrites.then(() => writer.write(encoder.encode(payload))).catch(failed);
|
|
1088
1373
|
}
|
|
1089
1374
|
};
|
|
1090
1375
|
buffer.write(tmp);
|
|
@@ -1100,36 +1385,40 @@ function renderToStream(code, options = {}) {
|
|
|
1100
1385
|
return p;
|
|
1101
1386
|
};
|
|
1102
1387
|
return {
|
|
1103
|
-
then(
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1388
|
+
then(onFulfilled, onRejected) {
|
|
1389
|
+
const p = new Promise(resolve => {
|
|
1390
|
+
function complete() {
|
|
1391
|
+
dispose();
|
|
1392
|
+
resolve(tmp);
|
|
1393
|
+
}
|
|
1394
|
+
if (onCompleteAll) {
|
|
1395
|
+
let ogComplete = onCompleteAll;
|
|
1396
|
+
onCompleteAll = options => {
|
|
1397
|
+
ogComplete(options);
|
|
1398
|
+
complete();
|
|
1399
|
+
};
|
|
1400
|
+
} else onCompleteAll = complete;
|
|
1401
|
+
function flush() {
|
|
1402
|
+
allSettled(blockingPromises).then(() => {
|
|
1403
|
+
scheduleFlush(() => {
|
|
1404
|
+
if (!resolveRootHoles() || !headShellReady(headRegistry, p => blockingPromises.add(p))) return flush();
|
|
1405
|
+
queue(flushEnd);
|
|
1406
|
+
});
|
|
1120
1407
|
});
|
|
1121
|
-
}
|
|
1122
|
-
|
|
1123
|
-
|
|
1408
|
+
}
|
|
1409
|
+
flush();
|
|
1410
|
+
});
|
|
1411
|
+
return p.then(onFulfilled, onRejected);
|
|
1124
1412
|
},
|
|
1125
1413
|
pipe(w) {
|
|
1126
1414
|
claimConsumer("pipe");
|
|
1127
1415
|
function flush() {
|
|
1128
1416
|
allSettled(blockingPromises).then(() => {
|
|
1129
1417
|
scheduleFlush(() => {
|
|
1418
|
+
if (dead) return;
|
|
1130
1419
|
doShell();
|
|
1131
1420
|
if (!shellCompleted) return flush();
|
|
1132
|
-
buffer = writable = w;
|
|
1421
|
+
buffer = writable = guardSink(w);
|
|
1133
1422
|
buffer.write(tmp);
|
|
1134
1423
|
firstFlushed = true;
|
|
1135
1424
|
if (completed) {
|
|
@@ -1490,18 +1779,6 @@ function getHydrationKey() {
|
|
|
1490
1779
|
function applyRef(r, element) {
|
|
1491
1780
|
Array.isArray(r) ? r.flat(Infinity).forEach(f => f && f(element)) : r(element);
|
|
1492
1781
|
}
|
|
1493
|
-
function useAssets(fn) {
|
|
1494
|
-
sharedConfig.context.assets.push(() => resolveSSRSync(escape(fn())));
|
|
1495
|
-
}
|
|
1496
|
-
function getAssets() {
|
|
1497
|
-
const assets = sharedConfig.context.assets;
|
|
1498
|
-
let out = "";
|
|
1499
|
-
for (let i = 0, len = assets.length; i < len; i++) out += assets[i]();
|
|
1500
|
-
return out;
|
|
1501
|
-
}
|
|
1502
|
-
function Assets(props) {
|
|
1503
|
-
useAssets(() => props.children);
|
|
1504
|
-
}
|
|
1505
1782
|
function generateHydrationScript({
|
|
1506
1783
|
eventNames = ["click", "input"],
|
|
1507
1784
|
nonce
|
|
@@ -1518,17 +1795,11 @@ function allSettled(promises) {
|
|
|
1518
1795
|
return;
|
|
1519
1796
|
});
|
|
1520
1797
|
}
|
|
1521
|
-
function
|
|
1522
|
-
if (!assets || !assets.length) return "";
|
|
1523
|
-
let out = "";
|
|
1524
|
-
for (let i = 0, len = assets.length; i < len; i++) out += assets[i]();
|
|
1525
|
-
return out;
|
|
1526
|
-
}
|
|
1527
|
-
function assembleDocument(html, assetsHtml, emittedAssets, inlineStyles, scripts, nonce, headTags, onHead) {
|
|
1798
|
+
function assembleDocument(html, emittedAssets, inlineStyles, scripts, nonce, headTags, onHead) {
|
|
1528
1799
|
const scriptTag = scripts ? `<script${nonce ? ` nonce="${nonce}"` : ""}>${scripts}</script>` : "";
|
|
1529
1800
|
const headTagsHtml = headTags ? headTags.html : "";
|
|
1530
1801
|
const headPrelude = headTags ? headTags.prelude : "";
|
|
1531
|
-
if (!onHead && !
|
|
1802
|
+
if (!onHead && !headTagsHtml && !headPrelude && !(emittedAssets && emittedAssets.size) && !(inlineStyles && inlineStyles.size)) {
|
|
1532
1803
|
if (!scriptTag) return html;
|
|
1533
1804
|
const xs = html.indexOf("<!--xs-->");
|
|
1534
1805
|
return xs === -1 ? html + scriptTag : html.slice(0, xs) + scriptTag + html.slice(xs);
|
|
@@ -1543,13 +1814,13 @@ function assembleDocument(html, assetsHtml, emittedAssets, inlineStyles, scripts
|
|
|
1543
1814
|
const headIdx = html.indexOf("</head>");
|
|
1544
1815
|
if (headIdx === -1) {
|
|
1545
1816
|
if (onHead) {
|
|
1546
|
-
onHead(headPrelude + headTagsHtml +
|
|
1817
|
+
onHead(headPrelude + headTagsHtml + renderHeadAssets(emittedAssets, inlineStyles, nonce));
|
|
1547
1818
|
}
|
|
1548
1819
|
if (!scriptTag) return html;
|
|
1549
1820
|
const xs = html.indexOf("<!--xs-->");
|
|
1550
1821
|
return xs === -1 ? html + scriptTag : html.slice(0, xs) + scriptTag + html.slice(xs);
|
|
1551
1822
|
}
|
|
1552
|
-
const head = headTagsHtml +
|
|
1823
|
+
const head = headTagsHtml + renderHeadAssets(emittedAssets, inlineStyles, nonce);
|
|
1553
1824
|
if (!scriptTag) return html.slice(0, headIdx) + head + html.slice(headIdx);
|
|
1554
1825
|
const xsIdx = html.indexOf("<!--xs-->");
|
|
1555
1826
|
if (xsIdx === -1) return html.slice(0, headIdx) + head + html.slice(headIdx) + scriptTag;
|
|
@@ -1749,90 +2020,226 @@ const RequestContext = Symbol.for("solid.RequestContext");
|
|
|
1749
2020
|
function getRequestEvent() {
|
|
1750
2021
|
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;
|
|
1751
2022
|
}
|
|
1752
|
-
function
|
|
1753
|
-
return
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
function claimElement(node) {
|
|
1760
|
-
return node;
|
|
2023
|
+
function createResponseStub() {
|
|
2024
|
+
return {
|
|
2025
|
+
status: undefined,
|
|
2026
|
+
statusText: undefined,
|
|
2027
|
+
headers: new Headers(),
|
|
2028
|
+
committed: false
|
|
2029
|
+
};
|
|
1761
2030
|
}
|
|
1762
|
-
function
|
|
1763
|
-
return
|
|
2031
|
+
function createRequestEvent(request, init) {
|
|
2032
|
+
return {
|
|
2033
|
+
request,
|
|
2034
|
+
locals: {},
|
|
2035
|
+
response: createResponseStub(),
|
|
2036
|
+
...init
|
|
2037
|
+
};
|
|
1764
2038
|
}
|
|
1765
|
-
function
|
|
1766
|
-
|
|
2039
|
+
function reportLostHeaderWrite(method, name) {
|
|
2040
|
+
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).";
|
|
2041
|
+
throw new Error(message);
|
|
1767
2042
|
}
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
2043
|
+
function commitResponseStub(stub, {
|
|
2044
|
+
allowLateLocation = false
|
|
2045
|
+
} = {}) {
|
|
2046
|
+
if (!stub || stub.committed) return stub;
|
|
2047
|
+
stub.committed = true;
|
|
2048
|
+
const headers = stub.headers;
|
|
2049
|
+
if (!headers || typeof headers.set !== "function") return stub;
|
|
2050
|
+
for (const method of ["set", "append", "delete"]) {
|
|
2051
|
+
const original = headers[method].bind(headers);
|
|
2052
|
+
headers[method] = function (name, ...rest) {
|
|
2053
|
+
if (allowLateLocation && method === "set" && String(name).toLowerCase() === "location") {
|
|
2054
|
+
return original(name, ...rest);
|
|
2055
|
+
}
|
|
2056
|
+
reportLostHeaderWrite(method, name);
|
|
2057
|
+
};
|
|
1774
2058
|
}
|
|
2059
|
+
return stub;
|
|
1775
2060
|
}
|
|
1776
|
-
|
|
1777
|
-
function
|
|
1778
|
-
|
|
2061
|
+
const validRedirectStatuses = /*#__PURE__*/new Set([301, 302, 303, 307, 308]);
|
|
2062
|
+
function getExpectedRedirectStatus(response) {
|
|
2063
|
+
if (response.status && validRedirectStatuses.has(response.status)) return response.status;
|
|
2064
|
+
return 302;
|
|
1779
2065
|
}
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
2066
|
+
function mergeStubHeaders(target, stub) {
|
|
2067
|
+
if (!stub) return target;
|
|
2068
|
+
stub.headers.forEach((value, key) => {
|
|
2069
|
+
if (key !== "set-cookie") target.set(key, value);
|
|
2070
|
+
});
|
|
2071
|
+
const setCookies = stub.headers.getSetCookie ? stub.headers.getSetCookie() : [];
|
|
2072
|
+
for (const cookie of setCookies) target.append("set-cookie", cookie);
|
|
2073
|
+
return target;
|
|
2074
|
+
}
|
|
2075
|
+
function copyInitHeaders(init) {
|
|
2076
|
+
if (!init || !init.getSetCookie) return new Headers(init);
|
|
2077
|
+
const headers = new Headers();
|
|
2078
|
+
init.forEach((value, key) => {
|
|
2079
|
+
if (key !== "set-cookie") headers.append(key, value);
|
|
2080
|
+
});
|
|
2081
|
+
for (const cookie of init.getSetCookie()) headers.append("Set-Cookie", cookie);
|
|
2082
|
+
return headers;
|
|
2083
|
+
}
|
|
2084
|
+
const STUB_GAP_FILL_EXCLUDED = /*#__PURE__*/new Set([ERROR_HEADER, BODY_FORMAT_HEADER, SINGLE_FLIGHT_HEADER, REVALIDATE_HEADER, "Location"].map(header => header.toLowerCase()));
|
|
2085
|
+
function fillsStubGap(key, headers, response) {
|
|
2086
|
+
if (key === "set-cookie" || STUB_GAP_FILL_EXCLUDED.has(key)) return false;
|
|
2087
|
+
if (response.body === null && (key === "content-type" || key === "content-length")) return false;
|
|
2088
|
+
return !headers.has(key);
|
|
2089
|
+
}
|
|
2090
|
+
function commitEventResponse(response, event = getRequestEvent()) {
|
|
2091
|
+
const stub = event && event.response;
|
|
2092
|
+
if (!stub || !stub.headers || stub.committed) return response;
|
|
2093
|
+
const cookies = stub.headers.getSetCookie ? stub.headers.getSetCookie() : [];
|
|
2094
|
+
commitResponseStub(stub);
|
|
2095
|
+
let hasGaps = false;
|
|
2096
|
+
stub.headers.forEach((value, key) => {
|
|
2097
|
+
if (fillsStubGap(key, response.headers, response)) hasGaps = true;
|
|
2098
|
+
});
|
|
2099
|
+
if (!cookies.length && !hasGaps) return response;
|
|
2100
|
+
try {
|
|
2101
|
+
for (const cookie of cookies) response.headers.append("Set-Cookie", cookie);
|
|
2102
|
+
stub.headers.forEach((value, key) => {
|
|
2103
|
+
if (fillsStubGap(key, response.headers, response)) response.headers.set(key, value);
|
|
2104
|
+
});
|
|
2105
|
+
return response;
|
|
2106
|
+
} catch {
|
|
2107
|
+
const headers = copyInitHeaders(response.headers);
|
|
2108
|
+
for (const cookie of cookies) headers.append("Set-Cookie", cookie);
|
|
2109
|
+
stub.headers.forEach((value, key) => {
|
|
2110
|
+
if (fillsStubGap(key, headers, response)) headers.set(key, value);
|
|
2111
|
+
});
|
|
2112
|
+
return new Response(response.body, {
|
|
2113
|
+
status: response.status,
|
|
2114
|
+
statusText: response.statusText,
|
|
2115
|
+
headers
|
|
2116
|
+
});
|
|
2117
|
+
}
|
|
1783
2118
|
}
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
const
|
|
1787
|
-
|
|
1788
|
-
...responseInit
|
|
1789
|
-
} = init;
|
|
1790
|
-
const headers = new Headers(responseInit.headers);
|
|
1791
|
-
revalidate !== undefined && headers.set(REVALIDATE_HEADER, revalidate.toString());
|
|
2119
|
+
function deriveHead(stub, responseInit = {}) {
|
|
2120
|
+
const headers = mergeStubHeaders(copyInitHeaders(responseInit.headers), stub);
|
|
2121
|
+
const status = stub && stub.status || responseInit.status || 200;
|
|
2122
|
+
const statusText = stub && stub.statusText || responseInit.statusText || undefined;
|
|
1792
2123
|
return {
|
|
1793
|
-
|
|
2124
|
+
status,
|
|
2125
|
+
statusText,
|
|
1794
2126
|
headers
|
|
1795
2127
|
};
|
|
1796
2128
|
}
|
|
1797
|
-
function
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
2129
|
+
function escapeAttribute(value) {
|
|
2130
|
+
return value.replace(/&/g, "&").replace(/"/g, """).replace(/</g, "<");
|
|
2131
|
+
}
|
|
2132
|
+
function createSSRResponse(result, event, options = {}) {
|
|
2133
|
+
const stub = event && event.response;
|
|
1801
2134
|
const {
|
|
1802
2135
|
responseInit,
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
2136
|
+
nonce,
|
|
2137
|
+
transformChunk
|
|
2138
|
+
} = options;
|
|
2139
|
+
if (typeof result === "string") {
|
|
2140
|
+
if (stub) commitResponseStub(stub);
|
|
2141
|
+
const head = deriveHead(stub, responseInit);
|
|
2142
|
+
if (stub && stub.headers.get("Location")) {
|
|
2143
|
+
return new Response(null, {
|
|
2144
|
+
status: getExpectedRedirectStatus(stub),
|
|
2145
|
+
headers: head.headers
|
|
2146
|
+
});
|
|
2147
|
+
}
|
|
2148
|
+
if (!head.headers.has("content-type")) {
|
|
2149
|
+
head.headers.set("content-type", "text/html; charset=utf-8");
|
|
2150
|
+
}
|
|
2151
|
+
return new Response(transformChunk ? transformChunk(result) : result, {
|
|
2152
|
+
status: head.status,
|
|
2153
|
+
statusText: head.statusText,
|
|
2154
|
+
headers: head.headers
|
|
2155
|
+
});
|
|
1809
2156
|
}
|
|
1810
|
-
|
|
1811
|
-
return new
|
|
1812
|
-
|
|
1813
|
-
|
|
2157
|
+
const encoder = new TextEncoder();
|
|
2158
|
+
return new Promise(resolve => {
|
|
2159
|
+
let controller;
|
|
2160
|
+
let closed = false;
|
|
2161
|
+
let flushed = false;
|
|
2162
|
+
const enqueue = value => {
|
|
2163
|
+
if (closed || !controller) return;
|
|
2164
|
+
try {
|
|
2165
|
+
controller.enqueue(encoder.encode(value));
|
|
2166
|
+
} catch {
|
|
2167
|
+
closed = true;
|
|
2168
|
+
}
|
|
2169
|
+
};
|
|
2170
|
+
result.pipe({
|
|
2171
|
+
write(chunk) {
|
|
2172
|
+
if (!flushed) {
|
|
2173
|
+
flushed = true;
|
|
2174
|
+
if (stub) commitResponseStub(stub, {
|
|
2175
|
+
allowLateLocation: true
|
|
2176
|
+
});
|
|
2177
|
+
const head = deriveHead(stub, responseInit);
|
|
2178
|
+
if (stub && stub.headers.get("Location")) {
|
|
2179
|
+
closed = true;
|
|
2180
|
+
resolve(new Response(null, {
|
|
2181
|
+
status: getExpectedRedirectStatus(stub),
|
|
2182
|
+
headers: head.headers
|
|
2183
|
+
}));
|
|
2184
|
+
return;
|
|
2185
|
+
}
|
|
2186
|
+
if (!head.headers.has("content-type")) {
|
|
2187
|
+
head.headers.set("content-type", "text/html; charset=utf-8");
|
|
2188
|
+
}
|
|
2189
|
+
resolve(new Response(new ReadableStream({
|
|
2190
|
+
start(c) {
|
|
2191
|
+
controller = c;
|
|
2192
|
+
},
|
|
2193
|
+
cancel() {
|
|
2194
|
+
closed = true;
|
|
2195
|
+
}
|
|
2196
|
+
}), {
|
|
2197
|
+
status: head.status,
|
|
2198
|
+
statusText: head.statusText,
|
|
2199
|
+
headers: head.headers
|
|
2200
|
+
}));
|
|
2201
|
+
}
|
|
2202
|
+
enqueue(transformChunk ? transformChunk(chunk) : chunk);
|
|
2203
|
+
},
|
|
2204
|
+
end() {
|
|
2205
|
+
if (closed || !controller) return;
|
|
2206
|
+
const location = stub && stub.headers.get("Location");
|
|
2207
|
+
if (location) {
|
|
2208
|
+
const attr = nonce ? ` nonce="${escapeAttribute(nonce)}"` : "";
|
|
2209
|
+
enqueue(`<script${attr}>window.location=${JSON.stringify(location).replace(/</g, "\\u003c")}</script>`);
|
|
2210
|
+
}
|
|
2211
|
+
closed = true;
|
|
2212
|
+
try {
|
|
2213
|
+
controller.close();
|
|
2214
|
+
} catch {}
|
|
2215
|
+
}
|
|
2216
|
+
});
|
|
1814
2217
|
});
|
|
1815
2218
|
}
|
|
1816
|
-
function
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
2219
|
+
function composeMiddleware(middlewares) {
|
|
2220
|
+
return function run(request, next) {
|
|
2221
|
+
let index = -1;
|
|
2222
|
+
function dispatch(i, req) {
|
|
2223
|
+
if (i <= index) return Promise.reject(new Error("next() called multiple times"));
|
|
2224
|
+
index = i;
|
|
2225
|
+
if (i === middlewares.length) return Promise.resolve(next(req));
|
|
2226
|
+
return Promise.resolve(middlewares[i](req, override => dispatch(i + 1, override || req)));
|
|
2227
|
+
}
|
|
2228
|
+
return dispatch(0, request);
|
|
2229
|
+
};
|
|
1825
2230
|
}
|
|
1826
|
-
function
|
|
1827
|
-
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
|
|
1831
|
-
|
|
1832
|
-
|
|
1833
|
-
|
|
1834
|
-
|
|
1835
|
-
|
|
2231
|
+
function registerElementClaim() {
|
|
2232
|
+
return noopCleanup;
|
|
2233
|
+
}
|
|
2234
|
+
function noopCleanup() {}
|
|
2235
|
+
function claimElement(node) {
|
|
2236
|
+
return node;
|
|
2237
|
+
}
|
|
2238
|
+
function claimElementTree(root) {
|
|
2239
|
+
return root;
|
|
2240
|
+
}
|
|
2241
|
+
function notSup() {
|
|
2242
|
+
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>.");
|
|
1836
2243
|
}
|
|
1837
2244
|
|
|
1838
2245
|
const isServer = true;
|
|
@@ -1920,13 +2327,18 @@ function httpHeader(name, value, options) {
|
|
|
1920
2327
|
const response = event && event.response;
|
|
1921
2328
|
if (response && !response.committed) {
|
|
1922
2329
|
const headers = response.headers;
|
|
1923
|
-
const
|
|
2330
|
+
const setCookie = name.toLowerCase() === "set-cookie";
|
|
2331
|
+
const prevCookies = setCookie ? headers.getSetCookie() : undefined;
|
|
2332
|
+
const prev = setCookie ? null : headers.get(name);
|
|
1924
2333
|
if (options && options.append) headers.append(name, value);else headers.set(name, value);
|
|
1925
2334
|
onCleanup(() => {
|
|
1926
2335
|
if (response.committed) return;
|
|
1927
|
-
if (
|
|
2336
|
+
if (setCookie) {
|
|
2337
|
+
headers.delete(name);
|
|
2338
|
+
for (const cookie of prevCookies) headers.append(name, cookie);
|
|
2339
|
+
} else if (prev === null) headers.delete(name);else headers.set(name, prev);
|
|
1928
2340
|
});
|
|
1929
2341
|
}
|
|
1930
2342
|
}
|
|
1931
2343
|
|
|
1932
|
-
export {
|
|
2344
|
+
export { ChildProperties, DOMElements, DOMWithState, DelegatedEvents, Dynamic, HREF, HydrationScript, MathMLElements, Namespaces, Portal, REVALIDATE_HEADER, RawTextElements, RequestContext, ResponseEnvelope, SAFE_ERROR, SVGElements, VoidElements, notSup as acquireAsset, notSup as addEvent, applyRef, notSup as assign, claimElement, claimElementTree, notSup as className, clientOnly, commitEventResponse, commitResponseStub, composeMiddleware, 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, httpHeader, httpStatus, notSup as hydrate, notSup as insert, isDev, isHref, isResponseEnvelope, isSafeError, isServer, markSafeError, memo, parseCookieHeader, redirect, notSup as ref, notSup as registerDelegatedContainer, notSup as registerDelegatedRoot, registerElementClaim, reload, notSup as render, renderToStream, renderToString, respond, notSup as runHydrationEvents, serializeCookie, notSup as setAttribute, notSup as setAttributeNS, notSup as setProperty, notSup as setStyleProperty, notSup as spread, ssr, ssrAttribute, ssrClassName, ssrElement, ssrGroup, ssrHydrationKey, ssrStyle, ssrStyleProperty, notSup as style, notSup as template, notSup as unregisterDelegatedContainer, notSup as unregisterDelegatedRoot, useHead };
|