next-font 1.2.0 → 1.2.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.
Files changed (71) hide show
  1. package/README.md +12 -8
  2. package/dist/chunk-9UNmgxP_.js +1 -0
  3. package/dist/constants.js +1 -1
  4. package/dist/declarations-D084A7_6.d.ts +39 -0
  5. package/dist/fontkit.d.ts +2 -2
  6. package/dist/fontkit.js +3 -1
  7. package/dist/format-available-values.js +1 -1
  8. package/dist/get-fallback-font-override-metrics-u23t231H.js +1 -0
  9. package/dist/google/fetch-css-from-google-fonts.js +1 -2
  10. package/dist/google/fetch-font-file.js +1 -1
  11. package/dist/google/fetch-resource.js +1 -1
  12. package/dist/google/find-font-files-in-css.js +2 -1
  13. package/dist/google/get-fallback-font-override-metrics.js +1 -1
  14. package/dist/google/get-font-axes.js +1 -3
  15. package/dist/google/get-google-fonts-url.js +1 -1
  16. package/dist/google/get-proxy-agent.js +13 -4
  17. package/dist/google/google-fonts-metadata.js +1 -1
  18. package/dist/google/index.js +1 -1
  19. package/dist/google/loader.d.ts +4 -38
  20. package/dist/google/loader.js +8 -9
  21. package/dist/google/retry.js +1 -3
  22. package/dist/google/sort-fonts-variant-values.js +1 -1
  23. package/dist/google/validate-google-font-function-call.js +1 -9
  24. package/dist/google-fonts-metadata-uXngxjL5.js +1 -0
  25. package/dist/index.d.ts +2 -38
  26. package/dist/index.js +1 -1
  27. package/dist/local/get-fallback-metrics-from-font-file.js +1 -1
  28. package/dist/local/index.js +1 -1
  29. package/dist/local/loader.d.ts +4 -38
  30. package/dist/local/loader.js +3 -5
  31. package/dist/local/pick-font-file-for-fallback-generation.js +1 -2
  32. package/dist/local/validate-local-font-function-call.js +1 -2
  33. package/dist/next-font-error.js +1 -1
  34. package/dist/types.js +1 -1
  35. package/dist/utils-Vxow00oE.js +1 -0
  36. package/google/index.d.ts +1 -1
  37. package/google/index.js +2 -2
  38. package/google/loader.d.ts +1 -1
  39. package/google/loader.js +1 -1
  40. package/local/index.d.ts +1 -1
  41. package/local/index.js +2 -2
  42. package/local/loader.d.ts +1 -1
  43. package/local/loader.js +1 -1
  44. package/manifest/index.d.ts +17 -15
  45. package/manifest/index.js +3 -1
  46. package/package.json +27 -28
  47. package/LICENSE +0 -11
  48. package/dist/cc-D_YwSRId.js +0 -1
  49. package/dist/constants.d.ts +0 -3
  50. package/dist/format-available-values.d.ts +0 -7
  51. package/dist/google/cc-BnfmUjCg.mjs +0 -1
  52. package/dist/google/fetch-css-from-google-fonts.d.ts +0 -10
  53. package/dist/google/fetch-font-file.d.ts +0 -7
  54. package/dist/google/fetch-resource.d.ts +0 -8
  55. package/dist/google/find-font-files-in-css.d.ts +0 -11
  56. package/dist/google/get-fallback-font-override-metrics.d.ts +0 -16
  57. package/dist/google/get-font-axes.d.ts +0 -10
  58. package/dist/google/get-google-fonts-url.d.ts +0 -10
  59. package/dist/google/get-proxy-agent.d.ts +0 -8
  60. package/dist/google/google-fonts-metadata.d.ts +0 -16
  61. package/dist/google/index.d.ts +0 -18414
  62. package/dist/google/retry.d.ts +0 -5
  63. package/dist/google/sort-fonts-variant-values.d.ts +0 -7
  64. package/dist/google/validate-google-font-function-call.d.ts +0 -18
  65. package/dist/local/fontkit-DX1wsFnK.js +0 -1
  66. package/dist/local/get-fallback-metrics-from-font-file.d.ts +0 -21
  67. package/dist/local/index.d.ts +0 -23
  68. package/dist/local/pick-font-file-for-fallback-generation.d.ts +0 -15
  69. package/dist/local/validate-local-font-function-call.d.ts +0 -26
  70. package/dist/next-font-error.d.ts +0 -6
  71. package/dist/types.d.ts +0 -15
