astro 7.0.0-beta.6 → 7.0.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.
- package/dist/cli/infra/build-time-astro-version-provider.js +1 -1
- package/dist/content/content-layer.js +3 -3
- package/dist/core/cache/handler.js +2 -2
- package/dist/core/cache/provider-utils.d.ts +38 -0
- package/dist/core/cache/provider-utils.js +43 -0
- package/dist/core/cache/runtime/cache.d.ts +1 -1
- package/dist/core/cache/runtime/cache.js +4 -4
- package/dist/core/cache/types.d.ts +1 -1
- package/dist/core/constants.js +1 -1
- package/dist/core/dev/dev.js +1 -1
- package/dist/core/logger/handlers.d.ts +7 -15
- package/dist/core/logger/handlers.js +7 -15
- package/dist/core/messages/runtime.js +1 -1
- package/dist/types/public/config.d.ts +3 -3
- package/package.json +3 -2
|
@@ -197,7 +197,7 @@ ${contentConfig.error.message}`
|
|
|
197
197
|
logger.info("Content config changed");
|
|
198
198
|
shouldClear = true;
|
|
199
199
|
}
|
|
200
|
-
if (previousAstroVersion && previousAstroVersion !== "7.0.0
|
|
200
|
+
if (previousAstroVersion && previousAstroVersion !== "7.0.0") {
|
|
201
201
|
logger.info("Astro version changed");
|
|
202
202
|
shouldClear = true;
|
|
203
203
|
}
|
|
@@ -205,8 +205,8 @@ ${contentConfig.error.message}`
|
|
|
205
205
|
logger.info("Clearing content store");
|
|
206
206
|
this.#store.clearAll();
|
|
207
207
|
}
|
|
208
|
-
if ("7.0.0
|
|
209
|
-
this.#store.metaStore().set("astro-version", "7.0.0
|
|
208
|
+
if ("7.0.0") {
|
|
209
|
+
this.#store.metaStore().set("astro-version", "7.0.0");
|
|
210
210
|
}
|
|
211
211
|
if (currentConfigDigest) {
|
|
212
212
|
this.#store.metaStore().set("content-config-digest", currentConfigDigest);
|
|
@@ -62,7 +62,7 @@ class CacheHandler {
|
|
|
62
62
|
},
|
|
63
63
|
async () => {
|
|
64
64
|
const res = await next();
|
|
65
|
-
applyCacheHeaders(cache, res);
|
|
65
|
+
applyCacheHeaders(cache, res, state.request);
|
|
66
66
|
return res;
|
|
67
67
|
}
|
|
68
68
|
);
|
|
@@ -71,7 +71,7 @@ class CacheHandler {
|
|
|
71
71
|
return response2;
|
|
72
72
|
}
|
|
73
73
|
const response = await next();
|
|
74
|
-
applyCacheHeaders(cache, response);
|
|
74
|
+
applyCacheHeaders(cache, response, state.request);
|
|
75
75
|
return response;
|
|
76
76
|
}
|
|
77
77
|
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared utilities for CDN cache providers.
|
|
3
|
+
*
|
|
4
|
+
* These helpers are used by first-party adapter cache providers
|
|
5
|
+
* (@astrojs/netlify/cache, @astrojs/vercel/cache, @astrojs/cloudflare/cache)
|
|
6
|
+
* to implement common patterns like cache-control header generation,
|
|
7
|
+
* path-based invalidation via tags, and tag normalization.
|
|
8
|
+
*/
|
|
9
|
+
import type { CacheOptions, InvalidateOptions } from './types.js';
|
|
10
|
+
/**
|
|
11
|
+
* Generate a cache tag for a given path.
|
|
12
|
+
* Used by Netlify and Vercel providers to support `invalidate({ path })`.
|
|
13
|
+
*/
|
|
14
|
+
export declare function pathTag(path: string): string;
|
|
15
|
+
/**
|
|
16
|
+
* Build cache-control directives from CacheOptions.
|
|
17
|
+
* Returns the directive string (e.g. `"public, max-age=300, stale-while-revalidate=60"`)
|
|
18
|
+
* without the header name, so each provider can use its own header
|
|
19
|
+
* (`Netlify-CDN-Cache-Control`, `Vercel-CDN-Cache-Control`, `Cloudflare-CDN-Cache-Control`).
|
|
20
|
+
*
|
|
21
|
+
* Returns `undefined` if no caching directives are present.
|
|
22
|
+
*/
|
|
23
|
+
export declare function buildCacheControlDirectives(options: CacheOptions, extraDirectives?: string[]): string | undefined;
|
|
24
|
+
/**
|
|
25
|
+
* Set common conditional headers (Last-Modified, ETag) on a Headers object.
|
|
26
|
+
*/
|
|
27
|
+
export declare function setConditionalHeaders(headers: Headers, options: CacheOptions): void;
|
|
28
|
+
/**
|
|
29
|
+
* Normalize `InvalidateOptions.tags` to a flat string array.
|
|
30
|
+
*/
|
|
31
|
+
export declare function normalizeTags(tags: string | string[] | undefined): string[];
|
|
32
|
+
/**
|
|
33
|
+
* Collect all tags needed to invalidate the given options,
|
|
34
|
+
* including the path tag if `options.path` is set.
|
|
35
|
+
* Used by providers that implement path invalidation via tags
|
|
36
|
+
* (Netlify, Vercel) rather than native path purge (Cloudflare).
|
|
37
|
+
*/
|
|
38
|
+
export declare function collectInvalidationTags(options: InvalidateOptions): string[];
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
const PATH_TAG_PREFIX = "astro-path:";
|
|
2
|
+
function pathTag(path) {
|
|
3
|
+
return `${PATH_TAG_PREFIX}${path}`;
|
|
4
|
+
}
|
|
5
|
+
function buildCacheControlDirectives(options, extraDirectives) {
|
|
6
|
+
const directives = [];
|
|
7
|
+
if (extraDirectives) {
|
|
8
|
+
directives.push(...extraDirectives);
|
|
9
|
+
}
|
|
10
|
+
if (options.maxAge !== void 0) {
|
|
11
|
+
directives.push(`max-age=${options.maxAge}`);
|
|
12
|
+
}
|
|
13
|
+
if (options.swr !== void 0) {
|
|
14
|
+
directives.push(`stale-while-revalidate=${options.swr}`);
|
|
15
|
+
}
|
|
16
|
+
return directives.length > 0 ? directives.join(", ") : void 0;
|
|
17
|
+
}
|
|
18
|
+
function setConditionalHeaders(headers, options) {
|
|
19
|
+
if (options.lastModified) {
|
|
20
|
+
headers.set("Last-Modified", options.lastModified.toUTCString());
|
|
21
|
+
}
|
|
22
|
+
if (options.etag) {
|
|
23
|
+
headers.set("ETag", options.etag);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function normalizeTags(tags) {
|
|
27
|
+
if (!tags) return [];
|
|
28
|
+
return Array.isArray(tags) ? tags : [tags];
|
|
29
|
+
}
|
|
30
|
+
function collectInvalidationTags(options) {
|
|
31
|
+
const tags = normalizeTags(options.tags);
|
|
32
|
+
if (options.path) {
|
|
33
|
+
tags.push(pathTag(options.path));
|
|
34
|
+
}
|
|
35
|
+
return tags;
|
|
36
|
+
}
|
|
37
|
+
export {
|
|
38
|
+
buildCacheControlDirectives,
|
|
39
|
+
collectInvalidationTags,
|
|
40
|
+
normalizeTags,
|
|
41
|
+
pathTag,
|
|
42
|
+
setConditionalHeaders
|
|
43
|
+
};
|
|
@@ -35,7 +35,7 @@ export declare class AstroCache implements CacheLike {
|
|
|
35
35
|
/**
|
|
36
36
|
* Apply cache headers to a response.
|
|
37
37
|
*/
|
|
38
|
-
export declare function applyCacheHeaders(cache: CacheLike, response: Response): void;
|
|
38
|
+
export declare function applyCacheHeaders(cache: CacheLike, response: Response, request: Request): void;
|
|
39
39
|
/**
|
|
40
40
|
* Check whether the cache has any active state worth acting on.
|
|
41
41
|
*/
|
|
@@ -67,11 +67,11 @@ class AstroCache {
|
|
|
67
67
|
return this.#provider.invalidate(options);
|
|
68
68
|
}
|
|
69
69
|
/** @internal */
|
|
70
|
-
[APPLY_HEADERS](response) {
|
|
70
|
+
[APPLY_HEADERS](response, request) {
|
|
71
71
|
if (this.#disabled) return;
|
|
72
72
|
const finalOptions = { ...this.#options, tags: this.tags };
|
|
73
73
|
if (finalOptions.maxAge === void 0 && !finalOptions.tags?.length) return;
|
|
74
|
-
const headers = this.#provider?.setHeaders?.(finalOptions) ?? defaultSetHeaders(finalOptions);
|
|
74
|
+
const headers = this.#provider?.setHeaders?.(finalOptions, request) ?? defaultSetHeaders(finalOptions);
|
|
75
75
|
for (const [key, value] of headers) {
|
|
76
76
|
response.headers.set(key, value);
|
|
77
77
|
}
|
|
@@ -81,9 +81,9 @@ class AstroCache {
|
|
|
81
81
|
return !this.#disabled && (this.#options.maxAge !== void 0 || this.#tags.size > 0);
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
|
-
function applyCacheHeaders(cache, response) {
|
|
84
|
+
function applyCacheHeaders(cache, response, request) {
|
|
85
85
|
if (APPLY_HEADERS in cache) {
|
|
86
|
-
cache[APPLY_HEADERS](response);
|
|
86
|
+
cache[APPLY_HEADERS](response, request);
|
|
87
87
|
}
|
|
88
88
|
}
|
|
89
89
|
function isCacheActive(cache) {
|
|
@@ -22,7 +22,7 @@ export interface InvalidateOptions {
|
|
|
22
22
|
}
|
|
23
23
|
export interface CacheProvider {
|
|
24
24
|
name: string;
|
|
25
|
-
setHeaders?(options: CacheOptions): Headers;
|
|
25
|
+
setHeaders?(options: CacheOptions, request: Request): Headers;
|
|
26
26
|
onRequest?(context: {
|
|
27
27
|
request: Request;
|
|
28
28
|
url: URL;
|
package/dist/core/constants.js
CHANGED
package/dist/core/dev/dev.js
CHANGED
|
@@ -26,7 +26,7 @@ async function dev(inlineConfig) {
|
|
|
26
26
|
await telemetry.record([]);
|
|
27
27
|
const restart = await createContainerWithAutomaticRestart({ inlineConfig, fs });
|
|
28
28
|
const logger = restart.container.logger;
|
|
29
|
-
const currentVersion = "7.0.0
|
|
29
|
+
const currentVersion = "7.0.0";
|
|
30
30
|
const isPrerelease = currentVersion.includes("-");
|
|
31
31
|
if (!isPrerelease) {
|
|
32
32
|
try {
|
|
@@ -8,9 +8,7 @@ export declare const logHandlers: {
|
|
|
8
8
|
* @example
|
|
9
9
|
* ```js
|
|
10
10
|
* export default defineConfig({
|
|
11
|
-
*
|
|
12
|
-
* logger: logHandlers.json({ pretty: true })
|
|
13
|
-
* }
|
|
11
|
+
* logger: logHandlers.json({ pretty: true })
|
|
14
12
|
* })
|
|
15
13
|
* ```
|
|
16
14
|
*/
|
|
@@ -21,9 +19,7 @@ export declare const logHandlers: {
|
|
|
21
19
|
* @example
|
|
22
20
|
* ```js
|
|
23
21
|
* export default defineConfig({
|
|
24
|
-
*
|
|
25
|
-
* logger: logHandlers.node({ pretty: true })
|
|
26
|
-
* }
|
|
22
|
+
* logger: logHandlers.node({ pretty: true })
|
|
27
23
|
* })
|
|
28
24
|
* ```
|
|
29
25
|
*/
|
|
@@ -34,9 +30,7 @@ export declare const logHandlers: {
|
|
|
34
30
|
* @example
|
|
35
31
|
* ```js
|
|
36
32
|
* export default defineConfig({
|
|
37
|
-
*
|
|
38
|
-
* logger: logHandlers.console({ pretty: true })
|
|
39
|
-
* }
|
|
33
|
+
* logger: logHandlers.console({ pretty: true })
|
|
40
34
|
* })
|
|
41
35
|
* ```
|
|
42
36
|
*/
|
|
@@ -47,12 +41,10 @@ export declare const logHandlers: {
|
|
|
47
41
|
* @example
|
|
48
42
|
* ```js
|
|
49
43
|
* export default defineConfig({
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
* )
|
|
55
|
-
* }
|
|
44
|
+
* logger: logHandlers.compose(
|
|
45
|
+
* logHandlers.console(),
|
|
46
|
+
* logHandlers.json(),
|
|
47
|
+
* )
|
|
56
48
|
* })
|
|
57
49
|
* ```
|
|
58
50
|
*/
|
|
@@ -4,9 +4,7 @@ const logHandlers = {
|
|
|
4
4
|
* @example
|
|
5
5
|
* ```js
|
|
6
6
|
* export default defineConfig({
|
|
7
|
-
*
|
|
8
|
-
* logger: logHandlers.json({ pretty: true })
|
|
9
|
-
* }
|
|
7
|
+
* logger: logHandlers.json({ pretty: true })
|
|
10
8
|
* })
|
|
11
9
|
* ```
|
|
12
10
|
*/
|
|
@@ -22,9 +20,7 @@ const logHandlers = {
|
|
|
22
20
|
* @example
|
|
23
21
|
* ```js
|
|
24
22
|
* export default defineConfig({
|
|
25
|
-
*
|
|
26
|
-
* logger: logHandlers.node({ pretty: true })
|
|
27
|
-
* }
|
|
23
|
+
* logger: logHandlers.node({ pretty: true })
|
|
28
24
|
* })
|
|
29
25
|
* ```
|
|
30
26
|
*/
|
|
@@ -40,9 +36,7 @@ const logHandlers = {
|
|
|
40
36
|
* @example
|
|
41
37
|
* ```js
|
|
42
38
|
* export default defineConfig({
|
|
43
|
-
*
|
|
44
|
-
* logger: logHandlers.console({ pretty: true })
|
|
45
|
-
* }
|
|
39
|
+
* logger: logHandlers.console({ pretty: true })
|
|
46
40
|
* })
|
|
47
41
|
* ```
|
|
48
42
|
*/
|
|
@@ -58,12 +52,10 @@ const logHandlers = {
|
|
|
58
52
|
* @example
|
|
59
53
|
* ```js
|
|
60
54
|
* export default defineConfig({
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
* )
|
|
66
|
-
* }
|
|
55
|
+
* logger: logHandlers.compose(
|
|
56
|
+
* logHandlers.console(),
|
|
57
|
+
* logHandlers.json(),
|
|
58
|
+
* )
|
|
67
59
|
* })
|
|
68
60
|
* ```
|
|
69
61
|
*/
|
|
@@ -1348,7 +1348,7 @@ export interface AstroUserConfig<TLocales extends Locales = never, TDriver exten
|
|
|
1348
1348
|
* });
|
|
1349
1349
|
* ```
|
|
1350
1350
|
*
|
|
1351
|
-
* Learn more about customizing the request pipeline in the [advanced routing guide](https://
|
|
1351
|
+
* Learn more about customizing the request pipeline in the [advanced routing guide](https://docs.astro.build/en/guides/routing/#advanced-routing).
|
|
1352
1352
|
*/
|
|
1353
1353
|
fetchFile?: string | null;
|
|
1354
1354
|
/**
|
|
@@ -1362,7 +1362,7 @@ export interface AstroUserConfig<TLocales extends Locales = never, TDriver exten
|
|
|
1362
1362
|
*
|
|
1363
1363
|
* Configures how Astro logs messages during development and production.
|
|
1364
1364
|
*
|
|
1365
|
-
* By default, Astro uses a built-in logger that outputs human-friendly logs to the console. You can customize this behavior by providing [your own logger handler](https://
|
|
1365
|
+
* By default, Astro uses a built-in logger that outputs human-friendly logs to the console. You can customize this behavior by providing [your own logger handler](https://docs.astro.build/en/reference/logger-reference/#custom-loggers) or by using one of the [built-in log handlers](https://docs.astro.build/en/reference/logger-reference/#built-in-loggers):
|
|
1366
1366
|
*
|
|
1367
1367
|
* ```js
|
|
1368
1368
|
* // astro.config.mjs
|
|
@@ -1373,7 +1373,7 @@ export interface AstroUserConfig<TLocales extends Locales = never, TDriver exten
|
|
|
1373
1373
|
* });
|
|
1374
1374
|
* ```
|
|
1375
1375
|
*
|
|
1376
|
-
* See [the logger API reference](https://
|
|
1376
|
+
* See [the logger API reference](https://docs.astro.build/en/reference/logger-reference/) for more information.
|
|
1377
1377
|
*/
|
|
1378
1378
|
logger?: LoggerHandlerConfig;
|
|
1379
1379
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "astro",
|
|
3
|
-
"version": "7.0.0
|
|
3
|
+
"version": "7.0.0",
|
|
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",
|
|
@@ -75,6 +75,7 @@
|
|
|
75
75
|
"./assets/services/sharp": "./dist/assets/services/sharp.js",
|
|
76
76
|
"./assets/services/noop": "./dist/assets/services/noop.js",
|
|
77
77
|
"./cache/memory": "./dist/core/cache/memory-provider.js",
|
|
78
|
+
"./cache/provider-utils": "./dist/core/cache/provider-utils.js",
|
|
78
79
|
"./fetch": "./dist/core/fetch/index.js",
|
|
79
80
|
"./hono": "./dist/core/hono/index.js",
|
|
80
81
|
"./assets/fonts/runtime.js": "./dist/assets/fonts/runtime.js",
|
|
@@ -166,7 +167,7 @@
|
|
|
166
167
|
"yargs-parser": "^22.0.0",
|
|
167
168
|
"zod": "^4.3.6",
|
|
168
169
|
"@astrojs/internal-helpers": "0.10.0",
|
|
169
|
-
"@astrojs/markdown-satteri": "0.3.1
|
|
170
|
+
"@astrojs/markdown-satteri": "0.3.1",
|
|
170
171
|
"@astrojs/telemetry": "3.3.2"
|
|
171
172
|
},
|
|
172
173
|
"optionalDependencies": {
|