astro 4.13.1 → 4.13.2

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 (65) hide show
  1. package/astro-jsx.d.ts +0 -1
  2. package/astro.js +2 -1
  3. package/client.d.ts +1 -1
  4. package/components/Picture.astro +2 -2
  5. package/components/ViewTransitions.astro +1 -1
  6. package/config.d.ts +1 -1
  7. package/dist/actions/runtime/middleware.d.ts +3 -4
  8. package/dist/actions/runtime/middleware.js +20 -64
  9. package/dist/actions/runtime/route.js +12 -19
  10. package/dist/actions/runtime/utils.d.ts +0 -8
  11. package/dist/actions/runtime/utils.js +0 -15
  12. package/dist/actions/runtime/virtual/get-action.d.ts +8 -0
  13. package/dist/actions/runtime/virtual/get-action.js +17 -0
  14. package/dist/actions/runtime/virtual/shared.d.ts +18 -1
  15. package/dist/actions/runtime/virtual/shared.js +56 -8
  16. package/dist/actions/utils.d.ts +2 -1
  17. package/dist/actions/utils.js +10 -17
  18. package/dist/assets/build/generate.js +1 -1
  19. package/dist/assets/endpoint/generic.js +1 -1
  20. package/dist/assets/endpoint/node.js +3 -3
  21. package/dist/assets/services/sharp.js +1 -1
  22. package/dist/assets/services/vendor/squoosh/avif/avif_node_dec.js +1 -1
  23. package/dist/assets/services/vendor/squoosh/avif/avif_node_enc.js +1 -1
  24. package/dist/assets/services/vendor/squoosh/mozjpeg/mozjpeg_node_dec.js +1 -1
  25. package/dist/assets/services/vendor/squoosh/mozjpeg/mozjpeg_node_enc.js +1 -1
  26. package/dist/assets/services/vendor/squoosh/webp/webp_node_dec.js +1 -1
  27. package/dist/assets/services/vendor/squoosh/webp/webp_node_enc.js +1 -1
  28. package/dist/assets/utils/metadata.js +1 -1
  29. package/dist/assets/utils/node/emitAsset.js +1 -1
  30. package/dist/assets/utils/remoteProbe.js +1 -1
  31. package/dist/assets/utils/vendor/image-size/lookup.js +1 -1
  32. package/dist/assets/utils/vendor/image-size/types/svg.js +4 -4
  33. package/dist/cli/info/index.js +2 -2
  34. package/dist/cli/install-package.js +2 -2
  35. package/dist/core/app/index.js +1 -1
  36. package/dist/core/build/css-asset-name.d.ts +3 -3
  37. package/dist/core/build/css-asset-name.js +15 -8
  38. package/dist/core/build/generate.js +3 -3
  39. package/dist/core/build/index.js +7 -1
  40. package/dist/core/build/plugins/plugin-css.js +2 -2
  41. package/dist/core/config/schema.d.ts +55 -55
  42. package/dist/core/config/tsconfig.d.ts +1 -1
  43. package/dist/core/constants.js +1 -1
  44. package/dist/core/dev/dev.js +2 -2
  45. package/dist/core/errors/dev/vite.js +4 -4
  46. package/dist/core/errors/errors-data.d.ts +5 -0
  47. package/dist/core/messages.js +2 -2
  48. package/dist/core/middleware/index.js +1 -1
  49. package/dist/core/render-context.js +7 -4
  50. package/dist/core/routing/manifest/create.js +2 -2
  51. package/dist/events/error.js +1 -1
  52. package/dist/runtime/client/dev-toolbar/apps/audit/index.js +1 -1
  53. package/dist/runtime/client/dev-toolbar/apps/audit/rules/perf.js +4 -2
  54. package/dist/runtime/server/render/component.js +1 -3
  55. package/dist/transitions/router.js +2 -2
  56. package/dist/type-utils.d.ts +1 -1
  57. package/dist/vite-plugin-astro-server/vite.js +1 -2
  58. package/dist/vite-plugin-env/index.js +0 -1
  59. package/dist/vite-plugin-load-fallback/index.js +3 -3
  60. package/dist/vite-plugin-scanner/index.js +1 -1
  61. package/dist/vite-plugin-scripts/page-ssr.js +1 -1
  62. package/package.json +8 -11
  63. package/templates/actions.mjs +23 -19
  64. package/templates/content/types.d.ts +12 -10
  65. package/types/content.d.ts +1 -1
