astro 4.0.5 → 4.0.7
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/Picture.astro +1 -1
- package/components/ViewTransitions.astro +1 -1
- package/dist/@types/astro.d.ts +1 -1
- package/dist/assets/build/generate.js +24 -9
- package/dist/assets/endpoint/config.d.ts +2 -0
- package/dist/assets/endpoint/config.js +12 -0
- package/dist/assets/endpoint/generic.js +3 -1
- package/dist/assets/endpoint/node.js +3 -1
- package/dist/assets/internal.d.ts +2 -6
- package/dist/assets/internal.js +2 -31
- package/dist/assets/services/service.js +2 -1
- package/dist/assets/utils/imageKind.d.ts +3 -0
- package/dist/assets/utils/imageKind.js +10 -0
- package/dist/assets/utils/index.d.ts +2 -0
- package/dist/assets/utils/index.js +17 -0
- package/dist/assets/utils/remotePattern.d.ts +2 -0
- package/dist/assets/utils/remotePattern.js +11 -0
- package/dist/assets/utils/transformToPath.js +1 -1
- package/dist/assets/vite-plugin-assets.js +1 -1
- package/dist/cli/add/index.js +1 -1
- package/dist/core/app/index.js +19 -7
- package/dist/core/build/generate.js +5 -4
- package/dist/core/build/index.js +1 -1
- package/dist/core/build/plugins/plugin-manifest.js +2 -1
- package/dist/core/build/static-build.js +5 -2
- package/dist/core/config/schema.d.ts +360 -360
- package/dist/core/constants.js +1 -1
- package/dist/core/dev/container.js +1 -1
- package/dist/core/dev/dev.js +1 -1
- package/dist/core/errors/errors-data.d.ts +34 -0
- package/dist/core/errors/errors-data.js +15 -2
- package/dist/core/logger/core.d.ts +8 -7
- package/dist/core/logger/core.js +15 -14
- package/dist/core/logger/node.js +4 -3
- package/dist/core/messages.js +2 -2
- package/dist/core/middleware/loadMiddleware.d.ts +1 -1
- package/dist/core/middleware/loadMiddleware.js +6 -4
- package/dist/core/redirects/helpers.js +7 -1
- package/dist/core/routing/manifest/create.js +1 -1
- package/dist/runtime/client/dev-overlay/plugins/audit/a11y.js +14 -8
- package/dist/transitions/router.js +11 -7
- package/dist/vite-plugin-astro-server/request.js +0 -4
- package/dist/vite-plugin-dev-overlay/vite-plugin-dev-overlay.js +1 -1
- package/package.json +4 -4
package/components/Picture.astro
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
import { getImage, type LocalImageProps, type RemoteImageProps } from 'astro:assets';
|
|
3
3
|
import type { GetImageResult, ImageOutputFormat } from '../dist/@types/astro';
|
|
4
|
-
import { isESMImportedImage } from '../dist/assets/
|
|
4
|
+
import { isESMImportedImage } from '../dist/assets/utils/imageKind';
|
|
5
5
|
import { AstroError, AstroErrorData } from '../dist/core/errors/index.js';
|
|
6
6
|
import type { HTMLAttributes } from '../types';
|
|
7
7
|
|
|
@@ -94,7 +94,7 @@ const { fallback = 'animate' } = Astro.props;
|
|
|
94
94
|
|
|
95
95
|
document.addEventListener('submit', (ev) => {
|
|
96
96
|
let el = ev.target as HTMLElement;
|
|
97
|
-
if (el.tagName !== 'FORM' || isReloadEl(el)) {
|
|
97
|
+
if (el.tagName !== 'FORM' || ev.defaultPrevented || isReloadEl(el)) {
|
|
98
98
|
return;
|
|
99
99
|
}
|
|
100
100
|
const form = el as HTMLFormElement;
|
package/dist/@types/astro.d.ts
CHANGED
|
@@ -589,7 +589,7 @@ export interface AstroUserConfig {
|
|
|
589
589
|
* [See our Server-side Rendering guide](https://docs.astro.build/en/guides/server-side-rendering/) for more on SSR, and [our deployment guides](https://docs.astro.build/en/guides/deploy/) for a complete list of hosts.
|
|
590
590
|
*
|
|
591
591
|
* ```js
|
|
592
|
-
* import netlify from '@astrojs/netlify
|
|
592
|
+
* import netlify from '@astrojs/netlify';
|
|
593
593
|
* {
|
|
594
594
|
* // Example: Build for Netlify serverless deployment
|
|
595
595
|
* adapter: netlify(),
|
|
@@ -3,9 +3,12 @@ import fs, { readFileSync } from "node:fs";
|
|
|
3
3
|
import { basename, join } from "node:path/posix";
|
|
4
4
|
import { getOutDirWithinCwd } from "../../core/build/common.js";
|
|
5
5
|
import { getTimeStat } from "../../core/build/util.js";
|
|
6
|
+
import { AstroError } from "../../core/errors/errors.js";
|
|
7
|
+
import { AstroErrorData } from "../../core/errors/index.js";
|
|
6
8
|
import { isRemotePath, prependForwardSlash } from "../../core/path.js";
|
|
7
9
|
import { isServerLikeOutput } from "../../prerender/utils.js";
|
|
8
|
-
import { getConfiguredImageService
|
|
10
|
+
import { getConfiguredImageService } from "../internal.js";
|
|
11
|
+
import { isESMImportedImage } from "../utils/imageKind.js";
|
|
9
12
|
import { loadRemoteImage } from "./remote.js";
|
|
10
13
|
async function prepareAssetsGenerationEnv(pipeline, totalCount) {
|
|
11
14
|
const config = pipeline.getConfig();
|
|
@@ -51,9 +54,9 @@ function getFullImagePath(originalFilePath, env) {
|
|
|
51
54
|
async function generateImagesForPath(originalFilePath, transformsAndPath, env, queue) {
|
|
52
55
|
const originalImageData = await loadImage(originalFilePath, env);
|
|
53
56
|
for (const [_, transform] of transformsAndPath.transforms) {
|
|
54
|
-
queue.add(
|
|
55
|
-
|
|
56
|
-
);
|
|
57
|
+
await queue.add(async () => generateImage(originalImageData, transform.finalPath, transform.transform)).catch((e) => {
|
|
58
|
+
throw e;
|
|
59
|
+
});
|
|
57
60
|
}
|
|
58
61
|
if (!env.isSSR && !isRemotePath(originalFilePath) && !globalThis.astroAsset.referencedImages?.has(transformsAndPath.originalSrcPath)) {
|
|
59
62
|
try {
|
|
@@ -116,11 +119,23 @@ async function generateImagesForPath(originalFilePath, transformsAndPath, env, q
|
|
|
116
119
|
expires: originalImage.expires
|
|
117
120
|
};
|
|
118
121
|
const imageService = await getConfiguredImageService();
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
122
|
+
try {
|
|
123
|
+
resultData.data = (await imageService.transform(
|
|
124
|
+
originalImage.data,
|
|
125
|
+
{ ...options, src: originalImagePath },
|
|
126
|
+
env.imageConfig
|
|
127
|
+
)).data;
|
|
128
|
+
} catch (e) {
|
|
129
|
+
const error = new AstroError(
|
|
130
|
+
{
|
|
131
|
+
...AstroErrorData.CouldNotTransformImage,
|
|
132
|
+
message: AstroErrorData.CouldNotTransformImage.message(originalFilePath)
|
|
133
|
+
},
|
|
134
|
+
void 0,
|
|
135
|
+
{ cause: e }
|
|
136
|
+
);
|
|
137
|
+
throw error;
|
|
138
|
+
}
|
|
124
139
|
try {
|
|
125
140
|
if (env.useCache) {
|
|
126
141
|
if (isLocalImage) {
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
function injectImageEndpoint(settings, mode) {
|
|
2
|
+
const endpointEntrypoint = settings.config.image.endpoint ?? (mode === "dev" ? "astro/assets/endpoint/node" : "astro/assets/endpoint/generic");
|
|
3
|
+
settings.injectedRoutes.push({
|
|
4
|
+
pattern: "/_image",
|
|
5
|
+
entrypoint: endpointEntrypoint,
|
|
6
|
+
prerender: false
|
|
7
|
+
});
|
|
8
|
+
return settings;
|
|
9
|
+
}
|
|
10
|
+
export {
|
|
11
|
+
injectImageEndpoint
|
|
12
|
+
};
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { isRemotePath } from "@astrojs/internal-helpers/path";
|
|
2
2
|
import mime from "mime/lite.js";
|
|
3
|
-
import { getConfiguredImageService
|
|
3
|
+
import { getConfiguredImageService } from "../internal.js";
|
|
4
4
|
import { etag } from "../utils/etag.js";
|
|
5
5
|
import { imageConfig } from "astro:assets";
|
|
6
|
+
import { isRemoteAllowed } from "../utils/remotePattern.js";
|
|
6
7
|
async function loadRemoteImage(src) {
|
|
7
8
|
try {
|
|
8
9
|
const res = await fetch(src);
|
|
@@ -49,6 +50,7 @@ const GET = async ({ request }) => {
|
|
|
49
50
|
}
|
|
50
51
|
});
|
|
51
52
|
} catch (err) {
|
|
53
|
+
console.error("Could not process image request:", err);
|
|
52
54
|
return new Response(`Server Error: ${err}`, { status: 500 });
|
|
53
55
|
}
|
|
54
56
|
};
|
|
@@ -2,9 +2,10 @@ import { isRemotePath, removeQueryString } from "@astrojs/internal-helpers/path"
|
|
|
2
2
|
import { readFile } from "fs/promises";
|
|
3
3
|
import mime from "mime/lite.js";
|
|
4
4
|
import os from "os";
|
|
5
|
-
import { getConfiguredImageService
|
|
5
|
+
import { getConfiguredImageService } from "../internal.js";
|
|
6
6
|
import { etag } from "../utils/etag.js";
|
|
7
7
|
import { assetsDir, imageConfig } from "astro:assets";
|
|
8
|
+
import { isRemoteAllowed } from "../utils/remotePattern.js";
|
|
8
9
|
function replaceFileSystemReferences(src) {
|
|
9
10
|
return os.platform().includes("win32") ? src.replace(/^\/@fs\//, "") : src.replace(/^\/@fs/, "");
|
|
10
11
|
}
|
|
@@ -64,6 +65,7 @@ const GET = async ({ request }) => {
|
|
|
64
65
|
}
|
|
65
66
|
});
|
|
66
67
|
} catch (err) {
|
|
68
|
+
console.error("Could not process image request:", err);
|
|
67
69
|
return new Response(`Server Error: ${err}`, { status: 500 });
|
|
68
70
|
}
|
|
69
71
|
};
|
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
import type { AstroConfig
|
|
1
|
+
import type { AstroConfig } from '../@types/astro.js';
|
|
2
2
|
import { type ImageService } from './services/service.js';
|
|
3
|
-
import type { GetImageResult,
|
|
4
|
-
export declare function injectImageEndpoint(settings: AstroSettings, mode: 'dev' | 'build'): AstroSettings;
|
|
5
|
-
export declare function isESMImportedImage(src: ImageMetadata | string): src is ImageMetadata;
|
|
6
|
-
export declare function isRemoteImage(src: ImageMetadata | string): src is string;
|
|
7
|
-
export declare function isRemoteAllowed(src: string, { domains, remotePatterns, }: Partial<Pick<AstroConfig['image'], 'domains' | 'remotePatterns'>>): boolean;
|
|
3
|
+
import type { GetImageResult, UnresolvedImageTransform } from './types.js';
|
|
8
4
|
export declare function getConfiguredImageService(): Promise<ImageService>;
|
|
9
5
|
export declare function getImage(options: UnresolvedImageTransform, imageConfig: AstroConfig['image']): Promise<GetImageResult>;
|
package/dist/assets/internal.js
CHANGED
|
@@ -1,32 +1,7 @@
|
|
|
1
|
-
import { isRemotePath } from "@astrojs/internal-helpers/path";
|
|
2
1
|
import { AstroError, AstroErrorData } from "../core/errors/index.js";
|
|
3
2
|
import { DEFAULT_HASH_PROPS } from "./consts.js";
|
|
4
3
|
import { isLocalService } from "./services/service.js";
|
|
5
|
-
import {
|
|
6
|
-
function injectImageEndpoint(settings, mode) {
|
|
7
|
-
const endpointEntrypoint = settings.config.image.endpoint ?? (mode === "dev" ? "astro/assets/endpoint/node" : "astro/assets/endpoint/generic");
|
|
8
|
-
settings.injectedRoutes.push({
|
|
9
|
-
pattern: "/_image",
|
|
10
|
-
entrypoint: endpointEntrypoint,
|
|
11
|
-
prerender: false
|
|
12
|
-
});
|
|
13
|
-
return settings;
|
|
14
|
-
}
|
|
15
|
-
function isESMImportedImage(src) {
|
|
16
|
-
return typeof src === "object";
|
|
17
|
-
}
|
|
18
|
-
function isRemoteImage(src) {
|
|
19
|
-
return typeof src === "string";
|
|
20
|
-
}
|
|
21
|
-
function isRemoteAllowed(src, {
|
|
22
|
-
domains = [],
|
|
23
|
-
remotePatterns = []
|
|
24
|
-
}) {
|
|
25
|
-
if (!isRemotePath(src))
|
|
26
|
-
return false;
|
|
27
|
-
const url = new URL(src);
|
|
28
|
-
return domains.some((domain) => matchHostname(url, domain)) || remotePatterns.some((remotePattern) => matchPattern(url, remotePattern));
|
|
29
|
-
}
|
|
4
|
+
import { isESMImportedImage, isRemoteImage } from "./utils/imageKind.js";
|
|
30
5
|
async function getConfiguredImageService() {
|
|
31
6
|
if (!globalThis?.astroAsset?.imageService) {
|
|
32
7
|
const { default: service } = await import(
|
|
@@ -105,9 +80,5 @@ async function getImage(options, imageConfig) {
|
|
|
105
80
|
}
|
|
106
81
|
export {
|
|
107
82
|
getConfiguredImageService,
|
|
108
|
-
getImage
|
|
109
|
-
injectImageEndpoint,
|
|
110
|
-
isESMImportedImage,
|
|
111
|
-
isRemoteAllowed,
|
|
112
|
-
isRemoteImage
|
|
83
|
+
getImage
|
|
113
84
|
};
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { AstroError, AstroErrorData } from "../../core/errors/index.js";
|
|
2
2
|
import { isRemotePath, joinPaths } from "../../core/path.js";
|
|
3
3
|
import { DEFAULT_HASH_PROPS, DEFAULT_OUTPUT_FORMAT, VALID_SUPPORTED_FORMATS } from "../consts.js";
|
|
4
|
-
import { isESMImportedImage
|
|
4
|
+
import { isESMImportedImage } from "../utils/imageKind.js";
|
|
5
|
+
import { isRemoteAllowed } from "../utils/remotePattern.js";
|
|
5
6
|
function isLocalService(service) {
|
|
6
7
|
if (!service) {
|
|
7
8
|
return false;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export { emitESMImage } from './emitAsset.js';
|
|
2
|
+
export { isESMImportedImage, isRemoteImage } from './imageKind.js';
|
|
2
3
|
export { imageMetadata } from './metadata.js';
|
|
3
4
|
export { getOrigQueryParams } from './queryParams.js';
|
|
5
|
+
export { isRemoteAllowed, matchHostname, matchPathname, matchPattern, matchPort, matchProtocol, type RemotePattern, } from './remotePattern.js';
|
|
4
6
|
export { hashTransform, propsToFilename } from './transformToPath.js';
|
|
@@ -1,11 +1,28 @@
|
|
|
1
1
|
import { emitESMImage } from "./emitAsset.js";
|
|
2
|
+
import { isESMImportedImage, isRemoteImage } from "./imageKind.js";
|
|
2
3
|
import { imageMetadata } from "./metadata.js";
|
|
3
4
|
import { getOrigQueryParams } from "./queryParams.js";
|
|
5
|
+
import {
|
|
6
|
+
isRemoteAllowed,
|
|
7
|
+
matchHostname,
|
|
8
|
+
matchPathname,
|
|
9
|
+
matchPattern,
|
|
10
|
+
matchPort,
|
|
11
|
+
matchProtocol
|
|
12
|
+
} from "./remotePattern.js";
|
|
4
13
|
import { hashTransform, propsToFilename } from "./transformToPath.js";
|
|
5
14
|
export {
|
|
6
15
|
emitESMImage,
|
|
7
16
|
getOrigQueryParams,
|
|
8
17
|
hashTransform,
|
|
9
18
|
imageMetadata,
|
|
19
|
+
isESMImportedImage,
|
|
20
|
+
isRemoteAllowed,
|
|
21
|
+
isRemoteImage,
|
|
22
|
+
matchHostname,
|
|
23
|
+
matchPathname,
|
|
24
|
+
matchPattern,
|
|
25
|
+
matchPort,
|
|
26
|
+
matchProtocol,
|
|
10
27
|
propsToFilename
|
|
11
28
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { AstroConfig } from '../../@types/astro.js';
|
|
1
2
|
export type RemotePattern = {
|
|
2
3
|
hostname?: string;
|
|
3
4
|
pathname?: string;
|
|
@@ -9,3 +10,4 @@ export declare function matchPort(url: URL, port?: string): boolean;
|
|
|
9
10
|
export declare function matchProtocol(url: URL, protocol?: string): boolean;
|
|
10
11
|
export declare function matchHostname(url: URL, hostname?: string, allowWildcard?: boolean): boolean;
|
|
11
12
|
export declare function matchPathname(url: URL, pathname?: string, allowWildcard?: boolean): boolean;
|
|
13
|
+
export declare function isRemoteAllowed(src: string, { domains, remotePatterns, }: Partial<Pick<AstroConfig['image'], 'domains' | 'remotePatterns'>>): boolean;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isRemotePath } from "@astrojs/internal-helpers/path";
|
|
1
2
|
function matchPattern(url, remotePattern) {
|
|
2
3
|
return matchProtocol(url, remotePattern.protocol) && matchHostname(url, remotePattern.hostname, true) && matchPort(url, remotePattern.port) && matchPathname(url, remotePattern.pathname, true);
|
|
3
4
|
}
|
|
@@ -37,7 +38,17 @@ function matchPathname(url, pathname, allowWildcard) {
|
|
|
37
38
|
}
|
|
38
39
|
return false;
|
|
39
40
|
}
|
|
41
|
+
function isRemoteAllowed(src, {
|
|
42
|
+
domains = [],
|
|
43
|
+
remotePatterns = []
|
|
44
|
+
}) {
|
|
45
|
+
if (!isRemotePath(src))
|
|
46
|
+
return false;
|
|
47
|
+
const url = new URL(src);
|
|
48
|
+
return domains.some((domain) => matchHostname(url, domain)) || remotePatterns.some((remotePattern) => matchPattern(url, remotePattern));
|
|
49
|
+
}
|
|
40
50
|
export {
|
|
51
|
+
isRemoteAllowed,
|
|
41
52
|
matchHostname,
|
|
42
53
|
matchPathname,
|
|
43
54
|
matchPattern,
|
|
@@ -2,7 +2,7 @@ import { deterministicString } from "deterministic-object-hash";
|
|
|
2
2
|
import { basename, extname } from "node:path";
|
|
3
3
|
import { removeQueryString } from "../../core/path.js";
|
|
4
4
|
import { shorthash } from "../../runtime/server/shorthash.js";
|
|
5
|
-
import { isESMImportedImage } from "
|
|
5
|
+
import { isESMImportedImage } from "./imageKind.js";
|
|
6
6
|
function propsToFilename(transform, hash) {
|
|
7
7
|
let filename = removeQueryString(
|
|
8
8
|
isESMImportedImage(transform.src) ? transform.src.src : transform.src
|
|
@@ -10,8 +10,8 @@ import {
|
|
|
10
10
|
} from "../core/path.js";
|
|
11
11
|
import { isServerLikeOutput } from "../prerender/utils.js";
|
|
12
12
|
import { VALID_INPUT_FORMATS, VIRTUAL_MODULE_ID, VIRTUAL_SERVICE_ID } from "./consts.js";
|
|
13
|
-
import { isESMImportedImage } from "./internal.js";
|
|
14
13
|
import { emitESMImage } from "./utils/emitAsset.js";
|
|
14
|
+
import { isESMImportedImage } from "./utils/imageKind.js";
|
|
15
15
|
import { getProxyCode } from "./utils/proxy.js";
|
|
16
16
|
import { hashTransform, propsToFilename } from "./utils/transformToPath.js";
|
|
17
17
|
const resolvedVirtualModuleId = "\0" + VIRTUAL_MODULE_ID;
|
package/dist/cli/add/index.js
CHANGED
|
@@ -56,7 +56,7 @@ const LIT_NPMRC_STUB = `# Lit libraries are required to be hoisted due to depend
|
|
|
56
56
|
public-hoist-pattern[]=*lit*
|
|
57
57
|
`;
|
|
58
58
|
const OFFICIAL_ADAPTER_TO_IMPORT_MAP = {
|
|
59
|
-
netlify: "@astrojs/netlify
|
|
59
|
+
netlify: "@astrojs/netlify",
|
|
60
60
|
vercel: "@astrojs/vercel/serverless",
|
|
61
61
|
cloudflare: "@astrojs/cloudflare",
|
|
62
62
|
node: "@astrojs/node"
|
package/dist/core/app/index.js
CHANGED
|
@@ -263,7 +263,8 @@ class App {
|
|
|
263
263
|
* This also handles pre-rendered /404 or /500 routes
|
|
264
264
|
*/
|
|
265
265
|
async #renderError(request, { status, response: originalResponse, skipMiddleware = false }) {
|
|
266
|
-
const
|
|
266
|
+
const errorRoutePath = `/${status}${this.#manifest.trailingSlash === "always" ? "/" : ""}`;
|
|
267
|
+
const errorRouteData = matchRoute(errorRoutePath, this.#manifestData);
|
|
267
268
|
const url = new URL(request.url);
|
|
268
269
|
if (errorRouteData) {
|
|
269
270
|
if (errorRouteData.prerender) {
|
|
@@ -308,8 +309,8 @@ class App {
|
|
|
308
309
|
Reflect.set(response, responseSentSymbol, true);
|
|
309
310
|
return response;
|
|
310
311
|
}
|
|
311
|
-
#mergeResponses(newResponse,
|
|
312
|
-
if (!
|
|
312
|
+
#mergeResponses(newResponse, originalResponse, override) {
|
|
313
|
+
if (!originalResponse) {
|
|
313
314
|
if (override !== void 0) {
|
|
314
315
|
return new Response(newResponse.body, {
|
|
315
316
|
status: override.status,
|
|
@@ -319,12 +320,23 @@ class App {
|
|
|
319
320
|
}
|
|
320
321
|
return newResponse;
|
|
321
322
|
}
|
|
322
|
-
const
|
|
323
|
-
|
|
323
|
+
const status = override?.status ? override.status : originalResponse.status === 200 ? newResponse.status : originalResponse.status;
|
|
324
|
+
try {
|
|
325
|
+
originalResponse.headers.delete("Content-type");
|
|
326
|
+
} catch {
|
|
327
|
+
}
|
|
324
328
|
return new Response(newResponse.body, {
|
|
325
329
|
status,
|
|
326
|
-
statusText: status === 200 ? newResponse.statusText : statusText,
|
|
327
|
-
|
|
330
|
+
statusText: status === 200 ? newResponse.statusText : originalResponse.statusText,
|
|
331
|
+
// If you're looking at here for possible bugs, it means that it's not a bug.
|
|
332
|
+
// With the middleware, users can meddle with headers, and we should pass to the 404/500.
|
|
333
|
+
// If users see something weird, it's because they are setting some headers they should not.
|
|
334
|
+
//
|
|
335
|
+
// Although, we don't want it to replace the content-type, because the error page must return `text/html`
|
|
336
|
+
headers: new Headers([
|
|
337
|
+
...Array.from(newResponse.headers),
|
|
338
|
+
...Array.from(originalResponse.headers)
|
|
339
|
+
])
|
|
328
340
|
});
|
|
329
341
|
}
|
|
330
342
|
#getDefaultStatusCode(routeData, pathname) {
|
|
@@ -168,7 +168,7 @@ ${bgGreen(black(` ${verb} static routes `))}`);
|
|
|
168
168
|
const totalCount = Array.from(staticImageList.values()).map((x) => x.transforms.size).reduce((a, b) => a + b, 0);
|
|
169
169
|
const cpuCount = os.cpus().length;
|
|
170
170
|
const assetsCreationEnvironment = await prepareAssetsGenerationEnv(pipeline, totalCount);
|
|
171
|
-
const queue = new PQueue({ concurrency: cpuCount });
|
|
171
|
+
const queue = new PQueue({ concurrency: Math.max(cpuCount, 1) });
|
|
172
172
|
const assetsTimer = performance.now();
|
|
173
173
|
for (const [originalPath, transforms] of staticImageList) {
|
|
174
174
|
await generateImagesForPath(originalPath, transforms, assetsCreationEnvironment, queue);
|
|
@@ -230,13 +230,14 @@ async function generatePage(pageData, ssrEntry, builtPaths, pipeline) {
|
|
|
230
230
|
for (let i = 0; i < paths.length; i++) {
|
|
231
231
|
const path = paths[i];
|
|
232
232
|
pipeline.getEnvironment().logger.debug("build", `Generating: ${path}`);
|
|
233
|
+
const filePath = getOutputFilename(pipeline.getConfig(), path, pageData.route.type);
|
|
234
|
+
const lineIcon = i === paths.length - 1 ? "\u2514\u2500" : "\u251C\u2500";
|
|
235
|
+
logger.info(null, ` ${blue(lineIcon)} ${dim(filePath)}`, false);
|
|
233
236
|
await generatePath(path, pipeline, generationOptions, route);
|
|
234
237
|
const timeEnd = performance.now();
|
|
235
238
|
const timeChange = getTimeStat(prevTimeEnd, timeEnd);
|
|
236
239
|
const timeIncrease = `(+${timeChange})`;
|
|
237
|
-
|
|
238
|
-
const lineIcon = i === paths.length - 1 ? "\u2514\u2500" : "\u251C\u2500";
|
|
239
|
-
logger.info(null, ` ${blue(lineIcon)} ${dim(filePath)} ${dim(timeIncrease)}`);
|
|
240
|
+
logger.info("SKIP_FORMAT", ` ${dim(timeIncrease)}`);
|
|
240
241
|
prevTimeEnd = timeEnd;
|
|
241
242
|
}
|
|
242
243
|
}
|
package/dist/core/build/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import { blue, bold, green } from "kleur/colors";
|
|
|
2
2
|
import fs from "node:fs";
|
|
3
3
|
import { performance } from "node:perf_hooks";
|
|
4
4
|
import { fileURLToPath } from "node:url";
|
|
5
|
-
import { injectImageEndpoint } from "../../assets/
|
|
5
|
+
import { injectImageEndpoint } from "../../assets/endpoint/config.js";
|
|
6
6
|
import { telemetry } from "../../events/index.js";
|
|
7
7
|
import { eventCliSession } from "../../events/session.js";
|
|
8
8
|
import {
|
|
@@ -148,8 +148,9 @@ function buildManifest(opts, internals, staticFiles) {
|
|
|
148
148
|
continue;
|
|
149
149
|
const scripts = [];
|
|
150
150
|
if (pageData.hoistedScript) {
|
|
151
|
+
const shouldPrefixAssetPath = pageData.hoistedScript.type === "external";
|
|
151
152
|
const hoistedValue = pageData.hoistedScript.value;
|
|
152
|
-
const value =
|
|
153
|
+
const value = shouldPrefixAssetPath ? prefixAssetPath(hoistedValue) : hoistedValue;
|
|
153
154
|
scripts.unshift(
|
|
154
155
|
Object.assign({}, pageData.hoistedScript, {
|
|
155
156
|
value
|
|
@@ -94,7 +94,7 @@ async function staticBuild(opts, internals, ssrOutputChunkNames) {
|
|
|
94
94
|
case settings.config.output === "static": {
|
|
95
95
|
settings.timer.start("Static generate");
|
|
96
96
|
await generatePages(opts, internals);
|
|
97
|
-
await cleanServerOutput(opts, ssrOutputChunkNames);
|
|
97
|
+
await cleanServerOutput(opts, ssrOutputChunkNames, internals);
|
|
98
98
|
settings.timer.end("Static generate");
|
|
99
99
|
return;
|
|
100
100
|
}
|
|
@@ -314,9 +314,12 @@ export const ${e.n} = noop;`;
|
|
|
314
314
|
removeEmptyDirs(out);
|
|
315
315
|
}
|
|
316
316
|
}
|
|
317
|
-
async function cleanServerOutput(opts, ssrOutputChunkNames) {
|
|
317
|
+
async function cleanServerOutput(opts, ssrOutputChunkNames, internals) {
|
|
318
318
|
const out = getOutDirWithinCwd(opts.settings.config.outDir);
|
|
319
319
|
const files = ssrOutputChunkNames.filter((f) => f.endsWith(".mjs"));
|
|
320
|
+
if (internals.manifestFileName) {
|
|
321
|
+
files.push(internals.manifestFileName);
|
|
322
|
+
}
|
|
320
323
|
if (files.length) {
|
|
321
324
|
await Promise.all(
|
|
322
325
|
files.map(async (filename) => {
|