@trentrand/react-native-app-clip 0.6.2-beta.7 → 0.6.2-beta.8

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@trentrand/react-native-app-clip",
3
- "version": "0.6.2-beta.7",
3
+ "version": "0.6.2-beta.8",
4
4
  "description": "Config plugin to add an App Clip to a React Native iOS app",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",
@@ -68,34 +68,41 @@ extension Data {
68
68
  var stream = z_stream()
69
69
  var decompressed = Data(capacity: self.count * 2)
70
70
 
71
- self.withUnsafeBytes { (ptr: UnsafeRawBufferPointer) in
71
+ let status: CInt = self.withUnsafeBytes { (inputPtr: UnsafeRawBufferPointer) -> CInt in
72
72
  stream.avail_in = UInt32(self.count)
73
- stream.next_in = UnsafeMutablePointer<UInt8>(mutating: ptr.bindMemory(to: UInt8.self).baseAddress!)
73
+ stream.next_in = UnsafeMutablePointer<UInt8>(mutating: inputPtr.bindMemory(to: UInt8.self).baseAddress!)
74
74
 
75
75
  guard inflateInit2_(&stream, 15 + 32, ZLIB_VERSION, Int32(MemoryLayout<z_stream>.size)) == Z_OK else {
76
- return
76
+ return Z_STREAM_ERROR
77
77
  }
78
78
 
79
- while stream.avail_out == 0 {
79
+ var result: CInt = Z_OK
80
+ repeat {
80
81
  if Int(stream.total_out) >= decompressed.count {
81
82
  decompressed.count += self.count / 2
82
83
  }
83
84
 
84
- decompressed.withUnsafeMutableBytes { (ptr: UnsafeMutableRawBufferPointer) in
85
- stream.avail_out = UInt32(decompressed.count) - UInt32(stream.total_out)
86
- stream.next_out = ptr.bindMemory(to: UInt8.self).baseAddress!.advanced(by: Int(stream.total_out))
85
+ let outputCount = decompressed.count
86
+ let totalOut = Int(stream.total_out)
87
87
 
88
- inflate(&stream, Z_SYNC_FLUSH)
88
+ result = decompressed.withUnsafeMutableBytes { (outputPtr: UnsafeMutableRawBufferPointer) -> CInt in
89
+ stream.avail_out = UInt32(outputCount) - UInt32(totalOut)
90
+ stream.next_out = outputPtr.bindMemory(to: UInt8.self).baseAddress!.advanced(by: totalOut)
91
+ return inflate(&stream, Z_SYNC_FLUSH)
89
92
  }
90
- }
93
+ } while result == Z_OK
91
94
 
92
95
  inflateEnd(&stream)
96
+ return result
97
+ }
98
+
99
+ guard status == Z_STREAM_END else {
100
+ return nil
93
101
  }
94
102
 
95
103
  decompressed.count = Int(stream.total_out)
96
104
  return decompressed
97
- }
98
- }`);
105
+ }`);
99
106
  node_fs_1.default.writeFileSync(appDelegatePath, content);
100
107
  console.log("✅ Modified AppDelegate for gzip decompression");
101
108
  }