expo-modules-core 0.6.1 → 0.7.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.
Files changed (161) hide show
  1. package/CHANGELOG.md +38 -0
  2. package/README.md +1 -1
  3. package/android/build.gradle +5 -5
  4. package/android/src/main/java/expo/modules/adapters/react/apploader/RNHeadlessAppLoader.kt +7 -1
  5. package/android/src/main/java/expo/modules/core/interfaces/ReactActivityLifecycleListener.java +23 -0
  6. package/android/src/main/java/expo/modules/kotlin/AppContext.kt +11 -1
  7. package/android/src/main/java/expo/modules/kotlin/DynamicExtenstions.kt +5 -3
  8. package/android/src/main/java/expo/modules/kotlin/KPromiseWrapper.kt +8 -2
  9. package/android/src/main/java/expo/modules/kotlin/KotlinInteropModuleRegistry.kt +13 -4
  10. package/android/src/main/java/expo/modules/kotlin/ModuleHolder.kt +7 -6
  11. package/android/src/main/java/expo/modules/kotlin/ModuleRegistry.kt +6 -1
  12. package/android/src/main/java/expo/modules/kotlin/Promise.kt +1 -1
  13. package/android/src/main/java/expo/modules/kotlin/callbacks/Callback.kt +5 -0
  14. package/android/src/main/java/expo/modules/kotlin/callbacks/ViewCallback.kt +28 -0
  15. package/android/src/main/java/expo/modules/kotlin/callbacks/ViewCallbackDelegate.kt +27 -0
  16. package/android/src/main/java/expo/modules/kotlin/defaultmodules/ErrorManagerModule.kt +25 -0
  17. package/android/src/main/java/expo/modules/kotlin/exception/CodedException.kt +68 -8
  18. package/android/src/main/java/expo/modules/kotlin/exception/ExceptionDecorator.kt +11 -0
  19. package/android/src/main/java/expo/modules/kotlin/methods/AnyMethod.kt +13 -14
  20. package/android/src/main/java/expo/modules/kotlin/modules/DefinitionMarker.kt +4 -0
  21. package/android/src/main/java/expo/modules/kotlin/modules/Module.kt +3 -2
  22. package/android/src/main/java/expo/modules/kotlin/modules/ModuleDefinitionBuilder.kt +44 -4
  23. package/android/src/main/java/expo/modules/kotlin/records/Record.kt +39 -0
  24. package/android/src/main/java/expo/modules/kotlin/records/RecordTypeConverter.kt +14 -7
  25. package/android/src/main/java/expo/modules/kotlin/types/ArrayTypeConverter.kt +11 -5
  26. package/android/src/main/java/expo/modules/kotlin/types/ListTypeConverter.kt +10 -4
  27. package/android/src/main/java/expo/modules/kotlin/types/MapTypeConverter.kt +12 -6
  28. package/android/src/main/java/expo/modules/kotlin/types/PairTypeConverter.kt +29 -13
  29. package/android/src/main/java/expo/modules/kotlin/types/TypeConverter.kt +2 -1
  30. package/android/src/main/java/expo/modules/kotlin/views/CallbacksDefinition.kt +3 -0
  31. package/android/src/main/java/expo/modules/kotlin/views/GroupViewManagerWrapper.kt +22 -0
  32. package/android/src/main/java/expo/modules/kotlin/views/SimpleViewManagerWrapper.kt +22 -0
  33. package/android/src/main/java/expo/modules/kotlin/views/ViewManagerDefinition.kt +27 -2
  34. package/android/src/main/java/expo/modules/kotlin/views/ViewManagerDefinitionBuilder.kt +29 -1
  35. package/android/src/main/java/expo/modules/kotlin/views/ViewManagerWrapperDelegate.kt +59 -2
  36. package/build/EventEmitter.d.ts +1 -0
  37. package/build/EventEmitter.d.ts.map +1 -0
  38. package/build/NativeModulesProxy.d.ts +1 -0
  39. package/build/NativeModulesProxy.d.ts.map +1 -0
  40. package/build/NativeModulesProxy.native.d.ts +1 -0
  41. package/build/NativeModulesProxy.native.d.ts.map +1 -0
  42. package/build/NativeModulesProxy.types.d.ts +1 -0
  43. package/build/NativeModulesProxy.types.d.ts.map +1 -0
  44. package/build/NativeViewManagerAdapter.d.ts +1 -0
  45. package/build/NativeViewManagerAdapter.d.ts.map +1 -0
  46. package/build/NativeViewManagerAdapter.native.d.ts +1 -0
  47. package/build/NativeViewManagerAdapter.native.d.ts.map +1 -0
  48. package/build/PermissionsHook.d.ts +1 -0
  49. package/build/PermissionsHook.d.ts.map +1 -0
  50. package/build/PermissionsInterface.d.ts +1 -0
  51. package/build/PermissionsInterface.d.ts.map +1 -0
  52. package/build/Platform.d.ts +1 -0
  53. package/build/Platform.d.ts.map +1 -0
  54. package/build/SyntheticPlatformEmitter.d.ts +1 -0
  55. package/build/SyntheticPlatformEmitter.d.ts.map +1 -0
  56. package/build/SyntheticPlatformEmitter.web.d.ts +1 -0
  57. package/build/SyntheticPlatformEmitter.web.d.ts.map +1 -0
  58. package/build/deprecate.d.ts +1 -0
  59. package/build/deprecate.d.ts.map +1 -0
  60. package/build/environment/browser.d.ts +1 -0
  61. package/build/environment/browser.d.ts.map +1 -0
  62. package/build/environment/browser.web.d.ts +1 -0
  63. package/build/environment/browser.web.d.ts.map +1 -0
  64. package/build/errors/CodedError.d.ts +1 -0
  65. package/build/errors/CodedError.d.ts.map +1 -0
  66. package/build/errors/UnavailabilityError.d.ts +1 -0
  67. package/build/errors/UnavailabilityError.d.ts.map +1 -0
  68. package/build/index.d.ts +3 -0
  69. package/build/index.d.ts.map +1 -0
  70. package/build/index.js +2 -0
  71. package/build/index.js.map +1 -1
  72. package/build/requireNativeModule.d.ts +16 -0
  73. package/build/requireNativeModule.d.ts.map +1 -0
  74. package/build/requireNativeModule.js +18 -0
  75. package/build/requireNativeModule.js.map +1 -0
  76. package/build/sweet/NativeErrorManager.d.ts +3 -0
  77. package/build/sweet/NativeErrorManager.d.ts.map +1 -0
  78. package/build/sweet/NativeErrorManager.js +3 -0
  79. package/build/sweet/NativeErrorManager.js.map +1 -0
  80. package/build/sweet/setUpErrorManager.fx.d.ts +2 -0
  81. package/build/sweet/setUpErrorManager.fx.d.ts.map +1 -0
  82. package/build/sweet/setUpErrorManager.fx.js +11 -0
  83. package/build/sweet/setUpErrorManager.fx.js.map +1 -0
  84. package/ios/AppDelegates/ExpoAppDelegate.swift +27 -8
  85. package/ios/JSI/ExpoModulesHostObject.h +33 -0
  86. package/ios/JSI/ExpoModulesHostObject.mm +40 -0
  87. package/ios/JSI/ExpoModulesProxySpec.h +4 -0
  88. package/ios/JSI/ExpoModulesProxySpec.mm +1 -3
  89. package/ios/JSI/JSIConversions.h +2 -0
  90. package/ios/JSI/JSIConversions.mm +9 -0
  91. package/ios/JSI/JSIInstaller.h +10 -0
  92. package/ios/JSI/JSIInstaller.mm +14 -2
  93. package/ios/JSI/JavaScriptObject.h +60 -0
  94. package/ios/JSI/JavaScriptObject.mm +93 -0
  95. package/ios/JSI/JavaScriptRuntime.h +54 -0
  96. package/ios/JSI/JavaScriptRuntime.mm +102 -0
  97. package/ios/ModuleRegistryAdapter/EXModuleRegistryAdapter.m +2 -12
  98. package/ios/NativeModulesProxy/EXComponentDataCompatibleWrapper.h +16 -0
  99. package/ios/NativeModulesProxy/EXComponentDataCompatibleWrapper.m +28 -0
  100. package/ios/NativeModulesProxy/EXNativeModulesProxy.mm +90 -66
  101. package/ios/RCTComponentData+Privates.h +12 -0
  102. package/ios/ReactDelegates/ExpoReactDelegate.swift +2 -2
  103. package/ios/ReactDelegates/ExpoReactDelegateHandler.swift +3 -3
  104. package/ios/ReactDelegates/ModulePriorities.swift +1 -1
  105. package/ios/Swift/AppContext.swift +38 -4
  106. package/ios/Swift/Arguments/ArgumentType.swift +4 -0
  107. package/ios/Swift/Arguments/Convertibles.swift +13 -13
  108. package/ios/Swift/Arguments/Types/EnumArgumentType.swift +11 -17
  109. package/ios/Swift/Arguments/Types/PromiseArgumentType.swift +1 -1
  110. package/ios/Swift/Arguments/Types/RawArgumentType.swift +2 -2
  111. package/ios/Swift/Conversions.swift +51 -56
  112. package/ios/Swift/EventListener.swift +8 -10
  113. package/ios/Swift/Events/Callback.swift +66 -0
  114. package/ios/Swift/Events/Event.swift +43 -0
  115. package/ios/Swift/Exceptions/ChainableException.swift +51 -0
  116. package/ios/Swift/{CodedError.swift → Exceptions/CodedError.swift} +1 -12
  117. package/ios/Swift/Exceptions/Exception.swift +62 -0
  118. package/ios/Swift/Exceptions/ExceptionOrigin.swift +28 -0
  119. package/ios/Swift/Exceptions/GenericException.swift +20 -0
  120. package/ios/Swift/Exceptions/UnexpectedException.swift +16 -0
  121. package/ios/Swift/Functions/AnyFunction.swift +11 -1
  122. package/ios/Swift/Functions/ConcreteFunction.swift +37 -16
  123. package/ios/Swift/JavaScriptUtils.swift +43 -0
  124. package/ios/Swift/ModuleHolder.swift +53 -14
  125. package/ios/Swift/ModuleRegistry.swift +4 -1
  126. package/ios/Swift/Modules/AnyModule.swift +0 -1
  127. package/ios/Swift/Modules/ModuleDefinition.swift +4 -13
  128. package/ios/Swift/Modules/ModuleDefinitionBuilder.swift +0 -1
  129. package/ios/Swift/Modules/ModuleDefinitionComponents.swift +0 -188
  130. package/ios/Swift/ModulesProvider.swift +0 -1
  131. package/ios/Swift/Objects/ObjectDefinition.swift +30 -0
  132. package/ios/Swift/Objects/ObjectDefinitionComponents.swift +208 -0
  133. package/ios/Swift/Promise.swift +8 -3
  134. package/ios/Swift/Records/AnyField.swift +7 -0
  135. package/ios/Swift/Records/Field.swift +24 -19
  136. package/ios/Swift/Records/FieldOption.swift +1 -1
  137. package/ios/Swift/Records/Record.swift +12 -4
  138. package/ios/Swift/SwiftInteropBridge.swift +39 -10
  139. package/ios/Swift/Views/AnyViewProp.swift +1 -1
  140. package/ios/Swift/Views/ComponentData.swift +95 -0
  141. package/ios/Swift/Views/ConcreteViewProp.swift +6 -8
  142. package/ios/Swift/Views/ViewFactory.swift +1 -1
  143. package/ios/Swift/Views/ViewManagerDefinition.swift +23 -2
  144. package/ios/Swift/Views/ViewManagerDefinitionBuilder.swift +0 -1
  145. package/ios/Swift/Views/ViewManagerDefinitionComponents.swift +26 -0
  146. package/ios/Swift/Views/ViewModuleWrapper.swift +5 -2
  147. package/ios/Tests/ArgumentTypeSpec.swift +3 -4
  148. package/ios/Tests/ConstantsSpec.swift +4 -4
  149. package/ios/Tests/ConvertiblesSpec.swift +33 -33
  150. package/ios/Tests/ExceptionsSpec.swift +112 -0
  151. package/ios/Tests/FunctionSpec.swift +20 -22
  152. package/ios/Tests/FunctionWithConvertiblesSpec.swift +2 -2
  153. package/ios/Tests/Mocks/ModuleMocks.swift +1 -1
  154. package/ios/Tests/Mocks/ModulesProviderMock.swift +0 -1
  155. package/ios/Tests/ModuleEventListenersSpec.swift +1 -1
  156. package/ios/Tests/RecordSpec.swift +7 -17
  157. package/package.json +3 -3
  158. package/src/index.ts +4 -0
  159. package/src/requireNativeModule.ts +29 -0
  160. package/src/sweet/NativeErrorManager.ts +2 -0
  161. package/src/sweet/setUpErrorManager.fx.ts +12 -0
