astro 6.3.3 → 6.3.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.
Files changed (39) hide show
  1. package/dist/assets/internal.js +0 -16
  2. package/dist/assets/utils/generateImageStylesCSS.js +26 -6
  3. package/dist/assets/utils/metadata.js +1 -1
  4. package/dist/assets/utils/vendor/image-size/types/svg.js +1 -1
  5. package/dist/cli/infra/build-time-astro-version-provider.js +1 -1
  6. package/dist/content/content-layer.js +3 -3
  7. package/dist/content/runtime.js +5 -2
  8. package/dist/core/build/generate.js +8 -1
  9. package/dist/core/build/plugins/plugin-internals.js +1 -1
  10. package/dist/core/build/static-build.js +9 -147
  11. package/dist/core/build/vite-build-config.d.ts +28 -0
  12. package/dist/core/build/vite-build-config.js +160 -0
  13. package/dist/core/config/schemas/base.d.ts +3 -1
  14. package/dist/core/config/schemas/base.js +6 -1
  15. package/dist/core/config/schemas/relative.d.ts +9 -3
  16. package/dist/core/constants.js +1 -1
  17. package/dist/core/dev/dev.js +1 -1
  18. package/dist/core/errors/errors-data.d.ts +29 -29
  19. package/dist/core/errors/errors-data.js +71 -71
  20. package/dist/core/fetch/fetch-state.d.ts +7 -0
  21. package/dist/core/fetch/fetch-state.js +5 -0
  22. package/dist/core/fetch/types.d.ts +19 -0
  23. package/dist/core/fetch/vite-plugin.js +11 -4
  24. package/dist/core/hono/index.d.ts +1 -1
  25. package/dist/core/hono/index.js +6 -3
  26. package/dist/core/messages/runtime.js +1 -1
  27. package/dist/core/middleware/astro-middleware.js +3 -1
  28. package/dist/core/module-loader/vite.js +1 -2
  29. package/dist/core/pages/handler.js +1 -0
  30. package/dist/types/public/config.d.ts +20 -3
  31. package/dist/types/public/context.d.ts +1 -1
  32. package/dist/types/public/extendables.d.ts +19 -0
  33. package/dist/types/public/index.d.ts +1 -0
  34. package/dist/vite-plugin-app/app.js +11 -11
  35. package/dist/vite-plugin-astro-server/plugin.js +8 -7
  36. package/dist/vite-plugin-hmr-reload/index.d.ts +1 -1
  37. package/dist/vite-plugin-hmr-reload/index.js +15 -1
  38. package/package.json +6 -6
  39. package/templates/content/types.d.ts +1 -0
