expo-modules-core 0.7.0 → 0.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (129) hide show
  1. package/CHANGELOG.md +49 -0
  2. package/README.md +1 -1
  3. package/android/ExpoModulesCorePlugin.gradle +15 -0
  4. package/android/build.gradle +46 -32
  5. package/android/src/main/java/expo/modules/adapters/react/NativeModulesProxy.java +5 -5
  6. package/android/src/main/java/expo/modules/adapters/react/services/UIManagerModuleWrapper.java +13 -0
  7. package/android/src/main/java/expo/modules/core/ViewManager.java +9 -0
  8. package/android/src/main/java/expo/modules/core/interfaces/JavaScriptContextProvider.java +4 -0
  9. package/android/src/main/java/expo/modules/core/interfaces/ReactActivityHandler.java +37 -1
  10. package/android/src/main/java/expo/modules/core/interfaces/ReactNativeHostHandler.java +30 -0
  11. package/android/src/main/java/expo/modules/core/interfaces/services/UIManager.java +2 -0
  12. package/android/src/main/java/expo/modules/kotlin/AppContext.kt +13 -5
  13. package/android/src/main/java/expo/modules/kotlin/KPromiseWrapper.kt +2 -13
  14. package/android/src/main/java/expo/modules/kotlin/KotlinInteropModuleRegistry.kt +11 -5
  15. package/android/src/main/java/expo/modules/kotlin/ModuleHolder.kt +5 -1
  16. package/android/src/main/java/expo/modules/kotlin/ModuleRegistry.kt +17 -0
  17. package/android/src/main/java/expo/modules/kotlin/callbacks/ViewCallback.kt +14 -3
  18. package/android/src/main/java/expo/modules/kotlin/events/EventEmitter.kt +13 -0
  19. package/android/src/main/java/expo/modules/kotlin/events/KModuleEventEmitterWrapper.kt +102 -0
  20. package/android/src/main/java/expo/modules/kotlin/exception/CodedException.kt +25 -1
  21. package/android/src/main/java/expo/modules/kotlin/{methods/AnyMethod.kt → functions/AnyFunction.kt} +6 -5
  22. package/android/src/main/java/expo/modules/kotlin/functions/AsyncFunction.kt +15 -0
  23. package/android/src/main/java/expo/modules/kotlin/functions/AsyncFunctionBuilder.kt +170 -0
  24. package/android/src/main/java/expo/modules/kotlin/functions/AsyncFunctionWithPromise.kt +15 -0
  25. package/android/src/main/java/expo/modules/kotlin/functions/AsyncSuspendFunction.kt +36 -0
  26. package/android/src/main/java/expo/modules/kotlin/modules/Module.kt +14 -0
  27. package/android/src/main/java/expo/modules/kotlin/modules/ModuleDefinitionBuilder.kt +374 -41
  28. package/android/src/main/java/expo/modules/kotlin/modules/ModuleDefinitionData.kt +2 -2
  29. package/android/src/main/java/expo/modules/kotlin/records/FieldValidator.kt +139 -0
  30. package/android/src/main/java/expo/modules/kotlin/records/Record.kt +0 -39
  31. package/android/src/main/java/expo/modules/kotlin/records/RecordTypeConverter.kt +59 -10
  32. package/android/src/main/java/expo/modules/kotlin/records/Required.kt +5 -0
  33. package/android/src/main/java/expo/modules/kotlin/records/ValidationBinder.kt +110 -0
  34. package/android/src/main/java/expo/modules/kotlin/records/Validators.kt +61 -0
  35. package/android/src/main/java/expo/modules/kotlin/types/JSTypeConverter.kt +35 -0
  36. package/android/src/main/java/expo/modules/kotlin/types/JSTypeConverterHelper.kt +148 -0
  37. package/android/src/main/java/expo/modules/kotlin/types/TypeConverterProvider.kt +9 -1
  38. package/android/src/main/java/expo/modules/kotlin/views/GroupViewManagerWrapper.kt +49 -0
  39. package/android/src/main/java/expo/modules/kotlin/views/ViewGroupDefinition.kt +18 -0
  40. package/android/src/main/java/expo/modules/kotlin/views/ViewGroupDefinitionBuilder.kt +114 -0
  41. package/android/src/main/java/expo/modules/kotlin/views/ViewManagerDefinition.kt +4 -1
  42. package/android/src/main/java/expo/modules/kotlin/views/ViewManagerDefinitionBuilder.kt +56 -5
  43. package/android/src/main/java/expo/modules/kotlin/views/ViewManagerWrapperDelegate.kt +3 -0
  44. package/build/NativeModulesProxy.native.d.ts +0 -4
  45. package/build/NativeModulesProxy.native.d.ts.map +1 -1
  46. package/build/NativeModulesProxy.native.js +1 -14
  47. package/build/NativeModulesProxy.native.js.map +1 -1
  48. package/build/NativeModulesProxy.types.d.ts +0 -3
  49. package/build/NativeModulesProxy.types.d.ts.map +1 -1
  50. package/build/NativeModulesProxy.types.js.map +1 -1
  51. package/build/NativeViewManagerAdapter.native.d.ts.map +1 -1
  52. package/build/NativeViewManagerAdapter.native.js +9 -33
  53. package/build/NativeViewManagerAdapter.native.js.map +1 -1
  54. package/build/sweet/NativeErrorManager.js +1 -1
  55. package/build/sweet/NativeErrorManager.js.map +1 -1
  56. package/ios/AppDelegates/EXAppDelegatesLoader.m +4 -8
  57. package/ios/AppDelegates/ExpoAppDelegate.swift +4 -10
  58. package/ios/EXAppDefines.h +1 -0
  59. package/ios/EXAppDefines.m +6 -0
  60. package/ios/EXUtilities.h +2 -0
  61. package/ios/EXUtilities.m +12 -0
  62. package/ios/ExpoModulesCore.h +4 -0
  63. package/ios/ExpoModulesCore.podspec +4 -2
  64. package/ios/Interfaces/FileSystem/EXFileSystemInterface.h +1 -1
  65. package/ios/Interfaces/TaskManager/EXTaskServiceInterface.h +1 -0
  66. package/ios/JSI/{JSIConversions.h → EXJSIConversions.h} +4 -1
  67. package/ios/JSI/{JSIConversions.mm → EXJSIConversions.mm} +16 -5
  68. package/ios/JSI/{JSIInstaller.h → EXJSIInstaller.h} +3 -3
  69. package/ios/JSI/EXJSIInstaller.mm +17 -0
  70. package/ios/JSI/{ExpoModulesProxySpec.h → EXJSIUtils.h} +0 -9
  71. package/ios/JSI/{ExpoModulesProxySpec.mm → EXJSIUtils.mm} +4 -48
  72. package/ios/JSI/EXJavaScriptObject.h +97 -0
  73. package/ios/JSI/EXJavaScriptObject.mm +121 -0
  74. package/ios/JSI/{JavaScriptRuntime.h → EXJavaScriptRuntime.h} +27 -8
  75. package/ios/JSI/EXJavaScriptRuntime.mm +153 -0
  76. package/ios/JSI/EXJavaScriptValue.h +57 -0
  77. package/ios/JSI/EXJavaScriptValue.mm +166 -0
  78. package/ios/JSI/ExpoModulesHostObject.mm +2 -1
  79. package/ios/JSI/JavaScriptRuntime.swift +32 -0
  80. package/ios/JSI/JavaScriptValue.swift +94 -0
  81. package/ios/ModuleRegistryAdapter/EXModuleRegistryAdapter.m +1 -11
  82. package/ios/NativeModulesProxy/EXNativeModulesProxy.h +2 -2
  83. package/ios/NativeModulesProxy/EXNativeModulesProxy.mm +24 -22
  84. package/ios/ReactDelegates/EXReactCompatibleHelpers.h +18 -0
  85. package/ios/ReactDelegates/EXReactCompatibleHelpers.m +19 -0
  86. package/ios/ReactDelegates/ExpoReactDelegate.swift +2 -2
  87. package/ios/ReactDelegates/ExpoReactDelegateHandler.swift +1 -1
  88. package/ios/Swift/AppContext.swift +21 -2
  89. package/ios/Swift/Arguments/AnyArgumentType.swift +1 -1
  90. package/ios/Swift/Functions/AnyFunction.swift +5 -0
  91. package/ios/Swift/Functions/AsyncFunctionComponent.swift +182 -0
  92. package/ios/Swift/Functions/ConcreteFunction.swift +40 -68
  93. package/ios/Swift/Functions/SyncFunctionComponent.swift +181 -0
  94. package/ios/Swift/JavaScriptUtils.swift +56 -0
  95. package/ios/Swift/ModuleHolder.swift +17 -5
  96. package/ios/Swift/Modules/ModuleDefinitionComponents.swift +66 -44
  97. package/ios/Swift/ModulesProvider.swift +3 -10
  98. package/ios/Swift/Objects/ObjectDefinitionComponents.swift +49 -0
  99. package/ios/Swift/SwiftInteropBridge.swift +14 -5
  100. package/ios/Swift/Views/ComponentData.swift +2 -1
  101. package/ios/Swift/Views/ExpoView.swift +8 -0
  102. package/ios/Swift/Views/ViewManagerDefinitionComponents.swift +23 -0
  103. package/ios/Swift.h +5 -0
  104. package/ios/Tests/ArgumentTypeSpec.swift +2 -3
  105. package/ios/Tests/ConstantsSpec.swift +6 -7
  106. package/ios/Tests/ConvertiblesSpec.swift +2 -3
  107. package/ios/Tests/ExceptionsSpec.swift +2 -3
  108. package/ios/Tests/ExpoModulesSpec.swift +75 -0
  109. package/ios/Tests/FunctionSpec.swift +13 -15
  110. package/ios/Tests/FunctionWithConvertiblesSpec.swift +4 -5
  111. package/ios/Tests/JavaScriptObjectSpec.swift +97 -0
  112. package/ios/Tests/JavaScriptRuntimeSpec.swift +94 -0
  113. package/ios/Tests/ModuleEventListenersSpec.swift +15 -16
  114. package/ios/Tests/ModuleRegistrySpec.swift +2 -3
  115. package/ios/Tests/RecordSpec.swift +2 -3
  116. package/package.json +2 -2
  117. package/src/NativeModulesProxy.native.ts +2 -22
  118. package/src/NativeModulesProxy.types.ts +0 -8
  119. package/src/NativeViewManagerAdapter.native.tsx +12 -28
  120. package/src/sweet/NativeErrorManager.ts +1 -1
  121. package/android/src/main/java/expo/modules/kotlin/events/KEventEmitterWrapper.kt +0 -26
  122. package/android/src/main/java/expo/modules/kotlin/methods/Method.kt +0 -14
  123. package/android/src/main/java/expo/modules/kotlin/methods/PromiseMethod.kt +0 -15
  124. package/ios/JSI/JSIInstaller.mm +0 -34
  125. package/ios/JSI/JavaScriptObject.h +0 -60
  126. package/ios/JSI/JavaScriptObject.mm +0 -93
  127. package/ios/JSI/JavaScriptRuntime.mm +0 -102
  128. package/ios/NativeModulesProxy/EXComponentDataCompatibleWrapper.h +0 -16
  129. package/ios/NativeModulesProxy/EXComponentDataCompatibleWrapper.m +0 -28
