astro 4.12.2 → 4.13.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 (50) hide show
  1. package/dist/@types/astro.d.ts +6 -106
  2. package/dist/actions/consts.d.ts +3 -0
  3. package/dist/actions/consts.js +6 -0
  4. package/dist/actions/index.d.ts +12 -2
  5. package/dist/actions/index.js +43 -7
  6. package/dist/actions/runtime/middleware.js +80 -23
  7. package/dist/actions/runtime/route.js +2 -3
  8. package/dist/actions/runtime/utils.d.ts +4 -2
  9. package/dist/actions/runtime/utils.js +1 -1
  10. package/dist/actions/runtime/virtual/server.d.ts +6 -5
  11. package/dist/actions/runtime/virtual/server.js +6 -5
  12. package/dist/actions/runtime/virtual/shared.d.ts +7 -0
  13. package/dist/actions/runtime/virtual/shared.js +11 -1
  14. package/dist/cli/add/index.js +1 -1
  15. package/dist/container/index.js +0 -1
  16. package/dist/content/runtime-assets.d.ts +1 -1
  17. package/dist/content/types-generator.js +5 -3
  18. package/dist/content/vite-plugin-content-assets.js +0 -14
  19. package/dist/core/app/types.d.ts +0 -1
  20. package/dist/core/build/generate.js +10 -4
  21. package/dist/core/build/pipeline.js +0 -1
  22. package/dist/core/build/plugins/plugin-content.js +1 -1
  23. package/dist/core/build/plugins/plugin-manifest.js +0 -1
  24. package/dist/core/config/schema.d.ts +0 -34
  25. package/dist/core/config/schema.js +0 -4
  26. package/dist/core/constants.js +1 -1
  27. package/dist/core/dev/dev.js +1 -1
  28. package/dist/core/errors/dev/utils.js +12 -3
  29. package/dist/core/errors/dev/vite.d.ts +13 -0
  30. package/dist/core/errors/dev/vite.js +18 -4
  31. package/dist/core/errors/errors-data.d.ts +28 -1
  32. package/dist/core/errors/errors-data.js +14 -0
  33. package/dist/core/messages.js +2 -2
  34. package/dist/core/middleware/callMiddleware.d.ts +1 -2
  35. package/dist/core/middleware/callMiddleware.js +2 -12
  36. package/dist/core/render-context.js +13 -37
  37. package/dist/env/runtime.d.ts +2 -2
  38. package/dist/env/runtime.js +1 -1
  39. package/dist/integrations/hooks.js +1 -1
  40. package/dist/runtime/client/dev-toolbar/apps/audit/rules/a11y.js +0 -14
  41. package/dist/runtime/server/render/astro/instance.d.ts +2 -2
  42. package/dist/runtime/server/render/server-islands.js +2 -1
  43. package/dist/transitions/router.js +0 -8
  44. package/dist/vite-plugin-astro-server/error.js +1 -2
  45. package/dist/vite-plugin-astro-server/plugin.js +0 -1
  46. package/dist/vite-plugin-astro-server/route.js +0 -1
  47. package/dist/vite-plugin-astro-server/vite.js +4 -0
  48. package/package.json +22 -22
  49. package/templates/actions.mjs +29 -32
  50. package/templates/env/module.mjs +2 -0
@@ -110,10 +110,6 @@ const a11y_required_content = [
110
110
  "h6"
111
111
  ];
112
112
  const a11y_distracting_elements = ["blink", "marquee"];
113
- const a11y_nested_implicit_semantics = /* @__PURE__ */ new Map([
114
- ["header", "banner"],
115
- ["footer", "contentinfo"]
116
- ]);
117
113
  const a11y_implicit_semantics = /* @__PURE__ */ new Map([
118
114
  ["a", "link"],
119
115
  ["area", "link"],
@@ -525,16 +521,6 @@ const a11y = [
525
521
  }
526
522
  }
527
523
  ];
