pulse-updates 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.
@@ -99,6 +99,13 @@ class PulseController private constructor() {
99
99
  private var embeddedManifest: EmbeddedManifest? = null
100
100
  private val executor = Executors.newSingleThreadExecutor()
101
101
 
102
+ // Embedded asset hashes set for download optimization
103
+ internal val embeddedAssetHashes: Set<String>
104
+ get() = embeddedManifest?.assets
105
+ ?.filter { !it.isLaunchAsset }
106
+ ?.map { it.hash.lowercase() }
107
+ ?.toSet() ?: emptySet()
108
+
102
109
  // Native runtime version (from config, embedded manifest, or app version)
103
110
  private val nativeRuntimeVersion: String
104
111
  get() {
@@ -1251,12 +1258,23 @@ object PulseRemoteLoader {
1251
1258
  }
1252
1259
 
1253
1260
  // Download assets and link them to the update
1261
+ val embeddedHashes = PulseController.getInstance().embeddedAssetHashes
1262
+
1254
1263
  for (asset in manifest.assets) {
1255
1264
  val assetHash = asset.hash.lowercase()
1256
1265
  val assetDest = File(directory, "assets/sha256/$assetHash")
1257
1266
 
1258
- // Download if not exists
1259
- if (!assetDest.exists()) {
1267
+ // Skip download if already cached
1268
+ if (assetDest.exists()) {
1269
+ // Asset already in cache, just link it
1270
+ }
1271
+ // Skip download if exists in embedded assets
1272
+ else if (embeddedHashes.contains(assetHash)) {
1273
+ pulseLog(TAG, "Asset ${assetHash.take(16)}... exists in embedded, skipping download")
1274
+ // Don't download - will use embedded fallback at runtime
1275
+ }
1276
+ // Download if not exists anywhere
1277
+ else {
1260
1278
  try {
1261
1279
  downloadFile(asset.url, assetDest, stagingDir)
1262
1280
 
@@ -62,7 +62,8 @@ public final class PulseController {
62
62
 
63
63
  // Embedded manifest cache
64
64
  private var embeddedManifest: PulseEmbeddedManifest?
65
- private var embeddedAssetHashes: [String: URL] = [:]
65
+ /// Embedded asset hashes map (hash -> file URL) - internal for download optimization
66
+ internal var embeddedAssetHashes: [String: URL] = [:]
66
67
  private var embeddedBundleHash: String?
67
68
 
68
69
  // MARK: - Native Config (from Info.plist, like expo-updates)
@@ -1134,6 +1135,14 @@ final class PulseRemoteLoader {
1134
1135
  continue
1135
1136
  }
1136
1137
 
1138
+ // Already exists in embedded assets? Skip download and use embedded
1139
+ if PulseController.shared.embeddedAssetHashes[assetHash] != nil {
1140
+ pulseLog("Asset \(assetHash.prefix(16))... exists in embedded, skipping download")
1141
+ storeAssetInDatabase(asset: asset, hash: assetHash, database: database, updateId: updateId)
1142
+ group.leave()
1143
+ continue
1144
+ }
1145
+
1137
1146
  guard let url = URL(string: asset.url) else {
1138
1147
  group.leave()
1139
1148
  continue
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pulse-updates",
3
- "version": "1.0.3",
3
+ "version": "1.0.4",
4
4
  "description": "OTA updates for React Native - lightweight alternative to expo-updates",
5
5
  "main": "lib/commonjs/index.js",
6
6
  "module": "lib/module/index.js",