astro 7.0.9 → 7.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/dist/assets/fonts/infra/fs-font-file-content-resolver.js +1 -1
  2. package/dist/cli/dev/index.d.ts +17 -0
  3. package/dist/cli/dev/index.js +56 -2
  4. package/dist/cli/infra/build-time-astro-version-provider.js +1 -1
  5. package/dist/content/consts.d.ts +2 -0
  6. package/dist/content/consts.js +4 -0
  7. package/dist/content/content-layer.d.ts +0 -6
  8. package/dist/content/content-layer.js +4 -9
  9. package/dist/content/data-store-source.d.ts +36 -0
  10. package/dist/content/data-store-source.js +30 -0
  11. package/dist/content/data-store-writer.d.ts +67 -0
  12. package/dist/content/data-store-writer.js +94 -0
  13. package/dist/content/data-store.d.ts +15 -0
  14. package/dist/content/data-store.js +33 -3
  15. package/dist/content/loaders/glob.d.ts +7 -0
  16. package/dist/content/loaders/glob.js +2 -2
  17. package/dist/content/mutable-data-store.d.ts +8 -0
  18. package/dist/content/mutable-data-store.js +52 -15
  19. package/dist/content/paths.d.ts +14 -0
  20. package/dist/content/paths.js +11 -0
  21. package/dist/content/runtime.js +4 -4
  22. package/dist/content/vite-plugin-content-virtual-mod.js +29 -2
  23. package/dist/core/app/dev/pipeline.js +2 -1
  24. package/dist/core/app/types.d.ts +39 -5
  25. package/dist/core/base-pipeline.d.ts +1 -1
  26. package/dist/core/base-pipeline.js +6 -2
  27. package/dist/core/build/index.js +2 -1
  28. package/dist/core/build/plugins/plugin-manifest.js +23 -8
  29. package/dist/core/config/schemas/base.d.ts +38 -5
  30. package/dist/core/config/schemas/base.js +15 -8
  31. package/dist/core/config/schemas/relative.d.ts +73 -15
  32. package/dist/core/constants.js +1 -1
  33. package/dist/core/csp/common.d.ts +7 -7
  34. package/dist/core/csp/common.js +8 -9
  35. package/dist/core/csp/config.d.ts +45 -0
  36. package/dist/core/csp/config.js +44 -2
  37. package/dist/core/csp/runtime.d.ts +21 -1
  38. package/dist/core/csp/runtime.js +31 -0
  39. package/dist/core/dev/dev.js +9 -4
  40. package/dist/core/dev/restart.js +7 -1
  41. package/dist/core/errors/zod-error-map.js +7 -1
  42. package/dist/core/fetch/fetch-state.js +77 -29
  43. package/dist/core/i18n/domain.d.ts +1 -1
  44. package/dist/core/i18n/domain.js +4 -5
  45. package/dist/core/logger/config.d.ts +1 -1
  46. package/dist/core/logger/core.d.ts +4 -4
  47. package/dist/core/logger/impls/console.d.ts +2 -2
  48. package/dist/core/logger/impls/json.d.ts +2 -2
  49. package/dist/core/logger/impls/json.js +3 -14
  50. package/dist/core/logger/impls/node.d.ts +2 -2
  51. package/dist/core/logger/load.d.ts +2 -2
  52. package/dist/core/logger/load.js +19 -27
  53. package/dist/core/messages/runtime.d.ts +8 -0
  54. package/dist/core/messages/runtime.js +34 -1
  55. package/dist/core/render/paginate.js +21 -16
  56. package/dist/core/sync/index.js +23 -8
  57. package/dist/integrations/hooks.js +8 -0
  58. package/dist/manifest/serialized.js +21 -6
  59. package/dist/runtime/server/escape.d.ts +2 -0
  60. package/dist/runtime/server/escape.js +4 -0
  61. package/dist/runtime/server/render/csp.js +80 -19
  62. package/dist/runtime/server/render/server-islands.js +6 -4
  63. package/dist/runtime/server/transition.js +2 -2
  64. package/dist/types/astro.d.ts +2 -3
  65. package/dist/types/public/common.d.ts +13 -0
  66. package/dist/types/public/config.d.ts +196 -15
  67. package/dist/types/public/context.d.ts +27 -11
  68. package/dist/types/public/internal.d.ts +12 -11
  69. package/dist/vite-plugin-app/pipeline.js +2 -1
  70. package/dist/vite-plugin-astro-server/route-guard.js +3 -2
  71. package/package.json +3 -3
