UNPKG

2.34 kBSource Map (JSON)View Raw
1{"version":3,"file":"ExpoFontLoader.web.js","sourceRoot":"","sources":["../src/ExpoFontLoader.web.ts"],"names":[],"mappings":"AAAA,OAAO,YAAY,MAAM,kBAAkB,CAAC;AAE5C,eAAe;IACb,IAAI,IAAI;QACN,OAAO,gBAAgB,CAAC;IAC1B,CAAC;IAED,SAAS,CAAC,cAAsB,EAAE,QAAgB;QAChD,MAAM,cAAc,GAAG,QAAQ,CAAC,IAAI,IAAI,OAAO,QAAQ,CAAC,IAAI,CAAC,WAAW,KAAK,UAAU,CAAC;QACxF,IAAI,CAAC,cAAc,EAAE;YACnB,MAAM,IAAI,KAAK,CAAC,0EAA0E,CAAC,CAAC;SAC7F;QAED,MAAM,KAAK,GAAG,eAAe,CAAC,cAAc,EAAE,QAAQ,CAAC,CAAC;QACxD,QAAQ,CAAC,IAAK,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;QAClC,OAAO,IAAI,YAAY,CAAC,cAAc,CAAC,CAAC,IAAI,EAAE,CAAC;IACjD,CAAC;CACF,CAAC;AAEF,SAAS,eAAe,CAAC,UAAkB,EAAE,QAAgB;IAC3D,MAAM,SAAS,GAAG;mBACD,UAAU;eACd,QAAQ;IACnB,CAAC;IAEH,MAAM,YAAY,GAAG,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;IACrD,YAAY,CAAC,IAAI,GAAG,UAAU,CAAC;IAC/B,+FAA+F;IAC/F,wDAAwD;IACxD,IAAI,YAAY,CAAC,UAAU,EAAE;QAC3B,aAAa;QACb,YAAY,CAAC,UAAU,CAAC,OAAO,GAAG,SAAS,CAAC;KAC7C;SAAM;QACL,MAAM,QAAQ,GAAG,QAAQ,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC;QACpD,YAAY,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;KACpC;IACD,OAAO,YAAY,CAAC;AACtB,CAAC","sourcesContent":["import FontObserver from 'fontfaceobserver';\n\nexport default {\n get name(): string {\n return 'ExpoFontLoader';\n },\n\n loadAsync(fontFamilyName: string, resource: string): Promise<void> {\n const canInjectStyle = document.head && typeof document.head.appendChild === 'function';\n if (!canInjectStyle) {\n throw new Error('E_FONT_CREATION_FAILED : document element cannot support injecting fonts');\n }\n\n const style = _createWebStyle(fontFamilyName, resource);\n document.head!.appendChild(style);\n return new FontObserver(fontFamilyName).load();\n },\n};\n\nfunction _createWebStyle(fontFamily: string, resource: string): HTMLStyleElement {\n const fontStyle = `@font-face {\n font-family: ${fontFamily};\n src: url(${resource});\n }`;\n\n const styleElement = document.createElement('style');\n styleElement.type = 'text/css';\n // @ts-ignore: TypeScript does not define HTMLStyleElement::styleSheet. This is just for IE and\n // possibly can be removed if it's unnecessary on IE 11.\n if (styleElement.styleSheet) {\n // @ts-ignore\n styleElement.styleSheet.cssText = fontStyle;\n } else {\n const textNode = document.createTextNode(fontStyle);\n styleElement.appendChild(textNode);\n }\n return styleElement;\n}\n"]}
\No newline at end of file