@thelacanians/vue-native-cli 0.4.12 → 0.4.13
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/dist/cli.js +1 -1
- package/native/android/.editorconfig +25 -0
- package/native/android/VueNativeCore/build.gradle.kts +25 -1
- package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Bridge/JSPolyfills.kt +17 -10
- package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Bridge/JSRuntime.kt +5 -5
- package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Bridge/NativeBridge.kt +13 -13
- package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Components/ComponentRegistry.kt +27 -27
- package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Components/Factories/VActionSheetFactory.kt +6 -4
- package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Components/Factories/VActivityIndicatorFactory.kt +1 -1
- package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Components/Factories/VAlertDialogFactory.kt +24 -12
- package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Components/Factories/VButtonFactory.kt +5 -2
- package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Components/Factories/VImageFactory.kt +7 -7
- package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Components/Factories/VInputFactory.kt +12 -12
- package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Components/Factories/VKeyboardAvoidingFactory.kt +0 -1
- package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Components/Factories/VListFactory.kt +5 -2
- package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Components/Factories/VModalFactory.kt +5 -2
- package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Components/Factories/VPickerFactory.kt +3 -2
- package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Components/Factories/VPressableFactory.kt +5 -3
- package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Components/Factories/VRootFactory.kt +5 -2
- package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Components/Factories/VScrollViewFactory.kt +5 -2
- package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Components/Factories/VSectionListFactory.kt +5 -2
- package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Components/Factories/VSegmentedControlFactory.kt +3 -3
- package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Components/Factories/VStatusBarFactory.kt +3 -3
- package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Components/Factories/VSwitchFactory.kt +0 -1
- package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Components/Factories/VViewFactory.kt +9 -3
- package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Components/Factories/VWebViewFactory.kt +7 -5
- package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Components/NativeComponentFactory.kt +5 -2
- package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Helpers/GestureHelper.kt +4 -1
- package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/AnimationModule.kt +77 -21
- package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/AsyncStorageModule.kt +20 -5
- package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/BackgroundTaskModule.kt +12 -3
- package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/BiometryModule.kt +5 -2
- package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/BluetoothModule.kt +88 -23
- package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/CalendarModule.kt +24 -11
- package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/ClipboardModule.kt +7 -2
- package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/ContactsModule.kt +24 -12
- package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/DeviceInfoModule.kt +14 -11
- package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/FileSystemModule.kt +79 -24
- package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/GeolocationModule.kt +10 -7
- package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/HapticsModule.kt +5 -5
- package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/HttpModule.kt +17 -8
- package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/IAPModule.kt +20 -5
- package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/KeyboardModule.kt +4 -1
- package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/LinkingModule.kt +12 -3
- package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/NetworkModule.kt +4 -1
- package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/NotificationsModule.kt +24 -6
- package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/OTAModule.kt +13 -5
- package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/PerformanceModule.kt +8 -2
- package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/PermissionsModule.kt +17 -8
- package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/SecureStorageModule.kt +20 -5
- package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/SensorsModule.kt +16 -4
- package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/ShareModule.kt +6 -3
- package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/SocialAuthModule.kt +4 -2
- package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/WebSocketModule.kt +26 -8
- package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Styling/StyleEngine.kt +127 -84
- package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Tags.kt +26 -26
- package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/VueNativeActivity.kt +1 -1
- package/native/android/VueNativeCore/src/test/kotlin/com/vuenative/core/ComponentRegistryTest.kt +173 -0
- package/native/android/VueNativeCore/src/test/kotlin/com/vuenative/core/NativeBridgeTest.kt +436 -0
- package/native/android/VueNativeCore/src/test/kotlin/com/vuenative/core/NativeModuleRegistryTest.kt +251 -0
- package/native/android/VueNativeCore/src/test/kotlin/com/vuenative/core/StyleEngineTest.kt +482 -0
- package/native/android/build.gradle.kts +1 -0
- package/native/ios/.swiftlint.yml +62 -0
- package/native/ios/VueNativeCore/Sources/VueNativeCore/Bridge/NativeBridge.swift +4 -1
- package/native/ios/VueNativeCore/Tests/VueNativeCoreTests/ComponentRegistryTests.swift +237 -0
- package/native/ios/VueNativeCore/Tests/VueNativeCoreTests/NativeBridgeOperationTests.swift +398 -0
- package/native/ios/VueNativeCore/Tests/VueNativeCoreTests/NativeModuleRegistryTests.swift +203 -0
- package/native/ios/VueNativeCore/Tests/VueNativeCoreTests/StyleEngineTests.swift +381 -0
- package/package.json +1 -1
package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/LinkingModule.kt
CHANGED
|
@@ -16,10 +16,16 @@ class LinkingModule : NativeModule {
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
override fun invoke(method: String, args: List<Any?>, bridge: NativeBridge, callback: (Any?, String?) -> Unit) {
|
|
19
|
-
val ctx = context ?: run {
|
|
19
|
+
val ctx = context ?: run {
|
|
20
|
+
callback(null, "Not initialized")
|
|
21
|
+
return
|
|
22
|
+
}
|
|
20
23
|
when (method) {
|
|
21
24
|
"openURL" -> {
|
|
22
|
-
val url = args.getOrNull(0)?.toString() ?: run {
|
|
25
|
+
val url = args.getOrNull(0)?.toString() ?: run {
|
|
26
|
+
callback(null, "Missing URL")
|
|
27
|
+
return
|
|
28
|
+
}
|
|
23
29
|
try {
|
|
24
30
|
val intent = Intent(Intent.ACTION_VIEW, Uri.parse(url)).apply {
|
|
25
31
|
addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
|
|
@@ -31,7 +37,10 @@ class LinkingModule : NativeModule {
|
|
|
31
37
|
}
|
|
32
38
|
}
|
|
33
39
|
"canOpenURL" -> {
|
|
34
|
-
val url = args.getOrNull(0)?.toString() ?: run {
|
|
40
|
+
val url = args.getOrNull(0)?.toString() ?: run {
|
|
41
|
+
callback(false, null)
|
|
42
|
+
return
|
|
43
|
+
}
|
|
35
44
|
val intent = Intent(Intent.ACTION_VIEW, Uri.parse(url))
|
|
36
45
|
val canOpen = ctx.packageManager.resolveActivity(intent, 0) != null
|
|
37
46
|
callback(canOpen, null)
|
package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/NetworkModule.kt
CHANGED
|
@@ -62,7 +62,10 @@ class NetworkModule : NativeModule {
|
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
override fun invoke(method: String, args: List<Any?>, bridge: NativeBridge, callback: (Any?, String?) -> Unit) {
|
|
65
|
-
val cm = connectivityManager ?: run {
|
|
65
|
+
val cm = connectivityManager ?: run {
|
|
66
|
+
callback(mapOf("isConnected" to false, "connectionType" to "none"), null)
|
|
67
|
+
return
|
|
68
|
+
}
|
|
66
69
|
when (method) {
|
|
67
70
|
"getStatus" -> callback(getStatus(cm), null)
|
|
68
71
|
else -> callback(null, "Unknown method: $method")
|
|
@@ -115,7 +115,10 @@ class NotificationsModule : NativeModule {
|
|
|
115
115
|
// Android <13: no runtime permission needed for notifications
|
|
116
116
|
// Android 13+: POST_NOTIFICATIONS must be granted via PermissionsModule
|
|
117
117
|
val granted = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.TIRAMISU) {
|
|
118
|
-
val ctx = context ?: run {
|
|
118
|
+
val ctx = context ?: run {
|
|
119
|
+
callback(null, "Not initialized")
|
|
120
|
+
return
|
|
121
|
+
}
|
|
119
122
|
ActivityCompat.checkSelfPermission(ctx, Manifest.permission.POST_NOTIFICATIONS) ==
|
|
120
123
|
PackageManager.PERMISSION_GRANTED
|
|
121
124
|
} else {
|
|
@@ -124,9 +127,15 @@ class NotificationsModule : NativeModule {
|
|
|
124
127
|
callback(mapOf("status" to if (granted) "granted" else "denied"), null)
|
|
125
128
|
}
|
|
126
129
|
"scheduleLocal" -> {
|
|
127
|
-
val ctx = context ?: run {
|
|
130
|
+
val ctx = context ?: run {
|
|
131
|
+
callback(null, "Not initialized")
|
|
132
|
+
return
|
|
133
|
+
}
|
|
128
134
|
val opts = args.getOrNull(0) as? Map<*, *>
|
|
129
|
-
?: run {
|
|
135
|
+
?: run {
|
|
136
|
+
callback(null, "Invalid args — expected options object")
|
|
137
|
+
return
|
|
138
|
+
}
|
|
130
139
|
|
|
131
140
|
val title = opts["title"]?.toString() ?: ""
|
|
132
141
|
val body = opts["body"]?.toString() ?: ""
|
|
@@ -157,14 +166,23 @@ class NotificationsModule : NativeModule {
|
|
|
157
166
|
callback(mapOf("id" to notifId), null)
|
|
158
167
|
}
|
|
159
168
|
"cancel" -> {
|
|
160
|
-
val ctx = context ?: run {
|
|
169
|
+
val ctx = context ?: run {
|
|
170
|
+
callback(null, "Not initialized")
|
|
171
|
+
return
|
|
172
|
+
}
|
|
161
173
|
val id = (args.getOrNull(0) as? Number)?.toInt()
|
|
162
|
-
?: run {
|
|
174
|
+
?: run {
|
|
175
|
+
callback(null, "Invalid args — expected notification id")
|
|
176
|
+
return
|
|
177
|
+
}
|
|
163
178
|
NotificationManagerCompat.from(ctx).cancel(id)
|
|
164
179
|
callback(null, null)
|
|
165
180
|
}
|
|
166
181
|
"cancelAll" -> {
|
|
167
|
-
val ctx = context ?: run {
|
|
182
|
+
val ctx = context ?: run {
|
|
183
|
+
callback(null, "Not initialized")
|
|
184
|
+
return
|
|
185
|
+
}
|
|
168
186
|
NotificationManagerCompat.from(ctx).cancelAll()
|
|
169
187
|
callback(null, null)
|
|
170
188
|
}
|
package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/OTAModule.kt
CHANGED
|
@@ -2,12 +2,11 @@ package com.vuenative.core
|
|
|
2
2
|
|
|
3
3
|
import android.content.Context
|
|
4
4
|
import android.content.SharedPreferences
|
|
5
|
-
import android.util.Log
|
|
6
|
-
import okhttp3.*
|
|
7
5
|
import java.io.File
|
|
8
6
|
import java.io.FileOutputStream
|
|
9
7
|
import java.io.IOException
|
|
10
8
|
import java.security.MessageDigest
|
|
9
|
+
import okhttp3.*
|
|
11
10
|
|
|
12
11
|
/**
|
|
13
12
|
* Native module for Over-The-Air (OTA) JS bundle updates.
|
|
@@ -43,17 +42,26 @@ class OTAModule : NativeModule {
|
|
|
43
42
|
}
|
|
44
43
|
|
|
45
44
|
override fun invoke(method: String, args: List<Any?>, bridge: NativeBridge, callback: (Any?, String?) -> Unit) {
|
|
46
|
-
val p = prefs ?: run {
|
|
45
|
+
val p = prefs ?: run {
|
|
46
|
+
callback(null, "OTA not initialized")
|
|
47
|
+
return
|
|
48
|
+
}
|
|
47
49
|
|
|
48
50
|
when (method) {
|
|
49
51
|
"checkForUpdate" -> {
|
|
50
52
|
val serverUrl = args.getOrNull(0)?.toString()
|
|
51
|
-
?: run {
|
|
53
|
+
?: run {
|
|
54
|
+
callback(null, "checkForUpdate: missing serverUrl")
|
|
55
|
+
return
|
|
56
|
+
}
|
|
52
57
|
checkForUpdate(serverUrl, p, callback)
|
|
53
58
|
}
|
|
54
59
|
"downloadUpdate" -> {
|
|
55
60
|
val url = args.getOrNull(0)?.toString()
|
|
56
|
-
?: run {
|
|
61
|
+
?: run {
|
|
62
|
+
callback(null, "downloadUpdate: missing url")
|
|
63
|
+
return
|
|
64
|
+
}
|
|
57
65
|
val expectedHash = args.getOrNull(1)?.toString()
|
|
58
66
|
downloadUpdate(url, expectedHash, p, callback)
|
|
59
67
|
}
|
package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/PerformanceModule.kt
CHANGED
|
@@ -52,7 +52,10 @@ class PerformanceModule : NativeModule {
|
|
|
52
52
|
// ── Start / Stop ──────────────────────────────────────────────────────
|
|
53
53
|
|
|
54
54
|
private fun startProfiling(callback: (Any?, String?) -> Unit) {
|
|
55
|
-
if (isProfiling) {
|
|
55
|
+
if (isProfiling) {
|
|
56
|
+
callback(true, null)
|
|
57
|
+
return
|
|
58
|
+
}
|
|
56
59
|
isProfiling = true
|
|
57
60
|
frameCount = 0
|
|
58
61
|
lastFrameTimeNanos = 0
|
|
@@ -101,7 +104,10 @@ class PerformanceModule : NativeModule {
|
|
|
101
104
|
}
|
|
102
105
|
|
|
103
106
|
private fun stopProfiling(callback: (Any?, String?) -> Unit) {
|
|
104
|
-
if (!isProfiling) {
|
|
107
|
+
if (!isProfiling) {
|
|
108
|
+
callback(true, null)
|
|
109
|
+
return
|
|
110
|
+
}
|
|
105
111
|
isProfiling = false
|
|
106
112
|
|
|
107
113
|
mainHandler.post {
|
package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/PermissionsModule.kt
CHANGED
|
@@ -50,10 +50,16 @@ class PermissionsModule : NativeModule {
|
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
override fun invoke(method: String, args: List<Any?>, bridge: NativeBridge, callback: (Any?, String?) -> Unit) {
|
|
53
|
-
val ctx = context ?: run {
|
|
53
|
+
val ctx = context ?: run {
|
|
54
|
+
callback(null, "Not initialized")
|
|
55
|
+
return
|
|
56
|
+
}
|
|
54
57
|
when (method) {
|
|
55
58
|
"check" -> {
|
|
56
|
-
val permission = args.getOrNull(0)?.toString() ?: run {
|
|
59
|
+
val permission = args.getOrNull(0)?.toString() ?: run {
|
|
60
|
+
callback("denied", null)
|
|
61
|
+
return
|
|
62
|
+
}
|
|
57
63
|
val androidPerm = mapPermission(permission)
|
|
58
64
|
if (androidPerm == null) {
|
|
59
65
|
callback("denied", null)
|
|
@@ -62,7 +68,10 @@ class PermissionsModule : NativeModule {
|
|
|
62
68
|
callback(checkStatus(ctx, androidPerm), null)
|
|
63
69
|
}
|
|
64
70
|
"request" -> {
|
|
65
|
-
val permission = args.getOrNull(0)?.toString() ?: run {
|
|
71
|
+
val permission = args.getOrNull(0)?.toString() ?: run {
|
|
72
|
+
callback("denied", null)
|
|
73
|
+
return
|
|
74
|
+
}
|
|
66
75
|
val androidPerm = mapPermission(permission)
|
|
67
76
|
if (androidPerm == null) {
|
|
68
77
|
callback("denied", null)
|
|
@@ -115,12 +124,12 @@ class PermissionsModule : NativeModule {
|
|
|
115
124
|
}
|
|
116
125
|
|
|
117
126
|
private fun mapPermission(name: String): String? = when (name) {
|
|
118
|
-
"camera"
|
|
119
|
-
"microphone"
|
|
120
|
-
"photos"
|
|
121
|
-
"location"
|
|
127
|
+
"camera" -> Manifest.permission.CAMERA
|
|
128
|
+
"microphone" -> Manifest.permission.RECORD_AUDIO
|
|
129
|
+
"photos" -> if (android.os.Build.VERSION.SDK_INT >= 33) Manifest.permission.READ_MEDIA_IMAGES else Manifest.permission.READ_EXTERNAL_STORAGE
|
|
130
|
+
"location" -> Manifest.permission.ACCESS_FINE_LOCATION
|
|
122
131
|
"locationAlways" -> Manifest.permission.ACCESS_BACKGROUND_LOCATION
|
|
123
|
-
"notifications"
|
|
132
|
+
"notifications" -> if (android.os.Build.VERSION.SDK_INT >= 33) Manifest.permission.POST_NOTIFICATIONS else null
|
|
124
133
|
else -> null
|
|
125
134
|
}
|
|
126
135
|
}
|
|
@@ -24,20 +24,35 @@ class SecureStorageModule : NativeModule {
|
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
override fun invoke(method: String, args: List<Any?>, bridge: NativeBridge, callback: (Any?, String?) -> Unit) {
|
|
27
|
-
val p = prefs ?: run {
|
|
27
|
+
val p = prefs ?: run {
|
|
28
|
+
callback(null, "SecureStorage not initialized")
|
|
29
|
+
return
|
|
30
|
+
}
|
|
28
31
|
when (method) {
|
|
29
32
|
"get" -> {
|
|
30
|
-
val key = args.getOrNull(0)?.toString() ?: run {
|
|
33
|
+
val key = args.getOrNull(0)?.toString() ?: run {
|
|
34
|
+
callback(null, "Missing key")
|
|
35
|
+
return
|
|
36
|
+
}
|
|
31
37
|
callback(p.getString(key, null), null)
|
|
32
38
|
}
|
|
33
39
|
"set" -> {
|
|
34
|
-
val key = args.getOrNull(0)?.toString() ?: run {
|
|
35
|
-
|
|
40
|
+
val key = args.getOrNull(0)?.toString() ?: run {
|
|
41
|
+
callback(null, "Missing key")
|
|
42
|
+
return
|
|
43
|
+
}
|
|
44
|
+
val value = args.getOrNull(1)?.toString() ?: run {
|
|
45
|
+
callback(null, "Missing value")
|
|
46
|
+
return
|
|
47
|
+
}
|
|
36
48
|
p.edit().putString(key, value).apply()
|
|
37
49
|
callback(null, null)
|
|
38
50
|
}
|
|
39
51
|
"remove" -> {
|
|
40
|
-
val key = args.getOrNull(0)?.toString() ?: run {
|
|
52
|
+
val key = args.getOrNull(0)?.toString() ?: run {
|
|
53
|
+
callback(null, "Missing key")
|
|
54
|
+
return
|
|
55
|
+
}
|
|
41
56
|
p.edit().remove(key).apply()
|
|
42
57
|
callback(null, null)
|
|
43
58
|
}
|
package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/SensorsModule.kt
CHANGED
|
@@ -59,9 +59,15 @@ class SensorsModule : NativeModule {
|
|
|
59
59
|
// -- Accelerometer --
|
|
60
60
|
|
|
61
61
|
private fun startAccelerometer(delay: Int, callback: (Any?, String?) -> Unit) {
|
|
62
|
-
val sm = sensorManager ?: run {
|
|
62
|
+
val sm = sensorManager ?: run {
|
|
63
|
+
callback(null, "SensorManager not available")
|
|
64
|
+
return
|
|
65
|
+
}
|
|
63
66
|
val sensor = sm.getDefaultSensor(Sensor.TYPE_ACCELEROMETER)
|
|
64
|
-
?: run {
|
|
67
|
+
?: run {
|
|
68
|
+
callback(null, "Accelerometer not available on this device")
|
|
69
|
+
return
|
|
70
|
+
}
|
|
65
71
|
|
|
66
72
|
// Stop previous if running
|
|
67
73
|
stopAccelerometer()
|
|
@@ -90,9 +96,15 @@ class SensorsModule : NativeModule {
|
|
|
90
96
|
// -- Gyroscope --
|
|
91
97
|
|
|
92
98
|
private fun startGyroscope(delay: Int, callback: (Any?, String?) -> Unit) {
|
|
93
|
-
val sm = sensorManager ?: run {
|
|
99
|
+
val sm = sensorManager ?: run {
|
|
100
|
+
callback(null, "SensorManager not available")
|
|
101
|
+
return
|
|
102
|
+
}
|
|
94
103
|
val sensor = sm.getDefaultSensor(Sensor.TYPE_GYROSCOPE)
|
|
95
|
-
?: run {
|
|
104
|
+
?: run {
|
|
105
|
+
callback(null, "Gyroscope not available on this device")
|
|
106
|
+
return
|
|
107
|
+
}
|
|
96
108
|
|
|
97
109
|
// Stop previous if running
|
|
98
110
|
stopGyroscope()
|
package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/ShareModule.kt
CHANGED
|
@@ -12,13 +12,16 @@ class ShareModule : NativeModule {
|
|
|
12
12
|
}
|
|
13
13
|
|
|
14
14
|
override fun invoke(method: String, args: List<Any?>, bridge: NativeBridge, callback: (Any?, String?) -> Unit) {
|
|
15
|
-
val ctx = context ?: run {
|
|
15
|
+
val ctx = context ?: run {
|
|
16
|
+
callback(null, "Not initialized")
|
|
17
|
+
return
|
|
18
|
+
}
|
|
16
19
|
when (method) {
|
|
17
20
|
"share" -> {
|
|
18
21
|
val content = args.getOrNull(0) as? Map<*, *>
|
|
19
22
|
val message = content?.get("message")?.toString() ?: ""
|
|
20
|
-
val url
|
|
21
|
-
val text
|
|
23
|
+
val url = content?.get("url")?.toString() ?: ""
|
|
24
|
+
val text = if (url.isNotEmpty()) "$message\n$url" else message
|
|
22
25
|
|
|
23
26
|
val intent = Intent(Intent.ACTION_SEND).apply {
|
|
24
27
|
type = "text/plain"
|
package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/SocialAuthModule.kt
CHANGED
|
@@ -2,7 +2,6 @@ package com.vuenative.core
|
|
|
2
2
|
|
|
3
3
|
import android.app.Activity
|
|
4
4
|
import android.content.Context
|
|
5
|
-
import android.content.Intent
|
|
6
5
|
import android.content.SharedPreferences
|
|
7
6
|
import android.os.Handler
|
|
8
7
|
import android.os.Looper
|
|
@@ -64,7 +63,10 @@ class SocialAuthModule : NativeModule {
|
|
|
64
63
|
// ── Google Sign In via Credential Manager ───────────────────────────────
|
|
65
64
|
|
|
66
65
|
private fun handleGoogleSignIn(clientId: String, callback: (Any?, String?) -> Unit) {
|
|
67
|
-
val ctx = context ?: run {
|
|
66
|
+
val ctx = context ?: run {
|
|
67
|
+
callback(null, "SocialAuth: no context")
|
|
68
|
+
return
|
|
69
|
+
}
|
|
68
70
|
val activity = ctx as? Activity
|
|
69
71
|
|
|
70
72
|
if (activity == null) {
|
package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/WebSocketModule.kt
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
package com.vuenative.core
|
|
2
2
|
|
|
3
3
|
import android.content.Context
|
|
4
|
+
import java.util.concurrent.ConcurrentHashMap
|
|
5
|
+
import java.util.concurrent.TimeUnit
|
|
4
6
|
import okhttp3.OkHttpClient
|
|
5
7
|
import okhttp3.Request
|
|
6
8
|
import okhttp3.Response
|
|
7
9
|
import okhttp3.WebSocket
|
|
8
10
|
import okhttp3.WebSocketListener
|
|
9
|
-
import java.util.concurrent.ConcurrentHashMap
|
|
10
|
-
import java.util.concurrent.TimeUnit
|
|
11
11
|
|
|
12
12
|
/**
|
|
13
13
|
* Native module for WebSocket connections using OkHttp.
|
|
@@ -47,21 +47,36 @@ class WebSocketModule : NativeModule {
|
|
|
47
47
|
when (method) {
|
|
48
48
|
"connect" -> {
|
|
49
49
|
val url = args.getOrNull(0) as? String
|
|
50
|
-
?: run {
|
|
50
|
+
?: run {
|
|
51
|
+
callback(null, "WebSocketModule: expected url")
|
|
52
|
+
return
|
|
53
|
+
}
|
|
51
54
|
val connectionId = args.getOrNull(1) as? String
|
|
52
|
-
?: run {
|
|
55
|
+
?: run {
|
|
56
|
+
callback(null, "WebSocketModule: expected connectionId")
|
|
57
|
+
return
|
|
58
|
+
}
|
|
53
59
|
connect(url, connectionId, bridge, callback)
|
|
54
60
|
}
|
|
55
61
|
"send" -> {
|
|
56
62
|
val connectionId = args.getOrNull(0) as? String
|
|
57
|
-
?: run {
|
|
63
|
+
?: run {
|
|
64
|
+
callback(null, "WebSocketModule: expected connectionId")
|
|
65
|
+
return
|
|
66
|
+
}
|
|
58
67
|
val data = args.getOrNull(1) as? String
|
|
59
|
-
?: run {
|
|
68
|
+
?: run {
|
|
69
|
+
callback(null, "WebSocketModule: expected data")
|
|
70
|
+
return
|
|
71
|
+
}
|
|
60
72
|
send(connectionId, data, callback)
|
|
61
73
|
}
|
|
62
74
|
"close" -> {
|
|
63
75
|
val connectionId = args.getOrNull(0) as? String
|
|
64
|
-
?: run {
|
|
76
|
+
?: run {
|
|
77
|
+
callback(null, "WebSocketModule: expected connectionId")
|
|
78
|
+
return
|
|
79
|
+
}
|
|
65
80
|
val code = (args.getOrNull(1) as? Number)?.toInt() ?: 1000
|
|
66
81
|
val reason = args.getOrNull(2) as? String ?: ""
|
|
67
82
|
close(connectionId, code, reason, bridge, callback)
|
|
@@ -125,7 +140,10 @@ class WebSocketModule : NativeModule {
|
|
|
125
140
|
|
|
126
141
|
private fun send(connectionId: String, data: String, callback: (Any?, String?) -> Unit) {
|
|
127
142
|
val ws = connections[connectionId]
|
|
128
|
-
?: run {
|
|
143
|
+
?: run {
|
|
144
|
+
callback(null, "WebSocketModule: no connection '$connectionId'")
|
|
145
|
+
return
|
|
146
|
+
}
|
|
129
147
|
val sent = ws.send(data)
|
|
130
148
|
if (sent) {
|
|
131
149
|
callback(true, null)
|