astro 4.3.2 → 4.3.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/client.d.ts +4 -0
- package/components/Picture.astro +3 -3
- package/content-types.template.d.ts +0 -49
- package/dist/@types/astro.d.ts +1 -1
- package/dist/content/vite-plugin-content-assets.js +16 -6
- 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/module-loader/loader.d.ts +1 -0
- package/dist/core/render/context.js +10 -1
- package/dist/runtime/server/index.js +1 -4
- package/dist/virtual-modules/content.d.ts +54 -0
- package/dist/virtual-modules/content.js +23 -0
- package/dist/vite-plugin-astro-server/css.d.ts +1 -0
- package/dist/vite-plugin-astro-server/css.js +6 -1
- package/dist/vite-plugin-astro-server/route.js +1 -1
- package/dist/vite-plugin-astro-server/scripts.d.ts +4 -1
- package/dist/vite-plugin-astro-server/scripts.js +5 -1
- package/package.json +2 -2
package/client.d.ts
CHANGED
|
@@ -160,6 +160,10 @@ declare module 'astro:components' {
|
|
|
160
160
|
export * from 'astro/components';
|
|
161
161
|
}
|
|
162
162
|
|
|
163
|
+
declare module 'astro:content' {
|
|
164
|
+
export * from 'astro/virtual-modules/content.js';
|
|
165
|
+
}
|
|
166
|
+
|
|
163
167
|
type MD = import('./dist/@types/astro.js').MarkdownInstance<Record<string, any>>;
|
|
164
168
|
interface ExportedMarkdownModuleEntities {
|
|
165
169
|
frontmatter: MD['frontmatter'];
|
package/components/Picture.astro
CHANGED
|
@@ -51,11 +51,11 @@ const fallbackImage = await getImage({
|
|
|
51
51
|
});
|
|
52
52
|
|
|
53
53
|
const imgAdditionalAttributes: HTMLAttributes<'img'> = {};
|
|
54
|
-
const
|
|
54
|
+
const sourceAdditionalAttributes: HTMLAttributes<'source'> = {};
|
|
55
55
|
|
|
56
56
|
// Propagate the `sizes` attribute to the `source` elements
|
|
57
57
|
if (props.sizes) {
|
|
58
|
-
|
|
58
|
+
sourceAdditionalAttributes.sizes = props.sizes;
|
|
59
59
|
}
|
|
60
60
|
|
|
61
61
|
if (fallbackImage.srcSet.values.length > 0) {
|
|
@@ -74,7 +74,7 @@ if (fallbackImage.srcSet.values.length > 0) {
|
|
|
74
74
|
<source
|
|
75
75
|
srcset={srcsetAttribute}
|
|
76
76
|
type={'image/' + image.options.format}
|
|
77
|
-
{...
|
|
77
|
+
{...sourceAdditionalAttributes}
|
|
78
78
|
/>
|
|
79
79
|
);
|
|
80
80
|
})
|
|
@@ -9,8 +9,6 @@ declare module 'astro:content' {
|
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
declare module 'astro:content' {
|
|
12
|
-
export { z } from 'astro/zod';
|
|
13
|
-
|
|
14
12
|
type Flatten<T> = T extends { [K: string]: infer U } ? U : never;
|
|
15
13
|
|
|
16
14
|
export type CollectionKey = keyof AnyEntryMap;
|
|
@@ -19,53 +17,6 @@ declare module 'astro:content' {
|
|
|
19
17
|
export type ContentCollectionKey = keyof ContentEntryMap;
|
|
20
18
|
export type DataCollectionKey = keyof DataEntryMap;
|
|
21
19
|
|
|
22
|
-
// This needs to be in sync with ImageMetadata
|
|
23
|
-
export type ImageFunction = () => import('astro/zod').ZodObject<{
|
|
24
|
-
src: import('astro/zod').ZodString;
|
|
25
|
-
width: import('astro/zod').ZodNumber;
|
|
26
|
-
height: import('astro/zod').ZodNumber;
|
|
27
|
-
format: import('astro/zod').ZodUnion<
|
|
28
|
-
[
|
|
29
|
-
import('astro/zod').ZodLiteral<'png'>,
|
|
30
|
-
import('astro/zod').ZodLiteral<'jpg'>,
|
|
31
|
-
import('astro/zod').ZodLiteral<'jpeg'>,
|
|
32
|
-
import('astro/zod').ZodLiteral<'tiff'>,
|
|
33
|
-
import('astro/zod').ZodLiteral<'webp'>,
|
|
34
|
-
import('astro/zod').ZodLiteral<'gif'>,
|
|
35
|
-
import('astro/zod').ZodLiteral<'svg'>,
|
|
36
|
-
import('astro/zod').ZodLiteral<'avif'>,
|
|
37
|
-
]
|
|
38
|
-
>;
|
|
39
|
-
}>;
|
|
40
|
-
|
|
41
|
-
type BaseSchemaWithoutEffects =
|
|
42
|
-
| import('astro/zod').AnyZodObject
|
|
43
|
-
| import('astro/zod').ZodUnion<[BaseSchemaWithoutEffects, ...BaseSchemaWithoutEffects[]]>
|
|
44
|
-
| import('astro/zod').ZodDiscriminatedUnion<string, import('astro/zod').AnyZodObject[]>
|
|
45
|
-
| import('astro/zod').ZodIntersection<BaseSchemaWithoutEffects, BaseSchemaWithoutEffects>;
|
|
46
|
-
|
|
47
|
-
type BaseSchema =
|
|
48
|
-
| BaseSchemaWithoutEffects
|
|
49
|
-
| import('astro/zod').ZodEffects<BaseSchemaWithoutEffects>;
|
|
50
|
-
|
|
51
|
-
export type SchemaContext = { image: ImageFunction };
|
|
52
|
-
|
|
53
|
-
type DataCollectionConfig<S extends BaseSchema> = {
|
|
54
|
-
type: 'data';
|
|
55
|
-
schema?: S | ((context: SchemaContext) => S);
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
type ContentCollectionConfig<S extends BaseSchema> = {
|
|
59
|
-
type?: 'content';
|
|
60
|
-
schema?: S | ((context: SchemaContext) => S);
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
type CollectionConfig<S> = ContentCollectionConfig<S> | DataCollectionConfig<S>;
|
|
64
|
-
|
|
65
|
-
export function defineCollection<S extends BaseSchema>(
|
|
66
|
-
input: CollectionConfig<S>
|
|
67
|
-
): CollectionConfig<S>;
|
|
68
|
-
|
|
69
20
|
type AllValuesOf<T> = T extends any ? T[keyof T] : never;
|
|
70
21
|
type ValidContentEntrySlug<C extends keyof ContentEntryMap> = AllValuesOf<
|
|
71
22
|
ContentEntryMap[C]
|
package/dist/@types/astro.d.ts
CHANGED
|
@@ -1410,7 +1410,7 @@ export interface AstroUserConfig {
|
|
|
1410
1410
|
* @version 3.7.0
|
|
1411
1411
|
* @description
|
|
1412
1412
|
*
|
|
1413
|
-
* - `"
|
|
1413
|
+
* - `"pathname": The strategy is applied to the pathname of the URLs
|
|
1414
1414
|
*/
|
|
1415
1415
|
strategy: 'pathname';
|
|
1416
1416
|
/**
|
|
@@ -49,12 +49,22 @@ function astroContentAssetPropagationPlugin({
|
|
|
49
49
|
if (!devModuleLoader.getModuleById(basePath)?.ssrModule) {
|
|
50
50
|
await devModuleLoader.import(basePath);
|
|
51
51
|
}
|
|
52
|
-
const {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
);
|
|
52
|
+
const {
|
|
53
|
+
styles,
|
|
54
|
+
urls,
|
|
55
|
+
crawledFiles: styleCrawledFiles
|
|
56
|
+
} = await getStylesForURL(pathToFileURL(basePath), devModuleLoader);
|
|
57
|
+
const { scripts: hoistedScripts, crawledFiles: scriptCrawledFiles } = await getScriptsForURL(pathToFileURL(basePath), settings.config.root, devModuleLoader);
|
|
58
|
+
for (const file of styleCrawledFiles) {
|
|
59
|
+
if (!file.includes("node_modules")) {
|
|
60
|
+
this.addWatchFile(file);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
for (const file of scriptCrawledFiles) {
|
|
64
|
+
if (!file.includes("node_modules")) {
|
|
65
|
+
this.addWatchFile(file);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
58
68
|
stringifiedLinks = JSON.stringify([...urls]);
|
|
59
69
|
stringifiedStyles = JSON.stringify(styles.map((s) => s.content));
|
|
60
70
|
stringifiedScripts = JSON.stringify([...hoistedScripts]);
|
package/dist/core/constants.js
CHANGED
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 = "4.3.
|
|
26
|
+
const currentVersion = "4.3.3";
|
|
27
27
|
if (currentVersion.includes("-")) {
|
|
28
28
|
logger.warn("SKIP_FORMAT", msg.prerelease({ currentVersion }));
|
|
29
29
|
}
|
package/dist/core/messages.js
CHANGED
|
@@ -36,7 +36,7 @@ function serverStart({
|
|
|
36
36
|
host,
|
|
37
37
|
base
|
|
38
38
|
}) {
|
|
39
|
-
const version = "4.3.
|
|
39
|
+
const version = "4.3.3";
|
|
40
40
|
const localPrefix = `${dim("\u2503")} Local `;
|
|
41
41
|
const networkPrefix = `${dim("\u2503")} Network `;
|
|
42
42
|
const emptyPrefix = " ".repeat(11);
|
|
@@ -261,7 +261,7 @@ function printHelp({
|
|
|
261
261
|
message.push(
|
|
262
262
|
linebreak(),
|
|
263
263
|
` ${bgGreen(black(` ${commandName} `))} ${green(
|
|
264
|
-
`v${"4.3.
|
|
264
|
+
`v${"4.3.3"}`
|
|
265
265
|
)} ${headline}`
|
|
266
266
|
);
|
|
267
267
|
}
|
|
@@ -154,15 +154,24 @@ function computeCurrentLocale(request, locales, routingStrategy, defaultLocale)
|
|
|
154
154
|
if (!routeData) {
|
|
155
155
|
return defaultLocale;
|
|
156
156
|
}
|
|
157
|
-
|
|
157
|
+
const pathname = routeData.pathname ?? new URL(request.url).pathname;
|
|
158
|
+
for (const segment of pathname.split("/").filter(Boolean)) {
|
|
158
159
|
for (const locale of locales) {
|
|
159
160
|
if (typeof locale === "string") {
|
|
161
|
+
if (!segment.includes(locale))
|
|
162
|
+
continue;
|
|
160
163
|
if (normalizeTheLocale(locale) === normalizeTheLocale(segment)) {
|
|
161
164
|
return locale;
|
|
162
165
|
}
|
|
163
166
|
} else {
|
|
164
167
|
if (locale.path === segment) {
|
|
165
168
|
return locale.codes.at(0);
|
|
169
|
+
} else {
|
|
170
|
+
for (const code of locale.codes) {
|
|
171
|
+
if (normalizeTheLocale(code) === normalizeTheLocale(segment)) {
|
|
172
|
+
return code;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
166
175
|
}
|
|
167
176
|
}
|
|
168
177
|
}
|
|
@@ -35,12 +35,9 @@ import { markHTMLString as markHTMLString2 } from "./escape.js";
|
|
|
35
35
|
import { addAttribute as addAttribute2, Renderer as Renderer2 } from "./render/index.js";
|
|
36
36
|
function mergeSlots(...slotted) {
|
|
37
37
|
const slots = {};
|
|
38
|
-
for (
|
|
38
|
+
for (const slot of slotted) {
|
|
39
39
|
if (!slot)
|
|
40
40
|
continue;
|
|
41
|
-
if (Array.isArray(slot)) {
|
|
42
|
-
slot = mergeSlots(...slot);
|
|
43
|
-
}
|
|
44
41
|
if (typeof slot === "object") {
|
|
45
42
|
Object.assign(slots, slot);
|
|
46
43
|
} else if (typeof slot === "function") {
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
export { z };
|
|
3
|
+
export type ImageFunction = () => z.ZodObject<{
|
|
4
|
+
src: z.ZodString;
|
|
5
|
+
width: z.ZodNumber;
|
|
6
|
+
height: z.ZodNumber;
|
|
7
|
+
format: z.ZodUnion<[
|
|
8
|
+
z.ZodLiteral<'png'>,
|
|
9
|
+
z.ZodLiteral<'jpg'>,
|
|
10
|
+
z.ZodLiteral<'jpeg'>,
|
|
11
|
+
z.ZodLiteral<'tiff'>,
|
|
12
|
+
z.ZodLiteral<'webp'>,
|
|
13
|
+
z.ZodLiteral<'gif'>,
|
|
14
|
+
z.ZodLiteral<'svg'>,
|
|
15
|
+
z.ZodLiteral<'avif'>
|
|
16
|
+
]>;
|
|
17
|
+
}>;
|
|
18
|
+
type BaseSchemaWithoutEffects = z.AnyZodObject | z.ZodUnion<[BaseSchemaWithoutEffects, ...BaseSchemaWithoutEffects[]]> | z.ZodDiscriminatedUnion<string, z.AnyZodObject[]> | z.ZodIntersection<BaseSchemaWithoutEffects, BaseSchemaWithoutEffects>;
|
|
19
|
+
type BaseSchema = BaseSchemaWithoutEffects | z.ZodEffects<BaseSchemaWithoutEffects>;
|
|
20
|
+
export type SchemaContext = {
|
|
21
|
+
image: ImageFunction;
|
|
22
|
+
};
|
|
23
|
+
type DataCollectionConfig<S extends BaseSchema> = {
|
|
24
|
+
type: 'data';
|
|
25
|
+
schema?: S | ((context: SchemaContext) => S);
|
|
26
|
+
};
|
|
27
|
+
type ContentCollectionConfig<S extends BaseSchema> = {
|
|
28
|
+
type?: 'content';
|
|
29
|
+
schema?: S | ((context: SchemaContext) => S);
|
|
30
|
+
};
|
|
31
|
+
type CollectionConfig<S extends BaseSchema> = ContentCollectionConfig<S> | DataCollectionConfig<S>;
|
|
32
|
+
export declare function defineCollection<S extends BaseSchema>(input: CollectionConfig<S>): CollectionConfig<S>;
|
|
33
|
+
/** Run `astro sync` to generate high fidelity types */
|
|
34
|
+
export declare const getEntryBySlug: (...args: any[]) => any;
|
|
35
|
+
/** Run `astro sync` to generate high fidelity types */
|
|
36
|
+
export declare const getDataEntryById: (...args: any[]) => any;
|
|
37
|
+
/** Run `astro sync` to generate high fidelity types */
|
|
38
|
+
export declare const getCollection: (...args: any[]) => any;
|
|
39
|
+
/** Run `astro sync` to generate high fidelity types */
|
|
40
|
+
export declare const getEntry: (...args: any[]) => any;
|
|
41
|
+
/** Run `astro sync` to generate high fidelity types */
|
|
42
|
+
export declare const getEntries: (...args: any[]) => any;
|
|
43
|
+
/** Run `astro sync` to generate high fidelity types */
|
|
44
|
+
export declare const reference: (...args: any[]) => any;
|
|
45
|
+
/** Run `astro sync` to generate high fidelity types */
|
|
46
|
+
export type CollectionKey = any;
|
|
47
|
+
/** Run `astro sync` to generate high fidelity types */
|
|
48
|
+
export type CollectionEntry<C> = any;
|
|
49
|
+
/** Run `astro sync` to generate high fidelity types */
|
|
50
|
+
export type ContentCollectionKey = any;
|
|
51
|
+
/** Run `astro sync` to generate high fidelity types */
|
|
52
|
+
export type DataCollectionKey = any;
|
|
53
|
+
/** Run `astro sync` to generate high fidelity types */
|
|
54
|
+
export type ContentConfig = any;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { defineCollection as _defineCollection } from "../content/runtime.js";
|
|
2
|
+
import { z } from "zod";
|
|
3
|
+
function defineCollection(input) {
|
|
4
|
+
return _defineCollection(input);
|
|
5
|
+
}
|
|
6
|
+
const noop = () => {
|
|
7
|
+
};
|
|
8
|
+
const getEntryBySlug = noop;
|
|
9
|
+
const getDataEntryById = noop;
|
|
10
|
+
const getCollection = noop;
|
|
11
|
+
const getEntry = noop;
|
|
12
|
+
const getEntries = noop;
|
|
13
|
+
const reference = noop;
|
|
14
|
+
export {
|
|
15
|
+
defineCollection,
|
|
16
|
+
getCollection,
|
|
17
|
+
getDataEntryById,
|
|
18
|
+
getEntries,
|
|
19
|
+
getEntry,
|
|
20
|
+
getEntryBySlug,
|
|
21
|
+
reference,
|
|
22
|
+
z
|
|
23
|
+
};
|
|
@@ -4,7 +4,11 @@ import { crawlGraph } from "./vite.js";
|
|
|
4
4
|
async function getStylesForURL(filePath, loader) {
|
|
5
5
|
const importedCssUrls = /* @__PURE__ */ new Set();
|
|
6
6
|
const importedStylesMap = /* @__PURE__ */ new Map();
|
|
7
|
+
const crawledFiles = /* @__PURE__ */ new Set();
|
|
7
8
|
for await (const importedModule of crawlGraph(loader, viteID(filePath), true)) {
|
|
9
|
+
if (importedModule.file) {
|
|
10
|
+
crawledFiles.add(importedModule.file);
|
|
11
|
+
}
|
|
8
12
|
if (isBuildableCSSRequest(importedModule.url)) {
|
|
9
13
|
let css = "";
|
|
10
14
|
if (typeof importedModule.ssrModule?.default === "string") {
|
|
@@ -32,7 +36,8 @@ async function getStylesForURL(filePath, loader) {
|
|
|
32
36
|
}
|
|
33
37
|
return {
|
|
34
38
|
urls: importedCssUrls,
|
|
35
|
-
styles: [...importedStylesMap.values()]
|
|
39
|
+
styles: [...importedStylesMap.values()],
|
|
40
|
+
crawledFiles
|
|
36
41
|
};
|
|
37
42
|
}
|
|
38
43
|
export {
|
|
@@ -296,7 +296,7 @@ async function getScriptsAndStyles({ pipeline, filePath }) {
|
|
|
296
296
|
const moduleLoader = pipeline.getModuleLoader();
|
|
297
297
|
const settings = pipeline.getSettings();
|
|
298
298
|
const mode = pipeline.getEnvironment().mode;
|
|
299
|
-
const scripts = await getScriptsForURL(filePath, settings.config.root, moduleLoader);
|
|
299
|
+
const { scripts } = await getScriptsForURL(filePath, settings.config.root, moduleLoader);
|
|
300
300
|
if (isPage(filePath, settings) && mode === "development") {
|
|
301
301
|
scripts.add({
|
|
302
302
|
props: { type: "module", src: "/@vite/client" },
|
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
import type { SSRElement } from '../@types/astro.js';
|
|
2
2
|
import type { ModuleLoader } from '../core/module-loader/index.js';
|
|
3
|
-
export declare function getScriptsForURL(filePath: URL, root: URL, loader: ModuleLoader): Promise<
|
|
3
|
+
export declare function getScriptsForURL(filePath: URL, root: URL, loader: ModuleLoader): Promise<{
|
|
4
|
+
scripts: Set<SSRElement>;
|
|
5
|
+
crawledFiles: Set<string>;
|
|
6
|
+
}>;
|
|
@@ -3,17 +3,21 @@ import { rootRelativePath, viteID } from "../core/util.js";
|
|
|
3
3
|
import { crawlGraph } from "./vite.js";
|
|
4
4
|
async function getScriptsForURL(filePath, root, loader) {
|
|
5
5
|
const elements = /* @__PURE__ */ new Set();
|
|
6
|
+
const crawledFiles = /* @__PURE__ */ new Set();
|
|
6
7
|
const rootID = viteID(filePath);
|
|
7
8
|
const modInfo = loader.getModuleInfo(rootID);
|
|
8
9
|
addHoistedScripts(elements, modInfo, root);
|
|
9
10
|
for await (const moduleNode of crawlGraph(loader, rootID, true)) {
|
|
11
|
+
if (moduleNode.file) {
|
|
12
|
+
crawledFiles.add(moduleNode.file);
|
|
13
|
+
}
|
|
10
14
|
const id = moduleNode.id;
|
|
11
15
|
if (id) {
|
|
12
16
|
const info = loader.getModuleInfo(id);
|
|
13
17
|
addHoistedScripts(elements, info, root);
|
|
14
18
|
}
|
|
15
19
|
}
|
|
16
|
-
return elements;
|
|
20
|
+
return { scripts: elements, crawledFiles };
|
|
17
21
|
}
|
|
18
22
|
function addHoistedScripts(set, info, root) {
|
|
19
23
|
if (!info?.meta?.astro) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "astro",
|
|
3
|
-
"version": "4.3.
|
|
3
|
+
"version": "4.3.3",
|
|
4
4
|
"description": "Astro is a modern site builder with web best practices, performance, and DX front-of-mind.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": "withastro",
|
|
@@ -101,7 +101,7 @@
|
|
|
101
101
|
"vendor"
|
|
102
102
|
],
|
|
103
103
|
"dependencies": {
|
|
104
|
-
"@astrojs/compiler": "^2.5.
|
|
104
|
+
"@astrojs/compiler": "^2.5.3",
|
|
105
105
|
"@babel/core": "^7.23.3",
|
|
106
106
|
"@babel/generator": "^7.23.3",
|
|
107
107
|
"@babel/parser": "^7.23.3",
|