@@ -2647,21 +2647,38 @@ export interface AstroUserConfig<TLocales extends Locales = never, TDriver exten
2647
2647
  experimental?: {
2648
2648
  /**
2649
2649
  * @name experimental.advancedRouting
2650
- * @type {boolean}
2650
+ * @type {boolean | object}
2651
2651
  * @default `false`
2652
2652
  * @description
2653
2653
  * Enables `src/app.ts` as an advanced routing entrypoint, allowing you to
2654
2654
  * compose Astro's request pipeline with the Web Fetch standard or your own Hono middleware.
2655
2655
  *
2656
+ * Pass `true` to enable with default settings, or an object to customize:
2657
+ *
2656
2658
  * ```js
2657
2659
  * export default defineConfig({
2658
2660
  * experimental: {
2659
- * advancedRouting: true,
2661
+ * advancedRouting: {
2662
+ * fetchFile: 'fetch.ts',
2663
+ * },
2660
2664
  * },
2661
2665
  * });
2662
2666
  * ```
2663
2667
  */
2664
- advancedRouting?: boolean;
2668
+ advancedRouting?: boolean | {
2669
+ /**
2670
+ * @name experimental.advancedRouting.fetchFile
2671
+ * @type {string | null}
2672
+ * @default 'app'
2673
+ * @description
2674
+ *
2675
+ * Customizes the file used as the advanced routing entrypoint inside `srcDir`.
2676
+ * Defaults to `'app'`, meaning Astro looks for `src/app.ts`.
2677
+ *
2678
+ * If you already have a `src/app.ts` file in use for other purposes, define a different filename or set the value to `null` to disable the entrypoint.
2679
+ */
2680
+ fetchFile?: string | null;
2681
+ };
2665
2682
  /**
2666
2683
  *
2667
2684
  * @name experimental.clientPrerender
@@ -126,7 +126,7 @@ export interface AstroGlobal<Props extends Record<string, any> = Record<string,
126
126
  *
127
127
  * [Astro reference](https://docs.astro.build/en/reference/api-reference/)
128
128
  */
129
- export interface APIContext<Props extends Record<string, any> = Record<string, any>, Params extends Record<string, string | undefined> = Record<string, string | undefined>> {
129
+ export interface APIContext<Props extends Record<string, any> = Record<string, any>, Params extends Record<string, string | undefined> = Record<string, string | undefined>> extends App.Providers {
130
130
  /**
131
131
  * The site provided in the astro config, parsed as an instance of `URL`, without base.
132
132
  * `undefined` if the site is not provided in the config.
@@ -12,6 +12,25 @@ declare global {
12
12
  */
13
13
  interface SessionData {
14
14
  }
15
+ /**
16
+ * Declare custom context providers to get typed access on `Astro` and `ctx`.
17
+ * Libraries and users register providers via `state.provide(key, { create, finalize? })`,
18
+ * and the corresponding types are declared here using module augmentation.
19
+ *
20
+ * Built-in providers like `session` are already typed by Astro and don't
21
+ * need to be declared here.
22
+ *
23
+ * @example
24
+ * ```ts
25
+ * declare namespace App {
26
+ * interface Providers {
27
+ * oauth: import('./lib/oauth').OAuthSession;
28
+ * }
29
+ * }
30
+ * ```
31
+ */
32
+ interface Providers {
33
+ }
15
34
  }
16
35
  namespace Astro {
17
36
  interface IntegrationHooks extends BaseIntegrationHooks {
@@ -9,6 +9,7 @@ export type { AstroIntegrationLogger } from '../../core/logger/core.js';
9
9
  export type { AstroSession } from '../../core/session/runtime.js';
10
10
  export type { ToolbarServerHelpers } from '../../runtime/client/dev-toolbar/helpers.js';
11
11
  export type { AstroEnvironmentNames } from '../../core/constants.js';
12
+ export type { Fetchable } from '../../core/fetch/types.js';
12
13
  export type { SessionDriver, SessionDriverConfig } from '../../core/session/types.js';
13
14
  export type { CacheProvider, CacheProviderConfig, CacheProviderFactory, CacheOptions, InvalidateOptions, } from '../../core/cache/types.js';
14
15
  export type * from './common.js';
@@ -125,17 +125,6 @@ class AstroServerApp extends BaseApp {
125
125
  if (url.pathname.endsWith("/") && !shouldAppendForwardSlash(this.manifest.trailingSlash, this.manifest.buildFormat)) {
126
126
  url.pathname = url.pathname.slice(0, -1);
127
127
  }
128
- let body = void 0;
129
- if (!(incomingRequest.method === "GET" || incomingRequest.method === "HEAD")) {
130
- let bytes = [];
131
- await new Promise((resolve) => {
132
- incomingRequest.on("data", (part) => {
133
- bytes.push(part);
134
- });
135
- incomingRequest.on("end", resolve);
136
- });
137
- body = Buffer.concat(bytes);
138
- }
139
128
  const self = this;
140
129
  await self.#loadFetchHandler();
141
130
  let handled = true;
@@ -155,6 +144,17 @@ class AstroServerApp extends BaseApp {
155
144
  handled = false;
156
145
  return;
157
146
  }
147
+ let body = void 0;
148
+ if (!(incomingRequest.method === "GET" || incomingRequest.method === "HEAD")) {
149
+ let bytes = [];
150
+ await new Promise((resolve) => {
151
+ incomingRequest.on("data", (part) => {
152
+ bytes.push(part);
153
+ });
154
+ incomingRequest.on("end", resolve);
155
+ });
156
+ body = Buffer.concat(bytes);
157
+ }
158
158
  const request = createRequest({
159
159
  url,
160
160
  headers: incomingRequest.headers,
@@ -107,17 +107,18 @@ function createVitePluginAstroServer({
107
107
  }
108
108
  try {
109
109
  const pathname = decodeURI(new URL(request.url, "http://localhost").pathname);
110
- const { routes } = await prerenderHandler.environment.runner.import("virtual:astro:routes");
111
- const routesList = { routes: routes.map((r) => r.routeData) };
110
+ const { routes } = await prerenderHandler.environment.runner.import(
111
+ "virtual:astro:routes"
112
+ );
113
+ const routesList = { routes: routes.map((route) => route.routeData) };
112
114
  const matches = matchAllRoutes(pathname, routesList);
113
115
  if (!matches.some((route) => route.prerender)) {
114
116
  return next();
115
117
  }
116
- const handled = await new Promise((resolve) => {
117
- localStorage.run(request, () => {
118
- prerenderHandler.handler(request, response, { prerenderOnly: true }).then((result) => resolve(result)).catch(() => resolve(true));
119
- });
120
- });
118
+ const handled = await localStorage.run(
119
+ request,
120
+ () => prerenderHandler.handler(request, response, { prerenderOnly: true })
121
+ );
121
122
  if (!handled) {
122
123
  return next();
123
124
  }
@@ -1,4 +1,4 @@
1
- import type { Plugin } from 'vite';
1
+ import { type Plugin } from 'vite';
2
2
  /**
3
3
  * The very last Vite plugin to reload the browser if any SSR-only module are updated
4
4
  * which will require a full page reload. This mimics the behaviour of Vite 5 where
@@ -1,3 +1,4 @@
1
+ import { isRunnableDevEnvironment } from "vite";
1
2
  import { VIRTUAL_PAGE_RESOLVED_MODULE_ID } from "../vite-plugin-pages/const.js";
2
3
  import { getDevCssModuleNameFromPageVirtualModuleName } from "../vite-plugin-css/util.js";
3
4
  import { isAstroServerEnvironment } from "../environments.js";
@@ -16,7 +17,7 @@ function hmrReload() {
16
17
  enforce: "post",
17
18
  hotUpdate: {
18
19
  order: "post",
19
- handler({ modules, server, timestamp }) {
20
+ handler({ modules, server, timestamp, file }) {
20
21
  if (!isAstroServerEnvironment(this.environment)) return;
21
22
  let hasSsrOnlyModules = false;
22
23
  let hasSkippedStyleModules = false;
@@ -30,6 +31,12 @@ function hmrReload() {
30
31
  const clientModule = server.environments.client.moduleGraph.getModuleById(mod.id);
31
32
  if (clientModule != null) continue;
32
33
  this.environment.moduleGraph.invalidateModule(mod, invalidatedModules, timestamp, true);
34
+ if (isRunnableDevEnvironment(this.environment)) {
35
+ const runnerModule = this.environment.runner.evaluatedModules.getModuleById(mod.id);
36
+ if (runnerModule) {
37
+ this.environment.runner.evaluatedModules.invalidateModule(runnerModule);
38
+ }
39
+ }
33
40
  hasSsrOnlyModules = true;
34
41
  }
35
42
  for (const invalidatedModule of invalidatedModules) {
@@ -43,6 +50,13 @@ function hmrReload() {
43
50
  }
44
51
  if (hasSsrOnlyModules) {
45
52
  server.ws.send({ type: "full-reload" });
53
+ if (!isRunnableDevEnvironment(this.environment)) {
54
+ this.environment.hot.send({
55
+ type: "full-reload",
56
+ triggeredBy: file,
57
+ path: "*"
58
+ });
59
+ }
46
60
  return [];
47
61
  }
48
62
  if (hasSkippedStyleModules) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "astro",
3
- "version": "6.3.3",
3
+ "version": "6.3.5",
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",
@@ -164,9 +164,9 @@
164
164
  "xxhash-wasm": "^1.1.0",
165
165
  "yargs-parser": "^22.0.0",
166
166
  "zod": "^4.3.6",
167
+ "@astrojs/telemetry": "3.3.2",
167
168
  "@astrojs/markdown-remark": "7.1.2",
168
- "@astrojs/internal-helpers": "0.9.1",
169
- "@astrojs/telemetry": "3.3.2"
169
+ "@astrojs/internal-helpers": "0.9.1"
170
170
  },
171
171
  "optionalDependencies": {
172
172
  "sharp": "^0.34.0"
@@ -198,7 +198,7 @@
198
198
  "remark-code-titles": "^0.1.2",
199
199
  "rollup": "^4.58.0",
200
200
  "sass": "^1.98.0",
201
- "typescript": "^5.9.3",
201
+ "typescript": "^6.0.3",
202
202
  "undici": "^7.22.0",
203
203
  "unified": "^11.0.5",
204
204
  "vitest": "^4.1.0",
@@ -223,8 +223,8 @@
223
223
  "build:ci": "pnpm run prebuild && astro-scripts build \"src/**/*.{ts,js}\" --copy-wasm",
224
224
  "dev": "astro-scripts dev --copy-wasm --prebuild \"src/runtime/server/astro-island.ts\" --prebuild \"src/runtime/client/{idle,load,media,only,visible}.ts\" \"src/**/*.{ts,js}\"",
225
225
  "test": "pnpm run test:unit && pnpm run test:integration && pnpm run test:types",
226
- "test:match": "astro-scripts test \"test/**/*.test.js\" --match",
227
- "test:cli": "astro-scripts test \"test/**/cli.test.js\"",
226
+ "test:match": "astro-scripts test \"test/**/*.test.ts\" --match",
227
+ "test:cli": "astro-scripts test \"test/**/cli.test.ts\"",
228
228
  "test:e2e": "pnpm test:e2e:chrome && pnpm test:e2e:firefox",
229
229
  "test:e2e:match": "playwright test -g",
230
230
  "test:e2e:chrome": "playwright test",
@@ -134,6 +134,7 @@ declare module 'astro:content' {
134
134
  type ExtractEntryFilterType<T> = ExtractLoaderTypes<T>['entryFilter'];
135
135
  type ExtractCollectionFilterType<T> = ExtractLoaderTypes<T>['collectionFilter'];
136
136
  type ExtractErrorType<T> = ExtractLoaderTypes<T>['error'];
137
+ type ExtractDataType<T> = ExtractLoaderTypes<T>['data'];
137
138
 
138
139
  type LiveLoaderDataType<C extends keyof LiveContentConfig['collections']> =
139
140
  LiveContentConfig['collections'][C]['schema'] extends undefined