@@ -1,6 +1,6 @@
1
1
  import type { ActionClient, ActionReturnType } from '../../actions/runtime/types.js';
2
2
  import type { AstroCookies } from '../../core/cookies/cookies.js';
3
- import type { CspDirective, CspHash } from '../../core/csp/config.js';
3
+ import type { CspDirective, CspHashEntry, CspResourceEntry } from '../../core/csp/config.js';
4
4
  import type { CacheLike } from '../../core/cache/runtime/cache.js';
5
5
  import type { AstroSession } from '../../core/session/runtime.js';
6
6
  import type { AstroComponentFactory } from '../../runtime/server/index.js';
@@ -493,61 +493,77 @@ export interface APIContext<Props extends Record<string, any> = Record<string, a
493
493
  */
494
494
  insertDirective: (directive: CspDirective) => void;
495
495
  /**
496
- * It set the resource for the directive `style-src` in the route being rendered. It overrides Astro's default.
496
+ * It sets the resource for the `style-src` family of directives in the route being rendered. It overrides Astro's default.
497
497
  *
498
- * @param {string} payload - The source to insert in the `style-src` directive.
498
+ * Pass a bare string to add the source to `style-src`, or an object with a `kind` to scope it:
499
+ * `"element"` → `style-src-elem`, `"attribute"` → `style-src-attr`, `"default"` → `style-src`.
500
+ *
501
+ * @param {string | { resource: string; kind?: "element" | "attribute" | "default" }} payload - The source to insert.
499
502
  *
500
503
  * ## Example
501
504
  *
502
505
  * ```js
503
506
  * ctx.insertStyleResource("https://styles.cdn.example.com/")
507
+ * ctx.insertStyleResource({ resource: "'unsafe-inline'", kind: "attribute" })
504
508
  * ```
505
509
  *
506
510
  * [Astro reference](https://docs.astro.build/en/reference/experimental-flags/csp/#cspinsertstyleresource)
507
511
  */
508
- insertStyleResource: (payload: string) => void;
512
+ insertStyleResource: (payload: CspResourceEntry) => void;
509
513
  /**
510
514
  * Insert a single style hash to the route being rendered.
511
515
  *
512
- * @param {CspHash} hash - The hash to insert in the `style-src` directive.
516
+ * Pass a bare hash to add it to `style-src`, or an object with a `kind` to scope it:
517
+ * `"element"` → `style-src-elem`, `"attribute"` → `style-src-attr`, `"default"` → `style-src`.
518
+ *
519
+ * @param {CspHash | { hash: CspHash; kind?: "element" | "attribute" | "default" }} payload - The hash to insert.
513
520
  *
514
521
  * ## Example
515
522
  *
516
523
  * ```js
517
524
  * ctx.insertStyleHash("sha256-1234567890abcdef1234567890")
525
+ * ctx.insertStyleHash({ hash: "sha256-1234567890abcdef1234567890", kind: "element" })
518
526
  * ```
519
527
  *
520
528
  * [Astro reference](https://docs.astro.build/en/reference/experimental-flags/csp/#cspinsertstylehash)
521
529
  */
