astro 5.8.2 → 5.9.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 (68) hide show
  1. package/dist/actions/runtime/utils.d.ts +1 -1
  2. package/dist/assets/fonts/config.d.ts +21 -21
  3. package/dist/container/index.js +2 -1
  4. package/dist/content/content-layer.js +14 -3
  5. package/dist/content/loaders/types.d.ts +3 -0
  6. package/dist/content/utils.d.ts +26 -10
  7. package/dist/content/utils.js +1 -0
  8. package/dist/core/app/types.d.ts +12 -1
  9. package/dist/core/base-pipeline.js +3 -3
  10. package/dist/core/build/generate.d.ts +1 -1
  11. package/dist/core/build/generate.js +38 -4
  12. package/dist/core/build/internal.d.ts +1 -0
  13. package/dist/core/build/internal.js +2 -1
  14. package/dist/core/build/plugins/index.js +1 -1
  15. package/dist/core/build/plugins/plugin-internals.d.ts +2 -1
  16. package/dist/core/build/plugins/plugin-internals.js +7 -4
  17. package/dist/core/build/plugins/plugin-manifest.js +37 -3
  18. package/dist/core/config/schemas/base.d.ts +435 -331
  19. package/dist/core/config/schemas/base.js +20 -2
  20. package/dist/core/config/schemas/index.d.ts +1 -1
  21. package/dist/core/config/schemas/index.js +4 -1
  22. package/dist/core/config/schemas/relative.d.ts +681 -552
  23. package/dist/core/constants.js +1 -1
  24. package/dist/core/csp/common.d.ts +16 -0
  25. package/dist/core/csp/common.js +116 -0
  26. package/dist/core/csp/config.d.ts +16 -0
  27. package/dist/core/csp/config.js +52 -0
  28. package/dist/core/dev/dev.js +1 -1
  29. package/dist/core/encryption.d.ts +8 -0
  30. package/dist/core/encryption.js +7 -0
  31. package/dist/core/errors/errors-data.d.ts +12 -0
  32. package/dist/core/errors/errors-data.js +6 -0
  33. package/dist/core/messages.js +2 -2
  34. package/dist/core/middleware/index.js +10 -0
  35. package/dist/core/render-context.d.ts +1 -0
  36. package/dist/core/render-context.js +77 -5
  37. package/dist/env/schema.d.ts +34 -34
  38. package/dist/integrations/features-validation.js +36 -30
  39. package/dist/integrations/hooks.d.ts +3 -2
  40. package/dist/runtime/server/astro-island-styles.d.ts +1 -0
  41. package/dist/runtime/server/astro-island-styles.js +4 -0
  42. package/dist/runtime/server/index.d.ts +1 -0
  43. package/dist/runtime/server/render/astro/factory.d.ts +3 -2
  44. package/dist/runtime/server/render/astro/factory.js +6 -1
  45. package/dist/runtime/server/render/astro/head-and-content.d.ts +7 -0
  46. package/dist/runtime/server/render/astro/head-and-content.js +6 -0
  47. package/dist/runtime/server/render/astro/render.d.ts +1 -0
  48. package/dist/runtime/server/render/astro/render.js +2 -1
  49. package/dist/runtime/server/render/common.d.ts +1 -1
  50. package/dist/runtime/server/render/common.js +5 -3
  51. package/dist/runtime/server/render/component.js +8 -2
  52. package/dist/runtime/server/render/csp.d.ts +2 -0
  53. package/dist/runtime/server/render/csp.js +35 -0
  54. package/dist/runtime/server/render/head.js +14 -0
  55. package/dist/runtime/server/render/page.d.ts +1 -1
  56. package/dist/runtime/server/render/page.js +1 -1
  57. package/dist/runtime/server/render/server-islands.d.ts +14 -3
  58. package/dist/runtime/server/render/server-islands.js +100 -69
  59. package/dist/runtime/server/scripts.d.ts +1 -1
  60. package/dist/runtime/server/scripts.js +2 -5
  61. package/dist/runtime/server/transition.d.ts +1 -1
  62. package/dist/runtime/server/transition.js +7 -2
  63. package/dist/types/public/config.d.ts +240 -0
  64. package/dist/types/public/context.d.ts +51 -0
  65. package/dist/types/public/integrations.d.ts +9 -0
  66. package/dist/types/public/internal.d.ts +24 -2
  67. package/dist/vite-plugin-astro-server/plugin.js +26 -4
  68. package/package.json +2 -2