package/dist/index.d.ts CHANGED
@@ -1,38 +1,2 @@
1
- type FontLoaderOptions = Omit<{
2
- functionName: string;
3
- variableName: string;
4
- data: any[];
5
- emitFontFile: (content: Buffer, ext: string, preload: boolean, isUsingSizeAdjust?: boolean) => string;
6
- resolve: (src: string) => string;
7
- isDev: boolean;
8
- isServer: boolean;
9
- loaderContext: any;
10
- }, 'loaderContext'> & {
11
- loaderContext: {
12
- fs?: {
13
- readFile: (...args: any[]) => Promise<Buffer | Uint8Array | string>;
14
- };
15
- error: (message: string) => any;
16
- };
17
- cache?: {
18
- css?: Map<string, string | null>;
19
- font?: Map<string, string | null>;
20
- };
21
- };
22
- type FontLoader = (options: FontLoaderOptions) => Promise<{
23
- css: string;
24
- fallbackFonts?: string[];
25
- variable?: string;
26
- adjustFontFallback?: AdjustFontFallback;
27
- weight?: string;
28
- style?: string;
29
- }>;
30
- type AdjustFontFallback = {
31
- fallbackFont: string;
32
- ascentOverride?: string;
33
- descentOverride?: string;
34
- lineGapOverride?: string;
35
- sizeAdjust?: string;
36
- };
37
-
38
- export type { AdjustFontFallback, FontLoader };
1
+ import { n as FontLoader, t as AdjustFontFallback } from "./declarations-D084A7_6.js";
2
+ export { type AdjustFontFallback, type FontLoader };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
-
1
+ export{};
@@ -1 +1 @@
1
- let e={name:"Arial",azAvgWidth:934.5116279069767,unitsPerEm:2048},t={name:"Times New Roman",azAvgWidth:854.3953488372093,unitsPerEm:2048};function r(e){return Math.abs(100*e).toFixed(2)+"%"}function n(i,a="serif"){let o="serif"===a?t:e,s=function(e){try{let t="aaabcdeeeefghiijklmnnoopqrrssttuvwxyz ";if(!e.glyphsForString(t).flatMap(e=>e.codePoints).every(t=>e.hasGlyphForCodePoint(t)))return;let r=e.glyphsForString(t).map(e=>e.advanceWidth);return r.reduce((e,t)=>e+t,0)/r.length}catch{return}}(i),{ascent:l,descent:d,lineGap:c,unitsPerEm:u}=i,h=o.azAvgWidth/o.unitsPerEm,m=s?s/u/h:1;return{ascentOverride:r(l/(u*m)),descentOverride:r(d/(u*m)),lineGapOverride:r(c/(u*m)),fallbackFont:o.name,sizeAdjust:r(m)}}export{n as getFallbackMetricsFromFontFile};
1
+ const e={name:`Arial`,azAvgWidth:934.5116279069767,unitsPerEm:2048},t={name:`Times New Roman`,azAvgWidth:854.3953488372093,unitsPerEm:2048};function n(e){try{let t=`aaabcdeeeefghiijklmnnoopqrrssttuvwxyz `;if(!e.glyphsForString(t).flatMap(e=>e.codePoints).every(t=>e.hasGlyphForCodePoint(t)))return;let n=e.glyphsForString(t).map(e=>e.advanceWidth);return n.reduce((e,t)=>e+t,0)/n.length}catch{return}}function r(e){return Math.abs(e*100).toFixed(2)+`%`}function i(i,a=`serif`){let o=a===`serif`?t:e,s=n(i),{ascent:c,descent:l,lineGap:u,unitsPerEm:d}=i,f=o.azAvgWidth/o.unitsPerEm,p=s?s/d/f:1;return{ascentOverride:r(c/(d*p)),descentOverride:r(l/(d*p)),lineGapOverride:r(u/(d*p)),fallbackFont:o.name,sizeAdjust:r(p)}}export{i as getFallbackMetricsFromFontFile};
@@ -1 +1 @@
1
- function o(o){throw Error()}export{o as default};
1
+ function e(e){throw Error()}export{e as default};
@@ -1,40 +1,6 @@
1
- type FontLoaderOptions = Omit<{
2
- functionName: string;
3
- variableName: string;
4
- data: any[];
5
- emitFontFile: (content: Buffer, ext: string, preload: boolean, isUsingSizeAdjust?: boolean) => string;
6
- resolve: (src: string) => string;
7
- isDev: boolean;
8
- isServer: boolean;
9
- loaderContext: any;
10
- }, 'loaderContext'> & {
11
- loaderContext: {
12
- fs?: {
13
- readFile: (...args: any[]) => Promise<Buffer | Uint8Array | string>;
14
- };
15
- error: (message: string) => any;
16
- };
17
- cache?: {
18
- css?: Map<string, string | null>;
19
- font?: Map<string, string | null>;
20
- };
21
- };
22
- type FontLoader = (options: FontLoaderOptions) => Promise<{
23
- css: string;
24
- fallbackFonts?: string[];
25
- variable?: string;
26
- adjustFontFallback?: AdjustFontFallback;
27
- weight?: string;
28
- style?: string;
29
- }>;
30
- type AdjustFontFallback = {
31
- fallbackFont: string;
32
- ascentOverride?: string;
33
- descentOverride?: string;
34
- lineGapOverride?: string;
35
- sizeAdjust?: string;
36
- };
1
+ import { n as FontLoader } from "../declarations-D084A7_6.js";
37
2
 
