catalyst-core 0.0.3-canary.14 → 0.0.3-canary.16

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 (73) hide show
  1. package/caching.js +1 -0
  2. package/changelog.md +9 -0
  3. package/dist/native/androidProject/app/build.gradle.kts +6 -6
  4. package/dist/native/androidProject/app/proguard-rules.pro +14 -0
  5. package/dist/native/androidProject/app/src/main/java/io/yourname/androidproject/CustomWebview.kt +4 -5
  6. package/dist/native/androidProject/app/src/main/java/io/yourname/androidproject/MainActivity.kt +14 -8
  7. package/dist/native/androidProject/app/src/main/java/io/yourname/androidproject/NativeBridge.kt +1 -1
  8. package/dist/native/androidProject/app/src/main/java/io/yourname/androidproject/SplashActivity.kt +15 -1
  9. package/dist/native/androidProject/app/src/main/java/io/yourname/androidproject/utils/DeviceInfoUtils.kt +26 -13
  10. package/dist/native/androidProject/app/src/main/java/io/yourname/androidproject/utils/FrameworkServerUtils.kt +1 -1
  11. package/dist/native/androidProject/app/src/main/res/drawable/splashscreen_fallback.png +0 -0
  12. package/dist/native/androidProject/gradle/libs.versions.toml +1 -1
  13. package/dist/native/bridge/WebBridge.js +1 -1
  14. package/dist/native/buildAppAndroid.js +4 -2
  15. package/dist/native/iosnativeWebView/iosnativeWebView/DeviceInfoUtils.swift +4 -1
  16. package/dist/native/iosnativeWebView/iosnativeWebView/FilePickerHandler.swift +152 -37
  17. package/dist/native/iosnativeWebView/iosnativeWebView/FrameworkServerUtils.swift +80 -1
  18. package/dist/native/iosnativeWebView/iosnativeWebView/WebViewNavigationDelegate.swift +29 -0
  19. package/dist/native/iosnativeWebView/iosnativeWebView/localhost.p12 +0 -0
  20. package/dist/native/iosnativeWebView/iosnativeWebView.xcodeproj/project.pbxproj +4 -0
  21. package/dist/native/renameAndroidProject.js +21 -11
  22. package/index.js +1 -0
  23. package/logger.js +68 -0
  24. package/package.json +2 -2
  25. package/router.js +1 -0
  26. package/dist/native/androidProject/.idea/.name +0 -1
  27. package/dist/native/androidProject/.idea/AndroidProjectSystem.xml +0 -6
  28. package/dist/native/androidProject/.idea/compiler.xml +0 -6
  29. package/dist/native/androidProject/.idea/deploymentTargetSelector.xml +0 -10
  30. package/dist/native/androidProject/.idea/gradle.xml +0 -19
  31. package/dist/native/androidProject/.idea/migrations.xml +0 -10
  32. package/dist/native/androidProject/.idea/misc.xml +0 -8
  33. package/dist/native/androidProject/.idea/runConfigurations.xml +0 -17
  34. package/dist/native/androidProject/.idea/vcs.xml +0 -6
  35. package/dist/native/androidProject/app/src/main/java/io/yourname/androidproject/utils/NotificationConstants.kt +0 -27
  36. package/dist/native/androidProject/app/src/main/java/io/yourname/androidproject/utils/NotificationUtils.kt +0 -612
  37. package/dist/native/androidProject/app/src/noFcm/java/io/yourname/androidproject/utils/NotificationManager.kt +0 -158
  38. package/dist/native/androidProject/app/src/noFcm/java/io/yourname/androidproject/utils/PushNotificationUtils.kt +0 -94
  39. package/dist/native/androidProject/app/src/withFcm/java/io/yourname/androidproject/utils/NotificationManager.kt +0 -221
  40. package/dist/native/androidProject/app/src/withFcm/java/io/yourname/androidproject/utils/PushNotificationUtils.kt +0 -378
  41. package/dist/native/iosnativeWebView/Package.resolved +0 -158
  42. package/dist/native/iosnativeWebView/Package.swift +0 -26
  43. package/dist/native/iosnativeWebView/Sources/CatalystNotifications/LocalNotificationHandler.swift +0 -293
  44. package/dist/native/iosnativeWebView/Sources/CatalystNotifications/NotificationManager.swift +0 -272
  45. package/dist/native/iosnativeWebView/Sources/CatalystNotifications/PushNotificationHandler.swift +0 -199
  46. package/dist/native/iosnativeWebView/Sources/Core/Constants/CatalystConstants.swift +0 -113
  47. package/dist/native/iosnativeWebView/Sources/Core/Constants/ConfigConstants.swift +0 -22
  48. package/dist/native/iosnativeWebView/Sources/Core/Notifications/NotificationModels.swift +0 -156
  49. package/dist/native/iosnativeWebView/Sources/Core/Protocols/NotificationHandlerProtocol.swift +0 -34
  50. package/dist/native/iosnativeWebView/Sources/Core/Utils/BootTimingUtility.swift +0 -26
  51. package/dist/native/iosnativeWebView/Sources/Core/Utils/CacheManager.swift +0 -272
  52. package/dist/native/iosnativeWebView/Sources/Core/Utils/CameraTransportUtils.swift +0 -363
  53. package/dist/native/iosnativeWebView/Sources/Core/Utils/DeviceInfoUtils.swift +0 -72
  54. package/dist/native/iosnativeWebView/Sources/Core/Utils/FilePickerHandler.swift +0 -656
  55. package/dist/native/iosnativeWebView/Sources/Core/Utils/FrameworkServerUtils.swift +0 -821
  56. package/dist/native/iosnativeWebView/Sources/Core/Utils/ImageHandler.swift +0 -461
  57. package/dist/native/iosnativeWebView/Sources/Core/Utils/NotificationHandlerProvider.swift +0 -20
  58. package/dist/native/iosnativeWebView/Sources/Core/Utils/NullNotificationHandler.swift +0 -80
  59. package/dist/native/iosnativeWebView/Sources/Core/Utils/ResourceURLProtocol.swift +0 -146
  60. package/dist/native/iosnativeWebView/Sources/Core/Utils/URLWhitelistManager.swift +0 -238
  61. package/dist/native/iosnativeWebView/Sources/Core/Utils/WebKitConfig.swift +0 -12
  62. package/dist/native/iosnativeWebView/Sources/Core/WebView/BridgeCommandHandler.swift +0 -592
  63. package/dist/native/iosnativeWebView/Sources/Core/WebView/BridgeDelegateHandler.swift +0 -221
  64. package/dist/native/iosnativeWebView/Sources/Core/WebView/BridgeFileHandler.swift +0 -340
  65. package/dist/native/iosnativeWebView/Sources/Core/WebView/BridgeJavaScriptInterface.swift +0 -149
  66. package/dist/native/iosnativeWebView/Sources/Core/WebView/BridgeMessageValidator.swift +0 -533
  67. package/dist/native/iosnativeWebView/Sources/Core/WebView/NativeBridge.swift +0 -245
  68. package/dist/native/iosnativeWebView/Sources/Core/WebView/SplashView.swift +0 -95
  69. package/dist/native/iosnativeWebView/Sources/Core/WebView/SplashViewModel.swift +0 -86
  70. package/dist/native/iosnativeWebView/Sources/Core/WebView/WebView.swift +0 -155
  71. package/dist/native/iosnativeWebView/Sources/Core/WebView/WebViewModel.swift +0 -49
  72. package/dist/native/iosnativeWebView/Sources/Core/WebView/WebViewNavigationDelegate.swift +0 -207
  73. package/dist/native/iosnativeWebView/iosnativeWebView/iosnativeWebView.entitlements +0 -8
