UNPKG

next

Version:

The React Framework

5 lines 1.18 kB
"use strict";exports.__esModule=true;exports.getFontDefinitionFromNetwork=getFontDefinitionFromNetwork;exports.getFontDefinitionFromManifest=getFontDefinitionFromManifest;const https=require('https');const CHROME_UA='Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.61 Safari/537.36';const IE_UA='Mozilla/5.0 (Windows NT 10.0; Trident/7.0; rv:11.0) like Gecko';function getFontForUA(url,UA){return new Promise(resolve=>{let rawData='';https.get(url,{headers:{'user-agent':UA}},res=>{res.on('data',chunk=>{rawData+=chunk;});res.on('end',()=>{resolve(rawData.toString('utf8'));});});});}async function getFontDefinitionFromNetwork(url){let result='';/** * The order of IE -> Chrome is important, other wise chrome starts loading woff1. * CSS cascading 🤷‍♂️. */result+=await getFontForUA(url,IE_UA);result+=await getFontForUA(url,CHROME_UA);return result;}function getFontDefinitionFromManifest(url,manifest){var _manifest$find;return((_manifest$find=manifest.find(font=>{if(font&&font.url===url){return true;}return false;}))==null?void 0:_manifest$find.content)||'';} //# sourceMappingURL=font-utils.js.map