Skip to content

Commit 423bb7e

Browse files
committed
style: 🎨 Format
1 parent 3b257e7 commit 423bb7e

File tree

5 files changed

+124
-124
lines changed

5 files changed

+124
-124
lines changed

lib/cache.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { createStorage } from "unstorage";
2-
import fsDriver from "unstorage/drivers/fs";
1+
import { createStorage } from 'unstorage';
2+
import fsDriver from 'unstorage/drivers/fs';
33

4-
export const cacheBase = "node_modules/.cache/fontless";
4+
export const cacheBase = 'node_modules/.cache/fontless';
55

66
export const storage = createStorage({
77
driver: fsDriver({ base: cacheBase }),

lib/css/assets.ts

+20-20
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
import fsp from "node:fs/promises";
2-
import { hash } from "ohash";
3-
import { extname, join } from "pathe";
4-
import { filename } from "pathe/utils";
5-
import { hasProtocol, joinRelativeURL, joinURL } from "ufo";
6-
import type { FontFaceData } from "unifont";
7-
import { storage } from "../cache";
8-
import type { Options, RawFontFaceData } from "../types";
9-
import { formatToExtension, parseFont } from "./render";
1+
import fsp from 'node:fs/promises';
2+
import { hash } from 'ohash';
3+
import { extname, join } from 'pathe';
4+
import { filename } from 'pathe/utils';
5+
import { hasProtocol, joinRelativeURL, joinURL } from 'ufo';
6+
import type { FontFaceData } from 'unifont';
7+
import { storage } from '../cache';
8+
import type { Options, RawFontFaceData } from '../types';
9+
import { formatToExtension, parseFont } from './render';
1010

1111
const renderedFontURLs = new Map<string, string>();
1212

1313
export async function setupPublicAssetStrategy(options: Options) {
1414
const { module } = options;
1515

16-
const assetsBaseURL = module.assets.prefix || "/fonts";
16+
const assetsBaseURL = module.assets.prefix || '/fonts';
1717

1818
function normalizeFontData(
19-
faces: RawFontFaceData | FontFaceData[]
19+
faces: RawFontFaceData | FontFaceData[],
2020
): FontFaceData[] {
2121
const data: FontFaceData[] = [];
2222
for (const face of Array.isArray(faces) ? faces : [faces]) {
@@ -27,20 +27,20 @@ export async function setupPublicAssetStrategy(options: Options) {
2727
? face.unicodeRange
2828
: [face.unicodeRange],
2929
src: (Array.isArray(face.src) ? face.src : [face.src]).map((src) => {
30-
const source = typeof src === "string" ? parseFont(src) : src;
30+
const source = typeof src === 'string' ? parseFont(src) : src;
3131
if (
32-
"url" in source &&
32+
'url' in source &&
3333
hasProtocol(source.url, { acceptRelative: true })
3434
) {
35-
source.url = source.url.replace(/^\/\//, "https://");
35+
source.url = source.url.replace(/^\/\//, 'https://');
3636
const file = [
3737
// TODO: investigate why negative ignore pattern below is being ignored
38-
filename(source.url.replace(/\?.*/, "")).replace(/^-+/, ""),
38+
filename(source.url.replace(/\?.*/, '')).replace(/^-+/, ''),
3939
hash(source) +
40-
(extname(source.url) || formatToExtension(source.format) || ""),
40+
(extname(source.url) || formatToExtension(source.format) || ''),
4141
]
4242
.filter(Boolean)
43-
.join("-");
43+
.join('-');
4444

4545
renderedFontURLs.set(file, source.url);
4646
source.originalURL = source.url;
@@ -59,7 +59,7 @@ export async function setupPublicAssetStrategy(options: Options) {
5959

6060
const rollupBefore = async () => {
6161
for (const [filename, url] of renderedFontURLs) {
62-
const key = "data:fonts:" + filename;
62+
const key = 'data:fonts:' + filename;
6363
// Use storage to cache the font data between builds
6464
let res = await storage.getItemRaw(key);
6565
if (!res) {
@@ -77,12 +77,12 @@ export async function setupPublicAssetStrategy(options: Options) {
7777

7878
await fsp.writeFile(
7979
joinRelativeURL(options.fontless.baseURL, assetsBaseURL, filename),
80-
res
80+
res,
8181
);
8282
}
8383
};
8484

85-
options.hooks["rollup:before"] = rollupBefore;
85+
options.hooks['rollup:before'] = rollupBefore;
8686

8787
return {
8888
normalizeFontData,

0 commit comments

Comments
 (0)