astro 5.0.4 → 5.0.5
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/dist/assets/utils/node/emitAsset.d.ts +1 -1
- package/dist/assets/utils/node/emitAsset.js +2 -2
- package/dist/assets/vite-plugin-assets.js +6 -1
- package/dist/cli/info/index.js +2 -2
- package/dist/content/content-layer.js +5 -4
- package/dist/content/mutable-data-store.js +2 -2
- package/dist/content/runtime-assets.d.ts +1 -1
- package/dist/content/runtime-assets.js +2 -1
- package/dist/content/utils.d.ts +2 -2
- package/dist/content/utils.js +9 -3
- package/dist/content/vite-plugin-content-imports.js +2 -0
- package/dist/core/build/pipeline.js +4 -5
- package/dist/core/constants.js +1 -1
- package/dist/core/dev/dev.js +1 -1
- package/dist/core/messages.js +2 -2
- package/dist/core/util.js +3 -2
- package/package.json +1 -1
|
@@ -6,5 +6,5 @@ type ImageMetadataWithContents = ImageMetadata & {
|
|
|
6
6
|
};
|
|
7
7
|
export declare function emitESMImage(id: string | undefined,
|
|
8
8
|
/** @deprecated */
|
|
9
|
-
_watchMode: boolean, fileEmitter?: FileEmitter): Promise<ImageMetadataWithContents | undefined>;
|
|
9
|
+
_watchMode: boolean, experimentalSvgEnabled: boolean, fileEmitter?: FileEmitter): Promise<ImageMetadataWithContents | undefined>;
|
|
10
10
|
export {};
|
|
@@ -3,7 +3,7 @@ import path from "node:path";
|
|
|
3
3
|
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
4
4
|
import { prependForwardSlash, slash } from "../../../core/path.js";
|
|
5
5
|
import { imageMetadata } from "../metadata.js";
|
|
6
|
-
async function emitESMImage(id, _watchMode, fileEmitter) {
|
|
6
|
+
async function emitESMImage(id, _watchMode, experimentalSvgEnabled, fileEmitter) {
|
|
7
7
|
if (!id) {
|
|
8
8
|
return void 0;
|
|
9
9
|
}
|
|
@@ -24,7 +24,7 @@ async function emitESMImage(id, _watchMode, fileEmitter) {
|
|
|
24
24
|
writable: false,
|
|
25
25
|
value: id
|
|
26
26
|
});
|
|
27
|
-
if (fileMetadata.format === "svg") {
|
|
27
|
+
if (fileMetadata.format === "svg" && experimentalSvgEnabled === true) {
|
|
28
28
|
emittedImage.contents = fileData;
|
|
29
29
|
}
|
|
30
30
|
let isBuild = typeof fileEmitter === "function";
|
|
@@ -167,7 +167,12 @@ function assets({ settings }) {
|
|
|
167
167
|
return;
|
|
168
168
|
}
|
|
169
169
|
const emitFile = shouldEmitFile ? this.emitFile : void 0;
|
|
170
|
-
const imageMetadata = await emitESMImage(
|
|
170
|
+
const imageMetadata = await emitESMImage(
|
|
171
|
+
id,
|
|
172
|
+
this.meta.watchMode,
|
|
173
|
+
!!settings.config.experimental.svg,
|
|
174
|
+
emitFile
|
|
175
|
+
);
|
|
171
176
|
if (!imageMetadata) {
|
|
172
177
|
throw new AstroError({
|
|
173
178
|
...AstroErrorData.ImageNotFound,
|
package/dist/cli/info/index.js
CHANGED
|
@@ -46,7 +46,7 @@ async function copyToClipboard(text, force) {
|
|
|
46
46
|
command = "clip";
|
|
47
47
|
} else {
|
|
48
48
|
const unixCommands = [
|
|
49
|
-
["xclip", ["-
|
|
49
|
+
["xclip", ["-selection", "clipboard", "-l", "1"]],
|
|
50
50
|
["wl-copy", []]
|
|
51
51
|
];
|
|
52
52
|
for (const [unixCommand, unixArgs] of unixCommands) {
|
|
@@ -77,7 +77,7 @@ async function copyToClipboard(text, force) {
|
|
|
77
77
|
if (!shouldCopy) return;
|
|
78
78
|
}
|
|
79
79
|
try {
|
|
80
|
-
const result = spawnSync(command, args, { input: text });
|
|
80
|
+
const result = spawnSync(command, args, { input: text, stdio: ["pipe", "ignore", "ignore"] });
|
|
81
81
|
if (result.error) {
|
|
82
82
|
throw result.error;
|
|
83
83
|
}
|
|
@@ -114,7 +114,7 @@ class ContentLayer {
|
|
|
114
114
|
logger.info("Content config changed");
|
|
115
115
|
shouldClear = true;
|
|
116
116
|
}
|
|
117
|
-
if (previousAstroVersion !== "5.0.
|
|
117
|
+
if (previousAstroVersion !== "5.0.5") {
|
|
118
118
|
logger.info("Astro version changed");
|
|
119
119
|
shouldClear = true;
|
|
120
120
|
}
|
|
@@ -122,8 +122,8 @@ class ContentLayer {
|
|
|
122
122
|
logger.info("Clearing content store");
|
|
123
123
|
this.#store.clearAll();
|
|
124
124
|
}
|
|
125
|
-
if ("5.0.
|
|
126
|
-
await this.#store.metaStore().set("astro-version", "5.0.
|
|
125
|
+
if ("5.0.5") {
|
|
126
|
+
await this.#store.metaStore().set("astro-version", "5.0.5");
|
|
127
127
|
}
|
|
128
128
|
if (currentConfigDigest) {
|
|
129
129
|
await this.#store.metaStore().set("config-digest", currentConfigDigest);
|
|
@@ -156,7 +156,8 @@ class ContentLayer {
|
|
|
156
156
|
}
|
|
157
157
|
},
|
|
158
158
|
collectionWithResolvedSchema,
|
|
159
|
-
false
|
|
159
|
+
false,
|
|
160
|
+
!!this.#settings.config.experimental.svg
|
|
160
161
|
);
|
|
161
162
|
return parsedData;
|
|
162
163
|
};
|
|
@@ -73,7 +73,7 @@ class MutableDataStore extends ImmutableDataStore {
|
|
|
73
73
|
const exports = [];
|
|
74
74
|
this.#assetImports.forEach((id) => {
|
|
75
75
|
const symbol = importIdToSymbolName(id);
|
|
76
|
-
imports.push(`import ${symbol} from
|
|
76
|
+
imports.push(`import ${symbol} from ${JSON.stringify(id)};`);
|
|
77
77
|
exports.push(`[${JSON.stringify(id)}, ${symbol}]`);
|
|
78
78
|
});
|
|
79
79
|
const code = (
|
|
@@ -104,7 +104,7 @@ export default new Map([${exports.join(", ")}]);
|
|
|
104
104
|
}
|
|
105
105
|
const lines = [];
|
|
106
106
|
for (const [fileName, specifier] of this.#moduleImports) {
|
|
107
|
-
lines.push(`[
|
|
107
|
+
lines.push(`[${JSON.stringify(fileName)}, () => import(${JSON.stringify(specifier)})]`);
|
|
108
108
|
}
|
|
109
109
|
const code = `
|
|
110
110
|
export default new Map([
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { PluginContext } from 'rollup';
|
|
2
2
|
import { z } from 'zod';
|
|
3
|
-
export declare function createImage(pluginContext: PluginContext, shouldEmitFile: boolean, entryFilePath: string): () => z.ZodEffects<z.ZodString, z.ZodNever | {
|
|
3
|
+
export declare function createImage(pluginContext: PluginContext, shouldEmitFile: boolean, entryFilePath: string, experimentalSvgEnabled: boolean): () => z.ZodEffects<z.ZodString, z.ZodNever | {
|
|
4
4
|
ASTRO_ASSET: string;
|
|
5
5
|
width: number;
|
|
6
6
|
height: number;
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { emitESMImage } from "../assets/utils/node/emitAsset.js";
|
|
3
|
-
function createImage(pluginContext, shouldEmitFile, entryFilePath) {
|
|
3
|
+
function createImage(pluginContext, shouldEmitFile, entryFilePath, experimentalSvgEnabled) {
|
|
4
4
|
return () => {
|
|
5
5
|
return z.string().transform(async (imagePath, ctx) => {
|
|
6
6
|
const resolvedFilePath = (await pluginContext.resolve(imagePath, entryFilePath))?.id;
|
|
7
7
|
const metadata = await emitESMImage(
|
|
8
8
|
resolvedFilePath,
|
|
9
9
|
pluginContext.meta.watchMode,
|
|
10
|
+
experimentalSvgEnabled,
|
|
10
11
|
shouldEmitFile ? pluginContext.emitFile : void 0
|
|
11
12
|
);
|
|
12
13
|
if (!metadata) {
|
package/dist/content/utils.d.ts
CHANGED
|
@@ -469,7 +469,7 @@ export declare function getEntryDataAndImages<TInputData extends Record<string,
|
|
|
469
469
|
collection: string;
|
|
470
470
|
unvalidatedData: TInputData;
|
|
471
471
|
_internal: EntryInternal;
|
|
472
|
-
}, collectionConfig: CollectionConfig, shouldEmitFile: boolean, pluginContext?: PluginContext): Promise<{
|
|
472
|
+
}, collectionConfig: CollectionConfig, shouldEmitFile: boolean, experimentalSvgEnabled: boolean, pluginContext?: PluginContext): Promise<{
|
|
473
473
|
data: TOutputData;
|
|
474
474
|
imageImports: Array<string>;
|
|
475
475
|
}>;
|
|
@@ -478,7 +478,7 @@ export declare function getEntryData(entry: {
|
|
|
478
478
|
collection: string;
|
|
479
479
|
unvalidatedData: Record<string, unknown>;
|
|
480
480
|
_internal: EntryInternal;
|
|
481
|
-
}, collectionConfig: CollectionConfig, shouldEmitFile: boolean, pluginContext?: PluginContext): Promise<Record<string, unknown>>;
|
|
481
|
+
}, collectionConfig: CollectionConfig, shouldEmitFile: boolean, experimentalSvgEnabled: boolean, pluginContext?: PluginContext): Promise<Record<string, unknown>>;
|
|
482
482
|
export declare function getContentEntryExts(settings: Pick<AstroSettings, 'contentEntryTypes'>): string[];
|
|
483
483
|
export declare function getDataEntryExts(settings: Pick<AstroSettings, 'dataEntryTypes'>): string[];
|
|
484
484
|
export declare function getEntryConfigByExtMap<TEntryType extends ContentEntryType | DataEntryType>(entryTypes: TEntryType[]): Map<string, TEntryType>;
|
package/dist/content/utils.js
CHANGED
|
@@ -110,7 +110,7 @@ function parseEntrySlug({
|
|
|
110
110
|
});
|
|
111
111
|
}
|
|
112
112
|
}
|
|
113
|
-
async function getEntryDataAndImages(entry, collectionConfig, shouldEmitFile, pluginContext) {
|
|
113
|
+
async function getEntryDataAndImages(entry, collectionConfig, shouldEmitFile, experimentalSvgEnabled, pluginContext) {
|
|
114
114
|
let data;
|
|
115
115
|
if (collectionConfig.type === "content" || collectionConfig._legacy) {
|
|
116
116
|
const { slug, ...unvalidatedData } = entry.unvalidatedData;
|
|
@@ -123,7 +123,12 @@ async function getEntryDataAndImages(entry, collectionConfig, shouldEmitFile, pl
|
|
|
123
123
|
if (typeof schema === "function") {
|
|
124
124
|
if (pluginContext) {
|
|
125
125
|
schema = schema({
|
|
126
|
-
image: createImage(
|
|
126
|
+
image: createImage(
|
|
127
|
+
pluginContext,
|
|
128
|
+
shouldEmitFile,
|
|
129
|
+
entry._internal.filePath,
|
|
130
|
+
experimentalSvgEnabled
|
|
131
|
+
)
|
|
127
132
|
});
|
|
128
133
|
} else if (collectionConfig.type === CONTENT_LAYER_TYPE) {
|
|
129
134
|
schema = schema({
|
|
@@ -173,11 +178,12 @@ async function getEntryDataAndImages(entry, collectionConfig, shouldEmitFile, pl
|
|
|
173
178
|
}
|
|
174
179
|
return { data, imageImports: Array.from(imageImports) };
|
|
175
180
|
}
|
|
176
|
-
async function getEntryData(entry, collectionConfig, shouldEmitFile, pluginContext) {
|
|
181
|
+
async function getEntryData(entry, collectionConfig, shouldEmitFile, experimentalSvgEnabled, pluginContext) {
|
|
177
182
|
const { data } = await getEntryDataAndImages(
|
|
178
183
|
entry,
|
|
179
184
|
collectionConfig,
|
|
180
185
|
shouldEmitFile,
|
|
186
|
+
experimentalSvgEnabled,
|
|
181
187
|
pluginContext
|
|
182
188
|
);
|
|
183
189
|
return data;
|
|
@@ -171,6 +171,7 @@ async function getContentEntryModule(params) {
|
|
|
171
171
|
{ id, collection, _internal, unvalidatedData },
|
|
172
172
|
collectionConfig,
|
|
173
173
|
params.shouldEmitFile,
|
|
174
|
+
!!params.config.experimental.svg,
|
|
174
175
|
pluginContext
|
|
175
176
|
) : unvalidatedData;
|
|
176
177
|
const contentEntryModule = {
|
|
@@ -196,6 +197,7 @@ async function getDataEntryModule(params) {
|
|
|
196
197
|
{ id, collection, _internal, unvalidatedData },
|
|
197
198
|
collectionConfig,
|
|
198
199
|
params.shouldEmitFile,
|
|
200
|
+
!!params.config.experimental.svg,
|
|
199
201
|
pluginContext
|
|
200
202
|
) : unvalidatedData;
|
|
201
203
|
const dataEntryModule = {
|
|
@@ -94,11 +94,10 @@ class BuildPipeline extends Pipeline {
|
|
|
94
94
|
}
|
|
95
95
|
const renderersEntryUrl = new URL(`renderers.mjs?time=${Date.now()}`, baseDirectory);
|
|
96
96
|
const renderers = await import(renderersEntryUrl.toString());
|
|
97
|
-
const middleware = internals.middlewareEntryPoint ?
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
}) : manifest.middleware;
|
|
97
|
+
const middleware = internals.middlewareEntryPoint ? async function() {
|
|
98
|
+
const mod = await import(internals.middlewareEntryPoint.toString());
|
|
99
|
+
return { onRequest: mod.onRequest };
|
|
100
|
+
} : manifest.middleware;
|
|
102
101
|
if (!renderers) {
|
|
103
102
|
throw new Error(
|
|
104
103
|
"Astro couldn't find the emitted renderers. This is an internal error, please file an issue."
|
package/dist/core/constants.js
CHANGED
package/dist/core/dev/dev.js
CHANGED
|
@@ -22,7 +22,7 @@ async function dev(inlineConfig) {
|
|
|
22
22
|
await telemetry.record([]);
|
|
23
23
|
const restart = await createContainerWithAutomaticRestart({ inlineConfig, fs });
|
|
24
24
|
const logger = restart.container.logger;
|
|
25
|
-
const currentVersion = "5.0.
|
|
25
|
+
const currentVersion = "5.0.5";
|
|
26
26
|
const isPrerelease = currentVersion.includes("-");
|
|
27
27
|
if (!isPrerelease) {
|
|
28
28
|
try {
|
package/dist/core/messages.js
CHANGED
|
@@ -38,7 +38,7 @@ function serverStart({
|
|
|
38
38
|
host,
|
|
39
39
|
base
|
|
40
40
|
}) {
|
|
41
|
-
const version = "5.0.
|
|
41
|
+
const version = "5.0.5";
|
|
42
42
|
const localPrefix = `${dim("\u2503")} Local `;
|
|
43
43
|
const networkPrefix = `${dim("\u2503")} Network `;
|
|
44
44
|
const emptyPrefix = " ".repeat(11);
|
|
@@ -276,7 +276,7 @@ function printHelp({
|
|
|
276
276
|
message.push(
|
|
277
277
|
linebreak(),
|
|
278
278
|
` ${bgGreen(black(` ${commandName} `))} ${green(
|
|
279
|
-
`v${"5.0.
|
|
279
|
+
`v${"5.0.5"}`
|
|
280
280
|
)} ${headline}`
|
|
281
281
|
);
|
|
282
282
|
}
|
package/dist/core/util.js
CHANGED
|
@@ -2,7 +2,7 @@ import fs from "node:fs";
|
|
|
2
2
|
import path from "node:path";
|
|
3
3
|
import { fileURLToPath } from "node:url";
|
|
4
4
|
import { SUPPORTED_MARKDOWN_FILE_EXTENSIONS } from "./constants.js";
|
|
5
|
-
import { removeTrailingForwardSlash, slash } from "./path.js";
|
|
5
|
+
import { removeQueryString, removeTrailingForwardSlash, slash } from "./path.js";
|
|
6
6
|
function isObject(value) {
|
|
7
7
|
return typeof value === "object" && value != null;
|
|
8
8
|
}
|
|
@@ -10,9 +10,10 @@ function isURL(value) {
|
|
|
10
10
|
return Object.prototype.toString.call(value) === "[object URL]";
|
|
11
11
|
}
|
|
12
12
|
function isMarkdownFile(fileId, option) {
|
|
13
|
+
const id = removeQueryString(fileId);
|
|
13
14
|
const _suffix = option?.suffix ?? "";
|
|
14
15
|
for (let markdownFileExtension of SUPPORTED_MARKDOWN_FILE_EXTENSIONS) {
|
|
15
|
-
if (
|
|
16
|
+
if (id.endsWith(`${markdownFileExtension}${_suffix}`)) return true;
|
|
16
17
|
}
|
|
17
18
|
return false;
|
|
18
19
|
}
|