expo-font 55.0.2 → 55.0.3

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 (48) hide show
  1. package/CHANGELOG.md +5 -0
  2. package/android/build.gradle +2 -2
  3. package/build/ExpoFontLoader.web.js +2 -4
  4. package/build/ExpoFontLoader.web.js.map +1 -1
  5. package/build/Font.types.d.ts +5 -0
  6. package/build/Font.types.d.ts.map +1 -1
  7. package/build/Font.types.js.map +1 -1
  8. package/build/FontLoader.web.d.ts.map +1 -1
  9. package/build/FontLoader.web.js +8 -0
  10. package/build/FontLoader.web.js.map +1 -1
  11. package/expo-module.config.json +1 -1
  12. package/local-maven-repo/host/exp/exponent/expo.modules.font/{55.0.2/expo.modules.font-55.0.2.module → 55.0.3/expo.modules.font-55.0.3.module} +7 -7
  13. package/local-maven-repo/host/exp/exponent/expo.modules.font/55.0.3/expo.modules.font-55.0.3.module.md5 +1 -0
  14. package/local-maven-repo/host/exp/exponent/expo.modules.font/55.0.3/expo.modules.font-55.0.3.module.sha1 +1 -0
  15. package/local-maven-repo/host/exp/exponent/expo.modules.font/55.0.3/expo.modules.font-55.0.3.module.sha256 +1 -0
  16. package/local-maven-repo/host/exp/exponent/expo.modules.font/55.0.3/expo.modules.font-55.0.3.module.sha512 +1 -0
  17. package/local-maven-repo/host/exp/exponent/expo.modules.font/{55.0.2/expo.modules.font-55.0.2.pom → 55.0.3/expo.modules.font-55.0.3.pom} +1 -1
  18. package/local-maven-repo/host/exp/exponent/expo.modules.font/55.0.3/expo.modules.font-55.0.3.pom.md5 +1 -0
  19. package/local-maven-repo/host/exp/exponent/expo.modules.font/55.0.3/expo.modules.font-55.0.3.pom.sha1 +1 -0
  20. package/local-maven-repo/host/exp/exponent/expo.modules.font/55.0.3/expo.modules.font-55.0.3.pom.sha256 +1 -0
  21. package/local-maven-repo/host/exp/exponent/expo.modules.font/55.0.3/expo.modules.font-55.0.3.pom.sha512 +1 -0
  22. package/local-maven-repo/host/exp/exponent/expo.modules.font/maven-metadata.xml +4 -4
  23. package/local-maven-repo/host/exp/exponent/expo.modules.font/maven-metadata.xml.md5 +1 -1
  24. package/local-maven-repo/host/exp/exponent/expo.modules.font/maven-metadata.xml.sha1 +1 -1
  25. package/local-maven-repo/host/exp/exponent/expo.modules.font/maven-metadata.xml.sha256 +1 -1
  26. package/local-maven-repo/host/exp/exponent/expo.modules.font/maven-metadata.xml.sha512 +1 -1
  27. package/package.json +2 -2
  28. package/src/ExpoFontLoader.web.ts +2 -4
  29. package/src/Font.types.ts +5 -0
  30. package/src/FontLoader.web.ts +10 -1
  31. package/local-maven-repo/host/exp/exponent/expo.modules.font/55.0.2/expo.modules.font-55.0.2.module.md5 +0 -1
  32. package/local-maven-repo/host/exp/exponent/expo.modules.font/55.0.2/expo.modules.font-55.0.2.module.sha1 +0 -1
  33. package/local-maven-repo/host/exp/exponent/expo.modules.font/55.0.2/expo.modules.font-55.0.2.module.sha256 +0 -1
  34. package/local-maven-repo/host/exp/exponent/expo.modules.font/55.0.2/expo.modules.font-55.0.2.module.sha512 +0 -1
  35. package/local-maven-repo/host/exp/exponent/expo.modules.font/55.0.2/expo.modules.font-55.0.2.pom.md5 +0 -1
  36. package/local-maven-repo/host/exp/exponent/expo.modules.font/55.0.2/expo.modules.font-55.0.2.pom.sha1 +0 -1
  37. package/local-maven-repo/host/exp/exponent/expo.modules.font/55.0.2/expo.modules.font-55.0.2.pom.sha256 +0 -1
  38. package/local-maven-repo/host/exp/exponent/expo.modules.font/55.0.2/expo.modules.font-55.0.2.pom.sha512 +0 -1
  39. /package/local-maven-repo/host/exp/exponent/expo.modules.font/{55.0.2/expo.modules.font-55.0.2-sources.jar → 55.0.3/expo.modules.font-55.0.3-sources.jar} +0 -0
  40. /package/local-maven-repo/host/exp/exponent/expo.modules.font/{55.0.2/expo.modules.font-55.0.2-sources.jar.md5 → 55.0.3/expo.modules.font-55.0.3-sources.jar.md5} +0 -0
  41. /package/local-maven-repo/host/exp/exponent/expo.modules.font/{55.0.2/expo.modules.font-55.0.2-sources.jar.sha1 → 55.0.3/expo.modules.font-55.0.3-sources.jar.sha1} +0 -0
  42. /package/local-maven-repo/host/exp/exponent/expo.modules.font/{55.0.2/expo.modules.font-55.0.2-sources.jar.sha256 → 55.0.3/expo.modules.font-55.0.3-sources.jar.sha256} +0 -0
  43. /package/local-maven-repo/host/exp/exponent/expo.modules.font/{55.0.2/expo.modules.font-55.0.2-sources.jar.sha512 → 55.0.3/expo.modules.font-55.0.3-sources.jar.sha512} +0 -0
  44. /package/local-maven-repo/host/exp/exponent/expo.modules.font/{55.0.2/expo.modules.font-55.0.2.aar → 55.0.3/expo.modules.font-55.0.3.aar} +0 -0
  45. /package/local-maven-repo/host/exp/exponent/expo.modules.font/{55.0.2/expo.modules.font-55.0.2.aar.md5 → 55.0.3/expo.modules.font-55.0.3.aar.md5} +0 -0
  46. /package/local-maven-repo/host/exp/exponent/expo.modules.font/{55.0.2/expo.modules.font-55.0.2.aar.sha1 → 55.0.3/expo.modules.font-55.0.3.aar.sha1} +0 -0
  47. /package/local-maven-repo/host/exp/exponent/expo.modules.font/{55.0.2/expo.modules.font-55.0.2.aar.sha256 → 55.0.3/expo.modules.font-55.0.3.aar.sha256} +0 -0
  48. /package/local-maven-repo/host/exp/exponent/expo.modules.font/{55.0.2/expo.modules.font-55.0.2.aar.sha512 → 55.0.3/expo.modules.font-55.0.3.aar.sha512} +0 -0
package/CHANGELOG.md CHANGED
@@ -10,6 +10,10 @@
10
10
 
11
11
  ### 💡 Others
12
12
 
13
+ ## 55.0.3 — 2026-01-27
14
+
15
+ _This version does not introduce any user-facing changes._
16
+
13
17
  ## 55.0.2 — 2026-01-26
14
18
 
15
19
  _This version does not introduce any user-facing changes._
