@react-native-vector-icons/common 12.0.0-alpha.14 → 12.0.0-alpha.21

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.
Files changed (78) hide show
  1. package/LICENSE +20 -0
  2. package/README.md +22 -40
  3. package/lib/commonjs/create-icon-set.js +11 -6
  4. package/lib/commonjs/create-icon-set.js.map +1 -1
  5. package/lib/commonjs/dynamicLoading/dynamic-font-loading.js +2 -1
  6. package/lib/commonjs/dynamicLoading/dynamic-font-loading.js.map +1 -1
  7. package/lib/commonjs/get-image-library.js +22 -0
  8. package/lib/commonjs/get-image-library.js.map +1 -0
  9. package/lib/commonjs/index.js +0 -31
  10. package/lib/commonjs/index.js.map +1 -1
  11. package/lib/module/create-icon-set.js +8 -4
  12. package/lib/module/create-icon-set.js.map +1 -1
  13. package/lib/module/dynamicLoading/dynamic-font-loading.js +2 -1
  14. package/lib/module/dynamicLoading/dynamic-font-loading.js.map +1 -1
  15. package/lib/module/get-image-library.js +17 -0
  16. package/lib/module/get-image-library.js.map +1 -0
  17. package/lib/module/index.js +0 -29
  18. package/lib/module/index.js.map +1 -1
  19. package/lib/typescript/commonjs/src/create-icon-set.d.ts.map +1 -1
  20. package/lib/typescript/commonjs/src/dynamicLoading/dynamic-font-loading.d.ts.map +1 -1
  21. package/lib/typescript/commonjs/src/dynamicLoading/dynamic-loading-setting.d.ts.map +1 -1
  22. package/lib/typescript/commonjs/src/get-image-library.d.ts +3 -0
  23. package/lib/typescript/commonjs/src/get-image-library.d.ts.map +1 -0
  24. package/lib/typescript/commonjs/src/index.d.ts +0 -2
  25. package/lib/typescript/commonjs/src/index.d.ts.map +1 -1
  26. package/lib/typescript/commonjs/src/scripts/common.d.ts.map +1 -1
  27. package/lib/typescript/module/src/create-icon-set.d.ts.map +1 -1
  28. package/lib/typescript/module/src/dynamicLoading/dynamic-font-loading.d.ts.map +1 -1
  29. package/lib/typescript/module/src/dynamicLoading/dynamic-loading-setting.d.ts.map +1 -1
  30. package/lib/typescript/module/src/get-image-library.d.ts +3 -0
  31. package/lib/typescript/module/src/get-image-library.d.ts.map +1 -0
  32. package/lib/typescript/module/src/index.d.ts +0 -2
  33. package/lib/typescript/module/src/index.d.ts.map +1 -1
  34. package/lib/typescript/module/src/scripts/common.d.ts.map +1 -1
  35. package/package.json +16 -53
  36. package/src/create-icon-set.tsx +9 -6
  37. package/src/dynamicLoading/dynamic-font-loading.ts +2 -1
  38. package/src/get-image-library.ts +19 -0
  39. package/src/index.ts +0 -41
  40. package/android/build.gradle +0 -146
  41. package/android/gradle.properties +0 -5
  42. package/android/src/main/AndroidManifest.xml +0 -3
  43. package/android/src/main/AndroidManifestNew.xml +0 -2
  44. package/android/src/main/java/com/reactnativevectoricons/common/VectorIconsModule.kt +0 -90
  45. package/android/src/main/java/com/reactnativevectoricons/common/VectorIconsPackage.kt +0 -35
  46. package/android/src/newarch/VectorIconsSpec.kt +0 -7
  47. package/android/src/oldarch/VectorIconsSpec.kt +0 -38
  48. package/ios/VectorIcons.h +0 -24
  49. package/ios/VectorIcons.mm +0 -161
  50. package/lib/commonjs/NativeVectorIcons.js +0 -16
  51. package/lib/commonjs/NativeVectorIcons.js.map +0 -1
  52. package/lib/commonjs/NativeVectorIcons.web.js +0 -8
  53. package/lib/commonjs/NativeVectorIcons.web.js.map +0 -1
  54. package/lib/commonjs/ensure-native-module-available.js +0 -14
  55. package/lib/commonjs/ensure-native-module-available.js.map +0 -1
  56. package/lib/module/NativeVectorIcons.js +0 -12
  57. package/lib/module/NativeVectorIcons.js.map +0 -1
  58. package/lib/module/NativeVectorIcons.web.js +0 -4
  59. package/lib/module/NativeVectorIcons.web.js.map +0 -1
  60. package/lib/module/ensure-native-module-available.js +0 -9
  61. package/lib/module/ensure-native-module-available.js.map +0 -1
  62. package/lib/typescript/commonjs/src/NativeVectorIcons.d.ts +0 -8
  63. package/lib/typescript/commonjs/src/NativeVectorIcons.d.ts.map +0 -1
  64. package/lib/typescript/commonjs/src/NativeVectorIcons.web.d.ts +0 -3
  65. package/lib/typescript/commonjs/src/NativeVectorIcons.web.d.ts.map +0 -1
  66. package/lib/typescript/commonjs/src/ensure-native-module-available.d.ts +0 -2
  67. package/lib/typescript/commonjs/src/ensure-native-module-available.d.ts.map +0 -1
  68. package/lib/typescript/module/src/NativeVectorIcons.d.ts +0 -8
  69. package/lib/typescript/module/src/NativeVectorIcons.d.ts.map +0 -1
  70. package/lib/typescript/module/src/NativeVectorIcons.web.d.ts +0 -3
  71. package/lib/typescript/module/src/NativeVectorIcons.web.d.ts.map +0 -1
  72. package/lib/typescript/module/src/ensure-native-module-available.d.ts +0 -2
  73. package/lib/typescript/module/src/ensure-native-module-available.d.ts.map +0 -1
  74. package/react-native-vector-icons.podspec +0 -41
  75. package/react-native.config.js +0 -13
  76. package/src/NativeVectorIcons.ts +0 -16
  77. package/src/NativeVectorIcons.web.ts +0 -1
  78. package/src/ensure-native-module-available.ts +0 -9
