expo-modules-core 0.6.5 → 0.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (219) hide show
  1. package/CHANGELOG.md +57 -0
  2. package/README.md +1 -1
  3. package/android/ExpoModulesCorePlugin.gradle +15 -0
  4. package/android/build.gradle +31 -15
  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 +23 -5
  13. package/android/src/main/java/expo/modules/kotlin/DynamicExtenstions.kt +5 -3
  14. package/android/src/main/java/expo/modules/kotlin/KPromiseWrapper.kt +3 -8
  15. package/android/src/main/java/expo/modules/kotlin/KotlinInteropModuleRegistry.kt +24 -9
  16. package/android/src/main/java/expo/modules/kotlin/ModuleHolder.kt +12 -7
  17. package/android/src/main/java/expo/modules/kotlin/ModuleRegistry.kt +23 -1
  18. package/android/src/main/java/expo/modules/kotlin/Promise.kt +1 -1
  19. package/android/src/main/java/expo/modules/kotlin/callbacks/Callback.kt +5 -0
  20. package/android/src/main/java/expo/modules/kotlin/callbacks/ViewCallback.kt +39 -0
  21. package/android/src/main/java/expo/modules/kotlin/callbacks/ViewCallbackDelegate.kt +27 -0
  22. package/android/src/main/java/expo/modules/kotlin/defaultmodules/ErrorManagerModule.kt +25 -0
  23. package/android/src/main/java/expo/modules/kotlin/events/EventEmitter.kt +13 -0
  24. package/android/src/main/java/expo/modules/kotlin/events/KModuleEventEmitterWrapper.kt +102 -0
  25. package/android/src/main/java/expo/modules/kotlin/exception/CodedException.kt +93 -9
  26. package/android/src/main/java/expo/modules/kotlin/exception/ExceptionDecorator.kt +11 -0
  27. package/android/src/main/java/expo/modules/kotlin/{methods/AnyMethod.kt → functions/AnyFunction.kt} +18 -18
  28. package/android/src/main/java/expo/modules/kotlin/functions/AsyncFunction.kt +15 -0
  29. package/android/src/main/java/expo/modules/kotlin/functions/AsyncFunctionBuilder.kt +170 -0
  30. package/android/src/main/java/expo/modules/kotlin/functions/AsyncFunctionWithPromise.kt +15 -0
  31. package/android/src/main/java/expo/modules/kotlin/functions/AsyncSuspendFunction.kt +36 -0
  32. package/android/src/main/java/expo/modules/kotlin/modules/DefinitionMarker.kt +4 -0
  33. package/android/src/main/java/expo/modules/kotlin/modules/Module.kt +17 -2
  34. package/android/src/main/java/expo/modules/kotlin/modules/ModuleDefinitionBuilder.kt +416 -43
  35. package/android/src/main/java/expo/modules/kotlin/modules/ModuleDefinitionData.kt +2 -2
  36. package/android/src/main/java/expo/modules/kotlin/records/FieldValidator.kt +139 -0
  37. package/android/src/main/java/expo/modules/kotlin/records/RecordTypeConverter.kt +71 -15
  38. package/android/src/main/java/expo/modules/kotlin/records/Required.kt +5 -0
  39. package/android/src/main/java/expo/modules/kotlin/records/ValidationBinder.kt +110 -0
  40. package/android/src/main/java/expo/modules/kotlin/records/Validators.kt +61 -0
  41. package/android/src/main/java/expo/modules/kotlin/types/ArrayTypeConverter.kt +11 -5
  42. package/android/src/main/java/expo/modules/kotlin/types/JSTypeConverter.kt +35 -0
  43. package/android/src/main/java/expo/modules/kotlin/types/JSTypeConverterHelper.kt +148 -0
  44. package/android/src/main/java/expo/modules/kotlin/types/ListTypeConverter.kt +10 -4
  45. package/android/src/main/java/expo/modules/kotlin/types/MapTypeConverter.kt +12 -6
  46. package/android/src/main/java/expo/modules/kotlin/types/PairTypeConverter.kt +29 -13
  47. package/android/src/main/java/expo/modules/kotlin/types/TypeConverter.kt +2 -1
  48. package/android/src/main/java/expo/modules/kotlin/types/TypeConverterProvider.kt +9 -1
  49. package/android/src/main/java/expo/modules/kotlin/views/CallbacksDefinition.kt +3 -0
  50. package/android/src/main/java/expo/modules/kotlin/views/GroupViewManagerWrapper.kt +71 -0
  51. package/android/src/main/java/expo/modules/kotlin/views/SimpleViewManagerWrapper.kt +22 -0
  52. package/android/src/main/java/expo/modules/kotlin/views/ViewGroupDefinition.kt +18 -0
  53. package/android/src/main/java/expo/modules/kotlin/views/ViewGroupDefinitionBuilder.kt +114 -0
  54. package/android/src/main/java/expo/modules/kotlin/views/ViewManagerDefinition.kt +30 -2
  55. package/android/src/main/java/expo/modules/kotlin/views/ViewManagerDefinitionBuilder.kt +81 -2
  56. package/android/src/main/java/expo/modules/kotlin/views/ViewManagerWrapperDelegate.kt +62 -2
  57. package/build/EventEmitter.d.ts +1 -0
  58. package/build/EventEmitter.d.ts.map +1 -0
  59. package/build/NativeModulesProxy.d.ts +1 -0
  60. package/build/NativeModulesProxy.d.ts.map +1 -0
  61. package/build/NativeModulesProxy.native.d.ts +1 -4
  62. package/build/NativeModulesProxy.native.d.ts.map +1 -0
  63. package/build/NativeModulesProxy.native.js +1 -14
  64. package/build/NativeModulesProxy.native.js.map +1 -1
  65. package/build/NativeModulesProxy.types.d.ts +1 -3
  66. package/build/NativeModulesProxy.types.d.ts.map +1 -0
  67. package/build/NativeModulesProxy.types.js.map +1 -1
  68. package/build/NativeViewManagerAdapter.d.ts +1 -0
  69. package/build/NativeViewManagerAdapter.d.ts.map +1 -0
  70. package/build/NativeViewManagerAdapter.native.d.ts +1 -0
  71. package/build/NativeViewManagerAdapter.native.d.ts.map +1 -0
  72. package/build/NativeViewManagerAdapter.native.js +9 -33
  73. package/build/NativeViewManagerAdapter.native.js.map +1 -1
  74. package/build/PermissionsHook.d.ts +1 -0
  75. package/build/PermissionsHook.d.ts.map +1 -0
  76. package/build/PermissionsInterface.d.ts +1 -0
  77. package/build/PermissionsInterface.d.ts.map +1 -0
  78. package/build/Platform.d.ts +1 -0
  79. package/build/Platform.d.ts.map +1 -0
  80. package/build/SyntheticPlatformEmitter.d.ts +1 -0
  81. package/build/SyntheticPlatformEmitter.d.ts.map +1 -0
  82. package/build/SyntheticPlatformEmitter.web.d.ts +1 -0
  83. package/build/SyntheticPlatformEmitter.web.d.ts.map +1 -0
  84. package/build/deprecate.d.ts +1 -0
  85. package/build/deprecate.d.ts.map +1 -0
  86. package/build/environment/browser.d.ts +1 -0
  87. package/build/environment/browser.d.ts.map +1 -0
  88. package/build/environment/browser.web.d.ts +1 -0
  89. package/build/environment/browser.web.d.ts.map +1 -0
  90. package/build/errors/CodedError.d.ts +1 -0
  91. package/build/errors/CodedError.d.ts.map +1 -0
  92. package/build/errors/UnavailabilityError.d.ts +1 -0
  93. package/build/errors/UnavailabilityError.d.ts.map +1 -0
  94. package/build/index.d.ts +3 -0
  95. package/build/index.d.ts.map +1 -0
  96. package/build/index.js +2 -0
  97. package/build/index.js.map +1 -1
  98. package/build/requireNativeModule.d.ts +16 -0
  99. package/build/requireNativeModule.d.ts.map +1 -0
  100. package/build/requireNativeModule.js +18 -0
  101. package/build/requireNativeModule.js.map +1 -0
  102. package/build/sweet/NativeErrorManager.d.ts +3 -0
  103. package/build/sweet/NativeErrorManager.d.ts.map +1 -0
  104. package/build/sweet/NativeErrorManager.js +3 -0
  105. package/build/sweet/NativeErrorManager.js.map +1 -0
  106. package/build/sweet/setUpErrorManager.fx.d.ts +2 -0
  107. package/build/sweet/setUpErrorManager.fx.d.ts.map +1 -0
  108. package/build/sweet/setUpErrorManager.fx.js +11 -0
  109. package/build/sweet/setUpErrorManager.fx.js.map +1 -0
  110. package/ios/AppDelegates/EXAppDelegatesLoader.m +4 -8
  111. package/ios/AppDelegates/ExpoAppDelegate.swift +22 -20
  112. package/ios/EXAppDefines.h +1 -0
  113. package/ios/EXAppDefines.m +6 -0
  114. package/ios/EXUtilities.h +2 -0
  115. package/ios/EXUtilities.m +12 -0
  116. package/ios/ExpoModulesCore.h +4 -0
  117. package/ios/ExpoModulesCore.podspec +4 -2
  118. package/ios/Interfaces/FileSystem/EXFileSystemInterface.h +1 -1
  119. package/ios/Interfaces/TaskManager/EXTaskServiceInterface.h +1 -0
  120. package/ios/JSI/{JSIConversions.h → EXJSIConversions.h} +5 -0
  121. package/ios/JSI/{JSIConversions.mm → EXJSIConversions.mm} +21 -1
  122. package/ios/JSI/{JSIInstaller.h → EXJSIInstaller.h} +10 -0
  123. package/ios/JSI/EXJSIInstaller.mm +17 -0
  124. package/ios/JSI/EXJSIUtils.h +19 -0
  125. package/ios/JSI/EXJSIUtils.mm +89 -0
  126. package/ios/JSI/EXJavaScriptObject.h +97 -0
  127. package/ios/JSI/EXJavaScriptObject.mm +121 -0
  128. package/ios/JSI/EXJavaScriptRuntime.h +73 -0
  129. package/ios/JSI/EXJavaScriptRuntime.mm +153 -0
  130. package/ios/JSI/EXJavaScriptValue.h +57 -0
  131. package/ios/JSI/EXJavaScriptValue.mm +166 -0
  132. package/ios/JSI/ExpoModulesHostObject.h +33 -0
  133. package/ios/JSI/ExpoModulesHostObject.mm +41 -0
  134. package/ios/JSI/JavaScriptRuntime.swift +32 -0
  135. package/ios/JSI/JavaScriptValue.swift +94 -0
  136. package/ios/ModuleRegistryAdapter/EXModuleRegistryAdapter.m +3 -23
  137. package/ios/NativeModulesProxy/EXNativeModulesProxy.h +2 -2
  138. package/ios/NativeModulesProxy/EXNativeModulesProxy.mm +101 -75
  139. package/ios/RCTComponentData+Privates.h +12 -0
  140. package/ios/ReactDelegates/EXReactCompatibleHelpers.h +18 -0
  141. package/ios/ReactDelegates/EXReactCompatibleHelpers.m +19 -0
  142. package/ios/ReactDelegates/ExpoReactDelegate.swift +3 -3
  143. package/ios/ReactDelegates/ExpoReactDelegateHandler.swift +4 -4
  144. package/ios/ReactDelegates/ModulePriorities.swift +1 -1
  145. package/ios/Swift/AppContext.swift +57 -4
  146. package/ios/Swift/Arguments/AnyArgumentType.swift +1 -1
  147. package/ios/Swift/Arguments/ArgumentType.swift +4 -0
  148. package/ios/Swift/Arguments/Convertibles.swift +13 -13
  149. package/ios/Swift/Arguments/Types/EnumArgumentType.swift +11 -17
  150. package/ios/Swift/Arguments/Types/PromiseArgumentType.swift +1 -1
  151. package/ios/Swift/Arguments/Types/RawArgumentType.swift +2 -2
  152. package/ios/Swift/Conversions.swift +51 -56
  153. package/ios/Swift/EventListener.swift +8 -10
  154. package/ios/Swift/Events/Callback.swift +66 -0
  155. package/ios/Swift/Events/Event.swift +43 -0
  156. package/ios/Swift/Exceptions/ChainableException.swift +51 -0
  157. package/ios/Swift/{CodedError.swift → Exceptions/CodedError.swift} +1 -12
  158. package/ios/Swift/Exceptions/Exception.swift +62 -0
  159. package/ios/Swift/Exceptions/ExceptionOrigin.swift +28 -0
  160. package/ios/Swift/Exceptions/GenericException.swift +20 -0
  161. package/ios/Swift/Exceptions/UnexpectedException.swift +16 -0
  162. package/ios/Swift/Functions/AnyFunction.swift +16 -1
  163. package/ios/Swift/Functions/AsyncFunctionComponent.swift +182 -0
  164. package/ios/Swift/Functions/ConcreteFunction.swift +52 -59
  165. package/ios/Swift/Functions/SyncFunctionComponent.swift +181 -0
  166. package/ios/Swift/JavaScriptUtils.swift +99 -0
  167. package/ios/Swift/ModuleHolder.swift +69 -18
  168. package/ios/Swift/ModuleRegistry.swift +4 -1
  169. package/ios/Swift/Modules/AnyModule.swift +0 -1
  170. package/ios/Swift/Modules/ModuleDefinition.swift +4 -13
  171. package/ios/Swift/Modules/ModuleDefinitionBuilder.swift +0 -1
  172. package/ios/Swift/Modules/ModuleDefinitionComponents.swift +54 -220
  173. package/ios/Swift/ModulesProvider.swift +3 -11
  174. package/ios/Swift/Objects/ObjectDefinition.swift +30 -0
  175. package/ios/Swift/Objects/ObjectDefinitionComponents.swift +257 -0
  176. package/ios/Swift/Promise.swift +8 -3
  177. package/ios/Swift/Records/AnyField.swift +7 -0
  178. package/ios/Swift/Records/Field.swift +24 -19
  179. package/ios/Swift/Records/FieldOption.swift +1 -1
  180. package/ios/Swift/Records/Record.swift +12 -4
  181. package/ios/Swift/SwiftInteropBridge.swift +53 -15
  182. package/ios/Swift/Views/AnyViewProp.swift +1 -1
  183. package/ios/Swift/Views/ComponentData.swift +96 -0
  184. package/ios/Swift/Views/ConcreteViewProp.swift +6 -8
  185. package/ios/Swift/Views/ExpoView.swift +8 -0
  186. package/ios/Swift/Views/ViewFactory.swift +1 -1
  187. package/ios/Swift/Views/ViewManagerDefinition.swift +23 -2
  188. package/ios/Swift/Views/ViewManagerDefinitionBuilder.swift +0 -1
  189. package/ios/Swift/Views/ViewManagerDefinitionComponents.swift +49 -0
  190. package/ios/Swift/Views/ViewModuleWrapper.swift +5 -2
  191. package/ios/Swift.h +5 -0
  192. package/ios/Tests/ArgumentTypeSpec.swift +5 -7
  193. package/ios/Tests/ConstantsSpec.swift +6 -7
  194. package/ios/Tests/ConvertiblesSpec.swift +35 -36
  195. package/ios/Tests/ExceptionsSpec.swift +111 -0
  196. package/ios/Tests/ExpoModulesSpec.swift +75 -0
  197. package/ios/Tests/FunctionSpec.swift +21 -25
  198. package/ios/Tests/FunctionWithConvertiblesSpec.swift +4 -5
  199. package/ios/Tests/JavaScriptObjectSpec.swift +97 -0
  200. package/ios/Tests/JavaScriptRuntimeSpec.swift +94 -0
  201. package/ios/Tests/Mocks/ModuleMocks.swift +1 -1
  202. package/ios/Tests/Mocks/ModulesProviderMock.swift +0 -1
  203. package/ios/Tests/ModuleEventListenersSpec.swift +16 -17
  204. package/ios/Tests/ModuleRegistrySpec.swift +2 -3
  205. package/ios/Tests/RecordSpec.swift +9 -20
  206. package/package.json +3 -3
  207. package/src/NativeModulesProxy.native.ts +2 -22
  208. package/src/NativeModulesProxy.types.ts +0 -8
  209. package/src/NativeViewManagerAdapter.native.tsx +12 -28
  210. package/src/index.ts +4 -0
  211. package/src/requireNativeModule.ts +29 -0
  212. package/src/sweet/NativeErrorManager.ts +2 -0
  213. package/src/sweet/setUpErrorManager.fx.ts +12 -0
  214. package/android/src/main/java/expo/modules/kotlin/events/KEventEmitterWrapper.kt +0 -26
  215. package/android/src/main/java/expo/modules/kotlin/methods/Method.kt +0 -14
  216. package/android/src/main/java/expo/modules/kotlin/methods/PromiseMethod.kt +0 -15
  217. package/ios/JSI/ExpoModulesProxySpec.h +0 -24
  218. package/ios/JSI/ExpoModulesProxySpec.mm +0 -135
  219. package/ios/JSI/JSIInstaller.mm +0 -22
