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,173 +0,0 @@
|
|
|
1
|
-
package expo.modules.core;
|
|
2
|
-
|
|
3
|
-
import android.content.Context;
|
|
4
|
-
|
|
5
|
-
import expo.modules.core.interfaces.ExpoMethod;
|
|
6
|
-
import expo.modules.core.interfaces.RegistryLifecycleListener;
|
|
7
|
-
|
|
8
|
-
import java.lang.reflect.InvocationTargetException;
|
|
9
|
-
import java.lang.reflect.Method;
|
|
10
|
-
import java.util.ArrayList;
|
|
11
|
-
import java.util.Collection;
|
|
12
|
-
import java.util.Collections;
|
|
13
|
-
import java.util.HashMap;
|
|
14
|
-
import java.util.Iterator;
|
|
15
|
-
import java.util.List;
|
|
16
|
-
import java.util.Map;
|
|
17
|
-
|
|
18
|
-
/**
|
|
19
|
-
* Abstract class for exported modules, i. e. modules which export some methods to client code.
|
|
20
|
-
* Use {@link ExpoMethod} or override {@link ExportedModule#getExportedMethods()}
|
|
21
|
-
* to export specific methods to client code and then {@link ExportedModule#invokeExportedMethod(String, Collection)}
|
|
22
|
-
* to support them.
|
|
23
|
-
*/
|
|
24
|
-
public abstract class ExportedModule implements RegistryLifecycleListener {
|
|
25
|
-
public class MethodInfo {
|
|
26
|
-
private Class<?>[] mParameterTypes;
|
|
27
|
-
|
|
28
|
-
MethodInfo(Method method) {
|
|
29
|
-
mParameterTypes = method.getParameterTypes();
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
public Class<?>[] getParameterTypes() {
|
|
33
|
-
return mParameterTypes;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
private Context mContext;
|
|
38
|
-
private Map<String, Method> mExportedMethods;
|
|
39
|
-
private Map<String, MethodInfo> mExportedMethodInfos;
|
|
40
|
-
|
|
41
|
-
public ExportedModule(Context context) {
|
|
42
|
-
mContext = context;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
public abstract String getName();
|
|
46
|
-
|
|
47
|
-
public Map<String, Object> getConstants() {
|
|
48
|
-
return Collections.unmodifiableMap(Collections.<String, Object>emptyMap());
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
protected Context getContext() {
|
|
52
|
-
return mContext;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
/**
|
|
56
|
-
* Returns a map of { exportedMethodName => methodInfo } so that eg. platform adapter knows
|
|
57
|
-
* what classes of arguments does the method expect.
|
|
58
|
-
*/
|
|
59
|
-
public Map<String, MethodInfo> getExportedMethodInfos() {
|
|
60
|
-
if (mExportedMethodInfos != null) {
|
|
61
|
-
return mExportedMethodInfos;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
Map<String, MethodInfo> exportedMethodInfos = new HashMap<>();
|
|
65
|
-
for (Map.Entry<String, Method> entry : getExportedMethods().entrySet()) {
|
|
66
|
-
exportedMethodInfos.put(entry.getKey(), new MethodInfo(entry.getValue()));
|
|
67
|
-
}
|
|
68
|
-
mExportedMethodInfos = exportedMethodInfos;
|
|
69
|
-
return mExportedMethodInfos;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Invokes an exported method
|
|
74
|
-
*/
|
|
75
|
-
public Object invokeExportedMethod(String methodName, Collection<Object> arguments) throws NoSuchMethodException, RuntimeException {
|
|
76
|
-
Method method = mExportedMethods.get(methodName);
|
|
77
|
-
|
|
78
|
-
if (method == null) {
|
|
79
|
-
throw new NoSuchMethodException("Module " + getName() + "does not export method " + methodName + ".");
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
int expectedArgumentsCount = method.getParameterTypes().length;
|
|
83
|
-
if (arguments.size() != expectedArgumentsCount) {
|
|
84
|
-
throw new IllegalArgumentException(
|
|
85
|
-
"Method " + methodName + " on class " + getName() + " expects " + expectedArgumentsCount + " arguments, "
|
|
86
|
-
+ "whereas " + arguments.size() + " arguments have been provided.");
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
Class<?>[] expectedArgumentClasses = method.getParameterTypes();
|
|
90
|
-
Iterator<Object> actualArgumentsIterator = arguments.iterator();
|
|
91
|
-
List<Object> transformedArguments = new ArrayList<>(arguments.size());
|
|
92
|
-
|
|
93
|
-
for (int i = 0; i < expectedArgumentsCount; i++) {
|
|
94
|
-
transformedArguments.add(transformArgumentToClass(actualArgumentsIterator.next(), expectedArgumentClasses[i]));
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
try {
|
|
98
|
-
return method.invoke(this, transformedArguments.toArray());
|
|
99
|
-
} catch (IllegalAccessException e) {
|
|
100
|
-
e.printStackTrace();
|
|
101
|
-
throw new RuntimeException("Exception occurred while executing exported method " + methodName
|
|
102
|
-
+ " on module " + getName() + ": " + e.getMessage(), e);
|
|
103
|
-
} catch (InvocationTargetException e) {
|
|
104
|
-
e.printStackTrace();
|
|
105
|
-
throw new RuntimeException("Exception occurred while executing exported method " + methodName
|
|
106
|
-
+ " on module " + getName() + ": " + e.getCause().getMessage(), e.getCause());
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
protected Object transformArgumentToClass(Object argument, Class<?> expectedArgumentClass) {
|
|
111
|
-
return ArgumentsHelper.validatedArgumentForClass(argument, expectedArgumentClass);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* Creates or returns a cached String-keyed map of validated methods exported from {@link ExportedModule},
|
|
116
|
-
* i. e. methods annotated with {@link ExpoMethod}, which should be available in client code land.
|
|
117
|
-
*/
|
|
118
|
-
public Map<String, Method> getExportedMethods() {
|
|
119
|
-
if (mExportedMethods != null) {
|
|
120
|
-
return mExportedMethods;
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
mExportedMethods = new HashMap<>();
|
|
124
|
-
Class klass = getClass();
|
|
125
|
-
while (klass != null && ExportedModule.class.isAssignableFrom(klass)) {
|
|
126
|
-
Map<String, Method> exportedMethods = getExportedMethods(klass);
|
|
127
|
-
for (Map.Entry<String, Method> methodEntry : exportedMethods.entrySet()) {
|
|
128
|
-
// Do not overwrite methods from subclasses with methods from superclasses
|
|
129
|
-
// (We're iterating from the furthest subclass to ExportedModule.)
|
|
130
|
-
if (!mExportedMethods.containsKey(methodEntry.getKey())) {
|
|
131
|
-
mExportedMethods.put(methodEntry.getKey(), methodEntry.getValue());
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
klass = klass.getSuperclass();
|
|
135
|
-
}
|
|
136
|
-
return mExportedMethods;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
protected Map<String, Method> getExportedMethods(Class klass) {
|
|
140
|
-
Map<String, Method> exportedMethods = new HashMap<>();
|
|
141
|
-
Method[] declaredMethodsArray = klass.getDeclaredMethods();
|
|
142
|
-
|
|
143
|
-
for (Method method : declaredMethodsArray) {
|
|
144
|
-
if (method.getAnnotation(ExpoMethod.class) != null) {
|
|
145
|
-
String methodName = method.getName();
|
|
146
|
-
Class<?>[] methodParameterTypes = method.getParameterTypes();
|
|
147
|
-
if (methodParameterTypes.length < 1) {
|
|
148
|
-
throw new IllegalArgumentException(
|
|
149
|
-
"Method " + methodName + " of Java Module " + getName() + " does not define any arguments - minimum argument set is a Promise"
|
|
150
|
-
);
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
Class<?> lastParameterClass = methodParameterTypes[methodParameterTypes.length - 1];
|
|
154
|
-
|
|
155
|
-
if (lastParameterClass != Promise.class) {
|
|
156
|
-
throw new IllegalArgumentException(
|
|
157
|
-
"Last argument of method " + methodName + " of Java Module " + getName() + " does not expect a Promise"
|
|
158
|
-
);
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
if (exportedMethods.containsKey(methodName)) {
|
|
162
|
-
throw new IllegalArgumentException(
|
|
163
|
-
"Java Module " + getName() + " method name already registered: " + methodName + "."
|
|
164
|
-
);
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
exportedMethods.put(methodName, method);
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
return exportedMethods;
|
|
172
|
-
}
|
|
173
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
package expo.modules.core
|
|
2
|
-
|
|
3
|
-
class ModuleRegistryDelegate {
|
|
4
|
-
var moduleRegistry: ModuleRegistry? = null
|
|
5
|
-
private set
|
|
6
|
-
|
|
7
|
-
fun onCreate(moduleRegistry: ModuleRegistry) {
|
|
8
|
-
this.moduleRegistry = moduleRegistry
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
inline fun <reified T> getFromModuleRegistry() = lazy { moduleRegistry!!.getModule(T::class.java) }
|
|
12
|
-
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
package expo.modules.core;
|
|
2
|
-
|
|
3
|
-
import android.view.View;
|
|
4
|
-
|
|
5
|
-
import expo.modules.core.interfaces.RegistryLifecycleListener;
|
|
6
|
-
|
|
7
|
-
@Deprecated
|
|
8
|
-
// TODO(@lukmccall): Remove in the SDK 51. We leave it for now because that class was used in the unimodules package interface.
|
|
9
|
-
public abstract class ViewManager<V extends View> implements RegistryLifecycleListener { }
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
package expo.modules.core.interfaces;
|
|
2
|
-
|
|
3
|
-
import java.lang.annotation.Retention;
|
|
4
|
-
|
|
5
|
-
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Methods annotated with {@link ExpoMethod} will get exported to client code realm.
|
|
9
|
-
*/
|
|
10
|
-
@Retention(RUNTIME)
|
|
11
|
-
public @interface ExpoMethod {
|
|
12
|
-
}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
package expo.modules.core.logging
|
|
2
|
-
|
|
3
|
-
import java.util.*
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* A class defining the logging options that are currently supported.
|
|
7
|
-
* Future options may include writing to a DB or other destinations
|
|
8
|
-
*/
|
|
9
|
-
class LoggerOptions(
|
|
10
|
-
private val bitSet: BitSet
|
|
11
|
-
) {
|
|
12
|
-
|
|
13
|
-
fun contains(other: LoggerOptions): Boolean {
|
|
14
|
-
return bitSet.intersects(other.bitSet)
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
companion object {
|
|
18
|
-
val logToOS = LoggerOptions(BitSet.valueOf(longArrayOf(1L)))
|
|
19
|
-
val logToFile = LoggerOptions(BitSet.valueOf(longArrayOf(2L)))
|
|
20
|
-
|
|
21
|
-
fun union(loggerOptions: List<LoggerOptions>): LoggerOptions {
|
|
22
|
-
val result = BitSet.valueOf(longArrayOf(0L))
|
|
23
|
-
loggerOptions.forEach { loggerOption ->
|
|
24
|
-
result.or(loggerOption.bitSet)
|
|
25
|
-
}
|
|
26
|
-
return LoggerOptions(result)
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
apply plugin: 'java-library'
|
|
2
|
-
apply plugin: 'org.jetbrains.kotlin.jvm'
|
|
3
|
-
apply plugin: 'kotlin'
|
|
4
|
-
|
|
5
|
-
group = 'host.exp.exponent'
|
|
6
|
-
version = '1.1.1'
|
|
7
|
-
|
|
8
|
-
def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
|
|
9
|
-
if (expoModulesCorePlugin.exists()) {
|
|
10
|
-
apply from: expoModulesCorePlugin
|
|
11
|
-
applyKotlinExpoModulesCorePlugin()
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
buildscript {
|
|
15
|
-
// Simple helper that allows the root project to override versions declared by this library.
|
|
16
|
-
ext.safeExtGet = { prop, fallback ->
|
|
17
|
-
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
// Ensures backward compatibility
|
|
21
|
-
ext.getKotlinVersion = {
|
|
22
|
-
if (ext.has("kotlinVersion")) {
|
|
23
|
-
ext.kotlinVersion()
|
|
24
|
-
} else {
|
|
25
|
-
ext.safeExtGet("kotlinVersion", "1.6.10")
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
repositories {
|
|
30
|
-
mavenCentral()
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
dependencies {
|
|
34
|
-
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${getKotlinVersion()}")
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
def agpVersion = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION
|
|
39
|
-
if (agpVersion.tokenize('.')[0].toInteger() < 8) {
|
|
40
|
-
java {
|
|
41
|
-
sourceCompatibility = JavaVersion.VERSION_11
|
|
42
|
-
targetCompatibility = JavaVersion.VERSION_11
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
dependencies {
|
|
47
|
-
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${getKotlinVersion()}"
|
|
48
|
-
}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
apply plugin: 'java-library'
|
|
2
|
-
apply plugin: 'org.jetbrains.kotlin.jvm'
|
|
3
|
-
apply plugin: 'kotlin'
|
|
4
|
-
|
|
5
|
-
group = 'host.exp.exponent'
|
|
6
|
-
version = '1.1.1'
|
|
7
|
-
|
|
8
|
-
def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
|
|
9
|
-
if (expoModulesCorePlugin.exists()) {
|
|
10
|
-
apply from: expoModulesCorePlugin
|
|
11
|
-
applyKotlinExpoModulesCorePlugin()
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
buildscript {
|
|
15
|
-
// Simple helper that allows the root project to override versions declared by this library.
|
|
16
|
-
ext.safeExtGet = { prop, fallback ->
|
|
17
|
-
rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
// Ensures backward compatibility
|
|
21
|
-
ext.getKotlinVersion = {
|
|
22
|
-
if (ext.has("kotlinVersion")) {
|
|
23
|
-
ext.kotlinVersion()
|
|
24
|
-
} else {
|
|
25
|
-
ext.safeExtGet("kotlinVersion", "1.6.10")
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
repositories {
|
|
30
|
-
mavenCentral()
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
dependencies {
|
|
34
|
-
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${getKotlinVersion()}")
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
def agpVersion = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION
|
|
39
|
-
if (agpVersion.tokenize('.')[0].toInteger() < 8) {
|
|
40
|
-
java {
|
|
41
|
-
sourceCompatibility = JavaVersion.VERSION_11
|
|
42
|
-
targetCompatibility = JavaVersion.VERSION_11
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
dependencies {
|
|
47
|
-
implementation project(':expo-modules-core$android-annotation')
|
|
48
|
-
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:${getKotlinVersion()}"
|
|
49
|
-
|
|
50
|
-
implementation "com.google.devtools.ksp:symbol-processing-api:${kspVersion()}"
|
|
51
|
-
|
|
52
|
-
implementation 'com.squareup:kotlinpoet:1.12.0'
|
|
53
|
-
implementation 'com.squareup:kotlinpoet-ksp:1.12.0'
|
|
54
|
-
}
|
|
@@ -1,175 +0,0 @@
|
|
|
1
|
-
package expo.modules.annotationprocessor
|
|
2
|
-
|
|
3
|
-
import com.google.devtools.ksp.getVisibility
|
|
4
|
-
import com.google.devtools.ksp.processing.CodeGenerator
|
|
5
|
-
import com.google.devtools.ksp.processing.Dependencies
|
|
6
|
-
import com.google.devtools.ksp.processing.KSPLogger
|
|
7
|
-
import com.google.devtools.ksp.processing.Resolver
|
|
8
|
-
import com.google.devtools.ksp.processing.SymbolProcessor
|
|
9
|
-
import com.google.devtools.ksp.symbol.FunctionKind
|
|
10
|
-
import com.google.devtools.ksp.symbol.KSAnnotated
|
|
11
|
-
import com.google.devtools.ksp.symbol.KSFunctionDeclaration
|
|
12
|
-
import com.google.devtools.ksp.symbol.KSType
|
|
13
|
-
import com.google.devtools.ksp.symbol.KSVisitorVoid
|
|
14
|
-
import com.google.devtools.ksp.symbol.Visibility
|
|
15
|
-
import com.squareup.kotlinpoet.ClassName
|
|
16
|
-
import com.squareup.kotlinpoet.FileSpec
|
|
17
|
-
import com.squareup.kotlinpoet.FunSpec
|
|
18
|
-
import com.squareup.kotlinpoet.ParameterizedTypeName.Companion.parameterizedBy
|
|
19
|
-
import com.squareup.kotlinpoet.TypeSpec
|
|
20
|
-
import com.squareup.kotlinpoet.ksp.toClassName
|
|
21
|
-
import expo.modules.annotation.Config
|
|
22
|
-
import expo.modules.annotation.ConverterBinder
|
|
23
|
-
import java.io.OutputStreamWriter
|
|
24
|
-
import java.nio.charset.StandardCharsets
|
|
25
|
-
|
|
26
|
-
class ExpoSymbolProcessor(
|
|
27
|
-
private val codeGenerator: CodeGenerator,
|
|
28
|
-
private val logger: KSPLogger
|
|
29
|
-
) : SymbolProcessor {
|
|
30
|
-
override fun process(resolver: Resolver): List<KSAnnotated> {
|
|
31
|
-
val symbols = resolver
|
|
32
|
-
.getSymbolsWithAnnotation(ConverterBinder::class.java.name)
|
|
33
|
-
.filterIsInstance<KSFunctionDeclaration>()
|
|
34
|
-
|
|
35
|
-
if (symbols.iterator().hasNext().not()) {
|
|
36
|
-
return emptyList()
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
symbols.forEach { symbol ->
|
|
40
|
-
val clazz = symbol.annotations.find {
|
|
41
|
-
it.shortName.asString() == ConverterBinder::class.java.simpleName
|
|
42
|
-
}!!.arguments[0].value as KSType
|
|
43
|
-
|
|
44
|
-
val parsedClazz = if (clazz.toString() == "Void") {
|
|
45
|
-
null
|
|
46
|
-
} else {
|
|
47
|
-
clazz.toClassName()
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
symbol.accept(ConverterBinderVisitor(parsedClazz, codeGenerator, logger), Unit)
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
return emptyList()
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
class ConverterBinderVisitor(
|
|
58
|
-
private val clazz: ClassName?,
|
|
59
|
-
private val codeGenerator: CodeGenerator,
|
|
60
|
-
private val logger: KSPLogger
|
|
61
|
-
) : KSVisitorVoid() {
|
|
62
|
-
|
|
63
|
-
override fun visitFunctionDeclaration(function: KSFunctionDeclaration, data: Unit) {
|
|
64
|
-
if (function.functionKind != FunctionKind.TOP_LEVEL ||
|
|
65
|
-
function.getVisibility() != Visibility.PUBLIC
|
|
66
|
-
) {
|
|
67
|
-
logger.error("ConverterBinder has to be a public top-level function", function)
|
|
68
|
-
return
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
val resolvedType = resolveConverterType(function) ?: return
|
|
72
|
-
val shouldReceiveType = shouldReceiveType(function) ?: return
|
|
73
|
-
|
|
74
|
-
val packageName = "${Config.packageNamePrefix}${resolvedType.packageName}"
|
|
75
|
-
val className = "${resolvedType.simpleName}${Config.classNameSuffix}"
|
|
76
|
-
|
|
77
|
-
val content = generateConverterProvider(
|
|
78
|
-
packageName,
|
|
79
|
-
className,
|
|
80
|
-
function,
|
|
81
|
-
resolvedType,
|
|
82
|
-
shouldReceiveType
|
|
83
|
-
)
|
|
84
|
-
|
|
85
|
-
logger.info("Generating: $packageName.$className")
|
|
86
|
-
|
|
87
|
-
val file = codeGenerator.createNewFile(
|
|
88
|
-
createFileDependencies(function),
|
|
89
|
-
packageName,
|
|
90
|
-
className
|
|
91
|
-
)
|
|
92
|
-
OutputStreamWriter(file, StandardCharsets.UTF_8).use {
|
|
93
|
-
content.writeTo(it)
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
private fun shouldReceiveType(function: KSFunctionDeclaration): Boolean? {
|
|
98
|
-
val argsNumber = function.parameters.size
|
|
99
|
-
if (argsNumber != 0 && argsNumber != 1) {
|
|
100
|
-
logger.error("ConverterBinder cannot receive more then one argument", function)
|
|
101
|
-
return null
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
return function.parameters.firstOrNull()?.type?.toString() == "KType"
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
private fun createFileDependencies(function: KSFunctionDeclaration): Dependencies {
|
|
108
|
-
val containingFile = function.containingFile
|
|
109
|
-
return if (containingFile == null) {
|
|
110
|
-
Dependencies(false)
|
|
111
|
-
} else {
|
|
112
|
-
Dependencies(false, containingFile)
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
private fun resolveConverterType(function: KSFunctionDeclaration): ClassName? {
|
|
117
|
-
if (clazz != null) {
|
|
118
|
-
return clazz
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
val returnType = function.returnType?.resolve()
|
|
122
|
-
if (returnType == null) {
|
|
123
|
-
logger.error("Cannot resolve return type", function)
|
|
124
|
-
return null
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
if (returnType.arguments.size != 1) {
|
|
128
|
-
logger.error("Incorrect return type", function)
|
|
129
|
-
return null
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
val type = returnType.arguments.first().type?.resolve()
|
|
133
|
-
if (type == null) {
|
|
134
|
-
logger.error("Cannot resolve converter inner type", function)
|
|
135
|
-
return null
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
return type.toClassName()
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
private fun generateConverterProvider(
|
|
142
|
-
packageName: String,
|
|
143
|
-
className: String,
|
|
144
|
-
function: KSFunctionDeclaration,
|
|
145
|
-
forType: ClassName,
|
|
146
|
-
receivesType: Boolean
|
|
147
|
-
): FileSpec {
|
|
148
|
-
val typeConverter = ClassName("expo.modules.kotlin.types", "TypeConverter")
|
|
149
|
-
.parameterizedBy(forType)
|
|
150
|
-
val kType = ClassName("kotlin.reflect", "KType")
|
|
151
|
-
|
|
152
|
-
return FileSpec
|
|
153
|
-
.builder(packageName, className)
|
|
154
|
-
.addType(
|
|
155
|
-
TypeSpec
|
|
156
|
-
.classBuilder(className)
|
|
157
|
-
.addFunction(
|
|
158
|
-
FunSpec
|
|
159
|
-
.builder(Config.converterProviderFunctionName)
|
|
160
|
-
.addParameter("type", kType)
|
|
161
|
-
.returns(typeConverter)
|
|
162
|
-
.apply {
|
|
163
|
-
if (receivesType) {
|
|
164
|
-
addStatement("return ${function.packageName.asString()}.${function.simpleName.asString()}(type)")
|
|
165
|
-
} else {
|
|
166
|
-
addStatement("return ${function.packageName.asString()}.${function.simpleName.asString()}()")
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
.build()
|
|
170
|
-
)
|
|
171
|
-
.build()
|
|
172
|
-
)
|
|
173
|
-
.build()
|
|
174
|
-
}
|
|
175
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
package expo.modules.annotationprocessor
|
|
2
|
-
|
|
3
|
-
import com.google.devtools.ksp.processing.SymbolProcessor
|
|
4
|
-
import com.google.devtools.ksp.processing.SymbolProcessorEnvironment
|
|
5
|
-
import com.google.devtools.ksp.processing.SymbolProcessorProvider
|
|
6
|
-
|
|
7
|
-
class ExpoSymbolProcessorProvider : SymbolProcessorProvider {
|
|
8
|
-
override fun create(environment: SymbolProcessorEnvironment): SymbolProcessor =
|
|
9
|
-
ExpoSymbolProcessor(environment.codeGenerator, environment.logger)
|
|
10
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
expo.modules.annotationprocessor.ExpoSymbolProcessorProvider
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
// Copyright 2022-present 650 Industries. All rights reserved.
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
A type-erased protocol that must be implemented by the components passed as ``ClassComponent`` elements.
|
|
5
|
-
*/
|
|
6
|
-
public protocol AnyClassComponentElement: AnyDefinition {}
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
Class component element with an associated owner type. The `OwnerType` should refer to
|
|
10
|
-
the type that the parent `Class` component is associated with (e.g. the shared object type).
|
|
11
|
-
*/
|
|
12
|
-
public protocol ClassComponentElement: AnyClassComponentElement {
|
|
13
|
-
associatedtype OwnerType
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
// MARK: - Conformance
|
|
17
|
-
// Allow some other components to be used as the class component elements.
|
|
18
|
-
|
|
19
|
-
extension SyncFunctionComponent: ClassComponentElement {
|
|
20
|
-
public typealias OwnerType = FirstArgType
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
extension AsyncFunctionComponent: ClassComponentElement {
|
|
24
|
-
public typealias OwnerType = FirstArgType
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
extension ConcurrentFunctionDefinition: ClassComponentElement {
|
|
28
|
-
public typealias OwnerType = FirstArgType
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
extension PropertyComponent: ClassComponentElement {
|
|
32
|
-
// It already has the `OwnerType`
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
extension ConstantsDefinition: ClassComponentElement {
|
|
36
|
-
public typealias OwnerType = Void
|
|
37
|
-
}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
// Copyright 2022-present 650 Industries. All rights reserved.
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
A result builder that captures the ``ClassComponent`` elements such as functions, constants and properties.
|
|
5
|
-
*/
|
|
6
|
-
@resultBuilder
|
|
7
|
-
public struct ClassComponentElementsBuilder<OwnerType> {
|
|
8
|
-
public static func buildBlock(_ elements: AnyClassComponentElement...) -> [AnyClassComponentElement] {
|
|
9
|
-
return elements
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
/**
|
|
13
|
-
Default implementation without any constraints that just returns type-erased element.
|
|
14
|
-
*/
|
|
15
|
-
public static func buildExpression<ElementType: ClassComponentElement>(
|
|
16
|
-
_ element: ElementType
|
|
17
|
-
) -> AnyClassComponentElement {
|
|
18
|
-
return element
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
In case the element's owner type matches builder's generic type,
|
|
23
|
-
we need to instruct the function to pass `this` to the closure
|
|
24
|
-
as the first argument and deduct it from `argumentsCount`.
|
|
25
|
-
*/
|
|
26
|
-
public static func buildExpression<ElementType: ClassComponentElement>(
|
|
27
|
-
_ element: ElementType
|
|
28
|
-
) -> AnyClassComponentElement where ElementType.OwnerType == OwnerType {
|
|
29
|
-
if var function = element as? AnyFunction {
|
|
30
|
-
function.takesOwner = true
|
|
31
|
-
}
|
|
32
|
-
return element
|
|
33
|
-
}
|
|
34
|
-
}
|