3
+ //#region src/local/loader.d.ts
38
4
  declare const loader: FontLoader;
39
-
40
- export { loader as default };
5
+ //#endregion
6
+ export { loader as default };
@@ -1,5 +1,3 @@
1
- import t from"node:fs/promises";import{validateLocalFontFunctionCall as e}from"./validate-local-font-function-call.js";let a=t=>{let e;return()=>(e||(e=t().then(t=>(e=t,t))),e)},o=a(()=>import("./get-fallback-metrics-from-font-file.js").then(t=>t.default||t)),l=a(()=>import("./pick-font-file-for-fallback-generation.js").then(t=>t.default||t)),f=a(()=>import("../fontkit.js").then(t=>t.default||t)),i=async({functionName:a,variableName:i,data:n,emitFontFile:r,resolve:s,loaderContext:m})=>{let c,{src:d,display:p,fallback:h,preload:u,variable:w,adjustFontFallback:y,declarations:g,weight:j,style:$}=e(a,n[0]),k=await Promise.all(d.map(async({path:e,style:a,weight:o,ext:l,format:n})=>{let c,d=s(e),h=Buffer.from(await (m.fs??t).readFile(d)),w=r(h,l,u,void 0===y||!!y),k=await f();try{c=k(h)}catch(t){console.error(`Failed to load font file: ${d}
2
- ${t}`)}let F=g?.some(({prop:t})=>"font-family"===t),b=[...g?g.map(({prop:t,value:e})=>[t,e]):[],...F?[]:[["font-family",i]],["src",`url(${w}) format('${n}')`],["font-display",p],...o??j?[["font-weight",o??j]]:[],...a??$?[["font-style",a??$]]:[]];return{css:`@font-face {
3
- ${b.map(([t,e])=>`${t}: ${e};`).join("\n")}
4
- }
5
- `,fontMetadata:c,weight:o,style:a}}));if(!1!==y){let{pickFontFileForFallbackGeneration:t}=await l(),e=t(k);if(e.fontMetadata){let{getFallbackMetricsFromFontFile:t}=await o();c=t(e.fontMetadata,"Times New Roman"===y?"serif":"sans-serif")}}return{css:k.map(({css:t})=>t).join("\n"),fallbackFonts:h,weight:1===d.length?d[0].weight:void 0,style:1===d.length?d[0].style:void 0,variable:w,adjustFontFallback:c}};export{i as default};
1
+ import{t as e}from"../utils-Vxow00oE.js";import t from"node:fs/promises";import{validateLocalFontFunctionCall as n}from"./validate-local-font-function-call.js";const r=e(()=>import(`./get-fallback-metrics-from-font-file.js`).then(e=>e.default||e)),i=e(()=>import(`./pick-font-file-for-fallback-generation.js`).then(e=>e.default||e)),a=e(()=>import(`../fontkit.js`).then(e=>e.default||e)),o=async({functionName:e,variableName:o,data:s,emitFontFile:c,resolve:l,loaderContext:u})=>{let{src:d,display:f,fallback:p,preload:m,variable:h,adjustFontFallback:g,declarations:_,weight:v,style:y}=n(e,s[0]),b=await Promise.all(d.map(async({path:e,style:n,weight:r,ext:i,format:s})=>{let d=l(e),p=Buffer.from(await(u.fs??t).readFile(d)),h=c(p,i,m,g===void 0||!!g),b=await a(),x;try{x=b(p)}catch(e){console.error(`Failed to load font file: ${d}\n${e}`)}let S=_?.some(({prop:e})=>e===`font-family`);return{css:`@font-face {\n${[..._?_.map(({prop:e,value:t})=>[e,t]):[],...S?[]:[[`font-family`,o]],[`src`,`url(${h}) format('${s}')`],[`font-display`,f],...r??v?[[`font-weight`,r??v]]:[],...n??y?[[`font-style`,n??y]]:[]].map(([e,t])=>`${e}: ${t};`).join(`
2
+ `)}\n}\n`,fontMetadata:x,weight:r,style:n}})),x;if(g!==!1){let{pickFontFileForFallbackGeneration:e}=await i(),t=e(b);if(t.fontMetadata){let{getFallbackMetricsFromFontFile:e}=await r();x=e(t.fontMetadata,g===`Times New Roman`?`serif`:`sans-serif`)}}return{css:b.map(({css:e})=>e).join(`
3
+ `),fallbackFonts:p,weight:d.length===1?d[0].weight:void 0,style:d.length===1?d[0].style:void 0,variable:h,adjustFontFallback:x}};export{o as default};
@@ -1,2 +1 @@
1
- import{nextFontError as r}from"../next-font-error.js";function t(r){return"normal"===r?400:"bold"===r?700:Number(r)}function e(e){if(!e)return 0;let[n,a]=e.trim().split(/ +/).map(t);if((Number.isNaN(n)||Number.isNaN(a))&&r(`Invalid weight value in src array: \`${e}\`.
2
- Expected \`normal\`, \`bold\` or a number.`),!a)return n-400;if(n<=400&&a>=400)return 0;let i=n-400,o=a-400;return Math.abs(i)<Math.abs(o)?i:o}function n(r){return r.reduce((r,t)=>{if(!r)return t;let n=e(r.weight),a=e(t.weight);if(n===a&&(void 0===t.style||"normal"===t.style))return t;let i=Math.abs(n),o=Math.abs(a);return o<i||i===o&&a<n?t:r})}export{n as pickFontFileForFallbackGeneration};
1
+ import{nextFontError as e}from"../next-font-error.js";function t(e){return e===`normal`?400:e===`bold`?700:Number(e)}function n(n){if(!n)return 0;let[r,i]=n.trim().split(/ +/).map(t);if((Number.isNaN(r)||Number.isNaN(i))&&e(`Invalid weight value in src array: \`${n}\`.\nExpected \`normal\`, \`bold\` or a number.`),!i)return r-400;if(r<=400&&i>=400)return 0;let a=r-400,o=i-400;return Math.abs(a)<Math.abs(o)?a:o}function r(e){return e.reduce((e,t)=>{if(!e)return t;let r=n(e.weight),i=n(t.weight);if(r===i&&(t.style===void 0||t.style===`normal`))return t;let a=Math.abs(r),o=Math.abs(i);return o<a||a===o&&i<r?t:e})}export{r as pickFontFileForFallbackGeneration};
@@ -1,2 +1 @@
1
- import{allowedDisplayValues as t}from"../constants.js";import{formatAvailableValues as e}from"../format-available-values.js";import{nextFontError as o}from"../next-font-error.js";let r={woff:"woff",woff2:"woff2",ttf:"truetype",otf:"opentype",eot:"embedded-opentype"};function a(a,f){a&&o("next/font/local has no named exports");let{src:n,display:p="swap",weight:l,style:i,fallback:s,preload:d=!0,variable:c,adjustFontFallback:y,declarations:m}=f||{};return t.includes(p)||o(`Invalid display value \`${p}\`.
2
- Available display values: ${e(t)}`),n||o("Missing required `src` property"),Array.isArray(n)?0===n.length&&o("Unexpected empty `src` array."):n=[{path:n,weight:l,style:i}],n=n.map(t=>{let e=/\.(woff|woff2|eot|ttf|otf)$/.exec(t.path)?.[1];return e||o(`Unexpected file \`${t.path}\``),{...t,ext:e,format:r[e]}}),Array.isArray(m)&&m.forEach(t=>{["src","font-display","font-weight","font-style"].includes(t?.prop)&&o(`Invalid declaration prop: \`${t.prop}\``)}),{src:n,display:p,weight:l,style:i,fallback:s,preload:d,variable:c,adjustFontFallback:y,declarations:m}}export{a as validateLocalFontFunctionCall};
1
+ import{formatAvailableValues as e}from"../format-available-values.js";import{allowedDisplayValues as t}from"../constants.js";import{nextFontError as n}from"../next-font-error.js";const r={woff:`woff`,woff2:`woff2`,ttf:`truetype`,otf:`opentype`,eot:`embedded-opentype`};function i(i,a){i&&n(`next-font/local has no named exports`);let{src:o,display:s=`swap`,weight:c,style:l,fallback:u,preload:d=!0,variable:f,adjustFontFallback:p,declarations:m}=a||{};return t.includes(s)||n(`Invalid display value \`${s}\`.\nAvailable display values: ${e(t)}`),o||n("Missing required `src` property"),Array.isArray(o)?o.length===0&&n("Unexpected empty `src` array."):o=[{path:o,weight:c,style:l}],o=o.map(e=>{let t=/\.(woff|woff2|eot|ttf|otf)$/.exec(e.path)?.[1];return t||n(`Unexpected file \`${e.path}\``),{...e,ext:t,format:r[t]}}),Array.isArray(m)&&m.forEach(e=>{[`src`,`font-display`,`font-weight`,`font-style`].includes(e?.prop)&&n(`Invalid declaration prop: \`${e.prop}\``)}),{src:o,display:s,weight:c,style:l,fallback:u,preload:d,variable:f,adjustFontFallback:p,declarations:m}}export{i as validateLocalFontFunctionCall};
@@ -1 +1 @@
1
- function r(r){let o=Error(r);throw o.name="NextFontError",o}export{r as nextFontError};
1
+ function e(e){let t=Error(e);throw t.name=`NextFontError`,t}export{e as nextFontError};
package/dist/types.js CHANGED
@@ -1 +1 @@
1
-
1
+ export{};
@@ -0,0 +1 @@
1
+ const e=e=>{let t;return()=>(t||=e().then(e=>(t=e,e)),t)},t=/[|\\{}()[\]^$+*?.-]/,n=/[|\\{}()[\]^$+*?.-]/g,r=e=>t.test(e)?e.replace(n,`\\$&`):e;export{r as n,e as t};
package/google/index.d.ts CHANGED
@@ -1 +1 @@
1
- export * from '../dist/google'
1
+ export * from '../dist/google';
package/google/index.js CHANGED
@@ -4,7 +4,7 @@ if (semver.lt(require('next/package.json').version, '13.0.0')) {
4
4
  throw new Error('`@next/font` is only available in Next.js 13 and newer.')
5
5
  }*/
