astro 5.8.2 → 5.9.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 (73) 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/index.js +9 -3
  9. package/dist/core/app/types.d.ts +12 -1
  10. package/dist/core/base-pipeline.js +3 -3
  11. package/dist/core/build/generate.d.ts +1 -1
  12. package/dist/core/build/generate.js +38 -4
  13. package/dist/core/build/internal.d.ts +1 -0
  14. package/dist/core/build/internal.js +2 -1
  15. package/dist/core/build/plugins/index.js +1 -1
  16. package/dist/core/build/plugins/plugin-internals.d.ts +2 -1
  17. package/dist/core/build/plugins/plugin-internals.js +7 -4
  18. package/dist/core/build/plugins/plugin-manifest.js +37 -3
  19. package/dist/core/config/merge.js +1 -6
  20. package/dist/core/config/schemas/base.d.ts +435 -331
  21. package/dist/core/config/schemas/base.js +20 -2
  22. package/dist/core/config/schemas/index.d.ts +1 -1
  23. package/dist/core/config/schemas/index.js +4 -1
  24. package/dist/core/config/schemas/relative.d.ts +681 -552
  25. package/dist/core/constants.js +1 -1
  26. package/dist/core/csp/common.d.ts +16 -0
  27. package/dist/core/csp/common.js +116 -0
  28. package/dist/core/csp/config.d.ts +16 -0
  29. package/dist/core/csp/config.js +52 -0
  30. package/dist/core/dev/dev.js +1 -1
  31. package/dist/core/encryption.d.ts +8 -0
  32. package/dist/core/encryption.js +7 -0
  33. package/dist/core/errors/errors-data.d.ts +12 -0
  34. package/dist/core/errors/errors-data.js +6 -0
  35. package/dist/core/messages.js +2 -2
  36. package/dist/core/middleware/index.js +10 -0
  37. package/dist/core/render-context.d.ts +1 -0
  38. package/dist/core/render-context.js +77 -5
  39. package/dist/core/util.d.ts +1 -0
  40. package/dist/core/util.js +6 -1
  41. package/dist/env/schema.d.ts +34 -34
  42. package/dist/integrations/features-validation.js +36 -30
  43. package/dist/integrations/hooks.d.ts +3 -2
  44. package/dist/runtime/server/astro-island-styles.d.ts +1 -0
  45. package/dist/runtime/server/astro-island-styles.js +4 -0
  46. package/dist/runtime/server/index.d.ts +1 -0
  47. package/dist/runtime/server/render/astro/factory.d.ts +3 -2
  48. package/dist/runtime/server/render/astro/factory.js +6 -1
  49. package/dist/runtime/server/render/astro/head-and-content.d.ts +7 -0
  50. package/dist/runtime/server/render/astro/head-and-content.js +6 -0
  51. package/dist/runtime/server/render/astro/render.d.ts +1 -0
  52. package/dist/runtime/server/render/astro/render.js +2 -1
  53. package/dist/runtime/server/render/common.d.ts +1 -1
  54. package/dist/runtime/server/render/common.js +5 -3
  55. package/dist/runtime/server/render/component.js +8 -2
  56. package/dist/runtime/server/render/csp.d.ts +2 -0
  57. package/dist/runtime/server/render/csp.js +35 -0
  58. package/dist/runtime/server/render/head.js +14 -0
  59. package/dist/runtime/server/render/page.d.ts +1 -1
  60. package/dist/runtime/server/render/page.js +1 -1
  61. package/dist/runtime/server/render/server-islands.d.ts +14 -3
  62. package/dist/runtime/server/render/server-islands.js +100 -69
  63. package/dist/runtime/server/scripts.d.ts +1 -1
  64. package/dist/runtime/server/scripts.js +2 -5
  65. package/dist/runtime/server/transition.d.ts +1 -1
  66. package/dist/runtime/server/transition.js +7 -2
  67. package/dist/types/public/config.d.ts +240 -7
  68. package/dist/types/public/context.d.ts +51 -0
  69. package/dist/types/public/integrations.d.ts +9 -0
  70. package/dist/types/public/internal.d.ts +24 -2
  71. package/dist/vite-plugin-astro-server/css.js +3 -3
  72. package/dist/vite-plugin-astro-server/plugin.js +26 -4
  73. package/package.json +3 -3
