astro 4.13.0 → 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 (63) hide show
  1. package/dist/@types/astro.d.ts +21 -2
  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/content/runtime-assets.d.ts +1 -1
  17. package/dist/content/utils.d.ts +2 -11
  18. package/dist/content/utils.js +0 -8
  19. package/dist/core/build/generate.d.ts +0 -4
  20. package/dist/core/build/generate.js +1 -21
  21. package/dist/core/build/index.js +1 -1
  22. package/dist/core/build/internal.d.ts +0 -18
  23. package/dist/core/build/internal.js +0 -17
  24. package/dist/core/build/page-data.d.ts +1 -1
  25. package/dist/core/build/page-data.js +1 -18
  26. package/dist/core/build/plugins/plugin-analyzer.js +0 -4
  27. package/dist/core/build/plugins/plugin-internals.js +0 -7
  28. package/dist/core/build/plugins/plugin-manifest.d.ts +0 -10
  29. package/dist/core/build/plugins/plugin-manifest.js +0 -2
  30. package/dist/core/build/plugins/plugin-ssr.js +0 -1
  31. package/dist/core/build/types.d.ts +1 -8
  32. package/dist/core/compile/index.d.ts +0 -1
  33. package/dist/core/compile/types.d.ts +0 -7
  34. package/dist/core/constants.js +1 -1
  35. package/dist/core/dev/dev.js +1 -1
  36. package/dist/core/dev/restart.d.ts +0 -2
  37. package/dist/core/dev/restart.js +1 -3
  38. package/dist/core/errors/dev/vite.d.ts +0 -13
  39. package/dist/core/errors/dev/vite.js +1 -2
  40. package/dist/core/errors/errors-data.d.ts +16 -5
  41. package/dist/core/errors/errors-data.js +13 -6
  42. package/dist/core/fs/index.d.ts +0 -2
  43. package/dist/core/fs/index.js +0 -5
  44. package/dist/core/logger/core.d.ts +0 -1
  45. package/dist/core/logger/core.js +0 -18
  46. package/dist/core/messages.d.ts +0 -1
  47. package/dist/core/messages.js +2 -3
  48. package/dist/core/middleware/index.js +3 -2
  49. package/dist/core/render/ssr-element.d.ts +0 -1
  50. package/dist/core/render/ssr-element.js +0 -6
  51. package/dist/core/render-context.d.ts +1 -1
  52. package/dist/core/render-context.js +4 -2
  53. package/dist/core/util.d.ts +0 -2
  54. package/dist/core/util.js +0 -14
  55. package/dist/preferences/index.d.ts +0 -1
  56. package/dist/preferences/index.js +0 -1
  57. package/dist/runtime/server/render/component.d.ts +0 -3
  58. package/dist/vite-plugin-astro-server/controller.d.ts +0 -4
  59. package/dist/vite-plugin-astro-server/controller.js +0 -2
  60. package/package.json +1 -7
  61. package/templates/actions.mjs +8 -5
  62. package/dist/actions/runtime/store.d.ts +0 -5
  63. package/dist/actions/runtime/store.js +0 -18
