astro 4.12.3 → 4.13.1

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 (71) hide show
  1. package/dist/@types/astro.d.ts +21 -104
  2. package/dist/actions/runtime/middleware.d.ts +1 -0
  3. package/dist/actions/runtime/middleware.js +35 -24
  4. package/dist/actions/runtime/route.js +4 -4
  5. package/dist/actions/runtime/utils.d.ts +2 -0
  6. package/dist/actions/runtime/virtual/client.d.ts +0 -1
  7. package/dist/actions/runtime/virtual/client.js +0 -4
  8. package/dist/actions/runtime/virtual/server.d.ts +1 -4
  9. package/dist/actions/runtime/virtual/server.js +20 -13
  10. package/dist/actions/utils.d.ts +1 -0
  11. package/dist/actions/utils.js +12 -0
  12. package/dist/cli/add/index.d.ts +0 -7
  13. package/dist/cli/add/index.js +1 -2
  14. package/dist/cli/install-package.d.ts +0 -1
  15. package/dist/cli/install-package.js +1 -2
  16. package/dist/container/index.js +0 -1
  17. package/dist/content/runtime-assets.d.ts +2 -2
  18. package/dist/content/types-generator.js +5 -3
  19. package/dist/content/utils.d.ts +2 -11
  20. package/dist/content/utils.js +0 -8
  21. package/dist/core/app/types.d.ts +0 -1
  22. package/dist/core/build/generate.d.ts +0 -4
  23. package/dist/core/build/generate.js +10 -24
  24. package/dist/core/build/index.js +1 -1
  25. package/dist/core/build/internal.d.ts +0 -18
  26. package/dist/core/build/internal.js +0 -17
  27. package/dist/core/build/page-data.d.ts +1 -1
  28. package/dist/core/build/page-data.js +1 -18
  29. package/dist/core/build/plugins/plugin-analyzer.js +0 -4
  30. package/dist/core/build/plugins/plugin-internals.js +0 -7
  31. package/dist/core/build/plugins/plugin-manifest.d.ts +0 -10
  32. package/dist/core/build/plugins/plugin-manifest.js +0 -3
  33. package/dist/core/build/plugins/plugin-ssr.js +0 -1
  34. package/dist/core/build/types.d.ts +1 -8
  35. package/dist/core/compile/index.d.ts +0 -1
  36. package/dist/core/compile/types.d.ts +0 -7
  37. package/dist/core/config/schema.d.ts +0 -34
  38. package/dist/core/config/schema.js +0 -4
  39. package/dist/core/constants.js +1 -1
  40. package/dist/core/dev/dev.js +1 -1
  41. package/dist/core/dev/restart.d.ts +0 -2
  42. package/dist/core/dev/restart.js +1 -3
  43. package/dist/core/errors/dev/vite.d.ts +0 -13
  44. package/dist/core/errors/dev/vite.js +1 -2
  45. package/dist/core/errors/errors-data.d.ts +18 -6
  46. package/dist/core/errors/errors-data.js +13 -6
  47. package/dist/core/fs/index.d.ts +0 -2
  48. package/dist/core/fs/index.js +0 -5
  49. package/dist/core/logger/core.d.ts +0 -1
  50. package/dist/core/logger/core.js +0 -18
  51. package/dist/core/messages.d.ts +0 -1
  52. package/dist/core/messages.js +2 -3
  53. package/dist/core/middleware/callMiddleware.d.ts +1 -2
  54. package/dist/core/middleware/callMiddleware.js +2 -12
  55. package/dist/core/middleware/index.js +3 -2
  56. package/dist/core/render/ssr-element.d.ts +0 -1
  57. package/dist/core/render/ssr-element.js +0 -6
  58. package/dist/core/render-context.d.ts +1 -1
  59. package/dist/core/render-context.js +15 -39
  60. package/dist/core/util.d.ts +0 -2
  61. package/dist/core/util.js +0 -14
  62. package/dist/preferences/index.d.ts +0 -1
  63. package/dist/preferences/index.js +0 -1
  64. package/dist/runtime/server/render/component.d.ts +0 -3
  65. package/dist/vite-plugin-astro-server/controller.d.ts +0 -4
  66. package/dist/vite-plugin-astro-server/controller.js +0 -2
  67. package/dist/vite-plugin-astro-server/plugin.js +0 -1
  68. package/package.json +19 -25
  69. package/templates/actions.mjs +8 -5
  70. package/dist/actions/runtime/store.d.ts +0 -5
  71. package/dist/actions/runtime/store.js +0 -18
