@thelacanians/vue-native-cli 0.4.2 → 0.4.4

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.
Files changed (172) hide show
  1. package/dist/cli.js +43 -23
  2. package/native/android/README.md +205 -0
  3. package/native/android/VueNativeCore/build.gradle.kts +100 -0
  4. package/native/android/VueNativeCore/consumer-rules.pro +12 -0
  5. package/native/android/VueNativeCore/proguard-rules.pro +33 -0
  6. package/native/android/VueNativeCore/src/main/AndroidManifest.xml +17 -0
  7. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Bridge/ErrorOverlayView.kt +94 -0
  8. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Bridge/HotReloadManager.kt +105 -0
  9. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Bridge/JSPolyfills.kt +652 -0
  10. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Bridge/JSRuntime.kt +207 -0
  11. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Bridge/NativeBridge.kt +417 -0
  12. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Components/ComponentRegistry.kt +76 -0
  13. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Components/Factories/VActionSheetFactory.kt +78 -0
  14. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Components/Factories/VActivityIndicatorFactory.kt +46 -0
  15. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Components/Factories/VAlertDialogFactory.kt +84 -0
  16. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Components/Factories/VButtonFactory.kt +73 -0
  17. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Components/Factories/VCheckboxFactory.kt +93 -0
  18. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Components/Factories/VDropdownFactory.kt +125 -0
  19. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Components/Factories/VImageFactory.kt +75 -0
  20. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Components/Factories/VInputFactory.kt +210 -0
  21. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Components/Factories/VKeyboardAvoidingFactory.kt +31 -0
  22. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Components/Factories/VListFactory.kt +183 -0
  23. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Components/Factories/VModalFactory.kt +105 -0
  24. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Components/Factories/VPickerFactory.kt +57 -0
  25. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Components/Factories/VPressableFactory.kt +109 -0
  26. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Components/Factories/VProgressBarFactory.kt +43 -0
  27. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Components/Factories/VRadioFactory.kt +103 -0
  28. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Components/Factories/VRefreshControlFactory.kt +73 -0
  29. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Components/Factories/VRootFactory.kt +39 -0
  30. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Components/Factories/VSafeAreaFactory.kt +48 -0
  31. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Components/Factories/VScrollViewFactory.kt +105 -0
  32. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Components/Factories/VSectionListFactory.kt +144 -0
  33. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Components/Factories/VSegmentedControlFactory.kt +77 -0
  34. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Components/Factories/VSliderFactory.kt +74 -0
  35. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Components/Factories/VStatusBarFactory.kt +52 -0
  36. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Components/Factories/VSwitchFactory.kt +62 -0
  37. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Components/Factories/VTextFactory.kt +53 -0
  38. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Components/Factories/VVideoFactory.kt +191 -0
  39. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Components/Factories/VViewFactory.kt +48 -0
  40. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Components/Factories/VWebViewFactory.kt +90 -0
  41. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Components/NativeComponentFactory.kt +40 -0
  42. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Components/VTextNodeView.kt +23 -0
  43. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Helpers/GestureHelper.kt +16 -0
  44. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Helpers/TouchableView.kt +105 -0
  45. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/AnimationModule.kt +292 -0
  46. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/AppStateModule.kt +41 -0
  47. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/AsyncStorageModule.kt +59 -0
  48. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/AudioModule.kt +331 -0
  49. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/BackgroundTaskModule.kt +166 -0
  50. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/BiometryModule.kt +56 -0
  51. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/BluetoothModule.kt +302 -0
  52. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/CalendarModule.kt +198 -0
  53. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/CameraModule.kt +64 -0
  54. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/ClipboardModule.kt +36 -0
  55. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/ContactsModule.kt +288 -0
  56. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/DatabaseModule.kt +229 -0
  57. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/DeviceInfoModule.kt +39 -0
  58. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/FileSystemModule.kt +193 -0
  59. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/GeolocationModule.kt +68 -0
  60. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/HapticsModule.kt +61 -0
  61. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/HttpModule.kt +111 -0
  62. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/IAPModule.kt +302 -0
  63. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/KeyboardModule.kt +26 -0
  64. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/LinkingModule.kt +43 -0
  65. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/NativeModule.kt +27 -0
  66. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/NativeModuleRegistry.kt +92 -0
  67. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/NetworkModule.kt +75 -0
  68. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/NotificationsModule.kt +181 -0
  69. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/OTAModule.kt +255 -0
  70. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/PerformanceModule.kt +147 -0
  71. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/PermissionsModule.kt +126 -0
  72. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/SecureStorageModule.kt +51 -0
  73. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/SensorsModule.kt +134 -0
  74. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/ShareModule.kt +36 -0
  75. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/SocialAuthModule.kt +160 -0
  76. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Modules/WebSocketModule.kt +155 -0
  77. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Styling/StyleEngine.kt +802 -0
  78. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/Tags.kt +43 -0
  79. package/native/android/VueNativeCore/src/main/kotlin/com/vuenative/core/VueNativeActivity.kt +169 -0
  80. package/native/android/VueNativeCore/src/main/res/values/ids.xml +8 -0
  81. package/native/android/app/build.gradle.kts +45 -0
  82. package/native/android/app/proguard-rules.pro +5 -0
  83. package/native/android/app/src/main/AndroidManifest.xml +25 -0
  84. package/native/android/app/src/main/assets/.gitkeep +0 -0
  85. package/native/android/app/src/main/kotlin/com/vuenative/example/counter/MainActivity.kt +14 -0
  86. package/native/android/app/src/main/res/layout/activity_main.xml +6 -0
  87. package/native/android/app/src/main/res/values/strings.xml +3 -0
  88. package/native/android/app/src/main/res/values/themes.xml +9 -0
  89. package/native/android/app/src/main/res/xml/network_security_config.xml +8 -0
  90. package/native/android/build.gradle.kts +6 -0
  91. package/native/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  92. package/native/android/gradle/wrapper/gradle-wrapper.properties +7 -0
  93. package/native/android/gradle.properties +4 -0
  94. package/native/android/gradlew +87 -0
  95. package/native/android/gradlew.bat +48 -0
  96. package/native/android/settings.gradle.kts +20 -0
  97. package/native/ios/VueNativeCore/Package.resolved +23 -0
  98. package/native/ios/VueNativeCore/Package.swift +32 -0
  99. package/native/ios/VueNativeCore/Sources/VueNativeCore/Bridge/CertificatePinning.swift +132 -0
  100. package/native/ios/VueNativeCore/Sources/VueNativeCore/Bridge/ErrorOverlayView.swift +92 -0
  101. package/native/ios/VueNativeCore/Sources/VueNativeCore/Bridge/HotReloadManager.swift +147 -0
  102. package/native/ios/VueNativeCore/Sources/VueNativeCore/Bridge/JSPolyfills.swift +711 -0
  103. package/native/ios/VueNativeCore/Sources/VueNativeCore/Bridge/JSRuntime.swift +421 -0
  104. package/native/ios/VueNativeCore/Sources/VueNativeCore/Bridge/NativeBridge.swift +891 -0
  105. package/native/ios/VueNativeCore/Sources/VueNativeCore/Bridge/VueNativeViewController.swift +88 -0
  106. package/native/ios/VueNativeCore/Sources/VueNativeCore/Components/ComponentRegistry.swift +193 -0
  107. package/native/ios/VueNativeCore/Sources/VueNativeCore/Components/Factories/VActionSheetFactory.swift +91 -0
  108. package/native/ios/VueNativeCore/Sources/VueNativeCore/Components/Factories/VActivityIndicatorFactory.swift +74 -0
  109. package/native/ios/VueNativeCore/Sources/VueNativeCore/Components/Factories/VAlertDialogFactory.swift +150 -0
  110. package/native/ios/VueNativeCore/Sources/VueNativeCore/Components/Factories/VButtonFactory.swift +93 -0
  111. package/native/ios/VueNativeCore/Sources/VueNativeCore/Components/Factories/VCheckboxFactory.swift +114 -0
  112. package/native/ios/VueNativeCore/Sources/VueNativeCore/Components/Factories/VDropdownFactory.swift +112 -0
  113. package/native/ios/VueNativeCore/Sources/VueNativeCore/Components/Factories/VImageFactory.swift +172 -0
  114. package/native/ios/VueNativeCore/Sources/VueNativeCore/Components/Factories/VInputFactory.swift +357 -0
  115. package/native/ios/VueNativeCore/Sources/VueNativeCore/Components/Factories/VKeyboardAvoidingFactory.swift +99 -0
  116. package/native/ios/VueNativeCore/Sources/VueNativeCore/Components/Factories/VListFactory.swift +250 -0
  117. package/native/ios/VueNativeCore/Sources/VueNativeCore/Components/Factories/VModalFactory.swift +112 -0
  118. package/native/ios/VueNativeCore/Sources/VueNativeCore/Components/Factories/VPickerFactory.swift +96 -0
  119. package/native/ios/VueNativeCore/Sources/VueNativeCore/Components/Factories/VPressableFactory.swift +168 -0
  120. package/native/ios/VueNativeCore/Sources/VueNativeCore/Components/Factories/VProgressBarFactory.swift +39 -0
  121. package/native/ios/VueNativeCore/Sources/VueNativeCore/Components/Factories/VRadioFactory.swift +167 -0
  122. package/native/ios/VueNativeCore/Sources/VueNativeCore/Components/Factories/VRefreshControlFactory.swift +153 -0
  123. package/native/ios/VueNativeCore/Sources/VueNativeCore/Components/Factories/VSafeAreaFactory.swift +56 -0
  124. package/native/ios/VueNativeCore/Sources/VueNativeCore/Components/Factories/VScrollViewFactory.swift +240 -0
  125. package/native/ios/VueNativeCore/Sources/VueNativeCore/Components/Factories/VSectionListFactory.swift +248 -0
  126. package/native/ios/VueNativeCore/Sources/VueNativeCore/Components/Factories/VSegmentedControlFactory.swift +73 -0
  127. package/native/ios/VueNativeCore/Sources/VueNativeCore/Components/Factories/VSliderFactory.swift +63 -0
  128. package/native/ios/VueNativeCore/Sources/VueNativeCore/Components/Factories/VStatusBarFactory.swift +50 -0
  129. package/native/ios/VueNativeCore/Sources/VueNativeCore/Components/Factories/VSwitchFactory.swift +108 -0
  130. package/native/ios/VueNativeCore/Sources/VueNativeCore/Components/Factories/VTextFactory.swift +290 -0
  131. package/native/ios/VueNativeCore/Sources/VueNativeCore/Components/Factories/VVideoFactory.swift +246 -0
  132. package/native/ios/VueNativeCore/Sources/VueNativeCore/Components/Factories/VViewFactory.swift +157 -0
  133. package/native/ios/VueNativeCore/Sources/VueNativeCore/Components/Factories/VWebViewFactory.swift +172 -0
  134. package/native/ios/VueNativeCore/Sources/VueNativeCore/Components/NativeComponentFactory.swift +53 -0
  135. package/native/ios/VueNativeCore/Sources/VueNativeCore/Helpers/GestureWrapper.swift +107 -0
  136. package/native/ios/VueNativeCore/Sources/VueNativeCore/Helpers/TouchableView.swift +136 -0
  137. package/native/ios/VueNativeCore/Sources/VueNativeCore/Helpers/UIColor+Hex.swift +80 -0
  138. package/native/ios/VueNativeCore/Sources/VueNativeCore/Modules/AnimationModule.swift +291 -0
  139. package/native/ios/VueNativeCore/Sources/VueNativeCore/Modules/AppStateModule.swift +65 -0
  140. package/native/ios/VueNativeCore/Sources/VueNativeCore/Modules/AsyncStorageModule.swift +68 -0
  141. package/native/ios/VueNativeCore/Sources/VueNativeCore/Modules/AudioModule.swift +366 -0
  142. package/native/ios/VueNativeCore/Sources/VueNativeCore/Modules/BackgroundTaskModule.swift +135 -0
  143. package/native/ios/VueNativeCore/Sources/VueNativeCore/Modules/BiometryModule.swift +61 -0
  144. package/native/ios/VueNativeCore/Sources/VueNativeCore/Modules/BluetoothModule.swift +387 -0
  145. package/native/ios/VueNativeCore/Sources/VueNativeCore/Modules/CalendarModule.swift +161 -0
  146. package/native/ios/VueNativeCore/Sources/VueNativeCore/Modules/CameraModule.swift +318 -0
  147. package/native/ios/VueNativeCore/Sources/VueNativeCore/Modules/ClipboardModule.swift +33 -0
  148. package/native/ios/VueNativeCore/Sources/VueNativeCore/Modules/ContactsModule.swift +173 -0
  149. package/native/ios/VueNativeCore/Sources/VueNativeCore/Modules/DatabaseModule.swift +259 -0
  150. package/native/ios/VueNativeCore/Sources/VueNativeCore/Modules/DeviceInfoModule.swift +34 -0
  151. package/native/ios/VueNativeCore/Sources/VueNativeCore/Modules/FileSystemModule.swift +233 -0
  152. package/native/ios/VueNativeCore/Sources/VueNativeCore/Modules/GeolocationModule.swift +147 -0
  153. package/native/ios/VueNativeCore/Sources/VueNativeCore/Modules/HapticsModule.swift +50 -0
  154. package/native/ios/VueNativeCore/Sources/VueNativeCore/Modules/IAPModule.swift +194 -0
  155. package/native/ios/VueNativeCore/Sources/VueNativeCore/Modules/KeyboardModule.swift +31 -0
  156. package/native/ios/VueNativeCore/Sources/VueNativeCore/Modules/LinkingModule.swift +42 -0
  157. package/native/ios/VueNativeCore/Sources/VueNativeCore/Modules/NativeModule.swift +28 -0
  158. package/native/ios/VueNativeCore/Sources/VueNativeCore/Modules/NativeModuleRegistry.swift +78 -0
  159. package/native/ios/VueNativeCore/Sources/VueNativeCore/Modules/NetworkModule.swift +62 -0
  160. package/native/ios/VueNativeCore/Sources/VueNativeCore/Modules/NotificationsModule.swift +215 -0
  161. package/native/ios/VueNativeCore/Sources/VueNativeCore/Modules/OTAModule.swift +281 -0
  162. package/native/ios/VueNativeCore/Sources/VueNativeCore/Modules/PerformanceModule.swift +138 -0
  163. package/native/ios/VueNativeCore/Sources/VueNativeCore/Modules/PermissionsModule.swift +190 -0
  164. package/native/ios/VueNativeCore/Sources/VueNativeCore/Modules/SecureStorageModule.swift +118 -0
  165. package/native/ios/VueNativeCore/Sources/VueNativeCore/Modules/SensorsModule.swift +103 -0
  166. package/native/ios/VueNativeCore/Sources/VueNativeCore/Modules/ShareModule.swift +49 -0
  167. package/native/ios/VueNativeCore/Sources/VueNativeCore/Modules/SocialAuthModule.swift +240 -0
  168. package/native/ios/VueNativeCore/Sources/VueNativeCore/Modules/WebSocketModule.swift +213 -0
  169. package/native/ios/VueNativeCore/Sources/VueNativeCore/Resources/vue-native-placeholder.js +8 -0
  170. package/native/ios/VueNativeCore/Sources/VueNativeCore/Styling/StyleEngine.swift +885 -0
  171. package/native/ios/VueNativeCore/Tests/VueNativeCoreTests/JSRuntimeTests.swift +362 -0
  172. package/package.json +3 -2
