astro 2.10.8 → 2.10.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/ViewTransitions.astro +30 -12
- package/dist/@types/astro.d.ts +68 -6
- package/dist/assets/{generate.d.ts → build/generate.d.ts} +2 -2
- package/dist/assets/build/generate.js +123 -0
- package/dist/assets/build/remote.d.ts +9 -0
- package/dist/assets/build/remote.js +42 -0
- package/dist/assets/image-endpoint.js +7 -8
- package/dist/assets/internal.d.ts +4 -2
- package/dist/assets/internal.js +23 -6
- package/dist/assets/services/service.d.ts +15 -8
- package/dist/assets/services/service.js +19 -10
- package/dist/assets/utils/remotePattern.d.ts +11 -0
- package/dist/assets/utils/remotePattern.js +46 -0
- package/dist/assets/utils/transformToPath.js +4 -5
- package/dist/assets/vite-plugin-assets.js +2 -6
- package/dist/core/app/index.js +21 -9
- package/dist/core/build/generate.js +4 -2
- package/dist/core/build/static-build.js +14 -4
- package/dist/core/config/schema.d.ts +104 -0
- package/dist/core/config/schema.js +20 -2
- package/dist/core/constants.js +1 -1
- package/dist/core/dev/container.js +5 -1
- package/dist/core/dev/dev.js +1 -1
- package/dist/core/errors/errors-data.js +1 -1
- package/dist/core/messages.js +2 -2
- package/dist/runtime/server/render/common.d.ts +1 -1
- package/dist/runtime/server/render/common.js +13 -15
- package/dist/runtime/server/render/component.d.ts +1 -1
- package/dist/runtime/server/render/component.js +2 -1
- package/dist/runtime/server/render/head.d.ts +1 -1
- package/dist/runtime/server/render/head.js +3 -2
- package/dist/runtime/server/render/index.d.ts +1 -1
- package/dist/runtime/server/render/instruction.d.ts +16 -0
- package/dist/runtime/server/render/instruction.js +13 -0
- package/dist/runtime/server/render/slot.d.ts +1 -1
- package/dist/vite-plugin-integrations-container/index.js +2 -2
- package/package.json +3 -1
- package/dist/assets/generate.js +0 -90
- package/dist/runtime/server/render/types.d.ts +0 -12
- package/dist/runtime/server/render/types.js +0 -0
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
function matchPattern(url, remotePattern) {
|
|
2
|
+
return matchProtocol(url, remotePattern.protocol) && matchHostname(url, remotePattern.hostname, true) && matchPort(url, remotePattern.port) && matchPathname(url, remotePattern.pathname, true);
|
|
3
|
+
}
|
|
4
|
+
function matchPort(url, port) {
|
|
5
|
+
return !port || port === url.port;
|
|
6
|
+
}
|
|
7
|
+
function matchProtocol(url, protocol) {
|
|
8
|
+
return !protocol || protocol === url.protocol.slice(0, -1);
|
|
9
|
+
}
|
|
10
|
+
function matchHostname(url, hostname, allowWildcard) {
|
|
11
|
+
if (!hostname) {
|
|
12
|
+
return true;
|
|
13
|
+
} else if (!allowWildcard || !hostname.startsWith("*")) {
|
|
14
|
+
return hostname === url.hostname;
|
|
15
|
+
} else if (hostname.startsWith("**.")) {
|
|
16
|
+
const slicedHostname = hostname.slice(2);
|
|
17
|
+
return slicedHostname !== url.hostname && url.hostname.endsWith(slicedHostname);
|
|
18
|
+
} else if (hostname.startsWith("*.")) {
|
|
19
|
+
const slicedHostname = hostname.slice(1);
|
|
20
|
+
const additionalSubdomains = url.hostname.replace(slicedHostname, "").split(".").filter(Boolean);
|
|
21
|
+
return additionalSubdomains.length === 1;
|
|
22
|
+
}
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
function matchPathname(url, pathname, allowWildcard) {
|
|
26
|
+
if (!pathname) {
|
|
27
|
+
return true;
|
|
28
|
+
} else if (!allowWildcard || !pathname.endsWith("*")) {
|
|
29
|
+
return pathname === url.pathname;
|
|
30
|
+
} else if (pathname.endsWith("/**")) {
|
|
31
|
+
const slicedPathname = pathname.slice(0, -2);
|
|
32
|
+
return slicedPathname !== url.pathname && url.pathname.startsWith(slicedPathname);
|
|
33
|
+
} else if (pathname.endsWith("/*")) {
|
|
34
|
+
const slicedPathname = pathname.slice(0, -1);
|
|
35
|
+
const additionalPathChunks = url.pathname.replace(slicedPathname, "").split("/").filter(Boolean);
|
|
36
|
+
return additionalPathChunks.length === 1;
|
|
37
|
+
}
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
export {
|
|
41
|
+
matchHostname,
|
|
42
|
+
matchPathname,
|
|
43
|
+
matchPattern,
|
|
44
|
+
matchPort,
|
|
45
|
+
matchProtocol
|
|
46
|
+
};
|
|
@@ -3,13 +3,12 @@ import { removeQueryString } from "../../core/path.js";
|
|
|
3
3
|
import { shorthash } from "../../runtime/server/shorthash.js";
|
|
4
4
|
import { isESMImportedImage } from "../internal.js";
|
|
5
5
|
function propsToFilename(transform, hash) {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
let filename = removeQueryString(transform.src.src);
|
|
6
|
+
let filename = removeQueryString(
|
|
7
|
+
isESMImportedImage(transform.src) ? transform.src.src : transform.src
|
|
8
|
+
);
|
|
10
9
|
const ext = extname(filename);
|
|
11
10
|
filename = basename(filename, ext);
|
|
12
|
-
|
|
11
|
+
let outputExt = transform.format ? `.${transform.format}` : ext;
|
|
13
12
|
return `/${filename}_${hash}${outputExt}`;
|
|
14
13
|
}
|
|
15
14
|
function hashTransform(transform, imageService) {
|
|
@@ -10,7 +10,6 @@ import {
|
|
|
10
10
|
removeQueryString
|
|
11
11
|
} from "../core/path.js";
|
|
12
12
|
import { VIRTUAL_MODULE_ID, VIRTUAL_SERVICE_ID } from "./consts.js";
|
|
13
|
-
import { isESMImportedImage } from "./internal.js";
|
|
14
13
|
import { emitESMImage } from "./utils/emitAsset.js";
|
|
15
14
|
import { hashTransform, propsToFilename } from "./utils/transformToPath.js";
|
|
16
15
|
const resolvedVirtualModuleId = "\0" + VIRTUAL_MODULE_ID;
|
|
@@ -73,8 +72,8 @@ function assets({
|
|
|
73
72
|
import { getImage as getImageInternal } from "astro/assets";
|
|
74
73
|
export { default as Image } from "astro/components/Image.astro";
|
|
75
74
|
|
|
76
|
-
export const
|
|
77
|
-
export const getImage = async (options) => await getImageInternal(options,
|
|
75
|
+
export const imageConfig = ${JSON.stringify(settings.config.image)};
|
|
76
|
+
export const getImage = async (options) => await getImageInternal(options, imageConfig);
|
|
78
77
|
`;
|
|
79
78
|
}
|
|
80
79
|
},
|
|
@@ -91,9 +90,6 @@ function assets({
|
|
|
91
90
|
if (globalThis.astroAsset.staticImages.has(hash)) {
|
|
92
91
|
filePath = globalThis.astroAsset.staticImages.get(hash).path;
|
|
93
92
|
} else {
|
|
94
|
-
if (!isESMImportedImage(options.src)) {
|
|
95
|
-
return options.src;
|
|
96
|
-
}
|
|
97
93
|
filePath = prependForwardSlash(
|
|
98
94
|
joinPaths(settings.config.build.assets, propsToFilename(options, hash))
|
|
99
95
|
);
|
package/dist/core/app/index.js
CHANGED
|
@@ -240,10 +240,15 @@ class App {
|
|
|
240
240
|
const errorRouteData = matchRoute("/" + status, this.#manifestData);
|
|
241
241
|
const url = new URL(request.url);
|
|
242
242
|
if (errorRouteData) {
|
|
243
|
-
if (errorRouteData.prerender
|
|
244
|
-
const
|
|
243
|
+
if (errorRouteData.prerender) {
|
|
244
|
+
const maybeDotHtml = errorRouteData.route.endsWith(`/${status}`) ? ".html" : "";
|
|
245
|
+
const statusURL = new URL(
|
|
246
|
+
`${this.#baseWithoutTrailingSlash}/${status}${maybeDotHtml}`,
|
|
247
|
+
url
|
|
248
|
+
);
|
|
245
249
|
const response2 = await fetch(statusURL.toString());
|
|
246
|
-
|
|
250
|
+
const override = { status };
|
|
251
|
+
return this.#mergeResponses(response2, originalResponse, override);
|
|
247
252
|
}
|
|
248
253
|
const mod = await this.#getModuleForRoute(errorRouteData);
|
|
249
254
|
try {
|
|
@@ -270,14 +275,21 @@ class App {
|
|
|
270
275
|
Reflect.set(response, responseSentSymbol, true);
|
|
271
276
|
return response;
|
|
272
277
|
}
|
|
273
|
-
#mergeResponses(newResponse, oldResponse) {
|
|
274
|
-
if (!oldResponse)
|
|
278
|
+
#mergeResponses(newResponse, oldResponse, override) {
|
|
279
|
+
if (!oldResponse) {
|
|
280
|
+
if (override !== void 0) {
|
|
281
|
+
return new Response(newResponse.body, {
|
|
282
|
+
status: override.status,
|
|
283
|
+
statusText: newResponse.statusText,
|
|
284
|
+
headers: newResponse.headers
|
|
285
|
+
});
|
|
286
|
+
}
|
|
275
287
|
return newResponse;
|
|
276
|
-
|
|
288
|
+
}
|
|
289
|
+
const { statusText, headers } = oldResponse;
|
|
290
|
+
const status = (override == null ? void 0 : override.status) ? override.status : oldResponse.status === 200 ? newResponse.status : oldResponse.status;
|
|
277
291
|
return new Response(newResponse.body, {
|
|
278
|
-
|
|
279
|
-
// Otherwise, the user set a specific status while rendering and we should respect that one
|
|
280
|
-
status: status === 200 ? newResponse.status : status,
|
|
292
|
+
status,
|
|
281
293
|
statusText: status === 200 ? newResponse.statusText : statusText,
|
|
282
294
|
headers: new Headers(Array.from(headers))
|
|
283
295
|
});
|
|
@@ -5,7 +5,7 @@ import { fileURLToPath } from "node:url";
|
|
|
5
5
|
import {
|
|
6
6
|
generateImage as generateImageInternal,
|
|
7
7
|
getStaticImageList
|
|
8
|
-
} from "../../assets/generate.js";
|
|
8
|
+
} from "../../assets/build/generate.js";
|
|
9
9
|
import {
|
|
10
10
|
eachPageDataFromEntryPoint,
|
|
11
11
|
eachRedirectPageData,
|
|
@@ -196,15 +196,17 @@ async function generatePage(opts, internals, pageData, ssrEntry, builtPaths, man
|
|
|
196
196
|
info(opts.logging, null, `${icon} ${pageData.route.component}`);
|
|
197
197
|
}
|
|
198
198
|
const paths = await getPathsForRoute(pageData, pageModule, opts, builtPaths);
|
|
199
|
+
let prevTimeEnd = timeStart;
|
|
199
200
|
for (let i = 0; i < paths.length; i++) {
|
|
200
201
|
const path = paths[i];
|
|
201
202
|
await generatePath(path, opts, generationOptions, manifest, onRequest);
|
|
202
203
|
const timeEnd = performance.now();
|
|
203
|
-
const timeChange = getTimeStat(
|
|
204
|
+
const timeChange = getTimeStat(prevTimeEnd, timeEnd);
|
|
204
205
|
const timeIncrease = `(+${timeChange})`;
|
|
205
206
|
const filePath = getOutputFilename(opts.settings.config, path, pageData.route.type);
|
|
206
207
|
const lineIcon = i === paths.length - 1 ? "\u2514\u2500" : "\u251C\u2500";
|
|
207
208
|
info(opts.logging, null, ` ${cyan(lineIcon)} ${dim(filePath)} ${dim(timeIncrease)}`);
|
|
209
|
+
prevTimeEnd = timeEnd;
|
|
208
210
|
}
|
|
209
211
|
}
|
|
210
212
|
async function getPathsForRoute(pageData, mod, opts, builtPaths) {
|
|
@@ -239,8 +239,12 @@ async function runPostBuildHooks(container, ssrReturn, clientReturn) {
|
|
|
239
239
|
async function cleanStaticOutput(opts, internals) {
|
|
240
240
|
const allStaticFiles = /* @__PURE__ */ new Set();
|
|
241
241
|
for (const pageData of eachPageData(internals)) {
|
|
242
|
-
if (pageData.route.prerender)
|
|
243
|
-
|
|
242
|
+
if (pageData.route.prerender) {
|
|
243
|
+
const { moduleSpecifier } = pageData;
|
|
244
|
+
const pageBundleId = internals.pageToBundleMap.get(moduleSpecifier);
|
|
245
|
+
const entryBundleId = internals.entrySpecifierToBundleMap.get(moduleSpecifier);
|
|
246
|
+
allStaticFiles.add(pageBundleId ?? entryBundleId);
|
|
247
|
+
}
|
|
244
248
|
}
|
|
245
249
|
const ssr = isServerLikeOutput(opts.settings.config);
|
|
246
250
|
const out = ssr ? opts.settings.config.build.server : getOutDirWithinCwd(opts.settings.config.outDir);
|
|
@@ -259,7 +263,11 @@ async function cleanStaticOutput(opts, internals) {
|
|
|
259
263
|
const [, exports] = eslexer.parse(text);
|
|
260
264
|
let value = "const noop = () => {};";
|
|
261
265
|
for (const e of exports) {
|
|
262
|
-
|
|
266
|
+
if (e.n === "default")
|
|
267
|
+
value += `
|
|
268
|
+
export default noop;`;
|
|
269
|
+
else
|
|
270
|
+
value += `
|
|
263
271
|
export const ${e.n} = noop;`;
|
|
264
272
|
}
|
|
265
273
|
await fs.promises.writeFile(url, value, { encoding: "utf8" });
|
|
@@ -271,7 +279,9 @@ export const ${e.n} = noop;`;
|
|
|
271
279
|
async function cleanServerOutput(opts) {
|
|
272
280
|
const out = getOutDirWithinCwd(opts.settings.config.outDir);
|
|
273
281
|
const files = await glob("**/*.mjs", {
|
|
274
|
-
cwd: fileURLToPath(out)
|
|
282
|
+
cwd: fileURLToPath(out),
|
|
283
|
+
// Important! Also cleanup dotfiles like `node_modules/.pnpm/**`
|
|
284
|
+
dot: true
|
|
275
285
|
});
|
|
276
286
|
if (files.length) {
|
|
277
287
|
await Promise.all(
|
|
@@ -116,12 +116,43 @@ export declare const AstroConfigSchema: z.ZodObject<{
|
|
|
116
116
|
config?: Record<string, any> | undefined;
|
|
117
117
|
entrypoint: string;
|
|
118
118
|
}>;
|
|
119
|
+
domains: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
120
|
+
remotePatterns: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
121
|
+
protocol: z.ZodOptional<z.ZodString>;
|
|
122
|
+
hostname: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
123
|
+
port: z.ZodOptional<z.ZodString>;
|
|
124
|
+
pathname: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
125
|
+
}, "strip", z.ZodTypeAny, {
|
|
126
|
+
port?: string | undefined;
|
|
127
|
+
protocol?: string | undefined;
|
|
128
|
+
hostname?: string | undefined;
|
|
129
|
+
pathname?: string | undefined;
|
|
130
|
+
}, {
|
|
131
|
+
port?: string | undefined;
|
|
132
|
+
protocol?: string | undefined;
|
|
133
|
+
hostname?: string | undefined;
|
|
134
|
+
pathname?: string | undefined;
|
|
135
|
+
}>, "many">>;
|
|
119
136
|
}, "strip", z.ZodTypeAny, {
|
|
120
137
|
service: {
|
|
121
138
|
entrypoint: string;
|
|
122
139
|
config: Record<string, any>;
|
|
123
140
|
};
|
|
141
|
+
domains: string[];
|
|
142
|
+
remotePatterns: {
|
|
143
|
+
port?: string | undefined;
|
|
144
|
+
protocol?: string | undefined;
|
|
145
|
+
hostname?: string | undefined;
|
|
146
|
+
pathname?: string | undefined;
|
|
147
|
+
}[];
|
|
124
148
|
}, {
|
|
149
|
+
domains?: string[] | undefined;
|
|
150
|
+
remotePatterns?: {
|
|
151
|
+
port?: string | undefined;
|
|
152
|
+
protocol?: string | undefined;
|
|
153
|
+
hostname?: string | undefined;
|
|
154
|
+
pathname?: string | undefined;
|
|
155
|
+
}[] | undefined;
|
|
125
156
|
service: {
|
|
126
157
|
config?: Record<string, any> | undefined;
|
|
127
158
|
entrypoint: string;
|
|
@@ -245,6 +276,13 @@ export declare const AstroConfigSchema: z.ZodObject<{
|
|
|
245
276
|
entrypoint: string;
|
|
246
277
|
config: Record<string, any>;
|
|
247
278
|
};
|
|
279
|
+
domains: string[];
|
|
280
|
+
remotePatterns: {
|
|
281
|
+
port?: string | undefined;
|
|
282
|
+
protocol?: string | undefined;
|
|
283
|
+
hostname?: string | undefined;
|
|
284
|
+
pathname?: string | undefined;
|
|
285
|
+
}[];
|
|
248
286
|
};
|
|
249
287
|
markdown: {
|
|
250
288
|
drafts: boolean;
|
|
@@ -302,6 +340,13 @@ export declare const AstroConfigSchema: z.ZodObject<{
|
|
|
302
340
|
assetsPrefix?: string | undefined;
|
|
303
341
|
} | undefined;
|
|
304
342
|
image?: {
|
|
343
|
+
domains?: string[] | undefined;
|
|
344
|
+
remotePatterns?: {
|
|
345
|
+
port?: string | undefined;
|
|
346
|
+
protocol?: string | undefined;
|
|
347
|
+
hostname?: string | undefined;
|
|
348
|
+
pathname?: string | undefined;
|
|
349
|
+
}[] | undefined;
|
|
305
350
|
service: {
|
|
306
351
|
config?: Record<string, any> | undefined;
|
|
307
352
|
entrypoint: string;
|
|
@@ -380,12 +425,43 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
|
|
|
380
425
|
config?: Record<string, any> | undefined;
|
|
381
426
|
entrypoint: string;
|
|
382
427
|
}>;
|
|
428
|
+
domains: z.ZodDefault<z.ZodArray<z.ZodString, "many">>;
|
|
429
|
+
remotePatterns: z.ZodDefault<z.ZodArray<z.ZodObject<{
|
|
430
|
+
protocol: z.ZodOptional<z.ZodString>;
|
|
431
|
+
hostname: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
432
|
+
port: z.ZodOptional<z.ZodString>;
|
|
433
|
+
pathname: z.ZodOptional<z.ZodEffects<z.ZodString, string, string>>;
|
|
434
|
+
}, "strip", z.ZodTypeAny, {
|
|
435
|
+
port?: string | undefined;
|
|
436
|
+
protocol?: string | undefined;
|
|
437
|
+
hostname?: string | undefined;
|
|
438
|
+
pathname?: string | undefined;
|
|
439
|
+
}, {
|
|
440
|
+
port?: string | undefined;
|
|
441
|
+
protocol?: string | undefined;
|
|
442
|
+
hostname?: string | undefined;
|
|
443
|
+
pathname?: string | undefined;
|
|
444
|
+
}>, "many">>;
|
|
383
445
|
}, "strip", z.ZodTypeAny, {
|
|
384
446
|
service: {
|
|
385
447
|
entrypoint: string;
|
|
386
448
|
config: Record<string, any>;
|
|
387
449
|
};
|
|
450
|
+
domains: string[];
|
|
451
|
+
remotePatterns: {
|
|
452
|
+
port?: string | undefined;
|
|
453
|
+
protocol?: string | undefined;
|
|
454
|
+
hostname?: string | undefined;
|
|
455
|
+
pathname?: string | undefined;
|
|
456
|
+
}[];
|
|
388
457
|
}, {
|
|
458
|
+
domains?: string[] | undefined;
|
|
459
|
+
remotePatterns?: {
|
|
460
|
+
port?: string | undefined;
|
|
461
|
+
protocol?: string | undefined;
|
|
462
|
+
hostname?: string | undefined;
|
|
463
|
+
pathname?: string | undefined;
|
|
464
|
+
}[] | undefined;
|
|
389
465
|
service: {
|
|
390
466
|
config?: Record<string, any> | undefined;
|
|
391
467
|
entrypoint: string;
|
|
@@ -575,6 +651,13 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
|
|
|
575
651
|
entrypoint: string;
|
|
576
652
|
config: Record<string, any>;
|
|
577
653
|
};
|
|
654
|
+
domains: string[];
|
|
655
|
+
remotePatterns: {
|
|
656
|
+
port?: string | undefined;
|
|
657
|
+
protocol?: string | undefined;
|
|
658
|
+
hostname?: string | undefined;
|
|
659
|
+
pathname?: string | undefined;
|
|
660
|
+
}[];
|
|
578
661
|
};
|
|
579
662
|
markdown: {
|
|
580
663
|
drafts: boolean;
|
|
@@ -632,6 +715,13 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
|
|
|
632
715
|
assetsPrefix?: string | undefined;
|
|
633
716
|
} | undefined;
|
|
634
717
|
image?: {
|
|
718
|
+
domains?: string[] | undefined;
|
|
719
|
+
remotePatterns?: {
|
|
720
|
+
port?: string | undefined;
|
|
721
|
+
protocol?: string | undefined;
|
|
722
|
+
hostname?: string | undefined;
|
|
723
|
+
pathname?: string | undefined;
|
|
724
|
+
}[] | undefined;
|
|
635
725
|
service: {
|
|
636
726
|
config?: Record<string, any> | undefined;
|
|
637
727
|
entrypoint: string;
|
|
@@ -706,6 +796,13 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
|
|
|
706
796
|
entrypoint: string;
|
|
707
797
|
config: Record<string, any>;
|
|
708
798
|
};
|
|
799
|
+
domains: string[];
|
|
800
|
+
remotePatterns: {
|
|
801
|
+
port?: string | undefined;
|
|
802
|
+
protocol?: string | undefined;
|
|
803
|
+
hostname?: string | undefined;
|
|
804
|
+
pathname?: string | undefined;
|
|
805
|
+
}[];
|
|
709
806
|
};
|
|
710
807
|
markdown: {
|
|
711
808
|
drafts: boolean;
|
|
@@ -763,6 +860,13 @@ export declare function createRelativeSchema(cmd: string, fileProtocolRoot: stri
|
|
|
763
860
|
assetsPrefix?: string | undefined;
|
|
764
861
|
} | undefined;
|
|
765
862
|
image?: {
|
|
863
|
+
domains?: string[] | undefined;
|
|
864
|
+
remotePatterns?: {
|
|
865
|
+
port?: string | undefined;
|
|
866
|
+
protocol?: string | undefined;
|
|
867
|
+
hostname?: string | undefined;
|
|
868
|
+
pathname?: string | undefined;
|
|
869
|
+
}[] | undefined;
|
|
766
870
|
service: {
|
|
767
871
|
config?: Record<string, any> | undefined;
|
|
768
872
|
entrypoint: string;
|
|
@@ -113,9 +113,27 @@ const AstroConfigSchema = z.object({
|
|
|
113
113
|
z.string()
|
|
114
114
|
]),
|
|
115
115
|
config: z.record(z.any()).default({})
|
|
116
|
-
})
|
|
116
|
+
}),
|
|
117
|
+
domains: z.array(z.string()).default([]),
|
|
118
|
+
remotePatterns: z.array(
|
|
119
|
+
z.object({
|
|
120
|
+
protocol: z.string().optional(),
|
|
121
|
+
hostname: z.string().refine(
|
|
122
|
+
(val) => !val.includes("*") || val.startsWith("*.") || val.startsWith("**."),
|
|
123
|
+
{
|
|
124
|
+
message: "wildcards can only be placed at the beginning of the hostname"
|
|
125
|
+
}
|
|
126
|
+
).optional(),
|
|
127
|
+
port: z.string().optional(),
|
|
128
|
+
pathname: z.string().refine((val) => !val.includes("*") || val.endsWith("/*") || val.endsWith("/**"), {
|
|
129
|
+
message: "wildcards can only be placed at the end of a pathname"
|
|
130
|
+
}).optional()
|
|
131
|
+
})
|
|
132
|
+
).default([])
|
|
117
133
|
}).default({
|
|
118
|
-
service: { entrypoint: "astro/assets/services/squoosh", config: {} }
|
|
134
|
+
service: { entrypoint: "astro/assets/services/squoosh", config: {} },
|
|
135
|
+
domains: [],
|
|
136
|
+
remotePatterns: []
|
|
119
137
|
}),
|
|
120
138
|
markdown: z.object({
|
|
121
139
|
drafts: z.boolean().default(false),
|
package/dist/core/constants.js
CHANGED
|
@@ -26,7 +26,11 @@ async function createContainer({
|
|
|
26
26
|
if (settings.config.experimental.assets) {
|
|
27
27
|
settings = injectImageEndpoint(settings);
|
|
28
28
|
}
|
|
29
|
-
const {
|
|
29
|
+
const {
|
|
30
|
+
base,
|
|
31
|
+
server: { host, headers, open: shouldOpen }
|
|
32
|
+
} = settings.config;
|
|
33
|
+
const open = shouldOpen ? base : false;
|
|
30
34
|
const rendererClientEntries = settings.renderers.map((r) => r.clientEntrypoint).filter(Boolean);
|
|
31
35
|
const viteConfig = await createVite(
|
|
32
36
|
{
|
package/dist/core/dev/dev.js
CHANGED
|
@@ -23,7 +23,7 @@ async function dev(inlineConfig) {
|
|
|
23
23
|
base: restart.container.settings.config.base
|
|
24
24
|
})
|
|
25
25
|
);
|
|
26
|
-
const currentVersion = "2.10.
|
|
26
|
+
const currentVersion = "2.10.10";
|
|
27
27
|
if (currentVersion.includes("-")) {
|
|
28
28
|
warn(logging, null, msg.prerelease({ currentVersion }));
|
|
29
29
|
}
|
|
@@ -102,7 +102,7 @@ const GetStaticPathsRequired = {
|
|
|
102
102
|
message: "`getStaticPaths()` function is required for dynamic routes. Make sure that you `export` a `getStaticPaths` function from your dynamic route.",
|
|
103
103
|
hint: `See https://docs.astro.build/en/core-concepts/routing/#dynamic-routes for more information on dynamic routes.
|
|
104
104
|
|
|
105
|
-
Alternatively, set \`output: "server"\` in your Astro config file to switch to a non-static server build. This error can also occur if using \`export const prerender = true;\`.
|
|
105
|
+
Alternatively, set \`output: "server"\` or \`output: "hybrid"\` in your Astro config file to switch to a non-static server build. This error can also occur if using \`export const prerender = true;\`.
|
|
106
106
|
See https://docs.astro.build/en/guides/server-side-rendering/ for more information on non-static rendering.`
|
|
107
107
|
};
|
|
108
108
|
const ReservedSlotName = {
|
package/dist/core/messages.js
CHANGED
|
@@ -47,7 +47,7 @@ function serverStart({
|
|
|
47
47
|
base,
|
|
48
48
|
isRestart = false
|
|
49
49
|
}) {
|
|
50
|
-
const version = "2.10.
|
|
50
|
+
const version = "2.10.10";
|
|
51
51
|
const localPrefix = `${dim("\u2503")} Local `;
|
|
52
52
|
const networkPrefix = `${dim("\u2503")} Network `;
|
|
53
53
|
const emptyPrefix = " ".repeat(11);
|
|
@@ -233,7 +233,7 @@ function printHelp({
|
|
|
233
233
|
message.push(
|
|
234
234
|
linebreak(),
|
|
235
235
|
` ${bgGreen(black(` ${commandName} `))} ${green(
|
|
236
|
-
`v${"2.10.
|
|
236
|
+
`v${"2.10.10"}`
|
|
237
237
|
)} ${headline}`
|
|
238
238
|
);
|
|
239
239
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { SSRResult } from '../../../@types/astro';
|
|
2
|
-
import type { RenderInstruction } from './
|
|
2
|
+
import type { RenderInstruction } from './instruction.js';
|
|
3
3
|
import { HTMLBytes, HTMLString } from '../escape.js';
|
|
4
4
|
import { type SlotString } from './slot.js';
|
|
5
5
|
/**
|
|
@@ -5,13 +5,14 @@ import {
|
|
|
5
5
|
getPrescripts
|
|
6
6
|
} from "../scripts.js";
|
|
7
7
|
import { renderAllHeadContent } from "./head.js";
|
|
8
|
+
import { isRenderInstruction } from "./instruction.js";
|
|
8
9
|
import { isSlotString } from "./slot.js";
|
|
9
10
|
const Fragment = Symbol.for("astro:fragment");
|
|
10
11
|
const Renderer = Symbol.for("astro:renderer");
|
|
11
12
|
const encoder = new TextEncoder();
|
|
12
13
|
const decoder = new TextDecoder();
|
|
13
14
|
function stringifyChunk(result, chunk) {
|
|
14
|
-
if (
|
|
15
|
+
if (isRenderInstruction(chunk)) {
|
|
15
16
|
const instruction = chunk;
|
|
16
17
|
switch (instruction.type) {
|
|
17
18
|
case "directive": {
|
|
@@ -39,26 +40,23 @@ function stringifyChunk(result, chunk) {
|
|
|
39
40
|
return renderAllHeadContent(result);
|
|
40
41
|
}
|
|
41
42
|
default: {
|
|
42
|
-
if (chunk instanceof Response) {
|
|
43
|
-
return "";
|
|
44
|
-
}
|
|
45
43
|
throw new Error(`Unknown chunk type: ${chunk.type}`);
|
|
46
44
|
}
|
|
47
45
|
}
|
|
48
|
-
} else {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
46
|
+
} else if (chunk instanceof Response) {
|
|
47
|
+
return "";
|
|
48
|
+
} else if (isSlotString(chunk)) {
|
|
49
|
+
let out = "";
|
|
50
|
+
const c = chunk;
|
|
51
|
+
if (c.instructions) {
|
|
52
|
+
for (const instr of c.instructions) {
|
|
53
|
+
out += stringifyChunk(result, instr);
|
|
56
54
|
}
|
|
57
|
-
out += chunk.toString();
|
|
58
|
-
return out;
|
|
59
55
|
}
|
|
60
|
-
|
|
56
|
+
out += chunk.toString();
|
|
57
|
+
return out;
|
|
61
58
|
}
|
|
59
|
+
return chunk.toString();
|
|
62
60
|
}
|
|
63
61
|
function chunkToString(result, chunk) {
|
|
64
62
|
if (ArrayBuffer.isView(chunk)) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { RouteData, SSRResult } from '../../../@types/astro';
|
|
2
|
-
import type
|
|
2
|
+
import { type RenderInstruction } from './instruction.js';
|
|
3
3
|
import { HTMLBytes } from '../escape.js';
|
|
4
4
|
import { type RenderInstance } from './common.js';
|
|
5
5
|
declare const needsHeadRenderingSymbol: unique symbol;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { createRenderInstruction } from "./instruction.js";
|
|
1
2
|
import { AstroError, AstroErrorData } from "../../../core/errors/index.js";
|
|
2
3
|
import { markHTMLString } from "../escape.js";
|
|
3
4
|
import { extractDirectives, generateHydrateScript } from "../hydration.js";
|
|
@@ -288,7 +289,7 @@ ${serializeProps(
|
|
|
288
289
|
destination.write(instruction);
|
|
289
290
|
}
|
|
290
291
|
}
|
|
291
|
-
destination.write({ type: "directive", hydration });
|
|
292
|
+
destination.write(createRenderInstruction({ type: "directive", hydration }));
|
|
292
293
|
destination.write(markHTMLString(renderElement("astro-island", island, false)));
|
|
293
294
|
}
|
|
294
295
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { SSRResult } from '../../../@types/astro';
|
|
2
|
-
import type { MaybeRenderHeadInstruction, RenderHeadInstruction } from './
|
|
2
|
+
import type { MaybeRenderHeadInstruction, RenderHeadInstruction } from './instruction.js';
|
|
3
3
|
export declare function renderAllHeadContent(result: SSRResult): any;
|
|
4
4
|
export declare function renderHead(): Generator<RenderHeadInstruction>;
|
|
5
5
|
export declare function maybeRenderHead(): Generator<MaybeRenderHeadInstruction>;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { markHTMLString } from "../escape.js";
|
|
2
|
+
import { createRenderInstruction } from "./instruction.js";
|
|
2
3
|
import { renderElement } from "./util.js";
|
|
3
4
|
const uniqueElements = (item, index, all) => {
|
|
4
5
|
const props = JSON.stringify(item.props);
|
|
@@ -24,10 +25,10 @@ function renderAllHeadContent(result) {
|
|
|
24
25
|
return markHTMLString(content);
|
|
25
26
|
}
|
|
26
27
|
function* renderHead() {
|
|
27
|
-
yield { type: "head" };
|
|
28
|
+
yield createRenderInstruction({ type: "head" });
|
|
28
29
|
}
|
|
29
30
|
function* maybeRenderHead() {
|
|
30
|
-
yield { type: "maybe-head" };
|
|
31
|
+
yield createRenderInstruction({ type: "maybe-head" });
|
|
31
32
|
}
|
|
32
33
|
export {
|
|
33
34
|
maybeRenderHead,
|
|
@@ -4,8 +4,8 @@ export { Fragment, Renderer, chunkToByteArray, chunkToString } from './common.js
|
|
|
4
4
|
export { renderComponent, renderComponentToString } from './component.js';
|
|
5
5
|
export { renderHTMLElement } from './dom.js';
|
|
6
6
|
export { maybeRenderHead, renderHead } from './head.js';
|
|
7
|
+
export type { RenderInstruction } from './instruction';
|
|
7
8
|
export { renderPage } from './page.js';
|
|
8
9
|
export { renderSlot, renderSlotToString, type ComponentSlots } from './slot.js';
|
|
9
10
|
export { renderScriptElement, renderUniqueStylesheet } from './tags.js';
|
|
10
|
-
export type { RenderInstruction } from './types';
|
|
11
11
|
export { addAttribute, defineScriptVars, voidElementNames } from './util.js';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { HydrationMetadata } from '../hydration.js';
|
|
2
|
+
export type RenderDirectiveInstruction = {
|
|
3
|
+
type: 'directive';
|
|
4
|
+
hydration: HydrationMetadata;
|
|
5
|
+
};
|
|
6
|
+
export type RenderHeadInstruction = {
|
|
7
|
+
type: 'head';
|
|
8
|
+
};
|
|
9
|
+
export type MaybeRenderHeadInstruction = {
|
|
10
|
+
type: 'maybe-head';
|
|
11
|
+
};
|
|
12
|
+
export type RenderInstruction = RenderDirectiveInstruction | RenderHeadInstruction | MaybeRenderHeadInstruction;
|
|
13
|
+
export declare function createRenderInstruction(instruction: RenderDirectiveInstruction): RenderDirectiveInstruction;
|
|
14
|
+
export declare function createRenderInstruction(instruction: RenderHeadInstruction): RenderHeadInstruction;
|
|
15
|
+
export declare function createRenderInstruction(instruction: MaybeRenderHeadInstruction): MaybeRenderHeadInstruction;
|
|
16
|
+
export declare function isRenderInstruction(chunk: any): chunk is RenderInstruction;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
const RenderInstructionSymbol = Symbol.for("astro:render");
|
|
2
|
+
function createRenderInstruction(instruction) {
|
|
3
|
+
return Object.defineProperty(instruction, RenderInstructionSymbol, {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
}
|
|
7
|
+
function isRenderInstruction(chunk) {
|
|
8
|
+
return chunk && typeof chunk === "object" && chunk[RenderInstructionSymbol];
|
|
9
|
+
}
|
|
10
|
+
export {
|
|
11
|
+
createRenderInstruction,
|
|
12
|
+
isRenderInstruction
|
|
13
|
+
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { SSRResult } from '../../../@types/astro.js';
|
|
2
2
|
import type { renderTemplate } from './astro/render-template.js';
|
|
3
|
-
import type { RenderInstruction } from './
|
|
3
|
+
import type { RenderInstruction } from './instruction.js';
|
|
4
4
|
import { HTMLString } from '../escape.js';
|
|
5
5
|
import { type RenderInstance } from './common.js';
|
|
6
6
|
type RenderTemplateResult = ReturnType<typeof renderTemplate>;
|
|
@@ -6,10 +6,10 @@ function astroIntegrationsContainerPlugin({
|
|
|
6
6
|
}) {
|
|
7
7
|
return {
|
|
8
8
|
name: "astro:integration-container",
|
|
9
|
-
configureServer(server) {
|
|
9
|
+
async configureServer(server) {
|
|
10
10
|
if (server.config.isProduction)
|
|
11
11
|
return;
|
|
12
|
-
runHookServerSetup({ config: settings.config, server, logging });
|
|
12
|
+
await runHookServerSetup({ config: settings.config, server, logging });
|
|
13
13
|
},
|
|
14
14
|
async buildStart() {
|
|
15
15
|
if (settings.injectedRoutes.length === settings.resolvedInjectedRoutes.length)
|