@@ -7,6 +7,7 @@ import com.facebook.react.common.MapBuilder
7
7
  import com.facebook.react.uimanager.ThemedReactContext
8
8
  import com.facebook.react.uimanager.ViewGroupManager
9
9
  import com.facebook.react.uimanager.annotations.ReactProp
10
+ import expo.modules.core.utilities.ifNull
10
11
 
11
12
  class GroupViewManagerWrapper(
12
13
  override val viewWrapperDelegate: ViewManagerWrapperDelegate
@@ -41,4 +42,52 @@ class GroupViewManagerWrapper(
41
42
 
42
43
  return super.getExportedCustomDirectEventTypeConstants()
43
44
  }
45
+
46
+ override fun addView(parent: ViewGroup, child: View, index: Int) {
47
+ viewWrapperDelegate
48
+ .viewGroupDefinition
49
+ ?.addViewAction
50
+ ?.invoke(parent, child, index)
51
+ .ifNull {
52
+ super.addView(parent, child, index)
53
+ }
54
+ }
55
+
56
+ override fun getChildCount(parent: ViewGroup): Int {
57
+ return viewWrapperDelegate.viewGroupDefinition
58
+ ?.getChildCountAction
59
+ ?.invoke(parent)
60
+ .ifNull {
61
+ super.getChildCount(parent)
62
+ }
63
+ }
64
+
65
+ override fun getChildAt(parent: ViewGroup, index: Int): View? {
66
+ viewWrapperDelegate.viewGroupDefinition
67
+ ?.getChildAtAction
68
+ ?.let {
69
+ return it.invoke(parent, index)
70
+ }
71
+ .ifNull {
72
+ return super.getChildAt(parent, index)
73
+ }
74
+ }
75
+
76
+ override fun removeViewAt(parent: ViewGroup, index: Int) {
77
+ viewWrapperDelegate.viewGroupDefinition
78
+ ?.removeViewAtAction
79
+ ?.invoke(parent, index)
80
+ .ifNull {
81
+ super.removeViewAt(parent, index)
82
+ }
83
+ }
84
+
85
+ override fun removeView(parent: ViewGroup, view: View) {
86
+ viewWrapperDelegate.viewGroupDefinition
87
+ ?.removeViewAction
88
+ ?.invoke(parent, view)
89
+ .ifNull {
90
+ super.removeView(parent, view)
91
+ }
92
+ }
44
93
  }