@@ -1021,6 +1021,7 @@ export declare const MissingMiddlewareForInternationalization: {
1021
1021
  message: string;
1022
1022
  };
1023
1023
  /**
1024
+ * @deprecated
1024
1025
  * @docs
1025
1026
  * @description
1026
1027
  * The user tried to rewrite using a route that doesn't exist, or it emitted a runtime error during its rendering phase.
@@ -1143,7 +1144,7 @@ export declare const ServerOnlyModule: {
1143
1144
  *
1144
1145
  * @see
1145
1146
  * - [Request.clone()](https://developer.mozilla.org/en-US/docs/Web/API/Request/clone)
1146
- * - [Astro.rewrite](https://docs.astro.build/en/reference/configuration-reference/#experimentalrewriting)
1147
+ * - [Astro.rewrite](https://docs.astro.build/en/reference/api-reference/#astrorewrite)
1147
1148
  */
1148
1149
  export declare const RewriteWithBodyUsed: {
1149
1150
  name: string;
@@ -1426,6 +1427,19 @@ export declare const DuplicateContentEntrySlugError: {
1426
1427
  title: string;
1427
1428
  message(collection: string, slug: string, preExisting: string, alsoFound: string): string;
1428
1429
  };
1430
+ /**
1431
+ * @docs
1432
+ * @see
1433
+ * - [devalue library](https://github.com/rich-harris/devalue)
1434
+ * @description
1435
+ * `transform()` functions in your content config must return valid JSON, or data types compatible with the devalue library (including Dates, Maps, and Sets).
1436
+ */
1437
+ export declare const UnsupportedConfigTransformError: {
1438
+ name: string;
1439
+ title: string;
1440
+ message: (parseError: string) => string;
1441
+ hint: string;
1442
+ };
1429
1443
  /**
1430
1444
  * @docs
1431
1445
  * @see
@@ -1467,15 +1481,13 @@ export declare const ActionQueryStringInvalidError: {
1467
1481
  };
1468
1482
  /**
1469
1483
  * @docs
1470
- * @see
1471
- * - [devalue library](https://github.com/rich-harris/devalue)
1472
1484
  * @description
1473
- * `transform()` functions in your content config must return valid JSON, or data types compatible with the devalue library (including Dates, Maps, and Sets).
1485
+ * Action called from a server page or endpoint without using `Astro.callAction()`.
1474
1486
  */
1475
- export declare const UnsupportedConfigTransformError: {
1487
+ export declare const ActionCalledFromServerError: {
1476
1488
  name: string;
1477
1489
  title: string;
1478
- message: (parseError: string) => string;
1490
+ message: string;
1479
1491
  hint: string;
1480
1492
  };
1481
1493
  export declare const UnknownError: {
@@ -541,6 +541,13 @@ Entries:
541
541
  - ${alsoFound}`;
542
542
  }
543
543
  };
544
+ const UnsupportedConfigTransformError = {
545
+ name: "UnsupportedConfigTransformError",
546
+ title: "Unsupported transform in content config.",
547
+ message: (parseError) => `\`transform()\` functions in your content config must return valid JSON, or data types compatible with the devalue library (including Dates, Maps, and Sets).
548
+ Full error: ${parseError}`,
549
+ hint: "See the devalue library for all supported types: https://github.com/rich-harris/devalue"
550
+ };
544
551
  const ActionsWithoutServerOutputError = {
545
552
  name: "ActionsWithoutServerOutputError",
546
553
  title: "Actions must be used with server output.",
@@ -559,15 +566,15 @@ const ActionQueryStringInvalidError = {
559
566
  message: (actionName) => `The server received the query string \`?_astroAction=${actionName}\`, but could not find an action with that name. If you changed an action's name in development, remove this query param from your URL and refresh.`,
560
567
  hint: "Actions are experimental. Visit the RFC for usage instructions: https://github.com/withastro/roadmap/blob/actions/proposals/0046-actions.md"
561
568
  };
562
- const UnsupportedConfigTransformError = {
563
- name: "UnsupportedConfigTransformError",
564
- title: "Unsupported transform in content config.",
565
- message: (parseError) => `\`transform()\` functions in your content config must return valid JSON, or data types compatible with the devalue library (including Dates, Maps, and Sets).
566
- Full error: ${parseError}`,
567
- hint: "See the devalue library for all supported types: https://github.com/rich-harris/devalue"
569
+ const ActionCalledFromServerError = {
570
+ name: "ActionCalledFromServerError",
571
+ title: "Action unexpected called from the server.",
572
+ message: "Action called from a server page or endpoint without using `Astro.callAction()`.",
573
+ hint: "See the RFC section on server calls for usage instructions: https://github.com/withastro/roadmap/blob/actions/proposals/0046-actions.md#call-actions-directly-from-server-code"
568
574
  };
569
575
  const UnknownError = { name: "UnknownError", title: "Unknown Error." };
570
576
  export {
577
+ ActionCalledFromServerError,
571
578
  ActionQueryStringInvalidError,
572
579
  ActionsUsedWithForGetError,
573
580
  ActionsWithoutServerOutputError,
@@ -1,4 +1,2 @@
1
- /** An fs utility, similar to `rimraf` or `rm -rf` */
2
- export declare function removeDir(_dir: URL): void;
3
1
  export declare function removeEmptyDirs(root: URL): void;
4
2
  export declare function emptyDir(_dir: URL, skip?: Set<string>): void;
@@ -3,10 +3,6 @@ import path from "node:path";
3
3
  import { fileURLToPath } from "node:url";
4
4
  import { appendForwardSlash } from "../path.js";
5
5
  const isWindows = process.platform === "win32";
6
- function removeDir(_dir) {
7
- const dir = fileURLToPath(_dir);
8
- fs.rmSync(dir, { recursive: true, force: true, maxRetries: 3 });
9
- }
10
6
  function removeEmptyDirs(root) {
11
7
  const dir = fileURLToPath(root);
12
8
  if (!fs.statSync(dir).isDirectory()) return;
@@ -90,6 +86,5 @@ const fixWinEPERMSync = (p, options, er) => {
90
86
  };
91
87
  export {
92
88
  emptyDir,
93
- removeDir,
94
89
  removeEmptyDirs
95
90
  };
@@ -38,7 +38,6 @@ export declare function debug(...args: any[]): void;
38
38
  * with colors. This is shared across different loggers, so it's defined here.
39
39
  */
40
40
  export declare function getEventPrefix({ level, label }: LogMessage): string;
41
- export declare let defaultLogLevel: LoggerLevel;
42
41
  /** Print out a timer message for debug() */
43
42
  export declare function timerMessage(message: string, startTime?: number): string;
44
43
  export declare class Logger {
@@ -81,23 +81,6 @@ function getEventPrefix({ level, label }) {
81
81
  }
82
82
  return dim(prefix[0]) + " " + blue(prefix.splice(1).join(" "));
83
83
  }
84
- let defaultLogLevel;
85
- if (typeof process !== "undefined") {
86
- let proc = process;
87
- if ("argv" in proc && Array.isArray(proc.argv)) {
88
- if (proc.argv.includes("--verbose")) {
89
- defaultLogLevel = "debug";
90
- } else if (proc.argv.includes("--silent")) {
91
- defaultLogLevel = "silent";
92
- } else {
93
- defaultLogLevel = "info";
94
- }
95
- } else {
96
- defaultLogLevel = "info";
97
- }
98
- } else {
99
- defaultLogLevel = "info";
100
- }
101
84
  function timerMessage(message, startTime = Date.now()) {
102
85
  let timeDiff = Date.now() - startTime;
103
86
  let timeDisplay = timeDiff < 750 ? `${Math.round(timeDiff)}ms` : `${(timeDiff / 1e3).toFixed(1)}s`;
@@ -158,7 +141,6 @@ export {
158
141
  Logger,
159
142
  dateTimeFormat,
160
143
  debug,
161
- defaultLogLevel,
162
144
  error,
163
145
  getEventPrefix,
164
146
  info,
@@ -45,7 +45,6 @@ export declare function prerelease({ currentVersion }: {
45
45
  export declare function success(message: string, tip?: string): string;
46
46
  export declare function failure(message: string, tip?: string): string;
47
47
  export declare function cancelled(message: string, tip?: string): string;
48
- export declare function getNetworkLogging(host: string | boolean): 'none' | 'host-to-expose' | 'visible';
49
48
  export declare function formatConfigErrorMessage(err: ZodError): string;
50
49
  export declare function formatErrorMessage(err: ErrorWithMetadata, showFullStacktrace: boolean): string;
51
50
  export declare function printHelp({ commandName, headline, usage, tables, description, }: {
@@ -38,7 +38,7 @@ function serverStart({
38
38
  host,
39
39
  base
40
40
  }) {
41
- const version = "4.12.3";
41
+ const version = "4.13.1";
42
42
  const localPrefix = `${dim("\u2503")} Local `;
43
43
  const networkPrefix = `${dim("\u2503")} Network `;
44
44
  const emptyPrefix = " ".repeat(11);
@@ -270,7 +270,7 @@ function printHelp({
270
270
  message.push(
271
271
  linebreak(),
272
272
  ` ${bgGreen(black(` ${commandName} `))} ${green(
273
- `v${"4.12.3"}`
273
+ `v${"4.13.1"}`
274
274
  )} ${headline}`
275
275
  );
276
276
  }
@@ -299,7 +299,6 @@ export {
299
299
  formatConfigErrorMessage,
300
300
  formatErrorMessage,
301
301
  fsStrictWarning,
302
- getNetworkLogging,
303
302
  newVersionAvailable,
304
303
  preferenceDefault,
305
304
  preferenceDefaultIntro,
@@ -1,5 +1,4 @@
1
1
  import type { APIContext, MiddlewareHandler, RewritePayload } from '../../@types/astro.js';
2
- import type { Logger } from '../logger/core.js';
3
2
  /**
4
3
  * Utility function that is in charge of calling the middleware.
5
4
  *
@@ -34,4 +33,4 @@ import type { Logger } from '../logger/core.js';
34
33
  * @param apiContext The API context
35
34
  * @param responseFunction A callback function that should return a promise with the response
36
35
  */
37
- export declare function callMiddleware(onRequest: MiddlewareHandler, apiContext: APIContext, responseFunction: (apiContext: APIContext, rewritePayload?: RewritePayload) => Promise<Response> | Response, enableRerouting: boolean, logger: Logger): Promise<Response>;
36
+ export declare function callMiddleware(onRequest: MiddlewareHandler, apiContext: APIContext, responseFunction: (apiContext: APIContext, rewritePayload?: RewritePayload) => Promise<Response> | Response): Promise<Response>;
@@ -1,20 +1,10 @@
1
1
  import { AstroError, AstroErrorData } from "../errors/index.js";
2
- async function callMiddleware(onRequest, apiContext, responseFunction, enableRerouting, logger) {
2
+ async function callMiddleware(onRequest, apiContext, responseFunction) {
3
3
  let nextCalled = false;
4
4
  let responseFunctionPromise = void 0;
5
5
  const next = async (payload) => {
6
6
  nextCalled = true;
7
- if (enableRerouting) {
8
- responseFunctionPromise = responseFunction(apiContext, payload);
9
- } else {
10
- if (payload) {
11
- logger.warn(
12
- "router",
13
- "The rewrite API is experimental. To use this feature, add the `rewriting` flag to the `experimental` object in your Astro config."
14
- );
15
- }
16
- responseFunctionPromise = responseFunction(apiContext);
17
- }
7
+ responseFunctionPromise = responseFunction(apiContext, payload);
18
8
  return responseFunctionPromise;
19
9
  };
20
10
  let middlewarePromise = onRequest(apiContext, next);
@@ -1,4 +1,4 @@
1
- import { createGetActionResult } from "../../actions/utils.js";
1
+ import { createCallAction, createGetActionResult } from "../../actions/utils.js";
2
2
  import {
3
3
  computeCurrentLocale,
4
4
  computePreferredLocale,
@@ -77,7 +77,8 @@ function createContext({
77
77
  }
78
78
  };
79
79
  return Object.assign(context, {
80
- getActionResult: createGetActionResult(context.locals)
80
+ getActionResult: createGetActionResult(context.locals),
81
+ callAction: createCallAction(context.locals)
81
82
  });
82
83
  }
83
84
  function isLocalsSerializable(value) {
@@ -8,7 +8,6 @@ export declare function createModuleScriptElement(script: {
8
8
  value: string;
9
9
  }, base?: string, assetsPrefix?: AssetsPrefix): SSRElement;
10
10
  export declare function createModuleScriptElementWithSrc(src: string, base?: string, assetsPrefix?: AssetsPrefix): SSRElement;
11
- export declare function createModuleScriptElementWithSrcSet(srces: string[], site?: string, assetsPrefix?: AssetsPrefix): Set<SSRElement>;
12
11
  export declare function createModuleScriptsSet(scripts: {
13
12
  type: 'inline' | 'external';
14
13
  value: string;
@@ -50,11 +50,6 @@ function createModuleScriptElementWithSrc(src, base, assetsPrefix) {
50
50
  children: ""
51
51
  };
52
52
  }
53
- function createModuleScriptElementWithSrcSet(srces, site, assetsPrefix) {
54
- return new Set(
55
- srces.map((src) => createModuleScriptElementWithSrc(src, site, assetsPrefix))
56
- );
57
- }
58
53
  function createModuleScriptsSet(scripts, base, assetsPrefix) {
59
54
  return new Set(
60
55
  scripts.map((script) => createModuleScriptElement(script, base, assetsPrefix))
@@ -64,7 +59,6 @@ export {
64
59
  createAssetLink,
65
60
  createModuleScriptElement,
66
61
  createModuleScriptElementWithSrc,
67
- createModuleScriptElementWithSrcSet,
68
62
  createModuleScriptsSet,
69
63
  createStylesheetElement,
70
64
  createStylesheetElementSet
@@ -1,5 +1,5 @@
1
1
  import type { APIContext, AstroGlobal, AstroGlobalPartial, ComponentInstance, MiddlewareHandler, Props, RouteData, SSRResult } from '../@types/astro.js';
2
- import type { ActionAPIContext } from '../actions/runtime/store.js';
2
+ import type { ActionAPIContext } from '../actions/runtime/utils.js';
3
3
  import { AstroCookies } from './cookies/index.js';
4
4
  import { type Pipeline } from './render/index.js';
5
5
  /**
@@ -1,4 +1,4 @@
1
- import { createGetActionResult, hasActionsInternal } from "../actions/utils.js";
1
+ import { createCallAction, createGetActionResult, hasActionsInternal } from "../actions/utils.js";
2
2
  import {
3
3
  computeCurrentLocale,
4
4
  computePreferredLocale,
@@ -105,23 +105,16 @@ class RenderContext {
105
105
  }
106
106
  const lastNext = async (ctx, payload) => {
107
107
  if (payload) {
108
- if (this.pipeline.manifest.rewritingEnabled) {
109
- pipeline.logger.debug("router", "Called rewriting to:", payload);
110
- const [routeData, component] = await pipeline.tryRewrite(
111
- payload,
112
- this.request,
113
- this.originalRoute
114
- );
115
- this.routeData = routeData;
116
- componentInstance = component;
117
- this.isRewriting = true;
118
- this.status = 200;
119
- } else {
120
- this.pipeline.logger.error(
121
- "router",
122
- "The rewrite API is experimental. To use this feature, add the `rewriting` flag to the `experimental` object in your Astro config."
123
- );
124
- }
108
+ pipeline.logger.debug("router", "Called rewriting to:", payload);
109
+ const [routeData, component] = await pipeline.tryRewrite(
110
+ payload,
111
+ this.request,
112
+ this.originalRoute
113
+ );
114
+ this.routeData = routeData;
115
+ componentInstance = component;
116
+ this.isRewriting = true;
117
+ this.status = 200;
125
118
  }
126
119
  let response2;
127
120
  switch (this.routeData.type) {
@@ -165,13 +158,7 @@ class RenderContext {
165
158
  }
166
159
  return response2;
167
160
  };
168
- const response = await callMiddleware(
169
- middleware,
170
- apiContext,
171
- lastNext,
172
- this.pipeline.manifest.rewritingEnabled,
173
- this.pipeline.logger
174
- );
161
+ const response = await callMiddleware(middleware, apiContext, lastNext);
175
162
  if (response.headers.get(ROUTE_TYPE_HEADER)) {
176
163
  response.headers.delete(ROUTE_TYPE_HEADER);
177
164
  }
@@ -182,24 +169,12 @@ class RenderContext {
182
169
  const context = this.createActionAPIContext();
183
170
  return Object.assign(context, {
184
171
  props,
185
- getActionResult: createGetActionResult(context.locals)
172
+ getActionResult: createGetActionResult(context.locals),
173
+ callAction: createCallAction(context.locals)
186
174
  });
187
175
  }
188
176
  async #executeRewrite(reroutePayload) {
189
177
  this.pipeline.logger.debug("router", "Calling rewrite: ", reroutePayload);
190
- if (!this.pipeline.manifest.rewritingEnabled) {
191
- this.pipeline.logger.error(
192
- "router",
193
- "The rewrite API is experimental. To use this feature, add the `rewriting` flag to the `experimental` object in your Astro config."
194
- );
195
- return new Response(
196
- "The rewrite API is experimental. To use this feature, add the `rewriting` flag to the `experimental` object in your Astro config.",
197
- {
198
- status: 500,
199
- statusText: "The rewrite API is experimental. To use this feature, add the `rewriting` flag to the `experimental` object in your Astro config."
200
- }
201
- );
202
- }
203
178
  const [routeData, component, newURL] = await this.pipeline.tryRewrite(
204
179
  reroutePayload,
205
180
  this.request,
@@ -396,6 +371,7 @@ class RenderContext {
396
371
  rewrite,
397
372
  request: this.request,
398
373
  getActionResult: createGetActionResult(locals),
374
+ callAction: createCallAction(locals),
399
375
  response,
400
376
  site: pipeline.site,
401
377
  url
@@ -38,8 +38,6 @@ export declare function isEndpoint(file: URL, settings: AstroSettings): boolean;
38
38
  export declare function isServerLikeOutput(config: AstroConfig): boolean;
39
39
  export declare function isModeServerWithNoAdapter(settings: AstroSettings): boolean;
40
40
  export declare function isContentCollectionsCacheEnabled(config: AstroConfig): boolean;
41
- export declare function relativeToSrcDir(config: AstroConfig, idOrUrl: URL | string): string;
42
- export declare function emoji(char: string, fallback: string): string;
43
41
  export declare function resolveJsToTs(filePath: string): string;
44
42
  /**
45
43
  * Set a default NODE_ENV so Vite doesn't set an incorrect default when loading the Astro config
package/dist/core/util.js CHANGED
@@ -113,18 +113,6 @@ function isContentCollectionsCacheEnabled(config) {
113
113
  return config.experimental.contentCollectionCache && // contentCollectionsCache is an SSG only feature
114
114
  !isServerLikeOutput(config);
115
115
  }
116
- function relativeToSrcDir(config, idOrUrl) {
117
- let id;
118
- if (typeof idOrUrl !== "string") {
119
- id = unwrapId(viteID(idOrUrl));
120
- } else {
121
- id = idOrUrl;
122
- }
123
- return id.slice(slash(fileURLToPath(config.srcDir)).length);
124
- }
125
- function emoji(char, fallback) {
126
- return process.platform !== "win32" ? char : fallback;
127
- }
128
116
  function resolveJsToTs(filePath) {
129
117
  if (filePath.endsWith(".jsx") && !fs.existsSync(filePath)) {
130
118
  const tryPath = filePath.slice(0, -4) + ".tsx";
@@ -143,7 +131,6 @@ export {
143
131
  NULL_BYTE_PLACEHOLDER,
144
132
  VALID_ID_PREFIX,
145
133
  arraify,
146
- emoji,
147
134
  ensureProcessNodeEnv,
148
135
  getOutputFilename,
149
136
  isContentCollectionsCacheEnabled,
@@ -156,7 +143,6 @@ export {
156
143
  isURL,
157
144
  padMultilineString,
158
145
  parseNpmName,
159
- relativeToSrcDir,
160
146
  resolveJsToTs,
161
147
  resolvePages,
162
148
  unwrapId,
@@ -33,5 +33,4 @@ export interface AstroPreferences {
33
33
  export declare function isValidKey(key: string): key is PreferenceKey;
34
34
  export declare function coerce(key: string, value: unknown): any;
35
35
  export default function createPreferences(config: AstroConfig): AstroPreferences;
36
- export declare function getGlobalPreferenceDir(): string;
37
36
  export {};
@@ -91,6 +91,5 @@ function getGlobalPreferenceDir() {
91
91
  export {
92
92
  coerce,
93
93
  createPreferences as default,
94
- getGlobalPreferenceDir,
95
94
  isValidKey
96
95
  };
@@ -1,10 +1,7 @@
1
1
  import type { RouteData, SSRResult } from '../../../@types/astro.js';
2
- import { type RenderInstruction } from './instruction.js';
3
- import type { HTMLBytes } from '../escape.js';
4
2
  import { type RenderInstance } from './common.js';
5
3
  import { type ComponentSlots } from './slot.js';
6
4
  declare const needsHeadRenderingSymbol: unique symbol;
7
- export type ComponentIterable = AsyncIterable<string | HTMLBytes | RenderInstruction>;
8
5
  export declare function renderComponent(result: SSRResult, displayName: string, Component: unknown, props: Record<string | number, any>, slots?: ComponentSlots): Promise<RenderInstance>;
9
6
  export declare function renderComponentToString(result: SSRResult, displayName: string, Component: unknown, props: Record<string | number, any>, slots?: any, isPage?: boolean, route?: RouteData): Promise<string>;
10
7
  export type NonAstroPageComponent = {
@@ -12,10 +12,6 @@ export type CreateControllerParams = {
12
12
  reload: ReloadFn;
13
13
  };
14
14
  export declare function createController(params: CreateControllerParams): DevServerController;
15
- export declare function createBaseController({ reload }: {
16
- reload: ReloadFn;
17
- }): DevServerController;
18
- export declare function createLoaderController(loader: ModuleLoader): DevServerController;
19
15
  export interface RunWithErrorHandlingParams {
20
16
  controller: DevServerController;
21
17
  pathname: string;
@@ -69,8 +69,6 @@ async function runWithErrorHandling({
69
69
  }
70
70
  }
71
71
  export {
72
- createBaseController,
73
72
  createController,
74
- createLoaderController,
75
73
  runWithErrorHandling
76
74
  };
@@ -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();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "astro",
3
- "version": "4.12.3",
3
+ "version": "4.13.1",
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,26 +110,25 @@
110
110
  "vendor"
111
111
  ],
112
112
  "dependencies": {
113
- "@astrojs/compiler": "^2.9.2",
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",
123
123
  "aria-query": "^5.3.0",
124
124
  "axobject-query": "^4.1.0",
125
125
  "boxen": "7.1.1",
126
- "chokidar": "^3.6.0",
127
126
  "ci-info": "^4.0.0",
128
127
  "clsx": "^2.1.1",
129
128
  "common-ancestor-path": "^1.0.1",
130
129
  "cookie": "^0.6.0",
131
130
  "cssesc": "^3.0.0",
132
- "debug": "^4.3.5",
131
+ "debug": "^4.3.6",
133
132
  "deterministic-object-hash": "^2.0.2",
134
133
  "devalue": "^5.0.0",
135
134
  "diff": "^5.2.0",
@@ -147,7 +146,7 @@
147
146
  "http-cache-semantics": "^4.1.1",
148
147
  "js-yaml": "^4.1.0",
149
148
  "kleur": "^4.1.5",
150
- "magic-string": "^0.30.10",
149
+ "magic-string": "^0.30.11",
151
150
  "mrmime": "^2.0.0",
152
151
  "ora": "^8.0.1",
153
152
  "p-limit": "^6.1.0",
@@ -157,18 +156,18 @@
157
156
  "prompts": "^2.4.2",
158
157
  "rehype": "^13.0.1",
159
158
  "semver": "^7.6.3",
160
- "shiki": "^1.11.0",
159
+ "shiki": "^1.12.0",
161
160
  "string-width": "^7.2.0",
162
161
  "strip-ansi": "^7.1.0",
163
162
  "tsconfck": "^3.1.1",
164
163
  "unist-util-visit": "^5.0.0",
165
164
  "vfile": "^6.0.2",
166
- "vite": "^5.3.4",
165
+ "vite": "^5.3.5",
167
166
  "vitefu": "^0.2.5",
168
167
  "which-pm": "^3.0.0",
169
168
  "yargs-parser": "^21.1.1",
170
169
  "zod": "^3.23.8",
171
- "zod-to-json-schema": "^3.23.1",
170
+ "zod-to-json-schema": "^3.23.2",
172
171
  "@astrojs/internal-helpers": "0.4.1",
173
172
  "@astrojs/markdown-remark": "5.2.0",
174
173
  "@astrojs/telemetry": "3.1.0"
@@ -177,13 +176,12 @@
177
176
  "sharp": "^0.33.3"
178
177
  },
179
178
  "devDependencies": {
180
- "@astrojs/check": "^0.8.2",
181
- "@playwright/test": "^1.45.2",
179
+ "@astrojs/check": "^0.9.0",
180
+ "@playwright/test": "^1.45.3",
182
181
  "@types/aria-query": "^5.0.4",
183
182
  "@types/babel__generator": "^7.6.8",
184
183
  "@types/babel__traverse": "^7.20.6",
185
184
  "@types/common-ancestor-path": "^1.0.2",
186
- "@types/connect": "^3.4.38",
187
185
  "@types/cssesc": "^3.0.2",
188
186
  "@types/debug": "^4.1.12",
189
187
  "@types/diff": "^5.2.1",
@@ -193,28 +191,24 @@
193
191
  "@types/html-escaper": "^3.0.2",
194
192
  "@types/http-cache-semantics": "^4.0.4",
195
193
  "@types/js-yaml": "^4.0.9",
196
- "@types/probe-image-size": "^7.2.4",
197
194
  "@types/prompts": "^2.4.9",
198
195
  "@types/semver": "^7.5.8",
199
- "@types/send": "^0.17.4",
200
- "@types/unist": "^3.0.2",
201
196
  "@types/yargs-parser": "^21.0.3",
202
197
  "cheerio": "1.0.0-rc.12",
203
198
  "eol": "^0.9.1",
204
199
  "expect-type": "^0.19.0",
205
200
  "mdast-util-mdx": "^3.0.0",
206
201
  "mdast-util-mdx-jsx": "^3.1.2",
207
- "memfs": "^4.9.3",
208
- "node-mocks-http": "^1.15.0",
202
+ "memfs": "^4.11.0",
203
+ "node-mocks-http": "^1.15.1",
209
204
  "parse-srcset": "^1.0.2",
210
205
  "rehype-autolink-headings": "^7.1.0",
211
206
  "rehype-slug": "^6.0.0",
212
207
  "rehype-toc": "^3.0.2",
213
208
  "remark-code-titles": "^0.1.2",
214
- "rollup": "^4.19.0",
209
+ "rollup": "^4.19.1",
215
210
  "sass": "^1.77.8",
216
- "srcset-parse": "^1.1.0",
217
- "undici": "^6.19.2",
211
+ "undici": "^6.19.5",
218
212
  "unified": "^11.0.5",
219
213
  "astro-scripts": "0.0.14"
220
214
  },
@@ -7,7 +7,9 @@ function toActionProxy(actionCallback = {}, aggregatedPath = '') {
7
7
  return target[objKey];
8
8
  }
9
9
  const path = aggregatedPath + objKey.toString();
10
- const action = (param) => callSafely(() => handleActionOrThrow(param, path));
10
+ function action(param) {
11
+ return callSafely(() => handleActionOrThrow(param, path, this));
12
+ }
11
13
 
12
14
  Object.assign(action, {
13
15
  queryString: getActionQueryString(path),
@@ -26,8 +28,8 @@ function toActionProxy(actionCallback = {}, aggregatedPath = '') {
26
28
  // Note: `orThrow` does not have progressive enhancement info.
27
29
  // If you want to throw exceptions,
28
30
  // you must handle those exceptions with client JS.
29
- orThrow: (param) => {
30
- return handleActionOrThrow(param, path);
31
+ orThrow(param) {
32
+ return handleActionOrThrow(param, path, this);
31
33
  },
32
34
  });
33
35
 
@@ -41,16 +43,17 @@ function toActionProxy(actionCallback = {}, aggregatedPath = '') {
41
43
  /**
42
44
  * @param {*} param argument passed to the action when called server or client-side.
43
45
  * @param {string} path Built path to call action by path name.
46
+ * @param {import('../src/@types/astro.d.ts').APIContext | undefined} context Injected API context when calling actions from the server.
44
47
  * Usage: `actions.[name](param)`.
45
48
  */
46
- async function handleActionOrThrow(param, path) {
49
+ async function handleActionOrThrow(param, path, context) {
47
50
  // When running server-side, import the action and call it.
48
51
  if (import.meta.env.SSR) {
49
52
  const { getAction } = await import('astro/actions/runtime/utils.js');
50
53
  const action = await getAction(path);
51
54
  if (!action) throw new Error(`Action not found: ${path}`);
52
55
 
53
- return action.orThrow(param);
56
+ return action.orThrow.bind(context)(param);
54
57
  }
55
58
 
56
59
  // When running client-side, make a fetch request to the action path.
@@ -1,5 +0,0 @@
1
- import { AsyncLocalStorage } from 'node:async_hooks';
2
- import type { APIContext } from '../../@types/astro.js';
3
- export type ActionAPIContext = Omit<APIContext, 'getActionResult' | 'props'>;
4
- export declare const ApiContextStorage: AsyncLocalStorage<ActionAPIContext>;
5
- export declare function getApiContext(): ActionAPIContext;