@@ -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,21 +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
- class ModuleDefinitionBuilder {
36
+ @DefinitionMarker
37
+ class ModuleDefinitionBuilder(@PublishedApi internal val module: Module? = null) {
35
38
  private var name: String? = null
36
39
  private var constantsProvider = { emptyMap<String, Any?>() }
37
40
  private var eventsDefinition: EventsDefinition? = null
41
+ private var functionBuilders = mutableListOf<AsyncFunctionBuilder>()
38
42
 
39
43
  @PublishedApi
40
- internal var methods = mutableMapOf<String, AnyMethod>()
44
+ internal var methods = mutableMapOf<String, AnyFunction>()
41
45
 
42
46
  @PublishedApi
43
47
  internal var viewManagerDefinition: ViewManagerDefinition? = null
@@ -46,128 +50,416 @@ class ModuleDefinitionBuilder {
46
50
  internal val eventListeners = mutableMapOf<EventName, EventListener>()
47
51
 
48
52
  fun build(): ModuleDefinitionData {
53
+ val moduleName = name ?: module?.javaClass?.simpleName
54
+
49
55
  return ModuleDefinitionData(
50
- requireNotNull(name),
56
+ requireNotNull(moduleName),
51
57
  constantsProvider,
52
- methods,
58
+ methods + functionBuilders.associate { it.build() },
53
59
  viewManagerDefinition,
54
60
  eventListeners,
55
61
  eventsDefinition
56
62
  )
57
63
  }
58
64
 
59
- fun name(name: String) {
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
+
71
+ /**
72
+ * Sets the name of the module that is exported to the JavaScript world.
73
+ */
74
+ fun Name(name: String) {
60
75
  this.name = name
61
76
  }
62
77
 
63
- fun constants(constantsProvider: () -> Map<String, Any?>) {
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
+
84
+ /**
85
+ * Definition function setting the module's constants to export.
86
+ */
87
+ fun Constants(constantsProvider: () -> Map<String, Any?>) {
64
88
  this.constantsProvider = constantsProvider
65
89
  }
66
90
 
67
- @JvmName("methodWithoutArgs")
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
+
97
+ /**
98
+ * Definition of the module's constants to export.
99
+ */
100
+ fun Constants(vararg constants: Pair<String, Any?>) {
101
+ constantsProvider = { constants.toMap() }
102
+ }
103
+
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")
68
109
  inline fun function(
69
110
  name: String,
70
111
  crossinline body: () -> Any?
71
112
  ) {
72
- methods[name] = Method(name, arrayOf()) { body() }
113
+ methods[name] = AsyncFunction(name, arrayOf()) { body() }
73
114
  }
74
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
+ )
75
120
  inline fun <reified R> function(
76
121
  name: String,
77
122
  crossinline body: () -> R
78
123
  ) {
79
- methods[name] = Method(name, arrayOf()) { body() }
124
+ methods[name] = AsyncFunction(name, arrayOf()) { body() }
80
125
  }
81
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
+ )
82
131
  inline fun <reified R, reified P0> function(
83
132
  name: String,
84
133
  crossinline body: (p0: P0) -> R
85
134
  ) {
86
135
  methods[name] = if (P0::class == Promise::class) {
87
- PromiseMethod(name, arrayOf()) { _, promise -> body(promise as P0) }
136
+ AsyncFunctionWithPromise(name, arrayOf()) { _, promise -> body(promise as P0) }
88
137
  } else {
89
- Method(name, arrayOf(typeOf<P0>().toAnyType())) { body(it[0] as P0) }
138
+ AsyncFunction(name, arrayOf(typeOf<P0>().toAnyType())) { body(it[0] as P0) }
90
139
  }
91
140
  }
92
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
+ )
93
146
  inline fun <reified R, reified P0, reified P1> function(
94
147
  name: String,
95
148
  crossinline body: (p0: P0, p1: P1) -> R
96
149
  ) {
97
150
  methods[name] = if (P1::class == Promise::class) {
98
- 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) }
99
152
  } else {
100
- 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) }
101
154
  }
