expo-modules-core 1.11.13 → 1.12.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.
- package/CHANGELOG.md +77 -13
- package/ExpoModulesCore.podspec +7 -4
- package/android/ExpoModulesCorePlugin.gradle +40 -28
- package/android/build.gradle +12 -93
- package/android/proguard-rules.pro +0 -8
- package/android/src/main/cpp/Exceptions.cpp +1 -1
- package/android/src/main/cpp/Exceptions.h +1 -1
- package/android/src/main/cpp/ExpoModulesHostObject.cpp +7 -6
- package/android/src/main/cpp/ExpoModulesHostObject.h +3 -3
- package/android/src/main/cpp/JNIInjector.cpp +4 -2
- package/android/src/main/cpp/JSIContext.cpp +354 -0
- package/android/src/main/cpp/{JSIInteropModuleRegistry.h → JSIContext.h} +90 -9
- package/android/src/main/cpp/JavaCallback.cpp +210 -24
- package/android/src/main/cpp/JavaCallback.h +42 -7
- package/android/src/main/cpp/JavaScriptFunction.cpp +20 -6
- package/android/src/main/cpp/JavaScriptFunction.h +4 -1
- package/android/src/main/cpp/JavaScriptModuleObject.cpp +118 -82
- package/android/src/main/cpp/JavaScriptModuleObject.h +21 -18
- package/android/src/main/cpp/JavaScriptObject.cpp +7 -8
- package/android/src/main/cpp/JavaScriptObject.h +4 -2
- package/android/src/main/cpp/JavaScriptRuntime.cpp +18 -41
- package/android/src/main/cpp/JavaScriptRuntime.h +2 -8
- package/android/src/main/cpp/JavaScriptTypedArray.cpp +3 -3
- package/android/src/main/cpp/JavaScriptTypedArray.h +1 -1
- package/android/src/main/cpp/JavaScriptValue.cpp +7 -7
- package/android/src/main/cpp/JavaScriptValue.h +1 -1
- package/android/src/main/cpp/JavaScriptWeakObject.cpp +4 -4
- package/android/src/main/cpp/JavaScriptWeakObject.h +1 -1
- package/android/src/main/cpp/MethodMetadata.cpp +44 -120
- package/android/src/main/cpp/MethodMetadata.h +5 -11
- package/android/src/main/cpp/WeakRuntimeHolder.cpp +3 -3
- package/android/src/main/cpp/WeakRuntimeHolder.h +2 -2
- package/android/src/main/cpp/types/AnyType.cpp +1 -1
- package/android/src/main/cpp/types/AnyType.h +1 -1
- package/android/src/main/cpp/types/FrontendConverter.cpp +32 -43
- package/android/src/main/cpp/types/FrontendConverter.h +1 -23
- package/android/src/main/cpp/types/JNIToJSIConverter.cpp +5 -10
- package/android/src/main/cpp/types/JNIToJSIConverter.h +6 -2
- package/android/src/main/java/expo/modules/adapters/react/ModuleRegistryAdapter.java +3 -0
- package/android/src/main/java/expo/modules/adapters/react/NativeModulesProxy.java +14 -100
- package/android/src/main/java/expo/modules/adapters/react/ReactAdapterPackage.java +3 -5
- package/android/src/main/java/expo/modules/adapters/react/ReactModuleRegistryProvider.java +6 -22
- package/android/src/main/java/expo/modules/adapters/react/apploader/RNHeadlessAppLoader.kt +8 -4
- package/android/src/main/java/expo/modules/adapters/react/services/EventEmitterModule.java +0 -1
- package/android/src/main/java/expo/modules/adapters/react/services/UIManagerModuleWrapper.java +23 -8
- package/android/src/main/java/expo/modules/core/BasePackage.java +0 -10
- package/android/src/main/java/expo/modules/core/ModulePriorities.kt +1 -0
- package/android/src/main/java/expo/modules/core/ModuleRegistry.java +2 -32
- package/android/src/main/java/expo/modules/core/ModuleRegistryProvider.java +0 -18
- package/android/src/main/java/expo/modules/core/Promise.java +2 -0
- package/android/src/main/java/expo/modules/core/interfaces/Package.java +0 -17
- package/android/src/main/java/expo/modules/core/interfaces/ReactActivityHandler.java +0 -9
- package/android/src/main/java/expo/modules/core/interfaces/ReactNativeHostHandler.java +24 -31
- package/android/src/main/java/expo/modules/core/logging/LogHandler.kt +1 -7
- package/android/src/main/java/expo/modules/core/logging/LogHandlers.kt +11 -0
- package/android/src/main/java/expo/modules/core/logging/Logger.kt +18 -29
- package/android/src/main/java/expo/modules/core/logging/LoggerTimer.kt +11 -0
- package/android/src/main/java/expo/modules/core/logging/OSLogHandler.kt +2 -4
- package/android/src/main/java/expo/modules/core/logging/PersistentFileLogHandler.kt +1 -3
- package/android/src/main/java/expo/modules/interfaces/constants/ConstantsInterface.java +0 -2
- package/android/src/main/java/expo/modules/interfaces/permissions/PermissionsStatus.java +1 -1
- package/android/src/main/java/expo/modules/kotlin/AppContext.kt +44 -24
- package/android/src/main/java/expo/modules/kotlin/ArrayExtenstions.kt +15 -0
- package/android/src/main/java/expo/modules/kotlin/CoreLogger.kt +2 -2
- package/android/src/main/java/expo/modules/kotlin/DynamicExtenstions.kt +0 -3
- package/android/src/main/java/expo/modules/kotlin/ExpoBridgeModule.kt +41 -0
- package/android/src/main/java/expo/modules/kotlin/ExpoModulesHelper.kt +1 -2
- package/android/src/main/java/expo/modules/kotlin/KPromiseWrapper.kt +1 -2
- package/android/src/main/java/expo/modules/kotlin/KotlinInteropModuleRegistry.kt +1 -33
- package/android/src/main/java/expo/modules/kotlin/ModuleHolder.kt +7 -6
- package/android/src/main/java/expo/modules/kotlin/ModuleRegistry.kt +12 -12
- package/android/src/main/java/expo/modules/kotlin/Promise.kt +10 -0
- package/android/src/main/java/expo/modules/kotlin/ReactExtensions.kt +14 -0
- package/android/src/main/java/expo/modules/kotlin/Utils.kt +4 -1
- package/android/src/main/java/expo/modules/kotlin/activityaware/AppCompatActivityAwareHelper.kt +1 -1
- package/android/src/main/java/expo/modules/kotlin/activityresult/AppContextActivityResultCaller.kt +1 -1
- package/android/src/main/java/expo/modules/kotlin/activityresult/AppContextActivityResultRegistry.kt +6 -6
- package/android/src/main/java/expo/modules/kotlin/classcomponent/ClassComponentBuilder.kt +44 -15
- package/android/src/main/java/expo/modules/kotlin/defaultmodules/CoreModule.kt +31 -1
- package/android/src/main/java/expo/modules/kotlin/defaultmodules/ErrorManagerModule.kt +2 -4
- package/android/src/main/java/expo/modules/kotlin/events/KModuleEventEmitterWrapper.kt +11 -4
- package/android/src/main/java/expo/modules/kotlin/exception/CodedException.kt +2 -3
- package/android/src/main/java/expo/modules/kotlin/functions/AsyncFunctionBuilder.kt +136 -43
- package/android/src/main/java/expo/modules/kotlin/functions/AsyncFunctionComponent.kt +71 -2
- package/android/src/main/java/expo/modules/kotlin/functions/FunctionBuilder.kt +39 -12
- package/android/src/main/java/expo/modules/kotlin/jni/ExpectedType.kt +2 -2
- package/android/src/main/java/expo/modules/kotlin/jni/JNIDeallocator.kt +1 -1
- package/android/src/main/java/expo/modules/kotlin/jni/{JSIInteropModuleRegistry.kt → JSIContext.kt} +90 -14
- package/android/src/main/java/expo/modules/kotlin/jni/JavaCallback.kt +51 -24
- package/android/src/main/java/expo/modules/kotlin/jni/JavaScriptFunction.kt +3 -3
- package/android/src/main/java/expo/modules/kotlin/jni/JavaScriptModuleObject.kt +4 -1
- package/android/src/main/java/expo/modules/kotlin/jni/JavaScriptObject.kt +1 -0
- package/android/src/main/java/expo/modules/kotlin/jni/JavaScriptValue.kt +1 -0
- package/android/src/main/java/expo/modules/kotlin/jni/PromiseImpl.kt +20 -0
- package/android/src/main/java/expo/modules/kotlin/modules/Module.kt +0 -1
- package/android/src/main/java/expo/modules/kotlin/modules/ModuleDefinitionBuilder.kt +1 -1
- package/android/src/main/java/expo/modules/kotlin/objects/ObjectDefinitionBuilder.kt +164 -65
- package/android/src/main/java/expo/modules/kotlin/objects/PropertyComponentBuilder.kt +3 -4
- package/android/src/main/java/expo/modules/kotlin/sharedobjects/ClassRegistry.kt +21 -0
- package/android/src/main/java/expo/modules/kotlin/sharedobjects/SharedObject.kt +34 -1
- package/android/src/main/java/expo/modules/kotlin/sharedobjects/SharedObjectRegistry.kt +23 -8
- package/android/src/main/java/expo/modules/kotlin/sharedobjects/SharedRef.kt +7 -1
- package/android/src/main/java/expo/modules/kotlin/tracing/ExpoTrace.kt +4 -0
- package/android/src/main/java/expo/modules/kotlin/types/AnyType.kt +134 -2
- package/android/src/main/java/expo/modules/kotlin/types/EnforceType.kt +60 -0
- package/android/src/main/java/expo/modules/kotlin/types/EnumTypeConverter.kt +2 -2
- package/android/src/main/java/expo/modules/kotlin/types/TypeConverter.kt +0 -2
- package/android/src/main/java/expo/modules/kotlin/types/TypeConverterProvider.kt +3 -27
- package/android/src/main/java/expo/modules/kotlin/types/UnitTypeConverter.kt +3 -7
- package/android/src/main/java/expo/modules/kotlin/types/io/PathTypeConverter.kt +3 -0
- package/android/src/main/java/expo/modules/kotlin/viewevent/ViewEvent.kt +2 -5
- package/android/src/main/java/expo/modules/kotlin/views/ViewDefinitionBuilder.kt +137 -48
- package/android/src/main/java/expo/modules/kotlin/views/ViewManagerDefinition.kt +2 -5
- package/build/EventEmitter.d.ts +2 -2
- package/build/EventEmitter.d.ts.map +1 -1
- package/build/EventEmitter.js +8 -8
- package/build/EventEmitter.js.map +1 -1
- package/build/NativeModule.d.ts +4 -0
- package/build/NativeModule.d.ts.map +1 -0
- package/build/NativeModule.js +4 -0
- package/build/NativeModule.js.map +1 -0
- package/build/NativeModulesProxy.native.d.ts.map +1 -1
- package/build/NativeModulesProxy.native.js +4 -0
- package/build/NativeModulesProxy.native.js.map +1 -1
- package/build/NativeModulesProxy.types.d.ts +2 -2
- package/build/NativeModulesProxy.types.d.ts.map +1 -1
- package/build/NativeModulesProxy.types.js.map +1 -1
- package/build/NativeViewManagerAdapter.native.d.ts.map +1 -1
- package/build/NativeViewManagerAdapter.native.js +20 -1
- package/build/NativeViewManagerAdapter.native.js.map +1 -1
- package/build/PermissionsHook.d.ts.map +1 -1
- package/build/PermissionsHook.js +2 -0
- package/build/PermissionsHook.js.map +1 -1
- package/build/Refs.d.ts +8 -0
- package/build/Refs.d.ts.map +1 -0
- package/build/Refs.js +10 -0
- package/build/Refs.js.map +1 -0
- package/build/SharedObject.d.ts +4 -0
- package/build/SharedObject.d.ts.map +1 -0
- package/build/SharedObject.js +4 -0
- package/build/SharedObject.js.map +1 -0
- package/build/createWebModule.d.ts +2 -0
- package/build/createWebModule.d.ts.map +1 -0
- package/build/createWebModule.js +6 -0
- package/build/createWebModule.js.map +1 -0
- package/build/createWebModule.web.d.ts +2 -0
- package/build/createWebModule.web.d.ts.map +1 -0
- package/build/createWebModule.web.js +6 -0
- package/build/createWebModule.web.js.map +1 -0
- package/build/ensureNativeModulesAreInstalled.d.ts +6 -0
- package/build/ensureNativeModulesAreInstalled.d.ts.map +1 -0
- package/build/ensureNativeModulesAreInstalled.js +26 -0
- package/build/ensureNativeModulesAreInstalled.js.map +1 -0
- package/build/hooks/useReleasingSharedObject.d.ts +7 -0
- package/build/hooks/useReleasingSharedObject.d.ts.map +1 -0
- package/build/hooks/useReleasingSharedObject.js +40 -0
- package/build/hooks/useReleasingSharedObject.js.map +1 -0
- package/build/index.d.ts +8 -1
- package/build/index.d.ts.map +1 -1
- package/build/index.js +8 -0
- package/build/index.js.map +1 -1
- package/build/requireNativeModule.d.ts +0 -17
- package/build/requireNativeModule.d.ts.map +1 -1
- package/build/requireNativeModule.js +2 -23
- package/build/requireNativeModule.js.map +1 -1
- package/build/ts-declarations/EventEmitter.d.ts +50 -0
- package/build/ts-declarations/EventEmitter.d.ts.map +1 -0
- package/build/ts-declarations/EventEmitter.js +2 -0
- package/build/ts-declarations/EventEmitter.js.map +1 -0
- package/build/ts-declarations/NativeModule.d.ts +14 -0
- package/build/ts-declarations/NativeModule.d.ts.map +1 -0
- package/build/ts-declarations/NativeModule.js +2 -0
- package/build/ts-declarations/NativeModule.js.map +1 -0
- package/build/ts-declarations/SharedObject.d.ts +14 -0
- package/build/ts-declarations/SharedObject.d.ts.map +1 -0
- package/build/ts-declarations/SharedObject.js +2 -0
- package/build/ts-declarations/SharedObject.js.map +1 -0
- package/build/ts-declarations/global.d.ts +49 -0
- package/build/ts-declarations/global.d.ts.map +1 -0
- package/build/ts-declarations/global.js +2 -0
- package/build/ts-declarations/global.js.map +1 -0
- package/build/web/CoreModule.d.ts +17 -0
- package/build/web/CoreModule.d.ts.map +1 -0
- package/build/web/CoreModule.js +51 -0
- package/build/web/CoreModule.js.map +1 -0
- package/build/web/index.d.ts +1 -0
- package/build/web/index.d.ts.map +1 -0
- package/build/web/index.js +1 -0
- package/build/web/index.js.map +1 -0
- package/build/web/index.web.d.ts +2 -0
- package/build/web/index.web.d.ts.map +1 -0
- package/build/web/index.web.js +2 -0
- package/build/web/index.web.js.map +1 -0
- package/common/cpp/BridgelessJSCallInvoker.h +41 -0
- package/common/cpp/EventEmitter.cpp +299 -0
- package/common/cpp/EventEmitter.h +111 -0
- package/common/cpp/JSIUtils.cpp +116 -11
- package/common/cpp/JSIUtils.h +54 -7
- package/common/cpp/LazyObject.cpp +15 -3
- package/common/cpp/LazyObject.h +13 -0
- package/common/cpp/NativeModule.cpp +16 -0
- package/common/cpp/NativeModule.h +34 -0
- package/common/cpp/ObjectDeallocator.cpp +3 -5
- package/common/cpp/ObjectDeallocator.h +2 -3
- package/common/cpp/SharedObject.cpp +69 -0
- package/common/cpp/SharedObject.h +59 -0
- package/common/cpp/TestingSyncJSCallInvoker.h +44 -0
- package/ios/Api/Builders/ClassComponentBuilder.swift +34 -0
- package/ios/{Objects → Api/Builders}/ObjectDefinitionBuilder.swift +3 -3
- package/ios/Api/Builders/ViewDefinitionBuilder.swift +53 -0
- package/ios/Api/Factories/AsyncFunctionFactories.swift +173 -0
- package/ios/{Classes/ClassComponentFactories.swift → Api/Factories/ClassFactories.swift} +19 -19
- package/ios/{Functions/ConcurrentFunctionDefinition.swift → Api/Factories/ConcurrentFunctionFactories.swift} +0 -113
- package/ios/{Modules/ModuleDefinitionComponents.swift → Api/Factories/EventListenersFactories.swift} +0 -20
- package/ios/Api/Factories/ModuleFactories.swift +6 -0
- package/ios/{Objects/ObjectDefinitionComponents.swift → Api/Factories/ObjectFactories.swift} +5 -5
- package/ios/Api/Factories/PropertyFactories.swift +50 -0
- package/ios/Api/Factories/SyncFunctionFactories.swift +173 -0
- package/ios/{Views/ViewManagerDefinitionComponents.swift → Api/Factories/ViewFactories.swift} +7 -6
- package/ios/AppDelegates/EXAppDelegateWrapper.h +0 -21
- package/ios/AppDelegates/EXAppDelegateWrapper.mm +37 -29
- package/ios/{AppContext.swift → Core/AppContext.swift} +34 -11
- package/ios/Core/Classes/AnyClassDefinitionElement.swift +37 -0
- package/ios/{Classes/ClassComponent.swift → Core/Classes/ClassDefinition.swift} +10 -10
- package/ios/{Conversions.swift → Core/Conversions.swift} +1 -1
- package/ios/{DynamicTypes → Core/DynamicTypes}/DynamicSharedObjectType.swift +3 -3
- package/ios/Core/Events/EventObservingDefinition.swift +79 -0
- package/ios/Core/Events/LegacyEventEmitterCompat.swift +32 -0
- package/ios/Core/ExpoBridgeModule.h +18 -0
- package/ios/Core/ExpoBridgeModule.mm +88 -0
- package/ios/Core/ExpoRuntime.swift +6 -0
- package/ios/{Functions/AnyFunction.swift → Core/Functions/AnyFunctionDefinition.swift} +9 -2
- package/ios/Core/Functions/AsyncFunctionDefinition.swift +150 -0
- package/ios/Core/Functions/ConcurrentFunctionDefinition.swift +112 -0
- package/ios/Core/Functions/SyncFunctionDefinition.swift +108 -0
- package/ios/{JavaScriptUtils.swift → Core/JavaScriptUtils.swift} +4 -4
- package/ios/{Logging → Core/Logging}/LogHandlers.swift +12 -5
- package/ios/{Logging → Core/Logging}/Logger.swift +14 -92
- package/ios/Core/Logging/LoggerTimer.swift +22 -0
- package/ios/{ModuleHolder.swift → Core/ModuleHolder.swift} +2 -10
- package/ios/Core/Modules/CoreModule.swift +43 -0
- package/ios/{Modules → Core/Modules}/ModuleDefinition.swift +20 -12
- package/ios/{Modules → Core/Modules}/ModuleDefinitionBuilder.swift +1 -3
- package/ios/{Objects → Core/Objects}/ObjectDefinition.swift +9 -9
- package/ios/{Objects/PropertyComponent.swift → Core/Objects/PropertyDefinition.swift} +11 -64
- package/ios/Core/Protocols/AnyDefinition.swift +4 -0
- package/ios/Core/Protocols/AnyExpoView.swift +7 -0
- package/ios/Core/Protocols/AnyModule.swift +17 -0
- package/ios/Core/Protocols/AnyViewDefinition.swift +34 -0
- package/ios/Core/SharedObjects/SharedObject.swift +80 -0
- package/ios/{SharedObjects → Core/SharedObjects}/SharedObjectRegistry.swift +45 -19
- package/ios/{Views → Core/Views}/AnyViewProp.swift +1 -1
- package/ios/{Views → Core/Views}/ComponentData.swift +7 -7
- package/ios/{Views → Core/Views}/ExpoView.swift +1 -1
- package/ios/Core/Views/ViewDefinition.swift +97 -0
- package/ios/{Views → Core/Views}/ViewLifecycleMethod.swift +1 -1
- package/ios/{Views → Core/Views}/ViewModuleWrapper.swift +1 -1
- package/ios/Fabric/ExpoFabricView.swift +5 -6
- package/ios/FileSystemUtilities/FileSystemLegacyUtilities.swift +111 -0
- package/ios/JSI/EXJSIInstaller.h +28 -0
- package/ios/JSI/EXJSIInstaller.mm +54 -10
- package/ios/JSI/EXJSIUtils.h +15 -11
- package/ios/JSI/EXJSIUtils.mm +21 -49
- package/ios/JSI/EXJavaScriptObject.mm +2 -2
- package/ios/JSI/EXJavaScriptRuntime.h +15 -0
- package/ios/JSI/EXJavaScriptRuntime.mm +53 -26
- package/ios/JSI/EXSharedObjectUtils.h +15 -0
- package/ios/JSI/EXSharedObjectUtils.mm +18 -0
- package/ios/JSI/JavaScriptRuntime.swift +16 -0
- package/ios/Legacy/ModuleRegistry/EXModuleRegistry.m +1 -0
- package/ios/Legacy/ModuleRegistryProvider/EXModuleRegistryProvider.m +5 -0
- package/ios/Legacy/NativeModulesProxy/EXNativeModulesProxy.mm +5 -4
- package/ios/Legacy/Services/EXReactNativeAdapter.mm +34 -28
- package/ios/ReactDelegates/EXReactDelegateWrapper.h +4 -12
- package/ios/ReactDelegates/EXReactDelegateWrapper.mm +41 -0
- package/ios/ReactDelegates/EXReactRootViewFactory.h +38 -0
- package/ios/ReactDelegates/EXReactRootViewFactory.mm +54 -0
- package/ios/ReactDelegates/ExpoReactDelegate.swift +22 -15
- package/ios/ReactDelegates/ExpoReactDelegateHandler.swift +10 -21
- package/ios/ReactDelegates/RCTAppDelegate+Recreate.h +28 -0
- package/ios/ReactDelegates/RCTAppDelegate+Recreate.mm +47 -0
- package/ios/Tests/{ClassComponentSpec.swift → ClassDefinitionSpec.swift} +6 -6
- package/ios/Tests/ConvertiblesSpec.swift +6 -1
- package/ios/Tests/CoreModuleSpec.swift +0 -4
- package/ios/Tests/DynamicTypeSpec.swift +1 -1
- package/ios/Tests/EventEmitterSpec.swift +274 -0
- package/ios/Tests/ExceptionsSpec.swift +114 -54
- package/ios/Tests/ExpoModulesSpec.swift +4 -3
- package/ios/Tests/LoggerSpec.swift +80 -0
- package/ios/Tests/{PropertyComponentSpec.swift → PropertyDefinitionSpec.swift} +1 -1
- package/ios/Tests/SharedObjectRegistrySpec.swift +34 -28
- package/ios/Tests/SharedObjectSpec.swift +141 -0
- package/ios/Tests/ViewDefinitionSpec.swift +1 -1
- package/package.json +2 -2
- package/src/EventEmitter.ts +15 -18
- package/src/NativeModule.ts +6 -0
- package/src/NativeModulesProxy.native.ts +5 -0
- package/src/NativeModulesProxy.types.ts +2 -2
- package/src/NativeViewManagerAdapter.native.tsx +25 -1
- package/src/PermissionsHook.ts +4 -0
- package/src/Refs.ts +10 -0
- package/src/SharedObject.ts +6 -0
- package/src/createWebModule.ts +5 -0
- package/src/createWebModule.web.ts +6 -0
- package/src/ensureNativeModulesAreInstalled.ts +24 -0
- package/src/hooks/useReleasingSharedObject.ts +51 -0
- package/src/index.ts +13 -0
- package/src/requireNativeModule.ts +2 -51
- package/src/ts-declarations/EventEmitter.ts +65 -0
- package/src/ts-declarations/ExpoModules.d.ts +0 -5
- package/src/ts-declarations/NativeModule.ts +18 -0
- package/src/ts-declarations/SharedObject.ts +16 -0
- package/src/ts-declarations/global.ts +60 -0
- package/src/web/CoreModule.ts +83 -0
- package/src/web/index.ts +0 -0
- package/src/web/index.web.ts +1 -0
- package/android/src/main/cpp/JSIInteropModuleRegistry.cpp +0 -196
- package/android/src/main/java/expo/modules/adapters/react/ArgumentsHelper.java +0 -48
- package/android/src/main/java/expo/modules/adapters/react/PromiseWrapper.java +0 -38
- package/android/src/main/java/expo/modules/adapters/react/services/CookieManagerModule.java +0 -53
- package/android/src/main/java/expo/modules/core/ArgumentsHelper.java +0 -44
- package/android/src/main/java/expo/modules/core/ExportedModule.java +0 -173
- package/android/src/main/java/expo/modules/core/ModuleRegistryDelegate.kt +0 -12
- package/android/src/main/java/expo/modules/core/ViewManager.java +0 -9
- package/android/src/main/java/expo/modules/core/interfaces/ExpoMethod.java +0 -12
- package/android/src/main/java/expo/modules/core/interfaces/ExpoProp.java +0 -10
- package/android/src/main/java/expo/modules/core/logging/LoggerOptions.kt +0 -29
- package/android-annotation/build.gradle +0 -48
- package/android-annotation/src/main/java/expo/modules/annotation/Config.kt +0 -7
- package/android-annotation/src/main/java/expo/modules/annotation/ConverterBinder.kt +0 -7
- package/android-annotation-processor/build.gradle +0 -54
- package/android-annotation-processor/src/main/java/expo/modules/annotationprocessor/ExpoSymbolProcessor.kt +0 -175
- package/android-annotation-processor/src/main/java/expo/modules/annotationprocessor/ExpoSymbolProcessorProvider.kt +0 -10
- package/android-annotation-processor/src/main/resources/META-INF/services/com.google.devtools.ksp.processing.SymbolProcessorProvider +0 -1
- package/ios/Classes/ClassComponentElement.swift +0 -37
- package/ios/Classes/ClassComponentElementsBuilder.swift +0 -34
- package/ios/ExpoBridgeModule.m +0 -7
- package/ios/ExpoBridgeModule.swift +0 -108
- package/ios/ExpoRuntime.swift +0 -28
- package/ios/Functions/AsyncFunctionComponent.swift +0 -327
- package/ios/Functions/SyncFunctionComponent.swift +0 -282
- package/ios/Interfaces/Font/EXFontManagerInterface.h +0 -9
- package/ios/Interfaces/Font/EXFontProcessorInterface.h +0 -15
- package/ios/Interfaces/Font/EXFontScalerInterface.h +0 -9
- package/ios/Interfaces/Font/EXFontScalersManagerInterface.h +0 -9
- package/ios/Legacy/Services/EXReactFontManager.h +0 -6
- package/ios/Legacy/Services/EXReactFontManager.m +0 -130
- package/ios/Modules/AnyModule.swift +0 -53
- package/ios/Modules/CoreModule.swift +0 -17
- package/ios/ReactDelegates/EXRCTBridgeDelegateInterceptor.h +0 -16
- package/ios/ReactDelegates/EXRCTBridgeDelegateInterceptor.m +0 -49
- package/ios/ReactDelegates/EXReactCompatibleHelpers.h +0 -15
- package/ios/ReactDelegates/EXReactCompatibleHelpers.m +0 -25
- package/ios/ReactDelegates/EXReactDelegateWrapper.m +0 -53
- package/ios/SharedObjects/SharedObject.swift +0 -31
- package/ios/Views/ViewDefinition.swift +0 -114
- package/ios/Views/ViewFactory.swift +0 -16
- package/ios/Views/ViewManagerDefinition.swift +0 -77
- package/ios/Views/ViewManagerDefinitionBuilder.swift +0 -11
- /package/ios/{AppContextConfig.swift → Core/AppContextConfig.swift} +0 -0
- /package/ios/{Arguments → Core/Arguments}/AnyArgument.swift +0 -0
- /package/ios/{Arguments → Core/Arguments}/Convertible.swift +0 -0
- /package/ios/{Arguments → Core/Arguments}/Convertibles.swift +0 -0
- /package/ios/{Arguments → Core/Arguments}/Enumerable.swift +0 -0
- /package/ios/{Classes → Core/Classes}/ClassRegistry.swift +0 -0
- /package/ios/{Convertibles → Core/Convertibles}/Convertibles+Color.swift +0 -0
- /package/ios/{Convertibles → Core/Convertibles}/Either.swift +0 -0
- /package/ios/{DynamicTypes → Core/DynamicTypes}/AnyDynamicType.swift +0 -0
- /package/ios/{DynamicTypes → Core/DynamicTypes}/DynamicArrayType.swift +0 -0
- /package/ios/{DynamicTypes → Core/DynamicTypes}/DynamicConvertibleType.swift +0 -0
- /package/ios/{DynamicTypes → Core/DynamicTypes}/DynamicDataType.swift +0 -0
- /package/ios/{DynamicTypes → Core/DynamicTypes}/DynamicDictionaryType.swift +0 -0
- /package/ios/{DynamicTypes → Core/DynamicTypes}/DynamicEnumType.swift +0 -0
- /package/ios/{DynamicTypes → Core/DynamicTypes}/DynamicJavaScriptType.swift +0 -0
- /package/ios/{DynamicTypes → Core/DynamicTypes}/DynamicOptionalType.swift +0 -0
- /package/ios/{DynamicTypes → Core/DynamicTypes}/DynamicRawType.swift +0 -0
- /package/ios/{DynamicTypes → Core/DynamicTypes}/DynamicType.swift +0 -0
- /package/ios/{DynamicTypes → Core/DynamicTypes}/DynamicTypedArrayType.swift +0 -0
- /package/ios/{DynamicTypes → Core/DynamicTypes}/DynamicViewType.swift +0 -0
- /package/ios/{EventListener.swift → Core/EventListener.swift} +0 -0
- /package/ios/{Events → Core/Events}/Callback.swift +0 -0
- /package/ios/{Events → Core/Events}/EventDispatcher.swift +0 -0
- /package/ios/{Exceptions → Core/Exceptions}/ChainableException.swift +0 -0
- /package/ios/{Exceptions → Core/Exceptions}/CodedError.swift +0 -0
- /package/ios/{Exceptions → Core/Exceptions}/CommonExceptions.swift +0 -0
- /package/ios/{Exceptions → Core/Exceptions}/Exception.swift +0 -0
- /package/ios/{Exceptions → Core/Exceptions}/ExceptionOrigin.swift +0 -0
- /package/ios/{Exceptions → Core/Exceptions}/GenericException.swift +0 -0
- /package/ios/{Exceptions → Core/Exceptions}/UnexpectedException.swift +0 -0
- /package/ios/{JavaScriptFunction.swift → Core/JavaScriptFunction.swift} +0 -0
- /package/ios/{Logging → Core/Logging}/LogType.swift +0 -0
- /package/ios/{Logging → Core/Logging}/PersistentFileLog.swift +0 -0
- /package/ios/{ModuleRegistry.swift → Core/ModuleRegistry.swift} +0 -0
- /package/ios/{Modules → Core/Modules}/Module.swift +0 -0
- /package/ios/{ModulesProvider.swift → Core/ModulesProvider.swift} +0 -0
- /package/ios/{Objects → Core/Objects}/JavaScriptObjectBuilder.swift +0 -0
- /package/ios/{Promise.swift → Core/Promise.swift} +0 -0
- /package/ios/{Records → Core/Records}/AnyField.swift +0 -0
- /package/ios/{Records → Core/Records}/Field.swift +0 -0
- /package/ios/{Records → Core/Records}/FieldExtensions.swift +0 -0
- /package/ios/{Records → Core/Records}/FieldOption.swift +0 -0
- /package/ios/{Records → Core/Records}/Record.swift +0 -0
- /package/ios/{SharedObjects → Core/SharedObjects}/SharedRef.swift +0 -0
- /package/ios/{TypedArrays → Core/TypedArrays}/AnyTypedArray.swift +0 -0
- /package/ios/{TypedArrays → Core/TypedArrays}/ConcreteTypedArrays.swift +0 -0
- /package/ios/{TypedArrays → Core/TypedArrays}/GenericTypedArray.swift +0 -0
- /package/ios/{TypedArrays → Core/TypedArrays}/TypedArray.swift +0 -0
- /package/ios/{Views → Core/Views}/ConcreteViewProp.swift +0 -0
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
package expo.modules.kotlin.types
|
|
2
2
|
|
|
3
|
-
import android.view.View
|
|
4
3
|
import expo.modules.kotlin.AppContext
|
|
5
4
|
import expo.modules.kotlin.jni.ExpectedType
|
|
6
5
|
import kotlin.reflect.KClass
|
|
7
6
|
import kotlin.reflect.KType
|
|
8
7
|
import kotlin.reflect.KTypeProjection
|
|
8
|
+
import kotlin.reflect.typeOf
|
|
9
9
|
|
|
10
10
|
class LazyKType(
|
|
11
11
|
override val classifier: KClass<*>,
|
|
@@ -52,6 +52,138 @@ inline fun <reified T> (() -> KType).toAnyType() = AnyType(
|
|
|
52
52
|
)
|
|
53
53
|
)
|
|
54
54
|
|
|
55
|
+
inline fun <reified T> toAnyType(): AnyType {
|
|
56
|
+
return { typeOf<T>() }.toAnyType<T>()
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
@Suppress("UNUSED_PARAMETER")
|
|
60
|
+
inline fun <reified P0> toArgsArray(
|
|
61
|
+
p0: Class<P0> = P0::class.java
|
|
62
|
+
): Array<AnyType> {
|
|
63
|
+
return arrayOf(
|
|
64
|
+
toAnyType<P0>()
|
|
65
|
+
)
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
@Suppress("UNUSED_PARAMETER")
|
|
69
|
+
inline fun <reified P0, reified P1> toArgsArray(
|
|
70
|
+
p0: Class<P0> = P0::class.java,
|
|
71
|
+
p1: Class<P1> = P1::class.java
|
|
72
|
+
): Array<AnyType> {
|
|
73
|
+
return arrayOf(
|
|
74
|
+
toAnyType<P0>(),
|
|
75
|
+
toAnyType<P1>()
|
|
76
|
+
)
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
@Suppress("UNUSED_PARAMETER")
|
|
80
|
+
inline fun <reified P0, reified P1, reified P2> toArgsArray(
|
|
81
|
+
p0: Class<P0> = P0::class.java,
|
|
82
|
+
p1: Class<P1> = P1::class.java,
|
|
83
|
+
p2: Class<P2> = P2::class.java
|
|
84
|
+
): Array<AnyType> {
|
|
85
|
+
return arrayOf(
|
|
86
|
+
toAnyType<P0>(),
|
|
87
|
+
toAnyType<P1>(),
|
|
88
|
+
toAnyType<P2>()
|
|
89
|
+
)
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
@Suppress("UNUSED_PARAMETER")
|
|
93
|
+
inline fun <reified P0, reified P1, reified P2, reified P3> toArgsArray(
|
|
94
|
+
p0: Class<P0> = P0::class.java,
|
|
95
|
+
p1: Class<P1> = P1::class.java,
|
|
96
|
+
p2: Class<P2> = P2::class.java,
|
|
97
|
+
p3: Class<P3> = P3::class.java
|
|
98
|
+
): Array<AnyType> {
|
|
99
|
+
return arrayOf(
|
|
100
|
+
toAnyType<P0>(),
|
|
101
|
+
toAnyType<P1>(),
|
|
102
|
+
toAnyType<P2>(),
|
|
103
|
+
toAnyType<P3>()
|
|
104
|
+
)
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
@Suppress("UNUSED_PARAMETER")
|
|
108
|
+
inline fun <reified P0, reified P1, reified P2, reified P3, reified P4> toArgsArray(
|
|
109
|
+
p0: Class<P0> = P0::class.java,
|
|
110
|
+
p1: Class<P1> = P1::class.java,
|
|
111
|
+
p2: Class<P2> = P2::class.java,
|
|
112
|
+
p3: Class<P3> = P3::class.java,
|
|
113
|
+
p4: Class<P4> = P4::class.java
|
|
114
|
+
): Array<AnyType> {
|
|
115
|
+
return arrayOf(
|
|
116
|
+
toAnyType<P0>(),
|
|
117
|
+
toAnyType<P1>(),
|
|
118
|
+
toAnyType<P2>(),
|
|
119
|
+
toAnyType<P3>(),
|
|
120
|
+
toAnyType<P4>()
|
|
121
|
+
)
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
@Suppress("UNUSED_PARAMETER")
|
|
125
|
+
inline fun <reified P0, reified P1, reified P2, reified P3, reified P4, reified P5> toArgsArray(
|
|
126
|
+
p0: Class<P0> = P0::class.java,
|
|
127
|
+
p1: Class<P1> = P1::class.java,
|
|
128
|
+
p2: Class<P2> = P2::class.java,
|
|
129
|
+
p3: Class<P3> = P3::class.java,
|
|
130
|
+
p4: Class<P4> = P4::class.java,
|
|
131
|
+
p5: Class<P5> = P5::class.java
|
|
132
|
+
): Array<AnyType> {
|
|
133
|
+
return arrayOf(
|
|
134
|
+
toAnyType<P0>(),
|
|
135
|
+
toAnyType<P1>(),
|
|
136
|
+
toAnyType<P2>(),
|
|
137
|
+
toAnyType<P3>(),
|
|
138
|
+
toAnyType<P4>(),
|
|
139
|
+
toAnyType<P5>()
|
|
140
|
+
)
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
@Suppress("UNUSED_PARAMETER")
|
|
144
|
+
inline fun <reified P0, reified P1, reified P2, reified P3, reified P4, reified P5, reified P6> toArgsArray(
|
|
145
|
+
p0: Class<P0> = P0::class.java,
|
|
146
|
+
p1: Class<P1> = P1::class.java,
|
|
147
|
+
p2: Class<P2> = P2::class.java,
|
|
148
|
+
p3: Class<P3> = P3::class.java,
|
|
149
|
+
p4: Class<P4> = P4::class.java,
|
|
150
|
+
p5: Class<P5> = P5::class.java,
|
|
151
|
+
p6: Class<P6> = P6::class.java
|
|
152
|
+
): Array<AnyType> {
|
|
153
|
+
return arrayOf(
|
|
154
|
+
toAnyType<P0>(),
|
|
155
|
+
toAnyType<P1>(),
|
|
156
|
+
toAnyType<P2>(),
|
|
157
|
+
toAnyType<P3>(),
|
|
158
|
+
toAnyType<P4>(),
|
|
159
|
+
toAnyType<P5>(),
|
|
160
|
+
toAnyType<P6>()
|
|
161
|
+
)
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
@Suppress("UNUSED_PARAMETER")
|
|
165
|
+
inline fun <reified P0, reified P1, reified P2, reified P3, reified P4, reified P5, reified P6, reified P7> toArgsArray(
|
|
166
|
+
p0: Class<P0> = P0::class.java,
|
|
167
|
+
p1: Class<P1> = P1::class.java,
|
|
168
|
+
p2: Class<P2> = P2::class.java,
|
|
169
|
+
p3: Class<P3> = P3::class.java,
|
|
170
|
+
p4: Class<P4> = P4::class.java,
|
|
171
|
+
p5: Class<P5> = P5::class.java,
|
|
172
|
+
p6: Class<P6> = P6::class.java,
|
|
173
|
+
p7: Class<P7> = P7::class.java
|
|
174
|
+
): Array<AnyType> {
|
|
175
|
+
return arrayOf(
|
|
176
|
+
toAnyType<P0>(),
|
|
177
|
+
toAnyType<P1>(),
|
|
178
|
+
toAnyType<P2>(),
|
|
179
|
+
toAnyType<P3>(),
|
|
180
|
+
toAnyType<P4>(),
|
|
181
|
+
toAnyType<P5>(),
|
|
182
|
+
toAnyType<P6>(),
|
|
183
|
+
toAnyType<P7>()
|
|
184
|
+
)
|
|
185
|
+
}
|
|
186
|
+
|
|
55
187
|
class AnyType(
|
|
56
188
|
val kType: KType
|
|
57
189
|
) {
|
|
@@ -68,6 +200,6 @@ class AnyType(
|
|
|
68
200
|
val kClass = kType.classifier as? KClass<*> ?: return false
|
|
69
201
|
val jClass = kClass.java
|
|
70
202
|
|
|
71
|
-
return
|
|
203
|
+
return T::class.java.isAssignableFrom(jClass)
|
|
72
204
|
}
|
|
73
205
|
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
package expo.modules.kotlin.types
|
|
2
|
+
|
|
3
|
+
import kotlin.contracts.ExperimentalContracts
|
|
4
|
+
import kotlin.contracts.contract
|
|
5
|
+
|
|
6
|
+
@OptIn(ExperimentalContracts::class)
|
|
7
|
+
inline fun <reified P0> enforceType(p0: Any?) {
|
|
8
|
+
contract {
|
|
9
|
+
returns() implies (p0 is P0)
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
@OptIn(ExperimentalContracts::class)
|
|
14
|
+
inline fun <reified P0, reified P1> enforceType(p0: Any?, p1: Any?) {
|
|
15
|
+
contract {
|
|
16
|
+
returns() implies (p0 is P0 && p1 is P1)
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
@OptIn(ExperimentalContracts::class)
|
|
21
|
+
inline fun <reified P0, reified P1, reified P2> enforceType(p0: Any?, p1: Any?, p2: Any?) {
|
|
22
|
+
contract {
|
|
23
|
+
returns() implies (p0 is P0 && p1 is P1 && p2 is P2)
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
@OptIn(ExperimentalContracts::class)
|
|
28
|
+
inline fun <reified P0, reified P1, reified P2, reified P3> enforceType(p0: Any?, p1: Any?, p2: Any?, p3: Any?) {
|
|
29
|
+
contract {
|
|
30
|
+
returns() implies (p0 is P0 && p1 is P1 && p2 is P2 && p3 is P3)
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
@OptIn(ExperimentalContracts::class)
|
|
35
|
+
inline fun <reified P0, reified P1, reified P2, reified P3, reified P4> enforceType(p0: Any?, p1: Any?, p2: Any?, p3: Any?, p4: Any?) {
|
|
36
|
+
contract {
|
|
37
|
+
returns() implies (p0 is P0 && p1 is P1 && p2 is P2 && p3 is P3 && p4 is P4)
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
@OptIn(ExperimentalContracts::class)
|
|
42
|
+
inline fun <reified P0, reified P1, reified P2, reified P3, reified P4, reified P5> enforceType(p0: Any?, p1: Any?, p2: Any?, p3: Any?, p4: Any?, p5: Any?) {
|
|
43
|
+
contract {
|
|
44
|
+
returns() implies (p0 is P0 && p1 is P1 && p2 is P2 && p3 is P3 && p4 is P4 && p5 is P5)
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
@OptIn(ExperimentalContracts::class)
|
|
49
|
+
inline fun <reified P0, reified P1, reified P2, reified P3, reified P4, reified P5, reified P6> enforceType(p0: Any?, p1: Any?, p2: Any?, p3: Any?, p4: Any?, p5: Any?, p6: Any?) {
|
|
50
|
+
contract {
|
|
51
|
+
returns() implies (p0 is P0 && p1 is P1 && p2 is P2 && p3 is P3 && p4 is P4 && p5 is P5 && p6 is P6)
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
@OptIn(ExperimentalContracts::class)
|
|
56
|
+
inline fun <reified P0, reified P1, reified P2, reified P3, reified P4, reified P5, reified P6, reified P7> enforceType(p0: Any?, p1: Any?, p2: Any?, p3: Any?, p4: Any?, p5: Any?, p6: Any?, p7: Any?) {
|
|
57
|
+
contract {
|
|
58
|
+
returns() implies (p0 is P0 && p1 is P1 && p2 is P2 && p3 is P3 && p4 is P4 && p5 is P5 && p6 is P6 && p7 is P7)
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -27,8 +27,8 @@ class EnumTypeConverter(
|
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
init {
|
|
30
|
-
if (Enumerable::class.java.isAssignableFrom(enumClass.java)) {
|
|
31
|
-
logger.
|
|
30
|
+
if (!Enumerable::class.java.isAssignableFrom(enumClass.java)) {
|
|
31
|
+
logger.error("Enum '$enumClass' should inherit from ${Enumerable::class}.")
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
|
|
@@ -81,8 +81,6 @@ inline fun <reified T : Any> createTrivialTypeConverter(
|
|
|
81
81
|
return object : DynamicAwareTypeConverters<T>(isOptional) {
|
|
82
82
|
override fun convertFromDynamic(value: Dynamic): T = dynamicFallback(value)
|
|
83
83
|
override fun getCppRequiredTypes(): ExpectedType = cppRequireType
|
|
84
|
-
|
|
85
|
-
@Suppress("UNCHECKED_CAST")
|
|
86
84
|
override fun convertFromAny(value: Any): T = value as T
|
|
87
85
|
}
|
|
88
86
|
}
|
|
@@ -6,7 +6,6 @@ import android.view.View
|
|
|
6
6
|
import com.facebook.react.bridge.Dynamic
|
|
7
7
|
import com.facebook.react.bridge.ReadableArray
|
|
8
8
|
import com.facebook.react.bridge.ReadableMap
|
|
9
|
-
import expo.modules.annotation.Config
|
|
10
9
|
import expo.modules.core.arguments.ReadableArguments
|
|
11
10
|
import expo.modules.kotlin.apifeatures.EitherType
|
|
12
11
|
import expo.modules.kotlin.exception.MissingTypeConverter
|
|
@@ -75,7 +74,6 @@ object TypeConverterProviderImpl : TypeConverterProvider {
|
|
|
75
74
|
private val nullableCachedConverters = createCachedConverters(true)
|
|
76
75
|
|
|
77
76
|
private val cachedRecordConverters = mutableMapOf<KClass<*>, TypeConverter<*>>()
|
|
78
|
-
private val cachedCustomConverters = mutableMapOf<KType, TypeConverter<*>>()
|
|
79
77
|
|
|
80
78
|
private fun getCachedConverter(inputType: KType): TypeConverter<*>? {
|
|
81
79
|
return if (inputType.isMarkedNullable) {
|
|
@@ -142,7 +140,6 @@ object TypeConverterProviderImpl : TypeConverterProvider {
|
|
|
142
140
|
}
|
|
143
141
|
|
|
144
142
|
return handelEither(type, jClass)
|
|
145
|
-
?: handelCustomConverter(type, kClass)
|
|
146
143
|
?: throw MissingTypeConverter(type)
|
|
147
144
|
}
|
|
148
145
|
|
|
@@ -161,29 +158,6 @@ object TypeConverterProviderImpl : TypeConverterProvider {
|
|
|
161
158
|
return null
|
|
162
159
|
}
|
|
163
160
|
|
|
164
|
-
private fun handelCustomConverter(type: KType, kClass: KClass<*>): TypeConverter<*>? {
|
|
165
|
-
val cachedConverter = cachedCustomConverters[type]
|
|
166
|
-
if (cachedConverter != null) {
|
|
167
|
-
return cachedConverter
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
val typeName = kClass.java.canonicalName ?: return null
|
|
171
|
-
|
|
172
|
-
val converterProviderName = "${Config.packageNamePrefix}$typeName${Config.classNameSuffix}"
|
|
173
|
-
return try {
|
|
174
|
-
val converterClazz = Class.forName(converterProviderName)
|
|
175
|
-
val converterProvider = converterClazz.newInstance()
|
|
176
|
-
val method = converterProvider.javaClass.getMethod(Config.converterProviderFunctionName, KType::class.java)
|
|
177
|
-
|
|
178
|
-
(method.invoke(converterProvider, type) as TypeConverter<*>)
|
|
179
|
-
.also {
|
|
180
|
-
cachedCustomConverters[type] = it
|
|
181
|
-
}
|
|
182
|
-
} catch (e: Throwable) {
|
|
183
|
-
null
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
|
|
187
161
|
private fun createCachedConverters(isOptional: Boolean): Map<KClass<*>, TypeConverter<*>> {
|
|
188
162
|
val intTypeConverter = createTrivialTypeConverter(
|
|
189
163
|
isOptional,
|
|
@@ -295,7 +269,9 @@ object TypeConverterProviderImpl : TypeConverterProvider {
|
|
|
295
269
|
|
|
296
270
|
Any::class to AnyTypeConverter(isOptional),
|
|
297
271
|
|
|
298
|
-
Unit
|
|
272
|
+
// Unit converter doesn't care about nullability.
|
|
273
|
+
// It will always return Unit
|
|
274
|
+
Unit::class to UnitTypeConverter(),
|
|
299
275
|
|
|
300
276
|
ReadableArguments::class to ReadableArgumentsTypeConverter(isOptional)
|
|
301
277
|
)
|
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
package expo.modules.kotlin.types
|
|
2
2
|
|
|
3
|
-
import
|
|
3
|
+
import expo.modules.kotlin.AppContext
|
|
4
4
|
import expo.modules.kotlin.jni.CppType
|
|
5
5
|
import expo.modules.kotlin.jni.ExpectedType
|
|
6
6
|
|
|
7
|
-
class UnitTypeConverter
|
|
8
|
-
override fun
|
|
9
|
-
return Unit
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
override fun convertFromAny(value: Any): Any = Unit
|
|
7
|
+
class UnitTypeConverter : TypeConverter<Unit>() {
|
|
8
|
+
override fun convert(value: Any?, context: AppContext?) = Unit
|
|
13
9
|
|
|
14
10
|
override fun getCppRequiredTypes(): ExpectedType = ExpectedType(CppType.ANY)
|
|
15
11
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
package expo.modules.kotlin.types.io
|
|
2
2
|
|
|
3
|
+
import android.os.Build
|
|
4
|
+
import androidx.annotation.RequiresApi
|
|
3
5
|
import com.facebook.react.bridge.Dynamic
|
|
4
6
|
import expo.modules.kotlin.jni.CppType
|
|
5
7
|
import expo.modules.kotlin.jni.ExpectedType
|
|
@@ -7,6 +9,7 @@ import expo.modules.kotlin.types.DynamicAwareTypeConverters
|
|
|
7
9
|
import java.nio.file.Path
|
|
8
10
|
import java.nio.file.Paths
|
|
9
11
|
|
|
12
|
+
@RequiresApi(Build.VERSION_CODES.O)
|
|
10
13
|
class PathTypeConverter(isOptional: Boolean) : DynamicAwareTypeConverters<Path>(isOptional) {
|
|
11
14
|
override fun convertFromDynamic(value: Dynamic): Path {
|
|
12
15
|
val stringPath = value.asString()
|
|
@@ -3,8 +3,8 @@ package expo.modules.kotlin.viewevent
|
|
|
3
3
|
import android.view.View
|
|
4
4
|
import com.facebook.react.bridge.ReactContext
|
|
5
5
|
import com.facebook.react.bridge.WritableMap
|
|
6
|
-
import expo.modules.adapters.react.NativeModulesProxy
|
|
7
6
|
import expo.modules.core.utilities.ifNull
|
|
7
|
+
import expo.modules.kotlin.getUnimoduleProxy
|
|
8
8
|
import expo.modules.kotlin.logger
|
|
9
9
|
import expo.modules.kotlin.types.JSTypeConverter
|
|
10
10
|
import expo.modules.kotlin.types.putGeneric
|
|
@@ -22,10 +22,7 @@ open class ViewEvent<T>(
|
|
|
22
22
|
|
|
23
23
|
override operator fun invoke(arg: T) {
|
|
24
24
|
val reactContext = view.context as ReactContext
|
|
25
|
-
val nativeModulesProxy = reactContext
|
|
26
|
-
.catalystInstance
|
|
27
|
-
?.getNativeModule("NativeUnimoduleProxy") as? NativeModulesProxy
|
|
28
|
-
?: return
|
|
25
|
+
val nativeModulesProxy = reactContext.getUnimoduleProxy() ?: return
|
|
29
26
|
val appContext = nativeModulesProxy.kotlinInteropModuleRegistry.appContext
|
|
30
27
|
|
|
31
28
|
if (!isValidated) {
|
|
@@ -12,16 +12,18 @@ import expo.modules.kotlin.exception.CodedException
|
|
|
12
12
|
import expo.modules.kotlin.exception.UnexpectedException
|
|
13
13
|
import expo.modules.kotlin.functions.AsyncFunction
|
|
14
14
|
import expo.modules.kotlin.functions.AsyncFunctionBuilder
|
|
15
|
-
import expo.modules.kotlin.functions.AsyncFunctionComponent
|
|
16
15
|
import expo.modules.kotlin.functions.AsyncFunctionWithPromiseComponent
|
|
17
16
|
import expo.modules.kotlin.functions.Queues
|
|
17
|
+
import expo.modules.kotlin.functions.createAsyncFunctionComponent
|
|
18
18
|
import expo.modules.kotlin.modules.DefinitionMarker
|
|
19
19
|
import expo.modules.kotlin.types.toAnyType
|
|
20
20
|
import kotlin.reflect.KClass
|
|
21
|
-
import kotlin.reflect.KFunction
|
|
22
21
|
import kotlin.reflect.KType
|
|
23
|
-
import
|
|
24
|
-
import kotlin.
|
|
22
|
+
import expo.modules.kotlin.component6
|
|
23
|
+
import expo.modules.kotlin.component7
|
|
24
|
+
import expo.modules.kotlin.component8
|
|
25
|
+
import expo.modules.kotlin.types.enforceType
|
|
26
|
+
import expo.modules.kotlin.types.toArgsArray
|
|
25
27
|
|
|
26
28
|
@DefinitionMarker
|
|
27
29
|
class ViewDefinitionBuilder<T : View>(
|
|
@@ -111,7 +113,7 @@ class ViewDefinitionBuilder<T : View>(
|
|
|
111
113
|
) {
|
|
112
114
|
props[name] = ConcreteViewProp(
|
|
113
115
|
name,
|
|
114
|
-
|
|
116
|
+
toAnyType<PropType>(),
|
|
115
117
|
body
|
|
116
118
|
)
|
|
117
119
|
}
|
|
@@ -126,11 +128,20 @@ class ViewDefinitionBuilder<T : View>(
|
|
|
126
128
|
) {
|
|
127
129
|
props[name] = ConcreteViewProp(
|
|
128
130
|
name,
|
|
129
|
-
|
|
131
|
+
toAnyType<PropType>(),
|
|
130
132
|
body
|
|
131
133
|
)
|
|
132
134
|
}
|
|
133
135
|
|
|
136
|
+
inline fun <reified ViewType : View, reified PropType, reified CustomValueType> PropGroup(
|
|
137
|
+
vararg props: Pair<String, CustomValueType>,
|
|
138
|
+
noinline body: (view: ViewType, value: CustomValueType, prop: PropType) -> Unit
|
|
139
|
+
) {
|
|
140
|
+
for ((name, value) in props) {
|
|
141
|
+
Prop<ViewType, PropType>(name) { view, prop -> body(view, value, prop) }
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
|
|
134
145
|
/**
|
|
135
146
|
* Defines prop names that should be treated as callbacks.
|
|
136
147
|
*/
|
|
@@ -163,7 +174,7 @@ class ViewDefinitionBuilder<T : View>(
|
|
|
163
174
|
name: String,
|
|
164
175
|
crossinline body: () -> Any?
|
|
165
176
|
): AsyncFunction {
|
|
166
|
-
return
|
|
177
|
+
return createAsyncFunctionComponent(name, emptyArray()) { body() }.also {
|
|
167
178
|
asyncFunctions[name] = it
|
|
168
179
|
}
|
|
169
180
|
}
|
|
@@ -172,7 +183,7 @@ class ViewDefinitionBuilder<T : View>(
|
|
|
172
183
|
name: String,
|
|
173
184
|
crossinline body: () -> R
|
|
174
185
|
): AsyncFunction {
|
|
175
|
-
return
|
|
186
|
+
return createAsyncFunctionComponent(name, emptyArray()) { body() }.also {
|
|
176
187
|
asyncFunctions[name] = it
|
|
177
188
|
}
|
|
178
189
|
}
|
|
@@ -181,10 +192,14 @@ class ViewDefinitionBuilder<T : View>(
|
|
|
181
192
|
name: String,
|
|
182
193
|
crossinline body: (p0: P0) -> R
|
|
183
194
|
): AsyncFunction {
|
|
195
|
+
// We can't split that function, because that introduces a ambiguity when creating DSL component without parameters.
|
|
184
196
|
return if (P0::class == Promise::class) {
|
|
185
|
-
AsyncFunctionWithPromiseComponent(name,
|
|
197
|
+
AsyncFunctionWithPromiseComponent(name, emptyArray()) { _, promise -> body(promise as P0) }
|
|
186
198
|
} else {
|
|
187
|
-
|
|
199
|
+
createAsyncFunctionComponent(name, toArgsArray<P0>()) { (p0) ->
|
|
200
|
+
enforceType<P0>(p0)
|
|
201
|
+
body(p0)
|
|
202
|
+
}
|
|
188
203
|
}.also {
|
|
189
204
|
asyncFunctions[name] = it
|
|
190
205
|
}
|
|
@@ -194,10 +209,22 @@ class ViewDefinitionBuilder<T : View>(
|
|
|
194
209
|
name: String,
|
|
195
210
|
crossinline body: (p0: P0, p1: P1) -> R
|
|
196
211
|
): AsyncFunction {
|
|
197
|
-
return
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
212
|
+
return createAsyncFunctionComponent(name, toArgsArray<P0, P1>()) { (p0, p1) ->
|
|
213
|
+
enforceType<P0, P1>(p0, p1)
|
|
214
|
+
body(p0, p1)
|
|
215
|
+
}.also {
|
|
216
|
+
asyncFunctions[name] = it
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
@JvmName("AsyncFunctionWithPromise")
|
|
221
|
+
inline fun <reified R, reified P0> AsyncFunction(
|
|
222
|
+
name: String,
|
|
223
|
+
crossinline body: (p0: P0, p1: Promise) -> R
|
|
224
|
+
): AsyncFunction {
|
|
225
|
+
return AsyncFunctionWithPromiseComponent(name, toArgsArray<P0>()) { (p0), promise ->
|
|
226
|
+
enforceType<P0>(p0)
|
|
227
|
+
body(p0, promise)
|
|
201
228
|
}.also {
|
|
202
229
|
asyncFunctions[name] = it
|
|
203
230
|
}
|
|
@@ -207,10 +234,22 @@ class ViewDefinitionBuilder<T : View>(
|
|
|
207
234
|
name: String,
|
|
208
235
|
crossinline body: (p0: P0, p1: P1, p2: P2) -> R
|
|
209
236
|
): AsyncFunction {
|
|
210
|
-
return
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
237
|
+
return createAsyncFunctionComponent(name, toArgsArray<P0, P1, P2>()) { (p0, p1, p2) ->
|
|
238
|
+
enforceType<P0, P1, P2>(p0, p1, p2)
|
|
239
|
+
body(p0, p1, p2)
|
|
240
|
+
}.also {
|
|
241
|
+
asyncFunctions[name] = it
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
@JvmName("AsyncFunctionWithPromise")
|
|
246
|
+
inline fun <reified R, reified P0, reified P1> AsyncFunction(
|
|
247
|
+
name: String,
|
|
248
|
+
crossinline body: (p0: P0, p1: P1, p2: Promise) -> R
|
|
249
|
+
): AsyncFunction {
|
|
250
|
+
return AsyncFunctionWithPromiseComponent(name, toArgsArray<P0, P1>()) { (p0, p1), promise ->
|
|
251
|
+
enforceType<P0, P1>(p0, p1)
|
|
252
|
+
body(p0, p1, promise)
|
|
214
253
|
}.also {
|
|
215
254
|
asyncFunctions[name] = it
|
|
216
255
|
}
|
|
@@ -220,10 +259,22 @@ class ViewDefinitionBuilder<T : View>(
|
|
|
220
259
|
name: String,
|
|
221
260
|
crossinline body: (p0: P0, p1: P1, p2: P2, p3: P3) -> R
|
|
222
261
|
): AsyncFunction {
|
|
223
|
-
return
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
262
|
+
return createAsyncFunctionComponent(name, toArgsArray<P0, P1, P2, P3>()) { (p0, p1, p2, p3) ->
|
|
263
|
+
enforceType<P0, P1, P2, P3>(p0, p1, p2, p3)
|
|
264
|
+
body(p0, p1, p2, p3)
|
|
265
|
+
}.also {
|
|
266
|
+
asyncFunctions[name] = it
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
@JvmName("AsyncFunctionWithPromise")
|
|
271
|
+
inline fun <reified R, reified P0, reified P1, reified P2> AsyncFunction(
|
|
272
|
+
name: String,
|
|
273
|
+
crossinline body: (p0: P0, p1: P1, p2: P2, p3: Promise) -> R
|
|
274
|
+
): AsyncFunction {
|
|
275
|
+
return AsyncFunctionWithPromiseComponent(name, toArgsArray<P0, P1, P2>()) { (p0, p1, p2), promise ->
|
|
276
|
+
enforceType<P0, P1, P2>(p0, p1, p2)
|
|
277
|
+
body(p0, p1, p2, promise)
|
|
227
278
|
}.also {
|
|
228
279
|
asyncFunctions[name] = it
|
|
229
280
|
}
|
|
@@ -233,10 +284,22 @@ class ViewDefinitionBuilder<T : View>(
|
|
|
233
284
|
name: String,
|
|
234
285
|
crossinline body: (p0: P0, p1: P1, p2: P2, p3: P3, p4: P4) -> R
|
|
235
286
|
): AsyncFunction {
|
|
236
|
-
return
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
287
|
+
return createAsyncFunctionComponent(name, toArgsArray<P0, P1, P2, P3, P4>()) { (p0, p1, p2, p3, p4) ->
|
|
288
|
+
enforceType<P0, P1, P2, P3, P4>(p0, p1, p2, p3, p4)
|
|
289
|
+
body(p0, p1, p2, p3, p4)
|
|
290
|
+
}.also {
|
|
291
|
+
asyncFunctions[name] = it
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
@JvmName("AsyncFunctionWithPromise")
|
|
296
|
+
inline fun <reified R, reified P0, reified P1, reified P2, reified P3> AsyncFunction(
|
|
297
|
+
name: String,
|
|
298
|
+
crossinline body: (p0: P0, p1: P1, p2: P2, p3: P3, p4: Promise) -> R
|
|
299
|
+
): AsyncFunction {
|
|
300
|
+
return AsyncFunctionWithPromiseComponent(name, toArgsArray<P0, P1, P2, P3>()) { (p0, p1, p2, p3), promise ->
|
|
301
|
+
enforceType<P0, P1, P2, P3>(p0, p1, p2, p3)
|
|
302
|
+
body(p0, p1, p2, p3, promise)
|
|
240
303
|
}.also {
|
|
241
304
|
asyncFunctions[name] = it
|
|
242
305
|
}
|
|
@@ -246,10 +309,22 @@ class ViewDefinitionBuilder<T : View>(
|
|
|
246
309
|
name: String,
|
|
247
310
|
crossinline body: (p0: P0, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5) -> R
|
|
248
311
|
): AsyncFunction {
|
|
249
|
-
return
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
312
|
+
return createAsyncFunctionComponent(name, toArgsArray<P0, P1, P2, P3, P4, P5>()) { (p0, p1, p2, p3, p4, p5) ->
|
|
313
|
+
enforceType<P0, P1, P2, P3, P4, P5>(p0, p1, p2, p3, p4, p5)
|
|
314
|
+
body(p0, p1, p2, p3, p4, p5)
|
|
315
|
+
}.also {
|
|
316
|
+
asyncFunctions[name] = it
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
@JvmName("AsyncFunctionWithPromise")
|
|
321
|
+
inline fun <reified R, reified P0, reified P1, reified P2, reified P3, reified P4> AsyncFunction(
|
|
322
|
+
name: String,
|
|
323
|
+
crossinline body: (p0: P0, p1: P1, p2: P2, p3: P3, p4: P4, p5: Promise) -> R
|
|
324
|
+
): AsyncFunction {
|
|
325
|
+
return AsyncFunctionWithPromiseComponent(name, toArgsArray<P0, P1, P2, P3, P4>()) { (p0, p1, p2, p3, p4), promise ->
|
|
326
|
+
enforceType<P0, P1, P2, P3, P4>(p0, p1, p2, p3, p4)
|
|
327
|
+
body(p0, p1, p2, p3, p4, promise)
|
|
253
328
|
}.also {
|
|
254
329
|
asyncFunctions[name] = it
|
|
255
330
|
}
|
|
@@ -259,10 +334,22 @@ class ViewDefinitionBuilder<T : View>(
|
|
|
259
334
|
name: String,
|
|
260
335
|
crossinline body: (p0: P0, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6) -> R
|
|
261
336
|
): AsyncFunction {
|
|
262
|
-
return
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
337
|
+
return createAsyncFunctionComponent(name, toArgsArray<P0, P1, P2, P3, P4, P5, P6>()) { (p0, p1, p2, p3, p4, p5, p6) ->
|
|
338
|
+
enforceType<P0, P1, P2, P3, P4, P5, P6>(p0, p1, p2, p3, p4, p5, p6)
|
|
339
|
+
body(p0, p1, p2, p3, p4, p5, p6)
|
|
340
|
+
}.also {
|
|
341
|
+
asyncFunctions[name] = it
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
|
|
345
|
+
@JvmName("AsyncFunctionWithPromise")
|
|
346
|
+
inline fun <reified R, reified P0, reified P1, reified P2, reified P3, reified P4, reified P5> AsyncFunction(
|
|
347
|
+
name: String,
|
|
348
|
+
crossinline body: (p0: P0, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: Promise) -> R
|
|
349
|
+
): AsyncFunction {
|
|
350
|
+
return AsyncFunctionWithPromiseComponent(name, toArgsArray<P0, P1, P2, P3, P4, P5>()) { (p0, p1, p2, p3, p4, p5), promise ->
|
|
351
|
+
enforceType<P0, P1, P2, P3, P4, P5>(p0, p1, p2, p3, p4, p5)
|
|
352
|
+
body(p0, p1, p2, p3, p4, p5, promise)
|
|
266
353
|
}.also {
|
|
267
354
|
asyncFunctions[name] = it
|
|
268
355
|
}
|
|
@@ -272,10 +359,22 @@ class ViewDefinitionBuilder<T : View>(
|
|
|
272
359
|
name: String,
|
|
273
360
|
crossinline body: (p0: P0, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7) -> R
|
|
274
361
|
): AsyncFunction {
|
|
275
|
-
return
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
362
|
+
return createAsyncFunctionComponent(name, toArgsArray<P0, P1, P2, P3, P4, P5, P6, P7>()) { (p0, p1, p2, p3, p4, p5, p6, p7) ->
|
|
363
|
+
enforceType<P0, P1, P2, P3, P4, P5, P6, P7>(p0, p1, p2, p3, p4, p5, p6, p7)
|
|
364
|
+
body(p0, p1, p2, p3, p4, p5, p6, p7)
|
|
365
|
+
}.also {
|
|
366
|
+
asyncFunctions[name] = it
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
@JvmName("AsyncFunctionWithPromise")
|
|
371
|
+
inline fun <reified R, reified P0, reified P1, reified P2, reified P3, reified P4, reified P5, reified P6> AsyncFunction(
|
|
372
|
+
name: String,
|
|
373
|
+
crossinline body: (p0: P0, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: Promise) -> R
|
|
374
|
+
): AsyncFunction {
|
|
375
|
+
return AsyncFunctionWithPromiseComponent(name, toArgsArray<P0, P1, P2, P3, P4, P5, P6>()) { (p0, p1, p2, p3, p4, p5, p6), promise ->
|
|
376
|
+
enforceType<P0, P1, P2, P3, P4, P5, P6>(p0, p1, p2, p3, p4, p5, p6)
|
|
377
|
+
body(p0, p1, p2, p3, p4, p5, p6, promise)
|
|
279
378
|
}.also {
|
|
280
379
|
asyncFunctions[name] = it
|
|
281
380
|
}
|
|
@@ -336,14 +435,4 @@ class ViewDefinitionBuilder<T : View>(
|
|
|
336
435
|
ErrorView(context)
|
|
337
436
|
}
|
|
338
437
|
}
|
|
339
|
-
|
|
340
|
-
private fun getPrimaryConstructor(): KFunction<T>? {
|
|
341
|
-
val kotlinContractor = viewClass.primaryConstructor
|
|
342
|
-
if (kotlinContractor != null) {
|
|
343
|
-
return kotlinContractor
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
// Add compatibility with Java
|
|
347
|
-
return viewClass.constructors.firstOrNull()
|
|
348
|
-
}
|
|
349
438
|
}
|