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,116 +1,3 @@
|
|
|
1
|
-
// Copyright 2022-present 650 Industries. All rights reserved.
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
Represents a concurrent function that can only be called asynchronously, thus its JavaScript equivalent returns a Promise.
|
|
5
|
-
As opposed to `AsyncFunctionComponent`, it can leverage the new Swift's concurrency model and take the async/await closure.
|
|
6
|
-
*/
|
|
7
|
-
public final class ConcurrentFunctionDefinition<Args, FirstArgType, ReturnType>: AnyFunction {
|
|
8
|
-
typealias ClosureType = (Args) async throws -> ReturnType
|
|
9
|
-
|
|
10
|
-
let body: ClosureType
|
|
11
|
-
|
|
12
|
-
init(
|
|
13
|
-
_ name: String,
|
|
14
|
-
firstArgType: FirstArgType.Type,
|
|
15
|
-
dynamicArgumentTypes: [AnyDynamicType],
|
|
16
|
-
_ body: @escaping ClosureType
|
|
17
|
-
) {
|
|
18
|
-
self.name = name
|
|
19
|
-
self.body = body
|
|
20
|
-
self.dynamicArgumentTypes = dynamicArgumentTypes
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
// MARK: - AnyFunction
|
|
24
|
-
|
|
25
|
-
let name: String
|
|
26
|
-
|
|
27
|
-
let dynamicArgumentTypes: [AnyDynamicType]
|
|
28
|
-
|
|
29
|
-
var argumentsCount: Int {
|
|
30
|
-
return dynamicArgumentTypes.count - (takesOwner ? 1 : 0)
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
var takesOwner: Bool = false
|
|
34
|
-
|
|
35
|
-
func call(by owner: AnyObject?, withArguments args: [Any], appContext: AppContext, callback: @escaping (FunctionCallResult) -> Void) {
|
|
36
|
-
var arguments: [Any]
|
|
37
|
-
|
|
38
|
-
do {
|
|
39
|
-
try validateArgumentsNumber(function: self, received: args.count)
|
|
40
|
-
|
|
41
|
-
arguments = concat(
|
|
42
|
-
arguments: args,
|
|
43
|
-
withOwner: owner,
|
|
44
|
-
withPromise: nil,
|
|
45
|
-
forFunction: self,
|
|
46
|
-
appContext: appContext
|
|
47
|
-
)
|
|
48
|
-
|
|
49
|
-
// All `JavaScriptValue` args must be preliminarly converted on the JS thread, before we jump to the function's queue.
|
|
50
|
-
arguments = try cast(jsValues: arguments, forFunction: self, appContext: appContext)
|
|
51
|
-
} catch let error as Exception {
|
|
52
|
-
callback(.failure(error))
|
|
53
|
-
return
|
|
54
|
-
} catch {
|
|
55
|
-
callback(.failure(UnexpectedException(error)))
|
|
56
|
-
return
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
// Switch from the synchronous context to asynchronous
|
|
60
|
-
Task { [arguments] in
|
|
61
|
-
let result: Result<Any, Exception>
|
|
62
|
-
|
|
63
|
-
do {
|
|
64
|
-
// Convert arguments to the types desired by the function.
|
|
65
|
-
let finalArguments = try cast(arguments: arguments, forFunction: self, appContext: appContext)
|
|
66
|
-
|
|
67
|
-
// TODO: Right now we force cast the tuple in all types of functions, but we should throw another exception here.
|
|
68
|
-
// swiftlint:disable force_cast
|
|
69
|
-
let argumentsTuple = try Conversions.toTuple(finalArguments) as! Args
|
|
70
|
-
let returnValue = try await body(argumentsTuple)
|
|
71
|
-
|
|
72
|
-
result = .success(returnValue)
|
|
73
|
-
} catch let error as Exception {
|
|
74
|
-
result = .failure(FunctionCallException(name).causedBy(error))
|
|
75
|
-
} catch {
|
|
76
|
-
result = .failure(UnexpectedException(error))
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
// Go back to the JS thread to execute the callback
|
|
80
|
-
appContext.executeOnJavaScriptThread {
|
|
81
|
-
callback(result)
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
// MARK: - JavaScriptObjectBuilder
|
|
87
|
-
|
|
88
|
-
func build(appContext: AppContext) throws -> JavaScriptObject {
|
|
89
|
-
return try appContext.runtime.createAsyncFunction(name, argsCount: argumentsCount) {
|
|
90
|
-
[weak appContext, weak self, name] this, args, resolve, reject in
|
|
91
|
-
|
|
92
|
-
guard let appContext else {
|
|
93
|
-
let exception = Exceptions.AppContextLost()
|
|
94
|
-
return reject(exception.code, exception.description, nil)
|
|
95
|
-
}
|
|
96
|
-
guard let self else {
|
|
97
|
-
let exception = NativeFunctionUnavailableException(name)
|
|
98
|
-
return reject(exception.code, exception.description, nil)
|
|
99
|
-
}
|
|
100
|
-
self.call(by: this, withArguments: args, appContext: appContext) { result in
|
|
101
|
-
switch result {
|
|
102
|
-
case .failure(let error):
|
|
103
|
-
reject(error.code, error.description, nil)
|
|
104
|
-
case .success(let value):
|
|
105
|
-
// Convert some results to primitive types (e.g. records) or JS values (e.g. shared objects)
|
|
106
|
-
let convertedResult = Conversions.convertFunctionResult(value, appContext: appContext, dynamicType: ~ReturnType.self)
|
|
107
|
-
resolve(convertedResult)
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
|
|
114
1
|
/**
|
|
115
2
|
Concurrently-executing asynchronous function without arguments.
|
|
116
3
|
*/
|
package/ios/{Modules/ModuleDefinitionComponents.swift → Api/Factories/EventListenersFactories.swift}
RENAMED
|
@@ -1,14 +1,3 @@
|
|
|
1
|
-
// MARK: - Module name
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
Sets the name of the module that is exported to the JavaScript world.
|
|
5
|
-
*/
|
|
6
|
-
public func Name(_ name: String) -> AnyDefinition {
|
|
7
|
-
return ModuleNameDefinition(name: name)
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
// MARK: - Module's lifecycle
|
|
11
|
-
|
|
12
1
|
/**
|
|
13
2
|
Creates module's lifecycle listener that is called right after module initialization.
|
|
14
3
|
*/
|
|
@@ -50,12 +39,3 @@ public func OnAppBecomesActive(@_implicitSelfCapture _ closure: @escaping () ->
|
|
|
50
39
|
public func OnAppEntersBackground(@_implicitSelfCapture _ closure: @escaping () -> Void) -> AnyDefinition {
|
|
51
40
|
return EventListener(.appEntersBackground, closure)
|
|
52
41
|
}
|
|
53
|
-
|
|
54
|
-
// MARK: - View Manager
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
Creates the view manager definition that scopes other view-related definitions.
|
|
58
|
-
*/
|
|
59
|
-
public func ViewManager(@ViewManagerDefinitionBuilder _ closure: @escaping () -> ViewManagerDefinition) -> AnyDefinition {
|
|
60
|
-
return closure()
|
|
61
|
-
}
|
package/ios/{Objects/ObjectDefinitionComponents.swift → Api/Factories/ObjectFactories.swift}
RENAMED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/// This file implements
|
|
1
|
+
/// This file implements factories for definitions that are allowed in any object-based definition — `ObjectDefinition`.
|
|
2
2
|
/// So far only constants and functions belong to plain object.
|
|
3
3
|
|
|
4
4
|
// MARK: - Object
|
|
@@ -42,13 +42,13 @@ public func Events(_ names: [String]) -> EventsDefinition {
|
|
|
42
42
|
/**
|
|
43
43
|
Function that is invoked when the first event listener is added.
|
|
44
44
|
*/
|
|
45
|
-
public func OnStartObserving(@_implicitSelfCapture _
|
|
46
|
-
return
|
|
45
|
+
public func OnStartObserving(_ event: String? = nil, @_implicitSelfCapture _ closure: @escaping () -> Void) -> EventObservingDefinition {
|
|
46
|
+
return EventObservingDefinition(type: .startObserving, event: event, closure)
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
/**
|
|
50
50
|
Function that is invoked when all event listeners are removed.
|
|
51
51
|
*/
|
|
52
|
-
public func OnStopObserving(@_implicitSelfCapture _
|
|
53
|
-
return
|
|
52
|
+
public func OnStopObserving(_ event: String? = nil, @_implicitSelfCapture _ closure: @escaping () -> Void) -> EventObservingDefinition {
|
|
53
|
+
return EventObservingDefinition(type: .stopObserving, event: event, closure)
|
|
54
54
|
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
Creates the property with given name. The definition is basically no-op if you don't call `.get(_:)` or `.set(_:)` on it.
|
|
3
|
+
*/
|
|
4
|
+
public func Property(_ name: String) -> PropertyDefinition<Void> {
|
|
5
|
+
return PropertyDefinition(name: name)
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
Creates the read-only property whose getter doesn't take the owner as an argument.
|
|
10
|
+
*/
|
|
11
|
+
public func Property<Value: AnyArgument>(_ name: String, @_implicitSelfCapture get: @escaping () -> Value) -> PropertyDefinition<Void> {
|
|
12
|
+
return PropertyDefinition(name: name, getter: get)
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
Creates the read-only property whose getter takes the owner as an argument.
|
|
17
|
+
*/
|
|
18
|
+
public func Property<Value: AnyArgument, OwnerType>(
|
|
19
|
+
_ name: String,
|
|
20
|
+
@_implicitSelfCapture get: @escaping (_ this: OwnerType) -> Value
|
|
21
|
+
) -> PropertyDefinition<OwnerType> {
|
|
22
|
+
return PropertyDefinition<OwnerType>(name: name, getter: get)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
Creates the property that references to an immutable property of the owner object using the key path.
|
|
27
|
+
*/
|
|
28
|
+
public func Property<Value: AnyArgument, OwnerType>(
|
|
29
|
+
_ name: String,
|
|
30
|
+
_ keyPath: KeyPath<OwnerType, Value>
|
|
31
|
+
) -> PropertyDefinition<OwnerType> {
|
|
32
|
+
return PropertyDefinition<OwnerType>(name: name) { owner in
|
|
33
|
+
return owner[keyPath: keyPath]
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
Creates the property that references to a mutable property of the owner object using the key path.
|
|
39
|
+
*/
|
|
40
|
+
public func Property<Value: AnyArgument, OwnerType>(
|
|
41
|
+
_ name: String,
|
|
42
|
+
_ keyPath: ReferenceWritableKeyPath<OwnerType, Value>
|
|
43
|
+
) -> PropertyDefinition<OwnerType> {
|
|
44
|
+
return PropertyDefinition<OwnerType>(name: name) { owner in
|
|
45
|
+
return owner[keyPath: keyPath]
|
|
46
|
+
}
|
|
47
|
+
.set { owner, newValue in
|
|
48
|
+
owner[keyPath: keyPath] = newValue
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
/**
|
|
2
|
+
Synchronous function without arguments.
|
|
3
|
+
*/
|
|
4
|
+
public func Function<R>(
|
|
5
|
+
_ name: String,
|
|
6
|
+
@_implicitSelfCapture _ closure: @escaping () throws -> R
|
|
7
|
+
) -> SyncFunctionDefinition<(), Void, R> {
|
|
8
|
+
return SyncFunctionDefinition(
|
|
9
|
+
name,
|
|
10
|
+
firstArgType: Void.self,
|
|
11
|
+
dynamicArgumentTypes: [],
|
|
12
|
+
closure
|
|
13
|
+
)
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
Synchronous function with one argument.
|
|
18
|
+
*/
|
|
19
|
+
public func Function<R, A0: AnyArgument>(
|
|
20
|
+
_ name: String,
|
|
21
|
+
@_implicitSelfCapture _ closure: @escaping (A0) throws -> R
|
|
22
|
+
) -> SyncFunctionDefinition<(A0), A0, R> {
|
|
23
|
+
return SyncFunctionDefinition(
|
|
24
|
+
name,
|
|
25
|
+
firstArgType: A0.self,
|
|
26
|
+
dynamicArgumentTypes: [~A0.self],
|
|
27
|
+
closure
|
|
28
|
+
)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
Synchronous function with two arguments.
|
|
33
|
+
*/
|
|
34
|
+
public func Function<R, A0: AnyArgument, A1: AnyArgument>(
|
|
35
|
+
_ name: String,
|
|
36
|
+
@_implicitSelfCapture _ closure: @escaping (A0, A1) throws -> R
|
|
37
|
+
) -> SyncFunctionDefinition<(A0, A1), A0, R> {
|
|
38
|
+
return SyncFunctionDefinition(
|
|
39
|
+
name,
|
|
40
|
+
firstArgType: A0.self,
|
|
41
|
+
dynamicArgumentTypes: [~A0.self, ~A1.self],
|
|
42
|
+
closure
|
|
43
|
+
)
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/**
|
|
47
|
+
Synchronous function with three arguments.
|
|
48
|
+
*/
|
|
49
|
+
public func Function<R, A0: AnyArgument, A1: AnyArgument, A2: AnyArgument>(
|
|
50
|
+
_ name: String,
|
|
51
|
+
@_implicitSelfCapture _ closure: @escaping (A0, A1, A2) throws -> R
|
|
52
|
+
) -> SyncFunctionDefinition<(A0, A1, A2), A0, R> {
|
|
53
|
+
return SyncFunctionDefinition(
|
|
54
|
+
name,
|
|
55
|
+
firstArgType: A0.self,
|
|
56
|
+
dynamicArgumentTypes: [
|
|
57
|
+
~A0.self,
|
|
58
|
+
~A1.self,
|
|
59
|
+
~A2.self
|
|
60
|
+
],
|
|
61
|
+
closure
|
|
62
|
+
)
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
Synchronous function with four arguments.
|
|
67
|
+
*/
|
|
68
|
+
public func Function<R, A0: AnyArgument, A1: AnyArgument, A2: AnyArgument, A3: AnyArgument>(
|
|
69
|
+
_ name: String,
|
|
70
|
+
@_implicitSelfCapture _ closure: @escaping (A0, A1, A2, A3) throws -> R
|
|
71
|
+
) -> SyncFunctionDefinition<(A0, A1, A2, A3), A0, R> {
|
|
72
|
+
return SyncFunctionDefinition(
|
|
73
|
+
name,
|
|
74
|
+
firstArgType: A0.self,
|
|
75
|
+
dynamicArgumentTypes: [
|
|
76
|
+
~A0.self,
|
|
77
|
+
~A1.self,
|
|
78
|
+
~A2.self,
|
|
79
|
+
~A3.self
|
|
80
|
+
],
|
|
81
|
+
closure
|
|
82
|
+
)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
Synchronous function with five arguments.
|
|
87
|
+
*/
|
|
88
|
+
public func Function<R, A0: AnyArgument, A1: AnyArgument, A2: AnyArgument, A3: AnyArgument, A4: AnyArgument>(
|
|
89
|
+
_ name: String,
|
|
90
|
+
@_implicitSelfCapture _ closure: @escaping (A0, A1, A2, A3, A4) throws -> R
|
|
91
|
+
) -> SyncFunctionDefinition<(A0, A1, A2, A3, A4), A0, R> {
|
|
92
|
+
return SyncFunctionDefinition(
|
|
93
|
+
name,
|
|
94
|
+
firstArgType: A0.self,
|
|
95
|
+
dynamicArgumentTypes: [
|
|
96
|
+
~A0.self,
|
|
97
|
+
~A1.self,
|
|
98
|
+
~A2.self,
|
|
99
|
+
~A3.self,
|
|
100
|
+
~A4.self
|
|
101
|
+
],
|
|
102
|
+
closure
|
|
103
|
+
)
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
Synchronous function with six arguments.
|
|
108
|
+
*/
|
|
109
|
+
public func Function<R, A0: AnyArgument, A1: AnyArgument, A2: AnyArgument, A3: AnyArgument, A4: AnyArgument, A5: AnyArgument>(
|
|
110
|
+
_ name: String,
|
|
111
|
+
@_implicitSelfCapture _ closure: @escaping (A0, A1, A2, A3, A4, A5) throws -> R
|
|
112
|
+
) -> SyncFunctionDefinition<(A0, A1, A2, A3, A4, A5), A0, R> {
|
|
113
|
+
return SyncFunctionDefinition(
|
|
114
|
+
name,
|
|
115
|
+
firstArgType: A0.self,
|
|
116
|
+
dynamicArgumentTypes: [
|
|
117
|
+
~A0.self,
|
|
118
|
+
~A1.self,
|
|
119
|
+
~A2.self,
|
|
120
|
+
~A3.self,
|
|
121
|
+
~A4.self,
|
|
122
|
+
~A5.self
|
|
123
|
+
],
|
|
124
|
+
closure
|
|
125
|
+
)
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
Synchronous function with seven arguments.
|
|
130
|
+
*/
|
|
131
|
+
public func Function<R, A0: AnyArgument, A1: AnyArgument, A2: AnyArgument, A3: AnyArgument, A4: AnyArgument, A5: AnyArgument, A6: AnyArgument>(
|
|
132
|
+
_ name: String,
|
|
133
|
+
@_implicitSelfCapture _ closure: @escaping (A0, A1, A2, A3, A4, A5, A6) throws -> R
|
|
134
|
+
) -> SyncFunctionDefinition<(A0, A1, A2, A3, A4, A5, A6), A0, R> {
|
|
135
|
+
return SyncFunctionDefinition(
|
|
136
|
+
name,
|
|
137
|
+
firstArgType: A0.self,
|
|
138
|
+
dynamicArgumentTypes: [
|
|
139
|
+
~A0.self,
|
|
140
|
+
~A1.self,
|
|
141
|
+
~A2.self,
|
|
142
|
+
~A3.self,
|
|
143
|
+
~A4.self,
|
|
144
|
+
~A5.self,
|
|
145
|
+
~A6.self
|
|
146
|
+
],
|
|
147
|
+
closure
|
|
148
|
+
)
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
Synchronous function with eight arguments.
|
|
153
|
+
*/
|
|
154
|
+
public func Function<R, A0: AnyArgument, A1: AnyArgument, A2: AnyArgument, A3: AnyArgument, A4: AnyArgument, A5: AnyArgument, A6: AnyArgument, A7: AnyArgument>(
|
|
155
|
+
_ name: String,
|
|
156
|
+
@_implicitSelfCapture _ closure: @escaping (A0, A1, A2, A3, A4, A5, A6, A7) throws -> R
|
|
157
|
+
) -> SyncFunctionDefinition<(A0, A1, A2, A3, A4, A5, A6, A7), A0, R> {
|
|
158
|
+
return SyncFunctionDefinition(
|
|
159
|
+
name,
|
|
160
|
+
firstArgType: A0.self,
|
|
161
|
+
dynamicArgumentTypes: [
|
|
162
|
+
~A0.self,
|
|
163
|
+
~A1.self,
|
|
164
|
+
~A2.self,
|
|
165
|
+
~A3.self,
|
|
166
|
+
~A4.self,
|
|
167
|
+
~A5.self,
|
|
168
|
+
~A6.self,
|
|
169
|
+
~A7.self
|
|
170
|
+
],
|
|
171
|
+
closure
|
|
172
|
+
)
|
|
173
|
+
}
|
package/ios/{Views/ViewManagerDefinitionComponents.swift → Api/Factories/ViewFactories.swift}
RENAMED
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
/// Here we implement the
|
|
2
|
-
|
|
3
|
-
// MARK: View factory
|
|
1
|
+
/// Here we implement factories for the definitions exclusive for native views.
|
|
4
2
|
|
|
5
3
|
/**
|
|
6
|
-
|
|
4
|
+
Creates a view definition describing the native view exported to React.
|
|
7
5
|
*/
|
|
8
|
-
public func View<ViewType: UIView>(
|
|
9
|
-
|
|
6
|
+
public func View<ViewType: UIView>(
|
|
7
|
+
_ viewType: ViewType.Type,
|
|
8
|
+
@ViewDefinitionBuilder<ViewType> _ elements: @escaping () -> [AnyViewDefinitionElement]
|
|
9
|
+
) -> ViewDefinition<ViewType> {
|
|
10
|
+
return ViewDefinition(viewType, elements: elements())
|
|
10
11
|
}
|
|
11
12
|
|
|
12
13
|
// MARK: Props
|
|
@@ -1,9 +1,6 @@
|
|
|
1
1
|
// Copyright 2018-present 650 Industries. All rights reserved.
|
|
2
2
|
|
|
3
3
|
#import <ExpoModulesCore/Platform.h>
|
|
4
|
-
|
|
5
|
-
#if __cplusplus
|
|
6
|
-
|
|
7
4
|
#import <ExpoModulesCore/EXReactDelegateWrapper.h>
|
|
8
5
|
|
|
9
6
|
#if __has_include(<React-RCTAppDelegate/RCTAppDelegate.h>)
|
|
@@ -15,28 +12,10 @@
|
|
|
15
12
|
|
|
16
13
|
NS_ASSUME_NONNULL_BEGIN
|
|
17
14
|
|
|
18
|
-
/**
|
|
19
|
-
Provides backwards compatibility for existing projects with `AppDelegate`
|
|
20
|
-
written in Objective-C and that forwards all messages to the new `ExpoAppDelegate`.
|
|
21
|
-
If your `AppDelegate` is in Swift, it should inherit from `ExpoAppDelegate` class instead.
|
|
22
|
-
*/
|
|
23
|
-
#if __has_include(<React-RCTAppDelegate/RCTAppDelegate.h>) || __has_include(<React_RCTAppDelegate/RCTAppDelegate.h>)
|
|
24
15
|
@interface EXAppDelegateWrapper : RCTAppDelegate
|
|
25
|
-
#else
|
|
26
|
-
@interface EXAppDelegateWrapper : UIResponder <UIApplicationDelegate>
|
|
27
|
-
#endif
|
|
28
16
|
|
|
29
17
|
@property (nonatomic, strong, readonly) EXReactDelegateWrapper *reactDelegate;
|
|
30
18
|
|
|
31
19
|
@end
|
|
32
20
|
|
|
33
21
|
NS_ASSUME_NONNULL_END
|
|
34
|
-
|
|
35
|
-
#else
|
|
36
|
-
|
|
37
|
-
// Workaround the main.m build error when running with new architecture mode
|
|
38
|
-
// Context: https://github.com/facebook/react-native/pull/35661
|
|
39
|
-
@interface EXAppDelegateWrapper : UIResponder
|
|
40
|
-
@end
|
|
41
|
-
|
|
42
|
-
#endif
|
|
@@ -2,8 +2,21 @@
|
|
|
2
2
|
|
|
3
3
|
#import <ExpoModulesCore/EXAppDelegateWrapper.h>
|
|
4
4
|
#import <ExpoModulesCore/EXReactDelegateWrapper+Private.h>
|
|
5
|
+
#import <ExpoModulesCore/EXReactRootViewFactory.h>
|
|
5
6
|
#import <ExpoModulesCore/Swift.h>
|
|
6
7
|
|
|
8
|
+
#if __has_include(<React-RCTAppDelegate/RCTRootViewFactory.h>)
|
|
9
|
+
#import <React-RCTAppDelegate/RCTRootViewFactory.h>
|
|
10
|
+
#elif __has_include(<React_RCTAppDelegate/RCTRootViewFactory.h>)
|
|
11
|
+
// for importing the header from framework, the dash will be transformed to underscore
|
|
12
|
+
#import <React_RCTAppDelegate/RCTRootViewFactory.h>
|
|
13
|
+
#endif
|
|
14
|
+
|
|
15
|
+
#import <ReactCommon/RCTTurboModuleManager.h>
|
|
16
|
+
|
|
17
|
+
@interface RCTAppDelegate () <RCTTurboModuleManagerDelegate>
|
|
18
|
+
@end
|
|
19
|
+
|
|
7
20
|
@interface EXAppDelegateWrapper()
|
|
8
21
|
|
|
9
22
|
@property (nonatomic, strong) EXReactDelegateWrapper *reactDelegate;
|
|
@@ -41,48 +54,43 @@
|
|
|
41
54
|
return _expoAppDelegate;
|
|
42
55
|
}
|
|
43
56
|
|
|
44
|
-
#if __has_include(<React-RCTAppDelegate/RCTAppDelegate.h>) || __has_include(<React_RCTAppDelegate/RCTAppDelegate.h>)
|
|
45
|
-
|
|
46
57
|
#if !TARGET_OS_OSX
|
|
47
58
|
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
|
|
48
59
|
{
|
|
49
60
|
[super application:application didFinishLaunchingWithOptions:launchOptions];
|
|
61
|
+
#pragma clang diagnostic push
|
|
62
|
+
#pragma clang diagnostic ignored "-Wunused-result"
|
|
50
63
|
[_expoAppDelegate application:application didFinishLaunchingWithOptions:launchOptions];
|
|
64
|
+
#pragma clang diagnostic pop
|
|
51
65
|
return YES;
|
|
52
66
|
}
|
|
53
67
|
#endif // !TARGET_OS_OSX
|
|
54
68
|
|
|
55
|
-
- (
|
|
56
|
-
{
|
|
57
|
-
return [self.reactDelegate createBridgeWithDelegate:delegate launchOptions:launchOptions];
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
- (UIView *)createRootViewWithBridge:(RCTBridge *)bridge
|
|
61
|
-
moduleName:(NSString *)moduleName
|
|
62
|
-
initProps:(NSDictionary *)initProps
|
|
69
|
+
- (UIViewController *)createRootViewController
|
|
63
70
|
{
|
|
64
|
-
|
|
65
|
-
#if RN_FABRIC_ENABLED
|
|
66
|
-
enableFabric = self.fabricEnabled;
|
|
67
|
-
#endif
|
|
68
|
-
|
|
69
|
-
UIView *rootView = [self.reactDelegate createRootViewWithBridge:bridge
|
|
70
|
-
moduleName:moduleName
|
|
71
|
-
initialProperties:initProps
|
|
72
|
-
fabricEnabled:enableFabric];
|
|
73
|
-
#if TARGET_OS_IOS
|
|
74
|
-
rootView.backgroundColor = UIColor.systemBackgroundColor;
|
|
75
|
-
#elif TARGET_OS_OSX
|
|
76
|
-
rootView.wantsLayer = YES;
|
|
77
|
-
rootView.layer.backgroundColor = NSColor.windowBackgroundColor.CGColor;
|
|
78
|
-
#endif
|
|
79
|
-
return rootView;
|
|
71
|
+
return [self.reactDelegate createRootViewController];
|
|
80
72
|
}
|
|
81
73
|
|
|
82
|
-
- (
|
|
74
|
+
- (RCTRootViewFactory *)createRCTRootViewFactory
|
|
83
75
|
{
|
|
84
|
-
|
|
76
|
+
RCTRootViewFactoryConfiguration *configuration =
|
|
77
|
+
[[RCTRootViewFactoryConfiguration alloc] initWithBundleURL:self.bundleURL
|
|
78
|
+
newArchEnabled:self.fabricEnabled
|
|
79
|
+
turboModuleEnabled:self.turboModuleEnabled
|
|
80
|
+
bridgelessEnabled:self.bridgelessEnabled];
|
|
81
|
+
|
|
82
|
+
__weak __typeof(self) weakSelf = self;
|
|
83
|
+
configuration.createRootViewWithBridge = ^UIView *(RCTBridge *bridge, NSString *moduleName, NSDictionary *initProps)
|
|
84
|
+
{
|
|
85
|
+
return [weakSelf createRootViewWithBridge:bridge moduleName:moduleName initProps:initProps];
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
configuration.createBridgeWithDelegate = ^RCTBridge *(id<RCTBridgeDelegate> delegate, NSDictionary *launchOptions)
|
|
89
|
+
{
|
|
90
|
+
return [weakSelf createBridgeWithDelegate:delegate launchOptions:launchOptions];
|
|
91
|
+
};
|
|
92
|
+
|
|
93
|
+
return [[EXReactRootViewFactory alloc] initWithReactDelegate:self.reactDelegate configuration:configuration turboModuleManagerDelegate:self];
|
|
85
94
|
}
|
|
86
|
-
#endif // __has_include(<React-RCTAppDelegate/RCTAppDelegate.h>)
|
|
87
95
|
|
|
88
96
|
@end
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import React
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
The app context is an interface to a single Expo app.
|
|
3
5
|
*/
|
|
@@ -31,9 +33,11 @@ public final class AppContext: NSObject {
|
|
|
31
33
|
/**
|
|
32
34
|
The legacy module registry with modules written in the old-fashioned way.
|
|
33
35
|
*/
|
|
36
|
+
@objc
|
|
34
37
|
public weak var legacyModuleRegistry: EXModuleRegistry?
|
|
35
38
|
|
|
36
|
-
|
|
39
|
+
@objc
|
|
40
|
+
public weak var legacyModulesProxy: LegacyNativeModulesProxy?
|
|
37
41
|
|
|
38
42
|
/**
|
|
39
43
|
React bridge of the context's app. Can be `nil` when the bridge
|
|
@@ -41,7 +45,7 @@ public final class AppContext: NSObject {
|
|
|
41
45
|
or when the app context is "bridgeless" (for example in native unit tests).
|
|
42
46
|
*/
|
|
43
47
|
@objc
|
|
44
|
-
public
|
|
48
|
+
public weak var reactBridge: RCTBridge?
|
|
45
49
|
|
|
46
50
|
/**
|
|
47
51
|
Underlying JSI runtime of the running app.
|
|
@@ -99,6 +103,12 @@ public final class AppContext: NSObject {
|
|
|
99
103
|
self.legacyModuleRegistry = legacyModuleRegistry as? EXModuleRegistry
|
|
100
104
|
}
|
|
101
105
|
|
|
106
|
+
@objc
|
|
107
|
+
public convenience override init() {
|
|
108
|
+
self.init(config: .default)
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
@objc
|
|
102
112
|
@discardableResult
|
|
103
113
|
public func useModulesProvider(_ providerName: String) -> Self {
|
|
104
114
|
return useModulesProvider(Self.modulesProvider(withName: providerName))
|
|
@@ -134,6 +144,8 @@ public final class AppContext: NSObject {
|
|
|
134
144
|
|
|
135
145
|
// MARK: - Classes
|
|
136
146
|
|
|
147
|
+
internal lazy var sharedObjectRegistry = SharedObjectRegistry(appContext: self)
|
|
148
|
+
|
|
137
149
|
/**
|
|
138
150
|
A registry containing references to JavaScript classes.
|
|
139
151
|
- ToDo: Make one registry per module, not the entire app context.
|
|
@@ -201,10 +213,10 @@ public final class AppContext: NSObject {
|
|
|
201
213
|
}
|
|
202
214
|
|
|
203
215
|
/**
|
|
204
|
-
Provides
|
|
216
|
+
Provides an event emitter that is compatible with the legacy interface.
|
|
205
217
|
*/
|
|
206
218
|
public var eventEmitter: EXEventEmitterService? {
|
|
207
|
-
return
|
|
219
|
+
return LegacyEventEmitterCompat(appContext: self)
|
|
208
220
|
}
|
|
209
221
|
|
|
210
222
|
/**
|
|
@@ -264,7 +276,7 @@ public final class AppContext: NSObject {
|
|
|
264
276
|
@objc
|
|
265
277
|
public func getViewManagers() -> [ViewModuleWrapper] {
|
|
266
278
|
return moduleRegistry.compactMap { holder in
|
|
267
|
-
if holder.definition.
|
|
279
|
+
if holder.definition.view != nil {
|
|
268
280
|
return ViewModuleWrapper(holder)
|
|
269
281
|
} else {
|
|
270
282
|
return nil
|
|
@@ -372,9 +384,9 @@ public final class AppContext: NSObject {
|
|
|
372
384
|
|
|
373
385
|
private func viewManagersMetadata() -> [String: Any] {
|
|
374
386
|
return moduleRegistry.reduce(into: [String: Any]()) { acc, holder in
|
|
375
|
-
if let
|
|
387
|
+
if let viewDefinition = holder.definition.view {
|
|
376
388
|
acc[holder.name] = [
|
|
377
|
-
"propsNames":
|
|
389
|
+
"propsNames": viewDefinition.props.map { $0.name }
|
|
378
390
|
]
|
|
379
391
|
}
|
|
380
392
|
}
|
|
@@ -384,11 +396,24 @@ public final class AppContext: NSObject {
|
|
|
384
396
|
|
|
385
397
|
internal func prepareRuntime() throws {
|
|
386
398
|
let runtime = try runtime
|
|
387
|
-
let coreObject =
|
|
399
|
+
let coreObject = runtime.createObject()
|
|
400
|
+
|
|
401
|
+
try coreModuleHolder.definition.decorate(object: coreObject, appContext: self)
|
|
388
402
|
|
|
389
403
|
// Initialize `global.expo`.
|
|
390
404
|
try runtime.initializeCoreObject(coreObject)
|
|
391
405
|
|
|
406
|
+
// Install `global.expo.EventEmitter`.
|
|
407
|
+
EXJavaScriptRuntimeManager.installEventEmitterClass(runtime)
|
|
408
|
+
|
|
409
|
+
// Install `global.expo.SharedObject`.
|
|
410
|
+
EXJavaScriptRuntimeManager.installSharedObjectClass(runtime) { [weak sharedObjectRegistry] objectId in
|
|
411
|
+
sharedObjectRegistry?.delete(objectId)
|
|
412
|
+
}
|
|
413
|
+
|
|
414
|
+
// Install `global.expo.NativeModule`.
|
|
415
|
+
EXJavaScriptRuntimeManager.installNativeModuleClass(runtime)
|
|
416
|
+
|
|
392
417
|
// Install the modules host object as the `global.expo.modules`.
|
|
393
418
|
EXJavaScriptRuntimeManager.installExpoModulesHostObject(self)
|
|
394
419
|
}
|
|
@@ -397,9 +422,7 @@ public final class AppContext: NSObject {
|
|
|
397
422
|
Unsets runtime objects that we hold for each module.
|
|
398
423
|
*/
|
|
399
424
|
private func releaseRuntimeObjects() {
|
|
400
|
-
|
|
401
|
-
// Making the registry non-global (similarly to the class registry) would fix it.
|
|
402
|
-
SharedObjectRegistry.clear()
|
|
425
|
+
sharedObjectRegistry.clear()
|
|
403
426
|
classRegistry.clear()
|
|
404
427
|
|
|
405
428
|
for module in moduleRegistry {
|