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
@@ -10,6 +10,7 @@
10
10
  * That's why we used typeOf. It solves all problems described above.
11
11
  */
12
12
  @file:OptIn(ExperimentalStdlibApi::class)
13
+ @file:Suppress("FunctionName")
13
14
 
14
15
  package expo.modules.kotlin.modules
15
16
 
@@ -23,22 +24,24 @@ import expo.modules.kotlin.events.EventListenerWithSenderAndPayload
23
24
  import expo.modules.kotlin.events.EventName
24
25
  import expo.modules.kotlin.events.EventsDefinition
25
26
  import expo.modules.kotlin.events.OnActivityResultPayload
26
- import expo.modules.kotlin.methods.AnyMethod
27
- import expo.modules.kotlin.methods.Method
28
- import expo.modules.kotlin.methods.PromiseMethod
27
+ import expo.modules.kotlin.functions.AnyFunction
28
+ import expo.modules.kotlin.functions.AsyncFunction
29
+ import expo.modules.kotlin.functions.AsyncFunctionWithPromise
30
+ import expo.modules.kotlin.functions.AsyncFunctionBuilder
29
31
  import expo.modules.kotlin.types.toAnyType
30
32
  import expo.modules.kotlin.views.ViewManagerDefinition
31
33
  import expo.modules.kotlin.views.ViewManagerDefinitionBuilder
32
34
  import kotlin.reflect.typeOf
33
35
 
34
36
  @DefinitionMarker