522
- insertStyleHash: (hash: CspHash) => void;
530
+ insertStyleHash: (payload: CspHashEntry) => void;
523
531
  /**
524
- * It set the resource for the directive `script-src` in the route being rendered.
532
+ * It sets the resource for the `script-src` family of directives in the route being rendered.
525
533
  *
526
- * @param {string} resource - The source to insert in the `script-src` directive.
534
+ * Pass a bare string to add the source to `script-src`, or an object with a `kind` to scope it:
535
+ * `"element"` → `script-src-elem`, `"attribute"` → `script-src-attr`, `"default"` → `script-src`.
536
+ *
537
+ * @param {string | { resource: string; kind?: "element" | "attribute" | "default" }} payload - The source to insert.
527
538
  *
528
539
  * ## Example
529
540
  *
530
541
  * ```js
531
542
  * ctx.insertScriptResource("https://scripts.cdn.example.com/")
543
+ * ctx.insertScriptResource({ resource: "https://scripts.cdn.example.com/", kind: "element" })
532
544
  * ```
533
545
  *
534
546
  * [Astro reference](https://docs.astro.build/en/reference/experimental-flags/csp/#cspinsertscriptresource)
535
547
  */
536
- insertScriptResource: (resource: string) => void;
548
+ insertScriptResource: (payload: CspResourceEntry) => void;
537
549
  /**
538
550
  * Insert a single script hash to the route being rendered.
539
551
  *
540
- * @param {CspHash} hash - The hash to insert in the `script-src` directive.
552
+ * Pass a bare hash to add it to `script-src`, or an object with a `kind` to scope it:
553
+ * `"element"` → `script-src-elem`, `"attribute"` → `script-src-attr`, `"default"` → `script-src`.
554
+ *
555
+ * @param {CspHash | { hash: CspHash; kind?: "element" | "attribute" | "default" }} payload - The hash to insert.
541
556
  *
542
557
  * ## Example
543
558
  *
544
559
  * ```js
545
560
  * ctx.insertScriptHash("sha256-1234567890abcdef1234567890")
561
+ * ctx.insertScriptHash({ hash: "sha256-1234567890abcdef1234567890", kind: "element" })
546
562
  * ```
547
563
  *
548
564
  * [Astro reference](https://docs.astro.build/en/reference/experimental-flags/csp/#cspinsertscripthash)
549
565
  */
550
- insertScriptHash: (hash: CspHash) => void;
566
+ insertScriptHash: (payload: CspHashEntry) => void;
551
567
  } | undefined;
552
568
  /**
553
569
  * It exposes utilities for logging messages.
@@ -210,26 +210,27 @@ export interface SSRResult {
210
210
  key: Promise<CryptoKey>;
211
211
  _metadata: SSRMetadata;
212
212
  /**
213
- * `header`:
214
- * - <meta> for static pages
215
- * - Response header for dynamic pages
216
- *
217
- * `meta`:
218
- * - <meta> for all pages
219
- *
220
- * `adapter`:
221
- * - nothing for static pages (the adapter does this)
222
- * - Response header for dynamic pages
213
+ * `cspDestination`:
214
+ * - `header`: `<meta>` for static pages, response header for dynamic pages
215
+ * - `meta`: `<meta>` for all pages
216
+ * - `adapter`: nothing for static pages (the adapter does this), response header for dynamic pages
223
217
  */
224
218
  cspDestination: NonNullable<SSRManifestCSP['cspDestination']>;
225
219
  shouldInjectCspMetaTags: boolean;
226
220
  cspAlgorithm: SSRManifestCSP['algorithm'];
221
+ directives: SSRManifestCSP['directives'];
222
+ /** @deprecated Use {@linkcode scriptDirective} instead. Holds the `default`-kind `script-src` hashes. */
227
223
  scriptHashes: SSRManifestCSP['scriptHashes'];
224
+ /** @deprecated Use {@linkcode scriptDirective} instead. Holds the `default`-kind `script-src` resources. */
228
225
  scriptResources: SSRManifestCSP['scriptResources'];
