@react-native-vector-icons/common 12.4.0 → 12.4.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/README.md +8 -26
- package/lib/commonjs/dynamicLoading/dynamic-loading-setting.js +11 -7
- package/lib/commonjs/dynamicLoading/dynamic-loading-setting.js.map +1 -1
- package/lib/module/dynamicLoading/dynamic-loading-setting.js +11 -7
- package/lib/module/dynamicLoading/dynamic-loading-setting.js.map +1 -1
- package/lib/typescript/commonjs/src/dynamicLoading/dynamic-loading-setting.d.ts.map +1 -1
- package/lib/typescript/module/src/dynamicLoading/dynamic-loading-setting.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/dynamicLoading/dynamic-loading-setting.ts +11 -9
package/README.md
CHANGED
|
@@ -45,12 +45,12 @@ RNVI comes with the following supported icons. You can [search NPM](https://www.
|
|
|
45
45
|
|
|
46
46
|
- [`AntDesign`](https://ant.design/components/icon) from Ant Group (v4.4.2 with _449_ icons)
|
|
47
47
|
- [`Feather`](http://feathericons.com) created by Cole Bemis & Contributors (v4.29.2 featuring _287_ icons)
|
|
48
|
-
- [`FontAwesome`](https://fontawesome.com/search) designed by Fonticons, Inc. (v7.
|
|
48
|
+
- [`FontAwesome`](https://fontawesome.com/search) designed by Fonticons, Inc. (v7.2.0 featuring _2,806_ free and _75,767_ pro icons)
|
|
49
49
|
- [`Foundation`](http://zurb.com/playground/foundation-icon-fonts-3) by ZURB, Inc. (v3.0 with _283_ icons)
|
|
50
50
|
- [`Ionicons`](https://ionic.io/ionicons) crafted by Ionic (v8.0.9 containing _1,357_ icons)
|
|
51
51
|
- [`MaterialDesignIcons`](https://pictogrammers.com/library/mdi/) from MaterialDesignIcons.com (v7.4.47 including _7448_ icons)
|
|
52
|
-
- [`Octicons`](https://primer.style/foundations/icons) designed by GitHub, Inc. (v19.
|
|
53
|
-
- [`Lucide`](https://lucide.dev/) designed by Lucide, (v0.
|
|
52
|
+
- [`Octicons`](https://primer.style/foundations/icons) designed by GitHub, Inc. (v19.22.0 with _339_ icons)
|
|
53
|
+
- [`Lucide`](https://lucide.dev/) designed by Lucide, (v0.576.0 with _1,639_ icons)
|
|
54
54
|
|
|
55
55
|
### No longer maintained upstream
|
|
56
56
|
|
|
@@ -73,16 +73,12 @@ See [MIGRATION.md](MIGRATION.md) if you are migrating from `react-native-vector-
|
|
|
73
73
|
1. Install the packages for the icons you want to use
|
|
74
74
|
|
|
75
75
|
```sh
|
|
76
|
-
npm install @react-native-vector-icons/
|
|
76
|
+
npm install @react-native-vector-icons/fontawesome-free-solid @react-native-vector-icons/evil-icons
|
|
77
77
|
```
|
|
78
78
|
|
|
79
79
|
1. Depending on the platform you're targeting (iOS/Android/Windows), follow the appropriate setup instructions below.
|
|
80
80
|
1. If you are using one of the following fonts, refer to their guides for further instructions
|
|
81
81
|
|
|
82
|
-
- [FontAwesome 6](packages/fontawesome6/README.md)
|
|
83
|
-
- [FontAwesome 6 Pro](packages/fontawesome6-pro/README.md)
|
|
84
|
-
- [FontAwesome 5](packages/fontawesome5/README.md)
|
|
85
|
-
- [FontAwesome 5 Pro](packages/fontawesome5-pro/README.md)
|
|
86
82
|
- [Fontello](packages/fontello/README.md)
|
|
87
83
|
- [Icomoon](packages/icomoon/README.md)
|
|
88
84
|
|
|
@@ -92,7 +88,7 @@ Refer to the guide for [Expo](./docs/SETUP-EXPO.md), [React Native](./docs/SETUP
|
|
|
92
88
|
|
|
93
89
|
### Font location customisation
|
|
94
90
|
|
|
95
|
-
For fonts like
|
|
91
|
+
For fonts like the FontAwesome Pro as well as fontello and icomoon where you provide the fonts the default location for the font files is `rnvi-fonts` in the same directory as your package.json. This can be customized by setting the `fontDir` property in your `package.json` file.
|
|
96
92
|
|
|
97
93
|
```json
|
|
98
94
|
{
|
|
@@ -107,9 +103,9 @@ For fonts like fontawesome6-pro, fontello and icomoon where you provide the font
|
|
|
107
103
|
You can either use one of the bundled icons above or roll your own custom font.
|
|
108
104
|
|
|
109
105
|
```js
|
|
110
|
-
import {
|
|
106
|
+
import { FontAwesomeFreeSolid } from "@react-native-vector-icons/fontawesome-free-solid";
|
|
111
107
|
|
|
112
|
-
<
|
|
108
|
+
<FontAwesomeFreeSolid name="rocket" size={30} color="#900" />;
|
|
113
109
|
```
|
|
114
110
|
|
|
115
111
|
### Props
|
|
@@ -140,20 +136,6 @@ By combining some of these you can create for example :
|
|
|
140
136
|

|
|
141
137
|

|
|
142
138
|
|
|
143
|
-
## Multi-Style Fonts
|
|
144
|
-
|
|
145
|
-
Some fonts today use multiple styles, FontAwesome 6 for example, which is supported by this library. The usage is pretty much the same as the standard `Icon` component:
|
|
146
|
-
|
|
147
|
-
```jsx
|
|
148
|
-
import { FontAwesome5 } from "@react-native-vector-icons/fontawesome5";
|
|
149
|
-
|
|
150
|
-
<FontAwesome5 name="comments" size={30} color="#900" />; // Defaults to regular
|
|
151
|
-
|
|
152
|
-
<FontAwesome5 name="comments" size={30} color="#900" iconType="solid" />
|
|
153
|
-
|
|
154
|
-
<FontAwesome5 name="comments" size={30} color="#900" iconType="light" />
|
|
155
|
-
```
|
|
156
|
-
|
|
157
139
|
## Usage as PNG Image/Source Object
|
|
158
140
|
|
|
159
141
|
Convenient way to plug this in into other components that rely on bitmap images rather than scalable vector icons. Takes the arguments `name`, `size` and `color` as described above.
|
|
@@ -222,7 +204,7 @@ animation library
|
|
|
222
204
|
|
|
223
205
|
Fonts can be available in an app statically (since build time) or loaded dynamically at runtime. The latter can be useful e.g. for apps that use over-the-air updates and want to load new fonts with an update, or when you need to use a font from a remote location.
|
|
224
206
|
|
|
225
|
-
Dynamic loading in `@react-native-vector-icons` is currently limited to those fonts that are bundled within the provided packages: it doesn't support Pro fonts (such as FontAwesome
|
|
207
|
+
Dynamic loading in `@react-native-vector-icons` is currently limited to those fonts that are bundled within the provided packages: it doesn't support Pro fonts (such as FontAwesome Pro). However, loading of custom fonts is not difficult to implement: use `createIconSet` as seen in [custom fonts](#custom-fonts) paragraph to obtain a icon font family with dynamic font loading enabled. See any of the free font packages for reference.
|
|
226
208
|
|
|
227
209
|
By default, dynamic loading is enabled if you run Expo SDK >= 52. It doesn't change the way you work with the package: If rendering an icon requires a font that is not known to the app, it will be loaded automatically and icon will render as expected.
|
|
228
210
|
|
|
@@ -24,10 +24,13 @@ function assertExpoModulesPresent(globalObj) {
|
|
|
24
24
|
throw new Error('Dynamic font loading not supported. Upgrade to latest expo and expo-font.');
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
|
|
28
|
+
// Detection of Expo modules is deferred to first use so that import order
|
|
29
|
+
// doesn't matter. By the time a component renders, all imports (including Expo)
|
|
30
|
+
// have been evaluated and globalThis.expo is available.
|
|
31
|
+
|
|
32
|
+
let dynamicFontLoadingOverride = null;
|
|
33
|
+
const isDynamicLoadingSupported = () => getIsDynamicLoadingSupported(globalThis);
|
|
31
34
|
|
|
32
35
|
/**
|
|
33
36
|
* Set whether dynamic loading of fonts is enabled.
|
|
@@ -39,14 +42,15 @@ const isDynamicLoadingSupported = () => hasNecessaryExpoFeatures;
|
|
|
39
42
|
* */
|
|
40
43
|
exports.isDynamicLoadingSupported = isDynamicLoadingSupported;
|
|
41
44
|
const setDynamicLoadingEnabled = value => {
|
|
42
|
-
if (!
|
|
45
|
+
if (!getIsDynamicLoadingSupported(globalThis)) {
|
|
43
46
|
if (process.env.NODE_ENV !== 'production' && !!value) {
|
|
47
|
+
const hasNecessaryExpoModules = (_reactNative.Platform.OS === 'web' || !!globalThis.expo?.modules?.ExpoAsset) && !!globalThis.expo?.modules?.ExpoFontLoader;
|
|
44
48
|
const message = hasNecessaryExpoModules ? 'Expo is installed, but does not support dynamic font loading. Make sure to use Expo SDK 54 or newer.' : 'Necessary Expo modules not found. Dynamic font loading is not available when necessary Expo modules are not present.';
|
|
45
49
|
console.error(message); // eslint-disable-line no-console
|
|
46
50
|
}
|
|
47
51
|
return false;
|
|
48
52
|
}
|
|
49
|
-
|
|
53
|
+
dynamicFontLoadingOverride = !!value;
|
|
50
54
|
return true;
|
|
51
55
|
};
|
|
52
56
|
|
|
@@ -54,7 +58,7 @@ const setDynamicLoadingEnabled = value => {
|
|
|
54
58
|
* Whether dynamic loading of fonts is enabled.
|
|
55
59
|
* */
|
|
56
60
|
exports.setDynamicLoadingEnabled = setDynamicLoadingEnabled;
|
|
57
|
-
const isDynamicLoadingEnabled = () =>
|
|
61
|
+
const isDynamicLoadingEnabled = () => dynamicFontLoadingOverride ?? getIsDynamicLoadingSupported(globalThis);
|
|
58
62
|
exports.isDynamicLoadingEnabled = isDynamicLoadingEnabled;
|
|
59
63
|
let dynamicLoadingErrorCallback;
|
|
60
64
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNative","require","getIsDynamicLoadingSupported","globalObj","expo","Platform","OS","modules","ExpoAsset","downloadAsync","ExpoFontLoader","getLoadedFonts","loadAsync","getIsRenderToImageSupported","ExpoFontUtils","renderToImageAsync","assertExpoModulesPresent","Error","
|
|
1
|
+
{"version":3,"names":["_reactNative","require","getIsDynamicLoadingSupported","globalObj","expo","Platform","OS","modules","ExpoAsset","downloadAsync","ExpoFontLoader","getLoadedFonts","loadAsync","getIsRenderToImageSupported","ExpoFontUtils","renderToImageAsync","assertExpoModulesPresent","Error","dynamicFontLoadingOverride","isDynamicLoadingSupported","globalThis","exports","setDynamicLoadingEnabled","value","process","env","NODE_ENV","hasNecessaryExpoModules","message","console","error","isDynamicLoadingEnabled","dynamicLoadingErrorCallback","setDynamicLoadingErrorCallback","callback","getErrorCallback"],"sourceRoot":"../../../src","sources":["dynamicLoading/dynamic-loading-setting.ts"],"mappings":";;;;;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAUA;;AAyCA;AACA,SAASC,4BAA4BA,CAACC,SAAc,EAElD;EACA,OACEA,SAAS,EAAEC,IAAI,KACdC,qBAAQ,CAACC,EAAE,KAAK,KAAK,IAAI,OAAOH,SAAS,CA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AK,CAACF,OAAO,CAAC,CAAC,CAAC;IAC1B;IACA,OAAO,KAAK;EACd;EAEAV,0BAA0B,GAAG,CAAC,CAACK,KAAK;EAEpC,OAAO,IAAI;AACb,CAAC;;AAED;AACA;AACA;AAFAF,OAAA,CAAAC,wBAAA,GAAAA,wBAAA;AAGO,MAAMS,uBAAuB,GAAGA,CAAA,KACrCb,0BAA0B,IAAIhB,4BAA4B,CAACkB,UAAU,CAAC;AAACC,OAAA,CAAAU,uBAAA,GAAAA,uBAAA;AAIzE,IAAIC,2BAAsD;;AAE1D;AACA;AACA;AACO,MAAMC,8BAA8B,GAAIC,QAAuB,IAAK;EACzEF,2BAA2B,GAAGE,QAAQ;AACxC,CAAC;AAACb,OAAA,CAAAY,8BAAA,GAAAA,8BAAA;AAEK,MAAME,gBAAgB,GAAGA,CAAA,KAAMH,2BAA2B;AAACX,OAAA,CAAAc,gBAAA,GAAAA,gBAAA","ignoreList":[]}
|
|
@@ -18,10 +18,13 @@ export function assertExpoModulesPresent(globalObj) {
|
|
|
18
18
|
throw new Error('Dynamic font loading not supported. Upgrade to latest expo and expo-font.');
|
|
19
19
|
}
|
|
20
20
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
|
|
22
|
+
// Detection of Expo modules is deferred to first use so that import order
|
|
23
|
+
// doesn't matter. By the time a component renders, all imports (including Expo)
|
|
24
|
+
// have been evaluated and globalThis.expo is available.
|
|
25
|
+
|
|
26
|
+
let dynamicFontLoadingOverride = null;
|
|
27
|
+
export const isDynamicLoadingSupported = () => getIsDynamicLoadingSupported(globalThis);
|
|
25
28
|
|
|
26
29
|
/**
|
|
27
30
|
* Set whether dynamic loading of fonts is enabled.
|
|
@@ -32,21 +35,22 @@ export const isDynamicLoadingSupported = () => hasNecessaryExpoFeatures;
|
|
|
32
35
|
* @returns `true` if dynamic loading of fonts was successfully set. `false` otherwise.
|
|
33
36
|
* */
|
|
34
37
|
export const setDynamicLoadingEnabled = value => {
|
|
35
|
-
if (!
|
|
38
|
+
if (!getIsDynamicLoadingSupported(globalThis)) {
|
|
36
39
|
if (process.env.NODE_ENV !== 'production' && !!value) {
|
|
40
|
+
const hasNecessaryExpoModules = (Platform.OS === 'web' || !!globalThis.expo?.modules?.ExpoAsset) && !!globalThis.expo?.modules?.ExpoFontLoader;
|
|
37
41
|
const message = hasNecessaryExpoModules ? 'Expo is installed, but does not support dynamic font loading. Make sure to use Expo SDK 54 or newer.' : 'Necessary Expo modules not found. Dynamic font loading is not available when necessary Expo modules are not present.';
|
|
38
42
|
console.error(message); // eslint-disable-line no-console
|
|
39
43
|
}
|
|
40
44
|
return false;
|
|
41
45
|
}
|
|
42
|
-
|
|
46
|
+
dynamicFontLoadingOverride = !!value;
|
|
43
47
|
return true;
|
|
44
48
|
};
|
|
45
49
|
|
|
46
50
|
/**
|
|
47
51
|
* Whether dynamic loading of fonts is enabled.
|
|
48
52
|
* */
|
|
49
|
-
export const isDynamicLoadingEnabled = () =>
|
|
53
|
+
export const isDynamicLoadingEnabled = () => dynamicFontLoadingOverride ?? getIsDynamicLoadingSupported(globalThis);
|
|
50
54
|
let dynamicLoadingErrorCallback;
|
|
51
55
|
|
|
52
56
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Platform","getIsDynamicLoadingSupported","globalObj","expo","OS","modules","ExpoAsset","downloadAsync","ExpoFontLoader","getLoadedFonts","loadAsync","getIsRenderToImageSupported","ExpoFontUtils","renderToImageAsync","assertExpoModulesPresent","Error","
|
|
1
|
+
{"version":3,"names":["Platform","getIsDynamicLoadingSupported","globalObj","expo","OS","modules","ExpoAsset","downloadAsync","ExpoFontLoader","getLoadedFonts","loadAsync","getIsRenderToImageSupported","ExpoFontUtils","renderToImageAsync","assertExpoModulesPresent","Error","dynamicFontLoadingOverride","isDynamicLoadingSupported","globalThis","setDynamicLoadingEnabled","value","process","env","NODE_ENV","hasNecessaryExpoModules","message","console","error","isDynamicLoadingEnabled","dynamicLoadingErrorCallback","setDynamicLoadingErrorCallback","callback","getErrorCallback"],"sourceRoot":"../../../src","sources":["dynamicLoading/dynamic-loading-setting.ts"],"mappings":";;AAAA,SAASA,QAAQ,QAAQ,cAAc;;AAUvC;;AAyCA;AACA,SAASC,4BAA4BA,CAACC,SAAc,EAElD;EACA,OACEA,SAAS,EAAEC,IAAI,KACdH,QAAQ,CAACI,EAAE,KAAK,KAAK,IAAI,OAAOF,SAAS,CAACC,IAAI,CAACE,OAAO,EAAEC,SAAS,EAAEC,aAAa,KAAK,UAAU,CAAC,IACjG,OAAOL,SAAS,CAACC,IAAI,CAACE,OAAO,EAAEG,cAAc,EAAEC,cAAc,KAAK,UAAU,IAC5E,OAAOP,SAAS,CAACC,IAAI,CAACE,OAAO,EAAEG,cAAc,EAAEE,SAAS,KAAK,UAAU;AAE3E;;AAEA;AACA,OAAO,SAASC,2BAA2BA,CAACT,SAAc,EAMxD;EACA,OAAOA,SAAS,EAAEC,IAAI,IAAI,OAAOD,SAAS,CAACC,IAAI,CAACE,OAAO,EAAEO,aAAa,EAAEC,kBAAkB,KAAK,UAAU;AAC3G;AAEA,OAAO,SAASC,wBAAwBA,CAACZ,SAAkB,EAAiD;EAC1G,IAAI,CAACD,4BAA4B,CAACC,SAAS,CAAC,EAAE;IAC5C,MAAM,IAAIa,KAAK,CAAC,2EAA2E,CAAC;EAC9F;AACF;;AAEA;AACA;AACA;;AAEA,IAAIC,0BAA0C,GAAG,IAAI;AAErD,OAAO,MAAMC,yBAAyB,GAAGA,CAAA,KAAMhB,4BAA4B,CAACiB,UAAU,CAAC;;AAEvF;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,wBAAwB,GAAIC,KAAc,IAAc;EACnE,IAAI,CAACnB,4BAA4B,CAACiB,UAAU,CAAC,EAAE;IAC7C,IAAIG,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,IAAI,CAAC,CAACH,KAAK,EAAE;MACpD,MAAMI,uBAAuB,GAC3B,CAACxB,QAAQ,CAACI,EAAE,KAAK,KAAK,IAAI,CAAC,CAACc,UAAU,CAACf,IAAI,EAAEE,OAAO,EAAEC,SAAS,KAAK,CAAC,CAACY,UAAU,CAACf,IAAI,EAAEE,OAAO,EAAEG,cAAc;MAChH,MAAMiB,OAAO,GAAGD,uBAAuB,GACnC,sGAAsG,GACtG,sHAAsH;MAC1HE,OAAO,CAACC,KAAK,CAACF,OAAO,CAAC,CAAC,CAAC;IAC1B;IACA,OAAO,KAAK;EACd;EAEAT,0BAA0B,GAAG,CAAC,CAACI,KAAK;EAEpC,OAAO,IAAI;AACb,CAAC;;AAED;AACA;AACA;AACA,OAAO,MAAMQ,uBAAuB,GAAGA,CAAA,KACrCZ,0BAA0B,IAAIf,4BAA4B,CAACiB,UAAU,CAAC;AAIxE,IAAIW,2BAAsD;;AAE1D;AACA;AACA;AACA,OAAO,MAAMC,8BAA8B,GAAIC,QAAuB,IAAK;EACzEF,2BAA2B,GAAGE,QAAQ;AACxC,CAAC;AAED,OAAO,MAAMC,gBAAgB,GAAGA,CAAA,KAAMH,2BAA2B","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dynamic-loading-setting.d.ts","sourceRoot":"","sources":["../../../../../src/dynamicLoading/dynamic-loading-setting.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE1C,KAAK,eAAe,GAAG;IAGrB,aAAa,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,SAAS,EAAE,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;CACzF,CAAC;AAGF,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC;AAEvE,KAAK,oBAAoB,GAAG;IAG1B,cAAc,EAAE,MAAM,MAAM,EAAE,CAAC;IAC/B,SAAS,EAAE,CAAC,eAAe,EAAE,MAAM,EAAE,KAAK,EAAE,cAAc,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9E,CAAC;AAEF,KAAK,mBAAmB,GAAG;IACzB,kBAAkB,EAAE,CAClB,KAAK,EAAE,MAAM,EACb,OAAO,EAAE;QACP,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,KACE,OAAO,CAAC,MAAM,CAAC,CAAC;CACtB,CAAC;AAEF,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,UAAU;QAClB,OAAO,EAAE;YACP,SAAS,CAAC,EAAE,eAAe,CAAC;YAC5B,cAAc,CAAC,EAAE,oBAAoB,CAAC;YACtC,aAAa,CAAC,EAAE,mBAAmB,CAAC;SACrC,CAAC;KACH;IAGD,IAAI,IAAI,EAAE,UAAU,GAAG,SAAS,CAAC;CAClC;AAED,KAAK,cAAc,GAAG;IACpB,OAAO,EAAE;QACP,SAAS,EAAE,eAAe,CAAC;QAC3B,cAAc,EAAE,oBAAoB,CAAC;KACtC,CAAC;CACH,CAAC;AAeF,wBAAgB,2BAA2B,CAAC,SAAS,EAAE,GAAG,GAAG,SAAS,IAAI;IACxE,IAAI,EAAE;QACJ,OAAO,EAAE;YACP,aAAa,EAAE,mBAAmB,CAAC;SACpC,CAAC;KACH,CAAC;CACH,CAEA;AAED,wBAAgB,wBAAwB,CAAC,SAAS,EAAE,OAAO,GAAG,OAAO,CAAC,SAAS,IAAI;IAAE,IAAI,EAAE,cAAc,CAAA;CAAE,CAI1G;
|
|
1
|
+
{"version":3,"file":"dynamic-loading-setting.d.ts","sourceRoot":"","sources":["../../../../../src/dynamicLoading/dynamic-loading-setting.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE1C,KAAK,eAAe,GAAG;IAGrB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AAC;AAEF,KAAK,mBAAmB,GAAG;IACzB,kBAAkB,EAAE,CAClB,KAAK,EAAE,MAAM,EACb,OAAO,EAAE;QACP,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,KACE,OAAO,CAAC,MAAM,CAAC,CAAC;CACtB,CAAC;AAEF,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,UAAU;QAClB,OAAO,EAAE;YACP,SAAS,CAAC,EAAE,eAAe,CAAC;YAC5B,cAAc,CAAC,EAAE,oBAAoB,CAAC;YACtC,aAAa,CAAC,EAAE,mBAAmB,CAAC;SACrC,CAAC;KACH;IAGD,IAAI,IAAI,EAAE,UAAU,GAAG,SAAS,CAAC;CAClC;AAED,KAAK,cAAc,GAAG;IACpB,OAAO,EAAE;QACP,SAAS,EAAE,eAAe,CAAC;QAC3B,cAAc,EAAE,oBAAoB,CAAC;KACtC,CAAC;CACH,CAAC;AAeF,wBAAgB,2BAA2B,CAAC,SAAS,EAAE,GAAG,GAAG,SAAS,IAAI;IACxE,IAAI,EAAE;QACJ,OAAO,EAAE;YACP,aAAa,EAAE,mBAAmB,CAAC;SACpC,CAAC;KACH,CAAC;CACH,CAEA;AAED,wBAAgB,wBAAwB,CAAC,SAAS,EAAE,OAAO,GAAG,OAAO,CAAC,SAAS,IAAI;IAAE,IAAI,EAAE,cAAc,CAAA;CAAE,CAI1G;
|
|
1
|
+
{"version":3,"file":"dynamic-loading-setting.d.ts","sourceRoot":"","sources":["../../../../../src/dynamicLoading/dynamic-loading-setting.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE1C,KAAK,eAAe,GAAG;IAGrB,aAAa,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,SAAS,EAAE,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAA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QD,eAAO,MAAM,yBAAyB,eAAiD,CAAC;AAExF;;;;;;;KAOK;AACL,eAAO,MAAM,wBAAwB,GAAI,OAAO,OAAO,KAAG,OAgBzD,CAAC;AAEF;;KAEK;AACL,eAAO,MAAM,uBAAuB,QAAO,OAC6B,CAAC;AAEzE,KAAK,aAAa,GAAG,CAAC,IAAI,EAAE;IAAE,KAAK,EAAE,KAAK,CAAC;IAAC,UAAU,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,UAAU,CAAA;CAAE,KAAK,IAAI,CAAC;AAIlG;;KAEK;AACL,eAAO,MAAM,8BAA8B,GAAI,UAAU,aAAa,SAErE,CAAC;AAEF,eAAO,MAAM,gBAAgB,iCAAoC,CAAC"}
|
package/package.json
CHANGED
|
@@ -78,14 +78,13 @@ export function assertExpoModulesPresent(globalObj: unknown): asserts globalObj
|
|
|
78
78
|
}
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
|
|
82
|
-
|
|
81
|
+
// Detection of Expo modules is deferred to first use so that import order
|
|
82
|
+
// doesn't matter. By the time a component renders, all imports (including Expo)
|
|
83
|
+
// have been evaluated and globalThis.expo is available.
|
|
83
84
|
|
|
84
|
-
|
|
85
|
+
let dynamicFontLoadingOverride: boolean | null = null;
|
|
85
86
|
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
export const isDynamicLoadingSupported = () => hasNecessaryExpoFeatures;
|
|
87
|
+
export const isDynamicLoadingSupported = () => getIsDynamicLoadingSupported(globalThis);
|
|
89
88
|
|
|
90
89
|
/**
|
|
91
90
|
* Set whether dynamic loading of fonts is enabled.
|
|
@@ -96,8 +95,10 @@ export const isDynamicLoadingSupported = () => hasNecessaryExpoFeatures;
|
|
|
96
95
|
* @returns `true` if dynamic loading of fonts was successfully set. `false` otherwise.
|
|
97
96
|
* */
|
|
98
97
|
export const setDynamicLoadingEnabled = (value: boolean): boolean => {
|
|
99
|
-
if (!
|
|
98
|
+
if (!getIsDynamicLoadingSupported(globalThis)) {
|
|
100
99
|
if (process.env.NODE_ENV !== 'production' && !!value) {
|
|
100
|
+
const hasNecessaryExpoModules =
|
|
101
|
+
(Platform.OS === 'web' || !!globalThis.expo?.modules?.ExpoAsset) && !!globalThis.expo?.modules?.ExpoFontLoader;
|
|
101
102
|
const message = hasNecessaryExpoModules
|
|
102
103
|
? 'Expo is installed, but does not support dynamic font loading. Make sure to use Expo SDK 54 or newer.'
|
|
103
104
|
: 'Necessary Expo modules not found. Dynamic font loading is not available when necessary Expo modules are not present.';
|
|
@@ -106,7 +107,7 @@ export const setDynamicLoadingEnabled = (value: boolean): boolean => {
|
|
|
106
107
|
return false;
|
|
107
108
|
}
|
|
108
109
|
|
|
109
|
-
|
|
110
|
+
dynamicFontLoadingOverride = !!value;
|
|
110
111
|
|
|
111
112
|
return true;
|
|
112
113
|
};
|
|
@@ -114,7 +115,8 @@ export const setDynamicLoadingEnabled = (value: boolean): boolean => {
|
|
|
114
115
|
/**
|
|
115
116
|
* Whether dynamic loading of fonts is enabled.
|
|
116
117
|
* */
|
|
117
|
-
export const isDynamicLoadingEnabled = () =>
|
|
118
|
+
export const isDynamicLoadingEnabled = (): boolean =>
|
|
119
|
+
dynamicFontLoadingOverride ?? getIsDynamicLoadingSupported(globalThis);
|
|
118
120
|
|
|
119
121
|
type ErrorCallback = (args: { error: Error; fontFamily: string; fontSource: FontSource }) => void;
|
|
120
122
|
|