@infilectorg/infiviz-shots-react-sdk 1.2.2 → 1.2.3

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.
@@ -239,30 +239,36 @@ class InfivizShotsReactSdk: RCTEventEmitter {
239
239
  private func unwrapOptional(_ value: Any) -> Any {
240
240
  let mirror = Mirror(reflecting: value)
241
241
 
242
- // 1. Check if it's an Optional
242
+ // 1. Handle Optional
243
243
  let typeName = String(describing: type(of: value))
244
244
  if typeName.hasPrefix("Optional<") {
245
245
  if let unwrapped = mirror.children.first?.value {
246
246
  return unwrapOptional(unwrapped)
247
247
  } else {
248
- return NSNull() // nil value
248
+ return NSNull()
249
249
  }
250
250
  }
251
251
 
252
- // 2. Handle String cleanup: remove "Optional(...)"
252
+ // 2. Strings cleanup
253
253
  if let str = value as? String {
254
254
  return str.replacingOccurrences(of: "Optional\\(|\\)",
255
255
  with: "",
256
256
  options: .regularExpression)
257
257
  }
258
258
 
259
- // 3. Handle Arrays
259
+ // 3. Arrays
260
260
  if let array = value as? [Any] {
261
261
  return array.map { unwrapOptional($0) }
262
262
  }
263
263
 
264
- // 4. Handle Dictionaries
264
+ // 4. Dictionaries
265
265
  if let dict = value as? [String: Any] {
266
+ // 👇 Detect special case: metadata dictionaries
267
+ if dict.keys.count == 1, let firstKey = dict.keys.first {
268
+ if ["string", "bool", "int", "double", "float"].contains(firstKey.lowercased()) {
269
+ return unwrapOptional(dict[firstKey]!)
270
+ }
271
+ }
266
272
  return cleanDictionary(dict)
267
273
  } else if let dict = value as? [AnyHashable: Any] {
268
274
  var result: [String: Any] = [:]
@@ -272,14 +278,14 @@ class InfivizShotsReactSdk: RCTEventEmitter {
272
278
  return result
273
279
  }
274
280
 
275
- // 5. Handle Date objects
281
+ // 5. Dates
276
282
  if let date = value as? Date {
277
283
  let formatter = DateFormatter()
278
284
  formatter.dateFormat = "yyyy-MM-dd HH:mm:ss Z"
279
285
  return formatter.string(from: date)
280
286
  }
281
287
 
282
- // 6. Handle custom objects via Mirror reflection
288
+ // 6. Custom objects
283
289
  let objectMirror = Mirror(reflecting: value)
284
290
  if !objectMirror.children.isEmpty {
285
291
  var result: [String: Any] = [:]
@@ -291,9 +297,10 @@ class InfivizShotsReactSdk: RCTEventEmitter {
291
297
  return result
292
298
  }
293
299
 
294
- // 7. Return primitive types as-is
300
+ // 7. Primitives
295
301
  return value
296
302
  }
303
+
297
304
 
298
305
  // MARK: - Logout
299
306
  @objc
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@infilectorg/infiviz-shots-react-sdk",
3
- "version": "1.2.2",
3
+ "version": "1.2.3",
4
4
  "description": "React Native package for native libraries",
5
5
  "source": "./src/index.tsx",
6
6
  "main": "./lib/module/index.js",
@@ -1,6 +1,6 @@
1
1
  Pod::Spec.new do |s|
2
2
  s.name = 'react-native-infiviz-shots'
3
- s.version = '1.1.5'
3
+ s.version = '1.2.3'
4
4
  s.summary = 'InfivizShots React Native SDK'
5
5
  s.homepage = 'https://your-repo-link.com' # ← replace with your real URL
6
6
  s.license = { :type => 'MIT' }