102
155
  }
103
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
+ )
104
161
  inline fun <reified R, reified P0, reified P1, reified P2> function(
105
162
  name: String,
106
163
  crossinline body: (p0: P0, p1: P1, p2: P2) -> R
107
164
  ) {
108
165
  methods[name] = if (P2::class == Promise::class) {
109
- 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) }
110
167
  } else {
111
- 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) }
112
169
  }
113
170
  }
114
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
+ )
115
176
  inline fun <reified R, reified P0, reified P1, reified P2, reified P3> function(
116
177
  name: String,
117
178
  crossinline body: (p0: P0, p1: P1, p2: P2, p3: P3) -> R
118
179
  ) {
119
180
  methods[name] = if (P3::class == Promise::class) {
120
- 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) }
121
182
  } else {
122
- 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) }
123
184
  }
124
185
  }
125
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
+ )
126
191
  inline fun <reified R, reified P0, reified P1, reified P2, reified P3, reified P4> function(
127
192
  name: String,
128
193
  crossinline body: (p0: P0, p1: P1, p2: P2, p3: P3, p4: P4) -> R
129
194
  ) {
130
195
  methods[name] = if (P4::class == Promise::class) {
131
- 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) }
132
197
  } else {
133
- 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) }
134
199
  }
135
200
  }
