@thelacanians/vue-native-cli 0.4.11 → 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/CalendarModule.kt
CHANGED
|
@@ -18,7 +18,10 @@ class CalendarModule : NativeModule {
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
override fun invoke(method: String, args: List<Any?>, bridge: NativeBridge, callback: (Any?, String?) -> Unit) {
|
|
21
|
-
val ctx = context ?: run {
|
|
21
|
+
val ctx = context ?: run {
|
|
22
|
+
callback(null, "Not initialized")
|
|
23
|
+
return
|
|
24
|
+
}
|
|
22
25
|
|
|
23
26
|
when (method) {
|
|
24
27
|
"requestAccess" -> {
|
|
@@ -29,14 +32,17 @@ class CalendarModule : NativeModule {
|
|
|
29
32
|
|
|
30
33
|
"getEvents" -> {
|
|
31
34
|
val startMs = (args.getOrNull(0) as? Number)?.toLong() ?: run {
|
|
32
|
-
callback(null, "Missing startDate")
|
|
35
|
+
callback(null, "Missing startDate")
|
|
36
|
+
return
|
|
33
37
|
}
|
|
34
38
|
val endMs = (args.getOrNull(1) as? Number)?.toLong() ?: run {
|
|
35
|
-
callback(null, "Missing endDate")
|
|
39
|
+
callback(null, "Missing endDate")
|
|
40
|
+
return
|
|
36
41
|
}
|
|
37
42
|
|
|
38
43
|
if (!hasCalendarReadPermission(ctx)) {
|
|
39
|
-
callback(null, "Calendar read permission not granted")
|
|
44
|
+
callback(null, "Calendar read permission not granted")
|
|
45
|
+
return
|
|
40
46
|
}
|
|
41
47
|
|
|
42
48
|
try {
|
|
@@ -79,19 +85,23 @@ class CalendarModule : NativeModule {
|
|
|
79
85
|
|
|
80
86
|
"createEvent" -> {
|
|
81
87
|
val title = args.getOrNull(0)?.toString() ?: run {
|
|
82
|
-
callback(null, "Missing title")
|
|
88
|
+
callback(null, "Missing title")
|
|
89
|
+
return
|
|
83
90
|
}
|
|
84
91
|
val startMs = (args.getOrNull(1) as? Number)?.toLong() ?: run {
|
|
85
|
-
callback(null, "Missing startDate")
|
|
92
|
+
callback(null, "Missing startDate")
|
|
93
|
+
return
|
|
86
94
|
}
|
|
87
95
|
val endMs = (args.getOrNull(2) as? Number)?.toLong() ?: run {
|
|
88
|
-
callback(null, "Missing endDate")
|
|
96
|
+
callback(null, "Missing endDate")
|
|
97
|
+
return
|
|
89
98
|
}
|
|
90
99
|
val notes = args.getOrNull(3)?.toString()
|
|
91
100
|
val calendarId = args.getOrNull(4)?.toString()
|
|
92
101
|
|
|
93
102
|
if (!hasCalendarWritePermission(ctx)) {
|
|
94
|
-
callback(null, "Calendar write permission not granted")
|
|
103
|
+
callback(null, "Calendar write permission not granted")
|
|
104
|
+
return
|
|
95
105
|
}
|
|
96
106
|
|
|
97
107
|
try {
|
|
@@ -117,11 +127,13 @@ class CalendarModule : NativeModule {
|
|
|
117
127
|
|
|
118
128
|
"deleteEvent" -> {
|
|
119
129
|
val eventId = args.getOrNull(0)?.toString() ?: run {
|
|
120
|
-
callback(null, "Missing eventId")
|
|
130
|
+
callback(null, "Missing eventId")
|
|
131
|
+
return
|
|
121
132
|
}
|
|
122
133
|
|
|
123
134
|
if (!hasCalendarWritePermission(ctx)) {
|
|
124
|
-
callback(null, "Calendar write permission not granted")
|
|
135
|
+
callback(null, "Calendar write permission not granted")
|
|
136
|
+
return
|
|
125
137
|
}
|
|
126
138
|
|
|
127
139
|
try {
|
|
@@ -135,7 +147,8 @@ class CalendarModule : NativeModule {
|
|
|
135
147
|
|
|
136
148
|
"getCalendars" -> {
|
|
137
149
|
if (!hasCalendarReadPermission(ctx)) {
|
|
138
|
-
callback(null, "Calendar read permission not granted")
|
|
150
|
+
callback(null, "Calendar read permission not granted")
|
|
151
|
+
return
|
|
139
152
|
}
|
|
140
153
|
|
|
141
154
|
try {
|
package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/ClipboardModule.kt
CHANGED
|
@@ -13,7 +13,10 @@ class ClipboardModule : NativeModule {
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
override fun invoke(method: String, args: List<Any?>, bridge: NativeBridge, callback: (Any?, String?) -> Unit) {
|
|
16
|
-
val cb = clipboard ?: run {
|
|
16
|
+
val cb = clipboard ?: run {
|
|
17
|
+
callback(null, "Clipboard not available")
|
|
18
|
+
return
|
|
19
|
+
}
|
|
17
20
|
when (method) {
|
|
18
21
|
"setString", "setContent" -> {
|
|
19
22
|
val text = args.getOrNull(0)?.toString() ?: ""
|
|
@@ -24,7 +27,9 @@ class ClipboardModule : NativeModule {
|
|
|
24
27
|
val clip = cb.primaryClip
|
|
25
28
|
val text = if (clip != null && clip.itemCount > 0) {
|
|
26
29
|
clip.getItemAt(0)?.text?.toString()
|
|
27
|
-
} else
|
|
30
|
+
} else {
|
|
31
|
+
null
|
|
32
|
+
}
|
|
28
33
|
callback(text, null)
|
|
29
34
|
}
|
|
30
35
|
"hasString" -> {
|
package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/ContactsModule.kt
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
package com.vuenative.core
|
|
2
2
|
|
|
3
3
|
import android.Manifest
|
|
4
|
-
import android.content.ContentValues
|
|
5
4
|
import android.content.Context
|
|
6
5
|
import android.content.pm.PackageManager
|
|
7
|
-
import android.net.Uri
|
|
8
6
|
import android.provider.ContactsContract
|
|
9
7
|
import androidx.core.content.ContextCompat
|
|
10
8
|
|
|
@@ -18,7 +16,10 @@ class ContactsModule : NativeModule {
|
|
|
18
16
|
}
|
|
19
17
|
|
|
20
18
|
override fun invoke(method: String, args: List<Any?>, bridge: NativeBridge, callback: (Any?, String?) -> Unit) {
|
|
21
|
-
val ctx = context ?: run {
|
|
19
|
+
val ctx = context ?: run {
|
|
20
|
+
callback(null, "Not initialized")
|
|
21
|
+
return
|
|
22
|
+
}
|
|
22
23
|
|
|
23
24
|
when (method) {
|
|
24
25
|
"requestAccess" -> {
|
|
@@ -31,17 +32,22 @@ class ContactsModule : NativeModule {
|
|
|
31
32
|
val query = args.getOrNull(0)?.toString()
|
|
32
33
|
|
|
33
34
|
if (!hasReadPermission(ctx)) {
|
|
34
|
-
callback(null, "Contacts read permission not granted")
|
|
35
|
+
callback(null, "Contacts read permission not granted")
|
|
36
|
+
return
|
|
35
37
|
}
|
|
36
38
|
|
|
37
39
|
try {
|
|
38
40
|
val contacts = mutableListOf<Map<String, Any?>>()
|
|
39
41
|
val selection = if (!query.isNullOrEmpty()) {
|
|
40
42
|
"${ContactsContract.Contacts.DISPLAY_NAME} LIKE ?"
|
|
41
|
-
} else
|
|
43
|
+
} else {
|
|
44
|
+
null
|
|
45
|
+
}
|
|
42
46
|
val selectionArgs = if (!query.isNullOrEmpty()) {
|
|
43
47
|
arrayOf("%$query%")
|
|
44
|
-
} else
|
|
48
|
+
} else {
|
|
49
|
+
null
|
|
50
|
+
}
|
|
45
51
|
|
|
46
52
|
ctx.contentResolver.query(
|
|
47
53
|
ContactsContract.Contacts.CONTENT_URI,
|
|
@@ -88,11 +94,13 @@ class ContactsModule : NativeModule {
|
|
|
88
94
|
|
|
89
95
|
"getContact" -> {
|
|
90
96
|
val contactId = args.getOrNull(0)?.toString() ?: run {
|
|
91
|
-
callback(null, "Missing contactId")
|
|
97
|
+
callback(null, "Missing contactId")
|
|
98
|
+
return
|
|
92
99
|
}
|
|
93
100
|
|
|
94
101
|
if (!hasReadPermission(ctx)) {
|
|
95
|
-
callback(null, "Contacts read permission not granted")
|
|
102
|
+
callback(null, "Contacts read permission not granted")
|
|
103
|
+
return
|
|
96
104
|
}
|
|
97
105
|
|
|
98
106
|
try {
|
|
@@ -136,11 +144,13 @@ class ContactsModule : NativeModule {
|
|
|
136
144
|
"createContact" -> {
|
|
137
145
|
@Suppress("UNCHECKED_CAST")
|
|
138
146
|
val data = args.getOrNull(0) as? Map<String, Any?> ?: run {
|
|
139
|
-
callback(null, "Missing contact data")
|
|
147
|
+
callback(null, "Missing contact data")
|
|
148
|
+
return
|
|
140
149
|
}
|
|
141
150
|
|
|
142
151
|
if (!hasWritePermission(ctx)) {
|
|
143
|
-
callback(null, "Contacts write permission not granted")
|
|
152
|
+
callback(null, "Contacts write permission not granted")
|
|
153
|
+
return
|
|
144
154
|
}
|
|
145
155
|
|
|
146
156
|
try {
|
|
@@ -205,11 +215,13 @@ class ContactsModule : NativeModule {
|
|
|
205
215
|
|
|
206
216
|
"deleteContact" -> {
|
|
207
217
|
val contactId = args.getOrNull(0)?.toString() ?: run {
|
|
208
|
-
callback(null, "Missing contactId")
|
|
218
|
+
callback(null, "Missing contactId")
|
|
219
|
+
return
|
|
209
220
|
}
|
|
210
221
|
|
|
211
222
|
if (!hasWritePermission(ctx)) {
|
|
212
|
-
callback(null, "Contacts write permission not granted")
|
|
223
|
+
callback(null, "Contacts write permission not granted")
|
|
224
|
+
return
|
|
213
225
|
}
|
|
214
226
|
|
|
215
227
|
try {
|
package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/DeviceInfoModule.kt
CHANGED
|
@@ -13,24 +13,27 @@ class DeviceInfoModule : NativeModule {
|
|
|
13
13
|
}
|
|
14
14
|
|
|
15
15
|
override fun invoke(method: String, args: List<Any?>, bridge: NativeBridge, callback: (Any?, String?) -> Unit) {
|
|
16
|
-
val ctx = context ?: run {
|
|
16
|
+
val ctx = context ?: run {
|
|
17
|
+
callback(null, "Not initialized")
|
|
18
|
+
return
|
|
19
|
+
}
|
|
17
20
|
when (method) {
|
|
18
21
|
"getDeviceInfo", "getInfo" -> {
|
|
19
22
|
val dm = ctx.resources.displayMetrics
|
|
20
23
|
callback(mapOf(
|
|
21
|
-
"model"
|
|
22
|
-
"brand"
|
|
23
|
-
"deviceName"
|
|
24
|
-
"systemName"
|
|
24
|
+
"model" to "${Build.MANUFACTURER} ${Build.MODEL}",
|
|
25
|
+
"brand" to Build.MANUFACTURER,
|
|
26
|
+
"deviceName" to Build.MODEL,
|
|
27
|
+
"systemName" to "Android",
|
|
25
28
|
"systemVersion" to Build.VERSION.RELEASE,
|
|
26
|
-
"screenWidth"
|
|
27
|
-
"screenHeight"
|
|
28
|
-
"screenScale"
|
|
29
|
-
"isTablet"
|
|
29
|
+
"screenWidth" to (dm.widthPixels / dm.density).toDouble(),
|
|
30
|
+
"screenHeight" to (dm.heightPixels / dm.density).toDouble(),
|
|
31
|
+
"screenScale" to dm.density.toDouble(),
|
|
32
|
+
"isTablet" to (ctx.resources.configuration.screenLayout and
|
|
30
33
|
Configuration.SCREENLAYOUT_SIZE_MASK >=
|
|
31
34
|
Configuration.SCREENLAYOUT_SIZE_LARGE),
|
|
32
|
-
"platform"
|
|
33
|
-
"bundleId"
|
|
35
|
+
"platform" to "android",
|
|
36
|
+
"bundleId" to ctx.packageName,
|
|
34
37
|
), null)
|
|
35
38
|
}
|
|
36
39
|
else -> callback(null, "Unknown method: $method")
|
package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/FileSystemModule.kt
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
package com.vuenative.core
|
|
2
2
|
|
|
3
3
|
import android.content.Context
|
|
4
|
-
import
|
|
5
|
-
import okhttp3.Request
|
|
4
|
+
import android.util.Base64
|
|
6
5
|
import java.io.File
|
|
7
6
|
import java.io.IOException
|
|
8
7
|
import java.util.concurrent.TimeUnit
|
|
9
|
-
import
|
|
8
|
+
import okhttp3.OkHttpClient
|
|
9
|
+
import okhttp3.Request
|
|
10
10
|
|
|
11
11
|
class FileSystemModule : NativeModule {
|
|
12
12
|
override val moduleName = "FileSystem"
|
|
@@ -30,11 +30,15 @@ class FileSystemModule : NativeModule {
|
|
|
30
30
|
when (method) {
|
|
31
31
|
"readFile" -> {
|
|
32
32
|
val path = args.getOrNull(0)?.toString()
|
|
33
|
-
?: run {
|
|
33
|
+
?: run {
|
|
34
|
+
callback(null, "readFile: missing path")
|
|
35
|
+
return
|
|
36
|
+
}
|
|
34
37
|
val encoding = args.getOrNull(1)?.toString() ?: "utf8"
|
|
35
38
|
val file = File(path)
|
|
36
39
|
if (!file.exists()) {
|
|
37
|
-
callback(null, "readFile: file not found at $path")
|
|
40
|
+
callback(null, "readFile: file not found at $path")
|
|
41
|
+
return
|
|
38
42
|
}
|
|
39
43
|
try {
|
|
40
44
|
if (encoding == "base64") {
|
|
@@ -49,9 +53,15 @@ class FileSystemModule : NativeModule {
|
|
|
49
53
|
}
|
|
50
54
|
"writeFile" -> {
|
|
51
55
|
val path = args.getOrNull(0)?.toString()
|
|
52
|
-
?: run {
|
|
56
|
+
?: run {
|
|
57
|
+
callback(null, "writeFile: missing path")
|
|
58
|
+
return
|
|
59
|
+
}
|
|
53
60
|
val content = args.getOrNull(1)?.toString()
|
|
54
|
-
?: run {
|
|
61
|
+
?: run {
|
|
62
|
+
callback(null, "writeFile: missing content")
|
|
63
|
+
return
|
|
64
|
+
}
|
|
55
65
|
val encoding = args.getOrNull(2)?.toString() ?: "utf8"
|
|
56
66
|
try {
|
|
57
67
|
val file = File(path)
|
|
@@ -69,10 +79,14 @@ class FileSystemModule : NativeModule {
|
|
|
69
79
|
}
|
|
70
80
|
"deleteFile" -> {
|
|
71
81
|
val path = args.getOrNull(0)?.toString()
|
|
72
|
-
?: run {
|
|
82
|
+
?: run {
|
|
83
|
+
callback(null, "deleteFile: missing path")
|
|
84
|
+
return
|
|
85
|
+
}
|
|
73
86
|
val file = File(path)
|
|
74
87
|
if (!file.exists()) {
|
|
75
|
-
callback(null, "deleteFile: file not found at $path")
|
|
88
|
+
callback(null, "deleteFile: file not found at $path")
|
|
89
|
+
return
|
|
76
90
|
}
|
|
77
91
|
try {
|
|
78
92
|
if (file.isDirectory) {
|
|
@@ -87,23 +101,36 @@ class FileSystemModule : NativeModule {
|
|
|
87
101
|
}
|
|
88
102
|
"exists" -> {
|
|
89
103
|
val path = args.getOrNull(0)?.toString()
|
|
90
|
-
?: run {
|
|
104
|
+
?: run {
|
|
105
|
+
callback(null, "exists: missing path")
|
|
106
|
+
return
|
|
107
|
+
}
|
|
91
108
|
callback(File(path).exists(), null)
|
|
92
109
|
}
|
|
93
110
|
"listDirectory" -> {
|
|
94
111
|
val path = args.getOrNull(0)?.toString()
|
|
95
|
-
?: run {
|
|
112
|
+
?: run {
|
|
113
|
+
callback(null, "listDirectory: missing path")
|
|
114
|
+
return
|
|
115
|
+
}
|
|
96
116
|
val dir = File(path)
|
|
97
117
|
if (!dir.exists() || !dir.isDirectory) {
|
|
98
|
-
callback(null, "listDirectory: not a directory at $path")
|
|
118
|
+
callback(null, "listDirectory: not a directory at $path")
|
|
119
|
+
return
|
|
99
120
|
}
|
|
100
121
|
callback(dir.list()?.toList() ?: emptyList<String>(), null)
|
|
101
122
|
}
|
|
102
123
|
"downloadFile" -> {
|
|
103
124
|
val url = args.getOrNull(0)?.toString()
|
|
104
|
-
?: run {
|
|
125
|
+
?: run {
|
|
126
|
+
callback(null, "downloadFile: missing url")
|
|
127
|
+
return
|
|
128
|
+
}
|
|
105
129
|
val destPath = args.getOrNull(1)?.toString()
|
|
106
|
-
?: run {
|
|
130
|
+
?: run {
|
|
131
|
+
callback(null, "downloadFile: missing destPath")
|
|
132
|
+
return
|
|
133
|
+
}
|
|
107
134
|
val request = Request.Builder().url(url).build()
|
|
108
135
|
client.newCall(request).enqueue(object : okhttp3.Callback {
|
|
109
136
|
override fun onFailure(call: okhttp3.Call, e: IOException) {
|
|
@@ -112,7 +139,10 @@ class FileSystemModule : NativeModule {
|
|
|
112
139
|
override fun onResponse(call: okhttp3.Call, response: okhttp3.Response) {
|
|
113
140
|
try {
|
|
114
141
|
val bytes = response.body?.bytes()
|
|
115
|
-
?: run {
|
|
142
|
+
?: run {
|
|
143
|
+
callback(null, "downloadFile: empty response")
|
|
144
|
+
return
|
|
145
|
+
}
|
|
116
146
|
val file = File(destPath)
|
|
117
147
|
file.parentFile?.mkdirs()
|
|
118
148
|
file.writeBytes(bytes)
|
|
@@ -125,20 +155,30 @@ class FileSystemModule : NativeModule {
|
|
|
125
155
|
}
|
|
126
156
|
"getDocumentsPath" -> {
|
|
127
157
|
val ctx = appContext
|
|
128
|
-
?: run {
|
|
158
|
+
?: run {
|
|
159
|
+
callback(null, "FileSystem not initialized")
|
|
160
|
+
return
|
|
161
|
+
}
|
|
129
162
|
callback(ctx.filesDir.absolutePath, null)
|
|
130
163
|
}
|
|
131
164
|
"getCachesPath" -> {
|
|
132
165
|
val ctx = appContext
|
|
133
|
-
?: run {
|
|
166
|
+
?: run {
|
|
167
|
+
callback(null, "FileSystem not initialized")
|
|
168
|
+
return
|
|
169
|
+
}
|
|
134
170
|
callback(ctx.cacheDir.absolutePath, null)
|
|
135
171
|
}
|
|
136
172
|
"stat" -> {
|
|
137
173
|
val path = args.getOrNull(0)?.toString()
|
|
138
|
-
?: run {
|
|
174
|
+
?: run {
|
|
175
|
+
callback(null, "stat: missing path")
|
|
176
|
+
return
|
|
177
|
+
}
|
|
139
178
|
val file = File(path)
|
|
140
179
|
if (!file.exists()) {
|
|
141
|
-
callback(null, "stat: file not found at $path")
|
|
180
|
+
callback(null, "stat: file not found at $path")
|
|
181
|
+
return
|
|
142
182
|
}
|
|
143
183
|
callback(mapOf(
|
|
144
184
|
"size" to file.length(),
|
|
@@ -148,7 +188,10 @@ class FileSystemModule : NativeModule {
|
|
|
148
188
|
}
|
|
149
189
|
"mkdir" -> {
|
|
150
190
|
val path = args.getOrNull(0)?.toString()
|
|
151
|
-
?: run {
|
|
191
|
+
?: run {
|
|
192
|
+
callback(null, "mkdir: missing path")
|
|
193
|
+
return
|
|
194
|
+
}
|
|
152
195
|
val dir = File(path)
|
|
153
196
|
if (dir.mkdirs() || dir.exists()) {
|
|
154
197
|
callback(null, null)
|
|
@@ -158,9 +201,15 @@ class FileSystemModule : NativeModule {
|
|
|
158
201
|
}
|
|
159
202
|
"copyFile" -> {
|
|
160
203
|
val srcPath = args.getOrNull(0)?.toString()
|
|
161
|
-
?: run {
|
|
204
|
+
?: run {
|
|
205
|
+
callback(null, "copyFile: missing srcPath")
|
|
206
|
+
return
|
|
207
|
+
}
|
|
162
208
|
val destPath = args.getOrNull(1)?.toString()
|
|
163
|
-
?: run {
|
|
209
|
+
?: run {
|
|
210
|
+
callback(null, "copyFile: missing destPath")
|
|
211
|
+
return
|
|
212
|
+
}
|
|
164
213
|
try {
|
|
165
214
|
val src = File(srcPath)
|
|
166
215
|
val dest = File(destPath)
|
|
@@ -173,9 +222,15 @@ class FileSystemModule : NativeModule {
|
|
|
173
222
|
}
|
|
174
223
|
"moveFile" -> {
|
|
175
224
|
val srcPath = args.getOrNull(0)?.toString()
|
|
176
|
-
?: run {
|
|
225
|
+
?: run {
|
|
226
|
+
callback(null, "moveFile: missing srcPath")
|
|
227
|
+
return
|
|
228
|
+
}
|
|
177
229
|
val destPath = args.getOrNull(1)?.toString()
|
|
178
|
-
?: run {
|
|
230
|
+
?: run {
|
|
231
|
+
callback(null, "moveFile: missing destPath")
|
|
232
|
+
return
|
|
233
|
+
}
|
|
179
234
|
try {
|
|
180
235
|
val src = File(srcPath)
|
|
181
236
|
val dest = File(destPath)
|
package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/GeolocationModule.kt
CHANGED
|
@@ -4,8 +4,8 @@ import android.Manifest
|
|
|
4
4
|
import android.content.Context
|
|
5
5
|
import android.content.pm.PackageManager
|
|
6
6
|
import androidx.core.content.ContextCompat
|
|
7
|
-
import com.google.android.gms.location.LocationServices
|
|
8
7
|
import com.google.android.gms.location.FusedLocationProviderClient
|
|
8
|
+
import com.google.android.gms.location.LocationServices
|
|
9
9
|
|
|
10
10
|
class GeolocationModule : NativeModule {
|
|
11
11
|
override val moduleName = "Geolocation"
|
|
@@ -26,7 +26,10 @@ class GeolocationModule : NativeModule {
|
|
|
26
26
|
) {
|
|
27
27
|
when (method) {
|
|
28
28
|
"getCurrentPosition" -> {
|
|
29
|
-
val ctx = context ?: run {
|
|
29
|
+
val ctx = context ?: run {
|
|
30
|
+
callback(null, "Not initialized")
|
|
31
|
+
return
|
|
32
|
+
}
|
|
30
33
|
if (ContextCompat.checkSelfPermission(ctx, Manifest.permission.ACCESS_FINE_LOCATION)
|
|
31
34
|
!= PackageManager.PERMISSION_GRANTED
|
|
32
35
|
) {
|
|
@@ -39,12 +42,12 @@ class GeolocationModule : NativeModule {
|
|
|
39
42
|
callback(
|
|
40
43
|
mapOf(
|
|
41
44
|
"coords" to mapOf(
|
|
42
|
-
"latitude"
|
|
45
|
+
"latitude" to location.latitude,
|
|
43
46
|
"longitude" to location.longitude,
|
|
44
|
-
"accuracy"
|
|
45
|
-
"altitude"
|
|
46
|
-
"speed"
|
|
47
|
-
"heading"
|
|
47
|
+
"accuracy" to location.accuracy.toDouble(),
|
|
48
|
+
"altitude" to location.altitude,
|
|
49
|
+
"speed" to location.speed.toDouble(),
|
|
50
|
+
"heading" to location.bearing.toDouble()
|
|
48
51
|
),
|
|
49
52
|
"timestamp" to location.time
|
|
50
53
|
), null
|
package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/HapticsModule.kt
CHANGED
|
@@ -44,13 +44,13 @@ class HapticsModule : NativeModule {
|
|
|
44
44
|
val vib = vibrator ?: return
|
|
45
45
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
|
46
46
|
val effect = when (style) {
|
|
47
|
-
"light"
|
|
48
|
-
"medium"
|
|
49
|
-
"heavy"
|
|
47
|
+
"light" -> VibrationEffect.createOneShot(30, 80)
|
|
48
|
+
"medium" -> VibrationEffect.createOneShot(50, 150)
|
|
49
|
+
"heavy" -> VibrationEffect.createOneShot(80, 200)
|
|
50
50
|
"success" -> VibrationEffect.createWaveform(longArrayOf(0, 50, 50, 50), intArrayOf(0, 180, 0, 100), -1)
|
|
51
51
|
"warning" -> VibrationEffect.createOneShot(100, 200)
|
|
52
|
-
"error"
|
|
53
|
-
else
|
|
52
|
+
"error" -> VibrationEffect.createWaveform(longArrayOf(0, 100, 50, 100), intArrayOf(0, 255, 0, 255), -1)
|
|
53
|
+
else -> VibrationEffect.createOneShot(50, 150)
|
|
54
54
|
}
|
|
55
55
|
vib.vibrate(effect)
|
|
56
56
|
} else {
|
package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/HttpModule.kt
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
package com.vuenative.core
|
|
2
2
|
|
|
3
|
+
import java.io.IOException
|
|
4
|
+
import java.util.concurrent.TimeUnit
|
|
3
5
|
import okhttp3.CertificatePinner
|
|
4
6
|
import okhttp3.MediaType.Companion.toMediaTypeOrNull
|
|
5
7
|
import okhttp3.OkHttpClient
|
|
6
8
|
import okhttp3.Request
|
|
7
9
|
import okhttp3.RequestBody.Companion.toRequestBody
|
|
8
|
-
import java.io.IOException
|
|
9
|
-
import java.util.concurrent.TimeUnit
|
|
10
10
|
|
|
11
11
|
/**
|
|
12
12
|
* HttpModule — backs the useHttp() composable.
|
|
@@ -39,7 +39,10 @@ class HttpModule : NativeModule {
|
|
|
39
39
|
"configurePins" -> {
|
|
40
40
|
@Suppress("UNCHECKED_CAST")
|
|
41
41
|
val pinsMap = args.getOrNull(0) as? Map<String, List<String>>
|
|
42
|
-
?: run {
|
|
42
|
+
?: run {
|
|
43
|
+
callback(null, "Invalid args — expected pins object")
|
|
44
|
+
return
|
|
45
|
+
}
|
|
43
46
|
|
|
44
47
|
val builder = CertificatePinner.Builder()
|
|
45
48
|
for ((domain, pins) in pinsMap) {
|
|
@@ -56,10 +59,16 @@ class HttpModule : NativeModule {
|
|
|
56
59
|
}
|
|
57
60
|
"request" -> {
|
|
58
61
|
val opts = args.getOrNull(0) as? Map<*, *>
|
|
59
|
-
?: run {
|
|
62
|
+
?: run {
|
|
63
|
+
callback(null, "Invalid args — expected options object")
|
|
64
|
+
return
|
|
65
|
+
}
|
|
60
66
|
|
|
61
67
|
val url = opts["url"]?.toString()
|
|
62
|
-
?: run {
|
|
68
|
+
?: run {
|
|
69
|
+
callback(null, "Missing required field: url")
|
|
70
|
+
return
|
|
71
|
+
}
|
|
63
72
|
val baseURL = opts["baseURL"]?.toString() ?: ""
|
|
64
73
|
val httpMethod = opts["method"]?.toString()?.uppercase() ?: "GET"
|
|
65
74
|
val body = opts["body"]?.toString() ?: ""
|
|
@@ -96,9 +105,9 @@ class HttpModule : NativeModule {
|
|
|
96
105
|
response.headers.forEach { (k, v) -> responseHeaders[k] = v }
|
|
97
106
|
callback(
|
|
98
107
|
mapOf(
|
|
99
|
-
"status"
|
|
100
|
-
"ok"
|
|
101
|
-
"data"
|
|
108
|
+
"status" to response.code,
|
|
109
|
+
"ok" to (response.code in 200..299),
|
|
110
|
+
"data" to responseBody,
|
|
102
111
|
"headers" to responseHeaders
|
|
103
112
|
), null
|
|
104
113
|
)
|
package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/IAPModule.kt
CHANGED
|
@@ -59,7 +59,10 @@ class IAPModule : NativeModule, PurchasesUpdatedListener {
|
|
|
59
59
|
// ── Initialize ──────────────────────────────────────────────────────────
|
|
60
60
|
|
|
61
61
|
private fun handleInitialize(callback: (Any?, String?) -> Unit) {
|
|
62
|
-
val ctx = context ?: run {
|
|
62
|
+
val ctx = context ?: run {
|
|
63
|
+
callback(null, "IAP: no context")
|
|
64
|
+
return
|
|
65
|
+
}
|
|
63
66
|
|
|
64
67
|
billingClient = BillingClient.newBuilder(ctx)
|
|
65
68
|
.setListener(this)
|
|
@@ -84,7 +87,10 @@ class IAPModule : NativeModule, PurchasesUpdatedListener {
|
|
|
84
87
|
// ── Get Products ────────────────────────────────────────────────────────
|
|
85
88
|
|
|
86
89
|
private fun handleGetProducts(skus: List<String>, callback: (Any?, String?) -> Unit) {
|
|
87
|
-
val client = billingClient ?: run {
|
|
90
|
+
val client = billingClient ?: run {
|
|
91
|
+
callback(null, "IAP: not initialized")
|
|
92
|
+
return
|
|
93
|
+
}
|
|
88
94
|
|
|
89
95
|
// Query both INAPP and SUBS
|
|
90
96
|
val inappParams = QueryProductDetailsParams.newBuilder()
|
|
@@ -131,7 +137,10 @@ class IAPModule : NativeModule, PurchasesUpdatedListener {
|
|
|
131
137
|
// ── Purchase ────────────────────────────────────────────────────────────
|
|
132
138
|
|
|
133
139
|
private fun handlePurchase(sku: String, bridge: NativeBridge, callback: (Any?, String?) -> Unit) {
|
|
134
|
-
val client = billingClient ?: run {
|
|
140
|
+
val client = billingClient ?: run {
|
|
141
|
+
callback(null, "IAP: not initialized")
|
|
142
|
+
return
|
|
143
|
+
}
|
|
135
144
|
val productDetails = cachedProducts[sku] ?: run {
|
|
136
145
|
callback(null, "purchase: product '$sku' not found. Call getProducts first.")
|
|
137
146
|
return
|
|
@@ -214,7 +223,10 @@ class IAPModule : NativeModule, PurchasesUpdatedListener {
|
|
|
214
223
|
// ── Restore Purchases ───────────────────────────────────────────────────
|
|
215
224
|
|
|
216
225
|
private fun handleRestorePurchases(callback: (Any?, String?) -> Unit) {
|
|
217
|
-
val client = billingClient ?: run {
|
|
226
|
+
val client = billingClient ?: run {
|
|
227
|
+
callback(null, "IAP: not initialized")
|
|
228
|
+
return
|
|
229
|
+
}
|
|
218
230
|
|
|
219
231
|
val params = QueryPurchasesParams.newBuilder()
|
|
220
232
|
.setProductType(BillingClient.ProductType.INAPP)
|
|
@@ -246,7 +258,10 @@ class IAPModule : NativeModule, PurchasesUpdatedListener {
|
|
|
246
258
|
// ── Active Subscriptions ────────────────────────────────────────────────
|
|
247
259
|
|
|
248
260
|
private fun handleGetActiveSubscriptions(callback: (Any?, String?) -> Unit) {
|
|
249
|
-
val client = billingClient ?: run {
|
|
261
|
+
val client = billingClient ?: run {
|
|
262
|
+
callback(null, "IAP: not initialized")
|
|
263
|
+
return
|
|
264
|
+
}
|
|
250
265
|
|
|
251
266
|
val params = QueryPurchasesParams.newBuilder()
|
|
252
267
|
.setProductType(BillingClient.ProductType.SUBS)
|
package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/KeyboardModule.kt
CHANGED
|
@@ -12,7 +12,10 @@ class KeyboardModule : 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
|
"dismiss" -> {
|
|
18
21
|
val imm = ctx.getSystemService(Context.INPUT_METHOD_SERVICE) as InputMethodManager
|