@react-native-vector-icons/common 12.0.0-beta.1 → 12.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/android/generated/android/app/build/generated/source/codegen/java/com/facebook/fbreact/specs/NativeVectorIconsSpec.java +42 -0
- package/android/generated/android/app/build/generated/source/codegen/jni/CMakeLists.txt +36 -0
- package/android/generated/android/app/build/generated/source/codegen/jni/RNVectorIconsSpec-generated.cpp +38 -0
- package/android/generated/android/app/build/generated/source/codegen/jni/RNVectorIconsSpec.h +31 -0
- package/android/generated/android/app/build/generated/source/codegen/jni/react/renderer/components/RNVectorIconsSpec/ComponentDescriptors.cpp +22 -0
- package/android/generated/android/app/build/generated/source/codegen/jni/react/renderer/components/RNVectorIconsSpec/ComponentDescriptors.h +24 -0
- package/android/generated/android/app/build/generated/source/codegen/jni/react/renderer/components/RNVectorIconsSpec/EventEmitters.cpp +16 -0
- package/android/generated/android/app/build/generated/source/codegen/jni/react/renderer/components/RNVectorIconsSpec/EventEmitters.h +17 -0
- package/android/generated/android/app/build/generated/source/codegen/jni/react/renderer/components/RNVectorIconsSpec/Props.cpp +19 -0
- package/android/generated/android/app/build/generated/source/codegen/jni/react/renderer/components/RNVectorIconsSpec/Props.h +18 -0
- package/android/generated/android/app/build/generated/source/codegen/jni/react/renderer/components/RNVectorIconsSpec/RNVectorIconsSpecJSI-generated.cpp +40 -0
- package/android/generated/android/app/build/generated/source/codegen/jni/react/renderer/components/RNVectorIconsSpec/RNVectorIconsSpecJSI.h +76 -0
- package/android/generated/android/app/build/generated/source/codegen/jni/react/renderer/components/RNVectorIconsSpec/ShadowNodes.cpp +17 -0
- package/android/generated/android/app/build/generated/source/codegen/jni/react/renderer/components/RNVectorIconsSpec/ShadowNodes.h +23 -0
- package/android/generated/android/app/build/generated/source/codegen/jni/react/renderer/components/RNVectorIconsSpec/States.cpp +16 -0
- package/android/generated/android/app/build/generated/source/codegen/jni/react/renderer/components/RNVectorIconsSpec/States.h +19 -0
- package/ios/generated/build/generated/ios/FBReactNativeSpec/FBReactNativeSpec-generated.mm +2321 -0
- package/ios/generated/build/generated/ios/FBReactNativeSpec/FBReactNativeSpec.h +2761 -0
- package/ios/generated/build/generated/ios/FBReactNativeSpecJSI-generated.cpp +2929 -0
- package/ios/generated/build/generated/ios/FBReactNativeSpecJSI.h +7727 -0
- package/ios/generated/build/generated/ios/RCTModulesConformingToProtocolsProvider.h +18 -0
- package/ios/generated/build/generated/ios/RCTModulesConformingToProtocolsProvider.mm +33 -0
- package/ios/generated/build/generated/ios/RNVectorIconsSpec/RNVectorIconsSpec-generated.mm +46 -0
- package/ios/generated/build/generated/ios/RNVectorIconsSpec/RNVectorIconsSpec.h +68 -0
- package/ios/generated/build/generated/ios/RNVectorIconsSpecJSI-generated.cpp +40 -0
- package/ios/generated/build/generated/ios/RNVectorIconsSpecJSI.h +76 -0
- package/ios/generated/build/generated/ios/react/renderer/components/RNVectorIconsSpec/ComponentDescriptors.cpp +22 -0
- package/ios/generated/build/generated/ios/react/renderer/components/RNVectorIconsSpec/ComponentDescriptors.h +24 -0
- package/ios/generated/build/generated/ios/react/renderer/components/RNVectorIconsSpec/EventEmitters.cpp +16 -0
- package/ios/generated/build/generated/ios/react/renderer/components/RNVectorIconsSpec/EventEmitters.h +17 -0
- package/ios/generated/build/generated/ios/react/renderer/components/RNVectorIconsSpec/Props.cpp +19 -0
- package/ios/generated/build/generated/ios/react/renderer/components/RNVectorIconsSpec/Props.h +18 -0
- package/ios/generated/build/generated/ios/react/renderer/components/RNVectorIconsSpec/RCTComponentViewHelpers.h +18 -0
- package/ios/generated/build/generated/ios/react/renderer/components/RNVectorIconsSpec/ShadowNodes.cpp +17 -0
- package/ios/generated/build/generated/ios/react/renderer/components/RNVectorIconsSpec/ShadowNodes.h +23 -0
- package/ios/generated/build/generated/ios/react/renderer/components/RNVectorIconsSpec/States.cpp +16 -0
- package/ios/generated/build/generated/ios/react/renderer/components/RNVectorIconsSpec/States.h +19 -0
- package/lib/commonjs/create-icon-set.js +9 -12
- package/lib/commonjs/create-icon-set.js.map +1 -1
- 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 +11 -1
- package/lib/commonjs/dynamicLoading/dynamic-loading-setting.js.map +1 -1
- package/lib/commonjs/get-image-library.js +4 -3
- package/lib/commonjs/get-image-library.js.map +1 -1
- package/lib/module/create-icon-set.js +8 -11
- package/lib/module/create-icon-set.js.map +1 -1
- package/lib/module/dynamicLoading/dynamic-font-loading.js +9 -17
- package/lib/module/dynamicLoading/dynamic-font-loading.js.map +1 -1
- package/lib/module/dynamicLoading/dynamic-loading-setting.js +10 -1
- package/lib/module/dynamicLoading/dynamic-loading-setting.js.map +1 -1
- package/lib/module/get-image-library.js +2 -1
- package/lib/module/get-image-library.js.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 +18 -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 +1 -2
- package/lib/typescript/commonjs/src/get-image-library.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 +18 -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 +1 -2
- package/lib/typescript/module/src/get-image-library.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/create-icon-set.tsx +11 -14
- package/src/dynamicLoading/dynamic-font-loading.ts +10 -17
- package/src/dynamicLoading/dynamic-loading-setting.ts +41 -13
- package/src/get-image-library.ts +3 -1
|
@@ -5,20 +5,17 @@
|
|
|
5
5
|
// @ts-expect-error missing types
|
|
6
6
|
// eslint-disable-next-line import/no-extraneous-dependencies,import/no-unresolved
|
|
7
7
|
import { getAssetByID } from '@react-native/assets-registry/registry';
|
|
8
|
-
import
|
|
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';
|
|
8
|
+
import { Image } from 'react-native';
|
|
9
|
+
import { assertExpoModulesPresent, getErrorCallback } from './dynamic-loading-setting';
|
|
13
10
|
import type { DynamicLoader, FontSource } from './types';
|
|
14
11
|
|
|
15
12
|
const loadPromises: { [fontSource: string]: Promise<void> } = {};
|
|
16
13
|
|
|
17
14
|
const loadFontAsync = async (fontFamily: string, fontSource: FontSource): Promise<void> => {
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
15
|
+
const globalRef = globalThis;
|
|
16
|
+
assertExpoModulesPresent(globalRef);
|
|
17
|
+
|
|
18
|
+
const expoModules = globalRef.expo.modules;
|
|
22
19
|
|
|
23
20
|
if (loadPromises[fontFamily]) {
|
|
24
21
|
return loadPromises[fontFamily];
|
|
@@ -66,8 +63,7 @@ const getLocalFontUrl = (fontModuleId: number, fontFamily: string) => {
|
|
|
66
63
|
throw new Error(`no asset found for font family "${fontFamily}", moduleId: ${String(fontModuleId)}`);
|
|
67
64
|
}
|
|
68
65
|
|
|
69
|
-
const
|
|
70
|
-
const assetSource = resolver(fontModuleId);
|
|
66
|
+
const assetSource = Image.resolveAssetSource(fontModuleId);
|
|
71
67
|
|
|
72
68
|
return { ...assetMeta, ...assetSource };
|
|
73
69
|
};
|
|
@@ -78,13 +74,10 @@ const isLoadedNative = (fontFamily: string) => {
|
|
|
78
74
|
if (fontFamily in loadedFontsCache) {
|
|
79
75
|
return true;
|
|
80
76
|
}
|
|
77
|
+
const globalRef = globalThis;
|
|
78
|
+
assertExpoModulesPresent(globalRef);
|
|
81
79
|
|
|
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();
|
|
80
|
+
const loadedNativeFonts = globalRef.expo.modules.ExpoFontLoader.getLoadedFonts();
|
|
88
81
|
loadedNativeFonts.forEach((font) => {
|
|
89
82
|
loadedFontsCache[font] = true;
|
|
90
83
|
});
|
|
@@ -1,19 +1,23 @@
|
|
|
1
1
|
import type { FontSource } from './types';
|
|
2
2
|
|
|
3
|
+
type ExpoAssetModule = {
|
|
4
|
+
// definition from
|
|
5
|
+
// https://github.com/expo/expo/blob/1f5a5991d14aad09282d1ce1612b44d30e7e7d3d/packages/expo-asset/ios/AssetModule.swift#L23
|
|
6
|
+
downloadAsync: (uri: string, hash: string | undefined, type: string) => Promise<string>;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
type ExpoFontLoaderModule = {
|
|
10
|
+
// definition from
|
|
11
|
+
// https://github.com/expo/expo/blob/1f5a5991d14aad09282d1ce1612b44d30e7e7d3d/packages/expo-font/ios/FontLoaderModule.swift#L18
|
|
12
|
+
getLoadedFonts: () => string[];
|
|
13
|
+
loadAsync: (fontFamilyAlias: string, fileUri: string) => Promise<void>;
|
|
14
|
+
};
|
|
15
|
+
|
|
3
16
|
declare global {
|
|
4
17
|
interface ExpoGlobal {
|
|
5
18
|
modules: {
|
|
6
|
-
ExpoAsset
|
|
7
|
-
|
|
8
|
-
// https://github.com/expo/expo/blob/1f5a5991d14aad09282d1ce1612b44d30e7e7d3d/packages/expo-asset/ios/AssetModule.swift#L23
|
|
9
|
-
downloadAsync: (uri: string, hash: string | undefined, type: string) => Promise<string>;
|
|
10
|
-
};
|
|
11
|
-
ExpoFontLoader: {
|
|
12
|
-
// definition from
|
|
13
|
-
// https://github.com/expo/expo/blob/1f5a5991d14aad09282d1ce1612b44d30e7e7d3d/packages/expo-font/ios/FontLoaderModule.swift#L18
|
|
14
|
-
getLoadedFonts: () => string[];
|
|
15
|
-
loadAsync: (fontFamilyAlias: string, fileUri: string) => Promise<void>;
|
|
16
|
-
};
|
|
19
|
+
ExpoAsset?: ExpoAssetModule;
|
|
20
|
+
ExpoFontLoader?: ExpoFontLoaderModule;
|
|
17
21
|
};
|
|
18
22
|
}
|
|
19
23
|
|
|
@@ -21,10 +25,34 @@ declare global {
|
|
|
21
25
|
var expo: ExpoGlobal | undefined;
|
|
22
26
|
}
|
|
23
27
|
|
|
28
|
+
type ExpoGlobalType = {
|
|
29
|
+
modules: {
|
|
30
|
+
ExpoAsset: ExpoAssetModule;
|
|
31
|
+
ExpoFontLoader: ExpoFontLoaderModule;
|
|
32
|
+
};
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
// biome-ignore lint/suspicious/noExplicitAny: this is used internally with globalThis
|
|
36
|
+
function getIsDynamicLoadingSupported(globalObj: any): globalObj is {
|
|
37
|
+
expo: ExpoGlobalType;
|
|
38
|
+
} {
|
|
39
|
+
return (
|
|
40
|
+
globalObj?.expo &&
|
|
41
|
+
typeof globalObj.expo.modules?.ExpoAsset?.downloadAsync === 'function' &&
|
|
42
|
+
typeof globalObj.expo.modules?.ExpoFontLoader?.getLoadedFonts === 'function' &&
|
|
43
|
+
typeof globalObj.expo.modules?.ExpoFontLoader?.loadAsync === 'function'
|
|
44
|
+
);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export function assertExpoModulesPresent(globalObj: unknown): asserts globalObj is { expo: ExpoGlobalType } {
|
|
48
|
+
if (!getIsDynamicLoadingSupported(globalObj)) {
|
|
49
|
+
throw new Error('Dynamic font loading for Expo is not available.');
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
24
53
|
const hasNecessaryExpoModules = !!globalThis.expo?.modules?.ExpoAsset && !!globalThis.expo?.modules?.ExpoFontLoader;
|
|
25
54
|
|
|
26
|
-
const hasNecessaryExpoFeatures =
|
|
27
|
-
hasNecessaryExpoModules && typeof globalThis.expo?.modules.ExpoFontLoader.getLoadedFonts === 'function';
|
|
55
|
+
const hasNecessaryExpoFeatures = getIsDynamicLoadingSupported(globalThis);
|
|
28
56
|
|
|
29
57
|
let dynamicFontLoadingEnabled = hasNecessaryExpoFeatures;
|
|
30
58
|
|
package/src/get-image-library.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// eslint-disable-next-line import/no-mutable-exports
|
|
2
|
-
|
|
2
|
+
let NativeIconAPI: typeof import('@react-native-vector-icons/get-image') | null = null;
|
|
3
3
|
|
|
4
4
|
try {
|
|
5
5
|
// eslint-disable-next-line global-require,import/no-extraneous-dependencies,@typescript-eslint/no-require-imports
|
|
@@ -16,4 +16,6 @@ export const ensureGetImageAvailable = () => {
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
NativeIconAPI.ensureNativeModuleAvailable();
|
|
19
|
+
|
|
20
|
+
return NativeIconAPI;
|
|
19
21
|
};
|