@pyreon/zero 0.12.0 → 0.12.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/lib/font.js +29 -2
- package/lib/font.js.map +1 -1
- package/lib/index.js +26 -2
- package/lib/index.js.map +1 -1
- package/lib/types/font.d.ts.map +1 -1
- package/package.json +30 -10
- package/src/font.ts +37 -1
package/lib/types/font.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"font.d.ts","sourceRoot":"","sources":["../../src/font.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"font.d.ts","sourceRoot":"","sources":["../../src/font.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,MAAM,CAAA;AAYlC,MAAM,WAAW,UAAU;IACzB;;;;;;;OAOG;IACH,MAAM,CAAC,EAAE,eAAe,EAAE,CAAA;IAC1B,wBAAwB;IACxB,KAAK,CAAC,EAAE,SAAS,EAAE,CAAA;IACnB,qDAAqD;IACrD,OAAO,CAAC,EAAE,WAAW,CAAA;IACrB,4CAA4C;IAC5C,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,0DAA0D;IAC1D,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,8CAA8C;IAC9C,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,eAAe,CAAC,CAAA;CAC5C;AAED,iCAAiC;AACjC,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,MAAM,EAAE,CAAA;IACjB,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,QAAQ,CAAC,EAAE,KAAK,CAAA;CACjB;AAED,mCAAmC;AACnC,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,MAAM,CAAA;IACd,wDAAwD;IACxD,WAAW,EAAE,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IAC7B,MAAM,CAAC,EAAE,OA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;;;GAMG;AACH,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,MAAM,GAAG,YAAY,CAyD7D;AAED;;GAEG;AACH,wBAAgB,cAAc,CAAC,QAAQ,EAAE,YAAY,EAAE,EAAE,OAAO,GAAE,WAAoB,GAAG,MAAM,CAkB9F;AAiKD;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,UAAU,CAAC,MAAM,GAAE,UAAe,GAAG,MAAM,CA4D1D;AAiDD;;GAEG;AACH,wBAAgB,aAAa,CAAC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,MAAM,CAKtE"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pyreon/zero",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.1",
|
|
4
4
|
"description": "Pyreon Zero — zero-config full-stack framework powered by Pyreon and Vite",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Vit Bokisch",
|
|
@@ -106,6 +106,26 @@
|
|
|
106
106
|
"bun": "./src/testing.ts",
|
|
107
107
|
"import": "./lib/testing.js",
|
|
108
108
|
"types": "./lib/types/testing.d.ts"
|
|
109
|
+
},
|
|
110
|
+
"./meta": {
|
|
111
|
+
"bun": "./src/meta.tsx",
|
|
112
|
+
"import": "./lib/meta.js",
|
|
113
|
+
"types": "./lib/types/meta.d.ts"
|
|
114
|
+
},
|
|
115
|
+
"./favicon": {
|
|
116
|
+
"bun": "./src/favicon.ts",
|
|
117
|
+
"import": "./lib/favicon.js",
|
|
118
|
+
"types": "./lib/types/favicon.d.ts"
|
|
119
|
+
},
|
|
120
|
+
"./i18n": {
|
|
121
|
+
"bun": "./src/i18n-routing.ts",
|
|
122
|
+
"import": "./lib/i18n-routing.js",
|
|
123
|
+
"types": "./lib/types/i18n-routing.d.ts"
|
|
124
|
+
},
|
|
125
|
+
"./middleware": {
|
|
126
|
+
"bun": "./src/middleware.ts",
|
|
127
|
+
"import": "./lib/middleware.js",
|
|
128
|
+
"types": "./lib/types/middleware.d.ts"
|
|
109
129
|
}
|
|
110
130
|
},
|
|
111
131
|
"scripts": {
|
|
@@ -116,17 +136,17 @@
|
|
|
116
136
|
"lint": "oxlint ."
|
|
117
137
|
},
|
|
118
138
|
"dependencies": {
|
|
119
|
-
"@pyreon/core": "^0.12.
|
|
120
|
-
"@pyreon/head": "^0.12.
|
|
121
|
-
"@pyreon/meta": "^0.12.
|
|
122
|
-
"@pyreon/router": "^0.12.
|
|
123
|
-
"@pyreon/runtime-dom": "^0.12.
|
|
124
|
-
"@pyreon/runtime-server": "^0.12.
|
|
125
|
-
"@pyreon/server": "^0.12.
|
|
126
|
-
"@pyreon/vite-plugin": "^0.12.
|
|
139
|
+
"@pyreon/core": "^0.12.1",
|
|
140
|
+
"@pyreon/head": "^0.12.1",
|
|
141
|
+
"@pyreon/meta": "^0.12.1",
|
|
142
|
+
"@pyreon/router": "^0.12.1",
|
|
143
|
+
"@pyreon/runtime-dom": "^0.12.1",
|
|
144
|
+
"@pyreon/runtime-server": "^0.12.1",
|
|
145
|
+
"@pyreon/server": "^0.12.1",
|
|
146
|
+
"@pyreon/vite-plugin": "^0.12.1",
|
|
127
147
|
"vite": "^8.0.0"
|
|
128
148
|
},
|
|
129
149
|
"peerDependencies": {
|
|
130
|
-
"@pyreon/reactivity": "^0.12.
|
|
150
|
+
"@pyreon/reactivity": "^0.12.1"
|
|
131
151
|
}
|
|
132
152
|
}
|
package/src/font.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { mkdir, readFile, writeFile } from 'node:fs/promises'
|
|
2
|
+
import { join } from 'node:path'
|
|
1
3
|
import type { Plugin } from 'vite'
|
|
2
4
|
|
|
3
5
|
// ─── Font optimization ──────────────────────────────────────────────────────
|
|
@@ -313,10 +315,31 @@ function extractFontUrls(css: string): string[] {
|
|
|
313
315
|
async function selfHostFonts(
|
|
314
316
|
cssUrl: string,
|
|
315
317
|
fontsSubDir: string,
|
|
318
|
+
root: string,
|
|
316
319
|
): Promise<{
|
|
317
320
|
css: string
|
|
318
321
|
fontFiles: Array<{ name: string; content: Buffer }>
|
|
319
322
|
}> {
|
|
323
|
+
// Cache fonts between builds to avoid re-downloading (~6s penalty)
|
|
324
|
+
const cacheDir = join(root, 'node_modules', '.cache', 'zero-fonts')
|
|
325
|
+
const cacheKey = Buffer.from(cssUrl).toString('base64url')
|
|
326
|
+
const cachePath = join(cacheDir, `${cacheKey}.json`)
|
|
327
|
+
|
|
328
|
+
try {
|
|
329
|
+
const cached = JSON.parse(await readFile(cachePath, 'utf-8'))
|
|
330
|
+
if (cached.css && cached.fontFiles) {
|
|
331
|
+
return {
|
|
332
|
+
css: cached.css,
|
|
333
|
+
fontFiles: cached.fontFiles.map((f: any) => ({
|
|
334
|
+
name: f.name,
|
|
335
|
+
content: Buffer.from(f.content, 'base64'),
|
|
336
|
+
})),
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
} catch {
|
|
340
|
+
// No cache — download fresh
|
|
341
|
+
}
|
|
342
|
+
|
|
320
343
|
const css = await downloadGoogleFontsCSS(cssUrl)
|
|
321
344
|
const fontUrls = extractFontUrls(css)
|
|
322
345
|
const fontFiles: Array<{ name: string; content: Buffer }> = []
|
|
@@ -332,6 +355,17 @@ async function selfHostFonts(
|
|
|
332
355
|
rewrittenCss = rewrittenCss.replace(url, `/${fontsSubDir}/${fileName}`)
|
|
333
356
|
}
|
|
334
357
|
|
|
358
|
+
// Write cache
|
|
359
|
+
try {
|
|
360
|
+
await mkdir(cacheDir, { recursive: true })
|
|
361
|
+
await writeFile(cachePath, JSON.stringify({
|
|
362
|
+
css: rewrittenCss,
|
|
363
|
+
fontFiles: fontFiles.map((f) => ({ name: f.name, content: f.content.toString('base64') })),
|
|
364
|
+
}))
|
|
365
|
+
} catch {
|
|
366
|
+
// Cache write failure is non-fatal
|
|
367
|
+
}
|
|
368
|
+
|
|
335
369
|
return { css: rewrittenCss, fontFiles }
|
|
336
370
|
}
|
|
337
371
|
|
|
@@ -364,6 +398,7 @@ export function fontPlugin(config: FontConfig = {}): Plugin {
|
|
|
364
398
|
const googleFamilies = (config.google ?? []).map(resolveGoogleFont)
|
|
365
399
|
|
|
366
400
|
let isBuild = false
|
|
401
|
+
let root = ''
|
|
367
402
|
let selfHostedCSS = ''
|
|
368
403
|
let selfHostedFontFiles: Array<{ name: string; content: Buffer }> = []
|
|
369
404
|
|
|
@@ -372,13 +407,14 @@ export function fontPlugin(config: FontConfig = {}): Plugin {
|
|
|
372
407
|
|
|
373
408
|
configResolved(resolvedConfig) {
|
|
374
409
|
isBuild = resolvedConfig.command === 'build'
|
|
410
|
+
root = resolvedConfig.root
|
|
375
411
|
},
|
|
376
412
|
|
|
377
413
|
async buildStart() {
|
|
378
414
|
if (isBuild && shouldSelfHost && googleFamilies.length > 0) {
|
|
379
415
|
const cssUrl = googleFontsUrl(googleFamilies, display)
|
|
380
416
|
try {
|
|
381
|
-
const result = await selfHostFonts(cssUrl, 'assets/fonts')
|
|
417
|
+
const result = await selfHostFonts(cssUrl, 'assets/fonts', root)
|
|
382
418
|
selfHostedCSS = result.css
|
|
383
419
|
selfHostedFontFiles = result.fontFiles
|
|
384
420
|
} catch {
|