@@ -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,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,UAAU;QAClB,OAAO,EAAE;YACP,SAAS,EAAE;gBAGT,aAAa,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,SAAS,EAAE,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;aACzF,CAAC;YACF,cAAc,EAAE;gBAGd,cAAc,EAAE,MAAM,MAAM,EAAE,CAAC;gBAC/B,SAAS,EAAE,CAAC,eAAe,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;aACxE,CAAC;SACH,CAAC;KACH;IAGD,IAAI,IAAI,EAAE,UAAU,GAAG,SAAS,CAAC;CAClC;AASD,eAAO,MAAM,yBAAyB,eAAiC,CAAC;AAExE;;;;;;;KAOK;AACL,eAAO,MAAM,wBAAwB,UAAW,OAAO,KAAG,OAczD,CAAC;AAEF;;KAEK;AACL,eAAO,MAAM,uBAAuB,eAAkC,CAAC;AAEvE,KAAK,aAAa,GAAG,CAAC,IAAI,EAAE;IAC1B,KAAK,EAAE,KAAK,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,UAAU,CAAC;CACxB,KAAK,IAAI,CAAC;AAIX;;KAEK;AACL,eAAO,MAAM,8BAA8B,aAAc,aAAa,SAErE,CAAC;AAEF,eAAO,MAAM,gBAAgB,iCAAoC,CAAC"}
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,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,UAAU;QAClB,OAAO,EAAE;YACP,SAAS,EAAE;gBAGT,aAAa,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,SAAS,EAAE,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,CAAC,CAAC;aACzF,CAAC;YACF,cAAc,EAAE;gBAGd,cAAc,EAAE,MAAM,MAAM,EAAE,CAAC;gBAC/B,SAAS,EAAE,CAAC,eAAe,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;aACxE,CAAC;SACH,CAAC;KACH;IAGD,IAAI,IAAI,EAAE,UAAU,GAAG,SAAS,CAAC;CAClC;AASD,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;IAC1B,KAAK,EAAE,KAAK,CAAC;IACb,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,UAAU,CAAC;CACxB,KAAK,IAAI,CAAC;AAIX;;KAEK;AACL,eAAO,MAAM,8BAA8B,GAAI,UAAU,aAAa,SAErE,CAAC;AAEF,eAAO,MAAM,gBAAgB,iCAAoC,CAAC"}
@@ -0,0 +1,3 @@
1
+ export declare let NativeIconAPI: typeof import('@react-native-vector-icons/get-image') | null;
2
+ export declare const ensureGetImageAvailable: () => void;
3
+ //# sourceMappingURL=get-image-library.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"get-image-library.d.ts","sourceRoot":"","sources":["../../../../src/get-image-library.ts"],"names":[],"mappings":"AACA,eAAO,IAAI,aAAa,EAAE,cAAc,sCAAsC,CAAC,GAAG,IAAW,CAAC;AAS9F,eAAO,MAAM,uBAAuB,YAQnC,CAAC"}
@@ -1,6 +1,4 @@
1
1
  export { createIconSet, DEFAULT_ICON_SIZE, DEFAULT_ICON_COLOR } from './create-icon-set';
