@react-native-vector-icons/common 12.4.1 → 13.0.0
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 +30 -19
- package/lib/commonjs/create-icon-set.js +25 -17
- package/lib/commonjs/create-icon-set.js.map +1 -1
- package/lib/commonjs/create-icon-source-cache.js +3 -26
- package/lib/commonjs/create-icon-source-cache.js.map +1 -1
- package/lib/commonjs/dynamicLoading/dynamic-font-loading.js +0 -1
- package/lib/commonjs/dynamicLoading/dynamic-font-loading.js.map +1 -1
- package/lib/commonjs/dynamicLoading/dynamic-loading-setting.js +3 -0
- package/lib/commonjs/dynamicLoading/dynamic-loading-setting.js.map +1 -1
- package/lib/commonjs/get-image-library.js +8 -7
- package/lib/commonjs/get-image-library.js.map +1 -1
- package/lib/commonjs/get-image-source.js +39 -45
- package/lib/commonjs/get-image-source.js.map +1 -1
- package/lib/module/create-icon-set.js +24 -13
- package/lib/module/create-icon-set.js.map +1 -1
- package/lib/module/create-icon-source-cache.js +3 -26
- package/lib/module/create-icon-source-cache.js.map +1 -1
- package/lib/module/dynamicLoading/dynamic-font-loading.js +0 -1
- package/lib/module/dynamicLoading/dynamic-font-loading.js.map +1 -1
- package/lib/module/dynamicLoading/dynamic-loading-setting.js +3 -0
- package/lib/module/dynamicLoading/dynamic-loading-setting.js.map +1 -1
- package/lib/module/get-image-library.js +8 -8
- package/lib/module/get-image-library.js.map +1 -1
- package/lib/module/get-image-source.js +39 -45
- package/lib/module/get-image-source.js.map +1 -1
- package/lib/typescript/commonjs/src/create-icon-set.d.ts +9 -5
- package/lib/typescript/commonjs/src/create-icon-set.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/create-icon-source-cache.d.ts +18 -15
- package/lib/typescript/commonjs/src/create-icon-source-cache.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/dynamicLoading/dynamic-font-loading.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/dynamicLoading/dynamic-loading-setting.d.ts +21 -2
- package/lib/typescript/commonjs/src/dynamicLoading/dynamic-loading-setting.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/get-image-library.d.ts +7 -3
- package/lib/typescript/commonjs/src/get-image-library.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/get-image-source.d.ts +7 -8
- package/lib/typescript/commonjs/src/get-image-source.d.ts.map +1 -1
- package/lib/typescript/module/src/create-icon-set.d.ts +9 -5
- package/lib/typescript/module/src/create-icon-set.d.ts.map +1 -1
- package/lib/typescript/module/src/create-icon-source-cache.d.ts +18 -15
- package/lib/typescript/module/src/create-icon-source-cache.d.ts.map +1 -1
- package/lib/typescript/module/src/dynamicLoading/dynamic-font-loading.d.ts.map +1 -1
- package/lib/typescript/module/src/dynamicLoading/dynamic-loading-setting.d.ts +21 -2
- package/lib/typescript/module/src/dynamicLoading/dynamic-loading-setting.d.ts.map +1 -1
- package/lib/typescript/module/src/get-image-library.d.ts +7 -3
- package/lib/typescript/module/src/get-image-library.d.ts.map +1 -1
- package/lib/typescript/module/src/get-image-source.d.ts +7 -8
- package/lib/typescript/module/src/get-image-source.d.ts.map +1 -1
- package/package.json +6 -2
- package/src/create-icon-set.tsx +41 -26
- package/src/create-icon-source-cache.ts +27 -28
- package/src/dynamicLoading/dynamic-font-loading.ts +0 -1
- package/src/dynamicLoading/dynamic-loading-setting.ts +25 -2
- package/src/get-image-library.ts +19 -9
- package/src/get-image-source.ts +36 -54
package/README.md
CHANGED
|
@@ -72,12 +72,12 @@ See [MIGRATION.md](MIGRATION.md) if you are migrating from `react-native-vector-
|
|
|
72
72
|
|
|
73
73
|
1. Install the packages for the icons you want to use
|
|
74
74
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
75
|
+
```sh
|
|
76
|
+
npm install @react-native-vector-icons/fontawesome-free-solid @react-native-vector-icons/evil-icons
|
|
77
|
+
```
|
|
78
78
|
|
|
79
|
-
|
|
80
|
-
|
|
79
|
+
2. Depending on the platform you're targeting (iOS/Android/Windows), follow the appropriate setup instructions below.
|
|
80
|
+
3. If you are using one of the following fonts, refer to their guides for further instructions
|
|
81
81
|
|
|
82
82
|
- [Fontello](packages/fontello/README.md)
|
|
83
83
|
- [Icomoon](packages/icomoon/README.md)
|
|
@@ -88,7 +88,7 @@ Refer to the guide for [Expo](./docs/SETUP-EXPO.md), [React Native](./docs/SETUP
|
|
|
88
88
|
|
|
89
89
|
### Font location customisation
|
|
90
90
|
|
|
91
|
-
For fonts like the FontAwesome Pro as well as
|
|
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.
|
|
92
92
|
|
|
93
93
|
```json
|
|
94
94
|
{
|
|
@@ -104,6 +104,8 @@ You can either use one of the bundled icons above or roll your own custom font.
|
|
|
104
104
|
|
|
105
105
|
```js
|
|
106
106
|
import { FontAwesomeFreeSolid } from "@react-native-vector-icons/fontawesome-free-solid";
|
|
107
|
+
// or use the static version if you don't need [dynamic font loading](#dynamic-icon-font-loading) to get a slightly smaller bundle size
|
|
108
|
+
import { FontAwesomeFreeSolid } from "@react-native-vector-icons/fontawesome-free-solid/static";
|
|
107
109
|
|
|
108
110
|
<FontAwesomeFreeSolid name="rocket" size={30} color="#900" />;
|
|
109
111
|
```
|
|
@@ -138,29 +140,38 @@ By combining some of these you can create for example :
|
|
|
138
140
|
|
|
139
141
|
## Usage as PNG Image/Source Object
|
|
140
142
|
|
|
141
|
-
Convenient way to plug this in into other components that rely on bitmap images rather than scalable vector icons.
|
|
143
|
+
Convenient way to plug this in into other components that rely on bitmap images rather than scalable vector icons.
|
|
144
|
+
|
|
145
|
+
You need to use Expo (with `expo-font` installed) _or_ install `@react-native-vector-icons/get-image` to use this feature.
|
|
142
146
|
|
|
143
|
-
|
|
147
|
+
Both methods return an `ImageResult` object (`{ uri, width, height, scale }`) that can be passed directly as an `Image` source.
|
|
144
148
|
|
|
145
149
|
```jsx
|
|
146
150
|
const source = Icon.getImageSourceSync('user', 20, 'red');
|
|
151
|
+
// or with an options object:
|
|
152
|
+
const source = Icon.getImageSourceSync('user', { size: 20, color: 'red', lineHeight: 28 });
|
|
147
153
|
|
|
148
154
|
return <Image source={source} />;
|
|
149
|
-
);
|
|
150
155
|
```
|
|
151
156
|
|
|
152
157
|
Alternatively you may use the async method `Icon.getImageSource`.
|
|
153
158
|
|
|
154
|
-
|
|
159
|
+
```jsx
|
|
160
|
+
const source = await Icon.getImageSource('user', 20, 'red');
|
|
161
|
+
// or with an options object:
|
|
162
|
+
const source = await Icon.getImageSource('user', { size: 20, color: 'red' });
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
Keep in mind that `Icon.getImageSourceSync` is blocking and might incur performance penalties. Subsequent calls will use cache, however.
|
|
155
166
|
|
|
156
167
|
### Static methods
|
|
157
168
|
|
|
158
169
|
All static methods from `Icon` are supported by multi-styled fonts.
|
|
159
170
|
|
|
160
|
-
|
|
|
171
|
+
| Method | Description |
|
|
161
172
|
| ------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
162
|
-
| **`getImageSource`** | Returns a promise
|
|
163
|
-
| **`getImageSourceSync`** | Same as `getImageSource` but synchronous. Usage: `const source = Icon.getImageSourceSync(name, size, color)`
|
|
173
|
+
| **`getImageSource`** | Returns a promise resolving to an `ImageResult` of a bitmap version of the icon. Usage: `const source = await Icon.getImageSource(name, { size, color, lineHeight })` |
|
|
174
|
+
| **`getImageSourceSync`** | Same as `getImageSource` but synchronous. Usage: `const source = Icon.getImageSourceSync(name, { size, color, lineHeight })` |
|
|
164
175
|
|
|
165
176
|
## Custom Fonts
|
|
166
177
|
|
|
@@ -200,9 +211,9 @@ animation library
|
|
|
200
211
|
|
|
201
212
|
## Dynamic icon font loading
|
|
202
213
|
|
|
203
|
-
> Dynamic loading is supported on all platforms if you use Expo ([Expo Go](https://expo.dev/go) or a development
|
|
214
|
+
> Dynamic loading is supported on all platforms if you use Expo ([Expo Go](https://expo.dev/go) or a [development build](https://docs.expo.dev/develop/development-builds/introduction/)). In the future, it should become available for all React Native projects via React Native core.
|
|
204
215
|
|
|
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.
|
|
216
|
+
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](https://docs.expo.dev/versions/latest/sdk/font/#loadasyncfontfamilyorfontmap-source) new fonts with an update, or when you need to use a font from a remote location. If you don't use dynamic loading, use the `/static` imports (e.g. `"@react-native-vector-icons/ionicons/static"`).
|
|
206
217
|
|
|
207
218
|
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.
|
|
208
219
|
|
|
@@ -226,10 +237,10 @@ Try the `IconExplorer` project in `Examples/IconExplorer` folder, there you can
|
|
|
226
237
|
### Basic Example
|
|
227
238
|
|
|
228
239
|
```js
|
|
229
|
-
import { IonIcons } from "@react-native-vector-icons/ionicons";
|
|
240
|
+
import { IonIcons } from "@react-native-vector-icons/ionicons/static";
|
|
230
241
|
|
|
231
242
|
const ExampleView = () => (
|
|
232
|
-
<
|
|
243
|
+
<IonIcons name="ios-person" size={30} color="#4F8EF7" />
|
|
233
244
|
);
|
|
234
245
|
```
|
|
235
246
|
|
|
@@ -237,11 +248,11 @@ const ExampleView = () => (
|
|
|
237
248
|
|
|
238
249
|
```js
|
|
239
250
|
import { Text } from "react-native";
|
|
240
|
-
import { IonIcons } from "@react-native-vector-icons/ionicons";
|
|
251
|
+
import { IonIcons } from "@react-native-vector-icons/ionicons/static";
|
|
241
252
|
|
|
242
253
|
const ExampleView = (props) => (
|
|
243
254
|
<Text>
|
|
244
|
-
Lorem <
|
|
255
|
+
Lorem <IonIcons name="ios-book" color="#4F8EF7" /> Ipsum
|
|
245
256
|
</Text>
|
|
246
257
|
);
|
|
247
258
|
```
|
|
@@ -6,18 +6,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
exports.createIconSet = createIconSet;
|
|
7
7
|
var _react = _interopRequireWildcard(require("react"));
|
|
8
8
|
var _reactNative = require("react-native");
|
|
9
|
-
var _createIconSourceCache =
|
|
9
|
+
var _createIconSourceCache = require("./create-icon-source-cache.js");
|
|
10
10
|
var _defaults = require("./defaults.js");
|
|
11
11
|
var _dynamicFontLoading = require("./dynamicLoading/dynamic-font-loading.js");
|
|
12
12
|
var _dynamicLoadingSetting = require("./dynamicLoading/dynamic-loading-setting.js");
|
|
13
13
|
var _getImageSource = require("./get-image-source.js");
|
|
14
14
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
15
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
16
15
|
function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
|
|
17
|
-
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
18
|
-
|
|
19
|
-
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
20
|
-
|
|
21
16
|
function createIconSet(glyphMap, postScriptNameOrOptions, fontFileNameParam, fontStyleParam) {
|
|
22
17
|
const {
|
|
23
18
|
postScriptName,
|
|
@@ -39,6 +34,7 @@ function createIconSet(glyphMap, postScriptNameOrOptions, fontFileNameParam, fon
|
|
|
39
34
|
fontWeight: 'normal',
|
|
40
35
|
fontStyle: 'normal'
|
|
41
36
|
};
|
|
37
|
+
const fontSource = typeof postScriptNameOrOptions === 'object' && postScriptNameOrOptions?.fontSource;
|
|
42
38
|
const resolveGlyph = name => {
|
|
43
39
|
const glyph = glyphMap[name] || '?';
|
|
44
40
|
if (typeof glyph === 'number') {
|
|
@@ -56,14 +52,15 @@ function createIconSet(glyphMap, postScriptNameOrOptions, fontFileNameParam, fon
|
|
|
56
52
|
innerRef,
|
|
57
53
|
...props
|
|
58
54
|
}) => {
|
|
59
|
-
const
|
|
55
|
+
const canUseDynamicLoading = !!fontSource && (0, _dynamicLoadingSetting.isDynamicLoadingEnabled)();
|
|
56
|
+
const [isFontLoaded, setIsFontLoaded] = _react.default.useState(canUseDynamicLoading ? _dynamicFontLoading.dynamicLoader.isLoaded(fontReference) : true);
|
|
60
57
|
const glyph = isFontLoaded && name ? resolveGlyph(name) : '';
|
|
61
|
-
|
|
58
|
+
const shouldLoadFontDynamically = !isFontLoaded && canUseDynamicLoading;
|
|
62
59
|
// biome-ignore lint/correctness/useExhaustiveDependencies: the dependencies never change
|
|
63
60
|
(0, _react.useEffect)(() => {
|
|
64
61
|
let isMounted = true;
|
|
65
|
-
if (
|
|
66
|
-
_dynamicFontLoading.dynamicLoader.loadFontAsync(fontReference,
|
|
62
|
+
if (shouldLoadFontDynamically) {
|
|
63
|
+
_dynamicFontLoading.dynamicLoader.loadFontAsync(fontReference, fontSource).finally(() => {
|
|
67
64
|
if (isMounted) {
|
|
68
65
|
setIsFontLoaded(true);
|
|
69
66
|
}
|
|
@@ -79,7 +76,7 @@ function createIconSet(glyphMap, postScriptNameOrOptions, fontFileNameParam, fon
|
|
|
79
76
|
};
|
|
80
77
|
const newProps = {
|
|
81
78
|
...props,
|
|
82
|
-
style: [styleDefaults, style, styleOverrides, fontStyle
|
|
79
|
+
style: [styleDefaults, style, styleOverrides, fontStyle],
|
|
83
80
|
allowFontScaling
|
|
84
81
|
};
|
|
85
82
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.Text, {
|
|
@@ -94,14 +91,25 @@ function createIconSet(glyphMap, postScriptNameOrOptions, fontFileNameParam, fon
|
|
|
94
91
|
...props
|
|
95
92
|
}));
|
|
96
93
|
WrappedIcon.displayName = `Icon(${postScriptName})`;
|
|
97
|
-
const imageSourceCache = (0, _createIconSourceCache.
|
|
98
|
-
const getImageSource = async (name,
|
|
99
|
-
|
|
100
|
-
|
|
94
|
+
const imageSourceCache = (0, _createIconSourceCache.createIconSourceCache)();
|
|
95
|
+
const getImageSource = async (name, sizeOrOptions, color) => {
|
|
96
|
+
const canUseDynamicLoading = !!fontSource && (0, _dynamicLoadingSetting.isDynamicLoadingEnabled)();
|
|
97
|
+
if (canUseDynamicLoading && !_dynamicFontLoading.dynamicLoader.isLoaded(fontReference)) {
|
|
98
|
+
await _dynamicFontLoading.dynamicLoader.loadFontAsync(fontReference, fontSource);
|
|
101
99
|
}
|
|
102
|
-
|
|
100
|
+
const options = typeof sizeOrOptions === 'object' ? sizeOrOptions : {
|
|
101
|
+
size: sizeOrOptions,
|
|
102
|
+
color
|
|
103
|
+
};
|
|
104
|
+
return (0, _getImageSource.getImageSource)(imageSourceCache, fontReference, resolveGlyph(name), options);
|
|
105
|
+
};
|
|
106
|
+
const getImageSourceSync = (name, sizeOrOptions, color) => {
|
|
107
|
+
const options = typeof sizeOrOptions === 'object' ? sizeOrOptions : {
|
|
108
|
+
size: sizeOrOptions,
|
|
109
|
+
color
|
|
110
|
+
};
|
|
111
|
+
return (0, _getImageSource.getImageSourceSync)(imageSourceCache, fontReference, resolveGlyph(name), options);
|
|
103
112
|
};
|
|
104
|
-
const getImageSourceSync = (name, size, color) => (0, _getImageSource.getImageSourceSync)(imageSourceCache, fontReference, resolveGlyph(name), size, color);
|
|
105
113
|
const IconNamespace = Object.assign(WrappedIcon, {
|
|
106
114
|
getImageSource,
|
|
107
115
|
getImageSourceSync
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_createIconSourceCache","
|
|
1
|
+
{"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_createIconSourceCache","_defaults","_dynamicFontLoading","_dynamicLoadingSetting","_getImageSource","_jsxRuntime","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","createIconSet","glyphMap","postScriptNameOrOptions","fontFileNameParam","fontStyleParam","postScriptName","fontFileName","fontStyle","fontBasename","replace","fontReference","Platform","select","windows","android","styleOverrides","fontFamily","fontWeight","fontSource","resolveGlyph","name","glyph","String","fromCodePoint","Icon","size","DEFAULT_ICON_SIZE","color","DEFAULT_ICON_COLOR","style","children","allowFontScaling","innerRef","props","canUseDynamicLoading","isDynamicLoadingEnabled","isFontLoaded","setIsFontLoaded","React","useState","dynamicLoader","isLoaded","shouldLoadFontDynamically","useEffect","isMounted","loadFontAsync","finally","styleDefaults","fontSize","newProps","jsxs","Text","ref","selectable","WrappedIcon","forwardRef","jsx","displayName","imageSourceCache","createIconSourceCache","getImageSource","sizeOrOptions","options","getImageSourceImpl","getImageSourceSync","getImageSourceSyncImpl","IconNamespace","assign"],"sourceRoot":"../../src","sources":["create-icon-set.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AACA,IAAAC,YAAA,GAAAD,OAAA;AAEA,IAAAE,sBAAA,GAAAF,OAAA;AACA,IAAAG,SAAA,GAAAH,OAAA;AACA,IAAAI,mBAAA,GAAAJ,OAAA;AACA,IAAAK,sBAAA,GAAAL,OAAA;AAEA,IAAAM,eAAA,GAAAN,OAAA;AAI4B,IAAAO,WAAA,GAAAP,OAAA;AAAA,SAAAD,wBAAAS,CAAA,EAAAC,CAAA,6BAAAC,OAAA,MAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAA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Aa,CAACC,QAAQ,CAAC/B,aAAa,CAAC,EAAE;MAClE,MAAM8B,iCAAa,CAACK,aAAa,CAACnC,aAAa,EAAEQ,UAAU,CAAC;IAC9D;IACA,MAAM4C,OAAO,GAAG,OAAOD,aAAa,KAAK,QAAQ,GAAGA,aAAa,GAAG;MAAEpC,IAAI,EAAEoC,aAAa;MAAElC;IAAM,CAAC;IAClG,OAAO,IAAAoC,8BAAkB,EAACL,gBAAgB,EAAEhD,aAAa,EAAES,YAAY,CAACC,IAAI,CAAC,EAAE0C,OAAO,CAAC;EACzF,CAAC;EAED,MAAME,kBAAwD,GAAGA,CAC/D5C,IAAc,EACdyC,aAA8C,EAC9ClC,KAA0B,KACvB;IACH,MAAMmC,OAAO,GAAG,OAAOD,aAAa,KAAK,QAAQ,GAAGA,aAAa,GAAG;MAAEpC,IAAI,EAAEoC,aAAa;MAAElC;IAAM,CAAC;IAClG,OAAO,IAAAsC,kCAAsB,EAACP,gBAAgB,EAAEhD,aAAa,EAAES,YAAY,CAACC,IAAI,CAAC,EAAE0C,OAAO,CAAC;EAC7F,CAAC;EAED,MAAMI,aAAa,GAAGrE,MAAM,CAACsE,MAAM,CAACb,WAAW,EAAE;IAC/CM,cAAc;IACdI;EACF,CAAC,CAAC;EAEF,OAAOE,aAAa;AACtB","ignoreList":[]}
|
|
@@ -3,36 +3,13 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
7
|
-
const TYPE_VALUE = 'value';
|
|
8
|
-
const TYPE_ERROR = 'error';
|
|
6
|
+
exports.createIconSourceCache = createIconSourceCache;
|
|
9
7
|
function createIconSourceCache() {
|
|
10
8
|
const cache = new Map();
|
|
11
|
-
const setValue = (key, value) => cache.set(key,
|
|
12
|
-
|
|
13
|
-
data: value
|
|
14
|
-
});
|
|
15
|
-
const setError = (key, error) => cache.set(key, {
|
|
16
|
-
type: TYPE_ERROR,
|
|
17
|
-
data: error
|
|
18
|
-
});
|
|
19
|
-
const get = key => {
|
|
20
|
-
const value = cache.get(key);
|
|
21
|
-
if (!value) {
|
|
22
|
-
return undefined;
|
|
23
|
-
}
|
|
24
|
-
const {
|
|
25
|
-
type,
|
|
26
|
-
data
|
|
27
|
-
} = value;
|
|
28
|
-
if (type === TYPE_ERROR) {
|
|
29
|
-
throw data;
|
|
30
|
-
}
|
|
31
|
-
return data;
|
|
32
|
-
};
|
|
9
|
+
const setValue = (key, value) => cache.set(key, value);
|
|
10
|
+
const get = key => cache.get(key);
|
|
33
11
|
return {
|
|
34
12
|
setValue,
|
|
35
|
-
setError,
|
|
36
13
|
get
|
|
37
14
|
};
|
|
38
15
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["createIconSourceCache","cache","Map","setValue","key","value","set","get"],"sourceRoot":"../../src","sources":["create-icon-source-cache.ts"],"mappings":";;;;;;AAmBO,SAASA,qBAAqBA,CAAA,EAAG;EACtC,MAAMC,KAAK,GAAG,IAAIC,GAAG,CAAsB,CAAC;EAE5C,MAAMC,QAAQ,GAAGA,CAACC,GAAW,EAAEC,KAAkB,KAAKJ,KAAK,CAACK,GAAG,CAACF,GAAG,EAAEC,KAAK,CAAC;EAE3E,MAAME,GAAG,GAAIH,GAAW,IAAKH,KAAK,CAACM,GAAG,CAACH,GAAG,CAAC;EAE3C,OAAO;IAAED,QAAQ;IAAEI;EAAI,CAAC;AAC1B","ignoreList":[]}
|
|
@@ -13,7 +13,6 @@ var _dynamicLoadingSetting = require("./dynamic-loading-setting.js");
|
|
|
13
13
|
* */
|
|
14
14
|
|
|
15
15
|
// @ts-expect-error missing types
|
|
16
|
-
// eslint-disable-next-line import/no-extraneous-dependencies,import/no-unresolved
|
|
17
16
|
|
|
18
17
|
const loadPromises = {};
|
|
19
18
|
const loadFontAsync = async (fontFamily, fontSource) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["_reactNative","require","_registry","_dynamicLoadingSetting","loadPromises","loadFontAsync","fontFamily","fontSource","globalRef","globalThis","assertExpoModulesPresent","expoModules","expo","modules","LoadFont","localUri","uri","type","hash","getLocalFontUrl","ExpoAsset","downloadAsync","asset","Platform","select","web","display","default","ExpoFontLoader","loadAsync","error","console","getErrorCallback","fontModuleId","assetMeta","getAssetByID","Error","String","assetSource","Image","resolveAssetSource","loadedFontsCache","isLoadedNative","loadedNativeFonts","getLoadedFonts","forEach","font","dynamicLoader","exports","isLoaded"],"sourceRoot":"../../../src","sources":["dynamicLoading/dynamic-font-loading.ts"],"mappings":";;;;;;AAIA,IAAAA,YAAA,GAAAC,OAAA;
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_registry","_dynamicLoadingSetting","loadPromises","loadFontAsync","fontFamily","fontSource","globalRef","globalThis","assertExpoModulesPresent","expoModules","expo","modules","LoadFont","localUri","uri","type","hash","getLocalFontUrl","ExpoAsset","downloadAsync","asset","Platform","select","web","display","default","ExpoFontLoader","loadAsync","error","console","getErrorCallback","fontModuleId","assetMeta","getAssetByID","Error","String","assetSource","Image","resolveAssetSource","loadedFontsCache","isLoadedNative","loadedNativeFonts","getLoadedFonts","forEach","font","dynamicLoader","exports","isLoaded"],"sourceRoot":"../../../src","sources":["dynamicLoading/dynamic-font-loading.ts"],"mappings":";;;;;;AAIA,IAAAA,YAAA,GAAAC,OAAA;AAGA,IAAAC,SAAA,GAAAD,OAAA;AAEA,IAAAE,sBAAA,GAAAF,OAAA;AATA;AACA;AACA;AACA;;AAGA;;AAMA,MAAMG,YAAqD,GAAG,CAAC,CAAC;AAEhE,MAAMC,aAAa,GAAG,MAAAA,CAAOC,UAAkB,EAAEC,UAAsB,KAAoB;EACzF,MAAMC,SAAS,GAAGC,UAAU;EAC5B,IAAAC,+CAAwB,EAACF,SAAS,CAAC;EAEnC,MAAMG,WAAW,GAAGH,SAAS,CAACI,IAAI,CAACC,OAAO;EAE1C,IAAIT,YAAY,CAACE,UAAU,CAAC,E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AAM,IAAIE,KAAK,CAAC,mCAAmC9B,UAAU,gBAAgB+B,MAAM,CAACJ,YAAY,CAAC,EAAE,CAAC;EACtG;EAEA,MAAMK,WAAW,GAAGC,kBAAK,CAACC,kBAAkB,CAACP,YAAY,CAAC;EAE1D,OAAO;IAAE,GAAGC,SAAS;IAAE,GAAGI;EAAY,CAAC;AACzC,CAAC;AAED,MAAMG,gBAA6C,GAAG,CAAC,CAAC;AAExD,MAAMC,cAAc,GAAIpC,UAAkB,IAAK;EAC7C,IAAIA,UAAU,IAAImC,gBAAgB,EAAE;IAClC,OAAO,IAAI;EACb;EACA,MAAMjC,SAAS,GAAGC,UAAU;EAC5B,IAAAC,+CAAwB,EAACF,SAAS,CAAC;EAEnC,MAAMmC,iBAAiB,GAAGnC,SAAS,CAACI,IAAI,CAACC,OAAO,CAACe,cAAc,CAACgB,cAAc,CAAC,CAAC;EAChFD,iBAAiB,CAACE,OAAO,CAAEC,IAAI,IAAK;IAClCL,gBAAgB,CAACK,IAAI,CAAC,GAAG,IAAI;EAC/B,CAAC,CAAC;EAEF,OAAOxC,UAAU,IAAImC,gBAAgB;AACvC,CAAC;AAEM,MAAMM,aAA4B,GAAAC,OAAA,CAAAD,aAAA,GAAG;EAC1CE,QAAQ,EAAEP,cAAc;EACxBrC;AACF,CAAC","ignoreList":[]}
|
|
@@ -10,6 +10,9 @@ exports.setDynamicLoadingErrorCallback = exports.setDynamicLoadingEnabled = expo
|
|
|
10
10
|
var _reactNative = require("react-native");
|
|
11
11
|
// this is a file:// uri on native, or an object with uri and display on web
|
|
12
12
|
|
|
13
|
+
// RenderToImageResult needs to be usable as the `source` prop for image,
|
|
14
|
+
// so it must stay compatible with ImageURISource type
|
|
15
|
+
|
|
13
16
|
// biome-ignore lint/suspicious/noExplicitAny: this is used internally with globalThis
|
|
14
17
|
function getIsDynamicLoadingSupported(globalObj) {
|
|
15
18
|
return globalObj?.expo && (_reactNative.Platform.OS === 'web' || typeof globalObj.expo.modules?.ExpoAsset?.downloadAsync === 'function') && typeof globalObj.expo.modules?.ExpoFontLoader?.getLoadedFonts === 'function' && typeof globalObj.expo.modules?.ExpoFontLoader?.loadAsync === 'function';
|
|
@@ -1 +1 @@
|
|
|
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;;
|
|
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;;AAUA;AACA;;AAqDA;AACA,SAASC,4BAA4BA,CAACC,SAAc,EAElD;EACA,OACEA,SAAS,EAAEC,IAAI,KACdC,qBAAQ,CAACC,EAAE,KAAK,KAAK,IAAI,OAAOH,SAAS,CAACC,IAAI,CAACG,OAAO,EAAEC,SAAS,EAAEC,aAAa,KA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,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":[]}
|
|
@@ -4,8 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.ensureGetImageAvailable = void 0;
|
|
7
|
+
var _reactNative = require("react-native");
|
|
7
8
|
var _dynamicLoadingSetting = require("./dynamicLoading/dynamic-loading-setting.js");
|
|
8
|
-
// eslint-disable-next-line import/no-mutable-exports
|
|
9
9
|
let NativeIconAPI = null;
|
|
10
10
|
try {
|
|
11
11
|
// eslint-disable-next-line global-require,import/no-extraneous-dependencies,@typescript-eslint/no-require-imports
|
|
@@ -27,17 +27,18 @@ const ensureGetImageAvailable = () => {
|
|
|
27
27
|
ExpoFontUtils
|
|
28
28
|
} = globalRef.expo.modules;
|
|
29
29
|
return {
|
|
30
|
-
getImageForFont: async (
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
30
|
+
getImageForFont: async (glyph, options) => {
|
|
31
|
+
return await ExpoFontUtils.renderToImageAsync(glyph, {
|
|
32
|
+
...options,
|
|
33
|
+
color: (0, _reactNative.processColor)(options.color ?? 'black')
|
|
34
|
+
});
|
|
35
|
+
},
|
|
35
36
|
getImageForFontSync: () => {
|
|
36
37
|
throw new Error('You attempted to call `getImageForFontSync`. Expo dev client with `@react-native-vector-icons/get-image` installed is required for this. Alternatively, call `getImageForFont` or generate the image yourself and bundle it with the app.');
|
|
37
38
|
}
|
|
38
39
|
};
|
|
39
40
|
}
|
|
40
|
-
throw new Error('Error in getImageSource / getImageSourceSync: You need to either (1) install `@react-native-vector-icons/get-image` or (2) use Expo SDK
|
|
41
|
+
throw new Error('Error in getImageSource / getImageSourceSync: You need to either (1) install `@react-native-vector-icons/get-image` or (2) use Expo SDK 54+ (Expo dev client or Expo Go). Check your setup and rebuild the app.');
|
|
41
42
|
};
|
|
42
43
|
exports.ensureGetImageAvailable = ensureGetImageAvailable;
|
|
43
44
|
//# sourceMappingURL=get-image-library.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["_reactNative","require","_dynamicLoadingSetting","NativeIconAPI","globalRef","globalThis","hasExpoRenderToImage","getIsRenderToImageSupported","ensureGetImageAvailable","ensureNativeModuleAvailable","ExpoFontUtils","expo","modules","getImageForFont","glyph","options","renderToImageAsync","color","processColor","getImageForFontSync","Error","exports"],"sourceRoot":"../../src","sources":["get-image-library.ts"],"mappings":";;;;;;AAAA,IAAAA,YAAA,GAAAC,OAAA;AAEA,IAAAC,sBAAA,GAAAD,OAAA;AAEA,IAAIE,aAA2E,GAAG,IAAI;AAMtF,IAAI;EACF;EACAA,aAAa,GAAGF,OAAO,CAAC,sCAAsC,CAAC;AACjE,CAAC,CAAC,MAAM;EACN;EACA;EACA;AAAA;AAGF,MAAMG,SAAS,GAAGC,UAAU;AAC5B,MAAMC,oBAAoB,GAAG,IAAAC,kDAA2B,EAACH,SAAS,CAAC;AAO5D,MAAMI,uBAAuB,GAAGA,CAAA,KAAmB;EACxD,IAAIL,aAAa,EAAE;IACjBA,aAAa,CAACM,2BAA2B,CAAC,CAAC;IAC3C,OAAON,aAAa;EACtB;EACA,IAAIG,oBAAoB,EAAE;IACxB,MAAM;MAAEI;IAAc,CAAC,GAAGN,SAAS,CAACO,IAAI,CAACC,OAAO;IAChD,OAAO;MACLC,eAAe,EAAE,MAAAA,CAAOC,KAAK,EAAEC,OAAO,KAAK;QACzC,OAAO,MAAML,aAAa,CAACM,kBAAkB,CAACF,KAAK,EAAE;UACnD,GAAGC,OAAO;UACVE,KAAK,EAAE,IAAAC,yBAAY,EAACH,OAAO,CAACE,KAAK,IAAI,OAAO;QAC9C,CAAC,CAAC;MACJ,CAAC;MACDE,mBAAmB,EAAEA,CAAA,KAAM;QACzB,MAAM,IAAIC,KAAK,CACb,2OACF,CAAC;MACH;IACF,CAAC;EACH;EACA,MAAM,IAAIA,KAAK,CACb,iNACF,CAAC;AACH,CAAC;AAACC,OAAA,CAAAb,uBAAA,GAAAA,uBAAA","ignoreList":[]}
|
|
@@ -4,55 +4,49 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.getImageSourceSync = exports.getImageSource = void 0;
|
|
7
|
-
var _reactNative = require("react-native");
|
|
8
7
|
var _defaults = require("./defaults.js");
|
|
9
8
|
var _getImageLibrary = require("./get-image-library.js");
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
9
|
+
const resolveOptions = (imageSourceCache, fontReference, glyph, {
|
|
10
|
+
size = _defaults.DEFAULT_ICON_SIZE,
|
|
11
|
+
color = _defaults.DEFAULT_ICON_COLOR,
|
|
12
|
+
lineHeight
|
|
13
|
+
} = {}) => {
|
|
14
|
+
const cacheKey = `${glyph}:${size}:${String(color)}:${lineHeight ?? ''}`;
|
|
15
|
+
const cached = imageSourceCache.get(cacheKey);
|
|
16
|
+
const nativeOptions = {
|
|
17
|
+
fontFamily: fontReference,
|
|
18
|
+
size,
|
|
19
|
+
color: color,
|
|
20
|
+
lineHeight
|
|
21
|
+
};
|
|
22
|
+
return {
|
|
23
|
+
cacheKey,
|
|
24
|
+
cached,
|
|
25
|
+
nativeOptions
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
const getImageSourceSync = (imageSourceCache, fontReference, glyph, options) => {
|
|
29
|
+
const {
|
|
30
|
+
cacheKey,
|
|
31
|
+
cached,
|
|
32
|
+
nativeOptions
|
|
33
|
+
} = resolveOptions(imageSourceCache, fontReference, glyph, options);
|
|
34
|
+
if (cached !== undefined) return cached;
|
|
35
|
+
const value = (0, _getImageLibrary.ensureGetImageAvailable)().getImageForFontSync(glyph, nativeOptions);
|
|
36
|
+
imageSourceCache.setValue(cacheKey, value);
|
|
37
|
+
return value;
|
|
32
38
|
};
|
|
33
39
|
exports.getImageSourceSync = getImageSourceSync;
|
|
34
|
-
const getImageSource = async (imageSourceCache, fontReference, glyph,
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
const imagePath = await NativeIconAPI.getImageForFont(fontReference, glyph, size, processedColor // FIXME what if a non existent colour was passed in?
|
|
45
|
-
);
|
|
46
|
-
const value = {
|
|
47
|
-
uri: imagePath,
|
|
48
|
-
scale: _reactNative.PixelRatio.get()
|
|
49
|
-
};
|
|
50
|
-
imageSourceCache.setValue(cacheKey, value);
|
|
51
|
-
return value;
|
|
52
|
-
} catch (error) {
|
|
53
|
-
imageSourceCache.setError(cacheKey, error);
|
|
54
|
-
throw error;
|
|
55
|
-
}
|
|
40
|
+
const getImageSource = async (imageSourceCache, fontReference, glyph, options) => {
|
|
41
|
+
const {
|
|
42
|
+
cacheKey,
|
|
43
|
+
cached,
|
|
44
|
+
nativeOptions
|
|
45
|
+
} = resolveOptions(imageSourceCache, fontReference, glyph, options);
|
|
46
|
+
if (cached !== undefined) return cached;
|
|
47
|
+
const value = await (0, _getImageLibrary.ensureGetImageAvailable)().getImageForFont(glyph, nativeOptions);
|
|
48
|
+
imageSourceCache.setValue(cacheKey, value);
|
|
49
|
+
return value;
|
|
56
50
|
};
|
|
57
51
|
exports.getImageSource = getImageSource;
|
|
58
52
|
//# sourceMappingURL=get-image-source.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["
|
|
1
|
+
{"version":3,"names":["_defaults","require","_getImageLibrary","resolveOptions","imageSourceCache","fontReference","glyph","size","DEFAULT_ICON_SIZE","color","DEFAULT_ICON_COLOR","lineHeight","cacheKey","String","cached","get","nativeOptions","fontFamily","getImageSourceSync","options","undefined","value","ensureGetImageAvailable","getImageForFontSync","setValue","exports","getImageSource","getImageForFont"],"sourceRoot":"../../src","sources":["get-image-source.ts"],"mappings":";;;;;;AAGA,IAAAA,SAAA,GAAAC,OAAA;AACA,IAAAC,gBAAA,GAAAD,OAAA;AAQA,MAAME,cAAc,GAAGA,CACrBC,gBAA0D,EAC1DC,aAAqB,EACrBC,KAAa,EACb;EAAEC,IAAI,GAAGC,2BAAiB;EAAEC,KAAK,GAAGC,4BAAkB;EAAEC;AAAkC,CAAC,GAAG,CAAC,CAAC,KAC7F;EACH,MAAMC,QAAQ,GAAG,GAAGN,KAAK,IAAIC,IAAI,IAAIM,MAAM,CAACJ,KAAK,CAAC,IAAIE,UAAU,IAAI,EAAE,EAAE;EACxE,MAAMG,MAAM,GAAGV,gBAAgB,CAACW,GAAG,CAACH,QAAQ,CAAC;EAC7C,MAAMI,aAAa,GAAG;IACpBC,UAAU,EAAEZ,aAAa;IACzBE,IAAI;IACJE,KAAK,EAAEA,KAAe;IACtBE;EACF,CAAC;EACD,OAAO;IAAEC,QAAQ;IAAEE,MAAM;IAAEE;EAAc,CAAC;AAC5C,CAAC;AAEM,MAAME,kBAAkB,GAAGA,CAChCd,gBAA0D,EAC1DC,aAAqB,EACrBC,KAAa,EACba,OAA+B,KAC5B;EACH,MAAM;IAAEP,QAAQ;IAAEE,MAAM;IAAEE;EAAc,CAAC,GAAGb,cAAc,CAACC,gBAAgB,EAAEC,aAAa,EAAEC,KAAK,EAAEa,OAAO,CAAC;EAC3G,IAAIL,MAAM,KAAKM,SAAS,EAAE,OAAON,MAAM;EAEvC,MAAMO,KAAK,GAAG,IAAAC,wCAAuB,EAAC,CAAC,CAACC,mBAAmB,CAACjB,KAAK,EAAEU,aAAa,CAAC;EACjFZ,gBAAgB,CAACoB,QAAQ,CAACZ,QAAQ,EAAES,KAAK,CAAC;EAC1C,OAAOA,KAAK;AACd,CAAC;AAACI,OAAA,CAAAP,kBAAA,GAAAA,kBAAA;AAEK,MAAMQ,cAAc,GAAG,MAAAA,CAC5BtB,gBAA0D,EAC1DC,aAAqB,EACrBC,KAAa,EACba,OAA+B,KAC5B;EACH,MAAM;IAAEP,QAAQ;IAAEE,MAAM;IAAEE;EAAc,CAAC,GAAGb,cAAc,CAACC,gBAAgB,EAAEC,aAAa,EAAEC,KAAK,EAAEa,OAAO,CAAC;EAC3G,IAAIL,MAAM,KAAKM,SAAS,EAAE,OAAON,MAAM;EAEvC,MAAMO,KAAK,GAAG,MAAM,IAAAC,wCAAuB,EAAC,CAAC,CAACK,eAAe,CAACrB,KAAK,EAAEU,aAAa,CAAC;EACnFZ,gBAAgB,CAACoB,QAAQ,CAACZ,QAAQ,EAAES,KAAK,CAAC;EAC1C,OAAOA,KAAK;AACd,CAAC;AAACI,OAAA,CAAAC,cAAA,GAAAA,cAAA","ignoreList":[]}
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
4
3
|
import React, { forwardRef, useEffect } from 'react';
|
|
5
|
-
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
6
4
|
import { Platform, Text } from 'react-native';
|
|
7
|
-
import createIconSourceCache from "./create-icon-source-cache.js";
|
|
5
|
+
import { createIconSourceCache } from "./create-icon-source-cache.js";
|
|
8
6
|
import { DEFAULT_ICON_COLOR, DEFAULT_ICON_SIZE } from "./defaults.js";
|
|
9
7
|
import { dynamicLoader } from "./dynamicLoading/dynamic-font-loading.js";
|
|
10
8
|
import { isDynamicLoadingEnabled } from "./dynamicLoading/dynamic-loading-setting.js";
|
|
@@ -31,6 +29,7 @@ export function createIconSet(glyphMap, postScriptNameOrOptions, fontFileNamePar
|
|
|
31
29
|
fontWeight: 'normal',
|
|
32
30
|
fontStyle: 'normal'
|
|
33
31
|
};
|
|
32
|
+
const fontSource = typeof postScriptNameOrOptions === 'object' && postScriptNameOrOptions?.fontSource;
|
|
34
33
|
const resolveGlyph = name => {
|
|
35
34
|
const glyph = glyphMap[name] || '?';
|
|
36
35
|
if (typeof glyph === 'number') {
|
|
@@ -48,14 +47,15 @@ export function createIconSet(glyphMap, postScriptNameOrOptions, fontFileNamePar
|
|
|
48
47
|
innerRef,
|
|
49
48
|
...props
|
|
50
49
|
}) => {
|
|
51
|
-
const
|
|
50
|
+
const canUseDynamicLoading = !!fontSource && isDynamicLoadingEnabled();
|
|
51
|
+
const [isFontLoaded, setIsFontLoaded] = React.useState(canUseDynamicLoading ? dynamicLoader.isLoaded(fontReference) : true);
|
|
52
52
|
const glyph = isFontLoaded && name ? resolveGlyph(name) : '';
|
|
53
|
-
|
|
53
|
+
const shouldLoadFontDynamically = !isFontLoaded && canUseDynamicLoading;
|
|
54
54
|
// biome-ignore lint/correctness/useExhaustiveDependencies: the dependencies never change
|
|
55
55
|
useEffect(() => {
|
|
56
56
|
let isMounted = true;
|
|
57
|
-
if (
|
|
58
|
-
dynamicLoader.loadFontAsync(fontReference,
|
|
57
|
+
if (shouldLoadFontDynamically) {
|
|
58
|
+
dynamicLoader.loadFontAsync(fontReference, fontSource).finally(() => {
|
|
59
59
|
if (isMounted) {
|
|
60
60
|
setIsFontLoaded(true);
|
|
61
61
|
}
|
|
@@ -71,7 +71,7 @@ export function createIconSet(glyphMap, postScriptNameOrOptions, fontFileNamePar
|
|
|
71
71
|
};
|
|
72
72
|
const newProps = {
|
|
73
73
|
...props,
|
|
74
|
-
style: [styleDefaults, style, styleOverrides, fontStyle
|
|
74
|
+
style: [styleDefaults, style, styleOverrides, fontStyle],
|
|
75
75
|
allowFontScaling
|
|
76
76
|
};
|
|
77
77
|
return /*#__PURE__*/_jsxs(Text, {
|
|
@@ -87,13 +87,24 @@ export function createIconSet(glyphMap, postScriptNameOrOptions, fontFileNamePar
|
|
|
87
87
|
}));
|
|
88
88
|
WrappedIcon.displayName = `Icon(${postScriptName})`;
|
|
89
89
|
const imageSourceCache = createIconSourceCache();
|
|
90
|
-
const getImageSource = async (name,
|
|
91
|
-
|
|
92
|
-
|
|
90
|
+
const getImageSource = async (name, sizeOrOptions, color) => {
|
|
91
|
+
const canUseDynamicLoading = !!fontSource && isDynamicLoadingEnabled();
|
|
92
|
+
if (canUseDynamicLoading && !dynamicLoader.isLoaded(fontReference)) {
|
|
93
|
+
await dynamicLoader.loadFontAsync(fontReference, fontSource);
|
|
93
94
|
}
|
|
94
|
-
|
|
95
|
+
const options = typeof sizeOrOptions === 'object' ? sizeOrOptions : {
|
|
96
|
+
size: sizeOrOptions,
|
|
97
|
+
color
|
|
98
|
+
};
|
|
99
|
+
return getImageSourceImpl(imageSourceCache, fontReference, resolveGlyph(name), options);
|
|
100
|
+
};
|
|
101
|
+
const getImageSourceSync = (name, sizeOrOptions, color) => {
|
|
102
|
+
const options = typeof sizeOrOptions === 'object' ? sizeOrOptions : {
|
|
103
|
+
size: sizeOrOptions,
|
|
104
|
+
color
|
|
105
|
+
};
|
|
106
|
+
return getImageSourceSyncImpl(imageSourceCache, fontReference, resolveGlyph(name), options);
|
|
95
107
|
};
|
|
96
|
-
const getImageSourceSync = (name, size, color) => getImageSourceSyncImpl(imageSourceCache, fontReference, resolveGlyph(name), size, color);
|
|
97
108
|
const IconNamespace = Object.assign(WrappedIcon, {
|
|
98
109
|
getImageSource,
|
|
99
110
|
getImageSourceSync
|