@react-native-vector-icons/common 12.0.0 → 12.1.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 +50 -38
- package/lib/commonjs/create-icon-set.js +16 -58
- package/lib/commonjs/create-icon-set.js.map +1 -1
- package/lib/commonjs/create-icon-source-cache.js +0 -2
- package/lib/commonjs/create-icon-source-cache.js.map +1 -1
- package/lib/commonjs/defaults.js +9 -0
- package/lib/commonjs/defaults.js.map +1 -0
- package/lib/commonjs/dynamicLoading/dynamic-font-loading.js +8 -18
- package/lib/commonjs/dynamicLoading/dynamic-font-loading.js.map +1 -1
- package/lib/commonjs/dynamicLoading/dynamic-loading-setting.js +19 -2
- package/lib/commonjs/dynamicLoading/dynamic-loading-setting.js.map +1 -1
- package/lib/commonjs/get-image-library.js +25 -5
- package/lib/commonjs/get-image-library.js.map +1 -1
- package/lib/commonjs/get-image-source.js +58 -0
- package/lib/commonjs/get-image-source.js.map +1 -0
- package/lib/commonjs/index.js +3 -2
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/scripts/common.js.map +1 -1
- package/lib/commonjs/scripts/updatePlist.js.map +1 -1
- package/lib/module/create-icon-set.js +15 -57
- package/lib/module/create-icon-set.js.map +1 -1
- package/lib/module/create-icon-source-cache.js +0 -2
- package/lib/module/create-icon-source-cache.js.map +1 -1
- package/lib/module/defaults.js +5 -0
- package/lib/module/defaults.js.map +1 -0
- package/lib/module/dynamicLoading/dynamic-font-loading.js +10 -17
- package/lib/module/dynamicLoading/dynamic-font-loading.js.map +1 -1
- package/lib/module/dynamicLoading/dynamic-loading-setting.js +15 -1
- package/lib/module/dynamicLoading/dynamic-loading-setting.js.map +1 -1
- package/lib/module/get-image-library.js +26 -5
- package/lib/module/get-image-library.js.map +1 -1
- package/lib/module/get-image-source.js +52 -0
- package/lib/module/get-image-source.js.map +1 -0
- package/lib/module/index.js +3 -2
- package/lib/module/index.js.map +1 -1
- package/lib/module/scripts/common.js.map +1 -1
- package/lib/module/scripts/updatePlist.js.map +1 -1
- package/lib/typescript/commonjs/src/create-icon-set.d.ts +0 -2
- package/lib/typescript/commonjs/src/create-icon-set.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/create-icon-source-cache.d.ts +0 -1
- package/lib/typescript/commonjs/src/create-icon-source-cache.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/defaults.d.ts +3 -0
- package/lib/typescript/commonjs/src/defaults.d.ts.map +1 -0
- 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 +33 -7
- package/lib/typescript/commonjs/src/dynamicLoading/dynamic-loading-setting.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/get-image-library.d.ts +4 -1
- package/lib/typescript/commonjs/src/get-image-library.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/get-image-source.d.ts +11 -0
- package/lib/typescript/commonjs/src/get-image-source.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/index.d.ts +4 -3
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/scripts/common.d.ts.map +1 -1
- package/lib/typescript/module/src/create-icon-set.d.ts +0 -2
- package/lib/typescript/module/src/create-icon-set.d.ts.map +1 -1
- package/lib/typescript/module/src/create-icon-source-cache.d.ts +0 -1
- package/lib/typescript/module/src/create-icon-source-cache.d.ts.map +1 -1
- package/lib/typescript/module/src/defaults.d.ts +3 -0
- package/lib/typescript/module/src/defaults.d.ts.map +1 -0
- 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 +33 -7
- package/lib/typescript/module/src/dynamicLoading/dynamic-loading-setting.d.ts.map +1 -1
- package/lib/typescript/module/src/get-image-library.d.ts +4 -1
- package/lib/typescript/module/src/get-image-library.d.ts.map +1 -1
- package/lib/typescript/module/src/get-image-source.d.ts +11 -0
- package/lib/typescript/module/src/get-image-source.d.ts.map +1 -0
- package/lib/typescript/module/src/index.d.ts +4 -3
- package/lib/typescript/module/src/index.d.ts.map +1 -1
- package/lib/typescript/module/src/scripts/common.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/create-icon-set.tsx +22 -76
- package/src/create-icon-source-cache.ts +1 -3
- package/src/defaults.ts +2 -0
- package/src/dynamicLoading/dynamic-font-loading.ts +12 -17
- package/src/dynamicLoading/dynamic-loading-setting.ts +65 -18
- package/src/get-image-library.ts +30 -9
- package/src/get-image-source.ts +74 -0
- package/src/index.ts +4 -3
- package/src/scripts/common.ts +1 -0
- package/src/scripts/updatePlist.ts +1 -0
|
@@ -1,18 +1,44 @@
|
|
|
1
1
|
import type { FontSource } from './types';
|
|
2
|
+
type ExpoAssetModule = {
|
|
3
|
+
downloadAsync: (uri: string, hash: string | undefined, type: string) => Promise<string>;
|
|
4
|
+
};
|
|
5
|
+
type ExpoFontLoaderModule = {
|
|
6
|
+
getLoadedFonts: () => string[];
|
|
7
|
+
loadAsync: (fontFamilyAlias: string, fileUri: string) => Promise<void>;
|
|
8
|
+
};
|
|
9
|
+
type ExpoFontUtilsModule = {
|
|
10
|
+
renderToImageAsync: (glyph: string, options: {
|
|
11
|
+
fontFamily?: string;
|
|
12
|
+
size?: number;
|
|
13
|
+
color?: number;
|
|
14
|
+
}) => Promise<string>;
|
|
15
|
+
};
|
|
2
16
|
declare global {
|
|
3
17
|
interface ExpoGlobal {
|
|
4
18
|
modules: {
|
|
5
|
-
ExpoAsset
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
ExpoFontLoader: {
|
|
9
|
-
getLoadedFonts: () => string[];
|
|
10
|
-
loadAsync: (fontFamilyAlias: string, fileUri: string) => Promise<void>;
|
|
11
|
-
};
|
|
19
|
+
ExpoAsset?: ExpoAssetModule;
|
|
20
|
+
ExpoFontLoader?: ExpoFontLoaderModule;
|
|
21
|
+
ExpoFontUtils?: ExpoFontUtilsModule;
|
|
12
22
|
};
|
|
13
23
|
}
|
|
14
24
|
var expo: ExpoGlobal | undefined;
|
|
15
25
|
}
|
|
26
|
+
type ExpoGlobalType = {
|
|
27
|
+
modules: {
|
|
28
|
+
ExpoAsset: ExpoAssetModule;
|
|
29
|
+
ExpoFontLoader: ExpoFontLoaderModule;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
export declare function getIsRenderToImageSupported(globalObj: any): globalObj is {
|
|
33
|
+
expo: {
|
|
34
|
+
modules: {
|
|
35
|
+
ExpoFontUtils: ExpoFontUtilsModule;
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
export declare function assertExpoModulesPresent(globalObj: unknown): asserts globalObj is {
|
|
40
|
+
expo: ExpoGlobalType;
|
|
41
|
+
};
|
|
16
42
|
export declare const isDynamicLoadingSupported: () => boolean;
|
|
17
43
|
/**
|
|
18
44
|
* Set whether dynamic loading of fonts is enabled.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dynamic-loading-setting.d.ts","sourceRoot":"","sources":["../../../../../src/dynamicLoading/dynamic-loading-setting.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE1C,
|
|
1
|
+
{"version":3,"file":"dynamic-loading-setting.d.ts","sourceRoot":"","sources":["../../../../../src/dynamicLoading/dynamic-loading-setting.ts"],"names":[],"mappings":"AAAA,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;AAEF,KAAK,oBAAoB,GAAG;IAG1B,cAAc,EAAE,MAAM,MAAM,EAAE,CAAC;IAC/B,SAAS,EAAE,CAAC,eAAe,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACxE,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;AAQD,eAAO,MAAM,yBAAyB,eAAiC,CAAC;AAExE;;;;;;;KAOK;AACL,eAAO,MAAM,wBAAwB,GAAI,OAAO,OAAO,KAAG,OAczD,CAAC;AAEF;;KAEK;AACL,eAAO,MAAM,uBAAuB,eAAkC,CAAC;AAEvE,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"}
|
|
@@ -1,2 +1,5 @@
|
|
|
1
|
-
export declare const ensureGetImageAvailable: () => typeof import("@react-native-vector-icons/get-image")
|
|
1
|
+
export declare const ensureGetImageAvailable: () => typeof import("@react-native-vector-icons/get-image") | {
|
|
2
|
+
getImageForFont: (fontReference: string, glyph: string, size: number, color: number) => Promise<string>;
|
|
3
|
+
getImageForFontSync: () => never;
|
|
4
|
+
};
|
|
2
5
|
//# sourceMappingURL=get-image-library.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-image-library.d.ts","sourceRoot":"","sources":["../../../../src/get-image-library.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"get-image-library.d.ts","sourceRoot":"","sources":["../../../../src/get-image-library.ts"],"names":[],"mappings":"AAiBA,eAAO,MAAM,uBAAuB;qCAQS,MAAM,SAAS,MAAM,QAAQ,MAAM,SAAS,MAAM;;CAgB9F,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { TextStyle } from 'react-native';
|
|
2
|
+
import type createIconSourceCache from './create-icon-source-cache';
|
|
3
|
+
export declare const getImageSourceSync: (imageSourceCache: ReturnType<typeof createIconSourceCache>, fontReference: string, glyph: string, size?: number, color?: TextStyle["color"]) => {
|
|
4
|
+
uri: string;
|
|
5
|
+
scale: number;
|
|
6
|
+
};
|
|
7
|
+
export declare const getImageSource: (imageSourceCache: ReturnType<typeof createIconSourceCache>, fontReference: string, glyph: string, size?: number, color?: TextStyle["color"]) => Promise<{
|
|
8
|
+
uri: string;
|
|
9
|
+
scale: number;
|
|
10
|
+
}>;
|
|
11
|
+
//# sourceMappingURL=get-image-source.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-image-source.d.ts","sourceRoot":"","sources":["../../../../src/get-image-source.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAG9C,OAAO,KAAK,qBAAqB,MAAM,4BAA4B,CAAC;AAIpE,eAAO,MAAM,kBAAkB,GAC7B,kBAAkB,UAAU,CAAC,OAAO,qBAAqB,CAAC,EAC1D,eAAe,MAAM,EACrB,OAAO,MAAM,EACb,aAAwB,EACxB,QAAO,SAAS,CAAC,OAAO,CAAsB;;;CA2B/C,CAAC;AAEF,eAAO,MAAM,cAAc,GACzB,kBAAkB,UAAU,CAAC,OAAO,qBAAqB,CAAC,EAC1D,eAAe,MAAM,EACrB,OAAO,MAAM,EACb,aAAwB,EACxB,QAAO,SAAS,CAAC,OAAO,CAAsB;;;EA2B/C,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export
|
|
3
|
-
export {
|
|
1
|
+
export type { CreateIconSetOptions, IconProps } from './create-icon-set';
|
|
2
|
+
export { createIconSet } from './create-icon-set';
|
|
3
|
+
export { DEFAULT_ICON_COLOR, DEFAULT_ICON_SIZE } from './defaults';
|
|
4
|
+
export { isDynamicLoadingEnabled, isDynamicLoadingSupported, setDynamicLoadingEnabled, setDynamicLoadingErrorCallback, } from './dynamicLoading/dynamic-loading-setting';
|
|
4
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,oBAAoB,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACzE,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AACnE,OAAO,EACL,uBAAuB,EACvB,yBAAyB,EACzB,wBAAwB,EACxB,8BAA8B,GAC/B,MAAM,0CAA0C,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../../../src/scripts/common.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../../../src/scripts/common.ts"],"names":[],"mappings":"AA8CA,eAAO,MAAM,YAAY,GAAI,qBAAqB,MAAM,aAMvD,CAAC"}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import React, { type Ref } from 'react';
|
|
2
2
|
import { Text, type TextProps, type TextStyle } from 'react-native';
|
|
3
3
|
import type { FontSource } from './dynamicLoading/types';
|
|
4
|
-
export declare const DEFAULT_ICON_SIZE = 12;
|
|
5
|
-
export declare const DEFAULT_ICON_COLOR = "black";
|
|
6
4
|
type ValueData = {
|
|
7
5
|
uri: string;
|
|
8
6
|
scale: number;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-icon-set.d.ts","sourceRoot":"","sources":["../../../../src/create-icon-set.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAc,KAAK,GAAG,EAAa,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"create-icon-set.d.ts","sourceRoot":"","sources":["../../../../src/create-icon-set.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,EAAc,KAAK,GAAG,EAAa,MAAM,OAAO,CAAC;AAE/D,OAAO,EAAY,IAAI,EAAE,KAAK,SAAS,EAAE,KAAK,SAAS,EAAE,MAAM,cAAc,CAAC;AAM9E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAGzD,KAAK,SAAS,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAChD,KAAK,0BAA0B,CAAC,EAAE,IAAI,CAAC,IAAI,EAAE,EAAE,EAAE,IAAI,CAAC,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,SAAS,CAAC,OAAO,CAAC,KAAK,SAAS,GAAG,SAAS,CAAC;AACrH,KAAK,sBAAsB,CAAC,EAAE,IAAI,CAChC,IAAI,EAAE,EAAE,EACR,IAAI,CAAC,EAAE,MAAM,EACb,KAAK,CAAC,EAAE,SAAS,CAAC,OAAO,CAAC,KACvB,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC,CAAC;AAEpC,MAAM,MAAM,SAAS,CAAC,CAAC,IAAI,SAAS,GAAG;IACrC,IAAI,EAAE,CAAC,CAAC;IACR,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC;IAC3B,QAAQ,CAAC,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC;CACtB,CAAC;AAEF,KAAK,aAAa,CAAC,EAAE,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,IAAI,KAAK,CAAC,EAAE,CAC9D,SAAS,GAAG;IACV,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC;IAC3B,QAAQ,CAAC,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC;CACtB,GAAG,KAAK,CAAC,aAAa,CAAC,IAAI,CAAC,CAC9B,GAAG;IACF,cAAc,EAAE,sBAAsB,CAAC,MAAM,EAAE,CAAC,CAAC;IACjD,kBAAkB,EAAE,0BAA0B,CAAC,MAAM,EAAE,CAAC,CAAC;CAC1D,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAAG;IACjC,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,SAAS,CAAC,EAAE,SAAS,CAAC,OAAO,CAAC,CAAC;CAChC,CAAC;AAEF,wBAAgB,aAAa,CAAC,EAAE,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC7D,QAAQ,EAAE,EAAE,EACZ,cAAc,EAAE,MAAM,EACtB,YAAY,EAAE,MAAM,EACpB,SAAS,CAAC,EAAE,SAAS,CAAC,OAAO,CAAC,GAC7B,aAAa,CAAC,EAAE,CAAC,CAAC;AACrB,wBAAgB,aAAa,CAAC,EAAE,SAAS,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC7D,QAAQ,EAAE,EAAE,EACZ,OAAO,EAAE,oBAAoB,GAC5B,aAAa,CAAC,EAAE,CAAC,CAAC"}
|
|
@@ -14,7 +14,6 @@ type Value = {
|
|
|
14
14
|
export default function createIconSourceCache(): {
|
|
15
15
|
setValue: (key: string, value: ValueData) => Map<string, Value>;
|
|
16
16
|
setError: (key: string, error: Error) => Map<string, Value>;
|
|
17
|
-
has: (key: string) => boolean;
|
|
18
17
|
get: (key: string) => ValueData | undefined;
|
|
19
18
|
};
|
|
20
19
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-icon-source-cache.d.ts","sourceRoot":"","sources":["../../../../src/create-icon-source-cache.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,UAAU,UAAU,CAAC;AAC3B,QAAA,MAAM,UAAU,UAAU,CAAC;AAE3B,KAAK,SAAS,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAEhD,KAAK,KAAK,GAAG;IAAE,IAAI,EAAE,OAAO,UAAU,CAAC;IAAC,IAAI,EAAE,SAAS,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,OAAO,UAAU,CAAC;IAAC,IAAI,EAAE,KAAK,CAAA;CAAE,CAAC;AAErG,MAAM,CAAC,OAAO,UAAU,qBAAqB;oBAGpB,MAAM,SAAS,SAAS;oBAExB,MAAM,SAAS,KAAK;eAEzB,MAAM;
|
|
1
|
+
{"version":3,"file":"create-icon-source-cache.d.ts","sourceRoot":"","sources":["../../../../src/create-icon-source-cache.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,UAAU,UAAU,CAAC;AAC3B,QAAA,MAAM,UAAU,UAAU,CAAC;AAE3B,KAAK,SAAS,GAAG;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAA;CAAE,CAAC;AAEhD,KAAK,KAAK,GAAG;IAAE,IAAI,EAAE,OAAO,UAAU,CAAC;IAAC,IAAI,EAAE,SAAS,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,OAAO,UAAU,CAAC;IAAC,IAAI,EAAE,KAAK,CAAA;CAAE,CAAC;AAErG,MAAM,CAAC,OAAO,UAAU,qBAAqB;oBAGpB,MAAM,SAAS,SAAS;oBAExB,MAAM,SAAS,KAAK;eAEzB,MAAM;EAczB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defaults.d.ts","sourceRoot":"","sources":["../../../../src/defaults.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,iBAAiB,KAAK,CAAC;AACpC,eAAO,MAAM,kBAAkB,UAAU,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dynamic-font-loading.d.ts","sourceRoot":"","sources":["../../../../../src/dynamicLoading/dynamic-font-loading.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"dynamic-font-loading.d.ts","sourceRoot":"","sources":["../../../../../src/dynamicLoading/dynamic-font-loading.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,aAAa,EAAc,MAAM,SAAS,CAAC;AA8EzD,eAAO,MAAM,aAAa,EAAE,aAG3B,CAAC"}
|
|
@@ -1,18 +1,44 @@
|
|
|
1
1
|
import type { FontSource } from './types';
|
|
2
|
+
type ExpoAssetModule = {
|
|
3
|
+
downloadAsync: (uri: string, hash: string | undefined, type: string) => Promise<string>;
|
|
4
|
+
};
|
|
5
|
+
type ExpoFontLoaderModule = {
|
|
6
|
+
getLoadedFonts: () => string[];
|
|
7
|
+
loadAsync: (fontFamilyAlias: string, fileUri: string) => Promise<void>;
|
|
8
|
+
};
|
|
9
|
+
type ExpoFontUtilsModule = {
|
|
10
|
+
renderToImageAsync: (glyph: string, options: {
|
|
11
|
+
fontFamily?: string;
|
|
12
|
+
size?: number;
|
|
13
|
+
color?: number;
|
|
14
|
+
}) => Promise<string>;
|
|
15
|
+
};
|
|
2
16
|
declare global {
|
|
3
17
|
interface ExpoGlobal {
|
|
4
18
|
modules: {
|
|
5
|
-
ExpoAsset
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
ExpoFontLoader: {
|
|
9
|
-
getLoadedFonts: () => string[];
|
|
10
|
-
loadAsync: (fontFamilyAlias: string, fileUri: string) => Promise<void>;
|
|
11
|
-
};
|
|
19
|
+
ExpoAsset?: ExpoAssetModule;
|
|
20
|
+
ExpoFontLoader?: ExpoFontLoaderModule;
|
|
21
|
+
ExpoFontUtils?: ExpoFontUtilsModule;
|
|
12
22
|
};
|
|
13
23
|
}
|
|
14
24
|
var expo: ExpoGlobal | undefined;
|
|
15
25
|
}
|
|
26
|
+
type ExpoGlobalType = {
|
|
27
|
+
modules: {
|
|
28
|
+
ExpoAsset: ExpoAssetModule;
|
|
29
|
+
ExpoFontLoader: ExpoFontLoaderModule;
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
export declare function getIsRenderToImageSupported(globalObj: any): globalObj is {
|
|
33
|
+
expo: {
|
|
34
|
+
modules: {
|
|
35
|
+
ExpoFontUtils: ExpoFontUtilsModule;
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
};
|
|
39
|
+
export declare function assertExpoModulesPresent(globalObj: unknown): asserts globalObj is {
|
|
40
|
+
expo: ExpoGlobalType;
|
|
41
|
+
};
|
|
16
42
|
export declare const isDynamicLoadingSupported: () => boolean;
|
|
17
43
|
/**
|
|
18
44
|
* Set whether dynamic loading of fonts is enabled.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dynamic-loading-setting.d.ts","sourceRoot":"","sources":["../../../../../src/dynamicLoading/dynamic-loading-setting.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAE1C,
|
|
1
|
+
{"version":3,"file":"dynamic-loading-setting.d.ts","sourceRoot":"","sources":["../../../../../src/dynamicLoading/dynamic-loading-setting.ts"],"names":[],"mappings":"AAAA,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;AAEF,KAAK,oBAAoB,GAAG;IAG1B,cAAc,EAAE,MAAM,MAAM,EAAE,CAAC;IAC/B,SAAS,EAAE,CAAC,eAAe,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACxE,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;AAQD,eAAO,MAAM,yBAAyB,eAAiC,CAAC;AAExE;;;;;;;KAOK;AACL,eAAO,MAAM,wBAAwB,GAAI,OAAO,OAAO,KAAG,OAczD,CAAC;AAEF;;KAEK;AACL,eAAO,MAAM,uBAAuB,eAAkC,CAAC;AAEvE,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"}
|
|
@@ -1,2 +1,5 @@
|
|
|
1
|
-
export declare const ensureGetImageAvailable: () => typeof import("@react-native-vector-icons/get-image")
|
|
1
|
+
export declare const ensureGetImageAvailable: () => typeof import("@react-native-vector-icons/get-image") | {
|
|
2
|
+
getImageForFont: (fontReference: string, glyph: string, size: number, color: number) => Promise<string>;
|
|
3
|
+
getImageForFontSync: () => never;
|
|
4
|
+
};
|
|
2
5
|
//# sourceMappingURL=get-image-library.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-image-library.d.ts","sourceRoot":"","sources":["../../../../src/get-image-library.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"get-image-library.d.ts","sourceRoot":"","sources":["../../../../src/get-image-library.ts"],"names":[],"mappings":"AAiBA,eAAO,MAAM,uBAAuB;qCAQS,MAAM,SAAS,MAAM,QAAQ,MAAM,SAAS,MAAM;;CAgB9F,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { TextStyle } from 'react-native';
|
|
2
|
+
import type createIconSourceCache from './create-icon-source-cache';
|
|
3
|
+
export declare const getImageSourceSync: (imageSourceCache: ReturnType<typeof createIconSourceCache>, fontReference: string, glyph: string, size?: number, color?: TextStyle["color"]) => {
|
|
4
|
+
uri: string;
|
|
5
|
+
scale: number;
|
|
6
|
+
};
|
|
7
|
+
export declare const getImageSource: (imageSourceCache: ReturnType<typeof createIconSourceCache>, fontReference: string, glyph: string, size?: number, color?: TextStyle["color"]) => Promise<{
|
|
8
|
+
uri: string;
|
|
9
|
+
scale: number;
|
|
10
|
+
}>;
|
|
11
|
+
//# sourceMappingURL=get-image-source.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"get-image-source.d.ts","sourceRoot":"","sources":["../../../../src/get-image-source.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAG9C,OAAO,KAAK,qBAAqB,MAAM,4BAA4B,CAAC;AAIpE,eAAO,MAAM,kBAAkB,GAC7B,kBAAkB,UAAU,CAAC,OAAO,qBAAqB,CAAC,EAC1D,eAAe,MAAM,EACrB,OAAO,MAAM,EACb,aAAwB,EACxB,QAAO,SAAS,CAAC,OAAO,CAAsB;;;CA2B/C,CAAC;AAEF,eAAO,MAAM,cAAc,GACzB,kBAAkB,UAAU,CAAC,OAAO,qBAAqB,CAAC,EAC1D,eAAe,MAAM,EACrB,OAAO,MAAM,EACb,aAAwB,EACxB,QAAO,SAAS,CAAC,OAAO,CAAsB;;;EA2B/C,CAAC"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export
|
|
3
|
-
export {
|
|
1
|
+
export type { CreateIconSetOptions, IconProps } from './create-icon-set';
|
|
2
|
+
export { createIconSet } from './create-icon-set';
|
|
3
|
+
export { DEFAULT_ICON_COLOR, DEFAULT_ICON_SIZE } from './defaults';
|
|
4
|
+
export { isDynamicLoadingEnabled, isDynamicLoadingSupported, setDynamicLoadingEnabled, setDynamicLoadingErrorCallback, } from './dynamicLoading/dynamic-loading-setting';
|
|
4
5
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,oBAAoB,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACzE,OAAO,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAClD,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AACnE,OAAO,EACL,uBAAuB,EACvB,yBAAyB,EACzB,wBAAwB,EACxB,8BAA8B,GAC/B,MAAM,0CAA0C,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../../../src/scripts/common.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../../../src/scripts/common.ts"],"names":[],"mappings":"AA8CA,eAAO,MAAM,YAAY,GAAI,qBAAqB,MAAM,aAMvD,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@react-native-vector-icons/common",
|
|
3
|
-
"version": "12.
|
|
3
|
+
"version": "12.1.0",
|
|
4
4
|
"description": "Customizable Icons for React Native with support for image source and full styling.",
|
|
5
5
|
"source": "./src/index.tsx",
|
|
6
6
|
"main": "./lib/commonjs/index.js",
|
|
@@ -76,7 +76,7 @@
|
|
|
76
76
|
},
|
|
77
77
|
"devDependencies": {
|
|
78
78
|
"@types/plist": "^3.0.5",
|
|
79
|
-
"@types/react": "^
|
|
79
|
+
"@types/react": "^19.0.12",
|
|
80
80
|
"del-cli": "^6.0.0",
|
|
81
81
|
"onchange": "^7.1.0",
|
|
82
82
|
"react-native-builder-bob": "^0.35.2",
|
|
@@ -85,7 +85,7 @@
|
|
|
85
85
|
"peerDependencies": {
|
|
86
86
|
"react": "*",
|
|
87
87
|
"react-native": "*",
|
|
88
|
-
"@react-native-vector-icons/get-image": "^12.
|
|
88
|
+
"@react-native-vector-icons/get-image": "^12.1.0"
|
|
89
89
|
},
|
|
90
90
|
"peerDependenciesMeta": {
|
|
91
91
|
"@react-native-vector-icons/get-image": {
|
package/src/create-icon-set.tsx
CHANGED
|
@@ -1,17 +1,14 @@
|
|
|
1
1
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
2
2
|
import React, { forwardRef, type Ref, useEffect } from 'react';
|
|
3
|
-
|
|
4
3
|
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
5
|
-
import {
|
|
4
|
+
import { Platform, Text, type TextProps, type TextStyle } from 'react-native';
|
|
6
5
|
|
|
7
6
|
import createIconSourceCache from './create-icon-source-cache';
|
|
7
|
+
import { DEFAULT_ICON_COLOR, DEFAULT_ICON_SIZE } from './defaults';
|
|
8
8
|
import { dynamicLoader } from './dynamicLoading/dynamic-font-loading';
|
|
9
9
|
import { isDynamicLoadingEnabled } from './dynamicLoading/dynamic-loading-setting';
|
|
10
10
|
import type { FontSource } from './dynamicLoading/types';
|
|
11
|
-
import {
|
|
12
|
-
|
|
13
|
-
export const DEFAULT_ICON_SIZE = 12;
|
|
14
|
-
export const DEFAULT_ICON_COLOR = 'black';
|
|
11
|
+
import { getImageSource as getImageSourceImpl, getImageSourceSync as getImageSourceSyncImpl } from './get-image-source';
|
|
15
12
|
|
|
16
13
|
type ValueData = { uri: string; scale: number };
|
|
17
14
|
type GetImageSourceSyncIconFunc<GM> = (name: GM, size?: number, color?: TextStyle['color']) => ValueData | undefined;
|
|
@@ -65,7 +62,11 @@ export function createIconSet<GM extends Record<string, number>>(
|
|
|
65
62
|
): IconComponent<GM> {
|
|
66
63
|
const { postScriptName, fontFileName, fontStyle } =
|
|
67
64
|
typeof postScriptNameOrOptions === 'string'
|
|
68
|
-
? {
|
|
65
|
+
? {
|
|
66
|
+
postScriptName: postScriptNameOrOptions,
|
|
67
|
+
fontFileName: fontFileNameParam,
|
|
68
|
+
fontStyle: fontStyleParam,
|
|
69
|
+
}
|
|
69
70
|
: postScriptNameOrOptions;
|
|
70
71
|
|
|
71
72
|
const fontBasename = fontFileName ? fontFileName.replace(/\.(otf|ttf)$/, '') : postScriptName;
|
|
@@ -73,18 +74,23 @@ export function createIconSet<GM extends Record<string, number>>(
|
|
|
73
74
|
const fontReference = Platform.select({
|
|
74
75
|
windows: `/Assets/${fontFileName}#${postScriptName}`,
|
|
75
76
|
android: fontBasename,
|
|
76
|
-
web: fontBasename,
|
|
77
77
|
default: postScriptName,
|
|
78
78
|
});
|
|
79
79
|
|
|
80
|
+
const styleOverrides: TextProps['style'] = {
|
|
81
|
+
fontFamily: fontReference,
|
|
82
|
+
fontWeight: 'normal',
|
|
83
|
+
fontStyle: 'normal',
|
|
84
|
+
};
|
|
85
|
+
|
|
80
86
|
const resolveGlyph = (name: keyof GM) => {
|
|
81
|
-
const glyph = glyphMap[name]
|
|
87
|
+
const glyph = glyphMap[name];
|
|
82
88
|
|
|
83
89
|
if (typeof glyph === 'number') {
|
|
84
90
|
return String.fromCodePoint(glyph);
|
|
85
91
|
}
|
|
86
92
|
|
|
87
|
-
return
|
|
93
|
+
return '?';
|
|
88
94
|
};
|
|
89
95
|
|
|
90
96
|
const Icon = ({
|
|
@@ -127,12 +133,6 @@ export function createIconSet<GM extends Record<string, number>>(
|
|
|
127
133
|
color,
|
|
128
134
|
};
|
|
129
135
|
|
|
130
|
-
const styleOverrides: TextProps['style'] = {
|
|
131
|
-
fontFamily: fontReference,
|
|
132
|
-
fontWeight: 'normal',
|
|
133
|
-
fontStyle: 'normal',
|
|
134
|
-
};
|
|
135
|
-
|
|
136
136
|
const newProps: TextProps = {
|
|
137
137
|
...props,
|
|
138
138
|
style: [styleDefaults, style, styleOverrides, fontStyle || {}],
|
|
@@ -154,69 +154,15 @@ export function createIconSet<GM extends Record<string, number>>(
|
|
|
154
154
|
|
|
155
155
|
const imageSourceCache = createIconSourceCache();
|
|
156
156
|
|
|
157
|
-
const
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
color: TextStyle['color'] = DEFAULT_ICON_COLOR,
|
|
161
|
-
) => {
|
|
162
|
-
const NativeIconAPI = ensureGetImageAvailable();
|
|
163
|
-
|
|
164
|
-
const glyph = resolveGlyph(name);
|
|
165
|
-
const processedColor = processColor(color);
|
|
166
|
-
const cacheKey = `${glyph}:${size}:${String(processedColor)}`;
|
|
167
|
-
|
|
168
|
-
if (imageSourceCache.has(cacheKey)) {
|
|
169
|
-
// FIXME: Should this check if it's an error and throw it again?
|
|
170
|
-
return imageSourceCache.get(cacheKey);
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
try {
|
|
174
|
-
const imagePath = NativeIconAPI.getImageForFontSync(
|
|
175
|
-
fontReference,
|
|
176
|
-
glyph,
|
|
177
|
-
size,
|
|
178
|
-
processedColor as number, // FIXME what if a non existant colour was passed in?
|
|
179
|
-
);
|
|
180
|
-
const value = { uri: imagePath, scale: PixelRatio.get() };
|
|
181
|
-
imageSourceCache.setValue(cacheKey, value);
|
|
182
|
-
return value;
|
|
183
|
-
} catch (error) {
|
|
184
|
-
imageSourceCache.setError(cacheKey, error as Error);
|
|
185
|
-
throw error;
|
|
157
|
+
const getImageSource: GetImageSourceIconFunc<keyof GM> = async (name, size, color) => {
|
|
158
|
+
if (typeof postScriptNameOrOptions === 'object' && typeof postScriptNameOrOptions.fontSource !== 'undefined') {
|
|
159
|
+
await dynamicLoader.loadFontAsync(fontReference, postScriptNameOrOptions.fontSource);
|
|
186
160
|
}
|
|
161
|
+
return getImageSourceImpl(imageSourceCache, fontReference, resolveGlyph(name), size, color);
|
|
187
162
|
};
|
|
188
163
|
|
|
189
|
-
const
|
|
190
|
-
name
|
|
191
|
-
size = DEFAULT_ICON_SIZE,
|
|
192
|
-
color: TextStyle['color'] = DEFAULT_ICON_COLOR,
|
|
193
|
-
) => {
|
|
194
|
-
const NativeIconAPI = ensureGetImageAvailable();
|
|
195
|
-
|
|
196
|
-
const glyph = resolveGlyph(name);
|
|
197
|
-
const processedColor = processColor(color);
|
|
198
|
-
const cacheKey = `${glyph}:${size}:${String(processedColor)}`;
|
|
199
|
-
|
|
200
|
-
if (imageSourceCache.has(cacheKey)) {
|
|
201
|
-
// FIXME: Should this check if it's an error and throw it again?
|
|
202
|
-
return imageSourceCache.get(cacheKey);
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
try {
|
|
206
|
-
const imagePath = await NativeIconAPI.getImageForFont(
|
|
207
|
-
fontReference,
|
|
208
|
-
glyph,
|
|
209
|
-
size,
|
|
210
|
-
processedColor as number, // FIXME what if a non existant colour was passed in?
|
|
211
|
-
);
|
|
212
|
-
const value = { uri: imagePath, scale: PixelRatio.get() };
|
|
213
|
-
imageSourceCache.setValue(cacheKey, value);
|
|
214
|
-
return value;
|
|
215
|
-
} catch (error) {
|
|
216
|
-
imageSourceCache.setError(cacheKey, error as Error);
|
|
217
|
-
throw error;
|
|
218
|
-
}
|
|
219
|
-
};
|
|
164
|
+
const getImageSourceSync: GetImageSourceSyncIconFunc<keyof GM> = (name, size, color) =>
|
|
165
|
+
getImageSourceSyncImpl(imageSourceCache, fontReference, resolveGlyph(name), size, color);
|
|
220
166
|
|
|
221
167
|
const IconNamespace = Object.assign(WrappedIcon, {
|
|
222
168
|
getImageSource,
|
|
@@ -12,8 +12,6 @@ export default function createIconSourceCache() {
|
|
|
12
12
|
|
|
13
13
|
const setError = (key: string, error: Error) => cache.set(key, { type: TYPE_ERROR, data: error });
|
|
14
14
|
|
|
15
|
-
const has = (key: string) => cache.has(key);
|
|
16
|
-
|
|
17
15
|
const get = (key: string) => {
|
|
18
16
|
const value = cache.get(key);
|
|
19
17
|
if (!value) {
|
|
@@ -27,5 +25,5 @@ export default function createIconSourceCache() {
|
|
|
27
25
|
return data;
|
|
28
26
|
};
|
|
29
27
|
|
|
30
|
-
return { setValue, setError,
|
|
28
|
+
return { setValue, setError, get };
|
|
31
29
|
}
|
package/src/defaults.ts
ADDED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { Image } from 'react-native';
|
|
2
|
+
|
|
1
3
|
/*
|
|
2
4
|
* The following imports are always present when react native is installed
|
|
3
5
|
* in the future, more explicit apis will be exposed by the core, including typings
|
|
@@ -5,20 +7,17 @@
|
|
|
5
7
|
// @ts-expect-error missing types
|
|
6
8
|
// eslint-disable-next-line import/no-extraneous-dependencies,import/no-unresolved
|
|
7
9
|
import { getAssetByID } from '@react-native/assets-registry/registry';
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
11
|
-
import resolveAssetSource from 'react-native/Libraries/Image/resolveAssetSource';
|
|
12
|
-
import { getErrorCallback } from './dynamic-loading-setting';
|
|
10
|
+
|
|
11
|
+
import { assertExpoModulesPresent, getErrorCallback } from './dynamic-loading-setting';
|
|
13
12
|
import type { DynamicLoader, FontSource } from './types';
|
|
14
13
|
|
|
15
14
|
const loadPromises: { [fontSource: string]: Promise<void> } = {};
|
|
16
15
|
|
|
17
16
|
const loadFontAsync = async (fontFamily: string, fontSource: FontSource): Promise<void> => {
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
const globalRef = globalThis;
|
|
18
|
+
assertExpoModulesPresent(globalRef);
|
|
19
|
+
|
|
20
|
+
const expoModules = globalRef.expo.modules;
|
|
22
21
|
|
|
23
22
|
if (loadPromises[fontFamily]) {
|
|
24
23
|
return loadPromises[fontFamily];
|
|
@@ -66,8 +65,7 @@ const getLocalFontUrl = (fontModuleId: number, fontFamily: string) => {
|
|
|
66
65
|
throw new Error(`no asset found for font family "${fontFamily}", moduleId: ${String(fontModuleId)}`);
|
|
67
66
|
}
|
|
68
67
|
|
|
69
|
-
const
|
|
70
|
-
const assetSource = resolver(fontModuleId);
|
|
68
|
+
const assetSource = Image.resolveAssetSource(fontModuleId);
|
|
71
69
|
|
|
72
70
|
return { ...assetMeta, ...assetSource };
|
|
73
71
|
};
|
|
@@ -78,13 +76,10 @@ const isLoadedNative = (fontFamily: string) => {
|
|
|
78
76
|
if (fontFamily in loadedFontsCache) {
|
|
79
77
|
return true;
|
|
80
78
|
}
|
|
79
|
+
const globalRef = globalThis;
|
|
80
|
+
assertExpoModulesPresent(globalRef);
|
|
81
81
|
|
|
82
|
-
const
|
|
83
|
-
if (!expo) {
|
|
84
|
-
throw new Error('Expo is not available. Dynamic font loading is not available.');
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
const loadedNativeFonts = expo.modules.ExpoFontLoader.getLoadedFonts();
|
|
82
|
+
const loadedNativeFonts = globalRef.expo.modules.ExpoFontLoader.getLoadedFonts();
|
|
88
83
|
loadedNativeFonts.forEach((font) => {
|
|
89
84
|
loadedFontsCache[font] = true;
|
|
90
85
|
});
|