next-font 1.2.0 → 1.2.2-beta.0
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/LICENSE +1 -1
- package/dist/declaration-DT93DSPn.d.mts +16 -0
- package/dist/entireMetricsCollection-B27p4vNx.mjs +1 -0
- package/dist/font-data-DAoQ4nTq.mjs +1 -0
- package/dist/fontkit-DZqVarF0.mjs +3 -0
- package/dist/google/index.d.mts +19164 -0
- package/dist/google/index.mjs +1 -0
- package/dist/local.d.mts +24 -0
- package/dist/local.mjs +1 -0
- package/dist/manifest.d.mts +14 -0
- package/dist/manifest.mjs +1 -0
- package/dist/rolldown-EavF8sBr.mjs +80 -0
- package/dist/rolldown.d.mts +6 -0
- package/dist/rolldown.mjs +1 -0
- package/dist/vite.d.mts +6 -0
- package/dist/vite.mjs +1 -0
- package/package.json +44 -44
- package/README.md +0 -51
- package/dist/cc-D_YwSRId.js +0 -1
- package/dist/constants.d.ts +0 -3
- package/dist/constants.js +0 -1
- package/dist/fontkit.d.ts +0 -2
- package/dist/fontkit.js +0 -1
- package/dist/format-available-values.d.ts +0 -7
- package/dist/format-available-values.js +0 -1
- package/dist/google/cc-BnfmUjCg.mjs +0 -1
- package/dist/google/fetch-css-from-google-fonts.d.ts +0 -10
- package/dist/google/fetch-css-from-google-fonts.js +0 -2
- package/dist/google/fetch-font-file.d.ts +0 -7
- package/dist/google/fetch-font-file.js +0 -1
- package/dist/google/fetch-resource.d.ts +0 -8
- package/dist/google/fetch-resource.js +0 -1
- package/dist/google/find-font-files-in-css.d.ts +0 -11
- package/dist/google/find-font-files-in-css.js +0 -1
- package/dist/google/get-fallback-font-override-metrics.d.ts +0 -16
- package/dist/google/get-fallback-font-override-metrics.js +0 -1
- package/dist/google/get-font-axes.d.ts +0 -10
- package/dist/google/get-font-axes.js +0 -3
- package/dist/google/get-google-fonts-url.d.ts +0 -10
- package/dist/google/get-google-fonts-url.js +0 -1
- package/dist/google/get-proxy-agent.d.ts +0 -8
- package/dist/google/get-proxy-agent.js +0 -4
- package/dist/google/google-fonts-metadata.d.ts +0 -16
- package/dist/google/google-fonts-metadata.js +0 -1
- package/dist/google/index.d.ts +0 -18414
- package/dist/google/index.js +0 -1
- package/dist/google/loader.d.ts +0 -40
- package/dist/google/loader.js +0 -9
- package/dist/google/retry.d.ts +0 -5
- package/dist/google/retry.js +0 -3
- package/dist/google/sort-fonts-variant-values.d.ts +0 -7
- package/dist/google/sort-fonts-variant-values.js +0 -1
- package/dist/google/validate-google-font-function-call.d.ts +0 -18
- package/dist/google/validate-google-font-function-call.js +0 -9
- package/dist/index.d.ts +0 -38
- package/dist/index.js +0 -1
- package/dist/local/fontkit-DX1wsFnK.js +0 -1
- package/dist/local/get-fallback-metrics-from-font-file.d.ts +0 -21
- package/dist/local/get-fallback-metrics-from-font-file.js +0 -1
- package/dist/local/index.d.ts +0 -23
- package/dist/local/index.js +0 -1
- package/dist/local/loader.d.ts +0 -40
- package/dist/local/loader.js +0 -5
- package/dist/local/pick-font-file-for-fallback-generation.d.ts +0 -15
- package/dist/local/pick-font-file-for-fallback-generation.js +0 -2
- package/dist/local/validate-local-font-function-call.d.ts +0 -26
- package/dist/local/validate-local-font-function-call.js +0 -2
- package/dist/next-font-error.d.ts +0 -6
- package/dist/next-font-error.js +0 -1
- package/dist/types.d.ts +0 -15
- package/dist/types.js +0 -1
- package/google/index.d.ts +0 -1
- package/google/index.js +0 -15
- package/google/loader.d.ts +0 -1
- package/google/loader.js +0 -1
- package/google/target.css +0 -1
- package/local/index.d.ts +0 -1
- package/local/index.js +0 -15
- package/local/loader.d.ts +0 -1
- package/local/loader.js +0 -1
- package/local/target.css +0 -1
- package/manifest/index.d.ts +0 -36
- package/manifest/index.js +0 -1
package/dist/google/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
|
package/dist/google/loader.d.ts
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
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
|
-
declare const loader: FontLoader;
|
|
39
|
-
|
|
40
|
-
export { loader as default };
|
package/dist/google/loader.js
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import{nextFontError as e}from"../next-font-error.js";import{findFontFilesInCss as t}from"./find-font-files-in-css.js";import{getFontAxes as o}from"./get-font-axes.js";import{getGoogleFontsUrl as l}from"./get-google-fonts-url.js";import{validateGoogleFontFunctionCall as a}from"./validate-google-font-function-call.js";let r=e=>{let t;return()=>(t||(t=e().then(e=>(t=e,e))),t)},n=/[|\\{}()[\]^$+*?.-]/,s=/[|\\{}()[\]^$+*?.-]/g,i=e=>n.test(e)?e.replace(s,"\\$&"):e,f=r(()=>import("./get-fallback-font-override-metrics.js").then(e=>e.default||e)),c=r(()=>import("./fetch-css-from-google-fonts.js").then(e=>e.default||e)),d=r(()=>import("./fetch-font-file.js").then(e=>e.default||e)),u=async({functionName:r,data:n,emitFontFile:s,isDev:u,isServer:g,loaderContext:m,cache:{css:h,font:p}={}})=>{let{fontFamily:w,weights:$,styles:v,display:F,preload:j,selectedVariableAxes:y,fallback:b,adjustFontFallback:x,variable:k,subsets:G}=a(r,n[0]),O=o(w,$,v,y),z=l(w,O,F),A=x?await (async()=>{let{getFallbackFontOverrideMetrics:e}=await f();return e(w)})():void 0,E={fallbackFonts:b,weight:1===$.length&&"variable"!==$[0]?$[0]:void 0,style:1===v.length?v[0]:void 0,variable:k,adjustFontFallback:A};try{let o=h?.has(z),l=null!=h&&o?h.get(z):await (async()=>{let{fetchCSSFromGoogleFonts:e}=await c();return await e(z,w,u).catch(e=>(console.error(e),null))})();o?h?.delete(z):h?.set(z,l??null),null==l&&e(`Failed to fetch \`${w}\` from Google Fonts.`),l=l.split("body {",1)[0];let a=t(l,j?G:void 0),r=await Promise.all(a.map(async({googleFontFileUrl:t,preloadFontFile:o})=>{let l=p?.has(t),a=null!=p&&l?p.get(t):await (async()=>{let{fetchFontFile:e}=await d();return await e(t,u).catch(e=>(console.error(e),null))})();l?p?.delete(t):p?.set(t,a??null),null==a&&e(`Failed to fetch \`${w}\` from Google Fonts.`);let r=/\.(woff|woff2|eot|ttf|otf)$/.exec(t)[1],n=s(a,r,o,!!A);return{googleFontFileUrl:t,selfHostedFileUrl:n}})),n=l;for(let{googleFontFileUrl:e,selfHostedFileUrl:t}of r)n=n.replace(RegExp(i(e),"g"),t);return{...E,css:n}}catch(e){if(u){g&&m.error(`Failed to download \`${w}\` from Google Fonts. Using fallback font instead.
|
|
2
|
-
|
|
3
|
-
${e.message}}`);let t=`@font-face {
|
|
4
|
-
font-family: '${w} Fallback';
|
|
5
|
-
src: local("${A?.fallbackFont??"Arial"}");`;return A&&(t+=`
|
|
6
|
-
ascent-override:${A.ascentOverride};
|
|
7
|
-
descent-override:${A.descentOverride};
|
|
8
|
-
line-gap-override:${A.lineGapOverride};
|
|
9
|
-
size-adjust:${A.sizeAdjust};`),t+="\n}",{...E,css:t}}throw e}};export{u as default};
|
package/dist/google/retry.d.ts
DELETED
package/dist/google/retry.js
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import t from"node:url";import e from"node:path";var r,o,i={exports:{}};let n=t.fileURLToPath(import.meta.url),s=e.dirname(n);var u=(r=function(){if(o)return i.exports;o=1;var t={632:(t,e,r)=>{var o=r(862);t.exports=function(t,e){return new Promise(function(r,i){var n=e||{},s=o.operation(n);function u(t){i(t||Error("Aborted"))}function a(t,e){if(t.bail)return void u(t);s.retry(t)?n.onRetry&&n.onRetry(t,e):i(s.mainError())}s.attempt(function(e){var o;try{o=t(u,e)}catch(t){a(t,e);return}Promise.resolve(o).then(r).catch(function(t){a(t,e)})})})}},862:(t,e,r)=>{t.exports=r(97)},97:(t,e,r)=>{var o=r(848);e.operation=function(t){return new o(e.timeouts(t),{forever:t&&t.forever,unref:t&&t.unref,maxRetryTime:t&&t.maxRetryTime})},e.timeouts=function(t){if(t instanceof Array)return[].concat(t);var e={retries:10,factor:2,minTimeout:1e3,maxTimeout:1/0,randomize:!1};for(var r in t)e[r]=t[r];if(e.minTimeout>e.maxTimeout)throw Error("minTimeout is greater than maxTimeout");for(var o=[],i=0;i<e.retries;i++)o.push(this.createTimeout(i,e));return t&&t.forever&&!o.length&&o.push(this.createTimeout(i,e)),o.sort(function(t,e){return t-e}),o},e.createTimeout=function(t,e){var r=Math.round((e.randomize?Math.random()+1:1)*e.minTimeout*Math.pow(e.factor,t));return Math.min(r,e.maxTimeout)},e.wrap=function(t,r,o){if(r instanceof Array&&(o=r,r=null),!o)for(var i in o=[],t)"function"==typeof t[i]&&o.push(i);for(var n=0;n<o.length;n++){var s=o[n],u=t[s];t[s]=(function(o){var i=e.operation(r),n=Array.prototype.slice.call(arguments,1),s=n.pop();n.push(function(t){i.retry(t)||(t&&(arguments[0]=i.mainError()),s.apply(this,arguments))}),i.attempt(function(){o.apply(t,n)})}).bind(t,u),t[s].options=r}}},848:t=>{function e(t,e){"boolean"==typeof e&&(e={forever:e}),this._originalTimeouts=JSON.parse(JSON.stringify(t)),this._timeouts=t,this._options=e||{},this._maxRetryTime=e&&e.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))}t.exports=e,e.prototype.reset=function(){this._attempts=1,this._timeouts=this._originalTimeouts},e.prototype.stop=function(){this._timeout&&clearTimeout(this._timeout),this._timeouts=[],this._cachedTimeouts=null},e.prototype.retry=function(t){if(this._timeout&&clearTimeout(this._timeout),!t)return!1;var e=(new Date).getTime();if(t&&e-this._operationStart>=this._maxRetryTime)return this._errors.unshift(Error("RetryOperation timeout occurred")),!1;this._errors.push(t);var r=this._timeouts.shift();if(void 0===r)if(!this._cachedTimeouts)return!1;else this._errors.splice(this._errors.length-1,this._errors.length),this._timeouts=this._cachedTimeouts.slice(0),r=this._timeouts.shift();var o=this,i=setTimeout(function(){o._attempts++,o._operationTimeoutCb&&(o._timeout=setTimeout(function(){o._operationTimeoutCb(o._attempts)},o._operationTimeout),o._options.unref&&o._timeout.unref()),o._fn(o._attempts)},r);return this._options.unref&&i.unref(),!0},e.prototype.attempt=function(t,e){this._fn=t,e&&(e.timeout&&(this._operationTimeout=e.timeout),e.cb&&(this._operationTimeoutCb=e.cb));var r=this;this._operationTimeoutCb&&(this._timeout=setTimeout(function(){r._operationTimeoutCb()},r._operationTimeout)),this._operationStart=(new Date).getTime(),this._fn(this._attempts)},e.prototype.try=function(t){console.log("Using RetryOperation.try() is deprecated"),this.attempt(t)},e.prototype.start=function(t){console.log("Using RetryOperation.start() is deprecated"),this.attempt(t)},e.prototype.start=e.prototype.try,e.prototype.errors=function(){return this._errors},e.prototype.attempts=function(){return this._attempts},e.prototype.mainError=function(){if(0===this._errors.length)return null;for(var t={},e=null,r=0,o=0;o<this._errors.length;o++){var i=this._errors[o],n=i.message,s=(t[n]||0)+1;t[n]=s,s>=r&&(e=i,r=s)}return e}}},e={};function r(o){var i=e[o];if(void 0!==i)return i.exports;var n=e[o]={exports:{}},s=!0;try{t[o](n,n.exports,r),s=!1}finally{s&&delete e[o]}return n.exports}return r.ab=s+"/",i.exports=r(632),i.exports}())&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r;async function a(t,e){return await u(t,{retries:e,onRetry(t,r){console.error(t.message+`
|
|
2
|
-
|
|
3
|
-
Retrying ${r}/${e}...`)},minTimeout:100})}export{a as retry};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
function t(t,n){if(t.includes(",")&&n.includes(",")){let[e,r]=t.split(",",2),[s,a]=n.split(",",2);return e===s?parseInt(r)-parseInt(a):parseInt(e)-parseInt(s)}return parseInt(t)-parseInt(n)}export{t as sortFontsVariantValues};
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
type FontOptions = {
|
|
2
|
-
fontFamily: string;
|
|
3
|
-
weights: string[];
|
|
4
|
-
styles: string[];
|
|
5
|
-
display: string;
|
|
6
|
-
preload: boolean;
|
|
7
|
-
selectedVariableAxes?: string[];
|
|
8
|
-
fallback?: string[];
|
|
9
|
-
adjustFontFallback: boolean;
|
|
10
|
-
variable?: string;
|
|
11
|
-
subsets: string[];
|
|
12
|
-
};
|
|
13
|
-
/**
|
|
14
|
-
* Validate the data received from next-swc next-transform-font on next/font/google calls
|
|
15
|
-
*/
|
|
16
|
-
declare function validateGoogleFontFunctionCall(functionName: string, fontFunctionArgument: any): FontOptions;
|
|
17
|
-
|
|
18
|
-
export { validateGoogleFontFunctionCall };
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import{allowedDisplayValues as e}from"../constants.js";import{formatAvailableValues as s}from"../format-available-values.js";import{nextFontError as a}from"../next-font-error.js";import{googleFontsMetadata as t}from"./google-fonts-metadata.js";function n(n,l){let{weight:o,style:i,preload:r=!0,display:f="swap",axes:b,fallback:d,adjustFontFallback:u=!0,variable:g,subsets:c}=l||{};""===n&&a("next/font/google has no default export");let h=n.replace(/_/g," "),v=t[h];v||a(`Unknown font \`${h}\``);let p=v.subsets;0===p.length?r=!1:r&&(c||a(`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.
|
|
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};
|
package/dist/index.d.ts
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
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 };
|
package/dist/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
|