528
- const a11y_labelable = [
529
- "button",
530
- "input",
531
- "keygen",
532
- "meter",
533
- "output",
534
- "progress",
535
- "select",
536
- "textarea"
537
- ];
538
524
  const a11y_non_interactive_element_to_interactive_role_exceptions = {
539
525
  ul: ["listbox", "menu", "menubar", "radiogroup", "tablist", "tree", "treegrid"],
540
526
  ol: ["listbox", "menu", "menubar", "radiogroup", "tablist", "tree", "treegrid"],
@@ -1,6 +1,6 @@
1
1
  import type { SSRResult } from '../../../../@types/astro.js';
2
2
  import type { ComponentSlots } from '../slot.js';
3
- import type { AstroComponentFactory, AstroFactoryReturnValue } from './factory.js';
3
+ import type { AstroComponentFactory } from './factory.js';
4
4
  import type { RenderDestination } from '../common.js';
5
5
  type ComponentProps = Record<string | number, any>;
6
6
  declare const astroComponentInstanceSym: unique symbol;
@@ -12,7 +12,7 @@ export declare class AstroComponentInstance {
12
12
  private readonly factory;
13
13
  private returnValue;
14
14
  constructor(result: SSRResult, props: ComponentProps, slots: ComponentSlots, factory: AstroComponentFactory);
15
- init(result: SSRResult): Promise<AstroFactoryReturnValue>;
15
+ init(result: SSRResult): Promise<import("./factory.js").AstroFactoryReturnValue>;
16
16
  render(destination: RenderDestination): Promise<void>;
17
17
  }
18
18
  export declare function createAstroComponentInstance(result: SSRResult, displayName: string, factory: AstroComponentFactory, props: ComponentProps, slots?: any): AstroComponentInstance;
@@ -37,6 +37,7 @@ function renderServerIsland(result, _displayName, props, slots) {
37
37
  }
38
38
  }
39
39
  const hostId = crypto.randomUUID();