6
6
 
7
- const message = 'next-font/google failed to run or is incorrectly configured.'
7
+ const message = 'next-font/google failed to run or is incorrectly configured.';
8
8
  /*if (process.env.NODE_ENV === 'development') {
9
9
  message +=
10
10
  '\nIf you just installed `@next/font`, please try restarting `next dev` and resaving your file.'
@@ -12,4 +12,4 @@ const message = 'next-font/google failed to run or is incorrectly configured.'
12
12
 
13
13
  message += `\n\nRead more: https://nextjs.org/docs/app/building-your-application/optimizing/fonts`*/
14
14
 
15
- throw new Error(message)
15
+ throw new Error(message);
@@ -1 +1 @@
1
- export { default } from '../dist/google/loader'
1
+ export { default } from '../dist/google/loader';
package/google/loader.js CHANGED
@@ -1 +1 @@
1
- export { default } from '../dist/google/loader.js'
1
+ export { default } from '../dist/google/loader.js';
package/local/index.d.ts CHANGED
@@ -1 +1 @@
1
- export { default } from '../dist/local/index'
1
+ export { default } from '../dist/local/index';
package/local/index.js CHANGED
@@ -4,7 +4,7 @@ if (semver.lt(require('next/package.json').version, '13.0.0')) {
4
4
  throw new Error('`@next/font` is only available in Next.js 13 and newer.')
5
5
  }*/
