astro 5.7.0 → 5.7.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/components/Font.astro +1 -1
- package/dist/assets/fonts/load.js +4 -2
- package/dist/assets/fonts/metrics.d.ts +0 -1
- package/dist/assets/fonts/metrics.js +0 -23
- package/dist/assets/fonts/utils.d.ts +4 -7
- package/dist/assets/fonts/utils.js +3 -3
- package/dist/assets/fonts/vite-plugin-fonts.js +6 -11
- package/dist/config/entrypoint.d.ts +1 -1
- package/dist/content/content-layer.js +3 -3
- package/dist/core/constants.js +1 -1
- package/dist/core/dev/dev.js +1 -1
- package/dist/core/messages.js +2 -2
- package/dist/core/session.d.ts +2 -2
- package/package.json +4 -5
package/components/Font.astro
CHANGED
|
@@ -23,10 +23,10 @@ if (!data) {
|
|
|
23
23
|
}
|
|
24
24
|
---
|
|
25
25
|
|
|
26
|
-
<style set:html={data.css}></style>
|
|
27
26
|
{
|
|
28
27
|
preload &&
|
|
29
28
|
data.preloadData.map(({ url, type }) => (
|
|
30
29
|
<link rel="preload" href={url} as="font" type={`font/${type}`} crossorigin />
|
|
31
30
|
))
|
|
32
31
|
}
|
|
32
|
+
<style set:html={data.css}></style>
|
|
@@ -81,9 +81,11 @@ async function loadFonts({
|
|
|
81
81
|
// Name has been set while extracting unifont providers from families (inside familiesToUnifontProviders)
|
|
82
82
|
[family.provider.name]
|
|
83
83
|
);
|
|
84
|
-
fonts = result.fonts.
|
|
84
|
+
fonts = result.fonts.filter(
|
|
85
|
+
(font) => typeof font.meta?.priority === "number" ? font.meta.priority === 0 : true
|
|
86
|
+
).map((font) => ({
|
|
85
87
|
...font,
|
|
86
|
-
src: font.src.map(
|
|
88
|
+
src: font.src.slice(0, 1).map(
|
|
87
89
|
(source) => "name" in source ? source : {
|
|
88
90
|
...source,
|
|
89
91
|
originalURL: source.url,
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { type Font } from '@capsizecss/unpack';
|
|
2
2
|
export type FontFaceMetrics = Pick<Font, 'ascent' | 'descent' | 'lineGap' | 'unitsPerEm' | 'xWidthAvg'>;
|
|
3
|
-
export declare function getMetricsForFamily(family: string): Promise<FontFaceMetrics | null>;
|
|
4
3
|
export declare function readMetrics(family: string, buffer: Buffer): Promise<FontFaceMetrics>;
|
|
5
4
|
export declare function generateFallbackFontFace(metrics: FontFaceMetrics, fallback: {
|
|
6
5
|
name: string;
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
import { fontFamilyToCamelCase } from "@capsizecss/metrics";
|
|
2
1
|
import { fromBuffer } from "@capsizecss/unpack";
|
|
3
|
-
const QUOTES_RE = /^["']|["']$/g;
|
|
4
|
-
const withoutQuotes = (str) => str.trim().replace(QUOTES_RE, "");
|
|
5
2
|
const metricCache = {};
|
|
6
3
|
function filterRequiredMetrics({
|
|
7
4
|
ascent,
|
|
@@ -18,25 +15,6 @@ function filterRequiredMetrics({
|
|
|
18
15
|
xWidthAvg
|
|
19
16
|
};
|
|
20
17
|
}
|
|
21
|
-
async function getMetricsForFamily(family) {
|
|
22
|
-
family = withoutQuotes(family);
|
|
23
|
-
if (family in metricCache) return metricCache[family];
|
|
24
|
-
try {
|
|
25
|
-
const name = fontFamilyToCamelCase(family);
|
|
26
|
-
const { entireMetricsCollection } = await import("@capsizecss/metrics/entireMetricsCollection");
|
|
27
|
-
const metrics = entireMetricsCollection[name];
|
|
28
|
-
if (!("descent" in metrics)) {
|
|
29
|
-
metricCache[family] = null;
|
|
30
|
-
return null;
|
|
31
|
-
}
|
|
32
|
-
const filteredMetrics = filterRequiredMetrics(metrics);
|
|
33
|
-
metricCache[family] = filteredMetrics;
|
|
34
|
-
return filteredMetrics;
|
|
35
|
-
} catch {
|
|
36
|
-
metricCache[family] = null;
|
|
37
|
-
return null;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
18
|
async function readMetrics(family, buffer) {
|
|
41
19
|
const metrics = await fromBuffer(buffer);
|
|
42
20
|
metricCache[family] = filterRequiredMetrics(metrics);
|
|
@@ -79,6 +57,5 @@ ${toCSS(declaration)}
|
|
|
79
57
|
}
|
|
80
58
|
export {
|
|
81
59
|
generateFallbackFontFace,
|
|
82
|
-
getMetricsForFamily,
|
|
83
60
|
readMetrics
|
|
84
61
|
};
|
|
@@ -7,10 +7,7 @@ import type { FontFamily, FontType, ResolvedFontFamily } from './types.js';
|
|
|
7
7
|
export declare function generateFontFace(family: string, font: unifont.FontFaceData): string;
|
|
8
8
|
export declare function extractFontType(str: string): FontType;
|
|
9
9
|
export declare function isFontType(str: string): str is FontType;
|
|
10
|
-
export declare function cache(storage: Storage, key: string, cb: () => Promise<Buffer>): Promise<
|
|
11
|
-
cached: boolean;
|
|
12
|
-
data: Buffer;
|
|
13
|
-
}>;
|
|
10
|
+
export declare function cache(storage: Storage, key: string, cb: () => Promise<Buffer>): Promise<Buffer>;
|
|
14
11
|
export interface ProxyURLOptions {
|
|
15
12
|
/**
|
|
16
13
|
* The original URL
|
|
@@ -45,10 +42,10 @@ export declare function isGenericFontFamily(str: string): str is keyof typeof DE
|
|
|
45
42
|
export type GetMetricsForFamilyFont = {
|
|
46
43
|
hash: string;
|
|
47
44
|
url: string;
|
|
48
|
-
}
|
|
45
|
+
};
|
|
49
46
|
export type GetMetricsForFamily = (name: string,
|
|
50
47
|
/** A remote url or local filepath to a font file. Used if metrics can't be resolved purely from the family name */
|
|
51
|
-
font: GetMetricsForFamilyFont) => Promise<FontFaceMetrics
|
|
48
|
+
font: GetMetricsForFamilyFont) => Promise<FontFaceMetrics>;
|
|
52
49
|
/**
|
|
53
50
|
* Generates CSS for a given family fallbacks if possible.
|
|
54
51
|
*
|
|
@@ -60,7 +57,7 @@ export declare function generateFallbacksCSS({ family, fallbacks: _fallbacks, fo
|
|
|
60
57
|
family: Pick<ResolvedFontFamily, 'name' | 'nameWithHash'>;
|
|
61
58
|
/** The family fallbacks */
|
|
62
59
|
fallbacks: Array<string>;
|
|
63
|
-
font: GetMetricsForFamilyFont;
|
|
60
|
+
font: GetMetricsForFamilyFont | null;
|
|
64
61
|
metrics: {
|
|
65
62
|
getMetricsForFamily: GetMetricsForFamily;
|
|
66
63
|
generateFontFace: typeof generateFallbackFontFace;
|
|
@@ -54,11 +54,11 @@ function isFontType(str) {
|
|
|
54
54
|
async function cache(storage, key, cb) {
|
|
55
55
|
const existing = await storage.getItemRaw(key);
|
|
56
56
|
if (existing) {
|
|
57
|
-
return
|
|
57
|
+
return existing;
|
|
58
58
|
}
|
|
59
59
|
const data = await cb();
|
|
60
60
|
await storage.setItemRaw(key, data);
|
|
61
|
-
return
|
|
61
|
+
return data;
|
|
62
62
|
}
|
|
63
63
|
function proxyURL({ value, hashString, collect }) {
|
|
64
64
|
const type = extractFontType(value);
|
|
@@ -80,7 +80,7 @@ async function generateFallbacksCSS({
|
|
|
80
80
|
return null;
|
|
81
81
|
}
|
|
82
82
|
let css = "";
|
|
83
|
-
if (!metrics) {
|
|
83
|
+
if (!fontData || !metrics) {
|
|
84
84
|
return { css, fallbacks };
|
|
85
85
|
}
|
|
86
86
|
const lastFallback = fallbacks[fallbacks.length - 1];
|
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
VIRTUAL_MODULE_ID
|
|
18
18
|
} from "./constants.js";
|
|
19
19
|
import { loadFonts } from "./load.js";
|
|
20
|
-
import { generateFallbackFontFace,
|
|
20
|
+
import { generateFallbackFontFace, readMetrics } from "./metrics.js";
|
|
21
21
|
import { cache, extractFontType, resolveFontFamily, sortObjectByKey } from "./utils.js";
|
|
22
22
|
async function fetchFont(url) {
|
|
23
23
|
try {
|
|
@@ -94,12 +94,7 @@ function fontsPlugin({ settings, sync, logger }) {
|
|
|
94
94
|
hashString: h64ToString,
|
|
95
95
|
generateFallbackFontFace,
|
|
96
96
|
getMetricsForFamily: async (name, font) => {
|
|
97
|
-
|
|
98
|
-
if (font && !metrics) {
|
|
99
|
-
const { data } = await cache(storage, font.hash, () => fetchFont(font.url));
|
|
100
|
-
metrics = await readMetrics(name, data);
|
|
101
|
-
}
|
|
102
|
-
return metrics;
|
|
97
|
+
return await readMetrics(name, await cache(storage, font.hash, () => fetchFont(font.url)));
|
|
103
98
|
},
|
|
104
99
|
log: (message) => logger.info("assets", message)
|
|
105
100
|
});
|
|
@@ -151,7 +146,7 @@ function fontsPlugin({ settings, sync, logger }) {
|
|
|
151
146
|
res.setHeader("Pragma", "no-cache");
|
|
152
147
|
res.setHeader("Expires", 0);
|
|
153
148
|
try {
|
|
154
|
-
const
|
|
149
|
+
const data = await cache(storage, hash, () => fetchFont(url));
|
|
155
150
|
res.setHeader("Content-Length", data.length);
|
|
156
151
|
res.setHeader("Content-Type", `font/${extractFontType(hash)}`);
|
|
157
152
|
res.end(data);
|
|
@@ -173,8 +168,8 @@ function fontsPlugin({ settings, sync, logger }) {
|
|
|
173
168
|
return RESOLVED_VIRTUAL_MODULE_ID;
|
|
174
169
|
}
|
|
175
170
|
},
|
|
176
|
-
load(id
|
|
177
|
-
if (id === RESOLVED_VIRTUAL_MODULE_ID
|
|
171
|
+
load(id) {
|
|
172
|
+
if (id === RESOLVED_VIRTUAL_MODULE_ID) {
|
|
178
173
|
return {
|
|
179
174
|
code: `export const fontsData = new Map(${JSON.stringify(Array.from(resolvedMap?.entries() ?? []))})`
|
|
180
175
|
};
|
|
@@ -197,7 +192,7 @@ function fontsPlugin({ settings, sync, logger }) {
|
|
|
197
192
|
logger.info("assets", "Copying fonts...");
|
|
198
193
|
await Promise.all(
|
|
199
194
|
Array.from(hashToUrlMap.entries()).map(async ([hash, url]) => {
|
|
200
|
-
const
|
|
195
|
+
const data = await cache(storage, hash, () => fetchFont(url));
|
|
201
196
|
try {
|
|
202
197
|
writeFileSync(new URL(hash, fontsDir), data);
|
|
203
198
|
} catch (cause) {
|
|
@@ -5,7 +5,7 @@ export { envField } from '../env/config.js';
|
|
|
5
5
|
export { mergeConfig } from '../core/config/merge.js';
|
|
6
6
|
export { validateConfig } from '../core/config/validate.js';
|
|
7
7
|
export { fontProviders, defineAstroFontProvider } from '../assets/fonts/providers/index.js';
|
|
8
|
-
export type { AstroFontProvider
|
|
8
|
+
export type { AstroFontProvider } from '../assets/fonts/types.js';
|
|
9
9
|
/**
|
|
10
10
|
* Return the configuration needed to use the Sharp-based image service
|
|
11
11
|
*/
|
|
@@ -153,7 +153,7 @@ ${contentConfig.error.message}`);
|
|
|
153
153
|
logger.info("Content config changed");
|
|
154
154
|
shouldClear = true;
|
|
155
155
|
}
|
|
156
|
-
if (previousAstroVersion && previousAstroVersion !== "5.7.
|
|
156
|
+
if (previousAstroVersion && previousAstroVersion !== "5.7.1") {
|
|
157
157
|
logger.info("Astro version changed");
|
|
158
158
|
shouldClear = true;
|
|
159
159
|
}
|
|
@@ -161,8 +161,8 @@ ${contentConfig.error.message}`);
|
|
|
161
161
|
logger.info("Clearing content store");
|
|
162
162
|
this.#store.clearAll();
|
|
163
163
|
}
|
|
164
|
-
if ("5.7.
|
|
165
|
-
await this.#store.metaStore().set("astro-version", "5.7.
|
|
164
|
+
if ("5.7.1") {
|
|
165
|
+
await this.#store.metaStore().set("astro-version", "5.7.1");
|
|
166
166
|
}
|
|
167
167
|
if (currentConfigDigest) {
|
|
168
168
|
await this.#store.metaStore().set("content-config-digest", currentConfigDigest);
|
package/dist/core/constants.js
CHANGED
package/dist/core/dev/dev.js
CHANGED
|
@@ -22,7 +22,7 @@ async function dev(inlineConfig) {
|
|
|
22
22
|
await telemetry.record([]);
|
|
23
23
|
const restart = await createContainerWithAutomaticRestart({ inlineConfig, fs });
|
|
24
24
|
const logger = restart.container.logger;
|
|
25
|
-
const currentVersion = "5.7.
|
|
25
|
+
const currentVersion = "5.7.1";
|
|
26
26
|
const isPrerelease = currentVersion.includes("-");
|
|
27
27
|
if (!isPrerelease) {
|
|
28
28
|
try {
|
package/dist/core/messages.js
CHANGED
|
@@ -38,7 +38,7 @@ function serverStart({
|
|
|
38
38
|
host,
|
|
39
39
|
base
|
|
40
40
|
}) {
|
|
41
|
-
const version = "5.7.
|
|
41
|
+
const version = "5.7.1";
|
|
42
42
|
const localPrefix = `${dim("\u2503")} Local `;
|
|
43
43
|
const networkPrefix = `${dim("\u2503")} Network `;
|
|
44
44
|
const emptyPrefix = " ".repeat(11);
|
|
@@ -282,7 +282,7 @@ function printHelp({
|
|
|
282
282
|
message.push(
|
|
283
283
|
linebreak(),
|
|
284
284
|
` ${bgGreen(black(` ${commandName} `))} ${green(
|
|
285
|
-
`v${"5.7.
|
|
285
|
+
`v${"5.7.1"}`
|
|
286
286
|
)} ${headline}`
|
|
287
287
|
);
|
|
288
288
|
}
|
package/dist/core/session.d.ts
CHANGED
|
@@ -7,7 +7,7 @@ export declare class AstroSession<TDriver extends SessionDriverName = any> {
|
|
|
7
7
|
/**
|
|
8
8
|
* Gets a session value. Returns `undefined` if the session or value does not exist.
|
|
9
9
|
*/
|
|
10
|
-
get<T = void, K extends string = string>(key: K): Promise<(T extends void ? (K extends keyof App.SessionData ? App.SessionData[K] : any) : T) | undefined>;
|
|
10
|
+
get<T = void, K extends string = keyof App.SessionData | (string & {})>(key: K): Promise<(T extends void ? (K extends keyof App.SessionData ? App.SessionData[K] : any) : T) | undefined>;
|
|
11
11
|
/**
|
|
12
12
|
* Checks if a session value exists.
|
|
13
13
|
*/
|
|
@@ -31,7 +31,7 @@ export declare class AstroSession<TDriver extends SessionDriverName = any> {
|
|
|
31
31
|
/**
|
|
32
32
|
* Sets a session value. The session is created if it does not exist.
|
|
33
33
|
*/
|
|
34
|
-
set<T = void, K extends string = string>(key: K, value: T extends void ? K extends keyof App.SessionData ? App.SessionData[K] : any : NoInfer<T>, { ttl }?: {
|
|
34
|
+
set<T = void, K extends string = keyof App.SessionData | (string & {})>(key: K, value: T extends void ? K extends keyof App.SessionData ? App.SessionData[K] : any : NoInfer<T>, { ttl }?: {
|
|
35
35
|
ttl?: number;
|
|
36
36
|
}): void;
|
|
37
37
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "astro",
|
|
3
|
-
"version": "5.7.
|
|
3
|
+
"version": "5.7.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",
|
|
@@ -105,7 +105,6 @@
|
|
|
105
105
|
],
|
|
106
106
|
"dependencies": {
|
|
107
107
|
"@astrojs/compiler": "^2.11.0",
|
|
108
|
-
"@capsizecss/metrics": "^3.5.0",
|
|
109
108
|
"@capsizecss/unpack": "^2.4.0",
|
|
110
109
|
"@oslojs/encoding": "^1.1.0",
|
|
111
110
|
"@rollup/pluginutils": "^5.1.4",
|
|
@@ -149,7 +148,7 @@
|
|
|
149
148
|
"tinyglobby": "^0.2.12",
|
|
150
149
|
"tsconfck": "^3.1.5",
|
|
151
150
|
"ultrahtml": "^1.6.0",
|
|
152
|
-
"unifont": "
|
|
151
|
+
"unifont": "~0.2.0",
|
|
153
152
|
"unist-util-visit": "^5.0.0",
|
|
154
153
|
"unstorage": "^1.15.0",
|
|
155
154
|
"vfile": "^6.0.3",
|
|
@@ -161,9 +160,9 @@
|
|
|
161
160
|
"zod": "^3.24.2",
|
|
162
161
|
"zod-to-json-schema": "^3.24.5",
|
|
163
162
|
"zod-to-ts": "^1.2.0",
|
|
164
|
-
"@astrojs/
|
|
163
|
+
"@astrojs/telemetry": "3.2.0",
|
|
165
164
|
"@astrojs/markdown-remark": "6.3.1",
|
|
166
|
-
"@astrojs/
|
|
165
|
+
"@astrojs/internal-helpers": "0.6.1"
|
|
167
166
|
},
|
|
168
167
|
"optionalDependencies": {
|
|
169
168
|
"sharp": "^0.33.3"
|