2
2
  export type { IconProps, CreateIconSetOptions } from './create-icon-set';
3
3
  export { setDynamicLoadingEnabled, isDynamicLoadingEnabled, isDynamicLoadingSupported, setDynamicLoadingErrorCallback, } from './dynamicLoading/dynamic-loading-setting';
4
- export declare function getImageForFont(fontFamilyName: string, glyph: string, fontSize: number, color: number): Promise<string>;
5
- export declare function getImageForFontSync(fontFamilyName: string, glyph: string, fontSize: number, color: number): string;
6
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACzF,YAAY,EAAE,SAAS,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACzE,OAAO,EACL,wBAAwB,EACxB,uBAAuB,EACvB,yBAAyB,EACzB,8BAA8B,GAC/B,MAAM,0CAA0C,CAAC;AA4BlD,wBAAgB,eAAe,CAC7B,cAAc,EAAE,MAAM,EACtB,KAAK,EAAE,MAAM,EACb,QAAQ,EAAE,MAAM,EAChB,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC,MAAM,CAAC,CAEjB;AAED,wBAAgB,mBAAmB,CAAC,cAAc,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,CAElH"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACzF,YAAY,EAAE,SAAS,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACzE,OAAO,EACL,wBAAwB,EACxB,uBAAuB,EACvB,yBAAyB,EACzB,8BAA8B,GAC/B,MAAM,0CAA0C,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../../../src/scripts/common.ts"],"names":[],"mappings":"AA6CA,eAAO,MAAM,YAAY,wBAAyB,MAAM,aAMvD,CAAC"}
1
+ {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../../../src/scripts/common.ts"],"names":[],"mappings":"AA6CA,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.0.0-alpha.14",
3
+ "version": "12.0.0-alpha.21",
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",
@@ -20,34 +20,17 @@
20
20
  }
21
21
  },
22
22
  "files": [
23
- "scripts",
24
23
  "src",
25
24
  "lib",
26
25
  "android",
27
26
  "ios",
28
27
  "cpp",
29
28
  "*.podspec",
30
- "react-native.config.js",
31
- "!ios/generated",
32
- "!android/generated",
33
- "!ios/build",
34
- "!android/build",
35
- "!android/gradle",
36
- "!android/gradlew",
37
- "!android/gradlew.bat",
38
- "!android/local.properties",
39
29
  "!**/__tests__",
40
30
  "!**/__fixtures__",
41
31
  "!**/__mocks__",
42
32
  "!**/.*"
43
33
  ],
44
- "scripts": {
45
- "clean": "del-cli android/build example/android/build example/android/app/build example/ios/build lib",
46
- "prepare": "bob build && chmod +x lib/commonjs/scripts/updatePlist.js",
47
- "prepack": "cp ../../README.md .",
48
- "postpack": "rm README.md",
49
- "watch": "onchange 'src/**' --initial -- yarn run prepare"
50
- },
51
34
  "bin": {
52
35
  "rnvi-update-plist": "lib/commonjs/scripts/updatePlist.js"
53
36
  },
@@ -71,7 +54,8 @@
71
54
  ],
72
55
  "repository": {
73
56
  "type": "git",
74
- "url": "git://github.com/oblador/react-native-vector-icons.git"
57
+ "url": "https://github.com/oblador/react-native-vector-icons.git",
58
+ "directory": "packages/common"
75
59
  },
76
60
  "author": {
77
61
  "name": "Joel Arvidsson",
@@ -86,43 +70,32 @@
86
70
  "registry": "https://registry.npmjs.org/"
87
71
  },
88
72
  "dependencies": {
89
- "@react-native-community/cli-tools": "^15.1.2",
73
+ "@react-native-community/cli-tools": "^17.0.0",
90
74
  "picocolors": "^1.1.1",
91
75
  "plist": "^3.1.0"
92
76
  },
93
77
  "devDependencies": {
94
78
  "@types/plist": "^3.0.5",
95
- "@types/react": "~18.3.18",
79
+ "@types/react": "^18.3.18",
96
80
  "del-cli": "^6.0.0",
97
81
  "onchange": "^7.1.0",
98
- "react": "18.3.1",
99
- "react-native": "0.76.5",
100
82
  "react-native-builder-bob": "^0.35.2",
101
- "turbo": "^1.13.4",
102
83
  "typescript": "^5.7.2"
103
84
  },