40
+ const serverIslandUrl = `${result.base}_server-islands/${componentId}${result.trailingSlash === "always" ? "/" : ""}`;
40
41
  destination.write(`<script async type="module" data-island-id="${hostId}">
41
42
  let componentId = ${safeJsonStringify(componentId)};
42
43
  let componentExport = ${safeJsonStringify(componentExport)};
@@ -47,7 +48,7 @@ let data = {
47
48
  slots: ${safeJsonStringify(renderedSlots)},
48
49
  };
49
50
 
50
- let response = await fetch('/_server-islands/${componentId}', {
51
+ let response = await fetch('${serverIslandUrl}', {
51
52
  method: 'POST',
52
53
  body: JSON.stringify(data),
53
54
  });
@@ -1,12 +1,4 @@
1
1
  import { TRANSITION_AFTER_SWAP, doPreparation, doSwap } from "./events.js";
2
- import {
3
- deselectScripts,
4
- restoreFocus,
5
- saveFocus,
6
- swapBodyElement,
7
- swapHeadElements,
8
- swapRootAttributes
9
- } from "./swap-functions.js";
10
2
  const inBrowser = import.meta.env.SSR === false;
11
3
  const pushState = inBrowser && history.pushState.bind(history);
12
4
  const replaceState = inBrowser && history.replaceState.bind(history);
@@ -1,7 +1,6 @@
1
1
  import { collectErrorMetadata } from "../core/errors/dev/index.js";
2
- import { AstroErrorData, createSafeError } from "../core/errors/index.js";
2
+ import { createSafeError } from "../core/errors/index.js";
3
3
  import { formatErrorMessage } from "../core/messages.js";
4
- import { eventError, telemetry } from "../events/index.js";
5
4
  function recordServerError(loader, config, { logger }, _err) {
6
5
  const err = createSafeError(_err);
7
6
  try {
@@ -116,7 +116,6 @@ function createDevelopmentManifest(settings) {
116
116
  inlinedScripts: /* @__PURE__ */ new Map(),
117
117
  i18n: i18nManifest,
118
118
  checkOrigin: settings.config.security?.checkOrigin ?? false,
119
- rewritingEnabled: settings.config.experimental.rewriting,
120
119
  experimentalEnvGetSecretEnabled: false,
121
120
  middleware(_, next) {
122
121
  return next();
@@ -1,5 +1,4 @@
1
1
  import {
2
- DEFAULT_404_COMPONENT,
3
2
  REROUTE_DIRECTIVE_HEADER,
4
3
  REWRITE_DIRECTIVE_HEADER_KEY,
5
4
  clientLocalsSymbol
@@ -1,6 +1,7 @@
1
1
  import npath from "node:path";
2
2
  import { SUPPORTED_MARKDOWN_FILE_EXTENSIONS } from "../core/constants.js";
3
3
  import { unwrapId } from "../core/util.js";
4
+ import { hasSpecialQueries } from "../vite-plugin-utils/index.js";
4
5
  import { isCSSRequest } from "./util.js";
5
6
  const fileExtensionsToSSR = /* @__PURE__ */ new Set([".astro", ".mdoc", ...SUPPORTED_MARKDOWN_FILE_EXTENSIONS]);
6
7
  const STRIP_QUERY_PARAMS_REGEX = /\?.*$/;
@@ -27,6 +28,9 @@ async function* crawlGraph(loader, _id, isRootFile, scanned = /* @__PURE__ */ ne
27
28
  if (isCSSRequest(id)) {
28
29
  continue;
29
30
  }
31
+ if (hasSpecialQueries(id)) {
32
+ continue;
33
+ }
30
34
  for (const importedModule of entry.importedModules) {
31
35
  if (!importedModule.id) continue;
32
36
  const importedModulePathname = importedModule.id.replace(STRIP_QUERY_PARAMS_REGEX, "");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "astro",
3
- "version": "4.12.2",
3
+ "version": "4.13.0",
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",
@@ -110,13 +110,13 @@
110
110
  "vendor"
111
111
  ],
112
112
  "dependencies": {
113
- "@astrojs/compiler": "^2.9.0",
114
- "@babel/core": "^7.24.9",
115
- "@babel/generator": "^7.24.10",
116
- "@babel/parser": "^7.24.8",
117
- "@babel/plugin-transform-react-jsx": "^7.24.7",
118
- "@babel/traverse": "^7.24.8",
119
- "@babel/types": "^7.24.9",
113
+ "@astrojs/compiler": "^2.10.0",
114
+ "@babel/core": "^7.25.2",
115
+ "@babel/generator": "^7.25.0",
116
+ "@babel/parser": "^7.25.3",
117
+ "@babel/plugin-transform-react-jsx": "^7.25.2",
118
+ "@babel/traverse": "^7.25.3",
119
+ "@babel/types": "^7.25.2",
120
120
  "@types/babel__core": "^7.20.5",
121
121
  "@types/cookie": "^0.6.0",
122
122
  "acorn": "^8.12.1",
@@ -129,7 +129,7 @@
129
129
  "common-ancestor-path": "^1.0.1",
130
130
  "cookie": "^0.6.0",
131
131
  "cssesc": "^3.0.0",
132
- "debug": "^4.3.5",
132
+ "debug": "^4.3.6",
133
133
  "deterministic-object-hash": "^2.0.2",
134
134
  "devalue": "^5.0.0",
135
135
  "diff": "^5.2.0",
@@ -147,7 +147,7 @@
147
147
  "http-cache-semantics": "^4.1.1",
148
148
  "js-yaml": "^4.1.0",
149
149
  "kleur": "^4.1.5",
150
- "magic-string": "^0.30.10",
150
+ "magic-string": "^0.30.11",
151
151
  "mrmime": "^2.0.0",
152
152
  "ora": "^8.0.1",
153
153
  "p-limit": "^6.1.0",
@@ -156,19 +156,19 @@
156
156
  "preferred-pm": "^4.0.0",
157
157
  "prompts": "^2.4.2",
158
158
  "rehype": "^13.0.1",
159
- "semver": "^7.6.2",
160
- "shiki": "^1.10.3",
159
+ "semver": "^7.6.3",
160
+ "shiki": "^1.12.0",
161
161
  "string-width": "^7.2.0",
162
162
  "strip-ansi": "^7.1.0",
163
163
  "tsconfck": "^3.1.1",
164
164
  "unist-util-visit": "^5.0.0",
165
165
  "vfile": "^6.0.2",
166
- "vite": "^5.3.4",
166
+ "vite": "^5.3.5",
167
167
  "vitefu": "^0.2.5",
168
168
  "which-pm": "^3.0.0",
169
169
  "yargs-parser": "^21.1.1",
170
170
  "zod": "^3.23.8",
171
- "zod-to-json-schema": "^3.23.1",
171
+ "zod-to-json-schema": "^3.23.2",
172
172
  "@astrojs/internal-helpers": "0.4.1",
173
173
  "@astrojs/markdown-remark": "5.2.0",
174
174
  "@astrojs/telemetry": "3.1.0"
@@ -177,8 +177,8 @@
177
177
  "sharp": "^0.33.3"
178
178
  },
179
179
  "devDependencies": {
180
- "@astrojs/check": "^0.8.1",
181
- "@playwright/test": "^1.45.2",
180
+ "@astrojs/check": "^0.9.0",
181
+ "@playwright/test": "^1.45.3",
182
182
  "@types/aria-query": "^5.0.4",
183
183
  "@types/babel__generator": "^7.6.8",
184
184
  "@types/babel__traverse": "^7.20.6",
@@ -188,12 +188,12 @@
188
188
  "@types/debug": "^4.1.12",
189
189
  "@types/diff": "^5.2.1",
190
190
  "@types/dlv": "^1.1.4",
191
- "@types/dom-view-transitions": "^1.0.4",
191
+ "@types/dom-view-transitions": "^1.0.5",
192
192
  "@types/hast": "^3.0.4",
193
193
  "@types/html-escaper": "^3.0.2",
194
194
  "@types/http-cache-semantics": "^4.0.4",
195
195
  "@types/js-yaml": "^4.0.9",
196
- "@types/probe-image-size": "^7.2.4",
196
+ "@types/probe-image-size": "^7.2.5",
197
197
  "@types/prompts": "^2.4.9",
198
198
  "@types/semver": "^7.5.8",
199
199
  "@types/send": "^0.17.4",
@@ -204,17 +204,17 @@
204
204
  "expect-type": "^0.19.0",
205
205
  "mdast-util-mdx": "^3.0.0",
206
206
  "mdast-util-mdx-jsx": "^3.1.2",
207
- "memfs": "^4.9.3",
208
- "node-mocks-http": "^1.15.0",
207
+ "memfs": "^4.11.0",
208
+ "node-mocks-http": "^1.15.1",
209
209
  "parse-srcset": "^1.0.2",
210
210
  "rehype-autolink-headings": "^7.1.0",
211
211
  "rehype-slug": "^6.0.0",
212
212
  "rehype-toc": "^3.0.2",
213
213
  "remark-code-titles": "^0.1.2",
214
- "rollup": "^4.18.1",
214
+ "rollup": "^4.19.1",
215
215
  "sass": "^1.77.8",
216
216
  "srcset-parse": "^1.1.0",
217
- "undici": "^6.19.2",
217
+ "undici": "^6.19.5",
218
218
  "unified": "^11.0.5",
219
219
  "astro-scripts": "0.0.14"
220
220
  },
@@ -1,39 +1,36 @@
1
- import { ActionError, callSafely } from 'astro:actions';
1
+ import { ActionError, callSafely, getActionQueryString } from 'astro:actions';
2
2
 
3
- function toActionProxy(actionCallback = {}, aggregatedPath = '/_actions/') {
3
+ function toActionProxy(actionCallback = {}, aggregatedPath = '') {
4
4
  return new Proxy(actionCallback, {
5
5
  get(target, objKey) {
6
- if (objKey in target) {
6
+ if (objKey in target || typeof objKey === 'symbol') {
7
7
  return target[objKey];
8
8
  }
9
9
  const path = aggregatedPath + objKey.toString();
10
- const action = (param) => actionHandler(param, path);
11
- action.toString = () => path;
12
- action.safe = (input) => {
13
- return callSafely(() => action(input));
14
- };
15
- action.safe.toString = () => path;
10
+ const action = (param) => callSafely(() => handleActionOrThrow(param, path));
11
+
12
+ Object.assign(action, {
13
+ queryString: getActionQueryString(path),
14
+ toString: () => action.queryString,
15
+ // Progressive enhancement info for React.
16
+ $$FORM_ACTION: function () {
17
+ return {
18
+ method: 'POST',
19
+ // `name` creates a hidden input.
20
+ // It's unused by Astro, but we can't turn this off.
21
+ // At least use a name that won't conflict with a user's formData.
22
+ name: '_astroAction',
23
+ action: action.toString(),
24
+ };
25
+ },
26
+ // Note: `orThrow` does not have progressive enhancement info.
27
+ // If you want to throw exceptions,
28
+ // you must handle those exceptions with client JS.
29
+ orThrow: (param) => {
30
+ return handleActionOrThrow(param, path);
31
+ },
32
+ });
16
33
 
17
- // Add progressive enhancement info for React.
18
- action.$$FORM_ACTION = function () {
19
- const data = new FormData();
20
- data.set('_astroAction', action.toString());
21
- return {
22
- method: 'POST',
23
- name: action.toString(),
24
- data,
25
- };
26
- };
27
- action.safe.$$FORM_ACTION = function () {
28
- const data = new FormData();
29
- data.set('_astroAction', action.toString());
30
- data.set('_astroActionSafe', 'true');
31
- return {
32
- method: 'POST',
33
- name: action.toString(),
34
- data,
35
- };
36
- };
37
34
  // recurse to construct queries for nested object paths
38
35
  // ex. actions.user.admins.auth()
39
36
  return toActionProxy(action, path + '.');
@@ -46,14 +43,14 @@ function toActionProxy(actionCallback = {}, aggregatedPath = '/_actions/') {
46
43
  * @param {string} path Built path to call action by path name.
47
44
  * Usage: `actions.[name](param)`.
48
45
  */
49
- async function actionHandler(param, path) {
46
+ async function handleActionOrThrow(param, path) {
50
47
  // When running server-side, import the action and call it.
51
48
  if (import.meta.env.SSR) {
52
49
  const { getAction } = await import('astro/actions/runtime/utils.js');
53
50
  const action = await getAction(path);
54
51
  if (!action) throw new Error(`Action not found: ${path}`);
55
52
 
56
- return action(param);
53
+ return action.orThrow(param);
57
54
  }
58
55
 
59
56
  // When running client-side, make a fetch request to the action path.
@@ -72,7 +69,7 @@ async function actionHandler(param, path) {
72
69
  headers.set('Content-Type', 'application/json');
73
70
  headers.set('Content-Length', body?.length.toString() ?? '0');
74
71
  }
75
- const res = await fetch(path, {
72
+ const res = await fetch(`/_actions/${path}`, {
76
73
  method: 'POST',
77
74
  body,
78
75
  headers,
@@ -25,6 +25,8 @@ const _internalGetSecret = (key) => {
25
25
  throw createInvalidVariablesError(key, type, result);
26
26
  };
27
27
 
28
+ // used while generating the virtual module
29
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
28
30
  setOnSetGetEnv((reset) => {
29
31
  // @@ON_SET_GET_ENV@@
30
32
  });