@@ -22,3 +22,4 @@ export declare class EventEmitter {
22
22
  emit(eventName: string, ...params: any[]): void;
23
23
  }
24
24
  export {};
25
+ //# sourceMappingURL=EventEmitter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EventEmitter.d.ts","sourceRoot":"","sources":["../src/EventEmitter.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,kBAAkB,EAAY,MAAM,cAAc,CAAC;AAI5D,aAAK,YAAY,GAAG;IAClB,cAAc,CAAC,EAAE,MAAM,IAAI,CAAC;IAC5B,aAAa,CAAC,EAAE,MAAM,IAAI,CAAC;IAC3B,WAAW,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;IACzC,eAAe,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CAC1C,CAAC;AAGF,oBAAY,YAAY,GAAG;IACzB;;OAEG;IACH,MAAM,EAAE,MAAM,IAAI,CAAC;CACpB,CAAC;AAEF,qBAAa,YAAY;IACvB,cAAc,SAAK;IACnB,aAAa,EAAE,YAAY,CAAC;IAC5B,aAAa,EAAE,kBAAkB,CAAC;gBAEtB,YAAY,EAAE,YAAY;IAKtC,WAAW,CAAC,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,GAAG,YAAY;IAgB7E,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;IAmB3C,kBAAkB,CAAC,YAAY,EAAE,YAAY,GAAG,IAAI;IA0BpD,IAAI,CAAC,SAAS,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,GAAG,EAAE,GAAG,IAAI;CAGhD"}
@@ -3,3 +3,4 @@ declare const _default: {
3
3
  [moduleName: string]: ProxyNativeModule;
4
4
  };
