@octopus-community/react-native 1.0.3 → 1.0.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.
@@ -89,18 +89,43 @@ class OctopusUIManager {
89
89
  }.resume()
90
90
  } else {
91
91
  // Local file path (from Image.resolveAssetSource)
92
- if let image = UIImage(contentsOfFile: uri) {
92
+ if let image = loadImageFromLocalPath(uri) {
93
93
  completion(image)
94
94
  } else {
95
- // Fallback: try to load from bundle using the filename
96
- let filename = (uri as NSString).lastPathComponent
97
- let nameWithoutExtension = (filename as NSString).deletingPathExtension
98
- let image = UIImage(named: nameWithoutExtension)
99
- completion(image)
95
+ completion(nil)
100
96
  }
101
97
  }
102
98
  }
103
99
 
100
+ private func loadImageFromLocalPath(_ path: String) -> UIImage? {
101
+ // Handle absolute file URLs (file://) first
102
+ if path.hasPrefix("file://"), let url = URL(string: path),
103
+ let image = UIImage(contentsOfFile: url.path) {
104
+ return image
105
+ }
106
+
107
+ // Try raw absolute path next
108
+ if path.hasPrefix("/"), FileManager.default.fileExists(atPath: path),
109
+ let image = UIImage(contentsOfFile: path) {
110
+ return image
111
+ }
112
+
113
+ // For React Native bundled assets the path is relative (e.g. assets/assets/logo.png)
114
+ let nsPath = path as NSString
115
+ let directory = nsPath.deletingLastPathComponent
116
+ let filename = nsPath.lastPathComponent
117
+ let nameWithoutExtension = (filename as NSString).deletingPathExtension
118
+ let fileExtension = (filename as NSString).pathExtension
119
+
120
+ if let bundlePath = Bundle.main.path(forResource: nameWithoutExtension, ofType: fileExtension.isEmpty ? nil : fileExtension, inDirectory: directory.isEmpty ? nil : directory) ,
121
+ let image = UIImage(contentsOfFile: bundlePath) {
122
+ return image
123
+ }
124
+
125
+ // Final fallback: let UIKit try to resolve it by name (works for assets catalog entries)
126
+ return UIImage(named: nameWithoutExtension)
127
+ }
128
+
104
129
  func closeUI() throws {
105
130
  guard let presentedVC = presentedViewController else {
106
131
  throw NSError(domain: "CLOSE_UI_ERROR", code: 0, userInfo: [NSLocalizedDescriptionKey: "No UI is currently presented"])
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@octopus-community/react-native",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "React Native module for the Octopus Community SDK",
5
5
  "source": "./src/index.ts",
6
6
  "main": "./lib/module/index.js",