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
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AstroError, AstroErrorData } from "../errors/index.js";
|
|
2
|
-
const VALID_PARAM_TYPES = ["string", "
|
|
2
|
+
const VALID_PARAM_TYPES = ["string", "undefined"];
|
|
3
3
|
function validateGetStaticPathsParameter([key, value], route) {
|
|
4
4
|
if (!VALID_PARAM_TYPES.includes(typeof value)) {
|
|
5
5
|
throw new AstroError({
|
|
@@ -22,7 +22,7 @@ function validateDynamicRouteModule(mod, {
|
|
|
22
22
|
});
|
|
23
23
|
}
|
|
24
24
|
}
|
|
25
|
-
function validateGetStaticPathsResult(result,
|
|
25
|
+
function validateGetStaticPathsResult(result, route) {
|
|
26
26
|
if (!Array.isArray(result)) {
|
|
27
27
|
throw new AstroError({
|
|
28
28
|
...AstroErrorData.InvalidGetStaticPathsReturn,
|
|
@@ -49,22 +49,6 @@ function validateGetStaticPathsResult(result, logger, route) {
|
|
|
49
49
|
}
|
|
50
50
|
});
|
|
51
51
|
}
|
|
52
|
-
for (const [key, val] of Object.entries(pathObject.params)) {
|
|
53
|
-
if (!(typeof val === "undefined" || typeof val === "string" || typeof val === "number")) {
|
|
54
|
-
logger.warn(
|
|
55
|
-
"router",
|
|
56
|
-
`getStaticPaths() returned an invalid path param: "${key}". A string, number or undefined value was expected, but got \`${JSON.stringify(
|
|
57
|
-
val
|
|
58
|
-
)}\`.`
|
|
59
|
-
);
|
|
60
|
-
}
|
|
61
|
-
if (typeof val === "string" && val === "") {
|
|
62
|
-
logger.warn(
|
|
63
|
-
"router",
|
|
64
|
-
`getStaticPaths() returned an invalid path param: "${key}". \`undefined\` expected for an optional param, but got empty string.`
|
|
65
|
-
);
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
52
|
});
|
|
69
53
|
}
|
|
70
54
|
export {
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import type { ComponentInstance, RoutesList } from '../../types/astro.js';
|
|
2
|
-
import type {
|
|
2
|
+
import type { SSRManifest } from '../../types/public/internal.js';
|
|
3
3
|
export declare const SERVER_ISLAND_ROUTE = "/_server-islands/[name]";
|
|
4
4
|
export declare const SERVER_ISLAND_COMPONENT = "_server-islands.astro";
|
|
5
5
|
export declare const SERVER_ISLAND_BASE_PREFIX = "_server-islands";
|
|
6
6
|
type ConfigFields = Pick<SSRManifest, 'base' | 'trailingSlash'>;
|
|
7
|
-
export declare function getServerIslandRouteData(config: ConfigFields): RouteData;
|
|
8
7
|
export declare function injectServerIslandRoute(config: ConfigFields, routeManifest: RoutesList): void;
|
|
9
8
|
export declare function createEndpoint(manifest: SSRManifest): ComponentInstance;
|
|
10
9
|
export {};
|
package/dist/core/sync/index.js
CHANGED
|
@@ -117,8 +117,7 @@ async function syncInternal({
|
|
|
117
117
|
settings.timer.end("Sync content layer");
|
|
118
118
|
} else {
|
|
119
119
|
const paths = getContentPaths(settings.config, fs);
|
|
120
|
-
if (paths.config.exists || paths.liveConfig.exists
|
|
121
|
-
settings.config.legacy?.collections && fs.existsSync(paths.contentDir)) {
|
|
120
|
+
if (paths.config.exists || paths.liveConfig.exists) {
|
|
122
121
|
settings.injectedTypes.push({
|
|
123
122
|
filename: CONTENT_TYPES_FILE
|
|
124
123
|
});
|
|
@@ -187,18 +186,11 @@ async function syncContentCollections(settings, {
|
|
|
187
186
|
settings,
|
|
188
187
|
viteServer: tempViteServer
|
|
189
188
|
});
|
|
190
|
-
|
|
189
|
+
await contentTypesGenerator.init();
|
|
191
190
|
const contentConfig = globalContentConfigObserver.get();
|
|
192
191
|
if (contentConfig.status === "error") {
|
|
193
192
|
throw contentConfig.error;
|
|
194
193
|
}
|
|
195
|
-
if (typesResult.typesGenerated === false) {
|
|
196
|
-
switch (typesResult.reason) {
|
|
197
|
-
case "no-content-dir":
|
|
198
|
-
default:
|
|
199
|
-
logger.debug("types", "No content directory found. Skipping type generation.");
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
194
|
} catch (e) {
|
|
203
195
|
const safeError = createSafeError(e);
|
|
204
196
|
if (isAstroError(e)) {
|
package/dist/env/env-loader.d.ts
CHANGED
package/dist/env/env-loader.js
CHANGED
|
@@ -3,8 +3,7 @@ import { loadEnv } from "vite";
|
|
|
3
3
|
const isValidIdentifierRe = /^[_$a-zA-Z][\w$]*$/;
|
|
4
4
|
function getPrivateEnv({
|
|
5
5
|
fullEnv,
|
|
6
|
-
viteConfig
|
|
7
|
-
useStatic
|
|
6
|
+
viteConfig
|
|
8
7
|
}) {
|
|
9
8
|
let envPrefixes = ["PUBLIC_"];
|
|
10
9
|
if (viteConfig.envPrefix) {
|
|
@@ -15,25 +14,13 @@ function getPrivateEnv({
|
|
|
15
14
|
if (!isValidIdentifierRe.test(key) || envPrefixes.some((prefix) => key.startsWith(prefix))) {
|
|
16
15
|
continue;
|
|
17
16
|
}
|
|
18
|
-
|
|
19
|
-
let value = process.env[key];
|
|
20
|
-
if (typeof value !== "string") {
|
|
21
|
-
value = `${value}`;
|
|
22
|
-
}
|
|
23
|
-
if (value === "0" || value === "1" || value === "true" || value === "false") {
|
|
24
|
-
privateEnv[key] = value;
|
|
25
|
-
} else {
|
|
26
|
-
privateEnv[key] = `process.env.${key}`;
|
|
27
|
-
}
|
|
28
|
-
} else {
|
|
29
|
-
privateEnv[key] = JSON.stringify(fullEnv[key]);
|
|
30
|
-
}
|
|
17
|
+
privateEnv[key] = JSON.stringify(fullEnv[key]);
|
|
31
18
|
}
|
|
32
19
|
return privateEnv;
|
|
33
20
|
}
|
|
34
|
-
function getEnv({ mode, config
|
|
21
|
+
function getEnv({ mode, config }) {
|
|
35
22
|
const loaded = loadEnv(mode, config.vite.envDir ?? fileURLToPath(config.root), "");
|
|
36
|
-
const privateEnv = getPrivateEnv({ fullEnv: loaded, viteConfig: config.vite
|
|
23
|
+
const privateEnv = getPrivateEnv({ fullEnv: loaded, viteConfig: config.vite });
|
|
37
24
|
return { loaded, privateEnv };
|
|
38
25
|
}
|
|
39
26
|
const createEnvLoader = (options) => {
|
|
@@ -13,42 +13,13 @@ import { invalidVariablesToError } from "./errors.js";
|
|
|
13
13
|
import { getEnvFieldType, validateEnvVariable } from "./validators.js";
|
|
14
14
|
function astroEnv({ settings, sync, envLoader }) {
|
|
15
15
|
const { schema, validateSecrets } = settings.config.env;
|
|
16
|
-
let
|
|
17
|
-
let
|
|
18
|
-
function ensureTemplateAreLoaded() {
|
|
19
|
-
if (templates !== null) {
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
const loadedEnv = envLoader.get();
|
|
23
|
-
if (!isDev) {
|
|
24
|
-
for (const [key, value] of Object.entries(loadedEnv)) {
|
|
25
|
-
if (value !== void 0) {
|
|
26
|
-
process.env[key] = value;
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
const validatedVariables = validatePublicVariables({
|
|
31
|
-
schema,
|
|
32
|
-
loadedEnv,
|
|
33
|
-
validateSecrets,
|
|
34
|
-
sync
|
|
35
|
-
});
|
|
36
|
-
templates = {
|
|
37
|
-
...getTemplates(schema, validatedVariables, isDev ? loadedEnv : null),
|
|
38
|
-
internal: `export const schema = ${JSON.stringify(schema)};`
|
|
39
|
-
};
|
|
40
|
-
}
|
|
16
|
+
let isBuild;
|
|
17
|
+
let populated = false;
|
|
41
18
|
return {
|
|
42
19
|
name: "astro-env-plugin",
|
|
43
20
|
enforce: "pre",
|
|
44
21
|
config(_, { command }) {
|
|
45
|
-
|
|
46
|
-
},
|
|
47
|
-
buildStart() {
|
|
48
|
-
ensureTemplateAreLoaded();
|
|
49
|
-
},
|
|
50
|
-
buildEnd() {
|
|
51
|
-
templates = null;
|
|
22
|
+
isBuild = command === "build";
|
|
52
23
|
},
|
|
53
24
|
resolveId(id) {
|
|
54
25
|
if (id === CLIENT_VIRTUAL_MODULE_ID) {
|
|
@@ -62,23 +33,43 @@ function astroEnv({ settings, sync, envLoader }) {
|
|
|
62
33
|
}
|
|
63
34
|
},
|
|
64
35
|
load(id, options) {
|
|
65
|
-
if (id ===
|
|
66
|
-
|
|
67
|
-
return { code: templates.client };
|
|
36
|
+
if (id === RESOLVED_INTERNAL_VIRTUAL_MODULE_ID) {
|
|
37
|
+
return { code: `export const schema = ${JSON.stringify(schema)};` };
|
|
68
38
|
}
|
|
69
|
-
if (id === RESOLVED_SERVER_VIRTUAL_MODULE_ID) {
|
|
70
|
-
if (options?.ssr) {
|
|
71
|
-
ensureTemplateAreLoaded();
|
|
72
|
-
return { code: templates.server };
|
|
73
|
-
}
|
|
39
|
+
if (id === RESOLVED_SERVER_VIRTUAL_MODULE_ID && !options?.ssr) {
|
|
74
40
|
throw new AstroError({
|
|
75
41
|
...AstroErrorData.ServerOnlyModule,
|
|
76
42
|
message: AstroErrorData.ServerOnlyModule.message(SERVER_VIRTUAL_MODULE_ID)
|
|
77
43
|
});
|
|
78
44
|
}
|
|
79
|
-
if (id ===
|
|
80
|
-
|
|
81
|
-
|
|
45
|
+
if (id === RESOLVED_CLIENT_VIRTUAL_MODULE_ID || id === RESOLVED_SERVER_VIRTUAL_MODULE_ID) {
|
|
46
|
+
const loadedEnv = envLoader.get();
|
|
47
|
+
if (isBuild && !populated) {
|
|
48
|
+
for (const [key, value] of Object.entries(loadedEnv)) {
|
|
49
|
+
if (value !== void 0) {
|
|
50
|
+
process.env[key] = value;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
populated = true;
|
|
54
|
+
}
|
|
55
|
+
const validatedVariables = validatePublicVariables({
|
|
56
|
+
schema,
|
|
57
|
+
loadedEnv,
|
|
58
|
+
validateSecrets,
|
|
59
|
+
sync
|
|
60
|
+
});
|
|
61
|
+
const { client, server } = getTemplates({
|
|
62
|
+
schema,
|
|
63
|
+
validatedVariables,
|
|
64
|
+
// In dev, we inline process.env to avoid freezing it
|
|
65
|
+
loadedEnv: isBuild ? null : loadedEnv
|
|
66
|
+
});
|
|
67
|
+
if (id === RESOLVED_CLIENT_VIRTUAL_MODULE_ID) {
|
|
68
|
+
return { code: client };
|
|
69
|
+
}
|
|
70
|
+
if (id === RESOLVED_SERVER_VIRTUAL_MODULE_ID) {
|
|
71
|
+
return { code: server };
|
|
72
|
+
}
|
|
82
73
|
}
|
|
83
74
|
}
|
|
84
75
|
};
|
|
@@ -112,9 +103,14 @@ function validatePublicVariables({
|
|
|
112
103
|
}
|
|
113
104
|
return valid;
|
|
114
105
|
}
|
|
115
|
-
|
|
106
|
+
let cachedServerTemplate;
|
|
107
|
+
function getTemplates({
|
|
108
|
+
schema,
|
|
109
|
+
validatedVariables,
|
|
110
|
+
loadedEnv
|
|
111
|
+
}) {
|
|
116
112
|
let client = "";
|
|
117
|
-
let server = readFileSync(MODULE_TEMPLATE_URL, "utf-8");
|
|
113
|
+
let server = cachedServerTemplate ??= readFileSync(MODULE_TEMPLATE_URL, "utf-8");
|
|
118
114
|
let onSetGetEnv = "";
|
|
119
115
|
for (const { key, value, context } of validatedVariables) {
|
|
120
116
|
const str = `export const ${key} = ${JSON.stringify(value)};`;
|
package/dist/i18n/index.js
CHANGED
|
@@ -251,9 +251,6 @@ function redirectToFallback({
|
|
|
251
251
|
if (pathFallbackLocale === defaultLocale && strategy === "pathname-prefix-other-locales") {
|
|
252
252
|
if (context.url.pathname.includes(`${base}`)) {
|
|
253
253
|
newPathname = context.url.pathname.replace(`/${urlLocale}`, ``);
|
|
254
|
-
if (newPathname === "") {
|
|
255
|
-
newPathname = "/";
|
|
256
|
-
}
|
|
257
254
|
} else {
|
|
258
255
|
newPathname = context.url.pathname.replace(`/${urlLocale}`, `/`);
|
|
259
256
|
}
|
|
@@ -80,10 +80,9 @@ type RunHookBuildSsr = {
|
|
|
80
80
|
config: AstroConfig;
|
|
81
81
|
manifest: SerializedSSRManifest;
|
|
82
82
|
logger: Logger;
|
|
83
|
-
entryPoints: Map<RouteData, URL>;
|
|
84
83
|
middlewareEntryPoint: URL | undefined;
|
|
85
84
|
};
|
|
86
|
-
export declare function runHookBuildSsr({ config, manifest, logger,
|
|
85
|
+
export declare function runHookBuildSsr({ config, manifest, logger, middlewareEntryPoint, }: RunHookBuildSsr): Promise<void>;
|
|
87
86
|
export declare function runHookBuildGenerated({ settings, logger, experimentalRouteToHeaders, }: {
|
|
88
87
|
settings: AstroSettings;
|
|
89
88
|
logger: Logger;
|
|
@@ -261,9 +261,6 @@ async function runHookConfigSetup({
|
|
|
261
261
|
if (astroJSXRenderer) {
|
|
262
262
|
updatedSettings.renderers.push(astroJSXRenderer);
|
|
263
263
|
}
|
|
264
|
-
if (updatedConfig.i18n && typeof updatedConfig.i18n.routing !== "string") {
|
|
265
|
-
updatedConfig.i18n.routing.redirectToDefaultLocale ??= updatedConfig.i18n.routing.prefixDefaultLocale || false;
|
|
266
|
-
}
|
|
267
264
|
updatedSettings.config = updatedConfig;
|
|
268
265
|
return updatedSettings;
|
|
269
266
|
}
|
|
@@ -415,13 +412,8 @@ async function runHookBuildSsr({
|
|
|
415
412
|
config,
|
|
416
413
|
manifest,
|
|
417
414
|
logger,
|
|
418
|
-
entryPoints,
|
|
419
415
|
middlewareEntryPoint
|
|
420
416
|
}) {
|
|
421
|
-
const entryPointsMap = /* @__PURE__ */ new Map();
|
|
422
|
-
for (const [key, value] of entryPoints) {
|
|
423
|
-
entryPointsMap.set(toIntegrationRouteData(key), value);
|
|
424
|
-
}
|
|
425
417
|
for (const integration of config.integrations) {
|
|
426
418
|
await runHookInternal({
|
|
427
419
|
integration,
|
|
@@ -429,7 +421,6 @@ async function runHookBuildSsr({
|
|
|
429
421
|
logger,
|
|
430
422
|
params: () => ({
|
|
431
423
|
manifest,
|
|
432
|
-
entryPoints: entryPointsMap,
|
|
433
424
|
middlewareEntryPoint
|
|
434
425
|
})
|
|
435
426
|
});
|
|
@@ -453,7 +444,6 @@ async function runHookBuildGenerated({
|
|
|
453
444
|
async function runHookBuildDone({ settings, pages, routes, logger }) {
|
|
454
445
|
const dir = getClientOutputDirectory(settings);
|
|
455
446
|
await fsMod.promises.mkdir(dir, { recursive: true });
|
|
456
|
-
const integrationRoutes = routes.map(toIntegrationRouteData);
|
|
457
447
|
for (const integration of settings.config.integrations) {
|
|
458
448
|
await runHookInternal({
|
|
459
449
|
integration,
|
|
@@ -462,7 +452,6 @@ async function runHookBuildDone({ settings, pages, routes, logger }) {
|
|
|
462
452
|
params: () => ({
|
|
463
453
|
pages: pages.map((p) => ({ pathname: p })),
|
|
464
454
|
dir,
|
|
465
|
-
routes: integrationRoutes,
|
|
466
455
|
assets: new Map(
|
|
467
456
|
routes.filter((r) => r.distURL !== void 0).map((r) => [r.route, r.distURL])
|
|
468
457
|
)
|
|
@@ -528,22 +517,6 @@ function toIntegrationResolvedRoute(route) {
|
|
|
528
517
|
redirectRoute: route.redirectRoute ? toIntegrationResolvedRoute(route.redirectRoute) : void 0
|
|
529
518
|
};
|
|
530
519
|
}
|
|
531
|
-
function toIntegrationRouteData(route) {
|
|
532
|
-
return {
|
|
533
|
-
route: route.route,
|
|
534
|
-
component: route.component,
|
|
535
|
-
generate: route.generate,
|
|
536
|
-
params: route.params,
|
|
537
|
-
pathname: route.pathname,
|
|
538
|
-
segments: route.segments,
|
|
539
|
-
prerender: route.prerender,
|
|
540
|
-
redirect: route.redirect,
|
|
541
|
-
redirectRoute: route.redirectRoute ? toIntegrationRouteData(route.redirectRoute) : void 0,
|
|
542
|
-
type: route.type,
|
|
543
|
-
pattern: route.pattern,
|
|
544
|
-
distURL: route.distURL
|
|
545
|
-
};
|
|
546
|
-
}
|
|
547
520
|
export {
|
|
548
521
|
getToolbarServerCommunicationHelpers,
|
|
549
522
|
normalizeCodegenDir,
|
package/dist/prefetch/index.d.ts
CHANGED
|
@@ -9,16 +9,6 @@ interface InitOptions {
|
|
|
9
9
|
*/
|
|
10
10
|
export declare function init(defaultOpts?: InitOptions): void;
|
|
11
11
|
export interface PrefetchOptions {
|
|
12
|
-
/**
|
|
13
|
-
* How the prefetch should prioritize the URL. (default `'link'`)
|
|
14
|
-
* - `'link'`: use `<link rel="prefetch">`.
|
|
15
|
-
* - `'fetch'`: use `fetch()`.
|
|
16
|
-
*
|
|
17
|
-
* @deprecated It is recommended to not use this option, and let prefetch use `'link'` whenever it's supported,
|
|
18
|
-
* or otherwise fall back to `'fetch'`. `'link'` works better if the URL doesn't set an appropriate cache header,
|
|
19
|
-
* as the browser will continue to cache it as long as it's used subsequently.
|
|
20
|
-
*/
|
|
21
|
-
with?: 'link' | 'fetch';
|
|
22
12
|
/**
|
|
23
13
|
* Should prefetch even on data saver mode or slow connection. (default `false`)
|
|
24
14
|
*/
|
package/dist/prefetch/index.js
CHANGED
|
@@ -127,7 +127,7 @@ function prefetch(url, opts) {
|
|
|
127
127
|
if (clientPrerender && HTMLScriptElement.supports?.("speculationrules")) {
|
|
128
128
|
debug?.(`[astro] Prefetching ${url} with <script type="speculationrules">`);
|
|
129
129
|
appendSpeculationRules(url, opts?.eagerness ?? "immediate");
|
|
130
|
-
} else if (document.createElement("link").relList?.supports?.("prefetch")
|
|
130
|
+
} else if (document.createElement("link").relList?.supports?.("prefetch")) {
|
|
131
131
|
debug?.(`[astro] Prefetching ${url} with <link rel="prefetch">`);
|
|
132
132
|
const link = document.createElement("link");
|
|
133
133
|
link.rel = "prefetch";
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
export declare function createAstro(site: string | undefined):
|
|
1
|
+
import type { AstroGlobal } from '../../types/public/context.js';
|
|
2
|
+
export declare function createAstro(site: string | undefined): AstroGlobal;
|
|
@@ -1,31 +1,93 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ASTRO_GENERATOR } from "../../core/constants.js";
|
|
2
2
|
import { AstroError, AstroErrorData } from "../../core/errors/index.js";
|
|
3
|
-
function
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
throw new AstroError({
|
|
9
|
-
...AstroErrorData.AstroGlobUsedOutside,
|
|
10
|
-
message: AstroErrorData.AstroGlobUsedOutside.message(JSON.stringify(importMetaGlobResult))
|
|
11
|
-
});
|
|
12
|
-
}
|
|
13
|
-
let allEntries = [...Object.values(importMetaGlobResult)];
|
|
14
|
-
if (allEntries.length === 0) {
|
|
15
|
-
throw new AstroError({
|
|
16
|
-
...AstroErrorData.AstroGlobNoMatch,
|
|
17
|
-
message: AstroErrorData.AstroGlobNoMatch.message(JSON.stringify(importMetaGlobResult))
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
return Promise.all(allEntries.map((fn) => fn()));
|
|
21
|
-
};
|
|
22
|
-
return globHandler;
|
|
3
|
+
function createError(name) {
|
|
4
|
+
return new AstroError({
|
|
5
|
+
...AstroErrorData.UnavailableAstroGlobal,
|
|
6
|
+
message: AstroErrorData.UnavailableAstroGlobal.message(name)
|
|
7
|
+
});
|
|
23
8
|
}
|
|
24
9
|
function createAstro(site) {
|
|
25
10
|
return {
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
11
|
+
// TODO: throw in Astro 7
|
|
12
|
+
get site() {
|
|
13
|
+
console.warn(
|
|
14
|
+
`Astro.site inside getStaticPaths is deprecated and will be removed in a future major version of Astro. Use import.meta.env.SITE instead`
|
|
15
|
+
);
|
|
16
|
+
return site ? new URL(site) : void 0;
|
|
17
|
+
},
|
|
18
|
+
// TODO: throw in Astro 7
|
|
19
|
+
get generator() {
|
|
20
|
+
console.warn(
|
|
21
|
+
`Astro.generator inside getStaticPaths is deprecated and will be removed in a future major version of Astro.`
|
|
22
|
+
);
|
|
23
|
+
return ASTRO_GENERATOR;
|
|
24
|
+
},
|
|
25
|
+
get callAction() {
|
|
26
|
+
throw createError("callAction");
|
|
27
|
+
},
|
|
28
|
+
get clientAddress() {
|
|
29
|
+
throw createError("clientAddress");
|
|
30
|
+
},
|
|
31
|
+
get cookies() {
|
|
32
|
+
throw createError("cookies");
|
|
33
|
+
},
|
|
34
|
+
get csp() {
|
|
35
|
+
throw createError("csp");
|
|
36
|
+
},
|
|
37
|
+
get currentLocale() {
|
|
38
|
+
throw createError("currentLocale");
|
|
39
|
+
},
|
|
40
|
+
get getActionResult() {
|
|
41
|
+
throw createError("getActionResult");
|
|
42
|
+
},
|
|
43
|
+
get isPrerendered() {
|
|
44
|
+
throw createError("isPrerendered");
|
|
45
|
+
},
|
|
46
|
+
get locals() {
|
|
47
|
+
throw createError("locals");
|
|
48
|
+
},
|
|
49
|
+
get originPathname() {
|
|
50
|
+
throw createError("originPathname");
|
|
51
|
+
},
|
|
52
|
+
get params() {
|
|
53
|
+
throw createError("params");
|
|
54
|
+
},
|
|
55
|
+
get preferredLocale() {
|
|
56
|
+
throw createError("preferredLocale");
|
|
57
|
+
},
|
|
58
|
+
get preferredLocaleList() {
|
|
59
|
+
throw createError("preferredLocaleList");
|
|
60
|
+
},
|
|
61
|
+
get props() {
|
|
62
|
+
throw createError("props");
|
|
63
|
+
},
|
|
64
|
+
get redirect() {
|
|
65
|
+
throw createError("redirect");
|
|
66
|
+
},
|
|
67
|
+
get request() {
|
|
68
|
+
throw createError("request");
|
|
69
|
+
},
|
|
70
|
+
get response() {
|
|
71
|
+
throw createError("response");
|
|
72
|
+
},
|
|
73
|
+
get rewrite() {
|
|
74
|
+
throw createError("rewrite");
|
|
75
|
+
},
|
|
76
|
+
get routePattern() {
|
|
77
|
+
throw createError("routePattern");
|
|
78
|
+
},
|
|
79
|
+
get self() {
|
|
80
|
+
throw createError("self");
|
|
81
|
+
},
|
|
82
|
+
get slots() {
|
|
83
|
+
throw createError("slots");
|
|
84
|
+
},
|
|
85
|
+
get url() {
|
|
86
|
+
throw createError("url");
|
|
87
|
+
},
|
|
88
|
+
get session() {
|
|
89
|
+
throw createError("session");
|
|
90
|
+
}
|
|
29
91
|
};
|
|
30
92
|
}
|
|
31
93
|
export {
|
|
@@ -25,10 +25,7 @@ function astroTransitions({ settings }) {
|
|
|
25
25
|
return {
|
|
26
26
|
code: `
|
|
27
27
|
export * from "astro/virtual-modules/transitions.js";
|
|
28
|
-
export {
|
|
29
|
-
default as ViewTransitions,
|
|
30
|
-
default as ClientRouter
|
|
31
|
-
} from "astro/components/ClientRouter.astro";
|
|
28
|
+
export { default as ClientRouter } from "astro/components/ClientRouter.astro";
|
|
32
29
|
`
|
|
33
30
|
};
|
|
34
31
|
}
|
package/dist/types/astro.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import type { TSConfig } from '../core/config/tsconfig.js';
|
|
|
4
4
|
import type { Logger } from '../core/logger/core.js';
|
|
5
5
|
import type { AstroPreferences } from '../preferences/index.js';
|
|
6
6
|
import type { AstroComponentFactory } from '../runtime/server/index.js';
|
|
7
|
-
import type {
|
|
7
|
+
import type { GetStaticPaths } from './public/common.js';
|
|
8
8
|
import type { AstroConfig } from './public/config.js';
|
|
9
9
|
import type { ContentEntryType, DataEntryType } from './public/content.js';
|
|
10
10
|
import type { AstroAdapter, AstroRenderer, InjectedScriptStage, InjectedType } from './public/integrations.js';
|
|
@@ -75,7 +75,7 @@ export interface ComponentInstance {
|
|
|
75
75
|
css?: string[];
|
|
76
76
|
partial?: boolean;
|
|
77
77
|
prerender?: boolean;
|
|
78
|
-
getStaticPaths?:
|
|
78
|
+
getStaticPaths?: GetStaticPaths;
|
|
79
79
|
}
|
|
80
80
|
export interface RoutesList {
|
|
81
81
|
routes: RouteData[];
|
|
@@ -11,9 +11,7 @@ export interface GetStaticPathsOptions {
|
|
|
11
11
|
routePattern: string;
|
|
12
12
|
}
|
|
13
13
|
export type GetStaticPathsItem = {
|
|
14
|
-
params:
|
|
15
|
-
[K in keyof Params]: Params[K] | number;
|
|
16
|
-
};
|
|
14
|
+
params: Params;
|
|
17
15
|
props?: Props;
|
|
18
16
|
};
|
|
19
17
|
export type GetStaticPathsResult = GetStaticPathsItem[];
|