6
6
 
7
- const message = 'next-font/local failed to run or is incorrectly configured.'
7
+ const message = 'next-font/local failed to run or is incorrectly configured.';
8
8
  /*if (process.env.NODE_ENV === 'development') {
9
9
  message +=
10
10
  '\nIf you just installed `@next/font`, please try restarting `next dev` and resaving your file.'
@@ -12,4 +12,4 @@ const message = 'next-font/local failed to run or is incorrectly configured.'
12
12
 
13
13
  message += `\n\nRead more: https://nextjs.org/docs/app/building-your-application/optimizing/fonts`*/
14
14
 
15
- throw new Error(message)
15
+ throw new Error(message);
package/local/loader.d.ts CHANGED
@@ -1 +1 @@
1
- export { default } from '../dist/local/loader'
1
+ export { default } from '../dist/local/loader';
package/local/loader.js CHANGED
@@ -1 +1 @@
1
- export { default } from '../dist/local/loader.js'
1
+ export { default } from '../dist/local/loader.js';
@@ -1,10 +1,10 @@
1
1
  export type NextFontManifest = Readonly<
2
2
  Record<string, string[]> & {
3
- isUsingSizeAdjust: boolean
3
+ isUsingSizeAdjust: boolean;
4
4
  }
5
- >
5
+ >;
6
6
 