package/astro-jsx.d.ts CHANGED
@@ -14,7 +14,6 @@ declare namespace astroHTML.JSX {
14
14
  export type Children = Child | Child[];
15
15
 
16
16
  interface ElementChildrenAttribute {
17
- // eslint-disable-next-line @typescript-eslint/ban-types
18
17
  children: {};
19
18
  }
20
19
 
package/astro.js CHANGED
@@ -52,6 +52,7 @@ async function errorNodeUnsupported() {
52
52
  Node.js v${process.versions.node} is not supported by Astro!
53
53
  Please upgrade Node.js to a supported version: "${engines}"\n`);
54
54
 
55
+ // eslint-disable-next-line @typescript-eslint/no-require-imports
55
56
  const ci = typeof require !== 'undefined' ? require('ci-info') : await import('ci-info');
56
57
 
57
58
  // Special instructions for CI environments, which may have special steps needed.
@@ -65,7 +66,7 @@ Please upgrade Node.js to a supported version: "${engines}"\n`);
65
66
  }
66
67
  }
67
68
  console.log(
68
- `${ci.name} CI Environment Detected!\nAdditional steps may be needed to set your Node.js version:`
69
+ `${ci.name} CI Environment Detected!\nAdditional steps may be needed to set your Node.js version:`,
69
70
  );
70
71
  console.log(`Documentation: https://docs.astro.build/en/guides/deploy/`);
71
72
  if (CI_INSTRUCTIONS[platform]) {
package/client.d.ts CHANGED
@@ -50,7 +50,7 @@ declare module 'astro:assets' {
50
50
  * This is functionally equivalent to using the `<Image />` component, as the component calls this function internally.
51
51
  */
52
52
  getImage: (
53
- options: import('./dist/assets/types.js').UnresolvedImageTransform
53
+ options: import('./dist/assets/types.js').UnresolvedImageTransform,
54
54
  ) => Promise<import('./dist/assets/types.js').GetImageResult>;
55
55
  imageConfig: import('./dist/@types/astro.js').AstroConfig['image'];
56
56
  getConfiguredImageService: typeof import('./dist/assets/index.js').getConfiguredImageService;
@@ -53,8 +53,8 @@ const optimizedImages: GetImageResult[] = await Promise.all(
53
53
  format: format,
54
54
  widths: props.widths,
55
55
  densities: props.densities,
56
- })
57
- )
56
+ }),
57
+ ),
58
58
  );
59
59
 
60
60
  let resultFallbackFormat = fallbackFormat ?? defaultFallbackFormat;