136
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
+ )
137
206
  inline fun <reified R, reified P0, reified P1, reified P2, reified P3, reified P4, reified P5> function(
138
207
  name: String,
139
208
  crossinline body: (p0: P0, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5) -> R
140
209
  ) {
141
210
  methods[name] = if (P5::class == Promise::class) {
142
- 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) }
143
212
  } else {
144
- 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) }
145
214
  }
146
215
  }
147
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
+ )
148
221
  inline fun <reified R, reified P0, reified P1, reified P2, reified P3, reified P4, reified P5, reified P6> function(
149
222
  name: String,
150
223
  crossinline body: (p0: P0, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6) -> R
151
224
  ) {
152
225
  methods[name] = if (P6::class == Promise::class) {
153
- 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) }
154
227
  } else {
155
- 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) }
156
229
  }
157
230
  }
158
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
+ )
159
236
  inline fun <reified R, reified P0, reified P1, reified P2, reified P3, reified P4, reified P5, reified P6, reified P7> function(
160
237
  name: String,
161
238
  crossinline body: (p0: P0, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7) -> R
162
239
  ) {
163
240
  methods[name] = if (P7::class == Promise::class) {
164
- 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) }
165
242
  } else {
166
- 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) }
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) }
167
244
  }
168
245
  }
169
246
 