7
- export declare const manifest: NextFontManifest
7
+ export declare const manifest: NextFontManifest;
8
8
 
9
9
  /**
10
10
  * Get hrefs for fonts to preload
@@ -13,24 +13,26 @@ export declare const manifest: NextFontManifest
13
13
  * Returns empty string[] if there are fonts but none to preload and no other fonts have been preloaded
14
14
  * Returns null if there are fonts but none to preload and at least some were previously preloaded
15
15
  */
16
- export declare const getPreloadableFonts: (filePath?: string) => string[] | null
16
+ export declare const getPreloadableFonts: (
17
+ filePath?: string,
18
+ ) => string[] | null;
17
19
 
18
20
  export declare const getFontMetadata: (filePath?: string) => {
19
21
  preconnect: {
20
- href: string
21
- type: string
22
- crossOrigin?: string
23
- nonce?: string
24
- }[]
22
+ href: string;
23
+ type: string;
24
+ crossOrigin?: string;
25
+ nonce?: string;
26
+ }[];
25
27
  preload: {
26
- href: string
27
- crossOrigin?: string
28
- nonce?: string
29
- }[]
30
- }
28
+ href: string;
29
+ crossOrigin?: string;
30
+ nonce?: string;
31
+ }[];
32
+ };
31
33
 