@@ -22,6 +26,7 @@ _This version does not introduce any user-facing changes._
22
26
 
23
27
  ### 🎉 New features
24
28
 
29
+ - Add support for setting custom testStrings for FontObserver on the web. ([#42442](https://github.com/expo/expo/pull/42442) by [@aleqsio](https://github.com/aleqsio))
25
30
  - add support for line-height ([#41094](https://github.com/expo/expo/pull/41094) by [@Ubax](https://github.com/Ubax))
26
31
 
27
32
  ### 🐛 Bug fixes
@@ -4,13 +4,13 @@ plugins {
4
4
  }
5
5
 
6
6
  group = 'host.exp.exponent'
7
- version = '55.0.2'
7
+ version = '55.0.3'
8
8
 
9
9
  android {
10
10
  namespace "expo.modules.font"
11
11
  defaultConfig {
12
12
  versionCode 29
13
- versionName "55.0.2"
13
+ versionName "55.0.3"
14
14
  }
15
15
  }
16
16
 
@@ -139,7 +139,7 @@ const ExpoFontLoader = {
139
139
  return new FontObserver(fontFamilyName, {
140
140
  // @ts-expect-error: TODO(@kitten): Typings indicate that the polyfill may not support this?
141
141
  display: resource.display,
142
- }).load(null, 6000);
142
+ }).load(resource.testString ?? null, 12000);
143
143
  },
144
144
  };
145
145
  const isServer = process.env.EXPO_OS === 'web' && typeof window === 'undefined';
@@ -192,8 +192,6 @@ function isFontLoadingListenerSupported() {
192
192
  const isEdge = userAgent.includes('Edge');
193
193
  // Internet Explorer
194
194
  const isIE = userAgent.includes('Trident');
195
- // Firefox
196
- const isFirefox = userAgent.includes('Firefox');
197
- return !isSafari && !isIOS && !isEdge && !isIE && !isFirefox;
195
+ return !isSafari && !isIOS && !isEdge && !isIE;
198
196
  }
199
197
  //# sourceMappingURL=ExpoFontLoader.web.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ExpoFontLoader.web.js","sourceRoot":"","sources":["../src/ExpoFontLoader.web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,YAAY,MAAM,kBAAkB,CAAC;AAI5C,OAAO,EAAE,WAAW,EAAgB,MAAM,cAAc,CAAC;AAEzD,SAAS,qBAAqB;IAC5B,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE,CAAC;QAClC,OAAO,IAAI,CAAC;IACd,CAAC;IACD,MAAM,UAAU,GAAG,eAA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edError, registerWebModule } from 'expo-modules-core';\nimport FontObserver from 'fontfaceobserver';\n\nimport type { ExpoFontLoaderModule } from './ExpoFontLoader';\nimport { UnloadFontOptions } from './Font';\nimport { FontDisplay, FontResource } from './Font.types';\n\nfunction getFontFaceStyleSheet(): CSSStyleSheet | null {\n if (typeof window === 'undefined') {\n return null;\n }\n const styleSheet = getStyleElement();\n return styleSheet.sheet ? (styleSheet.sheet as CSSStyleSheet) : null;\n}\n\ntype RuleItem = { rule: CSSFontFaceRule; index: number };\n\nfunction getFontFaceRules(): RuleItem[] {\n const sheet = getFontFaceStyleSheet();\n if (sheet) {\n // @ts-ignore: rule iterator\n const rules = [...sheet.cssRules];\n\n const items: RuleItem[] = [];\n\n for (let i = 0; i < rules.length; i++) {\n const rule = rules[i];\n if (rule instanceof CSSFontFaceRule) {\n items.push({ rule, index: i });\n }\n }\n return items;\n }\n return [];\n}\n\nfunction getFontFaceRulesMatchingResource(\n fontFamilyName: string,\n options?: UnloadFontOptions\n): RuleItem[] {\n const rules = getFontFaceRules();\n return rules.filter(({ rule }) => {\n return (\n rule.style.fontFamily === fontFamilyName &&\n (options && options.display ? options.display === (rule.style as any).fontDisplay : true)\n );\n });\n}\n\nconst serverContext: Set<{ name: string; css: string; resourceId: string }> = new Set();\n\nfunction getHeadElements(): {\n $$type: string;\n rel?: string;\n href?: string;\n as?: string;\n crossorigin?: string;\n children?: string;\n id?: string;\n type?: string;\n}[] {\n const entries = [...serverContext.entries()];\n if (!entries.length) {\n return [];\n }\n const css = entries.map(([{ css }]) => css).join('\\n');\n const links = entries.map(([{ resourceId }]) => resourceId);\n // TODO: Maybe return nothing if no fonts were loaded.\n return [\n {\n $$type: 'style',\n children: css,\n id: ID,\n type: 'text/css',\n },\n ...links.map((resourceId) => ({\n $$type: 'link',\n rel: 'preload',\n href: resourceId,\n as: 'font',\n crossorigin: '',\n })),\n ];\n}\n\nconst ExpoFontLoader: Required<ExpoFontLoaderModule> = {\n async unloadAllAsync(): Promise<void> {\n if (typeof window === 'undefined') return;\n\n const element = document.getElementById(ID);\n if (element && element instanceof HTMLStyleElement) {\n document.removeChild(element);\n }\n },\n\n async unloadAsync(fontFamilyName: string, options?: UnloadFontOptions): Promise<void> {\n const sheet = getFontFaceStyleSheet();\n if (!sheet) return;\n const items = getFontFaceRulesMatchingResource(fontFamilyName, options);\n for (const item of items) {\n sheet.deleteRule(item.index);\n }\n },\n\n getServerResources(): string[] {\n const elements = getHeadElements();\n\n return elements\n .map((element) => {\n switch (element.$$type) {\n case 'style':\n return `<style id=\"${element.id}\">${element.children}</style>`;\n case 'link':\n return `<link rel=\"${element.rel}\" href=\"${element.href}\" as=\"${element.as}\" crossorigin=\"${element.crossorigin}\" />`;\n default:\n return '';\n }\n })\n .filter(Boolean);\n },\n\n resetServerContext() {\n serverContext.clear();\n },\n\n getLoadedFonts(): string[] {\n if (typeof window === 'undefined') {\n return [...serverContext.values()].map(({ name }) => name);\n }\n const rules = getFontFaceRules();\n return rules.map(({ rule }) => rule.style.fontFamily);\n },\n\n isLoaded(fontFamilyName: string, resource: UnloadFontOptions = {}): boolean {\n if (typeof window === 'undefined') {\n return !![...serverContext.values()].find((asset) => {\n return asset.name === fontFamilyName;\n });\n }\n return getFontFaceRulesMatchingResource(fontFamilyName, resource)?.length > 0;\n },\n\n // NOTE(vonovak): This is used in RN vector-icons to load fonts dynamically on web. Changing the signature is breaking.\n // NOTE(EvanBacon): No async keyword! This cannot return a promise in Node environments.\n loadAsync(fontFamilyName: string, resource: FontResource): Promise<void> {\n if (__DEV__ && typeof resource !== 'object') {\n // to help devving on web, where loadAsync interface is different from native\n throw new CodedError(\n 'ERR_FONT_SOURCE',\n `Expected font resource of type \\`object\\` instead got: ${typeof resource}`\n );\n }\n if (typeof window === 'undefined') {\n serverContext.add({\n name: fontFamilyName,\n css: _createWebFontTemplate(fontFamilyName, resource),\n // @ts-expect-error: typeof string\n resourceId: resource.uri!,\n });\n return Promise.resolve();\n }\n\n const canInjectStyle = document.head && typeof document.head.appendChild === 'function';\n if (!canInjectStyle) {\n throw new CodedError(\n 'ERR_WEB_ENVIRONMENT',\n `The browser's \\`document.head\\` element doesn't support injecting fonts.`\n );\n }\n\n const style = getStyleElement();\n document.head!.appendChild(style);\n\n const res = getFontFaceRulesMatchingResource(fontFamilyName, resource);\n if (!res.length) {\n _createWebStyle(fontFamilyName, resource);\n }\n\n if (!isFontLoadingListenerSupported()) {\n return Promise.resolve();\n }\n\n return new FontObserver(fontFamilyName, {\n // @ts-expect-error: TODO(@kitten): Typings indicate that the polyfill may not support this?\n display: resource.display,\n }).load(null, 6000);\n },\n};\n\nconst isServer = process.env.EXPO_OS === 'web' && typeof window === 'undefined';\n\nfunction createExpoFontLoader() {\n return ExpoFontLoader;\n}\nconst toExport = isServer\n ? ExpoFontLoader\n : // @ts-expect-error: registerWebModule calls `new` on the module implementation.\n // Normally that'd be a class but that doesn't work on server, so we use a function instead.\n // TS doesn't like that but we don't need it to be a class.\n registerWebModule(createExpoFontLoader, 'ExpoFontLoader');\n\nexport default toExport as typeof ExpoFontLoader;\n\nconst ID = 'expo-generated-fonts';\n\nfunction getStyleElement(): HTMLStyleElement {\n const element = document.getElementById(ID);\n if (element && element instanceof HTMLStyleElement) {\n return element;\n }\n const styleElement = document.createElement('style');\n styleElement.id = ID;\n\n return styleElement;\n}\n\nexport function _createWebFontTemplate(fontFamily: string, resource: FontResource): string {\n return `@font-face{font-family:\"${fontFamily}\";src:url(\"${resource.uri}\");font-display:${\n resource.display || FontDisplay.AUTO\n }}`;\n}\n\nfunction _createWebStyle(fontFamily: string, resource: FontResource): HTMLStyleElement {\n const fontStyle = _createWebFontTemplate(fontFamily, resource);\n\n const styleElement = getStyleElement();\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 const styleElementIE = styleElement as any;\n styleElementIE.styleSheet.cssText = styleElementIE.styleSheet.cssText\n ? styleElementIE.styleSheet.cssText + fontStyle\n : fontStyle;\n } else {\n const textNode = document.createTextNode(fontStyle);\n styleElement.appendChild(textNode);\n }\n return styleElement;\n}\n\nfunction isFontLoadingListenerSupported(): boolean {\n const { userAgent } = window.navigator;\n // WebKit is broken https://github.com/bramstein/fontfaceobserver/issues/95\n const isIOS = !!userAgent.match(/iPad|iPhone/i);\n const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);\n // Edge is broken https://github.com/bramstein/fontfaceobserver/issues/109#issuecomment-333356795\n const isEdge = userAgent.includes('Edge');\n // Internet Explorer\n const isIE = userAgent.includes('Trident');\n // Firefox\n const isFirefox = userAgent.includes('Firefox');\n return !isSafari && !isIOS && !isEdge && !isIE && !isFirefox;\n}\n"]}
1
+ {"version":3,"file":"ExpoFontLoader.web.js","sourceRoot":"","sources":["../src/ExpoFontLoader.web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAClE,OAAO,YAAY,MAAM,kBAAkB,CAAC;AAI5C,OAAO,EAAE,WAAW,EAAgB,MAAM,cAAc,CAAC;AAEzD,SAAS,qBAAqB;IAC5B,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE,CAAC;QAClC,OAAO,IAAI,CAAC;IACd,CAAC;IACD,MAAM,UAAU,GAAG,eAAe,EAAE,CAAC;IACrC,OAAO,UAAU,CAAC,KAAK,CAAC,CAAC,CAAE,UAAU,CAAC,KAAuB,CAAC,CAAC,CAAC,IAAI,CAAC;AACvE,CAAC;AAID,SAAS,gBAAgB;IACvB,MAAM,KAAK,GAAG,qBAAqB,EAAE,CAAC;IACtC,IAAI,KAAK,EAAE,CAAC;QACV,4BAA4B;QAC5B,MAAM,KAAK,GAAG,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,CAAC;QAElC,MAAM,KAAK,GAAe,EAAE,CAAC;QAE7B,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MA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S;YAC/C,CAAC,CAAC,SAAS,CAAC;IAChB,CAAC;SAAM,CAAC;QACN,MAAM,QAAQ,GAAG,QAAQ,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC;QACpD,YAAY,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;IACrC,CAAC;IACD,OAAO,YAAY,CAAC;AACtB,CAAC;AAED,SAAS,8BAA8B;IACrC,MAAM,EAAE,SAAS,EAAE,GAAG,MAAM,CAAC,SAAS,CAAC;IACvC,2EAA2E;IAC3E,MAAM,KAAK,GAAG,CAAC,CAAC,SAAS,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC;IAChD,MAAM,QAAQ,GAAG,gCAAgC,CAAC,IAAI,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC;IAC5E,iGAAiG;IACjG,MAAM,MAAM,GAAG,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;IAC1C,oBAAoB;IACpB,MAAM,IAAI,GAAG,SAAS,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;IAC3C,OAAO,CAAC,QAAQ,IAAI,CAAC,KAAK,IAAI,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC;AACjD,CAAC","sourcesContent":["import { CodedError, registerWebModule } from 'expo-modules-core';\nimport FontObserver from 'fontfaceobserver';\n\nimport type { ExpoFontLoaderModule } from './ExpoFontLoader';\nimport { UnloadFontOptions } from './Font';\nimport { FontDisplay, FontResource } from './Font.types';\n\nfunction getFontFaceStyleSheet(): CSSStyleSheet | null {\n if (typeof window === 'undefined') {\n return null;\n }\n const styleSheet = getStyleElement();\n return styleSheet.sheet ? (styleSheet.sheet as CSSStyleSheet) : null;\n}\n\ntype RuleItem = { rule: CSSFontFaceRule; index: number };\n\nfunction getFontFaceRules(): RuleItem[] {\n const sheet = getFontFaceStyleSheet();\n if (sheet) {\n // @ts-ignore: rule iterator\n const rules = [...sheet.cssRules];\n\n const items: RuleItem[] = [];\n\n for (let i = 0; i < rules.length; i++) {\n const rule = rules[i];\n if (rule instanceof CSSFontFaceRule) {\n items.push({ rule, index: i });\n }\n }\n return items;\n }\n return [];\n}\n\nfunction getFontFaceRulesMatchingResource(\n fontFamilyName: string,\n options?: UnloadFontOptions\n): RuleItem[] {\n const rules = getFontFaceRules();\n return rules.filter(({ rule }) => {\n return (\n rule.style.fontFamily === fontFamilyName &&\n (options && options.display ? options.display === (rule.style as any).fontDisplay : true)\n );\n });\n}\n\nconst serverContext: Set<{ name: string; css: string; resourceId: string }> = new Set();\n\nfunction getHeadElements(): {\n $$type: string;\n rel?: string;\n href?: string;\n as?: string;\n crossorigin?: string;\n children?: string;\n id?: string;\n type?: string;\n}[] {\n const entries = [...serverContext.entries()];\n if (!entries.length) {\n return [];\n }\n const css = entries.map(([{ css }]) => css).join('\\n');\n const links = entries.map(([{ resourceId }]) => resourceId);\n // TODO: Maybe return nothing if no fonts were loaded.\n return [\n {\n $$type: 'style',\n children: css,\n id: ID,\n type: 'text/css',\n },\n ...links.map((resourceId) => ({\n $$type: 'link',\n rel: 'preload',\n href: resourceId,\n as: 'font',\n crossorigin: '',\n })),\n ];\n}\n\nconst ExpoFontLoader: Required<ExpoFontLoaderModule> = {\n async unloadAllAsync(): Promise<void> {\n if (typeof window === 'undefined') return;\n\n const element = document.getElementById(ID);\n if (element && element instanceof HTMLStyleElement) {\n document.removeChild(element);\n }\n },\n\n async unloadAsync(fontFamilyName: string, options?: UnloadFontOptions): Promise<void> {\n const sheet = getFontFaceStyleSheet();\n if (!sheet) return;\n const items = getFontFaceRulesMatchingResource(fontFamilyName, options);\n for (const item of items) {\n sheet.deleteRule(item.index);\n }\n },\n\n getServerResources(): string[] {\n const elements = getHeadElements();\n\n return elements\n .map((element) => {\n switch (element.$$type) {\n case 'style':\n return `<style id=\"${element.id}\">${element.children}</style>`;\n case 'link':\n return `<link rel=\"${element.rel}\" href=\"${element.href}\" as=\"${element.as}\" crossorigin=\"${element.crossorigin}\" />`;\n default:\n return '';\n }\n })\n .filter(Boolean);\n },\n\n resetServerContext() {\n serverContext.clear();\n },\n\n getLoadedFonts(): string[] {\n if (typeof window === 'undefined') {\n return [...serverContext.values()].map(({ name }) => name);\n }\n const rules = getFontFaceRules();\n return rules.map(({ rule }) => rule.style.fontFamily);\n },\n\n isLoaded(fontFamilyName: string, resource: UnloadFontOptions = {}): boolean {\n if (typeof window === 'undefined') {\n return !![...serverContext.values()].find((asset) => {\n return asset.name === fontFamilyName;\n });\n }\n return getFontFaceRulesMatchingResource(fontFamilyName, resource)?.length > 0;\n },\n\n // NOTE(vonovak): This is used in RN vector-icons to load fonts dynamically on web. Changing the signature is breaking.\n // NOTE(EvanBacon): No async keyword! This cannot return a promise in Node environments.\n loadAsync(fontFamilyName: string, resource: FontResource): Promise<void> {\n if (__DEV__ && typeof resource !== 'object') {\n // to help devving on web, where loadAsync interface is different from native\n throw new CodedError(\n 'ERR_FONT_SOURCE',\n `Expected font resource of type \\`object\\` instead got: ${typeof resource}`\n );\n }\n if (typeof window === 'undefined') {\n serverContext.add({\n name: fontFamilyName,\n css: _createWebFontTemplate(fontFamilyName, resource),\n // @ts-expect-error: typeof string\n resourceId: resource.uri!,\n });\n return Promise.resolve();\n }\n\n const canInjectStyle = document.head && typeof document.head.appendChild === 'function';\n if (!canInjectStyle) {\n throw new CodedError(\n 'ERR_WEB_ENVIRONMENT',\n `The browser's \\`document.head\\` element doesn't support injecting fonts.`\n );\n }\n\n const style = getStyleElement();\n document.head!.appendChild(style);\n\n const res = getFontFaceRulesMatchingResource(fontFamilyName, resource);\n if (!res.length) {\n _createWebStyle(fontFamilyName, resource);\n }\n\n if (!isFontLoadingListenerSupported()) {\n return Promise.resolve();\n }\n\n return new FontObserver(fontFamilyName, {\n // @ts-expect-error: TODO(@kitten): Typings indicate that the polyfill may not support this?\n display: resource.display,\n }).load(resource.testString ?? null, 12000);\n },\n};\n\nconst isServer = process.env.EXPO_OS === 'web' && typeof window === 'undefined';\n\nfunction createExpoFontLoader() {\n return ExpoFontLoader;\n}\nconst toExport = isServer\n ? ExpoFontLoader\n : // @ts-expect-error: registerWebModule calls `new` on the module implementation.\n // Normally that'd be a class but that doesn't work on server, so we use a function instead.\n // TS doesn't like that but we don't need it to be a class.\n registerWebModule(createExpoFontLoader, 'ExpoFontLoader');\n\nexport default toExport as typeof ExpoFontLoader;\n\nconst ID = 'expo-generated-fonts';\n\nfunction getStyleElement(): HTMLStyleElement {\n const element = document.getElementById(ID);\n if (element && element instanceof HTMLStyleElement) {\n return element;\n }\n const styleElement = document.createElement('style');\n styleElement.id = ID;\n\n return styleElement;\n}\n\nexport function _createWebFontTemplate(fontFamily: string, resource: FontResource): string {\n return `@font-face{font-family:\"${fontFamily}\";src:url(\"${resource.uri}\");font-display:${\n resource.display || FontDisplay.AUTO\n }}`;\n}\n\nfunction _createWebStyle(fontFamily: string, resource: FontResource): HTMLStyleElement {\n const fontStyle = _createWebFontTemplate(fontFamily, resource);\n\n const styleElement = getStyleElement();\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 const styleElementIE = styleElement as any;\n styleElementIE.styleSheet.cssText = styleElementIE.styleSheet.cssText\n ? styleElementIE.styleSheet.cssText + fontStyle\n : fontStyle;\n } else {\n const textNode = document.createTextNode(fontStyle);\n styleElement.appendChild(textNode);\n }\n return styleElement;\n}\n\nfunction isFontLoadingListenerSupported(): boolean {\n const { userAgent } = window.navigator;\n // WebKit is broken https://github.com/bramstein/fontfaceobserver/issues/95\n const isIOS = !!userAgent.match(/iPad|iPhone/i);\n const isSafari = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);\n // Edge is broken https://github.com/bramstein/fontfaceobserver/issues/109#issuecomment-333356795\n const isEdge = userAgent.includes('Edge');\n // Internet Explorer\n const isIE = userAgent.includes('Trident');\n return !isSafari && !isIOS && !isEdge && !isIE;\n}\n"]}
@@ -16,6 +16,11 @@ export type FontResource = {
16
16
  */
17
17
  display?: FontDisplay;
18
18
  default?: string;
19
+ /**
20
+ * Sets a custom test string passed to the [FontFace Observer](https://www.npmjs.com/package/fontfaceobserver).
21
+ * @platform web
22
+ */
23
+ testString?: string;
19
24
  };
20
25
  /**
21
26
  * Sets the [font-display](https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-display)
@@ -1 +1 @@
1
- {"version":3,"file":"Font.types.d.ts","sourceRoot":"","sources":["../src/Font.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAGnC;;;GAGG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,MAAM,GAAG,KAAK,GAAG,YAAY,CAAC;AAGhE;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACtB;;;OAGG;IACH,OAAO,CAAC,EAAE,WAAW,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAGF;;;;;;;;;GASG;AACH,oBAAY,WAAW;IACrB;;;;OAIG;IACH,IAAI,SAAS;IACb;;;OAGG;IACH,IAAI,SAAS;IACb;;;OAGG;IACH,KAAK,UAAU;IACf;;;;;;OAMG;IACH,QAAQ,aAAa;IACrB;;;OAGG;IACH,QAAQ,aAAa;CACtB;AAGD;;;GAGG;AACH,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAAC,YAAY,EAAE,SAAS,CAAC,CAAC;AAE9D,MAAM,MAAM,WAAW,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,KAAK,CAAC,OAAO,EAAE,KAAK,GAAG,IAAI,CAAC,CAAC"}
1
+ {"version":3,"file":"Font.types.d.ts","sourceRoot":"","sources":["../src/Font.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAGnC;;;GAGG;AACH,MAAM,MAAM,UAAU,GAAG,MAAM,GAAG,MAAM,GAAG,KAAK,GAAG,YAAY,CAAC;AAGhE;;;GAGG;AACH,MAAM,MAAM,YAAY,GAAG;IACzB,GAAG,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACtB;;;OAGG;IACH,OAAO,CAAC,EAAE,WAAW,CAAC;IACtB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB;;;OAGG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,CAAC;AAGF;;;;;;;;;GASG;AACH,oBAAY,WAAW;IACrB;;;;OAIG;IACH,IAAI,SAAS;IACb;;;OAGG;IACH,IAAI,SAAS;IACb;;;OAGG;IACH,KAAK,UAAU;IACf;;;;;;OAMG;IACH,QAAQ,aAAa;IACrB;;;OAGG;IACH,QAAQ,aAAa;CACtB;AAGD;;;GAGG;AACH,MAAM,MAAM,iBAAiB,GAAG,IAAI,CAAC,YAAY,EAAE,SAAS,CAAC,CAAC;AAE9D,MAAM,MAAM,WAAW,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,KAAK,CAAC,OAAO,EAAE,KAAK,GAAG,IAAI,CAAC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"Font.types.js","sourceRoot":"","sources":["../src/Font.types.ts"],"names":[],"mappings":"AAwBA,cAAc;AACd;;;;;;;;;GASG;AACH,MAAM,CAAN,IAAY,WA8BX;AA9BD,WAAY,WAAW;IACrB;;;;OAIG;IACH,4BAAa,CAAA;IACb;;;OAGG;IACH,4BAAa,CAAA;IACb;;;OAGG;IACH,8BAAe,CAAA;IACf;;;;;;OAMG;IACH,oCAAqB,CAAA;IACrB;;;OAGG;IACH,oCAAqB,CAAA;AACvB,CAAC,EA9BW,WAAW,KAAX,WAAW,QA8BtB","sourcesContent":["import { Asset } from 'expo-asset';\n\n// @needsAudit\n/**\n * The different types of assets you can provide to the [`loadAsync()`](#loadasyncfontfamilyorfontmap-source) function.\n * A font source can be a URI, a module ID, or an Expo Asset.\n */\nexport type FontSource = string | number | Asset | FontResource;\n\n// @needsAudit\n/**\n * An object used to dictate the resource that is loaded into the provided font namespace when used\n * with [`loadAsync`](#loadasyncfontfamilyorfontmap-source).\n */\nexport type FontResource = {\n uri?: string | number;\n /**\n * Sets the [`font-display`](#fontdisplay) property for a given typeface in the browser.\n * @platform web\n */\n display?: FontDisplay;\n default?: string;\n};\n\n// @needsAudit\n/**\n * Sets the [font-display](https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-display)\n * for a given typeface. The default font value on web is `FontDisplay.AUTO`.\n * Even though setting the `fontDisplay` does nothing on native platforms, the default behavior\n * emulates `FontDisplay.SWAP` on flagship devices like iOS, Samsung, Pixel, etc. Default\n * functionality varies on One Plus devices. In the browser this value is set in the generated\n * `@font-face` CSS block and not as a style property meaning you cannot dynamically change this\n * value based on the element it's used in.\n * @platform web\n */\nexport enum FontDisplay {\n /**\n * __(Default)__ The font display strategy is defined by the user agent or platform.\n * This generally defaults to the text being invisible until the font is loaded.\n * Good for buttons or banners that require a specific treatment.\n */\n AUTO = 'auto',\n /**\n * Fallback text is rendered immediately with a default font while the desired font is loaded.\n * This is good for making the content appear to load instantly and is usually preferred.\n */\n SWAP = 'swap',\n /**\n * The text will be invisible until the font has loaded. If the font fails to load then nothing\n * will appear - it's best to turn this off when debugging missing text.\n */\n BLOCK = 'block',\n /**\n * Splits the behavior between `SWAP` and `BLOCK`.\n * There will be a [100ms timeout](https://developers.google.com/web/updates/2016/02/font-display?hl=en)\n * where the text with a custom font is invisible, after that the text will either swap to the\n * styled text or it'll show the unstyled text and continue to load the custom font. This is good\n * for buttons that need a custom font but should also be quickly available to screen-readers.\n */\n FALLBACK = 'fallback',\n /**\n * This works almost identically to `FALLBACK`, the only difference is that the browser will\n * decide to load the font based on slow connection speed or critical resource demand.\n */\n OPTIONAL = 'optional',\n}\n\n// @needsAudit\n/**\n * Object used to query fonts for unloading.\n * @hidden\n */\nexport type UnloadFontOptions = Pick<FontResource, 'display'>;\n\nexport type UseFontHook = (map: string | Record<string, FontSource>) => [boolean, Error | null];\n"]}
1
+ {"version":3,"file":"Font.types.js","sourceRoot":"","sources":["../src/Font.types.ts"],"names":[],"mappings":"AA6BA,cAAc;AACd;;;;;;;;;GASG;AACH,MAAM,CAAN,IAAY,WA8BX;AA9BD,WAAY,WAAW;IACrB;;;;OAIG;IACH,4BAAa,CAAA;IACb;;;OAGG;IACH,4BAAa,CAAA;IACb;;;OAGG;IACH,8BAAe,CAAA;IACf;;;;;;OAMG;IACH,oCAAqB,CAAA;IACrB;;;OAGG;IACH,oCAAqB,CAAA;AACvB,CAAC,EA9BW,WAAW,KAAX,WAAW,QA8BtB","sourcesContent":["import { Asset } from 'expo-asset';\n\n// @needsAudit\n/**\n * The different types of assets you can provide to the [`loadAsync()`](#loadasyncfontfamilyorfontmap-source) function.\n * A font source can be a URI, a module ID, or an Expo Asset.\n */\nexport type FontSource = string | number | Asset | FontResource;\n\n// @needsAudit\n/**\n * An object used to dictate the resource that is loaded into the provided font namespace when used\n * with [`loadAsync`](#loadasyncfontfamilyorfontmap-source).\n */\nexport type FontResource = {\n uri?: string | number;\n /**\n * Sets the [`font-display`](#fontdisplay) property for a given typeface in the browser.\n * @platform web\n */\n display?: FontDisplay;\n default?: string;\n /**\n * Sets a custom test string passed to the [FontFace Observer](https://www.npmjs.com/package/fontfaceobserver).\n * @platform web\n */\n testString?: string;\n};\n\n// @needsAudit\n/**\n * Sets the [font-display](https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face/font-display)\n * for a given typeface. The default font value on web is `FontDisplay.AUTO`.\n * Even though setting the `fontDisplay` does nothing on native platforms, the default behavior\n * emulates `FontDisplay.SWAP` on flagship devices like iOS, Samsung, Pixel, etc. Default\n * functionality varies on One Plus devices. In the browser this value is set in the generated\n * `@font-face` CSS block and not as a style property meaning you cannot dynamically change this\n * value based on the element it's used in.\n * @platform web\n */\nexport enum FontDisplay {\n /**\n * __(Default)__ The font display strategy is defined by the user agent or platform.\n * This generally defaults to the text being invisible until the font is loaded.\n * Good for buttons or banners that require a specific treatment.\n */\n AUTO = 'auto',\n /**\n * Fallback text is rendered immediately with a default font while the desired font is loaded.\n * This is good for making the content appear to load instantly and is usually preferred.\n */\n SWAP = 'swap',\n /**\n * The text will be invisible until the font has loaded. If the font fails to load then nothing\n * will appear - it's best to turn this off when debugging missing text.\n */\n BLOCK = 'block',\n /**\n * Splits the behavior between `SWAP` and `BLOCK`.\n * There will be a [100ms timeout](https://developers.google.com/web/updates/2016/02/font-display?hl=en)\n * where the text with a custom font is invisible, after that the text will either swap to the\n * styled text or it'll show the unstyled text and continue to load the custom font. This is good\n * for buttons that need a custom font but should also be quickly available to screen-readers.\n */\n FALLBACK = 'fallback',\n /**\n * This works almost identically to `FALLBACK`, the only difference is that the browser will\n * decide to load the font based on slow connection speed or critical resource demand.\n */\n OPTIONAL = 'optional',\n}\n\n// @needsAudit\n/**\n * Object used to query fonts for unloading.\n * @hidden\n */\nexport type UnloadFontOptions = Pick<FontResource, 'display'>;\n\nexport type UseFontHook = (map: string | Record<string, FontSource>) => [boolean, Error | null];\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"FontLoader.web.d.ts","sourceRoot":"","sources":["../src/FontLoader.web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAInC,OAAO,EAAE,YAAY,EAAE,UAAU,EAAe,MAAM,cAAc,CAAC;AAwBrE,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,UAAU,GAAG,KAAK,GAAG,YAAY,CAY1E;AAYD,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,GAAG,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAY5F"}
1
+ {"version":3,"file":"FontLoader.web.d.ts","sourceRoot":"","sources":["../src/FontLoader.web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAInC,OAAO,EAAE,YAAY,EAAE,UAAU,EAAe,MAAM,cAAc,CAAC;AAgCrE,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,UAAU,GAAG,KAAK,GAAG,YAAY,CAa1E;AAYD,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,GAAG,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAY5F"}
@@ -23,15 +23,23 @@ function displayFromFontSource(asset) {
23
23
  }
24
24
  return FontDisplay.AUTO;
25
25
  }
26
+ function testStringFromFontSource(asset) {
27
+ if (typeof asset === 'object' && 'testString' in asset) {
28
+ return asset.testString ?? undefined;
29
+ }
30
+ return undefined;
31
+ }
26
32
  export function getAssetForSource(source) {
27
33
  const uri = uriFromFontSource(source);
28
34
  const display = displayFromFontSource(source);
35
+ const testString = testStringFromFontSource(source);
29
36
  if (!uri || typeof uri !== 'string') {
30
37
  throwInvalidSourceError(uri);
31
38
  }
32
39
  return {
33
40
  uri,
34
41
  display,
42
+ testString,
35
43
  };
36
44
  }
37
45
  function throwInvalidSourceError(source) {
@@ -1 +1 @@
1
- {"version":3,"file":"FontLoader.web.js","sourceRoot":"","sources":["../src/FontLoader.web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE/C,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAA4B,WAAW,EAAE,MAAM,cAAc,CAAC;AAErE,SAAS,iBAAiB,CAAC,KAAiB;IAC1C,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,KAAK,IAAI,IAAI,CAAC;IACvB,CAAC;SAAM,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QACrC,OAAO,iBAAiB,CAAC,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC;IACpD,CAAC;SAAM,IA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AY,EAAE,KAA2B;IAC3E,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,CAAC,GAAG,KAAK,QAAQ,IAAK,KAAa,CAAC,aAAa,EAAE,CAAC;QAC/F,uBAAuB,CAAC,KAAK,CAAC,CAAC;IACjC,CAAC;IAED,IAAI,CAAC;QACH,OAAO,cAAc,CAAC,SAAS,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IAC/C,CAAC;IAAC,MAAM,CAAC;QACP,SAAS;IACX,CAAC;IAED,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;AAC3B,CAAC","sourcesContent":["import { Asset } from 'expo-asset';\nimport { CodedError } from 'expo-modules-core';\n\nimport ExpoFontLoader from './ExpoFontLoader';\nimport { FontResource, FontSource, FontDisplay } from './Font.types';\n\nfunction uriFromFontSource(asset: FontSource): string | number | null {\n if (typeof asset === 'string') {\n return asset || null;\n } else if (typeof asset === 'number') {\n return uriFromFontSource(Asset.fromModule(asset));\n } else if (typeof asset === 'object' && typeof asset.uri === 'number') {\n return uriFromFontSource(asset.uri);\n } else if (typeof asset === 'object') {\n return asset.uri || (asset as Asset).localUri || (asset as FontResource).default || null;\n }\n\n return null;\n}\n\nfunction displayFromFontSource(asset: FontSource): FontDisplay {\n if (typeof asset === 'object' && 'display' in asset) {\n return asset.display || FontDisplay.AUTO;\n }\n\n return FontDisplay.AUTO;\n}\n\nexport function getAssetForSource(source: FontSource): Asset | FontResource {\n const uri = uriFromFontSource(source);\n const display = displayFromFontSource(source);\n\n if (!uri || typeof uri !== 'string') {\n throwInvalidSourceError(uri);\n }\n\n return {\n uri,\n display,\n };\n}\n\nfunction throwInvalidSourceError(source: any): never {\n let type: string = typeof source;\n if (type === 'object') type = JSON.stringify(source, null, 2);\n throw new CodedError(\n `ERR_FONT_SOURCE`,\n `Expected font asset of type \\`string | FontResource | Asset\\` instead got: ${type}`\n );\n}\n\n// NOTE(EvanBacon): No async keyword!\nexport function loadSingleFontAsync(name: string, input: Asset | FontResource): Promise<void> {\n if (typeof input !== 'object' || typeof input.uri !== 'string' || (input as any).downloadAsync) {\n throwInvalidSourceError(input);\n }\n\n try {\n return ExpoFontLoader.loadAsync(name, input);\n } catch {\n // No-op.\n }\n\n return Promise.resolve();\n}\n"]}
1
+ {"version":3,"file":"FontLoader.web.js","sourceRoot":"","sources":["../src/FontLoader.web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE/C,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAA4B,WAAW,EAAE,MAAM,cAAc,CAAC;AAErE,SAAS,iBAAiB,CAAC,KAAiB;IAC1C,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,OAAO,KAAK,IAAI,IAAI,CAAC;IACvB,CAAC;SAAM,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QACrC,OAAO,iBAAiB,CAAC,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC;IACpD,CAAC;SAAM,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,CAAC,GAAG,KAAK,QAAQ,EAAE,CAAC;QACtE,OAAO,iBAAiB,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IACtC,CAAC;SAAM,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QACrC,OAAO,KAAK,CAAC,GAAG,IAAK,KAAe,CAAC,QAAQ,IAAK,KAAsB,CAAC,OAAO,IAAI,IAAI,CAAC;IAC3F,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC;AAED,SAAS,qBAAqB,CAAC,KAAiB;IAC9C,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,SAAS,IAAI,KAAK,EAAE,CAAC;QACpD,OAAO,KAAK,CAAC,OAAO,IAAI,WAAW,CAAC,IAAI,CAAC;IAC3C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AK,CAAC,CAAC;IAC/C,CAAC;IAAC,MAAM,CAAC;QACP,SAAS;IACX,CAAC;IAED,OAAO,OAAO,CAAC,OAAO,EAAE,CAAC;AAC3B,CAAC","sourcesContent":["import { Asset } from 'expo-asset';\nimport { CodedError } from 'expo-modules-core';\n\nimport ExpoFontLoader from './ExpoFontLoader';\nimport { FontResource, FontSource, FontDisplay } from './Font.types';\n\nfunction uriFromFontSource(asset: FontSource): string | number | null {\n if (typeof asset === 'string') {\n return asset || null;\n } else if (typeof asset === 'number') {\n return uriFromFontSource(Asset.fromModule(asset));\n } else if (typeof asset === 'object' && typeof asset.uri === 'number') {\n return uriFromFontSource(asset.uri);\n } else if (typeof asset === 'object') {\n return asset.uri || (asset as Asset).localUri || (asset as FontResource).default || null;\n }\n\n return null;\n}\n\nfunction displayFromFontSource(asset: FontSource): FontDisplay {\n if (typeof asset === 'object' && 'display' in asset) {\n return asset.display || FontDisplay.AUTO;\n }\n\n return FontDisplay.AUTO;\n}\n\nfunction testStringFromFontSource(asset: FontSource): string | undefined {\n if (typeof asset === 'object' && 'testString' in asset) {\n return asset.testString ?? undefined;\n }\n\n return undefined;\n}\n\nexport function getAssetForSource(source: FontSource): Asset | FontResource {\n const uri = uriFromFontSource(source);\n const display = displayFromFontSource(source);\n const testString = testStringFromFontSource(source);\n if (!uri || typeof uri !== 'string') {\n throwInvalidSourceError(uri);\n }\n\n return {\n uri,\n display,\n testString,\n };\n}\n\nfunction throwInvalidSourceError(source: any): never {\n let type: string = typeof source;\n if (type === 'object') type = JSON.stringify(source, null, 2);\n throw new CodedError(\n `ERR_FONT_SOURCE`,\n `Expected font asset of type \\`string | FontResource | Asset\\` instead got: ${type}`\n );\n}\n\n// NOTE(EvanBacon): No async keyword!\nexport function loadSingleFontAsync(name: string, input: Asset | FontResource): Promise<void> {\n if (typeof input !== 'object' || typeof input.uri !== 'string' || (input as any).downloadAsync) {\n throwInvalidSourceError(input);\n }\n\n try {\n return ExpoFontLoader.loadAsync(name, input);\n } catch {\n // No-op.\n }\n\n return Promise.resolve();\n}\n"]}
@@ -8,7 +8,7 @@
8
8
  "publication": {
9
9
  "groupId": "host.exp.exponent",
10
10
  "artifactId": "expo.modules.font",
11
- "version": "55.0.2",
11
+ "version": "55.0.3",
12
12
  "repository": "local-maven-repo"
13
13
  }
14
14
  }
@@ -3,7 +3,7 @@
3
3
  "component": {
4
4
  "group": "host.exp.exponent",
5
5
  "module": "expo.modules.font",
6
- "version": "55.0.2",
6
+ "version": "55.0.3",
7
7
  "attributes": {
8
8
  "org.gradle.status": "release"
9
9
  }
@@ -24,8 +24,8 @@
24
24
  },
25
25
  "files": [
26
26
  {
27
- "name": "expo.modules.font-55.0.2.aar",
28
- "url": "expo.modules.font-55.0.2.aar",
27
+ "name": "expo.modules.font-55.0.3.aar",
28
+ "url": "expo.modules.font-55.0.3.aar",
29
29
  "size": 24759,
30
30
  "sha512": "cbd5ab540b3c62cd937430a30ea5c32e974286e22114512f9148ea972231ba9dd192589115f5d995ad84cad20d96213f6ee62c68b3ddc6d3f6296ae515ac962c",
31
31
  "sha256": "c82e1a1fbc4a07c66d8ed0c37ff32f3c848f3594bbe5b6de4b85095129fceaaa",
@@ -57,8 +57,8 @@
57
57
  ],
58
58
  "files": [
59
59
  {
60
- "name": "expo.modules.font-55.0.2.aar",
61
- "url": "expo.modules.font-55.0.2.aar",
60
+ "name": "expo.modules.font-55.0.3.aar",
61
+ "url": "expo.modules.font-55.0.3.aar",
62
62
  "size": 24759,
63
63
  "sha512": "cbd5ab540b3c62cd937430a30ea5c32e974286e22114512f9148ea972231ba9dd192589115f5d995ad84cad20d96213f6ee62c68b3ddc6d3f6296ae515ac962c",
64
64
  "sha256": "c82e1a1fbc4a07c66d8ed0c37ff32f3c848f3594bbe5b6de4b85095129fceaaa",
@@ -77,8 +77,8 @@
77
77
  },
78
78
  "files": [
79
79
  {
80
- "name": "expo.modules.font-55.0.2-sources.jar",
81
- "url": "expo.modules.font-55.0.2-sources.jar",
80
+ "name": "expo.modules.font-55.0.3-sources.jar",
81
+ "url": "expo.modules.font-55.0.3-sources.jar",
82
82
  "size": 4110,
83
83
  "sha512": "6166146d780248c7b12e8332a8eb53d885bbd63e276ec842ec4103ba94aed4ba91bc84020addcd7ccf69371059750452800464274c5c96c5af5527a9bf3fad49",
84
84
  "sha256": "57449a0d9ed2d42c7bbf535efb97dcab0e1a0108bc0a9f948d7724562c22e6ac",
@@ -0,0 +1 @@
1
+ bb9c13a9020fcfe80bd80aef05a7a3dd869b25533e2a4a4ac2402b7c4a1b359c
@@ -0,0 +1 @@
1
+ 6a6fe67933bc1e58fb77cbb00fefe59af8484aa74f9785438c422b1a942f3d32fa0efbb1410c23292b89e34d14ce6ffdc02e980013eba62b708bdb02e5d83bb4
@@ -9,7 +9,7 @@
9
9
  <modelVersion>4.0.0</modelVersion>
10
10
  <groupId>host.exp.exponent</groupId>
11
11
  <artifactId>expo.modules.font</artifactId>
12
- <version>55.0.2</version>
12
+ <version>55.0.3</version>
13
13
  <packaging>aar</packaging>
14
14
  <name>expo.modules.font</name>
15
15
  <url>https://github.com/expo/expo</url>
@@ -0,0 +1 @@
1
+ d17555d2a99efcfd347eeab22bc5533df0c5d692
@@ -0,0 +1 @@
1
+ 64461f2fd1e0013ddc7ee88eae5d112b1cd67e5326a332ba9ea9ad5211675c60
@@ -0,0 +1 @@
1
+ 80cfdb2c46ea7889133c0b485e78062f188f11228398277c13584224a4e9e8044a40cc3b97194747d7c5358536cfd14b6f48569b6b271a6e85fd4597a7d00503
@@ -3,11 +3,11 @@
3
3
  <groupId>host.exp.exponent</groupId>
4
4
  <artifactId>expo.modules.font</artifactId>
5
5
  <versioning>
6
- <latest>55.0.2</latest>
7
- <release>55.0.2</release>
6
+ <latest>55.0.3</latest>
7
+ <release>55.0.3</release>
8
8
  <versions>
9
- <version>55.0.2</version>
9
+ <version>55.0.3</version>
10
10
  </versions>
11
- <lastUpdated>20260126041948</lastUpdated>
11
+ <lastUpdated>20260127201430</lastUpdated>
12
12
  </versioning>
13
13
  </metadata>
@@ -1 +1 @@
1
- 551dca9cfbea1c8135dbd52ca8bef7a0
1
+ f73f35cf3665b6525410d02126601fff
@@ -1 +1 @@
1
- 3a4e010dfd2f4f0411de6ce8bd87522857ba8a38
1
+ 9f39b6b8667ff38d59e6f36c673b2f639b573c1d
@@ -1 +1 @@
1
- b1b0ea29689d6e8b54d5baadaf7739301de1ab4632600d831b6bdd9af00d5ec6
1
+ 20416455893f44ab79376a5f1c057eafefccee5f17a3b4e7e6f2ed6bea9b0d37
@@ -1 +1 @@
1
- af891626433343e9649707445c8a2ade0e4d3f7026ebbf77e860c8f8b1e73a959130b7c68119a344038c0f1942143e2faaaacec4f45a5aa0e81533aa11ef3a3c
1
+ 829d76c60a55fda525aaacc13437696d098af25ddcd30524e307a8497e5464dfa35b6b86a642fe71a5c4341253291eefbf11f4f90f74c4971f401cd7f80f1d01
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-font",
3
- "version": "55.0.2",
3
+ "version": "55.0.3",
4
4
  "description": "Load fonts at runtime and use them in React Native components.",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -59,5 +59,5 @@
59
59
  "react": "*",
60
60
  "react-native": "*"
61
61
  },
62
- "gitHead": "7d7f6762fc6907c27a329953c682134a84410dea"
62
+ "gitHead": "220594d473a3100248087151004ae4acb7282d5f"
63
63
  }
@@ -183,7 +183,7 @@ const ExpoFontLoader: Required<ExpoFontLoaderModule> = {
183
183
  return new FontObserver(fontFamilyName, {
184
184
  // @ts-expect-error: TODO(@kitten): Typings indicate that the polyfill may not support this?
185
185
  display: resource.display,
186
- }).load(null, 6000);
186
+ }).load(resource.testString ?? null, 12000);
187
187
  },
188
188
  };
189
189
 
@@ -247,7 +247,5 @@ function isFontLoadingListenerSupported(): boolean {
247
247
  const isEdge = userAgent.includes('Edge');
248
248
  // Internet Explorer
249
249
  const isIE = userAgent.includes('Trident');
250
- // Firefox
251
- const isFirefox = userAgent.includes('Firefox');
252
- return !isSafari && !isIOS && !isEdge && !isIE && !isFirefox;
250
+ return !isSafari && !isIOS && !isEdge && !isIE;
253
251
  }
package/src/Font.types.ts CHANGED
@@ -20,6 +20,11 @@ export type FontResource = {
20
20
  */
21
21
  display?: FontDisplay;
22
22
  default?: string;
23
+ /**
24
+ * Sets a custom test string passed to the [FontFace Observer](https://www.npmjs.com/package/fontfaceobserver).
25
+ * @platform web
26
+ */
27
+ testString?: string;
23
28
  };
24
29
 
25
30
  // @needsAudit
@@ -26,10 +26,18 @@ function displayFromFontSource(asset: FontSource): FontDisplay {
26
26
  return FontDisplay.AUTO;
27
27
  }
28
28
 
29
+ function testStringFromFontSource(asset: FontSource): string | undefined {
30
+ if (typeof asset === 'object' && 'testString' in asset) {
31
+ return asset.testString ?? undefined;
32
+ }
33
+
34
+ return undefined;
35
+ }
36
+
29
37
  export function getAssetForSource(source: FontSource): Asset | FontResource {
30
38
  const uri = uriFromFontSource(source);
31
39
  const display = displayFromFontSource(source);
32
-
40
+ const testString = testStringFromFontSource(source);
33
41
  if (!uri || typeof uri !== 'string') {
34
42
  throwInvalidSourceError(uri);
35
43
  }
@@ -37,6 +45,7 @@ export function getAssetForSource(source: FontSource): Asset | FontResource {
37
45
  return {
38
46
  uri,
39
47
  display,
48
+ testString,
40
49
  };
41
50
  }
42
51
 
@@ -1 +0,0 @@
1
- a7f12d47b298d02a9a619dd0f9c5bfc7294a04fc
@@ -1 +0,0 @@
1
- 6e15461b00c4e906f62c0f48e815698b778d2702768f004ebafd54cb3ab51202
@@ -1 +0,0 @@
1
- 6e752d87b1a376756f5e9325d018d4685c8ddc53a8ac191f7e6af27ac3804fe96145c907729ec68b5595bffba1986096242d5450ca9741dc1014c3025652b1ce
@@ -1 +0,0 @@
1
- 0266fe04d8a004b5dd02f2ceed5b7b4fff42b1a8
@@ -1 +0,0 @@
1
- 4591cd02d278d0c888091b15c853f3d27ca32f53fad2c9cab5b8e08ae19cbb23
@@ -1 +0,0 @@
1
- e5d254ead1a5d7b64d717439355287230e3ec49ec73f3eb4a46671cc16b6bff52ef82ed9e1578dd15dfc3c03fe5ef7185455e77a90f73ac2599ae06cb4e85459