@react-native-vector-icons/common 0.0.1-alpha.20 → 0.0.1-alpha.22

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 (162) hide show
  1. package/LICENSE +1 -2
  2. package/README.md +40 -182
  3. package/android/build.gradle +36 -2
  4. package/android/generated/java/com/reactnativevectoricons/common/NativeVectorIconsSpec.java +42 -0
  5. package/android/generated/jni/CMakeLists.txt +49 -0
  6. package/android/generated/jni/RNVectorIconsSpec-generated.cpp +38 -0
  7. package/android/generated/jni/RNVectorIconsSpec.h +31 -0
  8. package/android/generated/jni/react/renderer/components/RNVectorIconsSpec/ComponentDescriptors.cpp +22 -0
  9. package/android/generated/jni/react/renderer/components/RNVectorIconsSpec/ComponentDescriptors.h +24 -0
  10. package/android/generated/jni/react/renderer/components/RNVectorIconsSpec/EventEmitters.cpp +16 -0
  11. package/android/generated/jni/react/renderer/components/RNVectorIconsSpec/EventEmitters.h +17 -0
  12. package/android/generated/jni/react/renderer/components/RNVectorIconsSpec/Props.cpp +19 -0
  13. package/android/generated/jni/react/renderer/components/RNVectorIconsSpec/Props.h +18 -0
  14. package/android/generated/jni/react/renderer/components/RNVectorIconsSpec/RNVectorIconsSpecJSI-generated.cpp +40 -0
  15. package/android/generated/jni/react/renderer/components/RNVectorIconsSpec/RNVectorIconsSpecJSI.h +76 -0
  16. package/android/generated/jni/react/renderer/components/RNVectorIconsSpec/ShadowNodes.cpp +17 -0
  17. package/android/generated/jni/react/renderer/components/RNVectorIconsSpec/ShadowNodes.h +23 -0
  18. package/android/generated/jni/react/renderer/components/RNVectorIconsSpec/States.cpp +16 -0
  19. package/android/generated/jni/react/renderer/components/RNVectorIconsSpec/States.h +19 -0
  20. package/android/src/main/AndroidManifestNew.xml +1 -1
  21. package/android/src/main/java/com/reactnativevectoricons/common/VectorIconsModule.kt +90 -0
  22. package/android/src/main/java/com/reactnativevectoricons/common/VectorIconsPackage.kt +35 -0
  23. package/android/src/newarch/VectorIconsSpec.kt +7 -0
  24. package/android/src/oldarch/VectorIconsSpec.kt +38 -0
  25. package/ios/VectorIcons.h +13 -17
  26. package/ios/VectorIcons.mm +21 -51
  27. package/ios/generated/RNVectorIconsSpec/ComponentDescriptors.cpp +22 -0
  28. package/ios/generated/RNVectorIconsSpec/ComponentDescriptors.h +24 -0
  29. package/ios/generated/RNVectorIconsSpec/EventEmitters.cpp +16 -0
  30. package/ios/generated/RNVectorIconsSpec/EventEmitters.h +17 -0
  31. package/ios/generated/RNVectorIconsSpec/Props.cpp +19 -0
  32. package/ios/generated/RNVectorIconsSpec/Props.h +18 -0
  33. package/ios/generated/RNVectorIconsSpec/RCTComponentViewHelpers.h +18 -0
  34. package/ios/generated/RNVectorIconsSpec/RNVectorIconsSpec-generated.mm +36 -0
  35. package/ios/generated/RNVectorIconsSpec/RNVectorIconsSpec.h +58 -0
  36. package/ios/generated/RNVectorIconsSpec/ShadowNodes.cpp +17 -0
  37. package/ios/generated/RNVectorIconsSpec/ShadowNodes.h +23 -0
  38. package/ios/generated/RNVectorIconsSpec/States.cpp +16 -0
  39. package/ios/generated/RNVectorIconsSpec/States.h +19 -0
  40. package/ios/generated/RNVectorIconsSpecJSI-generated.cpp +40 -0
  41. package/ios/generated/RNVectorIconsSpecJSI.h +76 -0
  42. package/lib/commonjs/NativeVectorIcons.js.map +1 -1
  43. package/lib/commonjs/create-icon-set.js +48 -19
  44. package/lib/commonjs/create-icon-set.js.map +1 -1
  45. package/lib/commonjs/dynamicLoading/dynamic-font-loading.js +92 -0
  46. package/lib/commonjs/dynamicLoading/dynamic-font-loading.js.map +1 -0
  47. package/lib/commonjs/dynamicLoading/dynamic-font-loading.web.js +20 -0
  48. package/lib/commonjs/dynamicLoading/dynamic-font-loading.web.js.map +1 -0
  49. package/lib/commonjs/dynamicLoading/dynamic-loading-setting.js +50 -0
  50. package/lib/commonjs/dynamicLoading/dynamic-loading-setting.js.map +1 -0
  51. package/lib/commonjs/dynamicLoading/types.js +2 -0
  52. package/lib/commonjs/dynamicLoading/types.js.map +1 -0
  53. package/lib/commonjs/index.js +57 -1
  54. package/lib/commonjs/index.js.map +1 -1
  55. package/lib/commonjs/scripts/getFonts.js +1 -1
  56. package/lib/commonjs/scripts/updatePlist.js +1 -1
  57. package/lib/module/NativeVectorIcons.js +2 -0
  58. package/lib/module/NativeVectorIcons.js.map +1 -1
  59. package/lib/module/NativeVectorIcons.web.js +2 -0
  60. package/lib/module/NativeVectorIcons.web.js.map +1 -1
  61. package/lib/module/create-icon-set.js +49 -18
  62. package/lib/module/create-icon-set.js.map +1 -1
  63. package/lib/module/create-icon-source-cache.js +2 -0
  64. package/lib/module/create-icon-source-cache.js.map +1 -1
  65. package/lib/module/dynamicLoading/dynamic-font-loading.js +85 -0
  66. package/lib/module/dynamicLoading/dynamic-font-loading.js.map +1 -0
  67. package/lib/module/dynamicLoading/dynamic-font-loading.web.js +16 -0
  68. package/lib/module/dynamicLoading/dynamic-font-loading.web.js.map +1 -0
  69. package/lib/module/dynamicLoading/dynamic-loading-setting.js +41 -0
  70. package/lib/module/dynamicLoading/dynamic-loading-setting.js.map +1 -0
  71. package/lib/module/dynamicLoading/types.js +2 -0
  72. package/lib/module/dynamicLoading/types.js.map +1 -0
  73. package/lib/module/ensure-native-module-available.js +2 -0
  74. package/lib/module/ensure-native-module-available.js.map +1 -1
  75. package/lib/module/index.js +33 -1
  76. package/lib/module/index.js.map +1 -1
  77. package/lib/module/scripts/common.js +2 -0
  78. package/lib/module/scripts/common.js.map +1 -1
  79. package/lib/module/scripts/getFonts.js +3 -1
  80. package/lib/module/scripts/getFonts.js.map +1 -1
  81. package/lib/module/scripts/updatePlist.js +3 -1
  82. package/lib/module/scripts/updatePlist.js.map +1 -1
  83. package/lib/typescript/commonjs/package.json +1 -0
  84. package/lib/typescript/commonjs/src/NativeVectorIcons.d.ts +8 -0
  85. package/lib/typescript/commonjs/src/NativeVectorIcons.d.ts.map +1 -0
  86. package/lib/typescript/commonjs/src/NativeVectorIcons.web.d.ts.map +1 -0
  87. package/lib/typescript/commonjs/src/create-icon-set.d.ts +36 -0
  88. package/lib/typescript/commonjs/src/create-icon-set.d.ts.map +1 -0
  89. package/lib/typescript/commonjs/src/create-icon-source-cache.d.ts.map +1 -0
  90. package/lib/typescript/commonjs/src/dynamicLoading/dynamic-font-loading.d.ts +3 -0
  91. package/lib/typescript/commonjs/src/dynamicLoading/dynamic-font-loading.d.ts.map +1 -0
  92. package/lib/typescript/commonjs/src/dynamicLoading/dynamic-font-loading.web.d.ts +6 -0
  93. package/lib/typescript/commonjs/src/dynamicLoading/dynamic-font-loading.web.d.ts.map +1 -0
  94. package/lib/typescript/commonjs/src/dynamicLoading/dynamic-loading-setting.d.ts +41 -0
  95. package/lib/typescript/commonjs/src/dynamicLoading/dynamic-loading-setting.d.ts.map +1 -0
  96. package/lib/typescript/commonjs/src/dynamicLoading/types.d.ts +9 -0
  97. package/lib/typescript/commonjs/src/dynamicLoading/types.d.ts.map +1 -0
  98. package/lib/typescript/commonjs/src/ensure-native-module-available.d.ts.map +1 -0
  99. package/lib/typescript/commonjs/src/index.d.ts +6 -0
  100. package/lib/typescript/commonjs/src/index.d.ts.map +1 -0
  101. package/lib/typescript/commonjs/src/scripts/common.d.ts.map +1 -0
  102. package/lib/typescript/commonjs/src/scripts/getFonts.d.ts.map +1 -0
  103. package/lib/typescript/commonjs/src/scripts/updatePlist.d.ts.map +1 -0
  104. package/lib/typescript/module/package.json +1 -0
  105. package/lib/typescript/module/src/NativeVectorIcons.d.ts +8 -0
  106. package/lib/typescript/module/src/NativeVectorIcons.d.ts.map +1 -0
  107. package/lib/typescript/module/src/NativeVectorIcons.web.d.ts +3 -0
  108. package/lib/typescript/module/src/NativeVectorIcons.web.d.ts.map +1 -0
  109. package/lib/typescript/module/src/create-icon-set.d.ts +36 -0
  110. package/lib/typescript/module/src/create-icon-set.d.ts.map +1 -0
  111. package/lib/typescript/module/src/create-icon-source-cache.d.ts +21 -0
  112. package/lib/typescript/module/src/create-icon-source-cache.d.ts.map +1 -0
  113. package/lib/typescript/module/src/dynamicLoading/dynamic-font-loading.d.ts +3 -0
  114. package/lib/typescript/module/src/dynamicLoading/dynamic-font-loading.d.ts.map +1 -0
  115. package/lib/typescript/module/src/dynamicLoading/dynamic-font-loading.web.d.ts +6 -0
  116. package/lib/typescript/module/src/dynamicLoading/dynamic-font-loading.web.d.ts.map +1 -0
  117. package/lib/typescript/module/src/dynamicLoading/dynamic-loading-setting.d.ts +41 -0
  118. package/lib/typescript/module/src/dynamicLoading/dynamic-loading-setting.d.ts.map +1 -0
  119. package/lib/typescript/module/src/dynamicLoading/types.d.ts +9 -0
  120. package/lib/typescript/module/src/dynamicLoading/types.d.ts.map +1 -0
  121. package/lib/typescript/module/src/ensure-native-module-available.d.ts +2 -0
  122. package/lib/typescript/module/src/ensure-native-module-available.d.ts.map +1 -0
  123. package/lib/typescript/module/src/index.d.ts +6 -0
  124. package/lib/typescript/module/src/index.d.ts.map +1 -0
  125. package/lib/typescript/module/src/scripts/common.d.ts +2 -0
  126. package/lib/typescript/module/src/scripts/common.d.ts.map +1 -0
  127. package/lib/typescript/module/src/scripts/getFonts.d.ts +3 -0
  128. package/lib/typescript/module/src/scripts/getFonts.d.ts.map +1 -0
  129. package/lib/typescript/module/src/scripts/updatePlist.d.ts +3 -0
  130. package/lib/typescript/module/src/scripts/updatePlist.d.ts.map +1 -0
  131. package/package.json +65 -43
  132. package/react-native-vector-icons.podspec +26 -26
  133. package/src/NativeVectorIcons.ts +2 -4
  134. package/src/create-icon-set.tsx +79 -12
  135. package/src/dynamicLoading/dynamic-font-loading.ts +97 -0
  136. package/src/dynamicLoading/dynamic-font-loading.web.ts +15 -0
  137. package/src/dynamicLoading/dynamic-loading-setting.ts +77 -0
  138. package/src/dynamicLoading/types.ts +10 -0
  139. package/src/index.ts +48 -1
  140. package/src/scripts/getFonts.ts +1 -1
  141. package/android/src/main/java/com/reactnativevectoricons/common/VectorIconsModule.java +0 -121
  142. package/android/src/main/java/com/reactnativevectoricons/common/VectorIconsPackage.java +0 -45
  143. package/android/src/newarch/VectorIconsSpec.java +0 -9
  144. package/android/src/oldarch/VectorIconsSpec.java +0 -18
  145. package/lib/typescript/src/NativeVectorIcons.d.ts +0 -9
  146. package/lib/typescript/src/NativeVectorIcons.d.ts.map +0 -1
  147. package/lib/typescript/src/NativeVectorIcons.web.d.ts.map +0 -1
  148. package/lib/typescript/src/create-icon-set.d.ts +0 -26
  149. package/lib/typescript/src/create-icon-set.d.ts.map +0 -1
  150. package/lib/typescript/src/create-icon-source-cache.d.ts.map +0 -1
  151. package/lib/typescript/src/ensure-native-module-available.d.ts.map +0 -1
  152. package/lib/typescript/src/index.d.ts +0 -3
  153. package/lib/typescript/src/index.d.ts.map +0 -1
  154. package/lib/typescript/src/scripts/common.d.ts.map +0 -1
  155. package/lib/typescript/src/scripts/getFonts.d.ts.map +0 -1
  156. package/lib/typescript/src/scripts/updatePlist.d.ts.map +0 -1
  157. /package/lib/typescript/{src → commonjs/src}/NativeVectorIcons.web.d.ts +0 -0
  158. /package/lib/typescript/{src → commonjs/src}/create-icon-source-cache.d.ts +0 -0
  159. /package/lib/typescript/{src → commonjs/src}/ensure-native-module-available.d.ts +0 -0
  160. /package/lib/typescript/{src → commonjs/src}/scripts/common.d.ts +0 -0
  161. /package/lib/typescript/{src → commonjs/src}/scripts/getFonts.d.ts +0 -0
  162. /package/lib/typescript/{src → commonjs/src}/scripts/updatePlist.d.ts +0 -0
