astro 5.15.4 → 6.0.0-alpha.0
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/{astro.js → bin/astro.mjs} +7 -8
- package/client.d.ts +2 -4
- package/components/ClientRouter.astro +0 -5
- package/dist/actions/runtime/utils.d.ts +2 -8
- package/dist/assets/build/remote.js +4 -14
- package/dist/assets/fonts/implementations/font-metrics-resolver.js +15 -9
- package/dist/assets/services/sharp.js +5 -6
- package/dist/assets/utils/index.d.ts +1 -5
- package/dist/assets/utils/index.js +1 -5
- package/dist/assets/utils/node/emitAsset.d.ts +0 -14
- package/dist/assets/utils/node/emitAsset.js +0 -50
- package/dist/assets/vite-plugin-assets.js +3 -8
- package/dist/cli/add/index.js +0 -2
- package/dist/cli/db/index.js +0 -2
- package/dist/cli/info/index.js +0 -2
- package/dist/cli/infra/build-time-astro-version-provider.js +1 -1
- package/dist/cli/preferences/index.js +0 -2
- package/dist/config/index.js +3 -12
- package/dist/container/index.d.ts +0 -1
- package/dist/container/index.js +0 -1
- package/dist/content/config.js +17 -13
- package/dist/content/content-layer.js +4 -6
- package/dist/content/data-store.d.ts +0 -2
- package/dist/content/loaders/glob.d.ts +0 -5
- package/dist/content/loaders/glob.js +3 -30
- package/dist/content/mutable-data-store.js +1 -14
- package/dist/content/runtime-assets.d.ts +1 -1
- package/dist/content/runtime-assets.js +3 -6
- package/dist/content/runtime.d.ts +19 -58
- package/dist/content/runtime.js +52 -218
- package/dist/content/server-listeners.js +25 -88
- package/dist/content/types-generator.d.ts +1 -6
- package/dist/content/types-generator.js +20 -116
- package/dist/content/utils.d.ts +31 -104
- package/dist/content/utils.js +48 -158
- package/dist/content/vite-plugin-content-imports.js +0 -4
- package/dist/content/vite-plugin-content-virtual-mod.js +3 -134
- package/dist/core/app/index.d.ts +1 -1
- package/dist/core/app/index.js +7 -10
- package/dist/core/app/node.d.ts +2 -8
- package/dist/core/app/node.js +4 -6
- package/dist/core/build/generate.js +0 -1
- package/dist/core/build/index.js +1 -4
- package/dist/core/build/internal.d.ts +1 -2
- package/dist/core/build/internal.js +0 -1
- package/dist/core/build/plugins/plugin-manifest.js +2 -4
- package/dist/core/compile/compile.js +0 -2
- package/dist/core/config/schemas/base.d.ts +4 -40
- package/dist/core/config/schemas/base.js +3 -16
- package/dist/core/config/schemas/refined.js +7 -0
- package/dist/core/config/schemas/relative.d.ts +5 -47
- package/dist/core/constants.d.ts +1 -0
- package/dist/core/constants.js +3 -1
- package/dist/core/create-vite.js +1 -4
- package/dist/core/dev/container.js +0 -2
- package/dist/core/dev/dev.js +1 -1
- package/dist/core/errors/dev/vite.js +1 -18
- package/dist/core/errors/errors-data.d.ts +68 -50
- package/dist/core/errors/errors-data.js +30 -24
- package/dist/core/errors/overlay.js +1 -1
- package/dist/core/messages.js +2 -2
- package/dist/core/middleware/index.d.ts +1 -1
- package/dist/core/middleware/index.js +5 -9
- package/dist/core/preview/index.js +0 -2
- package/dist/core/render/params-and-props.js +0 -1
- package/dist/core/render/route-cache.d.ts +1 -2
- package/dist/core/render/route-cache.js +1 -2
- package/dist/core/render-context.d.ts +3 -3
- package/dist/core/render-context.js +13 -27
- package/dist/core/routing/manifest/create.js +1 -1
- package/dist/core/routing/params.js +5 -6
- package/dist/core/routing/validation.d.ts +1 -2
- package/dist/core/routing/validation.js +2 -18
- package/dist/core/server-islands/endpoint.d.ts +1 -2
- package/dist/core/server-islands/endpoint.js +0 -1
- package/dist/core/sync/index.js +2 -10
- package/dist/env/env-loader.d.ts +0 -1
- package/dist/env/env-loader.js +4 -17
- package/dist/env/vite-plugin-env.js +41 -45
- package/dist/i18n/index.js +0 -3
- package/dist/integrations/hooks.d.ts +1 -2
- package/dist/integrations/hooks.js +0 -27
- package/dist/prefetch/index.d.ts +0 -10
- package/dist/prefetch/index.js +1 -1
- package/dist/runtime/server/astro-global.d.ts +2 -2
- package/dist/runtime/server/astro-global.js +86 -24
- package/dist/transitions/vite-plugin-transitions.js +1 -4
- package/dist/types/astro.d.ts +2 -2
- package/dist/types/public/common.d.ts +1 -3
- package/dist/types/public/config.d.ts +4 -127
- package/dist/types/public/context.d.ts +18 -39
- package/dist/types/public/integrations.d.ts +0 -17
- package/dist/types/public/internal.d.ts +2 -2
- package/dist/virtual-modules/live-config.d.ts +0 -2
- package/dist/virtual-modules/live-config.js +0 -4
- package/dist/vite-plugin-markdown/index.js +0 -1
- package/package.json +8 -11
- package/templates/content/module.mjs +8 -63
- package/templates/content/types.d.ts +10 -69
- package/dist/config/vite-plugin-content-listen.d.ts +0 -17
- package/dist/config/vite-plugin-content-listen.js +0 -26
- package/dist/container/polyfill.d.ts +0 -1
- package/dist/container/polyfill.js +0 -2
- package/dist/core/polyfill.d.ts +0 -5
- package/dist/core/polyfill.js +0 -17
- package/dist/vite-plugin-astro-postprocess/index.d.ts +0 -2
- package/dist/vite-plugin-astro-postprocess/index.js +0 -48
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
|
-
// ISOMORPHIC FILE: NO TOP-LEVEL IMPORT/REQUIRE() ALLOWED
|
|
5
|
-
// This file has to run as both ESM and CJS on older Node.js versions
|
|
6
|
-
|
|
7
4
|
const CI_INSTRUCTIONS = {
|
|
8
5
|
NETLIFY: 'https://docs.netlify.com/configure-builds/manage-dependencies/#node-js-and-javascript',
|
|
9
6
|
GITHUB_ACTIONS:
|
|
@@ -11,9 +8,12 @@ const CI_INSTRUCTIONS = {
|
|
|
11
8
|
VERCEL: 'https://vercel.com/docs/runtimes#official-runtimes/node-js/node-js-version',
|
|
12
9
|
};
|
|
13
10
|
|
|
11
|
+
// TODO: remove once Stackblitz supports Node 22
|
|
12
|
+
const IS_STACKBLITZ = !!process.versions.webcontainer;
|
|
13
|
+
|
|
14
14
|
// Hardcode supported Node.js version so we don't have to read differently in CJS & ESM.
|
|
15
|
-
const engines = '>=
|
|
16
|
-
const skipSemverCheckIfAbove =
|
|
15
|
+
const engines = IS_STACKBLITZ ? '>=20.19.5' : '>=22.12.0';
|
|
16
|
+
const skipSemverCheckIfAbove = IS_STACKBLITZ ? 21 : 23;
|
|
17
17
|
|
|
18
18
|
/** `astro *` */
|
|
19
19
|
async function main() {
|
|
@@ -39,7 +39,7 @@ async function main() {
|
|
|
39
39
|
if (correctedCwd !== cwd) process.chdir(correctedCwd);
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
return import('
|
|
42
|
+
return import('../dist/cli/index.js')
|
|
43
43
|
.then(({ cli }) => cli(process.argv))
|
|
44
44
|
.catch((error) => {
|
|
45
45
|
console.error(error);
|
|
@@ -52,8 +52,7 @@ async function errorNodeUnsupported() {
|
|
|
52
52
|
Node.js v${process.versions.node} is not supported by Astro!
|
|
53
53
|
Please upgrade Node.js to a supported version: "${engines}"\n`);
|
|
54
54
|
|
|
55
|
-
|
|
56
|
-
const ci = typeof require !== 'undefined' ? require('ci-info') : await import('ci-info');
|
|
55
|
+
const ci = await import('ci-info');
|
|
57
56
|
|
|
58
57
|
// Special instructions for CI environments, which may have special steps needed.
|
|
59
58
|
// This is a common issue that we can help users with proactively.
|
package/client.d.ts
CHANGED
|
@@ -5,8 +5,10 @@
|
|
|
5
5
|
/// <reference path="./types/fonts.d.ts" />
|
|
6
6
|
|
|
7
7
|
interface ImportMetaEnv {
|
|
8
|
+
// TODO: remove in Astro 7
|
|
8
9
|
/**
|
|
9
10
|
* The prefix for Astro-generated asset links if the build.assetsPrefix config option is set. This can be used to create asset links not handled by Astro.
|
|
11
|
+
* @deprecated This will be removed in a future major version of Astro. Use `build.assetsPrefix` from `astro:config/server` instead.
|
|
10
12
|
*/
|
|
11
13
|
readonly ASSETS_PREFIX: string | Record<string, string>;
|
|
12
14
|
/**
|
|
@@ -124,10 +126,6 @@ declare module 'astro:transitions' {
|
|
|
124
126
|
export const createAnimationScope: TransitionModule['createAnimationScope'];
|
|
125
127
|
|
|
126
128
|
type ClientRouterModule = typeof import('./components/ClientRouter.astro');
|
|
127
|
-
/**
|
|
128
|
-
* @deprecated The ViewTransitions component has been renamed to ClientRouter
|
|
129
|
-
*/
|
|
130
|
-
export const ViewTransitions: ClientRouterModule['default'];
|
|
131
129
|
export const ClientRouter: ClientRouterModule['default'];
|
|
132
130
|
}
|
|
133
131
|
|
|
@@ -3,11 +3,6 @@ type Fallback = 'none' | 'animate' | 'swap';
|
|
|
3
3
|
|
|
4
4
|
export interface Props {
|
|
5
5
|
fallback?: Fallback;
|
|
6
|
-
/** @deprecated handleForms is enabled by default in Astro 4.0
|
|
7
|
-
*
|
|
8
|
-
* Set `data-astro-reload` on your form to opt-out of the default behavior.
|
|
9
|
-
*/
|
|
10
|
-
handleForms?: boolean;
|
|
11
6
|
}
|
|
12
7
|
|
|
13
8
|
const { fallback = 'animate' } = Astro.props;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { APIContext
|
|
1
|
+
import type { APIContext } from '../../types/public/context.js';
|
|
2
2
|
import type { SerializedActionResult } from './shared.js';
|
|
3
3
|
export type ActionPayload = {
|
|
4
4
|
actionResult: SerializedActionResult;
|
|
@@ -10,13 +10,7 @@ export type Locals = {
|
|
|
10
10
|
export declare const ACTION_API_CONTEXT_SYMBOL: unique symbol;
|
|
11
11
|
export declare const formContentTypes: string[];
|
|
12
12
|
export declare function hasContentType(contentType: string, expected: string[]): boolean;
|
|
13
|
-
export type ActionAPIContext = Pick<APIContext, '
|
|
14
|
-
/**
|
|
15
|
-
* @deprecated
|
|
16
|
-
* The use of `rewrite` in Actions is deprecated
|
|
17
|
-
*/
|
|
18
|
-
rewrite: AstroSharedContext['rewrite'];
|
|
19
|
-
};
|
|
13
|
+
export type ActionAPIContext = Pick<APIContext, 'request' | 'url' | 'isPrerendered' | 'locals' | 'clientAddress' | 'cookies' | 'currentLocale' | 'generator' | 'routePattern' | 'site' | 'params' | 'preferredLocale' | 'preferredLocaleList' | 'originPathname' | 'session' | 'csp'>;
|
|
20
14
|
export type MaybePromise<T> = T | Promise<T>;
|
|
21
15
|
/**
|
|
22
16
|
* Used to preserve the input schema type in the error object.
|
|
@@ -48,27 +48,17 @@ async function revalidateRemoteImage(src, revalidationData) {
|
|
|
48
48
|
lastModified: res.headers.get("Last-Modified") ?? (res.ok ? void 0 : revalidationData.lastModified)
|
|
49
49
|
};
|
|
50
50
|
}
|
|
51
|
-
function webToCachePolicyRequest({ url, method, headers
|
|
52
|
-
let headers = {};
|
|
53
|
-
try {
|
|
54
|
-
headers = Object.fromEntries(_headers.entries());
|
|
55
|
-
} catch {
|
|
56
|
-
}
|
|
51
|
+
function webToCachePolicyRequest({ url, method, headers }) {
|
|
57
52
|
return {
|
|
58
53
|
method,
|
|
59
54
|
url,
|
|
60
|
-
headers
|
|
55
|
+
headers: Object.fromEntries(headers.entries())
|
|
61
56
|
};
|
|
62
57
|
}
|
|
63
|
-
function webToCachePolicyResponse({ status, headers
|
|
64
|
-
let headers = {};
|
|
65
|
-
try {
|
|
66
|
-
headers = Object.fromEntries(_headers.entries());
|
|
67
|
-
} catch {
|
|
68
|
-
}
|
|
58
|
+
function webToCachePolicyResponse({ status, headers }) {
|
|
69
59
|
return {
|
|
70
60
|
status,
|
|
71
|
-
headers
|
|
61
|
+
headers: Object.fromEntries(headers.entries())
|
|
72
62
|
};
|
|
73
63
|
}
|
|
74
64
|
export {
|
|
@@ -15,9 +15,11 @@ function filterRequiredMetrics({
|
|
|
15
15
|
xWidthAvg
|
|
16
16
|
};
|
|
17
17
|
}
|
|
18
|
-
function
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
function round(value) {
|
|
19
|
+
return parseFloat(value.toFixed(4));
|
|
20
|
+
}
|
|
21
|
+
function toPercentString(value) {
|
|
22
|
+
return `${round(value * 100)}%`;
|
|
21
23
|
}
|
|
22
24
|
function createCapsizeFontMetricsResolver({
|
|
23
25
|
fontFetcher,
|
|
@@ -29,7 +31,8 @@ function createCapsizeFontMetricsResolver({
|
|
|
29
31
|
cache[name] ??= filterRequiredMetrics(await fromBuffer(await fontFetcher.fetch(input)));
|
|
30
32
|
return cache[name];
|
|
31
33
|
},
|
|
32
|
-
//
|
|
34
|
+
// Adapted from Capsize
|
|
35
|
+
// Source: https://github.com/seek-oss/capsize/blob/b752693428b45994442433f7e3476ca4e3e3c507/packages/core/src/createFontStack.ts
|
|
33
36
|
generateFontFace({
|
|
34
37
|
metrics,
|
|
35
38
|
fallbackMetrics,
|
|
@@ -39,18 +42,21 @@ function createCapsizeFontMetricsResolver({
|
|
|
39
42
|
}) {
|
|
40
43
|
const preferredFontXAvgRatio = metrics.xWidthAvg / metrics.unitsPerEm;
|
|
41
44
|
const fallbackFontXAvgRatio = fallbackMetrics.xWidthAvg / fallbackMetrics.unitsPerEm;
|
|
42
|
-
const sizeAdjust = preferredFontXAvgRatio / fallbackFontXAvgRatio;
|
|
45
|
+
const sizeAdjust = preferredFontXAvgRatio && fallbackFontXAvgRatio ? preferredFontXAvgRatio / fallbackFontXAvgRatio : 1;
|
|
43
46
|
const adjustedEmSquare = metrics.unitsPerEm * sizeAdjust;
|
|
44
47
|
const ascentOverride = metrics.ascent / adjustedEmSquare;
|
|
45
48
|
const descentOverride = Math.abs(metrics.descent) / adjustedEmSquare;
|
|
46
49
|
const lineGapOverride = metrics.lineGap / adjustedEmSquare;
|
|
50
|
+
const fallbackAscentOverride = fallbackMetrics.ascent / adjustedEmSquare;
|
|
51
|
+
const fallbackDescentOverride = Math.abs(fallbackMetrics.descent) / adjustedEmSquare;
|
|
52
|
+
const fallbackLineGapOverride = fallbackMetrics.lineGap / adjustedEmSquare;
|
|
47
53
|
return cssRenderer.generateFontFace(fallbackName, {
|
|
48
54
|
...properties,
|
|
49
55
|
src: renderFontSrc([{ name: fallbackFontName }]),
|
|
50
|
-
"size-adjust":
|
|
51
|
-
"ascent-override":
|
|
52
|
-
"descent-override":
|
|
53
|
-
"line-gap-override":
|
|
56
|
+
"size-adjust": sizeAdjust && sizeAdjust !== 1 ? toPercentString(sizeAdjust) : void 0,
|
|
57
|
+
"ascent-override": ascentOverride && ascentOverride !== fallbackAscentOverride ? toPercentString(ascentOverride) : void 0,
|
|
58
|
+
"descent-override": descentOverride && descentOverride !== fallbackDescentOverride ? toPercentString(descentOverride) : void 0,
|
|
59
|
+
"line-gap-override": lineGapOverride !== fallbackLineGapOverride ? toPercentString(lineGapOverride) : void 0
|
|
54
60
|
});
|
|
55
61
|
}
|
|
56
62
|
};
|
|
@@ -45,25 +45,24 @@ const sharpService = {
|
|
|
45
45
|
limitInputPixels: config.service.config.limitInputPixels
|
|
46
46
|
});
|
|
47
47
|
result.rotate();
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
const fit = fitMap[transform.fit] ?? "inside";
|
|
48
|
+
if (transform.width && transform.height) {
|
|
49
|
+
const fit = transform.fit ? fitMap[transform.fit] ?? "inside" : void 0;
|
|
51
50
|
result.resize({
|
|
52
51
|
width: Math.round(transform.width),
|
|
53
52
|
height: Math.round(transform.height),
|
|
54
53
|
fit,
|
|
55
54
|
position: transform.position,
|
|
56
|
-
withoutEnlargement
|
|
55
|
+
withoutEnlargement: true
|
|
57
56
|
});
|
|
58
57
|
} else if (transform.height && !transform.width) {
|
|
59
58
|
result.resize({
|
|
60
59
|
height: Math.round(transform.height),
|
|
61
|
-
withoutEnlargement
|
|
60
|
+
withoutEnlargement: true
|
|
62
61
|
});
|
|
63
62
|
} else if (transform.width) {
|
|
64
63
|
result.resize({
|
|
65
64
|
width: Math.round(transform.width),
|
|
66
|
-
withoutEnlargement
|
|
65
|
+
withoutEnlargement: true
|
|
67
66
|
});
|
|
68
67
|
}
|
|
69
68
|
if (transform.format) {
|
|
@@ -6,11 +6,7 @@
|
|
|
6
6
|
*/
|
|
7
7
|
export { isESMImportedImage, isRemoteImage, resolveSrc } from './imageKind.js';
|
|
8
8
|
export { imageMetadata } from './metadata.js';
|
|
9
|
-
export {
|
|
10
|
-
/**
|
|
11
|
-
* @deprecated
|
|
12
|
-
*/
|
|
13
|
-
emitESMImage, emitImageMetadata, } from './node/emitAsset.js';
|
|
9
|
+
export { emitImageMetadata } from './node/emitAsset.js';
|
|
14
10
|
export { getOrigQueryParams } from './queryParams.js';
|
|
15
11
|
export { isRemoteAllowed, matchHostname, matchPathname, matchPattern, matchPort, matchProtocol, type RemotePattern, } from './remotePattern.js';
|
|
16
12
|
export { inferRemoteSize } from './remoteProbe.js';
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
import { isESMImportedImage, isRemoteImage, resolveSrc } from "./imageKind.js";
|
|
2
2
|
import { imageMetadata } from "./metadata.js";
|
|
3
|
-
import {
|
|
4
|
-
emitESMImage,
|
|
5
|
-
emitImageMetadata
|
|
6
|
-
} from "./node/emitAsset.js";
|
|
3
|
+
import { emitImageMetadata } from "./node/emitAsset.js";
|
|
7
4
|
import { getOrigQueryParams } from "./queryParams.js";
|
|
8
5
|
import {
|
|
9
6
|
isRemoteAllowed,
|
|
@@ -16,7 +13,6 @@ import {
|
|
|
16
13
|
import { inferRemoteSize } from "./remoteProbe.js";
|
|
17
14
|
import { hashTransform, propsToFilename } from "./transformToPath.js";
|
|
18
15
|
export {
|
|
19
|
-
emitESMImage,
|
|
20
16
|
emitImageMetadata,
|
|
21
17
|
getOrigQueryParams,
|
|
22
18
|
hashTransform,
|
|
@@ -4,20 +4,6 @@ type FileEmitter = vite.Rollup.EmitFile;
|
|
|
4
4
|
type ImageMetadataWithContents = ImageMetadata & {
|
|
5
5
|
contents?: Buffer;
|
|
6
6
|
};
|
|
7
|
-
/**
|
|
8
|
-
* Processes an image file and emits its metadata and optionally its contents. This function supports both build and development modes.
|
|
9
|
-
*
|
|
10
|
-
* @param {string | undefined} id - The identifier or path of the image file to process. If undefined, the function returns immediately.
|
|
11
|
-
* @param {boolean} _watchMode - **Deprecated**: Indicates if the method is operating in watch mode. This parameter will be removed or updated in the future.
|
|
12
|
-
* @param {boolean} _experimentalSvgEnabled - **Deprecated**: A flag to enable experimental handling of SVG files. Embeds SVG file data if set to true.
|
|
13
|
-
* @param {FileEmitter | undefined} [fileEmitter] - Function for emitting files during the build process. May throw in certain scenarios.
|
|
14
|
-
* @return {Promise<ImageMetadataWithContents | undefined>} Resolves to metadata with optional image contents or `undefined` if processing fails.
|
|
15
|
-
*/
|
|
16
|
-
export declare function emitESMImage(id: string | undefined,
|
|
17
|
-
/** @deprecated */
|
|
18
|
-
_watchMode: boolean,
|
|
19
|
-
/** @deprecated */
|
|
20
|
-
_experimentalSvgEnabled: boolean, fileEmitter?: FileEmitter): Promise<ImageMetadataWithContents | undefined>;
|
|
21
7
|
/**
|
|
22
8
|
* Processes an image file and emits its metadata and optionally its contents. This function supports both build and development modes.
|
|
23
9
|
*
|
|
@@ -35,55 +35,6 @@ async function handleSvgDeduplication(fileData, filename, fileEmitter) {
|
|
|
35
35
|
return handle;
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
|
-
async function emitESMImage(id, _watchMode, _experimentalSvgEnabled, fileEmitter) {
|
|
39
|
-
if (!id) {
|
|
40
|
-
return void 0;
|
|
41
|
-
}
|
|
42
|
-
const url = pathToFileURL(id);
|
|
43
|
-
let fileData;
|
|
44
|
-
try {
|
|
45
|
-
fileData = await fs.readFile(url);
|
|
46
|
-
} catch {
|
|
47
|
-
return void 0;
|
|
48
|
-
}
|
|
49
|
-
const fileMetadata = await imageMetadata(fileData, id);
|
|
50
|
-
const emittedImage = {
|
|
51
|
-
src: "",
|
|
52
|
-
...fileMetadata
|
|
53
|
-
};
|
|
54
|
-
Object.defineProperty(emittedImage, "fsPath", {
|
|
55
|
-
enumerable: false,
|
|
56
|
-
writable: false,
|
|
57
|
-
value: id
|
|
58
|
-
});
|
|
59
|
-
let isBuild = typeof fileEmitter === "function";
|
|
60
|
-
if (isBuild) {
|
|
61
|
-
const pathname = decodeURI(url.pathname);
|
|
62
|
-
const filename = path.basename(pathname, path.extname(pathname) + `.${fileMetadata.format}`);
|
|
63
|
-
try {
|
|
64
|
-
let handle;
|
|
65
|
-
if (fileMetadata.format === "svg") {
|
|
66
|
-
handle = await handleSvgDeduplication(fileData, filename, fileEmitter);
|
|
67
|
-
} else {
|
|
68
|
-
handle = fileEmitter({
|
|
69
|
-
name: filename,
|
|
70
|
-
source: fileData,
|
|
71
|
-
type: "asset"
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
emittedImage.src = `__ASTRO_ASSET_IMAGE__${handle}__`;
|
|
75
|
-
} catch {
|
|
76
|
-
isBuild = false;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
if (!isBuild) {
|
|
80
|
-
url.searchParams.append("origWidth", fileMetadata.width.toString());
|
|
81
|
-
url.searchParams.append("origHeight", fileMetadata.height.toString());
|
|
82
|
-
url.searchParams.append("origFormat", fileMetadata.format);
|
|
83
|
-
emittedImage.src = `/@fs` + prependForwardSlash(fileURLToNormalizedPath(url));
|
|
84
|
-
}
|
|
85
|
-
return emittedImage;
|
|
86
|
-
}
|
|
87
38
|
async function emitImageMetadata(id, fileEmitter) {
|
|
88
39
|
if (!id) {
|
|
89
40
|
return void 0;
|
|
@@ -137,6 +88,5 @@ function fileURLToNormalizedPath(filePath) {
|
|
|
137
88
|
return slash(fileURLToPath(filePath) + filePath.search).replace(/\\/g, "/");
|
|
138
89
|
}
|
|
139
90
|
export {
|
|
140
|
-
emitESMImage,
|
|
141
91
|
emitImageMetadata
|
|
142
92
|
};
|
|
@@ -13,7 +13,7 @@ import { VALID_INPUT_FORMATS, VIRTUAL_MODULE_ID, VIRTUAL_SERVICE_ID } from "./co
|
|
|
13
13
|
import { fontsPlugin } from "./fonts/vite-plugin-fonts.js";
|
|
14
14
|
import { getAssetsPrefix } from "./utils/getAssetsPrefix.js";
|
|
15
15
|
import { isESMImportedImage } from "./utils/imageKind.js";
|
|
16
|
-
import {
|
|
16
|
+
import { emitImageMetadata } from "./utils/node/emitAsset.js";
|
|
17
17
|
import { getProxyCode } from "./utils/proxy.js";
|
|
18
18
|
import { makeSvgComponent } from "./utils/svg.js";
|
|
19
19
|
import { hashTransform, propsToFilename } from "./utils/transformToPath.js";
|
|
@@ -190,13 +190,8 @@ function assets({ fs, settings, sync, logger }) {
|
|
|
190
190
|
if (!assetRegexEnds.test(id)) {
|
|
191
191
|
return;
|
|
192
192
|
}
|
|
193
|
-
const
|
|
194
|
-
const imageMetadata = await
|
|
195
|
-
id,
|
|
196
|
-
this.meta.watchMode,
|
|
197
|
-
id.endsWith(".svg"),
|
|
198
|
-
emitFile
|
|
199
|
-
);
|
|
193
|
+
const fileEmitter = shouldEmitFile ? this.emitFile.bind(this) : void 0;
|
|
194
|
+
const imageMetadata = await emitImageMetadata(id, fileEmitter);
|
|
200
195
|
if (!imageMetadata) {
|
|
201
196
|
throw new AstroError({
|
|
202
197
|
...AstroErrorData.ImageNotFound,
|
package/dist/cli/add/index.js
CHANGED
|
@@ -24,7 +24,6 @@ import {
|
|
|
24
24
|
import * as msg from "../../core/messages.js";
|
|
25
25
|
import { printHelp } from "../../core/messages.js";
|
|
26
26
|
import { appendForwardSlash } from "../../core/path.js";
|
|
27
|
-
import { apply as applyPolyfill } from "../../core/polyfill.js";
|
|
28
27
|
import { ensureProcessNodeEnv, parseNpmName } from "../../core/util.js";
|
|
29
28
|
import { eventCliSession, telemetry } from "../../events/index.js";
|
|
30
29
|
import { exec } from "../exec.js";
|
|
@@ -90,7 +89,6 @@ const OFFICIAL_ADAPTER_TO_IMPORT_MAP = {
|
|
|
90
89
|
};
|
|
91
90
|
async function add(names, { flags }) {
|
|
92
91
|
ensureProcessNodeEnv("production");
|
|
93
|
-
applyPolyfill();
|
|
94
92
|
const inlineConfig = flagsToAstroInlineConfig(flags);
|
|
95
93
|
const { userConfig } = await resolveConfig(inlineConfig, "add");
|
|
96
94
|
telemetry.record(eventCliSession("add", userConfig));
|
package/dist/cli/db/index.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { resolveConfig } from "../../core/config/config.js";
|
|
2
|
-
import { apply as applyPolyfill } from "../../core/polyfill.js";
|
|
3
2
|
import { createLoggerFromFlags, flagsToAstroInlineConfig } from "../flags.js";
|
|
4
3
|
import { getPackage } from "../install-package.js";
|
|
5
4
|
async function db({ flags }) {
|
|
6
|
-
applyPolyfill();
|
|
7
5
|
const logger = createLoggerFromFlags(flags);
|
|
8
6
|
const getPackageOpts = {
|
|
9
7
|
skipAsk: !!flags.yes || !!flags.y,
|
package/dist/cli/info/index.js
CHANGED
|
@@ -4,7 +4,6 @@ import colors from "picocolors";
|
|
|
4
4
|
import prompts from "prompts";
|
|
5
5
|
import { resolveConfig } from "../../core/config/index.js";
|
|
6
6
|
import { ASTRO_VERSION } from "../../core/constants.js";
|
|
7
|
-
import { apply as applyPolyfill } from "../../core/polyfill.js";
|
|
8
7
|
import { flagsToAstroInlineConfig } from "../flags.js";
|
|
9
8
|
async function getInfoOutput({
|
|
10
9
|
userConfig,
|
|
@@ -52,7 +51,6 @@ async function getInfoOutput({
|
|
|
52
51
|
return output.trim();
|
|
53
52
|
}
|
|
54
53
|
async function printInfo({ flags }) {
|
|
55
|
-
applyPolyfill();
|
|
56
54
|
const { userConfig } = await resolveConfig(flagsToAstroInlineConfig(flags), "info");
|
|
57
55
|
const output = await getInfoOutput({ userConfig, print: true });
|
|
58
56
|
await copyToClipboard(output, flags.copy);
|
|
@@ -7,7 +7,6 @@ import { resolveConfig } from "../../core/config/config.js";
|
|
|
7
7
|
import { createSettings } from "../../core/config/settings.js";
|
|
8
8
|
import { collectErrorMetadata } from "../../core/errors/dev/utils.js";
|
|
9
9
|
import * as msg from "../../core/messages.js";
|
|
10
|
-
import { apply as applyPolyfill } from "../../core/polyfill.js";
|
|
11
10
|
import { DEFAULT_PREFERENCES } from "../../preferences/defaults.js";
|
|
12
11
|
import { coerce, isValidKey } from "../../preferences/index.js";
|
|
13
12
|
import { createLoggerFromFlags, flagsToAstroInlineConfig } from "../flags.js";
|
|
@@ -25,7 +24,6 @@ function isValidSubcommand(subcommand) {
|
|
|
25
24
|
return PREFERENCES_SUBCOMMANDS.includes(subcommand);
|
|
26
25
|
}
|
|
27
26
|
async function preferences(subcommand, key, value, { flags }) {
|
|
28
|
-
applyPolyfill();
|
|
29
27
|
if (!isValidSubcommand(subcommand) || flags?.help || flags?.h) {
|
|
30
28
|
msg.printHelp({
|
|
31
29
|
commandName: "astro preferences",
|
package/dist/config/index.js
CHANGED
|
@@ -7,21 +7,17 @@ function getViteConfig(userViteConfig, inlineAstroConfig = {}) {
|
|
|
7
7
|
return async ({ mode, command }) => {
|
|
8
8
|
const cmd = command === "serve" ? "dev" : "build";
|
|
9
9
|
const [
|
|
10
|
-
fs,
|
|
11
10
|
{ mergeConfig },
|
|
12
11
|
{ createNodeLogger },
|
|
13
12
|
{ resolveConfig, createSettings },
|
|
14
13
|
{ createVite },
|
|
15
|
-
{ runHookConfigSetup, runHookConfigDone }
|
|
16
|
-
{ astroContentListenPlugin }
|
|
14
|
+
{ runHookConfigSetup, runHookConfigDone }
|
|
17
15
|
] = await Promise.all([
|
|
18
|
-
import("node:fs"),
|
|
19
16
|
import("vite"),
|
|
20
17
|
import("../core/config/logging.js"),
|
|
21
18
|
import("../core/config/index.js"),
|
|
22
19
|
import("../core/create-vite.js"),
|
|
23
|
-
import("../integrations/hooks.js")
|
|
24
|
-
import("./vite-plugin-content-listen.js")
|
|
20
|
+
import("../integrations/hooks.js")
|
|
25
21
|
]);
|
|
26
22
|
const logger = createNodeLogger(inlineAstroConfig);
|
|
27
23
|
const { astroConfig: config } = await resolveConfig(inlineAstroConfig, cmd);
|
|
@@ -30,12 +26,7 @@ function getViteConfig(userViteConfig, inlineAstroConfig = {}) {
|
|
|
30
26
|
const routesList = await createRoutesList({ settings }, logger);
|
|
31
27
|
const manifest = createDevelopmentManifest(settings);
|
|
32
28
|
const viteConfig = await createVite(
|
|
33
|
-
{
|
|
34
|
-
plugins: config.legacy.collections ? [
|
|
35
|
-
// Initialize the content listener
|
|
36
|
-
astroContentListenPlugin({ settings, logger, fs })
|
|
37
|
-
] : []
|
|
38
|
-
},
|
|
29
|
+
{},
|
|
39
30
|
{ settings, command: cmd, logger, mode, sync: false, manifest, routesList }
|
|
40
31
|
);
|
|
41
32
|
await runHookConfigDone({ settings, logger });
|
package/dist/container/index.js
CHANGED
package/dist/content/config.js
CHANGED
|
@@ -71,20 +71,24 @@ function defineCollection(config) {
|
|
|
71
71
|
)
|
|
72
72
|
});
|
|
73
73
|
}
|
|
74
|
-
if ("loader" in config) {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
)
|
|
84
|
-
}
|
|
85
|
-
|
|
74
|
+
if (!("loader" in config)) {
|
|
75
|
+
throw new AstroError({
|
|
76
|
+
...AstroErrorData.ContentCollectionMissingLoader,
|
|
77
|
+
message: AstroErrorData.ContentCollectionMissingLoader.message(importerFilename)
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
if (config.type && config.type !== CONTENT_LAYER_TYPE) {
|
|
81
|
+
throw new AstroError({
|
|
82
|
+
...AstroErrorData.ContentCollectionInvalidType,
|
|
83
|
+
message: AstroErrorData.ContentCollectionInvalidType.message(config.type, importerFilename)
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
if (typeof config.loader === "object" && typeof config.loader.load !== "function" && ("loadEntry" in config.loader || "loadCollection" in config.loader)) {
|
|
87
|
+
throw new AstroUserError(
|
|
88
|
+
`Live content collections must be defined in "src/live.config.ts" file. Check your collection definitions in "${importerFilename ?? "your content config file"}" to ensure you are not using a live loader.`
|
|
89
|
+
);
|
|
86
90
|
}
|
|
87
|
-
|
|
91
|
+
config.type = CONTENT_LAYER_TYPE;
|
|
88
92
|
return config;
|
|
89
93
|
}
|
|
90
94
|
export {
|
|
@@ -164,7 +164,7 @@ ${contentConfig.error.message}`);
|
|
|
164
164
|
logger.info("Content config changed");
|
|
165
165
|
shouldClear = true;
|
|
166
166
|
}
|
|
167
|
-
if (previousAstroVersion && previousAstroVersion !== "
|
|
167
|
+
if (previousAstroVersion && previousAstroVersion !== "6.0.0-alpha.0") {
|
|
168
168
|
logger.info("Astro version changed");
|
|
169
169
|
shouldClear = true;
|
|
170
170
|
}
|
|
@@ -172,8 +172,8 @@ ${contentConfig.error.message}`);
|
|
|
172
172
|
logger.info("Clearing content store");
|
|
173
173
|
this.#store.clearAll();
|
|
174
174
|
}
|
|
175
|
-
if ("
|
|
176
|
-
await this.#store.metaStore().set("astro-version", "
|
|
175
|
+
if ("6.0.0-alpha.0") {
|
|
176
|
+
await this.#store.metaStore().set("astro-version", "6.0.0-alpha.0");
|
|
177
177
|
}
|
|
178
178
|
if (currentConfigDigest) {
|
|
179
179
|
await this.#store.metaStore().set("content-config-digest", currentConfigDigest);
|
|
@@ -212,9 +212,7 @@ ${contentConfig.error.message}`);
|
|
|
212
212
|
}
|
|
213
213
|
},
|
|
214
214
|
collectionWithResolvedSchema,
|
|
215
|
-
false
|
|
216
|
-
// FUTURE: Remove in this in v6
|
|
217
|
-
id.endsWith(".svg")
|
|
215
|
+
false
|
|
218
216
|
);
|
|
219
217
|
return parsedData;
|
|
220
218
|
};
|
|
@@ -31,8 +31,6 @@ export interface DataEntry<TData extends Record<string, unknown> = Record<string
|
|
|
31
31
|
*/
|
|
32
32
|
deferredRender?: boolean;
|
|
33
33
|
assetImports?: Array<string>;
|
|
34
|
-
/** @deprecated */
|
|
35
|
-
legacyId?: string;
|
|
36
34
|
}
|
|
37
35
|
/**
|
|
38
36
|
* A read-only data store for content collections. This is used to retrieve data from the content layer at runtime.
|
|
@@ -23,9 +23,4 @@ interface GlobOptions {
|
|
|
23
23
|
* @param pattern A glob pattern to match files, relative to the content directory.
|
|
24
24
|
*/
|
|
25
25
|
export declare function glob(globOptions: GlobOptions): Loader;
|
|
26
|
-
/** @private */
|
|
27
|
-
export declare function glob(globOptions: GlobOptions & {
|
|
28
|
-
/** @deprecated */
|
|
29
|
-
_legacy?: true;
|
|
30
|
-
}): Loader;
|
|
31
26
|
export {};
|
|
@@ -42,8 +42,6 @@ function glob(globOptions) {
|
|
|
42
42
|
load: async ({ config, logger, watcher, parseData, store, generateDigest, entryTypes }) => {
|
|
43
43
|
const renderFunctionByContentType = /* @__PURE__ */ new WeakMap();
|
|
44
44
|
const untouchedEntries = new Set(store.keys());
|
|
45
|
-
const isLegacy = globOptions._legacy;
|
|
46
|
-
const emulateLegacyCollections = !config.legacy.collections;
|
|
47
45
|
async function syncData(entry, base, entryType, oldId) {
|
|
48
46
|
if (!entryType) {
|
|
49
47
|
logger.warn(`No entry type found for ${entry}`);
|
|
@@ -66,16 +64,6 @@ function glob(globOptions) {
|
|
|
66
64
|
if (oldId && oldId !== id) {
|
|
67
65
|
store.delete(oldId);
|
|
68
66
|
}
|
|
69
|
-
let legacyId;
|
|
70
|
-
if (isLegacy) {
|
|
71
|
-
const entryURL = new URL(encodeURI(entry), base);
|
|
72
|
-
const legacyOptions = getContentEntryIdAndSlug({
|
|
73
|
-
entry: entryURL,
|
|
74
|
-
contentDir: base,
|
|
75
|
-
collection: ""
|
|
76
|
-
});
|
|
77
|
-
legacyId = legacyOptions.id;
|
|
78
|
-
}
|
|
79
67
|
untouchedEntries.delete(id);
|
|
80
68
|
const existingEntry = store.get(id);
|
|
81
69
|
const digest = generateDigest(contents);
|
|
@@ -97,11 +85,6 @@ function glob(globOptions) {
|
|
|
97
85
|
filePath: filePath2
|
|
98
86
|
});
|
|
99
87
|
if (entryType.getRenderFunction) {
|
|
100
|
-
if (isLegacy && data.layout) {
|
|
101
|
-
logger.error(
|
|
102
|
-
`The Markdown "layout" field is not supported in content collections in Astro 5. Ignoring layout for ${JSON.stringify(entry)}. Enable "legacy.collections" if you need to use the layout field.`
|
|
103
|
-
);
|
|
104
|
-
}
|
|
105
88
|
let render = renderFunctionByContentType.get(entryType);
|
|
106
89
|
if (!render) {
|
|
107
90
|
render = await entryType.getRenderFunction(config);
|
|
@@ -126,8 +109,7 @@ function glob(globOptions) {
|
|
|
126
109
|
filePath: relativePath2,
|
|
127
110
|
digest,
|
|
128
111
|
rendered,
|
|
129
|
-
assetImports: rendered?.metadata?.imagePaths
|
|
130
|
-
legacyId
|
|
112
|
+
assetImports: rendered?.metadata?.imagePaths
|
|
131
113
|
});
|
|
132
114
|
} else if ("contentModuleTypes" in entryType) {
|
|
133
115
|
store.set({
|
|
@@ -136,11 +118,10 @@ function glob(globOptions) {
|
|
|
136
118
|
body,
|
|
137
119
|
filePath: relativePath2,
|
|
138
120
|
digest,
|
|
139
|
-
deferredRender: true
|
|
140
|
-
legacyId
|
|
121
|
+
deferredRender: true
|
|
141
122
|
});
|
|
142
123
|
} else {
|
|
143
|
-
store.set({ id, data: parsedData, body, filePath: relativePath2, digest
|
|
124
|
+
store.set({ id, data: parsedData, body, filePath: relativePath2, digest });
|
|
144
125
|
}
|
|
145
126
|
fileToIdMap.set(filePath2, id);
|
|
146
127
|
}
|
|
@@ -175,10 +156,6 @@ function glob(globOptions) {
|
|
|
175
156
|
const limit = pLimit(10);
|
|
176
157
|
const skippedFiles = [];
|
|
177
158
|
const contentDir = new URL("content/", config.srcDir);
|
|
178
|
-
function isInContentDir(file) {
|
|
179
|
-
const fileUrl = new URL(file, baseDir);
|
|
180
|
-
return fileUrl.href.startsWith(contentDir.href);
|
|
181
|
-
}
|
|
182
159
|
const configFiles = new Set(
|
|
183
160
|
["config.js", "config.ts", "config.mjs"].map((file) => new URL(file, contentDir).href)
|
|
184
161
|
);
|
|
@@ -191,10 +168,6 @@ function glob(globOptions) {
|
|
|
191
168
|
if (isConfigFile(entry)) {
|
|
192
169
|
return;
|
|
193
170
|
}
|
|
194
|
-
if (!emulateLegacyCollections && isInContentDir(entry)) {
|
|
195
|
-
skippedFiles.push(entry);
|
|
196
|
-
return;
|
|
197
|
-
}
|
|
198
171
|
return limit(async () => {
|
|
199
172
|
const entryType = configForFile(entry);
|
|
200
173
|
await syncData(entry, baseDir, entryType);
|