170
- inline fun viewManager(body: ViewManagerDefinitionBuilder.() -> Unit) {
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) }
436
+ } else {
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) }
438
+ }
439
+ }
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
+
459
+ /**
460
+ * Creates the view manager definition that scopes other view-related definitions.
461
+ */
462
+ inline fun ViewManager(body: ViewManagerDefinitionBuilder.() -> Unit) {
171
463
  require(viewManagerDefinition == null) { "The module definition may have exported only one view manager." }
172
464
 
173
465
  val viewManagerDefinitionBuilder = ViewManagerDefinitionBuilder()
@@ -175,52 +467,133 @@ class ModuleDefinitionBuilder {
175
467
  viewManagerDefinition = viewManagerDefinitionBuilder.build()
176
468
  }
177
469
 
178
- inline fun onCreate(crossinline body: () -> Unit) {
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
+
476
+ /**
477
+ * Creates module's lifecycle listener that is called right after the module initialization.
478
+ */
479
+ inline fun OnCreate(crossinline body: () -> Unit) {
179
480
  eventListeners[EventName.MODULE_CREATE] = BasicEventListener(EventName.MODULE_CREATE) { body() }
180
481
  }
181
482
 
182
- inline fun onDestroy(crossinline body: () -> Unit) {
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
+
489
+ /**
490
+ * Creates module's lifecycle listener that is called when the module is about to be deallocated.
491
+ */
492
+ inline fun OnDestroy(crossinline body: () -> Unit) {
183
493
  eventListeners[EventName.MODULE_DESTROY] = BasicEventListener(EventName.MODULE_DESTROY) { body() }
184
494
  }
185
495
 
186
- inline fun onActivityEntersForeground(crossinline body: () -> Unit) {
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
+
502
+ /**
503
+ * Creates module's lifecycle listener that is called right after the activity is resumed.
504
+ */
505
+ inline fun OnActivityEntersForeground(crossinline body: () -> Unit) {
187
506
  eventListeners[EventName.ACTIVITY_ENTERS_FOREGROUND] = BasicEventListener(EventName.ACTIVITY_ENTERS_FOREGROUND) { body() }
188
507
  }
189
508
 
190
- inline fun onActivityEntersBackground(crossinline body: () -> Unit) {
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
+
515
+ /**
516
+ * Creates module's lifecycle listener that is called right after the activity is paused.
517
+ */
518
+ inline fun OnActivityEntersBackground(crossinline body: () -> Unit) {
191
519
  eventListeners[EventName.ACTIVITY_ENTERS_BACKGROUND] = BasicEventListener(EventName.ACTIVITY_ENTERS_BACKGROUND) { body() }
192
520
  }
193
521
 
194
- inline fun onActivityDestroys(crossinline body: () -> Unit) {
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
+
528
+ /**
529
+ * Creates module's lifecycle listener that is called right after the activity is destroyed.
530
+ */
531
+ inline fun OnActivityDestroys(crossinline body: () -> Unit) {
195
532
  eventListeners[EventName.ACTIVITY_DESTROYS] = BasicEventListener(EventName.ACTIVITY_DESTROYS) { body() }
196
533
  }
197
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
+
198
541
  /**
199
542
  * Defines event names that this module can send to JavaScript.
200
543
  */
201
- fun events(vararg events: String) {
544
+ fun Events(vararg events: String) {
202
545
  eventsDefinition = EventsDefinition(events)
203
546
  }
204
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
+
205
554
  /**
206
- * Method that is invoked when the first event listener is added.
555
+ * Creates module's lifecycle listener that is called right after the first event listener is added.
207
556
  */
208
- inline fun onStartObserving(crossinline body: () -> Unit) {
209
- function("startObserving", body)
557
+ inline fun OnStartObserving(crossinline body: () -> Unit) {
558
+ AsyncFunction("startObserving", body)
210
559
  }
211
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
+
212
567
  /**
213
- * Method that is invoked when all event listeners are removed.
568
+ * Creates module's lifecycle listener that is called right after all event listeners are removed.
214
569
  */
215
- inline fun onStopObserving(crossinline body: () -> Unit) {
216
- function("stopObserving", body)
570
+ inline fun OnStopObserving(crossinline body: () -> Unit) {
571
+ AsyncFunction("stopObserving", body)
217
572
  }
218
573
 
219
- inline fun onNewIntent(crossinline body: (Intent) -> Unit) {
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
+
580
+ /**
581
+ * Creates module's lifecycle listener that is called right after the new intent was received.
582
+ */
583
+ inline fun OnNewIntent(crossinline body: (Intent) -> Unit) {
220
584
  eventListeners[EventName.ON_NEW_INTENT] = EventListenerWithPayload<Intent>(EventName.ON_NEW_INTENT) { body(it) }
221
585
  }
222
586
 
223
- inline fun onActivityResult(crossinline body: (Activity, OnActivityResultPayload) -> Unit) {
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
+
593
+ /**
594
+ * Creates module's lifecycle listener that is called right after the activity has received a result.
595
+ */
596
+ inline fun OnActivityResult(crossinline body: (Activity, OnActivityResultPayload) -> Unit) {
224
597
  eventListeners[EventName.ON_ACTIVITY_RESULT] =
225
598
  EventListenerWithSenderAndPayload<Activity, OnActivityResultPayload>(EventName.ON_ACTIVITY_RESULT) { sender, payload -> body(sender, payload) }
226
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