@@ -0,0 +1,36 @@
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 and will be lost
5
+ * once the code is regenerated.
6
+ *
7
+ * @generated by codegen project: GenerateModuleObjCpp
8
+ *
9
+ * We create an umbrella header (and corresponding implementation) here since
10
+ * Cxx compilation in BUCK has a limitation: source-code producing genrule()s
11
+ * must have a single output. More files => more genrule()s => slower builds.
12
+ */
13
+
14
+ #import "RNVectorIconsSpec.h"
15
+
16
+
17
+ namespace facebook::react {
18
+
19
+ static facebook::jsi::Value __hostFunction_NativeVectorIconsSpecJSI_getImageForFont(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
20
+ return static_cast<ObjCTurboModule&>(turboModule).invokeObjCMethod(rt, PromiseKind, "getImageForFont", @selector(getImageForFont:glyph:fontSize:color:resolve:reject:), args, count);
21
+ }
22
+
23
+ static facebook::jsi::Value __hostFunction_NativeVectorIconsSpecJSI_getImageForFontSync(facebook::jsi::Runtime& rt, TurboModule &turboModule, const facebook::jsi::Value* args, size_t count) {
24
+ return static_cast<ObjCTurboModule&>(turboModule).invokeObjCMethod(rt, StringKind, "getImageForFontSync", @selector(getImageForFontSync:glyph:fontSize:color:), args, count);
25
+ }
26
+
27
+ NativeVectorIconsSpecJSI::NativeVectorIconsSpecJSI(const ObjCTurboModule::InitParams &params)
28
+ : ObjCTurboModule(params) {
29
+
30
+ methodMap_["getImageForFont"] = MethodMetadata {4, __hostFunction_NativeVectorIconsSpecJSI_getImageForFont};
31
+
32
+
33
+ methodMap_["getImageForFontSync"] = MethodMetadata {4, __hostFunction_NativeVectorIconsSpecJSI_getImageForFontSync};
34
+
35
+ }
36
+ } // namespace facebook::react
@@ -0,0 +1,58 @@
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 and will be lost
5
+ * once the code is regenerated.
6
+ *
7
+ * @generated by codegen project: GenerateModuleObjCpp
8
+ *
9
+ * We create an umbrella header (and corresponding implementation) here since
10
+ * Cxx compilation in BUCK has a limitation: source-code producing genrule()s
11
+ * must have a single output. More files => more genrule()s => slower builds.
12
+ */
13
+
14
+ #ifndef __cplusplus
15
+ #error This file must be compiled as Obj-C++. If you are importing it, you must change your file extension to .mm.
16
+ #endif
17
+
18
+ // Avoid multiple includes of RNVectorIconsSpec symbols
19
+ #ifndef RNVectorIconsSpec_H
20
+ #define RNVectorIconsSpec_H
21
+
22
+ #import <Foundation/Foundation.h>
23
+ #import <RCTRequired/RCTRequired.h>
24
+ #import <RCTTypeSafety/RCTConvertHelpers.h>
25
+ #import <RCTTypeSafety/RCTTypedModuleConstants.h>
26
+ #import <React/RCTBridgeModule.h>
27
+ #import <React/RCTCxxConvert.h>
28
+ #import <React/RCTManagedPointer.h>
29
+ #import <ReactCommon/RCTTurboModule.h>
30
+ #import <optional>
31
+ #import <vector>
32
+
33
+
34
+ @protocol NativeVectorIconsSpec <RCTBridgeModule, RCTTurboModule>
35
+
36
+ - (void)getImageForFont:(NSString *)fontFamilyName
37
+ glyph:(NSString *)glyph
38
+ fontSize:(double)fontSize
39
+ color:(double)color
40
+ resolve:(RCTPromiseResolveBlock)resolve
41
+ reject:(RCTPromiseRejectBlock)reject;
42
+ - (NSString *)getImageForFontSync:(NSString *)fontFamilyName
43
+ glyph:(NSString *)glyph
44
+ fontSize:(double)fontSize
45
+ color:(double)color;
46
+
47
+ @end
48
+ namespace facebook::react {
49
+ /**
50
+ * ObjC++ class for module 'NativeVectorIcons'
51
+ */
52
+ class JSI_EXPORT NativeVectorIconsSpecJSI : public ObjCTurboModule {
53
+ public:
54
+ NativeVectorIconsSpecJSI(const ObjCTurboModule::InitParams &params);
55
+ };
56
+ } // namespace facebook::react
57
+
58
+ #endif // RNVectorIconsSpec_H
@@ -0,0 +1,17 @@
1
+
2
+ /**
3
+ * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
4
+ *
5
+ * Do not edit this file as changes may cause incorrect behavior and will be lost
6
+ * once the code is regenerated.
7
+ *
8
+ * @generated by codegen project: GenerateShadowNodeCpp.js
9
+ */
10
+
11
+ #include "ShadowNodes.h"
12
+
13
+ namespace facebook::react {
14
+
15
+
16
+
17
+ } // namespace facebook::react
@@ -0,0 +1,23 @@
1
+
2
+ /**
3
+ * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
4
+ *
5
+ * Do not edit this file as changes may cause incorrect behavior and will be lost
6
+ * once the code is regenerated.
7
+ *
8
+ * @generated by codegen project: GenerateShadowNodeH.js
9
+ */
10
+
11
+ #pragma once
12
+
13
+ #include "EventEmitters.h"
14
+ #include "Props.h"
15
+ #include "States.h"
16
+ #include <react/renderer/components/view/ConcreteViewShadowNode.h>
17
+ #include <jsi/jsi.h>
18
+
19
+ namespace facebook::react {
20
+
21
+
22
+
23
+ } // namespace facebook::react
@@ -0,0 +1,16 @@
1
+
2
+ /**
3
+ * This code was generated by [react-native-codegen](https://www.npmjs.com/package/react-native-codegen).
4
+ *
5
+ * Do not edit this file as changes may cause incorrect behavior and will be lost
6
+ * once the code is regenerated.
7
+ *
8
+ * @generated by codegen project: GenerateStateCpp.js
9
+ */
10
+ #include "States.h"
11
+
12
+ namespace facebook::react {
13
+
14
+
15
+
16
+ } // namespace facebook::react
@@ -0,0 +1,19 @@
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 and will be lost
5
+ * once the code is regenerated.
6
+ *
7
+ * @generated by codegen project: GenerateStateH.js
8
+ */
9
+ #pragma once
10
+
11
+ #ifdef ANDROID
12
+ #include <folly/dynamic.h>
13
+ #endif
14
+
15
+ namespace facebook::react {
16
+
17
+
18
+
19
+ } // namespace facebook::react
@@ -0,0 +1,40 @@
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 and will be lost
5
+ * once the code is regenerated.
6
+ *
7
+ * @generated by codegen project: GenerateModuleCpp.js
8
+ */
9
+
10
+ #include "RNVectorIconsSpecJSI.h"
11
+
12
+ namespace facebook::react {
13
+
14
+ static jsi::Value __hostFunction_NativeVectorIconsCxxSpecJSI_getImageForFont(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
15
+ return static_cast<NativeVectorIconsCxxSpecJSI *>(&turboModule)->getImageForFont(
16
+ rt,
17
+ count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asString(rt),
18
+ count <= 1 ? throw jsi::JSError(rt, "Expected argument in position 1 to be passed") : args[1].asString(rt),
19
+ count <= 2 ? throw jsi::JSError(rt, "Expected argument in position 2 to be passed") : args[2].asNumber(),
20
+ count <= 3 ? throw jsi::JSError(rt, "Expected argument in position 3 to be passed") : args[3].asNumber()
21
+ );
22
+ }
23
+ static jsi::Value __hostFunction_NativeVectorIconsCxxSpecJSI_getImageForFontSync(jsi::Runtime &rt, TurboModule &turboModule, const jsi::Value* args, size_t count) {
24
+ return static_cast<NativeVectorIconsCxxSpecJSI *>(&turboModule)->getImageForFontSync(
25
+ rt,
26
+ count <= 0 ? throw jsi::JSError(rt, "Expected argument in position 0 to be passed") : args[0].asString(rt),
27
+ count <= 1 ? throw jsi::JSError(rt, "Expected argument in position 1 to be passed") : args[1].asString(rt),
28
+ count <= 2 ? throw jsi::JSError(rt, "Expected argument in position 2 to be passed") : args[2].asNumber(),
29
+ count <= 3 ? throw jsi::JSError(rt, "Expected argument in position 3 to be passed") : args[3].asNumber()
30
+ );
31
+ }
32
+
33
+ NativeVectorIconsCxxSpecJSI::NativeVectorIconsCxxSpecJSI(std::shared_ptr<CallInvoker> jsInvoker)
34
+ : TurboModule("VectorIcons", jsInvoker) {
35
+ methodMap_["getImageForFont"] = MethodMetadata {4, __hostFunction_NativeVectorIconsCxxSpecJSI_getImageForFont};
36
+ methodMap_["getImageForFontSync"] = MethodMetadata {4, __hostFunction_NativeVectorIconsCxxSpecJSI_getImageForFontSync};
37
+ }
38
+
39
+
40
+ } // namespace facebook::react
@@ -0,0 +1,76 @@
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 and will be lost
5
+ * once the code is regenerated.
6
+ *
7
+ * @generated by codegen project: GenerateModuleH.js
8
+ */
9
+
10
+ #pragma once
11
+
12
+ #include <ReactCommon/TurboModule.h>
13
+ #include <react/bridging/Bridging.h>
14
+
15
+ namespace facebook::react {
16
+
17
+
18
+ class JSI_EXPORT NativeVectorIconsCxxSpecJSI : public TurboModule {
19
+ protected:
20
+ NativeVectorIconsCxxSpecJSI(std::shared_ptr<CallInvoker> jsInvoker);
21
+
22
+ public:
23
+ virtual jsi::Value getImageForFont(jsi::Runtime &rt, jsi::String fontFamilyName, jsi::String glyph, double fontSize, double color) = 0;
24
+ virtual jsi::String getImageForFontSync(jsi::Runtime &rt, jsi::String fontFamilyName, jsi::String glyph, double fontSize, double color) = 0;
25
+
26
+ };
27
+
28
+ template <typename T>
29
+ class JSI_EXPORT NativeVectorIconsCxxSpec : public TurboModule {
30
+ public:
31
+ jsi::Value get(jsi::Runtime &rt, const jsi::PropNameID &propName) override {
32
+ return delegate_.get(rt, propName);
33
+ }
34
+
35
+ static constexpr std::string_view kModuleName = "VectorIcons";
36
+
37
+ protected:
38
+ NativeVectorIconsCxxSpec(std::shared_ptr<CallInvoker> jsInvoker)
39
+ : TurboModule(std::string{NativeVectorIconsCxxSpec::kModuleName}, jsInvoker),
40
+ delegate_(reinterpret_cast<T*>(this), jsInvoker) {}
41
+
42
+
43
+ private:
44
+ class Delegate : public NativeVectorIconsCxxSpecJSI {
45
+ public:
46
+ Delegate(T *instance, std::shared_ptr<CallInvoker> jsInvoker) :
47
+ NativeVectorIconsCxxSpecJSI(std::move(jsInvoker)), instance_(instance) {
48
+
49
+ }
50
+
51
+ jsi::Value getImageForFont(jsi::Runtime &rt, jsi::String fontFamilyName, jsi::String glyph, double fontSize, double color) override {
52
+ static_assert(
53
+ bridging::getParameterCount(&T::getImageForFont) == 5,
54
+ "Expected getImageForFont(...) to have 5 parameters");
55
+
56
+ return bridging::callFromJs<jsi::Value>(
57
+ rt, &T::getImageForFont, jsInvoker_, instance_, std::move(fontFamilyName), std::move(glyph), std::move(fontSize), std::move(color));
58
+ }
59
+ jsi::String getImageForFontSync(jsi::Runtime &rt, jsi::String fontFamilyName, jsi::String glyph, double fontSize, double color) override {
60
+ static_assert(
61
+ bridging::getParameterCount(&T::getImageForFontSync) == 5,
62
+ "Expected getImageForFontSync(...) to have 5 parameters");
63
+
64
+ return bridging::callFromJs<jsi::String>(
65
+ rt, &T::getImageForFontSync, jsInvoker_, instance_, std::move(fontFamilyName), std::move(glyph), std::move(fontSize), std::move(color));
66
+ }
67
+
68
+ private:
69
+ friend class NativeVectorIconsCxxSpec;
70
+ T *instance_;
71
+ };
72
+
73
+ Delegate delegate_;
74
+ };
75
+
76
+ } // namespace facebook::react
@@ -1 +1 @@
1
- {"version":3,"names":["_reactNative","require","_default","exports","default","TurboModuleRegistry","getEnforcing"],"sourceRoot":"../../src","sources":["NativeVectorIcons.ts"],"mappings":";;;;;;AACA,IAAAA,YAAA,GAAAC,OAAA;AAAmD,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAUpCC,gCAAmB,CAACC,YAAY,CAAO,aAAa,CAAC","ignoreList":[]}
1
+ {"version":3,"names":["_reactNative","require","_default","exports","default","TurboModuleRegistry","getEnforcing"],"sourceRoot":"../../src","sources":["NativeVectorIcons.ts"],"mappings":";;;;;;AACA,IAAAA,YAAA,GAAAC,OAAA;AAAmD,IAAAC,QAAA,GAAAC,OAAA,CAAAC,OAAA,GAQpCC,gCAAmB,CAACC,YAAY,CAAO,aAAa,CAAC","ignoreList":[]}
@@ -3,26 +3,37 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.createIconSet = exports.DEFAULT_ICON_SIZE = exports.DEFAULT_ICON_COLOR = void 0;
6
+ exports.DEFAULT_ICON_SIZE = exports.DEFAULT_ICON_COLOR = void 0;
7
+ exports.createIconSet = createIconSet;
7
8
  var _react = _interopRequireWildcard(require("react"));