@@ -16,22 +16,22 @@ declare const StringSchema: z.ZodObject<{
16
16
  includes?: string | undefined;
17
17
  endsWith?: string | undefined;
18
18
  startsWith?: string | undefined;
19
- default?: string | undefined;
20
19
  optional?: boolean | undefined;
20
+ url?: boolean | undefined;
21
+ default?: string | undefined;
21
22
  max?: number | undefined;
22
23
  min?: number | undefined;
23
- url?: boolean | undefined;
24
24
  }, {
25
25
  type: "string";
26
26
  length?: number | undefined;
27
27
  includes?: string | undefined;
28
28
  endsWith?: string | undefined;
29
29
  startsWith?: string | undefined;
30
- default?: string | undefined;
31
30
  optional?: boolean | undefined;
31
+ url?: boolean | undefined;
32
+ default?: string | undefined;
32
33
  max?: number | undefined;
33
34
  min?: number | undefined;
34
- url?: boolean | undefined;
35
35
  }>;
36
36
  export type StringSchema = z.infer<typeof StringSchema>;
37
37
  declare const NumberSchema: z.ZodObject<{
@@ -45,8 +45,8 @@ declare const NumberSchema: z.ZodObject<{
45
45
  int: z.ZodOptional<z.ZodBoolean>;
46
46
  }, "strip", z.ZodTypeAny, {
47
47
  type: "number";
48
- default?: number | undefined;
49
48
  optional?: boolean | undefined;
49
+ default?: number | undefined;
50
50
  max?: number | undefined;
51
51
  min?: number | undefined;
52
52
  gt?: number | undefined;
@@ -54,8 +54,8 @@ declare const NumberSchema: z.ZodObject<{
54
54
  int?: boolean | undefined;
55
55
  }, {
56
56
  type: "number";
57
- default?: number | undefined;
58
57
  optional?: boolean | undefined;
58
+ default?: number | undefined;
59
59
  max?: number | undefined;
60
60
  min?: number | undefined;
61
61
  gt?: number | undefined;
@@ -69,12 +69,12 @@ declare const BooleanSchema: z.ZodObject<{
69
69
  default: z.ZodOptional<z.ZodBoolean>;
70
70
  }, "strip", z.ZodTypeAny, {
71
71
  type: "boolean";
72
- default?: boolean | undefined;
73
72
  optional?: boolean | undefined;
73
+ default?: boolean | undefined;
74
74
  }, {
75
75
  type: "boolean";
76
- default?: boolean | undefined;
77
76
  optional?: boolean | undefined;
77
+ default?: boolean | undefined;
78
78
  }>;
79
79
  declare const EnumSchema: z.ZodObject<{
80
80
  type: z.ZodLiteral<"enum">;
@@ -84,13 +84,13 @@ declare const EnumSchema: z.ZodObject<{
84
84
  }, "strip", z.ZodTypeAny, {
85
85
  values: string[];
86
86
  type: "enum";
87
- default?: string | undefined;
88
87
  optional?: boolean | undefined;
88
+ default?: string | undefined;
89
89
  }, {
90
90
  values: string[];
91
91
  type: "enum";
92
- default?: string | undefined;
93
92
  optional?: boolean | undefined;
93
+ default?: string | undefined;
94
94
  }>;
95
95
  export type EnumSchema = z.infer<typeof EnumSchema>;
96
96
  declare const EnvFieldType: z.ZodUnion<[z.ZodObject<{
@@ -110,22 +110,22 @@ declare const EnvFieldType: z.ZodUnion<[z.ZodObject<{
110
110
  includes?: string | undefined;
111
111
  endsWith?: string | undefined;
112
112
  startsWith?: string | undefined;
113
- default?: string | undefined;
114
113
  optional?: boolean | undefined;
114
+ url?: boolean | undefined;
115
+ default?: string | undefined;
115
116
  max?: number | undefined;
116
117
  min?: number | undefined;
117
- url?: boolean | undefined;
118
118
  }, {
119
119
  type: "string";
120
120
  length?: number | undefined;
121
121
  includes?: string | undefined;
122
122
  endsWith?: string | undefined;
123
123
  startsWith?: string | undefined;
124
- default?: string | undefined;
125
124
  optional?: boolean | undefined;
125
+ url?: boolean | undefined;
126
+ default?: string | undefined;
126
127
  max?: number | undefined;
127
128
  min?: number | undefined;
128
- url?: boolean | undefined;
129
129
  }>, z.ZodObject<{
130
130
  type: z.ZodLiteral<"number">;
131
131
  optional: z.ZodOptional<z.ZodBoolean>;
@@ -137,8 +137,8 @@ declare const EnvFieldType: z.ZodUnion<[z.ZodObject<{
137
137
  int: z.ZodOptional<z.ZodBoolean>;
138
138
  }, "strip", z.ZodTypeAny, {
139
139
  type: "number";
140
- default?: number | undefined;
141
140
  optional?: boolean | undefined;
141
+ default?: number | undefined;
142
142
  max?: number | undefined;
143
143
  min?: number | undefined;
144
144
  gt?: number | undefined;
@@ -146,8 +146,8 @@ declare const EnvFieldType: z.ZodUnion<[z.ZodObject<{
146
146
  int?: boolean | undefined;
147
147
  }, {
148
148
  type: "number";
149
- default?: number | undefined;
150
149
  optional?: boolean | undefined;
150
+ default?: number | undefined;
151
151
  max?: number | undefined;
152
152
  min?: number | undefined;
153
153
  gt?: number | undefined;
@@ -159,12 +159,12 @@ declare const EnvFieldType: z.ZodUnion<[z.ZodObject<{
159
159
  default: z.ZodOptional<z.ZodBoolean>;
160
160
  }, "strip", z.ZodTypeAny, {
161
161
  type: "boolean";
162
- default?: boolean | undefined;
163
162
  optional?: boolean | undefined;
163
+ default?: boolean | undefined;
164
164
  }, {
165
165
  type: "boolean";
166
- default?: boolean | undefined;
167
166
  optional?: boolean | undefined;
167
+ default?: boolean | undefined;
168
168
  }>, z.ZodEffects<z.ZodObject<{
169
169
  type: z.ZodLiteral<"enum">;
170
170
  values: z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">;
@@ -173,23 +173,23 @@ declare const EnvFieldType: z.ZodUnion<[z.ZodObject<{
173
173
  }, "strip", z.ZodTypeAny, {
174
174
  values: string[];
175
175
  type: "enum";
176
- default?: string | undefined;
177
176
  optional?: boolean | undefined;
177
+ default?: string | undefined;
178
178
  }, {
179
179
  values: string[];
180
180
  type: "enum";
181
- default?: string | undefined;
182
181
  optional?: boolean | undefined;
182
+ default?: string | undefined;
183
183
  }>, {
184
184
  values: string[];
185
185
  type: "enum";
186
- default?: string | undefined;
187
186
  optional?: boolean | undefined;
187
+ default?: string | undefined;
188
188
  }, {
189
189
  values: string[];
190
190
  type: "enum";
191
- default?: string | undefined;
192
191
  optional?: boolean | undefined;
192
+ default?: string | undefined;
193
193
  }>]>;
194
194
  export type EnvFieldType = z.infer<typeof EnvFieldType>;
195
195
  declare const EnvFieldMetadata: z.ZodEffects<z.ZodType<{
@@ -282,22 +282,22 @@ export declare const EnvSchema: z.ZodRecord<z.ZodEffects<z.ZodEffects<z.ZodStrin
282
282
  includes?: string | undefined;
283
283
  endsWith?: string | undefined;
284
284
  startsWith?: string | undefined;
285
- default?: string | undefined;
286
285
  optional?: boolean | undefined;
286
+ url?: boolean | undefined;
287
+ default?: string | undefined;
287
288
  max?: number | undefined;
288
289
  min?: number | undefined;
289
- url?: boolean | undefined;
290
290
  }, {
291
291
  type: "string";
292
292
  length?: number | undefined;
293
293
  includes?: string | undefined;
294
294
  endsWith?: string | undefined;
295
295
  startsWith?: string | undefined;
296
- default?: string | undefined;
297
296
  optional?: boolean | undefined;
297
+ url?: boolean | undefined;
298
+ default?: string | undefined;
298
299
  max?: number | undefined;
299
300
  min?: number | undefined;
300
- url?: boolean | undefined;
301
301
  }>, z.ZodObject<{
302
302
  type: z.ZodLiteral<"number">;
303
303
  optional: z.ZodOptional<z.ZodBoolean>;
@@ -309,8 +309,8 @@ export declare const EnvSchema: z.ZodRecord<z.ZodEffects<z.ZodEffects<z.ZodStrin
309
309
  int: z.ZodOptional<z.ZodBoolean>;
310
310
  }, "strip", z.ZodTypeAny, {
311
311
  type: "number";
312
- default?: number | undefined;
313
312
  optional?: boolean | undefined;
313
+ default?: number | undefined;
314
314
  max?: number | undefined;
315
315
  min?: number | undefined;
316
316
  gt?: number | undefined;
@@ -318,8 +318,8 @@ export declare const EnvSchema: z.ZodRecord<z.ZodEffects<z.ZodEffects<z.ZodStrin
318
318
  int?: boolean | undefined;
319
319
  }, {
320
320
  type: "number";
321
- default?: number | undefined;
322
321
  optional?: boolean | undefined;
322
+ default?: number | undefined;
323
323
  max?: number | undefined;
324
324
  min?: number | undefined;
325
325
  gt?: number | undefined;
@@ -331,12 +331,12 @@ export declare const EnvSchema: z.ZodRecord<z.ZodEffects<z.ZodEffects<z.ZodStrin
331
331
  default: z.ZodOptional<z.ZodBoolean>;
332
332
  }, "strip", z.ZodTypeAny, {
333
333
  type: "boolean";
334
- default?: boolean | undefined;
335
334
  optional?: boolean | undefined;
335
+ default?: boolean | undefined;
336
336
  }, {
337
337
  type: "boolean";
338
- default?: boolean | undefined;
339
338
  optional?: boolean | undefined;
339
+ default?: boolean | undefined;
340
340
  }>, z.ZodEffects<z.ZodObject<{
341
341
  type: z.ZodLiteral<"enum">;
342
342
  values: z.ZodArray<z.ZodEffects<z.ZodString, string, string>, "many">;
@@ -345,23 +345,23 @@ export declare const EnvSchema: z.ZodRecord<z.ZodEffects<z.ZodEffects<z.ZodStrin
345
345
  }, "strip", z.ZodTypeAny, {
346
346
  values: string[];
347
347
  type: "enum";
348
- default?: string | undefined;
349
348
  optional?: boolean | undefined;
349
+ default?: string | undefined;
350
350
  }, {
351
351
  values: string[];
352
352
  type: "enum";
353
- default?: string | undefined;
354
353
  optional?: boolean | undefined;
354
+ default?: string | undefined;
355
355
  }>, {
356
356
  values: string[];
357
357
  type: "enum";
358
- default?: string | undefined;
359
358
  optional?: boolean | undefined;
359
+ default?: string | undefined;
360
360
  }, {
361
361
  values: string[];
362
362
  type: "enum";
363
- default?: string | undefined;
364
363
  optional?: boolean | undefined;
364
+ default?: string | undefined;
365
365
  }>]>>>;
366
366
  type Prettify<T> = {
367
367
  [K in keyof T]: T[K];
@@ -72,49 +72,55 @@ function unwrapSupportKind(supportKind) {
72
72
  function getSupportMessage(supportKind) {
73
73
  return typeof supportKind === "object" ? supportKind.message : void 0;
74
74
  }
75
+ function getSupportMessageSuppression(supportKind) {
76
+ return typeof supportKind === "object" ? supportKind.suppress : void 0;
77
+ }
75
78
  function validateSupportKind(supportKind, adapterName, logger, featureName, hasCorrectConfig) {
76
79
  const supportValue = unwrapSupportKind(supportKind);
77
80
  const message = getSupportMessage(supportKind);
81
+ const suppress = getSupportMessageSuppression(supportKind);
78
82
  if (!supportValue) {
79
83
  return false;
80
84
  }
81
85
  if (supportValue === AdapterFeatureStability.STABLE) {
82
86
  return true;
83
87
  } else if (hasCorrectConfig()) {
84
- logFeatureSupport(adapterName, logger, featureName, supportValue, message);
88
+ logFeatureSupport(adapterName, logger, featureName, supportValue, message, suppress);
85
89
  }
86
90
  return false;
87
91
  }
88
- function logFeatureSupport(adapterName, logger, featureName, supportKind, adapterMessage) {
89
- switch (supportKind) {
90
- case AdapterFeatureStability.STABLE:
91
- break;
92
- case AdapterFeatureStability.DEPRECATED:
93
- logger.warn(
94
- "config",
95
- `The adapter ${adapterName} has deprecated its support for "${featureName}", and future compatibility is not guaranteed. The adapter may completely remove support for this feature without warning.`
96
- );
97
- break;
98
- case AdapterFeatureStability.EXPERIMENTAL:
99
- logger.warn(
100
- "config",
101
- `The adapter ${adapterName} provides experimental support for "${featureName}". You may experience issues or breaking changes until this feature is fully supported by the adapter.`
102
- );
103
- break;
104
- case AdapterFeatureStability.LIMITED:
105
- logger.warn(
106
- "config",
107
- `The adapter ${adapterName} has limited support for "${featureName}". Certain features may not work as expected.`
108
- );
109
- break;
110
- case AdapterFeatureStability.UNSUPPORTED:
111
- logger.error(
112
- "config",
113
- `The adapter ${adapterName} does not currently support the feature "${featureName}". Your project may not build correctly.`
114
- );
115
- break;
92
+ function logFeatureSupport(adapterName, logger, featureName, supportKind, adapterMessage, suppress) {
93
+ if (!suppress) {
94
+ switch (supportKind) {
95
+ case AdapterFeatureStability.STABLE:
96
+ break;
97
+ case AdapterFeatureStability.DEPRECATED:
98
+ logger.warn(
99
+ "config",
100
+ `The adapter ${adapterName} has deprecated its support for "${featureName}", and future compatibility is not guaranteed. The adapter may completely remove support for this feature without warning.`
101
+ );
102
+ break;
103
+ case AdapterFeatureStability.EXPERIMENTAL:
104
+ logger.warn(
105
+ "config",
106
+ `The adapter ${adapterName} provides experimental support for "${featureName}". You may experience issues or breaking changes until this feature is fully supported by the adapter.`
107
+ );
108
+ break;
109
+ case AdapterFeatureStability.LIMITED:
110
+ logger.warn(
111
+ "config",
112
+ `The adapter ${adapterName} has limited support for "${featureName}". Certain features may not work as expected.`
113
+ );
114
+ break;
115
+ case AdapterFeatureStability.UNSUPPORTED:
116
+ logger.error(
117
+ "config",
118
+ `The adapter ${adapterName} does not currently support the feature "${featureName}". Your project may not build correctly.`
119
+ );
120
+ break;
121
+ }
116
122
  }
117
- if (adapterMessage) {
123
+ if (adapterMessage && suppress !== "all") {
118
124
  logger.warn("adapter", adapterMessage);
119
125
  }
120
126
  }
@@ -38,13 +38,14 @@ export declare function getToolbarServerCommunicationHelpers(server: ViteDevServ
38
38
  };
39
39
  export declare function normalizeCodegenDir(integrationName: string): string;
40
40
  export declare function normalizeInjectedTypeFilename(filename: string, integrationName: string): string;
41
- export declare function runHookConfigSetup({ settings, command, logger, isRestart, fs, }: {
41
+ interface RunHookConfigSetup {
42
42
  settings: AstroSettings;
43
43
  command: 'dev' | 'build' | 'preview' | 'sync';
44
44
  logger: Logger;
45
45
  isRestart?: boolean;
46
46
  fs?: typeof fsMod;
47
- }): Promise<AstroSettings>;
47
+ }
48
+ export declare function runHookConfigSetup({ settings, command, logger, isRestart, fs, }: RunHookConfigSetup): Promise<AstroSettings>;
48
49
  export declare function runHookConfigDone({ settings, logger, command, }: {
49
50
  settings: AstroSettings;
50
51
  logger: Logger;
@@ -0,0 +1 @@
1
+ export declare const ISLAND_STYLES = "astro-island,astro-slot,astro-static-slot{display:contents}";
@@ -0,0 +1,4 @@
1
+ const ISLAND_STYLES = "astro-island,astro-slot,astro-static-slot{display:contents}";
2
+ export {
3
+ ISLAND_STYLES
4
+ };
@@ -5,6 +5,7 @@ export { escapeHTML, HTMLBytes, HTMLString, isHTMLString, markHTMLString, unesca
5
5
  export { renderJSX } from './jsx.js';
6
6
  export { addAttribute, createHeadAndContent, defineScriptVars, Fragment, maybeRenderHead, renderTemplate as render, renderComponent, Renderer as Renderer, renderHead, renderHTMLElement, renderPage, renderScript, renderScriptElement, renderSlot, renderSlotToString, renderTemplate, renderToString, renderUniqueStylesheet, voidElementNames, } from './render/index.js';
7
7
  export type { AstroComponentFactory, AstroComponentInstance, ComponentSlots, RenderInstruction, } from './render/index.js';
8
+ export type { ServerIslandComponent } from './render/server-islands.js';
8
9
  export { createTransitionScope, renderTransition } from './transition.js';
9
10
  export declare function mergeSlots(...slotted: unknown[]): Record<string, () => any>;
10
11
  export declare function spreadAttributes(values?: Record<any, any>, _name?: string, { class: scopedClassName }?: {
@@ -1,7 +1,7 @@
1
1
  import type { PropagationHint, SSRResult } from '../../../../types/public/internal.js';
2
- import type { HeadAndContent } from './head-and-content.js';
2
+ import type { HeadAndContent, ThinHead } from './head-and-content.js';
3
3
  import type { RenderTemplateResult } from './render-template.js';
4
- export type AstroFactoryReturnValue = RenderTemplateResult | Response | HeadAndContent;
4
+ export type AstroFactoryReturnValue = RenderTemplateResult | Response | HeadAndContent | ThinHead;
5
5
  export interface AstroComponentFactory {
6
6
  (result: any, props: any, slots: any): AstroFactoryReturnValue | Promise<AstroFactoryReturnValue>;
7
7
  isAstroComponentFactory?: boolean;
@@ -10,3 +10,4 @@ export interface AstroComponentFactory {
10
10
  }
11
11
  export declare function isAstroComponentFactory(obj: any): obj is AstroComponentFactory;
12
12
  export declare function isAPropagatingComponent(result: SSRResult, factory: AstroComponentFactory): boolean;
13
+ export declare function getPropagationHint(result: SSRResult, factory: AstroComponentFactory): PropagationHint;
@@ -2,13 +2,18 @@ function isAstroComponentFactory(obj) {
2
2
  return obj == null ? false : obj.isAstroComponentFactory === true;
3
3
  }
4
4
  function isAPropagatingComponent(result, factory) {
5
+ const hint = getPropagationHint(result, factory);
6
+ return hint === "in-tree" || hint === "self";
7
+ }
8
+ function getPropagationHint(result, factory) {
5
9
  let hint = factory.propagation || "none";
6
10
  if (factory.moduleId && result.componentMetadata.has(factory.moduleId) && hint === "none") {
7
11
  hint = result.componentMetadata.get(factory.moduleId).propagation;
8
12
  }
9
- return hint === "in-tree" || hint === "self";
13
+ return hint;
10
14
  }
11
15
  export {
16
+ getPropagationHint,
12
17
  isAPropagatingComponent,
13
18
  isAstroComponentFactory
14
19
  };
@@ -5,6 +5,13 @@ export type HeadAndContent = {
5
5
  head: string;
6
6
  content: RenderTemplateResult;
7
7
  };
8
+ /**
9
+ * A head that doesn't contain any content
10
+ */
11
+ export type ThinHead = {
12
+ [headAndContentSym]: true;
13
+ };
8
14
  export declare function isHeadAndContent(obj: unknown): obj is HeadAndContent;
9
15
  export declare function createHeadAndContent(head: string, content: RenderTemplateResult): HeadAndContent;
16
+ export declare function createThinHead(): ThinHead;
10
17
  export {};
@@ -9,7 +9,13 @@ function createHeadAndContent(head, content) {
9
9
  content
10
10
  };
11
11
  }
12
+ function createThinHead() {
13
+ return {
14
+ [headAndContentSym]: true
15
+ };
16
+ }
12
17
  export {
13
18
  createHeadAndContent,
19
+ createThinHead,
14
20
  isHeadAndContent
15
21
  };
@@ -2,4 +2,5 @@ import type { RouteData, SSRResult } from '../../../../types/public/internal.js'
2
2
  import type { AstroComponentFactory } from './factory.js';
3
3
  export declare function renderToString(result: SSRResult, componentFactory: AstroComponentFactory, props: any, children: any, isPage?: boolean, route?: RouteData): Promise<string | Response>;
4
4
  export declare function renderToReadableStream(result: SSRResult, componentFactory: AstroComponentFactory, props: any, children: any, isPage?: boolean, route?: RouteData): Promise<ReadableStream | Response>;
5
+ export declare function bufferHeadContent(result: SSRResult): Promise<void>;
5
6
  export declare function renderToAsyncIterable(result: SSRResult, componentFactory: AstroComponentFactory, props: any, children: any, isPage?: boolean, route?: RouteData): Promise<AsyncIterable<Uint8Array> | Response>;
@@ -124,7 +124,7 @@ async function bufferHeadContent(result) {
124
124
  break;
125
125
  }
126
126
  const returnValue = await value.init(result);
127
- if (isHeadAndContent(returnValue)) {
127
+ if (isHeadAndContent(returnValue) && returnValue.head) {
128
128
  result._metadata.extraHead.push(returnValue.head);
129
129
  }
130
130
  }
@@ -229,6 +229,7 @@ function toPromise(fn) {
229
229
  }
230
230
  }
231
231
  export {
232
+ bufferHeadContent,
232
233
  renderToAsyncIterable,
233
234
  renderToReadableStream,
234
235
  renderToString
@@ -1,6 +1,6 @@
1
- import type { RenderInstruction } from './instruction.js';
2
1
  import type { SSRResult } from '../../../types/public/internal.js';
3
2
  import type { HTMLBytes, HTMLString } from '../escape.js';
3
+ import type { RenderInstruction } from './instruction.js';
4
4
  import { type SlotString } from './slot.js';
5
5
  /**
6
6
  * Possible chunk types to be written to the destination, and it'll
@@ -20,9 +20,11 @@ function stringifyChunk(result, chunk) {
20
20
  const { hydration } = instruction;
21
21
  let needsHydrationScript = hydration && determineIfNeedsHydrationScript(result);
22
22
  let needsDirectiveScript = hydration && determinesIfNeedsDirectiveScript(result, hydration.directive);
23
- let prescriptType = needsHydrationScript ? "both" : needsDirectiveScript ? "directive" : null;
24
- if (prescriptType) {
25
- let prescripts = getPrescripts(result, prescriptType, hydration.directive);
23
+ if (needsHydrationScript) {
24
+ let prescripts = getPrescripts(result, "both", hydration.directive);
25
+ return markHTMLString(prescripts);
26
+ } else if (needsDirectiveScript) {
27
+ let prescripts = getPrescripts(result, "directive", hydration.directive);
26
28
  return markHTMLString(prescripts);
27
29
  } else {
28
30
  return "";
@@ -9,6 +9,7 @@ import { isPromise } from "../util.js";
9
9
  import { isAstroComponentFactory } from "./astro/factory.js";
10
10
  import { renderTemplate } from "./astro/index.js";
11
11
  import { createAstroComponentInstance } from "./astro/instance.js";
12
+ import { bufferHeadContent } from "./astro/render.js";
12
13
  import {
13
14
  Fragment,
14
15
  Renderer,
@@ -16,7 +17,7 @@ import {
16
17
  } from "./common.js";
17
18
  import { componentIsHTMLElement, renderHTMLElement } from "./dom.js";
18
19
  import { maybeRenderHead } from "./head.js";
19
- import { containsServerDirective, renderServerIsland } from "./server-islands.js";
20
+ import { ServerIslandComponent, containsServerDirective } from "./server-islands.js";
20
21
  import { renderSlotToString, renderSlots } from "./slot.js";
21
22
  import { formatList, internalSpreadAttributes, renderElement, voidElementNames } from "./util.js";
22
23
  const needsHeadRenderingSymbol = Symbol.for("astro.needsHeadRendering");
@@ -342,7 +343,9 @@ async function renderHTMLComponent(result, Component, _props, slots = {}) {
342
343
  }
343
344
  function renderAstroComponent(result, displayName, Component, props, slots = {}) {
344
345
  if (containsServerDirective(props)) {
345
- return renderServerIsland(result, displayName, props, slots);
346
+ const serverIslandComponent = new ServerIslandComponent(result, props, slots, displayName);
347
+ result._metadata.propagators.add(serverIslandComponent);
348
+ return serverIslandComponent;
346
349
  }
347
350
  const instance = createAstroComponentInstance(result, displayName, Component, props, slots);
348
351
  return {
@@ -412,6 +415,9 @@ async function renderComponentToString(result, displayName, Component, props, sl
412
415
  }
413
416
  };
414
417
  const renderInstance = await renderComponent(result, displayName, Component, props, slots);
418
+ if (containsServerDirective(props)) {
419
+ await bufferHeadContent(result);
420
+ }
415
421
  await renderInstance.render(destination);
416
422
  } catch (e) {
417
423
  if (AstroError.is(e) && !e.loc) {
@@ -0,0 +1,2 @@
1
+ import type { SSRResult } from '../../../types/public/index.js';
2
+ export declare function renderCspContent(result: SSRResult): string;
@@ -0,0 +1,35 @@
1
+ function renderCspContent(result) {
2
+ const finalScriptHashes = /* @__PURE__ */ new Set();
3
+ const finalStyleHashes = /* @__PURE__ */ new Set();
4
+ for (const scriptHash of result.scriptHashes) {
5
+ finalScriptHashes.add(`'${scriptHash}'`);
6
+ }
7
+ for (const styleHash of result.styleHashes) {
8
+ finalStyleHashes.add(`'${styleHash}'`);
9
+ }
10
+ for (const styleHash of result._metadata.extraStyleHashes) {
11
+ finalStyleHashes.add(`'${styleHash}'`);
12
+ }
13
+ for (const scriptHash of result._metadata.extraScriptHashes) {
14
+ finalScriptHashes.add(`'${scriptHash}'`);
15
+ }
16
+ let directives = "";
17
+ if (result.directives.length > 0) {
18
+ directives = result.directives.join(";") + ";";
19
+ }
20
+ let scriptResources = "'self'";
21
+ if (result.scriptResources.length > 0) {
22
+ scriptResources = result.scriptResources.map((r) => `'${r}'`).join(" ");
23
+ }
24
+ let styleResources = "'self'";
25
+ if (result.styleResources.length > 0) {
26
+ styleResources = result.styleResources.map((r) => `'${r}'`).join(" ");
27
+ }
28
+ const strictDynamic = result.isStrictDynamic ? ` strict-dynamic` : "";
29
+ const scriptSrc = `script-src ${scriptResources} ${Array.from(finalScriptHashes).join(" ")}${strictDynamic};`;
30
+ const styleSrc = `style-src ${styleResources} ${Array.from(finalStyleHashes).join(" ")};`;
31
+ return `${directives} ${scriptSrc} ${styleSrc}`;
32
+ }
33
+ export {
34
+ renderCspContent
35
+ };
@@ -1,4 +1,5 @@
1
1
  import { markHTMLString } from "../escape.js";
2
+ import { renderCspContent } from "./csp.js";
2
3
  import { createRenderInstruction } from "./instruction.js";
3
4
  import { renderElement } from "./util.js";
4
5
  const uniqueElements = (item, index, all) => {
@@ -25,6 +26,19 @@ function renderAllHeadContent(result) {
25
26
  content += part;
26
27
  }
27
28
  }
29
+ if (result.shouldInjectCspMetaTags) {
30
+ content += renderElement(
31
+ "meta",
32
+ {
33
+ props: {
34
+ "http-equiv": "content-security-policy",
35
+ content: renderCspContent(result)
36
+ },
37
+ children: ""
38
+ },
39
+ false
40
+ );
41
+ }
28
42
  return markHTMLString(content);
29
43
  }
30
44
  function renderHead() {
@@ -1,4 +1,4 @@
1
+ import type { RouteData, SSRResult } from '../../../types/public/internal.js';
1
2
  import { type NonAstroPageComponent } from './component.js';
2
3
  import type { AstroComponentFactory } from './index.js';
3
- import type { RouteData, SSRResult } from '../../../types/public/internal.js';
4
4
  export declare function renderPage(result: SSRResult, componentFactory: AstroComponentFactory | NonAstroPageComponent, props: any, children: any, streaming: boolean, route?: RouteData): Promise<Response>;
@@ -1,7 +1,7 @@
1
- import { renderComponentToString } from "./component.js";
2
1
  import { isAstroComponentFactory } from "./astro/index.js";
3
2
  import { renderToAsyncIterable, renderToReadableStream, renderToString } from "./astro/render.js";
4
3
  import { encoder } from "./common.js";
4
+ import { renderComponentToString } from "./component.js";
5
5
  import { isDeno, isNode } from "./util.js";
6
6
  async function renderPage(result, componentFactory, props, children, streaming, route) {
7
7
  if (!isAstroComponentFactory(componentFactory)) {
@@ -1,6 +1,17 @@
1
1
  import type { SSRResult } from '../../../types/public/internal.js';
2
- import type { RenderInstance } from './common.js';
2
+ import { type ThinHead } from './astro/head-and-content.js';
3
+ import type { RenderDestination } from './common.js';
3
4
  import { type ComponentSlots } from './slot.js';
4
5
  export declare function containsServerDirective(props: Record<string | number, any>): boolean;
5
- export declare function renderServerIsland(result: SSRResult, _displayName: string, props: Record<string | number, any>, slots: ComponentSlots): RenderInstance;
6
- export declare const renderServerIslandRuntime: () => any;
6
+ export declare class ServerIslandComponent {
7
+ result: SSRResult;
8
+ props: Record<string | number, any>;
9
+ slots: ComponentSlots;
10
+ displayName: string;
11
+ hostId: string | undefined;
12
+ islandContent: string | undefined;
13
+ constructor(result: SSRResult, props: Record<string | number, any>, slots: ComponentSlots, displayName: string);
14
+ init(): Promise<ThinHead>;
15
+ render(destination: RenderDestination): Promise<void>;
16
+ }
17
+ export declare const renderServerIslandRuntime: () => string;