@@ -4,7 +4,7 @@ import type { MarkdownHeading, MarkdownVFile, RehypePlugins, RemarkPlugins, Rema
4
4
  import type * as babel from '@babel/core';
5
5
  import type * as rollup from 'rollup';
6
6
  import type * as vite from 'vite';
7
- import type { ActionAccept, ActionClient, ActionInputSchema } from '../actions/runtime/virtual/server.js';
7
+ import type { ActionAccept, ActionClient, ActionInputSchema, ActionReturnType } from '../actions/runtime/virtual/server.js';
8
8
  import type { RemotePattern } from '../assets/utils/remotePattern.js';
9
9
  import type { AssetsPrefix, SSRManifest, SerializedSSRManifest } from '../core/app/types.js';
10
10
  import type { PageBuildData } from '../core/build/types.js';
@@ -182,6 +182,21 @@ export interface AstroGlobal<Props extends Record<string, any> = Record<string,
182
182
  * ```
183
183
  */
184
184
  getActionResult: AstroSharedContext['getActionResult'];
185
+ /**
186
+ * Call an Action directly from an Astro page or API endpoint.
187
+ * Expects the action function as the first parameter,
188
+ * and the type-safe action input as the second parameter.
189
+ * Returns a Promise with the action result.
190
+ *
191
+ * Example usage:
192
+ *
193
+ * ```typescript
194
+ * import { actions } from 'astro:actions';
195
+ *
196
+ * const result = await Astro.callAction(actions.getPost, { postId: 'test' });
197
+ * ```
198
+ */
199
+ callAction: AstroSharedContext['callAction'];
185
200
  /** Redirect to another page
186
201
  *
187
202
  * Example usage:
@@ -2491,7 +2506,11 @@ interface AstroSharedContext<Props extends Record<string, any> = Record<string,
2491
2506
  /**
2492
2507
  * Get action result on the server when using a form POST.
2493
2508
  */
2494
- getActionResult: <TAccept extends ActionAccept, TInputSchema extends ActionInputSchema<TAccept>, TAction extends ActionClient<unknown, TAccept, TInputSchema>>(action: TAction) => Awaited<ReturnType<TAction>> | undefined;
2509
+ getActionResult: <TAccept extends ActionAccept, TInputSchema extends ActionInputSchema<TAccept>, TAction extends ActionClient<unknown, TAccept, TInputSchema>>(action: TAction) => ActionReturnType<TAction> | undefined;
2510
+ /**
2511
+ * Call action handler from the server.
2512
+ */
2513
+ callAction: <TAccept extends ActionAccept, TInputSchema extends ActionInputSchema<TAccept>, TOutput, TAction extends ActionClient<TOutput, TAccept, TInputSchema> | ActionClient<TOutput, TAccept, TInputSchema>['orThrow']>(action: TAction, input: Parameters<TAction>[0]) => Promise<ActionReturnType<TAction>>;
2495
2514
  /**
2496
2515
  * Route parameters for this request if this is a dynamic route.
2497
2516
  */
@@ -2,6 +2,7 @@ import type { APIContext } from '../../@types/astro.js';
2
2
  export type Locals = {
3
3
  _actionsInternal: {
4
4
  getActionResult: APIContext['getActionResult'];
5
+ callAction: APIContext['callAction'];
5
6
  actionResult?: ReturnType<APIContext['getActionResult']>;
6
7
  };
7
8
  };
@@ -5,13 +5,15 @@ import {
5
5
  } from "../../core/errors/errors-data.js";
6
6
  import { AstroError } from "../../core/errors/errors.js";
7
7
  import { defineMiddleware } from "../../core/middleware/index.js";
8
- import { ApiContextStorage } from "./store.js";
9
8
  import { formContentTypes, getAction, hasContentType } from "./utils.js";
10
9
  import { getActionQueryString } from "./virtual/shared.js";
11
10
  const onRequest = defineMiddleware(async (context, next) => {
12
11
  const locals = context.locals;
13
12
  const { request } = context;
14
- if (locals._actionsInternal) return ApiContextStorage.run(context, () => next());
13
+ if (locals._actionsInternal) {
14
+ locals._actionsInternal.callAction = createCallAction(context);
15
+ return next();
16
+ }
15
17
  if (request.method === "POST" && request.body === null) {
16
18
  return nextWithStaticStub(next, context);
17
19
  }
@@ -36,8 +38,8 @@ async function handlePost({
36
38
  actionName
37
39
  }) {
38
40
  const { request } = context;
39
- const action = await getAction(actionName);
40
- if (!action) {
41
+ const baseAction = await getAction(actionName);
42
+ if (!baseAction) {
41
43
  throw new AstroError({
42
44
  ...ActionQueryStringInvalidError,
43
45
  message: ActionQueryStringInvalidError.message(actionName)
@@ -48,10 +50,11 @@ async function handlePost({
48
50
  if (contentType && hasContentType(contentType, formContentTypes)) {
49
51
  formData = await request.clone().formData();
50
52
  }
51
- const actionResult = await ApiContextStorage.run(context, () => action(formData));
53
+ const action = baseAction.bind(context);
54
+ const actionResult = await action(formData);
52
55
  return handleResult({ context, next, actionName, actionResult });
53
56
  }
54
- function handleResult({
57
+ async function handleResult({
55
58
  context,
56
59
  next,
57
60
  actionName,
@@ -64,21 +67,20 @@ function handleResult({
64
67
  }
65
68
  return actionResult;
66
69
  },
70
+ callAction: createCallAction(context),
67
71
  actionResult
68
72
  };
69
73
  const locals = context.locals;
70
74
  Object.defineProperty(locals, "_actionsInternal", { writable: false, value: actionsInternal });
71
- return ApiContextStorage.run(context, async () => {
72
- const response = await next();
73
- if (actionResult.error) {
74
- return new Response(response.body, {
75
- status: actionResult.error.status,
76
- statusText: actionResult.error.type,
77
- headers: response.headers
78
- });
79
- }
80
- return response;
81
- });
75
+ const response = await next();
76
+ if (actionResult.error) {
77
+ return new Response(response.body, {
78
+ status: actionResult.error.status,
79
+ statusText: actionResult.error.type,
80
+ headers: response.headers
81
+ });
82
+ }
83
+ return response;
82
84
  }
83
85
  async function handlePostLegacy({ context, next }) {
84
86
  const { request } = context;
@@ -91,14 +93,15 @@ async function handlePostLegacy({ context, next }) {
91
93
  if (!formData) return nextWithLocalsStub(next, context);
92
94
  const actionName = formData.get("_astroAction");
93
95
  if (!actionName) return nextWithLocalsStub(next, context);
94
- const action = await getAction(actionName);
95
- if (!action) {
96
+ const baseAction = await getAction(actionName);
97
+ if (!baseAction) {
96
98
  throw new AstroError({
97
99
  ...ActionQueryStringInvalidError,
98
100
  message: ActionQueryStringInvalidError.message(actionName)
99
101
  });
100
102
  }
101
- const actionResult = await ApiContextStorage.run(context, () => action(formData));
103
+ const action = baseAction.bind(context);
104
+ const actionResult = await action(formData);
102
105
  return handleResult({ context, next, actionName, actionResult });
103
106
  }
104
107
  function nextWithStaticStub(next, context) {
@@ -111,19 +114,27 @@ function nextWithStaticStub(next, context) {
111
114
  "`getActionResult()` should not be called on prerendered pages. Astro can only handle actions for pages rendered on-demand."
112
115
  );
113
116
  return void 0;
114
- }
117
+ },
118
+ callAction: createCallAction(context)
115
119
  }
116
120
  });
117
- return ApiContextStorage.run(context, () => next());
121
+ return next();
118
122
  }
119
123
  function nextWithLocalsStub(next, context) {
120
124
  Object.defineProperty(context.locals, "_actionsInternal", {
121
125
  writable: false,
122
126
  value: {
123
- getActionResult: () => void 0
127
+ getActionResult: () => void 0,
128
+ callAction: createCallAction(context)
124
129
  }
125
130
  });
126
- return ApiContextStorage.run(context, () => next());
131
+ return next();
132
+ }
133
+ function createCallAction(context) {
134
+ return (baseAction, input) => {
135
+ const action = baseAction.bind(context);
136
+ return action(input);
137
+ };
127
138
  }
128
139
  export {
129
140
  onRequest
@@ -1,9 +1,8 @@
1
- import { ApiContextStorage } from "./store.js";
2
1
  import { formContentTypes, getAction, hasContentType } from "./utils.js";
3
2
  const POST = async (context) => {
4
3
  const { request, url } = context;
5
- const action = await getAction(url.pathname);
6
- if (!action) {
4
+ const baseAction = await getAction(url.pathname);
5
+ if (!baseAction) {
7
6
  return new Response(null, { status: 404 });
8
7
  }
9
8
  const contentType = request.headers.get("Content-Type");
@@ -18,7 +17,8 @@ const POST = async (context) => {
18
17
  } else {
19
18
  return new Response(null, { status: 415 });
20
19
  }
21
- const result = await ApiContextStorage.run(context, () => action(args));
20
+ const action = baseAction.bind(context);
21
+ const result = await action(args);
22
22
  if (result.error) {
23
23
  return new Response(
24
24
  JSON.stringify({
@@ -1,7 +1,9 @@
1
1
  import type { ZodType } from 'zod';
2
+ import type { APIContext } from '../../@types/astro.js';
2
3
  import type { ActionAccept, ActionClient } from './virtual/server.js';
3
4
  export declare const formContentTypes: string[];
4
5
  export declare function hasContentType(contentType: string, expected: string[]): boolean;
6
+ export type ActionAPIContext = Omit<APIContext, 'getActionResult' | 'callAction' | 'props'>;
5
7
  export type MaybePromise<T> = T | Promise<T>;
6
8
  /**
7
9
  * Get server-side action based on the route path.
@@ -1,4 +1,3 @@
1
1
  export * from './shared.js';
2
2
  export declare function defineAction(): void;
3
- export declare function getApiContext(): void;
4
3
  export declare const z: {};
@@ -2,9 +2,6 @@ export * from "./shared.js";
2
2
  function defineAction() {
3
3
  throw new Error("[astro:action] `defineAction()` unexpectedly used on the client.");
4
4
  }
5
- function getApiContext() {
6
- throw new Error("[astro:action] `getApiContext()` unexpectedly used on the client.");
7
- }
8
5
  const z = new Proxy(
9
6
  {},
10
7
  {
@@ -15,6 +12,5 @@ const z = new Proxy(
15
12
  );
16
13
  export {
17
14
  defineAction,
18
- getApiContext,
19
15
  z
20
16
  };
@@ -1,11 +1,8 @@
1
1
  import { z } from 'zod';
2
- import { type ActionAPIContext, getApiContext as _getApiContext } from '../store.js';
3
- import type { ErrorInferenceObject, MaybePromise } from '../utils.js';
2
+ import type { ActionAPIContext, ErrorInferenceObject, MaybePromise } from '../utils.js';
4
3
  import { type SafeResult } from './shared.js';
5
4
  export * from './shared.js';
6
5
  export { z } from 'zod';
7
- /** @deprecated Access context from the second `handler()` parameter. */
8
- export declare const getApiContext: typeof _getApiContext;
9
6
  export type ActionAccept = 'form' | 'json';
10
7
  export type ActionInputSchema<T extends ActionAccept | undefined> = T extends 'form' ? z.AnyZodObject | z.ZodType<FormData> : z.ZodType;
11
8
  export type ActionHandler<TInputSchema, TOutput> = TInputSchema extends z.ZodType ? (input: z.infer<TInputSchema>, context: ActionAPIContext) => MaybePromise<TOutput> : (input: any, context: ActionAPIContext) => MaybePromise<TOutput>;
@@ -1,53 +1,61 @@
1
1
  import { z } from "zod";
2
- import { getApiContext as _getApiContext } from "../store.js";
2
+ import { ActionCalledFromServerError } from "../../../core/errors/errors-data.js";
3
+ import { AstroError } from "../../../core/errors/errors.js";
3
4
  import { ActionError, ActionInputError, callSafely } from "./shared.js";
4
5
  export * from "./shared.js";
5
6
  import { z as z2 } from "zod";
6
- const getApiContext = _getApiContext;
7
7
  function defineAction({
8
8
  accept,
9
9
  input: inputSchema,
10
10
  handler
11
11
  }) {
12
12
  const serverHandler = accept === "form" ? getFormServerHandler(handler, inputSchema) : getJsonServerHandler(handler, inputSchema);
13
- const safeServerHandler = async (unparsedInput) => {
14
- return callSafely(() => serverHandler(unparsedInput));
15
- };
13
+ async function safeServerHandler(unparsedInput) {
14
+ if (typeof this === "function") {
15
+ throw new AstroError(ActionCalledFromServerError);
16
+ }
17
+ return callSafely(() => serverHandler(unparsedInput, this));
18
+ }
16
19
  Object.assign(safeServerHandler, {
17
- orThrow: serverHandler
20
+ orThrow(unparsedInput) {
21
+ if (typeof this === "function") {
22
+ throw new AstroError(ActionCalledFromServerError);
23
+ }
24
+ return serverHandler(unparsedInput, this);
25
+ }
18
26
  });
19
27
  return safeServerHandler;
20
28
  }
21
29
  function getFormServerHandler(handler, inputSchema) {
22
- return async (unparsedInput) => {
30
+ return async (unparsedInput, context) => {
23
31
  if (!(unparsedInput instanceof FormData)) {
24
32
  throw new ActionError({
25
33
  code: "UNSUPPORTED_MEDIA_TYPE",
26
34
  message: "This action only accepts FormData."
27
35
  });
28
36
  }
29
- if (!(inputSchema instanceof z.ZodObject)) return await handler(unparsedInput, getApiContext());
37
+ if (!(inputSchema instanceof z.ZodObject)) return await handler(unparsedInput, context);
30
38
  const parsed = await inputSchema.safeParseAsync(formDataToObject(unparsedInput, inputSchema));
31
39
  if (!parsed.success) {
32
40
  throw new ActionInputError(parsed.error.issues);
33
41
  }
34
- return await handler(parsed.data, getApiContext());
42
+ return await handler(parsed.data, context);
35
43
  };
36
44
  }
37
45
  function getJsonServerHandler(handler, inputSchema) {
38
- return async (unparsedInput) => {
46
+ return async (unparsedInput, context) => {
39
47
  if (unparsedInput instanceof FormData) {
40
48
  throw new ActionError({
41
49
  code: "UNSUPPORTED_MEDIA_TYPE",
42
50
  message: "This action only accepts JSON."
43
51
  });
44
52
  }
45
- if (!inputSchema) return await handler(unparsedInput, getApiContext());
53
+ if (!inputSchema) return await handler(unparsedInput, context);
46
54
  const parsed = await inputSchema.safeParseAsync(unparsedInput);
47
55
  if (!parsed.success) {
48
56
  throw new ActionInputError(parsed.error.issues);
49
57
  }
50
- return await handler(parsed.data, getApiContext());
58
+ return await handler(parsed.data, context);
51
59
  };
52
60
  }
53
61
  function formDataToObject(formData, schema) {
@@ -87,6 +95,5 @@ function handleFormDataGet(key, formData, validator, baseValidator) {
87
95
  export {
88
96
  defineAction,
89
97
  formDataToObject,
90
- getApiContext,
91
98
  z2 as z
92
99
  };
@@ -2,3 +2,4 @@ import type { APIContext } from '../@types/astro.js';
2
2
  import type { Locals } from './runtime/middleware.js';
3
3
  export declare function hasActionsInternal(locals: APIContext['locals']): locals is Locals;
4
4
  export declare function createGetActionResult(locals: APIContext['locals']): APIContext['getActionResult'];
5
+ export declare function createCallAction(locals: APIContext['locals']): APIContext['callAction'];
@@ -13,7 +13,19 @@ function createGetActionResult(locals) {
13
13
  return locals._actionsInternal.getActionResult(actionFn);
14
14
  };
15
15
  }
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);
25
+ };
26
+ }
16
27
  export {
28
+ createCallAction,
17
29
  createGetActionResult,
18
30
  hasActionsInternal
19
31
  };
@@ -2,12 +2,5 @@ import type yargs from 'yargs-parser';
2
2
  interface AddOptions {
3
3
  flags: yargs.Arguments;
4
4
  }
5
- interface IntegrationInfo {
6
- id: string;
7
- packageName: string;
8
- dependencies: [name: string, version: string][];
9
- type: 'integration' | 'adapter';
10
- }
11
5
  export declare function add(names: string[], { flags }: AddOptions): Promise<void>;
12
- export declare function validateIntegrations(integrations: string[]): Promise<IntegrationInfo[]>;
13
6
  export {};
@@ -898,6 +898,5 @@ async function setupIntegrationConfig(opts) {
898
898
  }
899
899
  }
900
900
  export {
901
- add,
902
- validateIntegrations
901
+ add
903
902
  };
@@ -13,5 +13,4 @@ export declare function getPackage<T>(packageName: string, logger: Logger, optio
13
13
  export declare function getExecCommand(packageManager?: string): Promise<string>;
14
14
  export declare function fetchPackageJson(scope: string | undefined, name: string, tag: string): Promise<Record<string, any> | Error>;
15
15
  export declare function fetchPackageVersions(packageName: string): Promise<string[] | Error>;
16
- export declare function getRegistry(): Promise<string>;
17
16
  export {};
@@ -165,6 +165,5 @@ export {
165
165
  fetchPackageJson,
166
166
  fetchPackageVersions,
167
167
  getExecCommand,
168
- getPackage,
169
- getRegistry
168
+ getPackage
170
169
  };
@@ -2,9 +2,9 @@ import type { PluginContext } from 'rollup';
2
2
  import { z } from 'zod';
3
3
  export declare function createImage(pluginContext: PluginContext, shouldEmitFile: boolean, entryFilePath: string): () => z.ZodEffects<z.ZodString, z.ZodNever | {
4
4
  ASTRO_ASSET: string;
5
- format: import("../assets/types.js").ImageInputFormat;
6
5
  width: number;
7
6
  height: number;
7
+ format: import("../assets/types.js").ImageInputFormat;
8
8
  src: string;
9
9
  fsPath: string;
10
10
  orientation?: number | undefined;
@@ -19,7 +19,7 @@ export type ContentLookupMap = {
19
19
  };
20
20
  };
21
21
  };
22
- export declare const collectionConfigParser: z.ZodUnion<[z.ZodObject<{
22
+ declare const collectionConfigParser: z.ZodUnion<[z.ZodObject<{
23
23
  type: z.ZodDefault<z.ZodOptional<z.ZodLiteral<"content">>>;
24
24
  schema: z.ZodOptional<z.ZodAny>;
25
25
  }, "strip", z.ZodTypeAny, {
@@ -38,7 +38,7 @@ export declare const collectionConfigParser: z.ZodUnion<[z.ZodObject<{
38
38
  type: "data";
39
39
  schema?: any;
40
40
  }>]>;
41
- export declare const contentConfigParser: z.ZodObject<{
41
+ declare const contentConfigParser: z.ZodObject<{
42
42
  collections: z.ZodRecord<z.ZodString, z.ZodUnion<[z.ZodObject<{
43
43
  type: z.ZodDefault<z.ZodOptional<z.ZodLiteral<"content">>>;
44
44
  schema: z.ZodOptional<z.ZodAny>;
@@ -81,9 +81,6 @@ type EntryInternal = {
81
81
  rawData: string | undefined;
82
82
  filePath: string;
83
83
  };
84
- export declare const msg: {
85
- collectionConfigMissing: (collection: string) => string;
86
- };
87
84
  export declare function parseEntrySlug({ id, collection, generatedSlug, frontmatterSlug, }: {
88
85
  id: string;
89
86
  collection: string;
@@ -124,7 +121,6 @@ export declare function getContentEntryIdAndSlug({ entry, contentDir, collection
124
121
  slug: string;
125
122
  };
126
123
  export declare function getEntryType(entryPath: string, paths: Pick<ContentPaths, 'config' | 'contentDir'>, contentFileExts: string[], dataFileExts: string[]): 'content' | 'data' | 'config' | 'ignored';
127
- export declare function hasUnderscoreBelowContentDirectoryPath(fileUrl: URL, contentDir: ContentPaths['contentDir']): boolean;
128
124
  export declare function safeParseFrontmatter(source: string, id?: string): matter.GrayMatterFile<string>;
129
125
  /**
130
126
  * The content config is loaded separately from other `src/` files.
@@ -134,11 +130,6 @@ export declare function safeParseFrontmatter(source: string, id?: string): matte
134
130
  export declare const globalContentConfigObserver: ContentObservable;
135
131
  export declare function hasAnyContentFlag(viteId: string): boolean;
136
132
  export declare function hasContentFlag(viteId: string, flag: (typeof CONTENT_FLAGS)[number]): boolean;
137
- export declare function loadContentConfig({ fs, settings, viteServer, }: {
138
- fs: typeof fsMod;
139
- settings: AstroSettings;
140
- viteServer: ViteDevServer;
141
- }): Promise<ContentConfig | undefined>;
142
133
  export declare function reloadContentConfigObserver({ observer, ...loadContentConfigOpts }: {
143
134
  fs: typeof fsMod;
144
135
  settings: AstroSettings;
@@ -22,9 +22,6 @@ const collectionConfigParser = z.union([
22
22
  const contentConfigParser = z.object({
23
23
  collections: z.record(collectionConfigParser)
24
24
  });
25
- const msg = {
26
- collectionConfigMissing: (collection) => `${collection} does not have a config. We suggest adding one for type safety!`
27
- };
28
25
  function parseEntrySlug({
29
26
  id,
30
27
  collection,
@@ -387,8 +384,6 @@ function hasAssetPropagationFlag(id) {
387
384
  }
388
385
  }
389
386
  export {
390
- collectionConfigParser,
391
- contentConfigParser,
392
387
  contentObservable,
393
388
  getContentEntryExts,
394
389
  getContentEntryIdAndSlug,
@@ -406,9 +401,6 @@ export {
406
401
  hasAnyContentFlag,
407
402
  hasAssetPropagationFlag,
408
403
  hasContentFlag,
409
- hasUnderscoreBelowContentDirectoryPath,
410
- loadContentConfig,
411
- msg,
412
404
  parseEntrySlug,
413
405
  reloadContentConfigObserver,
414
406
  reverseSymlink,
@@ -1,7 +1,3 @@
1
- import type { OutputAsset, OutputChunk } from 'rollup';
2
- import type { AstroSettings } from '../../@types/astro.js';
3
1
  import { type BuildInternals } from '../../core/build/internal.js';
4
2
  import type { StaticBuildOptions } from './types.js';
5
- export declare function rootRelativeFacadeId(facadeId: string, settings: AstroSettings): string;
6
- export declare function chunkIsPage(settings: AstroSettings, output: OutputAsset | OutputChunk, internals: BuildInternals): boolean;
7
3
  export declare function generatePages(options: StaticBuildOptions, internals: BuildInternals): Promise<void>;
@@ -1,6 +1,5 @@
1
1
  import fs from "node:fs";
2
2
  import os from "node:os";
3
- import { fileURLToPath } from "node:url";
4
3
  import { bgGreen, black, blue, bold, dim, green, magenta, red } from "kleur/colors";
5
4
  import PQueue from "p-queue";
6
5
  import {
@@ -12,7 +11,6 @@ import { hasPrerenderedPages } from "../../core/build/internal.js";
12
11
  import {
13
12
  isRelativePath,
14
13
  joinPaths,
15
- prependForwardSlash,
16
14
  removeLeadingForwardSlash,
17
15
  removeTrailingForwardSlash
18
16
  } from "../../core/path.js";
@@ -35,22 +33,6 @@ import { getTimeStat, shouldAppendForwardSlash } from "./util.js";
35
33
  function createEntryURL(filePath, outFolder) {
36
34
  return new URL("./" + filePath + `?time=${Date.now()}`, outFolder);
37
35
  }
38
- function rootRelativeFacadeId(facadeId, settings) {
39
- return facadeId.slice(fileURLToPath(settings.config.root).length);
40
- }
41
- function chunkIsPage(settings, output, internals) {
42
- if (output.type !== "chunk") {
43
- return false;
44
- }
45
- const chunk = output;
46
- if (chunk.facadeModuleId) {
47
- const facadeToEntryId = prependForwardSlash(
48
- rootRelativeFacadeId(chunk.facadeModuleId, settings)
49
- );
50
- return internals.entrySpecifierToBundleMap.has(facadeToEntryId);
51
- }
52
- return false;
53
- }
54
36
  async function generatePages(options, internals) {
55
37
  const generatePagesTimer = performance.now();
56
38
  const ssr = isServerLikeOutput(options.settings.config);
@@ -410,7 +392,5 @@ function createBuildManifest(settings, internals, renderers, middleware) {
410
392
  };
411
393
  }
412
394
  export {
413
- chunkIsPage,
414
- generatePages,
415
- rootRelativeFacadeId
395
+ generatePages
416
396
  };
@@ -108,7 +108,7 @@ class AstroBuilder {
108
108
  }
109
109
  this.logger.info("build", "Collecting build info...");
110
110
  this.timer.loadStart = performance.now();
111
- const { assets, allPages } = await collectPagesData({
111
+ const { assets, allPages } = collectPagesData({
112
112
  settings: this.settings,
113
113
  logger: this.logger,
114
114
  manifest: this.manifest
@@ -1,6 +1,5 @@
1
1
  import type { Rollup } from 'vite';
2
2
  import type { RouteData, SSRResult } from '../../@types/astro.js';
3
- import type { PageOptions } from '../../vite-plugin-astro/types.js';
4
3
  import type { PageBuildData, StylesheetAsset, ViteID } from './types.js';
5
4
  export interface BuildInternals {
6
5
  /**
@@ -20,18 +19,10 @@ export interface BuildInternals {
20
19
  */
21
20
  inlinedScripts: Map<string, string>;
22
21
  entrySpecifierToBundleMap: Map<string, string>;
23
- /**
24
- * A map to get a specific page's bundled output file.
25
- */
26
- pageToBundleMap: Map<string, string>;
27
22
  /**
28
23
  * A map for page-specific information.
29
24
  */
30
25
  pagesByKeys: Map<string, PageBuildData>;
31
- /**
32
- * A map for page-specific output.
33
- */
34
- pageOptionsByPage: Map<string, PageOptions>;
35
26
  /**
36
27
  * A map for page-specific information by Vite ID (a path-like string)
37
28
  */
@@ -86,7 +77,6 @@ export interface BuildInternals {
86
77
  manifestEntryChunk?: Rollup.OutputChunk;
87
78
  manifestFileName?: string;
88
79
  entryPoints: Map<RouteData, URL>;
89
- ssrSplitEntryChunks: Map<string, Rollup.OutputChunk>;
90
80
  componentMetadata: SSRResult['componentMetadata'];
91
81
  middlewareEntryPoint?: URL;
92
82
  /**
@@ -108,7 +98,6 @@ export declare function trackClientOnlyPageDatas(internals: BuildInternals, page
108
98
  * Tracks scripts to the pages they are associated with. (experimental.directRenderScript)
109
99
  */
110
100
  export declare function trackScriptPageDatas(internals: BuildInternals, pageData: PageBuildData, scriptIds: string[]): void;
111
- export declare function getPageDatasByChunk(internals: BuildInternals, chunk: Rollup.RenderedChunk): Generator<PageBuildData, void, unknown>;
112
101
  export declare function getPageDatasByClientOnlyID(internals: BuildInternals, viteid: ViteID): Generator<PageBuildData, void, unknown>;
113
102
  /**
114
103
  * From its route and component, get the page data from the build internals.
@@ -117,12 +106,6 @@ export declare function getPageDatasByClientOnlyID(internals: BuildInternals, vi
117
106
  * @param component The component of the page, used to identify the page
118
107
  */
119
108
  export declare function getPageData(internals: BuildInternals, route: string, component: string): PageBuildData | undefined;
120
- /**
121
- * Get all pages datas from the build internals, using a specific component.
122
- * @param internals Build Internals with all the pages
123
- * @param component path to the component, used to identify related pages
124
- */
125
- export declare function getPagesDatasByComponent(internals: BuildInternals, component: string): PageBuildData[];
126
109
  /**
127
110
  * Map internals.pagesByKeys to a new map with the public key instead of the internal key.
128
111
  * This function is only used to avoid breaking changes in the Integrations API, after we changed the way
@@ -134,7 +117,6 @@ export declare function getPagesDatasByComponent(internals: BuildInternals, comp
134
117
  */
135
118
  export declare function getPageDatasWithPublicKey(pagesByKeys: Map<string, PageBuildData>): Map<string, PageBuildData>;
136
119
  export declare function getPageDataByViteID(internals: BuildInternals, viteid: ViteID): PageBuildData | undefined;
137
- export declare function hasPageDataByViteID(internals: BuildInternals, viteid: ViteID): boolean;
138
120
  export declare function hasPrerenderedPages(internals: BuildInternals): boolean;
139
121
  interface OrderInfo {
140
122
  depth: number;