@@ -0,0 +1,18 @@
1
+ package expo.modules.kotlin.views
2
+
3
+ import android.view.View
4
+ import android.view.ViewGroup
5
+
6
+ class ViewGroupDefinition(
7
+ val addViewAction: AddViewAction?,
8
+ val getChildAtAction: GetChildAtAction?,
9
+ val getChildCountAction: GetChildCountAction?,
10
+ val removeViewAction: RemoveViewAction?,
11
+ val removeViewAtAction: RemoveViewAtAction?
12
+ )
13
+
14
+ internal typealias AddViewAction = (parent: ViewGroup, child: View, index: Int) -> Unit
15
+ internal typealias GetChildAtAction = (parent: ViewGroup, index: Int) -> View?
16
+ internal typealias GetChildCountAction = (parent: ViewGroup) -> Int
17
+ internal typealias RemoveViewAction = (parent: ViewGroup, childToRemove: View) -> Unit
18
+ internal typealias RemoveViewAtAction = (parent: ViewGroup, index: Int) -> Unit
@@ -0,0 +1,114 @@
1
+ @file:OptIn(ExperimentalStdlibApi::class)
2
+ @file:Suppress("FunctionName")
3
+
4
+ package expo.modules.kotlin.views
5
+
6
+ import android.view.View
7
+ import android.view.ViewGroup
8
+ import expo.modules.kotlin.modules.DefinitionMarker
9
+
10
+ @DefinitionMarker
11
+ class ViewGroupDefinitionBuilder {
12
+ @PublishedApi
13
+ internal var addViewAction: AddViewAction? = null
14
+
15
+ @PublishedApi
16
+ internal var getChildAtAction: GetChildAtAction? = null
17
+
18
+ @PublishedApi
19
+ internal var getChildCountAction: GetChildCountAction? = null
20
+
21
+ @PublishedApi
22
+ internal var removeViewAction: RemoveViewAction? = null
23
+
24
+ @PublishedApi
25
+ internal var removeViewAtAction: RemoveViewAtAction? = null
26
+
27
+ fun build() = ViewGroupDefinition(
28
+ addViewAction,
29
+ getChildAtAction,
30
+ getChildCountAction,
31
+ removeViewAction,
32
+ removeViewAtAction
33
+ )
34
+
35
+ @Deprecated(
36
+ message = "The 'addChildView' component was renamed to 'AddChildView'.",
37
+ replaceWith = ReplaceWith("AddChildView(body)")
38
+ )
39
+ inline fun <reified ParentViewType : ViewGroup, reified ChildViewType : View> addChildView(
40
+ noinline body: (parent: ParentViewType, child: ChildViewType, index: Int) -> Unit
41
+ ) = AddChildView(body)
42
+
43
+ inline fun <reified ParentViewType : ViewGroup, reified ChildViewType : View> AddChildView(
44
+ noinline body: (parent: ParentViewType, child: ChildViewType, index: Int) -> Unit
45
+ ) {
46
+ addViewAction = { parent, child, index ->
47
+ body(parent as ParentViewType, child as ChildViewType, index)
48
+ }
49
+ }
50
+
51
+ @Deprecated(
52
+ message = "The 'getChildCount' component was renamed to 'GetChildCount'.",
53
+ replaceWith = ReplaceWith("GetChildCount(body)")
54
+ )
55
+ inline fun <reified ParentViewType : ViewGroup> getChildCount(
56
+ noinline body: (view: ParentViewType) -> Int
57
+ ) = GetChildCount(body)
58
+
59
+ inline fun <reified ParentViewType : ViewGroup> GetChildCount(
60
+ noinline body: (view: ParentViewType) -> Int
61
+ ) {
62
+ getChildCountAction = { view ->
63
+ body(view as ParentViewType)
64
+ }
65
+ }
66
+
67
+ @Deprecated(
68
+ message = "The 'getChildViewAt' component was renamed to 'GetChildViewAt'.",
69
+ replaceWith = ReplaceWith("GetChildViewAt(body)")
70
+ )
71
+ inline fun <reified ParentViewType : ViewGroup, reified ChildViewType : View> getChildViewAt(
72
+ noinline body: (view: ParentViewType, index: Int) -> ChildViewType?
73
+ ) = GetChildViewAt(body)
74
+
75
+ inline fun <reified ParentViewType : ViewGroup, reified ChildViewType : View> GetChildViewAt(
76
+ noinline body: (view: ParentViewType, index: Int) -> ChildViewType?
77
+ ) {
78
+ getChildAtAction = { view, index ->
79
+ body(view as ParentViewType, index)
80
+ }
81
+ }
82
+
83
+ @Deprecated(
84
+ message = "The 'removeChildViewAt' component was renamed to 'RemoveChildViewAt'.",
85
+ replaceWith = ReplaceWith("RemoveChildViewAt(body)")
86
+ )
87
+ inline fun <reified ParentViewType : ViewGroup> removeChildViewAt(
88
+ noinline body: (view: ParentViewType, index: Int) -> Unit
89
+ ) = RemoveChildViewAt(body)
90
+
91
+ inline fun <reified ParentViewType : ViewGroup> RemoveChildViewAt(
92
+ noinline body: (view: ParentViewType, index: Int) -> Unit
93
+ ) {
94
+ removeViewAtAction = { view, index ->
95
+ body(view as ParentViewType, index)
96
+ }
97
+ }
98
+
99
+ @Deprecated(
100
+ message = "The 'removeChildView' component was renamed to 'RemoveChildView'.",
101
+ replaceWith = ReplaceWith("RemoveChildView(body)")
102
+ )
103
+ inline fun <reified ParentViewType : ViewGroup, reified ChildViewType : View> removeChildView(
104
+ noinline body: (parent: ParentViewType, child: ChildViewType) -> Unit
105
+ ) = RemoveChildView(body)
106
+
107
+ inline fun <reified ParentViewType : ViewGroup, reified ChildViewType : View> RemoveChildView(
108
+ noinline body: (parent: ParentViewType, child: ChildViewType) -> Unit
109
+ ) {
110
+ removeViewAction = { view, child ->
111
+ body(view as ParentViewType, child as ChildViewType)
112
+ }
113
+ }
114
+ }
@@ -17,11 +17,14 @@ class ViewManagerDefinition(
17
17
  private val viewType: Class<out View>,
18
18
  private val props: Map<String, AnyViewProp>,
19
19
  val onViewDestroys: ((View) -> Unit)? = null,
20
- val callbacksDefinition: CallbacksDefinition? = null
20
+ val callbacksDefinition: CallbacksDefinition? = null,
21
+ val viewGroupDefinition: ViewGroupDefinition? = null
21
22
  ) {
22
23
 
23
24
  fun createView(context: Context): View = viewFactory(context)
24
25
 
26
+ val propsNames: List<String> = props.keys.toList()
27
+
25
28
  fun getViewManagerType(): ViewManager.ViewManagerType {
26
29
  return if (ViewGroup::class.java.isAssignableFrom(viewType)) {
27
30
  ViewManager.ViewManagerType.GROUP
@@ -1,4 +1,5 @@
1
1
  @file:OptIn(ExperimentalStdlibApi::class)
2
+ @file:Suppress("FunctionName")
2
3
 
3
4
  package expo.modules.kotlin.views
4
5
 
@@ -12,13 +13,18 @@ import kotlin.reflect.typeOf
12
13
  class ViewManagerDefinitionBuilder {
13
14
  @PublishedApi
14
15
  internal var viewFactory: ((Context) -> View)? = null
16
+
15
17
  @PublishedApi
16
18
  internal var viewType: Class<out View>? = null
19
+
17
20
  @PublishedApi
18
21
  internal var props = mutableMapOf<String, AnyViewProp>()
22
+
19
23
  @PublishedApi
20
24
  internal var onViewDestroys: ((View) -> Unit)? = null
21
25
 
26
+ @PublishedApi
27
+ internal var viewGroupDefinition: ViewGroupDefinition? = null
22
28
  private var callbacksDefinition: CallbacksDefinition? = null
23
29
 
24
30
  fun build(): ViewManagerDefinition =
@@ -27,28 +33,50 @@ class ViewManagerDefinitionBuilder {
27
33
  requireNotNull(viewType),
28
34
  props,
29
35
  onViewDestroys,
30
- callbacksDefinition
36
+ callbacksDefinition,
37
+ viewGroupDefinition
31
38
  )
32
39
 
40
+ @Deprecated(
41
+ message = "The 'view' component was renamed to 'View'.",
42
+ replaceWith = ReplaceWith("View(body)")
43
+ )
44
+ inline fun <reified ViewType : View> view(noinline body: (Context) -> ViewType) = View(body)
45
+
33
46
  /**
34
47
  * Defines the factory creating a native view when the module is used as a view.
35
48
  */
36
- inline fun <reified ViewType : View> view(noinline body: (Context) -> ViewType) {
49
+ inline fun <reified ViewType : View> View(noinline body: (Context) -> ViewType) {
37
50
  viewType = ViewType::class.java
38
51
  viewFactory = body
39
52
  }
40
53
 
54
+ @Deprecated(
55
+ message = "The 'onViewDestroys' component was renamed to 'OnViewDestroys'.",
56
+ replaceWith = ReplaceWith("OnViewDestroys(body)")
57
+ )
58
+ inline fun <reified ViewType : View> onViewDestroys(noinline body: (view: ViewType) -> Unit) = OnViewDestroys(body)
59
+
41
60
  /**
42
61
  * Creates view's lifecycle listener that is called right after the view isn't longer used by React Native.
43
62
  */
44
- inline fun <reified ViewType : View> onViewDestroys(noinline body: (view: ViewType) -> Unit) {
63
+ inline fun <reified ViewType : View> OnViewDestroys(noinline body: (view: ViewType) -> Unit) {
45
64
  onViewDestroys = { body(it as ViewType) }
46
65
  }
47
66
 
67
+ @Deprecated(
68
+ message = "The 'prop' component was renamed to 'Prop'.",
69
+ replaceWith = ReplaceWith("Prop(body)")
70
+ )
71
+ inline fun <reified ViewType : View, reified PropType> prop(
72
+ name: String,
73
+ noinline body: (view: ViewType, prop: PropType) -> Unit
74
+ ) = Prop(name, body)
75
+
48
76
  /**
49
77
  * Creates a view prop that defines its name and setter.
50
78
  */
51
- inline fun <reified ViewType : View, reified PropType> prop(
79
+ inline fun <reified ViewType : View, reified PropType> Prop(
52
80
  name: String,
53
81
  noinline body: (view: ViewType, prop: PropType) -> Unit
54
82
  ) {
@@ -59,10 +87,33 @@ class ViewManagerDefinitionBuilder {
59
87
  )
60
88
  }
61
89
 
90
+ @Deprecated(
91
+ message = "The 'events' component was renamed to 'Events'.",
92
+ replaceWith = ReplaceWith("Events(callbacks)")
93
+ )
94
+ fun events(vararg callbacks: String) = Events(*callbacks)
95
+
62
96
  /**
63
97
  * Defines prop names that should be treated as callbacks.
64
98
  */
65
- fun events(vararg callbacks: String) {
99
+ fun Events(vararg callbacks: String) {
66
100
  callbacksDefinition = CallbacksDefinition(callbacks)
67
101
  }
102
+
103
+ @Deprecated(
104
+ message = "The 'groupView' component was renamed to 'GroupView'.",
105
+ replaceWith = ReplaceWith("GroupView(callbacks)")
106
+ )
107
+ inline fun groupView(body: ViewGroupDefinitionBuilder.() -> Unit) = GroupView(body)
108
+
109
+ /**
110
+ * Creates the group view definition that scopes group view-related definitions.
111
+ */
112
+ inline fun GroupView(body: ViewGroupDefinitionBuilder.() -> Unit) {
113
+ require(viewGroupDefinition == null) { "The viewManager definition may have exported only one groupView definition." }
114
+
115
+ val groupViewDefinitionBuilder = ViewGroupDefinitionBuilder()
116
+ body.invoke(groupViewDefinitionBuilder)
117
+ viewGroupDefinition = groupViewDefinitionBuilder.build()
118
+ }
68
119
  }
@@ -15,6 +15,9 @@ class ViewManagerWrapperDelegate(internal var moduleHolder: ModuleHolder) {
15
15
  private val definition: ViewManagerDefinition
16
16
  get() = requireNotNull(moduleHolder.definition.viewManagerDefinition)
17
17
 
18
+ internal val viewGroupDefinition: ViewGroupDefinition?
19
+ get() = definition.viewGroupDefinition
20
+
18
21
  val name: String
19
22
  get() = moduleHolder.name
20
23
 
@@ -2,9 +2,5 @@ import { ProxyNativeModule } from './NativeModulesProxy.types';
2
2
  declare const NativeModulesProxy: {
3
3
  [moduleName: string]: ProxyNativeModule;
4
4
  };
5
- /**
6
- * Sets whether to use a TurboModule version of the proxy.
7
- */
8
- export declare function useExpoTurboModules(state?: boolean): void;
9
5
  export default NativeModulesProxy;
10
6
  //# sourceMappingURL=NativeModulesProxy.native.d.ts.map
@@ -1 +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"}
1
+ {"version":3,"file":"NativeModulesProxy.native.d.ts","sourceRoot":"","sources":["../src/NativeModulesProxy.native.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAM/D,QAAA,MAAM,kBAAkB,EAAE;IAAE,CAAC,UAAU,EAAE,MAAM,GAAG,iBAAiB,CAAA;CAAO,CAAC;AAkD3E,eAAe,kBAAkB,CAAC"}
@@ -3,14 +3,6 @@ const NativeProxy = NativeModules.NativeUnimoduleProxy;
3
3
  const modulesConstantsKey = 'modulesConstants';
4
4
  const exportedMethodsKey = 'exportedMethods';
5
5
  const NativeModulesProxy = {};
6
- // Keep it opt-in for now. It's too risky without proper and thorough testing.
7
- let canUseExpoTurboModules = false;
8
- /**
9
- * Sets whether to use a TurboModule version of the proxy.
10
- */
11
- export function useExpoTurboModules(state = true) {
12
- canUseExpoTurboModules = state;
13
- }
14
6
  if (NativeProxy) {
15
7
  Object.keys(NativeProxy[exportedMethodsKey]).forEach((moduleName) => {
16
8
  NativeModulesProxy[moduleName] = NativeProxy[modulesConstantsKey][moduleName] || {};
@@ -20,12 +12,7 @@ if (NativeProxy) {
20
12
  if (argumentsCount !== args.length) {
21
13
  return Promise.reject(new Error(`Native method ${moduleName}.${methodInfo.name} expects ${argumentsCount} ${argumentsCount === 1 ? 'argument' : 'arguments'} but received ${args.length}`));
22
14
  }
23
- if (canUseExpoTurboModules && global.ExpoModulesProxy) {
24
- return global.ExpoModulesProxy.callMethodAsync(moduleName, methodInfo.name, args);
25
- }
26
- else {
27
- return NativeProxy.callMethod(moduleName, key, args);
28
- }
15
+ return NativeProxy.callMethod(moduleName, key, args);
29
16
  };
30
17
  });
31
18
  // These are called by EventEmitter (which is a wrapper for NativeEventEmitter)
@@ -1 +1 @@
1
- {"version":3,"file":"NativeModulesProxy.native.js","sourceRoot":"","sources":["../src/NativeModulesProxy.native.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAS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AAE,IAAI,CAAC,CAAC;iBACnF;qBAAM;oBACL,OAAO,WAAW,CAAC,UAAU,CAAC,UAAU,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;iBACtD;YACH,CAAC,CAAC;QACJ,CAAC,CAAC,CAAC;QAEH,+EAA+E;QAC/E,kFAAkF;QAClF,EAAE;QACF,wEAAwE;QACxE,gDAAgD;QAChD,EAAE;QACF,6GAA6G;QAC7G,gGAAgG;QAChG,4HAA4H;QAC5H,qCAAqC;QACrC,IAAI,aAAa,CAAC,yBAAyB,EAAE;YAC3C,kBAAkB,CAAC,UAAU,CAAC,CAAC,WAAW,GAAG,CAAC,GAAG,IAAI,EAAE,EAAE,CACvD,aAAa,CAAC,yBAAyB,CAAC,kBAAkB,CAAC,UAAU,EAAE,GAAG,IAAI,CAAC,CAAC;YAClF,kBAAkB,CAAC,UAAU,CAAC,CAAC,eAAe,GAAG,CAAC,GAAG,IAAI,EAAE,EAAE,CAC3D,aAAa,CAAC,yBAAyB,CAAC,sBAAsB,CAAC,UAAU,EAAE,GAAG,IAAI,CAAC,CAAC;SACvF;aAAM;YACL,oBAAoB;YACpB,kHAAkH;YAClH,sHAAsH;YACtH,kBAAkB,CAAC,UAAU,CAAC,CAAC,WAAW,GAAG,GAAG,EAAE,GAAE,CAAC,CAAC;YACtD,kBAAkB,CAAC,UAAU,CAAC,CAAC,eAAe,GAAG,GAAG,EAAE,GAAE,CAAC,CAAC;SAC3D;IACH,CAAC,CAAC,CAAC;CACJ;KAAM;IACL,OAAO,CAAC,IAAI,CACV,gJAAgJ,CACjJ,CAAC;CACH;AAED,eAAe,kBAAkB,CAAC","sourcesContent":["import { NativeModules } from 'react-native';\n\nimport { ProxyNativeModule, TurboNativeModuleProxy } from './NativeModulesProxy.types';\n\n// `ExpoModulesProxy` is not declared in TypeScript yet. It's installed via JSI.\ndeclare namespace global {\n const ExpoModulesProxy: TurboNativeModuleProxy;\n}\n\nconst NativeProxy = NativeModules.NativeUnimoduleProxy;\nconst modulesConstantsKey = 'modulesConstants';\nconst exportedMethodsKey = 'exportedMethods';\n\nconst NativeModulesProxy: { [moduleName: string]: ProxyNativeModule } = {};\n\n// Keep it opt-in for now. It's too risky without proper and thorough testing.\nlet canUseExpoTurboModules = false;\n\n/**\n * Sets whether to use a TurboModule version of the proxy.\n */\nexport function useExpoTurboModules(state: boolean = true) {\n canUseExpoTurboModules = state;\n}\n\nif (NativeProxy) {\n Object.keys(NativeProxy[exportedMethodsKey]).forEach((moduleName) => {\n NativeModulesProxy[moduleName] = NativeProxy[modulesConstantsKey][moduleName] || {};\n NativeProxy[exportedMethodsKey][moduleName].forEach((methodInfo) => {\n NativeModulesProxy[moduleName][methodInfo.name] = (...args: unknown[]): Promise<any> => {\n const { key, argumentsCount } = methodInfo;\n if (argumentsCount !== args.length) {\n return Promise.reject(\n new Error(\n `Native method ${moduleName}.${methodInfo.name} expects ${argumentsCount} ${\n argumentsCount === 1 ? 'argument' : 'arguments'\n } but received ${args.length}`\n )\n );\n }\n\n if (canUseExpoTurboModules && global.ExpoModulesProxy) {\n return global.ExpoModulesProxy.callMethodAsync(moduleName, methodInfo.name, args);\n } else {\n return NativeProxy.callMethod(moduleName, key, args);\n }\n };\n });\n\n // These are called by EventEmitter (which is a wrapper for NativeEventEmitter)\n // only on iOS and they use iOS-specific native module, EXReactNativeEventEmitter.\n //\n // On Android only {start,stop}Observing are called on the native module\n // and these should be exported as Expo methods.\n //\n // Before the RN 65, addListener/removeListeners weren't called on Android. However, it no longer stays true.\n // See https://github.com/facebook/react-native/commit/f5502fbda9fe271ff6e1d0da773a3a8ee206a453.\n // That's why, we check if the `EXReactNativeEventEmitter` exists and only if yes, we use it in the listener implementation.\n // Otherwise, those methods are NOOP.\n if (NativeModules.EXReactNativeEventEmitter) {\n NativeModulesProxy[moduleName].addListener = (...args) =>\n NativeModules.EXReactNativeEventEmitter.addProxiedListener(moduleName, ...args);\n NativeModulesProxy[moduleName].removeListeners = (...args) =>\n NativeModules.EXReactNativeEventEmitter.removeProxiedListeners(moduleName, ...args);\n } else {\n // Fixes on Android:\n // WARN `new NativeEventEmitter()` was called with a non-null argument without the required `addListener` method.\n // WARN `new NativeEventEmitter()` was called with a non-null argument without the required `removeListeners` method.\n NativeModulesProxy[moduleName].addListener = () => {};\n NativeModulesProxy[moduleName].removeListeners = () => {};\n }\n });\n} else {\n console.warn(\n `The \"EXNativeModulesProxy\" native module is not exported through NativeModules; verify that expo-modules-core's native code is linked properly`\n );\n}\n\nexport default NativeModulesProxy;\n"]}
1
+ {"version":3,"file":"NativeModulesProxy.native.js","sourceRoot":"","sources":["../src/NativeModulesProxy.native.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAI7C,MAAM,WAAW,GAAG,aAAa,CAAC,oBAAoB,CAAC;AACvD,MAAM,mBAAmB,GAAG,kBAAkB,CAAC;AAC/C,MAAM,kBAAkB,GAAG,iBAAiB,CAAC;AAE7C,MAAM,kBAAkB,GAAgD,EAAE,CAAC;AAE3E,IAAI,WAAW,EAAE;IACf,MAAM,CAAC,IAAI,CAAC,WAAW,CAAC,kBAAkB,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,UAAU,EAAE,EAAE;QAClE,kBAAkB,CAAC,UAAU,CAAC,GAAG,WAAW,CAAC,mBAAmB,CAAC,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC;QACpF,WAAW,CAAC,kBAAkB,CAAC,CAAC,UAAU,CAAC,CAAC,OAAO,CAAC,CAAC,UAAU,EAAE,EAAE;YACjE,kBAAkB,CAAC,UAAU,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,IAAe,EAAgB,EAAE;gBACrF,MAAM,EAAE,GAAG,EAAE,cAAc,EAAE,GAAG,UAAU,CAAC;gBAC3C,IAAI,cAAc,KAAK,IAAI,CAAC,MAAM,EAAE;oBAClC,OAAO,OAAO,CAAC,MAAM,CACnB,IAAI,KAAK,CACP,iBAAiB,UAAU,IAAI,UAAU,CAAC,IAAI,YAAY,cAAc,IACtE,cAAc,KAAK,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,WACtC,iBAAiB,IAAI,CAAC,MAAM,EAAE,CAC/B,CACF,CAAC;iBACH;gBACD,OAAO,WAAW,CAAC,UAAU,CAAC,UAAU,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;YACvD,CAAC,CAAC;QACJ,CAAC,CAAC,CAAC;QAEH,+EAA+E;QAC/E,kFAAkF;QAClF,EAAE;QACF,wEAAwE;QACxE,gDAAgD;QAChD,EAAE;QACF,6GAA6G;QAC7G,gGAAgG;QAChG,4HAA4H;QAC5H,qCAAqC;QACrC,IAAI,aAAa,CAAC,yBAAyB,EAAE;YAC3C,kBAAkB,CAAC,UAAU,CAAC,CAAC,WAAW,GAAG,CAAC,GAAG,IAAI,EAAE,EAAE,CACvD,aAAa,CAAC,yBAAyB,CAAC,kBAAkB,CAAC,UAAU,EAAE,GAAG,IAAI,CAAC,CAAC;YAClF,kBAAkB,CAAC,UAAU,CAAC,CAAC,eAAe,GAAG,CAAC,GAAG,IAAI,EAAE,EAAE,CAC3D,aAAa,CAAC,yBAAyB,CAAC,sBAAsB,CAAC,UAAU,EAAE,GAAG,IAAI,CAAC,CAAC;SACvF;aAAM;YACL,oBAAoB;YACpB,kHAAkH;YAClH,sHAAsH;YACtH,kBAAkB,CAAC,UAAU,CAAC,CAAC,WAAW,GAAG,GAAG,EAAE,GAAE,CAAC,CAAC;YACtD,kBAAkB,CAAC,UAAU,CAAC,CAAC,eAAe,GAAG,GAAG,EAAE,GAAE,CAAC,CAAC;SAC3D;IACH,CAAC,CAAC,CAAC;CACJ;KAAM;IACL,OAAO,CAAC,IAAI,CACV,gJAAgJ,CACjJ,CAAC;CACH;AAED,eAAe,kBAAkB,CAAC","sourcesContent":["import { NativeModules } from 'react-native';\n\nimport { ProxyNativeModule } from './NativeModulesProxy.types';\n\nconst NativeProxy = NativeModules.NativeUnimoduleProxy;\nconst modulesConstantsKey = 'modulesConstants';\nconst exportedMethodsKey = 'exportedMethods';\n\nconst NativeModulesProxy: { [moduleName: string]: ProxyNativeModule } = {};\n\nif (NativeProxy) {\n Object.keys(NativeProxy[exportedMethodsKey]).forEach((moduleName) => {\n NativeModulesProxy[moduleName] = NativeProxy[modulesConstantsKey][moduleName] || {};\n NativeProxy[exportedMethodsKey][moduleName].forEach((methodInfo) => {\n NativeModulesProxy[moduleName][methodInfo.name] = (...args: unknown[]): Promise<any> => {\n const { key, argumentsCount } = methodInfo;\n if (argumentsCount !== args.length) {\n return Promise.reject(\n new Error(\n `Native method ${moduleName}.${methodInfo.name} expects ${argumentsCount} ${\n argumentsCount === 1 ? 'argument' : 'arguments'\n } but received ${args.length}`\n )\n );\n }\n return NativeProxy.callMethod(moduleName, key, args);\n };\n });\n\n // These are called by EventEmitter (which is a wrapper for NativeEventEmitter)\n // only on iOS and they use iOS-specific native module, EXReactNativeEventEmitter.\n //\n // On Android only {start,stop}Observing are called on the native module\n // and these should be exported as Expo methods.\n //\n // Before the RN 65, addListener/removeListeners weren't called on Android. However, it no longer stays true.\n // See https://github.com/facebook/react-native/commit/f5502fbda9fe271ff6e1d0da773a3a8ee206a453.\n // That's why, we check if the `EXReactNativeEventEmitter` exists and only if yes, we use it in the listener implementation.\n // Otherwise, those methods are NOOP.\n if (NativeModules.EXReactNativeEventEmitter) {\n NativeModulesProxy[moduleName].addListener = (...args) =>\n NativeModules.EXReactNativeEventEmitter.addProxiedListener(moduleName, ...args);\n NativeModulesProxy[moduleName].removeListeners = (...args) =>\n NativeModules.EXReactNativeEventEmitter.removeProxiedListeners(moduleName, ...args);\n } else {\n // Fixes on Android:\n // WARN `new NativeEventEmitter()` was called with a non-null argument without the required `addListener` method.\n // WARN `new NativeEventEmitter()` was called with a non-null argument without the required `removeListeners` method.\n NativeModulesProxy[moduleName].addListener = () => {};\n NativeModulesProxy[moduleName].removeListeners = () => {};\n }\n });\n} else {\n console.warn(\n `The \"EXNativeModulesProxy\" native module is not exported through NativeModules; verify that expo-modules-core's native code is linked properly`\n );\n}\n\nexport default NativeModulesProxy;\n"]}
@@ -3,7 +3,4 @@ export declare type ProxyNativeModule = {
3
3
  addListener: (eventName: string) => void;
4
4
  removeListeners: (count: number) => void;
5
5
  };
6
- export declare type TurboNativeModuleProxy = {
7
- callMethodAsync: <ReturnType>(moduleName: string, methodName: string, args: any[]) => Promise<ReturnType>;
8
- };
9
6
  //# sourceMappingURL=NativeModulesProxy.types.d.ts.map
@@ -1 +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
+ {"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"}
@@ -1 +1 @@
1
- {"version":3,"file":"NativeModulesProxy.types.js","sourceRoot":"","sources":["../src/NativeModulesProxy.types.ts"],"names":[],"mappings":"","sourcesContent":["export type ProxyNativeModule = {\n [propertyName: string]: any;\n addListener: (eventName: string) => void;\n removeListeners: (count: number) => void;\n};\n\nexport type TurboNativeModuleProxy = {\n callMethodAsync: <ReturnType>(\n moduleName: string,\n methodName: string,\n args: any[]\n ) => Promise<ReturnType>;\n};\n"]}
1
+ {"version":3,"file":"NativeModulesProxy.types.js","sourceRoot":"","sources":["../src/NativeModulesProxy.types.ts"],"names":[],"mappings":"","sourcesContent":["export type ProxyNativeModule = {\n [propertyName: string]: any;\n addListener: (eventName: string) => void;\n removeListeners: (count: number) => void;\n};\n"]}
@@ -1 +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"}
1
+ {"version":3,"file":"NativeViewManagerAdapter.native.d.ts","sourceRoot":"","sources":["../src/NativeViewManagerAdapter.native.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAgB1B;;GAEG;AACH,wBAAgB,wBAAwB,CAAC,CAAC,GAAG,GAAG,EAAE,QAAQ,EAAE,MAAM,GAAG,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,CA0B1F"}
@@ -1,48 +1,24 @@
1
1
  import React from 'react';
2
- import { NativeModules, UIManager, ViewPropTypes, requireNativeComponent } from 'react-native';
3
- // To make the transition from React Native's `requireNativeComponent` to Expo's
4
- // `requireNativeViewManager` as easy as possible, `requireNativeViewManager` is a drop-in
5
- // replacement for `requireNativeComponent`.
6
- //
7
- // For each view manager, we create a wrapper component that accepts all of the props available to
8
- // the author of the universal module. This wrapper component splits the props into two sets: props
9
- // passed to React Native's View (ex: style, testID) and custom view props, which are passed to the
10
- // adapter view component in a prop called `proxiedProperties`.
11
- // NOTE: React Native is moving away from runtime PropTypes and may remove ViewPropTypes, in which
12
- // case we will need another way to separate standard React Native view props from other props,
13
- // which we proxy through the adapter
14
- const ViewPropTypesKeys = Object.keys(ViewPropTypes);
2
+ import { NativeModules, requireNativeComponent } from 'react-native';
15
3
  /**
16
4
  * A drop-in replacement for `requireNativeComponent`.
17
5
  */
18
6
  export function requireNativeViewManager(viewName) {
19
- if (__DEV__) {
20
- const { NativeUnimoduleProxy } = NativeModules;
21
- if (!NativeUnimoduleProxy.viewManagersNames.includes(viewName)) {
22
- const exportedViewManagerNames = NativeUnimoduleProxy.viewManagersNames.join(', ');
23
- console.warn(`The native view manager required by name (${viewName}) from NativeViewManagerAdapter isn't exported by expo-modules-core. Views of this type may not render correctly. Exported view managers: [${exportedViewManagerNames}].`);
24
- }
7
+ const { viewManagersMetadata } = NativeModules.NativeUnimoduleProxy;
8
+ const viewManagerConfig = viewManagersMetadata?.[viewName];
9
+ if (__DEV__ && !viewManagerConfig) {
10
+ const exportedViewManagerNames = Object.keys(viewManagersMetadata).join(', ');
11
+ console.warn(`The native view manager required by name (${viewName}) from NativeViewManagerAdapter isn't exported by expo-modules-core. Views of this type may not render correctly. Exported view managers: [${exportedViewManagerNames}].`);
25
12
  }
26
13
  // Set up the React Native native component, which is an adapter to the universal module's view
27
14
  // manager
28
15
  const reactNativeViewName = `ViewManagerAdapter_${viewName}`;
29
16
  const ReactNativeComponent = requireNativeComponent(reactNativeViewName);
30
- const reactNativeUIConfiguration = (UIManager.getViewManagerConfig
31
- ? UIManager.getViewManagerConfig(reactNativeViewName)
32
- : UIManager[reactNativeViewName]) || {
33
- NativeProps: {},
34
- directEventTypes: {},
35
- };
36
- const reactNativeComponentPropNames = [
37
- 'children',
38
- ...ViewPropTypesKeys,
39
- ...Object.keys(reactNativeUIConfiguration.NativeProps),
40
- ...Object.keys(reactNativeUIConfiguration.directEventTypes),
41
- ];
17
+ const proxiedPropsNames = viewManagerConfig?.propsNames ?? [];
42
18
  // Define a component for universal-module authors to access their native view manager
43
19
  function NativeComponentAdapter(props, ref) {
44
- const nativeProps = pick(props, reactNativeComponentPropNames);
45
- const proxiedProps = omit(props, reactNativeComponentPropNames);
20
+ const nativeProps = omit(props, proxiedPropsNames);
21
+ const proxiedProps = pick(props, proxiedPropsNames);
46
22
  return React.createElement(ReactNativeComponent, { ...nativeProps, proxiedProperties: proxiedProps, ref: ref });
47
23
  }
48
24
  NativeComponentAdapter.displayName = `Adapter<${viewName}>`;
@@ -1 +1 @@
1
- {"version":3,"file":"NativeViewManagerAdapter.native.js","sourceRoot":"","sources":["../src/NativeViewManagerAdapter.native.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,aAAa,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAE/F,gFAAgF;AAChF,0FAA0F;AAC1F,4CAA4C;AAC5C,EAAE;AACF,kGAAkG;AAClG,mGAAmG;AACnG,mGAAmG;AACnG,+DAA+D;AAE/D,kGAAkG;AAClG,+FAA+F;AAC/F,qCAAqC;AACrC,MAAM,iBAAiB,GAAG,MAAM,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;AAMrD;;GAEG;AACH,MAAM,UAAU,wBAAwB,CAAU,QAAgB;IAChE,IAAI,OAAO,EAAE;QACX,MAAM,EAAE,oBAAoB,EAAE,GAAG,aAAa,CAAC;QAC/C,IAAI,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE;YAC9D,MAAM,wBAAwB,GAAG,oBAAoB,CAAC,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;YACnF,OAAO,CAAC,IAAI,CACV,6CAA6C,QAAQ,8IAA8I,wBAAwB,IAAI,CAChO,CAAC;SACH;KACF;IAED,+FAA+F;IAC/F,UAAU;IACV,MAAM,mBAAmB,GAAG,sBAAsB,QA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AAS,CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE;QACrC,IAAI,IAAI,IAAI,KAAK,EAAE;YACjB,IAAI,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC,CAAC;SAC1B;QACD,OAAO,IAAI,CAAC;IACd,CAAC,EAAE,EAAE,CAAC,CAAC;AACT,CAAC","sourcesContent":["import React from 'react';\nimport { NativeModules, UIManager, ViewPropTypes, requireNativeComponent } from 'react-native';\n\n// To make the transition from React Native's `requireNativeComponent` to Expo's\n// `requireNativeViewManager` as easy as possible, `requireNativeViewManager` is a drop-in\n// replacement for `requireNativeComponent`.\n//\n// For each view manager, we create a wrapper component that accepts all of the props available to\n// the author of the universal module. This wrapper component splits the props into two sets: props\n// passed to React Native's View (ex: style, testID) and custom view props, which are passed to the\n// adapter view component in a prop called `proxiedProperties`.\n\n// NOTE: React Native is moving away from runtime PropTypes and may remove ViewPropTypes, in which\n// case we will need another way to separate standard React Native view props from other props,\n// which we proxy through the adapter\nconst ViewPropTypesKeys = Object.keys(ViewPropTypes);\n\ntype NativeExpoComponentProps = {\n proxiedProperties: object;\n};\n\n/**\n * A drop-in replacement for `requireNativeComponent`.\n */\nexport function requireNativeViewManager<P = any>(viewName: string): React.ComponentType<P> {\n if (__DEV__) {\n const { NativeUnimoduleProxy } = NativeModules;\n if (!NativeUnimoduleProxy.viewManagersNames.includes(viewName)) {\n const exportedViewManagerNames = NativeUnimoduleProxy.viewManagersNames.join(', ');\n console.warn(\n `The native view manager required by name (${viewName}) from NativeViewManagerAdapter isn't exported by expo-modules-core. Views of this type may not render correctly. Exported view managers: [${exportedViewManagerNames}].`\n );\n }\n }\n\n // Set up the React Native native component, which is an adapter to the universal module's view\n // manager\n const reactNativeViewName = `ViewManagerAdapter_${viewName}`;\n const ReactNativeComponent =\n requireNativeComponent<NativeExpoComponentProps>(reactNativeViewName);\n const reactNativeUIConfiguration = (UIManager.getViewManagerConfig\n ? UIManager.getViewManagerConfig(reactNativeViewName)\n : UIManager[reactNativeViewName]) || {\n NativeProps: {},\n directEventTypes: {},\n };\n const reactNativeComponentPropNames = [\n 'children',\n ...ViewPropTypesKeys,\n ...Object.keys(reactNativeUIConfiguration.NativeProps),\n ...Object.keys(reactNativeUIConfiguration.directEventTypes),\n ];\n\n // Define a component for universal-module authors to access their native view manager\n function NativeComponentAdapter(props, ref) {\n const nativeProps = pick(props, reactNativeComponentPropNames);\n const proxiedProps = omit(props, reactNativeComponentPropNames);\n return <ReactNativeComponent {...nativeProps} proxiedProperties={proxiedProps} ref={ref} />;\n }\n NativeComponentAdapter.displayName = `Adapter<${viewName}>`;\n return React.forwardRef(NativeComponentAdapter);\n}\n\nfunction omit(props: Record<string, any>, propNames: string[]) {\n const copied = { ...props };\n for (const propName of propNames) {\n delete copied[propName];\n }\n return copied;\n}\n\nfunction pick(props: Record<string, any>, propNames: string[]) {\n return propNames.reduce((prev, curr) => {\n if (curr in props) {\n prev[curr] = props[curr];\n }\n return prev;\n }, {});\n}\n"]}
1
+ {"version":3,"file":"NativeViewManagerAdapter.native.js","sourceRoot":"","sources":["../src/NativeViewManagerAdapter.native.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,aAAa,EAAE,sBAAsB,EAAE,MAAM,cAAc,CAAC;AAerE;;GAEG;AACH,MAAM,UAAU,wBAAwB,CAAU,QAAgB;IAChE,MAAM,EAAE,oBAAoB,EAAE,GAAG,aAAa,CAAC,oBAAoB,CAAC;IACpE,MAAM,iBAAiB,GAAG,oBAAoB,EAAE,CAAC,QAAQ,CAAC,CAAC;IAE3D,IAAI,OAAO,IAAI,CAAC,iBAAiB,EAAE;QACjC,MAAM,wBAAwB,GAAG,MAAM,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAC9E,OAAO,CAAC,IAAI,CACV,6CAA6C,QAAQ,8IAA8I,wBAAwB,IAAI,CA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native';\n\n// To make the transition from React Native's `requireNativeComponent` to Expo's\n// `requireNativeViewManager` as easy as possible, `requireNativeViewManager` is a drop-in\n// replacement for `requireNativeComponent`.\n//\n// For each view manager, we create a wrapper component that accepts all of the props available to\n// the author of the universal module. This wrapper component splits the props into two sets: props\n// passed to React Native's View (ex: style, testID) and custom view props, which are passed to the\n// adapter view component in a prop called `proxiedProperties`.\n\ntype NativeExpoComponentProps = {\n proxiedProperties: object;\n};\n\n/**\n * A drop-in replacement for `requireNativeComponent`.\n */\nexport function requireNativeViewManager<P = any>(viewName: string): React.ComponentType<P> {\n const { viewManagersMetadata } = NativeModules.NativeUnimoduleProxy;\n const viewManagerConfig = viewManagersMetadata?.[viewName];\n\n if (__DEV__ && !viewManagerConfig) {\n const exportedViewManagerNames = Object.keys(viewManagersMetadata).join(', ');\n console.warn(\n `The native view manager required by name (${viewName}) from NativeViewManagerAdapter isn't exported by expo-modules-core. Views of this type may not render correctly. Exported view managers: [${exportedViewManagerNames}].`\n );\n }\n\n // Set up the React Native native component, which is an adapter to the universal module's view\n // manager\n const reactNativeViewName = `ViewManagerAdapter_${viewName}`;\n const ReactNativeComponent =\n requireNativeComponent<NativeExpoComponentProps>(reactNativeViewName);\n const proxiedPropsNames = viewManagerConfig?.propsNames ?? [];\n\n // Define a component for universal-module authors to access their native view manager\n function NativeComponentAdapter(props, ref) {\n const nativeProps = omit(props, proxiedPropsNames);\n const proxiedProps = pick(props, proxiedPropsNames);\n return <ReactNativeComponent {...nativeProps} proxiedProperties={proxiedProps} ref={ref} />;\n }\n NativeComponentAdapter.displayName = `Adapter<${viewName}>`;\n return React.forwardRef(NativeComponentAdapter);\n}\n\nfunction omit(props: Record<string, any>, propNames: string[]) {\n const copied = { ...props };\n for (const propName of propNames) {\n delete copied[propName];\n }\n return copied;\n}\n\nfunction pick(props: Record<string, any>, propNames: string[]) {\n return propNames.reduce((prev, curr) => {\n if (curr in props) {\n prev[curr] = props[curr];\n }\n return prev;\n }, {});\n}\n"]}
@@ -1,3 +1,3 @@
1
- import { NativeModulesProxy } from '..';
1
+ import NativeModulesProxy from '../NativeModulesProxy';
2
2
  export default NativeModulesProxy.ExpoModulesCoreErrorManager;
3
3
  //# sourceMappingURL=NativeErrorManager.js.map
@@ -1 +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"]}
1
+ {"version":3,"file":"NativeErrorManager.js","sourceRoot":"","sources":["../../src/sweet/NativeErrorManager.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,MAAM,uBAAuB,CAAC;AACvD,eAAe,kBAAkB,CAAC,2BAA2B,CAAC","sourcesContent":["import NativeModulesProxy from '../NativeModulesProxy';\nexport default NativeModulesProxy.ExpoModulesCoreErrorManager;\n"]}
@@ -1,14 +1,10 @@
1
1
  // Copyright 2018-present 650 Industries. All rights reserved.
2
2
 
3
+ #import <ExpoModulesCore/EXLegacyAppDelegateWrapper.h>
4
+
3
5
  #import <ExpoModulesCore/EXAppDelegatesLoader.h>
4
6
  #import <ExpoModulesCore/EXNativeModulesProxy.h>
5
-
6
- #if __has_include(<ExpoModulesCore/ExpoModulesCore-Swift.h>)
7
- // When `use_frameworks!` is used, the generated Swift header is inside ExpoModulesCore module.
8
- #import <ExpoModulesCore/ExpoModulesCore-Swift.h>
9
- #else
10
- #import "ExpoModulesCore-Swift.h"
11
- #endif
7
+ #import <ExpoModulesCore/Swift.h>
12
8
 
13
9
  // Make the legacy wrapper conform to the protocol for subscribers.
14
10
  @interface EXLegacyAppDelegateWrapper () <EXAppDelegateSubscriberProtocol>
@@ -21,7 +17,7 @@
21
17
  // and before any code is executed, so we switch back to Objective-C just to do this one thing.
22
18
  + (void)load
23
19
  {
24
- id<ModulesProviderObjCProtocol> modulesProvider = [EXNativeModulesProxy getExpoModulesProvider];
20
+ ModulesProvider *modulesProvider = [EXNativeModulesProxy getExpoModulesProvider];
25
21
  [EXExpoAppDelegate registerSubscriber:[[EXLegacyAppDelegateWrapper alloc] init]];
26
22
  [EXExpoAppDelegate registerSubscribersFromModulesProvider:modulesProvider];
27
23
  [EXExpoAppDelegate registerReactDelegateHandlersFromModulesProvider:modulesProvider];
@@ -263,11 +263,8 @@ open class ExpoAppDelegate: UIResponder, UIApplicationDelegate {
263
263
  // MARK: - Statics
264
264
 
265
265
  @objc
266
- public static func registerSubscribersFrom(modulesProvider: ModulesProviderObjCProtocol) {
267
- guard let provider = modulesProvider as? ModulesProviderProtocol else {
268
- fatalError("Expo modules provider must implement `ModulesProviderProtocol`.")
269
- }
270
- provider.getAppDelegateSubscribers().forEach { subscriberType in
266
+ public static func registerSubscribersFrom(modulesProvider: ModulesProvider) {
267
+ modulesProvider.getAppDelegateSubscribers().forEach { subscriberType in
271
268
  registerSubscriber(subscriberType.init())
272
269
  }
273
270
  }
@@ -286,11 +283,8 @@ open class ExpoAppDelegate: UIResponder, UIApplicationDelegate {
286
283
  }
287
284
 
288
285
  @objc
289
- public static func registerReactDelegateHandlersFrom(modulesProvider: ModulesProviderObjCProtocol) {
290
- guard let provider = modulesProvider as? ModulesProviderProtocol else {
291
- fatalError("Expo modules provider must implement `ModulesProviderProtocol`.")
292
- }
293
- provider.getReactDelegateHandlers()
286
+ public static func registerReactDelegateHandlersFrom(modulesProvider: ModulesProvider) {
287
+ modulesProvider.getReactDelegateHandlers()
294
288
  .sorted { tuple1, tuple2 -> Bool in
295
289
  return ModulePriorities.get(tuple1.packageName) > ModulePriorities.get(tuple2.packageName)
296
290
  }
@@ -16,6 +16,7 @@ NS_ASSUME_NONNULL_BEGIN
16
16
  @property (class, nonatomic, assign, readonly) BOOL APP_DEBUG NS_SWIFT_NAME(APP_DEBUG);
17
17
  @property (class, nonatomic, assign, readonly) BOOL APP_RCT_DEBUG NS_SWIFT_NAME(APP_RCT_DEBUG);
18
18
  @property (class, nonatomic, assign, readonly) BOOL APP_RCT_DEV NS_SWIFT_NAME(APP_RCT_DEV);
19
+ @property (class, nonatomic, assign, readonly) BOOL APP_NEW_ARCH_ENABLED NS_SWIFT_NAME(APP_NEW_ARCH_ENABLED);
19
20
 
20
21
  + (NSDictionary *)getAllDefines;
21
22
 
@@ -26,6 +26,12 @@ static BOOL _loaded = NO;
26
26
  return [_storage[@"APP_RCT_DEV"] boolValue];
27
27
  }
28
28
 
29
+ + (BOOL)APP_NEW_ARCH_ENABLED
30
+ {
31
+ [self throwIfNotLoaded];
32
+ return [_storage[@"APP_NEW_ARCH_ENABLED"] boolValue];
33
+ }
34
+
29
35
  + (NSDictionary *)getAllDefines
30
36
  {
31
37
  return _storage;
package/ios/EXUtilities.h CHANGED
@@ -20,6 +20,8 @@ NS_ASSUME_NONNULL_BEGIN
20
20
  - (nullable UIViewController *)currentViewController;
21
21
  - (nullable NSDictionary *)launchOptions;
22
22
 
23
+ + (BOOL)catchException:(void(^)(void))tryBlock error:(__autoreleasing NSError **)error;
24
+
23
25
  @end
24
26
 
25
27
  NS_ASSUME_NONNULL_END
package/ios/EXUtilities.m CHANGED
@@ -206,6 +206,18 @@ EX_REGISTER_MODULE();
206
206
  }
207
207
  }
208
208
 
209
+ + (BOOL)catchException:(void(^)(void))tryBlock error:(__autoreleasing NSError **)error
210
+ {
211
+ @try {
212
+ tryBlock();
213
+ return YES;
214
+ }
215
+ @catch (NSException *exception) {
216
+ *error = [[NSError alloc] initWithDomain:exception.name code:0 userInfo:exception.userInfo];
217
+ return NO;
218
+ }
219
+ }
220
+
209
221
  @end
210
222
 
211
223
  UIApplication * EXSharedApplication(void)