package/caching.js ADDED
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,"__esModule",{value:true});var _apiCaching=require("@tata1mg/api-caching");Object.keys(_apiCaching).forEach(function(key){if(key==="default"||key==="__esModule")return;if(key in exports&&exports[key]===_apiCaching[key])return;Object.defineProperty(exports,key,{enumerable:true,get:function(){return _apiCaching[key];}});});
package/changelog.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # Changelog
2
2
 
3
+ ## [0.0.3-canary.16] - 2025-11-19
4
+ - FeaturesGallery Support for File Picker: Enhanced file picker to open native gallery for selecting images and videos
5
+ - HTTPS Framework Server: Enabled HTTPS support for the framework server with self-signed SSL certificate
6
+ - MIME Type Handling: Fixed and improved MIME type detection and handling in the file picker
7
+
8
+ ## [0.0.3-canary.15] - 2025-11-19
9
+
10
+ - Adding Android release support and appInfo key
11
+
3
12
  ## [0.0.3-canary.14] - 2025-09-29
4
13
 
5
14
  - Android custom splashscreen
@@ -139,13 +139,13 @@ dependencies {
139
139
  testImplementation(libs.junit)
140
140
  androidTestImplementation(libs.androidx.junit)
141
141
  androidTestImplementation(libs.androidx.espresso.core)
142
- implementation("androidx.webkit:webkit:1.12.1")
142
+ implementation(libs.androidx.webkit)
143
143
  implementation("org.json:json:20231013")
144
144
 
145
145
  // Ktor Server dependencies for FrameworkServer (~200KB total)
146
- implementation("io.ktor:ktor-server-core:2.3.7")
147
- implementation("io.ktor:ktor-server-netty:2.3.7")
148
- implementation("io.ktor:ktor-server-content-negotiation:2.3.7")
146
+ implementation("io.ktor:ktor-server-core:3.0.3")
147
+ implementation("io.ktor:ktor-server-netty:3.0.3")
148
+ implementation("io.ktor:ktor-server-content-negotiation:3.0.3")
149
149
  implementation("org.jetbrains.kotlinx:kotlinx-coroutines-android:1.7.3")
150
150
 
151
151
  // SLF4J simple logger for Ktor (optional, can be excluded if needed)
@@ -334,7 +334,7 @@ tasks.register("generateKeystore") {
334
334
  val keyPass = project.properties["keyPassword"] as? String ?: System.getenv("KEY_PASSWORD") ?: "android"
335
335
  val alias = project.properties["keyAlias"] as? String ?: System.getenv("KEY_ALIAS") ?: "release"
336
336
 
337
- exec {
337
+ project.exec {
338
338
  commandLine = listOf(
339
339
  "keytool",
340
340
  "-genkey",
@@ -363,7 +363,7 @@ tasks.register("createAppBundle") {
363
363
  =======================================================
364
364
  App Bundle created successfully!
365
365
 
366
- Location: ${project.buildDir}/outputs/bundle/release/app-release.aab
366
+ Location: ${layout.buildDirectory.get().asFile}/outputs/bundle/release/app-release.aab
367
367
 
368
368
  Next steps:
369
369
  1. Test your bundle with:
@@ -29,6 +29,20 @@
29
29
  -keepclassmembers class io.ktor.** { volatile <fields>; }
30
30
  -dontwarn io.ktor.**
31
31
 
32
+ # Keep Netty (used by Ktor server)
33
+ -keep class io.netty.** { *; }
34
+ -keepclassmembers class io.netty.** { *; }
35
+ -dontwarn io.netty.**
36
+
37
+ # Suppress warnings for optional Netty dependencies (not needed on Android)
38
+ -dontwarn io.netty.internal.tcnative.**
39
+ -dontwarn org.conscrypt.**
40
+ -dontwarn org.bouncycastle.**
41
+ -dontwarn org.eclipse.jetty.npn.**
42
+ -dontwarn reactor.blockhound.integration.**
43
+ -dontwarn org.apache.log4j.**
44
+ -dontwarn org.apache.logging.log4j.**
45
+
32
46
  # Keep WebViewClient overrides
33
47
  -keepclassmembers class * extends android.webkit.WebViewClient {
34
48
  public void *(android.webkit.WebView, java.lang.String);
@@ -525,17 +525,16 @@ class CustomWebView(
525
525
  WebSettings.MIXED_CONTENT_NEVER_ALLOW
526
526
  }
527
527
 
528
- setRenderPriority(WebSettings.RenderPriority.HIGH)
529
528
  cacheMode = WebSettings.LOAD_DEFAULT
530
529
  databaseEnabled = true
531
530
  domStorageEnabled = true
532
531
  allowFileAccess = true
533
532
  allowContentAccess = true
534
- setEnableSmoothTransition(true)
535
533
 
536
- // Allow access to file URLs and JavaScript interfaces - restrict in production if possible
537
- allowFileAccessFromFileURLs = BuildConfig.DEBUG
538
- allowUniversalAccessFromFileURLs = BuildConfig.DEBUG
534
+ // TODO: Enable these when build optimization feature is implemented
535
+ // These are deprecated but may be needed for local file access in development
536
+ // allowFileAccessFromFileURLs = BuildConfig.DEBUG
537
+ // allowUniversalAccessFromFileURLs = BuildConfig.DEBUG
539
538
  }
540
539
 
541
540
  // Setup ServiceWorker to intercept requests that bypass normal WebView intercept
@@ -3,6 +3,7 @@ package io.yourname.androidproject
3
3
  import android.os.Bundle
4
4
  import android.util.Log
5
5
  import android.view.WindowManager
6
+ import androidx.activity.OnBackPressedCallback
6
7
  import androidx.appcompat.app.AppCompatActivity
7
8
 
8
9
  import java.util.Properties
@@ -112,6 +113,19 @@ class MainActivity : AppCompatActivity(), CoroutineScope by MainScope() {
112
113
  } catch (e: Exception) {
113
114
  Log.e(TAG, "Failed to initialize NativeBridge: ${e.message}")
114
115
  }
116
+
117
+ // Setup back press handler (modern API)
118
+ onBackPressedDispatcher.addCallback(this, object : OnBackPressedCallback(true) {
119
+ override fun handleOnBackPressed() {
120
+ if (customWebView.canGoBack()) {
121
+ customWebView.goBack()
122
+ } else {
123
+ // Disable this callback and let the system handle back press
124
+ isEnabled = false
125
+ onBackPressedDispatcher.onBackPressed()
126
+ }
127
+ }
128
+ })
115
129
 
116
130
  // Load URL based on environment
117
131
  try {
@@ -151,14 +165,6 @@ class MainActivity : AppCompatActivity(), CoroutineScope by MainScope() {
151
165
  }
152
166
  }
153
167
 
154
- override fun onBackPressed() {
155
- if (customWebView.canGoBack()) {
156
- customWebView.goBack()
157
- } else {
158
- super.onBackPressed()
159
- }
160
- }
161
-
162
168
  override fun onPause() {
163
169
  super.onPause()
164
170
  customWebView.onPause()
@@ -268,7 +268,7 @@ class NativeBridge(
268
268
  fun getDeviceInfo(options: String?) {
269
269
  BridgeUtils.safeExecute(webView, BridgeUtils.WebEvents.ON_DEVICE_INFO_ERROR, "get device info") {
270
270
  mainActivity.runOnUiThread {
271
- val deviceInfo = DeviceInfoUtils.getDeviceInfo(mainActivity)
271
+ val deviceInfo = DeviceInfoUtils.getDeviceInfo(mainActivity, properties)
272
272
  BridgeUtils.logDebug(TAG, "Device info retrieved: $deviceInfo")
273
273
  BridgeUtils.notifyWeb(webView, BridgeUtils.WebEvents.ON_DEVICE_INFO_SUCCESS, deviceInfo.toString())
274
274
  }
@@ -1,7 +1,9 @@
1
1
  package io.yourname.androidproject
2
2
 
3
+ import android.app.Activity
3
4
  import android.content.Intent
4
5
  import android.graphics.Color
6
+ import android.os.Build
5
7
  import android.os.Bundle
6
8
  import android.os.Handler
7
9
  import android.os.Looper
@@ -87,7 +89,19 @@ class SplashActivity : AppCompatActivity() {
87
89
  isFinishing = true
88
90
  startActivity(Intent(this, MainActivity::class.java))
89
91
  finish()
90
- overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out)
92
+
93
+ // Use modern API for Android 14+ (API 34+)
94
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.UPSIDE_DOWN_CAKE) {
95
+ overrideActivityTransition(
96
+ Activity.OVERRIDE_TRANSITION_CLOSE,
97
+ android.R.anim.fade_in,
98
+ android.R.anim.fade_out
99
+ )
100
+ } else {
101
+ // Fallback to deprecated API for Android 13 and below
102
+ @Suppress("DEPRECATION")
103
+ overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out)
104
+ }
91
105
  }
92
106
 
93
107
  private fun startMainActivity() {
@@ -6,14 +6,14 @@ import android.util.DisplayMetrics
6
6
  import android.view.WindowManager
7
7
  import org.json.JSONObject
8
8
  import io.yourname.androidproject.BuildConfig
9
- import android.hardware.display.DisplayManager
9
+ import java.util.Properties
10
10
 
11
11
  object DeviceInfoUtils {
12
12
  private const val TAG = "DeviceInfoUtils"
13
-
14
- fun getDeviceInfo(context: Context): JSONObject {
13
+
14
+ fun getDeviceInfo(context: Context, properties: Properties? = null): JSONObject {
15
15
  val deviceInfo = JSONObject()
16
-
16
+
17
17
  try {
18
18
  // Basic device information
19
19
  deviceInfo.apply {
@@ -21,7 +21,7 @@ object DeviceInfoUtils {
21
21
  put("manufacturer", Build.MANUFACTURER)
22
22
  put("platform", "android")
23
23
  }
24
-
24
+
25
25
  // Screen dimensions only
26
26
  val displayMetrics = getDisplayMetrics(context)
27
27
  deviceInfo.apply {
@@ -29,32 +29,45 @@ object DeviceInfoUtils {
29
29
  put("screenHeight", displayMetrics.heightPixels)
30
30
  put("screenDensity", displayMetrics.density.toDouble())
31
31
  }
32
-
32
+
33
+ // Add appInfo from properties if available
34
+ val appInfo = properties?.getProperty("appInfo")
35
+ deviceInfo.put("appInfo", appInfo ?: JSONObject.NULL)
36
+
33
37
  } catch (e: Exception) {
34
38
  BridgeUtils.logError(TAG, "Error getting device info", e)
35
39
  return JSONObject().apply {
36
40
  put("error", "Failed to get device info: ${e.message}")
37
41
  }
38
42
  }
39
-
43
+
40
44
  return deviceInfo
41
45
  }
42
46
 
43
47
  private fun getDisplayMetrics(context: Context): DisplayMetrics {
44
48
  val displayMetrics = DisplayMetrics()
45
-
49
+
46
50
  if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.R) {
47
- // Use modern Display API for Android 11+
48
- val displayManager = context.getSystemService(Context.DISPLAY_SERVICE) as DisplayManager
49
- displayManager.getDisplay(0)?.getMetrics(displayMetrics)
51
+ // Use WindowMetrics API for Android 11+ (provides accurate app window bounds)
52
+ val windowManager = context.getSystemService(Context.WINDOW_SERVICE) as WindowManager
53
+ val windowMetrics = windowManager.currentWindowMetrics
54
+ val bounds = windowMetrics.bounds
55
+
56
+ // Populate DisplayMetrics with window bounds
57
+ displayMetrics.widthPixels = bounds.width()
58
+ displayMetrics.heightPixels = bounds.height()
59
+
60
+ // Get density from resources (still accurate)
61
+ displayMetrics.density = context.resources.displayMetrics.density
62
+ displayMetrics.densityDpi = context.resources.displayMetrics.densityDpi
50
63
  } else {
51
- // Fallback to deprecated API for older versions
64
+ // Fallback to deprecated API for Android 10 and below
52
65
  @Suppress("DEPRECATION")
53
66
  val windowManager = context.getSystemService(Context.WINDOW_SERVICE) as WindowManager
54
67
  @Suppress("DEPRECATION")
55
68
  windowManager.defaultDisplay.getMetrics(displayMetrics)
56
69
  }
57
-
70
+
58
71
  return displayMetrics
59
72
  }
60
73
  }
@@ -37,7 +37,7 @@ object FrameworkServerUtils {
37
37
  private const val SESSION_TIMEOUT_MS = 30 * 60 * 1000L // 30 minutes
38
38
 
39
39
  // Server state
40
- private var server: NettyApplicationEngine? = null
40
+ private var server: EmbeddedServer<NettyApplicationEngine, NettyApplicationEngine.Configuration>? = null
41
41
  private var serverPort: Int = 0
42
42
  private var sessionId: String = ""
43
43
  private var isServerRunning: Boolean = false
@@ -8,7 +8,7 @@ espressoCore = "3.6.1"
8
8
  appcompat = "1.7.0"
9
9
  material = "1.12.0"
10
10
  constraintlayout = "2.1.4"
11
- webkit = "1.11.0"
11
+ webkit = "1.13.0"
12
12
 
13
13
  [libraries]
14
14
  androidx-core-ktx = { group = "androidx.core", name = "core-ktx", version.ref = "coreKtx" }
@@ -56,4 +56,4 @@ if(this.handlers.has(interfaceName)){console.warn(`🌉 Interface ${interfaceNam
56
56
  * @returns {Promise<Object>} - Promise that resolves with device info or rejects with error
57
57
  */getDeviceInfo=()=>{const{platform,isNativeEnvironment}=_NativeBridge.default.getEnvironmentInfo();// Handle web environment
58
58
  if(!isNativeEnvironment||platform==="web"){return new Promise(resolve=>{const webDeviceInfo={model:navigator.userAgent,manufacturer:"browser",platform:"web",screenWidth:screen.width,screenHeight:screen.height,screenDensity:window.devicePixelRatio};resolve(webDeviceInfo);});}// Key mapping from native to web keys
59
- const DEVICE_INFO_KEY_MAP={android:{model:"model",manufacturer:"manufacturer",platform:"platform",screenWidth:"screenWidth",screenHeight:"screenHeight",screenDensity:"screenDensity"},ios:{model:"model",manufacturer:"manufacturer",platform:"platform",screenWidth:"screenWidth",screenHeight:"screenHeight",screenDensity:"screenDensity"}};const parseDeviceInfo=data=>{const rawDeviceInfo=typeof data==='string'?JSON.parse(data):data;const platformMapping=DEVICE_INFO_KEY_MAP[platform]||{};return Object.fromEntries(Object.entries(rawDeviceInfo).map(([key,value])=>[platformMapping[key]||key,value]));};return new Promise((resolve,reject)=>{const cleanup=()=>{this.unregister(_NativeInterfaces.NATIVE_CALLBACKS.ON_DEVICE_INFO_SUCCESS);this.unregister(_NativeInterfaces.NATIVE_CALLBACKS.ON_DEVICE_INFO_ERROR);};this.register(_NativeInterfaces.NATIVE_CALLBACKS.ON_DEVICE_INFO_SUCCESS,data=>{cleanup();resolve(parseDeviceInfo(data));});this.register(_NativeInterfaces.NATIVE_CALLBACKS.ON_DEVICE_INFO_ERROR,error=>{cleanup();reject(new Error(error));});try{_NativeBridge.default.device.getDeviceInfo();}catch(error){cleanup();reject(error);}});};}var _default=exports.default=WebBridge;
59
+ const DEVICE_INFO_KEY_MAP={android:{model:"model",manufacturer:"manufacturer",platform:"platform",screenWidth:"screenWidth",screenHeight:"screenHeight",screenDensity:"screenDensity",appInfo:"appInfo"},ios:{model:"model",manufacturer:"manufacturer",platform:"platform",screenWidth:"screenWidth",screenHeight:"screenHeight",screenDensity:"screenDensity",appInfo:"appInfo"}};const parseDeviceInfo=data=>{const rawDeviceInfo=typeof data==='string'?JSON.parse(data):data;const platformMapping=DEVICE_INFO_KEY_MAP[platform]||{};return Object.fromEntries(Object.entries(rawDeviceInfo).map(([key,value])=>[platformMapping[key]||key,value]));};return new Promise((resolve,reject)=>{const cleanup=()=>{this.unregister(_NativeInterfaces.NATIVE_CALLBACKS.ON_DEVICE_INFO_SUCCESS);this.unregister(_NativeInterfaces.NATIVE_CALLBACKS.ON_DEVICE_INFO_ERROR);};this.register(_NativeInterfaces.NATIVE_CALLBACKS.ON_DEVICE_INFO_SUCCESS,data=>{cleanup();resolve(parseDeviceInfo(data));});this.register(_NativeInterfaces.NATIVE_CALLBACKS.ON_DEVICE_INFO_ERROR,error=>{cleanup();reject(new Error(error));});try{_NativeBridge.default.device.getDeviceInfo();}catch(error){cleanup();reject(error);}});};}var _default=exports.default=WebBridge;
@@ -35,7 +35,8 @@ stringsContent=stringsContent.replace(/<string name="app_name">.*?<\/string>/,`<
35
35
  async function createAABConfig(androidConfig){// Create AAB configuration based on WebView config with defaults applied
36
36
  const aabConfig={// Apply defaults here in buildAppAndroid.js
37
37
  projectPath:androidConfig.projectPath||DEFAULT_PROJECT_PATH,deploymentPath:DEFAULT_DEPLOYMENT_PATH,oldProjectName:DEFAULT_OLD_PROJECT_NAME,overwriteExisting:androidConfig.overwriteExisting!==undefined?androidConfig.overwriteExisting:DEFAULT_OVERWRITE_EXISTING,// Required field - use configured value or derive from other config
38
- newProjectName:androidConfig.newProjectName||androidConfig.appName||androidConfig.packageName?.split(".").pop()||"catalystapp",// AAB specific settings
38
+ newProjectName:androidConfig.newProjectName||androidConfig.appName||androidConfig.packageName?.split(".").pop()||"catalystapp",// IMPORTANT: Pass packageName for renaming
39
+ packageName:androidConfig.packageName||null,// AAB specific settings
39
40
  createSignedAAB:true,outputPath:androidConfig.outputPath||`${process.env.PWD}/build-output`};// Add keystore configuration if available
40
41
  if(androidConfig.keystoreConfig){aabConfig.keystoreConfig=androidConfig.keystoreConfig;}else if(androidConfig.keystore){// Map old keystore format to new format
41
42
  aabConfig.keystoreConfig={keyAlias:androidConfig.keystore.alias||"release",storePassword:androidConfig.keystore.storePassword,keyPassword:androidConfig.keystore.keyPassword,validityYears:25,organizationInfo:{companyName:androidConfig.keystore.organizationName||"YourCompany",city:androidConfig.keystore.city||"YourCity",state:androidConfig.keystore.state||"YourState",countryCode:androidConfig.keystore.countryCode||"US"}};}// Log the configuration being used
@@ -46,7 +47,8 @@ let destinationApkFileName="";// Construct source and destination paths
46
47
  if(appName){destinationApkFileName=buildType==="release"?`${appName}-${currentTime}.release.apk`:`${appName}-${currentTime}.debug.apk`;}else{destinationApkFileName=buildType==="release"?`app-${currentTime}.release.apk`:`app-${currentTime}.debug.apk`;}const sourceApkFileName=buildType==="release"?`app.apk`:`app-debug.apk`;const sourceApkPath=_path.default.join(pwd,"androidProject","app","build","outputs","apk",buildType,sourceApkFileName);const destinationDir=_path.default.join(process.env.PWD,BUILD_OUTPUT_PATH,"native","android",currentDate,buildType);const destinationApkPath=_path.default.join(destinationDir,destinationApkFileName);// Check if source APK exists
47
48
  if(!_fs.default.existsSync(sourceApkPath)){progress.log(`APK not found at source path: ${sourceApkPath}`,"warning");return null;}// Create destination directory if it doesn't exist
48
49
  if(!_fs.default.existsSync(destinationDir)){_fs.default.mkdirSync(destinationDir,{recursive:true});}// Copy APK to destination
49
- _fs.default.copyFileSync(sourceApkPath,destinationApkPath);return destinationApkPath;}catch(error){progress.log(`Error moving APK: ${error.message}`,"error");return null;}}async function buildSignedAAB(androidConfig){progress.log("Building signed AAB for release...","info");try{// Create AAB configuration directly without temporary file
50
+ _fs.default.copyFileSync(sourceApkPath,destinationApkPath);return destinationApkPath;}catch(error){progress.log(`Error moving APK: ${error.message}`,"error");return null;}}async function buildSignedAAB(androidConfig){progress.log("Building signed AAB for release...","info");try{// Generate webview config BEFORE creating AAB
51
+ progress.log("Generating webview configuration for release...","info");try{const generateConfigCommand=`cd ${pwd}/androidProject && ./gradlew generateWebViewConfig -PconfigPath=${configPath}`;await(0,_utils.runInteractiveCommand)("sh",["-c",generateConfigCommand],{"BUILD SUCCESSFUL":""});progress.log("Webview config generated successfully","success");}catch(configError){progress.log(`Warning: Webview config generation failed: ${configError.message}`,"warning");throw new Error("Webview config generation is required for release builds");}// Create AAB configuration directly without temporary file
50
52
  const aabConfig=await createAABConfig(androidConfig);// Call the AAB builder directly with config object
51
53
  await(0,_renameAndroidProject.buildAndroidAAB)(aabConfig);progress.log("Signed AAB build completed successfully!","success");}catch(error){throw new Error("Error building signed AAB: "+error.message);}}async function buildAndroidApp(){// Initialize androidConfig outside try block to ensure it's available in catch
52
54
  let androidConfig=null;let targetDevice=null;try{// Initialize configuration
@@ -25,7 +25,7 @@ class DeviceInfoUtils {
25
25
  let screen = UIScreen.main
26
26
 
27
27
  // Basic device information
28
- let deviceInfo: [String: Any] = [
28
+ var deviceInfo: [String: Any] = [
29
29
  "model": device.model,
30
30
  "manufacturer": "Apple",
31
31
  "platform": "ios",
@@ -36,6 +36,9 @@ class DeviceInfoUtils {
36
36
  "screenDensity": screen.scale
37
37
  ]
38
38
 
39
+ deviceInfo["appInfo"] = ConfigConstants.appInfo
40
+
41
+
39
42
  logger.debug("Device info retrieved successfully: \(deviceInfo.description)")
40
43
  return deviceInfo
41
44
 
@@ -179,34 +179,28 @@ class FilePickerHandler: NSObject {
179
179
 
180
180
  delegate?.filePickerHandler(self, stateDidChange: "opening")
181
181
 
182
- // For image selection, use PHPickerViewController for better photo library access
183
- // Only use photo picker for image-specific requests or when explicitly asking for media
184
- let normalizedMimeType = options.mimeType.lowercased()
185
- if normalizedMimeType == "image/*" {
186
- if #available(iOS 14.0, *) {
187
- presentPhotoPicker(from: viewController, options: options)
188
- return
189
- }
182
+ // Use photo picker if all MIME types are images/videos, else use document picker
183
+ let mimeTypes = options.mimeType.lowercased().split(separator: ",").map { $0.trimmingCharacters(in: .whitespaces) }
184
+ let allMedia = mimeTypes.allSatisfy { $0.hasPrefix("image/") || $0.hasPrefix("video/") }
185
+
186
+ if allMedia, #available(iOS 14.0, *) {
187
+ presentPhotoPicker(from: viewController, options: options)
188
+ } else {
189
+ presentDocumentPicker(from: viewController, options: options)
190
190
  }
191
-
192
- // Use document picker for other file types
193
- presentDocumentPicker(from: viewController, options: options)
194
191
  }
195
192
 
196
193
  @available(iOS 14.0, *)
197
194
  private func presentPhotoPicker(from viewController: UIViewController, options: FilePickerOptions) {
198
- logger.debug("Using PHPickerViewController for image selection")
195
+ logger.debug("Using PHPickerViewController for image/video selection")
199
196
 
197
+ let mimeTypes = options.mimeType.lowercased().split(separator: ",").map { $0.trimmingCharacters(in: .whitespaces) }
198
+ let hasImages = mimeTypes.contains { $0.hasPrefix("image/") }
199
+ let hasVideos = mimeTypes.contains { $0.hasPrefix("video/") }
200
+
200
201
  var config = PHPickerConfiguration()
201
202
  config.selectionLimit = options.selectionLimit
202
-
203
- // Configure for images only if specifically requested
204
- if options.mimeType.lowercased() == "image/*" {
205
- config.filter = .images
206
- } else {
207
- // For *.* allow images and videos
208
- config.filter = .any(of: [.images, .videos])
209
- }
203
+ config.filter = (hasImages && hasVideos) ? .any(of: [.images, .videos]) : hasVideos ? .videos : .images
210
204
 
211
205
  photoPicker = PHPickerViewController(configuration: config)
212
206
  photoPicker?.delegate = self
@@ -384,25 +378,76 @@ class FilePickerHandler: NSObject {
384
378
  }
385
379
 
386
380
  private func getMimeType(for url: URL) -> String {
387
- // First try UTType
388
- if let utType = UTType(filenameExtension: url.pathExtension) {
389
- return utType.preferredMIMEType ?? "*/*"
381
+ // First try UTType - only return if it has a preferredMIMEType
382
+ if let utType = UTType(filenameExtension: url.pathExtension),
383
+ let mimeType = utType.preferredMIMEType {
384
+ return mimeType
390
385
  }
391
386
 
392
- // Fallback based on file extension
387
+ // Fallback based on file extension with comprehensive mapping
393
388
  let ext = url.pathExtension.lowercased()
389
+
394
390
  switch ext {
391
+ // Images
395
392
  case "jpg", "jpeg": return "image/jpeg"
396
393
  case "png": return "image/png"
397
394
  case "gif": return "image/gif"
395
+ case "webp": return "image/webp"
396
+ case "svg": return "image/svg+xml"
397
+ case "bmp": return "image/bmp"
398
+ case "heic": return "image/heic"
399
+ case "heif": return "image/heif"
400
+ case "ico": return "image/x-icon"
401
+ case "tiff", "tif": return "image/tiff"
402
+
403
+ // Documents
398
404
  case "pdf": return "application/pdf"
405
+ case "doc": return "application/msword"
406
+ case "docx": return "application/vnd.openxmlformats-officedocument.wordprocessingml.document"
407
+ case "xls": return "application/vnd.ms-excel"
408
+ case "xlsx": return "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
409
+ case "ppt": return "application/vnd.ms-powerpoint"
410
+ case "pptx": return "application/vnd.openxmlformats-officedocument.presentationml.presentation"
411
+
412
+ // Text
399
413
  case "txt": return "text/plain"
414
+ case "html", "htm": return "text/html"
415
+ case "css": return "text/css"
416
+ case "csv": return "text/csv"
417
+
418
+ // Data
400
419
  case "json": return "application/json"
420
+ case "xml": return "application/xml"
421
+ case "js": return "application/javascript"
422
+
423
+ // Archives
401
424
  case "zip": return "application/zip"
425
+ case "rar": return "application/x-rar-compressed"
426
+ case "7z": return "application/x-7z-compressed"
427
+ case "tar": return "application/x-tar"
428
+ case "gz": return "application/gzip"
429
+
430
+ // Video
402
431
  case "mp4": return "video/mp4"
432
+ case "mov": return "video/quicktime"
433
+ case "avi": return "video/x-msvideo"
434
+ case "webm": return "video/webm"
435
+ case "mkv": return "video/x-matroska"
436
+ case "m4v": return "video/x-m4v"
437
+ case "flv": return "video/x-flv"
438
+
439
+ // Audio
403
440
  case "mp3": return "audio/mpeg"
404
- case "csv": return "text/csv"
405
- default: return "*/*"
441
+ case "wav": return "audio/wav"
442
+ case "ogg": return "audio/ogg"
443
+ case "m4a": return "audio/mp4"
444
+ case "aac": return "audio/aac"
445
+ case "flac": return "audio/flac"
446
+ case "wma": return "audio/x-ms-wma"
447
+
448
+ default:
449
+ logger.warning("Unknown file extension '\(ext)', using application/octet-stream")
450
+ return "application/octet-stream"
406
451
  }
407
452
  }
408
453
 
@@ -762,6 +807,43 @@ extension FilePickerHandler: PHPickerViewControllerDelegate {
762
807
  }
763
808
 
764
809
  private func preferredTypeIdentifier(for itemProvider: NSItemProvider) -> String? {
810
+ // Try to get the most specific type identifier first
811
+ // Prefer specific types over generic ones
812
+ let specificImageTypes = [
813
+ UTType.heic.identifier,
814
+ UTType.heif.identifier,
815
+ UTType.jpeg.identifier,
816
+ UTType.png.identifier,
817
+ UTType.gif.identifier,
818
+ "public.heic",
819
+ "public.heif",
820
+ "public.jpeg",
821
+ "public.png",
822
+ "public.gif"
823
+ ]
824
+
825
+ // Check if any specific image type is available
826
+ for specificType in specificImageTypes {
827
+ if itemProvider.hasItemConformingToTypeIdentifier(specificType) {
828
+ return specificType
829
+ }
830
+ }
831
+
832
+ // Check for specific video types
833
+ let specificVideoTypes = [
834
+ UTType.mpeg4Movie.identifier,
835
+ UTType.quickTimeMovie.identifier,
836
+ "public.mpeg-4",
837
+ "com.apple.quicktime-movie"
838
+ ]
839
+
840
+ for specificType in specificVideoTypes {
841
+ if itemProvider.hasItemConformingToTypeIdentifier(specificType) {
842
+ return specificType
843
+ }
844
+ }
845
+
846
+ // Fall back to generic types
765
847
  if itemProvider.hasItemConformingToTypeIdentifier(UTType.image.identifier) {
766
848
  return UTType.image.identifier
767
849
  }
@@ -836,10 +918,14 @@ extension FilePickerHandler: PHPickerViewControllerDelegate {
836
918
 
837
919
  temporaryFiles.append(fileURL)
838
920
 
921
+ // Get MIME type from typeIdentifier first, as file extension might be generic (.dat)
922
+ let mimeTypeFromIdentifier = getMimeTypeFromTypeIdentifier(typeIdentifier)
923
+ let finalMimeType = mimeTypeFromIdentifier ?? getMimeType(for: fileURL)
924
+
839
925
  let metadata = FileMetadata(
840
926
  fileName: fileName,
841
927
  fileSize: Int64(data.count),
842
- mimeType: getMimeTypeFromTypeIdentifier(typeIdentifier) ?? getMimeType(for: fileURL),
928
+ mimeType: finalMimeType,
843
929
  fileExtension: fileExtension,
844
930
  lastModified: Date()
845
931
  )
@@ -853,39 +939,68 @@ extension FilePickerHandler: PHPickerViewControllerDelegate {
853
939
  // Try to get the file extension from the suggested name first
854
940
  if let suggestedName = result.itemProvider.suggestedName,
855
941
  !URL(fileURLWithPath: suggestedName).pathExtension.isEmpty {
856
- return URL(fileURLWithPath: suggestedName).pathExtension
942
+ let ext = URL(fileURLWithPath: suggestedName).pathExtension
943
+ logger.debug("Using file extension '\(ext)' from suggested name: \(suggestedName)")
944
+ return ext
857
945
  }
858
946
 
859
947
  // Fallback based on type identifier
860
948
  if let utType = UTType(typeIdentifier) {
861
949
  if let preferredExtension = utType.preferredFilenameExtension {
950
+ logger.debug("Using file extension '\(preferredExtension)' from UTType for identifier: \(typeIdentifier)")
862
951
  return preferredExtension
863
952
  }
864
953
  }
865
954
 
866
955
  // Final fallback based on common type identifiers
956
+ let fileExtension: String
867
957
  switch typeIdentifier {
868
958
  case UTType.jpeg.identifier, "public.jpeg":
869
- return "jpg"
959
+ fileExtension = "jpg"
870
960
  case UTType.png.identifier, "public.png":
871
- return "png"
961
+ fileExtension = "png"
872
962
  case UTType.heic.identifier, "public.heic":
873
- return "heic"
963
+ fileExtension = "heic"
874
964
  case UTType.gif.identifier, "public.gif":
875
- return "gif"
965
+ fileExtension = "gif"
876
966
  case UTType.mpeg4Movie.identifier, "public.mpeg-4":
877
- return "mp4"
967
+ fileExtension = "mp4"
878
968
  case UTType.quickTimeMovie.identifier, "com.apple.quicktime-movie":
879
- return "mov"
969
+ fileExtension = "mov"
880
970
  default:
881
- return "dat" // Generic data file
971
+ fileExtension = "dat"
972
+ logger.warning("Unknown type identifier '\(typeIdentifier)', defaulting to 'dat' extension")
882
973
  }
974
+
975
+ logger.debug("Using file extension '\(fileExtension)' from type identifier fallback")
976
+ return fileExtension
883
977
  }
884
978
 
885
979
  private func getMimeTypeFromTypeIdentifier(_ typeIdentifier: String) -> String? {
886
- if let utType = UTType(typeIdentifier) {
887
- return utType.preferredMIMEType
980
+ guard let utType = UTType(typeIdentifier) else {
981
+ return nil
982
+ }
983
+
984
+ // If UTType has a preferred MIME type, return it
985
+ if let mimeType = utType.preferredMIMEType {
986
+ return mimeType
987
+ }
988
+
989
+ // Handle generic types by checking if they conform to specific types
990
+ if utType.conforms(to: .jpeg) {
991
+ return "image/jpeg"
992
+ } else if utType.conforms(to: .png) {
993
+ return "image/png"
994
+ } else if utType.conforms(to: .heic) {
995
+ return "image/heic"
996
+ } else if utType.conforms(to: .gif) {
997
+ return "image/gif"
998
+ } else if utType.conforms(to: .image) {
999
+ return "image/jpeg" // Default for generic images
1000
+ } else if utType.conforms(to: .movie) {
1001
+ return "video/mp4" // Default for generic videos
888
1002
  }
1003
+
889
1004
  return nil
890
1005
  }
891
1006
  }