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,29 +1,18 @@
|
|
|
1
1
|
package expo.modules.core.interfaces;
|
|
2
2
|
|
|
3
|
-
import
|
|
4
|
-
import com.facebook.react.bridge.JavaScriptContextHolder;
|
|
5
|
-
import com.facebook.react.bridge.JavaScriptExecutorFactory;
|
|
6
|
-
import com.facebook.react.bridge.ReactApplicationContext;
|
|
7
|
-
|
|
3
|
+
import androidx.annotation.NonNull;
|
|
8
4
|
import androidx.annotation.Nullable;
|
|
9
5
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
*
|
|
14
|
-
* @param useDeveloperSupport true if {@link ReactNativeHost} enabled developer support
|
|
15
|
-
* @return instance of {@link ReactInstanceManager}, or null if not to override
|
|
16
|
-
*/
|
|
17
|
-
@Nullable
|
|
18
|
-
default ReactInstanceManager createReactInstanceManager(boolean useDeveloperSupport) {
|
|
19
|
-
return null;
|
|
20
|
-
}
|
|
6
|
+
import com.facebook.react.bridge.JavaScriptExecutorFactory;
|
|
7
|
+
import com.facebook.react.bridge.ReactContext;
|
|
8
|
+
import com.facebook.react.devsupport.interfaces.DevSupportManager;
|
|
21
9
|
|
|
10
|
+
public interface ReactNativeHostHandler {
|
|
22
11
|
/**
|
|
23
12
|
* Given chance for modules to override react bundle file.
|
|
24
13
|
* e.g. for expo-updates
|
|
25
14
|
*
|
|
26
|
-
* @param useDeveloperSupport true if {@link ReactNativeHost} enabled developer support
|
|
15
|
+
* @param useDeveloperSupport true if {@link com.facebook.react.ReactNativeHost} enabled developer support
|
|
27
16
|
* @return custom path to bundle file, or null if not to override
|
|
28
17
|
*/
|
|
29
18
|
@Nullable
|
|
@@ -35,7 +24,7 @@ public interface ReactNativeHostHandler {
|
|
|
35
24
|
* Given chance for modules to override react bundle asset name.
|
|
36
25
|
* e.g. for expo-updates
|
|
37
26
|
*
|
|
38
|
-
* @param useDeveloperSupport true if {@link ReactNativeHost} enabled developer support
|
|
27
|
+
* @param useDeveloperSupport true if {@link com.facebook.react.ReactNativeHost} enabled developer support
|
|
39
28
|
* @return custom bundle asset name, or null if not to override
|
|
40
29
|
*/
|
|
41
30
|
@Nullable
|
|
@@ -62,12 +51,16 @@ public interface ReactNativeHostHandler {
|
|
|
62
51
|
* doesn't exist in the React Native 0.66 or below.
|
|
63
52
|
*
|
|
64
53
|
* @return custom DevSupportManagerFactory, or null if not to override
|
|
54
|
+
*
|
|
55
|
+
* NOTE: This callback is not supported on bridgeless mode
|
|
65
56
|
*/
|
|
66
57
|
@Nullable
|
|
67
58
|
default Object getDevSupportManagerFactory() { return null; }
|
|
68
59
|
|
|
69
60
|
/**
|
|
70
61
|
* Given chance for modules to override the javascript executor factory.
|
|
62
|
+
*
|
|
63
|
+
* NOTE: This callback is not supported on bridgeless mode
|
|
71
64
|
*/
|
|
72
65
|
@Nullable
|
|
73
66
|
default JavaScriptExecutorFactory getJavaScriptExecutorFactory() { return null; }
|
|
@@ -75,26 +68,26 @@ public interface ReactNativeHostHandler {
|
|
|
75
68
|
//region event listeners
|
|
76
69
|
|
|
77
70
|
/**
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
* @param useDeveloperSupport true if {@link ReactNativeHost} enabled developer support
|
|
71
|
+
* Callback before react instance creation
|
|
81
72
|
*/
|
|
82
|
-
default void
|
|
83
|
-
ReactApplicationContext reactApplicationContext,
|
|
84
|
-
JavaScriptContextHolder jsContext,
|
|
85
|
-
boolean useDeveloperSupport
|
|
86
|
-
) {
|
|
87
|
-
}
|
|
73
|
+
default void onWillCreateReactInstance(boolean useDeveloperSupport) {}
|
|
88
74
|
|
|
89
75
|
/**
|
|
90
|
-
* Callback
|
|
76
|
+
* Callback when the {@link DevSupportManager} is available
|
|
91
77
|
*/
|
|
92
|
-
default void
|
|
78
|
+
default void onDidCreateDevSupportManager(@NonNull DevSupportManager devSupportManager) {}
|
|
93
79
|
|
|
94
80
|
/**
|
|
95
|
-
* Callback after
|
|
81
|
+
* Callback after react instance creation
|
|
82
|
+
*/
|
|
83
|
+
default void onDidCreateReactInstance(boolean useDeveloperSupport, ReactContext reactContext) {}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Callback when receiving unhandled React Native exceptions
|
|
87
|
+
*
|
|
88
|
+
* NOTE: This callback is only available on bridgeless mode
|
|
96
89
|
*/
|
|
97
|
-
default void
|
|
90
|
+
default void onReactInstanceException(boolean useDeveloperSupport, @NonNull Exception exception) {}
|
|
98
91
|
|
|
99
92
|
//endregion
|
|
100
93
|
}
|
|
@@ -3,12 +3,6 @@ package expo.modules.core.logging
|
|
|
3
3
|
/**
|
|
4
4
|
* The interface that needs to be implemented by log handlers.
|
|
5
5
|
*/
|
|
6
|
-
abstract class LogHandler
|
|
7
|
-
/**
|
|
8
|
-
* Category is always passed in from Logger
|
|
9
|
-
*/
|
|
10
|
-
val category: String
|
|
11
|
-
) {
|
|
12
|
-
|
|
6
|
+
abstract class LogHandler {
|
|
13
7
|
internal abstract fun log(type: LogType, message: String, cause: Throwable? = null)
|
|
14
8
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
package expo.modules.core.logging
|
|
2
|
+
|
|
3
|
+
import android.content.Context
|
|
4
|
+
|
|
5
|
+
object LogHandlers {
|
|
6
|
+
fun createOSLogHandler(category: String): LogHandler = OSLogHandler(category)
|
|
7
|
+
fun createPersistentFileLogHandler(context: Context, category: String): LogHandler = PersistentFileLogHandler(
|
|
8
|
+
category,
|
|
9
|
+
context
|
|
10
|
+
)
|
|
11
|
+
}
|
|
@@ -1,43 +1,18 @@
|
|
|
1
1
|
package expo.modules.core.logging
|
|
2
2
|
|
|
3
|
-
import android.content.Context
|
|
4
3
|
import android.util.Log
|
|
5
4
|
import expo.modules.BuildConfig
|
|
6
5
|
|
|
7
6
|
/**
|
|
8
|
-
*
|
|
7
|
+
* Logging class for Expo, with options to direct logs
|
|
9
8
|
* to different destinations.
|
|
10
9
|
*/
|
|
11
10
|
class Logger(
|
|
12
11
|
/**
|
|
13
|
-
*
|
|
14
|
-
* also used to derive the file name for logging to a file
|
|
12
|
+
* LogHandler instances to which logs should be send
|
|
15
13
|
*/
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* Android context is required if logging to a file
|
|
19
|
-
*/
|
|
20
|
-
context: Context? = null,
|
|
21
|
-
/**
|
|
22
|
-
* One of the predefined LoggerOptions values
|
|
23
|
-
*/
|
|
24
|
-
options: LoggerOptions
|
|
14
|
+
private val logHandlers: List<LogHandler>
|
|
25
15
|
) {
|
|
26
|
-
|
|
27
|
-
private val handlers = mutableListOf<LogHandler>().apply {
|
|
28
|
-
if (options.contains(LoggerOptions.logToOS)) {
|
|
29
|
-
this.add(OSLogHandler(category))
|
|
30
|
-
}
|
|
31
|
-
if (options.contains(LoggerOptions.logToFile)) {
|
|
32
|
-
this.add(
|
|
33
|
-
PersistentFileLogHandler(
|
|
34
|
-
category,
|
|
35
|
-
requireNotNull(context) { "You have to provide the `Context` to create a file logger" }
|
|
36
|
-
)
|
|
37
|
-
)
|
|
38
|
-
}
|
|
39
|
-
}.toList()
|
|
40
|
-
|
|
41
16
|
private val minOSLevel = when (BuildConfig.DEBUG) {
|
|
42
17
|
true -> Log.DEBUG
|
|
43
18
|
else -> Log.INFO
|
|
@@ -92,9 +67,23 @@ class Logger(
|
|
|
92
67
|
log(LogType.Fatal, message, cause)
|
|
93
68
|
}
|
|
94
69
|
|
|
70
|
+
/**
|
|
71
|
+
* Starts a timer that can be used to compute the duration of an operation. Upon calling
|
|
72
|
+
* `stop` on the returned object, a timer entry will be logged.
|
|
73
|
+
*/
|
|
74
|
+
fun startTimer(logFormatter: (duration: Long) -> String): LoggerTimer {
|
|
75
|
+
val start = System.currentTimeMillis()
|
|
76
|
+
return object : LoggerTimer {
|
|
77
|
+
override fun stop() {
|
|
78
|
+
val end = System.currentTimeMillis()
|
|
79
|
+
log(LogType.Timer, logFormatter(end - start))
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
95
84
|
private fun log(type: LogType, message: String, cause: Throwable? = null) {
|
|
96
85
|
if (LogType.toOSLogType(type) >= minOSLevel) {
|
|
97
|
-
|
|
86
|
+
logHandlers.forEach { handler ->
|
|
98
87
|
handler.log(type, message, cause)
|
|
99
88
|
}
|
|
100
89
|
}
|
|
@@ -6,10 +6,8 @@ import android.util.Log
|
|
|
6
6
|
* Simple log handler that forwards all logs to Android native Log class.
|
|
7
7
|
*/
|
|
8
8
|
internal class OSLogHandler(
|
|
9
|
-
category: String
|
|
10
|
-
) : LogHandler(
|
|
11
|
-
category
|
|
12
|
-
) {
|
|
9
|
+
val category: String
|
|
10
|
+
) : LogHandler() {
|
|
13
11
|
override fun log(type: LogType, message: String, cause: Throwable?) {
|
|
14
12
|
if (!isAndroid) {
|
|
15
13
|
println("[${type.type}] $category\t$message")
|
|
@@ -6,9 +6,7 @@ import java.util.Map;
|
|
|
6
6
|
public interface ConstantsInterface {
|
|
7
7
|
Map<String, Object> getConstants();
|
|
8
8
|
String getAppScopeKey();
|
|
9
|
-
String getAppOwnership();
|
|
10
9
|
String getDeviceName();
|
|
11
|
-
boolean getIsDevice();
|
|
12
10
|
int getStatusBarHeight();
|
|
13
11
|
String getSystemVersion();
|
|
14
12
|
List<String> getSystemFonts();
|
|
@@ -9,6 +9,8 @@ import android.view.View
|
|
|
9
9
|
import androidx.annotation.UiThread
|
|
10
10
|
import androidx.appcompat.app.AppCompatActivity
|
|
11
11
|
import com.facebook.react.bridge.ReactApplicationContext
|
|
12
|
+
import com.facebook.react.common.annotations.FrameworkAPI
|
|
13
|
+
import com.facebook.react.turbomodule.core.CallInvokerHolderImpl
|
|
12
14
|
import com.facebook.react.uimanager.UIManagerHelper
|
|
13
15
|
import com.facebook.react.uimanager.UIManagerModule
|
|
14
16
|
import com.facebook.react.uimanager.common.UIManagerType
|
|
@@ -16,7 +18,7 @@ import expo.modules.adapters.react.NativeModulesProxy
|
|
|
16
18
|
import expo.modules.core.errors.ContextDestroyedException
|
|
17
19
|
import expo.modules.core.errors.ModuleNotFoundException
|
|
18
20
|
import expo.modules.core.interfaces.ActivityProvider
|
|
19
|
-
import expo.modules.core.
|
|
21
|
+
import expo.modules.core.utilities.ifNull
|
|
20
22
|
import expo.modules.interfaces.barcodescanner.BarCodeScannerInterface
|
|
21
23
|
import expo.modules.interfaces.camera.CameraViewInterface
|
|
22
24
|
import expo.modules.interfaces.constants.ConstantsInterface
|
|
@@ -39,9 +41,10 @@ import expo.modules.kotlin.events.KModuleEventEmitterWrapper
|
|
|
39
41
|
import expo.modules.kotlin.events.OnActivityResultPayload
|
|
40
42
|
import expo.modules.kotlin.exception.Exceptions
|
|
41
43
|
import expo.modules.kotlin.jni.JNIDeallocator
|
|
42
|
-
import expo.modules.kotlin.jni.
|
|
44
|
+
import expo.modules.kotlin.jni.JSIContext
|
|
43
45
|
import expo.modules.kotlin.modules.Module
|
|
44
46
|
import expo.modules.kotlin.providers.CurrentActivityProvider
|
|
47
|
+
import expo.modules.kotlin.sharedobjects.ClassRegistry
|
|
45
48
|
import expo.modules.kotlin.sharedobjects.SharedObjectRegistry
|
|
46
49
|
import expo.modules.kotlin.tracing.trace
|
|
47
50
|
import kotlinx.coroutines.CoroutineName
|
|
@@ -61,11 +64,11 @@ class AppContext(
|
|
|
61
64
|
val registry = ModuleRegistry(WeakReference(this))
|
|
62
65
|
private val reactLifecycleDelegate = ReactLifecycleDelegate(this)
|
|
63
66
|
|
|
64
|
-
// We postpone creating the `JSIInteropModuleRegistry` to not load so files in unit tests.
|
|
65
|
-
internal lateinit var jsiInterop: JSIInteropModuleRegistry
|
|
66
|
-
|
|
67
67
|
private var hostWasDestroyed = false
|
|
68
68
|
|
|
69
|
+
// We postpone creating the `JSIContext` to not load so files in unit tests.
|
|
70
|
+
internal lateinit var jsiInterop: JSIContext
|
|
71
|
+
|
|
69
72
|
/**
|
|
70
73
|
* The core module that defines the `expo` object in the global scope of the JS runtime.
|
|
71
74
|
*
|
|
@@ -77,7 +80,9 @@ class AppContext(
|
|
|
77
80
|
ModuleHolder(module)
|
|
78
81
|
}
|
|
79
82
|
|
|
80
|
-
internal val sharedObjectRegistry = SharedObjectRegistry()
|
|
83
|
+
internal val sharedObjectRegistry = SharedObjectRegistry(this)
|
|
84
|
+
|
|
85
|
+
internal val classRegistry = ClassRegistry()
|
|
81
86
|
|
|
82
87
|
private val modulesQueueDispatcher = HandlerThread("expo.modules.AsyncFunctionQueue")
|
|
83
88
|
.apply { start() }
|
|
@@ -141,24 +146,42 @@ class AppContext(
|
|
|
141
146
|
* Initializes a JSI part of the module registry.
|
|
142
147
|
* It will be a NOOP if the remote debugging was activated.
|
|
143
148
|
*/
|
|
149
|
+
@OptIn(FrameworkAPI::class)
|
|
144
150
|
fun installJSIInterop() = synchronized(this) {
|
|
151
|
+
if (::jsiInterop.isInitialized) {
|
|
152
|
+
logger.warn("⚠️ JSI interop was already installed")
|
|
153
|
+
return
|
|
154
|
+
}
|
|
155
|
+
|
|
145
156
|
trace("AppContext.installJSIInterop") {
|
|
146
157
|
try {
|
|
147
|
-
jsiInterop =
|
|
158
|
+
jsiInterop = JSIContext()
|
|
148
159
|
val reactContext = reactContextHolder.get() ?: return@trace
|
|
149
|
-
val
|
|
150
|
-
|
|
151
|
-
val
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
160
|
+
val jsContextHolder = reactContext.javaScriptContextHolder?.get() ?: return@trace
|
|
161
|
+
|
|
162
|
+
val jsRuntimePointer = jsContextHolder.takeIf { it != 0L }.ifNull {
|
|
163
|
+
logger.error("❌ Cannot install JSI interop - JS runtime pointer is null")
|
|
164
|
+
return@trace
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
@Suppress("DEPRECATION")
|
|
168
|
+
if (reactContext.isBridgeless) {
|
|
169
|
+
jsiInterop.installJSIForBridgeless(
|
|
170
|
+
this,
|
|
171
|
+
jsRuntimePointer,
|
|
172
|
+
jniDeallocator,
|
|
173
|
+
reactContext.runtimeExecutor!!
|
|
174
|
+
)
|
|
175
|
+
} else {
|
|
176
|
+
jsiInterop.installJSI(
|
|
177
|
+
this,
|
|
178
|
+
jsRuntimePointer,
|
|
179
|
+
jniDeallocator,
|
|
180
|
+
reactContext.catalystInstance.jsCallInvokerHolder as CallInvokerHolderImpl
|
|
181
|
+
)
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
logger.info("✅ JSI interop was installed")
|
|
162
185
|
} catch (e: Throwable) {
|
|
163
186
|
logger.error("❌ Cannot install JSI interop: $e", e)
|
|
164
187
|
}
|
|
@@ -301,9 +324,6 @@ class AppContext(
|
|
|
301
324
|
modulesQueue.cancel(ContextDestroyedException())
|
|
302
325
|
mainQueue.cancel(ContextDestroyedException())
|
|
303
326
|
backgroundCoroutineScope.cancel(ContextDestroyedException())
|
|
304
|
-
if (::jsiInterop.isInitialized) {
|
|
305
|
-
jsiInterop.wasDeallocated()
|
|
306
|
-
}
|
|
307
327
|
jniDeallocator.deallocate()
|
|
308
328
|
logger.info("✅ AppContext was destroyed")
|
|
309
329
|
}
|
|
@@ -337,7 +357,6 @@ class AppContext(
|
|
|
337
357
|
activityResultsManager.onHostDestroy(it)
|
|
338
358
|
}
|
|
339
359
|
registry.post(EventName.ACTIVITY_DESTROYS)
|
|
340
|
-
|
|
341
360
|
// The host (Activity) was destroyed, but it doesn't mean that modules will be destroyed too.
|
|
342
361
|
// So we save that information, and we will re-register activity contracts when the host will be resumed with new Activity.
|
|
343
362
|
hostWasDestroyed = true
|
|
@@ -398,6 +417,7 @@ class AppContext(
|
|
|
398
417
|
override val currentActivity: Activity?
|
|
399
418
|
get() {
|
|
400
419
|
return activityProvider?.currentActivity
|
|
420
|
+
?: (reactContext as? ReactApplicationContext)?.currentActivity
|
|
401
421
|
}
|
|
402
422
|
|
|
403
423
|
// endregion
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
@file:Suppress("NOTHING_TO_INLINE")
|
|
2
|
+
|
|
3
|
+
package expo.modules.kotlin
|
|
4
|
+
|
|
5
|
+
inline operator fun <T> Array<out T>.component6(): T {
|
|
6
|
+
return get(5)
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
inline operator fun <T> Array<out T>.component7(): T {
|
|
10
|
+
return get(6)
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
inline operator fun <T> Array<out T>.component8(): T {
|
|
14
|
+
return get(7)
|
|
15
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
package expo.modules.kotlin
|
|
2
2
|
|
|
3
|
+
import expo.modules.core.logging.LogHandlers
|
|
3
4
|
import expo.modules.core.logging.Logger
|
|
4
|
-
import expo.modules.core.logging.LoggerOptions
|
|
5
5
|
|
|
6
|
-
internal val logger = Logger("ExpoModulesCore"
|
|
6
|
+
internal val logger = Logger(listOf(LogHandlers.createOSLogHandler("ExpoModulesCore")))
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
package expo.modules.kotlin
|
|
2
2
|
|
|
3
3
|
import com.facebook.react.bridge.Dynamic
|
|
4
|
-
import com.facebook.react.bridge.DynamicFromObject
|
|
5
4
|
|
|
6
5
|
inline fun <T> Dynamic.recycle(block: Dynamic.() -> T): T {
|
|
7
6
|
try {
|
|
@@ -10,5 +9,3 @@ inline fun <T> Dynamic.recycle(block: Dynamic.() -> T): T {
|
|
|
10
9
|
this.recycle()
|
|
11
10
|
}
|
|
12
11
|
}
|
|
13
|
-
|
|
14
|
-
val DynamicNull = DynamicFromObject(null)
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
package expo.modules.kotlin
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
4
|
+
import com.facebook.react.bridge.ReactContextBaseJavaModule
|
|
5
|
+
import com.facebook.react.bridge.ReactMethod
|
|
6
|
+
import expo.modules.adapters.react.NativeModulesProxy
|
|
7
|
+
import java.lang.ref.WeakReference
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* The classic bridge module that is responsible for installing the host object to the runtime.
|
|
11
|
+
*/
|
|
12
|
+
class ExpoBridgeModule(
|
|
13
|
+
reactContext: ReactApplicationContext,
|
|
14
|
+
private val nativeModulesProxy: WeakReference<NativeModulesProxy>
|
|
15
|
+
) :
|
|
16
|
+
ReactContextBaseJavaModule(reactContext) {
|
|
17
|
+
override fun getName(): String = "ExpoModulesCore"
|
|
18
|
+
|
|
19
|
+
@ReactMethod(isBlockingSynchronousMethod = true)
|
|
20
|
+
fun installModules(): Boolean {
|
|
21
|
+
// Bridgeless ReactHostImpl may have BridgelessReactContext ready but not ReactInstance.
|
|
22
|
+
// Try to busy wait until ReactInstance is available so we could get the javaScriptContextHolder.
|
|
23
|
+
tryWaitSync(waitMs = 100, retries = 10) {
|
|
24
|
+
reactApplicationContext.hasActiveReactInstance()
|
|
25
|
+
}
|
|
26
|
+
val kotlinInterop = nativeModulesProxy.get()?.kotlinInteropModuleRegistry
|
|
27
|
+
?: throw IllegalStateException("Couldn't find KotlinInteropModuleRegistry")
|
|
28
|
+
|
|
29
|
+
kotlinInterop.installJSIInterop()
|
|
30
|
+
return true
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
private fun tryWaitSync(waitMs: Long, retries: Int, predicate: () -> Boolean) {
|
|
34
|
+
repeat(retries) inner@{
|
|
35
|
+
if (predicate()) {
|
|
36
|
+
return
|
|
37
|
+
}
|
|
38
|
+
Thread.sleep(waitMs)
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -4,11 +4,10 @@ import android.util.Log
|
|
|
4
4
|
|
|
5
5
|
class ExpoModulesHelper {
|
|
6
6
|
companion object {
|
|
7
|
-
@Suppress("unchecked_cast")
|
|
8
7
|
val modulesProvider by lazy {
|
|
9
8
|
try {
|
|
10
9
|
val expoModules = Class.forName("expo.modules.ExpoModulesPackageList")
|
|
11
|
-
expoModules.newInstance() as ModulesProvider
|
|
10
|
+
expoModules.getConstructor().newInstance() as ModulesProvider
|
|
12
11
|
} catch (e: Exception) {
|
|
13
12
|
Log.e("ExpoModulesHelper", "Couldn't get expo modules list.", e)
|
|
14
13
|
null
|
|
@@ -3,10 +3,9 @@ package expo.modules.kotlin
|
|
|
3
3
|
import expo.modules.kotlin.types.JSTypeConverter
|
|
4
4
|
|
|
5
5
|
class KPromiseWrapper(
|
|
6
|
-
|
|
6
|
+
private val bridgePromise: com.facebook.react.bridge.Promise
|
|
7
7
|
) : Promise {
|
|
8
8
|
|
|
9
|
-
@Suppress("UNCHECKED_CAST")
|
|
10
9
|
override fun resolve(value: Any?) {
|
|
11
10
|
bridgePromise.resolve(
|
|
12
11
|
JSTypeConverter.convertToJSValue(value)
|
|
@@ -4,21 +4,16 @@ import com.facebook.react.bridge.ReactApplicationContext
|
|
|
4
4
|
import com.facebook.react.bridge.ReadableArray
|
|
5
5
|
import com.facebook.react.uimanager.ViewManager
|
|
6
6
|
import expo.modules.adapters.react.NativeModulesProxy
|
|
7
|
-
import expo.modules.kotlin.views.ViewManagerType
|
|
8
|
-
import expo.modules.kotlin.defaultmodules.NativeModulesProxyModuleName
|
|
9
7
|
import expo.modules.kotlin.exception.CodedException
|
|
10
8
|
import expo.modules.kotlin.exception.UnexpectedException
|
|
11
9
|
import expo.modules.kotlin.tracing.trace
|
|
12
10
|
import expo.modules.kotlin.views.GroupViewManagerWrapper
|
|
13
11
|
import expo.modules.kotlin.views.SimpleViewManagerWrapper
|
|
12
|
+
import expo.modules.kotlin.views.ViewManagerType
|
|
14
13
|
import expo.modules.kotlin.views.ViewManagerWrapperDelegate
|
|
15
14
|
import expo.modules.kotlin.views.ViewWrapperDelegateHolder
|
|
16
15
|
import java.lang.ref.WeakReference
|
|
17
16
|
|
|
18
|
-
private typealias ModuleName = String
|
|
19
|
-
private typealias ModuleConstants = Map<String, Any?>
|
|
20
|
-
private typealias ModuleMethodInfo = Map<String, Any?>
|
|
21
|
-
|
|
22
17
|
class KotlinInteropModuleRegistry(
|
|
23
18
|
modulesProvider: ModulesProvider,
|
|
24
19
|
legacyModuleRegistry: expo.modules.core.ModuleRegistry,
|
|
@@ -44,33 +39,6 @@ class KotlinInteropModuleRegistry(
|
|
|
44
39
|
}
|
|
45
40
|
}
|
|
46
41
|
|
|
47
|
-
fun exportedModulesConstants(): Map<ModuleName, ModuleConstants> =
|
|
48
|
-
trace("KotlinInteropModuleRegistry.exportedModulesConstants") {
|
|
49
|
-
registry
|
|
50
|
-
// prevent infinite recursion - exclude NativeProxyModule constants
|
|
51
|
-
.filter { holder -> holder.name != NativeModulesProxyModuleName }
|
|
52
|
-
.associate { holder ->
|
|
53
|
-
holder.name to holder.definition.constantsProvider()
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
fun exportMethods(exportKey: (String, List<ModuleMethodInfo>) -> Unit = { _, _ -> }): Map<ModuleName, List<ModuleMethodInfo>> =
|
|
58
|
-
trace("KotlinInteropModuleRegistry.exportMethods") {
|
|
59
|
-
registry.associate { holder ->
|
|
60
|
-
val methodsInfo = holder
|
|
61
|
-
.definition
|
|
62
|
-
.asyncFunctions
|
|
63
|
-
.map { (name, method) ->
|
|
64
|
-
mapOf(
|
|
65
|
-
"name" to name,
|
|
66
|
-
"argumentsCount" to method.argsCount
|
|
67
|
-
)
|
|
68
|
-
}
|
|
69
|
-
exportKey(holder.name, methodsInfo)
|
|
70
|
-
holder.name to methodsInfo
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
|
|
74
42
|
fun exportViewManagers(): List<ViewManager<*, *>> =
|
|
75
43
|
trace("KotlinInteropModuleRegistry.exportViewManagers") {
|
|
76
44
|
registry
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
package expo.modules.kotlin
|
|
2
2
|
|
|
3
|
-
import android.view.View
|
|
4
3
|
import com.facebook.react.bridge.ReadableArray
|
|
5
4
|
import expo.modules.kotlin.events.BasicEventListener
|
|
6
5
|
import expo.modules.kotlin.events.EventListenerWithPayload
|
|
@@ -31,6 +30,9 @@ class ModuleHolder<T : Module>(val module: T) {
|
|
|
31
30
|
JavaScriptModuleObject(jniDeallocator, name).apply {
|
|
32
31
|
initUsingObjectDefinition(appContext, definition.objectDefinition)
|
|
33
32
|
|
|
33
|
+
// Give the module object a name. It's used for compatibility reasons, see `EventEmitter.ts`.
|
|
34
|
+
registerProperty("__expo_module_name__", false, emptyArray(), { name }, false, emptyArray(), null)
|
|
35
|
+
|
|
34
36
|
val viewFunctions = definition.viewManagerDefinition?.asyncFunctions
|
|
35
37
|
if (viewFunctions?.isNotEmpty() == true) {
|
|
36
38
|
trace("Attaching view prototype") {
|
|
@@ -50,12 +52,15 @@ class ModuleHolder<T : Module>(val module: T) {
|
|
|
50
52
|
val clazzModuleObject = JavaScriptModuleObject(jniDeallocator, clazz.name)
|
|
51
53
|
.initUsingObjectDefinition(module.appContext, clazz.objectDefinition)
|
|
52
54
|
appContext.jniDeallocator.addReference(clazzModuleObject)
|
|
53
|
-
|
|
54
55
|
val constructor = clazz.constructor
|
|
56
|
+
|
|
57
|
+
val ownerClass = (constructor.ownerType?.classifier as? KClass<*>)?.java
|
|
58
|
+
|
|
55
59
|
registerClass(
|
|
56
60
|
clazz.name,
|
|
57
61
|
clazzModuleObject,
|
|
58
62
|
constructor.takesOwner,
|
|
63
|
+
ownerClass,
|
|
59
64
|
constructor.getCppRequiredTypes().toTypedArray(),
|
|
60
65
|
constructor.getJNIFunctionBody(clazz.name, appContext)
|
|
61
66
|
)
|
|
@@ -112,8 +117,4 @@ class ModuleHolder<T : Module>(val module: T) {
|
|
|
112
117
|
}
|
|
113
118
|
}
|
|
114
119
|
}
|
|
115
|
-
|
|
116
|
-
fun viewClass(): KClass<out View>? {
|
|
117
|
-
return definition.viewManagerDefinition?.viewType?.kotlin
|
|
118
|
-
}
|
|
119
120
|
}
|
|
@@ -71,6 +71,18 @@ class ModuleRegistry(
|
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
73
|
|
|
74
|
+
/**
|
|
75
|
+
* Post onCreate event to all modules. It has its own method to ensure that it’s called first.
|
|
76
|
+
*/
|
|
77
|
+
fun postOnCreate() {
|
|
78
|
+
forEach {
|
|
79
|
+
it.post(EventName.MODULE_CREATE)
|
|
80
|
+
}
|
|
81
|
+
registerActivityContracts()
|
|
82
|
+
readyForPostingEvents()
|
|
83
|
+
flushTheEventQueue()
|
|
84
|
+
}
|
|
85
|
+
|
|
74
86
|
fun post(eventName: EventName) {
|
|
75
87
|
if (addToQueueIfNeeded(eventName)) {
|
|
76
88
|
return
|
|
@@ -108,18 +120,6 @@ class ModuleRegistry(
|
|
|
108
120
|
logger.info("✅ ModuleRegistry was destroyed")
|
|
109
121
|
}
|
|
110
122
|
|
|
111
|
-
/**
|
|
112
|
-
* Post onCreate event to all modules. It has its own method to ensure that it’s called first.
|
|
113
|
-
*/
|
|
114
|
-
fun postOnCreate() {
|
|
115
|
-
forEach {
|
|
116
|
-
it.post(EventName.MODULE_CREATE)
|
|
117
|
-
}
|
|
118
|
-
registerActivityContracts()
|
|
119
|
-
readyForPostingEvents()
|
|
120
|
-
flushTheEventQueue()
|
|
121
|
-
}
|
|
122
|
-
|
|
123
123
|
internal fun registerActivityContracts() {
|
|
124
124
|
forEach { holder ->
|
|
125
125
|
holder.registerContracts()
|
|
@@ -13,6 +13,16 @@ interface Promise {
|
|
|
13
13
|
resolve(null)
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
+
fun resolve(result: Int) = resolve(result as Any?)
|
|
17
|
+
|
|
18
|
+
fun resolve(result: Boolean) = resolve(result as Any?)
|
|
19
|
+
|
|
20
|
+
fun resolve(result: Double) = resolve(result as Any?)
|
|
21
|
+
|
|
22
|
+
fun resolve(result: Float) = resolve(result as Any?)
|
|
23
|
+
|
|
24
|
+
fun resolve(result: String) = resolve(result as Any?)
|
|
25
|
+
|
|
16
26
|
fun reject(code: String, message: String?, cause: Throwable?)
|
|
17
27
|
|
|
18
28
|
fun reject(exception: CodedException) {
|