@@ -10,7 +10,7 @@ export type Locals = {
10
10
  export declare const ACTION_API_CONTEXT_SYMBOL: unique symbol;
11
11
  export declare const formContentTypes: string[];
12
12
  export declare function hasContentType(contentType: string, expected: string[]): boolean;
13
- export type ActionAPIContext = Pick<APIContext, 'rewrite' | 'request' | 'url' | 'isPrerendered' | 'locals' | 'clientAddress' | 'cookies' | 'currentLocale' | 'generator' | 'routePattern' | 'site' | 'params' | 'preferredLocale' | 'preferredLocaleList' | 'originPathname' | 'session'> & {
13
+ export type ActionAPIContext = Pick<APIContext, 'rewrite' | 'request' | 'url' | 'isPrerendered' | 'locals' | 'clientAddress' | 'cookies' | 'currentLocale' | 'generator' | 'routePattern' | 'site' | 'params' | 'preferredLocale' | 'preferredLocaleList' | 'originPathname' | 'session' | 'insertDirective' | 'insertScriptResource' | 'insertStyleResource' | 'insertScriptHash' | 'insertStyleHash'> & {
14
14
  /**
15
15
  * @deprecated
16
16
  * The use of `rewrite` in Actions is deprecated
@@ -116,9 +116,9 @@ export declare const localFontFamilySchema: z.ZodObject<z.objectUtil.extendShape
116
116
  url: string | URL;
117
117
  tech?: string | undefined;
118
118
  })[]];
119
- style?: "normal" | "italic" | "oblique" | undefined;
120
119
  weight?: string | number | undefined;
121
- display?: "fallback" | "auto" | "optional" | "block" | "swap" | undefined;
120
+ style?: "normal" | "italic" | "oblique" | undefined;
121
+ display?: "auto" | "block" | "swap" | "fallback" | "optional" | undefined;
122
122
  stretch?: string | undefined;
123
123
  featureSettings?: string | undefined;
124
124
  variationSettings?: string | undefined;
@@ -131,9 +131,9 @@ export declare const localFontFamilySchema: z.ZodObject<z.objectUtil.extendShape
131
131
  url: string | URL;
132
132
  tech?: string | undefined;
133
133
  })[]];
134
- style?: "normal" | "italic" | "oblique" | undefined;
135
134
  weight?: string | number | undefined;
136
- display?: "fallback" | "auto" | "optional" | "block" | "swap" | undefined;
135
+ style?: "normal" | "italic" | "oblique" | undefined;
136
+ display?: "auto" | "block" | "swap" | "fallback" | "optional" | undefined;
137
137
  stretch?: string | undefined;
138
138
  featureSettings?: string | undefined;
139
139
  variationSettings?: string | undefined;
@@ -151,9 +151,9 @@ export declare const localFontFamilySchema: z.ZodObject<z.objectUtil.extendShape
151
151
  url: string | URL;
152
152
  tech?: string | undefined;
153
153
  })[]];
154
- style?: "normal" | "italic" | "oblique" | undefined;
155
154
  weight?: string | number | undefined;
156
- display?: "fallback" | "auto" | "optional" | "block" | "swap" | undefined;
155
+ style?: "normal" | "italic" | "oblique" | undefined;
156
+ display?: "auto" | "block" | "swap" | "fallback" | "optional" | undefined;
157
157
  stretch?: string | undefined;
158
158
  featureSettings?: string | undefined;
159
159
  variationSettings?: string | undefined;
@@ -166,9 +166,9 @@ export declare const localFontFamilySchema: z.ZodObject<z.objectUtil.extendShape
166
166
  url: string | URL;
167
167
  tech?: string | undefined;
168
168
  })[]];
169
- style?: "normal" | "italic" | "oblique" | undefined;
170
169
  weight?: string | number | undefined;
171
- display?: "fallback" | "auto" | "optional" | "block" | "swap" | undefined;
170
+ style?: "normal" | "italic" | "oblique" | undefined;
171
+ display?: "auto" | "block" | "swap" | "fallback" | "optional" | undefined;
172
172
  stretch?: string | undefined;
173
173
  featureSettings?: string | undefined;
174
174
  variationSettings?: string | undefined;
@@ -188,9 +188,9 @@ export declare const localFontFamilySchema: z.ZodObject<z.objectUtil.extendShape
188
188
  url: string | URL;
189
189
  tech?: string | undefined;
190
190
  })[]];
191
- style?: "normal" | "italic" | "oblique" | undefined;
192
191
  weight?: string | number | undefined;
193
- display?: "fallback" | "auto" | "optional" | "block" | "swap" | undefined;
192
+ style?: "normal" | "italic" | "oblique" | undefined;
193
+ display?: "auto" | "block" | "swap" | "fallback" | "optional" | undefined;
194
194
  stretch?: string | undefined;
195
195
  featureSettings?: string | undefined;
196
196
  variationSettings?: string | undefined;
@@ -203,9 +203,9 @@ export declare const localFontFamilySchema: z.ZodObject<z.objectUtil.extendShape
203
203
  url: string | URL;
204
204
  tech?: string | undefined;
205
205
  })[]];
206
- style?: "normal" | "italic" | "oblique" | undefined;
207
206
  weight?: string | number | undefined;
208
- display?: "fallback" | "auto" | "optional" | "block" | "swap" | undefined;
207
+ style?: "normal" | "italic" | "oblique" | undefined;
208
+ display?: "auto" | "block" | "swap" | "fallback" | "optional" | undefined;
209
209
  stretch?: string | undefined;
210
210
  featureSettings?: string | undefined;
211
211
  variationSettings?: string | undefined;
@@ -254,7 +254,7 @@ export declare const remoteFontFamilySchema: z.ZodObject<z.objectUtil.extendShap
254
254
  * Font [variation settings](https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-variation-settings).
255
255
  */
256
256
  variationSettings: z.ZodOptional<z.ZodString>;
257
- }, "style" | "weight">>, {
257
+ }, "weight" | "style">>, {
258
258
  /**
259
259
  * @default `["sans-serif"]`
260
260
  *
@@ -333,16 +333,16 @@ export declare const remoteFontFamilySchema: z.ZodObject<z.objectUtil.extendShap
333
333
  entrypoint: string | URL;
334
334
  config?: Record<string, any> | undefined;
335
335
  };
336
+ weights?: [string | number, ...(string | number)[]] | undefined;
337
+ styles?: ["normal" | "italic" | "oblique", ...("normal" | "italic" | "oblique")[]] | undefined;
338
+ subsets?: [string, ...string[]] | undefined;
336
339
  fallbacks?: string[] | undefined;
337
340
  optimizedFallbacks?: boolean | undefined;
338
- display?: "fallback" | "auto" | "optional" | "block" | "swap" | undefined;
341
+ display?: "auto" | "block" | "swap" | "fallback" | "optional" | undefined;
339
342
  stretch?: string | undefined;
340
343
  featureSettings?: string | undefined;
341
344
  variationSettings?: string | undefined;
342
345
  unicodeRange?: [string, ...string[]] | undefined;
343
- weights?: [string | number, ...(string | number)[]] | undefined;
344
- styles?: ["normal" | "italic" | "oblique", ...("normal" | "italic" | "oblique")[]] | undefined;
345
- subsets?: [string, ...string[]] | undefined;
346
346
  }, {
347
347
  name: string;
348
348
  cssVariable: string;
@@ -350,14 +350,14 @@ export declare const remoteFontFamilySchema: z.ZodObject<z.objectUtil.extendShap
350
350
  entrypoint: string | URL;
351
351
  config?: Record<string, any> | undefined;
352
352
  };
353
+ weights?: [string | number, ...(string | number)[]] | undefined;
354
+ styles?: ["normal" | "italic" | "oblique", ...("normal" | "italic" | "oblique")[]] | undefined;
355
+ subsets?: [string, ...string[]] | undefined;
353
356
  fallbacks?: string[] | undefined;
354
357
  optimizedFallbacks?: boolean | undefined;
355
- display?: "fallback" | "auto" | "optional" | "block" | "swap" | undefined;
358
+ display?: "auto" | "block" | "swap" | "fallback" | "optional" | undefined;
356
359
  stretch?: string | undefined;
357
360
  featureSettings?: string | undefined;
358
361
  variationSettings?: string | undefined;
359
362
  unicodeRange?: [string, ...string[]] | undefined;
360
- weights?: [string | number, ...(string | number)[]] | undefined;
361
- styles?: ["normal" | "italic" | "oblique", ...("normal" | "italic" | "oblique")[]] | undefined;
362
- subsets?: [string, ...string[]] | undefined;
363
363
  }>;
@@ -45,7 +45,8 @@ function createManifest(manifest, renderers, middleware) {
45
45
  i18n: manifest?.i18n,
46
46
  checkOrigin: false,
47
47
  middleware: manifest?.middleware ?? middlewareInstance,
48
- key: createKey()
48
+ key: createKey(),
49
+ csp: manifest?.csp
49
50
  };
50
51
  }
51
52
  class experimental_AstroContainer {
@@ -1,4 +1,5 @@
1
1
  import { promises as fs, existsSync } from "node:fs";
2
+ import { createMarkdownProcessor } from "@astrojs/markdown-remark";
2
3
  import PQueue from "p-queue";
3
4
  import xxhash from "xxhash-wasm";
4
5
  import { AstroError, AstroErrorData } from "../core/errors/index.js";
@@ -24,6 +25,7 @@ class ContentLayer {
24
25
  #watcher;
25
26
  #lastConfigDigest;
26
27
  #unsubscribe;
28
+ #markdownProcessor;
27
29
  #generateDigest;
28
30
  #queue;
29
31
  constructor({ settings, logger, store, watcher }) {
@@ -85,6 +87,7 @@ class ContentLayer {
85
87
  logger: this.#logger.forkIntegrationLogger(loaderName),
86
88
  config: this.#settings.config,
87
89
  parseData,
90
+ renderMarkdown: this.#processMarkdown.bind(this),
88
91
  generateDigest: await this.#getGenerateDigest(),
89
92
  watcher: this.#watcher,
90
93
  refreshContextData,
@@ -94,6 +97,14 @@ class ContentLayer {
94
97
  ])
95
98
  };
96
99
  }
100
+ async #processMarkdown(content) {
101
+ this.#markdownProcessor ??= await createMarkdownProcessor(this.#settings.config.markdown);
102
+ const { code, metadata } = await this.#markdownProcessor.render(content);
103
+ return {
104
+ html: code,
105
+ metadata
106
+ };
107
+ }
97
108
  /**
98
109
  * Enqueues a sync job that runs the `load()` method of each collection's loader, which will load the data and save it in the data store.
99
110
  * The loader itself is responsible for deciding whether this will clear and reload the full collection, or
@@ -153,7 +164,7 @@ ${contentConfig.error.message}`);
153
164
  logger.info("Content config changed");
154
165
  shouldClear = true;
155
166
  }
156
- if (previousAstroVersion && previousAstroVersion !== "5.8.2") {
167
+ if (previousAstroVersion && previousAstroVersion !== "5.9.0") {
157
168
  logger.info("Astro version changed");
158
169
  shouldClear = true;
159
170
  }
@@ -161,8 +172,8 @@ ${contentConfig.error.message}`);
161
172
  logger.info("Clearing content store");
162
173
  this.#store.clearAll();
163
174
  }
164
- if ("5.8.2") {
165
- await this.#store.metaStore().set("astro-version", "5.8.2");
175
+ if ("5.9.0") {
176
+ await this.#store.metaStore().set("astro-version", "5.9.0");
166
177
  }
167
178
  if (currentConfigDigest) {
168
179
  await this.#store.metaStore().set("content-config-digest", currentConfigDigest);
@@ -2,6 +2,7 @@ import type { FSWatcher } from 'vite';
2
2
  import type { ZodSchema } from 'zod';
3
3
  import type { AstroIntegrationLogger } from '../../core/logger/core.js';
4
4
  import type { AstroConfig } from '../../types/public/config.js';
5
+ import type { RenderedContent } from '../data-store.js';
5
6
  import type { DataStore, MetaStore } from '../mutable-data-store.js';
6
7
  export type { DataStore, MetaStore };
7
8
  export interface ParseDataOptions<TData extends Record<string, unknown>> {
@@ -24,6 +25,8 @@ export interface LoaderContext {
24
25
  config: AstroConfig;
25
26
  /** Validates and parses the data according to the collection schema */
26
27
  parseData<TData extends Record<string, unknown>>(props: ParseDataOptions<TData>): Promise<TData>;
28
+ /** Renders markdown content to HTML and metadata */
29
+ renderMarkdown(content: string): Promise<RenderedContent>;
27
30
  /** Generates a non-cryptographic content digest. This can be used to check if the data has changed */
28
31
  generateDigest(data: Record<string, unknown> | string): string;
29
32
  /** When running in dev, this is a filesystem watcher that can be used to trigger updates */
@@ -64,6 +64,7 @@ declare const collectionConfigParser: z.ZodUnion<[z.ZodObject<{
64
64
  config: z.ZodAny;
65
65
  entryTypes: z.ZodAny;
66
66
  parseData: z.ZodAny;
67
+ renderMarkdown: z.ZodAny;
67
68
  generateDigest: z.ZodFunction<z.ZodTuple<[z.ZodAny], null>, z.ZodUnknown>;
68
69
  watcher: z.ZodOptional<z.ZodAny>;
69
70
  refreshContextData: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
@@ -77,6 +78,7 @@ declare const collectionConfigParser: z.ZodUnion<[z.ZodObject<{
77
78
  parseData?: any;
78
79
  store?: any;
79
80
  entryTypes?: any;
81
+ renderMarkdown?: any;
80
82
  refreshContextData?: Record<string, unknown> | undefined;
81
83
  }, {
82
84
  collection: string;
@@ -88,11 +90,13 @@ declare const collectionConfigParser: z.ZodUnion<[z.ZodObject<{
88
90
  parseData?: any;
89
91
  store?: any;
90
92
  entryTypes?: any;
93
+ renderMarkdown?: any;
91
94
  refreshContextData?: Record<string, unknown> | undefined;
92
95
  }>], null>, z.ZodUnknown>;
93
96
  schema: z.ZodOptional<z.ZodAny>;
94
97
  render: z.ZodOptional<z.ZodFunction<z.ZodTuple<[z.ZodAny], null>, z.ZodUnknown>>;
95
98
  }, "strip", z.ZodTypeAny, {
99
+ name: string;
96
100
  load: (args_0: {
97
101
  collection: string;
98
102
  generateDigest: (args_0: any) => unknown;
@@ -103,12 +107,13 @@ declare const collectionConfigParser: z.ZodUnion<[z.ZodObject<{
103
107
  parseData?: any;
104
108
  store?: any;
105
109
  entryTypes?: any;
110
+ renderMarkdown?: any;
106
111
  refreshContextData?: Record<string, unknown> | undefined;
107
112
  }) => unknown;
108
- name: string;
109
113
  schema?: any;
110
114
  render?: ((args_0: any) => unknown) | undefined;
111
115
  }, {
116
+ name: string;
112
117
  load: (args_0: {
113
118
  collection: string;
114
119
  generateDigest: (args_0: any) => unknown;
@@ -119,9 +124,9 @@ declare const collectionConfigParser: z.ZodUnion<[z.ZodObject<{
119
124
  parseData?: any;
120
125
  store?: any;
121
126
  entryTypes?: any;
127
+ renderMarkdown?: any;
122
128
  refreshContextData?: Record<string, unknown> | undefined;
123
129
  }) => unknown;
124
- name: string;
125
130
  schema?: any;
126
131
  render?: ((args_0: any) => unknown) | undefined;
127
132
  }>]>;
@@ -130,6 +135,7 @@ declare const collectionConfigParser: z.ZodUnion<[z.ZodObject<{
130
135
  }, "strip", z.ZodTypeAny, {
131
136
  type: "content_layer";
132
137
  loader: ((...args: unknown[]) => unknown) | {
138
+ name: string;
133
139
  load: (args_0: {
134
140
  collection: string;
135
141
  generateDigest: (args_0: any) => unknown;
@@ -140,9 +146,9 @@ declare const collectionConfigParser: z.ZodUnion<[z.ZodObject<{
140
146
  parseData?: any;
141
147
  store?: any;
142
148
  entryTypes?: any;
149
+ renderMarkdown?: any;
143
150
  refreshContextData?: Record<string, unknown> | undefined;
144
151
  }) => unknown;
145
- name: string;
146
152
  schema?: any;
147
153
  render?: ((args_0: any) => unknown) | undefined;
148
154
  };
@@ -151,6 +157,7 @@ declare const collectionConfigParser: z.ZodUnion<[z.ZodObject<{
151
157
  }, {
152
158
  type: "content_layer";
153
159
  loader: ((...args: unknown[]) => unknown) | {
160
+ name: string;
154
161
  load: (args_0: {
155
162
  collection: string;
156
163
  generateDigest: (args_0: any) => unknown;
@@ -161,9 +168,9 @@ declare const collectionConfigParser: z.ZodUnion<[z.ZodObject<{
161
168
  parseData?: any;
162
169
  store?: any;
163
170
  entryTypes?: any;
171
+ renderMarkdown?: any;
164
172
  refreshContextData?: Record<string, unknown> | undefined;
165
173
  }) => unknown;
166
- name: string;
167
174
  schema?: any;
168
175
  render?: ((args_0: any) => unknown) | undefined;
169
176
  };
@@ -202,6 +209,7 @@ declare const contentConfigParser: z.ZodObject<{
202
209
  config: z.ZodAny;
203
210
  entryTypes: z.ZodAny;
204
211
  parseData: z.ZodAny;
212
+ renderMarkdown: z.ZodAny;
205
213
  generateDigest: z.ZodFunction<z.ZodTuple<[z.ZodAny], null>, z.ZodUnknown>;
206
214
  watcher: z.ZodOptional<z.ZodAny>;
207
215
  refreshContextData: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
@@ -215,6 +223,7 @@ declare const contentConfigParser: z.ZodObject<{
215
223
  parseData?: any;
216
224
  store?: any;
217
225
  entryTypes?: any;
226
+ renderMarkdown?: any;
218
227
  refreshContextData?: Record<string, unknown> | undefined;
219
228
  }, {
220
229
  collection: string;
@@ -226,11 +235,13 @@ declare const contentConfigParser: z.ZodObject<{
226
235
  parseData?: any;
227
236
  store?: any;
228
237
  entryTypes?: any;
238
+ renderMarkdown?: any;
229
239
  refreshContextData?: Record<string, unknown> | undefined;
230
240
  }>], null>, z.ZodUnknown>;
231
241
  schema: z.ZodOptional<z.ZodAny>;
232
242
  render: z.ZodOptional<z.ZodFunction<z.ZodTuple<[z.ZodAny], null>, z.ZodUnknown>>;
233
243
  }, "strip", z.ZodTypeAny, {
244
+ name: string;
234
245
  load: (args_0: {
235
246
  collection: string;
236
247
  generateDigest: (args_0: any) => unknown;
@@ -241,12 +252,13 @@ declare const contentConfigParser: z.ZodObject<{
241
252
  parseData?: any;
242
253
  store?: any;
243
254
  entryTypes?: any;
255
+ renderMarkdown?: any;
244
256
  refreshContextData?: Record<string, unknown> | undefined;
245
257
  }) => unknown;
246
- name: string;
247
258
  schema?: any;
248
259
  render?: ((args_0: any) => unknown) | undefined;
249
260
  }, {
261
+ name: string;
250
262
  load: (args_0: {
251
263
  collection: string;
252
264
  generateDigest: (args_0: any) => unknown;
@@ -257,9 +269,9 @@ declare const contentConfigParser: z.ZodObject<{
257
269
  parseData?: any;
258
270
  store?: any;
259
271
  entryTypes?: any;
272
+ renderMarkdown?: any;
260
273
  refreshContextData?: Record<string, unknown> | undefined;
261
274
  }) => unknown;
262
- name: string;
263
275
  schema?: any;
264
276
  render?: ((args_0: any) => unknown) | undefined;
265
277
  }>]>;
@@ -268,6 +280,7 @@ declare const contentConfigParser: z.ZodObject<{
268
280
  }, "strip", z.ZodTypeAny, {
269
281
  type: "content_layer";
270
282
  loader: ((...args: unknown[]) => unknown) | {
283
+ name: string;
271
284
  load: (args_0: {
272
285
  collection: string;
273
286
  generateDigest: (args_0: any) => unknown;
@@ -278,9 +291,9 @@ declare const contentConfigParser: z.ZodObject<{
278
291
  parseData?: any;
279
292
  store?: any;
280
293
  entryTypes?: any;
294
+ renderMarkdown?: any;
281
295
  refreshContextData?: Record<string, unknown> | undefined;
282
296
  }) => unknown;
283
- name: string;
284
297
  schema?: any;
285
298
  render?: ((args_0: any) => unknown) | undefined;
286
299
  };
@@ -289,6 +302,7 @@ declare const contentConfigParser: z.ZodObject<{
289
302
  }, {
290
303
  type: "content_layer";
291
304
  loader: ((...args: unknown[]) => unknown) | {
305
+ name: string;
292
306
  load: (args_0: {
293
307
  collection: string;
294
308
  generateDigest: (args_0: any) => unknown;
@@ -299,9 +313,9 @@ declare const contentConfigParser: z.ZodObject<{
299
313
  parseData?: any;
300
314
  store?: any;
301
315
  entryTypes?: any;
316
+ renderMarkdown?: any;
302
317
  refreshContextData?: Record<string, unknown> | undefined;
303
318
  }) => unknown;
304
- name: string;
305
319
  schema?: any;
306
320
  render?: ((args_0: any) => unknown) | undefined;
307
321
  };
@@ -318,6 +332,7 @@ declare const contentConfigParser: z.ZodObject<{
318
332
  } | {
319
333
  type: "content_layer";
320
334
  loader: ((...args: unknown[]) => unknown) | {
335
+ name: string;
321
336
  load: (args_0: {
322
337
  collection: string;
323
338
  generateDigest: (args_0: any) => unknown;
@@ -328,9 +343,9 @@ declare const contentConfigParser: z.ZodObject<{
328
343
  parseData?: any;
329
344
  store?: any;
330
345
  entryTypes?: any;
346
+ renderMarkdown?: any;
331
347
  refreshContextData?: Record<string, unknown> | undefined;
332
348
  }) => unknown;
333
- name: string;
334
349
  schema?: any;
335
350
  render?: ((args_0: any) => unknown) | undefined;
336
351
  };
@@ -347,6 +362,7 @@ declare const contentConfigParser: z.ZodObject<{
347
362
  } | {
348
363
  type: "content_layer";
349
364
  loader: ((...args: unknown[]) => unknown) | {
365
+ name: string;
350
366
  load: (args_0: {
351
367
  collection: string;
352
368
  generateDigest: (args_0: any) => unknown;
@@ -357,9 +373,9 @@ declare const contentConfigParser: z.ZodObject<{
357
373
  parseData?: any;
358
374
  store?: any;
359
375
  entryTypes?: any;
376
+ renderMarkdown?: any;
360
377
  refreshContextData?: Record<string, unknown> | undefined;
361
378
  }) => unknown;
362
- name: string;
363
379
  schema?: any;
364
380
  render?: ((args_0: any) => unknown) | undefined;
365
381
  };
@@ -63,6 +63,7 @@ const collectionConfigParser = z.union([
63
63
  config: z.any(),
64
64
  entryTypes: z.any(),
65
65
  parseData: z.any(),
66
+ renderMarkdown: z.any(),
66
67
  generateDigest: z.function(z.tuple([z.any()], z.string())),
67
68
  watcher: z.any().optional(),
68
69
  refreshContextData: z.record(z.unknown()).optional()
@@ -3,9 +3,10 @@ import type { ActionAccept, ActionClient } from '../../actions/runtime/virtual/s
3
3
  import type { RoutingStrategies } from '../../i18n/utils.js';
4
4
  import type { ComponentInstance, SerializedRouteData } from '../../types/astro.js';
5
5
  import type { AstroMiddlewareInstance } from '../../types/public/common.js';
6
- import type { AstroConfig, Locales, ResolvedSessionConfig } from '../../types/public/config.js';
6
+ import type { AstroConfig, CspAlgorithm, Locales, ResolvedSessionConfig } from '../../types/public/config.js';
7
7
  import type { RouteData, SSRComponentMetadata, SSRLoadedRenderer, SSRResult } from '../../types/public/internal.js';
8
8
  import type { SinglePageBuiltModule } from '../build/types.js';
9
+ import type { CspDirective } from '../csp/config.js';
9
10
  type ComponentPath = string;
10
11
  export type StylesheetAsset = {
11
12
  type: 'inline';
@@ -76,6 +77,7 @@ export type SSRManifest = {
76
77
  publicDir: string | URL;
77
78
  buildClientDir: string | URL;
78
79
  buildServerDir: string | URL;
80
+ csp: SSRManifestCSP | undefined;
79
81
  };
80
82
  export type SSRActions = {
81
83
  server: Record<string, ActionClient<unknown, ActionAccept, ZodType>>;
@@ -88,6 +90,15 @@ export type SSRManifestI18n = {
88
90
  defaultLocale: string;
89
91
  domainLookupTable: Record<string, string>;
90
92
  };
93
+ export type SSRManifestCSP = {
94
+ algorithm: CspAlgorithm;
95
+ scriptHashes: string[];
96
+ scriptResources: string[];
97
+ isStrictDynamic: boolean;
98
+ styleHashes: string[];
99
+ styleResources: string[];
100
+ directives: CspDirective[];
101
+ };
91
102
  /** Public type exposed through the `astro:build:ssr` integration hook */
92
103
  export type SerializedSSRManifest = Omit<SSRManifest, 'middleware' | 'routes' | 'assets' | 'componentMetadata' | 'inlinedScripts' | 'clientDirectives' | 'serverIslandNameMap' | 'key'> & {
93
104
  routes: SerializedRouteInfo[];
@@ -46,11 +46,11 @@ class Pipeline {
46
46
  } else if (this.middleware) {
47
47
  const middlewareInstance = await this.middleware();
48
48
  const onRequest = middlewareInstance.onRequest ?? NOOP_MIDDLEWARE_FN;
49
+ const internalMiddlewares = [onRequest];
49
50
  if (this.manifest.checkOrigin) {
50
- this.resolvedMiddleware = sequence(createOriginCheckMiddleware(), onRequest);
51
- } else {
52
- this.resolvedMiddleware = onRequest;
51
+ internalMiddlewares.unshift(createOriginCheckMiddleware());
53
52
  }
53
+ this.resolvedMiddleware = sequence(...internalMiddlewares);
54
54
  return this.resolvedMiddleware;
55
55
  } else {
56
56
  this.resolvedMiddleware = NOOP_MIDDLEWARE_FN;
@@ -1,3 +1,3 @@
1
- import { type BuildInternals } from '../../core/build/internal.js';
1
+ import { type BuildInternals } from './internal.js';
2
2
  import type { StaticBuildOptions } from './types.js';
3
3
  export declare function generatePages(options: StaticBuildOptions, internals: BuildInternals): Promise<void>;
@@ -9,7 +9,6 @@ import {
9
9
  getStaticImageList,
10
10
  prepareAssetsGenerationEnv
11
11
  } from "../../assets/build/generate.js";
12
- import { hasPrerenderedPages } from "../../core/build/internal.js";
13
12
  import {
14
13
  isRelativePath,
15
14
  joinPaths,
@@ -19,6 +18,18 @@ import {
19
18
  import { toFallbackType, toRoutingStrategy } from "../../i18n/utils.js";
20
19
  import { runHookBuildGenerated } from "../../integrations/hooks.js";
21
20
  import { getServerOutputDirectory } from "../../prerender/utils.js";
21
+ import {
22
+ getAlgorithm,
23
+ getDirectives,
24
+ getScriptHashes,
25
+ getScriptResources,
26
+ getStrictDynamic,
27
+ getStyleHashes,
28
+ getStyleResources,
29
+ shouldTrackCspHashes,
30
+ trackScriptHashes,
31
+ trackStyleHashes
32
+ } from "../csp/common.js";
22
33
  import { NoPrerenderedRoutesWithDomains } from "../errors/errors-data.js";
23
34
  import { AstroError, AstroErrorData } from "../errors/index.js";
24
35
  import { NOOP_MIDDLEWARE_FN } from "../middleware/noop-middleware.js";
@@ -31,6 +42,7 @@ import { matchRoute } from "../routing/match.js";
31
42
  import { stringifyParams } from "../routing/params.js";
32
43
  import { getOutputFilename } from "../util.js";
33
44
  import { getOutFile, getOutFolder } from "./common.js";
45
+ import { hasPrerenderedPages } from "./internal.js";
34
46
  import { cssOrder, mergeInlineCss } from "./internal.js";
35
47
  import { BuildPipeline } from "./pipeline.js";
36
48
  import { getTimeStat, shouldAppendForwardSlash } from "./util.js";
@@ -46,7 +58,7 @@ async function generatePages(options, internals) {
46
58
  const renderers = await import(renderersEntryUrl.toString());
47
59
  const middleware = internals.middlewareEntryPoint ? await import(internals.middlewareEntryPoint.toString()).then((mod) => mod.onRequest) : NOOP_MIDDLEWARE_FN;
48
60
  const actions = internals.astroActionsEntryPoint ? await import(internals.astroActionsEntryPoint.toString()).then((mod) => mod) : NOOP_ACTIONS_MOD;
49
- manifest = createBuildManifest(
61
+ manifest = await createBuildManifest(
50
62
  options.settings,
51
63
  internals,
52
64
  renderers.renderers,
@@ -365,8 +377,9 @@ function getPrettyRouteName(route) {
365
377
  }
366
378
  return route.component;
367
379
  }
368
- function createBuildManifest(settings, internals, renderers, middleware, actions, key) {
380
+ async function createBuildManifest(settings, internals, renderers, middleware, actions, key) {
369
381
  let i18nManifest = void 0;
382
+ let csp = void 0;
370
383
  if (settings.config.i18n) {
371
384
  i18nManifest = {
372
385
  fallback: settings.config.i18n.fallback,
@@ -377,6 +390,26 @@ function createBuildManifest(settings, internals, renderers, middleware, actions
377
390
  domainLookupTable: {}
378
391
  };
379
392
  }
393
+ if (shouldTrackCspHashes(settings.config.experimental.csp)) {
394
+ const algorithm = getAlgorithm(settings.config.experimental.csp);
395
+ const scriptHashes = [
396
+ ...getScriptHashes(settings.config.experimental.csp),
397
+ ...await trackScriptHashes(internals, settings, algorithm)
398
+ ];
399
+ const styleHashes = [
400
+ ...getStyleHashes(settings.config.experimental.csp),
401
+ ...await trackStyleHashes(internals, settings, algorithm)
402
+ ];
403
+ csp = {
404
+ styleHashes,
405
+ styleResources: getStyleResources(settings.config.experimental.csp),
406
+ scriptHashes,
407
+ scriptResources: getScriptResources(settings.config.experimental.csp),
408
+ algorithm,
409
+ directives: getDirectives(settings.config.experimental.csp),
410
+ isStrictDynamic: getStrictDynamic(settings.config.experimental.csp)
411
+ };
412
+ }
380
413
  return {
381
414
  hrefRoot: settings.config.root.toString(),
382
415
  srcDir: settings.config.srcDir,
@@ -408,7 +441,8 @@ function createBuildManifest(settings, internals, renderers, middleware, actions
408
441
  },
409
442
  actions: () => actions,
410
443
  checkOrigin: (settings.config.security?.checkOrigin && settings.buildOutput === "server") ?? false,
411
- key
444
+ key,
445
+ csp
412
446
  };
413
447
  }
414
448
  export {
@@ -64,6 +64,7 @@ export interface BuildInternals {
64
64
  */
65
65
  propagatedStylesMap: Map<string, Set<StylesheetAsset>>;
66
66
  staticFiles: Set<string>;
67
+ clientChunksAndAssets: Set<string>;
67
68
  ssrEntryChunk?: Rollup.OutputChunk;
68
69
  manifestEntryChunk?: Rollup.OutputChunk;
69
70
  manifestFileName?: string;
@@ -19,7 +19,8 @@ function createBuildInternals() {
19
19
  entryPoints: /* @__PURE__ */ new Map(),
20
20
  prerenderOnlyChunks: [],
21
21
  astroActionsEntryPoint: void 0,
22
- middlewareEntryPoint: void 0
22
+ middlewareEntryPoint: void 0,
23
+ clientChunksAndAssets: /* @__PURE__ */ new Set()
23
24
  };
24
25
  }
25
26
  function trackPageData(internals, _component, pageData, componentModuleId, componentURL) {
@@ -16,7 +16,7 @@ import { pluginSSR } from "./plugin-ssr.js";
16
16
  function registerAllPlugins({ internals, options, register }) {
17
17
  register(pluginComponentEntry(internals));
18
18
  register(pluginAnalyzer(internals));
19
- register(pluginInternals(internals));
19
+ register(pluginInternals(options, internals));
20
20
  register(pluginManifest(options, internals));
21
21
  register(pluginRenderers(options));
22
22
  register(pluginMiddleware(options, internals));
@@ -1,3 +1,4 @@
1
1
  import type { BuildInternals } from '../internal.js';
2
2
  import type { AstroBuildPlugin } from '../plugin.js';
3
- export declare function pluginInternals(internals: BuildInternals): AstroBuildPlugin;
3
+ import type { StaticBuildOptions } from '../types.js';
4
+ export declare function pluginInternals(options: StaticBuildOptions, internals: BuildInternals): AstroBuildPlugin;
@@ -1,5 +1,5 @@
1
1
  import { normalizeEntryId } from "./plugin-component-entry.js";
2
- function vitePluginInternals(input, internals) {
2
+ function vitePluginInternals(input, opts, internals) {
3
3
  return {
4
4
  name: "@astro/plugin-build-internals",
5
5
  config(config, options) {
@@ -35,7 +35,10 @@ function vitePluginInternals(input, internals) {
35
35
  );
36
36
  }
37
37
  await Promise.all(promises);
38
- for (const [, chunk] of Object.entries(bundle)) {
38
+ for (const [_, chunk] of Object.entries(bundle)) {
39
+ if (chunk.fileName.startsWith(opts.settings.config.build.assets)) {
40
+ internals.clientChunksAndAssets.add(chunk.fileName);
41
+ }
39
42
  if (chunk.type === "chunk" && chunk.facadeModuleId) {
40
43
  const specifiers = mapping.get(chunk.facadeModuleId) || /* @__PURE__ */ new Set([chunk.facadeModuleId]);
41
44
  for (const specifier of specifiers) {
@@ -46,13 +49,13 @@ function vitePluginInternals(input, internals) {
46
49
  }
47
50
  };
48
51
  }
49
- function pluginInternals(internals) {
52
+ function pluginInternals(options, internals) {
50
53
  return {
51
54
  targets: ["client", "server"],
52
55
  hooks: {
53
56
  "build:before": ({ input }) => {
54
57
  return {
55
- vitePlugin: vitePluginInternals(input, internals)
58
+ vitePlugin: vitePluginInternals(input, options, internals)
56
59
  };
57
60
  }
58
61
  }