226
+ /** @deprecated Use {@linkcode styleDirective} instead. Holds the `default`-kind `style-src` hashes. */
229
227
  styleHashes: SSRManifestCSP['styleHashes'];
228
+ /** @deprecated Use {@linkcode styleDirective} instead. Holds the `default`-kind `style-src` resources. */
230
229
  styleResources: SSRManifestCSP['styleResources'];
231
- directives: SSRManifestCSP['directives'];
230
+ /** @deprecated Use {@linkcode scriptDirective}'s `strictDynamic` instead. */
232
231
  isStrictDynamic: SSRManifestCSP['isStrictDynamic'];
232
+ scriptDirective: SSRManifestCSP['scriptDirective'];
233
+ styleDirective: SSRManifestCSP['styleDirective'];
233
234
  internalFetchHeaders?: Record<string, string>;
234
235
  }
235
236
  /**
@@ -8,6 +8,7 @@ import { loadRenderer } from "../core/render/index.js";
8
8
  import { routeIsRedirect } from "../core/routing/helpers.js";
9
9
  import { findRouteToRewrite } from "../core/routing/rewrite.js";
10
10
  import { isPage } from "../core/util.js";
11
+ import { stringifyForScript } from "../runtime/server/escape.js";
11
12
  import { getComponentMetadata } from "../vite-plugin-astro-server/metadata.js";
12
13
  import { createResolve } from "../vite-plugin-astro-server/resolve.js";
13
14
  import { PAGE_SCRIPT_ID } from "../vite-plugin-scripts/index.js";
@@ -90,7 +91,7 @@ class RunnablePipeline extends Pipeline {
90
91
  debugInfo: await this.getDebugInfo(),
91
92
  placement: settings.config.devToolbar.placement
92
93
  };
93
- const children = `window.__astro_dev_toolbar__ = ${JSON.stringify(additionalMetadata)}`;
94
+ const children = `window.__astro_dev_toolbar__ = ${stringifyForScript(additionalMetadata)}`;
94
95
  scripts.add({ props: {}, children });
95
96
  }
96
97
  }
@@ -48,9 +48,10 @@ function routeGuardMiddleware(settings) {
48
48
  } catch {
49
49
  return next();
50
50
  }
51
+ const resolved = new URL("." + pathname, config.root);
51
52
  const fsInfo = {
52
- existsInPublic: fs.existsSync(new URL("." + pathname, config.publicDir)),
53
- existsInSrc: fs.existsSync(new URL("." + pathname, config.srcDir)),
53
+ existsInPublic: resolved.pathname.startsWith(config.publicDir.pathname) && fs.existsSync(resolved),
54
+ existsInSrc: resolved.pathname.startsWith(config.srcDir.pathname) && fs.existsSync(resolved),
54
55
  existsAtRootAsFile: false
55
56
  };
56
57
  if (accept.includes("text/html") && !url.includes("?") && !VITE_INTERNAL_PREFIXES.some((prefix) => pathname.startsWith(prefix))) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "astro",
3
- "version": "7.0.9",
3
+ "version": "7.1.1",
4
4
  "description": "Astro is a modern site builder with web best practices, performance, and DX front-of-mind.",
5
5
  "type": "module",
6
6
  "author": "withastro",
@@ -147,8 +147,8 @@
147
147
  "yargs-parser": "^22.0.0",
148
148
  "zod": "^4.3.6",
149
149
  "@astrojs/internal-helpers": "0.10.1",
150
- "@astrojs/markdown-satteri": "0.3.4",
151
- "@astrojs/telemetry": "3.3.3"
150
+ "@astrojs/telemetry": "3.3.3",
151
+ "@astrojs/markdown-satteri": "0.3.4"
152
152
  },
153
153
  "optionalDependencies": {
154
154
  "sharp": "^0.34.0 || ^0.35.0"