@hot-updater/react-native 1.0.0-rc.1 → 1.0.0-rc.15
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/android/proguard-rules.pro +17 -2
- package/android/src/main/java/com/hotupdater/BuiltInAssetResolver.kt +286 -0
- package/android/src/main/java/com/hotupdater/BundleFileStorageService.kt +651 -637
- package/android/src/main/java/com/hotupdater/BundleMetadata.kt +10 -0
- package/android/src/main/java/com/hotupdater/HotUpdaterException.kt +0 -13
- package/android/src/main/java/com/hotupdater/HotUpdaterImpl.kt +10 -14
- package/android/src/main/java/com/hotupdater/HotUpdaterRecoveryManager.kt +37 -54
- package/android/src/main/java/com/hotupdater/HotUpdaterRecoveryState.kt +64 -0
- package/android/src/main/java/com/hotupdater/OkHttpDownloadService.kt +19 -0
- package/android/src/main/java/com/hotupdater/TarArchiveInputStream.kt +214 -375
- package/android/src/main/java/com/hotupdater/TarBrArchiveExtractor.kt +119 -0
- package/android/src/newarch/HotUpdater.kt +7 -9
- package/android/src/newarch/HotUpdaterModule.kt +40 -20
- package/android/src/oldarch/HotUpdater.kt +7 -9
- package/android/src/oldarch/HotUpdaterModule.kt +40 -20
- package/android/src/test/java/com/hotupdater/BundleFileStorageServiceTest.kt +1126 -74
- package/android/src/test/java/com/hotupdater/HotUpdaterImplTest.kt +4 -5
- package/android/src/test/java/com/hotupdater/HotUpdaterRecoveryStateTest.kt +97 -0
- package/android/src/test/java/com/hotupdater/PendingCrashRecoveryTest.kt +44 -0
- package/android/src/test/java/com/hotupdater/TarBrArchiveExtractorTest.kt +206 -0
- package/ios/HotUpdater/Internal/BrotliFileDecompressor.swift +167 -0
- package/ios/HotUpdater/Internal/BuiltInAssetResolver.swift +196 -0
- package/ios/HotUpdater/Internal/BundleFileStorageService.swift +773 -1016
- package/ios/HotUpdater/Internal/BundleMetadata.swift +5 -0
- package/ios/HotUpdater/Internal/FileUtilities.swift +64 -0
- package/ios/HotUpdater/Internal/HotUpdater-Bridging-Header.h +0 -1
- package/ios/HotUpdater/Internal/HotUpdater.mm +5 -27
- package/ios/HotUpdater/Internal/HotUpdaterImpl.swift +149 -51
- package/ios/HotUpdater/Internal/NotificationExtension.swift +0 -2
- package/ios/HotUpdater/Internal/TarArchiveExtractor.swift +182 -311
- package/ios/HotUpdater/Internal/URLSessionDownloadService.swift +13 -72
- package/ios/HotUpdater/Recovery/HotUpdaterRecovery.h +16 -0
- package/ios/HotUpdater/Recovery/HotUpdaterRecovery.mm +83 -0
- package/ios/HotUpdater/Recovery/HotUpdaterRecoveryHooks.mm +49 -0
- package/lib/commonjs/checkForUpdate.js +32 -23
- package/lib/commonjs/checkForUpdate.js.map +1 -1
- package/lib/commonjs/checkForUpdate.releaseCatalog.spec.js +97 -28
- package/lib/commonjs/checkForUpdate.releaseCatalog.spec.js.map +1 -1
- package/lib/commonjs/error.js +4 -13
- package/lib/commonjs/error.js.map +1 -1
- package/lib/commonjs/fetchJSON.js +9 -2
- package/lib/commonjs/fetchJSON.js.map +1 -1
- package/lib/commonjs/httpClient.js +46 -29
- package/lib/commonjs/httpClient.js.map +1 -1
- package/lib/commonjs/httpClient.spec.js +57 -5
- package/lib/commonjs/httpClient.spec.js.map +1 -1
- package/lib/commonjs/index.js +31 -14
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/index.spec.js +56 -11
- package/lib/commonjs/index.spec.js.map +1 -1
- package/lib/commonjs/native.js +15 -14
- package/lib/commonjs/native.js.map +1 -1
- package/lib/commonjs/native.spec.js +128 -22
- package/lib/commonjs/native.spec.js.map +1 -1
- package/lib/commonjs/{notifyAppReadyAnalytics.boundary.spec.js → notifyAppReadyInsights.boundary.spec.js} +28 -21
- package/lib/commonjs/notifyAppReadyInsights.boundary.spec.js.map +1 -0
- package/lib/commonjs/notifyAppReadyInsights.js +188 -0
- package/lib/commonjs/notifyAppReadyInsights.js.map +1 -0
- package/lib/commonjs/{notifyAppReadyAnalytics.spec.js → notifyAppReadyInsights.spec.js} +161 -29
- package/lib/commonjs/notifyAppReadyInsights.spec.js.map +1 -0
- package/lib/commonjs/{notifyAppReadyAnalytics.test-utils.js → notifyAppReadyInsights.test-utils.js} +3 -3
- package/lib/commonjs/notifyAppReadyInsights.test-utils.js.map +1 -0
- package/lib/commonjs/{notifyAppReadyAnalytics.transport.spec.js → notifyAppReadyInsights.transport.spec.js} +14 -7
- package/lib/commonjs/notifyAppReadyInsights.transport.spec.js.map +1 -0
- package/lib/commonjs/sdkVersion.js +1 -1
- package/lib/commonjs/sdkVersion.js.map +1 -1
- package/lib/commonjs/specs/NativeHotUpdater.js.map +1 -1
- package/lib/commonjs/store.js +3 -10
- package/lib/commonjs/store.js.map +1 -1
- package/lib/commonjs/store.notification.spec.js +12 -4
- package/lib/commonjs/store.notification.spec.js.map +1 -1
- package/lib/commonjs/store.spec.js +2 -136
- package/lib/commonjs/store.spec.js.map +1 -1
- package/lib/commonjs/wrap.js +11 -12
- package/lib/commonjs/wrap.js.map +1 -1
- package/lib/commonjs/wrap.spec.js +97 -25
- package/lib/commonjs/wrap.spec.js.map +1 -1
- package/lib/module/checkForUpdate.js +32 -23
- package/lib/module/checkForUpdate.js.map +1 -1
- package/lib/module/checkForUpdate.releaseCatalog.spec.js +97 -28
- package/lib/module/checkForUpdate.releaseCatalog.spec.js.map +1 -1
- package/lib/module/error.js +4 -13
- package/lib/module/error.js.map +1 -1
- package/lib/module/fetchJSON.js +7 -1
- package/lib/module/fetchJSON.js.map +1 -1
- package/lib/module/httpClient.js +48 -31
- package/lib/module/httpClient.js.map +1 -1
- package/lib/module/httpClient.spec.js +57 -5
- package/lib/module/httpClient.spec.js.map +1 -1
- package/lib/module/index.js +32 -15
- package/lib/module/index.js.map +1 -1
- package/lib/module/index.spec.js +56 -11
- package/lib/module/index.spec.js.map +1 -1
- package/lib/module/native.js +13 -12
- package/lib/module/native.js.map +1 -1
- package/lib/module/native.spec.js +128 -22
- package/lib/module/native.spec.js.map +1 -1
- package/lib/module/{notifyAppReadyAnalytics.boundary.spec.js → notifyAppReadyInsights.boundary.spec.js} +23 -16
- package/lib/module/notifyAppReadyInsights.boundary.spec.js.map +1 -0
- package/lib/module/notifyAppReadyInsights.js +181 -0
- package/lib/module/notifyAppReadyInsights.js.map +1 -0
- package/lib/module/{notifyAppReadyAnalytics.spec.js → notifyAppReadyInsights.spec.js} +153 -21
- package/lib/module/notifyAppReadyInsights.spec.js.map +1 -0
- package/lib/module/{notifyAppReadyAnalytics.test-utils.js → notifyAppReadyInsights.test-utils.js} +3 -3
- package/lib/module/notifyAppReadyInsights.test-utils.js.map +1 -0
- package/lib/module/{notifyAppReadyAnalytics.transport.spec.js → notifyAppReadyInsights.transport.spec.js} +11 -4
- package/lib/module/notifyAppReadyInsights.transport.spec.js.map +1 -0
- package/lib/module/sdkVersion.js +1 -1
- package/lib/module/sdkVersion.js.map +1 -1
- package/lib/module/specs/NativeHotUpdater.js.map +1 -1
- package/lib/module/store.js +3 -10
- package/lib/module/store.js.map +1 -1
- package/lib/module/store.notification.spec.js +12 -4
- package/lib/module/store.notification.spec.js.map +1 -1
- package/lib/module/store.spec.js +2 -136
- package/lib/module/store.spec.js.map +1 -1
- package/lib/module/wrap.js +11 -12
- package/lib/module/wrap.js.map +1 -1
- package/lib/module/wrap.spec.js +99 -25
- package/lib/module/wrap.spec.js.map +1 -1
- package/lib/typescript/commonjs/checkForUpdate.d.ts +2 -3
- package/lib/typescript/commonjs/checkForUpdate.d.ts.map +1 -1
- package/lib/typescript/commonjs/error.d.ts +4 -13
- package/lib/typescript/commonjs/error.d.ts.map +1 -1
- package/lib/typescript/commonjs/fetchJSON.d.ts +4 -0
- package/lib/typescript/commonjs/fetchJSON.d.ts.map +1 -1
- package/lib/typescript/commonjs/httpClient.d.ts +6 -6
- package/lib/typescript/commonjs/httpClient.d.ts.map +1 -1
- package/lib/typescript/commonjs/index.d.ts +4 -7
- package/lib/typescript/commonjs/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/native.d.ts +5 -9
- package/lib/typescript/commonjs/native.d.ts.map +1 -1
- package/lib/typescript/commonjs/notifyAppReadyInsights.d.ts +25 -0
- package/lib/typescript/commonjs/notifyAppReadyInsights.d.ts.map +1 -0
- package/lib/typescript/commonjs/notifyAppReadyInsights.test-utils.d.ts +8 -0
- package/lib/typescript/commonjs/notifyAppReadyInsights.test-utils.d.ts.map +1 -0
- package/lib/typescript/commonjs/sdkVersion.d.ts +1 -1
- package/lib/typescript/commonjs/sdkVersion.d.ts.map +1 -1
- package/lib/typescript/commonjs/specs/NativeHotUpdater.d.ts +8 -35
- package/lib/typescript/commonjs/specs/NativeHotUpdater.d.ts.map +1 -1
- package/lib/typescript/commonjs/store.d.ts +1 -3
- package/lib/typescript/commonjs/store.d.ts.map +1 -1
- package/lib/typescript/commonjs/wrap.types.d.ts +5 -8
- package/lib/typescript/commonjs/wrap.types.d.ts.map +1 -1
- package/lib/typescript/module/checkForUpdate.d.ts +2 -3
- package/lib/typescript/module/checkForUpdate.d.ts.map +1 -1
- package/lib/typescript/module/error.d.ts +4 -13
- package/lib/typescript/module/error.d.ts.map +1 -1
- package/lib/typescript/module/fetchJSON.d.ts +4 -0
- package/lib/typescript/module/fetchJSON.d.ts.map +1 -1
- package/lib/typescript/module/httpClient.d.ts +6 -6
- package/lib/typescript/module/httpClient.d.ts.map +1 -1
- package/lib/typescript/module/index.d.ts +4 -7
- package/lib/typescript/module/index.d.ts.map +1 -1
- package/lib/typescript/module/native.d.ts +5 -9
- package/lib/typescript/module/native.d.ts.map +1 -1
- package/lib/typescript/module/notifyAppReadyInsights.d.ts +25 -0
- package/lib/typescript/module/notifyAppReadyInsights.d.ts.map +1 -0
- package/lib/typescript/module/notifyAppReadyInsights.test-utils.d.ts +8 -0
- package/lib/typescript/module/notifyAppReadyInsights.test-utils.d.ts.map +1 -0
- package/lib/typescript/module/sdkVersion.d.ts +1 -1
- package/lib/typescript/module/sdkVersion.d.ts.map +1 -1
- package/lib/typescript/module/specs/NativeHotUpdater.d.ts +8 -35
- package/lib/typescript/module/specs/NativeHotUpdater.d.ts.map +1 -1
- package/lib/typescript/module/store.d.ts +1 -3
- package/lib/typescript/module/store.d.ts.map +1 -1
- package/lib/typescript/module/wrap.types.d.ts +5 -8
- package/lib/typescript/module/wrap.types.d.ts.map +1 -1
- package/package.json +3 -3
- package/src/checkForUpdate.releaseCatalog.spec.ts +137 -61
- package/src/checkForUpdate.ts +35 -29
- package/src/error.ts +4 -14
- package/src/fetchJSON.ts +12 -1
- package/src/httpClient.spec.ts +70 -5
- package/src/httpClient.ts +78 -64
- package/src/index.spec.ts +59 -11
- package/src/index.ts +41 -17
- package/src/native.spec.ts +133 -22
- package/src/native.ts +21 -32
- package/src/{notifyAppReadyAnalytics.boundary.spec.ts → notifyAppReadyInsights.boundary.spec.ts} +25 -17
- package/src/{notifyAppReadyAnalytics.spec.ts → notifyAppReadyInsights.spec.ts} +141 -22
- package/src/{notifyAppReadyAnalytics.test-utils.ts → notifyAppReadyInsights.test-utils.ts} +4 -4
- package/src/{notifyAppReadyAnalytics.transport.spec.ts → notifyAppReadyInsights.transport.spec.ts} +13 -5
- package/src/notifyAppReadyInsights.ts +293 -0
- package/src/sdkVersion.ts +1 -1
- package/src/specs/NativeHotUpdater.ts +8 -36
- package/src/store.notification.spec.ts +13 -3
- package/src/store.spec.ts +0 -157
- package/src/store.ts +2 -23
- package/src/wrap.spec.ts +109 -31
- package/src/wrap.tsx +11 -11
- package/src/wrap.types.ts +5 -8
- package/android/src/main/java/com/hotupdater/DecompressService.kt +0 -89
- package/android/src/main/java/com/hotupdater/DecompressionStrategy.kt +0 -26
- package/android/src/main/java/com/hotupdater/TarBrDecompressionStrategy.kt +0 -117
- package/android/src/main/java/com/hotupdater/TarGzDecompressionStrategy.kt +0 -117
- package/android/src/main/java/com/hotupdater/ZipDecompressionStrategy.kt +0 -192
- package/android/src/test/java/com/hotupdater/TarArchiveInputStreamTest.kt +0 -68
- package/ios/HotUpdater/Internal/ArchiveExtractionUtilities.swift +0 -178
- package/ios/HotUpdater/Internal/DecompressService.swift +0 -112
- package/ios/HotUpdater/Internal/DecompressionStrategy.swift +0 -22
- package/ios/HotUpdater/Internal/StreamingTarArchiveExtractor.swift +0 -370
- package/ios/HotUpdater/Internal/TarBrDecompressionStrategy.swift +0 -39
- package/ios/HotUpdater/Internal/TarGzDecompressionStrategy.swift +0 -59
- package/ios/HotUpdater/Internal/ZipArchiveExtractor.swift +0 -482
- package/ios/HotUpdater/Internal/ZipDecompressionStrategy.swift +0 -56
- package/lib/commonjs/notifyAppReadyAnalytics.boundary.spec.js.map +0 -1
- package/lib/commonjs/notifyAppReadyAnalytics.js +0 -133
- package/lib/commonjs/notifyAppReadyAnalytics.js.map +0 -1
- package/lib/commonjs/notifyAppReadyAnalytics.spec.js.map +0 -1
- package/lib/commonjs/notifyAppReadyAnalytics.test-utils.js.map +0 -1
- package/lib/commonjs/notifyAppReadyAnalytics.transport.spec.js.map +0 -1
- package/lib/module/notifyAppReadyAnalytics.boundary.spec.js.map +0 -1
- package/lib/module/notifyAppReadyAnalytics.js +0 -128
- package/lib/module/notifyAppReadyAnalytics.js.map +0 -1
- package/lib/module/notifyAppReadyAnalytics.spec.js.map +0 -1
- package/lib/module/notifyAppReadyAnalytics.test-utils.js.map +0 -1
- package/lib/module/notifyAppReadyAnalytics.transport.spec.js.map +0 -1
- package/lib/typescript/commonjs/notifyAppReadyAnalytics.d.ts +0 -13
- package/lib/typescript/commonjs/notifyAppReadyAnalytics.d.ts.map +0 -1
- package/lib/typescript/commonjs/notifyAppReadyAnalytics.test-utils.d.ts +0 -8
- package/lib/typescript/commonjs/notifyAppReadyAnalytics.test-utils.d.ts.map +0 -1
- package/lib/typescript/module/notifyAppReadyAnalytics.d.ts +0 -13
- package/lib/typescript/module/notifyAppReadyAnalytics.d.ts.map +0 -1
- package/lib/typescript/module/notifyAppReadyAnalytics.test-utils.d.ts +0 -8
- package/lib/typescript/module/notifyAppReadyAnalytics.test-utils.d.ts.map +0 -1
- package/src/notifyAppReadyAnalytics.ts +0 -194
|
@@ -1,482 +0,0 @@
|
|
|
1
|
-
import Foundation
|
|
2
|
-
import zlib
|
|
3
|
-
|
|
4
|
-
enum ZipArchiveExtractor {
|
|
5
|
-
private static let localFileHeaderSignature: UInt32 = 0x04034B50
|
|
6
|
-
private static let centralDirectoryHeaderSignature: UInt32 = 0x02014B50
|
|
7
|
-
private static let endOfCentralDirectorySignature: UInt32 = 0x06054B50
|
|
8
|
-
private static let storedMethod: UInt16 = 0
|
|
9
|
-
private static let deflatedMethod: UInt16 = 8
|
|
10
|
-
private static let encryptedFlag: UInt16 = 1 << 0
|
|
11
|
-
private static let maxCommentLength = 0xFFFF
|
|
12
|
-
private static let unixHostIdentifier: UInt8 = 3
|
|
13
|
-
private static let fileTypeMask: UInt16 = 0o170000
|
|
14
|
-
private static let symbolicLinkMode: UInt16 = 0o120000
|
|
15
|
-
private static let directoryMode: UInt16 = 0o040000
|
|
16
|
-
|
|
17
|
-
private struct CentralDirectoryEntry {
|
|
18
|
-
let path: String
|
|
19
|
-
let compressionMethod: UInt16
|
|
20
|
-
let flags: UInt16
|
|
21
|
-
let compressedSize: UInt64
|
|
22
|
-
let uncompressedSize: UInt64
|
|
23
|
-
let checksum: UInt32
|
|
24
|
-
let localHeaderOffset: UInt64
|
|
25
|
-
let isDirectory: Bool
|
|
26
|
-
let isSymbolicLink: Bool
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
private struct EndOfCentralDirectoryRecord {
|
|
30
|
-
let totalEntries: UInt16
|
|
31
|
-
let centralDirectoryOffset: UInt64
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
static func extract(file: String, to destination: String, progressHandler: @escaping (Double) -> Void) throws {
|
|
35
|
-
let fileURL = URL(fileURLWithPath: file)
|
|
36
|
-
let fileSize = try archiveFileSize(at: file)
|
|
37
|
-
let handle = try FileHandle(forReadingFrom: fileURL)
|
|
38
|
-
|
|
39
|
-
defer {
|
|
40
|
-
try? handle.close()
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
let entries = try readCentralDirectoryEntries(from: handle, fileSize: fileSize)
|
|
44
|
-
|
|
45
|
-
let destinationURL = URL(fileURLWithPath: destination)
|
|
46
|
-
try ArchiveExtractionUtilities.ensureDirectory(at: destinationURL)
|
|
47
|
-
|
|
48
|
-
let totalCompressedBytes = entries.reduce(UInt64(0)) { $0 + max($1.compressedSize, 1) }
|
|
49
|
-
var processedCompressedBytes: UInt64 = 0
|
|
50
|
-
|
|
51
|
-
for entry in entries {
|
|
52
|
-
try extractEntry(entry, from: handle, to: destinationURL.standardizedFileURL.path)
|
|
53
|
-
processedCompressedBytes += max(entry.compressedSize, 1)
|
|
54
|
-
|
|
55
|
-
guard totalCompressedBytes > 0 else {
|
|
56
|
-
continue
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
let progress = min(Double(processedCompressedBytes) / Double(totalCompressedBytes), 1.0)
|
|
60
|
-
progressHandler(progress)
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
progressHandler(1.0)
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
private static func readCentralDirectoryEntries(
|
|
67
|
-
from handle: FileHandle,
|
|
68
|
-
fileSize: UInt64
|
|
69
|
-
) throws -> [CentralDirectoryEntry] {
|
|
70
|
-
let endRecord = try locateEndOfCentralDirectory(in: handle, fileSize: fileSize)
|
|
71
|
-
|
|
72
|
-
try ArchiveExtractionUtilities.seek(handle, to: endRecord.centralDirectoryOffset)
|
|
73
|
-
|
|
74
|
-
var entries: [CentralDirectoryEntry] = []
|
|
75
|
-
entries.reserveCapacity(Int(endRecord.totalEntries))
|
|
76
|
-
|
|
77
|
-
for _ in 0..<endRecord.totalEntries {
|
|
78
|
-
let header = try ArchiveExtractionUtilities.readExactly(from: handle, count: 46)
|
|
79
|
-
|
|
80
|
-
guard header.archiveUInt32LE(at: 0) == centralDirectoryHeaderSignature else {
|
|
81
|
-
throw NSError(
|
|
82
|
-
domain: "ZipArchiveExtractor",
|
|
83
|
-
code: 1,
|
|
84
|
-
userInfo: [NSLocalizedDescriptionKey: "Invalid ZIP central directory header"]
|
|
85
|
-
)
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
let flags = header.archiveUInt16LE(at: 8)
|
|
89
|
-
let compressionMethod = header.archiveUInt16LE(at: 10)
|
|
90
|
-
let compressedSize = header.archiveUInt32LE(at: 20)
|
|
91
|
-
let uncompressedSize = header.archiveUInt32LE(at: 24)
|
|
92
|
-
let fileNameLength = Int(header.archiveUInt16LE(at: 28))
|
|
93
|
-
let extraFieldLength = Int(header.archiveUInt16LE(at: 30))
|
|
94
|
-
let commentLength = Int(header.archiveUInt16LE(at: 32))
|
|
95
|
-
let checksum = header.archiveUInt32LE(at: 16)
|
|
96
|
-
let localHeaderOffset = header.archiveUInt32LE(at: 42)
|
|
97
|
-
let versionMadeBy = header.archiveUInt16LE(at: 4)
|
|
98
|
-
let externalAttributes = header.archiveUInt32LE(at: 38)
|
|
99
|
-
|
|
100
|
-
guard compressedSize != UInt32.max,
|
|
101
|
-
uncompressedSize != UInt32.max,
|
|
102
|
-
localHeaderOffset != UInt32.max else {
|
|
103
|
-
throw NSError(
|
|
104
|
-
domain: "ZipArchiveExtractor",
|
|
105
|
-
code: 2,
|
|
106
|
-
userInfo: [NSLocalizedDescriptionKey: "ZIP64 archives are not supported"]
|
|
107
|
-
)
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
let fileNameData = try ArchiveExtractionUtilities.readExactly(from: handle, count: fileNameLength)
|
|
111
|
-
let extraFieldData = try ArchiveExtractionUtilities.readExactly(from: handle, count: extraFieldLength)
|
|
112
|
-
_ = extraFieldData
|
|
113
|
-
if commentLength > 0 {
|
|
114
|
-
try ArchiveExtractionUtilities.skipBytes(UInt64(commentLength), in: handle)
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
let path = decodePath(from: fileNameData)
|
|
118
|
-
let mode = unixFileMode(versionMadeBy: versionMadeBy, externalAttributes: externalAttributes)
|
|
119
|
-
let isDirectory = path.hasSuffix("/") || mode == directoryMode
|
|
120
|
-
let isSymbolicLink = mode == symbolicLinkMode
|
|
121
|
-
|
|
122
|
-
entries.append(
|
|
123
|
-
CentralDirectoryEntry(
|
|
124
|
-
path: path,
|
|
125
|
-
compressionMethod: compressionMethod,
|
|
126
|
-
flags: flags,
|
|
127
|
-
compressedSize: UInt64(compressedSize),
|
|
128
|
-
uncompressedSize: UInt64(uncompressedSize),
|
|
129
|
-
checksum: checksum,
|
|
130
|
-
localHeaderOffset: UInt64(localHeaderOffset),
|
|
131
|
-
isDirectory: isDirectory,
|
|
132
|
-
isSymbolicLink: isSymbolicLink
|
|
133
|
-
)
|
|
134
|
-
)
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
return entries
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
private static func locateEndOfCentralDirectory(
|
|
141
|
-
in handle: FileHandle,
|
|
142
|
-
fileSize: UInt64
|
|
143
|
-
) throws -> EndOfCentralDirectoryRecord {
|
|
144
|
-
let minimumRecordLength = 22
|
|
145
|
-
let searchLength = Int(min(fileSize, UInt64(maxCommentLength + minimumRecordLength)))
|
|
146
|
-
let searchOffset = fileSize - UInt64(searchLength)
|
|
147
|
-
|
|
148
|
-
try ArchiveExtractionUtilities.seek(handle, to: searchOffset)
|
|
149
|
-
let tailData = try ArchiveExtractionUtilities.readExactly(from: handle, count: searchLength)
|
|
150
|
-
|
|
151
|
-
let signatureBytes: [UInt8] = [0x50, 0x4B, 0x05, 0x06]
|
|
152
|
-
|
|
153
|
-
guard let recordIndex = findLastSignature(signatureBytes, in: tailData) else {
|
|
154
|
-
throw NSError(
|
|
155
|
-
domain: "ZipArchiveExtractor",
|
|
156
|
-
code: 3,
|
|
157
|
-
userInfo: [NSLocalizedDescriptionKey: "ZIP end of central directory record not found"]
|
|
158
|
-
)
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
let minimumEndIndex = recordIndex + minimumRecordLength
|
|
162
|
-
guard minimumEndIndex <= tailData.count else {
|
|
163
|
-
throw NSError(
|
|
164
|
-
domain: "ZipArchiveExtractor",
|
|
165
|
-
code: 4,
|
|
166
|
-
userInfo: [NSLocalizedDescriptionKey: "ZIP end of central directory record is truncated"]
|
|
167
|
-
)
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
let commentLength = Int(tailData.archiveUInt16LE(at: recordIndex + 20))
|
|
171
|
-
guard minimumEndIndex + commentLength == tailData.count else {
|
|
172
|
-
throw NSError(
|
|
173
|
-
domain: "ZipArchiveExtractor",
|
|
174
|
-
code: 5,
|
|
175
|
-
userInfo: [NSLocalizedDescriptionKey: "ZIP central directory comment is malformed"]
|
|
176
|
-
)
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
return EndOfCentralDirectoryRecord(
|
|
180
|
-
totalEntries: tailData.archiveUInt16LE(at: recordIndex + 10),
|
|
181
|
-
centralDirectoryOffset: UInt64(tailData.archiveUInt32LE(at: recordIndex + 16))
|
|
182
|
-
)
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
private static func extractEntry(
|
|
186
|
-
_ entry: CentralDirectoryEntry,
|
|
187
|
-
from handle: FileHandle,
|
|
188
|
-
to destinationRoot: String
|
|
189
|
-
) throws {
|
|
190
|
-
guard entry.flags & encryptedFlag == 0 else {
|
|
191
|
-
throw NSError(
|
|
192
|
-
domain: "ZipArchiveExtractor",
|
|
193
|
-
code: 6,
|
|
194
|
-
userInfo: [NSLocalizedDescriptionKey: "Encrypted ZIP entries are not supported"]
|
|
195
|
-
)
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
guard let relativePath = ArchiveExtractionUtilities.normalizedRelativePath(from: entry.path) else {
|
|
199
|
-
return
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
let targetURL = try ArchiveExtractionUtilities.extractionURL(
|
|
203
|
-
for: relativePath,
|
|
204
|
-
destinationRoot: destinationRoot
|
|
205
|
-
)
|
|
206
|
-
|
|
207
|
-
if entry.isDirectory {
|
|
208
|
-
try ArchiveExtractionUtilities.ensureDirectory(at: targetURL)
|
|
209
|
-
return
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
if entry.isSymbolicLink {
|
|
213
|
-
NSLog("[ZipArchiveExtractor] Skipping symbolic link entry: \(entry.path)")
|
|
214
|
-
return
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
try ArchiveExtractionUtilities.seek(handle, to: entry.localHeaderOffset)
|
|
218
|
-
let localHeader = try ArchiveExtractionUtilities.readExactly(from: handle, count: 30)
|
|
219
|
-
|
|
220
|
-
guard localHeader.archiveUInt32LE(at: 0) == localFileHeaderSignature else {
|
|
221
|
-
throw NSError(
|
|
222
|
-
domain: "ZipArchiveExtractor",
|
|
223
|
-
code: 7,
|
|
224
|
-
userInfo: [NSLocalizedDescriptionKey: "Invalid ZIP local file header for \(entry.path)"]
|
|
225
|
-
)
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
let fileNameLength = UInt64(localHeader.archiveUInt16LE(at: 26))
|
|
229
|
-
let extraFieldLength = UInt64(localHeader.archiveUInt16LE(at: 28))
|
|
230
|
-
let dataOffset = entry.localHeaderOffset + 30 + fileNameLength + extraFieldLength
|
|
231
|
-
|
|
232
|
-
try ArchiveExtractionUtilities.seek(handle, to: dataOffset)
|
|
233
|
-
let outputHandle = try ArchiveExtractionUtilities.createOutputFile(at: targetURL)
|
|
234
|
-
|
|
235
|
-
defer {
|
|
236
|
-
try? outputHandle.close()
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
let extractionResult: (writtenSize: UInt64, checksum: UInt32)
|
|
240
|
-
|
|
241
|
-
switch entry.compressionMethod {
|
|
242
|
-
case storedMethod:
|
|
243
|
-
extractionResult = try extractStoredEntry(
|
|
244
|
-
from: handle,
|
|
245
|
-
compressedSize: entry.compressedSize,
|
|
246
|
-
to: outputHandle
|
|
247
|
-
)
|
|
248
|
-
case deflatedMethod:
|
|
249
|
-
extractionResult = try extractDeflatedEntry(
|
|
250
|
-
from: handle,
|
|
251
|
-
compressedSize: entry.compressedSize,
|
|
252
|
-
path: entry.path,
|
|
253
|
-
to: outputHandle
|
|
254
|
-
)
|
|
255
|
-
default:
|
|
256
|
-
throw NSError(
|
|
257
|
-
domain: "ZipArchiveExtractor",
|
|
258
|
-
code: 8,
|
|
259
|
-
userInfo: [NSLocalizedDescriptionKey: "Unsupported ZIP compression method \(entry.compressionMethod) for \(entry.path)"]
|
|
260
|
-
)
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
guard extractionResult.writtenSize == entry.uncompressedSize else {
|
|
264
|
-
throw NSError(
|
|
265
|
-
domain: "ZipArchiveExtractor",
|
|
266
|
-
code: 9,
|
|
267
|
-
userInfo: [NSLocalizedDescriptionKey: "ZIP entry size mismatch for \(entry.path)"]
|
|
268
|
-
)
|
|
269
|
-
}
|
|
270
|
-
|
|
271
|
-
guard extractionResult.checksum == entry.checksum else {
|
|
272
|
-
throw NSError(
|
|
273
|
-
domain: "ZipArchiveExtractor",
|
|
274
|
-
code: 10,
|
|
275
|
-
userInfo: [NSLocalizedDescriptionKey: "ZIP entry checksum mismatch for \(entry.path)"]
|
|
276
|
-
)
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
private static func extractStoredEntry(
|
|
281
|
-
from handle: FileHandle,
|
|
282
|
-
compressedSize: UInt64,
|
|
283
|
-
to outputHandle: FileHandle
|
|
284
|
-
) throws -> (writtenSize: UInt64, checksum: UInt32) {
|
|
285
|
-
var remainingBytes = compressedSize
|
|
286
|
-
var totalWritten: UInt64 = 0
|
|
287
|
-
var checksum: uLong = crc32(0, nil, 0)
|
|
288
|
-
|
|
289
|
-
while remainingBytes > 0 {
|
|
290
|
-
let chunkSize = Int(min(remainingBytes, UInt64(ArchiveExtractionUtilities.bufferSize)))
|
|
291
|
-
let chunk = try ArchiveExtractionUtilities.readExactly(from: handle, count: chunkSize)
|
|
292
|
-
outputHandle.write(chunk)
|
|
293
|
-
totalWritten += UInt64(chunk.count)
|
|
294
|
-
checksum = updateCRC32(checksum, with: chunk)
|
|
295
|
-
remainingBytes -= UInt64(chunk.count)
|
|
296
|
-
}
|
|
297
|
-
|
|
298
|
-
return (totalWritten, UInt32(checksum))
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
private static func extractDeflatedEntry(
|
|
302
|
-
from handle: FileHandle,
|
|
303
|
-
compressedSize: UInt64,
|
|
304
|
-
path: String,
|
|
305
|
-
to outputHandle: FileHandle
|
|
306
|
-
) throws -> (writtenSize: UInt64, checksum: UInt32) {
|
|
307
|
-
let outputBuffer = UnsafeMutablePointer<UInt8>.allocate(capacity: ArchiveExtractionUtilities.bufferSize)
|
|
308
|
-
|
|
309
|
-
defer {
|
|
310
|
-
outputBuffer.deallocate()
|
|
311
|
-
}
|
|
312
|
-
|
|
313
|
-
var stream = z_stream()
|
|
314
|
-
let initStatus = inflateInit2_(
|
|
315
|
-
&stream,
|
|
316
|
-
-MAX_WBITS,
|
|
317
|
-
ZLIB_VERSION,
|
|
318
|
-
Int32(MemoryLayout<z_stream>.size)
|
|
319
|
-
)
|
|
320
|
-
|
|
321
|
-
guard initStatus == Z_OK else {
|
|
322
|
-
throw NSError(
|
|
323
|
-
domain: "ZipArchiveExtractor",
|
|
324
|
-
code: 11,
|
|
325
|
-
userInfo: [NSLocalizedDescriptionKey: "Failed to initialize ZIP inflater"]
|
|
326
|
-
)
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
defer {
|
|
330
|
-
inflateEnd(&stream)
|
|
331
|
-
}
|
|
332
|
-
|
|
333
|
-
var remainingBytes = compressedSize
|
|
334
|
-
var totalWritten: UInt64 = 0
|
|
335
|
-
var checksum: uLong = crc32(0, nil, 0)
|
|
336
|
-
var reachedStreamEnd = false
|
|
337
|
-
|
|
338
|
-
while remainingBytes > 0 {
|
|
339
|
-
let chunkSize = Int(min(remainingBytes, UInt64(ArchiveExtractionUtilities.bufferSize)))
|
|
340
|
-
let chunk = try ArchiveExtractionUtilities.readExactly(from: handle, count: chunkSize)
|
|
341
|
-
remainingBytes -= UInt64(chunk.count)
|
|
342
|
-
|
|
343
|
-
try chunk.withUnsafeBytes { rawBuffer in
|
|
344
|
-
guard let baseAddress = rawBuffer.bindMemory(to: UInt8.self).baseAddress else {
|
|
345
|
-
return
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
stream.next_in = UnsafeMutablePointer(mutating: baseAddress)
|
|
349
|
-
stream.avail_in = uInt(chunk.count)
|
|
350
|
-
var needsMoreInput = false
|
|
351
|
-
|
|
352
|
-
repeat {
|
|
353
|
-
stream.next_out = outputBuffer
|
|
354
|
-
stream.avail_out = uInt(ArchiveExtractionUtilities.bufferSize)
|
|
355
|
-
|
|
356
|
-
let status = inflate(&stream, Z_NO_FLUSH)
|
|
357
|
-
let producedBytes = ArchiveExtractionUtilities.bufferSize - Int(stream.avail_out)
|
|
358
|
-
if producedBytes > 0 {
|
|
359
|
-
let outputData = Data(bytes: outputBuffer, count: producedBytes)
|
|
360
|
-
outputHandle.write(outputData)
|
|
361
|
-
totalWritten += UInt64(producedBytes)
|
|
362
|
-
checksum = updateCRC32(checksum, with: outputData)
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
switch status {
|
|
366
|
-
case Z_OK, Z_STREAM_END:
|
|
367
|
-
if status == Z_STREAM_END {
|
|
368
|
-
guard stream.avail_in == 0, remainingBytes == 0 else {
|
|
369
|
-
throw NSError(
|
|
370
|
-
domain: "ZipArchiveExtractor",
|
|
371
|
-
code: 12,
|
|
372
|
-
userInfo: [NSLocalizedDescriptionKey: "ZIP deflate stream ended unexpectedly"]
|
|
373
|
-
)
|
|
374
|
-
}
|
|
375
|
-
|
|
376
|
-
reachedStreamEnd = true
|
|
377
|
-
}
|
|
378
|
-
case Z_BUF_ERROR:
|
|
379
|
-
guard stream.avail_in == 0, remainingBytes > 0 else {
|
|
380
|
-
let message = stream.msg.map { String(cString: $0) } ?? "Unknown zlib error"
|
|
381
|
-
throw NSError(
|
|
382
|
-
domain: "ZipArchiveExtractor",
|
|
383
|
-
code: 13,
|
|
384
|
-
userInfo: [
|
|
385
|
-
NSLocalizedDescriptionKey:
|
|
386
|
-
"ZIP deflate failed for \(path): status=\(status) totalIn=\(stream.total_in) totalOut=\(stream.total_out) \(message)"
|
|
387
|
-
]
|
|
388
|
-
)
|
|
389
|
-
}
|
|
390
|
-
|
|
391
|
-
needsMoreInput = true
|
|
392
|
-
|
|
393
|
-
default:
|
|
394
|
-
let message = stream.msg.map { String(cString: $0) } ?? "Unknown zlib error"
|
|
395
|
-
throw NSError(
|
|
396
|
-
domain: "ZipArchiveExtractor",
|
|
397
|
-
code: 13,
|
|
398
|
-
userInfo: [
|
|
399
|
-
NSLocalizedDescriptionKey:
|
|
400
|
-
"ZIP deflate failed for \(path): status=\(status) totalIn=\(stream.total_in) totalOut=\(stream.total_out) \(message)"
|
|
401
|
-
]
|
|
402
|
-
)
|
|
403
|
-
}
|
|
404
|
-
} while (stream.avail_in > 0 || stream.avail_out == 0) && !needsMoreInput && !reachedStreamEnd
|
|
405
|
-
}
|
|
406
|
-
|
|
407
|
-
if reachedStreamEnd {
|
|
408
|
-
break
|
|
409
|
-
}
|
|
410
|
-
}
|
|
411
|
-
|
|
412
|
-
guard reachedStreamEnd || compressedSize == 0 else {
|
|
413
|
-
throw NSError(
|
|
414
|
-
domain: "ZipArchiveExtractor",
|
|
415
|
-
code: 14,
|
|
416
|
-
userInfo: [NSLocalizedDescriptionKey: "ZIP deflate stream did not terminate correctly"]
|
|
417
|
-
)
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
return (totalWritten, UInt32(checksum))
|
|
421
|
-
}
|
|
422
|
-
|
|
423
|
-
private static func findLastSignature(_ signature: [UInt8], in data: Data) -> Int? {
|
|
424
|
-
guard signature.count <= data.count else {
|
|
425
|
-
return nil
|
|
426
|
-
}
|
|
427
|
-
|
|
428
|
-
let lastStartIndex = data.count - signature.count
|
|
429
|
-
for startIndex in stride(from: lastStartIndex, through: 0, by: -1) {
|
|
430
|
-
if Array(data[startIndex..<(startIndex + signature.count)]) == signature {
|
|
431
|
-
return startIndex
|
|
432
|
-
}
|
|
433
|
-
}
|
|
434
|
-
|
|
435
|
-
return nil
|
|
436
|
-
}
|
|
437
|
-
|
|
438
|
-
private static func decodePath(from data: Data) -> String {
|
|
439
|
-
if let utf8Path = String(data: data, encoding: .utf8) {
|
|
440
|
-
return utf8Path
|
|
441
|
-
}
|
|
442
|
-
|
|
443
|
-
return String(decoding: data, as: UTF8.self)
|
|
444
|
-
}
|
|
445
|
-
|
|
446
|
-
private static func updateCRC32(_ checksum: uLong, with data: Data) -> uLong {
|
|
447
|
-
data.withUnsafeBytes { rawBuffer in
|
|
448
|
-
guard let baseAddress = rawBuffer.bindMemory(to: Bytef.self).baseAddress else {
|
|
449
|
-
return checksum
|
|
450
|
-
}
|
|
451
|
-
|
|
452
|
-
return crc32(checksum, baseAddress, uInt(data.count))
|
|
453
|
-
}
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
private static func unixFileMode(versionMadeBy: UInt16, externalAttributes: UInt32) -> UInt16? {
|
|
457
|
-
let hostIdentifier = UInt8((versionMadeBy >> 8) & 0xFF)
|
|
458
|
-
guard hostIdentifier == unixHostIdentifier else {
|
|
459
|
-
return nil
|
|
460
|
-
}
|
|
461
|
-
|
|
462
|
-
let mode = UInt16((externalAttributes >> 16) & 0xFFFF) & fileTypeMask
|
|
463
|
-
guard mode != 0 else {
|
|
464
|
-
return nil
|
|
465
|
-
}
|
|
466
|
-
|
|
467
|
-
return mode
|
|
468
|
-
}
|
|
469
|
-
|
|
470
|
-
private static func archiveFileSize(at path: String) throws -> UInt64 {
|
|
471
|
-
let attributes = try FileManager.default.attributesOfItem(atPath: path)
|
|
472
|
-
if let number = attributes[.size] as? NSNumber {
|
|
473
|
-
return number.uint64Value
|
|
474
|
-
}
|
|
475
|
-
|
|
476
|
-
if let value = attributes[.size] as? UInt64 {
|
|
477
|
-
return value
|
|
478
|
-
}
|
|
479
|
-
|
|
480
|
-
return 0
|
|
481
|
-
}
|
|
482
|
-
}
|
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
import Foundation
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* Strategy for handling ZIP compressed files
|
|
5
|
-
*/
|
|
6
|
-
class ZipDecompressionStrategy: DecompressionStrategy {
|
|
7
|
-
private static let ZIP_MAGIC_NUMBER: [UInt8] = [0x50, 0x4B, 0x03, 0x04]
|
|
8
|
-
private static let MIN_ZIP_SIZE: UInt64 = 22
|
|
9
|
-
|
|
10
|
-
func isValid(file: String) -> Bool {
|
|
11
|
-
guard FileManager.default.fileExists(atPath: file) else {
|
|
12
|
-
NSLog("[ZipStrategy] Invalid ZIP: file doesn't exist")
|
|
13
|
-
return false
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
do {
|
|
17
|
-
let attributes = try FileManager.default.attributesOfItem(atPath: file)
|
|
18
|
-
guard let fileSize = attributes[.size] as? UInt64, fileSize >= Self.MIN_ZIP_SIZE else {
|
|
19
|
-
NSLog("[ZipStrategy] Invalid ZIP: file too small")
|
|
20
|
-
return false
|
|
21
|
-
}
|
|
22
|
-
} catch {
|
|
23
|
-
NSLog("[ZipStrategy] Invalid ZIP: cannot read attributes - \(error.localizedDescription)")
|
|
24
|
-
return false
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
guard let fileHandle = FileHandle(forReadingAtPath: file) else {
|
|
28
|
-
NSLog("[ZipStrategy] Invalid ZIP: cannot open file")
|
|
29
|
-
return false
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
defer {
|
|
33
|
-
fileHandle.closeFile()
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
guard let header = try? ArchiveExtractionUtilities.readUpToCount(from: fileHandle, count: 4),
|
|
37
|
-
header.count == 4 else {
|
|
38
|
-
NSLog("[ZipStrategy] Invalid ZIP: cannot read header")
|
|
39
|
-
return false
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
let magicBytes = [UInt8](header)
|
|
43
|
-
guard magicBytes == Self.ZIP_MAGIC_NUMBER else {
|
|
44
|
-
NSLog("[ZipStrategy] Invalid ZIP: wrong magic number")
|
|
45
|
-
return false
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
return true
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
func decompress(file: String, to destination: String, progressHandler: @escaping (Double) -> Void) throws {
|
|
52
|
-
NSLog("[ZipStrategy] Starting extraction of \(file) to \(destination)")
|
|
53
|
-
try ZipArchiveExtractor.extract(file: file, to: destination, progressHandler: progressHandler)
|
|
54
|
-
NSLog("[ZipStrategy] Successfully extracted all entries")
|
|
55
|
-
}
|
|
56
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"names":["_vitest","require","_notifyAppReadyAnalyticsTestUtils","_interopRequireWildcard","e","t","WeakMap","r","n","__esModule","o","i","f","__proto__","default","has","get","set","hasOwnProperty","call","Object","defineProperty","getOwnPropertyDescriptor","platformState","vi","hoisted","OS","mock","NativeEventEmitter","Platform","nativePersistence","persistedInstallId","getConstants","fn","APP_VERSION","CHANNEL","DEFAULT_CHANNEL","FINGERPRINT_HASH","MIN_BUNDLE_ID","getInstallId","setPersistedInstallId","installId","mocks","addListener","checkForUpdate","getAppVersion","getBundleId","getChannel","getCohort","getFingerprintHash","getPersistedUserIdentity","readNotifyAppReady","createNotifyReadResult","reload","createClient","sendAnalyticsEvent","mockResolvedValue","undefined","client","createSession","fetchReleaseCatalog","resolveArtifact","describe","beforeEach","resetModules","unstubAllGlobals","useRealTimers","values","mockReset","mockReturnValue","mockClear","it","stubNotifyFrame","warn","spyOn","console","mockImplementation","onError","onNotifyAppReady","init","Promise","resolve","then","analytics","Error","runOnlyPendingTimersAsync","expect","not","toHaveBeenCalled","toHaveBeenCalledWith","status","objectContaining","message","mockRestore","each","label","value","any","platform","native","importActual","toBe","nativeAfterReset","toHaveBeenCalledTimes"],"sourceRoot":"../../src","sources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CAACU,GAAG,CAACC,gBAAgB,CAAC,CAAC;IACtC,IAAAF,cAAM,EAACR,gBAAgB,CAAC,CAACW,oBAAoB,CAAC;MAAEC,MAAM,EAAE;IAAY,CAAC,CAAC;IACtE,IAAAJ,cAAM,EAACb,IAAI,CAAC,CAACgB,oBAAoB,CAC/B,yDAAyD,EACzDH,cAAM,CAACW,GAAG,CAACb,KAAK,CAClB,CAAC;IACDX,IAAI,CAACoB,WAAW,CAAC,CAAC;EACpB,CACF,CAAC;EAEDtB,UAAE,CAACuB,IAAI,CAAC,CAAC,KAAK,EAAE,SAAS,CAAU,CAAC,CAClC,4EAA4E,EAC5E,MAAOI,QAAQ,IAAK;IAClB3E,aAAa,CAACG,EAAE,GAAGwE,QAAQ;IAC3BpE,iBAAiB,CAACU,qBAAqB,CAAC,mBAAmB,CAAC;IAC5D,MAAM2D,MAAM,GACV,MAAM3E,UAAE,CAAC4E,YAAY,CAA4B,UAAU,CAAC;IAE9D,IAAAd,cAAM,EAACa,MAAM,CAAC5D,YAAY,CAAC,CAAC,CAAC,CAAC8D,IAAI,CAAC,mBAAmB,CAAC;IACvD7E,UAAE,CAACwC,YAAY,CAAC,CAAC;IACjB,MAAMsC,gBAAgB,GACpB,MAAM9E,UAAE,CAAC4E,YAAY,CAA4B,UAAU,CAAC;IAE9D,IAAAd,cAAM,EAACgB,gBAAgB,CAAC/D,YAAY,CAAC,CAAC,CAAC,CAAC8D,IAAI,CAAC,mBAAmB,CAAC;IACjE,IAAAf,cAAM,EAACxD,iBAAiB,CAACS,YAAY,CAAC,CAACgE,qBAAqB,CAAC,CAAC,CAAC;EACjE,CACF,CAAC;AACH,CAAC,CAAC","ignoreList":[]}
|
|
@@ -1,133 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.handleNotifyAppReady = void 0;
|
|
7
|
-
var _reactNative = require("react-native");
|
|
8
|
-
var _native = require("./native.js");
|
|
9
|
-
let didAttemptAutomaticAnalytics = false;
|
|
10
|
-
const waitForNextFrame = () => new Promise(resolve => {
|
|
11
|
-
const requestAnimationFrame = globalThis?.requestAnimationFrame;
|
|
12
|
-
if (requestAnimationFrame) {
|
|
13
|
-
requestAnimationFrame(() => resolve());
|
|
14
|
-
return;
|
|
15
|
-
}
|
|
16
|
-
void Promise.resolve().then(resolve);
|
|
17
|
-
});
|
|
18
|
-
const assertNever = value => {
|
|
19
|
-
throw new Error(`[HotUpdater] Unexpected notifyAppReady status: ${value}`);
|
|
20
|
-
};
|
|
21
|
-
const buildNotifyAppReadyAnalyticsParams = (nativeResult, analyticsEvent, options) => {
|
|
22
|
-
const appVersion = (0, _native.getAppVersion)();
|
|
23
|
-
if (!appVersion) {
|
|
24
|
-
throw new Error("[HotUpdater] Automatic analytics requires a non-null native app version.");
|
|
25
|
-
}
|
|
26
|
-
const {
|
|
27
|
-
userId,
|
|
28
|
-
username
|
|
29
|
-
} = (0, _native.getPersistedUserIdentity)();
|
|
30
|
-
const installId = (0, _native.getInstallId)();
|
|
31
|
-
if (!installId) {
|
|
32
|
-
throw new Error("[HotUpdater] Automatic analytics requires a non-null native install id.");
|
|
33
|
-
}
|
|
34
|
-
const platform = _reactNative.Platform.OS === "android" ? "android" : "ios";
|
|
35
|
-
const commonParams = {
|
|
36
|
-
appVersion,
|
|
37
|
-
channel: (0, _native.getChannel)(),
|
|
38
|
-
cohort: (0, _native.getCohort)(),
|
|
39
|
-
fingerprintHash: (0, _native.getFingerprintHash)(),
|
|
40
|
-
fromReleaseId: analyticsEvent?.fromReleaseId ?? null,
|
|
41
|
-
installId,
|
|
42
|
-
platform,
|
|
43
|
-
requestHeaders: options.requestHeaders,
|
|
44
|
-
requestTimeout: options.requestTimeout,
|
|
45
|
-
toReleaseId: analyticsEvent?.toReleaseId ?? null,
|
|
46
|
-
...(userId != null ? {
|
|
47
|
-
userId
|
|
48
|
-
} : {}),
|
|
49
|
-
...(username != null ? {
|
|
50
|
-
username
|
|
51
|
-
} : {})
|
|
52
|
-
};
|
|
53
|
-
switch (nativeResult.status) {
|
|
54
|
-
case "UNCHANGED":
|
|
55
|
-
{
|
|
56
|
-
const bundleId = (0, _native.getBundleId)();
|
|
57
|
-
if (!bundleId) {
|
|
58
|
-
throw new Error("[HotUpdater] Automatic analytics requires a non-null current bundle id.");
|
|
59
|
-
}
|
|
60
|
-
return {
|
|
61
|
-
...commonParams,
|
|
62
|
-
fromBundleId: null,
|
|
63
|
-
toBundleId: bundleId,
|
|
64
|
-
type: "UNCHANGED",
|
|
65
|
-
updateStrategy: null
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
case "UPDATE_APPLIED":
|
|
69
|
-
case "RECOVERED":
|
|
70
|
-
if (!analyticsEvent) {
|
|
71
|
-
throw new Error("[HotUpdater] Native launch report is missing persisted metadata required for automatic analytics.");
|
|
72
|
-
}
|
|
73
|
-
switch (analyticsEvent.type) {
|
|
74
|
-
case "UPDATE_APPLIED":
|
|
75
|
-
return {
|
|
76
|
-
...commonParams,
|
|
77
|
-
fromBundleId: analyticsEvent.fromBundleId,
|
|
78
|
-
toBundleId: analyticsEvent.toBundleId,
|
|
79
|
-
type: "UPDATE_APPLIED",
|
|
80
|
-
updateStrategy: analyticsEvent.updateStrategy
|
|
81
|
-
};
|
|
82
|
-
case "RECOVERED":
|
|
83
|
-
return {
|
|
84
|
-
...commonParams,
|
|
85
|
-
fromBundleId: analyticsEvent.fromBundleId,
|
|
86
|
-
toBundleId: analyticsEvent.toBundleId,
|
|
87
|
-
type: "RECOVERED",
|
|
88
|
-
updateStrategy: analyticsEvent.updateStrategy
|
|
89
|
-
};
|
|
90
|
-
default:
|
|
91
|
-
return assertNever(analyticsEvent.type);
|
|
92
|
-
}
|
|
93
|
-
default:
|
|
94
|
-
return assertNever(nativeResult);
|
|
95
|
-
}
|
|
96
|
-
};
|
|
97
|
-
const maybeSendAutomaticAnalytics = async (options, nativeResult, analyticsEvent) => {
|
|
98
|
-
if (!options.analytics || didAttemptAutomaticAnalytics) {
|
|
99
|
-
return;
|
|
100
|
-
}
|
|
101
|
-
didAttemptAutomaticAnalytics = true;
|
|
102
|
-
if (nativeResult.status !== "UNCHANGED" && !analyticsEvent) {
|
|
103
|
-
throw new Error("[HotUpdater] Native launch report is missing persisted metadata required for automatic analytics.");
|
|
104
|
-
}
|
|
105
|
-
const session = await options.client.createSession();
|
|
106
|
-
await session.sendAnalyticsEvent(buildNotifyAppReadyAnalyticsParams(nativeResult, analyticsEvent, options));
|
|
107
|
-
};
|
|
108
|
-
const handleNotifyAppReady = async options => {
|
|
109
|
-
try {
|
|
110
|
-
let nativeReadResult;
|
|
111
|
-
do {
|
|
112
|
-
await waitForNextFrame();
|
|
113
|
-
nativeReadResult = (0, _native.readNotifyAppReady)();
|
|
114
|
-
} while (nativeReadResult.pending);
|
|
115
|
-
const {
|
|
116
|
-
analyticsEvent,
|
|
117
|
-
result: nativeResult
|
|
118
|
-
} = nativeReadResult;
|
|
119
|
-
try {
|
|
120
|
-
await maybeSendAutomaticAnalytics(options, nativeResult, analyticsEvent);
|
|
121
|
-
} catch (error) {
|
|
122
|
-
const warning = error instanceof Error ? error : new Error(String(error));
|
|
123
|
-
console.warn("[HotUpdater] Automatic notifyAppReady analytics failed:", warning);
|
|
124
|
-
}
|
|
125
|
-
options.onNotifyAppReady?.(nativeResult);
|
|
126
|
-
} catch (error) {
|
|
127
|
-
const normalizedError = error instanceof Error ? error : new Error(String(error));
|
|
128
|
-
options.onError?.(error);
|
|
129
|
-
console.warn("[HotUpdater] Failed to notify app ready:", normalizedError);
|
|
130
|
-
}
|
|
131
|
-
};
|
|
132
|
-
exports.handleNotifyAppReady = handleNotifyAppReady;
|
|
133
|
-
//# sourceMappingURL=notifyAppReadyAnalytics.js.map
|