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,6 +1,6 @@
|
|
|
1
1
|
// Copyright 2022-present 650 Industries. All rights reserved.
|
|
2
2
|
|
|
3
|
-
protocol
|
|
3
|
+
protocol AnyPropertyDefinition {
|
|
4
4
|
/**
|
|
5
5
|
Name of the property.
|
|
6
6
|
*/
|
|
@@ -12,7 +12,7 @@ protocol AnyPropertyComponent {
|
|
|
12
12
|
func buildDescriptor(appContext: AppContext) throws -> JavaScriptObject
|
|
13
13
|
}
|
|
14
14
|
|
|
15
|
-
public final class
|
|
15
|
+
public final class PropertyDefinition<OwnerType>: AnyDefinition, AnyPropertyDefinition {
|
|
16
16
|
/**
|
|
17
17
|
Name of the property.
|
|
18
18
|
*/
|
|
@@ -21,22 +21,22 @@ public final class PropertyComponent<OwnerType>: AnyDefinition, AnyPropertyCompo
|
|
|
21
21
|
/**
|
|
22
22
|
Synchronous function that is called when the property is being accessed.
|
|
23
23
|
*/
|
|
24
|
-
var getter:
|
|
24
|
+
var getter: AnySyncFunctionDefinition?
|
|
25
25
|
|
|
26
26
|
/**
|
|
27
27
|
Synchronous function that is called when the property is being set.
|
|
28
28
|
*/
|
|
29
|
-
var setter:
|
|
29
|
+
var setter: AnySyncFunctionDefinition?
|
|
30
30
|
|
|
31
31
|
/**
|
|
32
|
-
Initializes an unowned
|
|
32
|
+
Initializes an unowned PropertyDefinition without getter and setter functions.
|
|
33
33
|
*/
|
|
34
34
|
init(name: String) {
|
|
35
35
|
self.name = name
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
/**
|
|
39
|
-
Initializes an unowned
|
|
39
|
+
Initializes an unowned PropertyDefinition with a getter without arguments.
|
|
40
40
|
*/
|
|
41
41
|
init<ReturnType>(name: String, getter: @escaping () -> ReturnType) {
|
|
42
42
|
self.name = name
|
|
@@ -46,7 +46,7 @@ public final class PropertyComponent<OwnerType>: AnyDefinition, AnyPropertyCompo
|
|
|
46
46
|
}
|
|
47
47
|
|
|
48
48
|
/**
|
|
49
|
-
Initializes an owned
|
|
49
|
+
Initializes an owned PropertyDefinition with a getter that takes the owner as its first argument.
|
|
50
50
|
*/
|
|
51
51
|
init<ReturnType>(name: String, getter: @escaping (_ this: OwnerType) -> ReturnType) {
|
|
52
52
|
self.name = name
|
|
@@ -62,7 +62,7 @@ public final class PropertyComponent<OwnerType>: AnyDefinition, AnyPropertyCompo
|
|
|
62
62
|
*/
|
|
63
63
|
@discardableResult
|
|
64
64
|
public func get<ReturnType>(_ getter: @escaping () -> ReturnType) -> Self {
|
|
65
|
-
self.getter =
|
|
65
|
+
self.getter = SyncFunctionDefinition(
|
|
66
66
|
"get",
|
|
67
67
|
firstArgType: Void.self,
|
|
68
68
|
dynamicArgumentTypes: [],
|
|
@@ -77,7 +77,7 @@ public final class PropertyComponent<OwnerType>: AnyDefinition, AnyPropertyCompo
|
|
|
77
77
|
*/
|
|
78
78
|
@discardableResult
|
|
79
79
|
public func get<ReturnType>(_ getter: @escaping (_ this: OwnerType) -> ReturnType) -> Self {
|
|
80
|
-
self.getter =
|
|
80
|
+
self.getter = SyncFunctionDefinition(
|
|
81
81
|
"get",
|
|
82
82
|
firstArgType: OwnerType.self,
|
|
83
83
|
dynamicArgumentTypes: [~OwnerType.self],
|
|
@@ -92,7 +92,7 @@ public final class PropertyComponent<OwnerType>: AnyDefinition, AnyPropertyCompo
|
|
|
92
92
|
*/
|
|
93
93
|
@discardableResult
|
|
94
94
|
public func set<ValueType>(_ setter: @escaping (_ newValue: ValueType) -> Void) -> Self {
|
|
95
|
-
self.setter =
|
|
95
|
+
self.setter = SyncFunctionDefinition(
|
|
96
96
|
"set",
|
|
97
97
|
firstArgType: ValueType.self,
|
|
98
98
|
dynamicArgumentTypes: [~ValueType.self],
|
|
@@ -107,7 +107,7 @@ public final class PropertyComponent<OwnerType>: AnyDefinition, AnyPropertyCompo
|
|
|
107
107
|
*/
|
|
108
108
|
@discardableResult
|
|
109
109
|
public func set<ValueType>(_ setter: @escaping (_ this: OwnerType, _ newValue: ValueType) -> Void) -> Self {
|
|
110
|
-
self.setter =
|
|
110
|
+
self.setter = SyncFunctionDefinition(
|
|
111
111
|
"set",
|
|
112
112
|
firstArgType: OwnerType.self,
|
|
113
113
|
dynamicArgumentTypes: [~OwnerType.self, ~ValueType.self],
|
|
@@ -191,56 +191,3 @@ internal final class NativePropertyUnavailableException: GenericException<String
|
|
|
191
191
|
return "Native property '\(param)' is no longer available in memory"
|
|
192
192
|
}
|
|
193
193
|
}
|
|
194
|
-
|
|
195
|
-
// MARK: - Factory functions
|
|
196
|
-
|
|
197
|
-
/**
|
|
198
|
-
Creates the property with given name. The component is basically no-op if you don't call `.get(_:)` or `.set(_:)` on it.
|
|
199
|
-
*/
|
|
200
|
-
public func Property(_ name: String) -> PropertyComponent<Void> {
|
|
201
|
-
return PropertyComponent(name: name)
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
/**
|
|
205
|
-
Creates the read-only property whose getter doesn't take the owner as an argument.
|
|
206
|
-
*/
|
|
207
|
-
public func Property<Value: AnyArgument>(_ name: String, @_implicitSelfCapture get: @escaping () -> Value) -> PropertyComponent<Void> {
|
|
208
|
-
return PropertyComponent(name: name, getter: get)
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
/**
|
|
212
|
-
Creates the read-only property whose getter takes the owner as an argument.
|
|
213
|
-
*/
|
|
214
|
-
public func Property<Value: AnyArgument, OwnerType>(
|
|
215
|
-
_ name: String,
|
|
216
|
-
@_implicitSelfCapture get: @escaping (_ this: OwnerType) -> Value
|
|
217
|
-
) -> PropertyComponent<OwnerType> {
|
|
218
|
-
return PropertyComponent<OwnerType>(name: name, getter: get)
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
/**
|
|
222
|
-
Creates the property that references to an immutable property of the owner object using the key path.
|
|
223
|
-
*/
|
|
224
|
-
public func Property<Value: AnyArgument, OwnerType>(
|
|
225
|
-
_ name: String,
|
|
226
|
-
_ keyPath: KeyPath<OwnerType, Value>
|
|
227
|
-
) -> PropertyComponent<OwnerType> {
|
|
228
|
-
return PropertyComponent<OwnerType>(name: name) { owner in
|
|
229
|
-
return owner[keyPath: keyPath]
|
|
230
|
-
}
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
/**
|
|
234
|
-
Creates the property that references to a mutable property of the owner object using the key path.
|
|
235
|
-
*/
|
|
236
|
-
public func Property<Value: AnyArgument, OwnerType>(
|
|
237
|
-
_ name: String,
|
|
238
|
-
_ keyPath: ReferenceWritableKeyPath<OwnerType, Value>
|
|
239
|
-
) -> PropertyComponent<OwnerType> {
|
|
240
|
-
return PropertyComponent<OwnerType>(name: name) { owner in
|
|
241
|
-
return owner[keyPath: keyPath]
|
|
242
|
-
}
|
|
243
|
-
.set { owner, newValue in
|
|
244
|
-
owner[keyPath: keyPath] = newValue
|
|
245
|
-
}
|
|
246
|
-
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
A protocol for any type-erased module that provides functions used by the core.
|
|
3
|
+
*/
|
|
4
|
+
public protocol AnyModule: AnyObject, AnyArgument {
|
|
5
|
+
/**
|
|
6
|
+
The default initializer. Must be public, but the module class does *not* need to
|
|
7
|
+
define it as it is implemented in protocol composition, see `BaseModule` class.
|
|
8
|
+
*/
|
|
9
|
+
init(appContext: AppContext)
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
A DSL-like function that returns a `ModuleDefinition` which can be built up from module's name, constants or functions.
|
|
13
|
+
The `@ModuleDefinitionBuilder` wrapper is *not* required in the implementation — it is implicitly inferred from the protocol.
|
|
14
|
+
*/
|
|
15
|
+
@ModuleDefinitionBuilder
|
|
16
|
+
func definition() -> ModuleDefinition
|
|
17
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
A protocol for any type-erased view definition.
|
|
3
|
+
*/
|
|
4
|
+
public protocol AnyViewDefinition {
|
|
5
|
+
/**
|
|
6
|
+
An array of view props supported by the view.
|
|
7
|
+
*/
|
|
8
|
+
var props: [AnyViewProp] { get }
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
Names of the events that the view can send to JavaScript.
|
|
12
|
+
*/
|
|
13
|
+
var eventNames: [String] { get }
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
Creates an instance of the native view.
|
|
17
|
+
*/
|
|
18
|
+
func createView(appContext: AppContext) -> UIView?
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
Returns props definitions as a dictionary where the keys are the prop names.
|
|
22
|
+
*/
|
|
23
|
+
func propsDict() -> [String: AnyViewProp]
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
Calls defined lifecycle methods with the given type.
|
|
27
|
+
*/
|
|
28
|
+
func callLifecycleMethods(withType type: ViewLifecycleMethodType, forView view: UIView)
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
Creates a JavaScript object that may be used as a React component prototype.
|
|
32
|
+
*/
|
|
33
|
+
func createReactComponentPrototype(appContext: AppContext) throws -> JavaScriptObject
|
|
34
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
// Copyright 2022-present 650 Industries. All rights reserved.
|
|
2
|
+
|
|
3
|
+
public protocol AnySharedObject: AnyArgument {
|
|
4
|
+
var sharedObjectId: SharedObjectId { get }
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
extension AnySharedObject {
|
|
8
|
+
public static func getDynamicType() -> AnyDynamicType {
|
|
9
|
+
return DynamicSharedObjectType(innerType: Self.self)
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
open class SharedObject: AnySharedObject {
|
|
14
|
+
/**
|
|
15
|
+
An identifier of the native shared object that maps to the JavaScript object.
|
|
16
|
+
When the object is not linked with any JavaScript object, its value is 0.
|
|
17
|
+
*/
|
|
18
|
+
public internal(set) var sharedObjectId: SharedObjectId = 0
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
An app context for which the shared object was created.
|
|
22
|
+
*/
|
|
23
|
+
public internal(set) weak var appContext: AppContext?
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
The default public initializer of the shared object.
|
|
27
|
+
*/
|
|
28
|
+
public init() {}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
Returns the JavaScript shared object associated with the native shared object.
|
|
32
|
+
*/
|
|
33
|
+
public func getJavaScriptObject() -> JavaScriptObject? {
|
|
34
|
+
return appContext?.sharedObjectRegistry.toJavaScriptObject(self)
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
// Unfortunately the `emit` function needs to be defined in the extension.
|
|
39
|
+
// When put in the class, pack expansion is crashing with `EXC_BAD_ACCESS` code.
|
|
40
|
+
// See https://github.com/apple/swift/issues/72381 for more details.
|
|
41
|
+
public extension SharedObject { // swiftlint:disable:this no_grouping_extension
|
|
42
|
+
// Parameter packs feature requires Swift 5.9 (Xcode 15.0), but some CIs and EAS images may still use older versions.
|
|
43
|
+
// As of April 29, all submissions must be made with Xcode 15, so hopefully we can remove this condition soon.
|
|
44
|
+
// No one should use <15.0 these days.
|
|
45
|
+
#if swift(>=5.9)
|
|
46
|
+
/**
|
|
47
|
+
Schedules an event with the given name and arguments to be emitted to the associated JavaScript object.
|
|
48
|
+
*/
|
|
49
|
+
public func emit<each A: AnyArgument>(event: String, arguments: repeat each A) {
|
|
50
|
+
guard let appContext, let runtime = try? appContext.runtime else {
|
|
51
|
+
log.warn("Trying to send event '\(event)' to \(type(of: self)), but the JS runtime has been lost")
|
|
52
|
+
return
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// Collect arguments and their dynamic types from parameter pack
|
|
56
|
+
var argumentPairs: [(AnyArgument, AnyDynamicType)] = []
|
|
57
|
+
repeat argumentPairs.append((each arguments, ~(each A).self))
|
|
58
|
+
|
|
59
|
+
// Schedule the event to be asynchronously emitted from the runtime's thread
|
|
60
|
+
runtime.schedule { [weak self, weak appContext] in
|
|
61
|
+
guard let appContext, let runtime = try? appContext.runtime, let jsObject = self?.getJavaScriptObject() else {
|
|
62
|
+
log.warn("Trying to send event '\(event)' to \(type(of: self)), but the JS object is no longer associated with the native instance")
|
|
63
|
+
return
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// Convert native arguments to JS, just like function results
|
|
67
|
+
let arguments = argumentPairs.map { argument, dynamicType in
|
|
68
|
+
return Conversions.convertFunctionResult(argument, appContext: appContext, dynamicType: dynamicType)
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
JSIUtils.emitEvent(event, to: jsObject, withArguments: arguments, in: runtime)
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
#else // swift(>=5.9)
|
|
75
|
+
@available(*, unavailable, message: "Unavailable in Xcode <15.0")
|
|
76
|
+
public func emit(event: String, arguments: AnyArgument...) {
|
|
77
|
+
fatalError("Emitting events to JS requires at least Xcode 15.0")
|
|
78
|
+
}
|
|
79
|
+
#endif // swift(<5.9)
|
|
80
|
+
}
|
|
@@ -20,16 +20,21 @@ let sharedObjectIdPropertyName = "__expo_shared_object_id__"
|
|
|
20
20
|
It's been made static for simplicity.
|
|
21
21
|
*/
|
|
22
22
|
public final class SharedObjectRegistry {
|
|
23
|
+
/**
|
|
24
|
+
Weak reference to the app context for the registry.
|
|
25
|
+
*/
|
|
26
|
+
private weak var appContext: AppContext?
|
|
27
|
+
|
|
23
28
|
/**
|
|
24
29
|
The counter of IDs to assign to the shared object pairs.
|
|
25
30
|
The next pair added to the registry will be saved using this ID.
|
|
26
31
|
*/
|
|
27
|
-
internal
|
|
32
|
+
internal var nextId: SharedObjectId = 1
|
|
28
33
|
|
|
29
34
|
/**
|
|
30
35
|
A dictionary of shared object pairs.
|
|
31
36
|
*/
|
|
32
|
-
internal
|
|
37
|
+
internal var pairs = [SharedObjectId: SharedObjectPair]()
|
|
33
38
|
|
|
34
39
|
/**
|
|
35
40
|
The lock queue to keep thread safety for internal data structures.
|
|
@@ -39,17 +44,31 @@ public final class SharedObjectRegistry {
|
|
|
39
44
|
/**
|
|
40
45
|
A number of all pairs stored in the registry.
|
|
41
46
|
*/
|
|
42
|
-
internal
|
|
47
|
+
internal var size: Int {
|
|
43
48
|
return Self.lockQueue.sync {
|
|
44
49
|
return pairs.count
|
|
45
50
|
}
|
|
46
51
|
}
|
|
47
52
|
|
|
53
|
+
/**
|
|
54
|
+
Shared object releaser that is common to all instances.
|
|
55
|
+
*/
|
|
56
|
+
private lazy var objectReleaser: (SharedObjectId) -> Void = { [weak self] objectId in
|
|
57
|
+
self?.delete(objectId)
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
The default initializer that takes the app context.
|
|
62
|
+
*/
|
|
63
|
+
internal init(appContext: AppContext) {
|
|
64
|
+
self.appContext = appContext
|
|
65
|
+
}
|
|
66
|
+
|
|
48
67
|
/**
|
|
49
68
|
Returns the next shared object ID and increases the counter.
|
|
50
69
|
*/
|
|
51
70
|
@discardableResult
|
|
52
|
-
internal
|
|
71
|
+
internal func pullNextId() -> SharedObjectId {
|
|
53
72
|
return Self.lockQueue.sync {
|
|
54
73
|
let id = nextId
|
|
55
74
|
nextId += 1
|
|
@@ -60,7 +79,7 @@ public final class SharedObjectRegistry {
|
|
|
60
79
|
/**
|
|
61
80
|
Returns a pair of shared objects with given ID or `nil` when there is no such pair in the registry.
|
|
62
81
|
*/
|
|
63
|
-
internal
|
|
82
|
+
internal func get(_ id: SharedObjectId) -> SharedObjectPair? {
|
|
64
83
|
return Self.lockQueue.sync {
|
|
65
84
|
return pairs[id]
|
|
66
85
|
}
|
|
@@ -70,20 +89,27 @@ public final class SharedObjectRegistry {
|
|
|
70
89
|
Adds a pair of native and JS shared object to the registry. Assigns a new shared object ID to these objects.
|
|
71
90
|
*/
|
|
72
91
|
@discardableResult
|
|
73
|
-
internal
|
|
92
|
+
internal func add(native nativeObject: SharedObject, javaScript jsObject: JavaScriptObject) -> SharedObjectId {
|
|
74
93
|
let id = pullNextId()
|
|
75
94
|
|
|
76
|
-
//
|
|
95
|
+
// Assign the ID and the app context to the object.
|
|
77
96
|
nativeObject.sharedObjectId = id
|
|
97
|
+
nativeObject.appContext = appContext
|
|
98
|
+
|
|
99
|
+
// This property should be deprecated, but it's still used when passing as a view prop.
|
|
100
|
+
// It's already defined in the JS base SharedObject class prototype,
|
|
101
|
+
// but with the current implementation it's possible to use a raw object for registration.
|
|
78
102
|
jsObject.defineProperty(sharedObjectIdPropertyName, value: id, options: [.writable])
|
|
79
103
|
|
|
80
|
-
// Set the
|
|
81
|
-
|
|
104
|
+
// Set the native state in the JS object.
|
|
105
|
+
if let runtime = try? appContext?.runtime {
|
|
106
|
+
SharedObjectUtils.setNativeState(jsObject, runtime: runtime, objectId: id, releaser: objectReleaser)
|
|
107
|
+
}
|
|
82
108
|
|
|
83
109
|
// Save the pair in the dictionary.
|
|
84
110
|
let jsWeakObject = jsObject.createWeak()
|
|
85
111
|
Self.lockQueue.async {
|
|
86
|
-
pairs[id] = (native: nativeObject, javaScript: jsWeakObject)
|
|
112
|
+
self.pairs[id] = (native: nativeObject, javaScript: jsWeakObject)
|
|
87
113
|
}
|
|
88
114
|
|
|
89
115
|
return id
|
|
@@ -92,14 +118,14 @@ public final class SharedObjectRegistry {
|
|
|
92
118
|
/**
|
|
93
119
|
Deletes the shared objects pair with a given ID.
|
|
94
120
|
*/
|
|
95
|
-
internal
|
|
121
|
+
internal func delete(_ id: SharedObjectId) {
|
|
96
122
|
Self.lockQueue.async {
|
|
97
|
-
if let pair = pairs[id] {
|
|
123
|
+
if let pair = self.pairs[id] {
|
|
98
124
|
// Reset an ID on the objects.
|
|
99
125
|
pair.native.sharedObjectId = 0
|
|
100
126
|
|
|
101
127
|
// Delete the pair from the dictionary.
|
|
102
|
-
pairs[id] = nil
|
|
128
|
+
self.pairs[id] = nil
|
|
103
129
|
}
|
|
104
130
|
}
|
|
105
131
|
}
|
|
@@ -107,7 +133,7 @@ public final class SharedObjectRegistry {
|
|
|
107
133
|
/**
|
|
108
134
|
Gets the native shared object that is paired with a given JS object.
|
|
109
135
|
*/
|
|
110
|
-
internal
|
|
136
|
+
internal func toNativeObject(_ jsObject: JavaScriptObject) -> SharedObject? {
|
|
111
137
|
if let objectId = try? jsObject.getProperty(sharedObjectIdPropertyName).asInt() {
|
|
112
138
|
return Self.lockQueue.sync {
|
|
113
139
|
return pairs[objectId]?.native
|
|
@@ -119,7 +145,7 @@ public final class SharedObjectRegistry {
|
|
|
119
145
|
/**
|
|
120
146
|
Gets the JS shared object that is paired with a given native object.
|
|
121
147
|
*/
|
|
122
|
-
internal
|
|
148
|
+
internal func toJavaScriptObject(_ nativeObject: SharedObject) -> JavaScriptObject? {
|
|
123
149
|
let objectId = nativeObject.sharedObjectId
|
|
124
150
|
return Self.lockQueue.sync {
|
|
125
151
|
return pairs[objectId]?.javaScript.lock()
|
|
@@ -129,7 +155,7 @@ public final class SharedObjectRegistry {
|
|
|
129
155
|
/**
|
|
130
156
|
Creates a plain JS object and pairs it with a given native object.
|
|
131
157
|
*/
|
|
132
|
-
internal
|
|
158
|
+
internal func createSharedJavaScriptObject(runtime: JavaScriptRuntime, nativeObject: SharedObject) -> JavaScriptObject {
|
|
133
159
|
let object = runtime.createObject()
|
|
134
160
|
add(native: nativeObject, javaScript: object)
|
|
135
161
|
return object
|
|
@@ -138,7 +164,7 @@ public final class SharedObjectRegistry {
|
|
|
138
164
|
/**
|
|
139
165
|
Ensures that there is a JS object paired with a given native object. If not, a plain JS object is created.
|
|
140
166
|
*/
|
|
141
|
-
internal
|
|
167
|
+
internal func ensureSharedJavaScriptObject(runtime: JavaScriptRuntime, nativeObject: SharedObject) -> JavaScriptObject {
|
|
142
168
|
if let jsObject = toJavaScriptObject(nativeObject) {
|
|
143
169
|
// JS object for this native object already exists in the registry, just return it.
|
|
144
170
|
return jsObject
|
|
@@ -146,9 +172,9 @@ public final class SharedObjectRegistry {
|
|
|
146
172
|
return createSharedJavaScriptObject(runtime: runtime, nativeObject: nativeObject)
|
|
147
173
|
}
|
|
148
174
|
|
|
149
|
-
internal
|
|
175
|
+
internal func clear() {
|
|
150
176
|
Self.lockQueue.async {
|
|
151
|
-
pairs.removeAll()
|
|
177
|
+
self.pairs.removeAll()
|
|
152
178
|
}
|
|
153
179
|
}
|
|
154
180
|
}
|
|
@@ -35,7 +35,7 @@ public final class ComponentData: RCTComponentDataSwiftAdapter {
|
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
// If the prop is defined as an event, create our own event setter.
|
|
38
|
-
if moduleHolder?.
|
|
38
|
+
if moduleHolder?.definition.view?.eventNames.contains(propName) == true {
|
|
39
39
|
return createEventSetter(eventName: propName, bridge: self.manager?.bridge)
|
|
40
40
|
}
|
|
41
41
|
|
|
@@ -48,7 +48,7 @@ public final class ComponentData: RCTComponentDataSwiftAdapter {
|
|
|
48
48
|
log.warn("Given view is not an UIView")
|
|
49
49
|
return
|
|
50
50
|
}
|
|
51
|
-
guard let
|
|
51
|
+
guard let viewDefinition = moduleHolder?.definition.view else {
|
|
52
52
|
log.warn("View manager '\(self.name)' not found")
|
|
53
53
|
return
|
|
54
54
|
}
|
|
@@ -56,7 +56,7 @@ public final class ComponentData: RCTComponentDataSwiftAdapter {
|
|
|
56
56
|
log.warn("App context has been lost")
|
|
57
57
|
return
|
|
58
58
|
}
|
|
59
|
-
let propsDict =
|
|
59
|
+
let propsDict = viewDefinition.propsDict()
|
|
60
60
|
var remainingProps = props
|
|
61
61
|
|
|
62
62
|
for (key, prop) in propsDict {
|
|
@@ -75,7 +75,7 @@ public final class ComponentData: RCTComponentDataSwiftAdapter {
|
|
|
75
75
|
// Let the base class `RCTComponentData` handle all remaining props.
|
|
76
76
|
super.setProps(remainingProps, forView: view)
|
|
77
77
|
|
|
78
|
-
|
|
78
|
+
viewDefinition.callLifecycleMethods(withType: .didUpdateProps, forView: view)
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
/**
|
|
@@ -87,12 +87,12 @@ public final class ComponentData: RCTComponentDataSwiftAdapter {
|
|
|
87
87
|
var directEvents: [String] = []
|
|
88
88
|
let superClass: AnyClass? = managerClass.superclass()
|
|
89
89
|
|
|
90
|
-
if let
|
|
91
|
-
for prop in
|
|
90
|
+
if let viewDefinition = moduleHolder?.definition.view {
|
|
91
|
+
for prop in viewDefinition.props {
|
|
92
92
|
// `id` allows every type to be passed in
|
|
93
93
|
propTypes[prop.name] = "id"
|
|
94
94
|
}
|
|
95
|
-
for eventName in
|
|
95
|
+
for eventName in viewDefinition.eventNames {
|
|
96
96
|
directEvents.append(RCTNormalizeInputEventName(eventName))
|
|
97
97
|
propTypes[eventName] = "BOOL"
|
|
98
98
|
}
|
|
@@ -6,7 +6,7 @@ import React
|
|
|
6
6
|
The view that extends `RCTView` which handles some styles (e.g. borders) and accessibility.
|
|
7
7
|
Inherit from `ExpoView` to keep this behavior and let your view use the associated `AppContext`.
|
|
8
8
|
*/
|
|
9
|
-
open class ExpoView: RCTView {
|
|
9
|
+
open class ExpoView: RCTView, AnyExpoView {
|
|
10
10
|
/**
|
|
11
11
|
A weak pointer to the associated `AppContext`.
|
|
12
12
|
*/
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
// Copyright 2022-present 650 Industries. All rights reserved.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
A definition representing the native view to export to React.
|
|
5
|
+
*/
|
|
6
|
+
public final class ViewDefinition<ViewType: UIView>: ObjectDefinition, AnyViewDefinition {
|
|
7
|
+
/**
|
|
8
|
+
An array of view props definitions.
|
|
9
|
+
*/
|
|
10
|
+
public let props: [AnyViewProp]
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
Names of the events that the view can send to JavaScript.
|
|
14
|
+
*/
|
|
15
|
+
public let eventNames: [String]
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
An array of the view lifecycle methods.
|
|
19
|
+
*/
|
|
20
|
+
let lifecycleMethods: [AnyViewLifecycleMethod]
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
Default initializer receiving children definitions from the result builder.
|
|
24
|
+
*/
|
|
25
|
+
init(_ viewType: ViewType.Type, elements: [AnyViewDefinitionElement]) {
|
|
26
|
+
self.props = elements
|
|
27
|
+
.compactMap { $0 as? AnyViewProp }
|
|
28
|
+
|
|
29
|
+
self.eventNames = Array(
|
|
30
|
+
elements
|
|
31
|
+
.compactMap { ($0 as? EventsDefinition)?.names }
|
|
32
|
+
.joined()
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
self.lifecycleMethods = elements
|
|
36
|
+
.compactMap { $0 as? AnyViewLifecycleMethod }
|
|
37
|
+
|
|
38
|
+
super.init(definitions: elements)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// MARK: - AnyViewDefinition
|
|
42
|
+
|
|
43
|
+
public func createView(appContext: AppContext) -> UIView? {
|
|
44
|
+
if let expoViewType = ViewType.self as? AnyExpoView.Type {
|
|
45
|
+
return expoViewType.init(appContext: appContext)
|
|
46
|
+
}
|
|
47
|
+
if let legacyViewType = ViewType.self as? EXLegacyExpoViewProtocol.Type {
|
|
48
|
+
return legacyViewType.init(moduleRegistry: appContext.legacyModuleRegistry) as? UIView
|
|
49
|
+
}
|
|
50
|
+
return ViewType(frame: .zero)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
public func propsDict() -> [String: AnyViewProp] {
|
|
54
|
+
return props.reduce(into: [String: AnyViewProp]()) { acc, prop in
|
|
55
|
+
acc[prop.name] = prop
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
public func callLifecycleMethods(withType type: ViewLifecycleMethodType, forView view: UIView) {
|
|
60
|
+
for method in lifecycleMethods where method.type == type {
|
|
61
|
+
method(view)
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
public func createReactComponentPrototype(appContext: AppContext) throws -> JavaScriptObject {
|
|
66
|
+
let prototype = try appContext.runtime.createObject()
|
|
67
|
+
|
|
68
|
+
try decorateWithFunctions(object: prototype, appContext: appContext)
|
|
69
|
+
|
|
70
|
+
return prototype
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
// MARK: - AnyViewDefinitionElement
|
|
75
|
+
|
|
76
|
+
public protocol AnyViewDefinitionElement: AnyDefinition {}
|
|
77
|
+
extension ConcreteViewProp: AnyViewDefinitionElement {}
|
|
78
|
+
extension EventsDefinition: AnyViewDefinitionElement {}
|
|
79
|
+
extension ViewLifecycleMethod: AnyViewDefinitionElement {}
|
|
80
|
+
|
|
81
|
+
// MARK: - ViewDefinitionFunctionElement
|
|
82
|
+
|
|
83
|
+
public protocol ViewDefinitionFunctionElement: AnyViewDefinitionElement {
|
|
84
|
+
associatedtype ViewType
|
|
85
|
+
}
|
|
86
|
+
extension AsyncFunctionDefinition: ViewDefinitionFunctionElement {
|
|
87
|
+
public typealias ViewType = FirstArgType
|
|
88
|
+
}
|
|
89
|
+
extension ConcurrentFunctionDefinition: ViewDefinitionFunctionElement {
|
|
90
|
+
public typealias ViewType = FirstArgType
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
extension UIView: AnyArgument {
|
|
94
|
+
public static func getDynamicType() -> AnyDynamicType {
|
|
95
|
+
return DynamicViewType(innerType: Self.self)
|
|
96
|
+
}
|
|
97
|
+
}
|
|
@@ -86,7 +86,7 @@ public final class ViewModuleWrapper: RCTViewManager, DynamicModuleWrapperProtoc
|
|
|
86
86
|
guard let appContext = wrappedModuleHolder.appContext else {
|
|
87
87
|
fatalError(Exceptions.AppContextLost().reason)
|
|
88
88
|
}
|
|
89
|
-
guard let view = wrappedModuleHolder.definition.
|
|
89
|
+
guard let view = wrappedModuleHolder.definition.view?.createView(appContext: appContext) else {
|
|
90
90
|
fatalError("Cannot create a view from module '\(self.name)'")
|
|
91
91
|
}
|
|
92
92
|
return view
|