8
9
  var _reactNative = require("react-native");
9
10
  var _NativeVectorIcons = _interopRequireDefault(require("./NativeVectorIcons"));
10
- var _createIconSourceCache = _interopRequireDefault(require("./create-icon-source-cache"));
11
- var _ensureNativeModuleAvailable = _interopRequireDefault(require("./ensure-native-module-available"));
11
+ var _createIconSourceCache = _interopRequireDefault(require("./create-icon-source-cache.js"));
12
+ var _dynamicFontLoading = require("./dynamicLoading/dynamic-font-loading");
13
+ var _dynamicLoadingSetting = require("./dynamicLoading/dynamic-loading-setting.js");
14
+ var _ensureNativeModuleAvailable = _interopRequireDefault(require("./ensure-native-module-available.js"));
15
+ var _jsxRuntime = require("react/jsx-runtime");
12
16
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
13
17
  function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
14
18
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
15
- function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
16
19
  const DEFAULT_ICON_SIZE = exports.DEFAULT_ICON_SIZE = 12;
17
20
  const DEFAULT_ICON_COLOR = exports.DEFAULT_ICON_COLOR = 'black';
18
- const createIconSet = (glyphMap, fontFamily, fontFile, fontStyle) => {
19
- // Android doesn't care about actual fontFamily name, it will only look in fonts folder.
20
- const fontBasename = fontFile ? fontFile.replace(/\.(otf|ttf)$/, '') : fontFamily;
21
+ function createIconSet(glyphMap, postScriptNameOrOptions, fontFileNameParam, fontStyleParam) {
22
+ const {
23
+ postScriptName,
24
+ fontFileName,
25
+ fontStyle
26
+ } = typeof postScriptNameOrOptions === 'string' ? {
27
+ postScriptName: postScriptNameOrOptions,
28
+ fontFileName: fontFileNameParam,
29
+ fontStyle: fontStyleParam
30
+ } : postScriptNameOrOptions;
31
+ const fontBasename = fontFileName ? fontFileName.replace(/\.(otf|ttf)$/, '') : postScriptName;
21
32
  const fontReference = _reactNative.Platform.select({
22
- windows: `/Assets/${fontFile}#${fontFamily}`,
33
+ windows: `/Assets/${fontFileName}#${postScriptName}`,
23
34
  android: fontBasename,
24
35
  web: fontBasename,
25
- default: fontFamily
36
+ default: postScriptName
26
37
  });
27
38
  const resolveGlyph = name => {
28
39
  const glyph = glyphMap[name] || '?';
@@ -34,14 +45,30 @@ const createIconSet = (glyphMap, fontFamily, fontFile, fontStyle) => {
34
45
  const Icon = ({
35
46
  name,
36
47
  size = DEFAULT_ICON_SIZE,
37
- color,
48
+ color = DEFAULT_ICON_COLOR,
38
49
  style,
39
50
  children,
40
51
  allowFontScaling = false,
41
52
  innerRef,
42
53
  ...props
43
54
  }) => {
44
- const glyph = name ? resolveGlyph(name) : '';
55
+ const [isFontLoaded, setIsFontLoaded] = _react.default.useState((0, _dynamicLoadingSetting.isDynamicLoadingEnabled)() ? _dynamicFontLoading.dynamicLoader.isLoaded(fontReference) : true);
56
+ const glyph = isFontLoaded && name ? resolveGlyph(name) : '';
57
+
58
+ // biome-ignore lint/correctness/useExhaustiveDependencies: the dependencies never change
59
+ (0, _react.useEffect)(() => {
60
+ let isMounted = true;
61
+ if (!isFontLoaded && typeof postScriptNameOrOptions === 'object' && typeof postScriptNameOrOptions.fontSource !== 'undefined') {
62
+ _dynamicFontLoading.dynamicLoader.loadFontAsync(fontReference, postScriptNameOrOptions.fontSource).finally(() => {
63
+ if (isMounted) {
64
+ setIsFontLoaded(true);
65
+ }
66
+ });
67
+ }
68
+ return () => {
69
+ isMounted = false;
70
+ };
71
+ }, []);
45
72
  const styleDefaults = {
46
73
  fontSize: size,
47
74
  color
@@ -56,14 +83,17 @@ const createIconSet = (glyphMap, fontFamily, fontFile, fontStyle) => {
56
83
  style: [styleDefaults, style, styleOverrides, fontStyle || {}],
57
84
  allowFontScaling
58
85
  };
59
- return /*#__PURE__*/_react.default.createElement(_reactNative.Text, _extends({
86
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.Text, {
60
87
  ref: innerRef,
61
- selectable: false
62
- }, newProps), glyph, children);
88
+ selectable: false,
89
+ ...newProps,
90
+ children: [glyph, children]
91
+ });
63
92
  };
64
- const WrappedIcon = /*#__PURE__*/(0, _react.forwardRef)((props, ref) => /*#__PURE__*/_react.default.createElement(Icon, _extends({
65
- innerRef: ref
66
- }, props)));
93
+ const WrappedIcon = /*#__PURE__*/(0, _react.forwardRef)((props, ref) => /*#__PURE__*/(0, _jsxRuntime.jsx)(Icon, {
94
+ innerRef: ref,
95
+ ...props
96
+ }));
67
97
  WrappedIcon.displayName = 'Icon';
68
98
  const imageSourceCache = (0, _createIconSourceCache.default)();
69
99
  const getImageSourceSync = (name, size = DEFAULT_ICON_SIZE, color = DEFAULT_ICON_COLOR) => {
@@ -117,6 +147,5 @@ const createIconSet = (glyphMap, fontFamily, fontFile, fontStyle) => {
117
147
  getImageSourceSync
118
148
  });
119
149
  return IconNamespace;
120
- };
121
- exports.createIconSet = createIconSet;
150
+ }
122
151
  //# sourceMappingURL=create-icon-set.js.map
@@ -1 +1 @@
1
- {"version":3,"names":["_react","_interopRequireWildcard","require","_reactNative","_NativeVectorIcons","_interopRequireDefault","_createIconSourceCache","_ensureNativeModuleAvailable","e","__esModule","default","_getRequireWildcardCache","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","_extends","assign","bind","arguments","length","apply","DEFAULT_ICON_SIZE","exports","DEFAULT_ICON_COLOR","createIconSet","glyphMap","fontFamily","fontFile","fontStyle","fontBasename","replace","fontReference","Platform","select","windows","android","web","resolveGlyph","name","glyph","String","fromCodePoint","Icon","size","color","style","children","allowFontScaling","innerRef","props","styleDefaults","fontSize","styleOverrides","fontWeight","newProps","createElement","Text","ref","selectable","WrappedIcon","forwardRef","displayName","imageSourceCache","createIconSourceCache","getImageSourceSync","ensureNativeModuleAvailable","processedColor","processColor","cacheKey","imagePath","NativeIconAPI","getImageForFontSync","value","uri","scale","PixelRatio","setValue","error","setError","getImageSource","getImageForFont","IconNamespace"],"sourceRoot":"../../src","sources":["create-icon-set.tsx"],"mappings":";;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAEA,IAAAC,YAAA,GAAAD,OAAA;AAEA,IAAAE,kBAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,sBAAA,GAAAD,sBAAA,CAAAH,OAAA;AACA,IAAAK,4BAAA,GAAAF,sBAAA,CAAAH,OAAA;AAA2E,SAAAG,uBAAAG,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAG,yBAAAH,CAAA,6BAAAI,OAAA,mBAAAC,CAAA,OAAAD,OAAA,IAAAE,CAAA,OAAAF,OAAA,YAAAD,wBAAA,YAAAA,CAAAH,CAAA,WAAAA,CAAA,GAAAM,CAAA,GAAAD,CAAA,KAAAL,CAAA;AAAA,SAAAP,wBAAAO,CAAA,EAAAK,CAAA,SAAAA,CAAA,IAAAL,CAAA,IAAAA,CAAA,CAAAC,UAAA,SAAAD,CAAA,eAAAA,CAAA,uBAAAA,CAAA,yBAAAA,CAAA,WAAAE,OAAA,EAAAF,CAAA,QAAAM,CAAA,GAAAH,wBAAA,CAAAE,CAAA,OAAAC,CAAA,IAAAA,CAAA,CAAAC,GAAA,CAAAP,CAAA,UAAAM,CAAA,CAAAE,GAAA,CAAAR,CAAA,OAAAS,CAAA,KAAAC,SAAA,UAAAC,CAAA,GAA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_interopRequireDefault","_createIconSourceCache","_dynamicFontLoading","_dynamicLoadingSetting","_ensureNativeModuleAvailable","_jsxRuntime","e","__esModule","default","_getRequireWildcardCache","WeakMap","r","t","has","get","n","__proto__","a","Object","defineProperty","getOwnPropertyDescriptor","u","hasOwnProperty","call","i","set","DEFAULT_ICON_SIZE","exports","DEFAULT_ICON_COLOR","createIconSet","glyphMap","postScriptNameOrOptions","fontFileNameParam","fontStyleParam","postScriptName","fontFileName","fontStyle","fontBasename","replace","fontReference","Platform","select","windows","android","web","resolveGlyph","name","glyph","String","fromCodePoint","Icon","size","color","style","children","allowFontScaling","innerRef","props","isFontLoaded","setIsFontLoaded","React","useState","isDynamicLoadingEnabled","dynamicLoader","isLoaded","useEffect","isMounted","fontSource","loadFontAsync","finally","styleDefaults","fontSize","styleOverrides","fontFamily","fontWeight","newProps","jsxs","Text","ref","selectable","WrappedIcon","forwardRef","jsx","displayName","imageSourceCache","createIconSourceCache","getImageSourceSync","ensureNativeModuleAvailable","processedColor","processColor","cacheKey","imagePath","NativeIconAPI","getImageForFontSync","value","uri","scale","PixelRatio","setValue","error","setError","getImageSource","getImageForFont","IconNamespace","assign"],"sourceRoot":"../../src","sources":["create-icon-set.tsx"],"mappings":";;;;;;;AAAA,IAAAA,MAAA,GAAAC,uBAAA,CAAAC,OAAA;AAEA,IAAAC,YAAA,GAAAD,OAAA;AAEA,IAAAE,kBAAA,GAAAC,sBAAA,CAAAH,OAAA;AACA,IAAAI,sBAAA,GAAAD,sBAAA,CAAAH,OAAA;AACA,IAAAK,mBAAA,GAAAL,OAAA;AACA,IAAAM,sBAAA,GAAAN,OAAA;AAEA,IAAAO,4BAAA,GAAAJ,sBAAA,CAAAH,OAAA;AAA2E,IAAAQ,WAAA,GAAAR,OAAA;AAAA,SAAAG,uBAAAM,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAAA,SAAAG,yBAAAH,CAAA,6BA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yBAAY,EAACrC,KAAK,CAAC;IAC1C,MAAMsC,QAAQ,GAAG,GAAG3C,KAAK,IAAII,IAAI,IAAIH,MAAM,CAACwC,cAAc,CAAC,EAAE;IAE7D,IAAIJ,gBAAgB,CAACvE,GAAG,CAAC6E,QAAQ,CAAC,EAAE;MAClC;MACA,OAAON,gBAAgB,CAACtE,GAAG,CAAC4E,QAAQ,CAAC;IACvC;IAEA,IAAI;MACF,MAAMC,SAAS,GAAG,MAAMC,0BAAa,CAACU,eAAe,CACnD/D,aAAa,EACbQ,KAAK,EACLI,IAAI,EACJqC,cAAc,CAAY;MAC5B,CAAC;MACD,MAAMM,KAAK,GAAG;QAAEC,GAAG,EAAEJ,SAAS;QAAEK,KAAK,EAAEC,uBAAU,CAACnF,GAAG,CAAC;MAAE,CAAC;MACzDsE,gBAAgB,CAACc,QAAQ,CAACR,QAAQ,EAAEI,KAAK,CAAC;MAC1C,OAAOA,KAAK;IACd,CAAC,CAAC,OAAOK,KAAK,EAAE;MACdf,gBAAgB,CAACgB,QAAQ,CAACV,QAAQ,EAAES,KAAc,CAAC;MACnD,MAAMA,KAAK;IACb;EACF,CAAC;EAED,MAAMI,aAAa,GAAGrF,MAAM,CAACsF,MAAM,CAACxB,WAAW,EAAE;IAC/CqB,cAAc;IACdf;EACF,CAAC,CAAC;EAEF,OAAOiB,aAAa;AACtB","ignoreList":[]}
@@ -0,0 +1,92 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.dynamicLoader = void 0;
7
+ var _registry = require("@react-native/assets-registry/registry");
8
+ var _resolveAssetSource = _interopRequireDefault(require("react-native/Libraries/Image/resolveAssetSource"));
9
+ var _dynamicLoadingSetting = require("./dynamic-loading-setting.js");
10
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
11
+ /*
12
+ * The following imports are always present when react native is installed
13
+ * in the future, more explicit apis will be exposed by the core, including typings
14
+ * */
15
+ // @ts-expect-error missing types
16
+ // eslint-disable-next-line import/no-extraneous-dependencies
17
+
18
+ // @ts-expect-error missing types
19
+
20
+ const loadPromises = {};
21
+ const loadFontAsync = async (fontFamily, fontSource) => {
22
+ const expoModules = globalThis?.expo?.modules;
23
+ if (!expoModules) {
24
+ throw new Error('Expo is not available. Dynamic font loading is not available.');
25
+ }
26
+ if (loadPromises[fontFamily]) {
27
+ return loadPromises[fontFamily];
28
+ }
29
+ loadPromises[fontFamily] = async function LoadFont() {
30
+ try {
31
+ const localUri = await (() => {
32
+ if (typeof fontSource === 'string') {
33
+ // a local filesystem uri
34
+ return fontSource;
35
+ }
36
+ // a module id
37
+ const {
38
+ uri,
39
+ type,
40
+ hash
41
+ } = getLocalFontUrl(fontSource, fontFamily);
42
+ return expoModules.ExpoAsset.downloadAsync(uri, hash, type);
43
+ })();
44
+ await expoModules.ExpoFontLoader.loadAsync(fontFamily, localUri);
45
+ } catch (error) {
46
+ console.error(`Failed to load font ${fontFamily}`, error); // eslint-disable-line no-console
47
+
48
+ (0, _dynamicLoadingSetting.getErrorCallback)()?.({
49
+ error: error,
50
+ fontFamily,
51
+ fontSource
52
+ });
53
+ } finally {
54
+ delete loadPromises[fontFamily];
55
+ }
56
+ }();
57
+ return loadPromises[fontFamily];
58
+ };
59
+ const getLocalFontUrl = (fontModuleId, fontFamily) => {
60
+ const assetMeta = (0, _registry.getAssetByID)(fontModuleId);
61
+ if (!assetMeta) {
62
+ throw new Error(`no asset found for font family "${fontFamily}", moduleId: ${String(fontModuleId)}`);
63
+ }
64
+ const resolver = _resolveAssetSource.default;
65
+ const assetSource = resolver(fontModuleId);
66
+ return {
67
+ ...assetMeta,
68
+ ...assetSource
69
+ };
70
+ };
71
+ const loadedFontsCache = {};
72
+ const isLoadedNative = fontFamily => {
73
+ if (fontFamily in loadedFontsCache) {
74
+ return true;
75
+ }
76
+ const {
77
+ expo
78
+ } = globalThis;
79
+ if (!expo) {
80
+ throw new Error('Expo is not available. Dynamic font loading is not available.');
81
+ }
82
+ const loadedNativeFonts = expo.modules.ExpoFontLoader.getLoadedFonts();
83
+ loadedNativeFonts.forEach(font => {
84
+ loadedFontsCache[font] = true;
85
+ });
86
+ return fontFamily in loadedFontsCache;
87
+ };
88
+ const dynamicLoader = exports.dynamicLoader = {
89
+ isLoaded: isLoadedNative,
90
+ loadFontAsync
91
+ };
92
+ //# sourceMappingURL=dynamic-font-loading.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["_registry","require","_resolveAssetSource","_interopRequireDefault","_dynamicLoadingSetting","e","__esModule","default","loadPromises","loadFontAsync","fontFamily","fontSource","expoModules","globalThis","expo","modules","Error","LoadFont","localUri","uri","type","hash","getLocalFontUrl","ExpoAsset","downloadAsync","ExpoFontLoader","loadAsync","error","console","getErrorCallback","fontModuleId","assetMeta","getAssetByID","String","resolver","resolveAssetSource","assetSource","loadedFontsCache","isLoadedNative","loadedNativeFonts","getLoadedFonts","forEach","font","dynamicLoader","exports","isLoaded"],"sourceRoot":"../../../src","sources":["dynamicLoading/dynamic-font-loading.ts"],"mappings":";;;;;;AAMA,IAAAA,SAAA,GAAAC,OAAA;AAGA,IAAAC,mBAAA,GAAAC,sBAAA,CAAAF,OAAA;AACA,IAAAG,sBAAA,GAAAH,OAAA;AAA6D,SAAAE,uBAAAE,CAAA,WAAAA,CAAA,IAAAA,CAAA,CAAAC,UAAA,GAAAD,CAAA,KAAAE,OAAA,EAAAF,CAAA;AAV7D;AACA;AACA;AACA;AACA;AACA;;AAGA;;AAKA,MAAMG,YAAqD,GAAG,CAAC,CAAC;AAEhE,MAAMC,aAAa,GAAG,MAAAA,CAAOC,UAAkB,EAAEC,UAAsB,KAAoB;EACzF,MAAMC,WAAW,GAAGC,UAAU,EAAEC,IAAI,EAAEC,OAAO;EAC7C,IAAI,CAACH,WAAW,EAAE;IAChB,MAAM,IAAII,KAAK,CAAC,+DAA+D,CAAC;EAClF;EAEA,IAAIR,YAAY,CAACE,UAAU,CAAC,EAAE;IAC5B,OAAOF,YAAY,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AAE,GAAGC,SAAS;IAAE,GAAGK;EAAY,CAAC;AACzC,CAAC;AAED,MAAMC,gBAA6C,GAAG,CAAC,CAAC;AAExD,MAAMC,cAAc,GAAI5B,UAAkB,IAAK;EAC7C,IAAIA,UAAU,IAAI2B,gBAAgB,EAAE;IAClC,OAAO,IAAI;EACb;EAEA,MAAM;IAAEvB;EAAK,CAAC,GAAGD,UAAU;EAC3B,IAAI,CAACC,IAAI,EAAE;IACT,MAAM,IAAIE,KAAK,CAAC,+DAA+D,CAAC;EAClF;EAEA,MAAMuB,iBAAiB,GAAGzB,IAAI,CAACC,OAAO,CAACU,cAAc,CAACe,cAAc,CAAC,CAAC;EACtED,iBAAiB,CAACE,OAAO,CAAEC,IAAI,IAAK;IAClCL,gBAAgB,CAACK,IAAI,CAAC,GAAG,IAAI;EAC/B,CAAC,CAAC;EAEF,OAAOhC,UAAU,IAAI2B,gBAAgB;AACvC,CAAC;AAEM,MAAMM,aAA4B,GAAAC,OAAA,CAAAD,aAAA,GAAG;EAC1CE,QAAQ,EAAEP,cAAc;EACxB7B;AACF,CAAC","ignoreList":[]}
@@ -0,0 +1,20 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.dynamicLoader = void 0;
7
+ /**
8
+ * dynamic font loading isn't supported on web
9
+ * */
10
+
11
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
12
+ const loadFontAsync = async (_fontFamily, _fontSource) => undefined;
13
+
14
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
15
+ const isLoaded = _fontFamily => true;
16
+ const dynamicLoader = exports.dynamicLoader = {
17
+ isLoaded,
18
+ loadFontAsync
19
+ };
20
+ //# sourceMappingURL=dynamic-font-loading.web.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["loadFontAsync","_fontFamily","_fontSource","undefined","isLoaded","dynamicLoader","exports"],"sourceRoot":"../../../src","sources":["dynamicLoading/dynamic-font-loading.web.ts"],"mappings":";;;;;;AAAA;AACA;AACA;;AAGA;AACA,MAAMA,aAAa,GAAG,MAAAA,CAAOC,WAAmB,EAAEC,WAAuB,KAAoBC,SAAS;;AAEtG;AACA,MAAMC,QAAQ,GAAIH,WAAmB,IAAK,IAAI;AAEvC,MAAMI,aAA4B,GAAAC,OAAA,CAAAD,aAAA,GAAG;EAC1CD,QAAQ;EACRJ;AACF,CAAC","ignoreList":[]}
@@ -0,0 +1,50 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.setDynamicLoadingErrorCallback = exports.setDynamicLoadingEnabled = exports.isDynamicLoadingSupported = exports.isDynamicLoadingEnabled = exports.getErrorCallback = void 0;
7
+ const hasNecessaryExpoModules = !!globalThis.expo?.modules?.ExpoAsset && !!globalThis.expo?.modules?.ExpoFontLoader;
8
+ const hasNecessaryExpoFeatures = hasNecessaryExpoModules && typeof globalThis.expo?.modules.ExpoFontLoader.getLoadedFonts === 'function';
9
+ let dynamicFontLoadingEnabled = hasNecessaryExpoFeatures;
10
+ const isDynamicLoadingSupported = () => hasNecessaryExpoFeatures;
11
+
12
+ /**
13
+ * Set whether dynamic loading of fonts is enabled.
14
+ * Currently, the presence of Expo Asset and Font Loader modules is a prerequisite for enabling.
15
+ * In the future, React Native core apis will be used for dynamic font loading.
16
+ *
17
+ * @param value - whether dynamic loading of fonts is enabled
18
+ * @returns `true` if dynamic loading of fonts was successfully set. `false` otherwise.
19
+ * */
20
+ exports.isDynamicLoadingSupported = isDynamicLoadingSupported;
21
+ const setDynamicLoadingEnabled = value => {
22
+ if (!hasNecessaryExpoFeatures) {
23
+ if (process.env.NODE_ENV !== 'production' && !!value) {
24
+ const message = hasNecessaryExpoModules ? 'Expo is installed, but does not support dynamic font loading. Make sure to use Expo SDK 52 or newer.' : 'Necessary Expo modules not found. Dynamic font loading is not available on Web or when necessary Expo modules are not present.';
25
+ console.error(message); // eslint-disable-line no-console
26
+ }
27
+ return false;
28
+ }
29
+ dynamicFontLoadingEnabled = !!value;
30
+ return true;
31
+ };
32
+
33
+ /**
34
+ * Whether dynamic loading of fonts is enabled.
35
+ * */
36
+ exports.setDynamicLoadingEnabled = setDynamicLoadingEnabled;
37
+ const isDynamicLoadingEnabled = () => dynamicFontLoadingEnabled;
38
+ exports.isDynamicLoadingEnabled = isDynamicLoadingEnabled;
39
+ let dynamicLoadingErrorCallback;
40
+
41
+ /**
42
+ * Set a callback to be called when an error occurs during dynamic font loading.
43
+ * */
44
+ const setDynamicLoadingErrorCallback = callback => {
45
+ dynamicLoadingErrorCallback = callback;
46
+ };
47
+ exports.setDynamicLoadingErrorCallback = setDynamicLoadingErrorCallback;
48
+ const getErrorCallback = () => dynamicLoadingErrorCallback;
49
+ exports.getErrorCallback = getErrorCallback;
50
+ //# sourceMappingURL=dynamic-loading-setting.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["hasNecessaryExpoModules","globalThis","expo","modules","ExpoAsset","ExpoFontLoader","hasNecessaryExpoFeatures","getLoadedFonts","dynamicFontLoadingEnabled","isDynamicLoadingSupported","exports","setDynamicLoadingEnabled","value","process","env","NODE_ENV","message","console","error","isDynamicLoadingEnabled","dynamicLoadingErrorCallback","setDynamicLoadingErrorCallback","callback","getErrorCallback"],"sourceRoot":"../../../src","sources":["dynamicLoading/dynamic-loading-setting.ts"],"mappings":";;;;;;AAuBA,MAAMA,uBAAuB,GAAG,CAAC,CAACC,UAAU,CAACC,IAAI,EAAEC,OAAO,EAAEC,SAAS,IAAI,CAAC,CAACH,UAAU,CAACC,IAAI,EAAEC,OAAO,EAAEE,cAAc;AAEnH,MAAMC,wBAAwB,GAC5BN,uBAAuB,IAAI,OAAOC,UAAU,CAACC,IAAI,EAAEC,OAAO,CAACE,cAAc,CAACE,cAAc,KAAK,UAAU;AAEzG,IAAIC,yBAAyB,GAAGF,wBAAwB;AAEjD,MAAMG,yBAAyB,GAAGA,CAAA,KAAMH,wBAAwB;;AAEvE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAPAI,OAAA,CAAAD,yBAAA,GAAAA,yBAAA;AAQO,MAAME,wBAAwB,GAAIC,KAAc,IAAc;EACnE,IAAI,CAACN,wBAAwB,EAAE;IAC7B,IAAIO,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY,IAAI,CAAC,CAACH,KAAK,EAAE;MACpD,MAAMI,OAAO,GAAGhB,uBAAuB,GACnC,sGAAsG,GACtG,gIAAgI;MACpIiB,OAAO,CAACC,KAAK,CAACF,OAAO,CAAC,CAAC,CAAC;IAC1B;IACA,OAAO,KAAK;EACd;EAEAR,yBAAyB,GAAG,CAAC,CAACI,KAAK;EAEnC,OAAO,IAAI;AACb,CAAC;;AAED;AACA;AACA;AAFAF,OAAA,CAAAC,wBAAA,GAAAA,wBAAA;AAGO,MAAMQ,uBAAuB,GAAGA,CAAA,KAAMX,yBAAyB;AAACE,OAAA,CAAAS,uBAAA,GAAAA,uBAAA;AAQvE,IAAIC,2BAAsD;;AAE1D;AACA;AACA;AACO,MAAMC,8BAA8B,GAAIC,QAAuB,IAAK;EACzEF,2BAA2B,GAAGE,QAAQ;AACxC,CAAC;AAACZ,OAAA,CAAAW,8BAAA,GAAAA,8BAAA;AAEK,MAAME,gBAAgB,GAAGA,CAAA,KAAMH,2BAA2B;AAACV,OAAA,CAAAa,gBAAA,GAAAA,gBAAA","ignoreList":[]}
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":[],"sourceRoot":"../../../src","sources":["dynamicLoading/types.ts"],"mappings":"","ignoreList":[]}