expo-font 13.0.0 → 13.0.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/CHANGELOG.md +6 -0
- package/android/build.gradle +2 -2
- package/build/Font.d.ts +0 -10
- package/build/Font.d.ts.map +1 -1
- package/build/Font.js +0 -13
- package/build/Font.js.map +1 -1
- package/package.json +2 -2
- package/src/Font.ts +0 -14
package/CHANGELOG.md
CHANGED
|
@@ -10,6 +10,12 @@
|
|
|
10
10
|
|
|
11
11
|
### 💡 Others
|
|
12
12
|
|
|
13
|
+
## 13.0.1 — 2024-11-05
|
|
14
|
+
|
|
15
|
+
### 💡 Others
|
|
16
|
+
|
|
17
|
+
- Remove deprecated Font.processFontFamily() ([#32631](https://github.com/expo/expo/pull/32631) by [@brentvatne](https://github.com/brentvatne))
|
|
18
|
+
|
|
13
19
|
## 13.0.0 — 2024-10-22
|
|
14
20
|
|
|
15
21
|
### 🛠 Breaking changes
|
package/android/build.gradle
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
apply plugin: 'com.android.library'
|
|
2
2
|
|
|
3
3
|
group = 'host.exp.exponent'
|
|
4
|
-
version = '13.0.
|
|
4
|
+
version = '13.0.1'
|
|
5
5
|
|
|
6
6
|
def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
|
|
7
7
|
apply from: expoModulesCorePlugin
|
|
@@ -14,7 +14,7 @@ android {
|
|
|
14
14
|
namespace "expo.modules.font"
|
|
15
15
|
defaultConfig {
|
|
16
16
|
versionCode 29
|
|
17
|
-
versionName "13.0.
|
|
17
|
+
versionName "13.0.1"
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
|
package/build/Font.d.ts
CHANGED
|
@@ -1,14 +1,4 @@
|
|
|
1
1
|
import { FontDisplay, FontSource, FontResource, UnloadFontOptions } from './Font.types';
|
|
2
|
-
/**
|
|
3
|
-
* Used to transform font family names to the scoped name. This does not need to
|
|
4
|
-
* be called in standalone or bare apps, but it will return unscoped font family
|
|
5
|
-
* names if it is called in those contexts.
|
|
6
|
-
*
|
|
7
|
-
* @param fontFamily Name of font to process.
|
|
8
|
-
* @returns Returns a name processed for use with the [current workflow](https://docs.expo.dev/archive/managed-vs-bare/).
|
|
9
|
-
* @deprecated This method is not needed anymore and will be removed in the future.
|
|
10
|
-
*/
|
|
11
|
-
export declare function processFontFamily(fontFamily: string | null): string | null;
|
|
12
2
|
/**
|
|
13
3
|
* Synchronously detect if the font for `fontFamily` has finished loading.
|
|
14
4
|
*
|
package/build/Font.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Font.d.ts","sourceRoot":"","sources":["../src/Font.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAaxF
|
|
1
|
+
{"version":3,"file":"Font.d.ts","sourceRoot":"","sources":["../src/Font.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAaxF;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAKpD;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,IAAI,MAAM,EAAE,CAEzC;AAGD;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAErD;AAGD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,SAAS,CACvB,mBAAmB,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,UAAU,CAAC,EACxD,MAAM,CAAC,EAAE,UAAU,GAClB,OAAO,CAAC,IAAI,CAAC,CAkCf;AA0CD;;;GAGG;AACH,wBAAsB,cAAc,IAAI,OAAO,CAAC,IAAI,CAAC,CAapD;AAGD;;;;;;;;GAQG;AACH,wBAAsB,WAAW,CAC/B,mBAAmB,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,EAC/D,OAAO,CAAC,EAAE,iBAAiB,GAC1B,OAAO,CAAC,IAAI,CAAC,CAkBf;AAwBD,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,YAAY,EAAE,iBAAiB,EAAE,CAAC"}
|
package/build/Font.js
CHANGED
|
@@ -5,19 +5,6 @@ import { getAssetForSource, loadSingleFontAsync } from './FontLoader';
|
|
|
5
5
|
import { isLoadedInCache, isLoadedNative, loadPromises, markLoaded, purgeCache, purgeFontFamilyFromCache, } from './memory';
|
|
6
6
|
import { registerStaticFont } from './server';
|
|
7
7
|
// @needsAudit
|
|
8
|
-
/**
|
|
9
|
-
* Used to transform font family names to the scoped name. This does not need to
|
|
10
|
-
* be called in standalone or bare apps, but it will return unscoped font family
|
|
11
|
-
* names if it is called in those contexts.
|
|
12
|
-
*
|
|
13
|
-
* @param fontFamily Name of font to process.
|
|
14
|
-
* @returns Returns a name processed for use with the [current workflow](https://docs.expo.dev/archive/managed-vs-bare/).
|
|
15
|
-
* @deprecated This method is not needed anymore and will be removed in the future.
|
|
16
|
-
*/
|
|
17
|
-
export function processFontFamily(fontFamily) {
|
|
18
|
-
return fontFamily;
|
|
19
|
-
}
|
|
20
|
-
// @needsAudit
|
|
21
8
|
/**
|
|
22
9
|
* Synchronously detect if the font for `fontFamily` has finished loading.
|
|
23
10
|
*
|
package/build/Font.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Font.js","sourceRoot":"","sources":["../src/Font.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAE9E,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,WAAW,EAA+C,MAAM,cAAc,CAAC;AACxF,OAAO,EAAE,iBAAiB,EAAE,m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,EAAE,CAAC,0BAA0B,CAAC,IAAI,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;QACxF,OAAO;KACR;IAED,OAAO,MAAM,0BAA0B,CAAC,mBAAmB,EAAE,OAAO,CAAC,CAAC;AACxE,CAAC;AAED,KAAK,UAAU,0BAA0B,CACvC,UAAkB,EAClB,OAAkC;IAElC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE;QACzB,OAAO;KACR;SAAM;QACL,wBAAwB,CAAC,UAAU,CAAC,CAAC;KACtC;IAED,+FAA+F;IAC/F,2FAA2F;IAC3F,iGAAiG;IACjG,wBAAwB;IAExB,IAAI,CAAC,UAAU,EAAE;QACf,MAAM,IAAI,UAAU,CAAC,iBAAiB,EAAE,6BAA6B,CAAC,CAAC;KACxE;IAED,MAAM,cAAc,CAAC,WAAW,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;AACxD,CAAC;AAED,OAAO,EAAE,WAAW,EAA+C,CAAC","sourcesContent":["import { CodedError, Platform, UnavailabilityError } from 'expo-modules-core';\n\nimport ExpoFontLoader from './ExpoFontLoader';\nimport { FontDisplay, FontSource, FontResource, UnloadFontOptions } from './Font.types';\nimport { getAssetForSource, loadSingleFontAsync } from './FontLoader';\nimport {\n isLoadedInCache,\n isLoadedNative,\n loadPromises,\n markLoaded,\n purgeCache,\n purgeFontFamilyFromCache,\n} from './memory';\nimport { registerStaticFont } from './server';\n\n// @needsAudit\n/**\n * Used to transform font family names to the scoped name. This does not need to\n * be called in standalone or bare apps, but it will return unscoped font family\n * names if it is called in those contexts.\n *\n * @param fontFamily Name of font to process.\n * @returns Returns a name processed for use with the [current workflow](https://docs.expo.dev/archive/managed-vs-bare/).\n * @deprecated This method is not needed anymore and will be removed in the future.\n */\nexport function processFontFamily(fontFamily: string | null): string | null {\n return fontFamily;\n}\n\n// @needsAudit\n/**\n * Synchronously detect if the font for `fontFamily` has finished loading.\n *\n * @param fontFamily The name used to load the `FontResource`.\n * @return Returns `true` if the font has fully loaded.\n */\nexport function isLoaded(fontFamily: string): boolean {\n if (Platform.OS === 'web') {\n return isLoadedInCache(fontFamily) || !!ExpoFontLoader.isLoaded(fontFamily);\n }\n return isLoadedNative(fontFamily);\n}\n\n/**\n * Synchronously get all the fonts that have been loaded.\n * This includes fonts that were bundled at build time using the config plugin, as well as those loaded at runtime using `loadAsync`.\n *\n * @returns Returns array of strings which you can use as `fontFamily` [style prop](https://reactnative.dev/docs/text#style).\n */\nexport function getLoadedFonts(): string[] {\n return ExpoFontLoader.getLoadedFonts();\n}\n\n// @needsAudit\n/**\n * Synchronously detect if the font for `fontFamily` is still being loaded.\n *\n * @param fontFamily The name used to load the `FontResource`.\n * @returns Returns `true` if the font is still loading.\n */\nexport function isLoading(fontFamily: string): boolean {\n return fontFamily in loadPromises;\n}\n\n// @needsAudit\n/**\n * An efficient method for loading fonts from static or remote resources which can then be used\n * with the platform's native text elements. In the browser, this generates a `@font-face` block in\n * a shared style sheet for fonts. No CSS is needed to use this method.\n *\n * > **Note**: We recommend using the [config plugin](#configuration-in-appjsonappconfigjs) instead whenever possible.\n *\n * @param fontFamilyOrFontMap String or map of values that can be used as the `fontFamily` [style prop](https://reactnative.dev/docs/text#style)\n * with React Native `Text` elements.\n * @param source The font asset that should be loaded into the `fontFamily` namespace.\n *\n * @return Returns a promise that fulfils when the font has loaded. Often you may want to wrap the\n * method in a `try/catch/finally` to ensure the app continues if the font fails to load.\n */\nexport function loadAsync(\n fontFamilyOrFontMap: string | Record<string, FontSource>,\n source?: FontSource\n): Promise<void> {\n // NOTE(EvanBacon): Static render pass on web must be synchronous to collect all fonts.\n // Because of this, `loadAsync` doesn't use the `async` keyword and deviates from the\n // standard Expo SDK style guide.\n const isServer = Platform.OS === 'web' && typeof window === 'undefined';\n\n if (typeof fontFamilyOrFontMap === 'object') {\n if (source) {\n return Promise.reject(\n new CodedError(\n `ERR_FONT_API`,\n `No fontFamily can be used for the provided source: ${source}. The second argument of \\`loadAsync()\\` can only be used with a \\`string\\` value as the first argument.`\n )\n );\n }\n const fontMap = fontFamilyOrFontMap;\n const names = Object.keys(fontMap);\n\n if (isServer) {\n names.map((name) => registerStaticFont(name, fontMap[name]));\n return Promise.resolve();\n }\n\n return Promise.all(names.map((name) => loadFontInNamespaceAsync(name, fontMap[name]))).then(\n () => {}\n );\n }\n\n if (isServer) {\n registerStaticFont(fontFamilyOrFontMap, source);\n return Promise.resolve();\n }\n\n return loadFontInNamespaceAsync(fontFamilyOrFontMap, source);\n}\n\nasync function loadFontInNamespaceAsync(\n fontFamily: string,\n source?: FontSource | null\n): Promise<void> {\n if (!source) {\n throw new CodedError(\n `ERR_FONT_SOURCE`,\n `Cannot load null or undefined font source: { \"${fontFamily}\": ${source} }. Expected asset of type \\`FontSource\\` for fontFamily of name: \"${fontFamily}\"`\n );\n }\n\n // we consult the native module to see if the font is already loaded\n // this is slower than checking the cache but can help avoid loading the same font n times\n if (isLoaded(fontFamily)) {\n return;\n }\n\n if (loadPromises.hasOwnProperty(fontFamily)) {\n return loadPromises[fontFamily];\n }\n\n // Important: we want all callers that concurrently try to load the same font to await the same\n // promise. If we're here, we haven't created the promise yet. To ensure we create only one\n // promise in the program, we need to create the promise synchronously without yielding the event\n // loop from this point.\n\n const asset = getAssetForSource(source);\n loadPromises[fontFamily] = (async () => {\n try {\n await loadSingleFontAsync(fontFamily, asset);\n markLoaded(fontFamily);\n } finally {\n delete loadPromises[fontFamily];\n }\n })();\n\n await loadPromises[fontFamily];\n}\n\n// @needsAudit\n/**\n * Unloads all the custom fonts. This is used for testing.\n * @hidden\n */\nexport async function unloadAllAsync(): Promise<void> {\n if (!ExpoFontLoader.unloadAllAsync) {\n throw new UnavailabilityError('expo-font', 'unloadAllAsync');\n }\n\n if (Object.keys(loadPromises).length) {\n throw new CodedError(\n `ERR_UNLOAD`,\n `Cannot unload fonts while they're still loading: ${Object.keys(loadPromises).join(', ')}`\n );\n }\n purgeCache();\n await ExpoFontLoader.unloadAllAsync();\n}\n\n// @needsAudit\n/**\n * Unload custom fonts matching the `fontFamily`s and display values provided.\n * This is used for testing.\n *\n * @param fontFamilyOrFontMap The name or names of the custom fonts that will be unloaded.\n * @param options When `fontFamilyOrFontMap` is a string, this should be the font source used to load\n * the custom font originally.\n * @hidden\n */\nexport async function unloadAsync(\n fontFamilyOrFontMap: string | Record<string, UnloadFontOptions>,\n options?: UnloadFontOptions\n): Promise<void> {\n if (!ExpoFontLoader.unloadAsync) {\n throw new UnavailabilityError('expo-font', 'unloadAsync');\n }\n if (typeof fontFamilyOrFontMap === 'object') {\n if (options) {\n throw new CodedError(\n `ERR_FONT_API`,\n `No fontFamily can be used for the provided options: ${options}. The second argument of \\`unloadAsync()\\` can only be used with a \\`string\\` value as the first argument.`\n );\n }\n const fontMap = fontFamilyOrFontMap;\n const names = Object.keys(fontMap);\n await Promise.all(names.map((name) => unloadFontInNamespaceAsync(name, fontMap[name])));\n return;\n }\n\n return await unloadFontInNamespaceAsync(fontFamilyOrFontMap, options);\n}\n\nasync function unloadFontInNamespaceAsync(\n fontFamily: string,\n options?: UnloadFontOptions | null\n): Promise<void> {\n if (!isLoaded(fontFamily)) {\n return;\n } else {\n purgeFontFamilyFromCache(fontFamily);\n }\n\n // Important: we want all callers that concurrently try to load the same font to await the same\n // promise. If we're here, we haven't created the promise yet. To ensure we create only one\n // promise in the program, we need to create the promise synchronously without yielding the event\n // loop from this point.\n\n if (!fontFamily) {\n throw new CodedError(`ERR_FONT_FAMILY`, `Cannot unload an empty name`);\n }\n\n await ExpoFontLoader.unloadAsync(fontFamily, options);\n}\n\nexport { FontDisplay, FontSource, FontResource, UnloadFontOptions };\n"]}
|
|
1
|
+
{"version":3,"file":"Font.js","sourceRoot":"","sources":["../src/Font.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAE9E,OAAO,cAAc,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE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,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC;QACxF,OAAO;KACR;IAED,OAAO,MAAM,0BAA0B,CAAC,mBAAmB,EAAE,OAAO,CAAC,CAAC;AACxE,CAAC;AAED,KAAK,UAAU,0BAA0B,CACvC,UAAkB,EAClB,OAAkC;IAElC,IAAI,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE;QACzB,OAAO;KACR;SAAM;QACL,wBAAwB,CAAC,UAAU,CAAC,CAAC;KACtC;IAED,+FAA+F;IAC/F,2FAA2F;IAC3F,iGAAiG;IACjG,wBAAwB;IAExB,IAAI,CAAC,UAAU,EAAE;QACf,MAAM,IAAI,UAAU,CAAC,iBAAiB,EAAE,6BAA6B,CAAC,CAAC;KACxE;IAED,MAAM,cAAc,CAAC,WAAW,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;AACxD,CAAC;AAED,OAAO,EAAE,WAAW,EAA+C,CAAC","sourcesContent":["import { CodedError, Platform, UnavailabilityError } from 'expo-modules-core';\n\nimport ExpoFontLoader from './ExpoFontLoader';\nimport { FontDisplay, FontSource, FontResource, UnloadFontOptions } from './Font.types';\nimport { getAssetForSource, loadSingleFontAsync } from './FontLoader';\nimport {\n isLoadedInCache,\n isLoadedNative,\n loadPromises,\n markLoaded,\n purgeCache,\n purgeFontFamilyFromCache,\n} from './memory';\nimport { registerStaticFont } from './server';\n\n// @needsAudit\n/**\n * Synchronously detect if the font for `fontFamily` has finished loading.\n *\n * @param fontFamily The name used to load the `FontResource`.\n * @return Returns `true` if the font has fully loaded.\n */\nexport function isLoaded(fontFamily: string): boolean {\n if (Platform.OS === 'web') {\n return isLoadedInCache(fontFamily) || !!ExpoFontLoader.isLoaded(fontFamily);\n }\n return isLoadedNative(fontFamily);\n}\n\n/**\n * Synchronously get all the fonts that have been loaded.\n * This includes fonts that were bundled at build time using the config plugin, as well as those loaded at runtime using `loadAsync`.\n *\n * @returns Returns array of strings which you can use as `fontFamily` [style prop](https://reactnative.dev/docs/text#style).\n */\nexport function getLoadedFonts(): string[] {\n return ExpoFontLoader.getLoadedFonts();\n}\n\n// @needsAudit\n/**\n * Synchronously detect if the font for `fontFamily` is still being loaded.\n *\n * @param fontFamily The name used to load the `FontResource`.\n * @returns Returns `true` if the font is still loading.\n */\nexport function isLoading(fontFamily: string): boolean {\n return fontFamily in loadPromises;\n}\n\n// @needsAudit\n/**\n * An efficient method for loading fonts from static or remote resources which can then be used\n * with the platform's native text elements. In the browser, this generates a `@font-face` block in\n * a shared style sheet for fonts. No CSS is needed to use this method.\n *\n * > **Note**: We recommend using the [config plugin](#configuration-in-appjsonappconfigjs) instead whenever possible.\n *\n * @param fontFamilyOrFontMap String or map of values that can be used as the `fontFamily` [style prop](https://reactnative.dev/docs/text#style)\n * with React Native `Text` elements.\n * @param source The font asset that should be loaded into the `fontFamily` namespace.\n *\n * @return Returns a promise that fulfils when the font has loaded. Often you may want to wrap the\n * method in a `try/catch/finally` to ensure the app continues if the font fails to load.\n */\nexport function loadAsync(\n fontFamilyOrFontMap: string | Record<string, FontSource>,\n source?: FontSource\n): Promise<void> {\n // NOTE(EvanBacon): Static render pass on web must be synchronous to collect all fonts.\n // Because of this, `loadAsync` doesn't use the `async` keyword and deviates from the\n // standard Expo SDK style guide.\n const isServer = Platform.OS === 'web' && typeof window === 'undefined';\n\n if (typeof fontFamilyOrFontMap === 'object') {\n if (source) {\n return Promise.reject(\n new CodedError(\n `ERR_FONT_API`,\n `No fontFamily can be used for the provided source: ${source}. The second argument of \\`loadAsync()\\` can only be used with a \\`string\\` value as the first argument.`\n )\n );\n }\n const fontMap = fontFamilyOrFontMap;\n const names = Object.keys(fontMap);\n\n if (isServer) {\n names.map((name) => registerStaticFont(name, fontMap[name]));\n return Promise.resolve();\n }\n\n return Promise.all(names.map((name) => loadFontInNamespaceAsync(name, fontMap[name]))).then(\n () => {}\n );\n }\n\n if (isServer) {\n registerStaticFont(fontFamilyOrFontMap, source);\n return Promise.resolve();\n }\n\n return loadFontInNamespaceAsync(fontFamilyOrFontMap, source);\n}\n\nasync function loadFontInNamespaceAsync(\n fontFamily: string,\n source?: FontSource | null\n): Promise<void> {\n if (!source) {\n throw new CodedError(\n `ERR_FONT_SOURCE`,\n `Cannot load null or undefined font source: { \"${fontFamily}\": ${source} }. Expected asset of type \\`FontSource\\` for fontFamily of name: \"${fontFamily}\"`\n );\n }\n\n // we consult the native module to see if the font is already loaded\n // this is slower than checking the cache but can help avoid loading the same font n times\n if (isLoaded(fontFamily)) {\n return;\n }\n\n if (loadPromises.hasOwnProperty(fontFamily)) {\n return loadPromises[fontFamily];\n }\n\n // Important: we want all callers that concurrently try to load the same font to await the same\n // promise. If we're here, we haven't created the promise yet. To ensure we create only one\n // promise in the program, we need to create the promise synchronously without yielding the event\n // loop from this point.\n\n const asset = getAssetForSource(source);\n loadPromises[fontFamily] = (async () => {\n try {\n await loadSingleFontAsync(fontFamily, asset);\n markLoaded(fontFamily);\n } finally {\n delete loadPromises[fontFamily];\n }\n })();\n\n await loadPromises[fontFamily];\n}\n\n// @needsAudit\n/**\n * Unloads all the custom fonts. This is used for testing.\n * @hidden\n */\nexport async function unloadAllAsync(): Promise<void> {\n if (!ExpoFontLoader.unloadAllAsync) {\n throw new UnavailabilityError('expo-font', 'unloadAllAsync');\n }\n\n if (Object.keys(loadPromises).length) {\n throw new CodedError(\n `ERR_UNLOAD`,\n `Cannot unload fonts while they're still loading: ${Object.keys(loadPromises).join(', ')}`\n );\n }\n purgeCache();\n await ExpoFontLoader.unloadAllAsync();\n}\n\n// @needsAudit\n/**\n * Unload custom fonts matching the `fontFamily`s and display values provided.\n * This is used for testing.\n *\n * @param fontFamilyOrFontMap The name or names of the custom fonts that will be unloaded.\n * @param options When `fontFamilyOrFontMap` is a string, this should be the font source used to load\n * the custom font originally.\n * @hidden\n */\nexport async function unloadAsync(\n fontFamilyOrFontMap: string | Record<string, UnloadFontOptions>,\n options?: UnloadFontOptions\n): Promise<void> {\n if (!ExpoFontLoader.unloadAsync) {\n throw new UnavailabilityError('expo-font', 'unloadAsync');\n }\n if (typeof fontFamilyOrFontMap === 'object') {\n if (options) {\n throw new CodedError(\n `ERR_FONT_API`,\n `No fontFamily can be used for the provided options: ${options}. The second argument of \\`unloadAsync()\\` can only be used with a \\`string\\` value as the first argument.`\n );\n }\n const fontMap = fontFamilyOrFontMap;\n const names = Object.keys(fontMap);\n await Promise.all(names.map((name) => unloadFontInNamespaceAsync(name, fontMap[name])));\n return;\n }\n\n return await unloadFontInNamespaceAsync(fontFamilyOrFontMap, options);\n}\n\nasync function unloadFontInNamespaceAsync(\n fontFamily: string,\n options?: UnloadFontOptions | null\n): Promise<void> {\n if (!isLoaded(fontFamily)) {\n return;\n } else {\n purgeFontFamilyFromCache(fontFamily);\n }\n\n // Important: we want all callers that concurrently try to load the same font to await the same\n // promise. If we're here, we haven't created the promise yet. To ensure we create only one\n // promise in the program, we need to create the promise synchronously without yielding the event\n // loop from this point.\n\n if (!fontFamily) {\n throw new CodedError(`ERR_FONT_FAMILY`, `Cannot unload an empty name`);\n }\n\n await ExpoFontLoader.unloadAsync(fontFamily, options);\n}\n\nexport { FontDisplay, FontSource, FontResource, UnloadFontOptions };\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-font",
|
|
3
|
-
"version": "13.0.
|
|
3
|
+
"version": "13.0.1",
|
|
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",
|
|
@@ -44,5 +44,5 @@
|
|
|
44
44
|
"expo": "*",
|
|
45
45
|
"react": "*"
|
|
46
46
|
},
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "a64603dce90981bf7688657f87dfa4be3e24f58b"
|
|
48
48
|
}
|
package/src/Font.ts
CHANGED
|
@@ -13,20 +13,6 @@ import {
|
|
|
13
13
|
} from './memory';
|
|
14
14
|
import { registerStaticFont } from './server';
|
|
15
15
|
|
|
16
|
-
// @needsAudit
|
|
17
|
-
/**
|
|
18
|
-
* Used to transform font family names to the scoped name. This does not need to
|
|
19
|
-
* be called in standalone or bare apps, but it will return unscoped font family
|
|
20
|
-
* names if it is called in those contexts.
|
|
21
|
-
*
|
|
22
|
-
* @param fontFamily Name of font to process.
|
|
23
|
-
* @returns Returns a name processed for use with the [current workflow](https://docs.expo.dev/archive/managed-vs-bare/).
|
|
24
|
-
* @deprecated This method is not needed anymore and will be removed in the future.
|
|
25
|
-
*/
|
|
26
|
-
export function processFontFamily(fontFamily: string | null): string | null {
|
|
27
|
-
return fontFamily;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
16
|
// @needsAudit
|
|
31
17
|
/**
|
|
32
18
|
* Synchronously detect if the font for `fontFamily` has finished loading.
|