@kyro-cms/admin 0.1.2 → 0.1.3
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/package.json +17 -6
- package/src/components/Admin.tsx +50 -1
- package/src/components/LoginPage.tsx +223 -0
- package/src/components/layout/Sidebar.tsx +35 -0
- package/src/index.ts +35 -0
- package/src/middleware.ts +2 -0
- package/src/pages/api/auth/register.ts +133 -0
- package/src/styles/main.css +148 -0
- package/.astro/content.d.ts +0 -154
- package/.astro/settings.json +0 -5
- package/.astro/types.d.ts +0 -2
- package/astro.config.mjs +0 -28
- package/bun.lock +0 -1374
- package/dist/client/_astro/AdminLayout.DkDpng53.css +0 -1
- package/dist/client/_astro/AutoForm.3eJCmCJp.js +0 -1
- package/dist/client/_astro/client.DyczpTbx.js +0 -9
- package/dist/client/_astro/index.B02hbnpo.js +0 -1
- package/dist/client/fonts/Serotiva-Black.woff2 +0 -0
- package/dist/client/fonts/Serotiva-Bold.woff2 +0 -0
- package/dist/client/fonts/Serotiva-Medium.woff2 +0 -0
- package/dist/client/fonts/Serotiva-Regular.woff2 +0 -0
- package/dist/client/fonts/Serotiva-SemiBold.woff2 +0 -0
- package/dist/server/chunks/AdminLayout_D-_JeUqC.mjs +0 -26
- package/dist/server/chunks/_id__BzI_o0qT.mjs +0 -50
- package/dist/server/chunks/_id__Cd-jOuY3.mjs +0 -238
- package/dist/server/chunks/_id__DvbD--iR.mjs +0 -992
- package/dist/server/chunks/_id__vpVaEo16.mjs +0 -128
- package/dist/server/chunks/_virtual_astro_server-island-manifest_CQQ1F5PF.mjs +0 -7
- package/dist/server/chunks/_virtual_astro_session-driver_Bk3Q189E.mjs +0 -4
- package/dist/server/chunks/astro-component_Dbx3T2Nh.mjs +0 -37
- package/dist/server/chunks/audit-logs_DrnUMRvY.mjs +0 -74
- package/dist/server/chunks/config_CPXslElD.mjs +0 -4221
- package/dist/server/chunks/dataStore_Dl7cA2Qp.mjs +0 -89
- package/dist/server/chunks/index_CVqOkerS.mjs +0 -2960
- package/dist/server/chunks/index_CX8SQ4BF.mjs +0 -55
- package/dist/server/chunks/index_CYofDU51.mjs +0 -58
- package/dist/server/chunks/index_DdNRhuaM.mjs +0 -55
- package/dist/server/chunks/index_DupPvtIF.mjs +0 -42
- package/dist/server/chunks/index_YTS_M-B9.mjs +0 -263
- package/dist/server/chunks/index_YeCzuVps.mjs +0 -53
- package/dist/server/chunks/login_DLyqMRO8.mjs +0 -93
- package/dist/server/chunks/logout_CSbt5wea.mjs +0 -50
- package/dist/server/chunks/me_C04jlYhH.mjs +0 -41
- package/dist/server/chunks/new_BbQ9b55M.mjs +0 -92
- package/dist/server/chunks/node_9bvTewss.mjs +0 -1014
- package/dist/server/chunks/noop-entrypoint_BOlrdqWF.mjs +0 -3
- package/dist/server/chunks/sequence_9cl7AJy-.mjs +0 -2503
- package/dist/server/chunks/server_peBx9VXG.mjs +0 -8117
- package/dist/server/chunks/sharp_pmJ7nHES.mjs +0 -142
- package/dist/server/chunks/users_Dzddy_YR.mjs +0 -137
- package/dist/server/entry.mjs +0 -5
- package/dist/server/virtual_astro_middleware.mjs +0 -48
- package/public/fonts/Serotiva-Black.woff2 +0 -0
- package/public/fonts/Serotiva-Bold.woff2 +0 -0
- package/public/fonts/Serotiva-Medium.woff2 +0 -0
- package/public/fonts/Serotiva-Regular.woff2 +0 -0
- package/public/fonts/Serotiva-SemiBold.woff2 +0 -0
- package/tsconfig.json +0 -12
|
@@ -1,2503 +0,0 @@
|
|
|
1
|
-
import { escape } from 'html-escaper';
|
|
2
|
-
import 'piccolore';
|
|
3
|
-
import { clsx } from 'clsx';
|
|
4
|
-
import { decodeBase64, encodeBase64, decodeHex, encodeHexUpperCase } from '@oslojs/encoding';
|
|
5
|
-
import * as z from 'zod/v4';
|
|
6
|
-
|
|
7
|
-
function appendForwardSlash(path) {
|
|
8
|
-
return path.endsWith("/") ? path : path + "/";
|
|
9
|
-
}
|
|
10
|
-
function prependForwardSlash(path) {
|
|
11
|
-
return path[0] === "/" ? path : "/" + path;
|
|
12
|
-
}
|
|
13
|
-
const MANY_LEADING_SLASHES = /^\/{2,}/;
|
|
14
|
-
function collapseDuplicateLeadingSlashes(path) {
|
|
15
|
-
if (!path) {
|
|
16
|
-
return path;
|
|
17
|
-
}
|
|
18
|
-
return path.replace(MANY_LEADING_SLASHES, "/");
|
|
19
|
-
}
|
|
20
|
-
const MANY_SLASHES = /\/{2,}/g;
|
|
21
|
-
function collapseDuplicateSlashes(path) {
|
|
22
|
-
if (!path) {
|
|
23
|
-
return path;
|
|
24
|
-
}
|
|
25
|
-
return path.replace(MANY_SLASHES, "/");
|
|
26
|
-
}
|
|
27
|
-
const MANY_TRAILING_SLASHES = /\/{2,}$/g;
|
|
28
|
-
function collapseDuplicateTrailingSlashes(path, trailingSlash) {
|
|
29
|
-
if (!path) {
|
|
30
|
-
return path;
|
|
31
|
-
}
|
|
32
|
-
return path.replace(MANY_TRAILING_SLASHES, trailingSlash ? "/" : "") || "/";
|
|
33
|
-
}
|
|
34
|
-
function removeTrailingForwardSlash(path) {
|
|
35
|
-
return path.endsWith("/") ? path.slice(0, path.length - 1) : path;
|
|
36
|
-
}
|
|
37
|
-
function removeLeadingForwardSlash(path) {
|
|
38
|
-
return path.startsWith("/") ? path.substring(1) : path;
|
|
39
|
-
}
|
|
40
|
-
function trimSlashes(path) {
|
|
41
|
-
return path.replace(/^\/|\/$/g, "");
|
|
42
|
-
}
|
|
43
|
-
function isString(path) {
|
|
44
|
-
return typeof path === "string" || path instanceof String;
|
|
45
|
-
}
|
|
46
|
-
const INTERNAL_PREFIXES = /* @__PURE__ */ new Set(["/_", "/@", "/.", "//"]);
|
|
47
|
-
const JUST_SLASHES = /^\/{2,}$/;
|
|
48
|
-
function isInternalPath(path) {
|
|
49
|
-
return INTERNAL_PREFIXES.has(path.slice(0, 2)) && !JUST_SLASHES.test(path);
|
|
50
|
-
}
|
|
51
|
-
function joinPaths(...paths) {
|
|
52
|
-
return paths.filter(isString).map((path, i) => {
|
|
53
|
-
if (i === 0) {
|
|
54
|
-
return removeTrailingForwardSlash(path);
|
|
55
|
-
} else if (i === paths.length - 1) {
|
|
56
|
-
return removeLeadingForwardSlash(path);
|
|
57
|
-
} else {
|
|
58
|
-
return trimSlashes(path);
|
|
59
|
-
}
|
|
60
|
-
}).join("/");
|
|
61
|
-
}
|
|
62
|
-
function removeQueryString(path) {
|
|
63
|
-
const index = path.lastIndexOf("?");
|
|
64
|
-
return index > 0 ? path.substring(0, index) : path;
|
|
65
|
-
}
|
|
66
|
-
function isRemotePath(src) {
|
|
67
|
-
if (!src) return false;
|
|
68
|
-
const trimmed = src.trim();
|
|
69
|
-
if (!trimmed) return false;
|
|
70
|
-
let decoded = trimmed;
|
|
71
|
-
let previousDecoded = "";
|
|
72
|
-
let maxIterations = 10;
|
|
73
|
-
while (decoded !== previousDecoded && maxIterations > 0) {
|
|
74
|
-
previousDecoded = decoded;
|
|
75
|
-
try {
|
|
76
|
-
decoded = decodeURIComponent(decoded);
|
|
77
|
-
} catch {
|
|
78
|
-
break;
|
|
79
|
-
}
|
|
80
|
-
maxIterations--;
|
|
81
|
-
}
|
|
82
|
-
if (/^[a-zA-Z]:/.test(decoded)) {
|
|
83
|
-
return false;
|
|
84
|
-
}
|
|
85
|
-
if (decoded[0] === "/" && decoded[1] !== "/" && decoded[1] !== "\\") {
|
|
86
|
-
return false;
|
|
87
|
-
}
|
|
88
|
-
if (decoded[0] === "\\") {
|
|
89
|
-
return true;
|
|
90
|
-
}
|
|
91
|
-
if (decoded.startsWith("//")) {
|
|
92
|
-
return true;
|
|
93
|
-
}
|
|
94
|
-
try {
|
|
95
|
-
const url = new URL(decoded, "http://n");
|
|
96
|
-
if (url.username || url.password) {
|
|
97
|
-
return true;
|
|
98
|
-
}
|
|
99
|
-
if (decoded.includes("@") && !url.pathname.includes("@") && !url.search.includes("@")) {
|
|
100
|
-
return true;
|
|
101
|
-
}
|
|
102
|
-
if (url.origin !== "http://n") {
|
|
103
|
-
const protocol = url.protocol.toLowerCase();
|
|
104
|
-
if (protocol === "file:") {
|
|
105
|
-
return false;
|
|
106
|
-
}
|
|
107
|
-
return true;
|
|
108
|
-
}
|
|
109
|
-
if (URL.canParse(decoded)) {
|
|
110
|
-
return true;
|
|
111
|
-
}
|
|
112
|
-
return false;
|
|
113
|
-
} catch {
|
|
114
|
-
return true;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
function isParentDirectory(parentPath, childPath) {
|
|
118
|
-
if (!parentPath || !childPath) {
|
|
119
|
-
return false;
|
|
120
|
-
}
|
|
121
|
-
if (parentPath.includes("://") || childPath.includes("://")) {
|
|
122
|
-
return false;
|
|
123
|
-
}
|
|
124
|
-
if (isRemotePath(parentPath) || isRemotePath(childPath)) {
|
|
125
|
-
return false;
|
|
126
|
-
}
|
|
127
|
-
if (parentPath.includes("..") || childPath.includes("..")) {
|
|
128
|
-
return false;
|
|
129
|
-
}
|
|
130
|
-
if (parentPath.includes("\0") || childPath.includes("\0")) {
|
|
131
|
-
return false;
|
|
132
|
-
}
|
|
133
|
-
const normalizedParent = appendForwardSlash(slash(parentPath).toLowerCase());
|
|
134
|
-
const normalizedChild = slash(childPath).toLowerCase();
|
|
135
|
-
if (normalizedParent === normalizedChild || normalizedParent === normalizedChild + "/") {
|
|
136
|
-
return false;
|
|
137
|
-
}
|
|
138
|
-
return normalizedChild.startsWith(normalizedParent);
|
|
139
|
-
}
|
|
140
|
-
function slash(path) {
|
|
141
|
-
return path.replace(/\\/g, "/");
|
|
142
|
-
}
|
|
143
|
-
function fileExtension(path) {
|
|
144
|
-
const ext = path.split(".").pop();
|
|
145
|
-
return ext !== path ? `.${ext}` : "";
|
|
146
|
-
}
|
|
147
|
-
const WITH_FILE_EXT = /\/[^/]+\.\w+$/;
|
|
148
|
-
function hasFileExtension(path) {
|
|
149
|
-
return WITH_FILE_EXT.test(path);
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
function normalizeLF(code) {
|
|
153
|
-
return code.replace(/\r\n|\r(?!\n)|\n/g, "\n");
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
function codeFrame(src, loc) {
|
|
157
|
-
if (!loc || loc.line === void 0 || loc.column === void 0) {
|
|
158
|
-
return "";
|
|
159
|
-
}
|
|
160
|
-
const lines = normalizeLF(src).split("\n").map((ln) => ln.replace(/\t/g, " "));
|
|
161
|
-
const visibleLines = [];
|
|
162
|
-
for (let n = -2; n <= 2; n++) {
|
|
163
|
-
if (lines[loc.line + n]) visibleLines.push(loc.line + n);
|
|
164
|
-
}
|
|
165
|
-
let gutterWidth = 0;
|
|
166
|
-
for (const lineNo of visibleLines) {
|
|
167
|
-
let w = `> ${lineNo}`;
|
|
168
|
-
if (w.length > gutterWidth) gutterWidth = w.length;
|
|
169
|
-
}
|
|
170
|
-
let output = "";
|
|
171
|
-
for (const lineNo of visibleLines) {
|
|
172
|
-
const isFocusedLine = lineNo === loc.line - 1;
|
|
173
|
-
output += isFocusedLine ? "> " : " ";
|
|
174
|
-
output += `${lineNo + 1} | ${lines[lineNo]}
|
|
175
|
-
`;
|
|
176
|
-
if (isFocusedLine)
|
|
177
|
-
output += `${Array.from({ length: gutterWidth }).join(" ")} | ${Array.from({
|
|
178
|
-
length: loc.column
|
|
179
|
-
}).join(" ")}^
|
|
180
|
-
`;
|
|
181
|
-
}
|
|
182
|
-
return output;
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
class AstroError extends Error {
|
|
186
|
-
loc;
|
|
187
|
-
title;
|
|
188
|
-
hint;
|
|
189
|
-
frame;
|
|
190
|
-
type = "AstroError";
|
|
191
|
-
constructor(props, options) {
|
|
192
|
-
const { name, title, message, stack, location, hint, frame } = props;
|
|
193
|
-
super(message, options);
|
|
194
|
-
this.title = title;
|
|
195
|
-
this.name = name;
|
|
196
|
-
if (message) this.message = message;
|
|
197
|
-
this.stack = stack ? stack : this.stack;
|
|
198
|
-
this.loc = location;
|
|
199
|
-
this.hint = hint;
|
|
200
|
-
this.frame = frame;
|
|
201
|
-
}
|
|
202
|
-
setLocation(location) {
|
|
203
|
-
this.loc = location;
|
|
204
|
-
}
|
|
205
|
-
setName(name) {
|
|
206
|
-
this.name = name;
|
|
207
|
-
}
|
|
208
|
-
setMessage(message) {
|
|
209
|
-
this.message = message;
|
|
210
|
-
}
|
|
211
|
-
setHint(hint) {
|
|
212
|
-
this.hint = hint;
|
|
213
|
-
}
|
|
214
|
-
setFrame(source, location) {
|
|
215
|
-
this.frame = codeFrame(source, location);
|
|
216
|
-
}
|
|
217
|
-
static is(err) {
|
|
218
|
-
return err?.type === "AstroError";
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
const ClientAddressNotAvailable = {
|
|
223
|
-
name: "ClientAddressNotAvailable",
|
|
224
|
-
title: "`Astro.clientAddress` is not available in current adapter.",
|
|
225
|
-
message: (adapterName) => `\`Astro.clientAddress\` is not available in the \`${adapterName}\` adapter. File an issue with the adapter to add support.`
|
|
226
|
-
};
|
|
227
|
-
const PrerenderClientAddressNotAvailable = {
|
|
228
|
-
name: "PrerenderClientAddressNotAvailable",
|
|
229
|
-
title: "`Astro.clientAddress` cannot be used inside prerendered routes.",
|
|
230
|
-
message: (name) => `\`Astro.clientAddress\` cannot be used inside prerendered route ${name}`
|
|
231
|
-
};
|
|
232
|
-
const StaticClientAddressNotAvailable = {
|
|
233
|
-
name: "StaticClientAddressNotAvailable",
|
|
234
|
-
title: "`Astro.clientAddress` is not available in prerendered pages.",
|
|
235
|
-
message: "`Astro.clientAddress` is only available on pages that are server-rendered.",
|
|
236
|
-
hint: "See https://docs.astro.build/en/guides/on-demand-rendering/ for more information on how to enable SSR."
|
|
237
|
-
};
|
|
238
|
-
const NoMatchingStaticPathFound = {
|
|
239
|
-
name: "NoMatchingStaticPathFound",
|
|
240
|
-
title: "No static path found for requested path.",
|
|
241
|
-
message: (pathName) => `A \`getStaticPaths()\` route pattern was matched, but no matching static path was found for requested path \`${pathName}\`.`,
|
|
242
|
-
hint: (possibleRoutes) => `Possible dynamic routes being matched: ${possibleRoutes.join(", ")}.`
|
|
243
|
-
};
|
|
244
|
-
const OnlyResponseCanBeReturned = {
|
|
245
|
-
name: "OnlyResponseCanBeReturned",
|
|
246
|
-
title: "Invalid type returned by Astro page.",
|
|
247
|
-
message: (route, returnedValue) => `Route \`${route ? route : ""}\` returned a \`${returnedValue}\`. Only a [Response](https://developer.mozilla.org/en-US/docs/Web/API/Response) can be returned from Astro files.`,
|
|
248
|
-
hint: "See https://docs.astro.build/en/guides/on-demand-rendering/#response for more information."
|
|
249
|
-
};
|
|
250
|
-
const MissingMediaQueryDirective = {
|
|
251
|
-
name: "MissingMediaQueryDirective",
|
|
252
|
-
title: "Missing value for `client:media` directive.",
|
|
253
|
-
message: 'Media query not provided for `client:media` directive. A media query similar to `client:media="(max-width: 600px)"` must be provided'
|
|
254
|
-
};
|
|
255
|
-
const NoMatchingRenderer = {
|
|
256
|
-
name: "NoMatchingRenderer",
|
|
257
|
-
title: "No matching renderer found.",
|
|
258
|
-
message: (componentName, componentExtension, plural, validRenderersCount) => `Unable to render \`${componentName}\`.
|
|
259
|
-
|
|
260
|
-
${validRenderersCount > 0 ? `There ${plural ? "are" : "is"} ${validRenderersCount} renderer${plural ? "s" : ""} configured in your \`astro.config.mjs\` file,
|
|
261
|
-
but ${plural ? "none were" : "it was not"} able to server-side render \`${componentName}\`.` : `No valid renderer was found ${componentExtension ? `for the \`.${componentExtension}\` file extension.` : `for this file extension.`}`}`,
|
|
262
|
-
hint: (probableRenderers) => `Did you mean to enable the ${probableRenderers} integration?
|
|
263
|
-
|
|
264
|
-
See https://docs.astro.build/en/guides/framework-components/ for more information on how to install and configure integrations.`
|
|
265
|
-
};
|
|
266
|
-
const NoClientOnlyHint = {
|
|
267
|
-
name: "NoClientOnlyHint",
|
|
268
|
-
title: "Missing hint on client:only directive.",
|
|
269
|
-
message: (componentName) => `Unable to render \`${componentName}\`. When using the \`client:only\` hydration strategy, Astro needs a hint to use the correct renderer.`,
|
|
270
|
-
hint: (probableRenderers) => `Did you mean to pass \`client:only="${probableRenderers}"\`? See https://docs.astro.build/en/reference/directives-reference/#clientonly for more information on client:only`
|
|
271
|
-
};
|
|
272
|
-
const InvalidGetStaticPathsEntry = {
|
|
273
|
-
name: "InvalidGetStaticPathsEntry",
|
|
274
|
-
title: "Invalid entry inside getStaticPath's return value",
|
|
275
|
-
message: (entryType) => `Invalid entry returned by getStaticPaths. Expected an object, got \`${entryType}\``,
|
|
276
|
-
hint: "If you're using a `.map` call, you might be looking for `.flatMap()` instead. See https://docs.astro.build/en/reference/routing-reference/#getstaticpaths for more information on getStaticPaths."
|
|
277
|
-
};
|
|
278
|
-
const InvalidGetStaticPathsReturn = {
|
|
279
|
-
name: "InvalidGetStaticPathsReturn",
|
|
280
|
-
title: "Invalid value returned by getStaticPaths.",
|
|
281
|
-
message: (returnType) => `Invalid type returned by \`getStaticPaths\`. Expected an \`array\`, got \`${returnType}\``,
|
|
282
|
-
hint: "See https://docs.astro.build/en/reference/routing-reference/#getstaticpaths for more information on getStaticPaths."
|
|
283
|
-
};
|
|
284
|
-
const GetStaticPathsExpectedParams = {
|
|
285
|
-
name: "GetStaticPathsExpectedParams",
|
|
286
|
-
title: "Missing params property on `getStaticPaths` route.",
|
|
287
|
-
message: "Missing or empty required `params` property on `getStaticPaths` route.",
|
|
288
|
-
hint: "See https://docs.astro.build/en/reference/routing-reference/#getstaticpaths for more information on getStaticPaths."
|
|
289
|
-
};
|
|
290
|
-
const GetStaticPathsInvalidRouteParam = {
|
|
291
|
-
name: "GetStaticPathsInvalidRouteParam",
|
|
292
|
-
title: "Invalid route parameter returned by `getStaticPaths()`.",
|
|
293
|
-
message: (key, value, valueType) => `Invalid \`getStaticPaths()\` route parameter for \`${key}\`. Expected a string or undefined, received \`${valueType}\` (\`${value}\`)`,
|
|
294
|
-
hint: "See https://docs.astro.build/en/reference/routing-reference/#getstaticpaths for more information on getStaticPaths."
|
|
295
|
-
};
|
|
296
|
-
const GetStaticPathsRequired = {
|
|
297
|
-
name: "GetStaticPathsRequired",
|
|
298
|
-
title: "`getStaticPaths()` function required for dynamic routes.",
|
|
299
|
-
message: "`getStaticPaths()` function is required for dynamic routes. Make sure that you `export` a `getStaticPaths` function from your dynamic route.",
|
|
300
|
-
hint: `See https://docs.astro.build/en/guides/routing/#dynamic-routes for more information on dynamic routes.
|
|
301
|
-
|
|
302
|
-
If you meant for this route to be server-rendered, set \`export const prerender = false;\` in the page.`
|
|
303
|
-
};
|
|
304
|
-
const ReservedSlotName = {
|
|
305
|
-
name: "ReservedSlotName",
|
|
306
|
-
title: "Invalid slot name.",
|
|
307
|
-
message: (slotName) => `Unable to create a slot named \`${slotName}\`. \`${slotName}\` is a reserved slot name. Please update the name of this slot.`
|
|
308
|
-
};
|
|
309
|
-
const NoMatchingImport = {
|
|
310
|
-
name: "NoMatchingImport",
|
|
311
|
-
title: "No import found for component.",
|
|
312
|
-
message: (componentName) => `Could not render \`${componentName}\`. No matching import has been found for \`${componentName}\`.`,
|
|
313
|
-
hint: "Please make sure the component is properly imported."
|
|
314
|
-
};
|
|
315
|
-
const InvalidComponentArgs = {
|
|
316
|
-
name: "InvalidComponentArgs",
|
|
317
|
-
title: "Invalid component arguments.",
|
|
318
|
-
message: (name) => `Invalid arguments passed to${name ? ` <${name}>` : ""} component.`,
|
|
319
|
-
hint: "Astro components cannot be rendered directly via function call, such as `Component()` or `{items.map(Component)}`."
|
|
320
|
-
};
|
|
321
|
-
const PageNumberParamNotFound = {
|
|
322
|
-
name: "PageNumberParamNotFound",
|
|
323
|
-
title: "Page number param not found.",
|
|
324
|
-
message: (paramName) => `[paginate()] page number param \`${paramName}\` not found in your filepath.`,
|
|
325
|
-
hint: "Rename your file to `[page].astro` or `[...page].astro`."
|
|
326
|
-
};
|
|
327
|
-
const ImageMissingAlt = {
|
|
328
|
-
name: "ImageMissingAlt",
|
|
329
|
-
title: 'Image missing required "alt" property.',
|
|
330
|
-
message: 'Image missing "alt" property. "alt" text is required to describe important images on the page.',
|
|
331
|
-
hint: 'Use an empty string ("") for decorative images.'
|
|
332
|
-
};
|
|
333
|
-
const InvalidImageService = {
|
|
334
|
-
name: "InvalidImageService",
|
|
335
|
-
title: "Error while loading image service.",
|
|
336
|
-
message: "There was an error loading the configured image service. Please see the stack trace for more information."
|
|
337
|
-
};
|
|
338
|
-
const MissingImageDimension = {
|
|
339
|
-
name: "MissingImageDimension",
|
|
340
|
-
title: "Missing image dimensions",
|
|
341
|
-
message: (missingDimension, imageURL) => `Missing ${missingDimension === "both" ? "width and height attributes" : `${missingDimension} attribute`} for ${imageURL}. When using remote images, both dimensions are required in order to avoid CLS.`,
|
|
342
|
-
hint: "If your image is inside your `src` folder, you probably meant to import it instead. See [the Imports guide for more information](https://docs.astro.build/en/guides/imports/#other-assets). You can also use `inferSize={true}` for remote images to get the original dimensions."
|
|
343
|
-
};
|
|
344
|
-
const FailedToFetchRemoteImageDimensions = {
|
|
345
|
-
name: "FailedToFetchRemoteImageDimensions",
|
|
346
|
-
title: "Failed to retrieve remote image dimensions",
|
|
347
|
-
message: (imageURL) => `Failed to get the dimensions for ${imageURL}.`,
|
|
348
|
-
hint: "Verify your remote image URL is accurate, and that you are not using `inferSize` with a file located in your `public/` folder."
|
|
349
|
-
};
|
|
350
|
-
const RemoteImageNotAllowed = {
|
|
351
|
-
name: "RemoteImageNotAllowed",
|
|
352
|
-
title: "Remote image is not allowed",
|
|
353
|
-
message: (imageURL) => `Remote image ${imageURL} is not allowed by your image configuration.`,
|
|
354
|
-
hint: "Update `image.domains` or `image.remotePatterns`, or remove `inferSize` for this image."
|
|
355
|
-
};
|
|
356
|
-
const UnsupportedImageFormat = {
|
|
357
|
-
name: "UnsupportedImageFormat",
|
|
358
|
-
title: "Unsupported image format",
|
|
359
|
-
message: (format, imagePath, supportedFormats) => `Received unsupported format \`${format}\` from \`${imagePath}\`. Currently only ${supportedFormats.join(
|
|
360
|
-
", "
|
|
361
|
-
)} are supported by our image services.`,
|
|
362
|
-
hint: "Using an `img` tag directly instead of the `Image` component might be what you're looking for."
|
|
363
|
-
};
|
|
364
|
-
const UnsupportedImageConversion = {
|
|
365
|
-
name: "UnsupportedImageConversion",
|
|
366
|
-
title: "Unsupported image conversion",
|
|
367
|
-
message: "Converting between vector (such as SVGs) and raster (such as PNGs and JPEGs) images is not currently supported."
|
|
368
|
-
};
|
|
369
|
-
const PrerenderDynamicEndpointPathCollide = {
|
|
370
|
-
name: "PrerenderDynamicEndpointPathCollide",
|
|
371
|
-
title: "Prerendered dynamic endpoint has path collision.",
|
|
372
|
-
message: (pathname) => `Could not render \`${pathname}\` with an \`undefined\` param as the generated path will collide during prerendering. Prevent passing \`undefined\` as \`params\` for the endpoint's \`getStaticPaths()\` function, or add an additional extension to the endpoint's filename.`,
|
|
373
|
-
hint: (filename) => `Rename \`${filename}\` to \`${filename.replace(/\.(?:js|ts)/, (m) => `.json` + m)}\``
|
|
374
|
-
};
|
|
375
|
-
const ExpectedImage = {
|
|
376
|
-
name: "ExpectedImage",
|
|
377
|
-
title: "Expected src to be an image.",
|
|
378
|
-
message: (src, typeofOptions, fullOptions) => `Expected \`src\` property for \`getImage\` or \`<Image />\` to be either an ESM imported image or a string with the path of a remote image. Received \`${src}\` (type: \`${typeofOptions}\`).
|
|
379
|
-
|
|
380
|
-
Full serialized options received: \`${fullOptions}\`.`,
|
|
381
|
-
hint: "This error can often happen because of a wrong path. Make sure the path to your image is correct. If you're passing an async function, make sure to call and await it."
|
|
382
|
-
};
|
|
383
|
-
const ExpectedImageOptions = {
|
|
384
|
-
name: "ExpectedImageOptions",
|
|
385
|
-
title: "Expected image options.",
|
|
386
|
-
message: (options) => `Expected getImage() parameter to be an object. Received \`${options}\`.`
|
|
387
|
-
};
|
|
388
|
-
const ExpectedNotESMImage = {
|
|
389
|
-
name: "ExpectedNotESMImage",
|
|
390
|
-
title: "Expected image options, not an ESM-imported image.",
|
|
391
|
-
message: "An ESM-imported image cannot be passed directly to `getImage()`. Instead, pass an object with the image in the `src` property.",
|
|
392
|
-
hint: "Try changing `getImage(myImage)` to `getImage({ src: myImage })`"
|
|
393
|
-
};
|
|
394
|
-
const IncompatibleDescriptorOptions = {
|
|
395
|
-
name: "IncompatibleDescriptorOptions",
|
|
396
|
-
title: "Cannot set both `densities` and `widths`",
|
|
397
|
-
message: "Only one of `densities` or `widths` can be specified. In most cases, you'll probably want to use only `widths` if you require specific widths.",
|
|
398
|
-
hint: "Those attributes are used to construct a `srcset` attribute, which cannot have both `x` and `w` descriptors."
|
|
399
|
-
};
|
|
400
|
-
const NoImageMetadata = {
|
|
401
|
-
name: "NoImageMetadata",
|
|
402
|
-
title: "Could not process image metadata.",
|
|
403
|
-
message: (imagePath) => `Could not process image metadata${imagePath ? ` for \`${imagePath}\`` : ""}.`,
|
|
404
|
-
hint: "This is often caused by a corrupted or malformed image. Re-exporting the image from your image editor may fix this issue."
|
|
405
|
-
};
|
|
406
|
-
const ResponseSentError = {
|
|
407
|
-
name: "ResponseSentError",
|
|
408
|
-
title: "Unable to set response.",
|
|
409
|
-
message: "The response has already been sent to the browser and cannot be altered."
|
|
410
|
-
};
|
|
411
|
-
const MiddlewareNoDataOrNextCalled = {
|
|
412
|
-
name: "MiddlewareNoDataOrNextCalled",
|
|
413
|
-
title: "The middleware didn't return a `Response`.",
|
|
414
|
-
message: "Make sure your middleware returns a `Response` object, either directly or by returning the `Response` from calling the `next` function."
|
|
415
|
-
};
|
|
416
|
-
const MiddlewareNotAResponse = {
|
|
417
|
-
name: "MiddlewareNotAResponse",
|
|
418
|
-
title: "The middleware returned something that is not a `Response` object.",
|
|
419
|
-
message: "Any data returned from middleware must be a valid `Response` object."
|
|
420
|
-
};
|
|
421
|
-
const EndpointDidNotReturnAResponse = {
|
|
422
|
-
name: "EndpointDidNotReturnAResponse",
|
|
423
|
-
title: "The endpoint did not return a `Response`.",
|
|
424
|
-
message: "An endpoint must return either a `Response`, or a `Promise` that resolves with a `Response`."
|
|
425
|
-
};
|
|
426
|
-
const LocalsNotAnObject = {
|
|
427
|
-
name: "LocalsNotAnObject",
|
|
428
|
-
title: "Value assigned to `locals` is not accepted.",
|
|
429
|
-
message: "`locals` can only be assigned to an object. Other values like numbers, strings, etc. are not accepted.",
|
|
430
|
-
hint: "If you tried to remove some information from the `locals` object, try to use `delete` or set the property to `undefined`."
|
|
431
|
-
};
|
|
432
|
-
const LocalsReassigned = {
|
|
433
|
-
name: "LocalsReassigned",
|
|
434
|
-
title: "`locals` must not be reassigned.",
|
|
435
|
-
message: "`locals` cannot be assigned directly.",
|
|
436
|
-
hint: "Set a `locals` property instead."
|
|
437
|
-
};
|
|
438
|
-
const AstroResponseHeadersReassigned = {
|
|
439
|
-
name: "AstroResponseHeadersReassigned",
|
|
440
|
-
title: "`Astro.response.headers` must not be reassigned.",
|
|
441
|
-
message: "Individual headers can be added to and removed from `Astro.response.headers`, but it must not be replaced with another instance of `Headers` altogether.",
|
|
442
|
-
hint: "Consider using `Astro.response.headers.add()`, and `Astro.response.headers.delete()`."
|
|
443
|
-
};
|
|
444
|
-
const LocalImageUsedWrongly = {
|
|
445
|
-
name: "LocalImageUsedWrongly",
|
|
446
|
-
title: "Local images must be imported.",
|
|
447
|
-
message: (imageFilePath) => `\`Image\`'s and \`getImage\`'s \`src\` parameter must be an imported image or an URL, it cannot be a string filepath. Received \`${imageFilePath}\`.`,
|
|
448
|
-
hint: "If you want to use an image from your `src` folder, you need to either import it or if the image is coming from a content collection, use the [image() schema helper](https://docs.astro.build/en/guides/images/#images-in-content-collections). See https://docs.astro.build/en/guides/images/#src-required for more information on the `src` property."
|
|
449
|
-
};
|
|
450
|
-
const MissingSharp = {
|
|
451
|
-
name: "MissingSharp",
|
|
452
|
-
title: "Could not find Sharp.",
|
|
453
|
-
message: "Could not find Sharp. Please install Sharp (`sharp`) manually into your project or migrate to another image service.",
|
|
454
|
-
hint: "See Sharp's installation instructions for more information: https://sharp.pixelplumbing.com/install. If you are not relying on `astro:assets` to optimize, transform, or process any images, you can configure a passthrough image service instead of installing Sharp. See https://docs.astro.build/en/reference/errors/missing-sharp for more information.\n\nSee https://docs.astro.build/en/guides/images/#default-image-service for more information on how to migrate to another image service."
|
|
455
|
-
};
|
|
456
|
-
const i18nNoLocaleFoundInPath = {
|
|
457
|
-
name: "i18nNoLocaleFoundInPath",
|
|
458
|
-
title: "The path doesn't contain any locale",
|
|
459
|
-
message: "You tried to use an i18n utility on a path that doesn't contain any locale. You can use `pathHasLocale` first to determine if the path has a locale."
|
|
460
|
-
};
|
|
461
|
-
const RewriteWithBodyUsed = {
|
|
462
|
-
name: "RewriteWithBodyUsed",
|
|
463
|
-
title: "Cannot use Astro.rewrite after the request body has been read",
|
|
464
|
-
message: "Astro.rewrite() cannot be used if the request body has already been read. If you need to read the body, first clone the request."
|
|
465
|
-
};
|
|
466
|
-
const ForbiddenRewrite = {
|
|
467
|
-
name: "ForbiddenRewrite",
|
|
468
|
-
title: "Forbidden rewrite to a static route.",
|
|
469
|
-
message: (from, to, component) => `You tried to rewrite the on-demand route '${from}' with the static route '${to}', when using the 'server' output.
|
|
470
|
-
|
|
471
|
-
The static route '${to}' is rendered by the component
|
|
472
|
-
'${component}', which is marked as prerendered. This is a forbidden operation because during the build, the component '${component}' is compiled to an
|
|
473
|
-
HTML file, which can't be retrieved at runtime by Astro.`,
|
|
474
|
-
hint: (component) => `Add \`export const prerender = false\` to the component '${component}', or use a Astro.redirect().`
|
|
475
|
-
};
|
|
476
|
-
const FontFamilyNotFound = {
|
|
477
|
-
name: "FontFamilyNotFound",
|
|
478
|
-
title: "Font family not found",
|
|
479
|
-
message: (family) => `No data was found for the \`"${family}"\` family passed to the \`<Font>\` component.`,
|
|
480
|
-
hint: "This is often caused by a typo. Check that the `<Font />` component is using a `cssVariable` specified in your config."
|
|
481
|
-
};
|
|
482
|
-
const ActionsReturnedInvalidDataError = {
|
|
483
|
-
name: "ActionsReturnedInvalidDataError",
|
|
484
|
-
title: "Action handler returned invalid data.",
|
|
485
|
-
message: (error) => `Action handler returned invalid data. Handlers should return serializable data types like objects, arrays, strings, and numbers. Parse error: ${error}`,
|
|
486
|
-
hint: "See the devalue library for all supported types: https://github.com/rich-harris/devalue"
|
|
487
|
-
};
|
|
488
|
-
const ActionNotFoundError = {
|
|
489
|
-
name: "ActionNotFoundError",
|
|
490
|
-
title: "Action not found.",
|
|
491
|
-
message: (actionName) => `The server received a request for an action named \`${actionName}\` but could not find a match. If you renamed an action, check that you've updated your \`actions/index\` file and your calling code to match.`,
|
|
492
|
-
hint: "You can run `astro check` to detect type errors caused by mismatched action names."
|
|
493
|
-
};
|
|
494
|
-
const SessionStorageInitError = {
|
|
495
|
-
name: "SessionStorageInitError",
|
|
496
|
-
title: "Session storage could not be initialized.",
|
|
497
|
-
message: (error, driver) => `Error when initializing session storage${driver ? ` with driver \`${driver}\`` : ""}. \`${error ?? ""}\``,
|
|
498
|
-
hint: "For more information, see https://docs.astro.build/en/guides/sessions/"
|
|
499
|
-
};
|
|
500
|
-
const SessionStorageSaveError = {
|
|
501
|
-
name: "SessionStorageSaveError",
|
|
502
|
-
title: "Session data could not be saved.",
|
|
503
|
-
message: (error, driver) => `Error when saving session data${driver ? ` with driver \`${driver}\`` : ""}. \`${error ?? ""}\``,
|
|
504
|
-
hint: "For more information, see https://docs.astro.build/en/guides/sessions/"
|
|
505
|
-
};
|
|
506
|
-
const CacheNotEnabled = {
|
|
507
|
-
name: "CacheNotEnabled",
|
|
508
|
-
title: "Cache is not enabled.",
|
|
509
|
-
message: "`Astro.cache` is not available because the cache feature is not enabled. To use caching, configure a cache provider in your Astro config under `experimental.cache`.",
|
|
510
|
-
hint: 'Use an adapter that provides a default cache provider, or set one explicitly: `experimental: { cache: { provider: "..." } }`. See https://docs.astro.build/en/reference/experimental-flags/route-caching/.'
|
|
511
|
-
};
|
|
512
|
-
|
|
513
|
-
function shouldAppendForwardSlash(trailingSlash, buildFormat) {
|
|
514
|
-
switch (trailingSlash) {
|
|
515
|
-
case "always":
|
|
516
|
-
return true;
|
|
517
|
-
case "never":
|
|
518
|
-
return false;
|
|
519
|
-
case "ignore": {
|
|
520
|
-
switch (buildFormat) {
|
|
521
|
-
case "directory":
|
|
522
|
-
return true;
|
|
523
|
-
case "preserve":
|
|
524
|
-
case "file":
|
|
525
|
-
return false;
|
|
526
|
-
}
|
|
527
|
-
}
|
|
528
|
-
}
|
|
529
|
-
}
|
|
530
|
-
|
|
531
|
-
const ASTRO_VERSION = "6.1.3";
|
|
532
|
-
const ASTRO_GENERATOR = `Astro v${ASTRO_VERSION}`;
|
|
533
|
-
const REROUTE_DIRECTIVE_HEADER = "X-Astro-Reroute";
|
|
534
|
-
const REWRITE_DIRECTIVE_HEADER_KEY = "X-Astro-Rewrite";
|
|
535
|
-
const REWRITE_DIRECTIVE_HEADER_VALUE = "yes";
|
|
536
|
-
const NOOP_MIDDLEWARE_HEADER = "X-Astro-Noop";
|
|
537
|
-
const ROUTE_TYPE_HEADER = "X-Astro-Route-Type";
|
|
538
|
-
const DEFAULT_404_COMPONENT = "astro-default-404.astro";
|
|
539
|
-
const REDIRECT_STATUS_CODES = [301, 302, 303, 307, 308, 300, 304];
|
|
540
|
-
const REROUTABLE_STATUS_CODES = [404, 500];
|
|
541
|
-
const clientAddressSymbol = /* @__PURE__ */ Symbol.for("astro.clientAddress");
|
|
542
|
-
const originPathnameSymbol = /* @__PURE__ */ Symbol.for("astro.originPathname");
|
|
543
|
-
const pipelineSymbol = /* @__PURE__ */ Symbol.for("astro.pipeline");
|
|
544
|
-
const nodeRequestAbortControllerCleanupSymbol = /* @__PURE__ */ Symbol.for(
|
|
545
|
-
"astro.nodeRequestAbortControllerCleanup"
|
|
546
|
-
);
|
|
547
|
-
const responseSentSymbol = /* @__PURE__ */ Symbol.for("astro.responseSent");
|
|
548
|
-
|
|
549
|
-
function isPromise(value) {
|
|
550
|
-
return !!value && typeof value === "object" && "then" in value && typeof value.then === "function";
|
|
551
|
-
}
|
|
552
|
-
async function* streamAsyncIterator(stream) {
|
|
553
|
-
const reader = stream.getReader();
|
|
554
|
-
try {
|
|
555
|
-
while (true) {
|
|
556
|
-
const { done, value } = await reader.read();
|
|
557
|
-
if (done) return;
|
|
558
|
-
yield value;
|
|
559
|
-
}
|
|
560
|
-
} finally {
|
|
561
|
-
reader.releaseLock();
|
|
562
|
-
}
|
|
563
|
-
}
|
|
564
|
-
|
|
565
|
-
const escapeHTML = escape;
|
|
566
|
-
class HTMLBytes extends Uint8Array {
|
|
567
|
-
}
|
|
568
|
-
Object.defineProperty(HTMLBytes.prototype, Symbol.toStringTag, {
|
|
569
|
-
get() {
|
|
570
|
-
return "HTMLBytes";
|
|
571
|
-
}
|
|
572
|
-
});
|
|
573
|
-
const htmlStringSymbol = /* @__PURE__ */ Symbol.for("astro:html-string");
|
|
574
|
-
class HTMLString extends String {
|
|
575
|
-
[htmlStringSymbol] = true;
|
|
576
|
-
}
|
|
577
|
-
const markHTMLString = (value) => {
|
|
578
|
-
if (isHTMLString(value)) {
|
|
579
|
-
return value;
|
|
580
|
-
}
|
|
581
|
-
if (typeof value === "string") {
|
|
582
|
-
return new HTMLString(value);
|
|
583
|
-
}
|
|
584
|
-
return value;
|
|
585
|
-
};
|
|
586
|
-
function isHTMLString(value) {
|
|
587
|
-
return !!value?.[htmlStringSymbol];
|
|
588
|
-
}
|
|
589
|
-
function markHTMLBytes(bytes) {
|
|
590
|
-
return new HTMLBytes(bytes);
|
|
591
|
-
}
|
|
592
|
-
function hasGetReader(obj) {
|
|
593
|
-
return typeof obj.getReader === "function";
|
|
594
|
-
}
|
|
595
|
-
async function* unescapeChunksAsync(iterable) {
|
|
596
|
-
if (hasGetReader(iterable)) {
|
|
597
|
-
for await (const chunk of streamAsyncIterator(iterable)) {
|
|
598
|
-
yield unescapeHTML(chunk);
|
|
599
|
-
}
|
|
600
|
-
} else {
|
|
601
|
-
for await (const chunk of iterable) {
|
|
602
|
-
yield unescapeHTML(chunk);
|
|
603
|
-
}
|
|
604
|
-
}
|
|
605
|
-
}
|
|
606
|
-
function* unescapeChunks(iterable) {
|
|
607
|
-
for (const chunk of iterable) {
|
|
608
|
-
yield unescapeHTML(chunk);
|
|
609
|
-
}
|
|
610
|
-
}
|
|
611
|
-
function unescapeHTML(str) {
|
|
612
|
-
if (!!str && typeof str === "object") {
|
|
613
|
-
if (str instanceof Uint8Array) {
|
|
614
|
-
return markHTMLBytes(str);
|
|
615
|
-
} else if (str instanceof Response && str.body) {
|
|
616
|
-
const body = str.body;
|
|
617
|
-
return unescapeChunksAsync(body);
|
|
618
|
-
} else if (typeof str.then === "function") {
|
|
619
|
-
return Promise.resolve(str).then((value) => {
|
|
620
|
-
return unescapeHTML(value);
|
|
621
|
-
});
|
|
622
|
-
} else if (str[/* @__PURE__ */ Symbol.for("astro:slot-string")]) {
|
|
623
|
-
return str;
|
|
624
|
-
} else if (Symbol.iterator in str) {
|
|
625
|
-
return unescapeChunks(str);
|
|
626
|
-
} else if (Symbol.asyncIterator in str || hasGetReader(str)) {
|
|
627
|
-
return unescapeChunksAsync(str);
|
|
628
|
-
}
|
|
629
|
-
}
|
|
630
|
-
return markHTMLString(str);
|
|
631
|
-
}
|
|
632
|
-
|
|
633
|
-
function resolvePropagationHint(input) {
|
|
634
|
-
const explicitHint = input.factoryHint ?? "none";
|
|
635
|
-
if (explicitHint !== "none") {
|
|
636
|
-
return explicitHint;
|
|
637
|
-
}
|
|
638
|
-
if (!input.moduleId) {
|
|
639
|
-
return "none";
|
|
640
|
-
}
|
|
641
|
-
return input.metadataLookup(input.moduleId) ?? "none";
|
|
642
|
-
}
|
|
643
|
-
function isPropagatingHint(hint) {
|
|
644
|
-
return hint === "self" || hint === "in-tree";
|
|
645
|
-
}
|
|
646
|
-
function getPropagationHint(result, factory) {
|
|
647
|
-
return resolvePropagationHint({
|
|
648
|
-
factoryHint: factory.propagation,
|
|
649
|
-
moduleId: factory.moduleId,
|
|
650
|
-
metadataLookup: (moduleId) => result.componentMetadata.get(moduleId)?.propagation
|
|
651
|
-
});
|
|
652
|
-
}
|
|
653
|
-
|
|
654
|
-
const headAndContentSym = /* @__PURE__ */ Symbol.for("astro.headAndContent");
|
|
655
|
-
function isHeadAndContent(obj) {
|
|
656
|
-
return typeof obj === "object" && obj !== null && !!obj[headAndContentSym];
|
|
657
|
-
}
|
|
658
|
-
function createThinHead() {
|
|
659
|
-
return {
|
|
660
|
-
[headAndContentSym]: true
|
|
661
|
-
};
|
|
662
|
-
}
|
|
663
|
-
|
|
664
|
-
var astro_island_prebuilt_default = `(()=>{var A=Object.defineProperty;var g=(i,o,a)=>o in i?A(i,o,{enumerable:!0,configurable:!0,writable:!0,value:a}):i[o]=a;var d=(i,o,a)=>g(i,typeof o!="symbol"?o+"":o,a);{let i={0:t=>m(t),1:t=>a(t),2:t=>new RegExp(t),3:t=>new Date(t),4:t=>new Map(a(t)),5:t=>new Set(a(t)),6:t=>BigInt(t),7:t=>new URL(t),8:t=>new Uint8Array(t),9:t=>new Uint16Array(t),10:t=>new Uint32Array(t),11:t=>Number.POSITIVE_INFINITY*t},o=t=>{let[l,e]=t;return l in i?i[l](e):void 0},a=t=>t.map(o),m=t=>typeof t!="object"||t===null?t:Object.fromEntries(Object.entries(t).map(([l,e])=>[l,o(e)]));class y extends HTMLElement{constructor(){super(...arguments);d(this,"Component");d(this,"hydrator");d(this,"hydrate",async()=>{var b;if(!this.hydrator||!this.isConnected)return;let e=(b=this.parentElement)==null?void 0:b.closest("astro-island[ssr]");if(e){e.addEventListener("astro:hydrate",this.hydrate,{once:!0});return}let c=this.querySelectorAll("astro-slot"),n={},h=this.querySelectorAll("template[data-astro-template]");for(let r of h){let s=r.closest(this.tagName);s!=null&&s.isSameNode(this)&&(n[r.getAttribute("data-astro-template")||"default"]=r.innerHTML,r.remove())}for(let r of c){let s=r.closest(this.tagName);s!=null&&s.isSameNode(this)&&(n[r.getAttribute("name")||"default"]=r.innerHTML)}let p;try{p=this.hasAttribute("props")?m(JSON.parse(this.getAttribute("props"))):{}}catch(r){let s=this.getAttribute("component-url")||"<unknown>",v=this.getAttribute("component-export");throw v&&(s+=\` (export \${v})\`),console.error(\`[hydrate] Error parsing props for component \${s}\`,this.getAttribute("props"),r),r}let u;await this.hydrator(this)(this.Component,p,n,{client:this.getAttribute("client")}),this.removeAttribute("ssr"),this.dispatchEvent(new CustomEvent("astro:hydrate"))});d(this,"unmount",()=>{this.isConnected||this.dispatchEvent(new CustomEvent("astro:unmount"))})}disconnectedCallback(){document.removeEventListener("astro:after-swap",this.unmount),document.addEventListener("astro:after-swap",this.unmount,{once:!0})}connectedCallback(){if(!this.hasAttribute("await-children")||document.readyState==="interactive"||document.readyState==="complete")this.childrenConnectedCallback();else{let e=()=>{document.removeEventListener("DOMContentLoaded",e),c.disconnect(),this.childrenConnectedCallback()},c=new MutationObserver(()=>{var n;((n=this.lastChild)==null?void 0:n.nodeType)===Node.COMMENT_NODE&&this.lastChild.nodeValue==="astro:end"&&(this.lastChild.remove(),e())});c.observe(this,{childList:!0}),document.addEventListener("DOMContentLoaded",e)}}async childrenConnectedCallback(){let e=this.getAttribute("before-hydration-url");e&&await import(e),this.start()}async start(){let e=JSON.parse(this.getAttribute("opts")),c=this.getAttribute("client");if(Astro[c]===void 0){window.addEventListener(\`astro:\${c}\`,()=>this.start(),{once:!0});return}try{await Astro[c](async()=>{let n=this.getAttribute("renderer-url"),[h,{default:p}]=await Promise.all([import(this.getAttribute("component-url")),n?import(n):()=>()=>{}]),u=this.getAttribute("component-export")||"default";if(!u.includes("."))this.Component=h[u];else{this.Component=h;for(let f of u.split("."))this.Component=this.Component[f]}return this.hydrator=p,this.hydrate},e,this)}catch(n){console.error(\`[astro-island] Error hydrating \${this.getAttribute("component-url")}\`,n)}}attributeChangedCallback(){this.hydrate()}}d(y,"observedAttributes",["props"]),customElements.get("astro-island")||customElements.define("astro-island",y)}})();`;
|
|
665
|
-
|
|
666
|
-
var astro_island_prebuilt_dev_default = `(()=>{var A=Object.defineProperty;var g=(i,o,a)=>o in i?A(i,o,{enumerable:!0,configurable:!0,writable:!0,value:a}):i[o]=a;var l=(i,o,a)=>g(i,typeof o!="symbol"?o+"":o,a);{let i={0:t=>y(t),1:t=>a(t),2:t=>new RegExp(t),3:t=>new Date(t),4:t=>new Map(a(t)),5:t=>new Set(a(t)),6:t=>BigInt(t),7:t=>new URL(t),8:t=>new Uint8Array(t),9:t=>new Uint16Array(t),10:t=>new Uint32Array(t),11:t=>Number.POSITIVE_INFINITY*t},o=t=>{let[h,e]=t;return h in i?i[h](e):void 0},a=t=>t.map(o),y=t=>typeof t!="object"||t===null?t:Object.fromEntries(Object.entries(t).map(([h,e])=>[h,o(e)]));class f extends HTMLElement{constructor(){super(...arguments);l(this,"Component");l(this,"hydrator");l(this,"hydrate",async()=>{var b;if(!this.hydrator||!this.isConnected)return;let e=(b=this.parentElement)==null?void 0:b.closest("astro-island[ssr]");if(e){e.addEventListener("astro:hydrate",this.hydrate,{once:!0});return}let c=this.querySelectorAll("astro-slot"),n={},p=this.querySelectorAll("template[data-astro-template]");for(let r of p){let s=r.closest(this.tagName);s!=null&&s.isSameNode(this)&&(n[r.getAttribute("data-astro-template")||"default"]=r.innerHTML,r.remove())}for(let r of c){let s=r.closest(this.tagName);s!=null&&s.isSameNode(this)&&(n[r.getAttribute("name")||"default"]=r.innerHTML)}let u;try{u=this.hasAttribute("props")?y(JSON.parse(this.getAttribute("props"))):{}}catch(r){let s=this.getAttribute("component-url")||"<unknown>",v=this.getAttribute("component-export");throw v&&(s+=\` (export \${v})\`),console.error(\`[hydrate] Error parsing props for component \${s}\`,this.getAttribute("props"),r),r}let d,m=this.hydrator(this);d=performance.now(),await m(this.Component,u,n,{client:this.getAttribute("client")}),d&&this.setAttribute("client-render-time",(performance.now()-d).toString()),this.removeAttribute("ssr"),this.dispatchEvent(new CustomEvent("astro:hydrate"))});l(this,"unmount",()=>{this.isConnected||this.dispatchEvent(new CustomEvent("astro:unmount"))})}disconnectedCallback(){document.removeEventListener("astro:after-swap",this.unmount),document.addEventListener("astro:after-swap",this.unmount,{once:!0})}connectedCallback(){if(!this.hasAttribute("await-children")||document.readyState==="interactive"||document.readyState==="complete")this.childrenConnectedCallback();else{let e=()=>{document.removeEventListener("DOMContentLoaded",e),c.disconnect(),this.childrenConnectedCallback()},c=new MutationObserver(()=>{var n;((n=this.lastChild)==null?void 0:n.nodeType)===Node.COMMENT_NODE&&this.lastChild.nodeValue==="astro:end"&&(this.lastChild.remove(),e())});c.observe(this,{childList:!0}),document.addEventListener("DOMContentLoaded",e)}}async childrenConnectedCallback(){let e=this.getAttribute("before-hydration-url");e&&await import(e),this.start()}async start(){let e=JSON.parse(this.getAttribute("opts")),c=this.getAttribute("client");if(Astro[c]===void 0){window.addEventListener(\`astro:\${c}\`,()=>this.start(),{once:!0});return}try{await Astro[c](async()=>{let n=this.getAttribute("renderer-url"),[p,{default:u}]=await Promise.all([import(this.getAttribute("component-url")),n?import(n):()=>()=>{}]),d=this.getAttribute("component-export")||"default";if(!d.includes("."))this.Component=p[d];else{this.Component=p;for(let m of d.split("."))this.Component=this.Component[m]}return this.hydrator=u,this.hydrate},e,this)}catch(n){console.error(\`[astro-island] Error hydrating \${this.getAttribute("component-url")}\`,n)}}attributeChangedCallback(){this.hydrate()}}l(f,"observedAttributes",["props"]),customElements.get("astro-island")||customElements.define("astro-island",f)}})();`;
|
|
667
|
-
|
|
668
|
-
const ISLAND_STYLES = "astro-island,astro-slot,astro-static-slot{display:contents}";
|
|
669
|
-
|
|
670
|
-
function determineIfNeedsHydrationScript(result) {
|
|
671
|
-
if (result._metadata.hasHydrationScript) {
|
|
672
|
-
return false;
|
|
673
|
-
}
|
|
674
|
-
return result._metadata.hasHydrationScript = true;
|
|
675
|
-
}
|
|
676
|
-
function determinesIfNeedsDirectiveScript(result, directive) {
|
|
677
|
-
if (result._metadata.hasDirectives.has(directive)) {
|
|
678
|
-
return false;
|
|
679
|
-
}
|
|
680
|
-
result._metadata.hasDirectives.add(directive);
|
|
681
|
-
return true;
|
|
682
|
-
}
|
|
683
|
-
function getDirectiveScriptText(result, directive) {
|
|
684
|
-
const clientDirectives = result.clientDirectives;
|
|
685
|
-
const clientDirective = clientDirectives.get(directive);
|
|
686
|
-
if (!clientDirective) {
|
|
687
|
-
throw new Error(`Unknown directive: ${directive}`);
|
|
688
|
-
}
|
|
689
|
-
return clientDirective;
|
|
690
|
-
}
|
|
691
|
-
function getPrescripts(result, type, directive) {
|
|
692
|
-
switch (type) {
|
|
693
|
-
case "both":
|
|
694
|
-
return `<style>${ISLAND_STYLES}</style><script>${getDirectiveScriptText(result, directive)}</script><script>${process.env.NODE_ENV === "development" ? astro_island_prebuilt_dev_default : astro_island_prebuilt_default}</script>`;
|
|
695
|
-
case "directive":
|
|
696
|
-
return `<script>${getDirectiveScriptText(result, directive)}</script>`;
|
|
697
|
-
}
|
|
698
|
-
}
|
|
699
|
-
|
|
700
|
-
async function collectPropagatedHeadParts(input) {
|
|
701
|
-
const collectedHeadParts = [];
|
|
702
|
-
const iterator = input.propagators.values();
|
|
703
|
-
while (true) {
|
|
704
|
-
const { value, done } = iterator.next();
|
|
705
|
-
if (done) {
|
|
706
|
-
break;
|
|
707
|
-
}
|
|
708
|
-
const returnValue = await value.init(input.result);
|
|
709
|
-
if (input.isHeadAndContent(returnValue) && returnValue.head) {
|
|
710
|
-
collectedHeadParts.push(returnValue.head);
|
|
711
|
-
}
|
|
712
|
-
}
|
|
713
|
-
return collectedHeadParts;
|
|
714
|
-
}
|
|
715
|
-
|
|
716
|
-
function shouldRenderHeadInstruction(state) {
|
|
717
|
-
return !state.hasRenderedHead && !state.partial;
|
|
718
|
-
}
|
|
719
|
-
function shouldRenderMaybeHeadInstruction(state) {
|
|
720
|
-
return !state.hasRenderedHead && !state.headInTree && !state.partial;
|
|
721
|
-
}
|
|
722
|
-
function shouldRenderInstruction$1(type, state) {
|
|
723
|
-
return type === "head" ? shouldRenderHeadInstruction(state) : shouldRenderMaybeHeadInstruction(state);
|
|
724
|
-
}
|
|
725
|
-
|
|
726
|
-
function registerIfPropagating(result, factory, instance) {
|
|
727
|
-
if (factory.propagation === "self" || factory.propagation === "in-tree") {
|
|
728
|
-
result._metadata.propagators.add(
|
|
729
|
-
instance
|
|
730
|
-
);
|
|
731
|
-
return;
|
|
732
|
-
}
|
|
733
|
-
if (factory.moduleId) {
|
|
734
|
-
const hint = result.componentMetadata.get(factory.moduleId)?.propagation;
|
|
735
|
-
if (isPropagatingHint(hint ?? "none")) {
|
|
736
|
-
result._metadata.propagators.add(
|
|
737
|
-
instance
|
|
738
|
-
);
|
|
739
|
-
}
|
|
740
|
-
}
|
|
741
|
-
}
|
|
742
|
-
async function bufferPropagatedHead(result) {
|
|
743
|
-
const collected = await collectPropagatedHeadParts({
|
|
744
|
-
propagators: result._metadata.propagators,
|
|
745
|
-
result,
|
|
746
|
-
isHeadAndContent
|
|
747
|
-
});
|
|
748
|
-
result._metadata.extraHead.push(...collected);
|
|
749
|
-
}
|
|
750
|
-
function shouldRenderInstruction(type, state) {
|
|
751
|
-
return shouldRenderInstruction$1(type, state);
|
|
752
|
-
}
|
|
753
|
-
function getInstructionRenderState(result) {
|
|
754
|
-
return {
|
|
755
|
-
hasRenderedHead: result._metadata.hasRenderedHead,
|
|
756
|
-
headInTree: result._metadata.headInTree,
|
|
757
|
-
partial: result.partial
|
|
758
|
-
};
|
|
759
|
-
}
|
|
760
|
-
|
|
761
|
-
function renderCspContent(result) {
|
|
762
|
-
const finalScriptHashes = /* @__PURE__ */ new Set();
|
|
763
|
-
const finalStyleHashes = /* @__PURE__ */ new Set();
|
|
764
|
-
for (const scriptHash of result.scriptHashes) {
|
|
765
|
-
finalScriptHashes.add(`'${scriptHash}'`);
|
|
766
|
-
}
|
|
767
|
-
for (const styleHash of result.styleHashes) {
|
|
768
|
-
finalStyleHashes.add(`'${styleHash}'`);
|
|
769
|
-
}
|
|
770
|
-
for (const styleHash of result._metadata.extraStyleHashes) {
|
|
771
|
-
finalStyleHashes.add(`'${styleHash}'`);
|
|
772
|
-
}
|
|
773
|
-
for (const scriptHash of result._metadata.extraScriptHashes) {
|
|
774
|
-
finalScriptHashes.add(`'${scriptHash}'`);
|
|
775
|
-
}
|
|
776
|
-
let directives;
|
|
777
|
-
if (result.directives.length > 0) {
|
|
778
|
-
directives = result.directives.join(";") + ";";
|
|
779
|
-
}
|
|
780
|
-
let scriptResources = "'self'";
|
|
781
|
-
if (result.scriptResources.length > 0) {
|
|
782
|
-
scriptResources = result.scriptResources.map((r) => `${r}`).join(" ");
|
|
783
|
-
}
|
|
784
|
-
let styleResources = "'self'";
|
|
785
|
-
if (result.styleResources.length > 0) {
|
|
786
|
-
styleResources = result.styleResources.map((r) => `${r}`).join(" ");
|
|
787
|
-
}
|
|
788
|
-
const strictDynamic = result.isStrictDynamic ? ` 'strict-dynamic'` : "";
|
|
789
|
-
const scriptSrc = `script-src ${scriptResources} ${Array.from(finalScriptHashes).join(" ")}${strictDynamic};`;
|
|
790
|
-
const styleSrc = `style-src ${styleResources} ${Array.from(finalStyleHashes).join(" ")};`;
|
|
791
|
-
return [directives, scriptSrc, styleSrc].filter(Boolean).join(" ");
|
|
792
|
-
}
|
|
793
|
-
|
|
794
|
-
const RenderInstructionSymbol = /* @__PURE__ */ Symbol.for("astro:render");
|
|
795
|
-
function createRenderInstruction(instruction) {
|
|
796
|
-
return Object.defineProperty(instruction, RenderInstructionSymbol, {
|
|
797
|
-
value: true
|
|
798
|
-
});
|
|
799
|
-
}
|
|
800
|
-
function isRenderInstruction(chunk) {
|
|
801
|
-
return chunk && typeof chunk === "object" && chunk[RenderInstructionSymbol];
|
|
802
|
-
}
|
|
803
|
-
|
|
804
|
-
const voidElementNames = /^(area|base|br|col|command|embed|hr|img|input|keygen|link|meta|param|source|track|wbr)$/i;
|
|
805
|
-
const htmlBooleanAttributes = /^(?:allowfullscreen|async|autofocus|autoplay|checked|controls|default|defer|disabled|disablepictureinpicture|disableremoteplayback|formnovalidate|inert|loop|muted|nomodule|novalidate|open|playsinline|readonly|required|reversed|scoped|seamless|selected|itemscope)$/i;
|
|
806
|
-
const AMPERSAND_REGEX = /&/g;
|
|
807
|
-
const DOUBLE_QUOTE_REGEX = /"/g;
|
|
808
|
-
const STATIC_DIRECTIVES = /* @__PURE__ */ new Set(["set:html", "set:text"]);
|
|
809
|
-
const toIdent = (k) => k.trim().replace(/(?!^)\b\w|\s+|\W+/g, (match, index) => {
|
|
810
|
-
if (/\W/.test(match)) return "";
|
|
811
|
-
return index === 0 ? match : match.toUpperCase();
|
|
812
|
-
});
|
|
813
|
-
const toAttributeString = (value, shouldEscape = true) => shouldEscape ? String(value).replace(AMPERSAND_REGEX, "&").replace(DOUBLE_QUOTE_REGEX, """) : value;
|
|
814
|
-
const kebab = (k) => k.toLowerCase() === k ? k : k.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`);
|
|
815
|
-
const toStyleString = (obj) => Object.entries(obj).filter(([_, v]) => typeof v === "string" && v.trim() || typeof v === "number").map(([k, v]) => {
|
|
816
|
-
if (k[0] !== "-" && k[1] !== "-") return `${kebab(k)}:${v}`;
|
|
817
|
-
return `${k}:${v}`;
|
|
818
|
-
}).join(";");
|
|
819
|
-
function defineScriptVars(vars) {
|
|
820
|
-
let output = "";
|
|
821
|
-
for (const [key, value] of Object.entries(vars)) {
|
|
822
|
-
output += `const ${toIdent(key)} = ${JSON.stringify(value)?.replace(
|
|
823
|
-
/<\/script>/g,
|
|
824
|
-
"\\x3C/script>"
|
|
825
|
-
)};
|
|
826
|
-
`;
|
|
827
|
-
}
|
|
828
|
-
return markHTMLString(output);
|
|
829
|
-
}
|
|
830
|
-
function formatList(values) {
|
|
831
|
-
if (values.length === 1) {
|
|
832
|
-
return values[0];
|
|
833
|
-
}
|
|
834
|
-
return `${values.slice(0, -1).join(", ")} or ${values[values.length - 1]}`;
|
|
835
|
-
}
|
|
836
|
-
function isCustomElement(tagName) {
|
|
837
|
-
return tagName.includes("-");
|
|
838
|
-
}
|
|
839
|
-
function handleBooleanAttribute(key, value, shouldEscape, tagName) {
|
|
840
|
-
if (tagName && isCustomElement(tagName)) {
|
|
841
|
-
return markHTMLString(` ${key}="${toAttributeString(value, shouldEscape)}"`);
|
|
842
|
-
}
|
|
843
|
-
return markHTMLString(value ? ` ${key}` : "");
|
|
844
|
-
}
|
|
845
|
-
function addAttribute(value, key, shouldEscape = true, tagName = "") {
|
|
846
|
-
if (value == null) {
|
|
847
|
-
return "";
|
|
848
|
-
}
|
|
849
|
-
if (STATIC_DIRECTIVES.has(key)) {
|
|
850
|
-
console.warn(`[astro] The "${key}" directive cannot be applied dynamically at runtime. It will not be rendered as an attribute.
|
|
851
|
-
|
|
852
|
-
Make sure to use the static attribute syntax (\`${key}={value}\`) instead of the dynamic spread syntax (\`{...{ "${key}": value }}\`).`);
|
|
853
|
-
return "";
|
|
854
|
-
}
|
|
855
|
-
if (key === "class:list") {
|
|
856
|
-
const listValue = toAttributeString(clsx(value), shouldEscape);
|
|
857
|
-
if (listValue === "") {
|
|
858
|
-
return "";
|
|
859
|
-
}
|
|
860
|
-
return markHTMLString(` ${key.slice(0, -5)}="${listValue}"`);
|
|
861
|
-
}
|
|
862
|
-
if (key === "style" && !(value instanceof HTMLString)) {
|
|
863
|
-
if (Array.isArray(value) && value.length === 2) {
|
|
864
|
-
return markHTMLString(
|
|
865
|
-
` ${key}="${toAttributeString(`${toStyleString(value[0])};${value[1]}`, shouldEscape)}"`
|
|
866
|
-
);
|
|
867
|
-
}
|
|
868
|
-
if (typeof value === "object") {
|
|
869
|
-
return markHTMLString(` ${key}="${toAttributeString(toStyleString(value), shouldEscape)}"`);
|
|
870
|
-
}
|
|
871
|
-
}
|
|
872
|
-
if (key === "className") {
|
|
873
|
-
return markHTMLString(` class="${toAttributeString(value, shouldEscape)}"`);
|
|
874
|
-
}
|
|
875
|
-
if (htmlBooleanAttributes.test(key)) {
|
|
876
|
-
return handleBooleanAttribute(key, value, shouldEscape, tagName);
|
|
877
|
-
}
|
|
878
|
-
if (value === "") {
|
|
879
|
-
return markHTMLString(` ${key}`);
|
|
880
|
-
}
|
|
881
|
-
if (key === "popover" && typeof value === "boolean") {
|
|
882
|
-
return handleBooleanAttribute(key, value, shouldEscape, tagName);
|
|
883
|
-
}
|
|
884
|
-
if (key === "download" && typeof value === "boolean") {
|
|
885
|
-
return handleBooleanAttribute(key, value, shouldEscape, tagName);
|
|
886
|
-
}
|
|
887
|
-
if (key === "hidden" && typeof value === "boolean") {
|
|
888
|
-
return handleBooleanAttribute(key, value, shouldEscape, tagName);
|
|
889
|
-
}
|
|
890
|
-
return markHTMLString(` ${key}="${toAttributeString(value, shouldEscape)}"`);
|
|
891
|
-
}
|
|
892
|
-
function internalSpreadAttributes(values, shouldEscape = true, tagName) {
|
|
893
|
-
let output = "";
|
|
894
|
-
for (const [key, value] of Object.entries(values)) {
|
|
895
|
-
output += addAttribute(value, key, shouldEscape, tagName);
|
|
896
|
-
}
|
|
897
|
-
return markHTMLString(output);
|
|
898
|
-
}
|
|
899
|
-
function renderElement(name, { props: _props, children = "" }, shouldEscape = true) {
|
|
900
|
-
const { lang: _, "data-astro-id": astroId, "define:vars": defineVars, ...props } = _props;
|
|
901
|
-
if (defineVars) {
|
|
902
|
-
if (name === "style") {
|
|
903
|
-
delete props["is:global"];
|
|
904
|
-
delete props["is:scoped"];
|
|
905
|
-
}
|
|
906
|
-
if (name === "script") {
|
|
907
|
-
delete props.hoist;
|
|
908
|
-
children = defineScriptVars(defineVars) + "\n" + children;
|
|
909
|
-
}
|
|
910
|
-
}
|
|
911
|
-
if ((children == null || children === "") && voidElementNames.test(name)) {
|
|
912
|
-
return `<${name}${internalSpreadAttributes(props, shouldEscape, name)}>`;
|
|
913
|
-
}
|
|
914
|
-
return `<${name}${internalSpreadAttributes(props, shouldEscape, name)}>${children}</${name}>`;
|
|
915
|
-
}
|
|
916
|
-
const noop = () => {
|
|
917
|
-
};
|
|
918
|
-
class BufferedRenderer {
|
|
919
|
-
chunks = [];
|
|
920
|
-
renderPromise;
|
|
921
|
-
destination;
|
|
922
|
-
/**
|
|
923
|
-
* Determines whether buffer has been flushed
|
|
924
|
-
* to the final destination.
|
|
925
|
-
*/
|
|
926
|
-
flushed = false;
|
|
927
|
-
constructor(destination, renderFunction) {
|
|
928
|
-
this.destination = destination;
|
|
929
|
-
this.renderPromise = renderFunction(this);
|
|
930
|
-
if (isPromise(this.renderPromise)) {
|
|
931
|
-
Promise.resolve(this.renderPromise).catch(noop);
|
|
932
|
-
}
|
|
933
|
-
}
|
|
934
|
-
write(chunk) {
|
|
935
|
-
if (this.flushed) {
|
|
936
|
-
this.destination.write(chunk);
|
|
937
|
-
} else {
|
|
938
|
-
this.chunks.push(chunk);
|
|
939
|
-
}
|
|
940
|
-
}
|
|
941
|
-
flush() {
|
|
942
|
-
if (this.flushed) {
|
|
943
|
-
throw new Error("The render buffer has already been flushed.");
|
|
944
|
-
}
|
|
945
|
-
this.flushed = true;
|
|
946
|
-
for (const chunk of this.chunks) {
|
|
947
|
-
this.destination.write(chunk);
|
|
948
|
-
}
|
|
949
|
-
return this.renderPromise;
|
|
950
|
-
}
|
|
951
|
-
}
|
|
952
|
-
function createBufferedRenderer(destination, renderFunction) {
|
|
953
|
-
return new BufferedRenderer(destination, renderFunction);
|
|
954
|
-
}
|
|
955
|
-
const isNode = typeof process !== "undefined" && Object.prototype.toString.call(process) === "[object process]";
|
|
956
|
-
const isDeno = typeof Deno !== "undefined";
|
|
957
|
-
function promiseWithResolvers() {
|
|
958
|
-
let resolve, reject;
|
|
959
|
-
const promise = new Promise((_resolve, _reject) => {
|
|
960
|
-
resolve = _resolve;
|
|
961
|
-
reject = _reject;
|
|
962
|
-
});
|
|
963
|
-
return {
|
|
964
|
-
promise,
|
|
965
|
-
resolve,
|
|
966
|
-
reject
|
|
967
|
-
};
|
|
968
|
-
}
|
|
969
|
-
|
|
970
|
-
function stablePropsKey(props) {
|
|
971
|
-
const keys = Object.keys(props).sort();
|
|
972
|
-
let result = "{";
|
|
973
|
-
for (let i = 0; i < keys.length; i++) {
|
|
974
|
-
if (i > 0) result += ",";
|
|
975
|
-
result += JSON.stringify(keys[i]) + ":" + JSON.stringify(props[keys[i]]);
|
|
976
|
-
}
|
|
977
|
-
result += "}";
|
|
978
|
-
return result;
|
|
979
|
-
}
|
|
980
|
-
function deduplicateElements(elements) {
|
|
981
|
-
if (elements.length <= 1) return elements;
|
|
982
|
-
const seen = /* @__PURE__ */ new Set();
|
|
983
|
-
return elements.filter((item) => {
|
|
984
|
-
const key = stablePropsKey(item.props) + item.children;
|
|
985
|
-
if (seen.has(key)) return false;
|
|
986
|
-
seen.add(key);
|
|
987
|
-
return true;
|
|
988
|
-
});
|
|
989
|
-
}
|
|
990
|
-
function renderAllHeadContent(result) {
|
|
991
|
-
result._metadata.hasRenderedHead = true;
|
|
992
|
-
let content = "";
|
|
993
|
-
if (result.shouldInjectCspMetaTags && result.cspDestination === "meta") {
|
|
994
|
-
content += renderElement(
|
|
995
|
-
"meta",
|
|
996
|
-
{
|
|
997
|
-
props: {
|
|
998
|
-
"http-equiv": "content-security-policy",
|
|
999
|
-
content: renderCspContent(result)
|
|
1000
|
-
},
|
|
1001
|
-
children: ""
|
|
1002
|
-
},
|
|
1003
|
-
false
|
|
1004
|
-
);
|
|
1005
|
-
}
|
|
1006
|
-
const styles = deduplicateElements(Array.from(result.styles)).map(
|
|
1007
|
-
(style) => style.props.rel === "stylesheet" ? renderElement("link", style) : renderElement("style", style)
|
|
1008
|
-
);
|
|
1009
|
-
result.styles.clear();
|
|
1010
|
-
const scripts = deduplicateElements(Array.from(result.scripts)).map((script) => {
|
|
1011
|
-
if (result.userAssetsBase) {
|
|
1012
|
-
script.props.src = (result.base === "/" ? "" : result.base) + result.userAssetsBase + script.props.src;
|
|
1013
|
-
}
|
|
1014
|
-
return renderElement("script", script, false);
|
|
1015
|
-
});
|
|
1016
|
-
const links = deduplicateElements(Array.from(result.links)).map(
|
|
1017
|
-
(link) => renderElement("link", link, false)
|
|
1018
|
-
);
|
|
1019
|
-
content += styles.join("\n") + links.join("\n") + scripts.join("\n");
|
|
1020
|
-
if (result._metadata.extraHead.length > 0) {
|
|
1021
|
-
for (const part of result._metadata.extraHead) {
|
|
1022
|
-
content += part;
|
|
1023
|
-
}
|
|
1024
|
-
}
|
|
1025
|
-
return markHTMLString(content);
|
|
1026
|
-
}
|
|
1027
|
-
function renderHead() {
|
|
1028
|
-
return createRenderInstruction({ type: "head" });
|
|
1029
|
-
}
|
|
1030
|
-
function maybeRenderHead() {
|
|
1031
|
-
return createRenderInstruction({ type: "maybe-head" });
|
|
1032
|
-
}
|
|
1033
|
-
|
|
1034
|
-
const ALGORITHMS = {
|
|
1035
|
-
"SHA-256": "sha256-",
|
|
1036
|
-
"SHA-384": "sha384-",
|
|
1037
|
-
"SHA-512": "sha512-"
|
|
1038
|
-
};
|
|
1039
|
-
const ALGORITHM_VALUES = Object.values(ALGORITHMS);
|
|
1040
|
-
z.enum(Object.keys(ALGORITHMS)).optional().default("SHA-256");
|
|
1041
|
-
z.custom((value) => {
|
|
1042
|
-
if (typeof value !== "string") {
|
|
1043
|
-
return false;
|
|
1044
|
-
}
|
|
1045
|
-
return ALGORITHM_VALUES.some((allowedValue) => {
|
|
1046
|
-
return value.startsWith(allowedValue);
|
|
1047
|
-
});
|
|
1048
|
-
});
|
|
1049
|
-
const ALLOWED_DIRECTIVES = [
|
|
1050
|
-
"base-uri",
|
|
1051
|
-
"child-src",
|
|
1052
|
-
"connect-src",
|
|
1053
|
-
"default-src",
|
|
1054
|
-
"fenced-frame-src",
|
|
1055
|
-
"font-src",
|
|
1056
|
-
"form-action",
|
|
1057
|
-
"frame-ancestors",
|
|
1058
|
-
"frame-src",
|
|
1059
|
-
"img-src",
|
|
1060
|
-
"manifest-src",
|
|
1061
|
-
"media-src",
|
|
1062
|
-
"object-src",
|
|
1063
|
-
"referrer",
|
|
1064
|
-
"report-to",
|
|
1065
|
-
"report-uri",
|
|
1066
|
-
"require-trusted-types-for",
|
|
1067
|
-
"sandbox",
|
|
1068
|
-
"trusted-types",
|
|
1069
|
-
"upgrade-insecure-requests",
|
|
1070
|
-
"worker-src"
|
|
1071
|
-
];
|
|
1072
|
-
z.custom((value) => {
|
|
1073
|
-
if (typeof value !== "string") {
|
|
1074
|
-
return false;
|
|
1075
|
-
}
|
|
1076
|
-
return ALLOWED_DIRECTIVES.some((allowedValue) => {
|
|
1077
|
-
return value.startsWith(allowedValue);
|
|
1078
|
-
});
|
|
1079
|
-
});
|
|
1080
|
-
|
|
1081
|
-
const ALGORITHM = "AES-GCM";
|
|
1082
|
-
async function decodeKey(encoded) {
|
|
1083
|
-
const bytes = decodeBase64(encoded);
|
|
1084
|
-
return crypto.subtle.importKey("raw", bytes.buffer, ALGORITHM, true, [
|
|
1085
|
-
"encrypt",
|
|
1086
|
-
"decrypt"
|
|
1087
|
-
]);
|
|
1088
|
-
}
|
|
1089
|
-
const encoder$1 = new TextEncoder();
|
|
1090
|
-
const decoder$1 = new TextDecoder();
|
|
1091
|
-
const IV_LENGTH = 24;
|
|
1092
|
-
async function encryptString(key, raw) {
|
|
1093
|
-
const iv = crypto.getRandomValues(new Uint8Array(IV_LENGTH / 2));
|
|
1094
|
-
const data = encoder$1.encode(raw);
|
|
1095
|
-
const buffer = await crypto.subtle.encrypt(
|
|
1096
|
-
{
|
|
1097
|
-
name: ALGORITHM,
|
|
1098
|
-
iv
|
|
1099
|
-
},
|
|
1100
|
-
key,
|
|
1101
|
-
data
|
|
1102
|
-
);
|
|
1103
|
-
return encodeHexUpperCase(iv) + encodeBase64(new Uint8Array(buffer));
|
|
1104
|
-
}
|
|
1105
|
-
async function decryptString(key, encoded) {
|
|
1106
|
-
const iv = decodeHex(encoded.slice(0, IV_LENGTH));
|
|
1107
|
-
const dataArray = decodeBase64(encoded.slice(IV_LENGTH));
|
|
1108
|
-
const decryptedBuffer = await crypto.subtle.decrypt(
|
|
1109
|
-
{
|
|
1110
|
-
name: ALGORITHM,
|
|
1111
|
-
iv
|
|
1112
|
-
},
|
|
1113
|
-
key,
|
|
1114
|
-
dataArray
|
|
1115
|
-
);
|
|
1116
|
-
const decryptedString = decoder$1.decode(decryptedBuffer);
|
|
1117
|
-
return decryptedString;
|
|
1118
|
-
}
|
|
1119
|
-
async function generateCspDigest(data, algorithm) {
|
|
1120
|
-
const hashBuffer = await crypto.subtle.digest(algorithm, encoder$1.encode(data));
|
|
1121
|
-
const hash = encodeBase64(new Uint8Array(hashBuffer));
|
|
1122
|
-
return `${ALGORITHMS[algorithm]}${hash}`;
|
|
1123
|
-
}
|
|
1124
|
-
|
|
1125
|
-
const renderTemplateResultSym = /* @__PURE__ */ Symbol.for("astro.renderTemplateResult");
|
|
1126
|
-
class RenderTemplateResult {
|
|
1127
|
-
[renderTemplateResultSym] = true;
|
|
1128
|
-
htmlParts;
|
|
1129
|
-
expressions;
|
|
1130
|
-
error;
|
|
1131
|
-
constructor(htmlParts, expressions) {
|
|
1132
|
-
this.htmlParts = htmlParts;
|
|
1133
|
-
this.error = void 0;
|
|
1134
|
-
this.expressions = expressions.map((expression) => {
|
|
1135
|
-
if (isPromise(expression)) {
|
|
1136
|
-
return Promise.resolve(expression).catch((err) => {
|
|
1137
|
-
if (!this.error) {
|
|
1138
|
-
this.error = err;
|
|
1139
|
-
throw err;
|
|
1140
|
-
}
|
|
1141
|
-
});
|
|
1142
|
-
}
|
|
1143
|
-
return expression;
|
|
1144
|
-
});
|
|
1145
|
-
}
|
|
1146
|
-
render(destination) {
|
|
1147
|
-
const { htmlParts, expressions } = this;
|
|
1148
|
-
for (let i = 0; i < htmlParts.length; i++) {
|
|
1149
|
-
const html = htmlParts[i];
|
|
1150
|
-
if (html) {
|
|
1151
|
-
destination.write(markHTMLString(html));
|
|
1152
|
-
}
|
|
1153
|
-
if (i >= expressions.length) break;
|
|
1154
|
-
const exp = expressions[i];
|
|
1155
|
-
if (!(exp || exp === 0)) continue;
|
|
1156
|
-
const result = renderChild(destination, exp);
|
|
1157
|
-
if (isPromise(result)) {
|
|
1158
|
-
const startIdx = i + 1;
|
|
1159
|
-
const remaining = expressions.length - startIdx;
|
|
1160
|
-
const flushers = new Array(remaining);
|
|
1161
|
-
for (let j = 0; j < remaining; j++) {
|
|
1162
|
-
const rExp = expressions[startIdx + j];
|
|
1163
|
-
flushers[j] = createBufferedRenderer(destination, (bufferDestination) => {
|
|
1164
|
-
if (rExp || rExp === 0) {
|
|
1165
|
-
return renderChild(bufferDestination, rExp);
|
|
1166
|
-
}
|
|
1167
|
-
});
|
|
1168
|
-
}
|
|
1169
|
-
return result.then(() => {
|
|
1170
|
-
let k = 0;
|
|
1171
|
-
const iterate = () => {
|
|
1172
|
-
while (k < flushers.length) {
|
|
1173
|
-
const rHtml = htmlParts[startIdx + k];
|
|
1174
|
-
if (rHtml) {
|
|
1175
|
-
destination.write(markHTMLString(rHtml));
|
|
1176
|
-
}
|
|
1177
|
-
const flushResult = flushers[k++].flush();
|
|
1178
|
-
if (isPromise(flushResult)) {
|
|
1179
|
-
return flushResult.then(iterate);
|
|
1180
|
-
}
|
|
1181
|
-
}
|
|
1182
|
-
const lastHtml = htmlParts[htmlParts.length - 1];
|
|
1183
|
-
if (lastHtml) {
|
|
1184
|
-
destination.write(markHTMLString(lastHtml));
|
|
1185
|
-
}
|
|
1186
|
-
};
|
|
1187
|
-
return iterate();
|
|
1188
|
-
});
|
|
1189
|
-
}
|
|
1190
|
-
}
|
|
1191
|
-
}
|
|
1192
|
-
}
|
|
1193
|
-
function isRenderTemplateResult(obj) {
|
|
1194
|
-
return typeof obj === "object" && obj !== null && !!obj[renderTemplateResultSym];
|
|
1195
|
-
}
|
|
1196
|
-
function renderTemplate(htmlParts, ...expressions) {
|
|
1197
|
-
return new RenderTemplateResult(htmlParts, expressions);
|
|
1198
|
-
}
|
|
1199
|
-
|
|
1200
|
-
const slotString = /* @__PURE__ */ Symbol.for("astro:slot-string");
|
|
1201
|
-
class SlotString extends HTMLString {
|
|
1202
|
-
instructions;
|
|
1203
|
-
[slotString];
|
|
1204
|
-
constructor(content, instructions) {
|
|
1205
|
-
super(content);
|
|
1206
|
-
this.instructions = instructions;
|
|
1207
|
-
this[slotString] = true;
|
|
1208
|
-
}
|
|
1209
|
-
}
|
|
1210
|
-
function isSlotString(str) {
|
|
1211
|
-
return !!str[slotString];
|
|
1212
|
-
}
|
|
1213
|
-
function mergeSlotInstructions(target, source) {
|
|
1214
|
-
if (source.instructions?.length) {
|
|
1215
|
-
target ??= [];
|
|
1216
|
-
target.push(...source.instructions);
|
|
1217
|
-
}
|
|
1218
|
-
return target;
|
|
1219
|
-
}
|
|
1220
|
-
function renderSlot(result, slotted, fallback) {
|
|
1221
|
-
if (!slotted && fallback) {
|
|
1222
|
-
return renderSlot(result, fallback);
|
|
1223
|
-
}
|
|
1224
|
-
return {
|
|
1225
|
-
async render(destination) {
|
|
1226
|
-
await renderChild(destination, typeof slotted === "function" ? slotted(result) : slotted);
|
|
1227
|
-
}
|
|
1228
|
-
};
|
|
1229
|
-
}
|
|
1230
|
-
async function renderSlotToString(result, slotted, fallback) {
|
|
1231
|
-
let content = "";
|
|
1232
|
-
let instructions = null;
|
|
1233
|
-
const temporaryDestination = {
|
|
1234
|
-
write(chunk) {
|
|
1235
|
-
if (chunk instanceof SlotString) {
|
|
1236
|
-
content += chunk;
|
|
1237
|
-
instructions = mergeSlotInstructions(instructions, chunk);
|
|
1238
|
-
} else if (chunk instanceof Response) return;
|
|
1239
|
-
else if (typeof chunk === "object" && "type" in chunk && typeof chunk.type === "string") {
|
|
1240
|
-
if (instructions === null) {
|
|
1241
|
-
instructions = [];
|
|
1242
|
-
}
|
|
1243
|
-
instructions.push(chunk);
|
|
1244
|
-
} else {
|
|
1245
|
-
content += chunkToString(result, chunk);
|
|
1246
|
-
}
|
|
1247
|
-
}
|
|
1248
|
-
};
|
|
1249
|
-
const renderInstance = renderSlot(result, slotted, fallback);
|
|
1250
|
-
await renderInstance.render(temporaryDestination);
|
|
1251
|
-
return markHTMLString(new SlotString(content, instructions));
|
|
1252
|
-
}
|
|
1253
|
-
async function renderSlots(result, slots = {}) {
|
|
1254
|
-
let slotInstructions = null;
|
|
1255
|
-
let children = {};
|
|
1256
|
-
if (slots) {
|
|
1257
|
-
await Promise.all(
|
|
1258
|
-
Object.entries(slots).map(
|
|
1259
|
-
([key, value]) => renderSlotToString(result, value).then((output) => {
|
|
1260
|
-
if (output.instructions) {
|
|
1261
|
-
if (slotInstructions === null) {
|
|
1262
|
-
slotInstructions = [];
|
|
1263
|
-
}
|
|
1264
|
-
slotInstructions.push(...output.instructions);
|
|
1265
|
-
}
|
|
1266
|
-
children[key] = output;
|
|
1267
|
-
})
|
|
1268
|
-
)
|
|
1269
|
-
);
|
|
1270
|
-
}
|
|
1271
|
-
return { slotInstructions, children };
|
|
1272
|
-
}
|
|
1273
|
-
function createSlotValueFromString(content) {
|
|
1274
|
-
return function() {
|
|
1275
|
-
return renderTemplate`${unescapeHTML(content)}`;
|
|
1276
|
-
};
|
|
1277
|
-
}
|
|
1278
|
-
|
|
1279
|
-
const internalProps = /* @__PURE__ */ new Set([
|
|
1280
|
-
"server:component-path",
|
|
1281
|
-
"server:component-export",
|
|
1282
|
-
"server:component-directive",
|
|
1283
|
-
"server:defer"
|
|
1284
|
-
]);
|
|
1285
|
-
function containsServerDirective(props) {
|
|
1286
|
-
return "server:component-directive" in props;
|
|
1287
|
-
}
|
|
1288
|
-
const SCRIPT_RE = /<\/script/giu;
|
|
1289
|
-
const COMMENT_RE = /<!--/gu;
|
|
1290
|
-
const SCRIPT_REPLACER = "<\\/script";
|
|
1291
|
-
const COMMENT_REPLACER = "\\u003C!--";
|
|
1292
|
-
function safeJsonStringify(obj) {
|
|
1293
|
-
return JSON.stringify(obj).replace(SCRIPT_RE, SCRIPT_REPLACER).replace(COMMENT_RE, COMMENT_REPLACER);
|
|
1294
|
-
}
|
|
1295
|
-
function createSearchParams(encryptedComponentExport, encryptedProps, slots) {
|
|
1296
|
-
const params = new URLSearchParams();
|
|
1297
|
-
params.set("e", encryptedComponentExport);
|
|
1298
|
-
params.set("p", encryptedProps);
|
|
1299
|
-
params.set("s", slots);
|
|
1300
|
-
return params;
|
|
1301
|
-
}
|
|
1302
|
-
function isWithinURLLimit(pathname, params) {
|
|
1303
|
-
const url = pathname + "?" + params.toString();
|
|
1304
|
-
const chars = url.length;
|
|
1305
|
-
return chars < 2048;
|
|
1306
|
-
}
|
|
1307
|
-
class ServerIslandComponent {
|
|
1308
|
-
result;
|
|
1309
|
-
props;
|
|
1310
|
-
slots;
|
|
1311
|
-
displayName;
|
|
1312
|
-
hostId;
|
|
1313
|
-
islandContent;
|
|
1314
|
-
componentPath;
|
|
1315
|
-
componentExport;
|
|
1316
|
-
componentId;
|
|
1317
|
-
constructor(result, props, slots, displayName) {
|
|
1318
|
-
this.result = result;
|
|
1319
|
-
this.props = props;
|
|
1320
|
-
this.slots = slots;
|
|
1321
|
-
this.displayName = displayName;
|
|
1322
|
-
}
|
|
1323
|
-
async init() {
|
|
1324
|
-
const content = await this.getIslandContent();
|
|
1325
|
-
if (this.result.cspDestination) {
|
|
1326
|
-
this.result._metadata.extraScriptHashes.push(
|
|
1327
|
-
await generateCspDigest(SERVER_ISLAND_REPLACER, this.result.cspAlgorithm)
|
|
1328
|
-
);
|
|
1329
|
-
const contentDigest = await generateCspDigest(content, this.result.cspAlgorithm);
|
|
1330
|
-
this.result._metadata.extraScriptHashes.push(contentDigest);
|
|
1331
|
-
}
|
|
1332
|
-
return createThinHead();
|
|
1333
|
-
}
|
|
1334
|
-
async render(destination) {
|
|
1335
|
-
const hostId = await this.getHostId();
|
|
1336
|
-
const islandContent = await this.getIslandContent();
|
|
1337
|
-
destination.write(createRenderInstruction({ type: "server-island-runtime" }));
|
|
1338
|
-
destination.write("<!--[if astro]>server-island-start<![endif]-->");
|
|
1339
|
-
for (const name in this.slots) {
|
|
1340
|
-
if (name === "fallback") {
|
|
1341
|
-
await renderChild(destination, this.slots.fallback(this.result));
|
|
1342
|
-
}
|
|
1343
|
-
}
|
|
1344
|
-
destination.write(
|
|
1345
|
-
`<script type="module" data-astro-rerun data-island-id="${hostId}">${islandContent}</script>`
|
|
1346
|
-
);
|
|
1347
|
-
}
|
|
1348
|
-
getComponentPath() {
|
|
1349
|
-
if (this.componentPath) {
|
|
1350
|
-
return this.componentPath;
|
|
1351
|
-
}
|
|
1352
|
-
const componentPath = this.props["server:component-path"];
|
|
1353
|
-
if (!componentPath) {
|
|
1354
|
-
throw new Error(`Could not find server component path`);
|
|
1355
|
-
}
|
|
1356
|
-
this.componentPath = componentPath;
|
|
1357
|
-
return componentPath;
|
|
1358
|
-
}
|
|
1359
|
-
getComponentExport() {
|
|
1360
|
-
if (this.componentExport) {
|
|
1361
|
-
return this.componentExport;
|
|
1362
|
-
}
|
|
1363
|
-
const componentExport = this.props["server:component-export"];
|
|
1364
|
-
if (!componentExport) {
|
|
1365
|
-
throw new Error(`Could not find server component export`);
|
|
1366
|
-
}
|
|
1367
|
-
this.componentExport = componentExport;
|
|
1368
|
-
return componentExport;
|
|
1369
|
-
}
|
|
1370
|
-
async getHostId() {
|
|
1371
|
-
if (!this.hostId) {
|
|
1372
|
-
this.hostId = await crypto.randomUUID();
|
|
1373
|
-
}
|
|
1374
|
-
return this.hostId;
|
|
1375
|
-
}
|
|
1376
|
-
async getIslandContent() {
|
|
1377
|
-
if (this.islandContent) {
|
|
1378
|
-
return this.islandContent;
|
|
1379
|
-
}
|
|
1380
|
-
const componentPath = this.getComponentPath();
|
|
1381
|
-
const componentExport = this.getComponentExport();
|
|
1382
|
-
let componentId = this.result.serverIslandNameMap.get(componentPath);
|
|
1383
|
-
if (!componentId) {
|
|
1384
|
-
throw new Error(`Could not find server component name ${componentPath}`);
|
|
1385
|
-
}
|
|
1386
|
-
for (const key2 of Object.keys(this.props)) {
|
|
1387
|
-
if (internalProps.has(key2)) {
|
|
1388
|
-
delete this.props[key2];
|
|
1389
|
-
}
|
|
1390
|
-
}
|
|
1391
|
-
const renderedSlots = {};
|
|
1392
|
-
for (const name in this.slots) {
|
|
1393
|
-
if (name !== "fallback") {
|
|
1394
|
-
const content = await renderSlotToString(this.result, this.slots[name]);
|
|
1395
|
-
let slotHtml = content.toString();
|
|
1396
|
-
const slotContent = content;
|
|
1397
|
-
if (Array.isArray(slotContent.instructions)) {
|
|
1398
|
-
for (const instruction of slotContent.instructions) {
|
|
1399
|
-
if (instruction.type === "script") {
|
|
1400
|
-
slotHtml += instruction.content;
|
|
1401
|
-
}
|
|
1402
|
-
}
|
|
1403
|
-
}
|
|
1404
|
-
renderedSlots[name] = slotHtml;
|
|
1405
|
-
}
|
|
1406
|
-
}
|
|
1407
|
-
const key = await this.result.key;
|
|
1408
|
-
const componentExportEncrypted = await encryptString(key, componentExport);
|
|
1409
|
-
const propsEncrypted = Object.keys(this.props).length === 0 ? "" : await encryptString(key, JSON.stringify(this.props));
|
|
1410
|
-
const slotsEncrypted = Object.keys(renderedSlots).length === 0 ? "" : await encryptString(key, JSON.stringify(renderedSlots));
|
|
1411
|
-
const hostId = await this.getHostId();
|
|
1412
|
-
const slash = this.result.base.endsWith("/") ? "" : "/";
|
|
1413
|
-
let serverIslandUrl = `${this.result.base}${slash}_server-islands/${componentId}${this.result.trailingSlash === "always" ? "/" : ""}`;
|
|
1414
|
-
const potentialSearchParams = createSearchParams(
|
|
1415
|
-
componentExportEncrypted,
|
|
1416
|
-
propsEncrypted,
|
|
1417
|
-
slotsEncrypted
|
|
1418
|
-
);
|
|
1419
|
-
const useGETRequest = isWithinURLLimit(serverIslandUrl, potentialSearchParams);
|
|
1420
|
-
if (useGETRequest) {
|
|
1421
|
-
serverIslandUrl += "?" + potentialSearchParams.toString();
|
|
1422
|
-
this.result._metadata.extraHead.push(
|
|
1423
|
-
markHTMLString(
|
|
1424
|
-
`<link rel="preload" as="fetch" href="${serverIslandUrl}" crossorigin="anonymous">`
|
|
1425
|
-
)
|
|
1426
|
-
);
|
|
1427
|
-
}
|
|
1428
|
-
const adapterHeaders = this.result.internalFetchHeaders || {};
|
|
1429
|
-
const headersJson = safeJsonStringify(adapterHeaders);
|
|
1430
|
-
const method = useGETRequest ? (
|
|
1431
|
-
// GET request
|
|
1432
|
-
`const headers = new Headers(${headersJson});
|
|
1433
|
-
let response = await fetch('${serverIslandUrl}', { headers });`
|
|
1434
|
-
) : (
|
|
1435
|
-
// POST request
|
|
1436
|
-
`let data = {
|
|
1437
|
-
encryptedComponentExport: ${safeJsonStringify(componentExportEncrypted)},
|
|
1438
|
-
encryptedProps: ${safeJsonStringify(propsEncrypted)},
|
|
1439
|
-
encryptedSlots: ${safeJsonStringify(slotsEncrypted)},
|
|
1440
|
-
};
|
|
1441
|
-
const headers = new Headers({ 'Content-Type': 'application/json', ...${headersJson} });
|
|
1442
|
-
let response = await fetch('${serverIslandUrl}', {
|
|
1443
|
-
method: 'POST',
|
|
1444
|
-
body: JSON.stringify(data),
|
|
1445
|
-
headers,
|
|
1446
|
-
});`
|
|
1447
|
-
);
|
|
1448
|
-
this.islandContent = `${method}replaceServerIsland('${hostId}', response);`;
|
|
1449
|
-
return this.islandContent;
|
|
1450
|
-
}
|
|
1451
|
-
}
|
|
1452
|
-
const renderServerIslandRuntime = () => {
|
|
1453
|
-
return `<script>${SERVER_ISLAND_REPLACER}</script>`;
|
|
1454
|
-
};
|
|
1455
|
-
const SERVER_ISLAND_REPLACER = markHTMLString(
|
|
1456
|
-
`async function replaceServerIsland(id, r) {
|
|
1457
|
-
let s = document.querySelector(\`script[data-island-id="\${id}"]\`);
|
|
1458
|
-
// If there's no matching script, or the request fails then return
|
|
1459
|
-
if (!s || r.status !== 200 || r.headers.get('content-type')?.split(';')[0].trim() !== 'text/html') return;
|
|
1460
|
-
// Load the HTML before modifying the DOM in case of errors
|
|
1461
|
-
let html = await r.text();
|
|
1462
|
-
// Remove any placeholder content before the island script
|
|
1463
|
-
while (s.previousSibling && s.previousSibling.nodeType !== 8 && s.previousSibling.data !== '[if astro]>server-island-start<![endif]')
|
|
1464
|
-
s.previousSibling.remove();
|
|
1465
|
-
s.previousSibling?.remove();
|
|
1466
|
-
// Insert the new HTML
|
|
1467
|
-
s.before(document.createRange().createContextualFragment(html));
|
|
1468
|
-
// Remove the script. Prior to v5.4.2, this was the trick to force rerun of scripts. Keeping it to minimize change to the existing behavior.
|
|
1469
|
-
s.remove();
|
|
1470
|
-
}`.split("\n").map((line) => line.trim()).filter((line) => line && !line.startsWith("//")).join(" ")
|
|
1471
|
-
);
|
|
1472
|
-
|
|
1473
|
-
const Fragment = /* @__PURE__ */ Symbol.for("astro:fragment");
|
|
1474
|
-
const Renderer = /* @__PURE__ */ Symbol.for("astro:renderer");
|
|
1475
|
-
const encoder = new TextEncoder();
|
|
1476
|
-
const decoder = new TextDecoder();
|
|
1477
|
-
function stringifyChunk(result, chunk) {
|
|
1478
|
-
if (isRenderInstruction(chunk)) {
|
|
1479
|
-
const instruction = chunk;
|
|
1480
|
-
switch (instruction.type) {
|
|
1481
|
-
case "directive": {
|
|
1482
|
-
const { hydration } = instruction;
|
|
1483
|
-
let needsHydrationScript = hydration && determineIfNeedsHydrationScript(result);
|
|
1484
|
-
let needsDirectiveScript = hydration && determinesIfNeedsDirectiveScript(result, hydration.directive);
|
|
1485
|
-
if (needsHydrationScript) {
|
|
1486
|
-
let prescripts = getPrescripts(result, "both", hydration.directive);
|
|
1487
|
-
return markHTMLString(prescripts);
|
|
1488
|
-
} else if (needsDirectiveScript) {
|
|
1489
|
-
let prescripts = getPrescripts(result, "directive", hydration.directive);
|
|
1490
|
-
return markHTMLString(prescripts);
|
|
1491
|
-
} else {
|
|
1492
|
-
return "";
|
|
1493
|
-
}
|
|
1494
|
-
}
|
|
1495
|
-
case "head": {
|
|
1496
|
-
if (!shouldRenderInstruction("head", getInstructionRenderState(result))) {
|
|
1497
|
-
return "";
|
|
1498
|
-
}
|
|
1499
|
-
return renderAllHeadContent(result);
|
|
1500
|
-
}
|
|
1501
|
-
case "maybe-head": {
|
|
1502
|
-
if (!shouldRenderInstruction("maybe-head", getInstructionRenderState(result))) {
|
|
1503
|
-
return "";
|
|
1504
|
-
}
|
|
1505
|
-
return renderAllHeadContent(result);
|
|
1506
|
-
}
|
|
1507
|
-
case "renderer-hydration-script": {
|
|
1508
|
-
const { rendererSpecificHydrationScripts } = result._metadata;
|
|
1509
|
-
const { rendererName } = instruction;
|
|
1510
|
-
if (!rendererSpecificHydrationScripts.has(rendererName)) {
|
|
1511
|
-
rendererSpecificHydrationScripts.add(rendererName);
|
|
1512
|
-
return instruction.render();
|
|
1513
|
-
}
|
|
1514
|
-
return "";
|
|
1515
|
-
}
|
|
1516
|
-
case "server-island-runtime": {
|
|
1517
|
-
if (result._metadata.hasRenderedServerIslandRuntime) {
|
|
1518
|
-
return "";
|
|
1519
|
-
}
|
|
1520
|
-
result._metadata.hasRenderedServerIslandRuntime = true;
|
|
1521
|
-
return renderServerIslandRuntime();
|
|
1522
|
-
}
|
|
1523
|
-
case "script": {
|
|
1524
|
-
const { id, content } = instruction;
|
|
1525
|
-
if (result._metadata.renderedScripts.has(id)) {
|
|
1526
|
-
return "";
|
|
1527
|
-
}
|
|
1528
|
-
result._metadata.renderedScripts.add(id);
|
|
1529
|
-
return content;
|
|
1530
|
-
}
|
|
1531
|
-
default: {
|
|
1532
|
-
throw new Error(`Unknown chunk type: ${chunk.type}`);
|
|
1533
|
-
}
|
|
1534
|
-
}
|
|
1535
|
-
} else if (chunk instanceof Response) {
|
|
1536
|
-
return "";
|
|
1537
|
-
} else if (isSlotString(chunk)) {
|
|
1538
|
-
let out = "";
|
|
1539
|
-
const c = chunk;
|
|
1540
|
-
if (c.instructions) {
|
|
1541
|
-
for (const instr of c.instructions) {
|
|
1542
|
-
out += stringifyChunk(result, instr);
|
|
1543
|
-
}
|
|
1544
|
-
}
|
|
1545
|
-
out += chunk.toString();
|
|
1546
|
-
return out;
|
|
1547
|
-
}
|
|
1548
|
-
return chunk.toString();
|
|
1549
|
-
}
|
|
1550
|
-
function chunkToString(result, chunk) {
|
|
1551
|
-
if (ArrayBuffer.isView(chunk)) {
|
|
1552
|
-
return decoder.decode(chunk);
|
|
1553
|
-
} else {
|
|
1554
|
-
return stringifyChunk(result, chunk);
|
|
1555
|
-
}
|
|
1556
|
-
}
|
|
1557
|
-
function chunkToByteArray(result, chunk) {
|
|
1558
|
-
if (ArrayBuffer.isView(chunk)) {
|
|
1559
|
-
return chunk;
|
|
1560
|
-
} else {
|
|
1561
|
-
const stringified = stringifyChunk(result, chunk);
|
|
1562
|
-
return encoder.encode(stringified.toString());
|
|
1563
|
-
}
|
|
1564
|
-
}
|
|
1565
|
-
function chunkToByteArrayOrString(result, chunk) {
|
|
1566
|
-
if (ArrayBuffer.isView(chunk)) {
|
|
1567
|
-
return chunk;
|
|
1568
|
-
} else {
|
|
1569
|
-
return stringifyChunk(result, chunk).toString();
|
|
1570
|
-
}
|
|
1571
|
-
}
|
|
1572
|
-
function isRenderInstance(obj) {
|
|
1573
|
-
return !!obj && typeof obj === "object" && "render" in obj && typeof obj.render === "function";
|
|
1574
|
-
}
|
|
1575
|
-
|
|
1576
|
-
function renderChild(destination, child) {
|
|
1577
|
-
if (typeof child === "string") {
|
|
1578
|
-
destination.write(markHTMLString(escapeHTML(child)));
|
|
1579
|
-
return;
|
|
1580
|
-
}
|
|
1581
|
-
if (isPromise(child)) {
|
|
1582
|
-
return child.then((x) => renderChild(destination, x));
|
|
1583
|
-
}
|
|
1584
|
-
if (child instanceof SlotString) {
|
|
1585
|
-
destination.write(child);
|
|
1586
|
-
return;
|
|
1587
|
-
}
|
|
1588
|
-
if (isHTMLString(child)) {
|
|
1589
|
-
destination.write(child);
|
|
1590
|
-
return;
|
|
1591
|
-
}
|
|
1592
|
-
if (!child && child !== 0) {
|
|
1593
|
-
return;
|
|
1594
|
-
}
|
|
1595
|
-
if (Array.isArray(child)) {
|
|
1596
|
-
return renderArray(destination, child);
|
|
1597
|
-
}
|
|
1598
|
-
if (typeof child === "function") {
|
|
1599
|
-
return renderChild(destination, child());
|
|
1600
|
-
}
|
|
1601
|
-
if (isRenderInstance(child)) {
|
|
1602
|
-
return child.render(destination);
|
|
1603
|
-
}
|
|
1604
|
-
if (isRenderTemplateResult(child)) {
|
|
1605
|
-
return child.render(destination);
|
|
1606
|
-
}
|
|
1607
|
-
if (isAstroComponentInstance(child)) {
|
|
1608
|
-
return child.render(destination);
|
|
1609
|
-
}
|
|
1610
|
-
if (ArrayBuffer.isView(child)) {
|
|
1611
|
-
destination.write(child);
|
|
1612
|
-
return;
|
|
1613
|
-
}
|
|
1614
|
-
if (typeof child === "object" && (Symbol.asyncIterator in child || Symbol.iterator in child)) {
|
|
1615
|
-
if (Symbol.asyncIterator in child) {
|
|
1616
|
-
return renderAsyncIterable(destination, child);
|
|
1617
|
-
}
|
|
1618
|
-
return renderIterable(destination, child);
|
|
1619
|
-
}
|
|
1620
|
-
destination.write(child);
|
|
1621
|
-
}
|
|
1622
|
-
function renderArray(destination, children) {
|
|
1623
|
-
for (let i = 0; i < children.length; i++) {
|
|
1624
|
-
const result = renderChild(destination, children[i]);
|
|
1625
|
-
if (isPromise(result)) {
|
|
1626
|
-
if (i + 1 >= children.length) {
|
|
1627
|
-
return result;
|
|
1628
|
-
}
|
|
1629
|
-
const remaining = children.length - i - 1;
|
|
1630
|
-
const flushers = new Array(remaining);
|
|
1631
|
-
for (let j = 0; j < remaining; j++) {
|
|
1632
|
-
flushers[j] = createBufferedRenderer(destination, (bufferDestination) => {
|
|
1633
|
-
return renderChild(bufferDestination, children[i + 1 + j]);
|
|
1634
|
-
});
|
|
1635
|
-
}
|
|
1636
|
-
return result.then(() => {
|
|
1637
|
-
let k = 0;
|
|
1638
|
-
const iterate = () => {
|
|
1639
|
-
while (k < flushers.length) {
|
|
1640
|
-
const flushResult = flushers[k++].flush();
|
|
1641
|
-
if (isPromise(flushResult)) {
|
|
1642
|
-
return flushResult.then(iterate);
|
|
1643
|
-
}
|
|
1644
|
-
}
|
|
1645
|
-
};
|
|
1646
|
-
return iterate();
|
|
1647
|
-
});
|
|
1648
|
-
}
|
|
1649
|
-
}
|
|
1650
|
-
}
|
|
1651
|
-
function renderIterable(destination, children) {
|
|
1652
|
-
const iterator = children[Symbol.iterator]();
|
|
1653
|
-
const iterate = () => {
|
|
1654
|
-
for (; ; ) {
|
|
1655
|
-
const { value, done } = iterator.next();
|
|
1656
|
-
if (done) {
|
|
1657
|
-
break;
|
|
1658
|
-
}
|
|
1659
|
-
const result = renderChild(destination, value);
|
|
1660
|
-
if (isPromise(result)) {
|
|
1661
|
-
return result.then(iterate);
|
|
1662
|
-
}
|
|
1663
|
-
}
|
|
1664
|
-
};
|
|
1665
|
-
return iterate();
|
|
1666
|
-
}
|
|
1667
|
-
async function renderAsyncIterable(destination, children) {
|
|
1668
|
-
for await (const value of children) {
|
|
1669
|
-
await renderChild(destination, value);
|
|
1670
|
-
}
|
|
1671
|
-
}
|
|
1672
|
-
|
|
1673
|
-
const astroComponentInstanceSym = /* @__PURE__ */ Symbol.for("astro.componentInstance");
|
|
1674
|
-
class AstroComponentInstance {
|
|
1675
|
-
[astroComponentInstanceSym] = true;
|
|
1676
|
-
result;
|
|
1677
|
-
props;
|
|
1678
|
-
slotValues;
|
|
1679
|
-
factory;
|
|
1680
|
-
returnValue;
|
|
1681
|
-
constructor(result, props, slots, factory) {
|
|
1682
|
-
this.result = result;
|
|
1683
|
-
this.props = props;
|
|
1684
|
-
this.factory = factory;
|
|
1685
|
-
this.slotValues = {};
|
|
1686
|
-
for (const name in slots) {
|
|
1687
|
-
let didRender = false;
|
|
1688
|
-
let value = slots[name](result);
|
|
1689
|
-
this.slotValues[name] = () => {
|
|
1690
|
-
if (!didRender) {
|
|
1691
|
-
didRender = true;
|
|
1692
|
-
return value;
|
|
1693
|
-
}
|
|
1694
|
-
return slots[name](result);
|
|
1695
|
-
};
|
|
1696
|
-
}
|
|
1697
|
-
}
|
|
1698
|
-
init(result) {
|
|
1699
|
-
if (this.returnValue !== void 0) {
|
|
1700
|
-
return this.returnValue;
|
|
1701
|
-
}
|
|
1702
|
-
this.returnValue = this.factory(result, this.props, this.slotValues);
|
|
1703
|
-
if (isPromise(this.returnValue)) {
|
|
1704
|
-
this.returnValue.then((resolved) => {
|
|
1705
|
-
this.returnValue = resolved;
|
|
1706
|
-
}).catch(() => {
|
|
1707
|
-
});
|
|
1708
|
-
}
|
|
1709
|
-
return this.returnValue;
|
|
1710
|
-
}
|
|
1711
|
-
render(destination) {
|
|
1712
|
-
const returnValue = this.init(this.result);
|
|
1713
|
-
if (isPromise(returnValue)) {
|
|
1714
|
-
return returnValue.then((x) => this.renderImpl(destination, x));
|
|
1715
|
-
}
|
|
1716
|
-
return this.renderImpl(destination, returnValue);
|
|
1717
|
-
}
|
|
1718
|
-
renderImpl(destination, returnValue) {
|
|
1719
|
-
if (isHeadAndContent(returnValue)) {
|
|
1720
|
-
return returnValue.content.render(destination);
|
|
1721
|
-
} else {
|
|
1722
|
-
return renderChild(destination, returnValue);
|
|
1723
|
-
}
|
|
1724
|
-
}
|
|
1725
|
-
}
|
|
1726
|
-
function validateComponentProps(props, clientDirectives, displayName) {
|
|
1727
|
-
if (props != null) {
|
|
1728
|
-
const directives = [...clientDirectives.keys()].map((directive) => `client:${directive}`);
|
|
1729
|
-
for (const prop of Object.keys(props)) {
|
|
1730
|
-
if (directives.includes(prop)) {
|
|
1731
|
-
console.warn(
|
|
1732
|
-
`You are attempting to render <${displayName} ${prop} />, but ${displayName} is an Astro component. Astro components do not render in the client and should not have a hydration directive. Please use a framework component for client rendering.`
|
|
1733
|
-
);
|
|
1734
|
-
}
|
|
1735
|
-
}
|
|
1736
|
-
}
|
|
1737
|
-
}
|
|
1738
|
-
function createAstroComponentInstance(result, displayName, factory, props, slots = {}) {
|
|
1739
|
-
validateComponentProps(props, result.clientDirectives, displayName);
|
|
1740
|
-
const instance = new AstroComponentInstance(result, props, slots, factory);
|
|
1741
|
-
registerIfPropagating(result, factory, instance);
|
|
1742
|
-
return instance;
|
|
1743
|
-
}
|
|
1744
|
-
function isAstroComponentInstance(obj) {
|
|
1745
|
-
return typeof obj === "object" && obj !== null && !!obj[astroComponentInstanceSym];
|
|
1746
|
-
}
|
|
1747
|
-
|
|
1748
|
-
"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ-_".split("").reduce((v, c) => (v[c.charCodeAt(0)] = c, v), []);
|
|
1749
|
-
"-0123456789_".split("").reduce((v, c) => (v[c.charCodeAt(0)] = c, v), []);
|
|
1750
|
-
|
|
1751
|
-
function createRequest({
|
|
1752
|
-
url,
|
|
1753
|
-
headers,
|
|
1754
|
-
method = "GET",
|
|
1755
|
-
body = void 0,
|
|
1756
|
-
logger,
|
|
1757
|
-
isPrerendered = false,
|
|
1758
|
-
routePattern,
|
|
1759
|
-
init
|
|
1760
|
-
}) {
|
|
1761
|
-
const headersObj = isPrerendered ? void 0 : headers instanceof Headers ? headers : new Headers(
|
|
1762
|
-
// Filter out HTTP/2 pseudo-headers. These are internally-generated headers added to all HTTP/2 requests with trusted metadata about the request.
|
|
1763
|
-
// Examples include `:method`, `:scheme`, `:authority`, and `:path`.
|
|
1764
|
-
// They are always prefixed with a colon to distinguish them from other headers, and it is an error to add the to a Headers object manually.
|
|
1765
|
-
// See https://httpwg.org/specs/rfc7540.html#HttpRequest
|
|
1766
|
-
Object.entries(headers).filter(([name]) => !name.startsWith(":"))
|
|
1767
|
-
);
|
|
1768
|
-
if (typeof url === "string") url = new URL(url);
|
|
1769
|
-
if (isPrerendered) {
|
|
1770
|
-
url.search = "";
|
|
1771
|
-
}
|
|
1772
|
-
const request = new Request(url, {
|
|
1773
|
-
method,
|
|
1774
|
-
headers: headersObj,
|
|
1775
|
-
// body is made available only if the request is for a page that will be on-demand rendered
|
|
1776
|
-
body: isPrerendered ? null : body,
|
|
1777
|
-
...init
|
|
1778
|
-
});
|
|
1779
|
-
if (isPrerendered) {
|
|
1780
|
-
let _headers = request.headers;
|
|
1781
|
-
const { value, writable, ...headersDesc } = Object.getOwnPropertyDescriptor(request, "headers") || {};
|
|
1782
|
-
Object.defineProperty(request, "headers", {
|
|
1783
|
-
...headersDesc,
|
|
1784
|
-
get() {
|
|
1785
|
-
logger.warn(
|
|
1786
|
-
null,
|
|
1787
|
-
`\`Astro.request.headers\` was used when rendering the route \`${routePattern}'\`. \`Astro.request.headers\` is not available on prerendered pages. If you need access to request headers, make sure that the page is server-rendered using \`export const prerender = false;\` or by setting \`output\` to \`"server"\` in your Astro config to make all your pages server-rendered by default.`
|
|
1788
|
-
);
|
|
1789
|
-
return _headers;
|
|
1790
|
-
},
|
|
1791
|
-
set(newHeaders) {
|
|
1792
|
-
_headers = newHeaders;
|
|
1793
|
-
}
|
|
1794
|
-
});
|
|
1795
|
-
}
|
|
1796
|
-
return request;
|
|
1797
|
-
}
|
|
1798
|
-
|
|
1799
|
-
function template({
|
|
1800
|
-
title,
|
|
1801
|
-
pathname,
|
|
1802
|
-
statusCode = 404,
|
|
1803
|
-
tabTitle,
|
|
1804
|
-
body
|
|
1805
|
-
}) {
|
|
1806
|
-
return `<!doctype html>
|
|
1807
|
-
<html lang="en">
|
|
1808
|
-
<head>
|
|
1809
|
-
<meta charset="UTF-8">
|
|
1810
|
-
<title>${tabTitle}</title>
|
|
1811
|
-
<style>
|
|
1812
|
-
:root {
|
|
1813
|
-
--gray-10: hsl(258, 7%, 10%);
|
|
1814
|
-
--gray-20: hsl(258, 7%, 20%);
|
|
1815
|
-
--gray-30: hsl(258, 7%, 30%);
|
|
1816
|
-
--gray-40: hsl(258, 7%, 40%);
|
|
1817
|
-
--gray-50: hsl(258, 7%, 50%);
|
|
1818
|
-
--gray-60: hsl(258, 7%, 60%);
|
|
1819
|
-
--gray-70: hsl(258, 7%, 70%);
|
|
1820
|
-
--gray-80: hsl(258, 7%, 80%);
|
|
1821
|
-
--gray-90: hsl(258, 7%, 90%);
|
|
1822
|
-
--black: #13151A;
|
|
1823
|
-
--accent-light: #E0CCFA;
|
|
1824
|
-
}
|
|
1825
|
-
|
|
1826
|
-
* {
|
|
1827
|
-
box-sizing: border-box;
|
|
1828
|
-
}
|
|
1829
|
-
|
|
1830
|
-
html {
|
|
1831
|
-
background: var(--black);
|
|
1832
|
-
color-scheme: dark;
|
|
1833
|
-
accent-color: var(--accent-light);
|
|
1834
|
-
}
|
|
1835
|
-
|
|
1836
|
-
body {
|
|
1837
|
-
background-color: var(--gray-10);
|
|
1838
|
-
color: var(--gray-80);
|
|
1839
|
-
font-family: ui-monospace, Menlo, Monaco, "Cascadia Mono", "Segoe UI Mono", "Roboto Mono", "Oxygen Mono", "Ubuntu Monospace", "Source Code Pro", "Fira Mono", "Droid Sans Mono", "Courier New", monospace;
|
|
1840
|
-
line-height: 1.5;
|
|
1841
|
-
margin: 0;
|
|
1842
|
-
}
|
|
1843
|
-
|
|
1844
|
-
a {
|
|
1845
|
-
color: var(--accent-light);
|
|
1846
|
-
}
|
|
1847
|
-
|
|
1848
|
-
.center {
|
|
1849
|
-
display: flex;
|
|
1850
|
-
flex-direction: column;
|
|
1851
|
-
justify-content: center;
|
|
1852
|
-
align-items: center;
|
|
1853
|
-
height: 100vh;
|
|
1854
|
-
width: 100vw;
|
|
1855
|
-
}
|
|
1856
|
-
|
|
1857
|
-
h1 {
|
|
1858
|
-
margin-bottom: 8px;
|
|
1859
|
-
color: white;
|
|
1860
|
-
font-family: system-ui, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
|
|
1861
|
-
font-weight: 700;
|
|
1862
|
-
margin-top: 1rem;
|
|
1863
|
-
margin-bottom: 0;
|
|
1864
|
-
}
|
|
1865
|
-
|
|
1866
|
-
.statusCode {
|
|
1867
|
-
color: var(--accent-light);
|
|
1868
|
-
}
|
|
1869
|
-
|
|
1870
|
-
.astro-icon {
|
|
1871
|
-
height: 124px;
|
|
1872
|
-
width: 124px;
|
|
1873
|
-
}
|
|
1874
|
-
|
|
1875
|
-
pre, code {
|
|
1876
|
-
padding: 2px 8px;
|
|
1877
|
-
background: rgba(0,0,0, 0.25);
|
|
1878
|
-
border: 1px solid rgba(255,255,255, 0.25);
|
|
1879
|
-
border-radius: 4px;
|
|
1880
|
-
font-size: 1.2em;
|
|
1881
|
-
margin-top: 0;
|
|
1882
|
-
max-width: 60em;
|
|
1883
|
-
}
|
|
1884
|
-
</style>
|
|
1885
|
-
</head>
|
|
1886
|
-
<body>
|
|
1887
|
-
<main class="center">
|
|
1888
|
-
<svg class="astro-icon" xmlns="http://www.w3.org/2000/svg" width="64" height="80" viewBox="0 0 64 80" fill="none"> <path d="M20.5253 67.6322C16.9291 64.3531 15.8793 57.4632 17.3776 52.4717C19.9755 55.6188 23.575 56.6157 27.3035 57.1784C33.0594 58.0468 38.7122 57.722 44.0592 55.0977C44.6709 54.7972 45.2362 54.3978 45.9045 53.9931C46.4062 55.4451 46.5368 56.9109 46.3616 58.4028C45.9355 62.0362 44.1228 64.8429 41.2397 66.9705C40.0868 67.8215 38.8669 68.5822 37.6762 69.3846C34.0181 71.8508 33.0285 74.7426 34.403 78.9491C34.4357 79.0516 34.4649 79.1541 34.5388 79.4042C32.6711 78.5705 31.3069 77.3565 30.2674 75.7604C29.1694 74.0757 28.6471 72.2121 28.6196 70.1957C28.6059 69.2144 28.6059 68.2244 28.4736 67.257C28.1506 64.8985 27.0406 63.8425 24.9496 63.7817C22.8036 63.7192 21.106 65.0426 20.6559 67.1268C20.6215 67.2865 20.5717 67.4446 20.5218 67.6304L20.5253 67.6322Z" fill="white"/> <path d="M20.5253 67.6322C16.9291 64.3531 15.8793 57.4632 17.3776 52.4717C19.9755 55.6188 23.575 56.6157 27.3035 57.1784C33.0594 58.0468 38.7122 57.722 44.0592 55.0977C44.6709 54.7972 45.2362 54.3978 45.9045 53.9931C46.4062 55.4451 46.5368 56.9109 46.3616 58.4028C45.9355 62.0362 44.1228 64.8429 41.2397 66.9705C40.0868 67.8215 38.8669 68.5822 37.6762 69.3846C34.0181 71.8508 33.0285 74.7426 34.403 78.9491C34.4357 79.0516 34.4649 79.1541 34.5388 79.4042C32.6711 78.5705 31.3069 77.3565 30.2674 75.7604C29.1694 74.0757 28.6471 72.2121 28.6196 70.1957C28.6059 69.2144 28.6059 68.2244 28.4736 67.257C28.1506 64.8985 27.0406 63.8425 24.9496 63.7817C22.8036 63.7192 21.106 65.0426 20.6559 67.1268C20.6215 67.2865 20.5717 67.4446 20.5218 67.6304L20.5253 67.6322Z" fill="url(#paint0_linear_738_686)"/> <path d="M0 51.6401C0 51.6401 10.6488 46.4654 21.3274 46.4654L29.3786 21.6102C29.6801 20.4082 30.5602 19.5913 31.5538 19.5913C32.5474 19.5913 33.4275 20.4082 33.7289 21.6102L41.7802 46.4654C54.4274 46.4654 63.1076 51.6401 63.1076 51.6401C63.1076 51.6401 45.0197 2.48776 44.9843 2.38914C44.4652 0.935933 43.5888 0 42.4073 0H20.7022C19.5206 0 18.6796 0.935933 18.1251 2.38914C18.086 2.4859 0 51.6401 0 51.6401Z" fill="white"/> <defs> <linearGradient id="paint0_linear_738_686" x1="31.554" y1="75.4423" x2="39.7462" y2="48.376" gradientUnits="userSpaceOnUse"> <stop stop-color="#D83333"/> <stop offset="1" stop-color="#F041FF"/> </linearGradient> </defs> </svg>
|
|
1889
|
-
<h1>${statusCode ? `<span class="statusCode">${statusCode}: </span> ` : ""}<span class="statusMessage">${title}</span></h1>
|
|
1890
|
-
${body || `
|
|
1891
|
-
<pre>Path: ${escape(pathname)}</pre>
|
|
1892
|
-
`}
|
|
1893
|
-
</main>
|
|
1894
|
-
</body>
|
|
1895
|
-
</html>`;
|
|
1896
|
-
}
|
|
1897
|
-
|
|
1898
|
-
const DEFAULT_404_ROUTE = {
|
|
1899
|
-
component: DEFAULT_404_COMPONENT,
|
|
1900
|
-
params: [],
|
|
1901
|
-
pattern: /^\/404\/?$/,
|
|
1902
|
-
prerender: false,
|
|
1903
|
-
pathname: "/404",
|
|
1904
|
-
segments: [[{ content: "404", dynamic: false, spread: false }]],
|
|
1905
|
-
type: "page",
|
|
1906
|
-
route: "/404",
|
|
1907
|
-
fallbackRoutes: [],
|
|
1908
|
-
isIndex: false,
|
|
1909
|
-
origin: "internal",
|
|
1910
|
-
distURL: []
|
|
1911
|
-
};
|
|
1912
|
-
async function default404Page({ pathname }) {
|
|
1913
|
-
return new Response(
|
|
1914
|
-
template({
|
|
1915
|
-
statusCode: 404,
|
|
1916
|
-
title: "Not found",
|
|
1917
|
-
tabTitle: "404: Not Found",
|
|
1918
|
-
pathname
|
|
1919
|
-
}),
|
|
1920
|
-
{ status: 404, headers: { "Content-Type": "text/html" } }
|
|
1921
|
-
);
|
|
1922
|
-
}
|
|
1923
|
-
default404Page.isAstroComponentFactory = true;
|
|
1924
|
-
const default404Instance = {
|
|
1925
|
-
default: default404Page
|
|
1926
|
-
};
|
|
1927
|
-
|
|
1928
|
-
const ROUTE404_RE = /^\/404\/?$/;
|
|
1929
|
-
const ROUTE500_RE = /^\/500\/?$/;
|
|
1930
|
-
function isRoute404(route) {
|
|
1931
|
-
return ROUTE404_RE.test(route);
|
|
1932
|
-
}
|
|
1933
|
-
function isRoute500(route) {
|
|
1934
|
-
return ROUTE500_RE.test(route);
|
|
1935
|
-
}
|
|
1936
|
-
|
|
1937
|
-
function findRouteToRewrite({
|
|
1938
|
-
payload,
|
|
1939
|
-
routes,
|
|
1940
|
-
request,
|
|
1941
|
-
trailingSlash,
|
|
1942
|
-
buildFormat,
|
|
1943
|
-
base,
|
|
1944
|
-
outDir
|
|
1945
|
-
}) {
|
|
1946
|
-
let newUrl = void 0;
|
|
1947
|
-
if (payload instanceof URL) {
|
|
1948
|
-
newUrl = payload;
|
|
1949
|
-
} else if (payload instanceof Request) {
|
|
1950
|
-
newUrl = new URL(payload.url);
|
|
1951
|
-
} else {
|
|
1952
|
-
newUrl = new URL(collapseDuplicateSlashes(payload), new URL(request.url).origin);
|
|
1953
|
-
}
|
|
1954
|
-
const { pathname, resolvedUrlPathname } = normalizeRewritePathname(
|
|
1955
|
-
newUrl.pathname,
|
|
1956
|
-
base,
|
|
1957
|
-
trailingSlash,
|
|
1958
|
-
buildFormat
|
|
1959
|
-
);
|
|
1960
|
-
newUrl.pathname = resolvedUrlPathname;
|
|
1961
|
-
const decodedPathname = decodeURI(pathname);
|
|
1962
|
-
if (isRoute404(decodedPathname)) {
|
|
1963
|
-
const errorRoute = routes.find((route) => route.route === "/404");
|
|
1964
|
-
if (errorRoute) {
|
|
1965
|
-
return { routeData: errorRoute, newUrl, pathname: decodedPathname };
|
|
1966
|
-
}
|
|
1967
|
-
}
|
|
1968
|
-
if (isRoute500(decodedPathname)) {
|
|
1969
|
-
const errorRoute = routes.find((route) => route.route === "/500");
|
|
1970
|
-
if (errorRoute) {
|
|
1971
|
-
return { routeData: errorRoute, newUrl, pathname: decodedPathname };
|
|
1972
|
-
}
|
|
1973
|
-
}
|
|
1974
|
-
let foundRoute;
|
|
1975
|
-
for (const route of routes) {
|
|
1976
|
-
if (route.pattern.test(decodedPathname)) {
|
|
1977
|
-
if (route.params && route.params.length !== 0 && route.distURL && route.distURL.length !== 0) {
|
|
1978
|
-
if (!route.distURL.find(
|
|
1979
|
-
(url) => url.href.replace(outDir.toString(), "").replace(/(?:\/index\.html|\.html)$/, "") === trimSlashes(pathname)
|
|
1980
|
-
)) {
|
|
1981
|
-
continue;
|
|
1982
|
-
}
|
|
1983
|
-
}
|
|
1984
|
-
foundRoute = route;
|
|
1985
|
-
break;
|
|
1986
|
-
}
|
|
1987
|
-
}
|
|
1988
|
-
if (foundRoute) {
|
|
1989
|
-
return {
|
|
1990
|
-
routeData: foundRoute,
|
|
1991
|
-
newUrl,
|
|
1992
|
-
pathname: decodedPathname
|
|
1993
|
-
};
|
|
1994
|
-
} else {
|
|
1995
|
-
const custom404 = routes.find((route) => route.route === "/404");
|
|
1996
|
-
if (custom404) {
|
|
1997
|
-
return { routeData: custom404, newUrl, pathname };
|
|
1998
|
-
} else {
|
|
1999
|
-
return { routeData: DEFAULT_404_ROUTE, newUrl, pathname };
|
|
2000
|
-
}
|
|
2001
|
-
}
|
|
2002
|
-
}
|
|
2003
|
-
function copyRequest(newUrl, oldRequest, isPrerendered, logger, routePattern) {
|
|
2004
|
-
if (oldRequest.bodyUsed) {
|
|
2005
|
-
throw new AstroError(RewriteWithBodyUsed);
|
|
2006
|
-
}
|
|
2007
|
-
return createRequest({
|
|
2008
|
-
url: newUrl,
|
|
2009
|
-
method: oldRequest.method,
|
|
2010
|
-
body: oldRequest.body,
|
|
2011
|
-
isPrerendered,
|
|
2012
|
-
logger,
|
|
2013
|
-
headers: isPrerendered ? {} : oldRequest.headers,
|
|
2014
|
-
routePattern,
|
|
2015
|
-
init: {
|
|
2016
|
-
referrer: oldRequest.referrer,
|
|
2017
|
-
referrerPolicy: oldRequest.referrerPolicy,
|
|
2018
|
-
mode: oldRequest.mode,
|
|
2019
|
-
credentials: oldRequest.credentials,
|
|
2020
|
-
cache: oldRequest.cache,
|
|
2021
|
-
redirect: oldRequest.redirect,
|
|
2022
|
-
integrity: oldRequest.integrity,
|
|
2023
|
-
signal: oldRequest.signal,
|
|
2024
|
-
keepalive: oldRequest.keepalive,
|
|
2025
|
-
// https://fetch.spec.whatwg.org/#dom-request-duplex
|
|
2026
|
-
// @ts-expect-error It isn't part of the types, but undici accepts it and it allows to carry over the body to a new request
|
|
2027
|
-
duplex: "half"
|
|
2028
|
-
}
|
|
2029
|
-
});
|
|
2030
|
-
}
|
|
2031
|
-
function setOriginPathname(request, pathname, trailingSlash, buildFormat) {
|
|
2032
|
-
if (!pathname) {
|
|
2033
|
-
pathname = "/";
|
|
2034
|
-
}
|
|
2035
|
-
const shouldAppendSlash = shouldAppendForwardSlash(trailingSlash, buildFormat);
|
|
2036
|
-
let finalPathname;
|
|
2037
|
-
if (pathname === "/") {
|
|
2038
|
-
finalPathname = "/";
|
|
2039
|
-
} else if (shouldAppendSlash) {
|
|
2040
|
-
finalPathname = appendForwardSlash(pathname);
|
|
2041
|
-
} else {
|
|
2042
|
-
finalPathname = removeTrailingForwardSlash(pathname);
|
|
2043
|
-
}
|
|
2044
|
-
Reflect.set(request, originPathnameSymbol, encodeURIComponent(finalPathname));
|
|
2045
|
-
}
|
|
2046
|
-
function getOriginPathname(request) {
|
|
2047
|
-
const origin = Reflect.get(request, originPathnameSymbol);
|
|
2048
|
-
if (origin) {
|
|
2049
|
-
return decodeURIComponent(origin);
|
|
2050
|
-
}
|
|
2051
|
-
return new URL(request.url).pathname;
|
|
2052
|
-
}
|
|
2053
|
-
function normalizeRewritePathname(urlPathname, base, trailingSlash, buildFormat) {
|
|
2054
|
-
let pathname = collapseDuplicateSlashes(urlPathname);
|
|
2055
|
-
const shouldAppendSlash = shouldAppendForwardSlash(trailingSlash, buildFormat);
|
|
2056
|
-
if (base !== "/") {
|
|
2057
|
-
const isBasePathRequest = urlPathname === base || urlPathname === removeTrailingForwardSlash(base);
|
|
2058
|
-
if (isBasePathRequest) {
|
|
2059
|
-
pathname = shouldAppendSlash ? "/" : "";
|
|
2060
|
-
} else if (urlPathname.startsWith(base)) {
|
|
2061
|
-
pathname = shouldAppendSlash ? appendForwardSlash(urlPathname) : removeTrailingForwardSlash(urlPathname);
|
|
2062
|
-
pathname = pathname.slice(base.length);
|
|
2063
|
-
}
|
|
2064
|
-
}
|
|
2065
|
-
if (!pathname.startsWith("/") && shouldAppendSlash && urlPathname.endsWith("/")) {
|
|
2066
|
-
pathname = prependForwardSlash(pathname);
|
|
2067
|
-
}
|
|
2068
|
-
if (pathname === "/" && base !== "/" && !shouldAppendSlash) {
|
|
2069
|
-
pathname = "";
|
|
2070
|
-
}
|
|
2071
|
-
if (buildFormat === "file") {
|
|
2072
|
-
pathname = pathname.replace(/\.html$/, "");
|
|
2073
|
-
}
|
|
2074
|
-
let resolvedUrlPathname;
|
|
2075
|
-
if (base !== "/" && (pathname === "" || pathname === "/") && !shouldAppendSlash) {
|
|
2076
|
-
resolvedUrlPathname = removeTrailingForwardSlash(base);
|
|
2077
|
-
} else {
|
|
2078
|
-
resolvedUrlPathname = joinPaths(...[base, pathname].filter(Boolean));
|
|
2079
|
-
}
|
|
2080
|
-
return { pathname, resolvedUrlPathname };
|
|
2081
|
-
}
|
|
2082
|
-
|
|
2083
|
-
function defineMiddleware(fn) {
|
|
2084
|
-
return fn;
|
|
2085
|
-
}
|
|
2086
|
-
|
|
2087
|
-
function sanitizeParams(params) {
|
|
2088
|
-
return Object.fromEntries(
|
|
2089
|
-
Object.entries(params).map(([key, value]) => {
|
|
2090
|
-
if (typeof value === "string") {
|
|
2091
|
-
return [key, value.normalize().replace(/#/g, "%23").replace(/\?/g, "%3F")];
|
|
2092
|
-
}
|
|
2093
|
-
return [key, value];
|
|
2094
|
-
})
|
|
2095
|
-
);
|
|
2096
|
-
}
|
|
2097
|
-
function getParameter(part, params) {
|
|
2098
|
-
if (part.spread) {
|
|
2099
|
-
return params[part.content.slice(3)] || "";
|
|
2100
|
-
}
|
|
2101
|
-
if (part.dynamic) {
|
|
2102
|
-
if (!params[part.content]) {
|
|
2103
|
-
throw new TypeError(`Missing parameter: ${part.content}`);
|
|
2104
|
-
}
|
|
2105
|
-
return params[part.content];
|
|
2106
|
-
}
|
|
2107
|
-
return part.content.normalize().replace(/\?/g, "%3F").replace(/#/g, "%23").replace(/%5B/g, "[").replace(/%5D/g, "]");
|
|
2108
|
-
}
|
|
2109
|
-
function getSegment(segment, params) {
|
|
2110
|
-
const segmentPath = segment.map((part) => getParameter(part, params)).join("");
|
|
2111
|
-
return segmentPath ? collapseDuplicateLeadingSlashes("/" + segmentPath) : "";
|
|
2112
|
-
}
|
|
2113
|
-
function getRouteGenerator(segments, addTrailingSlash) {
|
|
2114
|
-
return (params) => {
|
|
2115
|
-
const sanitizedParams = sanitizeParams(params);
|
|
2116
|
-
let trailing = "";
|
|
2117
|
-
if (addTrailingSlash === "always" && segments.length) {
|
|
2118
|
-
trailing = "/";
|
|
2119
|
-
}
|
|
2120
|
-
const path = segments.map((segment) => getSegment(segment, sanitizedParams)).join("") + trailing;
|
|
2121
|
-
return path || "/";
|
|
2122
|
-
};
|
|
2123
|
-
}
|
|
2124
|
-
|
|
2125
|
-
const VALID_PARAM_TYPES = ["string", "undefined"];
|
|
2126
|
-
function validateGetStaticPathsParameter([key, value], route) {
|
|
2127
|
-
if (!VALID_PARAM_TYPES.includes(typeof value)) {
|
|
2128
|
-
throw new AstroError({
|
|
2129
|
-
...GetStaticPathsInvalidRouteParam,
|
|
2130
|
-
message: GetStaticPathsInvalidRouteParam.message(key, value, typeof value),
|
|
2131
|
-
location: {
|
|
2132
|
-
file: route
|
|
2133
|
-
}
|
|
2134
|
-
});
|
|
2135
|
-
}
|
|
2136
|
-
}
|
|
2137
|
-
|
|
2138
|
-
function stringifyParams(params, route, trailingSlash) {
|
|
2139
|
-
const validatedParams = {};
|
|
2140
|
-
for (const [key, value] of Object.entries(params)) {
|
|
2141
|
-
validateGetStaticPathsParameter([key, value], route.component);
|
|
2142
|
-
if (value !== void 0) {
|
|
2143
|
-
validatedParams[key] = trimSlashes(value);
|
|
2144
|
-
}
|
|
2145
|
-
}
|
|
2146
|
-
return getRouteGenerator(route.segments, trailingSlash)(validatedParams);
|
|
2147
|
-
}
|
|
2148
|
-
|
|
2149
|
-
function validateDynamicRouteModule(mod, {
|
|
2150
|
-
ssr,
|
|
2151
|
-
route
|
|
2152
|
-
}) {
|
|
2153
|
-
if ((!ssr || route.prerender) && !mod.getStaticPaths) {
|
|
2154
|
-
throw new AstroError({
|
|
2155
|
-
...GetStaticPathsRequired,
|
|
2156
|
-
location: { file: route.component }
|
|
2157
|
-
});
|
|
2158
|
-
}
|
|
2159
|
-
}
|
|
2160
|
-
function validateGetStaticPathsResult(result, route) {
|
|
2161
|
-
if (!Array.isArray(result)) {
|
|
2162
|
-
throw new AstroError({
|
|
2163
|
-
...InvalidGetStaticPathsReturn,
|
|
2164
|
-
message: InvalidGetStaticPathsReturn.message(typeof result),
|
|
2165
|
-
location: {
|
|
2166
|
-
file: route.component
|
|
2167
|
-
}
|
|
2168
|
-
});
|
|
2169
|
-
}
|
|
2170
|
-
result.forEach((pathObject) => {
|
|
2171
|
-
if (typeof pathObject === "object" && Array.isArray(pathObject) || pathObject === null) {
|
|
2172
|
-
throw new AstroError({
|
|
2173
|
-
...InvalidGetStaticPathsEntry,
|
|
2174
|
-
message: InvalidGetStaticPathsEntry.message(
|
|
2175
|
-
Array.isArray(pathObject) ? "array" : typeof pathObject
|
|
2176
|
-
)
|
|
2177
|
-
});
|
|
2178
|
-
}
|
|
2179
|
-
if (pathObject.params === void 0 || pathObject.params === null || pathObject.params && Object.keys(pathObject.params).length === 0) {
|
|
2180
|
-
throw new AstroError({
|
|
2181
|
-
...GetStaticPathsExpectedParams,
|
|
2182
|
-
location: {
|
|
2183
|
-
file: route.component
|
|
2184
|
-
}
|
|
2185
|
-
});
|
|
2186
|
-
}
|
|
2187
|
-
});
|
|
2188
|
-
}
|
|
2189
|
-
|
|
2190
|
-
function generatePaginateFunction(routeMatch, base, trailingSlash) {
|
|
2191
|
-
return function paginateUtility(data, args = {}) {
|
|
2192
|
-
const generate = getRouteGenerator(routeMatch.segments, trailingSlash);
|
|
2193
|
-
let { pageSize: _pageSize, params: _params, props: _props } = args;
|
|
2194
|
-
const pageSize = _pageSize || 10;
|
|
2195
|
-
const paramName = "page";
|
|
2196
|
-
const additionalParams = _params || {};
|
|
2197
|
-
const additionalProps = _props || {};
|
|
2198
|
-
let includesFirstPageNumber;
|
|
2199
|
-
if (routeMatch.params.includes(`...${paramName}`)) {
|
|
2200
|
-
includesFirstPageNumber = false;
|
|
2201
|
-
} else if (routeMatch.params.includes(`${paramName}`)) {
|
|
2202
|
-
includesFirstPageNumber = true;
|
|
2203
|
-
} else {
|
|
2204
|
-
throw new AstroError({
|
|
2205
|
-
...PageNumberParamNotFound,
|
|
2206
|
-
message: PageNumberParamNotFound.message(paramName)
|
|
2207
|
-
});
|
|
2208
|
-
}
|
|
2209
|
-
const lastPage = Math.max(1, Math.ceil(data.length / pageSize));
|
|
2210
|
-
const result = [...Array(lastPage).keys()].map((num) => {
|
|
2211
|
-
const pageNum = num + 1;
|
|
2212
|
-
const start = pageSize === Number.POSITIVE_INFINITY ? 0 : (pageNum - 1) * pageSize;
|
|
2213
|
-
const end = Math.min(start + pageSize, data.length);
|
|
2214
|
-
const params = {
|
|
2215
|
-
...additionalParams,
|
|
2216
|
-
[paramName]: includesFirstPageNumber || pageNum > 1 ? String(pageNum) : void 0
|
|
2217
|
-
};
|
|
2218
|
-
const current = addRouteBase(generate({ ...params }), base);
|
|
2219
|
-
const next = pageNum === lastPage ? void 0 : addRouteBase(generate({ ...params, page: String(pageNum + 1) }), base);
|
|
2220
|
-
const prev = pageNum === 1 ? void 0 : addRouteBase(
|
|
2221
|
-
generate({
|
|
2222
|
-
...params,
|
|
2223
|
-
page: !includesFirstPageNumber && pageNum - 1 === 1 ? void 0 : String(pageNum - 1)
|
|
2224
|
-
}),
|
|
2225
|
-
base
|
|
2226
|
-
);
|
|
2227
|
-
const first = pageNum === 1 ? void 0 : addRouteBase(
|
|
2228
|
-
generate({
|
|
2229
|
-
...params,
|
|
2230
|
-
page: includesFirstPageNumber ? "1" : void 0
|
|
2231
|
-
}),
|
|
2232
|
-
base
|
|
2233
|
-
);
|
|
2234
|
-
const last = pageNum === lastPage ? void 0 : addRouteBase(generate({ ...params, page: String(lastPage) }), base);
|
|
2235
|
-
return {
|
|
2236
|
-
params,
|
|
2237
|
-
props: {
|
|
2238
|
-
...additionalProps,
|
|
2239
|
-
page: {
|
|
2240
|
-
data: data.slice(start, end),
|
|
2241
|
-
start,
|
|
2242
|
-
end: end - 1,
|
|
2243
|
-
size: pageSize,
|
|
2244
|
-
total: data.length,
|
|
2245
|
-
currentPage: pageNum,
|
|
2246
|
-
lastPage,
|
|
2247
|
-
url: { current, next, prev, first, last }
|
|
2248
|
-
}
|
|
2249
|
-
}
|
|
2250
|
-
};
|
|
2251
|
-
});
|
|
2252
|
-
return result;
|
|
2253
|
-
};
|
|
2254
|
-
}
|
|
2255
|
-
function addRouteBase(route, base) {
|
|
2256
|
-
let routeWithBase = joinPaths(base, route);
|
|
2257
|
-
if (routeWithBase === "") routeWithBase = "/";
|
|
2258
|
-
return routeWithBase;
|
|
2259
|
-
}
|
|
2260
|
-
|
|
2261
|
-
async function callGetStaticPaths({
|
|
2262
|
-
mod,
|
|
2263
|
-
route,
|
|
2264
|
-
routeCache,
|
|
2265
|
-
ssr,
|
|
2266
|
-
base,
|
|
2267
|
-
trailingSlash
|
|
2268
|
-
}) {
|
|
2269
|
-
const cached = routeCache.get(route);
|
|
2270
|
-
if (!mod) {
|
|
2271
|
-
throw new Error("This is an error caused by Astro and not your code. Please file an issue.");
|
|
2272
|
-
}
|
|
2273
|
-
if (cached?.staticPaths) {
|
|
2274
|
-
return cached.staticPaths;
|
|
2275
|
-
}
|
|
2276
|
-
validateDynamicRouteModule(mod, { ssr, route });
|
|
2277
|
-
if (ssr && !route.prerender) {
|
|
2278
|
-
const entry = Object.assign([], { keyed: /* @__PURE__ */ new Map() });
|
|
2279
|
-
routeCache.set(route, { ...cached, staticPaths: entry });
|
|
2280
|
-
return entry;
|
|
2281
|
-
}
|
|
2282
|
-
let staticPaths = [];
|
|
2283
|
-
if (!mod.getStaticPaths) {
|
|
2284
|
-
throw new Error("Unexpected Error.");
|
|
2285
|
-
}
|
|
2286
|
-
staticPaths = await mod.getStaticPaths({
|
|
2287
|
-
// Q: Why the cast?
|
|
2288
|
-
// A: So users downstream can have nicer typings, we have to make some sacrifice in our internal typings, which necessitate a cast here
|
|
2289
|
-
paginate: generatePaginateFunction(route, base, trailingSlash),
|
|
2290
|
-
routePattern: route.route
|
|
2291
|
-
});
|
|
2292
|
-
validateGetStaticPathsResult(staticPaths, route);
|
|
2293
|
-
const keyedStaticPaths = staticPaths;
|
|
2294
|
-
keyedStaticPaths.keyed = /* @__PURE__ */ new Map();
|
|
2295
|
-
for (const sp of keyedStaticPaths) {
|
|
2296
|
-
const paramsKey = stringifyParams(sp.params, route, trailingSlash);
|
|
2297
|
-
keyedStaticPaths.keyed.set(paramsKey, sp);
|
|
2298
|
-
}
|
|
2299
|
-
routeCache.set(route, { ...cached, staticPaths: keyedStaticPaths });
|
|
2300
|
-
return keyedStaticPaths;
|
|
2301
|
-
}
|
|
2302
|
-
class RouteCache {
|
|
2303
|
-
logger;
|
|
2304
|
-
cache = {};
|
|
2305
|
-
runtimeMode;
|
|
2306
|
-
constructor(logger, runtimeMode = "production") {
|
|
2307
|
-
this.logger = logger;
|
|
2308
|
-
this.runtimeMode = runtimeMode;
|
|
2309
|
-
}
|
|
2310
|
-
/** Clear the cache. */
|
|
2311
|
-
clearAll() {
|
|
2312
|
-
this.cache = {};
|
|
2313
|
-
}
|
|
2314
|
-
set(route, entry) {
|
|
2315
|
-
const key = this.key(route);
|
|
2316
|
-
if (this.runtimeMode === "production" && this.cache[key]?.staticPaths) {
|
|
2317
|
-
this.logger.warn(null, `Internal Warning: route cache overwritten. (${key})`);
|
|
2318
|
-
}
|
|
2319
|
-
this.cache[key] = entry;
|
|
2320
|
-
}
|
|
2321
|
-
get(route) {
|
|
2322
|
-
return this.cache[this.key(route)];
|
|
2323
|
-
}
|
|
2324
|
-
key(route) {
|
|
2325
|
-
return `${route.route}_${route.component}`;
|
|
2326
|
-
}
|
|
2327
|
-
}
|
|
2328
|
-
function findPathItemByKey(staticPaths, params, route, logger, trailingSlash) {
|
|
2329
|
-
const paramsKey = stringifyParams(params, route, trailingSlash);
|
|
2330
|
-
const matchedStaticPath = staticPaths.keyed.get(paramsKey);
|
|
2331
|
-
if (matchedStaticPath) {
|
|
2332
|
-
return matchedStaticPath;
|
|
2333
|
-
}
|
|
2334
|
-
logger.debug("router", `findPathItemByKey() - Unexpected cache miss looking for ${paramsKey}`);
|
|
2335
|
-
}
|
|
2336
|
-
|
|
2337
|
-
function routeIsRedirect(route) {
|
|
2338
|
-
return route?.type === "redirect";
|
|
2339
|
-
}
|
|
2340
|
-
function routeIsFallback(route) {
|
|
2341
|
-
return route?.type === "fallback";
|
|
2342
|
-
}
|
|
2343
|
-
function getFallbackRoute(route, routeList) {
|
|
2344
|
-
const fallbackRoute = routeList.find((r) => {
|
|
2345
|
-
if (route.route === "/" && r.routeData.route === "/") {
|
|
2346
|
-
return true;
|
|
2347
|
-
}
|
|
2348
|
-
return r.routeData.fallbackRoutes.find((f) => {
|
|
2349
|
-
return f.route === route.route;
|
|
2350
|
-
});
|
|
2351
|
-
});
|
|
2352
|
-
if (!fallbackRoute) {
|
|
2353
|
-
throw new Error(`No fallback route found for route ${route.route}`);
|
|
2354
|
-
}
|
|
2355
|
-
return fallbackRoute.routeData;
|
|
2356
|
-
}
|
|
2357
|
-
function routeHasHtmlExtension(route) {
|
|
2358
|
-
return route.segments.some(
|
|
2359
|
-
(segment) => segment.some((part) => !part.dynamic && part.content.includes(".html"))
|
|
2360
|
-
);
|
|
2361
|
-
}
|
|
2362
|
-
|
|
2363
|
-
async function getProps(opts) {
|
|
2364
|
-
const {
|
|
2365
|
-
logger,
|
|
2366
|
-
mod,
|
|
2367
|
-
routeData: route,
|
|
2368
|
-
routeCache,
|
|
2369
|
-
pathname,
|
|
2370
|
-
serverLike,
|
|
2371
|
-
base,
|
|
2372
|
-
trailingSlash
|
|
2373
|
-
} = opts;
|
|
2374
|
-
if (!route || route.pathname) {
|
|
2375
|
-
return {};
|
|
2376
|
-
}
|
|
2377
|
-
if (routeIsRedirect(route) || routeIsFallback(route) || route.component === DEFAULT_404_COMPONENT) {
|
|
2378
|
-
return {};
|
|
2379
|
-
}
|
|
2380
|
-
const staticPaths = await callGetStaticPaths({
|
|
2381
|
-
mod,
|
|
2382
|
-
route,
|
|
2383
|
-
routeCache,
|
|
2384
|
-
ssr: serverLike,
|
|
2385
|
-
base,
|
|
2386
|
-
trailingSlash
|
|
2387
|
-
});
|
|
2388
|
-
const params = getParams(route, pathname);
|
|
2389
|
-
const matchedStaticPath = findPathItemByKey(staticPaths, params, route, logger, trailingSlash);
|
|
2390
|
-
if (!matchedStaticPath && (serverLike ? route.prerender : true)) {
|
|
2391
|
-
throw new AstroError({
|
|
2392
|
-
...NoMatchingStaticPathFound,
|
|
2393
|
-
message: NoMatchingStaticPathFound.message(pathname),
|
|
2394
|
-
hint: NoMatchingStaticPathFound.hint([route.component])
|
|
2395
|
-
});
|
|
2396
|
-
}
|
|
2397
|
-
if (mod) {
|
|
2398
|
-
validatePrerenderEndpointCollision(route, mod, params);
|
|
2399
|
-
}
|
|
2400
|
-
const props = matchedStaticPath?.props ? { ...matchedStaticPath.props } : {};
|
|
2401
|
-
return props;
|
|
2402
|
-
}
|
|
2403
|
-
function getParams(route, pathname) {
|
|
2404
|
-
if (!route.params.length) return {};
|
|
2405
|
-
const path = pathname.endsWith(".html") && !routeHasHtmlExtension(route) ? pathname.slice(0, -5) : pathname;
|
|
2406
|
-
const allPatterns = [route, ...route.fallbackRoutes].map((r) => r.pattern);
|
|
2407
|
-
const paramsMatch = allPatterns.map((pattern) => pattern.exec(path)).find((x) => x);
|
|
2408
|
-
if (!paramsMatch) return {};
|
|
2409
|
-
const params = {};
|
|
2410
|
-
route.params.forEach((key, i) => {
|
|
2411
|
-
if (key.startsWith("...")) {
|
|
2412
|
-
params[key.slice(3)] = paramsMatch[i + 1] ? paramsMatch[i + 1] : void 0;
|
|
2413
|
-
} else {
|
|
2414
|
-
params[key] = paramsMatch[i + 1];
|
|
2415
|
-
}
|
|
2416
|
-
});
|
|
2417
|
-
return params;
|
|
2418
|
-
}
|
|
2419
|
-
function validatePrerenderEndpointCollision(route, mod, params) {
|
|
2420
|
-
if (route.type === "endpoint" && mod.getStaticPaths) {
|
|
2421
|
-
const lastSegment = route.segments[route.segments.length - 1];
|
|
2422
|
-
const paramValues = Object.values(params);
|
|
2423
|
-
const lastParam = paramValues[paramValues.length - 1];
|
|
2424
|
-
if (lastSegment.length === 1 && lastSegment[0].dynamic && lastParam === void 0) {
|
|
2425
|
-
throw new AstroError({
|
|
2426
|
-
...PrerenderDynamicEndpointPathCollide,
|
|
2427
|
-
message: PrerenderDynamicEndpointPathCollide.message(route.route),
|
|
2428
|
-
hint: PrerenderDynamicEndpointPathCollide.hint(route.component),
|
|
2429
|
-
location: {
|
|
2430
|
-
file: route.component
|
|
2431
|
-
}
|
|
2432
|
-
});
|
|
2433
|
-
}
|
|
2434
|
-
}
|
|
2435
|
-
}
|
|
2436
|
-
|
|
2437
|
-
function sequence(...handlers) {
|
|
2438
|
-
const filtered = handlers.filter((h) => !!h);
|
|
2439
|
-
const length = filtered.length;
|
|
2440
|
-
if (!length) {
|
|
2441
|
-
return defineMiddleware((_context, next) => {
|
|
2442
|
-
return next();
|
|
2443
|
-
});
|
|
2444
|
-
}
|
|
2445
|
-
return defineMiddleware((context, next) => {
|
|
2446
|
-
let carriedPayload = void 0;
|
|
2447
|
-
return applyHandle(0, context);
|
|
2448
|
-
function applyHandle(i, handleContext) {
|
|
2449
|
-
const handle = filtered[i];
|
|
2450
|
-
const result = handle(handleContext, async (payload) => {
|
|
2451
|
-
if (i < length - 1) {
|
|
2452
|
-
if (payload) {
|
|
2453
|
-
let newRequest;
|
|
2454
|
-
if (payload instanceof Request) {
|
|
2455
|
-
newRequest = payload;
|
|
2456
|
-
} else if (payload instanceof URL) {
|
|
2457
|
-
newRequest = new Request(payload, handleContext.request.clone());
|
|
2458
|
-
} else {
|
|
2459
|
-
newRequest = new Request(
|
|
2460
|
-
new URL(payload, handleContext.url.origin),
|
|
2461
|
-
handleContext.request.clone()
|
|
2462
|
-
);
|
|
2463
|
-
}
|
|
2464
|
-
const oldPathname = handleContext.url.pathname;
|
|
2465
|
-
const pipeline = Reflect.get(handleContext, pipelineSymbol);
|
|
2466
|
-
const { routeData, pathname } = await pipeline.tryRewrite(
|
|
2467
|
-
payload,
|
|
2468
|
-
handleContext.request
|
|
2469
|
-
);
|
|
2470
|
-
if (pipeline.manifest.serverLike === true && handleContext.isPrerendered === false && routeData.prerender === true) {
|
|
2471
|
-
throw new AstroError({
|
|
2472
|
-
...ForbiddenRewrite,
|
|
2473
|
-
message: ForbiddenRewrite.message(
|
|
2474
|
-
handleContext.url.pathname,
|
|
2475
|
-
pathname,
|
|
2476
|
-
routeData.component
|
|
2477
|
-
),
|
|
2478
|
-
hint: ForbiddenRewrite.hint(routeData.component)
|
|
2479
|
-
});
|
|
2480
|
-
}
|
|
2481
|
-
carriedPayload = payload;
|
|
2482
|
-
handleContext.request = newRequest;
|
|
2483
|
-
handleContext.url = new URL(newRequest.url);
|
|
2484
|
-
handleContext.params = getParams(routeData, pathname);
|
|
2485
|
-
handleContext.routePattern = routeData.route;
|
|
2486
|
-
setOriginPathname(
|
|
2487
|
-
handleContext.request,
|
|
2488
|
-
oldPathname,
|
|
2489
|
-
pipeline.manifest.trailingSlash,
|
|
2490
|
-
pipeline.manifest.buildFormat
|
|
2491
|
-
);
|
|
2492
|
-
}
|
|
2493
|
-
return applyHandle(i + 1, handleContext);
|
|
2494
|
-
} else {
|
|
2495
|
-
return next(payload ?? carriedPayload);
|
|
2496
|
-
}
|
|
2497
|
-
});
|
|
2498
|
-
return result;
|
|
2499
|
-
}
|
|
2500
|
-
});
|
|
2501
|
-
}
|
|
2502
|
-
|
|
2503
|
-
export { isRenderInstance as $, AstroError as A, maybeRenderHead as B, containsServerDirective as C, renderSlots as D, EndpointDidNotReturnAResponse as E, Fragment as F, createAstroComponentInstance as G, Renderer as H, NoMatchingRenderer as I, formatList as J, NoClientOnlyHint as K, internalSpreadAttributes as L, MissingMediaQueryDirective as M, NoMatchingImport as N, OnlyResponseCanBeReturned as O, voidElementNames as P, renderTemplate as Q, ROUTE_TYPE_HEADER as R, ServerIslandComponent as S, createRenderInstruction as T, renderElement as U, SlotString as V, mergeSlotInstructions as W, HTMLString as X, isHTMLString as Y, isRenderInstruction as Z, isAstroComponentInstance as _, REROUTE_DIRECTIVE_HEADER as a, MissingImageDimension as a$, renderCspContent as a0, isNode as a1, isDeno as a2, addAttribute as a3, MiddlewareNoDataOrNextCalled as a4, MiddlewareNotAResponse as a5, CacheNotEnabled as a6, defineMiddleware as a7, NOOP_MIDDLEWARE_HEADER as a8, decryptString as a9, StaticClientAddressNotAvailable as aA, REWRITE_DIRECTIVE_HEADER_KEY as aB, REWRITE_DIRECTIVE_HEADER_VALUE as aC, AstroResponseHeadersReassigned as aD, responseSentSymbol as aE, prependForwardSlash as aF, collapseDuplicateLeadingSlashes as aG, joinPaths as aH, isInternalPath as aI, collapseDuplicateTrailingSlashes as aJ, hasFileExtension as aK, LocalsNotAnObject as aL, routeHasHtmlExtension as aM, clientAddressSymbol as aN, fileExtension as aO, slash as aP, routeIsRedirect as aQ, routeIsFallback as aR, getFallbackRoute as aS, findRouteToRewrite as aT, nodeRequestAbortControllerCleanupSymbol as aU, NoImageMetadata as aV, FailedToFetchRemoteImageDimensions as aW, RemoteImageNotAllowed as aX, ExpectedImage as aY, isRemotePath as aZ, LocalImageUsedWrongly as a_, createSlotValueFromString as aa, DEFAULT_404_COMPONENT as ab, DEFAULT_404_ROUTE as ac, default404Instance as ad, decodeKey as ae, RouteCache as af, sequence as ag, ReservedSlotName as ah, getRouteGenerator as ai, isRoute404 as aj, isRoute500 as ak, removeLeadingForwardSlash as al, SessionStorageInitError as am, SessionStorageSaveError as an, getParams as ao, collapseDuplicateSlashes as ap, setOriginPathname as aq, getProps as ar, ForbiddenRewrite as as, copyRequest as at, ASTRO_GENERATOR as au, getOriginPathname as av, LocalsReassigned as aw, generateCspDigest as ax, PrerenderClientAddressNotAvailable as ay, ClientAddressNotAvailable as az, appendForwardSlash as b, UnsupportedImageFormat as b0, IncompatibleDescriptorOptions as b1, UnsupportedImageConversion as b2, InvalidImageService as b3, ExpectedImageOptions as b4, ExpectedNotESMImage as b5, ImageMissingAlt as b6, FontFamilyNotFound as b7, unescapeHTML as b8, removeQueryString as b9, isParentDirectory as ba, defineScriptVars as bb, renderHead as bc, renderSlot as bd, InvalidComponentArgs as be, MissingSharp as bf, ResponseSentError as c, ActionNotFoundError as d, REDIRECT_STATUS_CODES as e, ActionsReturnedInvalidDataError as f, REROUTABLE_STATUS_CODES as g, isPropagatingHint as h, i18nNoLocaleFoundInPath as i, getPropagationHint as j, escapeHTML as k, bufferPropagatedHead as l, isHeadAndContent as m, isRenderTemplateResult as n, isPromise as o, pipelineSymbol as p, promiseWithResolvers as q, removeTrailingForwardSlash as r, shouldAppendForwardSlash as s, encoder as t, chunkToByteArray as u, chunkToString as v, chunkToByteArrayOrString as w, toAttributeString as x, markHTMLString as y, renderSlotToString as z };
|