5
5
  export default _default;
6
+ //# sourceMappingURL=NativeModulesProxy.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NativeModulesProxy.d.ts","sourceRoot":"","sources":["../src/NativeModulesProxy.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;;;;AAG/D,wBAAiE"}
@@ -7,3 +7,4 @@ declare const NativeModulesProxy: {
7
7
  */
8
8
  export declare function useExpoTurboModules(state?: boolean): void;
9
9
  export default NativeModulesProxy;
10
+ //# sourceMappingURL=NativeModulesProxy.native.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NativeModulesProxy.native.d.ts","sourceRoot":"","sources":["../src/NativeModulesProxy.native.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAA0B,MAAM,4BAA4B,CAAC;AAWvF,QAAA,MAAM,kBAAkB,EAAE;IAAE,CAAC,UAAU,EAAE,MAAM,GAAG,iBAAiB,CAAA;CAAO,CAAC;AAK3E;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,KAAK,GAAE,OAAc,QAExD;AAuDD,eAAe,kBAAkB,CAAC"}
@@ -6,3 +6,4 @@ export declare type ProxyNativeModule = {
6
6
  export declare type TurboNativeModuleProxy = {
7
7
  callMethodAsync: <ReturnType>(moduleName: string, methodName: string, args: any[]) => Promise<ReturnType>;
8
8
  };
9
+ //# sourceMappingURL=NativeModulesProxy.types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NativeModulesProxy.types.d.ts","sourceRoot":"","sources":["../src/NativeModulesProxy.types.ts"],"names":[],"mappings":"AAAA,oBAAY,iBAAiB,GAAG;IAC9B,CAAC,YAAY,EAAE,MAAM,GAAG,GAAG,CAAC;IAC5B,WAAW,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;IACzC,eAAe,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CAC1C,CAAC;AAEF,oBAAY,sBAAsB,GAAG;IACnC,eAAe,EAAE,CAAC,UAAU,EAC1B,UAAU,EAAE,MAAM,EAClB,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,GAAG,EAAE,KACR,OAAO,CAAC,UAAU,CAAC,CAAC;CAC1B,CAAC"}
@@ -1,2 +1,3 @@
1
1
  import React from 'react';
2
2
  export declare function requireNativeViewManager<P = any>(viewName: string): React.ComponentType<P>;
3
+ //# sourceMappingURL=NativeViewManagerAdapter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NativeViewManagerAdapter.d.ts","sourceRoot":"","sources":["../src/NativeViewManagerAdapter.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,wBAAgB,wBAAwB,CAAC,CAAC,GAAG,GAAG,EAAE,QAAQ,EAAE,MAAM,GAAG,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,CAE1F"}
@@ -3,3 +3,4 @@ import React from 'react';
3
3
  * A drop-in replacement for `requireNativeComponent`.
4
4
  */
5
5
  export declare function requireNativeViewManager<P = any>(viewName: string): React.ComponentType<P>;
6
+ //# sourceMappingURL=NativeViewManagerAdapter.native.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NativeViewManagerAdapter.native.d.ts","sourceRoot":"","sources":["../src/NativeViewManagerAdapter.native.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAqB1B;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,CAAC,GAAG,GAAG,EAAE,QAAQ,EAAE,MAAM,GAAG,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,CAqC1F"}
@@ -20,3 +20,4 @@ export declare type PermissionHookOptions<Options extends object> = PermissionHo
20
20
  */
21
21
  export declare function createPermissionHook<Permission extends PermissionResponse, Options extends object>(methods: PermissionHookMethods<Permission, Options>): (options?: PermissionHookOptions<Options> | undefined) => [Permission | null, RequestPermissionMethod<Permission>, GetPermissionMethod<Permission>];
22
22
  export {};
23
+ //# sourceMappingURL=PermissionsHook.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PermissionsHook.d.ts","sourceRoot":"","sources":["../src/PermissionsHook.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAG5D,aAAK,uBAAuB,CAAC,UAAU,SAAS,kBAAkB,IAAI,MAAM,OAAO,CAAC,UAAU,CAAC,CAAC;AAChG,aAAK,mBAAmB,CAAC,UAAU,SAAS,kBAAkB,IAAI,MAAM,OAAO,CAAC,UAAU,CAAC,CAAC;AAE5F,UAAU,qBAAqB,CAAC,UAAU,SAAS,kBAAkB,EAAE,OAAO,GAAG,KAAK;IACpF,wEAAwE;IACxE,aAAa,EAAE,CAAC,OAAO,CAAC,EAAE,OAAO,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC;IAC1D,6EAA6E;IAC7E,SAAS,EAAE,CAAC,OAAO,CAAC,EAAE,OAAO,KAAK,OAAO,CAAC,UAAU,CAAC,CAAC;CACvD;AAED,UAAU,sBAAsB;IAC9B,qGAAqG;IACrG,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,6EAA6E;IAC7E,OAAO,CAAC,EAAE,OAAO,CAAC;CACnB;AAED,oBAAY,qBAAqB,CAAC,OAAO,SAAS,MAAM,IAAI,sBAAsB,GAAG,OAAO,CAAC;AAkD7F;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,UAAU,SAAS,kBAAkB,EAAE,OAAO,SAAS,MAAM,EAChG,OAAO,EAAE,qBAAqB,CAAC,UAAU,EAAE,OAAO,CAAC,uJAIpD"}
@@ -10,3 +10,4 @@ export interface PermissionResponse {
10
10
  granted: boolean;
11
11
  canAskAgain: boolean;
12
12
  }
13
+ //# sourceMappingURL=PermissionsInterface.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PermissionsInterface.d.ts","sourceRoot":"","sources":["../src/PermissionsInterface.ts"],"names":[],"mappings":"AAAA,oBAAY,gBAAgB;IAC1B,OAAO,YAAY;IACnB,YAAY,iBAAiB;IAC7B,MAAM,WAAW;CAClB;AAED,oBAAY,oBAAoB,GAAG,OAAO,GAAG,MAAM,CAAC;AAEpD,MAAM,WAAW,kBAAkB;IACjC,MAAM,EAAE,gBAAgB,CAAC;IACzB,OAAO,EAAE,oBAAoB,CAAC;IAC9B,OAAO,EAAE,OAAO,CAAC;IACjB,WAAW,EAAE,OAAO,CAAC;CACtB"}
@@ -42,3 +42,4 @@ declare const Platform: {
42
42
  isAsyncDebugging: boolean;
43
43
  };
44
44
  export default Platform;
45
+ //# sourceMappingURL=Platform.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Platform.d.ts","sourceRoot":"","sources":["../src/Platform.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmC,cAAc,EAAE,MAAM,cAAc,CAAC;AAS/E,oBAAY,oBAAoB,GAAG,cAAc,GAAG,QAAQ,GAAG,UAAU,GAAG,SAAS,CAAC;AAEtF,oBAAY,cAAc,GAAG,CAAC,CAAC,EAAE,SAAS,EAAE;KAAG,QAAQ,IAAI,oBAAoB,CAAC,CAAC,EAAE,CAAC;CAAE,KAAK,CAAC,CAAC;AAE7F,QAAA,MAAM,QAAQ;IACZ;;;OAGG;;IAEH;;;;;;;OAOG;;IAEH;;;OAGG;;IAEH;;;;OAIG;;IAEH;;;;OAIG;;IAEH;;;OAGG;;CAEJ,CAAC;AAEF,eAAe,QAAQ,CAAC"}
@@ -3,3 +3,4 @@
3
3
  * registered in the API layer with `NativeEventEmitter`.
4
4
  */
5
5
  export { default } from 'react-native/Libraries/EventEmitter/RCTDeviceEventEmitter';
6
+ //# sourceMappingURL=SyntheticPlatformEmitter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SyntheticPlatformEmitter.d.ts","sourceRoot":"","sources":["../src/SyntheticPlatformEmitter.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,2DAA2D,CAAC"}
@@ -3,3 +3,4 @@
3
3
  * registered in the API layer with `NativeEventEmitter`.
4
4
  */
5
5
  export { default } from 'react-native-web/dist/vendor/react-native/NativeEventEmitter/RCTDeviceEventEmitter';
6
+ //# sourceMappingURL=SyntheticPlatformEmitter.web.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"SyntheticPlatformEmitter.web.d.ts","sourceRoot":"","sources":["../src/SyntheticPlatformEmitter.web.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,oFAAoF,CAAC"}
@@ -6,3 +6,4 @@ export default function deprecate(library: string, deprecatedAPI: string, option
6
6
  currentVersion?: string;
7
7
  versionToRemove?: string;
8
8
  }): void;
9
+ //# sourceMappingURL=deprecate.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deprecate.d.ts","sourceRoot":"","sources":["../src/deprecate.ts"],"names":[],"mappings":"AAMA;;GAEG;AACH,MAAM,CAAC,OAAO,UAAU,SAAS,CAC/B,OAAO,EAAE,MAAM,EACf,aAAa,EAAE,MAAM,EACrB,OAAO,GAAE;IACP,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,eAAe,CAAC,EAAE,MAAM,CAAC;CACrB,GACL,IAAI,CAgCN"}
@@ -2,3 +2,4 @@ export declare const isDOMAvailable = false;
2
2
  export declare const canUseEventListeners = false;
3
3
  export declare const canUseViewport = false;
4
4
  export declare let isAsyncDebugging: boolean;
5
+ //# sourceMappingURL=browser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../../src/environment/browser.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,cAAc,QAAQ,CAAC;AACpC,eAAO,MAAM,oBAAoB,QAAQ,CAAC;AAC1C,eAAO,MAAM,cAAc,QAAQ,CAAC;AAEpC,eAAO,IAAI,gBAAgB,EAAE,OAAe,CAAC"}
@@ -7,3 +7,4 @@ export declare const isDOMAvailable: boolean;
7
7
  export declare const canUseEventListeners: boolean;
8
8
  export declare const canUseViewport: boolean;
9
9
  export declare const isAsyncDebugging = false;
10
+ //# sourceMappingURL=browser.web.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"browser.web.d.ts","sourceRoot":"","sources":["../../src/environment/browser.web.ts"],"names":[],"mappings":"AAAA,OAAO,CAAC,MAAM,CAAC;IAEb,UAAU,MAAM;QACd,WAAW,CAAC,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,aAAa,GAAG,OAAO,CAAC;KAC9D;CACF;AAID,eAAO,MAAM,cAAc,SAAoE,CAAC;AAChG,eAAO,MAAM,oBAAoB,SACoC,CAAC;AACtE,eAAO,MAAM,cAAc,SAAoC,CAAC;AAChE,eAAO,MAAM,gBAAgB,QAAQ,CAAC"}
@@ -8,3 +8,4 @@ export declare class CodedError extends Error {
8
8
  info?: any;
9
9
  constructor(code: string, message: string);
10
10
  }
11
+ //# sourceMappingURL=CodedError.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CodedError.d.ts","sourceRoot":"","sources":["../../src/errors/CodedError.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,qBAAa,UAAW,SAAQ,KAAK;IACnC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,GAAG,CAAC;gBAEC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;CAI1C"}
@@ -7,3 +7,4 @@ import { CodedError } from './CodedError';
7
7
  export declare class UnavailabilityError extends CodedError {
8
8
  constructor(moduleName: string, propertyName: string);
9
9
  }
10
+ //# sourceMappingURL=UnavailabilityError.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"UnavailabilityError.d.ts","sourceRoot":"","sources":["../../src/errors/UnavailabilityError.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C;;;;GAIG;AACH,qBAAa,mBAAoB,SAAQ,UAAU;gBACrC,UAAU,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM;CAMrD"}
package/build/index.d.ts CHANGED
@@ -7,11 +7,14 @@ import Platform from './Platform';
7
7
  import SyntheticPlatformEmitter from './SyntheticPlatformEmitter';
8
8
  import { CodedError } from './errors/CodedError';
9
9
  import { UnavailabilityError } from './errors/UnavailabilityError';
10
+ import './sweet/setUpErrorManager.fx';
10
11
  export { default as deprecate } from './deprecate';
11
12
  export { DeviceEventEmitter, EventEmitter, NativeModulesProxy, ProxyNativeModule, Platform, Subscription, SyntheticPlatformEmitter, requireNativeViewManager, CodedError, UnavailabilityError, };
13
+ export * from './requireNativeModule';
12
14
  /**
13
15
  * @deprecated renamed to `DeviceEventEmitter`
14
16
  */
15
17
  export declare const RCTDeviceEventEmitter: import("react-native").DeviceEventEmitterStatic;
16
18
  export * from './PermissionsInterface';
17
19
  export * from './PermissionsHook';
20
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAElD,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAC5D,OAAO,kBAAkB,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,QAAQ,MAAM,YAAY,CAAC;AAClC,OAAO,wBAAwB,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAEnE,OAAO,8BAA8B,CAAC;AAEtC,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,aAAa,CAAC;AAEnD,OAAO,EACL,kBAAkB,EAClB,YAAY,EACZ,kBAAkB,EAClB,iBAAiB,EACjB,QAAQ,EACR,YAAY,EACZ,wBAAwB,EACxB,wBAAwB,EAExB,UAAU,EACV,mBAAmB,GACpB,CAAC;AAEF,cAAc,uBAAuB,CAAC;AAEtC;;GAEG;AACH,eAAO,MAAM,qBAAqB,iDAAqB,CAAC;AAExD,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC"}
package/build/index.js CHANGED
@@ -6,10 +6,12 @@ import Platform from './Platform';
6
6
  import SyntheticPlatformEmitter from './SyntheticPlatformEmitter';
7
7
  import { CodedError } from './errors/CodedError';
8
8
  import { UnavailabilityError } from './errors/UnavailabilityError';
9
+ import './sweet/setUpErrorManager.fx';
9
10
  export { default as deprecate } from './deprecate';
10
11
  export { DeviceEventEmitter, EventEmitter, NativeModulesProxy, Platform, SyntheticPlatformEmitter, requireNativeViewManager,
11
12
  // Errors
12
13
  CodedError, UnavailabilityError, };
14
+ export * from './requireNativeModule';
13
15
  /**
14
16
  * @deprecated renamed to `DeviceEventEmitter`
15
17
  */
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAElD,OAAO,EAAE,YAAY,EAAgB,MAAM,gBAAgB,CAAC;AAC5D,OAAO,kBAAkB,MAAM,sBAAsB,CAAC;AAEtD,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,QAAQ,MAAM,YAAY,CAAC;AAClC,OAAO,wBAAwB,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAEnE,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,aAAa,CAAC;AAEnD,OAAO,EACL,kBAAkB,EAClB,YAAY,EACZ,kBAAkB,EAElB,QAAQ,EAER,wBAAwB,EACxB,wBAAwB;AACxB,SAAS;AACT,UAAU,EACV,mBAAmB,GACpB,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,kBAAkB,CAAC;AAExD,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC","sourcesContent":["import { DeviceEventEmitter } from 'react-native';\n\nimport { EventEmitter, Subscription } from './EventEmitter';\nimport NativeModulesProxy from './NativeModulesProxy';\nimport { ProxyNativeModule } from './NativeModulesProxy.types';\nimport { requireNativeViewManager } from './NativeViewManagerAdapter';\nimport Platform from './Platform';\nimport SyntheticPlatformEmitter from './SyntheticPlatformEmitter';\nimport { CodedError } from './errors/CodedError';\nimport { UnavailabilityError } from './errors/UnavailabilityError';\n\nexport { default as deprecate } from './deprecate';\n\nexport {\n DeviceEventEmitter,\n EventEmitter,\n NativeModulesProxy,\n ProxyNativeModule,\n Platform,\n Subscription,\n SyntheticPlatformEmitter,\n requireNativeViewManager,\n // Errors\n CodedError,\n UnavailabilityError,\n};\n\n/**\n * @deprecated renamed to `DeviceEventEmitter`\n */\nexport const RCTDeviceEventEmitter = DeviceEventEmitter;\n\nexport * from './PermissionsInterface';\nexport * from './PermissionsHook';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAElD,OAAO,EAAE,YAAY,EAAgB,MAAM,gBAAgB,CAAC;AAC5D,OAAO,kBAAkB,MAAM,sBAAsB,CAAC;AAEtD,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AACtE,OAAO,QAAQ,MAAM,YAAY,CAAC;AAClC,OAAO,wBAAwB,MAAM,4BAA4B,CAAC;AAClE,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,8BAA8B,CAAC;AAEnE,OAAO,8BAA8B,CAAC;AAEtC,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,aAAa,CAAC;AAEnD,OAAO,EACL,kBAAkB,EAClB,YAAY,EACZ,kBAAkB,EAElB,QAAQ,EAER,wBAAwB,EACxB,wBAAwB;AACxB,SAAS;AACT,UAAU,EACV,mBAAmB,GACpB,CAAC;AAEF,cAAc,uBAAuB,CAAC;AAEtC;;GAEG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAG,kBAAkB,CAAC;AAExD,cAAc,wBAAwB,CAAC;AACvC,cAAc,mBAAmB,CAAC","sourcesContent":["import { DeviceEventEmitter } from 'react-native';\n\nimport { EventEmitter, Subscription } from './EventEmitter';\nimport NativeModulesProxy from './NativeModulesProxy';\nimport { ProxyNativeModule } from './NativeModulesProxy.types';\nimport { requireNativeViewManager } from './NativeViewManagerAdapter';\nimport Platform from './Platform';\nimport SyntheticPlatformEmitter from './SyntheticPlatformEmitter';\nimport { CodedError } from './errors/CodedError';\nimport { UnavailabilityError } from './errors/UnavailabilityError';\n\nimport './sweet/setUpErrorManager.fx';\n\nexport { default as deprecate } from './deprecate';\n\nexport {\n DeviceEventEmitter,\n EventEmitter,\n NativeModulesProxy,\n ProxyNativeModule,\n Platform,\n Subscription,\n SyntheticPlatformEmitter,\n requireNativeViewManager,\n // Errors\n CodedError,\n UnavailabilityError,\n};\n\nexport * from './requireNativeModule';\n\n/**\n * @deprecated renamed to `DeviceEventEmitter`\n */\nexport const RCTDeviceEventEmitter = DeviceEventEmitter;\n\nexport * from './PermissionsInterface';\nexport * from './PermissionsHook';\n"]}
@@ -0,0 +1,16 @@
1
+ declare global {
2
+ var ExpoModules: undefined | {
3
+ [key: string]: any;
4
+ };
5
+ }
6
+ /**
7
+ * Imports the native module registered with given name. In the first place it tries to load
8
+ * the module installed through the JSI host object and then falls back to the bridge proxy module.
9
+ * Notice that the modules loaded from the proxy may not support some features like synchronous functions.
10
+ *
11
+ * @param moduleName Name of the requested native module.
12
+ * @returns Object representing the native module.
13
+ * @throws Error when there is no native module with given name.
14
+ */
15
+ export declare function requireNativeModule<ModuleType = any>(moduleName: string): ModuleType;
16
+ //# sourceMappingURL=requireNativeModule.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"requireNativeModule.d.ts","sourceRoot":"","sources":["../src/requireNativeModule.ts"],"names":[],"mappings":"AAEA,OAAO,CAAC,MAAM,CAAC;IAEb,IAAI,WAAW,EACX,SAAS,GACT;QACE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAC;KACpB,CAAC;CACP;AAED;;;;;;;;GAQG;AACH,wBAAgB,mBAAmB,CAAC,UAAU,GAAG,GAAG,EAAE,UAAU,EAAE,MAAM,GAAG,UAAU,CAQpF"}
@@ -0,0 +1,18 @@
1
+ import NativeModulesProxy from './NativeModulesProxy';
2
+ /**
3
+ * Imports the native module registered with given name. In the first place it tries to load
4
+ * the module installed through the JSI host object and then falls back to the bridge proxy module.
5
+ * Notice that the modules loaded from the proxy may not support some features like synchronous functions.
6
+ *
7
+ * @param moduleName Name of the requested native module.
8
+ * @returns Object representing the native module.
9
+ * @throws Error when there is no native module with given name.
10
+ */
11
+ export function requireNativeModule(moduleName) {
12
+ const nativeModule = global.ExpoModules?.[moduleName] ?? NativeModulesProxy[moduleName];
13
+ if (!nativeModule) {
14
+ throw new Error(`Cannot find native module '${moduleName}'`);
15
+ }
16
+ return nativeModule;
17
+ }
18
+ //# sourceMappingURL=requireNativeModule.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"requireNativeModule.js","sourceRoot":"","sources":["../src/requireNativeModule.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,MAAM,sBAAsB,CAAC;AAWtD;;;;;;;;GAQG;AACH,MAAM,UAAU,mBAAmB,CAAmB,UAAkB;IACtE,MAAM,YAAY,GAChB,MAAM,CAAC,WAAW,EAAE,CAAC,UAAU,CAAC,IAAI,kBAAkB,CAAC,UAAU,CAAC,CAAC;IAErE,IAAI,CAAC,YAAY,EAAE;QACjB,MAAM,IAAI,KAAK,CAAC,8BAA8B,UAAU,GAAG,CAAC,CAAC;KAC9D;IACD,OAAO,YAAY,CAAC;AACtB,CAAC","sourcesContent":["import NativeModulesProxy from './NativeModulesProxy';\n\ndeclare global {\n // eslint-disable-next-line no-var\n var ExpoModules:\n | undefined\n | {\n [key: string]: any;\n };\n}\n\n/**\n * Imports the native module registered with given name. In the first place it tries to load\n * the module installed through the JSI host object and then falls back to the bridge proxy module.\n * Notice that the modules loaded from the proxy may not support some features like synchronous functions.\n *\n * @param moduleName Name of the requested native module.\n * @returns Object representing the native module.\n * @throws Error when there is no native module with given name.\n */\nexport function requireNativeModule<ModuleType = any>(moduleName: string): ModuleType {\n const nativeModule: ModuleType =\n global.ExpoModules?.[moduleName] ?? NativeModulesProxy[moduleName];\n\n if (!nativeModule) {\n throw new Error(`Cannot find native module '${moduleName}'`);\n }\n return nativeModule;\n}\n"]}
@@ -0,0 +1,3 @@
1
+ declare const _default: import("..").ProxyNativeModule;
2
+ export default _default;
3
+ //# sourceMappingURL=NativeErrorManager.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NativeErrorManager.d.ts","sourceRoot":"","sources":["../../src/sweet/NativeErrorManager.ts"],"names":[],"mappings":";AACA,wBAA8D"}
@@ -0,0 +1,3 @@
1
+ import { NativeModulesProxy } from '..';
2
+ export default NativeModulesProxy.ExpoModulesCoreErrorManager;
3
+ //# sourceMappingURL=NativeErrorManager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"NativeErrorManager.js","sourceRoot":"","sources":["../../src/sweet/NativeErrorManager.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,IAAI,CAAC;AACxC,eAAe,kBAAkB,CAAC,2BAA2B,CAAC","sourcesContent":["import { NativeModulesProxy } from '..';\nexport default NativeModulesProxy.ExpoModulesCoreErrorManager;\n"]}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=setUpErrorManager.fx.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setUpErrorManager.fx.d.ts","sourceRoot":"","sources":["../../src/sweet/setUpErrorManager.fx.ts"],"names":[],"mappings":""}
@@ -0,0 +1,11 @@
1
+ import { EventEmitter } from '../EventEmitter';
2
+ import Platform from '../Platform';
3
+ import NativeErrorManager from './NativeErrorManager';
4
+ if (__DEV__ && Platform.OS === 'android' && NativeErrorManager) {
5
+ const onNewException = 'ExpoModulesCoreErrorManager.onNewException';
6
+ const eventEmitter = new EventEmitter(NativeErrorManager);
7
+ eventEmitter.addListener(onNewException, ({ message }) => {
8
+ console.error(message);
9
+ });
10
+ }
11
+ //# sourceMappingURL=setUpErrorManager.fx.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setUpErrorManager.fx.js","sourceRoot":"","sources":["../../src/sweet/setUpErrorManager.fx.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAC/C,OAAO,QAAQ,MAAM,aAAa,CAAC;AACnC,OAAO,kBAAkB,MAAM,sBAAsB,CAAC;AAEtD,IAAI,OAAO,IAAI,QAAQ,CAAC,EAAE,KAAK,SAAS,IAAI,kBAAkB,EAAE;IAC9D,MAAM,cAAc,GAAG,4CAA4C,CAAC;IACpE,MAAM,YAAY,GAAG,IAAI,YAAY,CAAC,kBAAkB,CAAC,CAAC;IAE1D,YAAY,CAAC,WAAW,CAAC,cAAc,EAAE,CAAC,EAAE,OAAO,EAAuB,EAAE,EAAE;QAC5E,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IACzB,CAAC,CAAC,CAAC;CACJ","sourcesContent":["import { EventEmitter } from '../EventEmitter';\nimport Platform from '../Platform';\nimport NativeErrorManager from './NativeErrorManager';\n\nif (__DEV__ && Platform.OS === 'android' && NativeErrorManager) {\n const onNewException = 'ExpoModulesCoreErrorManager.onNewException';\n const eventEmitter = new EventEmitter(NativeErrorManager);\n\n eventEmitter.addListener(onNewException, ({ message }: { message: string }) => {\n console.error(message);\n });\n}\n"]}
@@ -20,13 +20,24 @@ open class ExpoAppDelegate: UIResponder, UIApplicationDelegate {
20
20
 
21
21
  // MARK: - Initializing the App
22
22
 
23
- open func application(_ application: UIApplication, willFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
24
- return subscribers.reduce(false) { result, subscriber in
25
- return subscriber.application?(application, willFinishLaunchingWithOptions: launchOptions) ?? false || result
23
+ open func application(_ application: UIApplication, willFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool {
24
+ let parsedSubscribers = subscribers.filter {
25
+ $0.responds(to: #selector(application(_:willFinishLaunchingWithOptions:)))
26
+ }
27
+
28
+ // If we can't find a subscriber that implements `willFinishLaunchingWithOptions`, we will delegate the decision if we can handel the passed URL to
29
+ // the `didFinishLaunchingWithOptions` method by returning `true` here.
30
+ // You can read more about how iOS handles deep links here: https://developer.apple.com/documentation/uikit/uiapplicationdelegate/1623112-application#discussion
31
+ if parsedSubscribers.isEmpty {
32
+ return true
33
+ }
34
+
35
+ return parsedSubscribers.reduce(false) { result, subscriber in
36
+ return subscriber.application!(application, willFinishLaunchingWithOptions: launchOptions) || result
26
37
  }
27
38
  }
28
39
 
29
- open func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
40
+ open func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil) -> Bool {
30
41
  return subscribers.reduce(false) { result, subscriber in
31
42
  return subscriber.application?(application, didFinishLaunchingWithOptions: launchOptions) ?? false || result
32
43
  }
@@ -96,7 +107,11 @@ open class ExpoAppDelegate: UIResponder, UIApplicationDelegate {
96
107
  subscribers.forEach { $0.application?(application, didFailToRegisterForRemoteNotificationsWithError: error) }
97
108
  }
98
109
 
99
- open func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
110
+ open func application(
111
+ _ application: UIApplication,
112
+ didReceiveRemoteNotification userInfo: [AnyHashable: Any],
113
+ fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void
114
+ ) {
100
115
  let selector = #selector(application(_:didReceiveRemoteNotification:fetchCompletionHandler:))
101
116
  let subs = subscribers.filter { $0.responds(to: selector) }
102
117
  var subscribersLeft = subs.count
@@ -132,7 +147,11 @@ open class ExpoAppDelegate: UIResponder, UIApplicationDelegate {
132
147
  }
133
148
  }
134
149
 
135
- open func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
150
+ open func application(
151
+ _ application: UIApplication,
152
+ continue userActivity: NSUserActivity,
153
+ restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void
154
+ ) -> Bool {
136
155
  let selector = #selector(application(_:continue:restorationHandler:))
137
156
  let subs = subscribers.filter { $0.responds(to: selector) }
138
157
  var subscribersLeft = subs.count
@@ -227,7 +246,7 @@ open class ExpoAppDelegate: UIResponder, UIApplicationDelegate {
227
246
 
228
247
  // MARK: - Opening a URL-Specified Resource
229
248
 
230
- open func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
249
+ open func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey: Any] = [:]) -> Bool {
231
250
  return subscribers.contains { subscriber in
232
251
  return subscriber.application?(app, open: url, options: options) ?? false
233
252
  }
@@ -272,7 +291,7 @@ open class ExpoAppDelegate: UIResponder, UIApplicationDelegate {
272
291
  fatalError("Expo modules provider must implement `ModulesProviderProtocol`.")
273
292
  }
274
293
  provider.getReactDelegateHandlers()
275
- .sorted { (tuple1, tuple2) -> Bool in
294
+ .sorted { tuple1, tuple2 -> Bool in
276
295
  return ModulePriorities.get(tuple1.packageName) > ModulePriorities.get(tuple2.packageName)
277
296
  }
278
297
  .forEach { handlerTuple in
@@ -0,0 +1,33 @@
1
+ // Copyright 2022-present 650 Industries. All rights reserved.
2
+
3
+ #ifdef __cplusplus
4
+
5
+ #import <vector>
6
+ #import <jsi/jsi.h>
7
+
8
+ namespace jsi = facebook::jsi;
9
+
10
+ @class SwiftInteropBridge;
11
+
12
+ namespace expo {
13
+
14
+ class JSI_EXPORT ExpoModulesHostObject : public jsi::HostObject {
15
+ public:
16
+ ExpoModulesHostObject(SwiftInteropBridge *interopBridge);
17
+
18
+ virtual ~ExpoModulesHostObject();
19
+
20
+ jsi::Value get(jsi::Runtime &, const jsi::PropNameID &name) override;
21
+
22
+ void set(jsi::Runtime &, const jsi::PropNameID &name, const jsi::Value &value) override;
23
+
24
+ std::vector<jsi::PropNameID> getPropertyNames(jsi::Runtime &rt) override;
25
+
26
+ private:
27
+ SwiftInteropBridge *swiftInterop;
28
+
29
+ }; // class ExpoModulesHostObject
30
+
31
+ } // namespace expo
32
+
33
+ #endif
@@ -0,0 +1,40 @@
1
+ // Copyright 2022-present 650 Industries. All rights reserved.
2
+
3
+ #import <ExpoModulesCore/ExpoModulesHostObject.h>
4
+ #import <ExpoModulesCore/Swift.h>
5
+
6
+ namespace expo {
7
+
8
+ ExpoModulesHostObject::ExpoModulesHostObject(SwiftInteropBridge *swiftInterop) : swiftInterop(swiftInterop) {}
9
+
10
+ ExpoModulesHostObject::~ExpoModulesHostObject() {
11
+ [swiftInterop setRuntime:nil];
12
+ }
13
+
14
+ jsi::Value ExpoModulesHostObject::get(jsi::Runtime &runtime, const jsi::PropNameID &name) {
15
+ NSString *moduleName = [NSString stringWithUTF8String:name.utf8(runtime).c_str()];
16
+ JavaScriptObject *nativeObject = [swiftInterop getNativeModuleObject:moduleName];
17
+
18
+ return nativeObject ? jsi::Value(runtime, *[nativeObject get]) : jsi::Value::undefined();
19
+ }
20
+
21
+ void ExpoModulesHostObject::set(jsi::Runtime &runtime, const jsi::PropNameID &name, const jsi::Value &value) {
22
+ std::string message("RuntimeError: Cannot override the host object for expo module '");
23
+ message += name.utf8(runtime);
24
+ message += "'.";
25
+ throw jsi::JSError(runtime, message);
26
+ }
27
+
28
+ std::vector<jsi::PropNameID> ExpoModulesHostObject::getPropertyNames(jsi::Runtime &runtime) {
29
+ NSArray<NSString *> *moduleNames = [swiftInterop getModuleNames];
30
+ std::vector<jsi::PropNameID> propertyNames;
31
+
32
+ propertyNames.reserve([moduleNames count]);
33
+
34
+ for (NSString *moduleName in moduleNames) {
35
+ propertyNames.push_back(jsi::PropNameID::forAscii(runtime, [moduleName UTF8String]));
36
+ }
37
+ return propertyNames;
38
+ }
39
+
40
+ } // namespace expo
@@ -12,6 +12,10 @@ using namespace react;
12
12
 
13
13
  namespace expo {
14
14
 
15
+ using PromiseInvocationBlock = void (^)(RCTPromiseResolveBlock resolveWrapper, RCTPromiseRejectBlock rejectWrapper);
16
+
17
+ void callPromiseSetupWithBlock(jsi::Runtime &runtime, std::shared_ptr<CallInvoker> jsInvoker, std::shared_ptr<Promise> promise, PromiseInvocationBlock setupBlock);
18
+
15
19
  class JSI_EXPORT ExpoModulesProxySpec : public TurboModule {
16
20
  public:
17
21
  ExpoModulesProxySpec(std::shared_ptr<CallInvoker> callInvoker, EXNativeModulesProxy *nativeModulesProxy);
@@ -7,9 +7,7 @@
7
7
 
8
8
  namespace expo {
9
9
 
10
- using PromiseInvocationBlock = void (^)(RCTPromiseResolveBlock resolveWrapper, RCTPromiseRejectBlock rejectWrapper);
11
-
12
- static void callPromiseSetupWithBlock(jsi::Runtime &runtime, std::shared_ptr<CallInvoker> jsInvoker, std::shared_ptr<Promise> promise, PromiseInvocationBlock setupBlock)
10
+ void callPromiseSetupWithBlock(jsi::Runtime &runtime, std::shared_ptr<CallInvoker> jsInvoker, std::shared_ptr<Promise> promise, PromiseInvocationBlock setupBlock)
13
11
  {
14
12
  auto weakResolveWrapper = CallbackWrapper::createWeak(promise->resolve_.getFunction(runtime), runtime, jsInvoker);
15
13
  auto weakRejectWrapper = CallbackWrapper::createWeak(promise->reject_.getFunction(runtime), runtime, jsInvoker);
@@ -31,6 +31,8 @@ NSString *convertJSIStringToNSString(jsi::Runtime &runtime, const jsi::String &v
31
31
 
32
32
  NSArray *convertJSIArrayToNSArray(jsi::Runtime &runtime, const jsi::Array &value, std::shared_ptr<CallInvoker> jsInvoker);
33
33
 
34
+ NSArray *convertJSIValuesToNSArray(jsi::Runtime &runtime, const jsi::Value *values, size_t count, std::shared_ptr<CallInvoker> jsInvoker);
35
+
34
36
  NSDictionary *convertJSIObjectToNSDictionary(jsi::Runtime &runtime, const jsi::Object &value, std::shared_ptr<CallInvoker> jsInvoker);
35
37
 
36
38
  id convertJSIValueToObjCObject(jsi::Runtime &runtime, const jsi::Value &value, std::shared_ptr<CallInvoker> jsInvoker);
@@ -86,6 +86,15 @@ NSArray *convertJSIArrayToNSArray(jsi::Runtime &runtime, const jsi::Array &value
86
86
  return [result copy];
87
87
  }
88
88
 
89
+ NSArray *convertJSIValuesToNSArray(jsi::Runtime &runtime, const jsi::Value *values, size_t count, std::shared_ptr<CallInvoker> jsInvoker)
90
+ {
91
+ NSMutableArray *result = [NSMutableArray arrayWithCapacity:count];
92
+ for (int i = 0; i < count; i++) {
93
+ result[i] = convertJSIValueToObjCObject(runtime, values[i], jsInvoker);
94
+ }
95
+ return result;
96
+ }
97
+
89
98
  NSDictionary *convertJSIObjectToNSDictionary(jsi::Runtime &runtime, const jsi::Object &value, std::shared_ptr<CallInvoker> jsInvoker)
90
99
  {
91
100
  jsi::Array propertyNames = value.getPropertyNames(runtime);
@@ -17,3 +17,13 @@ void installRuntimeObjects(jsi::Runtime &runtime, std::shared_ptr<CallInvoker> c
17
17
  } // namespace expo
18
18
 
19
19
  #endif
20
+
21
+ #import <ExpoModulesCore/JavaScriptRuntime.h>
22
+
23
+ @class SwiftInteropBridge;
24
+
25
+ @interface JavaScriptRuntimeManager : NSObject
26
+
27
+ + (void)installExpoModulesToRuntime:(nonnull JavaScriptRuntime *)runtime withSwiftInterop:(nonnull SwiftInteropBridge *)swiftInterop;
28
+
29
+ @end
@@ -2,12 +2,12 @@
2
2
 
3
3
  #import <ExpoModulesCore/JSIInstaller.h>
4
4
  #import <ExpoModulesCore/ExpoModulesProxySpec.h>
5
+ #import <ExpoModulesCore/ExpoModulesHostObject.h>
6
+ #import <ExpoModulesCore/Swift.h>
5
7
 
6
8
  using namespace facebook;
7
9
  using namespace react;
8
10
 
9
- //using PromiseInvocationBlock = void (^)(RCTPromiseResolveBlock resolveWrapper, RCTPromiseRejectBlock rejectWrapper);
10
-
11
11
  namespace expo {
12
12
 
13
13
  void installRuntimeObjects(jsi::Runtime &runtime, std::shared_ptr<CallInvoker> callInvoker, EXNativeModulesProxy *nativeModulesProxy)
@@ -20,3 +20,15 @@ void installRuntimeObjects(jsi::Runtime &runtime, std::shared_ptr<CallInvoker> c
20
20
  }
21
21
 
22
22
  } // namespace expo
23
+
24
+ @implementation JavaScriptRuntimeManager
25
+
26
+ + (void)installExpoModulesToRuntime:(nonnull JavaScriptRuntime *)runtime withSwiftInterop:(nonnull SwiftInteropBridge *)swiftInterop
27
+ {
28
+ std::shared_ptr<expo::ExpoModulesHostObject> hostObjectPtr = std::make_shared<expo::ExpoModulesHostObject>(swiftInterop);
29
+ JavaScriptObject *global = [runtime global];
30
+
31
+ global[@"ExpoModules"] = [runtime createHostObject:hostObjectPtr];
32
+ }
33
+
34
+ @end
@@ -0,0 +1,60 @@
1
+ // Copyright 2022-present 650 Industries. All rights reserved.
2
+
3
+ #import <Foundation/Foundation.h>
4
+ #import <React/RCTBridgeModule.h>
5
+
6
+ #ifdef __cplusplus
7
+ #import <jsi/jsi.h>
8
+ #import <ReactCommon/CallInvoker.h>
9
+
10
+ namespace jsi = facebook::jsi;
11
+ #endif // __cplusplus
12
+
13
+ typedef void (^JSAsyncFunctionBlock)(NSArray * _Nonnull, RCTPromiseResolveBlock _Nonnull, RCTPromiseRejectBlock _Nonnull);
14
+ typedef id _Nullable (^JSSyncFunctionBlock)(NSArray * _Nonnull);
15
+
16
+ @class JavaScriptRuntime;
17
+
18
+ @interface JavaScriptObject : NSObject
19
+
20
+ // Some parts of the interface must be hidden for Swift – it can't import any C++ code.
21
+ #ifdef __cplusplus
22
+ - (nonnull instancetype)initWith:(std::shared_ptr<jsi::Object>)jsObjectPtr
23
+ runtime:(nonnull JavaScriptRuntime *)runtime;
24
+
25
+ /**
26
+ Returns the pointer to the underlying object.
27
+ */
28
+ - (nonnull jsi::Object *)get;
29
+ #endif // __cplusplus
30
+
31
+ #pragma mark - Subscripting
32
+
33
+ /**
34
+ Subscript getter. Supports only values convertible to Foundation types, otherwise `nil` is returned.
35
+ */
36
+ - (nullable id)objectForKeyedSubscript:(nonnull NSString *)key;
37
+
38
+ /**
39
+ Subscript setter. Only `JavaScriptObject` and Foundation object convertible to JSI values can be used as a value,
40
+ otherwise the property is set to `undefined`.
41
+ */
42
+ - (void)setObject:(nullable id)obj forKeyedSubscript:(nonnull NSString *)key;
43
+
44
+ #pragma mark - Functions
45
+
46
+ /**
47
+ Sets given function block on the object as a host function returning a promise.
48
+ */
49
+ - (void)setAsyncFunction:(nonnull NSString *)key
50
+ argsCount:(NSInteger)argsCount
51
+ block:(nonnull JSAsyncFunctionBlock)block;
52
+
53
+ /**
54
+ Sets given synchronous function block as a host function on the object.
55
+ */
56
+ - (void)setSyncFunction:(nonnull NSString *)name
57
+ argsCount:(NSInteger)argsCount
58
+ block:(nonnull JSSyncFunctionBlock)block;
59
+
60
+ @end