@@ -53,7 +53,7 @@ const { fallback = 'animate' } = Astro.props;
53
53
  if (supportsViewTransitions || getFallback() !== 'none') {
54
54
  if (import.meta.env.DEV && window.matchMedia('(prefers-reduced-motion)').matches) {
55
55
  console.warn(
56
- `[transitions]: all view transition animations, including fallback animation, are disabled as this device has the prefer-reduced-motion setting enabled.`
56
+ `[transitions]: all view transition animations, including fallback animation, are disabled as this device has the prefer-reduced-motion setting enabled.`,
57
57
  );
58
58
  }
59
59
  document.addEventListener('click', (ev) => {
package/config.d.ts CHANGED
@@ -17,7 +17,7 @@ export function defineConfig(config: AstroUserConfig): AstroUserConfig;
17
17
  */
18
18
  export function getViteConfig(
19
19
  config: ViteUserConfig,
20
- inlineAstroConfig?: AstroInlineConfig
20
+ inlineAstroConfig?: AstroInlineConfig,
21
21
  ): ViteUserConfigFn;
22
22
 
23
23
  /**
@@ -1,9 +1,8 @@
1
- import type { APIContext } from '../../@types/astro.js';
1
+ import { type SerializedActionResult } from './virtual/shared.js';
2
2
  export type Locals = {
3
3
  _actionsInternal: {
4
- getActionResult: APIContext['getActionResult'];
5
- callAction: APIContext['callAction'];
6
- actionResult?: ReturnType<APIContext['getActionResult']>;
4
+ actionResult: SerializedActionResult;
5
+ actionName: string;
7
6
  };
8
7
  };
9
8
  export declare const onRequest: import("../../@types/astro.js").MiddlewareHandler;
@@ -1,36 +1,31 @@
1
1
  import { yellow } from "kleur/colors";
2
- import {
3
- ActionQueryStringInvalidError,
4
- ActionsUsedWithForGetError
5
- } from "../../core/errors/errors-data.js";
2
+ import { ActionQueryStringInvalidError } from "../../core/errors/errors-data.js";
6
3
  import { AstroError } from "../../core/errors/errors.js";
7
4
  import { defineMiddleware } from "../../core/middleware/index.js";
8
- import { formContentTypes, getAction, hasContentType } from "./utils.js";
9
- import { getActionQueryString } from "./virtual/shared.js";
5
+ import { formContentTypes, hasContentType } from "./utils.js";
6
+ import { getAction } from "./virtual/get-action.js";
7
+ import {
8
+ serializeActionResult
9
+ } from "./virtual/shared.js";
10
10
  const onRequest = defineMiddleware(async (context, next) => {
11
11
  const locals = context.locals;
12
12
  const { request } = context;
13
- if (locals._actionsInternal) {
14
- locals._actionsInternal.callAction = createCallAction(context);
13
+ if (locals._actionsInternal) return next();
14
+ if (import.meta.env.DEV && request.method === "POST" && request.body === null) {
15
+ console.warn(
16
+ yellow("[astro:actions]"),
17
+ 'POST requests should not be sent to prerendered pages. If you\'re using Actions, disable prerendering with `export const prerender = "false".'
18
+ );
15
19
  return next();
16
20
  }
17
- if (request.method === "POST" && request.body === null) {
18
- return nextWithStaticStub(next, context);
19
- }
20
21
  const actionName = context.url.searchParams.get("_astroAction");
21
22
  if (context.request.method === "POST" && actionName) {
22
23
  return handlePost({ context, next, actionName });
23
24
  }
24
- if (context.request.method === "GET" && actionName) {
25
- throw new AstroError({
26
- ...ActionsUsedWithForGetError,
27
- message: ActionsUsedWithForGetError.message(actionName)
28
- });
29
- }
30
25
  if (context.request.method === "POST") {
31
26
  return handlePostLegacy({ context, next });
32
27
  }
33
- return nextWithLocalsStub(next, context);
28
+ return next();
34
29
  });
35
30
  async function handlePost({
36
31
  context,
@@ -60,18 +55,11 @@ async function handleResult({
60
55
  actionName,
61
56
  actionResult
62
57
  }) {
63
- const actionsInternal = {
64
- getActionResult: (actionFn) => {
65
- if (actionFn.toString() !== getActionQueryString(actionName)) {
66
- return Promise.resolve(void 0);
67
- }
68
- return actionResult;
69
- },
70
- callAction: createCallAction(context),
71
- actionResult
72
- };
73
58
  const locals = context.locals;
74
- Object.defineProperty(locals, "_actionsInternal", { writable: false, value: actionsInternal });
59
+ locals._actionsInternal = {
60
+ actionName,
61
+ actionResult: serializeActionResult(actionResult)
62
+ };
75
63
  const response = await next();
76
64
  if (actionResult.error) {
77
65
  return new Response(response.body, {
@@ -84,15 +72,15 @@ async function handleResult({
84
72
  }
85
73
  async function handlePostLegacy({ context, next }) {
86
74
  const { request } = context;
87
- if (context.url.pathname.startsWith("/_actions")) return nextWithLocalsStub(next, context);
75
+ if (context.url.pathname.startsWith("/_actions")) return next();
88
76
  const contentType = request.headers.get("content-type");
89
77
  let formData;
90
78
  if (contentType && hasContentType(contentType, formContentTypes)) {
91
79
  formData = await request.clone().formData();
92
80
  }
93
- if (!formData) return nextWithLocalsStub(next, context);
81
+ if (!formData) return next();
94
82
  const actionName = formData.get("_astroAction");
95
- if (!actionName) return nextWithLocalsStub(next, context);
83
+ if (!actionName) return next();
96
84
  const baseAction = await getAction(actionName);
97
85
  if (!baseAction) {
98
86
  throw new AstroError({
@@ -104,38 +92,6 @@ async function handlePostLegacy({ context, next }) {
104
92
  const actionResult = await action(formData);
105
93
  return handleResult({ context, next, actionName, actionResult });
106
94
  }
107
- function nextWithStaticStub(next, context) {
108
- Object.defineProperty(context.locals, "_actionsInternal", {
109
- writable: false,
110
- value: {
111
- getActionResult: () => {
112
- console.warn(
113
- yellow("[astro:actions]"),
114
- "`getActionResult()` should not be called on prerendered pages. Astro can only handle actions for pages rendered on-demand."
115
- );
116
- return void 0;
117
- },
118
- callAction: createCallAction(context)
119
- }
120
- });
121
- return next();
122
- }
123
- function nextWithLocalsStub(next, context) {
124
- Object.defineProperty(context.locals, "_actionsInternal", {
125
- writable: false,
126
- value: {
127
- getActionResult: () => void 0,
128
- callAction: createCallAction(context)
129
- }
130
- });
131
- return next();
132
- }
133
- function createCallAction(context) {
134
- return (baseAction, input) => {
135
- const action = baseAction.bind(context);
136
- return action(input);
137
- };
138
- }
139
95
  export {
140
96
  onRequest
141
97
  };
@@ -1,4 +1,6 @@
1
- import { formContentTypes, getAction, hasContentType } from "./utils.js";
1
+ import { formContentTypes, hasContentType } from "./utils.js";
2
+ import { getAction } from "./virtual/get-action.js";
3
+ import { serializeActionResult } from "./virtual/shared.js";
2
4
  const POST = async (context) => {
3
5
  const { request, url } = context;
4
6
  const baseAction = await getAction(url.pathname);
@@ -8,7 +10,7 @@ const POST = async (context) => {
8
10
  const contentType = request.headers.get("Content-Type");
9
11
  const contentLength = request.headers.get("Content-Length");
10
12
  let args;
11
- if (contentLength === "0") {
13
+ if (!contentType || contentLength === "0") {
12
14
  args = void 0;
13
15
  } else if (contentType && hasContentType(contentType, formContentTypes)) {
14
16
  args = await request.clone().formData();
@@ -19,25 +21,16 @@ const POST = async (context) => {
19
21
  }
20
22
  const action = baseAction.bind(context);
21
23
  const result = await action(args);
22
- if (result.error) {
23
- return new Response(
24
- JSON.stringify({
25
- ...result.error,
26
- message: result.error.message,
27
- stack: import.meta.env.PROD ? void 0 : result.error.stack
28
- }),
29
- {
30
- status: result.error.status,
31
- headers: {
32
- "Content-Type": "application/json"
33
- }
34
- }
35
- );
24
+ const serialized = serializeActionResult(result);
25
+ if (serialized.type === "empty") {
26
+ return new Response(null, {
27
+ status: serialized.status
28
+ });
36
29
  }
37
- return new Response(JSON.stringify(result.data), {
38
- status: result.data !== void 0 ? 200 : 204,
30
+ return new Response(serialized.body, {
31
+ status: serialized.status,
39
32
  headers: {
40
- "Content-Type": "application/json"
33
+ "Content-Type": serialized.contentType
41
34
  }
42
35
  });
43
36
  };
@@ -1,16 +1,8 @@
1
- import type { ZodType } from 'zod';
2
1
  import type { APIContext } from '../../@types/astro.js';
3
- import type { ActionAccept, ActionClient } from './virtual/server.js';
4
2
  export declare const formContentTypes: string[];
5
3
  export declare function hasContentType(contentType: string, expected: string[]): boolean;
6
4
  export type ActionAPIContext = Omit<APIContext, 'getActionResult' | 'callAction' | 'props'>;
7
5
  export type MaybePromise<T> = T | Promise<T>;
8
- /**
9
- * Get server-side action based on the route path.
10
- * Imports from the virtual module `astro:internal-actions`, which maps to
11
- * the user's `src/actions/index.ts` file at build-time.
12
- */
13
- export declare function getAction(path: string): Promise<ActionClient<unknown, ActionAccept, ZodType> | undefined>;
14
6
  /**
15
7
  * Used to preserve the input schema type in the error object.
16
8
  * This allows for type inference on the `fields` property
@@ -3,22 +3,7 @@ function hasContentType(contentType, expected) {
3
3
  const type = contentType.split(";")[0].toLowerCase();
4
4
  return expected.some((t) => type === t);
5
5
  }
6
- async function getAction(path) {
7
- const pathKeys = path.replace("/_actions/", "").split(".");
8
- let { server: actionLookup } = await import("astro:internal-actions");
9
- for (const key of pathKeys) {
10
- if (!(key in actionLookup)) {
11
- return void 0;
12
- }
13
- actionLookup = actionLookup[key];
14
- }
15
- if (typeof actionLookup !== "function") {
16
- return void 0;
17
- }
18
- return actionLookup;
19
- }
20
6
  export {
21
7
  formContentTypes,
22
- getAction,
23
8
  hasContentType
24
9
  };
@@ -0,0 +1,8 @@
1
+ import type { ZodType } from 'zod';
2
+ import type { ActionAccept, ActionClient } from './server.js';
3
+ /**
4
+ * Get server-side action based on the route path.
5
+ * Imports from the virtual module `astro:internal-actions`, which maps to
6
+ * the user's `src/actions/index.ts` file at build-time.
7
+ */
8
+ export declare function getAction(path: string): Promise<ActionClient<unknown, ActionAccept, ZodType> | undefined>;
@@ -0,0 +1,17 @@
1
+ async function getAction(path) {
2
+ const pathKeys = path.replace("/_actions/", "").split(".");
3
+ let { server: actionLookup } = await import("astro:internal-actions");
4
+ for (const key of pathKeys) {
5
+ if (!(key in actionLookup)) {
6
+ return void 0;
7
+ }
8
+ actionLookup = actionLookup[key];
9
+ }
10
+ if (typeof actionLookup !== "function") {
11
+ return void 0;
12
+ }
13
+ return actionLookup;
14
+ }
15
+ export {
16
+ getAction
17
+ };
@@ -13,8 +13,9 @@ export declare class ActionError<T extends ErrorInferenceObject = ErrorInference
13
13
  });
14
14
  static codeToStatus(code: ActionErrorCode): number;
15
15
  static statusToCode(status: number): ActionErrorCode;
16
- static fromResponse(res: Response): Promise<ActionError<ErrorInferenceObject>>;
16
+ static fromJson(body: any): ActionError<ErrorInferenceObject>;
17
17
  }
