expo-modules-core 0.10.0 → 0.11.2
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 +23 -0
- package/README.md +3 -3
- package/android/CMakeLists.txt +14 -5
- package/android/build.gradle +78 -28
- package/android/src/main/cpp/CachedReferencesRegistry.cpp +67 -0
- package/android/src/main/cpp/CachedReferencesRegistry.h +80 -0
- package/android/src/main/cpp/JNIFunctionBody.cpp +28 -12
- package/android/src/main/cpp/JNIFunctionBody.h +2 -2
- package/android/src/main/cpp/JNIInjector.cpp +4 -0
- package/android/src/main/cpp/JavaScriptModuleObject.cpp +86 -5
- package/android/src/main/cpp/JavaScriptModuleObject.h +27 -5
- package/android/src/main/cpp/JavaScriptRuntime.cpp +10 -12
- package/android/src/main/cpp/MethodMetadata.cpp +181 -40
- package/android/src/main/cpp/MethodMetadata.h +43 -3
- package/android/src/main/java/expo/modules/kotlin/AppContext.kt +63 -10
- package/android/src/main/java/expo/modules/kotlin/ModuleHolder.kt +6 -0
- package/android/src/main/java/expo/modules/kotlin/activityaware/AppCompatActivityAware.kt +49 -0
- package/android/src/main/java/expo/modules/kotlin/activityaware/AppCompatActivityAwareHelper.kt +43 -0
- package/android/src/main/java/expo/modules/kotlin/activityaware/OnActivityAvailableListener.kt +18 -0
- package/android/src/main/java/expo/modules/kotlin/activityresult/ActivityResultsManager.kt +99 -0
- package/android/src/main/java/expo/modules/kotlin/activityresult/AppContextActivityResultCaller.kt +25 -0
- package/android/src/main/java/expo/modules/kotlin/activityresult/AppContextActivityResultContract.kt +27 -0
- package/android/src/main/java/expo/modules/kotlin/activityresult/AppContextActivityResultFallbackCallback.kt +17 -0
- package/android/src/main/java/expo/modules/kotlin/activityresult/AppContextActivityResultLauncher.kt +30 -0
- package/android/src/main/java/expo/modules/kotlin/activityresult/AppContextActivityResultRegistry.kt +358 -0
- package/android/src/main/java/expo/modules/kotlin/activityresult/DataPersistor.kt +135 -0
- package/android/src/main/java/expo/modules/kotlin/functions/AnyFunction.kt +34 -1
- package/android/src/main/java/expo/modules/kotlin/functions/AsyncFunction.kt +7 -1
- package/android/src/main/java/expo/modules/kotlin/functions/AsyncFunctionBuilder.kt +0 -108
- package/android/src/main/java/expo/modules/kotlin/functions/AsyncFunctionComponent.kt +5 -2
- package/android/src/main/java/expo/modules/kotlin/functions/AsyncFunctionWithPromiseComponent.kt +5 -2
- package/android/src/main/java/expo/modules/kotlin/functions/SuspendFunctionComponent.kt +9 -2
- package/android/src/main/java/expo/modules/kotlin/functions/SyncFunctionComponent.kt +9 -1
- package/android/src/main/java/expo/modules/kotlin/jni/CppType.kt +1 -0
- package/android/src/main/java/expo/modules/kotlin/jni/JNIFunctionBody.kt +2 -2
- package/android/src/main/java/expo/modules/kotlin/jni/JavaScriptModuleObject.kt +4 -2
- package/android/src/main/java/expo/modules/kotlin/modules/Module.kt +1 -1
- package/android/src/main/java/expo/modules/kotlin/modules/ModuleDefinitionBuilder.kt +5 -454
- package/android/src/main/java/expo/modules/kotlin/modules/ModuleDefinitionData.kt +7 -15
- package/android/src/main/java/expo/modules/kotlin/objects/ObjectDefinitionBuilder.kt +271 -0
- package/android/src/main/java/expo/modules/kotlin/objects/ObjectDefinitionData.kt +21 -0
- package/android/src/main/java/expo/modules/kotlin/objects/PropertyComponent.kt +54 -0
- package/android/src/main/java/expo/modules/kotlin/objects/PropertyComponentBuilder.kt +32 -0
- package/android/src/main/java/expo/modules/kotlin/types/AnyTypeConverter.kt +36 -0
- package/android/src/main/java/expo/modules/kotlin/types/TypeConverterProvider.kt +7 -0
- package/android/src/main/java/expo/modules/kotlin/views/ViewGroupDefinitionBuilder.kt +0 -41
- package/android/src/main/java/expo/modules/kotlin/views/ViewManagerDefinitionBuilder.kt +0 -33
- package/build/PermissionsInterface.d.ts +29 -0
- package/build/PermissionsInterface.d.ts.map +1 -1
- package/build/PermissionsInterface.js +9 -0
- package/build/PermissionsInterface.js.map +1 -1
- package/ios/ExpoModulesCore.podspec +2 -1
- package/ios/JSI/EXJSIInstaller.mm +2 -0
- package/ios/JSI/EXJSIUtils.h +1 -0
- package/ios/NativeModulesProxy/EXNativeModulesProxy.mm +4 -3
- package/ios/Swift/AppContext.swift +2 -4
- package/ios/Swift/Classes/ClassComponentElementsBuilder.swift +2 -2
- package/ios/Swift/Exceptions/ChainableException.swift +3 -3
- package/ios/Swift/ExpoBridgeModule.swift +16 -2
- package/ios/Swift/Logging/Logger.swift +3 -0
- package/ios/Swift/Promise.swift +5 -1
- package/package.json +2 -2
- package/src/PermissionsInterface.ts +29 -0
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
// Copyright 2018-present 650 Industries. All rights reserved.
|
|
2
2
|
|
|
3
3
|
#import <ExpoModulesCore/EXJSIInstaller.h>
|
|
4
|
+
#import <ExpoModulesCore/EXJavaScriptRuntime.h>
|
|
4
5
|
#import <ExpoModulesCore/ExpoModulesHostObject.h>
|
|
5
6
|
#import <ExpoModulesCore/Swift.h>
|
|
6
7
|
|
|
@@ -14,6 +15,7 @@ static NSString *expoModulesHostObjectPropertyName = @"ExpoModules";
|
|
|
14
15
|
@interface RCTBridge (ExpoBridgeWithRuntime)
|
|
15
16
|
|
|
16
17
|
- (void *)runtime;
|
|
18
|
+
- (std::shared_ptr<facebook::react::CallInvoker>)jsCallInvoker;
|
|
17
19
|
|
|
18
20
|
@end
|
|
19
21
|
|
package/ios/JSI/EXJSIUtils.h
CHANGED
|
@@ -201,9 +201,10 @@ RCT_EXPORT_MODULE(NativeUnimoduleProxy)
|
|
|
201
201
|
|
|
202
202
|
- (void)setBridge:(RCTBridge *)bridge
|
|
203
203
|
{
|
|
204
|
-
|
|
205
|
-
[
|
|
206
|
-
|
|
204
|
+
ExpoBridgeModule* expoBridgeModule = [bridge moduleForClass:ExpoBridgeModule.class];
|
|
205
|
+
[expoBridgeModule legacyProxyDidSetBridgeWithLegacyModulesProxy:self
|
|
206
|
+
legacyModuleRegistry:_exModuleRegistry];
|
|
207
|
+
_appContext = [expoBridgeModule appContext];
|
|
207
208
|
|
|
208
209
|
if (!_bridge) {
|
|
209
210
|
// The `setBridge` can be called during module setup or after. Registering more modules
|
|
@@ -28,11 +28,9 @@ public final class AppContext: NSObject {
|
|
|
28
28
|
/**
|
|
29
29
|
The legacy module registry with modules written in the old-fashioned way.
|
|
30
30
|
*/
|
|
31
|
-
|
|
32
|
-
public weak var legacyModuleRegistry: EXModuleRegistry?
|
|
31
|
+
internal weak var legacyModuleRegistry: EXModuleRegistry?
|
|
33
32
|
|
|
34
|
-
|
|
35
|
-
public weak var legacyModulesProxy: LegacyNativeModulesProxy?
|
|
33
|
+
internal weak var legacyModulesProxy: LegacyNativeModulesProxy?
|
|
36
34
|
|
|
37
35
|
/**
|
|
38
36
|
React bridge of the context's app. Can be `nil` when the bridge
|
|
@@ -12,7 +12,7 @@ public struct ClassComponentElementsBuilder<OwnerType> {
|
|
|
12
12
|
/**
|
|
13
13
|
Default implementation without any constraints that just returns type-erased element.
|
|
14
14
|
*/
|
|
15
|
-
static func buildExpression<ElementType: ClassComponentElement>(
|
|
15
|
+
public static func buildExpression<ElementType: ClassComponentElement>(
|
|
16
16
|
_ element: ElementType
|
|
17
17
|
) -> AnyClassComponentElement {
|
|
18
18
|
return element
|
|
@@ -23,7 +23,7 @@ public struct ClassComponentElementsBuilder<OwnerType> {
|
|
|
23
23
|
we need to instruct the function to pass `this` to the closure
|
|
24
24
|
as the first argument and deduct it from `argumentsCount`.
|
|
25
25
|
*/
|
|
26
|
-
static func buildExpression<ElementType: ClassComponentElement>(
|
|
26
|
+
public static func buildExpression<ElementType: ClassComponentElement>(
|
|
27
27
|
_ element: ElementType
|
|
28
28
|
) -> AnyClassComponentElement where ElementType.OwnerType == OwnerType {
|
|
29
29
|
if var function = element as? AnyFunction {
|
|
@@ -17,7 +17,7 @@ public protocol ChainableException: Error, AnyObject {
|
|
|
17
17
|
/**
|
|
18
18
|
Sets the direct cause of the exception and returns itself.
|
|
19
19
|
*/
|
|
20
|
-
func causedBy(_ error: Error) -> Self
|
|
20
|
+
func causedBy(_ error: Error?) -> Self
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
23
|
Tells whether any of the cause in chain is of given type.
|
|
@@ -34,8 +34,8 @@ public extension ChainableException {
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
@discardableResult
|
|
37
|
-
func causedBy(_ error: Error) -> Self {
|
|
38
|
-
cause = error
|
|
37
|
+
func causedBy(_ error: Error?) -> Self {
|
|
38
|
+
cause = error ?? cause
|
|
39
39
|
return self
|
|
40
40
|
}
|
|
41
41
|
|
|
@@ -20,8 +20,7 @@ public final class ExpoBridgeModule: NSObject, RCTBridgeModule {
|
|
|
20
20
|
architecture of Expo modules and the app itself.
|
|
21
21
|
*/
|
|
22
22
|
override init() {
|
|
23
|
-
appContext = AppContext()
|
|
24
|
-
appContext.moduleRegistry.register(moduleType: NativeModulesProxyModule.self)
|
|
23
|
+
appContext = AppContext()
|
|
25
24
|
super.init()
|
|
26
25
|
|
|
27
26
|
// Listen to React Native notifications posted just before the JS is executed.
|
|
@@ -50,6 +49,21 @@ public final class ExpoBridgeModule: NSObject, RCTBridgeModule {
|
|
|
50
49
|
appContext.reactBridge = bridge
|
|
51
50
|
}
|
|
52
51
|
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
This should be called inside EXNativeModulesProxy.setBridge()
|
|
55
|
+
*/
|
|
56
|
+
@objc
|
|
57
|
+
public func legacyProxyDidSetBridge(legacyModulesProxy: LegacyNativeModulesProxy,
|
|
58
|
+
legacyModuleRegistry: EXModuleRegistry) {
|
|
59
|
+
appContext.legacyModuleRegistry = legacyModuleRegistry
|
|
60
|
+
appContext.legacyModulesProxy = legacyModulesProxy
|
|
61
|
+
|
|
62
|
+
// we need to register all the modules after the legacy module registry is set
|
|
63
|
+
// otherwise legacy modules (e.g. permissions) won't be available in OnCreate { }
|
|
64
|
+
appContext.useModulesProvider("ExpoModulesProvider")
|
|
65
|
+
appContext.moduleRegistry.register(moduleType: NativeModulesProxyModule.self)
|
|
66
|
+
}
|
|
53
67
|
|
|
54
68
|
// MARK: - Notifications
|
|
55
69
|
|
|
@@ -188,6 +188,9 @@ fileprivate func reformatStackSymbol(_ symbol: String) -> String {
|
|
|
188
188
|
}
|
|
189
189
|
|
|
190
190
|
fileprivate func describe(value: Any) -> String {
|
|
191
|
+
if let value = value as? String {
|
|
192
|
+
return value
|
|
193
|
+
}
|
|
191
194
|
if let value = value as? CustomDebugStringConvertible {
|
|
192
195
|
return value.debugDescription
|
|
193
196
|
}
|
package/ios/Swift/Promise.swift
CHANGED
|
@@ -22,7 +22,11 @@ public struct Promise: AnyArgument {
|
|
|
22
22
|
}
|
|
23
23
|
|
|
24
24
|
public func reject(_ error: Error) {
|
|
25
|
-
|
|
25
|
+
if let exception = error as? Exception {
|
|
26
|
+
rejecter(exception)
|
|
27
|
+
} else {
|
|
28
|
+
rejecter(UnexpectedException(error))
|
|
29
|
+
}
|
|
26
30
|
}
|
|
27
31
|
|
|
28
32
|
public func reject(_ error: Exception) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-modules-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.11.2",
|
|
4
4
|
"description": "The core of Expo Modules architecture",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -42,5 +42,5 @@
|
|
|
42
42
|
"@testing-library/react-hooks": "^7.0.1",
|
|
43
43
|
"expo-module-scripts": "^2.0.0"
|
|
44
44
|
},
|
|
45
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "c6678c65b68e45062d49a2deea8e822f69388278"
|
|
46
46
|
}
|
|
@@ -1,14 +1,43 @@
|
|
|
1
1
|
export enum PermissionStatus {
|
|
2
|
+
/**
|
|
3
|
+
* User has granted the permission.
|
|
4
|
+
*/
|
|
2
5
|
GRANTED = 'granted',
|
|
6
|
+
/**
|
|
7
|
+
* User hasn't granted or denied the permission yet.
|
|
8
|
+
*/
|
|
3
9
|
UNDETERMINED = 'undetermined',
|
|
10
|
+
/**
|
|
11
|
+
* User has denied the permission.
|
|
12
|
+
*/
|
|
4
13
|
DENIED = 'denied',
|
|
5
14
|
}
|
|
6
15
|
|
|
16
|
+
/**
|
|
17
|
+
* Permission expiration time. Currently, all permissions are granted permamently.
|
|
18
|
+
*/
|
|
7
19
|
export type PermissionExpiration = 'never' | number;
|
|
8
20
|
|
|
21
|
+
/**
|
|
22
|
+
* An object obtained by `getPermissionsAsync` and `requestPermissionsAsync` functions.
|
|
23
|
+
*/
|
|
9
24
|
export interface PermissionResponse {
|
|
25
|
+
/**
|
|
26
|
+
* Determines the status of the permission.
|
|
27
|
+
*/
|
|
10
28
|
status: PermissionStatus;
|
|
29
|
+
/**
|
|
30
|
+
* Determines time when the permission expires.
|
|
31
|
+
*/
|
|
11
32
|
expires: PermissionExpiration;
|
|
33
|
+
/**
|
|
34
|
+
* A convenience boolean that indicates if the permission is granted.
|
|
35
|
+
*/
|
|
12
36
|
granted: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* Indicates if user can be asked again for specific permission.
|
|
39
|
+
* If not, one should be directed to the Settings app
|
|
40
|
+
* in order to enable/disable the permission.
|
|
41
|
+
*/
|
|
13
42
|
canAskAgain: boolean;
|
|
14
43
|
}
|