one 2.6.18 → 2.6.19
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/One.podspec +2 -0
- package/android/src/main/java/com/margelo/nitro/one/HybridOneDevice.kt +124 -0
- package/android/src/main/java/com/margelo/nitro/one/HybridOneHaptics.kt +31 -0
- package/android/src/main/java/com/margelo/nitro/one/HybridOneImageManipulator.kt +25 -5
- package/android/src/main/java/com/margelo/nitro/one/HybridOneKeepAwake.kt +34 -9
- package/android/src/main/java/com/margelo/nitro/one/HybridOneSecureStore.kt +269 -78
- package/dist/cjs/index.cjs +3 -0
- package/dist/cjs/index.native.cjs +3 -0
- package/dist/cjs/index.native.js +3 -0
- package/dist/cjs/index.native.js.map +1 -1
- package/dist/cjs/one.cjs +1 -0
- package/dist/cjs/one.native.cjs +1 -0
- package/dist/cjs/one.native.js +1 -0
- package/dist/cjs/one.native.js.map +1 -1
- package/dist/cjs/platform/extras.cjs +4 -0
- package/dist/cjs/platform/extras.native.cjs +4 -0
- package/dist/cjs/platform/extras.native.js +4 -0
- package/dist/cjs/platform/extras.native.js.map +1 -1
- package/dist/cjs/platform/haptics/index.cjs +3 -0
- package/dist/cjs/platform/haptics/index.native.cjs +4 -0
- package/dist/cjs/platform/haptics/index.native.js +4 -0
- package/dist/cjs/platform/haptics/index.native.js.map +1 -1
- package/dist/cjs/platform/haptics/validation.cjs +28 -0
- package/dist/cjs/platform/haptics/validation.native.cjs +28 -0
- package/dist/cjs/platform/haptics/validation.native.js +28 -0
- package/dist/cjs/platform/haptics/validation.native.js.map +1 -1
- package/dist/cjs/platform/image-manipulator/index.cjs +10 -3
- package/dist/cjs/platform/image-manipulator/index.native.cjs +1 -0
- package/dist/cjs/platform/image-manipulator/index.native.js +1 -0
- package/dist/cjs/platform/image-manipulator/index.native.js.map +1 -1
- package/dist/cjs/platform/index.cjs +1 -0
- package/dist/cjs/platform/index.native.cjs +1 -0
- package/dist/cjs/platform/index.native.js +1 -0
- package/dist/cjs/platform/index.native.js.map +1 -1
- package/dist/cjs/platform/keep-awake/index.cjs +53 -14
- package/dist/cjs/platform/keep-awake/index.native.cjs +29 -2
- package/dist/cjs/platform/keep-awake/index.native.js +29 -2
- package/dist/cjs/platform/keep-awake/index.native.js.map +1 -1
- package/dist/cjs/platform/keep-awake/unavailable.cjs +11 -1
- package/dist/cjs/platform/keep-awake/unavailable.native.cjs +11 -1
- package/dist/cjs/platform/keep-awake/unavailable.native.js +11 -1
- package/dist/cjs/platform/keep-awake/unavailable.native.js.map +1 -1
- package/dist/cjs/platform/keep-awake/validate.cjs +15 -1
- package/dist/cjs/platform/keep-awake/validate.native.cjs +15 -1
- package/dist/cjs/platform/keep-awake/validate.native.js +15 -1
- package/dist/cjs/platform/keep-awake/validate.native.js.map +1 -1
- package/dist/cjs/platform/localization/index.cjs +100 -0
- package/dist/cjs/platform/localization/index.native.cjs +71 -0
- package/dist/cjs/platform/localization/index.native.js +73 -0
- package/dist/cjs/platform/localization/index.native.js.map +1 -0
- package/dist/cjs/platform/localization/map.cjs +86 -0
- package/dist/cjs/platform/localization/map.native.cjs +90 -0
- package/dist/cjs/platform/localization/map.native.js +92 -0
- package/dist/cjs/platform/localization/map.native.js.map +1 -0
- package/dist/cjs/platform/localization/types.cjs +16 -0
- package/dist/cjs/platform/localization/types.native.cjs +18 -0
- package/dist/cjs/platform/localization/types.native.js +20 -0
- package/dist/cjs/platform/localization/types.native.js.map +1 -0
- package/dist/cjs/platform/secure-store/index.cjs +12 -6
- package/dist/cjs/platform/secure-store/index.native.cjs +18 -12
- package/dist/cjs/platform/secure-store/index.native.js +18 -12
- package/dist/cjs/platform/secure-store/index.native.js.map +1 -1
- package/dist/cjs/platform/secure-store/types.cjs +16 -0
- package/dist/cjs/platform/secure-store/types.native.cjs +18 -0
- package/dist/cjs/platform/secure-store/types.native.js +20 -0
- package/dist/cjs/platform/secure-store/types.native.js.map +1 -0
- package/dist/cjs/platform/secure-store/validate.cjs +34 -0
- package/dist/cjs/platform/secure-store/validate.native.cjs +34 -0
- package/dist/cjs/platform/secure-store/validate.native.js +34 -0
- package/dist/cjs/platform/secure-store/validate.native.js.map +1 -1
- package/dist/esm/index.js +2 -2
- package/dist/esm/index.mjs +2 -2
- package/dist/esm/index.native.js +2 -2
- package/dist/esm/one.mjs +2 -1
- package/dist/esm/one.mjs.map +1 -1
- package/dist/esm/one.native.js +2 -1
- package/dist/esm/one.native.js.map +1 -1
- package/dist/esm/platform/extras.mjs +2 -1
- package/dist/esm/platform/extras.native.js +2 -1
- package/dist/esm/platform/haptics/index.mjs +4 -1
- package/dist/esm/platform/haptics/index.mjs.map +1 -1
- package/dist/esm/platform/haptics/index.native.js +5 -1
- package/dist/esm/platform/haptics/index.native.js.map +1 -1
- package/dist/esm/platform/haptics/validation.mjs +27 -1
- package/dist/esm/platform/haptics/validation.mjs.map +1 -1
- package/dist/esm/platform/haptics/validation.native.js +27 -1
- package/dist/esm/platform/haptics/validation.native.js.map +1 -1
- package/dist/esm/platform/image-manipulator/index.mjs +10 -3
- package/dist/esm/platform/image-manipulator/index.mjs.map +1 -1
- package/dist/esm/platform/image-manipulator/index.native.js +1 -0
- package/dist/esm/platform/image-manipulator/index.native.js.map +1 -1
- package/dist/esm/platform/index.mjs +2 -2
- package/dist/esm/platform/index.mjs.map +1 -1
- package/dist/esm/platform/index.native.js +2 -2
- package/dist/esm/platform/index.native.js.map +1 -1
- package/dist/esm/platform/keep-awake/index.mjs +51 -15
- package/dist/esm/platform/keep-awake/index.mjs.map +1 -1
- package/dist/esm/platform/keep-awake/index.native.js +27 -3
- package/dist/esm/platform/keep-awake/index.native.js.map +1 -1
- package/dist/esm/platform/keep-awake/unavailable.mjs +12 -2
- package/dist/esm/platform/keep-awake/unavailable.mjs.map +1 -1
- package/dist/esm/platform/keep-awake/unavailable.native.js +12 -2
- package/dist/esm/platform/keep-awake/unavailable.native.js.map +1 -1
- package/dist/esm/platform/keep-awake/validate.mjs +10 -1
- package/dist/esm/platform/keep-awake/validate.mjs.map +1 -1
- package/dist/esm/platform/keep-awake/validate.native.js +10 -1
- package/dist/esm/platform/keep-awake/validate.native.js.map +1 -1
- package/dist/esm/platform/localization/index.mjs +77 -0
- package/dist/esm/platform/localization/index.mjs.map +1 -0
- package/dist/esm/platform/localization/index.native.js +46 -0
- package/dist/esm/platform/localization/index.native.js.map +1 -0
- package/dist/esm/platform/localization/map.mjs +59 -0
- package/dist/esm/platform/localization/map.mjs.map +1 -0
- package/dist/esm/platform/localization/map.native.js +61 -0
- package/dist/esm/platform/localization/map.native.js.map +1 -0
- package/dist/esm/platform/localization/types.mjs +0 -0
- package/dist/esm/platform/localization/types.native.js +0 -0
- package/dist/esm/platform/secure-store/index.mjs +13 -7
- package/dist/esm/platform/secure-store/index.mjs.map +1 -1
- package/dist/esm/platform/secure-store/index.native.js +19 -13
- package/dist/esm/platform/secure-store/index.native.js.map +1 -1
- package/dist/esm/platform/secure-store/types.mjs +0 -0
- package/dist/esm/platform/secure-store/types.native.js +0 -0
- package/dist/esm/platform/secure-store/validate.mjs +33 -1
- package/dist/esm/platform/secure-store/validate.mjs.map +1 -1
- package/dist/esm/platform/secure-store/validate.native.js +33 -1
- package/dist/esm/platform/secure-store/validate.native.js.map +1 -1
- package/ios/Nitro/HybridOneDevice.swift +117 -0
- package/ios/Nitro/HybridOneHaptics.swift +4 -0
- package/ios/Nitro/HybridOneImageManipulator.swift +25 -8
- package/ios/Nitro/HybridOneKeepAwake.swift +34 -2
- package/ios/Nitro/HybridOneSecureStore.swift +112 -46
- package/ios/Tests/ImageManipulator/Package.swift +12 -0
- package/ios/Tests/ImageManipulator/README.md +21 -0
- package/ios/Tests/ImageManipulator/Sources/NitroModules/Promise.swift +33 -0
- package/ios/Tests/ImageManipulator/Sources/OneImageManipulatorCore/Types.swift +41 -0
- package/ios/Tests/ImageManipulator/Sources/SDWebImageWebPCoder/SDImageWebPCoder.swift +23 -0
- package/nitrogen/generated/android/c++/JAndroidHaptic.hpp +109 -0
- package/nitrogen/generated/android/c++/JCalendarInfo.hpp +70 -0
- package/nitrogen/generated/android/c++/JHapticImpact.hpp +3 -3
- package/nitrogen/generated/android/c++/JHybridOneDeviceSpec.cpp +52 -0
- package/nitrogen/generated/android/c++/JHybridOneDeviceSpec.hpp +3 -0
- package/nitrogen/generated/android/c++/JHybridOneHapticsSpec.cpp +8 -0
- package/nitrogen/generated/android/c++/JHybridOneHapticsSpec.hpp +1 -0
- package/nitrogen/generated/android/c++/JHybridOneImageManipulatorSpec.cpp +5 -1
- package/nitrogen/generated/android/c++/JHybridOneKeepAwakeSpec.cpp +31 -0
- package/nitrogen/generated/android/c++/JHybridOneKeepAwakeSpec.hpp +2 -0
- package/nitrogen/generated/android/c++/JHybridOneSecureStoreSpec.cpp +26 -19
- package/nitrogen/generated/android/c++/JHybridOneSecureStoreSpec.hpp +6 -6
- package/nitrogen/generated/android/c++/JImageTransformOptions.hpp +7 -1
- package/nitrogen/generated/android/c++/JLocaleInfo.hpp +110 -0
- package/nitrogen/generated/android/c++/JOneImageFlip.hpp +58 -0
- package/nitrogen/generated/android/c++/JOneImageFormat.hpp +3 -0
- package/nitrogen/generated/android/c++/JSecureStoreAccessibility.hpp +73 -0
- package/nitrogen/generated/android/c++/JSecureStoreOptions.hpp +76 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/one/AndroidHaptic.kt +40 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/one/CalendarInfo.kt +66 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/one/HapticImpact.kt +2 -2
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/one/HybridOneDeviceSpec.kt +17 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/one/HybridOneHapticsSpec.kt +4 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/one/HybridOneKeepAwakeSpec.kt +8 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/one/HybridOneSecureStoreSpec.kt +6 -6
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/one/ImageTransformOptions.kt +7 -2
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/one/LocaleInfo.kt +116 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/one/OneImageFlip.kt +23 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/one/OneImageFormat.kt +2 -1
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/one/SecureStoreAccessibility.kt +28 -0
- package/nitrogen/generated/android/kotlin/com/margelo/nitro/one/SecureStoreOptions.kt +71 -0
- package/nitrogen/generated/ios/One-Swift-Cxx-Bridge.hpp +133 -51
- package/nitrogen/generated/ios/One-Swift-Cxx-Umbrella.hpp +19 -1
- package/nitrogen/generated/ios/c++/HybridOneDeviceSpecSwift.hpp +31 -0
- package/nitrogen/generated/ios/c++/HybridOneHapticsSpecSwift.hpp +9 -0
- package/nitrogen/generated/ios/c++/HybridOneImageManipulatorSpecSwift.hpp +4 -1
- package/nitrogen/generated/ios/c++/HybridOneKeepAwakeSpecSwift.hpp +18 -1
- package/nitrogen/generated/ios/c++/HybridOneSecureStoreSpecSwift.hpp +18 -13
- package/nitrogen/generated/ios/swift/AndroidHaptic.swift +108 -0
- package/nitrogen/generated/ios/swift/CalendarInfo.swift +96 -0
- package/nitrogen/generated/ios/swift/HapticImpact.swift +4 -4
- package/nitrogen/generated/ios/swift/HybridOneDeviceSpec.swift +3 -0
- package/nitrogen/generated/ios/swift/HybridOneDeviceSpec_cxx.swift +56 -0
- package/nitrogen/generated/ios/swift/HybridOneHapticsSpec.swift +1 -0
- package/nitrogen/generated/ios/swift/HybridOneHapticsSpec_cxx.swift +11 -0
- package/nitrogen/generated/ios/swift/HybridOneKeepAwakeSpec.swift +3 -1
- package/nitrogen/generated/ios/swift/HybridOneKeepAwakeSpec_cxx.swift +41 -3
- package/nitrogen/generated/ios/swift/HybridOneSecureStoreSpec.swift +6 -6
- package/nitrogen/generated/ios/swift/HybridOneSecureStoreSpec_cxx.swift +12 -12
- package/nitrogen/generated/ios/swift/ImageTransformOptions.swift +16 -5
- package/nitrogen/generated/ios/swift/LocaleInfo.swift +250 -0
- package/nitrogen/generated/ios/swift/OneImageFlip.swift +40 -0
- package/nitrogen/generated/ios/swift/OneImageFormat.swift +4 -0
- package/nitrogen/generated/ios/swift/SecureStoreAccessibility.swift +60 -0
- package/nitrogen/generated/ios/swift/SecureStoreOptions.swift +107 -0
- package/nitrogen/generated/shared/c++/AndroidHaptic.hpp +144 -0
- package/nitrogen/generated/shared/c++/CalendarInfo.hpp +96 -0
- package/nitrogen/generated/shared/c++/HapticImpact.hpp +5 -5
- package/nitrogen/generated/shared/c++/HybridOneDeviceSpec.cpp +3 -0
- package/nitrogen/generated/shared/c++/HybridOneDeviceSpec.hpp +11 -0
- package/nitrogen/generated/shared/c++/HybridOneHapticsSpec.cpp +1 -0
- package/nitrogen/generated/shared/c++/HybridOneHapticsSpec.hpp +4 -0
- package/nitrogen/generated/shared/c++/HybridOneKeepAwakeSpec.cpp +2 -0
- package/nitrogen/generated/shared/c++/HybridOneKeepAwakeSpec.hpp +4 -1
- package/nitrogen/generated/shared/c++/HybridOneSecureStoreSpec.hpp +9 -7
- package/nitrogen/generated/shared/c++/ImageTransformOptions.hpp +8 -1
- package/nitrogen/generated/shared/c++/LocaleInfo.hpp +136 -0
- package/nitrogen/generated/shared/c++/OneImageFlip.hpp +76 -0
- package/nitrogen/generated/shared/c++/OneImageFormat.hpp +4 -0
- package/nitrogen/generated/shared/c++/SecureStoreAccessibility.hpp +96 -0
- package/nitrogen/generated/shared/c++/SecureStoreOptions.hpp +102 -0
- package/package.json +15 -15
- package/src/index.ts +3 -0
- package/src/one.test.ts +2 -0
- package/src/one.ts +3 -0
- package/src/platform/extras.ts +3 -0
- package/src/platform/haptics/index.native.ts +13 -3
- package/src/platform/haptics/index.ts +12 -3
- package/src/platform/haptics/types.ts +25 -0
- package/src/platform/haptics/validation.ts +31 -1
- package/src/platform/image-manipulator/index.native.ts +3 -0
- package/src/platform/image-manipulator/index.ts +10 -3
- package/src/platform/index.native.ts +3 -2
- package/src/platform/index.ts +3 -2
- package/src/platform/keep-awake/index.native.ts +31 -2
- package/src/platform/keep-awake/index.ts +66 -17
- package/src/platform/keep-awake/unavailable.ts +12 -2
- package/src/platform/keep-awake/validate.ts +16 -0
- package/src/platform/localization/index.native.ts +47 -0
- package/src/platform/localization/index.ts +90 -0
- package/src/platform/localization/map.ts +77 -0
- package/src/platform/localization/types.ts +36 -0
- package/src/platform/secure-store/index.native.ts +26 -13
- package/src/platform/secure-store/index.ts +20 -7
- package/src/platform/secure-store/types.ts +33 -0
- package/src/platform/secure-store/validate.ts +48 -0
- package/src/platform/specs/OneDevice.nitro.ts +34 -0
- package/src/platform/specs/OneHaptics.nitro.ts +4 -1
- package/src/platform/specs/OneImageManipulator.nitro.ts +4 -1
- package/src/platform/specs/OneKeepAwake.nitro.ts +2 -0
- package/src/platform/specs/OneSecureStore.nitro.ts +12 -8
- package/types/index.d.ts +1 -1
- package/types/index.d.ts.map +1 -1
- package/types/one.d.ts +2 -1
- package/types/one.d.ts.map +1 -1
- package/types/platform/extras.d.ts +3 -0
- package/types/platform/extras.d.ts.map +1 -1
- package/types/platform/haptics/index.d.ts +2 -2
- package/types/platform/haptics/index.d.ts.map +1 -1
- package/types/platform/haptics/index.native.d.ts +2 -2
- package/types/platform/haptics/index.native.d.ts.map +1 -1
- package/types/platform/haptics/types.d.ts +3 -0
- package/types/platform/haptics/types.d.ts.map +1 -1
- package/types/platform/haptics/validation.d.ts +3 -1
- package/types/platform/haptics/validation.d.ts.map +1 -1
- package/types/platform/image-manipulator/index.d.ts +1 -1
- package/types/platform/image-manipulator/index.d.ts.map +1 -1
- package/types/platform/image-manipulator/index.native.d.ts +1 -1
- package/types/platform/image-manipulator/index.native.d.ts.map +1 -1
- package/types/platform/index.d.ts +3 -3
- package/types/platform/index.d.ts.map +1 -1
- package/types/platform/index.native.d.ts +3 -3
- package/types/platform/index.native.d.ts.map +1 -1
- package/types/platform/keep-awake/index.d.ts +3 -0
- package/types/platform/keep-awake/index.d.ts.map +1 -1
- package/types/platform/keep-awake/index.native.d.ts +5 -0
- package/types/platform/keep-awake/index.native.d.ts.map +1 -1
- package/types/platform/keep-awake/unavailable.d.ts +4 -0
- package/types/platform/keep-awake/unavailable.d.ts.map +1 -1
- package/types/platform/keep-awake/validate.d.ts +3 -0
- package/types/platform/keep-awake/validate.d.ts.map +1 -1
- package/types/platform/localization/index.d.ts +7 -0
- package/types/platform/localization/index.d.ts.map +1 -0
- package/types/platform/localization/index.native.d.ts +7 -0
- package/types/platform/localization/index.native.d.ts.map +1 -0
- package/types/platform/localization/map.d.ts +9 -0
- package/types/platform/localization/map.d.ts.map +1 -0
- package/types/platform/localization/types.d.ts +31 -0
- package/types/platform/localization/types.d.ts.map +1 -0
- package/types/platform/secure-store/index.d.ts +8 -7
- package/types/platform/secure-store/index.d.ts.map +1 -1
- package/types/platform/secure-store/index.native.d.ts +8 -7
- package/types/platform/secure-store/index.native.d.ts.map +1 -1
- package/types/platform/secure-store/types.d.ts +24 -0
- package/types/platform/secure-store/types.d.ts.map +1 -0
- package/types/platform/secure-store/validate.d.ts +3 -0
- package/types/platform/secure-store/validate.d.ts.map +1 -1
- package/types/platform/specs/OneDevice.nitro.d.ts +25 -0
- package/types/platform/specs/OneDevice.nitro.d.ts.map +1 -1
- package/types/platform/specs/OneHaptics.nitro.d.ts +2 -1
- package/types/platform/specs/OneHaptics.nitro.d.ts.map +1 -1
- package/types/platform/specs/OneImageManipulator.nitro.d.ts +3 -1
- package/types/platform/specs/OneImageManipulator.nitro.d.ts.map +1 -1
- package/types/platform/specs/OneKeepAwake.nitro.d.ts +2 -0
- package/types/platform/specs/OneKeepAwake.nitro.d.ts.map +1 -1
- package/types/platform/specs/OneSecureStore.nitro.d.ts +8 -6
- package/types/platform/specs/OneSecureStore.nitro.d.ts.map +1 -1
|
@@ -1,24 +1,67 @@
|
|
|
1
1
|
import Foundation
|
|
2
|
+
import LocalAuthentication
|
|
2
3
|
import NitroModules
|
|
3
4
|
import Security
|
|
4
5
|
|
|
5
|
-
// string key-value storage matching expo-secure-store's item api
|
|
6
|
-
// the keychain: generic-password items keyed by account
|
|
7
|
-
//
|
|
8
|
-
//
|
|
6
|
+
// string key-value storage matching expo-secure-store's item api and its
|
|
7
|
+
// options, backed by the keychain: generic-password items keyed by account
|
|
8
|
+
// under the option's service (default One.SecureStore, so items written
|
|
9
|
+
// before options existed read back unchanged). an authenticated item lives
|
|
10
|
+
// under "<service>:auth" with a biometryCurrentSet access control, like
|
|
11
|
+
// expo's split; a read checks the plain service first, then the auth
|
|
12
|
+
// service, and a write removes the other mode's item. a missing key reads
|
|
13
|
+
// nil; deleting one resolves all the same and never prompts.
|
|
9
14
|
final class HybridOneSecureStore: HybridOneSecureStoreSpec {
|
|
10
|
-
private static let
|
|
15
|
+
private static let defaultService = "One.SecureStore"
|
|
11
16
|
|
|
12
|
-
private static func
|
|
13
|
-
|
|
17
|
+
private static func service(options: SecureStoreOptions, authenticated: Bool) -> String {
|
|
18
|
+
let base = options.keychainService ?? defaultService
|
|
19
|
+
return authenticated ? base + ":auth" : base
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
private static func query(key: String, options: SecureStoreOptions, authenticated: Bool)
|
|
23
|
+
-> [String: Any]
|
|
24
|
+
{
|
|
25
|
+
var query: [String: Any] = [
|
|
14
26
|
kSecClass as String: kSecClassGenericPassword,
|
|
15
|
-
kSecAttrService as String: service,
|
|
27
|
+
kSecAttrService as String: service(options: options, authenticated: authenticated),
|
|
16
28
|
kSecAttrAccount as String: key,
|
|
17
29
|
]
|
|
30
|
+
if let accessGroup = options.accessGroup {
|
|
31
|
+
query[kSecAttrAccessGroup as String] = accessGroup
|
|
32
|
+
}
|
|
33
|
+
return query
|
|
18
34
|
}
|
|
19
35
|
|
|
20
|
-
private static func
|
|
21
|
-
|
|
36
|
+
private static func accessible(options: SecureStoreOptions) -> CFString {
|
|
37
|
+
switch options.keychainAccessible {
|
|
38
|
+
case .afterfirstunlock: return kSecAttrAccessibleAfterFirstUnlock
|
|
39
|
+
case .afterfirstunlockthisdeviceonly: return kSecAttrAccessibleAfterFirstUnlockThisDeviceOnly
|
|
40
|
+
case .always: return kSecAttrAccessibleAlways
|
|
41
|
+
case .alwaysthisdeviceonly: return kSecAttrAccessibleAlwaysThisDeviceOnly
|
|
42
|
+
case .whenpasscodesetthisdeviceonly: return kSecAttrAccessibleWhenPasscodeSetThisDeviceOnly
|
|
43
|
+
case .whenunlockedthisdeviceonly: return kSecAttrAccessibleWhenUnlockedThisDeviceOnly
|
|
44
|
+
case .whenunlocked, nil: return kSecAttrAccessibleWhenUnlocked
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
// the authentication context carries the prompt; without a custom prompt
|
|
49
|
+
// no context is attached and the system wording stands.
|
|
50
|
+
private static func withPrompt(_ query: [String: Any], options: SecureStoreOptions)
|
|
51
|
+
-> [String: Any]
|
|
52
|
+
{
|
|
53
|
+
guard let prompt = options.authenticationPrompt else { return query }
|
|
54
|
+
var next = query
|
|
55
|
+
let context = LAContext()
|
|
56
|
+
context.localizedReason = prompt
|
|
57
|
+
next[kSecUseAuthenticationContext as String] = context
|
|
58
|
+
return next
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
private static func fetch(key: String, options: SecureStoreOptions, authenticated: Bool) throws
|
|
62
|
+
-> String?
|
|
63
|
+
{
|
|
64
|
+
var lookup = withPrompt(query(key: key, options: options, authenticated: authenticated), options: options)
|
|
22
65
|
lookup[kSecReturnData as String] = true
|
|
23
66
|
lookup[kSecMatchLimit as String] = kSecMatchLimitOne
|
|
24
67
|
var item: CFTypeRef?
|
|
@@ -37,73 +80,96 @@ final class HybridOneSecureStore: HybridOneSecureStoreSpec {
|
|
|
37
80
|
return value
|
|
38
81
|
}
|
|
39
82
|
|
|
40
|
-
private static func
|
|
83
|
+
private static func read(key: String, options: SecureStoreOptions) throws -> String? {
|
|
84
|
+
if let value = try fetch(key: key, options: options, authenticated: false) {
|
|
85
|
+
return value
|
|
86
|
+
}
|
|
87
|
+
return try fetch(key: key, options: options, authenticated: true)
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
private static func write(key: String, value: String, options: SecureStoreOptions) throws {
|
|
41
91
|
guard let data = value.data(using: .utf8) else {
|
|
42
92
|
throw oneNativeError(
|
|
43
93
|
"E_SECURE_STORE_SET", "SecureStore.setItem: the value is not utf-8 text")
|
|
44
94
|
}
|
|
45
|
-
let
|
|
95
|
+
let authenticated = options.requireAuthentication ?? false
|
|
96
|
+
let target = query(key: key, options: options, authenticated: authenticated)
|
|
97
|
+
let status = SecItemUpdate(
|
|
98
|
+
withPrompt(target, options: options) as CFDictionary,
|
|
99
|
+
[kSecValueData as String: data] as CFDictionary)
|
|
46
100
|
if status == errSecSuccess {
|
|
101
|
+
removeOther(key: key, options: options, authenticated: authenticated)
|
|
47
102
|
return
|
|
48
103
|
}
|
|
49
104
|
if status != errSecItemNotFound {
|
|
50
105
|
throw oneNativeError(
|
|
51
106
|
"E_SECURE_STORE_SET", "SecureStore.setItem: the keychain write failed (status \(status))")
|
|
52
107
|
}
|
|
53
|
-
var addition =
|
|
108
|
+
var addition = target
|
|
54
109
|
addition[kSecValueData as String] = data
|
|
55
|
-
|
|
110
|
+
if authenticated {
|
|
111
|
+
var error: Unmanaged<CFError>?
|
|
112
|
+
guard
|
|
113
|
+
let control = SecAccessControlCreateWithFlags(
|
|
114
|
+
kCFAllocatorDefault, accessible(options: options), .biometryCurrentSet, &error)
|
|
115
|
+
else {
|
|
116
|
+
throw oneNativeError(
|
|
117
|
+
"E_SECURE_STORE_SET",
|
|
118
|
+
"SecureStore.setItem: the authentication access control could not be created")
|
|
119
|
+
}
|
|
120
|
+
addition[kSecAttrAccessControl as String] = control
|
|
121
|
+
} else {
|
|
122
|
+
addition[kSecAttrAccessible as String] = accessible(options: options)
|
|
123
|
+
}
|
|
56
124
|
let added = SecItemAdd(addition as CFDictionary, nil)
|
|
57
125
|
if added != errSecSuccess {
|
|
58
126
|
throw oneNativeError(
|
|
59
127
|
"E_SECURE_STORE_SET", "SecureStore.setItem: the keychain write failed (status \(added))")
|
|
60
128
|
}
|
|
129
|
+
removeOther(key: key, options: options, authenticated: authenticated)
|
|
61
130
|
}
|
|
62
131
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
"E_SECURE_STORE_DELETE",
|
|
68
|
-
"SecureStore.deleteItem: the keychain delete failed (status \(status))")
|
|
69
|
-
}
|
|
132
|
+
// one value per key across the two modes: writing one mode clears the
|
|
133
|
+
// other, so a later read can never return a stale mode's value.
|
|
134
|
+
private static func removeOther(key: String, options: SecureStoreOptions, authenticated: Bool) {
|
|
135
|
+
SecItemDelete(query(key: key, options: options, authenticated: !authenticated) as CFDictionary)
|
|
70
136
|
}
|
|
71
137
|
|
|
72
|
-
func
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
138
|
+
private static func remove(key: String, options: SecureStoreOptions) throws {
|
|
139
|
+
for authenticated in [false, true] {
|
|
140
|
+
let status = SecItemDelete(
|
|
141
|
+
query(key: key, options: options, authenticated: authenticated) as CFDictionary)
|
|
142
|
+
if status != errSecSuccess && status != errSecItemNotFound {
|
|
143
|
+
throw oneNativeError(
|
|
144
|
+
"E_SECURE_STORE_DELETE",
|
|
145
|
+
"SecureStore.deleteItem: the keychain delete failed (status \(status))")
|
|
146
|
+
}
|
|
77
147
|
}
|
|
78
148
|
}
|
|
79
149
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
} catch {
|
|
85
|
-
return Promise.rejected(withError: error)
|
|
86
|
-
}
|
|
150
|
+
// the async verbs leave the js thread: an authenticated item's keychain
|
|
151
|
+
// call blocks until the user answers the biometric prompt.
|
|
152
|
+
func getItem(key: String, options: SecureStoreOptions) throws -> Promise<String?> {
|
|
153
|
+
return Promise.async { try Self.read(key: key, options: options) }
|
|
87
154
|
}
|
|
88
155
|
|
|
89
|
-
func
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
}
|
|
156
|
+
func setItem(key: String, value: String, options: SecureStoreOptions) throws -> Promise<Void> {
|
|
157
|
+
return Promise.async { try Self.write(key: key, value: value, options: options) }
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
func deleteItem(key: String, options: SecureStoreOptions) throws -> Promise<Void> {
|
|
161
|
+
return Promise.async { try Self.remove(key: key, options: options) }
|
|
96
162
|
}
|
|
97
163
|
|
|
98
|
-
func getItemSync(key: String) throws -> String? {
|
|
99
|
-
return try Self.read(key: key)
|
|
164
|
+
func getItemSync(key: String, options: SecureStoreOptions) throws -> String? {
|
|
165
|
+
return try Self.read(key: key, options: options)
|
|
100
166
|
}
|
|
101
167
|
|
|
102
|
-
func setItemSync(key: String, value: String) throws {
|
|
103
|
-
try Self.write(key: key, value: value)
|
|
168
|
+
func setItemSync(key: String, value: String, options: SecureStoreOptions) throws {
|
|
169
|
+
try Self.write(key: key, value: value, options: options)
|
|
104
170
|
}
|
|
105
171
|
|
|
106
|
-
func deleteItemSync(key: String) throws {
|
|
107
|
-
try Self.remove(key: key)
|
|
172
|
+
func deleteItemSync(key: String, options: SecureStoreOptions) throws {
|
|
173
|
+
try Self.remove(key: key, options: options)
|
|
108
174
|
}
|
|
109
175
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
// swift-tools-version:5.9
|
|
2
|
+
import PackageDescription
|
|
3
|
+
|
|
4
|
+
let package = Package(
|
|
5
|
+
name: "OneImageManipulatorHarness",
|
|
6
|
+
platforms: [.iOS(.v17)],
|
|
7
|
+
targets: [
|
|
8
|
+
.target(name: "NitroModules"),
|
|
9
|
+
.target(name: "SDWebImageWebPCoder", dependencies: []),
|
|
10
|
+
.target(name: "OneImageManipulatorCore", dependencies: ["NitroModules", "SDWebImageWebPCoder"]),
|
|
11
|
+
]
|
|
12
|
+
)
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# ImageManipulator native typecheck
|
|
2
|
+
|
|
3
|
+
This SwiftPM harness compiles the production `HybridOneImageManipulator.swift`
|
|
4
|
+
and `OneNativeError.swift` through source symlinks against the iOS simulator
|
|
5
|
+
SDK. Only Nitro transport, generated value types, and the WebP coder are
|
|
6
|
+
stand-ins. The class uses UIKit, so unlike the FileSystem harness nothing here
|
|
7
|
+
runs on macOS: there is no test target, only a simulator-triple build.
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
swift build --triple arm64-apple-ios17.0-simulator \
|
|
11
|
+
--sdk $(xcrun --sdk iphonesimulator --show-sdk-path) \
|
|
12
|
+
--package-path packages/one/ios/Tests/ImageManipulator
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
The real `SDWebImageWebPCoder` call shape (`sharedCoder`, `.webP`,
|
|
16
|
+
`.encodeCompressionQuality`) was read off the vendored 0.15.0 pod headers, not
|
|
17
|
+
the stub. The stub only proves the production file is internally consistent.
|
|
18
|
+
Real WebP bytes, flip pixels, and validation codes are proven by the
|
|
19
|
+
native-features `image-manipulator` fixture on the iOS 27 simulator and
|
|
20
|
+
Android 37 emulator; this harness does not prove transport, sandbox behavior,
|
|
21
|
+
or a device pass.
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
|
|
3
|
+
// test transport only; the production class settles these off-thread.
|
|
4
|
+
public final class Promise<T> {
|
|
5
|
+
private let condition = NSCondition()
|
|
6
|
+
private var result: Result<T, Error>?
|
|
7
|
+
public init() {}
|
|
8
|
+
public func resolve(withResult value: T) { settle(.success(value)) }
|
|
9
|
+
public func reject(withError error: Error) { settle(.failure(error)) }
|
|
10
|
+
private func settle(_ value: Result<T, Error>) {
|
|
11
|
+
condition.lock()
|
|
12
|
+
result = value
|
|
13
|
+
condition.broadcast()
|
|
14
|
+
condition.unlock()
|
|
15
|
+
}
|
|
16
|
+
public func wait() throws -> T {
|
|
17
|
+
condition.lock()
|
|
18
|
+
defer { condition.unlock() }
|
|
19
|
+
let deadline = Date().addingTimeInterval(5)
|
|
20
|
+
while result == nil {
|
|
21
|
+
guard condition.wait(until: deadline) else { throw RuntimeError.error(withMessage: "promise did not settle") }
|
|
22
|
+
}
|
|
23
|
+
return try result!.get()
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
extension Promise where T == Void {
|
|
28
|
+
public func resolve() { resolve(withResult: ()) }
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
public enum RuntimeError: Error {
|
|
32
|
+
case error(withMessage: String)
|
|
33
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// stand-ins for generated nitro value types; no image behavior.
|
|
2
|
+
class HybridOneImageManipulatorSpec {}
|
|
3
|
+
|
|
4
|
+
struct ImageCrop {
|
|
5
|
+
let x: Double
|
|
6
|
+
let y: Double
|
|
7
|
+
let width: Double
|
|
8
|
+
let height: Double
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
struct ImageResize {
|
|
12
|
+
let width: Double?
|
|
13
|
+
let height: Double?
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
enum OneImageFlip {
|
|
17
|
+
case horizontal
|
|
18
|
+
case vertical
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
enum OneImageFormat {
|
|
22
|
+
case jpeg
|
|
23
|
+
case png
|
|
24
|
+
case webp
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
struct ImageTransformOptions {
|
|
28
|
+
let crop: ImageCrop?
|
|
29
|
+
let resize: ImageResize?
|
|
30
|
+
let rotate: Double?
|
|
31
|
+
let flip: OneImageFlip?
|
|
32
|
+
let format: OneImageFormat
|
|
33
|
+
let quality: Double?
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
struct ImageTransformResult {
|
|
37
|
+
let uri: String
|
|
38
|
+
let width: Double
|
|
39
|
+
let height: Double
|
|
40
|
+
let size: Double
|
|
41
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import UIKit
|
|
2
|
+
|
|
3
|
+
// stand-in for the SDWebImageWebPCoder pod, which the harness never links.
|
|
4
|
+
// member names mirror the vendored 0.15.0 headers (SDImageWebPCoder.h,
|
|
5
|
+
// SDImageCoder.h, NSData+ImageContentType.h); only call-site shapes are stubbed.
|
|
6
|
+
public struct SDImageFormat: Hashable {
|
|
7
|
+
public static let webP = SDImageFormat()
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
public struct SDImageCoderOption: Hashable {
|
|
11
|
+
public static let encodeCompressionQuality = SDImageCoderOption()
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
public final class SDImageWebPCoder {
|
|
15
|
+
public static let sharedCoder = SDImageWebPCoder()
|
|
16
|
+
public func encodedData(
|
|
17
|
+
with image: UIImage?,
|
|
18
|
+
format: SDImageFormat,
|
|
19
|
+
options: [SDImageCoderOption: Any]?
|
|
20
|
+
) -> Data? {
|
|
21
|
+
nil
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JAndroidHaptic.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include <fbjni/fbjni.h>
|
|
11
|
+
#include "AndroidHaptic.hpp"
|
|
12
|
+
|
|
13
|
+
namespace margelo::nitro::one {
|
|
14
|
+
|
|
15
|
+
using namespace facebook;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* The C++ JNI bridge between the C++ enum "AndroidHaptic" and the Kotlin enum "AndroidHaptic".
|
|
19
|
+
*/
|
|
20
|
+
struct JAndroidHaptic final: public jni::JavaClass<JAndroidHaptic> {
|
|
21
|
+
public:
|
|
22
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/one/AndroidHaptic;";
|
|
23
|
+
|
|
24
|
+
public:
|
|
25
|
+
/**
|
|
26
|
+
* Convert this Java/Kotlin-based enum to the C++ enum AndroidHaptic.
|
|
27
|
+
*/
|
|
28
|
+
[[maybe_unused]]
|
|
29
|
+
[[nodiscard]]
|
|
30
|
+
AndroidHaptic toCpp() const {
|
|
31
|
+
static const auto clazz = javaClassStatic();
|
|
32
|
+
static const auto fieldOrdinal = clazz->getField<int>("value");
|
|
33
|
+
int ordinal = this->getFieldValue(fieldOrdinal);
|
|
34
|
+
return static_cast<AndroidHaptic>(ordinal);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
public:
|
|
38
|
+
/**
|
|
39
|
+
* Create a Java/Kotlin-based enum with the given C++ enum's value.
|
|
40
|
+
*/
|
|
41
|
+
[[maybe_unused]]
|
|
42
|
+
static jni::alias_ref<JAndroidHaptic> fromCpp(AndroidHaptic value) {
|
|
43
|
+
static const auto clazz = javaClassStatic();
|
|
44
|
+
switch (value) {
|
|
45
|
+
case AndroidHaptic::CLOCK_TICK:
|
|
46
|
+
static const auto fieldCLOCK_TICK = clazz->getStaticField<JAndroidHaptic>("CLOCK_TICK");
|
|
47
|
+
return clazz->getStaticFieldValue(fieldCLOCK_TICK);
|
|
48
|
+
case AndroidHaptic::CONFIRM:
|
|
49
|
+
static const auto fieldCONFIRM = clazz->getStaticField<JAndroidHaptic>("CONFIRM");
|
|
50
|
+
return clazz->getStaticFieldValue(fieldCONFIRM);
|
|
51
|
+
case AndroidHaptic::CONTEXT_CLICK:
|
|
52
|
+
static const auto fieldCONTEXT_CLICK = clazz->getStaticField<JAndroidHaptic>("CONTEXT_CLICK");
|
|
53
|
+
return clazz->getStaticFieldValue(fieldCONTEXT_CLICK);
|
|
54
|
+
case AndroidHaptic::DRAG_START:
|
|
55
|
+
static const auto fieldDRAG_START = clazz->getStaticField<JAndroidHaptic>("DRAG_START");
|
|
56
|
+
return clazz->getStaticFieldValue(fieldDRAG_START);
|
|
57
|
+
case AndroidHaptic::GESTURE_END:
|
|
58
|
+
static const auto fieldGESTURE_END = clazz->getStaticField<JAndroidHaptic>("GESTURE_END");
|
|
59
|
+
return clazz->getStaticFieldValue(fieldGESTURE_END);
|
|
60
|
+
case AndroidHaptic::GESTURE_START:
|
|
61
|
+
static const auto fieldGESTURE_START = clazz->getStaticField<JAndroidHaptic>("GESTURE_START");
|
|
62
|
+
return clazz->getStaticFieldValue(fieldGESTURE_START);
|
|
63
|
+
case AndroidHaptic::KEYBOARD_PRESS:
|
|
64
|
+
static const auto fieldKEYBOARD_PRESS = clazz->getStaticField<JAndroidHaptic>("KEYBOARD_PRESS");
|
|
65
|
+
return clazz->getStaticFieldValue(fieldKEYBOARD_PRESS);
|
|
66
|
+
case AndroidHaptic::KEYBOARD_RELEASE:
|
|
67
|
+
static const auto fieldKEYBOARD_RELEASE = clazz->getStaticField<JAndroidHaptic>("KEYBOARD_RELEASE");
|
|
68
|
+
return clazz->getStaticFieldValue(fieldKEYBOARD_RELEASE);
|
|
69
|
+
case AndroidHaptic::KEYBOARD_TAP:
|
|
70
|
+
static const auto fieldKEYBOARD_TAP = clazz->getStaticField<JAndroidHaptic>("KEYBOARD_TAP");
|
|
71
|
+
return clazz->getStaticFieldValue(fieldKEYBOARD_TAP);
|
|
72
|
+
case AndroidHaptic::LONG_PRESS:
|
|
73
|
+
static const auto fieldLONG_PRESS = clazz->getStaticField<JAndroidHaptic>("LONG_PRESS");
|
|
74
|
+
return clazz->getStaticFieldValue(fieldLONG_PRESS);
|
|
75
|
+
case AndroidHaptic::NO_HAPTICS:
|
|
76
|
+
static const auto fieldNO_HAPTICS = clazz->getStaticField<JAndroidHaptic>("NO_HAPTICS");
|
|
77
|
+
return clazz->getStaticFieldValue(fieldNO_HAPTICS);
|
|
78
|
+
case AndroidHaptic::REJECT:
|
|
79
|
+
static const auto fieldREJECT = clazz->getStaticField<JAndroidHaptic>("REJECT");
|
|
80
|
+
return clazz->getStaticFieldValue(fieldREJECT);
|
|
81
|
+
case AndroidHaptic::SEGMENT_FREQUENT_TICK:
|
|
82
|
+
static const auto fieldSEGMENT_FREQUENT_TICK = clazz->getStaticField<JAndroidHaptic>("SEGMENT_FREQUENT_TICK");
|
|
83
|
+
return clazz->getStaticFieldValue(fieldSEGMENT_FREQUENT_TICK);
|
|
84
|
+
case AndroidHaptic::SEGMENT_TICK:
|
|
85
|
+
static const auto fieldSEGMENT_TICK = clazz->getStaticField<JAndroidHaptic>("SEGMENT_TICK");
|
|
86
|
+
return clazz->getStaticFieldValue(fieldSEGMENT_TICK);
|
|
87
|
+
case AndroidHaptic::TEXT_HANDLE_MOVE:
|
|
88
|
+
static const auto fieldTEXT_HANDLE_MOVE = clazz->getStaticField<JAndroidHaptic>("TEXT_HANDLE_MOVE");
|
|
89
|
+
return clazz->getStaticFieldValue(fieldTEXT_HANDLE_MOVE);
|
|
90
|
+
case AndroidHaptic::TOGGLE_OFF:
|
|
91
|
+
static const auto fieldTOGGLE_OFF = clazz->getStaticField<JAndroidHaptic>("TOGGLE_OFF");
|
|
92
|
+
return clazz->getStaticFieldValue(fieldTOGGLE_OFF);
|
|
93
|
+
case AndroidHaptic::TOGGLE_ON:
|
|
94
|
+
static const auto fieldTOGGLE_ON = clazz->getStaticField<JAndroidHaptic>("TOGGLE_ON");
|
|
95
|
+
return clazz->getStaticFieldValue(fieldTOGGLE_ON);
|
|
96
|
+
case AndroidHaptic::VIRTUAL_KEY:
|
|
97
|
+
static const auto fieldVIRTUAL_KEY = clazz->getStaticField<JAndroidHaptic>("VIRTUAL_KEY");
|
|
98
|
+
return clazz->getStaticFieldValue(fieldVIRTUAL_KEY);
|
|
99
|
+
case AndroidHaptic::VIRTUAL_KEY_RELEASE:
|
|
100
|
+
static const auto fieldVIRTUAL_KEY_RELEASE = clazz->getStaticField<JAndroidHaptic>("VIRTUAL_KEY_RELEASE");
|
|
101
|
+
return clazz->getStaticFieldValue(fieldVIRTUAL_KEY_RELEASE);
|
|
102
|
+
default:
|
|
103
|
+
std::string stringValue = std::to_string(static_cast<int>(value));
|
|
104
|
+
throw std::invalid_argument("Invalid enum value (" + stringValue + "!");
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
} // namespace margelo::nitro::one
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
///
|
|
2
|
+
/// JCalendarInfo.hpp
|
|
3
|
+
/// This file was generated by nitrogen. DO NOT MODIFY THIS FILE.
|
|
4
|
+
/// https://github.com/mrousavy/nitro
|
|
5
|
+
/// Copyright © Marc Rousavy @ Margelo
|
|
6
|
+
///
|
|
7
|
+
|
|
8
|
+
#pragma once
|
|
9
|
+
|
|
10
|
+
#include <fbjni/fbjni.h>
|
|
11
|
+
#include "CalendarInfo.hpp"
|
|
12
|
+
|
|
13
|
+
#include <optional>
|
|
14
|
+
#include <string>
|
|
15
|
+
|
|
16
|
+
namespace margelo::nitro::one {
|
|
17
|
+
|
|
18
|
+
using namespace facebook;
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* The C++ JNI bridge between the C++ struct "CalendarInfo" and the Kotlin data class "CalendarInfo".
|
|
22
|
+
*/
|
|
23
|
+
struct JCalendarInfo final: public jni::JavaClass<JCalendarInfo> {
|
|
24
|
+
public:
|
|
25
|
+
static constexpr auto kJavaDescriptor = "Lcom/margelo/nitro/one/CalendarInfo;";
|
|
26
|
+
|
|
27
|
+
public:
|
|
28
|
+
/**
|
|
29
|
+
* Convert this Java/Kotlin-based struct to the C++ struct CalendarInfo by copying all values to C++.
|
|
30
|
+
*/
|
|
31
|
+
[[maybe_unused]]
|
|
32
|
+
[[nodiscard]]
|
|
33
|
+
CalendarInfo toCpp() const {
|
|
34
|
+
static const auto clazz = javaClassStatic();
|
|
35
|
+
static const auto fieldCalendar = clazz->getField<jni::JString>("calendar");
|
|
36
|
+
jni::local_ref<jni::JString> calendar = this->getFieldValue(fieldCalendar);
|
|
37
|
+
static const auto fieldTimeZone = clazz->getField<jni::JString>("timeZone");
|
|
38
|
+
jni::local_ref<jni::JString> timeZone = this->getFieldValue(fieldTimeZone);
|
|
39
|
+
static const auto fieldUses24hourClock = clazz->getField<jni::JBoolean>("uses24hourClock");
|
|
40
|
+
jni::local_ref<jni::JBoolean> uses24hourClock = this->getFieldValue(fieldUses24hourClock);
|
|
41
|
+
static const auto fieldFirstWeekday = clazz->getField<jni::JDouble>("firstWeekday");
|
|
42
|
+
jni::local_ref<jni::JDouble> firstWeekday = this->getFieldValue(fieldFirstWeekday);
|
|
43
|
+
return CalendarInfo(
|
|
44
|
+
calendar != nullptr ? std::make_optional(calendar->toStdString()) : std::nullopt,
|
|
45
|
+
timeZone != nullptr ? std::make_optional(timeZone->toStdString()) : std::nullopt,
|
|
46
|
+
uses24hourClock != nullptr ? std::make_optional(static_cast<bool>(uses24hourClock->value())) : std::nullopt,
|
|
47
|
+
firstWeekday != nullptr ? std::make_optional(firstWeekday->value()) : std::nullopt
|
|
48
|
+
);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
public:
|
|
52
|
+
/**
|
|
53
|
+
* Create a Java/Kotlin-based struct by copying all values from the given C++ struct to Java.
|
|
54
|
+
*/
|
|
55
|
+
[[maybe_unused]]
|
|
56
|
+
static jni::local_ref<JCalendarInfo::javaobject> fromCpp(const CalendarInfo& value) {
|
|
57
|
+
using JSignature = JCalendarInfo(jni::alias_ref<jni::JString>, jni::alias_ref<jni::JString>, jni::alias_ref<jni::JBoolean>, jni::alias_ref<jni::JDouble>);
|
|
58
|
+
static const auto clazz = javaClassStatic();
|
|
59
|
+
static const auto create = clazz->getStaticMethod<JSignature>("fromCpp");
|
|
60
|
+
return create(
|
|
61
|
+
clazz,
|
|
62
|
+
value.calendar.has_value() ? jni::make_jstring(value.calendar.value()) : nullptr,
|
|
63
|
+
value.timeZone.has_value() ? jni::make_jstring(value.timeZone.value()) : nullptr,
|
|
64
|
+
value.uses24hourClock.has_value() ? jni::JBoolean::valueOf(value.uses24hourClock.value()) : nullptr,
|
|
65
|
+
value.firstWeekday.has_value() ? jni::JDouble::valueOf(value.firstWeekday.value()) : nullptr
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
} // namespace margelo::nitro::one
|
|
@@ -42,12 +42,12 @@ namespace margelo::nitro::one {
|
|
|
42
42
|
static jni::alias_ref<JHapticImpact> fromCpp(HapticImpact value) {
|
|
43
43
|
static const auto clazz = javaClassStatic();
|
|
44
44
|
switch (value) {
|
|
45
|
-
case HapticImpact::LIGHT:
|
|
46
|
-
static const auto fieldLIGHT = clazz->getStaticField<JHapticImpact>("LIGHT");
|
|
47
|
-
return clazz->getStaticFieldValue(fieldLIGHT);
|
|
48
45
|
case HapticImpact::MEDIUM:
|
|
49
46
|
static const auto fieldMEDIUM = clazz->getStaticField<JHapticImpact>("MEDIUM");
|
|
50
47
|
return clazz->getStaticFieldValue(fieldMEDIUM);
|
|
48
|
+
case HapticImpact::LIGHT:
|
|
49
|
+
static const auto fieldLIGHT = clazz->getStaticField<JHapticImpact>("LIGHT");
|
|
50
|
+
return clazz->getStaticFieldValue(fieldLIGHT);
|
|
51
51
|
case HapticImpact::HEAVY:
|
|
52
52
|
static const auto fieldHEAVY = clazz->getStaticField<JHapticImpact>("HEAVY");
|
|
53
53
|
return clazz->getStaticFieldValue(fieldHEAVY);
|
|
@@ -11,6 +11,10 @@
|
|
|
11
11
|
namespace margelo::nitro::one { struct DeviceInfo; }
|
|
12
12
|
// Forward declaration of `LocalizationInfo` to properly resolve imports.
|
|
13
13
|
namespace margelo::nitro::one { struct LocalizationInfo; }
|
|
14
|
+
// Forward declaration of `LocaleInfo` to properly resolve imports.
|
|
15
|
+
namespace margelo::nitro::one { struct LocaleInfo; }
|
|
16
|
+
// Forward declaration of `CalendarInfo` to properly resolve imports.
|
|
17
|
+
namespace margelo::nitro::one { struct CalendarInfo; }
|
|
14
18
|
|
|
15
19
|
#include "DeviceInfo.hpp"
|
|
16
20
|
#include <NitroModules/Promise.hpp>
|
|
@@ -21,6 +25,13 @@ namespace margelo::nitro::one { struct LocalizationInfo; }
|
|
|
21
25
|
#include "LocalizationInfo.hpp"
|
|
22
26
|
#include "JLocalizationInfo.hpp"
|
|
23
27
|
#include <vector>
|
|
28
|
+
#include "LocaleInfo.hpp"
|
|
29
|
+
#include "JLocaleInfo.hpp"
|
|
30
|
+
#include "CalendarInfo.hpp"
|
|
31
|
+
#include "JCalendarInfo.hpp"
|
|
32
|
+
#include <functional>
|
|
33
|
+
#include "JFunc_void.hpp"
|
|
34
|
+
#include <NitroModules/JNICallable.hpp>
|
|
24
35
|
|
|
25
36
|
namespace margelo::nitro::one {
|
|
26
37
|
|
|
@@ -87,5 +98,46 @@ namespace margelo::nitro::one {
|
|
|
87
98
|
return __promise;
|
|
88
99
|
}();
|
|
89
100
|
}
|
|
101
|
+
std::vector<LocaleInfo> JHybridOneDeviceSpec::getLocales() {
|
|
102
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<jni::JArrayClass<JLocaleInfo>>()>("getLocales");
|
|
103
|
+
auto __result = method(_javaPart);
|
|
104
|
+
return [&](auto&& __input) {
|
|
105
|
+
size_t __size = __input->size();
|
|
106
|
+
std::vector<LocaleInfo> __vector;
|
|
107
|
+
__vector.reserve(__size);
|
|
108
|
+
for (size_t __i = 0; __i < __size; __i++) {
|
|
109
|
+
auto __element = __input->getElement(__i);
|
|
110
|
+
__vector.push_back(__element->toCpp());
|
|
111
|
+
}
|
|
112
|
+
return __vector;
|
|
113
|
+
}(__result);
|
|
114
|
+
}
|
|
115
|
+
std::vector<CalendarInfo> JHybridOneDeviceSpec::getCalendars() {
|
|
116
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<jni::JArrayClass<JCalendarInfo>>()>("getCalendars");
|
|
117
|
+
auto __result = method(_javaPart);
|
|
118
|
+
return [&](auto&& __input) {
|
|
119
|
+
size_t __size = __input->size();
|
|
120
|
+
std::vector<CalendarInfo> __vector;
|
|
121
|
+
__vector.reserve(__size);
|
|
122
|
+
for (size_t __i = 0; __i < __size; __i++) {
|
|
123
|
+
auto __element = __input->getElement(__i);
|
|
124
|
+
__vector.push_back(__element->toCpp());
|
|
125
|
+
}
|
|
126
|
+
return __vector;
|
|
127
|
+
}(__result);
|
|
128
|
+
}
|
|
129
|
+
std::function<void()> JHybridOneDeviceSpec::addLocalizationListener(const std::function<void()>& listener) {
|
|
130
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<jni::local_ref<JFunc_void::javaobject>(jni::alias_ref<JFunc_void::javaobject> /* listener */)>("addLocalizationListener_cxx");
|
|
131
|
+
auto __result = method(_javaPart, JFunc_void_cxx::fromCpp(listener));
|
|
132
|
+
return [&]() -> std::function<void()> {
|
|
133
|
+
if (__result->isInstanceOf(JFunc_void_cxx::javaClassStatic())) [[likely]] {
|
|
134
|
+
auto downcast = jni::static_ref_cast<JFunc_void_cxx::javaobject>(__result);
|
|
135
|
+
return downcast->cthis()->getFunction();
|
|
136
|
+
} else {
|
|
137
|
+
auto __resultRef = jni::make_global(__result);
|
|
138
|
+
return JNICallable<JFunc_void, void()>(std::move(__resultRef));
|
|
139
|
+
}
|
|
140
|
+
}();
|
|
141
|
+
}
|
|
90
142
|
|
|
91
143
|
} // namespace margelo::nitro::one
|
|
@@ -56,6 +56,9 @@ namespace margelo::nitro::one {
|
|
|
56
56
|
// Methods
|
|
57
57
|
std::shared_ptr<Promise<DeviceInfo>> getInfo() override;
|
|
58
58
|
std::shared_ptr<Promise<LocalizationInfo>> getLocalizationInfo() override;
|
|
59
|
+
std::vector<LocaleInfo> getLocales() override;
|
|
60
|
+
std::vector<CalendarInfo> getCalendars() override;
|
|
61
|
+
std::function<void()> addLocalizationListener(const std::function<void()>& listener) override;
|
|
59
62
|
|
|
60
63
|
private:
|
|
61
64
|
jni::global_ref<JHybridOneDeviceSpec::JavaPart> _javaPart;
|
|
@@ -11,11 +11,15 @@
|
|
|
11
11
|
namespace margelo::nitro::one { enum class HapticImpact; }
|
|
12
12
|
// Forward declaration of `HapticNotification` to properly resolve imports.
|
|
13
13
|
namespace margelo::nitro::one { enum class HapticNotification; }
|
|
14
|
+
// Forward declaration of `AndroidHaptic` to properly resolve imports.
|
|
15
|
+
namespace margelo::nitro::one { enum class AndroidHaptic; }
|
|
14
16
|
|
|
15
17
|
#include "HapticImpact.hpp"
|
|
16
18
|
#include "JHapticImpact.hpp"
|
|
17
19
|
#include "HapticNotification.hpp"
|
|
18
20
|
#include "JHapticNotification.hpp"
|
|
21
|
+
#include "AndroidHaptic.hpp"
|
|
22
|
+
#include "JAndroidHaptic.hpp"
|
|
19
23
|
|
|
20
24
|
namespace margelo::nitro::one {
|
|
21
25
|
|
|
@@ -62,5 +66,9 @@ namespace margelo::nitro::one {
|
|
|
62
66
|
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<JHapticNotification> /* type */)>("notification");
|
|
63
67
|
method(_javaPart, JHapticNotification::fromCpp(type));
|
|
64
68
|
}
|
|
69
|
+
void JHybridOneHapticsSpec::performAndroidHaptics(AndroidHaptic type) {
|
|
70
|
+
static const auto method = _javaPart->javaClassStatic()->getMethod<void(jni::alias_ref<JAndroidHaptic> /* type */)>("performAndroidHaptics");
|
|
71
|
+
method(_javaPart, JAndroidHaptic::fromCpp(type));
|
|
72
|
+
}
|
|
65
73
|
|
|
66
74
|
} // namespace margelo::nitro::one
|
|
@@ -57,6 +57,7 @@ namespace margelo::nitro::one {
|
|
|
57
57
|
void selection() override;
|
|
58
58
|
void impact(HapticImpact style) override;
|
|
59
59
|
void notification(HapticNotification type) override;
|
|
60
|
+
void performAndroidHaptics(AndroidHaptic type) override;
|
|
60
61
|
|
|
61
62
|
private:
|
|
62
63
|
jni::global_ref<JHybridOneHapticsSpec::JavaPart> _javaPart;
|