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.
- package/README.md +12 -8
- package/dist/chunk-9UNmgxP_.js +1 -0
- package/dist/constants.js +1 -1
- package/dist/declarations-D084A7_6.d.ts +39 -0
- package/dist/fontkit.d.ts +2 -2
- package/dist/fontkit.js +3 -1
- package/dist/format-available-values.js +1 -1
- package/dist/get-fallback-font-override-metrics-u23t231H.js +1 -0
- package/dist/google/fetch-css-from-google-fonts.js +1 -2
- package/dist/google/fetch-font-file.js +1 -1
- package/dist/google/fetch-resource.js +1 -1
- package/dist/google/find-font-files-in-css.js +2 -1
- package/dist/google/get-fallback-font-override-metrics.js +1 -1
- package/dist/google/get-font-axes.js +1 -3
- package/dist/google/get-google-fonts-url.js +1 -1
- package/dist/google/get-proxy-agent.js +13 -4
- package/dist/google/google-fonts-metadata.js +1 -1
- package/dist/google/index.js +1 -1
- package/dist/google/loader.d.ts +4 -38
- package/dist/google/loader.js +8 -9
- package/dist/google/retry.js +1 -3
- package/dist/google/sort-fonts-variant-values.js +1 -1
- package/dist/google/validate-google-font-function-call.js +1 -9
- package/dist/google-fonts-metadata-uXngxjL5.js +1 -0
- package/dist/index.d.ts +2 -38
- package/dist/index.js +1 -1
- package/dist/local/get-fallback-metrics-from-font-file.js +1 -1
- package/dist/local/index.js +1 -1
- package/dist/local/loader.d.ts +4 -38
- package/dist/local/loader.js +3 -5
- package/dist/local/pick-font-file-for-fallback-generation.js +1 -2
- package/dist/local/validate-local-font-function-call.js +1 -2
- package/dist/next-font-error.js +1 -1
- package/dist/types.js +1 -1
- package/dist/utils-Vxow00oE.js +1 -0
- package/google/index.d.ts +1 -1
- package/google/index.js +2 -2
- package/google/loader.d.ts +1 -1
- package/google/loader.js +1 -1
- package/local/index.d.ts +1 -1
- package/local/index.js +2 -2
- package/local/loader.d.ts +1 -1
- package/local/loader.js +1 -1
- package/manifest/index.d.ts +17 -15
- package/manifest/index.js +3 -1
- package/package.json +27 -28
- package/LICENSE +0 -11
- package/dist/cc-D_YwSRId.js +0 -1
- package/dist/constants.d.ts +0 -3
- package/dist/format-available-values.d.ts +0 -7
- package/dist/google/cc-BnfmUjCg.mjs +0 -1
- package/dist/google/fetch-css-from-google-fonts.d.ts +0 -10
- package/dist/google/fetch-font-file.d.ts +0 -7
- package/dist/google/fetch-resource.d.ts +0 -8
- package/dist/google/find-font-files-in-css.d.ts +0 -11
- package/dist/google/get-fallback-font-override-metrics.d.ts +0 -16
- package/dist/google/get-font-axes.d.ts +0 -10
- package/dist/google/get-google-fonts-url.d.ts +0 -10
- package/dist/google/get-proxy-agent.d.ts +0 -8
- package/dist/google/google-fonts-metadata.d.ts +0 -16
- package/dist/google/index.d.ts +0 -18414
- package/dist/google/retry.d.ts +0 -5
- package/dist/google/sort-fonts-variant-values.d.ts +0 -7
- package/dist/google/validate-google-font-function-call.d.ts +0 -18
- package/dist/local/fontkit-DX1wsFnK.js +0 -1
- package/dist/local/get-fallback-metrics-from-font-file.d.ts +0 -21
- package/dist/local/index.d.ts +0 -23
- package/dist/local/pick-font-file-for-fallback-generation.d.ts +0 -15
- package/dist/local/validate-local-font-function-call.d.ts +0 -26
- package/dist/next-font-error.d.ts +0 -6
- package/dist/types.d.ts +0 -15
package/dist/google/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
export{};
|
package/dist/google/loader.d.ts
CHANGED
|
@@ -1,40 +1,6 @@
|
|
|
1
|
-
|
|
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/google/loader.d.ts
|
|
38
4
|
declare const loader: FontLoader;
|
|
39
|
-
|
|
40
|
-
export { loader as default };
|
|
5
|
+
//#endregion
|
|
6
|
+
export { loader as default };
|
package/dist/google/loader.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import{
|
|
2
|
-
|
|
3
|
-
${
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
size-adjust:${A.sizeAdjust};`),t+="\n}",{...E,css:t}}throw e}};export{u as default};
|
|
1
|
+
import{n as e,t}from"../utils-Vxow00oE.js";import{nextFontError as n}from"../next-font-error.js";import{findFontFilesInCss as r}from"./find-font-files-in-css.js";import{getFontAxes as i}from"./get-font-axes.js";import{getGoogleFontsUrl as a}from"./get-google-fonts-url.js";import{validateGoogleFontFunctionCall as o}from"./validate-google-font-function-call.js";const s=n,c=t(()=>import(`./get-fallback-font-override-metrics.js`).then(e=>e.default||e)),l=t(()=>import(`./fetch-css-from-google-fonts.js`).then(e=>e.default||e)),u=t(()=>import(`./fetch-font-file.js`).then(e=>e.default||e)),d=async({functionName:t,data:n,emitFontFile:d,isDev:f,isServer:p,loaderContext:m,cache:{css:h,font:g}={}})=>{let{fontFamily:_,weights:v,styles:y,display:b,preload:x,selectedVariableAxes:S,fallback:C,adjustFontFallback:w,variable:T,subsets:E}=o(t,n[0]),D=a(_,i(_,v,y,S),b),O=w?await(async()=>{let{getFallbackFontOverrideMetrics:e}=await c();return e(_)})():void 0,k={fallbackFonts:C,weight:v.length===1&&v[0]!==`variable`?v[0]:void 0,style:y.length===1?y[0]:void 0,variable:T,adjustFontFallback:O};try{let t=h?.has(D),n=h!=null&&t?h.get(D):await(async()=>{let{fetchCSSFromGoogleFonts:e}=await l();return await e(D,_,f).catch(e=>(console.error(e),null))})();t?h?.delete(D):h?.set(D,n??null),n??s(`Failed to fetch \`${_}\` from Google Fonts.`),n=n.split(`body {`,1)[0];let i=r(n,x?E:void 0),a=await Promise.all(i.map(async({googleFontFileUrl:e,preloadFontFile:t})=>{let n=g?.has(e),r=g!=null&&n?g.get(e):await(async()=>{let{fetchFontFile:t}=await u();return await t(e,f).catch(e=>(console.error(e),null))})();n?g?.delete(e):g?.set(e,r??null),r??s(`Failed to fetch \`${_}\` from Google Fonts.`);let i=/\.(woff|woff2|eot|ttf|otf)$/.exec(e)[1];return{googleFontFileUrl:e,selfHostedFileUrl:d(r,i,t,!!O)}})),o=n;for(let{googleFontFileUrl:t,selfHostedFileUrl:n}of a)o=o.replace(new RegExp(e(t),`g`),n);return{...k,css:o}}catch(e){if(f){p&&m.error(`Failed to download \`${_}\` from Google Fonts. Using fallback font instead.\n\n${e.message}}`);let t=`@font-face {
|
|
2
|
+
font-family: '${_} Fallback';
|
|
3
|
+
src: local("${O?.fallbackFont??`Arial`}");`;return O&&(t+=`
|
|
4
|
+
ascent-override:${O.ascentOverride};
|
|
5
|
+
descent-override:${O.descentOverride};
|
|
6
|
+
line-gap-override:${O.lineGapOverride};
|
|
7
|
+
size-adjust:${O.sizeAdjust};`),t+=`
|
|
8
|
+
}`,{...k,css:t}}else throw e}};export{d as default};
|
package/dist/google/retry.js
CHANGED
|
@@ -1,3 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
Retrying ${r}/${e}...`)},minTimeout:100})}export{a as retry};
|
|
1
|
+
import{r as e,t}from"../chunk-9UNmgxP_.js";var n=e(t(((e,t)=>{(()=>{var e={632:(e,t,n)=>{var r=n(862);function i(e,t){function n(n,i){var a=t||{},o=r.operation(a);function s(e){i(e||Error(`Aborted`))}function c(e,t){if(e.bail){s(e);return}o.retry(e)?a.onRetry&&a.onRetry(e,t):i(o.mainError())}function l(t){var r;try{r=e(s,t)}catch(e){c(e,t);return}Promise.resolve(r).then(n).catch((function(e){c(e,t)}))}o.attempt(l)}return new Promise(n)}e.exports=i},862:(e,t,n)=>{e.exports=n(97)},97:(e,t,n)=>{var r=n(848);t.operation=function(e){return new r(t.timeouts(e),{forever:e&&e.forever,unref:e&&e.unref,maxRetryTime:e&&e.maxRetryTime})},t.timeouts=function(e){if(e instanceof Array)return[].concat(e);var t={retries:10,factor:2,minTimeout:1*1e3,maxTimeout:1/0,randomize:!1};for(var n in e)t[n]=e[n];if(t.minTimeout>t.maxTimeout)throw Error(`minTimeout is greater than maxTimeout`);for(var r=[],i=0;i<t.retries;i++)r.push(this.createTimeout(i,t));return e&&e.forever&&!r.length&&r.push(this.createTimeout(i,t)),r.sort((function(e,t){return e-t})),r},t.createTimeout=function(e,t){var n=t.randomize?Math.random()+1:1,r=Math.round(n*t.minTimeout*t.factor**+e);return r=Math.min(r,t.maxTimeout),r},t.wrap=function(e,n,r){if(n instanceof Array&&(r=n,n=null),!r)for(var i in r=[],e)typeof e[i]==`function`&&r.push(i);for(var a=0;a<r.length;a++){var o=r[a],s=e[o];e[o]=function(r){var i=t.operation(n),a=Array.prototype.slice.call(arguments,1),o=a.pop();a.push((function(e){i.retry(e)||(e&&(arguments[0]=i.mainError()),o.apply(this,arguments))})),i.attempt((function(){r.apply(e,a)}))}.bind(e,s),e[o].options=n}}},848:e=>{function t(e,t){typeof t==`boolean`&&(t={forever:t}),this._originalTimeouts=JSON.parse(JSON.stringify(e)),this._timeouts=e,this._options=t||{},this._maxRetryTime=t&&t.maxRetryTime||1/0,this._fn=null,this._errors=[],this._attempts=1,this._operationTimeout=null,this._operationTimeoutCb=null,this._timeout=null,this._operationStart=null,this._options.forever&&(this._cachedTimeouts=this._timeouts.slice(0))}e.exports=t,t.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts},t.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timeouts=[],this._cachedTimeouts=null},t.prototype.retry=function(e){if(this._timeout&&clearTimeout(this._timeout),!e)return!1;var t=new Date().getTime();if(e&&t-this._operationStart>=this._maxRetryTime)return this._errors.unshift(Error(`RetryOperation timeout occurred`)),!1;this._errors.push(e);var n=this._timeouts.shift();if(n===void 0)if(this._cachedTimeouts)this._errors.splice(this._errors.length-1,this._errors.length),this._timeouts=this._cachedTimeouts.slice(0),n=this._timeouts.shift();else return!1;var r=this,i=setTimeout((function(){r._attempts++,r._operationTimeoutCb&&(r._timeout=setTimeout((function(){r._operationTimeoutCb(r._attempts)}),r._operationTimeout),r._options.unref&&r._timeout.unref()),r._fn(r._attempts)}),n);return this._options.unref&&i.unref(),!0},t.prototype.attempt=function(e,t){this._fn=e,t&&(t.timeout&&(this._operationTimeout=t.timeout),t.cb&&(this._operationTimeoutCb=t.cb));var n=this;this._operationTimeoutCb&&(this._timeout=setTimeout((function(){n._operationTimeoutCb()}),n._operationTimeout)),this._operationStart=new Date().getTime(),this._fn(this._attempts)},t.prototype.try=function(e){console.log(`Using RetryOperation.try() is deprecated`),this.attempt(e)},t.prototype.start=function(e){console.log(`Using RetryOperation.start() is deprecated`),this.attempt(e)},t.prototype.start=t.prototype.try,t.prototype.errors=function(){return this._errors},t.prototype.attempts=function(){return this._attempts},t.prototype.mainError=function(){if(this._errors.length===0)return null;for(var e={},t=null,n=0,r=0;r<this._errors.length;r++){var i=this._errors[r],a=i.message,o=(e[a]||0)+1;e[a]=o,o>=n&&(t=i,n=o)}return t}}},n={};function r(t){var i=n[t];if(i!==void 0)return i.exports;var a=n[t]={exports:{}},o=!0;try{e[t](a,a.exports,r),o=!1}finally{o&&delete n[t]}return a.exports}r!==void 0&&(r.ab=__dirname+`/`),t.exports=r(632)})()}))());async function r(e,t){return await(0,n.default)(e,{retries:t,onRetry(e,n){console.error(e.message+`\n\nRetrying ${n}/${t}...`)},minTimeout:100})}export{r as retry};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
function
|
|
1
|
+
function e(e,t){if(e.includes(`,`)&&t.includes(`,`)){let[n,r]=e.split(`,`,2),[i,a]=t.split(`,`,2);return n===i?parseInt(r)-parseInt(a):parseInt(n)-parseInt(i)}return parseInt(e)-parseInt(t)}export{e as sortFontsVariantValues};
|
|
@@ -1,9 +1 @@
|
|
|
1
|
-
import{
|
|
2
|
-
Available subsets: ${s(p)}
|
|
3
|
-
|
|
4
|
-
Read more: https://nextjs.org/docs/messages/google-fonts-missing-subsets`),c.forEach(e=>{p.includes(e)||a(`Unknown subset \`${e}\` for font \`${h}\`.
|
|
5
|
-
Available subsets: ${s(p)}`)}));let $=v.weights,w=v.styles,y=o?[...new Set(Array.isArray(o)?o:[o])]:[],m=i?[...new Set(Array.isArray(i)?i:[i])]:[];return 0===y.length&&($.includes("variable")?y.push("variable"):a(`Missing weight for font \`${h}\`.
|
|
6
|
-
Available weights: ${s($)}`)),y.length>1&&y.includes("variable")&&a(`Unexpected \`variable\` in weight array for font \`${h}\`. You only need \`variable\`, it includes all available weights.`),y.forEach(e=>{$.includes(e)||a(`Unknown weight \`${e}\` for font \`${h}\`.
|
|
7
|
-
Available weights: ${s($)}`)}),0===m.length&&(1===w.length?m.push(w[0]):m.push("normal")),m.forEach(e=>{w.includes(e)||a(`Unknown style \`${e}\` for font \`${h}\`.
|
|
8
|
-
Available styles: ${s(w)}`)}),e.includes(f)||a(`Invalid display value \`${f}\` for font \`${h}\`.
|
|
9
|
-
Available display values: ${s(e)}`),b&&($.includes("variable")||a("Axes can only be defined for variable fonts."),"variable"!==y[0]&&a("Axes can only be defined for variable fonts when the weight property is nonexistent or set to `variable`.")),{fontFamily:h,weights:y,styles:m,display:f,preload:r,selectedVariableAxes:b,fallback:d,adjustFontFallback:u,variable:g,subsets:c}}export{n as validateGoogleFontFunctionCall};
|
|
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";import{t as r}from"../google-fonts-metadata-uXngxjL5.js";function i(i,a){let{weight:o,style:s,preload:c=!0,display:l=`swap`,axes:u,fallback:d,adjustFontFallback:f=!0,variable:p,subsets:m}=a||{};i===``&&n(`next-font/google has no default export`);let h=i.replace(/_/g,` `),g=r[h];g||n(`Unknown font \`${h}\``);let _=g.subsets;_.length===0?c=!1:c&&(m||n(`Preload is enabled but no subsets were specified for font \`${h}\`. Please specify subsets or disable preloading if your intended subset can't be preloaded.\nAvailable subsets: ${e(_)}\n\nRead more: https://nextjs.org/docs/messages/google-fonts-missing-subsets`),m.forEach(t=>{_.includes(t)||n(`Unknown subset \`${t}\` for font \`${h}\`.\nAvailable subsets: ${e(_)}`)}));let v=g.weights,y=g.styles,b=o?[...new Set(Array.isArray(o)?o:[o])]:[],x=s?[...new Set(Array.isArray(s)?s:[s])]:[];return b.length===0&&(v.includes(`variable`)?b.push(`variable`):n(`Missing weight for font \`${h}\`.\nAvailable weights: ${e(v)}`)),b.length>1&&b.includes(`variable`)&&n(`Unexpected \`variable\` in weight array for font \`${h}\`. You only need \`variable\`, it includes all available weights.`),b.forEach(t=>{v.includes(t)||n(`Unknown weight \`${t}\` for font \`${h}\`.\nAvailable weights: ${e(v)}`)}),x.length===0&&(y.length===1?x.push(y[0]):x.push(`normal`)),x.forEach(t=>{y.includes(t)||n(`Unknown style \`${t}\` for font \`${h}\`.\nAvailable styles: ${e(y)}`)}),t.includes(l)||n(`Invalid display value \`${l}\` for font \`${h}\`.\nAvailable display values: ${e(t)}`),u&&(v.includes(`variable`)||n(`Axes can only be defined for variable fonts.`),b[0]!==`variable`&&n("Axes can only be defined for variable fonts when the weight property is nonexistent or set to `variable`.")),{fontFamily:h,weights:b,styles:x,display:l,preload:c,selectedVariableAxes:u,fallback:d,adjustFontFallback:f,variable:p,subsets:m}}export{i as validateGoogleFontFunctionCall};
|