@@ -0,0 +1,193 @@
1
+ package com.vuenative.core
2
+
3
+ import android.content.Context
4
+ import okhttp3.OkHttpClient
5
+ import okhttp3.Request
6
+ import java.io.File
7
+ import java.io.IOException
8
+ import java.util.concurrent.TimeUnit
9
+ import android.util.Base64
10
+
11
+ class FileSystemModule : NativeModule {
12
+ override val moduleName = "FileSystem"
13
+ private var appContext: Context? = null
14
+
15
+ private val client = OkHttpClient.Builder()
16
+ .connectTimeout(30, TimeUnit.SECONDS)
17
+ .readTimeout(30, TimeUnit.SECONDS)
18
+ .build()
19
+
20
+ override fun initialize(context: Context, bridge: NativeBridge) {
21
+ appContext = context
22
+ }
23
+
24
+ override fun invoke(
25
+ method: String,
26
+ args: List<Any?>,
27
+ bridge: NativeBridge,
28
+ callback: (Any?, String?) -> Unit
29
+ ) {
30
+ when (method) {
31
+ "readFile" -> {
32
+ val path = args.getOrNull(0)?.toString()
33
+ ?: run { callback(null, "readFile: missing path"); return }
34
+ val encoding = args.getOrNull(1)?.toString() ?: "utf8"
35
+ val file = File(path)
36
+ if (!file.exists()) {
37
+ callback(null, "readFile: file not found at $path"); return
38
+ }
39
+ try {
40
+ if (encoding == "base64") {
41
+ val bytes = file.readBytes()
42
+ callback(Base64.encodeToString(bytes, Base64.NO_WRAP), null)
43
+ } else {
44
+ callback(file.readText(Charsets.UTF_8), null)
45
+ }
46
+ } catch (e: Exception) {
47
+ callback(null, "readFile: ${e.message}")
48
+ }
49
+ }
50
+ "writeFile" -> {
51
+ val path = args.getOrNull(0)?.toString()
52
+ ?: run { callback(null, "writeFile: missing path"); return }
53
+ val content = args.getOrNull(1)?.toString()
54
+ ?: run { callback(null, "writeFile: missing content"); return }
55
+ val encoding = args.getOrNull(2)?.toString() ?: "utf8"
56
+ try {
57
+ val file = File(path)
58
+ file.parentFile?.mkdirs()
59
+ if (encoding == "base64") {
60
+ val bytes = Base64.decode(content, Base64.DEFAULT)
61
+ file.writeBytes(bytes)
62
+ } else {
63
+ file.writeText(content, Charsets.UTF_8)
64
+ }
65
+ callback(null, null)
66
+ } catch (e: Exception) {
67
+ callback(null, "writeFile: ${e.message}")
68
+ }
69
+ }
70
+ "deleteFile" -> {
71
+ val path = args.getOrNull(0)?.toString()
72
+ ?: run { callback(null, "deleteFile: missing path"); return }
73
+ val file = File(path)
74
+ if (!file.exists()) {
75
+ callback(null, "deleteFile: file not found at $path"); return
76
+ }
77
+ try {
78
+ if (file.isDirectory) {
79
+ file.deleteRecursively()
80
+ } else {
81
+ file.delete()
82
+ }
83
+ callback(null, null)
84
+ } catch (e: Exception) {
85
+ callback(null, "deleteFile: ${e.message}")
86
+ }
87
+ }
88
+ "exists" -> {
89
+ val path = args.getOrNull(0)?.toString()
90
+ ?: run { callback(null, "exists: missing path"); return }
91
+ callback(File(path).exists(), null)
92
+ }
93
+ "listDirectory" -> {
94
+ val path = args.getOrNull(0)?.toString()
95
+ ?: run { callback(null, "listDirectory: missing path"); return }
96
+ val dir = File(path)
97
+ if (!dir.exists() || !dir.isDirectory) {
98
+ callback(null, "listDirectory: not a directory at $path"); return
99
+ }
100
+ callback(dir.list()?.toList() ?: emptyList<String>(), null)
101
+ }
102
+ "downloadFile" -> {
103
+ val url = args.getOrNull(0)?.toString()
104
+ ?: run { callback(null, "downloadFile: missing url"); return }
105
+ val destPath = args.getOrNull(1)?.toString()
106
+ ?: run { callback(null, "downloadFile: missing destPath"); return }
107
+ val request = Request.Builder().url(url).build()
108
+ client.newCall(request).enqueue(object : okhttp3.Callback {
109
+ override fun onFailure(call: okhttp3.Call, e: IOException) {
110
+ callback(null, "downloadFile: ${e.message}")
111
+ }
112
+ override fun onResponse(call: okhttp3.Call, response: okhttp3.Response) {
113
+ try {
114
+ val bytes = response.body?.bytes()
115
+ ?: run { callback(null, "downloadFile: empty response"); return }
116
+ val file = File(destPath)
117
+ file.parentFile?.mkdirs()
118
+ file.writeBytes(bytes)
119
+ callback(destPath, null)
120
+ } catch (e: Exception) {
121
+ callback(null, "downloadFile: ${e.message}")
122
+ }
123
+ }
124
+ })
125
+ }
126
+ "getDocumentsPath" -> {
127
+ val ctx = appContext
128
+ ?: run { callback(null, "FileSystem not initialized"); return }
129
+ callback(ctx.filesDir.absolutePath, null)
130
+ }
131
+ "getCachesPath" -> {
132
+ val ctx = appContext
133
+ ?: run { callback(null, "FileSystem not initialized"); return }
134
+ callback(ctx.cacheDir.absolutePath, null)
135
+ }
136
+ "stat" -> {
137
+ val path = args.getOrNull(0)?.toString()
138
+ ?: run { callback(null, "stat: missing path"); return }
139
+ val file = File(path)
140
+ if (!file.exists()) {
141
+ callback(null, "stat: file not found at $path"); return
142
+ }
143
+ callback(mapOf(
144
+ "size" to file.length(),
145
+ "isDirectory" to file.isDirectory,
146
+ "modified" to file.lastModified()
147
+ ), null)
148
+ }
149
+ "mkdir" -> {
150
+ val path = args.getOrNull(0)?.toString()
151
+ ?: run { callback(null, "mkdir: missing path"); return }
152
+ val dir = File(path)
153
+ if (dir.mkdirs() || dir.exists()) {
154
+ callback(null, null)
155
+ } else {
156
+ callback(null, "mkdir: could not create directory at $path")
157
+ }
158
+ }
159
+ "copyFile" -> {
160
+ val srcPath = args.getOrNull(0)?.toString()
161
+ ?: run { callback(null, "copyFile: missing srcPath"); return }
162
+ val destPath = args.getOrNull(1)?.toString()
163
+ ?: run { callback(null, "copyFile: missing destPath"); return }
164
+ try {
165
+ val src = File(srcPath)
166
+ val dest = File(destPath)
167
+ dest.parentFile?.mkdirs()
168
+ src.copyTo(dest, overwrite = true)
169
+ callback(null, null)
170
+ } catch (e: Exception) {
171
+ callback(null, "copyFile: ${e.message}")
172
+ }
173
+ }
174
+ "moveFile" -> {
175
+ val srcPath = args.getOrNull(0)?.toString()
176
+ ?: run { callback(null, "moveFile: missing srcPath"); return }
177
+ val destPath = args.getOrNull(1)?.toString()
178
+ ?: run { callback(null, "moveFile: missing destPath"); return }
179
+ try {
180
+ val src = File(srcPath)
181
+ val dest = File(destPath)
182
+ dest.parentFile?.mkdirs()
183
+ src.copyTo(dest, overwrite = true)
184
+ src.delete()
185
+ callback(null, null)
186
+ } catch (e: Exception) {
187
+ callback(null, "moveFile: ${e.message}")
188
+ }
189
+ }
190
+ else -> callback(null, "Unknown method: $method")
191
+ }
192
+ }
193
+ }
@@ -0,0 +1,68 @@
1
+ package com.vuenative.core
2
+
3
+ import android.Manifest
4
+ import android.content.Context
5
+ import android.content.pm.PackageManager
6
+ import androidx.core.content.ContextCompat
7
+ import com.google.android.gms.location.LocationServices
8
+ import com.google.android.gms.location.FusedLocationProviderClient
9
+
10
+ class GeolocationModule : NativeModule {
11
+ override val moduleName = "Geolocation"
12
+
13
+ private var fusedClient: FusedLocationProviderClient? = null
14
+ private var context: Context? = null
15
+
16
+ override fun initialize(context: Context, bridge: NativeBridge) {
17
+ this.context = context
18
+ fusedClient = LocationServices.getFusedLocationProviderClient(context)
19
+ }
20
+
21
+ override fun invoke(
22
+ method: String,
23
+ args: List<Any?>,
24
+ bridge: NativeBridge,
25
+ callback: (Any?, String?) -> Unit
26
+ ) {
27
+ when (method) {
28
+ "getCurrentPosition" -> {
29
+ val ctx = context ?: run { callback(null, "Not initialized"); return }
30
+ if (ContextCompat.checkSelfPermission(ctx, Manifest.permission.ACCESS_FINE_LOCATION)
31
+ != PackageManager.PERMISSION_GRANTED
32
+ ) {
33
+ callback(null, "Location permission not granted. Request permission first.")
34
+ return
35
+ }
36
+ fusedClient?.lastLocation
37
+ ?.addOnSuccessListener { location ->
38
+ if (location != null) {
39
+ callback(
40
+ mapOf(
41
+ "coords" to mapOf(
42
+ "latitude" to location.latitude,
43
+ "longitude" to location.longitude,
44
+ "accuracy" to location.accuracy.toDouble(),
45
+ "altitude" to location.altitude,
46
+ "speed" to location.speed.toDouble(),
47
+ "heading" to location.bearing.toDouble()
48
+ ),
49
+ "timestamp" to location.time
50
+ ), null
51
+ )
52
+ } else {
53
+ callback(null, "Location unavailable — no last known position")
54
+ }
55
+ }
56
+ ?.addOnFailureListener { e ->
57
+ callback(null, e.message ?: "Location error")
58
+ }
59
+ }
60
+ "requestAuthorization" -> {
61
+ // Authorization must be handled via PermissionsModule / Activity; signal success
62
+ // so composables can call getCurrentPosition without a separate step.
63
+ callback(mapOf("status" to "whenInUse"), null)
64
+ }
65
+ else -> callback(null, "Unknown method: $method")
66
+ }
67
+ }
68
+ }
@@ -0,0 +1,61 @@
1
+ package com.vuenative.core
2
+
3
+ import android.content.Context
4
+ import android.os.Build
5
+ import android.os.VibrationEffect
6
+ import android.os.Vibrator
7
+ import android.os.VibratorManager
8
+
9
+ class HapticsModule : NativeModule {
10
+ override val moduleName = "Haptics"
11
+ private var vibrator: Vibrator? = null
12
+
13
+ override fun initialize(context: Context, bridge: NativeBridge) {
14
+ vibrator = if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.S) {
15
+ val vm = context.getSystemService(Context.VIBRATOR_MANAGER_SERVICE) as VibratorManager
16
+ vm.defaultVibrator
17
+ } else {
18
+ @Suppress("DEPRECATION")
19
+ context.getSystemService(Context.VIBRATOR_SERVICE) as Vibrator
20
+ }
21
+ }
22
+
23
+ override fun invoke(method: String, args: List<Any?>, bridge: NativeBridge, callback: (Any?, String?) -> Unit) {
24
+ when (method) {
25
+ "vibrate", "impact" -> {
26
+ val style = args.getOrNull(0)?.toString() ?: "medium"
27
+ vibrate(style)
28
+ callback(null, null)
29
+ }
30
+ "selectionChanged" -> {
31
+ vibrate("light")
32
+ callback(null, null)
33
+ }
34
+ "notificationOccurred" -> {
35
+ val type = args.getOrNull(0)?.toString() ?: "success"
36
+ vibrate(type)
37
+ callback(null, null)
38
+ }
39
+ else -> callback(null, "Unknown method: $method")
40
+ }
41
+ }
42
+
43
+ private fun vibrate(style: String) {
44
+ val vib = vibrator ?: return
45
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
46
+ val effect = when (style) {
47
+ "light" -> VibrationEffect.createOneShot(30, 80)
48
+ "medium" -> VibrationEffect.createOneShot(50, 150)
49
+ "heavy" -> VibrationEffect.createOneShot(80, 200)
50
+ "success" -> VibrationEffect.createWaveform(longArrayOf(0, 50, 50, 50), intArrayOf(0, 180, 0, 100), -1)
51
+ "warning" -> VibrationEffect.createOneShot(100, 200)
52
+ "error" -> VibrationEffect.createWaveform(longArrayOf(0, 100, 50, 100), intArrayOf(0, 255, 0, 255), -1)
53
+ else -> VibrationEffect.createOneShot(50, 150)
54
+ }
55
+ vib.vibrate(effect)
56
+ } else {
57
+ @Suppress("DEPRECATION")
58
+ vib.vibrate(50)
59
+ }
60
+ }
61
+ }
@@ -0,0 +1,111 @@
1
+ package com.vuenative.core
2
+
3
+ import okhttp3.CertificatePinner
4
+ import okhttp3.MediaType.Companion.toMediaTypeOrNull
5
+ import okhttp3.OkHttpClient
6
+ import okhttp3.Request
7
+ import okhttp3.RequestBody.Companion.toRequestBody
8
+ import java.io.IOException
9
+ import java.util.concurrent.TimeUnit
10
+
11
+ /**
12
+ * HttpModule — backs the useHttp() composable.
13
+ * Provides a request() method that handles arbitrary HTTP calls from JS with
14
+ * support for baseURL, custom headers, all HTTP methods, and certificate pinning.
15
+ */
16
+ class HttpModule : NativeModule {
17
+ override val moduleName = "Http"
18
+
19
+ /** Default client without certificate pinning. */
20
+ private val defaultClient = OkHttpClient.Builder()
21
+ .connectTimeout(30, TimeUnit.SECONDS)
22
+ .readTimeout(30, TimeUnit.SECONDS)
23
+ .writeTimeout(30, TimeUnit.SECONDS)
24
+ .build()
25
+
26
+ /** Client with certificate pinning — rebuilt when pins are configured. */
27
+ private var pinnedClient: OkHttpClient? = null
28
+
29
+ /** Current certificate pinner, if any. */
30
+ private var certificatePinner: CertificatePinner? = null
31
+
32
+ override fun invoke(
33
+ method: String,
34
+ args: List<Any?>,
35
+ bridge: NativeBridge,
36
+ callback: (Any?, String?) -> Unit
37
+ ) {
38
+ when (method) {
39
+ "configurePins" -> {
40
+ @Suppress("UNCHECKED_CAST")
41
+ val pinsMap = args.getOrNull(0) as? Map<String, List<String>>
42
+ ?: run { callback(null, "Invalid args — expected pins object"); return }
43
+
44
+ val builder = CertificatePinner.Builder()
45
+ for ((domain, pins) in pinsMap) {
46
+ for (pin in pins) {
47
+ // OkHttp expects pins in "sha256/base64hash" format
48
+ builder.add(domain, pin)
49
+ }
50
+ }
51
+ certificatePinner = builder.build()
52
+ pinnedClient = defaultClient.newBuilder()
53
+ .certificatePinner(certificatePinner!!)
54
+ .build()
55
+ callback(true, null)
56
+ }
57
+ "request" -> {
58
+ val opts = args.getOrNull(0) as? Map<*, *>
59
+ ?: run { callback(null, "Invalid args — expected options object"); return }
60
+
61
+ val url = opts["url"]?.toString()
62
+ ?: run { callback(null, "Missing required field: url"); return }
63
+ val baseURL = opts["baseURL"]?.toString() ?: ""
64
+ val httpMethod = opts["method"]?.toString()?.uppercase() ?: "GET"
65
+ val body = opts["body"]?.toString() ?: ""
66
+ @Suppress("UNCHECKED_CAST")
67
+ val headers = opts["headers"] as? Map<String, String>
68
+
69
+ val fullUrl = if (url.startsWith("http")) url else "$baseURL$url"
70
+
71
+ val builder = Request.Builder().url(fullUrl)
72
+ headers?.forEach { (k, v) -> builder.addHeader(k, v) }
73
+
74
+ val contentType = headers?.get("Content-Type")
75
+ ?: headers?.get("content-type")
76
+ ?: "application/json"
77
+
78
+ val requestBody = when {
79
+ body.isNotEmpty() -> body.toRequestBody(contentType.toMediaTypeOrNull())
80
+ httpMethod != "GET" && httpMethod != "HEAD" -> "".toRequestBody()
81
+ else -> null
82
+ }
83
+ builder.method(httpMethod, requestBody)
84
+
85
+ // Use pinned client when configured, otherwise default
86
+ val client = pinnedClient ?: defaultClient
87
+
88
+ client.newCall(builder.build()).enqueue(object : okhttp3.Callback {
89
+ override fun onFailure(call: okhttp3.Call, e: IOException) {
90
+ callback(null, e.message ?: "Network error")
91
+ }
92
+
93
+ override fun onResponse(call: okhttp3.Call, response: okhttp3.Response) {
94
+ val responseBody = response.body?.string() ?: ""
95
+ val responseHeaders = mutableMapOf<String, String>()
96
+ response.headers.forEach { (k, v) -> responseHeaders[k] = v }
97
+ callback(
98
+ mapOf(
99
+ "status" to response.code,
100
+ "ok" to (response.code in 200..299),
101
+ "data" to responseBody,
102
+ "headers" to responseHeaders
103
+ ), null
104
+ )
105
+ }
106
+ })
107
+ }
108
+ else -> callback(null, "Unknown method: $method")
109
+ }
110
+ }
111
+ }