@timber-js/app 0.2.0-alpha.149 → 0.2.0-alpha.150
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/index.d.ts.map +1 -1
- package/dist/index.js +23 -23
- package/dist/index.js.map +1 -1
- package/dist/plugins/fonts.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +9 -3
- package/src/plugins/fonts.ts +28 -48
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAU,YAAY,EAAE,MAAM,MAAM,CAAC;AA2BjD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAa1D,YAAY,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAQ1D,YAAY,EAAE,QAAQ,EAAE,aAAa,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAElG;;;;;;;;;GASG;AAEH,MAAM,WAAW,MAAM;CAAG;AAE1B;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,gBAAgB,GAAG,gBAAgB,CAEvE;AAgGD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,MAAM,CAAC,MAAM,CAAC,EAAE,gBAAgB,GAAG,YAAY,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,EAAU,YAAY,EAAE,MAAM,MAAM,CAAC;AA2BjD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAa1D,YAAY,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAQ1D,YAAY,EAAE,QAAQ,EAAE,aAAa,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAElG;;;;;;;;;GASG;AAEH,MAAM,WAAW,MAAM;CAAG;AAE1B;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,gBAAgB,GAAG,gBAAgB,CAEvE;AAgGD;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,MAAM,CAAC,MAAM,CAAC,EAAE,gBAAgB,GAAG,YAAY,EAAE,CAqVhE;AAED,eAAe,MAAM,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -5951,8 +5951,11 @@ function timberFonts(ctx) {
|
|
|
5951
5951
|
* emitted as a real CSS asset and @vitejs/plugin-rsc's `collectCss`
|
|
5952
5952
|
* walks the RSC module graph to find it.
|
|
5953
5953
|
*
|
|
5954
|
-
*
|
|
5955
|
-
*
|
|
5954
|
+
* Google `@font-face` descriptors are resolved lazily here (both
|
|
5955
|
+
* dev and production) because `load` runs after `transform` has
|
|
5956
|
+
* registered the font. `buildStart` runs before any transforms,
|
|
5957
|
+
* so fonts aren't in the pipeline yet when it fires for the first
|
|
5958
|
+
* environment.
|
|
5956
5959
|
*/
|
|
5957
5960
|
async load(id) {
|
|
5958
5961
|
if (id === "\0@timber/fonts/google") return generateGoogleVirtualModule(pipeline.fonts());
|
|
@@ -5960,13 +5963,20 @@ function timberFonts(ctx) {
|
|
|
5960
5963
|
if (pipeline.cssIdMap.matches(id)) {
|
|
5961
5964
|
const importer = pipeline.cssIdMap.importerFor(id);
|
|
5962
5965
|
if (!importer) return "";
|
|
5963
|
-
|
|
5966
|
+
for (const font of pipeline.googleFonts()) {
|
|
5964
5967
|
if (font.importer !== importer) continue;
|
|
5965
5968
|
if (pipeline.hasFaces(font.id)) continue;
|
|
5966
5969
|
try {
|
|
5967
|
-
|
|
5968
|
-
|
|
5970
|
+
if (ctx.dev) {
|
|
5971
|
+
const faces = await resolveDevFontFaces(font);
|
|
5972
|
+
pipeline.attachFaces(font.id, faces);
|
|
5973
|
+
} else {
|
|
5974
|
+
const familyCached = groupCachedFontsByFamily(await downloadAndCacheFonts([font], ctx.root)).get(font.family.toLowerCase()) ?? [];
|
|
5975
|
+
pipeline.attachCachedFiles(font.id, familyCached);
|
|
5976
|
+
pipeline.attachFaces(font.id, generateProductionFontFaces(familyCached, font.display, fontUrlPrefix(resolvedBase)));
|
|
5977
|
+
}
|
|
5969
5978
|
} catch (e) {
|
|
5979
|
+
if (!ctx.dev) throw e;
|
|
5970
5980
|
const msg = e instanceof Error ? e.message : String(e);
|
|
5971
5981
|
console.warn(`[timber-fonts] Failed to resolve Google font "${font.family}": ${msg}. Will retry on next request.`);
|
|
5972
5982
|
}
|
|
@@ -5984,27 +5994,15 @@ function timberFonts(ctx) {
|
|
|
5984
5994
|
installFontDevMiddleware(server, pipeline, resolvedBase);
|
|
5985
5995
|
},
|
|
5986
5996
|
/**
|
|
5987
|
-
*
|
|
5988
|
-
*
|
|
5989
|
-
*
|
|
5990
|
-
* resolved lazily inside `load()` when the side-effect module runs.
|
|
5997
|
+
* No-op. Font downloading and face attachment happen lazily in `load()`
|
|
5998
|
+
* because `buildStart` runs before `transform` — fonts aren't registered
|
|
5999
|
+
* in the pipeline yet when this fires for the first environment.
|
|
5991
6000
|
*
|
|
5992
6001
|
* Local font hashing is handled at registration time by the pipeline
|
|
5993
6002
|
* (when `hashOnRegister` is set) so hashed filenames are available
|
|
5994
6003
|
* before the virtual CSS `load()` hook runs.
|
|
5995
6004
|
*/
|
|
5996
|
-
|
|
5997
|
-
if (ctx.dev) return;
|
|
5998
|
-
const googleFonts = [...pipeline.googleFonts()];
|
|
5999
|
-
if (googleFonts.length === 0) return;
|
|
6000
|
-
const cachedByFamily = groupCachedFontsByFamily(await downloadAndCacheFonts(googleFonts, ctx.root));
|
|
6001
|
-
const urlPrefix = fontUrlPrefix(resolvedBase);
|
|
6002
|
-
for (const font of googleFonts) {
|
|
6003
|
-
const familyCached = cachedByFamily.get(font.family.toLowerCase()) ?? [];
|
|
6004
|
-
pipeline.attachCachedFiles(font.id, familyCached);
|
|
6005
|
-
pipeline.attachFaces(font.id, generateProductionFontFaces(familyCached, font.display, urlPrefix));
|
|
6006
|
-
}
|
|
6007
|
-
},
|
|
6005
|
+
buildStart() {},
|
|
6008
6006
|
/**
|
|
6009
6007
|
* Scan source files for font function calls and extract static config.
|
|
6010
6008
|
*
|
|
@@ -7977,9 +7975,11 @@ function timber(config) {
|
|
|
7977
7975
|
envPort: process.env.PORT,
|
|
7978
7976
|
listen: (p) => holdingRef.listen(p)
|
|
7979
7977
|
});
|
|
7980
|
-
resolvedDevPort = result.port;
|
|
7981
|
-
resolvedDevPortExplicit = result.explicit;
|
|
7982
7978
|
if (!result.bound) ctx.holdingServer = null;
|
|
7979
|
+
if (result.bound || result.explicit) {
|
|
7980
|
+
resolvedDevPort = result.port;
|
|
7981
|
+
resolvedDevPortExplicit = result.explicit;
|
|
7982
|
+
}
|
|
7983
7983
|
} else if (command === "serve" && isPreview) {
|
|
7984
7984
|
const start = resolveStartPort({
|
|
7985
7985
|
configPort: typeof userConfig.preview?.port === "number" ? userConfig.preview.port : typeof userConfig.server?.port === "number" ? userConfig.server.port : void 0,
|