@bravemobile/react-native-code-push 12.3.0 → 12.3.1

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/README.md CHANGED
@@ -8,7 +8,7 @@
8
8
 
9
9
  ### 🚀 New Architecture support
10
10
 
11
- Supports React Native 0.74 ~ 0.82.
11
+ Supports React Native 0.74 ~ 0.83.
12
12
 
13
13
  > [!NOTE]
14
14
  > If you are using React Native 0.76 or lower, please use version `12.0.2` of this library.
@@ -32,6 +32,7 @@
32
32
  long long _latestExpectedContentLength;
33
33
  long long _latestReceivedConentLength;
34
34
  BOOL _didUpdateProgress;
35
+ NSTimeInterval _lastProgressEventTime;
35
36
 
36
37
  BOOL _allowed;
37
38
  BOOL _restartInProgress;
@@ -336,6 +337,18 @@ static NSString *const LatestRollbackCountKey = @"count";
336
337
  }];
337
338
  }
338
339
 
340
+ - (void)dispatchThrottledDownloadProgressEventWithForce:(BOOL)force
341
+ {
342
+ static const NSTimeInterval interval = 0.05; // 50 ms throttle
343
+ NSTimeInterval now = CFAbsoluteTimeGetCurrent();
344
+ if (!force && _lastProgressEventTime > 0 && (now - _lastProgressEventTime) < interval) {
345
+ return;
346
+ }
347
+
348
+ _lastProgressEventTime = now;
349
+ [self dispatchDownloadProgressEvent];
350
+ }
351
+
339
352
  /*
340
353
  * This method ensures that the app was packaged with a JS bundle
341
354
  * file, and if not, it throws the appropriate exception.
@@ -377,6 +390,7 @@ static NSString *const LatestRollbackCountKey = @"count";
377
390
  _allowed = YES;
378
391
  _restartInProgress = NO;
379
392
  _restartQueue = [NSMutableArray arrayWithCapacity:1];
393
+ _lastProgressEventTime = 0;
380
394
 
381
395
  self = [super init];
382
396
  if (self) {
@@ -723,6 +737,7 @@ RCT_EXPORT_METHOD(downloadUpdate:(NSDictionary*)updatePackage
723
737
  // progress events every frame if the progress is updated.
724
738
  _didUpdateProgress = NO;
725
739
  self.paused = NO;
740
+ _lastProgressEventTime = 0;
726
741
  }
727
742
 
728
743
  NSString * publicKey = [[CodePushConfig current] publicKey];
@@ -738,13 +753,19 @@ RCT_EXPORT_METHOD(downloadUpdate:(NSDictionary*)updatePackage
738
753
  _latestExpectedContentLength = expectedContentLength;
739
754
  _latestReceivedConentLength = receivedContentLength;
740
755
  _didUpdateProgress = YES;
756
+ // Fabric/TurboModules don't hook RCTFrameUpdateObserver, so _pauseCallback
757
+ // stays nil there and we must emit progress events directly.
758
+ // On the legacy bridge _pauseCallback is set, and didUpdateFrame handles dispatch.
759
+ if (!_pauseCallback) {
760
+ [self dispatchThrottledDownloadProgressEventWithForce:NO];
761
+ }
741
762
 
742
763
  // If the download is completed, stop observing frame
743
764
  // updates and synchronously send the last event.
744
765
  if (expectedContentLength == receivedContentLength) {
745
766
  _didUpdateProgress = NO;
746
767
  self.paused = YES;
747
- [self dispatchDownloadProgressEvent];
768
+ [self dispatchThrottledDownloadProgressEventWithForce:YES];
748
769
  }
749
770
  }
750
771
  // The download completed
@@ -1115,7 +1136,7 @@ RCT_EXPORT_METHOD(saveStatusReportForRetry:(NSDictionary *)statusReport)
1115
1136
  return;
1116
1137
  }
1117
1138
 
1118
- [self dispatchDownloadProgressEvent];
1139
+ [self dispatchThrottledDownloadProgressEventWithForce:YES];
1119
1140
  _didUpdateProgress = NO;
1120
1141
  }
1121
1142
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bravemobile/react-native-code-push",
3
- "version": "12.3.0",
3
+ "version": "12.3.1",
4
4
  "description": "React Native plugin for the CodePush service",
5
5
  "main": "src/CodePush.js",
6
6
  "react-native": "src/CodePush.js",