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
|
@@ -4,21 +4,24 @@ package expo.modules.kotlin.objects
|
|
|
4
4
|
|
|
5
5
|
import com.facebook.react.bridge.Arguments
|
|
6
6
|
import expo.modules.kotlin.Promise
|
|
7
|
+
import expo.modules.kotlin.component6
|
|
8
|
+
import expo.modules.kotlin.component7
|
|
9
|
+
import expo.modules.kotlin.component8
|
|
7
10
|
import expo.modules.kotlin.events.EventsDefinition
|
|
8
11
|
import expo.modules.kotlin.functions.AsyncFunction
|
|
9
12
|
import expo.modules.kotlin.functions.AsyncFunctionBuilder
|
|
10
|
-
import expo.modules.kotlin.functions.AsyncFunctionComponent
|
|
11
13
|
import expo.modules.kotlin.functions.AsyncFunctionWithPromiseComponent
|
|
12
14
|
import expo.modules.kotlin.functions.FunctionBuilder
|
|
13
15
|
import expo.modules.kotlin.functions.SyncFunctionComponent
|
|
16
|
+
import expo.modules.kotlin.functions.createAsyncFunctionComponent
|
|
14
17
|
import expo.modules.kotlin.jni.JavaScriptModuleObject
|
|
15
18
|
import expo.modules.kotlin.modules.Module
|
|
16
19
|
import expo.modules.kotlin.modules.ModuleDefinitionBuilder
|
|
17
20
|
import expo.modules.kotlin.types.Enumerable
|
|
18
|
-
import expo.modules.kotlin.types.
|
|
21
|
+
import expo.modules.kotlin.types.enforceType
|
|
22
|
+
import expo.modules.kotlin.types.toArgsArray
|
|
19
23
|
import kotlin.reflect.full.declaredMemberProperties
|
|
20
24
|
import kotlin.reflect.full.primaryConstructor
|
|
21
|
-
import kotlin.reflect.typeOf
|
|
22
25
|
|
|
23
26
|
/**
|
|
24
27
|
* Base class for other definitions representing an object, such as `ModuleDefinition`.
|
|
@@ -44,18 +47,6 @@ open class ObjectDefinitionBuilder {
|
|
|
44
47
|
internal var properties = mutableMapOf<String, PropertyComponentBuilder>()
|
|
45
48
|
|
|
46
49
|
fun buildObject(): ObjectDefinitionData {
|
|
47
|
-
// Register stub functions to bypass react-native `NativeEventEmitter` warnings
|
|
48
|
-
// WARN `new NativeEventEmitter()` was called with a non-null argument without the required `addListener` method.
|
|
49
|
-
// WARN `new NativeEventEmitter()` was called with a non-null argument without the required `removeListeners` method.
|
|
50
|
-
eventsDefinition?.run {
|
|
51
|
-
if (!containsFunction("addListener")) {
|
|
52
|
-
Function("addListener") { _: String -> { } }
|
|
53
|
-
}
|
|
54
|
-
if (!containsFunction("removeListeners")) {
|
|
55
|
-
Function("removeListeners") { _: Int -> { } }
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
50
|
return ObjectDefinitionData(
|
|
60
51
|
constantsProvider,
|
|
61
52
|
syncFunctions + syncFunctionBuilder.mapValues { (_, value) -> value.build() },
|
|
@@ -65,12 +56,6 @@ open class ObjectDefinitionBuilder {
|
|
|
65
56
|
)
|
|
66
57
|
}
|
|
67
58
|
|
|
68
|
-
private fun containsFunction(functionName: String): Boolean {
|
|
69
|
-
return syncFunctions.containsKey(functionName) ||
|
|
70
|
-
asyncFunctions.containsKey(functionName) ||
|
|
71
|
-
asyncFunctionBuilders.containsKey(functionName)
|
|
72
|
-
}
|
|
73
|
-
|
|
74
59
|
/**
|
|
75
60
|
* Definition function setting the module's constants to export.
|
|
76
61
|
*/
|
|
@@ -94,7 +79,7 @@ open class ObjectDefinitionBuilder {
|
|
|
94
79
|
name: String,
|
|
95
80
|
crossinline body: () -> Any?
|
|
96
81
|
): SyncFunctionComponent {
|
|
97
|
-
return SyncFunctionComponent(name,
|
|
82
|
+
return SyncFunctionComponent(name, emptyArray()) { body() }.also {
|
|
98
83
|
syncFunctions[name] = it
|
|
99
84
|
}
|
|
100
85
|
}
|
|
@@ -103,7 +88,7 @@ open class ObjectDefinitionBuilder {
|
|
|
103
88
|
name: String,
|
|
104
89
|
crossinline body: () -> R
|
|
105
90
|
): SyncFunctionComponent {
|
|
106
|
-
return SyncFunctionComponent(name,
|
|
91
|
+
return SyncFunctionComponent(name, emptyArray()) { body() }.also {
|
|
107
92
|
syncFunctions[name] = it
|
|
108
93
|
}
|
|
109
94
|
}
|
|
@@ -112,7 +97,10 @@ open class ObjectDefinitionBuilder {
|
|
|
112
97
|
name: String,
|
|
113
98
|
crossinline body: (p0: P0) -> R
|
|
114
99
|
): SyncFunctionComponent {
|
|
115
|
-
return SyncFunctionComponent(name,
|
|
100
|
+
return SyncFunctionComponent(name, toArgsArray<P0>()) { (p0) ->
|
|
101
|
+
enforceType<P0>(p0)
|
|
102
|
+
body(p0)
|
|
103
|
+
}.also {
|
|
116
104
|
syncFunctions[name] = it
|
|
117
105
|
}
|
|
118
106
|
}
|
|
@@ -121,7 +109,10 @@ open class ObjectDefinitionBuilder {
|
|
|
121
109
|
name: String,
|
|
122
110
|
crossinline body: (p0: P0, p1: P1) -> R
|
|
123
111
|
): SyncFunctionComponent {
|
|
124
|
-
return SyncFunctionComponent(name,
|
|
112
|
+
return SyncFunctionComponent(name, toArgsArray<P0, P1>()) { (p0, p1) ->
|
|
113
|
+
enforceType<P0, P1>(p0, p1)
|
|
114
|
+
body(p0, p1)
|
|
115
|
+
}.also {
|
|
125
116
|
syncFunctions[name] = it
|
|
126
117
|
}
|
|
127
118
|
}
|
|
@@ -130,7 +121,10 @@ open class ObjectDefinitionBuilder {
|
|
|
130
121
|
name: String,
|
|
131
122
|
crossinline body: (p0: P0, p1: P1, p2: P2) -> R
|
|
132
123
|
): SyncFunctionComponent {
|
|
133
|
-
return SyncFunctionComponent(name,
|
|
124
|
+
return SyncFunctionComponent(name, toArgsArray<P0, P1, P2>()) { (p0, p1, p2) ->
|
|
125
|
+
enforceType<P0, P1, P2>(p0, p1, p2)
|
|
126
|
+
body(p0, p1, p2)
|
|
127
|
+
}.also {
|
|
134
128
|
syncFunctions[name] = it
|
|
135
129
|
}
|
|
136
130
|
}
|
|
@@ -139,7 +133,10 @@ open class ObjectDefinitionBuilder {
|
|
|
139
133
|
name: String,
|
|
140
134
|
crossinline body: (p0: P0, p1: P1, p2: P2, p3: P3) -> R
|
|
141
135
|
): SyncFunctionComponent {
|
|
142
|
-
return SyncFunctionComponent(name,
|
|
136
|
+
return SyncFunctionComponent(name, toArgsArray<P0, P1, P2, P3>()) { (p0, p1, p2, p3) ->
|
|
137
|
+
enforceType<P0, P1, P2, P3>(p0, p1, p2, p3)
|
|
138
|
+
body(p0, p1, p2, p3)
|
|
139
|
+
}.also {
|
|
143
140
|
syncFunctions[name] = it
|
|
144
141
|
}
|
|
145
142
|
}
|
|
@@ -148,7 +145,10 @@ open class ObjectDefinitionBuilder {
|
|
|
148
145
|
name: String,
|
|
149
146
|
crossinline body: (p0: P0, p1: P1, p2: P2, p3: P3, p4: P4) -> R
|
|
150
147
|
): SyncFunctionComponent {
|
|
151
|
-
return SyncFunctionComponent(name,
|
|
148
|
+
return SyncFunctionComponent(name, toArgsArray<P0, P1, P2, P3, P4>()) { (p0, p1, p2, p3, p4) ->
|
|
149
|
+
enforceType<P0, P1, P2, P3, P4>(p0, p1, p2, p3, p4)
|
|
150
|
+
body(p0, p1, p2, p3, p4)
|
|
151
|
+
}.also {
|
|
152
152
|
syncFunctions[name] = it
|
|
153
153
|
}
|
|
154
154
|
}
|
|
@@ -157,7 +157,10 @@ open class ObjectDefinitionBuilder {
|
|
|
157
157
|
name: String,
|
|
158
158
|
crossinline body: (p0: P0, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5) -> R
|
|
159
159
|
): SyncFunctionComponent {
|
|
160
|
-
return SyncFunctionComponent(name,
|
|
160
|
+
return SyncFunctionComponent(name, toArgsArray<P0, P1, P2, P3, P4, P5>()) { (p0, p1, p2, p3, p4, p5) ->
|
|
161
|
+
enforceType<P0, P1, P2, P3, P4, P5>(p0, p1, p2, p3, p4, p5)
|
|
162
|
+
body(p0, p1, p2, p3, p4, p5)
|
|
163
|
+
}.also {
|
|
161
164
|
syncFunctions[name] = it
|
|
162
165
|
}
|
|
163
166
|
}
|
|
@@ -166,7 +169,10 @@ open class ObjectDefinitionBuilder {
|
|
|
166
169
|
name: String,
|
|
167
170
|
crossinline body: (p0: P0, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6) -> R
|
|
168
171
|
): SyncFunctionComponent {
|
|
169
|
-
return SyncFunctionComponent(name,
|
|
172
|
+
return SyncFunctionComponent(name, toArgsArray<P0, P1, P2, P3, P4, P5, P6>()) { (p0, p1, p2, p3, p4, p5, p6) ->
|
|
173
|
+
enforceType<P0, P1, P2, P3, P4, P5, P6>(p0, p1, p2, p3, p4, p5, p6)
|
|
174
|
+
body(p0, p1, p2, p3, p4, p5, p6)
|
|
175
|
+
}.also {
|
|
170
176
|
syncFunctions[name] = it
|
|
171
177
|
}
|
|
172
178
|
}
|
|
@@ -175,7 +181,10 @@ open class ObjectDefinitionBuilder {
|
|
|
175
181
|
name: String,
|
|
176
182
|
crossinline body: (p0: P0, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7) -> R
|
|
177
183
|
): SyncFunctionComponent {
|
|
178
|
-
return SyncFunctionComponent(name,
|
|
184
|
+
return SyncFunctionComponent(name, toArgsArray<P0, P1, P2, P3, P4, P5, P6, P7>()) { (p0, p1, p2, p3, p4, p5, p6, p7) ->
|
|
185
|
+
enforceType<P0, P1, P2, P3, P4, P5, P6, P7>(p0, p1, p2, p3, p4, p5, p6, p7)
|
|
186
|
+
body(p0, p1, p2, p3, p4, p5, p6, p7)
|
|
187
|
+
}.also {
|
|
179
188
|
syncFunctions[name] = it
|
|
180
189
|
}
|
|
181
190
|
}
|
|
@@ -185,7 +194,7 @@ open class ObjectDefinitionBuilder {
|
|
|
185
194
|
name: String,
|
|
186
195
|
crossinline body: () -> Any?
|
|
187
196
|
): AsyncFunction {
|
|
188
|
-
return
|
|
197
|
+
return createAsyncFunctionComponent(name, emptyArray()) { body() }.also {
|
|
189
198
|
asyncFunctions[name] = it
|
|
190
199
|
}
|
|
191
200
|
}
|
|
@@ -194,7 +203,7 @@ open class ObjectDefinitionBuilder {
|
|
|
194
203
|
name: String,
|
|
195
204
|
crossinline body: () -> R
|
|
196
205
|
): AsyncFunction {
|
|
197
|
-
return
|
|
206
|
+
return createAsyncFunctionComponent(name, emptyArray()) { body() }.also {
|
|
198
207
|
asyncFunctions[name] = it
|
|
199
208
|
}
|
|
200
209
|
}
|
|
@@ -203,10 +212,14 @@ open class ObjectDefinitionBuilder {
|
|
|
203
212
|
name: String,
|
|
204
213
|
crossinline body: (p0: P0) -> R
|
|
205
214
|
): AsyncFunction {
|
|
206
|
-
|
|
215
|
+
// We can't split that function, because that introduces a ambiguity when creating DSL component without parameters.
|
|
216
|
+
return if (P0::class.java == Promise::class.java) {
|
|
207
217
|
AsyncFunctionWithPromiseComponent(name, arrayOf()) { _, promise -> body(promise as P0) }
|
|
208
218
|
} else {
|
|
209
|
-
|
|
219
|
+
createAsyncFunctionComponent(name, toArgsArray<P0>()) { (p0) ->
|
|
220
|
+
enforceType<P0>(p0)
|
|
221
|
+
body(p0)
|
|
222
|
+
}
|
|
210
223
|
}.also {
|
|
211
224
|
asyncFunctions[name] = it
|
|
212
225
|
}
|
|
@@ -216,10 +229,22 @@ open class ObjectDefinitionBuilder {
|
|
|
216
229
|
name: String,
|
|
217
230
|
crossinline body: (p0: P0, p1: P1) -> R
|
|
218
231
|
): AsyncFunction {
|
|
219
|
-
return
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
232
|
+
return createAsyncFunctionComponent(name, toArgsArray<P0, P1>()) { (p0, p1) ->
|
|
233
|
+
enforceType<P0, P1>(p0, p1)
|
|
234
|
+
body(p0, p1)
|
|
235
|
+
}.also {
|
|
236
|
+
asyncFunctions[name] = it
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
@JvmName("AsyncFunctionWithPromise")
|
|
241
|
+
inline fun <reified R, reified P0> AsyncFunction(
|
|
242
|
+
name: String,
|
|
243
|
+
crossinline body: (p0: P0, p1: Promise) -> R
|
|
244
|
+
): AsyncFunction {
|
|
245
|
+
return AsyncFunctionWithPromiseComponent(name, toArgsArray<P0>()) { (p0), promise ->
|
|
246
|
+
enforceType<P0>(p0)
|
|
247
|
+
body(p0, promise)
|
|
223
248
|
}.also {
|
|
224
249
|
asyncFunctions[name] = it
|
|
225
250
|
}
|
|
@@ -229,10 +254,22 @@ open class ObjectDefinitionBuilder {
|
|
|
229
254
|
name: String,
|
|
230
255
|
crossinline body: (p0: P0, p1: P1, p2: P2) -> R
|
|
231
256
|
): AsyncFunction {
|
|
232
|
-
return
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
257
|
+
return createAsyncFunctionComponent(name, toArgsArray<P0, P1, P2>()) { (p0, p1, p2) ->
|
|
258
|
+
enforceType<P0, P1, P2>(p0, p1, p2)
|
|
259
|
+
body(p0, p1, p2)
|
|
260
|
+
}.also {
|
|
261
|
+
asyncFunctions[name] = it
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
@JvmName("AsyncFunctionWithPromise")
|
|
266
|
+
inline fun <reified R, reified P0, reified P1> AsyncFunction(
|
|
267
|
+
name: String,
|
|
268
|
+
crossinline body: (p0: P0, p1: P1, p2: Promise) -> R
|
|
269
|
+
): AsyncFunction {
|
|
270
|
+
return AsyncFunctionWithPromiseComponent(name, toArgsArray<P0, P1>()) { (p0, p1), promise ->
|
|
271
|
+
enforceType<P0, P1>(p0, p1)
|
|
272
|
+
body(p0, p1, promise)
|
|
236
273
|
}.also {
|
|
237
274
|
asyncFunctions[name] = it
|
|
238
275
|
}
|
|
@@ -242,10 +279,22 @@ open class ObjectDefinitionBuilder {
|
|
|
242
279
|
name: String,
|
|
243
280
|
crossinline body: (p0: P0, p1: P1, p2: P2, p3: P3) -> R
|
|
244
281
|
): AsyncFunction {
|
|
245
|
-
return
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
282
|
+
return createAsyncFunctionComponent(name, toArgsArray<P0, P1, P2, P3>()) { (p0, p1, p2, p3) ->
|
|
283
|
+
enforceType<P0, P1, P2, P3>(p0, p1, p2, p3)
|
|
284
|
+
body(p0, p1, p2, p3)
|
|
285
|
+
}.also {
|
|
286
|
+
asyncFunctions[name] = it
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
@JvmName("AsyncFunctionWithPromise")
|
|
291
|
+
inline fun <reified R, reified P0, reified P1, reified P2> AsyncFunction(
|
|
292
|
+
name: String,
|
|
293
|
+
crossinline body: (p0: P0, p1: P1, p2: P2, p3: Promise) -> R
|
|
294
|
+
): AsyncFunction {
|
|
295
|
+
return AsyncFunctionWithPromiseComponent(name, toArgsArray<P0, P1, P2>()) { (p0, p1, p2), promise ->
|
|
296
|
+
enforceType<P0, P1, P2>(p0, p1, p2)
|
|
297
|
+
body(p0, p1, p2, promise)
|
|
249
298
|
}.also {
|
|
250
299
|
asyncFunctions[name] = it
|
|
251
300
|
}
|
|
@@ -255,10 +304,22 @@ open class ObjectDefinitionBuilder {
|
|
|
255
304
|
name: String,
|
|
256
305
|
crossinline body: (p0: P0, p1: P1, p2: P2, p3: P3, p4: P4) -> R
|
|
257
306
|
): AsyncFunction {
|
|
258
|
-
return
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
307
|
+
return createAsyncFunctionComponent(name, toArgsArray<P0, P1, P2, P3, P4>()) { (p0, p1, p2, p3, p4) ->
|
|
308
|
+
enforceType<P0, P1, P2, P3, P4>(p0, p1, p2, p3, p4)
|
|
309
|
+
body(p0, p1, p2, p3, p4)
|
|
310
|
+
}.also {
|
|
311
|
+
asyncFunctions[name] = it
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
@JvmName("AsyncFunctionWithPromise")
|
|
316
|
+
inline fun <reified R, reified P0, reified P1, reified P2, reified P3> AsyncFunction(
|
|
317
|
+
name: String,
|
|
318
|
+
crossinline body: (p0: P0, p1: P1, p2: P2, p3: P3, p4: Promise) -> R
|
|
319
|
+
): AsyncFunction {
|
|
320
|
+
return AsyncFunctionWithPromiseComponent(name, toArgsArray<P0, P1, P2, P3>()) { (p0, p1, p2, p3), promise ->
|
|
321
|
+
enforceType<P0, P1, P2, P3>(p0, p1, p2, p3)
|
|
322
|
+
body(p0, p1, p2, p3, promise)
|
|
262
323
|
}.also {
|
|
263
324
|
asyncFunctions[name] = it
|
|
264
325
|
}
|
|
@@ -268,10 +329,22 @@ open class ObjectDefinitionBuilder {
|
|
|
268
329
|
name: String,
|
|
269
330
|
crossinline body: (p0: P0, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5) -> R
|
|
270
331
|
): AsyncFunction {
|
|
271
|
-
return
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
332
|
+
return createAsyncFunctionComponent(name, toArgsArray<P0, P1, P2, P3, P4, P5>()) { (p0, p1, p2, p3, p4, p5) ->
|
|
333
|
+
enforceType<P0, P1, P2, P3, P4, P5>(p0, p1, p2, p3, p4, p5)
|
|
334
|
+
body(p0, p1, p2, p3, p4, p5)
|
|
335
|
+
}.also {
|
|
336
|
+
asyncFunctions[name] = it
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
@JvmName("AsyncFunctionWithPromise")
|
|
341
|
+
inline fun <reified R, reified P0, reified P1, reified P2, reified P3, reified P4> AsyncFunction(
|
|
342
|
+
name: String,
|
|
343
|
+
crossinline body: (p0: P0, p1: P1, p2: P2, p3: P3, p4: P4, p5: Promise) -> R
|
|
344
|
+
): AsyncFunction {
|
|
345
|
+
return AsyncFunctionWithPromiseComponent(name, toArgsArray<P0, P1, P2, P3, P4>()) { (p0, p1, p2, p3, p4), promise ->
|
|
346
|
+
enforceType<P0, P1, P2, P3, P4>(p0, p1, p2, p3, p4)
|
|
347
|
+
body(p0, p1, p2, p3, p4, promise)
|
|
275
348
|
}.also {
|
|
276
349
|
asyncFunctions[name] = it
|
|
277
350
|
}
|
|
@@ -281,10 +354,22 @@ open class ObjectDefinitionBuilder {
|
|
|
281
354
|
name: String,
|
|
282
355
|
crossinline body: (p0: P0, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6) -> R
|
|
283
356
|
): AsyncFunction {
|
|
284
|
-
return
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
357
|
+
return createAsyncFunctionComponent(name, toArgsArray<P0, P1, P2, P3, P4, P5, P6>()) { (p0, p1, p2, p3, p4, p5, p6) ->
|
|
358
|
+
enforceType<P0, P1, P2, P3, P4, P5, P6>(p0, p1, p2, p3, p4, p5, p6)
|
|
359
|
+
body(p0, p1, p2, p3, p4, p5, p6)
|
|
360
|
+
}.also {
|
|
361
|
+
asyncFunctions[name] = it
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
@JvmName("AsyncFunctionWithPromise")
|
|
366
|
+
inline fun <reified R, reified P0, reified P1, reified P2, reified P3, reified P4, reified P5> AsyncFunction(
|
|
367
|
+
name: String,
|
|
368
|
+
crossinline body: (p0: P0, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: Promise) -> R
|
|
369
|
+
): AsyncFunction {
|
|
370
|
+
return AsyncFunctionWithPromiseComponent(name, toArgsArray<P0, P1, P2, P3, P4, P5>()) { (p0, p1, p2, p3, p4, p5), promise ->
|
|
371
|
+
enforceType<P0, P1, P2, P3, P4, P5>(p0, p1, p2, p3, p4, p5)
|
|
372
|
+
body(p0, p1, p2, p3, p4, p5, promise)
|
|
288
373
|
}.also {
|
|
289
374
|
asyncFunctions[name] = it
|
|
290
375
|
}
|
|
@@ -294,10 +379,22 @@ open class ObjectDefinitionBuilder {
|
|
|
294
379
|
name: String,
|
|
295
380
|
crossinline body: (p0: P0, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: P7) -> R
|
|
296
381
|
): AsyncFunction {
|
|
297
|
-
return
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
382
|
+
return createAsyncFunctionComponent(name, toArgsArray<P0, P1, P2, P3, P4, P5, P6, P7>()) { (p0, p1, p2, p3, p4, p5, p6, p7) ->
|
|
383
|
+
enforceType<P0, P1, P2, P3, P4, P5, P6, P7>(p0, p1, p2, p3, p4, p5, p6, p7)
|
|
384
|
+
body(p0, p1, p2, p3, p4, p5, p6, p7)
|
|
385
|
+
}.also {
|
|
386
|
+
asyncFunctions[name] = it
|
|
387
|
+
}
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
@JvmName("AsyncFunctionWithPromise")
|
|
391
|
+
inline fun <reified R, reified P0, reified P1, reified P2, reified P3, reified P4, reified P5, reified P6> AsyncFunction(
|
|
392
|
+
name: String,
|
|
393
|
+
crossinline body: (p0: P0, p1: P1, p2: P2, p3: P3, p4: P4, p5: P5, p6: P6, p7: Promise) -> R
|
|
394
|
+
): AsyncFunction {
|
|
395
|
+
return AsyncFunctionWithPromiseComponent(name, toArgsArray<P0, P1, P2, P3, P4, P5, P6>()) { (p0, p1, p2, p3, p4, p5, p6), promise ->
|
|
396
|
+
enforceType<P0, P1, P2, P3, P4, P5, P6>(p0, p1, p2, p3, p4, p5, p6)
|
|
397
|
+
body(p0, p1, p2, p3, p4, p5, p6, promise)
|
|
301
398
|
}.also {
|
|
302
399
|
asyncFunctions[name] = it
|
|
303
400
|
}
|
|
@@ -348,14 +445,16 @@ open class ObjectDefinitionBuilder {
|
|
|
348
445
|
* Creates module's lifecycle listener that is called right after the first event listener is added.
|
|
349
446
|
*/
|
|
350
447
|
inline fun OnStartObserving(crossinline body: () -> Unit) {
|
|
351
|
-
|
|
448
|
+
@Suppress("UNUSED_ANONYMOUS_PARAMETER")
|
|
449
|
+
AsyncFunction("startObserving") { eventName: String? -> body() }
|
|
352
450
|
}
|
|
353
451
|
|
|
354
452
|
/**
|
|
355
453
|
* Creates module's lifecycle listener that is called right after all event listeners are removed.
|
|
356
454
|
*/
|
|
357
455
|
inline fun OnStopObserving(crossinline body: () -> Unit) {
|
|
358
|
-
|
|
456
|
+
@Suppress("UNUSED_ANONYMOUS_PARAMETER")
|
|
457
|
+
AsyncFunction("stopObserving") { eventName: String? -> body() }
|
|
359
458
|
}
|
|
360
459
|
|
|
361
460
|
/**
|
|
@@ -4,7 +4,6 @@ import expo.modules.kotlin.functions.SyncFunctionComponent
|
|
|
4
4
|
import expo.modules.kotlin.types.AnyType
|
|
5
5
|
import expo.modules.kotlin.types.toAnyType
|
|
6
6
|
import kotlin.reflect.KType
|
|
7
|
-
import kotlin.reflect.typeOf
|
|
8
7
|
|
|
9
8
|
open class PropertyComponentBuilder(
|
|
10
9
|
val name: String
|
|
@@ -16,14 +15,14 @@ open class PropertyComponentBuilder(
|
|
|
16
15
|
* Modifier that sets property getter that has no arguments (the caller is not used).
|
|
17
16
|
*/
|
|
18
17
|
inline fun <T> get(crossinline body: () -> T) = apply {
|
|
19
|
-
getter = SyncFunctionComponent("get",
|
|
18
|
+
getter = SyncFunctionComponent("get", emptyArray()) { body() }
|
|
20
19
|
}
|
|
21
20
|
|
|
22
21
|
/**
|
|
23
22
|
* Modifier that sets property setter that receives only the new value as an argument.
|
|
24
23
|
*/
|
|
25
24
|
inline fun <reified T> set(crossinline body: (newValue: T) -> Unit) = apply {
|
|
26
|
-
setter = SyncFunctionComponent("set", arrayOf(
|
|
25
|
+
setter = SyncFunctionComponent("set", arrayOf(toAnyType<T>())) { body(it[0] as T) }
|
|
27
26
|
}
|
|
28
27
|
|
|
29
28
|
fun build(): PropertyComponent {
|
|
@@ -53,7 +52,7 @@ class PropertyComponentBuilderWithThis<ThisType>(
|
|
|
53
52
|
* Modifier that sets property setter that receives only the new value as an argument.
|
|
54
53
|
*/
|
|
55
54
|
inline fun <reified T> set(crossinline body: (self: ThisType, newValue: T) -> Unit) = apply {
|
|
56
|
-
setter = SyncFunctionComponent("set", arrayOf(AnyType(thisType),
|
|
55
|
+
setter = SyncFunctionComponent("set", arrayOf(AnyType(thisType), toAnyType<T>())) {
|
|
57
56
|
@Suppress("UNCHECKED_CAST")
|
|
58
57
|
body(it[0] as ThisType, it[1] as T)
|
|
59
58
|
}.also {
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
package expo.modules.kotlin.sharedobjects
|
|
2
|
+
|
|
3
|
+
import expo.modules.kotlin.jni.JavaScriptObject
|
|
4
|
+
|
|
5
|
+
class ClassRegistry {
|
|
6
|
+
internal var pairs = mutableMapOf<Class<*>, JavaScriptObject>()
|
|
7
|
+
|
|
8
|
+
internal fun add(native: Class<*>, js: JavaScriptObject) {
|
|
9
|
+
js.defineDeallocator {
|
|
10
|
+
delete(native)
|
|
11
|
+
}
|
|
12
|
+
pairs[native] = js
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
private fun delete(native: Class<*>) {
|
|
16
|
+
pairs.remove(native)
|
|
17
|
+
}
|
|
18
|
+
internal fun toJavaScriptObject(native: Class<*>): JavaScriptObject? {
|
|
19
|
+
return pairs[native]
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -1,15 +1,48 @@
|
|
|
1
1
|
package expo.modules.kotlin.sharedobjects
|
|
2
2
|
|
|
3
3
|
import expo.modules.core.interfaces.DoNotStrip
|
|
4
|
+
import expo.modules.kotlin.AppContext
|
|
5
|
+
import expo.modules.kotlin.jni.JavaScriptObject
|
|
6
|
+
import expo.modules.kotlin.logger
|
|
7
|
+
import java.lang.ref.WeakReference
|
|
4
8
|
|
|
5
9
|
@DoNotStrip
|
|
6
|
-
open class SharedObject {
|
|
10
|
+
open class SharedObject(appContext: AppContext? = null) {
|
|
7
11
|
/**
|
|
8
12
|
* An identifier of the native shared object that maps to the JavaScript object.
|
|
9
13
|
* When the object is not linked with any JavaScript object, its value is 0.
|
|
10
14
|
*/
|
|
11
15
|
internal var sharedObjectId: SharedObjectId = SharedObjectId(0)
|
|
12
16
|
|
|
17
|
+
internal var appContextHolder = WeakReference<AppContext>(appContext)
|
|
18
|
+
|
|
19
|
+
val appContext: AppContext?
|
|
20
|
+
get() = appContextHolder.get()
|
|
21
|
+
|
|
22
|
+
private fun getJavaScriptObject(): JavaScriptObject? {
|
|
23
|
+
return SharedObjectId(sharedObjectId.value)
|
|
24
|
+
.toJavaScriptObject(
|
|
25
|
+
appContext ?: return null
|
|
26
|
+
)
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
fun sendEvent(eventName: String, vararg args: Any?) {
|
|
30
|
+
val jsThis = getJavaScriptObject() ?: return
|
|
31
|
+
|
|
32
|
+
try {
|
|
33
|
+
jsThis.getProperty("emit")
|
|
34
|
+
.getFunction<Unit?>()
|
|
35
|
+
.invoke(
|
|
36
|
+
eventName,
|
|
37
|
+
*args,
|
|
38
|
+
thisValue = jsThis,
|
|
39
|
+
appContext = appContext
|
|
40
|
+
)
|
|
41
|
+
} catch (e: Throwable) {
|
|
42
|
+
logger.error("Unable to send event '$eventName' by shared object of type ${this::class.java.simpleName}", e)
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
13
46
|
/**
|
|
14
47
|
* Called when the shared object being deallocated.
|
|
15
48
|
*/
|
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
package expo.modules.kotlin.sharedobjects
|
|
2
2
|
|
|
3
3
|
import expo.modules.kotlin.AppContext
|
|
4
|
+
import expo.modules.kotlin.exception.Exceptions
|
|
4
5
|
import expo.modules.kotlin.jni.JavaScriptObject
|
|
5
6
|
import expo.modules.kotlin.jni.JavaScriptWeakObject
|
|
7
|
+
import java.lang.ref.WeakReference
|
|
6
8
|
|
|
7
9
|
@JvmInline
|
|
8
10
|
value class SharedObjectId(val value: Int) {
|
|
11
|
+
|
|
9
12
|
fun toNativeObject(appContext: AppContext): SharedObject? {
|
|
10
13
|
return appContext.sharedObjectRegistry.toNativeObject(this)
|
|
11
14
|
}
|
|
@@ -20,7 +23,9 @@ typealias SharedObjectPair = Pair<SharedObject, JavaScriptWeakObject>
|
|
|
20
23
|
|
|
21
24
|
const val sharedObjectIdPropertyName = "__expo_shared_object_id__"
|
|
22
25
|
|
|
23
|
-
class SharedObjectRegistry {
|
|
26
|
+
class SharedObjectRegistry(appContext: AppContext) {
|
|
27
|
+
private val appContextHolder = WeakReference(appContext)
|
|
28
|
+
|
|
24
29
|
private var currentId: SharedObjectId = SharedObjectId(1)
|
|
25
30
|
|
|
26
31
|
internal var pairs = mutableMapOf<SharedObjectId, SharedObjectPair>()
|
|
@@ -34,24 +39,34 @@ class SharedObjectRegistry {
|
|
|
34
39
|
internal fun add(native: SharedObject, js: JavaScriptObject): SharedObjectId {
|
|
35
40
|
val id = pullNextId()
|
|
36
41
|
native.sharedObjectId = id
|
|
42
|
+
|
|
43
|
+
// This property should be deprecated, but it's still used when passing as a view prop.
|
|
44
|
+
// It's already defined in the JS base SharedObject class prototype,
|
|
45
|
+
// but with the current implementation it's possible to use a raw object for registration.
|
|
37
46
|
js.defineProperty(sharedObjectIdPropertyName, id.value)
|
|
38
47
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
48
|
+
val appContext = appContextHolder.get() ?: throw Exceptions.AppContextLost()
|
|
49
|
+
|
|
50
|
+
appContext
|
|
51
|
+
.jsiInterop
|
|
52
|
+
.setNativeStateForSharedObject(id.value, js)
|
|
42
53
|
|
|
43
54
|
val jsWeakObject = js.createWeak()
|
|
44
55
|
synchronized(this) {
|
|
45
56
|
pairs[id] = native to jsWeakObject
|
|
46
57
|
}
|
|
58
|
+
|
|
59
|
+
if (native.appContextHolder.get() == null) {
|
|
60
|
+
native.appContextHolder = WeakReference(appContext)
|
|
61
|
+
}
|
|
62
|
+
|
|
47
63
|
return id
|
|
48
64
|
}
|
|
49
65
|
|
|
50
66
|
internal fun delete(id: SharedObjectId) {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
}
|
|
54
|
-
removedObject?.let { (native, js) ->
|
|
67
|
+
synchronized(this) {
|
|
68
|
+
pairs.remove(id)
|
|
69
|
+
}?.let { (native, _) ->
|
|
55
70
|
native.sharedObjectId = SharedObjectId(0)
|
|
56
71
|
native.deallocate()
|
|
57
72
|
}
|
|
@@ -1,7 +1,13 @@
|
|
|
1
1
|
package expo.modules.kotlin.sharedobjects
|
|
2
2
|
|
|
3
|
+
import expo.modules.core.interfaces.DoNotStrip
|
|
4
|
+
import expo.modules.kotlin.AppContext
|
|
5
|
+
|
|
3
6
|
/**
|
|
4
7
|
* Shared object (ref) that holds a strong reference to any native object. Allows passing references
|
|
5
8
|
* to native instances among different independent libraries.
|
|
6
9
|
*/
|
|
7
|
-
|
|
10
|
+
@Suppress("KotlinJniMissingFunction")
|
|
11
|
+
@DoNotStrip
|
|
12
|
+
open class SharedRef<RefType>(val ref: RefType, appContext: AppContext? = null) :
|
|
13
|
+
SharedObject(appContext)
|
|
@@ -30,6 +30,7 @@ inline fun <T> trace(tag: String, blockName: String, crossinline block: () -> T)
|
|
|
30
30
|
* <p>This call must be followed by a corresponding call to {@link #endTraceBlock()} on the same
|
|
31
31
|
* thread.
|
|
32
32
|
*/
|
|
33
|
+
@Suppress("NOTHING_TO_INLINE")
|
|
33
34
|
inline fun beginTraceBlock(tag: String, blockName: String) {
|
|
34
35
|
Trace.beginSection("[$tag] $blockName")
|
|
35
36
|
}
|
|
@@ -37,6 +38,7 @@ inline fun beginTraceBlock(tag: String, blockName: String) {
|
|
|
37
38
|
/**
|
|
38
39
|
* Writes a trace message to indicate that a given section of code has ended.
|
|
39
40
|
*/
|
|
41
|
+
@Suppress("NOTHING_TO_INLINE")
|
|
40
42
|
inline fun endTraceBlock() {
|
|
41
43
|
Trace.endSection()
|
|
42
44
|
}
|
|
@@ -47,11 +49,13 @@ inline fun endTraceBlock() {
|
|
|
47
49
|
* <p>Must be followed by a call to {@link #endAsyncTraceBlock(String, String, int)} with the same
|
|
48
50
|
* tag, blockName and cookie.
|
|
49
51
|
*/
|
|
52
|
+
@Suppress("NOTHING_TO_INLINE")
|
|
50
53
|
inline fun beginAsyncTraceBlock(tag: String, blockName: String, cookie: Int = 0) =
|
|
51
54
|
Trace.beginAsyncSection("[$tag] $blockName", cookie)
|
|
52
55
|
|
|
53
56
|
/**
|
|
54
57
|
* Writes a trace message to indicate that the current method has ended.
|
|
55
58
|
*/
|
|
59
|
+
@Suppress("NOTHING_TO_INLINE")
|
|
56
60
|
inline fun endAsyncTraceBlock(tag: String, blockName: String, cookie: Int = 0) =
|
|
57
61
|
Trace.endAsyncSection("[$tag] $blockName", cookie)
|