104
- "resolutions": {
105
- "@types/react": "^18.2.44"
106
- },
107
85
  "peerDependencies": {
108
86
  "react": "*",
109
87
  "react-native": "*"
110
88
  },
111
- "workspaces": [
112
- "packages/*"
113
- ],
114
- "jest": {
115
- "preset": "react-native",
116
- "modulePathIgnorePatterns": [
117
- "<rootDir>/example/node_modules",
118
- "<rootDir>/lib/"
119
- ]
89
+ "optionalDependencies": {
90
+ "@react-native-vector-icons/get-image": "12.0.0-alpha.21"
91
+ },
92
+ "engines": {
93
+ "node": ">= 18.0.0"
120
94
  },
121
95
  "react-native-builder-bob": {
122
96
  "source": "src",
123
97
  "output": "lib",
124
98
  "targets": [
125
- "codegen",
126
99
  [
127
100
  "commonjs",
128
101
  {
@@ -144,22 +117,12 @@
144
117
  ]
145
118
  ]
146
119
  },
147
- "codegenConfig": {
148
- "name": "RNVectorIconsSpec",
149
- "type": "all",
150
- "jsSrcsDir": "src",
151
- "outputDir": {
152
- "ios": "ios/generated",
153
- "android": "android/generated"
154
- },
155
- "android": {
156
- "javaPackageName": "com.reactnativevectoricons.common"
157
- },
158
- "includesGeneratedCode": false
159
- },
160
120
  "create-react-native-library": {
161
- "type": "module-mixed",
162
- "languages": "kotlin-objc",
121
+ "type": "library",
163
122
  "version": "0.41.2"
123
+ },
124
+ "scripts": {
125
+ "clean": "del-cli lib",
126
+ "watch": "onchange 'src/**' --initial -- pnpm run prepare"
164
127
  }
165
- }
128
+ }
@@ -1,13 +1,14 @@
1
+ // eslint-disable-next-line import/no-extraneous-dependencies
1
2
  import React, { forwardRef, type Ref, useEffect } from 'react';
2
3
 
4
+ // eslint-disable-next-line import/no-extraneous-dependencies
3
5
  import { PixelRatio, Platform, Text, type TextProps, type TextStyle, processColor } from 'react-native';
4
6
 
5
- import NativeIconAPI from './NativeVectorIcons';
6
7
  import createIconSourceCache from './create-icon-source-cache';
7
8
  import { dynamicLoader } from './dynamicLoading/dynamic-font-loading';
8
9
  import { isDynamicLoadingEnabled } from './dynamicLoading/dynamic-loading-setting';
9
10
  import type { FontSource } from './dynamicLoading/types';
10
- import ensureNativeModuleAvailable from './ensure-native-module-available';
11
+ import { NativeIconAPI, ensureGetImageAvailable } from './get-image-library';
11
12
 
12
13
  export const DEFAULT_ICON_SIZE = 12;
13
14
  export const DEFAULT_ICON_COLOR = 'black';
