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.
Files changed (111) hide show
  1. package/{astro.js → bin/astro.mjs} +7 -8
  2. package/client.d.ts +2 -4
  3. package/components/ClientRouter.astro +0 -5
  4. package/dist/actions/runtime/utils.d.ts +2 -8
  5. package/dist/assets/build/remote.js +4 -14
  6. package/dist/assets/fonts/implementations/font-metrics-resolver.js +15 -9
  7. package/dist/assets/fonts/logic/normalize-remote-font-faces.js +1 -1
  8. package/dist/assets/fonts/logic/optimize-fallbacks.js +1 -1
  9. package/dist/assets/services/sharp.js +5 -6
  10. package/dist/assets/utils/index.d.ts +1 -5
  11. package/dist/assets/utils/index.js +1 -5
  12. package/dist/assets/utils/node/emitAsset.d.ts +0 -14
  13. package/dist/assets/utils/node/emitAsset.js +0 -50
  14. package/dist/assets/vite-plugin-assets.js +3 -8
  15. package/dist/cli/add/index.js +0 -2
  16. package/dist/cli/db/index.js +0 -2
  17. package/dist/cli/info/index.js +0 -2
  18. package/dist/cli/infra/build-time-astro-version-provider.js +1 -1
  19. package/dist/cli/preferences/index.js +0 -2
  20. package/dist/config/index.js +3 -12
  21. package/dist/container/index.d.ts +4 -2
  22. package/dist/container/index.js +0 -1
  23. package/dist/content/config.js +17 -13
  24. package/dist/content/content-layer.js +4 -6
  25. package/dist/content/data-store.d.ts +0 -2
  26. package/dist/content/loaders/glob.d.ts +0 -5
  27. package/dist/content/loaders/glob.js +3 -30
  28. package/dist/content/mutable-data-store.js +1 -14
  29. package/dist/content/runtime-assets.d.ts +1 -1
  30. package/dist/content/runtime-assets.js +3 -6
  31. package/dist/content/runtime.d.ts +19 -58
  32. package/dist/content/runtime.js +52 -218
  33. package/dist/content/server-listeners.js +25 -88
  34. package/dist/content/types-generator.d.ts +1 -6
  35. package/dist/content/types-generator.js +20 -116
  36. package/dist/content/utils.d.ts +31 -104
  37. package/dist/content/utils.js +48 -158
  38. package/dist/content/vite-plugin-content-imports.js +0 -4
  39. package/dist/content/vite-plugin-content-virtual-mod.js +3 -134
  40. package/dist/core/app/index.d.ts +1 -1
  41. package/dist/core/app/index.js +7 -10
  42. package/dist/core/app/node.d.ts +2 -8
  43. package/dist/core/app/node.js +4 -6
  44. package/dist/core/build/generate.js +0 -1
  45. package/dist/core/build/index.js +1 -4
  46. package/dist/core/build/internal.d.ts +1 -2
  47. package/dist/core/build/internal.js +0 -1
  48. package/dist/core/build/plugins/plugin-manifest.js +2 -4
  49. package/dist/core/compile/compile.js +0 -2
  50. package/dist/core/config/schemas/base.d.ts +4 -40
  51. package/dist/core/config/schemas/base.js +3 -16
  52. package/dist/core/config/schemas/refined.js +7 -0
  53. package/dist/core/config/schemas/relative.d.ts +5 -47
  54. package/dist/core/constants.d.ts +1 -0
  55. package/dist/core/constants.js +3 -1
  56. package/dist/core/create-vite.js +1 -4
  57. package/dist/core/dev/container.js +0 -2
  58. package/dist/core/dev/dev.js +1 -1
  59. package/dist/core/errors/dev/vite.js +1 -18
  60. package/dist/core/errors/errors-data.d.ts +71 -53
  61. package/dist/core/errors/errors-data.js +31 -25
  62. package/dist/core/errors/overlay.js +1 -1
  63. package/dist/core/messages.js +2 -2
  64. package/dist/core/middleware/index.d.ts +1 -1
  65. package/dist/core/middleware/index.js +5 -9
  66. package/dist/core/preview/index.js +0 -2
  67. package/dist/core/render/params-and-props.js +0 -1
  68. package/dist/core/render/route-cache.d.ts +1 -2
  69. package/dist/core/render/route-cache.js +1 -2
  70. package/dist/core/render-context.d.ts +3 -3
  71. package/dist/core/render-context.js +13 -27
  72. package/dist/core/routing/manifest/create.js +1 -1
  73. package/dist/core/routing/params.js +5 -6
  74. package/dist/core/routing/validation.d.ts +1 -2
  75. package/dist/core/routing/validation.js +2 -18
  76. package/dist/core/server-islands/endpoint.d.ts +1 -2
  77. package/dist/core/server-islands/endpoint.js +0 -1
  78. package/dist/core/sync/index.js +2 -10
  79. package/dist/env/env-loader.d.ts +0 -1
  80. package/dist/env/env-loader.js +4 -17
  81. package/dist/env/vite-plugin-env.js +41 -45
  82. package/dist/i18n/index.js +0 -3
  83. package/dist/integrations/hooks.d.ts +1 -2
  84. package/dist/integrations/hooks.js +0 -27
  85. package/dist/prefetch/index.d.ts +0 -10
  86. package/dist/prefetch/index.js +1 -1
  87. package/dist/runtime/server/astro-global.d.ts +2 -2
  88. package/dist/runtime/server/astro-global.js +86 -24
  89. package/dist/transitions/vite-plugin-transitions.js +1 -4
  90. package/dist/types/astro.d.ts +2 -2
  91. package/dist/types/public/common.d.ts +1 -3
  92. package/dist/types/public/config.d.ts +4 -127
  93. package/dist/types/public/context.d.ts +18 -39
  94. package/dist/types/public/integrations.d.ts +0 -17
  95. package/dist/types/public/internal.d.ts +2 -2
  96. package/dist/virtual-modules/i18n.d.ts +87 -5
  97. package/dist/virtual-modules/i18n.js +3 -1
  98. package/dist/virtual-modules/live-config.d.ts +0 -2
  99. package/dist/virtual-modules/live-config.js +0 -4
  100. package/dist/vite-plugin-markdown/index.js +0 -1
  101. package/package.json +8 -12
  102. package/templates/content/module.mjs +8 -63
  103. package/templates/content/types.d.ts +10 -69
  104. package/dist/config/vite-plugin-content-listen.d.ts +0 -17
  105. package/dist/config/vite-plugin-content-listen.js +0 -26
  106. package/dist/container/polyfill.d.ts +0 -1
  107. package/dist/container/polyfill.js +0 -2
  108. package/dist/core/polyfill.d.ts +0 -5
  109. package/dist/core/polyfill.js +0 -17
  110. package/dist/vite-plugin-astro-postprocess/index.d.ts +0 -2
  111. 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", "number", "undefined"];
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, logger, route) {
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 { RouteData, SSRManifest } from '../../types/public/internal.js';
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 {};
@@ -125,6 +125,5 @@ export {
125
125
  SERVER_ISLAND_COMPONENT,
126
126
  SERVER_ISLAND_ROUTE,
127
127
  createEndpoint,
128
- getServerIslandRouteData,
129
128
  injectServerIslandRoute
130
129
  };
@@ -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 || // Legacy collections don't require a config file
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
- const typesResult = await contentTypesGenerator.init();
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)) {
@@ -2,7 +2,6 @@ import type { AstroConfig } from '../types/public/index.js';
2
2
  interface EnvLoaderOptions {
3
3
  mode: string;
4
4
  config: AstroConfig;
5
- useStatic: boolean;
6
5
  }
7
6
  export declare const createEnvLoader: (options: EnvLoaderOptions) => {
8
7
  get: () => Record<string, string>;
@@ -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
- if (!useStatic && typeof process.env[key] !== "undefined") {
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, useStatic }) {
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, useStatic });
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 isDev;
17
- let templates = null;
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
- isDev = command !== "build";
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 === RESOLVED_CLIENT_VIRTUAL_MODULE_ID) {
66
- ensureTemplateAreLoaded();
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 === RESOLVED_INTERNAL_VIRTUAL_MODULE_ID) {
80
- ensureTemplateAreLoaded();
81
- return { code: templates.internal };
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
- function getTemplates(schema, validatedVariables, loadedEnv) {
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)};`;
@@ -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, entryPoints, middlewareEntryPoint, }: RunHookBuildSsr): Promise<void>;
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,
@@ -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
  */
@@ -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") && opts?.with !== "fetch") {
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 { AstroGlobalPartial } from '../../types/public/context.js';
2
- export declare function createAstro(site: string | undefined): AstroGlobalPartial;
1
+ import type { AstroGlobal } from '../../types/public/context.js';
2
+ export declare function createAstro(site: string | undefined): AstroGlobal;
@@ -1,31 +1,93 @@
1
- import { ASTRO_VERSION } from "../../core/constants.js";
1
+ import { ASTRO_GENERATOR } from "../../core/constants.js";
2
2
  import { AstroError, AstroErrorData } from "../../core/errors/index.js";
3
- function createAstroGlobFn() {
4
- const globHandler = (importMetaGlobResult) => {
5
- console.warn(`Astro.glob is deprecated and will be removed in a future major version of Astro.
6
- Use import.meta.glob instead: https://vitejs.dev/guide/features.html#glob-import`);
7
- if (typeof importMetaGlobResult === "string") {
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
- site: site ? new URL(site) : void 0,
27
- generator: `Astro v${ASTRO_VERSION}`,
28
- glob: createAstroGlobFn()
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
  }
@@ -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 { GetStaticPathsOptions, GetStaticPathsResult } from './public/common.js';
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?: (options: GetStaticPathsOptions) => GetStaticPathsResult;
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[];