35
- class ModuleDefinitionBuilder(private val module: Module? = null) {
37
+ class ModuleDefinitionBuilder(@PublishedApi internal val module: Module? = null) {
36
38
  private var name: String? = null
37
39
  private var constantsProvider = { emptyMap<String, Any?>() }
38
40
  private var eventsDefinition: EventsDefinition? = null
41
+ private var functionBuilders = mutableListOf<AsyncFunctionBuilder>()
39
42
 
40
43
  @PublishedApi
41
- internal var methods = mutableMapOf<String, AnyMethod>()
44
+ internal var methods = mutableMapOf<String, AnyFunction>()
42
45
 
43
46
  @PublishedApi
44
47
  internal var viewManagerDefinition: ViewManagerDefinition? = null
@@ -52,141 +55,411 @@ class ModuleDefinitionBuilder(private val module: Module? = null) {
52
55
  return ModuleDefinitionData(
53
56
  requireNotNull(moduleName),
54
57
  constantsProvider,
55
- methods,
58
+ methods + functionBuilders.associate { it.build() },
56
59
  viewManagerDefinition,
57
60
  eventListeners,
58
61
  eventsDefinition
59
62
  )
60
63
  }
61
64
 
65
+ @Deprecated(
66
+ message = "The 'name' component was renamed to 'Name'.",
67
+ replaceWith = ReplaceWith("Name(name)")
68
+ )
69
+ fun name(name: String) = Name(name)
70
+
62
71
  /**
63
72
  * Sets the name of the module that is exported to the JavaScript world.
64
73
  */
65
- fun name(name: String) {
74
+ fun Name(name: String) {
66
75
  this.name = name
67
76
  }
68
77
 
78
+ @Deprecated(
79
+ message = "The 'constants' component was renamed to 'Constants'.",
80
+ replaceWith = ReplaceWith("Constants(constantsProvider)")
81
+ )
82
+ fun constants(constantsProvider: () -> Map<String, Any?>) = Constants(constantsProvider)
83
+
69
84
  /**
70
85
  * Definition function setting the module's constants to export.
71
86
  */
72
- fun constants(constantsProvider: () -> Map<String, Any?>) {
87
+ fun Constants(constantsProvider: () -> Map<String, Any?>) {
73
88
  this.constantsProvider = constantsProvider
74
89
  }
75
90
 
91
+ @Deprecated(
92
+ message = "The 'constants' component was renamed to 'Constants'.",
93
+ replaceWith = ReplaceWith("Constants(constants)")
94
+ )
95
+ fun constants(vararg constants: Pair<String, Any?>) = Constants(*constants)
96
+
76
97
  /**
77
98
  * Definition of the module's constants to export.
78
99
  */
79
- fun constants(vararg constants: Pair<String, Any?>) {
100
+ fun Constants(vararg constants: Pair<String, Any?>) {
80
101
  constantsProvider = { constants.toMap() }
81
102
  }
82
103
 
83
- @JvmName("methodWithoutArgs")
104
+ @Deprecated(
105
+ message = "The 'function' component was deprecated and will change its behavior in the future.",
106
+ replaceWith = ReplaceWith("AsyncFunction(name, body)")
107
+ )
108
+ @JvmName("functionWithoutArgs")
84
109
  inline fun function(
85
110
  name: String,
86
111
  crossinline body: () -> Any?
87
112
  ) {
88
- methods[name] = Method(name, arrayOf()) { body() }
113
+ methods[name] = AsyncFunction(name, arrayOf()) { body() }
89
114
  }
90
115
 
116
+ @Deprecated(
117
+ message = "The 'function' component was deprecated and will change its behavior in the future.",
118
+ replaceWith = ReplaceWith("AsyncFunction(name, body)")
119
+ )
91
120
  inline fun <reified R> function(
92
121
  name: String,
93
122
  crossinline body: () -> R
94
123
  ) {
95
- methods[name] = Method(name, arrayOf()) { body() }
124
+ methods[name] = AsyncFunction(name, arrayOf()) { body() }
96
125
  }
97
126
 
127
+ @Deprecated(
128
+ message = "The 'function' component was deprecated and will change its behavior in the future.",
129
+ replaceWith = ReplaceWith("AsyncFunction(name, body)")
130
+ )
98
131
  inline fun <reified R, reified P0> function(
99
132
  name: String,
100
133
  crossinline body: (p0: P0) -> R
101
134
  ) {
102
135
  methods[name] = if (P0::class == Promise::class) {
103
- PromiseMethod(name, arrayOf()) { _, promise -> body(promise as P0) }
136
+ AsyncFunctionWithPromise(name, arrayOf()) { _, promise -> body(promise as P0) }
104
137
  } else {
105
- Method(name, arrayOf(typeOf<P0>().toAnyType())) { body(it[0] as P0) }
138
+ AsyncFunction(name, arrayOf(typeOf<P0>().toAnyType())) { body(it[0] as P0) }
106
139
  }
107
140
  }
108
141
 
142
+ @Deprecated(
143
+ message = "The 'function' component was deprecated and will change its behavior in the future.",
144
+ replaceWith = ReplaceWith("AsyncFunction(name, body)")
145
+ )
109
146
  inline fun <reified R, reified P0, reified P1> function(
110
147
  name: String,
111
148
  crossinline body: (p0: P0, p1: P1) -> R
112
149
  ) {
113
150
  methods[name] = if (P1::class == Promise::class) {
114
- PromiseMethod(name, arrayOf(typeOf<P0>().toAnyType())) { args, promise -> body(args[0] as P0, promise as P1) }
151
+ AsyncFunctionWithPromise(name, arrayOf(typeOf<P0>().toAnyType())) { args, promise -> body(args[0] as P0, promise as P1) }
115
152
  } else {
116
- Method(name, arrayOf(typeOf<P0>().toAnyType(), typeOf<P1>().toAnyType())) { body(it[0] as P0, it[1] as P1) }
153
+ AsyncFunction(name, arrayOf(typeOf<P0>().toAnyType(), typeOf<P1>().toAnyType())) { body(it[0] as P0, it[1] as P1) }
117
154
  }
118
155
  }
119
156
 
157
+ @Deprecated(
158
+ message = "The 'function' component was deprecated and will change its behavior in the future.",
159
+ replaceWith = ReplaceWith("AsyncFunction(name, body)")
160
+ )
120
161
  inline fun <reified R, reified P0, reified P1, reified P2> function(
121
162
  name: String,
122
163
  crossinline body: (p0: P0, p1: P1, p2: P2) -> R
123
164
  ) {
124
165
  methods[name] = if (P2::class == Promise::class) {
125
- PromiseMethod(name, arrayOf(typeOf<P0>().toAnyType(), typeOf<P1>().toAnyType())) { args, promise -> body(args[0] as P0, args[1] as P1, promise as P2) }
166
+ AsyncFunctionWithPromise(name, arrayOf(typeOf<P0>().toAnyType(), typeOf<P1>().toAnyType())) { args, promise -> body(args[0] as P0, args[1] as P1, promise as P2) }
126
167
  } else {
127
- Method(name, arrayOf(typeOf<P0>().toAnyType(), typeOf<P1>().toAnyType(), typeOf<P2>().toAnyType())) { body(it[0] as P0, it[1] as P1, it[2] as P2) }
168
+ AsyncFunction(name, arrayOf(typeOf<P0>().toAnyType(), typeOf<P1>().toAnyType(), typeOf<P2>().toAnyType())) { body(it[0] as P0, it[1] as P1, it[2] as P2) }
128
169
  }
129
170
  }
130
171
 
172
+ @Deprecated(
173
+ message = "The 'function' component was deprecated and will change its behavior in the future.",
174
+ replaceWith = ReplaceWith("AsyncFunction(name, body)")
175
+ )
131
176
  inline fun <reified R, reified P0, reified P1, reified P2, reified P3> function(
132
177
  name: String,
133
178
  crossinline body: (p0: P0, p1: P1, p2: P2, p3: P3) -> R
134
179
  ) {
135
180
  methods[name] = if (P3::class == Promise::class) {
136
- PromiseMethod(name, arrayOf(typeOf<P0>().toAnyType(), typeOf<P1>().toAnyType(), typeOf<P2>().toAnyType())) { args, promise -> body(args[0] as P0, args[1] as P1, args[2] as P2, promise as P3) }
181
+ AsyncFunctionWithPromise(name, arrayOf(typeOf<P0>().toAnyType(), typeOf<P1>().toAnyType(), typeOf<P2>().toAnyType())) { args, promise -> body(args[0] as P0, args[1] as P1, args[2] as P2, promise as P3) }
137
182
  } else {
138
- Method(name, arrayOf(typeOf<P0>().toAnyType(), typeOf<P1>().toAnyType(), typeOf<P2>().toAnyType(), typeOf<P3>().toAnyType())) { body(it[0] as P0, it[1] as P1, it[2] as P2, it[3] as P3) }
183
+ AsyncFunction(name, arrayOf(typeOf<P0>().toAnyType(), typeOf<P1>().toAnyType(), typeOf<P2>().toAnyType(), typeOf<P3>().toAnyType())) { body(it[0] as P0, it[1] as P1, it[2] as P2, it[3] as P3) }
139
184
  }
140
185
  }
141
186
 
187
+ @Deprecated(
188
+ message = "The 'function' component was deprecated and will change its behavior in the future.",
189
+ replaceWith = ReplaceWith("AsyncFunction(name, body)")
190
+ )
142
191
  inline fun <reified R, reified P0, reified P1, reified P2, reified P3, reified P4> function(
143
192
  name: String,
144
193
  crossinline body: (p0: P0, p1: P1, p2: P2, p3: P3, p4: P4) -> R
145
194
  ) {
146
195
  methods[name] = if (P4::class == Promise::class) {
147
- PromiseMethod(name, arrayOf(typeOf<P0>().toAnyType(), typeOf<P1>().toAnyType(), typeOf<P2>().toAnyType(), typeOf<P3>().toAnyType())) { args, promise -> body(args[0] as P0, args[1] as P1, args[2] as P2, args[3] as P3, promise as P4) }
196
+ AsyncFunctionWithPromise(name, arrayOf(typeOf<P0>().toAnyType(), typeOf<P1>().toAnyType(), typeOf<P2>().toAnyType(), typeOf<P3>().toAnyType())) { args, promise -> body(args[0] as P0, args[1] as P1, args[2] as P2, args[3] as P3, promise as P4) }
148
197
  } else {
149
- Method(name, arrayOf(typeOf<P0>().toAnyType(), typeOf<P1>().toAnyType(), typeOf<P2>().toAnyType(), typeOf<P3>().toAnyType(), typeOf<P4>().toAnyType())) { body(it[0] as P0, it[1] as P1, it[2] as P2, it[3] as P3, it[4] as P4) }
198
+ AsyncFunction(name, arrayOf(typeOf<P0>().toAnyType(), typeOf<P1>().toAnyType(), typeOf<P2>().toAnyType(), typeOf<P3>().toAnyType(), typeOf<P4>().toAnyType())) { body(it[0] as P0, it[1] as P1, it[2] as P2, it[3] as P3, it[4] as P4) }
150
199
  }
151
200
  }
152
201
 
202
+ @Deprecated(
203
+ message = "The 'function' component was deprecated and will change its behavior in the future.",
204
+ replaceWith = ReplaceWith("AsyncFunction(name, body)")
205
+ )
153
206
  inline fun <reified R, reified P0, reified P1, reified P2, reified P3, reified P4, reified P5> function(
154
207
  name: String,
155
208
  crossinline body: (p0: P0, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5) -> R
156
209
  ) {
157
210
  methods[name] = if (P5::class == Promise::class) {
158
- PromiseMethod(name, arrayOf(typeOf<P0>().toAnyType(), typeOf<P1>().toAnyType(), typeOf<P2>().toAnyType(), typeOf<P3>().toAnyType(), typeOf<P4>().toAnyType())) { args, promise -> body(args[0] as P0, args[1] as P1, args[2] as P2, args[3] as P3, args[4] as P4, promise as P5) }
211
+ AsyncFunctionWithPromise(name, arrayOf(typeOf<P0>().toAnyType(), typeOf<P1>().toAnyType(), typeOf<P2>().toAnyType(), typeOf<P3>().toAnyType(), typeOf<P4>().toAnyType())) { args, promise -> body(args[0] as P0, args[1] as P1, args[2] as P2, args[3] as P3, args[4] as P4, promise as P5) }
159
212
  } else {
160
- Method(name, arrayOf(typeOf<P0>().toAnyType(), typeOf<P1>().toAnyType(), typeOf<P2>().toAnyType(), typeOf<P3>().toAnyType(), typeOf<P4>().toAnyType(), typeOf<P5>().toAnyType())) { body(it[0] as P0, it[1] as P1, it[2] as P2, it[3] as P3, it[4] as P4, it[5] as P5) }
213
+ AsyncFunction(name, arrayOf(typeOf<P0>().toAnyType(), typeOf<P1>().toAnyType(), typeOf<P2>().toAnyType(), typeOf<P3>().toAnyType(), typeOf<P4>().toAnyType(), typeOf<P5>().toAnyType())) { body(it[0] as P0, it[1] as P1, it[2] as P2, it[3] as P3, it[4] as P4, it[5] as P5) }
161
214
  }
162
215
  }
163
216
 
217
+ @Deprecated(
218
+ message = "The 'function' component was deprecated and will change its behavior in the future.",
219
+ replaceWith = ReplaceWith("AsyncFunction(name, body)")
220
+ )
164
221
  inline fun <reified R, reified P0, reified P1, reified P2, reified P3, reified P4, reified P5, reified P6> function(
165
222
  name: String,
166
223
  crossinline body: (p0: P0, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6) -> R
167
224
  ) {
168
225
  methods[name] = if (P6::class == Promise::class) {
169
- PromiseMethod(name, arrayOf(typeOf<P0>().toAnyType(), typeOf<P1>().toAnyType(), typeOf<P2>().toAnyType(), typeOf<P3>().toAnyType(), typeOf<P4>().toAnyType(), typeOf<P5>().toAnyType())) { args, promise -> body(args[0] as P0, args[1] as P1, args[2] as P2, args[3] as P3, args[4] as P4, args[5] as P5, promise as P6) }
226
+ AsyncFunctionWithPromise(name, arrayOf(typeOf<P0>().toAnyType(), typeOf<P1>().toAnyType(), typeOf<P2>().toAnyType(), typeOf<P3>().toAnyType(), typeOf<P4>().toAnyType(), typeOf<P5>().toAnyType())) { args, promise -> body(args[0] as P0, args[1] as P1, args[2] as P2, args[3] as P3, args[4] as P4, args[5] as P5, promise as P6) }
170
227
  } else {
171
- Method(name, arrayOf(typeOf<P0>().toAnyType(), typeOf<P1>().toAnyType(), typeOf<P2>().toAnyType(), typeOf<P3>().toAnyType(), typeOf<P4>().toAnyType(), typeOf<P5>().toAnyType(), typeOf<P6>().toAnyType())) { body(it[0] as P0, it[1] as P1, it[2] as P2, it[3] as P3, it[4] as P4, it[5] as P5, it[6] as P6) }
228
+ AsyncFunction(name, arrayOf(typeOf<P0>().toAnyType(), typeOf<P1>().toAnyType(), typeOf<P2>().toAnyType(), typeOf<P3>().toAnyType(), typeOf<P4>().toAnyType(), typeOf<P5>().toAnyType(), typeOf<P6>().toAnyType())) { body(it[0] as P0, it[1] as P1, it[2] as P2, it[3] as P3, it[4] as P4, it[5] as P5, it[6] as P6) }
172
229
  }
173
230
  }
174
231
 
232
+ @Deprecated(
233
+ message = "The 'function' component was deprecated and will change its behavior in the future.",
234
+ replaceWith = ReplaceWith("AsyncFunction(name, body)")
235
+ )
175
236
  inline fun <reified R, reified P0, reified P1, reified P2, reified P3, reified P4, reified P5, reified P6, reified P7> function(
176
237
  name: String,
177
238
  crossinline body: (p0: P0, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7) -> R
178
239
  ) {
179
240
  methods[name] = if (P7::class == Promise::class) {
180
- PromiseMethod(name, arrayOf(typeOf<P0>().toAnyType(), typeOf<P1>().toAnyType(), typeOf<P2>().toAnyType(), typeOf<P3>().toAnyType(), typeOf<P4>().toAnyType(), typeOf<P5>().toAnyType(), typeOf<P6>().toAnyType())) { args, promise -> body(args[0] as P0, args[1] as P1, args[2] as P2, args[3] as P3, args[4] as P4, args[5] as P5, args[6] as P6, promise as P7) }
241
+ AsyncFunctionWithPromise(name, arrayOf(typeOf<P0>().toAnyType(), typeOf<P1>().toAnyType(), typeOf<P2>().toAnyType(), typeOf<P3>().toAnyType(), typeOf<P4>().toAnyType(), typeOf<P5>().toAnyType(), typeOf<P6>().toAnyType())) { args, promise -> body(args[0] as P0, args[1] as P1, args[2] as P2, args[3] as P3, args[4] as P4, args[5] as P5, args[6] as P6, promise as P7) }
242
+ } else {
243
+ AsyncFunction(name, arrayOf(typeOf<P0>().toAnyType(), typeOf<P1>().toAnyType(), typeOf<P2>().toAnyType(), typeOf<P3>().toAnyType(), typeOf<P4>().toAnyType(), typeOf<P5>().toAnyType(), typeOf<P6>().toAnyType(), typeOf<P7>().toAnyType())) { body(it[0] as P0, it[1] as P1, it[2] as P2, it[3] as P3, it[4] as P4, it[5] as P5, it[6] as P6, it[7] as P7) }
244
+ }
245
+ }
246
+
247
+ @Deprecated(
248
+ message = "The 'asyncFunction' component was renamed to 'AsyncFunction'.",
249
+ replaceWith = ReplaceWith("AsyncFunction(name, body)")
250
+ )
251
+ @JvmName("asyncFunctionWithoutArgs")
252
+ inline fun asyncFunction(
253
+ name: String,
254
+ crossinline body: () -> Any?
255
+ ) = AsyncFunction(name, body)
256
+
257
+ @JvmName("AsyncFunctionWithoutArgs")
258
+ inline fun AsyncFunction(
259
+ name: String,
260
+ crossinline body: () -> Any?
261
+ ) {
262
+ methods[name] = AsyncFunction(name, arrayOf()) { body() }
263
+ }
264
+
265
+ @Deprecated(
266
+ message = "The 'asyncFunction' component was renamed to 'AsyncFunction'.",
267
+ replaceWith = ReplaceWith("AsyncFunction(name, body)")
268
+ )
269
+ inline fun <reified R> asyncFunction(
270
+ name: String,
271
+ crossinline body: () -> R
272
+ ) = AsyncFunction(name, body)
273
+
274
+ inline fun <reified R> AsyncFunction(
275
+ name: String,
276
+ crossinline body: () -> R
277
+ ) {
278
+ methods[name] = AsyncFunction(name, arrayOf()) { body() }
279
+ }
280
+
281
+ @Deprecated(
282
+ message = "The 'asyncFunction' component was renamed to 'AsyncFunction'.",
283
+ replaceWith = ReplaceWith("AsyncFunction(name, body)")
284
+ )
285
+ inline fun <reified R, reified P0> asyncFunction(
286
+ name: String,
287
+ crossinline body: (p0: P0) -> R
288
+ ) = AsyncFunction(name, body)
289
+
290
+ inline fun <reified R, reified P0> AsyncFunction(
291
+ name: String,
292
+ crossinline body: (p0: P0) -> R
293
+ ) {
294
+ methods[name] = if (P0::class == Promise::class) {
295
+ AsyncFunctionWithPromise(name, arrayOf()) { _, promise -> body(promise as P0) }
296
+ } else {
297
+ AsyncFunction(name, arrayOf(typeOf<P0>().toAnyType())) { body(it[0] as P0) }
298
+ }
299
+ }
300
+
301
+ @Deprecated(
302
+ message = "The 'asyncFunction' component was renamed to 'AsyncFunction'.",
303
+ replaceWith = ReplaceWith("AsyncFunction(name, body)")
304
+ )
305
+ inline fun <reified R, reified P0, reified P1> asyncFunction(
306
+ name: String,
307
+ crossinline body: (p0: P0, p1: P1) -> R
308
+ ) = AsyncFunction(name, body)
309
+
310
+ inline fun <reified R, reified P0, reified P1> AsyncFunction(
311
+ name: String,
312
+ crossinline body: (p0: P0, p1: P1) -> R
313
+ ) {
314
+ methods[name] = if (P1::class == Promise::class) {
315
+ AsyncFunctionWithPromise(name, arrayOf(typeOf<P0>().toAnyType())) { args, promise -> body(args[0] as P0, promise as P1) }
316
+ } else {
317
+ AsyncFunction(name, arrayOf(typeOf<P0>().toAnyType(), typeOf<P1>().toAnyType())) { body(it[0] as P0, it[1] as P1) }
318
+ }
319
+ }
320
+
321
+ @Deprecated(
322
+ message = "The 'asyncFunction' component was renamed to 'AsyncFunction'.",
323
+ replaceWith = ReplaceWith("AsyncFunction(name, body)")
324
+ )
325
+ inline fun <reified R, reified P0, reified P1, reified P2> asyncFunction(
326
+ name: String,
327
+ crossinline body: (p0: P0, p1: P1, p2: P2) -> R
328
+ ) = AsyncFunction(name, body)
329
+
330
+ inline fun <reified R, reified P0, reified P1, reified P2> AsyncFunction(
331
+ name: String,
332
+ crossinline body: (p0: P0, p1: P1, p2: P2) -> R
333
+ ) {
334
+ methods[name] = if (P2::class == Promise::class) {
335
+ AsyncFunctionWithPromise(name, arrayOf(typeOf<P0>().toAnyType(), typeOf<P1>().toAnyType())) { args, promise -> body(args[0] as P0, args[1] as P1, promise as P2) }
336
+ } else {
337
+ AsyncFunction(name, arrayOf(typeOf<P0>().toAnyType(), typeOf<P1>().toAnyType(), typeOf<P2>().toAnyType())) { body(it[0] as P0, it[1] as P1, it[2] as P2) }
338
+ }
339
+ }
340
+
341
+ @Deprecated(
342
+ message = "The 'asyncFunction' component was renamed to 'AsyncFunction'.",
343
+ replaceWith = ReplaceWith("AsyncFunction(name, body)")
344
+ )
345
+ inline fun <reified R, reified P0, reified P1, reified P2, reified P3> asyncFunction(
346
+ name: String,
347
+ crossinline body: (p0: P0, p1: P1, p2: P2, p3: P3) -> R
348
+ ) = AsyncFunction(name, body)
349
+
350
+ inline fun <reified R, reified P0, reified P1, reified P2, reified P3> AsyncFunction(
351
+ name: String,
352
+ crossinline body: (p0: P0, p1: P1, p2: P2, p3: P3) -> R
353
+ ) {
354
+ methods[name] = if (P3::class == Promise::class) {
355
+ AsyncFunctionWithPromise(name, arrayOf(typeOf<P0>().toAnyType(), typeOf<P1>().toAnyType(), typeOf<P2>().toAnyType())) { args, promise -> body(args[0] as P0, args[1] as P1, args[2] as P2, promise as P3) }
356
+ } else {
357
+ AsyncFunction(name, arrayOf(typeOf<P0>().toAnyType(), typeOf<P1>().toAnyType(), typeOf<P2>().toAnyType(), typeOf<P3>().toAnyType())) { body(it[0] as P0, it[1] as P1, it[2] as P2, it[3] as P3) }
358
+ }
359
+ }
360
+
361
+ @Deprecated(
362
+ message = "The 'asyncFunction' component was renamed to 'AsyncFunction'.",
363
+ replaceWith = ReplaceWith("AsyncFunction(name, body)")
364
+ )
365
+ inline fun <reified R, reified P0, reified P1, reified P2, reified P3, reified P4> asyncFunction(
366
+ name: String,
367
+ crossinline body: (p0: P0, p1: P1, p2: P2, p3: P3, p4: P4) -> R
368
+ ) = AsyncFunction(name, body)
369
+
370
+ inline fun <reified R, reified P0, reified P1, reified P2, reified P3, reified P4> AsyncFunction(
371
+ name: String,
372
+ crossinline body: (p0: P0, p1: P1, p2: P2, p3: P3, p4: P4) -> R
373
+ ) {
374
+ methods[name] = if (P4::class == Promise::class) {
375
+ AsyncFunctionWithPromise(name, arrayOf(typeOf<P0>().toAnyType(), typeOf<P1>().toAnyType(), typeOf<P2>().toAnyType(), typeOf<P3>().toAnyType())) { args, promise -> body(args[0] as P0, args[1] as P1, args[2] as P2, args[3] as P3, promise as P4) }
376
+ } else {
377
+ AsyncFunction(name, arrayOf(typeOf<P0>().toAnyType(), typeOf<P1>().toAnyType(), typeOf<P2>().toAnyType(), typeOf<P3>().toAnyType(), typeOf<P4>().toAnyType())) { body(it[0] as P0, it[1] as P1, it[2] as P2, it[3] as P3, it[4] as P4) }
378
+ }
379
+ }
380
+
381
+ @Deprecated(
382
+ message = "The 'asyncFunction' component was renamed to 'AsyncFunction'.",
383
+ replaceWith = ReplaceWith("AsyncFunction(name, body)")
384
+ )
385
+ inline fun <reified R, reified P0, reified P1, reified P2, reified P3, reified P4, reified P5> asyncFunction(
386
+ name: String,
387
+ crossinline body: (p0: P0, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5) -> R
388
+ ) = AsyncFunction(name, body)
389
+
390
+ inline fun <reified R, reified P0, reified P1, reified P2, reified P3, reified P4, reified P5> AsyncFunction(
391
+ name: String,
392
+ crossinline body: (p0: P0, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5) -> R
393
+ ) {
394
+ methods[name] = if (P5::class == Promise::class) {
395
+ AsyncFunctionWithPromise(name, arrayOf(typeOf<P0>().toAnyType(), typeOf<P1>().toAnyType(), typeOf<P2>().toAnyType(), typeOf<P3>().toAnyType(), typeOf<P4>().toAnyType())) { args, promise -> body(args[0] as P0, args[1] as P1, args[2] as P2, args[3] as P3, args[4] as P4, promise as P5) }
396
+ } else {
397
+ AsyncFunction(name, arrayOf(typeOf<P0>().toAnyType(), typeOf<P1>().toAnyType(), typeOf<P2>().toAnyType(), typeOf<P3>().toAnyType(), typeOf<P4>().toAnyType(), typeOf<P5>().toAnyType())) { body(it[0] as P0, it[1] as P1, it[2] as P2, it[3] as P3, it[4] as P4, it[5] as P5) }
398
+ }
399
+ }
400
+
401
+ @Deprecated(
402
+ message = "The 'asyncFunction' component was renamed to 'AsyncFunction'.",
403
+ replaceWith = ReplaceWith("AsyncFunction(name, body)")
404
+ )
405
+ inline fun <reified R, reified P0, reified P1, reified P2, reified P3, reified P4, reified P5, reified P6> asyncFunction(
406
+ name: String,
407
+ crossinline body: (p0: P0, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6) -> R
408
+ ) = AsyncFunction(name, body)
409
+
410
+ inline fun <reified R, reified P0, reified P1, reified P2, reified P3, reified P4, reified P5, reified P6> AsyncFunction(
411
+ name: String,
412
+ crossinline body: (p0: P0, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6) -> R
413
+ ) {
414
+ methods[name] = if (P6::class == Promise::class) {
415
+ AsyncFunctionWithPromise(name, arrayOf(typeOf<P0>().toAnyType(), typeOf<P1>().toAnyType(), typeOf<P2>().toAnyType(), typeOf<P3>().toAnyType(), typeOf<P4>().toAnyType(), typeOf<P5>().toAnyType())) { args, promise -> body(args[0] as P0, args[1] as P1, args[2] as P2, args[3] as P3, args[4] as P4, args[5] as P5, promise as P6) }
416
+ } else {
417
+ AsyncFunction(name, arrayOf(typeOf<P0>().toAnyType(), typeOf<P1>().toAnyType(), typeOf<P2>().toAnyType(), typeOf<P3>().toAnyType(), typeOf<P4>().toAnyType(), typeOf<P5>().toAnyType(), typeOf<P6>().toAnyType())) { body(it[0] as P0, it[1] as P1, it[2] as P2, it[3] as P3, it[4] as P4, it[5] as P5, it[6] as P6) }
418
+ }
419
+ }
420
+
421
+ @Deprecated(
422
+ message = "The 'asyncFunction' component was renamed to 'AsyncFunction'.",
423
+ replaceWith = ReplaceWith("AsyncFunction(name, body)")
424
+ )
425
+ inline fun <reified R, reified P0, reified P1, reified P2, reified P3, reified P4, reified P5, reified P6, reified P7> asyncFunction(
426
+ name: String,
427
+ crossinline body: (p0: P0, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7) -> R
428
+ ) = AsyncFunction(name, body)
429
+
430
+ inline fun <reified R, reified P0, reified P1, reified P2, reified P3, reified P4, reified P5, reified P6, reified P7> AsyncFunction(
431
+ name: String,
432
+ crossinline body: (p0: P0, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7) -> R
433
+ ) {
434
+ methods[name] = if (P7::class == Promise::class) {
435
+ AsyncFunctionWithPromise(name, arrayOf(typeOf<P0>().toAnyType(), typeOf<P1>().toAnyType(), typeOf<P2>().toAnyType(), typeOf<P3>().toAnyType(), typeOf<P4>().toAnyType(), typeOf<P5>().toAnyType(), typeOf<P6>().toAnyType())) { args, promise -> body(args[0] as P0, args[1] as P1, args[2] as P2, args[3] as P3, args[4] as P4, args[5] as P5, args[6] as P6, promise as P7) }
181
436
  } else {
182
- Method(name, arrayOf(typeOf<P0>().toAnyType(), typeOf<P1>().toAnyType(), typeOf<P2>().toAnyType(), typeOf<P3>().toAnyType(), typeOf<P4>().toAnyType(), typeOf<P5>().toAnyType(), typeOf<P6>().toAnyType(), typeOf<P7>().toAnyType())) { body(it[0] as P0, it[1] as P1, it[2] as P2, it[3] as P3, it[4] as P4, it[5] as P5, it[6] as P6, it[7] as P7) }
437
+ AsyncFunction(name, arrayOf(typeOf<P0>().toAnyType(), typeOf<P1>().toAnyType(), typeOf<P2>().toAnyType(), typeOf<P3>().toAnyType(), typeOf<P4>().toAnyType(), typeOf<P5>().toAnyType(), typeOf<P6>().toAnyType(), typeOf<P7>().toAnyType())) { body(it[0] as P0, it[1] as P1, it[2] as P2, it[3] as P3, it[4] as P4, it[5] as P5, it[6] as P6, it[7] as P7) }
183
438
  }
184
439
  }
185
440
 
441
+ @Deprecated(
442
+ message = "The 'asyncFunction' component was renamed to 'AsyncFunction'.",
443
+ replaceWith = ReplaceWith("AsyncFunction(name, body)")
444
+ )
445
+ fun asyncFunction(
446
+ name: String
447
+ ) = AsyncFunction(name)
448
+
449
+ fun AsyncFunction(
450
+ name: String
451
+ ) = AsyncFunctionBuilder(name).also { functionBuilders.add(it) }
452
+
453
+ @Deprecated(
454
+ message = "The 'viewManager' component was renamed to 'ViewManager'.",
455
+ replaceWith = ReplaceWith("ViewManager(body)")
456
+ )
457
+ inline fun viewManager(body: ViewManagerDefinitionBuilder.() -> Unit) = ViewManager(body)
458
+
186
459
  /**
187
460
  * Creates the view manager definition that scopes other view-related definitions.
188
461
  */
189
- inline fun viewManager(body: ViewManagerDefinitionBuilder.() -> Unit) {
462
+ inline fun ViewManager(body: ViewManagerDefinitionBuilder.() -> Unit) {
190
463
  require(viewManagerDefinition == null) { "The module definition may have exported only one view manager." }
191
464
 
192
465
  val viewManagerDefinitionBuilder = ViewManagerDefinitionBuilder()
@@ -194,73 +467,133 @@ class ModuleDefinitionBuilder(private val module: Module? = null) {
194
467
  viewManagerDefinition = viewManagerDefinitionBuilder.build()
195
468
  }
196
469
 
470
+ @Deprecated(
471
+ message = "The 'onCreate' component was renamed to 'OnCreate'.",
472
+ replaceWith = ReplaceWith("OnCreate(body)")
473
+ )
474
+ inline fun onCreate(crossinline body: () -> Unit) = OnCreate(body)
475
+
197
476
  /**
198
477
  * Creates module's lifecycle listener that is called right after the module initialization.
199
478
  */
200
- inline fun onCreate(crossinline body: () -> Unit) {
479
+ inline fun OnCreate(crossinline body: () -> Unit) {
201
480
  eventListeners[EventName.MODULE_CREATE] = BasicEventListener(EventName.MODULE_CREATE) { body() }
202
481
  }
203
482
 
483
+ @Deprecated(
484
+ message = "The 'onDestroy' component was renamed to 'OnDestroy'.",
485
+ replaceWith = ReplaceWith("OnDestroy(body)")
486
+ )
487
+ inline fun onDestroy(crossinline body: () -> Unit) = OnDestroy(body)
488
+
204
489
  /**
205
490
  * Creates module's lifecycle listener that is called when the module is about to be deallocated.
206
491
  */
207
- inline fun onDestroy(crossinline body: () -> Unit) {
492
+ inline fun OnDestroy(crossinline body: () -> Unit) {
208
493
  eventListeners[EventName.MODULE_DESTROY] = BasicEventListener(EventName.MODULE_DESTROY) { body() }
209
494
  }
210
495
 
496
+ @Deprecated(
497
+ message = "The 'onActivityEntersForeground' component was renamed to 'OnActivityEntersForeground'.",
498
+ replaceWith = ReplaceWith("OnActivityEntersForeground(body)")
499
+ )
500
+ inline fun onActivityEntersForeground(crossinline body: () -> Unit) = OnActivityEntersForeground(body)
501
+
211
502
  /**
212
503
  * Creates module's lifecycle listener that is called right after the activity is resumed.
213
504
  */
214
- inline fun onActivityEntersForeground(crossinline body: () -> Unit) {
505
+ inline fun OnActivityEntersForeground(crossinline body: () -> Unit) {
215
506
  eventListeners[EventName.ACTIVITY_ENTERS_FOREGROUND] = BasicEventListener(EventName.ACTIVITY_ENTERS_FOREGROUND) { body() }
216
507
  }
217
508
 
509
+ @Deprecated(
510
+ message = "The 'onActivityEntersBackground' component was renamed to 'OnActivityEntersBackground'.",
511
+ replaceWith = ReplaceWith("OnActivityEntersBackground(body)")
512
+ )
513
+ inline fun onActivityEntersBackground(crossinline body: () -> Unit) = OnActivityEntersBackground(body)
514
+
218
515
  /**
219
516
  * Creates module's lifecycle listener that is called right after the activity is paused.
220
517
  */
221
- inline fun onActivityEntersBackground(crossinline body: () -> Unit) {
518
+ inline fun OnActivityEntersBackground(crossinline body: () -> Unit) {
222
519
  eventListeners[EventName.ACTIVITY_ENTERS_BACKGROUND] = BasicEventListener(EventName.ACTIVITY_ENTERS_BACKGROUND) { body() }
223
520
  }
224
521
 
522
+ @Deprecated(
523
+ message = "The 'onActivityDestroys' component was renamed to 'OnActivityDestroys'.",
524
+ replaceWith = ReplaceWith("OnActivityDestroys(body)")
525
+ )
526
+ inline fun onActivityDestroys(crossinline body: () -> Unit) = OnActivityDestroys(body)
527
+
225
528
  /**
226
529
  * Creates module's lifecycle listener that is called right after the activity is destroyed.
227
530
  */
228
- inline fun onActivityDestroys(crossinline body: () -> Unit) {
531
+ inline fun OnActivityDestroys(crossinline body: () -> Unit) {
229
532
  eventListeners[EventName.ACTIVITY_DESTROYS] = BasicEventListener(EventName.ACTIVITY_DESTROYS) { body() }
230
533
  }
231
534
 
535
+ @Deprecated(
536
+ message = "The 'events' component was renamed to 'Events'.",
537
+ replaceWith = ReplaceWith("Events(events)")
538
+ )
539
+ fun events(vararg events: String) = Events(*events)
540
+
232
541
  /**
233
542
  * Defines event names that this module can send to JavaScript.
234
543
  */
235
- fun events(vararg events: String) {
544
+ fun Events(vararg events: String) {
236
545
  eventsDefinition = EventsDefinition(events)
237
546
  }
238
547
 
548
+ @Deprecated(
549
+ message = "The 'onStartObserving' component was renamed to 'OnStartObserving'.",
550
+ replaceWith = ReplaceWith("OnStartObserving(body)")
551
+ )
552
+ inline fun onStartObserving(crossinline body: () -> Unit) = OnStartObserving(body)
553
+
239
554
  /**
240
555
  * Creates module's lifecycle listener that is called right after the first event listener is added.
241
556
  */
242
- inline fun onStartObserving(crossinline body: () -> Unit) {
243
- function("startObserving", body)
557
+ inline fun OnStartObserving(crossinline body: () -> Unit) {
558
+ AsyncFunction("startObserving", body)
244
559
  }
245
560
 
561
+ @Deprecated(
562
+ message = "The 'onStopObserving' component was renamed to 'OnStopObserving'.",
563
+ replaceWith = ReplaceWith("OnStopObserving(body)")
564
+ )
565
+ inline fun onStopObserving(crossinline body: () -> Unit) = OnStopObserving(body)
566
+
246
567
  /**
247
568
  * Creates module's lifecycle listener that is called right after all event listeners are removed.
248
569
  */
249
- inline fun onStopObserving(crossinline body: () -> Unit) {
250
- function("stopObserving", body)
570
+ inline fun OnStopObserving(crossinline body: () -> Unit) {
571
+ AsyncFunction("stopObserving", body)
251
572
  }
252
573
 
574
+ @Deprecated(
575
+ message = "The 'onNewIntent' component was renamed to 'OnNewIntent'.",
576
+ replaceWith = ReplaceWith("OnNewIntent(body)")
577
+ )
578
+ inline fun onNewIntent(crossinline body: (Intent) -> Unit) = OnNewIntent(body)
579
+
253
580
  /**
254
581
  * Creates module's lifecycle listener that is called right after the new intent was received.
255
582
  */
256
- inline fun onNewIntent(crossinline body: (Intent) -> Unit) {
583
+ inline fun OnNewIntent(crossinline body: (Intent) -> Unit) {
257
584
  eventListeners[EventName.ON_NEW_INTENT] = EventListenerWithPayload<Intent>(EventName.ON_NEW_INTENT) { body(it) }
258
585
  }
259
586
 
587
+ @Deprecated(
588
+ message = "The 'onActivityResult' component was renamed to 'OnActivityResult'.",
589
+ replaceWith = ReplaceWith("OnActivityResult(body)")
590
+ )
591
+ inline fun onActivityResult(crossinline body: (Activity, OnActivityResultPayload) -> Unit) = OnActivityResult(body)
592
+
260
593
  /**
261
594
  * Creates module's lifecycle listener that is called right after the activity has received a result.
262
595
  */
263
- inline fun onActivityResult(crossinline body: (Activity, OnActivityResultPayload) -> Unit) {
596
+ inline fun OnActivityResult(crossinline body: (Activity, OnActivityResultPayload) -> Unit) {
264
597
  eventListeners[EventName.ON_ACTIVITY_RESULT] =
265
598
  EventListenerWithSenderAndPayload<Activity, OnActivityResultPayload>(EventName.ON_ACTIVITY_RESULT) { sender, payload -> body(sender, payload) }
266
599
  }
@@ -3,13 +3,13 @@ package expo.modules.kotlin.modules
3
3
  import expo.modules.kotlin.events.EventListener
4
4
  import expo.modules.kotlin.events.EventName
5
5
  import expo.modules.kotlin.events.EventsDefinition
6
- import expo.modules.kotlin.methods.AnyMethod
6
+ import expo.modules.kotlin.functions.AnyFunction
7
7
  import expo.modules.kotlin.views.ViewManagerDefinition
8
8
 
9
9
  class ModuleDefinitionData(
10
10
  val name: String,
11
11
  val constantsProvider: () -> Map<String, Any?>,
12
- val methods: Map<String, AnyMethod>,
12
+ val methods: Map<String, AnyFunction>,
13
13
  val viewManagerDefinition: ViewManagerDefinition? = null,
14
14
  val eventListeners: Map<EventName, EventListener> = emptyMap(),
15
15
  val eventsDefinition: EventsDefinition? = null