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
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
// Copyright 2022-present 650 Industries. All rights reserved.
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
Type-erased protocol for synchronous functions.
|
|
5
|
+
*/
|
|
6
|
+
internal protocol AnySyncFunctionDefinition: AnyFunctionDefinition {
|
|
7
|
+
/**
|
|
8
|
+
Calls the function synchronously with given arguments.
|
|
9
|
+
- Parameters:
|
|
10
|
+
- owner: An object that calls this function. If the `takesOwner` property is true
|
|
11
|
+
and type of the first argument matches the owner type, it's being passed as the argument.
|
|
12
|
+
- args: An array of arguments to pass to the function. The arguments must be of the same type as in the underlying closure.
|
|
13
|
+
- appContext: An app context where the function is executed.
|
|
14
|
+
- Returns: A value returned by the called function when succeeded or an error when it failed.
|
|
15
|
+
*/
|
|
16
|
+
func call(by owner: AnyObject?, withArguments args: [Any], appContext: AppContext) throws -> Any
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
Represents a function that can only be called synchronously.
|
|
21
|
+
*/
|
|
22
|
+
public final class SyncFunctionDefinition<Args, FirstArgType, ReturnType>: AnySyncFunctionDefinition {
|
|
23
|
+
typealias ClosureType = (Args) throws -> ReturnType
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
The underlying closure to run when the function is called.
|
|
27
|
+
*/
|
|
28
|
+
let body: ClosureType
|
|
29
|
+
|
|
30
|
+
init(
|
|
31
|
+
_ name: String,
|
|
32
|
+
firstArgType: FirstArgType.Type,
|
|
33
|
+
dynamicArgumentTypes: [AnyDynamicType],
|
|
34
|
+
_ body: @escaping ClosureType
|
|
35
|
+
) {
|
|
36
|
+
self.name = name
|
|
37
|
+
self.dynamicArgumentTypes = dynamicArgumentTypes
|
|
38
|
+
self.body = body
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// MARK: - AnyFunction
|
|
42
|
+
|
|
43
|
+
let name: String
|
|
44
|
+
|
|
45
|
+
let dynamicArgumentTypes: [AnyDynamicType]
|
|
46
|
+
|
|
47
|
+
var argumentsCount: Int {
|
|
48
|
+
return dynamicArgumentTypes.count - (takesOwner ? 1 : 0)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
var takesOwner: Bool = false
|
|
52
|
+
|
|
53
|
+
func call(by owner: AnyObject?, withArguments args: [Any], appContext: AppContext, callback: @escaping (FunctionCallResult) -> ()) {
|
|
54
|
+
do {
|
|
55
|
+
let result = try call(by: owner, withArguments: args, appContext: appContext)
|
|
56
|
+
callback(.success(Conversions.convertFunctionResult(result)))
|
|
57
|
+
} catch let error as Exception {
|
|
58
|
+
callback(.failure(error))
|
|
59
|
+
} catch {
|
|
60
|
+
callback(.failure(UnexpectedException(error)))
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
// MARK: - AnySyncFunctionDefinition
|
|
65
|
+
|
|
66
|
+
func call(by owner: AnyObject?, withArguments args: [Any], appContext: AppContext) throws -> Any {
|
|
67
|
+
do {
|
|
68
|
+
try validateArgumentsNumber(function: self, received: args.count)
|
|
69
|
+
|
|
70
|
+
var arguments = concat(
|
|
71
|
+
arguments: args,
|
|
72
|
+
withOwner: owner,
|
|
73
|
+
withPromise: nil,
|
|
74
|
+
forFunction: self,
|
|
75
|
+
appContext: appContext
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
// Convert JS values to non-JS native types.
|
|
79
|
+
arguments = try cast(jsValues: arguments, forFunction: self, appContext: appContext)
|
|
80
|
+
|
|
81
|
+
// Convert arguments to the types desired by the function.
|
|
82
|
+
arguments = try cast(arguments: arguments, forFunction: self, appContext: appContext)
|
|
83
|
+
|
|
84
|
+
let argumentsTuple = try Conversions.toTuple(arguments) as! Args
|
|
85
|
+
return try body(argumentsTuple)
|
|
86
|
+
} catch let error as Exception {
|
|
87
|
+
throw FunctionCallException(name).causedBy(error)
|
|
88
|
+
} catch {
|
|
89
|
+
throw UnexpectedException(error)
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
// MARK: - JavaScriptObjectBuilder
|
|
94
|
+
|
|
95
|
+
func build(appContext: AppContext) throws -> JavaScriptObject {
|
|
96
|
+
// We intentionally capture a strong reference to `self`, otherwise the "detached" objects would
|
|
97
|
+
// immediately lose the reference to the definition and thus the underlying native function.
|
|
98
|
+
// It may potentially cause memory leaks, but at the time of writing this comment,
|
|
99
|
+
// the native definition instance deallocates correctly when the JS VM triggers the garbage collector.
|
|
100
|
+
return try appContext.runtime.createSyncFunction(name, argsCount: argumentsCount) { [weak appContext, self] this, args in
|
|
101
|
+
guard let appContext else {
|
|
102
|
+
throw Exceptions.AppContextLost()
|
|
103
|
+
}
|
|
104
|
+
let result = try self.call(by: this, withArguments: args, appContext: appContext)
|
|
105
|
+
return Conversions.convertFunctionResult(result, appContext: appContext, dynamicType: ~ReturnType.self)
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
@@ -30,7 +30,7 @@ internal func cast(_ value: Any, toType type: AnyDynamicType, appContext: AppCon
|
|
|
30
30
|
- Throws: `InvalidArgsNumberException` when the number of arguments is not equal to the actual number
|
|
31
31
|
of function's arguments (without an owner and promise). Rethrows exceptions thrown by `cast(_:toType:)`.
|
|
32
32
|
*/
|
|
33
|
-
internal func cast(arguments: [Any], forFunction function:
|
|
33
|
+
internal func cast(arguments: [Any], forFunction function: AnyFunctionDefinition, appContext: AppContext) throws -> [Any] {
|
|
34
34
|
return try arguments.enumerated().map { index, argument in
|
|
35
35
|
let argumentType = function.dynamicArgumentTypes[index]
|
|
36
36
|
|
|
@@ -45,7 +45,7 @@ internal func cast(arguments: [Any], forFunction function: AnyFunction, appConte
|
|
|
45
45
|
/**
|
|
46
46
|
Casts an array of JavaScript values to non-JavaScript types.
|
|
47
47
|
*/
|
|
48
|
-
internal func cast(jsValues: [Any], forFunction function:
|
|
48
|
+
internal func cast(jsValues: [Any], forFunction function: AnyFunctionDefinition, appContext: AppContext) throws -> [Any] {
|
|
49
49
|
// TODO: Replace `[Any]` with `[JavaScriptValue]` once we make sure only JS values are passed here
|
|
50
50
|
return try jsValues.enumerated().map { index, jsValue in
|
|
51
51
|
let type = function.dynamicArgumentTypes[index]
|
|
@@ -67,7 +67,7 @@ internal func cast(jsValues: [Any], forFunction function: AnyFunction, appContex
|
|
|
67
67
|
Validates whether the number of received arguments is enough to call the given function.
|
|
68
68
|
Throws `InvalidArgsNumberException` otherwise.
|
|
69
69
|
*/
|
|
70
|
-
internal func validateArgumentsNumber(function:
|
|
70
|
+
internal func validateArgumentsNumber(function: AnyFunctionDefinition, received: Int) throws {
|
|
71
71
|
let argumentsCount = function.argumentsCount
|
|
72
72
|
let requiredArgumentsCount = function.requiredArgumentsCount
|
|
73
73
|
|
|
@@ -89,7 +89,7 @@ internal func concat(
|
|
|
89
89
|
arguments: [Any],
|
|
90
90
|
withOwner owner: AnyObject?,
|
|
91
91
|
withPromise promise: Promise?,
|
|
92
|
-
forFunction function:
|
|
92
|
+
forFunction function: AnyFunctionDefinition,
|
|
93
93
|
appContext: AppContext
|
|
94
94
|
) -> [Any] {
|
|
95
95
|
var result = arguments
|
|
@@ -2,12 +2,21 @@
|
|
|
2
2
|
|
|
3
3
|
import os.log
|
|
4
4
|
|
|
5
|
+
public func createOSLogHandler(category: String) -> LogHandler {
|
|
6
|
+
if #available(macOS 11.0, iOS 14.0, watchOS 7.0, tvOS 14.0, *) {
|
|
7
|
+
return OSLogHandler(category: category)
|
|
8
|
+
}
|
|
9
|
+
return PrintLogHandler()
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
public func createPersistentFileLogHandler(category: String) -> LogHandler {
|
|
13
|
+
return PersistentFileLogHandler(category: category)
|
|
14
|
+
}
|
|
15
|
+
|
|
5
16
|
/**
|
|
6
17
|
The protocol that needs to be implemented by log handlers.
|
|
7
18
|
*/
|
|
8
|
-
|
|
9
|
-
init(category: String)
|
|
10
|
-
|
|
19
|
+
public protocol LogHandler {
|
|
11
20
|
func log(type: LogType, _ message: String)
|
|
12
21
|
}
|
|
13
22
|
|
|
@@ -31,8 +40,6 @@ internal class OSLogHandler: LogHandler {
|
|
|
31
40
|
Simple log handler that forwards all logs to `print` function.
|
|
32
41
|
*/
|
|
33
42
|
internal class PrintLogHandler: LogHandler {
|
|
34
|
-
required init(category: String) {}
|
|
35
|
-
|
|
36
43
|
func log(type: LogType, _ message: String) {
|
|
37
44
|
print(message)
|
|
38
45
|
}
|
|
@@ -2,30 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
import Dispatch
|
|
4
4
|
|
|
5
|
-
public let log = Logger(category: Logger.EXPO_LOG_CATEGORY)
|
|
5
|
+
public let log = Logger(logHandlers: [createOSLogHandler(category: Logger.EXPO_LOG_CATEGORY)])
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
An OptionSet defining the logging options that are currently supported.
|
|
9
|
-
Future options may include writing to a DB or other destinations
|
|
10
|
-
*/
|
|
11
|
-
public struct LoggerOptions: OptionSet {
|
|
12
|
-
public let rawValue: Int
|
|
13
|
-
|
|
14
|
-
public init(rawValue: Int) {
|
|
15
|
-
self.rawValue = rawValue
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
Including this option will result in logs being written using os.log() or print(),
|
|
20
|
-
depending on the iOS version.
|
|
21
|
-
*/
|
|
22
|
-
public static let logToOS = LoggerOptions(rawValue: 1 << 0)
|
|
23
|
-
/**
|
|
24
|
-
Including this option will result in logs being written to a flat file, as
|
|
25
|
-
strings separated by carriage returns.
|
|
26
|
-
*/
|
|
27
|
-
public static let logToFile = LoggerOptions(rawValue: 1 << 1)
|
|
28
|
-
}
|
|
7
|
+
public typealias LoggerTimerFormatterBlock = (_ duration: Double) -> String
|
|
29
8
|
|
|
30
9
|
/**
|
|
31
10
|
Native iOS logging class for Expo, with options to direct logs
|
|
@@ -41,31 +20,10 @@ public class Logger {
|
|
|
41
20
|
private var minLevel: LogType = .info
|
|
42
21
|
#endif
|
|
43
22
|
|
|
44
|
-
private let
|
|
45
|
-
|
|
46
|
-
private var handlers: [LogHandler] = []
|
|
47
|
-
|
|
48
|
-
public init(category: String = "main", options: LoggerOptions = [.logToOS]) {
|
|
49
|
-
self.category = category
|
|
50
|
-
|
|
51
|
-
if options.contains(.logToFile) {
|
|
52
|
-
addHandler(withType: PersistentFileLogHandler.self)
|
|
53
|
-
}
|
|
54
|
-
if options.contains(.logToOS) {
|
|
55
|
-
if #available(macOS 11.0, iOS 14.0, watchOS 7.0, tvOS 14.0, *) {
|
|
56
|
-
addHandler(withType: OSLogHandler.self)
|
|
57
|
-
} else {
|
|
58
|
-
addHandler(withType: PrintLogHandler.self)
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
internal func addHandler<LogHandlerType: LogHandler>(_ handler: LogHandlerType) {
|
|
64
|
-
handlers.append(handler)
|
|
65
|
-
}
|
|
23
|
+
private let logHandlers: [LogHandler]
|
|
66
24
|
|
|
67
|
-
|
|
68
|
-
|
|
25
|
+
public required init(logHandlers: [LogHandler]) {
|
|
26
|
+
self.logHandlers = logHandlers
|
|
69
27
|
}
|
|
70
28
|
|
|
71
29
|
// MARK: - Public logging functions
|
|
@@ -146,52 +104,16 @@ public class Logger {
|
|
|
146
104
|
// MARK: - Timers
|
|
147
105
|
|
|
148
106
|
/**
|
|
149
|
-
|
|
107
|
+
Starts a timer that can be used to compute the duration of an operation. Upon calling
|
|
108
|
+
`stop` on the returned object, a timer entry will be logged.
|
|
150
109
|
*/
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
guard LogType.timer.rawValue >= minLevel.rawValue else {
|
|
158
|
-
return
|
|
159
|
-
}
|
|
160
|
-
log(type: .timer, "Starting timer '\(id)'")
|
|
161
|
-
timers[id] = DispatchTime.now()
|
|
162
|
-
}
|
|
163
|
-
|
|
164
|
-
/**
|
|
165
|
-
Stops the timer and logs how much time elapsed since it started.
|
|
166
|
-
*/
|
|
167
|
-
public func timeEnd(_ id: String) {
|
|
168
|
-
guard LogType.timer.rawValue >= minLevel.rawValue else {
|
|
169
|
-
return
|
|
110
|
+
public func startTimer(_ formatterBlock: @escaping LoggerTimerFormatterBlock) -> LoggerTimer {
|
|
111
|
+
let startTime = DispatchTime.now()
|
|
112
|
+
return LoggerTimer {
|
|
113
|
+
let endTime = DispatchTime.now()
|
|
114
|
+
let diff = Double(endTime.uptimeNanoseconds - startTime.uptimeNanoseconds) / 1_000_000
|
|
115
|
+
self.log(type: .timer, formatterBlock(diff))
|
|
170
116
|
}
|
|
171
|
-
guard let startTime = timers[id] else {
|
|
172
|
-
log(type: .timer, "Timer '\(id)' has not been started!")
|
|
173
|
-
return
|
|
174
|
-
}
|
|
175
|
-
let endTime = DispatchTime.now()
|
|
176
|
-
let diff = Double(endTime.uptimeNanoseconds - startTime.uptimeNanoseconds) / 1_000_000
|
|
177
|
-
log(type: .timer, "Timer '\(id)' has finished in: \(diff) ms")
|
|
178
|
-
timers.removeValue(forKey: id)
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
/**
|
|
182
|
-
Measures how much time it takes to run given closure. Returns the same value as the closure returned.
|
|
183
|
-
*/
|
|
184
|
-
public func time<ReturnType>(_ id: String, _ closure: () -> ReturnType) -> ReturnType {
|
|
185
|
-
timeStart(id)
|
|
186
|
-
let result = closure()
|
|
187
|
-
timeEnd(id)
|
|
188
|
-
return result
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
// MARK: - Changing the category
|
|
192
|
-
|
|
193
|
-
public func category(_ category: String) -> Logger {
|
|
194
|
-
return Logger(category: category)
|
|
195
117
|
}
|
|
196
118
|
|
|
197
119
|
// MARK: - Private logging functions
|
|
@@ -206,7 +128,7 @@ public class Logger {
|
|
|
206
128
|
.split(whereSeparator: \.isNewline)
|
|
207
129
|
.map { "\(type.prefix) \($0)" }
|
|
208
130
|
|
|
209
|
-
|
|
131
|
+
logHandlers.forEach { handler in
|
|
210
132
|
messages.forEach { message in
|
|
211
133
|
handler.log(type: type, message)
|
|
212
134
|
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
// Copyright 2021-present 650 Industries. All rights reserved.
|
|
2
|
+
|
|
3
|
+
import Foundation
|
|
4
|
+
|
|
5
|
+
typealias LoggerTimerStopBlock = () -> Void
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
An instance of a timer.
|
|
9
|
+
*/
|
|
10
|
+
public class LoggerTimer {
|
|
11
|
+
private let stopBlock: LoggerTimerStopBlock
|
|
12
|
+
|
|
13
|
+
internal required init(stopBlock: @escaping LoggerTimerStopBlock) {
|
|
14
|
+
self.stopBlock = stopBlock
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
End the timer and log a timer entry.
|
|
18
|
+
*/
|
|
19
|
+
public func stop() {
|
|
20
|
+
self.stopBlock()
|
|
21
|
+
}
|
|
22
|
+
}
|
|
@@ -31,13 +31,6 @@ public final class ModuleHolder {
|
|
|
31
31
|
return definition.name.isEmpty ? String(describing: type(of: module)) : definition.name
|
|
32
32
|
}
|
|
33
33
|
|
|
34
|
-
/**
|
|
35
|
-
Shortcut to get the underlying view manager definition.
|
|
36
|
-
*/
|
|
37
|
-
var viewManager: ViewManagerDefinition? {
|
|
38
|
-
return definition.viewManager
|
|
39
|
-
}
|
|
40
|
-
|
|
41
34
|
/**
|
|
42
35
|
Number of JavaScript listeners attached to the module.
|
|
43
36
|
*/
|
|
@@ -75,7 +68,7 @@ public final class ModuleHolder {
|
|
|
75
68
|
|
|
76
69
|
@discardableResult
|
|
77
70
|
func callSync(function functionName: String, args: [Any]) -> Any? {
|
|
78
|
-
guard let appContext, let function = definition.functions[functionName] as?
|
|
71
|
+
guard let appContext, let function = definition.functions[functionName] as? AnySyncFunctionDefinition else {
|
|
79
72
|
return nil
|
|
80
73
|
}
|
|
81
74
|
do {
|
|
@@ -83,8 +76,7 @@ public final class ModuleHolder {
|
|
|
83
76
|
let result = try function.call(by: self, withArguments: arguments, appContext: appContext)
|
|
84
77
|
|
|
85
78
|
if let result = result as? SharedObject {
|
|
86
|
-
|
|
87
|
-
return jsObject
|
|
79
|
+
return appContext.sharedObjectRegistry.ensureSharedJavaScriptObject(runtime: try appContext.runtime, nativeObject: result)
|
|
88
80
|
}
|
|
89
81
|
return result
|
|
90
82
|
} catch {
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
// The core module that describes the `global.expo` object.
|
|
2
|
+
internal final class CoreModule: Module {
|
|
3
|
+
internal func definition() -> ModuleDefinition {
|
|
4
|
+
// Expose some common classes and maybe even the `modules` host object in the future.
|
|
5
|
+
Function("uuidv4") { () -> String in
|
|
6
|
+
return UUID().uuidString.lowercased()
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
Function("uuidv5") { (name: String, namespace: String) -> String in
|
|
10
|
+
guard let namespaceUuid = UUID(uuidString: namespace) else {
|
|
11
|
+
throw InvalidNamespaceException(namespace)
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
return uuidv5(name: name, namespace: namespaceUuid).uuidString.lowercased()
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
Function("getViewConfig") { (viewName: String) -> [String: Any]? in
|
|
18
|
+
var validAttributes: [String: Any] = [:]
|
|
19
|
+
var directEventTypes: [String: Any] = [:]
|
|
20
|
+
let moduleHolder = appContext?.moduleRegistry.get(moduleHolderForName: viewName)
|
|
21
|
+
|
|
22
|
+
guard let viewDefinition = moduleHolder?.definition.view else {
|
|
23
|
+
return nil
|
|
24
|
+
}
|
|
25
|
+
for prop in viewDefinition.props {
|
|
26
|
+
validAttributes[prop.name] = true
|
|
27
|
+
}
|
|
28
|
+
for eventName in viewDefinition.eventNames {
|
|
29
|
+
guard let normalizedEventName = RCTNormalizeInputEventName(eventName) else {
|
|
30
|
+
continue
|
|
31
|
+
}
|
|
32
|
+
directEventTypes[normalizedEventName] = [
|
|
33
|
+
"registrationName": eventName
|
|
34
|
+
]
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return [
|
|
38
|
+
"validAttributes": validAttributes,
|
|
39
|
+
"directEventTypes": directEventTypes
|
|
40
|
+
]
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
A protocol that must be implemented to be a part of module's definition and the module definition itself.
|
|
3
|
-
*/
|
|
4
|
-
public protocol AnyDefinition {}
|
|
5
|
-
|
|
6
1
|
/**
|
|
7
2
|
The definition of the module. It is used to define some parameters
|
|
8
3
|
of the module and what it exports to the JavaScript world.
|
|
@@ -20,13 +15,16 @@ public final class ModuleDefinition: ObjectDefinition {
|
|
|
20
15
|
var name: String
|
|
21
16
|
|
|
22
17
|
let eventListeners: [EventListener]
|
|
23
|
-
|
|
18
|
+
|
|
19
|
+
let view: AnyViewDefinition?
|
|
24
20
|
|
|
25
21
|
/**
|
|
26
22
|
Names of the events that the module can send to JavaScript.
|
|
27
23
|
*/
|
|
28
24
|
let eventNames: [String]
|
|
29
25
|
|
|
26
|
+
let eventObservers: [AnyEventObservingDefinition]
|
|
27
|
+
|
|
30
28
|
/**
|
|
31
29
|
Initializer that is called by the `ModuleDefinitionBuilder` results builder.
|
|
32
30
|
*/
|
|
@@ -38,8 +36,8 @@ public final class ModuleDefinition: ObjectDefinition {
|
|
|
38
36
|
|
|
39
37
|
self.eventListeners = definitions.compactMap { $0 as? EventListener }
|
|
40
38
|
|
|
41
|
-
self.
|
|
42
|
-
.compactMap { $0 as?
|
|
39
|
+
self.view = definitions
|
|
40
|
+
.compactMap { $0 as? AnyViewDefinition }
|
|
43
41
|
.last
|
|
44
42
|
|
|
45
43
|
self.eventNames = Array(
|
|
@@ -48,6 +46,9 @@ public final class ModuleDefinition: ObjectDefinition {
|
|
|
48
46
|
.joined()
|
|
49
47
|
)
|
|
50
48
|
|
|
49
|
+
self.eventObservers = definitions
|
|
50
|
+
.compactMap { $0 as? AnyEventObservingDefinition }
|
|
51
|
+
|
|
51
52
|
super.init(definitions: definitions)
|
|
52
53
|
}
|
|
53
54
|
|
|
@@ -66,14 +67,21 @@ public final class ModuleDefinition: ObjectDefinition {
|
|
|
66
67
|
}
|
|
67
68
|
|
|
68
69
|
public override func build(appContext: AppContext) throws -> JavaScriptObject {
|
|
69
|
-
|
|
70
|
+
// Create an instance of `global.expo.NativeModule`
|
|
71
|
+
let object = JSIUtils.createNativeModuleObject(try appContext.runtime)
|
|
72
|
+
|
|
73
|
+
try super.decorate(object: object, appContext: appContext)
|
|
70
74
|
|
|
71
|
-
if let
|
|
72
|
-
let reactComponentPrototype = try
|
|
73
|
-
try viewManager.decorateWithFunctions(object: reactComponentPrototype, appContext: appContext)
|
|
75
|
+
if let viewDefinition = view {
|
|
76
|
+
let reactComponentPrototype = try viewDefinition.createReactComponentPrototype(appContext: appContext)
|
|
74
77
|
object.setProperty("ViewPrototype", value: reactComponentPrototype)
|
|
75
78
|
}
|
|
76
79
|
|
|
80
|
+
if !eventObservers.isEmpty {
|
|
81
|
+
try EventObservingDecorator(definitions: eventObservers)
|
|
82
|
+
.decorate(object: object, appContext: appContext)
|
|
83
|
+
}
|
|
84
|
+
|
|
77
85
|
// Give the module object a name. It's used for compatibility reasons, see `EventEmitter.ts`.
|
|
78
86
|
object.defineProperty("__expo_module_name__", value: name, options: [])
|
|
79
87
|
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
#if swift(>=5.4)
|
|
2
1
|
/**
|
|
3
2
|
A function builder that provides DSL-like syntax. Thanks to this, the function doesn't need to explicitly return an array,
|
|
4
|
-
but can just return multiple
|
|
3
|
+
but can just return multiple definitions one after another. This works similarly to SwiftUI's `body` block.
|
|
5
4
|
*/
|
|
6
5
|
@resultBuilder
|
|
7
6
|
public struct ModuleDefinitionBuilder {
|
|
@@ -9,4 +8,3 @@ public struct ModuleDefinitionBuilder {
|
|
|
9
8
|
return ModuleDefinition(definitions: definitions)
|
|
10
9
|
}
|
|
11
10
|
}
|
|
12
|
-
#endif
|
|
@@ -7,7 +7,7 @@ public class ObjectDefinition: AnyDefinition, JavaScriptObjectBuilder {
|
|
|
7
7
|
/**
|
|
8
8
|
A dictionary of functions defined by the object.
|
|
9
9
|
*/
|
|
10
|
-
let functions: [String:
|
|
10
|
+
let functions: [String: AnyFunctionDefinition]
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
An array of constants definitions.
|
|
@@ -17,20 +17,20 @@ public class ObjectDefinition: AnyDefinition, JavaScriptObjectBuilder {
|
|
|
17
17
|
/**
|
|
18
18
|
A map of dynamic properties defined by the object.
|
|
19
19
|
*/
|
|
20
|
-
let properties: [String:
|
|
20
|
+
let properties: [String: AnyPropertyDefinition]
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
23
|
A map of classes defined within the object.
|
|
24
24
|
*/
|
|
25
|
-
let classes: [String:
|
|
25
|
+
let classes: [String: ClassDefinition]
|
|
26
26
|
|
|
27
27
|
/**
|
|
28
28
|
Default initializer receiving children definitions from the result builder.
|
|
29
29
|
*/
|
|
30
30
|
init(definitions: [AnyDefinition]) {
|
|
31
31
|
self.functions = definitions
|
|
32
|
-
.compactMap { $0 as?
|
|
33
|
-
.reduce(into: [String:
|
|
32
|
+
.compactMap { $0 as? AnyFunctionDefinition }
|
|
33
|
+
.reduce(into: [String: AnyFunctionDefinition]()) { dict, function in
|
|
34
34
|
dict[function.name] = function
|
|
35
35
|
}
|
|
36
36
|
|
|
@@ -38,14 +38,14 @@ public class ObjectDefinition: AnyDefinition, JavaScriptObjectBuilder {
|
|
|
38
38
|
.compactMap { $0 as? ConstantsDefinition }
|
|
39
39
|
|
|
40
40
|
self.properties = definitions
|
|
41
|
-
.compactMap { $0 as?
|
|
42
|
-
.reduce(into: [String:
|
|
41
|
+
.compactMap { $0 as? AnyPropertyDefinition }
|
|
42
|
+
.reduce(into: [String: AnyPropertyDefinition]()) { dict, property in
|
|
43
43
|
dict[property.name] = property
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
self.classes = definitions
|
|
47
|
-
.compactMap { $0 as?
|
|
48
|
-
.reduce(into: [String:
|
|
47
|
+
.compactMap { $0 as? ClassDefinition }
|
|
48
|
+
.reduce(into: [String: ClassDefinition]()) { dict, klass in
|
|
49
49
|
dict[klass.name] = klass
|
|
50
50
|
}
|
|
51
51
|
}
|