@@ -158,7 +159,7 @@ export function createIconSet<GM extends Record<string, number>>(
158
159
  size = DEFAULT_ICON_SIZE,
159
160
  color: TextStyle['color'] = DEFAULT_ICON_COLOR,
160
161
  ) => {
161
- ensureNativeModuleAvailable();
162
+ ensureGetImageAvailable();
162
163
 
163
164
  const glyph = resolveGlyph(name);
164
165
  const processedColor = processColor(color);
@@ -170,7 +171,8 @@ export function createIconSet<GM extends Record<string, number>>(
170
171
  }
171
172
 
172
173
  try {
173
- const imagePath = NativeIconAPI.getImageForFontSync(
174
+ // biome-ignore lint/style/noNonNullAssertion: this is checked in ensureGetImageAvailable
175
+ const imagePath = NativeIconAPI!.getImageForFontSync(
174
176
  fontReference,
175
177
  glyph,
176
178
  size,
@@ -190,7 +192,7 @@ export function createIconSet<GM extends Record<string, number>>(
190
192
  size = DEFAULT_ICON_SIZE,
191
193
  color: TextStyle['color'] = DEFAULT_ICON_COLOR,
192
194
  ) => {
193
- ensureNativeModuleAvailable();
195
+ ensureGetImageAvailable();
194
196
 
195
197
  const glyph = resolveGlyph(name);
196
198
  const processedColor = processColor(color);
@@ -202,7 +204,8 @@ export function createIconSet<GM extends Record<string, number>>(
202
204
  }
203
205
 
204
206
  try {
205
- const imagePath = await NativeIconAPI.getImageForFont(
207
+ // biome-ignore lint/style/noNonNullAssertion: this is checked in ensureGetImageAvailable
208
+ const imagePath = await NativeIconAPI!.getImageForFont(
206
209
  fontReference,
207
210
  glyph,
208
211
  size,
@@ -3,10 +3,11 @@
3
3
  * in the future, more explicit apis will be exposed by the core, including typings
4
4
  * */
5
5
  // @ts-expect-error missing types
6
- // eslint-disable-next-line import/no-extraneous-dependencies
6
+ // eslint-disable-next-line import/no-extraneous-dependencies,import/no-unresolved
7
7
  import { getAssetByID } from '@react-native/assets-registry/registry';
8
8
  import type { Image } from 'react-native';
9
9
  // @ts-expect-error missing types
10
+ // eslint-disable-next-line import/no-extraneous-dependencies
10
11
  import resolveAssetSource from 'react-native/Libraries/Image/resolveAssetSource';
11
12
  import { getErrorCallback } from './dynamic-loading-setting';
12
13
  import type { DynamicLoader, FontSource } from './types';
@@ -0,0 +1,19 @@
1
+ // eslint-disable-next-line import/no-mutable-exports
2
+ export let NativeIconAPI: typeof import('@react-native-vector-icons/get-image') | null = null;
3
+
4
+ try {
5
+ // eslint-disable-next-line global-require,import/no-extraneous-dependencies,@typescript-eslint/no-require-imports
6
+ NativeIconAPI = require('@react-native-vector-icons/get-image');
7
+ } catch {
8
+ // No warning at this stage
9
+ }
10
+
11
+ export const ensureGetImageAvailable = () => {
12
+ if (!NativeIconAPI) {
13
+ throw new Error(
14
+ 'Could not import @react-native-vector-icons/get-image, did you install it? It is required for getImageSource*',
15
+ );
16
+ }
17
+
18
+ NativeIconAPI.ensureNativeModuleAvailable();
19
+ };
package/src/index.ts CHANGED
@@ -1,5 +1,3 @@
1
- import { NativeModules, Platform } from 'react-native';
2
-
3
1
  export { createIconSet, DEFAULT_ICON_SIZE, DEFAULT_ICON_COLOR } from './create-icon-set';
4
2
  export type { IconProps, CreateIconSetOptions } from './create-icon-set';
5
3
  export {
@@ -8,42 +6,3 @@ export {
8
6
  isDynamicLoadingSupported,
9
7
  setDynamicLoadingErrorCallback,
10
8
  } from './dynamicLoading/dynamic-loading-setting';
11
-
12
- const LINKING_ERROR = `
13
- The package '@react-native-vector-icons/common' doesn't seem to be linked. Make sure:
14
- ${Platform.select({ ios: "- You have run 'pod install'\n", default: '' })}
15
- - You rebuilt the app after installing the package\n'
16
- - You are not using Expo Go
17
- `;
18
-
19
- // @ts-expect-error : NativeModules type is incomplete
20
- const isTurboModuleEnabled = global.__turboModuleProxy != null; // eslint-disable-line no-underscore-dangle
21
-
22
- const VectorIconsModule = isTurboModuleEnabled
23
- ? require('./NativeVectorIcons').default // eslint-disable-line @typescript-eslint/no-require-imports
24
- : NativeModules.VectorIcons;
25
-
26
- const VectorIcons = VectorIconsModule
27
- ? VectorIconsModule
28
- : new Proxy(
29
- {},
30
- {
31
- get() {
32
- throw new Error(LINKING_ERROR);
33
- },
34
- },
35
- );
36
-
37
- // TODO: Do we want to expose this as a public API?
38
- export function getImageForFont(
39
- fontFamilyName: string,
40
- glyph: string,
41
- fontSize: number,
42
- color: number,
43
- ): Promise<string> {
44
- return VectorIcons.getImageForFont(fontFamilyName, glyph, fontSize, color);
45
- }
46
-
47
- export function getImageForFontSync(fontFamilyName: string, glyph: string, fontSize: number, color: number): string {
48
- return VectorIcons.getImageForFontSync(fontFamilyName, glyph, fontSize, color);
49
- }
@@ -1,146 +0,0 @@
1
- buildscript {
2
- // Buildscript is evaluated before everything else so we can't use getExtOrDefault
3
- def kotlin_version = rootProject.ext.has("kotlinVersion") ? rootProject.ext.get("kotlinVersion") : project.properties["VectorIcons_kotlinVersion"]
4
-
5
- repositories {
6
- google()
7
- mavenCentral()
8
- }
9
-
10
- dependencies {
11
- classpath "com.android.tools.build:gradle:7.2.1"
12
- // noinspection DifferentKotlinGradleVersion
13
- classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
14
- }
15
- }
16
-
17
- def reactNativeArchitectures() {
18
- def value = rootProject.getProperties().get("reactNativeArchitectures")
19
- return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
20
- }
21
-
22
- def isNewArchitectureEnabled() {
23
- return rootProject.hasProperty("newArchEnabled") && rootProject.getProperty("newArchEnabled") == "true"
24
- }
25
-
26
- apply plugin: "com.android.library"
27
- apply plugin: "kotlin-android"
28
-
29
- if (isNewArchitectureEnabled()) {
30
- apply plugin: "com.facebook.react"
31
- }
32
-
33
- def getExtOrDefault(name) {
34
- return rootProject.ext.has(name) ? rootProject.ext.get(name) : project.properties["VectorIcons_" + name]
35
- }
36
-
37
- def getExtOrIntegerDefault(name) {
38
- return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["VectorIcons_" + name]).toInteger()
39
- }
40
-
41
- def supportsNamespace() {
42
- def parsed = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')
43
- def major = parsed[0].toInteger()
44
- def minor = parsed[1].toInteger()
45
-
46
- // Namespace support was added in 7.3.0
47
- return (major == 7 && minor >= 3) || major >= 8
48
- }
49
-
50
- import groovy.json.JsonSlurper
51
-
52
- def generatedCompat() {
53
- def rnviProject = rootProject.allprojects.find { it.name == 'react-native-vector-icons_common' }
54
- if (rnviProject == null) return false
55
-
56
- def reactNativeManifest = file("${rnviProject.projectDir}/../../../react-native/package.json")
57
- def reactNativeVersion = new JsonSlurper().parseText(reactNativeManifest.text).version as String
58
-
59
- reactNativeVersion.matches('(0.71.*|0.72.*|0.73.*)')
60
- }
61
-
62
- android {
63
- if (supportsNamespace()) {
64
- namespace "com.reactnativevectoricons.common"
65
-
66
- sourceSets {
67
- main {
68
- manifest.srcFile "src/main/AndroidManifestNew.xml"
69
- }
70
- }
71
- }
72
-
73
- compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
74
-
75
- defaultConfig {
76
- minSdkVersion getExtOrIntegerDefault("minSdkVersion")
77
- targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
78
- buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
79
-
80
- }
81
-
82
- buildFeatures {
83
- buildConfig true
84
- }
85
-
86
- buildTypes {
87
- release {
88
- minifyEnabled false
89
- }
90
- }
91
-
92
- lintOptions {
93
- disable "GradleCompatible"
94
- }
95
-
96
- compileOptions {
97
- sourceCompatibility JavaVersion.VERSION_1_8
98
- targetCompatibility JavaVersion.VERSION_1_8
99
- }
100
-
101
- sourceSets {
102
- main {
103
- if (isNewArchitectureEnabled()) {
104
- java.srcDirs += [
105
- "src/newarch",
106
- ]
107
- if (!generatedCompat()) {
108
- println("Adding generated directories")
109
- println("Adding generated directories")
110
- println("Adding generated directories")
111
- // NOTE: create-react-native-library has these here but it breaks <= 0.73
112
- java.srcDirs += [
113
- // Codegen specs
114
- "generated/java",
115
- "generated/jni"
116
- ]
117
- }
118
- } else {
119
- java.srcDirs += ["src/oldarch"]
120
- }
121
- }
122
- }
123
- }
124
-
125
- repositories {
126
- mavenCentral()
127
- google()
128
- }
129
-
130
- def kotlin_version = getExtOrDefault("kotlinVersion")
131
-
132
- dependencies {
133
- // For < 0.71, this will be from the local maven repo
134
- // For > 0.71, this will be replaced by `com.facebook.react:react-android:$version` by react gradle plugin
135
- //noinspection GradleDynamicVersion
136
- implementation "com.facebook.react:react-native:+"
137
- implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
138
- }
139
-
140
- if (isNewArchitectureEnabled()) {
141
- react {
142
- jsRootDir = file("../src/")
143
- libraryName = "VectorIcons"
144
- codegenJavaPackageName = "com.reactnativevectoricons.common"
145
- }
146
- }
@@ -1,5 +0,0 @@
1
- VectorIcons_kotlinVersion=1.7.0
2
- VectorIcons_minSdkVersion=21
3
- VectorIcons_targetSdkVersion=31
4
- VectorIcons_compileSdkVersion=31
5
- VectorIcons_ndkversion=21.4.7075529
@@ -1,3 +0,0 @@
1
- <manifest xmlns:android="http://schemas.android.com/apk/res/android"
2
- package="com.reactnativevectoricons.common">
3
- </manifest>
@@ -1,2 +0,0 @@
1
- <manifest xmlns:android="http://schemas.android.com/apk/res/android">
2
- </manifest>
@@ -1,90 +0,0 @@
1
- package com.reactnativevectoricons.common
2
-
3
- import com.facebook.react.bridge.ReactApplicationContext
4
- import com.facebook.react.bridge.ReactMethod
5
- import com.facebook.react.bridge.Promise
6
-
7
- import com.facebook.react.util.RNLog
8
- import com.facebook.react.views.text.ReactFontManager
9
-
10
- import android.graphics.*
11
-
12
- import java.io.File
13
- import java.io.FileOutputStream
14
- import java.io.IOException
15
-
16
- class VectorIconsModule internal constructor(context: ReactApplicationContext) :
17
- VectorIconsSpec(context) {
18
-
19
- override fun getName(): String {
20
- return NAME
21
- }
22
-
23
- @ReactMethod
24
- override fun getImageForFont(fontFamilyName: String, glyph: String, fontSize: Double, color: Double, promise: Promise) {
25
- try {
26
- val imagePath = getImageForFontSync(fontFamilyName, glyph, fontSize, color)
27
- promise.resolve(imagePath)
28
- } catch (e: Throwable) {
29
- promise.reject("Failed to get image for font family \"$fontFamilyName\":${e.message}", e)
30
- }
31
- }
32
-
33
- @ReactMethod(isBlockingSynchronousMethod = true)
34
- override fun getImageForFontSync(fontFamilyName: String, glyph: String, fontSize: Double, color: Double): String {
35
- val context = reactApplicationContext
36
- val cacheFolder = context.cacheDir
37
- val cacheFolderPath = "${cacheFolder.absolutePath}/"
38
-
39
- val scale = context.resources.displayMetrics.density
40
- val scaleSuffix = "@${if (scale == scale.toInt().toFloat()) scale.toInt() else scale}x"
41
- val size = Math.round(fontSize * scale).toInt()
42
- val cacheKey = "$fontFamilyName:$glyph:$color"
43
- val hash = cacheKey.hashCode().toString(32)
44
- val cacheFilePath = "${cacheFolderPath}${hash}_${fontSize}${scaleSuffix}.png"
45
- val cacheFileUrl = "file://$cacheFilePath"
46
- val cacheFile = File(cacheFilePath)
47
-
48
- if (cacheFile.exists()) {
49
- return cacheFileUrl
50
- }
51
-
52
- val typeface = ReactFontManager.getInstance().getTypeface(fontFamilyName, Typeface.NORMAL, context.assets)
53
- if (typeface == Typeface.DEFAULT) {
54
- RNLog.w(context, "getImageForFontSync: the lookup for $fontFamilyName returned the default typeface, this likely means that the font is not available on the device.")
55
- }
56
- val paint =
57
- Paint().apply {
58
- this.typeface = typeface
59
- this.color = color.toInt()
60
- textSize = size.toFloat()
61
- isAntiAlias = true
62
- }
63
- val textBounds = Rect()
64
- paint.getTextBounds(glyph, 0, glyph.length, textBounds)
65
-
66
- val offsetX = 0
67
- val offsetY = size - paint.fontMetrics.bottom.toInt()
68
-
69
- val bitmap = Bitmap.createBitmap(size, size, Bitmap.Config.ARGB_8888)
70
- val canvas = Canvas(bitmap)
71
- canvas.drawText(glyph, offsetX.toFloat(), offsetY.toFloat(), paint)
72
-
73
- try {
74
- FileOutputStream(cacheFile).use { fos ->
75
- bitmap.compress(Bitmap.CompressFormat.PNG, 100, fos)
76
- fos.flush()
77
- return cacheFileUrl
78
- }
79
- } catch (e: IOException) {
80
- // we're rethrowing this as a runtime exception because we can't change the method signature
81
- // to `throws IOException`
82
- // that would be at odds with the codegen-generated spec
83
- throw RuntimeException(e)
84
- }
85
- }
86
-
87
- companion object {
88
- const val NAME = "VectorIcons"
89
- }
90
- }
@@ -1,35 +0,0 @@
1
- package com.reactnativevectoricons.common
2
-
3
- import com.facebook.react.TurboReactPackage
4
- import com.facebook.react.bridge.ReactApplicationContext
5
- import com.facebook.react.bridge.NativeModule
6
- import com.facebook.react.module.model.ReactModuleInfoProvider
7
- import com.facebook.react.module.model.ReactModuleInfo
8
- import java.util.HashMap
9
-
10
- class VectorIconsPackage : TurboReactPackage() {
11
- override fun getModule(name: String, reactContext: ReactApplicationContext): NativeModule? {
12
- return if (name == VectorIconsModule.NAME) {
13
- VectorIconsModule(reactContext)
14
- } else {
15
- null
16
- }
17
- }
18
-
19
- override fun getReactModuleInfoProvider(): ReactModuleInfoProvider {
20
- return ReactModuleInfoProvider {
21
- val moduleInfos: MutableMap<String, ReactModuleInfo> = HashMap()
22
- val isTurboModule: Boolean = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED
23
- moduleInfos[VectorIconsModule.NAME] = ReactModuleInfo(
24
- VectorIconsModule.NAME, // name
25
- VectorIconsModule.NAME, // className
26
- false, // canOverrideExistingModule
27
- false, // needsEagerInit
28
- false, // hasConstants NOTE: This is deprecated but we need it to keep compatability with RN <= 0.72
29
- false, // isCxxModule
30
- isTurboModule // isTurboModule
31
- )
32
- moduleInfos
33
- }
34
- }
35
- }
@@ -1,7 +0,0 @@
1
- package com.reactnativevectoricons.common
2
-
3
- import com.facebook.react.bridge.ReactApplicationContext
4
-
5
- abstract class VectorIconsSpec internal constructor(context: ReactApplicationContext) :
6
- NativeVectorIconsSpec(context) {
7
- }
@@ -1,38 +0,0 @@
1
- /**
2
- * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
3
- *
4
- * Do not edit this file as changes may cause incorrect behavior.
5
- *
6
- * Instead turn on new architecture, make JS spec file changes, re-run codegen (you can trigger that by rebuilding) and copy codegen result here.
7
- *
8
- * @generated by codegen project: GenerateModuleJavaSpec.js
9
- *
10
- * @nolint
11
- */
12
-
13
- package com.reactnativevectoricons.common
14
-
15
- import com.facebook.proguard.annotations.DoNotStrip
16
- import com.facebook.react.bridge.Promise
17
- import com.facebook.react.bridge.ReactApplicationContext
18
- import com.facebook.react.bridge.ReactContextBaseJavaModule
19
- import com.facebook.react.bridge.ReactMethod
20
- import com.facebook.react.turbomodule.core.interfaces.TurboModule
21
-
22
- abstract class VectorIconsSpec internal constructor(context: ReactApplicationContext) :
23
- ReactContextBaseJavaModule(context) {
24
-
25
- companion object {
26
- const val NAME = "VectorIcons"
27
- }
28
-
29
- override fun getName(): String = NAME
30
-
31
- @ReactMethod
32
- @DoNotStrip
33
- abstract fun getImageForFont(fontFamilyName: String, glyph: String, fontSize: Double, color: Double, promise: Promise)
34
-
35
- @ReactMethod(isBlockingSynchronousMethod = true)
36
- @DoNotStrip
37
- abstract fun getImageForFontSync(fontFamilyName: String, glyph: String, fontSize: Double, color: Double): String
38
- }
package/ios/VectorIcons.h DELETED
@@ -1,24 +0,0 @@
1
-
2
- #ifdef RCT_NEW_ARCH_ENABLED
3
- #import "RNVectorIconsSpec.h"
4
-
5
- @interface VectorIcons : NSObject <NativeVectorIconsSpec>
6
- #else
7
- #import <React/RCTBridgeModule.h>
8
-
9
- @interface VectorIcons : NSObject <RCTBridgeModule>
10
- #endif
11
-
12
- // - (NSString *)hexStringFromColor:(UIColor *)color;
13
- // - (NSString *)generateFilePath:(NSString *)glyph withFontName:(NSString
14
- // *)fontName
15
- // withFontSize:(CGFloat)fontSize
16
- // withColor:(UIColor *)color
17
- // withExtraIdentifier:(NSString
18
- // *)identifier;
19
- // - (BOOL)createAndSaveGlyphImage:(NSString *)glyph withFont:(UIFont *)font
20
- // withFilePath:(NSString
21
- // *)filePath
22
- // withColor:(UIColor *)color;
23
- //
24
- @end