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.
- package/dist/assets/fonts/infra/fs-font-file-content-resolver.js +1 -1
- package/dist/cli/dev/index.d.ts +17 -0
- package/dist/cli/dev/index.js +56 -2
- package/dist/cli/infra/build-time-astro-version-provider.js +1 -1
- package/dist/content/consts.d.ts +2 -0
- package/dist/content/consts.js +4 -0
- package/dist/content/content-layer.d.ts +0 -6
- package/dist/content/content-layer.js +4 -9
- package/dist/content/data-store-source.d.ts +36 -0
- package/dist/content/data-store-source.js +30 -0
- package/dist/content/data-store-writer.d.ts +67 -0
- package/dist/content/data-store-writer.js +94 -0
- package/dist/content/data-store.d.ts +15 -0
- package/dist/content/data-store.js +33 -3
- package/dist/content/loaders/glob.d.ts +7 -0
- package/dist/content/loaders/glob.js +2 -2
- package/dist/content/mutable-data-store.d.ts +8 -0
- package/dist/content/mutable-data-store.js +52 -15
- package/dist/content/paths.d.ts +14 -0
- package/dist/content/paths.js +11 -0
- package/dist/content/runtime.js +4 -4
- package/dist/content/vite-plugin-content-virtual-mod.js +29 -2
- package/dist/core/app/dev/pipeline.js +2 -1
- package/dist/core/app/types.d.ts +39 -5
- package/dist/core/base-pipeline.d.ts +1 -1
- package/dist/core/base-pipeline.js +6 -2
- package/dist/core/build/index.js +2 -1
- package/dist/core/build/plugins/plugin-manifest.js +23 -8
- package/dist/core/config/schemas/base.d.ts +38 -5
- package/dist/core/config/schemas/base.js +15 -8
- package/dist/core/config/schemas/relative.d.ts +73 -15
- package/dist/core/constants.js +1 -1
- package/dist/core/csp/common.d.ts +7 -7
- package/dist/core/csp/common.js +8 -9
- package/dist/core/csp/config.d.ts +45 -0
- package/dist/core/csp/config.js +44 -2
- package/dist/core/csp/runtime.d.ts +21 -1
- package/dist/core/csp/runtime.js +31 -0
- package/dist/core/dev/dev.js +9 -4
- package/dist/core/dev/restart.js +7 -1
- package/dist/core/errors/zod-error-map.js +7 -1
- package/dist/core/fetch/fetch-state.js +77 -29
- package/dist/core/i18n/domain.d.ts +1 -1
- package/dist/core/i18n/domain.js +4 -5
- package/dist/core/logger/config.d.ts +1 -1
- package/dist/core/logger/core.d.ts +4 -4
- package/dist/core/logger/impls/console.d.ts +2 -2
- package/dist/core/logger/impls/json.d.ts +2 -2
- package/dist/core/logger/impls/json.js +3 -14
- package/dist/core/logger/impls/node.d.ts +2 -2
- package/dist/core/logger/load.d.ts +2 -2
- package/dist/core/logger/load.js +19 -27
- package/dist/core/messages/runtime.d.ts +8 -0
- package/dist/core/messages/runtime.js +34 -1
- package/dist/core/render/paginate.js +21 -16
- package/dist/core/sync/index.js +23 -8
- package/dist/integrations/hooks.js +8 -0
- package/dist/manifest/serialized.js +21 -6
- package/dist/runtime/server/escape.d.ts +2 -0
- package/dist/runtime/server/escape.js +4 -0
- package/dist/runtime/server/render/csp.js +80 -19
- package/dist/runtime/server/render/server-islands.js +6 -4
- package/dist/runtime/server/transition.js +2 -2
- package/dist/types/astro.d.ts +2 -3
- package/dist/types/public/common.d.ts +13 -0
- package/dist/types/public/config.d.ts +196 -15
- package/dist/types/public/context.d.ts +27 -11
- package/dist/types/public/internal.d.ts +12 -11
- package/dist/vite-plugin-app/pipeline.js +2 -1
- package/dist/vite-plugin-astro-server/route-guard.js +3 -2
- 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,
|
|
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
|
|
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
|
-
*
|
|
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:
|
|
512
|
+
insertStyleResource: (payload: CspResourceEntry) => void;
|
|
509
513
|
/**
|
|
510
514
|
* Insert a single style hash to the route being rendered.
|
|
511
515
|
*
|
|
512
|
-
*
|
|
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: (
|
|
530
|
+
insertStyleHash: (payload: CspHashEntry) => void;
|
|
523
531
|
/**
|
|
524
|
-
* It
|
|
532
|
+
* It sets the resource for the `script-src` family of directives in the route being rendered.
|
|
525
533
|
*
|
|
526
|
-
*
|
|
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: (
|
|
548
|
+
insertScriptResource: (payload: CspResourceEntry) => void;
|
|
537
549
|
/**
|
|
538
550
|
* Insert a single script hash to the route being rendered.
|
|
539
551
|
*
|
|
540
|
-
*
|
|
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: (
|
|
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
|
-
* `
|
|
214
|
-
* -
|
|
215
|
-
* -
|
|
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
|
-
|
|
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__ = ${
|
|
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:
|
|
53
|
-
existsInSrc:
|
|
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.
|
|
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/
|
|
151
|
-
"@astrojs/
|
|
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"
|