@bravemobile/react-native-code-push 12.2.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
|
@@ -96,10 +96,9 @@ function getHermesCommand() {
|
|
|
96
96
|
return false;
|
|
97
97
|
}
|
|
98
98
|
};
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
return bundledHermesEngine;
|
|
99
|
+
const hermescExecutable = path.join(getHermesCompilerPath(), getHermesOSBin(), getHermesOSExe());
|
|
100
|
+
if (fileExists(hermescExecutable)) {
|
|
101
|
+
return hermescExecutable;
|
|
103
102
|
}
|
|
104
103
|
throw new Error('Hermes engine binary not found. Please upgrade to react-native 0.69 or later');
|
|
105
104
|
}
|
|
@@ -144,6 +143,28 @@ function getReactNativePackagePath() {
|
|
|
144
143
|
}
|
|
145
144
|
return path.join('node_modules', 'react-native');
|
|
146
145
|
}
|
|
146
|
+
function getHermescDirPathInHermesCompilerPackage() {
|
|
147
|
+
const result = childProcess.spawnSync('node', [
|
|
148
|
+
'--print',
|
|
149
|
+
"require.resolve('hermes-compiler/package.json')",
|
|
150
|
+
]);
|
|
151
|
+
const packagePath = path.dirname(result.stdout.toString());
|
|
152
|
+
const hermescDirPath = path.join(packagePath, 'hermesc');
|
|
153
|
+
if (result.status === 0 && directoryExistsSync(hermescDirPath)) {
|
|
154
|
+
return hermescDirPath;
|
|
155
|
+
}
|
|
156
|
+
return null;
|
|
157
|
+
}
|
|
158
|
+
function getHermesCompilerPath() {
|
|
159
|
+
const hermescDirPath = getHermescDirPathInHermesCompilerPackage();
|
|
160
|
+
if (hermescDirPath) {
|
|
161
|
+
// Since react-native 0.83, Hermes compiler executables are in 'hermes-compiler' package
|
|
162
|
+
return hermescDirPath;
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
return path.join(getReactNativePackagePath(), 'sdks', 'hermesc');
|
|
166
|
+
}
|
|
167
|
+
}
|
|
147
168
|
function directoryExistsSync(dirname) {
|
|
148
169
|
try {
|
|
149
170
|
return fs.statSync(dirname).isDirectory();
|
|
@@ -114,16 +114,10 @@ function getHermesCommand(): string {
|
|
|
114
114
|
return false;
|
|
115
115
|
}
|
|
116
116
|
};
|
|
117
|
-
|
|
118
|
-
const
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
'hermesc',
|
|
122
|
-
getHermesOSBin(),
|
|
123
|
-
getHermesOSExe(),
|
|
124
|
-
);
|
|
125
|
-
if (fileExists(bundledHermesEngine)) {
|
|
126
|
-
return bundledHermesEngine;
|
|
117
|
+
|
|
118
|
+
const hermescExecutable = path.join(getHermesCompilerPath(), getHermesOSBin(), getHermesOSExe());
|
|
119
|
+
if (fileExists(hermescExecutable)) {
|
|
120
|
+
return hermescExecutable;
|
|
127
121
|
}
|
|
128
122
|
throw new Error('Hermes engine binary not found. Please upgrade to react-native 0.69 or later');
|
|
129
123
|
}
|
|
@@ -174,6 +168,29 @@ function getReactNativePackagePath(): string {
|
|
|
174
168
|
return path.join('node_modules', 'react-native');
|
|
175
169
|
}
|
|
176
170
|
|
|
171
|
+
function getHermescDirPathInHermesCompilerPackage() {
|
|
172
|
+
const result = childProcess.spawnSync('node', [
|
|
173
|
+
'--print',
|
|
174
|
+
"require.resolve('hermes-compiler/package.json')",
|
|
175
|
+
]);
|
|
176
|
+
const packagePath = path.dirname(result.stdout.toString());
|
|
177
|
+
const hermescDirPath = path.join(packagePath, 'hermesc');
|
|
178
|
+
if (result.status === 0 && directoryExistsSync(hermescDirPath)) {
|
|
179
|
+
return hermescDirPath;
|
|
180
|
+
}
|
|
181
|
+
return null;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
function getHermesCompilerPath() {
|
|
185
|
+
const hermescDirPath = getHermescDirPathInHermesCompilerPackage();
|
|
186
|
+
if (hermescDirPath) {
|
|
187
|
+
// Since react-native 0.83, Hermes compiler executables are in 'hermes-compiler' package
|
|
188
|
+
return hermescDirPath
|
|
189
|
+
} else {
|
|
190
|
+
return path.join(getReactNativePackagePath(), 'sdks', 'hermesc');
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
|
|
177
194
|
function directoryExistsSync(dirname: string): boolean {
|
|
178
195
|
try {
|
|
179
196
|
return fs.statSync(dirname).isDirectory();
|
package/ios/CodePush/CodePush.m
CHANGED
|
@@ -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
|
|
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
|
|
1139
|
+
[self dispatchThrottledDownloadProgressEventWithForce:YES];
|
|
1119
1140
|
_didUpdateProgress = NO;
|
|
1120
1141
|
}
|
|
1121
1142
|
|