32
34
  export default {
33
35
  manifest,
34
36
  getPreloadableFonts,
35
37
  getFontMetadata,
36
- }
38
+ };
package/manifest/index.js CHANGED
@@ -1 +1,3 @@
1
- throw new Error('next-font/manifest failed to run or is incorrectly configured.')
1
+ throw new Error(
2
+ 'next-font/manifest failed to run or is incorrectly configured.',
3
+ );
package/package.json CHANGED
@@ -1,8 +1,13 @@
1
1
  {
2
2
  "name": "next-font",
3
+ "version": "1.2.1",
3
4
  "description": "@next/font (next/font) replacement",
4
- "version": "1.2.0",
5
5
  "license": "BSD-2-Clause",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/kijv/next-font.git",
9
+ "directory": "packages/next-font"
10
+ },
6
11
  "files": [
7
12
  "dist",
8
13
  "google",
@@ -14,52 +19,46 @@
14
19
  "types": "./dist/index.d.ts",
15
20
  "exports": {
16
21
  "./google": {
17
- "import": "./google/index.js",
18
- "types": "./google/index.d.ts"
22
+ "types": "./google/index.d.ts",
23
+ "import": "./google/index.js"
19
24
  },
20
25
  "./local": {
21
- "import": "./local/index.js",
22
- "types": "./local/index.d.ts"
26
+ "types": "./local/index.d.ts",
27
+ "import": "./local/index.js"
23
28
  },
24
29
  "./google/loader": {
25
- "import": "./google/loader.js",
26
- "types": "./google/loader.d.ts"
30
+ "types": "./google/loader.d.ts",
31
+ "import": "./google/loader.js"
27
32
  },
28
33
  "./local/loader": {
29
- "import": "./local/loader.js",
30
- "types": "./local/loader.d.ts"
34
+ "types": "./local/loader.d.ts",
35
+ "import": "./local/loader.js"
31
36
  },
32
37
  "./google/target.css": "./google/target.css",
33
38
  "./local/target.css": "./local/target.css",
34
39
  "./manifest": {
35
- "import": "./manifest/index.js",
36
- "types": "./manifest/index.d.ts"
40
+ "types": "./manifest/index.d.ts",
41
+ "import": "./manifest/index.js"
37
42
  },
38
43
  "./dist/*": {
39
- "import": "./dist/*.js",
40
- "types": "./dist/*.d.ts"
44
+ "types": "./dist/*.d.ts",
45
+ "import": "./dist/*.js"
41
46
  },
42
47
  ".": {
43
- "import": "./dist/index.js",
44
- "types": "./dist/index.d.ts"
48
+ "types": "./dist/index.d.ts",
49
+ "import": "./dist/index.js"
45
50
  }
46
51
  },
52
+ "publishConfig": {
53
+ "access": "public"
54
+ },
47
55
  "scripts": {
48
- "build": "bun run clean && turbo run build-next-font && turbo run build-src",
49
- "clean": "bun run ./scripts/clean-dist.ts",
50
- "build-next-font": "bun run ./scripts/build-next-font.ts",
51
- "build-src": "bun run ./scripts/build-src.ts"
56
+ "build": "bun run ./scripts/build"
52
57
  },
53
58
  "devDependencies": {
54
59
  "@types/fontkit": "^2.0.8",
55
- "fontkit": "^2.0.4"
56
- },
57
- "publishConfig": {
58
- "access": "public"
59
- },
60
- "repository": {
61
- "type": "git",
62
- "url": "git+https://github.com/kijv/next-font.git",
63
- "directory": "packages/next-font"
60
+ "fontkit": "^2.0.4",
61
+ "next": "^16.1.6",
62
+ "next-repo": "git://github.com/vercel/next.js#adf8c612adddd103647c90ff0f511ea35c57076e"
64
63
  }
65
64
  }
