astro 5.15.3 → 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/fonts/logic/normalize-remote-font-faces.js +1 -1
- package/dist/assets/fonts/logic/optimize-fallbacks.js +1 -1
- 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 +4 -2
- 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 +71 -53
- package/dist/core/errors/errors-data.js +31 -25
- 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/i18n.d.ts +87 -5
- package/dist/virtual-modules/i18n.js +3 -1
- 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 -12
- 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
|
@@ -20,16 +20,10 @@ declare module 'astro:content' {
|
|
|
20
20
|
declare module 'astro:content' {
|
|
21
21
|
type Flatten<T> = T extends { [K: string]: infer U } ? U : never;
|
|
22
22
|
|
|
23
|
-
export type CollectionKey = keyof
|
|
24
|
-
export type CollectionEntry<C extends CollectionKey> = Flatten<
|
|
25
|
-
|
|
26
|
-
export type ContentCollectionKey = keyof ContentEntryMap;
|
|
27
|
-
export type DataCollectionKey = keyof DataEntryMap;
|
|
23
|
+
export type CollectionKey = keyof DataEntryMap;
|
|
24
|
+
export type CollectionEntry<C extends CollectionKey> = Flatten<DataEntryMap[C]>;
|
|
28
25
|
|
|
29
26
|
type AllValuesOf<T> = T extends any ? T[keyof T] : never;
|
|
30
|
-
type ValidContentEntrySlug<C extends keyof ContentEntryMap> = AllValuesOf<
|
|
31
|
-
ContentEntryMap[C]
|
|
32
|
-
>['slug'];
|
|
33
27
|
|
|
34
28
|
export type ReferenceDataEntry<
|
|
35
29
|
C extends CollectionKey,
|
|
@@ -38,41 +32,17 @@ declare module 'astro:content' {
|
|
|
38
32
|
collection: C;
|
|
39
33
|
id: E;
|
|
40
34
|
};
|
|
41
|
-
|
|
42
|
-
C extends keyof ContentEntryMap,
|
|
43
|
-
E extends ValidContentEntrySlug<C> | (string & {}) = string,
|
|
44
|
-
> = {
|
|
45
|
-
collection: C;
|
|
46
|
-
slug: E;
|
|
47
|
-
};
|
|
35
|
+
|
|
48
36
|
export type ReferenceLiveEntry<C extends keyof LiveContentConfig['collections']> = {
|
|
49
37
|
collection: C;
|
|
50
38
|
id: string;
|
|
51
39
|
};
|
|
52
40
|
|
|
53
|
-
|
|
54
|
-
export function getEntryBySlug<
|
|
55
|
-
C extends keyof ContentEntryMap,
|
|
56
|
-
E extends ValidContentEntrySlug<C> | (string & {}),
|
|
57
|
-
>(
|
|
58
|
-
collection: C,
|
|
59
|
-
// Note that this has to accept a regular string too, for SSR
|
|
60
|
-
entrySlug: E,
|
|
61
|
-
): E extends ValidContentEntrySlug<C>
|
|
62
|
-
? Promise<CollectionEntry<C>>
|
|
63
|
-
: Promise<CollectionEntry<C> | undefined>;
|
|
64
|
-
|
|
65
|
-
/** @deprecated Use `getEntry` instead. */
|
|
66
|
-
export function getDataEntryById<C extends keyof DataEntryMap, E extends keyof DataEntryMap[C]>(
|
|
67
|
-
collection: C,
|
|
68
|
-
entryId: E,
|
|
69
|
-
): Promise<CollectionEntry<C>>;
|
|
70
|
-
|
|
71
|
-
export function getCollection<C extends keyof AnyEntryMap, E extends CollectionEntry<C>>(
|
|
41
|
+
export function getCollection<C extends keyof DataEntryMap, E extends CollectionEntry<C>>(
|
|
72
42
|
collection: C,
|
|
73
43
|
filter?: (entry: CollectionEntry<C>) => entry is E,
|
|
74
44
|
): Promise<E[]>;
|
|
75
|
-
export function getCollection<C extends keyof
|
|
45
|
+
export function getCollection<C extends keyof DataEntryMap>(
|
|
76
46
|
collection: C,
|
|
77
47
|
filter?: (entry: CollectionEntry<C>) => unknown,
|
|
78
48
|
): Promise<CollectionEntry<C>[]>;
|
|
@@ -84,14 +54,6 @@ declare module 'astro:content' {
|
|
|
84
54
|
import('astro').LiveDataCollectionResult<LiveLoaderDataType<C>, LiveLoaderErrorType<C>>
|
|
85
55
|
>;
|
|
86
56
|
|
|
87
|
-
export function getEntry<
|
|
88
|
-
C extends keyof ContentEntryMap,
|
|
89
|
-
E extends ValidContentEntrySlug<C> | (string & {}),
|
|
90
|
-
>(
|
|
91
|
-
entry: ReferenceContentEntry<C, E>,
|
|
92
|
-
): E extends ValidContentEntrySlug<C>
|
|
93
|
-
? Promise<CollectionEntry<C>>
|
|
94
|
-
: Promise<CollectionEntry<C> | undefined>;
|
|
95
57
|
export function getEntry<
|
|
96
58
|
C extends keyof DataEntryMap,
|
|
97
59
|
E extends keyof DataEntryMap[C] | (string & {}),
|
|
@@ -100,15 +62,6 @@ declare module 'astro:content' {
|
|
|
100
62
|
): E extends keyof DataEntryMap[C]
|
|
101
63
|
? Promise<DataEntryMap[C][E]>
|
|
102
64
|
: Promise<CollectionEntry<C> | undefined>;
|
|
103
|
-
export function getEntry<
|
|
104
|
-
C extends keyof ContentEntryMap,
|
|
105
|
-
E extends ValidContentEntrySlug<C> | (string & {}),
|
|
106
|
-
>(
|
|
107
|
-
collection: C,
|
|
108
|
-
slug: E,
|
|
109
|
-
): E extends ValidContentEntrySlug<C>
|
|
110
|
-
? Promise<CollectionEntry<C>>
|
|
111
|
-
: Promise<CollectionEntry<C> | undefined>;
|
|
112
65
|
export function getEntry<
|
|
113
66
|
C extends keyof DataEntryMap,
|
|
114
67
|
E extends keyof DataEntryMap[C] | (string & {}),
|
|
@@ -126,24 +79,19 @@ declare module 'astro:content' {
|
|
|
126
79
|
): Promise<import('astro').LiveDataEntryResult<LiveLoaderDataType<C>, LiveLoaderErrorType<C>>>;
|
|
127
80
|
|
|
128
81
|
/** Resolve an array of entry references from the same collection */
|
|
129
|
-
export function getEntries<C extends keyof ContentEntryMap>(
|
|
130
|
-
entries: ReferenceContentEntry<C, ValidContentEntrySlug<C>>[],
|
|
131
|
-
): Promise<CollectionEntry<C>[]>;
|
|
132
82
|
export function getEntries<C extends keyof DataEntryMap>(
|
|
133
83
|
entries: ReferenceDataEntry<C, keyof DataEntryMap[C]>[],
|
|
134
84
|
): Promise<CollectionEntry<C>[]>;
|
|
135
85
|
|
|
136
|
-
export function render<C extends keyof
|
|
137
|
-
entry:
|
|
86
|
+
export function render<C extends keyof DataEntryMap>(
|
|
87
|
+
entry: DataEntryMap[C][string],
|
|
138
88
|
): Promise<RenderResult>;
|
|
139
89
|
|
|
140
|
-
export function reference<C extends keyof
|
|
90
|
+
export function reference<C extends keyof DataEntryMap>(
|
|
141
91
|
collection: C,
|
|
142
92
|
): import('astro/zod').ZodEffects<
|
|
143
93
|
import('astro/zod').ZodString,
|
|
144
|
-
C
|
|
145
|
-
? ReferenceContentEntry<C, ValidContentEntrySlug<C>>
|
|
146
|
-
: ReferenceDataEntry<C, keyof DataEntryMap[C]>
|
|
94
|
+
ReferenceDataEntry<C, keyof DataEntryMap[C]>
|
|
147
95
|
>;
|
|
148
96
|
// Allow generic `string` to avoid excessive type errors in the config
|
|
149
97
|
// if `dev` is not running to update as you edit.
|
|
@@ -153,20 +101,14 @@ declare module 'astro:content' {
|
|
|
153
101
|
): import('astro/zod').ZodEffects<import('astro/zod').ZodString, never>;
|
|
154
102
|
|
|
155
103
|
type ReturnTypeOrOriginal<T> = T extends (...args: any[]) => infer R ? R : T;
|
|
156
|
-
type InferEntrySchema<C extends keyof
|
|
104
|
+
type InferEntrySchema<C extends keyof DataEntryMap> = import('astro/zod').infer<
|
|
157
105
|
ReturnTypeOrOriginal<Required<ContentConfig['collections'][C]>['schema']>
|
|
158
106
|
>;
|
|
159
107
|
|
|
160
|
-
type ContentEntryMap = {
|
|
161
|
-
// @@CONTENT_ENTRY_MAP@@
|
|
162
|
-
};
|
|
163
|
-
|
|
164
108
|
type DataEntryMap = {
|
|
165
109
|
// @@DATA_ENTRY_MAP@@
|
|
166
110
|
};
|
|
167
111
|
|
|
168
|
-
type AnyEntryMap = ContentEntryMap & DataEntryMap;
|
|
169
|
-
|
|
170
112
|
type ExtractLoaderTypes<T> = T extends import('astro/loaders').LiveLoader<
|
|
171
113
|
infer TData,
|
|
172
114
|
infer TEntryFilter,
|
|
@@ -175,7 +117,6 @@ declare module 'astro:content' {
|
|
|
175
117
|
>
|
|
176
118
|
? { data: TData; entryFilter: TEntryFilter; collectionFilter: TCollectionFilter; error: TError }
|
|
177
119
|
: { data: never; entryFilter: never; collectionFilter: never; error: never };
|
|
178
|
-
type ExtractDataType<T> = ExtractLoaderTypes<T>['data'];
|
|
179
120
|
type ExtractEntryFilterType<T> = ExtractLoaderTypes<T>['entryFilter'];
|
|
180
121
|
type ExtractCollectionFilterType<T> = ExtractLoaderTypes<T>['collectionFilter'];
|
|
181
122
|
type ExtractErrorType<T> = ExtractLoaderTypes<T>['error'];
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import type fsMod from 'node:fs';
|
|
2
|
-
import type { Plugin } from 'vite';
|
|
3
|
-
import type { Logger } from '../core/logger/core.js';
|
|
4
|
-
import type { AstroSettings } from '../types/astro.js';
|
|
5
|
-
/**
|
|
6
|
-
* Listen for Astro content directory changes and generate types.
|
|
7
|
-
*
|
|
8
|
-
* This is a separate plugin for `getViteConfig` as the `attachContentServerListeners` API
|
|
9
|
-
* needs to be called at different times in `astro dev` and `getViteConfig`. For `astro dev`,
|
|
10
|
-
* it needs to be called after the Astro server is started (packages/astro/src/core/dev/dev.ts).
|
|
11
|
-
* For `getViteConfig`, it needs to be called after the Vite server is started.
|
|
12
|
-
*/
|
|
13
|
-
export declare function astroContentListenPlugin({ settings, logger, fs, }: {
|
|
14
|
-
settings: AstroSettings;
|
|
15
|
-
logger: Logger;
|
|
16
|
-
fs: typeof fsMod;
|
|
17
|
-
}): Plugin;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { attachContentServerListeners } from "../content/server-listeners.js";
|
|
2
|
-
function astroContentListenPlugin({
|
|
3
|
-
settings,
|
|
4
|
-
logger,
|
|
5
|
-
fs
|
|
6
|
-
}) {
|
|
7
|
-
let server;
|
|
8
|
-
return {
|
|
9
|
-
name: "astro:content-listen",
|
|
10
|
-
apply: "serve",
|
|
11
|
-
configureServer(_server) {
|
|
12
|
-
server = _server;
|
|
13
|
-
},
|
|
14
|
-
async buildStart() {
|
|
15
|
-
await attachContentServerListeners({
|
|
16
|
-
fs,
|
|
17
|
-
settings,
|
|
18
|
-
logger,
|
|
19
|
-
viteServer: server
|
|
20
|
-
});
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
export {
|
|
25
|
-
astroContentListenPlugin
|
|
26
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/core/polyfill.d.ts
DELETED
package/dist/core/polyfill.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import buffer from "node:buffer";
|
|
2
|
-
import crypto from "node:crypto";
|
|
3
|
-
function apply() {
|
|
4
|
-
if (!globalThis.crypto) {
|
|
5
|
-
Object.defineProperty(globalThis, "crypto", {
|
|
6
|
-
value: crypto.webcrypto
|
|
7
|
-
});
|
|
8
|
-
}
|
|
9
|
-
if (!globalThis.File) {
|
|
10
|
-
Object.defineProperty(globalThis, "File", {
|
|
11
|
-
value: buffer.File
|
|
12
|
-
});
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
export {
|
|
16
|
-
apply
|
|
17
|
-
};
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { parse } from "acorn";
|
|
2
|
-
import { walk } from "estree-walker";
|
|
3
|
-
import MagicString from "magic-string";
|
|
4
|
-
import { isMarkdownFile } from "../core/util.js";
|
|
5
|
-
const ASTRO_GLOB_REGEX = /Astro2?\s*\.\s*glob\s*\(/;
|
|
6
|
-
function astro() {
|
|
7
|
-
return {
|
|
8
|
-
name: "astro:postprocess",
|
|
9
|
-
async transform(code, id) {
|
|
10
|
-
if (!id.endsWith(".astro") && !isMarkdownFile(id)) {
|
|
11
|
-
return null;
|
|
12
|
-
}
|
|
13
|
-
if (!ASTRO_GLOB_REGEX.test(code)) {
|
|
14
|
-
return null;
|
|
15
|
-
}
|
|
16
|
-
let s;
|
|
17
|
-
const ast = parse(code, {
|
|
18
|
-
ecmaVersion: "latest",
|
|
19
|
-
sourceType: "module"
|
|
20
|
-
});
|
|
21
|
-
walk(ast, {
|
|
22
|
-
enter(node) {
|
|
23
|
-
if (node.type === "CallExpression" && node.callee.type === "MemberExpression" && node.callee.property.name === "glob" && (node.callee.object.name === "Astro" || node.callee.object.name === "Astro2") && node.arguments.length) {
|
|
24
|
-
const firstArgStart = node.arguments[0].start;
|
|
25
|
-
const firstArgEnd = node.arguments[0].end;
|
|
26
|
-
const lastArgEnd = node.arguments[node.arguments.length - 1].end;
|
|
27
|
-
const firstArg = code.slice(firstArgStart, firstArgEnd);
|
|
28
|
-
s ??= new MagicString(code);
|
|
29
|
-
s.overwrite(
|
|
30
|
-
firstArgStart,
|
|
31
|
-
lastArgEnd,
|
|
32
|
-
`import.meta.glob(${firstArg}), () => ${firstArg}`
|
|
33
|
-
);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
if (s) {
|
|
38
|
-
return {
|
|
39
|
-
code: s.toString(),
|
|
40
|
-
map: s.generateMap({ hires: "boundary" })
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
export {
|
|
47
|
-
astro as default
|
|
48
|
-
};
|