18
+ export declare function isActionError(error?: unknown): error is ActionError;
18
19
  export declare function isInputError<T extends ErrorInferenceObject>(error?: ActionError<T>): error is ActionInputError<T>;
19
20
  export declare function isInputError(error?: unknown): error is ActionInputError<ErrorInferenceObject>;
20
21
  export type SafeResult<TInput extends ErrorInferenceObject, TOutput> = {
@@ -43,3 +44,19 @@ export declare function getActionProps<T extends (args: FormData) => MaybePromis
43
44
  readonly name: "_astroAction";
44
45
  readonly value: string;
45
46
  };
47
+ export type SerializedActionResult = {
48
+ type: 'data';
49
+ contentType: 'application/json+devalue';
50
+ status: 200;
51
+ body: string;
52
+ } | {
53
+ type: 'error';
54
+ contentType: 'application/json';
55
+ status: number;
56
+ body: string;
57
+ } | {
58
+ type: 'empty';
59
+ status: 204;
60
+ };
61
+ export declare function serializeActionResult(res: SafeResult<any, any>): SerializedActionResult;
62
+ export declare function deserializeActionResult(res: SerializedActionResult): SafeResult<any, any>;
@@ -1,3 +1,4 @@
1
+ import { parse as devalueParse, stringify as devalueStringify } from "devalue";
1
2
  const ACTION_ERROR_CODES = [
2
3
  "BAD_REQUEST",
3
4
  "UNAUTHORIZED",
@@ -53,22 +54,23 @@ class ActionError extends Error {
53
54
  static statusToCode(status) {
54
55
  return statusToCodeMap[status] ?? "INTERNAL_SERVER_ERROR";
55
56
  }
56
- static async fromResponse(res) {
57
- const body = await res.clone().json();
58
- if (typeof body === "object" && body?.type === "AstroActionInputError" && Array.isArray(body.issues)) {
57
+ static fromJson(body) {
58
+ if (isInputError(body)) {
59
59
  return new ActionInputError(body.issues);
60
60
  }
61
- if (typeof body === "object" && body?.type === "AstroActionError") {
61
+ if (isActionError(body)) {
62
62
  return new ActionError(body);
63
63
  }
64
64
  return new ActionError({
65
- message: res.statusText,
66
- code: ActionError.statusToCode(res.status)
65
+ code: "INTERNAL_SERVER_ERROR"
67
66
  });
68
67
  }
69
68
  }
69
+ function isActionError(error) {
70
+ return typeof error === "object" && error != null && "type" in error && error.type === "AstroActionError";
71
+ }
70
72
  function isInputError(error) {
71
- return error instanceof ActionInputError;
73
+ return typeof error === "object" && error != null && "type" in error && error.type === "AstroActionInputError" && "issues" in error && Array.isArray(error.issues);
72
74
  }
73
75
  class ActionInputError extends ActionError {
74
76
  type = "AstroActionInputError";
@@ -126,12 +128,58 @@ function getActionProps(action) {
126
128
  value: actionName
127
129
  };
128
130
  }
131
+ function serializeActionResult(res) {
132
+ if (res.error) {
133
+ return {
134
+ type: "error",
135
+ status: res.error.status,
136
+ contentType: "application/json",
137
+ body: JSON.stringify({
138
+ ...res.error,
139
+ message: res.error.message,
140
+ stack: import.meta.env.PROD ? void 0 : res.error.stack
141
+ })
142
+ };
143
+ }
144
+ if (res.data === void 0) {
145
+ return {
146
+ type: "empty",
147
+ status: 204
148
+ };
149
+ }
150
+ return {
151
+ type: "data",
152
+ status: 200,
153
+ contentType: "application/json+devalue",
154
+ body: devalueStringify(res.data, {
155
+ // Add support for URL objects
156
+ URL: (value) => value instanceof URL && value.href
157
+ })
158
+ };
159
+ }
160
+ function deserializeActionResult(res) {
161
+ if (res.type === "error") {
162
+ return { error: ActionError.fromJson(JSON.parse(res.body)), data: void 0 };
163
+ }
164
+ if (res.type === "empty") {
165
+ return { data: void 0, error: void 0 };
166
+ }
167
+ return {
168
+ data: devalueParse(res.body, {
169
+ URL: (href) => new URL(href)
170
+ }),
171
+ error: void 0
172
+ };
173
+ }
129
174
  export {
130
175
  ACTION_ERROR_CODES,
131
176
  ActionError,
132
177
  ActionInputError,
133
178
  callSafely,
179
+ deserializeActionResult,
134
180
  getActionProps,
135
181
  getActionQueryString,
136
- isInputError
182
+ isActionError,
183
+ isInputError,
184
+ serializeActionResult
137
185
  };
@@ -1,5 +1,6 @@
1
1
  import type { APIContext } from '../@types/astro.js';
2
2
  import type { Locals } from './runtime/middleware.js';
3
+ import { type ActionAPIContext } from './runtime/utils.js';
3
4
  export declare function hasActionsInternal(locals: APIContext['locals']): locals is Locals;
4
5
  export declare function createGetActionResult(locals: APIContext['locals']): APIContext['getActionResult'];
5
- export declare function createCallAction(locals: APIContext['locals']): APIContext['callAction'];
6
+ export declare function createCallAction(context: ActionAPIContext): APIContext['callAction'];
@@ -1,27 +1,20 @@
1
- import { AstroError } from "../core/errors/errors.js";
1
+ import {} from "./runtime/utils.js";
2
+ import { deserializeActionResult, getActionQueryString } from "./runtime/virtual/shared.js";
2
3
  function hasActionsInternal(locals) {
3
4
  return "_actionsInternal" in locals;
4
5
  }
5
6
  function createGetActionResult(locals) {
6
7
  return (actionFn) => {
7
- if (!hasActionsInternal(locals))
8
- throw new AstroError({
9
- name: "AstroActionError",
10
- message: "Experimental actions are not enabled in your project.",
11
- hint: "See https://docs.astro.build/en/reference/configuration-reference/#experimental-flags"
12
- });
13
- return locals._actionsInternal.getActionResult(actionFn);
8
+ if (!hasActionsInternal(locals) || actionFn.toString() !== getActionQueryString(locals._actionsInternal.actionName)) {
9
+ return void 0;
10
+ }
11
+ return deserializeActionResult(locals._actionsInternal.actionResult);
14
12
  };
15
13
  }
16
- function createCallAction(locals) {
17
- return (actionFn, input) => {
18
- if (!hasActionsInternal(locals))
19
- throw new AstroError({
20
- name: "AstroActionError",
21
- message: "Experimental actions are not enabled in your project.",
22
- hint: "See https://docs.astro.build/en/reference/configuration-reference/#experimental-flags"
23
- });
24
- return locals._actionsInternal.callAction(actionFn, input);
14
+ function createCallAction(context) {
15
+ return (baseAction, input) => {
16
+ const action = baseAction.bind(context);
17
+ return action(input);
25
18
  };
26
19
  }
27
20
  export {
@@ -63,7 +63,7 @@ async function generateImagesForPath(originalFilePath, transformsAndPath, env, q
63
63
  );
64
64
  await fs.promises.unlink(getFullImagePath(originalFilePath, env));
65
65
  }
66
- } catch (e) {
66
+ } catch {
67
67
  }
68
68
  }
69
69
  async function generateImage(originalImage, filepath, options) {
@@ -14,7 +14,7 @@ async function loadRemoteImage(src, headers) {
14
14
  return void 0;
15
15
  }
16
16
  return await res.arrayBuffer();
17
- } catch (err) {
17
+ } catch {
18
18
  return void 0;
19
19
  }
20
20
  }
@@ -23,14 +23,14 @@ async function loadLocalImage(src, url) {
23
23
  if (!isAbsolute(filePath) || !filePath.startsWith(assetsDirPath)) {
24
24
  return void 0;
25
25
  }
26
- } catch (err) {
26
+ } catch {
27
27
  return void 0;
28
28
  }
29
29
  }
30
30
  let buffer = void 0;
31
31
  try {
32
32
  buffer = await readFile(fileUrl);
33
- } catch (e) {
33
+ } catch {
34
34
  try {
35
35
  const sourceUrl = new URL(src, url.origin);
36
36
  buffer = await loadRemoteImage(sourceUrl);
@@ -48,7 +48,7 @@ async function loadRemoteImage(src) {
48
48
  return void 0;
49
49
  }
50
50
  return Buffer.from(await res.arrayBuffer());
51
- } catch (err) {
51
+ } catch {
52
52
  return void 0;
53
53
  }
54
54
  }
@@ -14,7 +14,7 @@ async function loadSharp() {
14
14
  let sharpImport;
15
15
  try {
16
16
  sharpImport = (await import("sharp")).default;
17
- } catch (e) {
17
+ } catch {
18
18
  throw new AstroError(AstroErrorData.MissingSharp);
19
19
  }
20
20
  sharpImport.cache(false);
@@ -1332,7 +1332,7 @@ var Module = /* @__PURE__ */ function() {
1332
1332
  wasmMemory.grow(size - buffer.byteLength + 65535 >>> 16);
1333
1333
  updateGlobalBufferAndViews(wasmMemory.buffer);
1334
1334
  return 1;
1335
- } catch (e) {
1335
+ } catch {
1336
1336
  }
1337
1337
  }
1338
1338
  function _emscripten_resize_heap(requestedSize) {
@@ -1473,7 +1473,7 @@ var Module = /* @__PURE__ */ function() {
1473
1473
  wasmMemory.grow(size - buffer.byteLength + 65535 >>> 16);
1474
1474
  updateGlobalBufferAndViews(wasmMemory.buffer);
1475
1475
  return 1;
1476
- } catch (e) {
1476
+ } catch {
1477
1477
  }
1478
1478
  }
1479
1479
  function _emscripten_resize_heap(requestedSize) {
@@ -1336,7 +1336,7 @@ var Module = /* @__PURE__ */ function() {
1336
1336
  wasmMemory.grow(size - buffer.byteLength + 65535 >>> 16);
1337
1337
  updateGlobalBufferAndViews(wasmMemory.buffer);
1338
1338
  return 1;
1339
- } catch (e) {
1339
+ } catch {
1340
1340
  }
1341
1341
  }
1342
1342
  function _emscripten_resize_heap(requestedSize) {
@@ -1439,7 +1439,7 @@ var Module = /* @__PURE__ */ function() {
1439
1439
  wasmMemory.grow(size - buffer.byteLength + 65535 >>> 16);
1440
1440
  updateGlobalBufferAndViews(wasmMemory.buffer);
1441
1441
  return 1;
1442
- } catch (e) {
1442
+ } catch {
1443
1443
  }
1444
1444
  }
1445
1445
  function _emscripten_resize_heap(requestedSize) {
@@ -1310,7 +1310,7 @@ var Module = /* @__PURE__ */ function() {
1310
1310
  wasmMemory.grow(size - buffer.byteLength + 65535 >>> 16);
1311
1311
  updateGlobalBufferAndViews(wasmMemory.buffer);
1312
1312
  return 1;
1313
- } catch (e) {
1313
+ } catch {
1314
1314
  }
1315
1315
  }
1316
1316
  function _emscripten_resize_heap(requestedSize) {
@@ -1472,7 +1472,7 @@ var Module = /* @__PURE__ */ function() {
1472
1472
  wasmMemory.grow(size - buffer.byteLength + 65535 >>> 16);
1473
1473
  updateGlobalBufferAndViews(wasmMemory.buffer);
1474
1474
  return 1;
1475
- } catch (e) {
1475
+ } catch {
1476
1476
  }
1477
1477
  }
1478
1478
  function _emscripten_resize_heap(requestedSize) {
@@ -17,7 +17,7 @@ async function imageMetadata(data, src) {
17
17
  format: type,
18
18
  orientation
19
19
  };
20
- } catch (e) {
20
+ } catch {
21
21
  throw new AstroError({
22
22
  ...AstroErrorData.NoImageMetadata,
23
23
  message: AstroErrorData.NoImageMetadata.message(src)
@@ -11,7 +11,7 @@ async function emitESMImage(id, _watchMode, fileEmitter) {
11
11
  let fileData;
12
12
  try {
13
13
  fileData = await fs.readFile(url);
14
- } catch (err) {
14
+ } catch {
15
15
  return void 0;
16
16
  }
17
17
  const fileMetadata = await imageMetadata(fileData, id);
@@ -27,7 +27,7 @@ async function inferRemoteSize(url) {
27
27
  await reader.cancel();
28
28
  return dimensions;
29
29
  }
30
- } catch (error) {
30
+ } catch {
31
31
  }
32
32
  }
33
33
  }