package/LICENSE DELETED
@@ -1,11 +0,0 @@
1
- BSD 2-Clause License
2
-
3
- Copyright (c) 2025, kijv
4
-
5
- Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
6
-
7
- 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
8
-
9
- 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
10
-
11
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS “AS IS” AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
@@ -1 +0,0 @@
1
- function e(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function t(e,t,r,n){var o,c=arguments.length,f=c<3?t:null===n?n=Object.getOwnPropertyDescriptor(t,r):n;if("object"==typeof Reflect&&"function"==typeof Reflect.decorate)f=Reflect.decorate(e,t,r,n);else for(var a=e.length-1;a>=0;a--)(o=e[a])&&(f=(c<3?o(f):c>3?o(t,r,f):o(t,r))||f);return c>3&&f&&Object.defineProperty(t,r,f),f}export{t as _,e as a};
@@ -1,3 +0,0 @@
1
- declare const allowedDisplayValues: string[];
2
-
3
- export { allowedDisplayValues };
@@ -1,7 +0,0 @@
1
- /**
2
- * Formats an array of values into a string that can be used error messages.
3
- * ["a", "b", "c"] => "`a`, `b`, `c`"
4
- */
5
- declare const formatAvailableValues: (values: string[]) => string;
6
-
7
- export { formatAvailableValues };
@@ -1 +0,0 @@
1
- var e,r={};function u(){return e||(e=1,r._=function(e){return e&&e.__esModule?e:{default:e}}),r}export{u as r};
@@ -1,10 +0,0 @@
1
- /**
2
- * Fetches the CSS containing the @font-face declarations from Google Fonts.
3
- * The fetch has a user agent header with a modern browser to ensure we'll get .woff2 files.
4
- *
5
- * The env variable NEXT_FONT_GOOGLE_MOCKED_RESPONSES may be set containing a path to mocked data.
6
- * It's used to define mocked data to avoid hitting the Google Fonts API during tests.
7
- */
8
- declare function fetchCSSFromGoogleFonts(url: string, fontFamily: string, isDev: boolean): Promise<string>;
9
-
10
- export { fetchCSSFromGoogleFonts };
@@ -1,7 +0,0 @@
1
- /**
2
- * Fetches a font file and returns its contents as a Buffer.
3
- * If NEXT_FONT_GOOGLE_MOCKED_RESPONSES is set, we handle mock data logic.
4
- */
5
- declare function fetchFontFile(url: string, isDev: boolean): Promise<any>;
6
-
7
- export { fetchFontFile };
@@ -1,8 +0,0 @@
1
- /**
2
- * Makes a simple GET request and returns the entire response as a Buffer.
3
- * - Throws if the response status is not 200.
4
- * - Applies a 3000 ms timeout when `isDev` is `true`.
5
- */
6
- declare function fetchResource(url: string, isDev: boolean, errorMessage?: string): Promise<Buffer>;
7
-
8
- export { fetchResource };
@@ -1,11 +0,0 @@
1
- /**
2
- * Find all font files in the CSS response and determine which files should be preloaded.
3
- * In Google Fonts responses, the @font-face's subset is above it in a comment.
4
- * Walk through the CSS from top to bottom, keeping track of the current subset.
5
- */
6
- declare function findFontFilesInCss(css: string, subsetsToPreload?: string[]): {
7
- googleFontFileUrl: string;
8
- preloadFontFile: boolean;
9
- }[];
10
-
11
- export { findFontFilesInCss };
@@ -1,16 +0,0 @@
1
- /**
2
- * Get precalculated fallback font metrics for the Google Fonts family.
3
- *
4
- * TODO:
5
- * We might want to calculate these values with fontkit instead (like in next/font/local).
6
- * That way we don't have to update the precalculated values every time a new font is added to Google Fonts.
7
- */
8
- declare function getFallbackFontOverrideMetrics(fontFamily: string): {
9
- fallbackFont: string;
10
- ascentOverride: string;
11
- descentOverride: string;
12
- lineGapOverride: string;
13
- sizeAdjust: string;
14
- } | undefined;
15
-
16
- export { getFallbackFontOverrideMetrics };
@@ -1,10 +0,0 @@
1
- /**
2
- * Validates and gets the data for each font axis required to generate the Google Fonts URL.
3
- */
4
- declare function getFontAxes(fontFamily: string, weights: string[], styles: string[], selectedVariableAxes?: string[]): {
5
- wght?: string[];
6
- ital?: string[];
7
- variableAxes?: [string, string][];
8
- };
9
-
10
- export { getFontAxes };
@@ -1,10 +0,0 @@
1
- /**
2
- * Generate the Google Fonts URL given the requested weight(s), style(s) and additional variable axes
3
- */
4
- declare function getGoogleFontsUrl(fontFamily: string, axes: {
5
- wght?: string[];
6
- ital?: string[];
7
- variableAxes?: [string, string][];
8
- }, display: string): string;
9
-
10
- export { getGoogleFontsUrl };
@@ -1,8 +0,0 @@
1
- import { Agent } from 'https';
2
-
3
- /**
4
- * If the http(s)_proxy environment variables is set, return a proxy agent.
5
- */
6
- declare function getProxyAgent(): Agent | undefined;
7
-
8
- export { getProxyAgent };
@@ -1,16 +0,0 @@
1
- type GoogleFontsMetadata = {
2
- [fontFamily: string]: {
3
- weights: string[];
4
- styles: string[];
5
- subsets: string[];
6
- axes?: Array<{
7
- tag: string;
8
- min: number;
9
- max: number;
10
- defaultValue: number;
11
- }>;
12
- };
13
- };
14
- declare const googleFontsMetadata: GoogleFontsMetadata;
15
-
16
- export { googleFontsMetadata };