@bravemobile/react-native-code-push 12.4.1 → 13.0.0
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/CodePush.podspec +14 -1
- package/README.md +3 -0
- package/android/app/build.gradle +7 -0
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePush.java +45 -10
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePushNativeModule.java +67 -86
- package/cli/dist/functions/runHermesEmitBinaryCommand.js +50 -26
- package/cli/functions/runHermesEmitBinaryCommand.ts +55 -25
- package/ios/CodePush/CodePush.h +40 -8
- package/ios/CodePush/{CodePush.m → CodePush.mm} +61 -62
- package/ios/CodePush.xcodeproj/project.pbxproj +6 -6
- package/package.json +19 -2
- package/react-native.config.js +3 -1
- package/src/CodePush.js +144 -93
- package/src/native/NativeCodePush.ts +162 -0
- package/src/package-mixins.js +4 -9
- package/src/specs/NativeCodePush.ts +43 -0
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePushDialog.java +0 -102
- package/src/AlertAdapter.js +0 -24
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
import childProcess from "child_process";
|
|
6
6
|
import fs from "fs";
|
|
7
7
|
import path from "path";
|
|
8
|
+
import { createRequire } from "node:module";
|
|
8
9
|
import shell from "shelljs";
|
|
9
10
|
|
|
10
11
|
/**
|
|
@@ -14,6 +15,7 @@ import shell from "shelljs";
|
|
|
14
15
|
* @param outputPath {string} Path to output .hbc file
|
|
15
16
|
* @param sourcemapOutput {string} Path to output sourcemap file (Warning: if sourcemapOutput points to the outputPath, the sourcemap will be included in the CodePush bundle and increase the deployment size)
|
|
16
17
|
* @param extraHermesFlags {string[]} Additional options to pass to `hermesc` command
|
|
18
|
+
* @param projectRoot {string} Root directory of the target app project used to resolve the app's React Native module and locate the matching Hermes compiler. Defaults to the current working directory.
|
|
17
19
|
* @return {Promise<void>}
|
|
18
20
|
*/
|
|
19
21
|
export async function runHermesEmitBinaryCommand(
|
|
@@ -21,6 +23,7 @@ export async function runHermesEmitBinaryCommand(
|
|
|
21
23
|
outputPath: string,
|
|
22
24
|
sourcemapOutput: string,
|
|
23
25
|
extraHermesFlags: string[] = [],
|
|
26
|
+
projectRoot: string = process.cwd(),
|
|
24
27
|
): Promise<void> {
|
|
25
28
|
const hermesArgs: string[] = [
|
|
26
29
|
'-emit-binary',
|
|
@@ -37,7 +40,7 @@ export async function runHermesEmitBinaryCommand(
|
|
|
37
40
|
|
|
38
41
|
return new Promise<void>((resolve, reject) => {
|
|
39
42
|
try {
|
|
40
|
-
const hermesCommand = getHermesCommand();
|
|
43
|
+
const hermesCommand = getHermesCommand(projectRoot);
|
|
41
44
|
|
|
42
45
|
const disableAllWarningsArg = '-w';
|
|
43
46
|
shell.exec(`${hermesCommand} ${hermesArgs.join(' ')} ${disableAllWarningsArg}`);
|
|
@@ -58,7 +61,7 @@ export async function runHermesEmitBinaryCommand(
|
|
|
58
61
|
}
|
|
59
62
|
|
|
60
63
|
// compose-source-maps.js file path
|
|
61
|
-
const composeSourceMapsPath = getComposeSourceMapsPath();
|
|
64
|
+
const composeSourceMapsPath = getComposeSourceMapsPath(projectRoot);
|
|
62
65
|
if (composeSourceMapsPath === null) {
|
|
63
66
|
throw new Error('react-native compose-source-maps.js scripts is not found');
|
|
64
67
|
}
|
|
@@ -106,7 +109,7 @@ export async function runHermesEmitBinaryCommand(
|
|
|
106
109
|
});
|
|
107
110
|
}
|
|
108
111
|
|
|
109
|
-
function getHermesCommand(): string {
|
|
112
|
+
function getHermesCommand(projectRoot: string): string {
|
|
110
113
|
const fileExists = (file: string): boolean => {
|
|
111
114
|
try {
|
|
112
115
|
return fs.statSync(file).isFile();
|
|
@@ -115,7 +118,7 @@ function getHermesCommand(): string {
|
|
|
115
118
|
}
|
|
116
119
|
};
|
|
117
120
|
|
|
118
|
-
const hermescExecutable = path.join(getHermesCompilerPath(), getHermesOSBin(), getHermesOSExe());
|
|
121
|
+
const hermescExecutable = path.join(getHermesCompilerPath(projectRoot), getHermesOSBin(), getHermesOSExe());
|
|
119
122
|
if (fileExists(hermescExecutable)) {
|
|
120
123
|
return hermescExecutable;
|
|
121
124
|
}
|
|
@@ -146,48 +149,75 @@ function getHermesOSExe(): string {
|
|
|
146
149
|
}
|
|
147
150
|
}
|
|
148
151
|
|
|
149
|
-
function getComposeSourceMapsPath(): string | null {
|
|
152
|
+
function getComposeSourceMapsPath(projectRoot: string): string | null {
|
|
150
153
|
// detect if compose-source-maps.js script exists
|
|
151
|
-
const composeSourceMaps = path.join(getReactNativePackagePath(), 'scripts', 'compose-source-maps.js');
|
|
154
|
+
const composeSourceMaps = path.join(getReactNativePackagePath(projectRoot), 'scripts', 'compose-source-maps.js');
|
|
152
155
|
if (fs.existsSync(composeSourceMaps)) {
|
|
153
156
|
return composeSourceMaps;
|
|
154
157
|
}
|
|
155
158
|
return null;
|
|
156
159
|
}
|
|
157
160
|
|
|
158
|
-
function getReactNativePackagePath(): string {
|
|
159
|
-
const
|
|
160
|
-
|
|
161
|
-
"require.resolve('react-native/package.json')",
|
|
162
|
-
]);
|
|
163
|
-
const packagePath = path.dirname(result.stdout.toString());
|
|
164
|
-
if (result.status === 0 && directoryExistsSync(packagePath)) {
|
|
161
|
+
function getReactNativePackagePath(projectRoot: string): string {
|
|
162
|
+
const packagePath = resolvePackageRoot(projectRoot, 'react-native');
|
|
163
|
+
if (packagePath !== null) {
|
|
165
164
|
return packagePath;
|
|
166
165
|
}
|
|
167
166
|
|
|
168
|
-
return path.join('node_modules', 'react-native');
|
|
167
|
+
return path.join(projectRoot, 'node_modules', 'react-native');
|
|
169
168
|
}
|
|
170
169
|
|
|
171
|
-
function getHermescDirPathInHermesCompilerPackage() {
|
|
172
|
-
const
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
const packagePath = path.dirname(result.stdout.toString());
|
|
177
|
-
const hermescDirPath = path.join(packagePath, 'hermesc');
|
|
178
|
-
if (result.status === 0 && directoryExistsSync(hermescDirPath)) {
|
|
170
|
+
function getHermescDirPathInHermesCompilerPackage(projectRoot: string) {
|
|
171
|
+
const reactNativePackagePath = getReactNativePackagePath(projectRoot);
|
|
172
|
+
const hermescDirPath = path.join(path.dirname(reactNativePackagePath), 'hermes-compiler', 'hermesc');
|
|
173
|
+
|
|
174
|
+
if (directoryExistsSync(hermescDirPath)) {
|
|
179
175
|
return hermescDirPath;
|
|
180
176
|
}
|
|
177
|
+
|
|
181
178
|
return null;
|
|
182
179
|
}
|
|
183
180
|
|
|
184
|
-
function getHermesCompilerPath() {
|
|
185
|
-
const hermescDirPath = getHermescDirPathInHermesCompilerPackage();
|
|
181
|
+
function getHermesCompilerPath(projectRoot: string) {
|
|
182
|
+
const hermescDirPath = getHermescDirPathInHermesCompilerPackage(projectRoot);
|
|
186
183
|
if (hermescDirPath) {
|
|
187
184
|
// Since react-native 0.83, Hermes compiler executables are in 'hermes-compiler' package
|
|
188
185
|
return hermescDirPath
|
|
189
186
|
} else {
|
|
190
|
-
return path.join(getReactNativePackagePath(), 'sdks', 'hermesc');
|
|
187
|
+
return path.join(getReactNativePackagePath(projectRoot), 'sdks', 'hermesc');
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
function resolvePackageRoot(projectRoot: string, packageName: string): string | null {
|
|
192
|
+
try {
|
|
193
|
+
const projectRequire = createRequire(path.join(projectRoot, 'package.json'));
|
|
194
|
+
const resolvedPath = projectRequire.resolve(packageName);
|
|
195
|
+
return findPackageRoot(packageName, resolvedPath);
|
|
196
|
+
} catch {
|
|
197
|
+
return null;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
function findPackageRoot(packageName: string, resolvedPath: string): string | null {
|
|
202
|
+
let currentPath = path.dirname(resolvedPath);
|
|
203
|
+
|
|
204
|
+
while (true) {
|
|
205
|
+
const packageJsonPath = path.join(currentPath, 'package.json');
|
|
206
|
+
|
|
207
|
+
try {
|
|
208
|
+
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8')) as { name?: string };
|
|
209
|
+
if (packageJson.name === packageName) {
|
|
210
|
+
return currentPath;
|
|
211
|
+
}
|
|
212
|
+
} catch {
|
|
213
|
+
// Continue traversing upward until the package root is found.
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
const parentPath = path.dirname(currentPath);
|
|
217
|
+
if (parentPath === currentPath) {
|
|
218
|
+
return null;
|
|
219
|
+
}
|
|
220
|
+
currentPath = parentPath;
|
|
191
221
|
}
|
|
192
222
|
}
|
|
193
223
|
|
package/ios/CodePush/CodePush.h
CHANGED
|
@@ -1,14 +1,40 @@
|
|
|
1
|
-
#
|
|
2
|
-
|
|
3
|
-
#
|
|
4
|
-
#
|
|
1
|
+
#import <Foundation/Foundation.h>
|
|
2
|
+
|
|
3
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
4
|
+
#if defined(__cplusplus)
|
|
5
|
+
#if __has_include(<RNCodePushSpec/RNCodePushSpec.h>)
|
|
6
|
+
#import <RNCodePushSpec/RNCodePushSpec.h>
|
|
7
|
+
#elif __has_include("RNCodePushSpec.h")
|
|
8
|
+
#import "RNCodePushSpec.h"
|
|
9
|
+
#endif
|
|
10
|
+
#else
|
|
11
|
+
#if __has_include(<React/RCTBridgeModule.h>)
|
|
12
|
+
#import <React/RCTBridgeModule.h>
|
|
13
|
+
#elif __has_include("RCTBridgeModule.h")
|
|
14
|
+
#import "RCTBridgeModule.h"
|
|
15
|
+
#else
|
|
16
|
+
#import "React/RCTBridgeModule.h"
|
|
17
|
+
#endif
|
|
18
|
+
#endif
|
|
5
19
|
#else
|
|
6
|
-
#
|
|
20
|
+
#if __has_include(<React/RCTEventEmitter.h>)
|
|
21
|
+
#import <React/RCTEventEmitter.h>
|
|
22
|
+
#elif __has_include("RCTEventEmitter.h")
|
|
23
|
+
#import "RCTEventEmitter.h"
|
|
24
|
+
#else
|
|
25
|
+
#import "React/RCTEventEmitter.h" // Required when used as a Pod in a Swift project
|
|
26
|
+
#endif
|
|
7
27
|
#endif
|
|
8
28
|
|
|
9
|
-
#
|
|
10
|
-
|
|
29
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
30
|
+
#if defined(__cplusplus)
|
|
31
|
+
@interface CodePush : NativeCodePushSpecBase
|
|
32
|
+
#else
|
|
33
|
+
@interface CodePush : NSObject <RCTBridgeModule>
|
|
34
|
+
#endif
|
|
35
|
+
#else
|
|
11
36
|
@interface CodePush : RCTEventEmitter
|
|
37
|
+
#endif
|
|
12
38
|
|
|
13
39
|
+ (NSURL *)binaryBundleURL;
|
|
14
40
|
/*
|
|
@@ -68,7 +94,7 @@
|
|
|
68
94
|
* This information will be used to decide whether the application
|
|
69
95
|
* should ignore the update or not.
|
|
70
96
|
*/
|
|
71
|
-
+ (NSDictionary*)
|
|
97
|
+
+ (NSDictionary*)getLatestRollbackInfo;
|
|
72
98
|
/*
|
|
73
99
|
* This method is used to save information about the latest rollback.
|
|
74
100
|
* This information will be used to decide whether the application
|
|
@@ -203,7 +229,13 @@ failCallback:(void (^)(NSError *err))failCallback;
|
|
|
203
229
|
|
|
204
230
|
@end
|
|
205
231
|
|
|
232
|
+
#if defined(__cplusplus)
|
|
233
|
+
extern "C" {
|
|
234
|
+
#endif
|
|
206
235
|
void CPLog(NSString *formatString, ...);
|
|
236
|
+
#if defined(__cplusplus)
|
|
237
|
+
}
|
|
238
|
+
#endif
|
|
207
239
|
|
|
208
240
|
typedef NS_ENUM(NSInteger, CodePushInstallMode) {
|
|
209
241
|
CodePushInstallModeImmediate,
|
|
@@ -8,7 +8,11 @@
|
|
|
8
8
|
|
|
9
9
|
#import "CodePush.h"
|
|
10
10
|
|
|
11
|
-
@interface CodePush () <
|
|
11
|
+
@interface CodePush () <RCTFrameUpdateObserver
|
|
12
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
13
|
+
, NativeCodePushSpec
|
|
14
|
+
#endif
|
|
15
|
+
>
|
|
12
16
|
@end
|
|
13
17
|
|
|
14
18
|
@implementation CodePush {
|
|
@@ -62,6 +66,7 @@ static NSString *const PackageIsPendingKey = @"isPending";
|
|
|
62
66
|
static BOOL isRunningBinaryVersion = NO;
|
|
63
67
|
static BOOL needToReportRollback = NO;
|
|
64
68
|
static BOOL testConfigurationFlag = NO;
|
|
69
|
+
static BOOL hasInitializedUpdateAfterRestartForCurrentLoad = NO;
|
|
65
70
|
|
|
66
71
|
// These values are used to save the NS bundle, name, extension and subdirectory
|
|
67
72
|
// for the JS bundle in the binary.
|
|
@@ -246,6 +251,9 @@ static NSString *const LatestRollbackCountKey = @"count";
|
|
|
246
251
|
|
|
247
252
|
#pragma mark - Private API methods
|
|
248
253
|
|
|
254
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
255
|
+
@synthesize bridge = _bridge;
|
|
256
|
+
#endif
|
|
249
257
|
@synthesize methodQueue = _methodQueue;
|
|
250
258
|
@synthesize pauseCallback = _pauseCallback;
|
|
251
259
|
@synthesize paused = _paused;
|
|
@@ -269,7 +277,7 @@ static NSString *const LatestRollbackCountKey = @"count";
|
|
|
269
277
|
- (void)clearDebugUpdates
|
|
270
278
|
{
|
|
271
279
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
272
|
-
if ([
|
|
280
|
+
if ([self.bridge.bundleURL.scheme hasPrefix:@"http"]) {
|
|
273
281
|
NSError *error;
|
|
274
282
|
NSString *binaryAppVersion = [[CodePushConfig current] appVersion];
|
|
275
283
|
NSDictionary *currentPackageMetadata = [CodePushPackage getCurrentPackage:&error];
|
|
@@ -283,28 +291,6 @@ static NSString *const LatestRollbackCountKey = @"count";
|
|
|
283
291
|
});
|
|
284
292
|
}
|
|
285
293
|
|
|
286
|
-
/*
|
|
287
|
-
* This method is used by the React Native bridge to allow
|
|
288
|
-
* our plugin to expose constants to the JS-side. In our case
|
|
289
|
-
* we're simply exporting enum values so that the JS and Native
|
|
290
|
-
* sides of the plugin can be in sync.
|
|
291
|
-
*/
|
|
292
|
-
- (NSDictionary *)constantsToExport
|
|
293
|
-
{
|
|
294
|
-
// Export the values of the CodePushInstallMode and CodePushUpdateState
|
|
295
|
-
// enums so that the script-side can easily stay in sync
|
|
296
|
-
return @{
|
|
297
|
-
@"codePushInstallModeOnNextRestart":@(CodePushInstallModeOnNextRestart),
|
|
298
|
-
@"codePushInstallModeImmediate": @(CodePushInstallModeImmediate),
|
|
299
|
-
@"codePushInstallModeOnNextResume": @(CodePushInstallModeOnNextResume),
|
|
300
|
-
@"codePushInstallModeOnNextSuspend": @(CodePushInstallModeOnNextSuspend),
|
|
301
|
-
|
|
302
|
-
@"codePushUpdateStateRunning": @(CodePushUpdateStateRunning),
|
|
303
|
-
@"codePushUpdateStatePending": @(CodePushUpdateStatePending),
|
|
304
|
-
@"codePushUpdateStateLatest": @(CodePushUpdateStateLatest)
|
|
305
|
-
};
|
|
306
|
-
};
|
|
307
|
-
|
|
308
294
|
+ (BOOL)requiresMainQueueSetup
|
|
309
295
|
{
|
|
310
296
|
return YES;
|
|
@@ -319,13 +305,16 @@ static NSString *const LatestRollbackCountKey = @"count";
|
|
|
319
305
|
|
|
320
306
|
- (void)dispatchDownloadProgressEvent {
|
|
321
307
|
// Notify the script-side about the progress
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
308
|
+
NSDictionary *progress = @{
|
|
309
|
+
@"totalBytes" : [NSNumber numberWithLongLong:_latestExpectedContentLength],
|
|
310
|
+
@"receivedBytes" : [NSNumber numberWithLongLong:_latestReceivedConentLength]
|
|
311
|
+
};
|
|
312
|
+
|
|
313
|
+
#ifndef RCT_NEW_ARCH_ENABLED
|
|
314
|
+
[self sendEventWithName:DownloadProgressEvent body:progress];
|
|
315
|
+
#else
|
|
316
|
+
[self emitOnDownloadProgress:progress];
|
|
317
|
+
#endif
|
|
329
318
|
}
|
|
330
319
|
|
|
331
320
|
- (void)dispatchThrottledDownloadProgressEventWithForce:(BOOL)force
|
|
@@ -385,7 +374,12 @@ static NSString *const LatestRollbackCountKey = @"count";
|
|
|
385
374
|
|
|
386
375
|
self = [super init];
|
|
387
376
|
if (self) {
|
|
388
|
-
[
|
|
377
|
+
@synchronized([CodePush class]) {
|
|
378
|
+
if (!hasInitializedUpdateAfterRestartForCurrentLoad) {
|
|
379
|
+
hasInitializedUpdateAfterRestartForCurrentLoad = YES;
|
|
380
|
+
[self initializeUpdateAfterRestart];
|
|
381
|
+
}
|
|
382
|
+
}
|
|
389
383
|
}
|
|
390
384
|
|
|
391
385
|
return self;
|
|
@@ -535,6 +529,10 @@ static NSString *const LatestRollbackCountKey = @"count";
|
|
|
535
529
|
*/
|
|
536
530
|
- (void)loadBundle
|
|
537
531
|
{
|
|
532
|
+
@synchronized([CodePush class]) {
|
|
533
|
+
hasInitializedUpdateAfterRestartForCurrentLoad = NO;
|
|
534
|
+
}
|
|
535
|
+
|
|
538
536
|
// This needs to be async dispatched because the bridge is not set on init
|
|
539
537
|
// when the app first starts, therefore rollbacks will not take effect.
|
|
540
538
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
@@ -542,8 +540,8 @@ static NSString *const LatestRollbackCountKey = @"count";
|
|
|
542
540
|
// is debugging and therefore, shouldn't be redirected to a local
|
|
543
541
|
// file (since Chrome wouldn't support it). Otherwise, update
|
|
544
542
|
// the current bundle URL to point at the latest update
|
|
545
|
-
if ([CodePush isUsingTestConfiguration] || ![
|
|
546
|
-
[
|
|
543
|
+
if ([CodePush isUsingTestConfiguration] || ![self.bridge.bundleURL.scheme hasPrefix:@"http"]) {
|
|
544
|
+
[self.bridge setValue:[CodePush bundleURL] forKey:@"bundleURL"];
|
|
547
545
|
}
|
|
548
546
|
|
|
549
547
|
RCTTriggerReloadCommandListeners(@"CodePush reload");
|
|
@@ -713,8 +711,8 @@ static NSString *const LatestRollbackCountKey = @"count";
|
|
|
713
711
|
*/
|
|
714
712
|
RCT_EXPORT_METHOD(downloadUpdate:(NSDictionary*)updatePackage
|
|
715
713
|
notifyProgress:(BOOL)notifyProgress
|
|
716
|
-
|
|
717
|
-
|
|
714
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
715
|
+
reject:(RCTPromiseRejectBlock)reject)
|
|
718
716
|
{
|
|
719
717
|
NSDictionary *mutableUpdatePackage = [updatePackage mutableCopy];
|
|
720
718
|
NSURL *binaryBundleURL = [CodePush binaryBundleURL];
|
|
@@ -813,7 +811,7 @@ RCT_EXPORT_METHOD(downloadUpdate:(NSDictionary*)updatePackage
|
|
|
813
811
|
* app version, as well as the deployment key that was configured in the Info.plist file.
|
|
814
812
|
*/
|
|
815
813
|
RCT_EXPORT_METHOD(getConfiguration:(RCTPromiseResolveBlock)resolve
|
|
816
|
-
|
|
814
|
+
reject:(RCTPromiseRejectBlock)reject)
|
|
817
815
|
{
|
|
818
816
|
NSDictionary *configuration = [[CodePushConfig current] configuration];
|
|
819
817
|
NSError *error;
|
|
@@ -846,10 +844,11 @@ RCT_EXPORT_METHOD(getConfiguration:(RCTPromiseResolveBlock)resolve
|
|
|
846
844
|
/*
|
|
847
845
|
* This method is the native side of the CodePush.getUpdateMetadata method.
|
|
848
846
|
*/
|
|
849
|
-
RCT_EXPORT_METHOD(getUpdateMetadata:(
|
|
850
|
-
|
|
851
|
-
|
|
847
|
+
RCT_EXPORT_METHOD(getUpdateMetadata:(double)updateStateValue
|
|
848
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
849
|
+
reject:(RCTPromiseRejectBlock)reject)
|
|
852
850
|
{
|
|
851
|
+
CodePushUpdateState updateState = (CodePushUpdateState)updateStateValue;
|
|
853
852
|
NSError *error;
|
|
854
853
|
NSMutableDictionary *package = [[CodePushPackage getCurrentPackage:&error] mutableCopy];
|
|
855
854
|
|
|
@@ -895,11 +894,13 @@ RCT_EXPORT_METHOD(getUpdateMetadata:(CodePushUpdateState)updateState
|
|
|
895
894
|
* This method is the native side of the LocalPackage.install method.
|
|
896
895
|
*/
|
|
897
896
|
RCT_EXPORT_METHOD(installUpdate:(NSDictionary*)updatePackage
|
|
898
|
-
installMode:(
|
|
899
|
-
minimumBackgroundDuration:(
|
|
900
|
-
|
|
901
|
-
|
|
897
|
+
installMode:(double)installModeValue
|
|
898
|
+
minimumBackgroundDuration:(double)minimumBackgroundDurationValue
|
|
899
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
900
|
+
reject:(RCTPromiseRejectBlock)reject)
|
|
902
901
|
{
|
|
902
|
+
CodePushInstallMode installMode = (CodePushInstallMode)installModeValue;
|
|
903
|
+
int minimumBackgroundDuration = (int)minimumBackgroundDurationValue;
|
|
903
904
|
NSError *error;
|
|
904
905
|
[CodePushPackage installPackage:updatePackage
|
|
905
906
|
removePendingUpdate:[[self class] isPendingUpdate:nil]
|
|
@@ -965,7 +966,7 @@ RCT_EXPORT_METHOD(setLatestRollbackInfo:(NSString *)packageHash
|
|
|
965
966
|
|
|
966
967
|
|
|
967
968
|
RCT_EXPORT_METHOD(getLatestRollbackInfo:(RCTPromiseResolveBlock)resolve
|
|
968
|
-
|
|
969
|
+
reject:(RCTPromiseRejectBlock)reject)
|
|
969
970
|
{
|
|
970
971
|
NSDictionary *latestRollbackInfo = [[self class] getLatestRollbackInfo];
|
|
971
972
|
resolve(latestRollbackInfo);
|
|
@@ -977,7 +978,7 @@ RCT_EXPORT_METHOD(getLatestRollbackInfo:(RCTPromiseResolveBlock)resolve
|
|
|
977
978
|
*/
|
|
978
979
|
RCT_EXPORT_METHOD(isFirstRun:(NSString *)packageHash
|
|
979
980
|
resolve:(RCTPromiseResolveBlock)resolve
|
|
980
|
-
|
|
981
|
+
reject:(RCTPromiseRejectBlock)reject)
|
|
981
982
|
{
|
|
982
983
|
NSError *error;
|
|
983
984
|
BOOL isFirstRun = _isFirstRunAfterUpdate
|
|
@@ -992,14 +993,13 @@ RCT_EXPORT_METHOD(isFirstRun:(NSString *)packageHash
|
|
|
992
993
|
* This method is the native side of the CodePush.notifyApplicationReady() method.
|
|
993
994
|
*/
|
|
994
995
|
RCT_EXPORT_METHOD(notifyApplicationReady:(RCTPromiseResolveBlock)resolve
|
|
995
|
-
|
|
996
|
+
reject:(RCTPromiseRejectBlock)reject)
|
|
996
997
|
{
|
|
997
998
|
[CodePush removePendingUpdate];
|
|
998
999
|
resolve(nil);
|
|
999
1000
|
}
|
|
1000
1001
|
|
|
1001
|
-
RCT_EXPORT_METHOD(allow
|
|
1002
|
-
rejecter:(RCTPromiseRejectBlock)reject)
|
|
1002
|
+
RCT_EXPORT_METHOD(allow)
|
|
1003
1003
|
{
|
|
1004
1004
|
CPLog(@"Re-allowing restarts.");
|
|
1005
1005
|
_allowed = YES;
|
|
@@ -1010,34 +1010,25 @@ RCT_EXPORT_METHOD(allow:(RCTPromiseResolveBlock)resolve
|
|
|
1010
1010
|
[_restartQueue removeObjectAtIndex:0];
|
|
1011
1011
|
[self restartAppInternal:buf];
|
|
1012
1012
|
}
|
|
1013
|
-
|
|
1014
|
-
resolve(nil);
|
|
1015
1013
|
}
|
|
1016
1014
|
|
|
1017
|
-
RCT_EXPORT_METHOD(clearPendingRestart
|
|
1018
|
-
rejecter:(RCTPromiseRejectBlock)reject)
|
|
1015
|
+
RCT_EXPORT_METHOD(clearPendingRestart)
|
|
1019
1016
|
{
|
|
1020
1017
|
[_restartQueue removeAllObjects];
|
|
1021
|
-
resolve(nil);
|
|
1022
1018
|
}
|
|
1023
1019
|
|
|
1024
|
-
RCT_EXPORT_METHOD(disallow
|
|
1025
|
-
rejecter:(RCTPromiseRejectBlock)reject)
|
|
1020
|
+
RCT_EXPORT_METHOD(disallow)
|
|
1026
1021
|
{
|
|
1027
1022
|
CPLog(@"Disallowing restarts.");
|
|
1028
1023
|
_allowed = NO;
|
|
1029
|
-
resolve(nil);
|
|
1030
1024
|
}
|
|
1031
1025
|
|
|
1032
1026
|
/*
|
|
1033
1027
|
* This method is the native side of the CodePush.restartApp() method.
|
|
1034
1028
|
*/
|
|
1035
|
-
RCT_EXPORT_METHOD(restartApp:(BOOL)onlyIfUpdateIsPending
|
|
1036
|
-
resolve:(RCTPromiseResolveBlock)resolve
|
|
1037
|
-
rejecter:(RCTPromiseRejectBlock)reject)
|
|
1029
|
+
RCT_EXPORT_METHOD(restartApp:(BOOL)onlyIfUpdateIsPending)
|
|
1038
1030
|
{
|
|
1039
1031
|
[self restartAppInternal:onlyIfUpdateIsPending];
|
|
1040
|
-
resolve(nil);
|
|
1041
1032
|
}
|
|
1042
1033
|
|
|
1043
1034
|
/*
|
|
@@ -1071,7 +1062,7 @@ RCT_EXPORT_METHOD(downloadAndReplaceCurrentBundle:(NSString *)remoteBundleUrl)
|
|
|
1071
1062
|
* or an update failed) and return its details (version label, status).
|
|
1072
1063
|
*/
|
|
1073
1064
|
RCT_EXPORT_METHOD(getNewStatusReport:(RCTPromiseResolveBlock)resolve
|
|
1074
|
-
|
|
1065
|
+
reject:(RCTPromiseRejectBlock)reject)
|
|
1075
1066
|
{
|
|
1076
1067
|
if (needToReportRollback) {
|
|
1077
1068
|
needToReportRollback = NO;
|
|
@@ -1128,4 +1119,12 @@ RCT_EXPORT_METHOD(saveStatusReportForRetry:(NSDictionary *)statusReport)
|
|
|
1128
1119
|
_didUpdateProgress = NO;
|
|
1129
1120
|
}
|
|
1130
1121
|
|
|
1122
|
+
#ifdef RCT_NEW_ARCH_ENABLED
|
|
1123
|
+
- (std::shared_ptr<facebook::react::TurboModule>)getTurboModule:
|
|
1124
|
+
(const facebook::react::ObjCTurboModule::InitParams &)params
|
|
1125
|
+
{
|
|
1126
|
+
return std::make_shared<facebook::react::NativeCodePushSpecJSI>(params);
|
|
1127
|
+
}
|
|
1128
|
+
#endif
|
|
1129
|
+
|
|
1131
1130
|
@end
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
objects = {
|
|
8
8
|
|
|
9
9
|
/* Begin PBXBuildFile section */
|
|
10
|
-
13BE3DEE1AC21097009241FE /* CodePush.
|
|
10
|
+
13BE3DEE1AC21097009241FE /* CodePush.mm in Sources */ = {isa = PBXBuildFile; fileRef = 13BE3DED1AC21097009241FE /* CodePush.mm */; };
|
|
11
11
|
1B23B9141BF9267B000BB2F0 /* RCTConvert+CodePushInstallMode.m in Sources */ = {isa = PBXBuildFile; fileRef = 1B23B9131BF9267B000BB2F0 /* RCTConvert+CodePushInstallMode.m */; };
|
|
12
12
|
1B762E901C9A5E9A006EF800 /* CodePushErrorUtils.m in Sources */ = {isa = PBXBuildFile; fileRef = 1B762E8F1C9A5E9A006EF800 /* CodePushErrorUtils.m */; };
|
|
13
13
|
1BCC09A71CC19EB700DDC0DD /* RCTConvert+CodePushUpdateState.m in Sources */ = {isa = PBXBuildFile; fileRef = 1BCC09A61CC19EB700DDC0DD /* RCTConvert+CodePushUpdateState.m */; };
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
5498D8F61D21F14100B5EB43 /* CodePushUtils.m in Sources */ = {isa = PBXBuildFile; fileRef = 5498D8F51D21F14100B5EB43 /* CodePushUtils.m */; };
|
|
83
83
|
54FFEDE01BF550630061DD23 /* CodePushDownloadHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = 54FFEDDF1BF550630061DD23 /* CodePushDownloadHandler.m */; };
|
|
84
84
|
6463C82D1EBA0CFB0095B8CD /* CodePushUtils.m in Sources */ = {isa = PBXBuildFile; fileRef = 5498D8F51D21F14100B5EB43 /* CodePushUtils.m */; };
|
|
85
|
-
6463C82E1EBA0CFB0095B8CD /* CodePush.
|
|
85
|
+
6463C82E1EBA0CFB0095B8CD /* CodePush.mm in Sources */ = {isa = PBXBuildFile; fileRef = 13BE3DED1AC21097009241FE /* CodePush.mm */; };
|
|
86
86
|
6463C82F1EBA0CFB0095B8CD /* CodePushConfig.m in Sources */ = {isa = PBXBuildFile; fileRef = 81D51F391B6181C2000DA084 /* CodePushConfig.m */; };
|
|
87
87
|
6463C8301EBA0CFB0095B8CD /* CodePushDownloadHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = 54FFEDDF1BF550630061DD23 /* CodePushDownloadHandler.m */; };
|
|
88
88
|
6463C8311EBA0CFB0095B8CD /* CodePushErrorUtils.m in Sources */ = {isa = PBXBuildFile; fileRef = 1B762E8F1C9A5E9A006EF800 /* CodePushErrorUtils.m */; };
|
|
@@ -125,7 +125,7 @@
|
|
|
125
125
|
/* Begin PBXFileReference section */
|
|
126
126
|
134814201AA4EA6300B7C361 /* libCodePush.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libCodePush.a; sourceTree = BUILT_PRODUCTS_DIR; };
|
|
127
127
|
13BE3DEC1AC21097009241FE /* CodePush.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = CodePush.h; path = CodePush/CodePush.h; sourceTree = "<group>"; };
|
|
128
|
-
13BE3DED1AC21097009241FE /* CodePush.
|
|
128
|
+
13BE3DED1AC21097009241FE /* CodePush.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = CodePush.mm; path = CodePush/CodePush.mm; sourceTree = "<group>"; };
|
|
129
129
|
1B23B9131BF9267B000BB2F0 /* RCTConvert+CodePushInstallMode.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "RCTConvert+CodePushInstallMode.m"; path = "CodePush/RCTConvert+CodePushInstallMode.m"; sourceTree = "<group>"; };
|
|
130
130
|
1B762E8F1C9A5E9A006EF800 /* CodePushErrorUtils.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = CodePushErrorUtils.m; path = CodePush/CodePushErrorUtils.m; sourceTree = "<group>"; };
|
|
131
131
|
1BCC09A61CC19EB700DDC0DD /* RCTConvert+CodePushUpdateState.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = "RCTConvert+CodePushUpdateState.m"; path = "CodePush/RCTConvert+CodePushUpdateState.m"; sourceTree = "<group>"; };
|
|
@@ -277,7 +277,7 @@
|
|
|
277
277
|
FF90DEF92C5A808600CA8692 /* PrivacyInfo.xcprivacy */,
|
|
278
278
|
5498D8F51D21F14100B5EB43 /* CodePushUtils.m */,
|
|
279
279
|
13BE3DEC1AC21097009241FE /* CodePush.h */,
|
|
280
|
-
13BE3DED1AC21097009241FE /* CodePush.
|
|
280
|
+
13BE3DED1AC21097009241FE /* CodePush.mm */,
|
|
281
281
|
81D51F391B6181C2000DA084 /* CodePushConfig.m */,
|
|
282
282
|
54FFEDDF1BF550630061DD23 /* CodePushDownloadHandler.m */,
|
|
283
283
|
1B762E8F1C9A5E9A006EF800 /* CodePushErrorUtils.m */,
|
|
@@ -451,7 +451,7 @@
|
|
|
451
451
|
3221E4912C8ABE1400268379 /* SSZipArchive.m in Sources */,
|
|
452
452
|
5421FE311C58AD5A00986A55 /* CodePushTelemetryManager.m in Sources */,
|
|
453
453
|
3221E46F2C8ABE1300268379 /* mz_strm_wzaes.c in Sources */,
|
|
454
|
-
13BE3DEE1AC21097009241FE /* CodePush.
|
|
454
|
+
13BE3DEE1AC21097009241FE /* CodePush.mm in Sources */,
|
|
455
455
|
3221E45D2C8ABE1300268379 /* mz_zip.c in Sources */,
|
|
456
456
|
1B762E901C9A5E9A006EF800 /* CodePushErrorUtils.m in Sources */,
|
|
457
457
|
3221E4832C8ABE1400268379 /* mz_strm_split.c in Sources */,
|
|
@@ -473,7 +473,7 @@
|
|
|
473
473
|
3221E4822C8ABE1400268379 /* mz_strm_buf.c in Sources */,
|
|
474
474
|
3221E45E2C8ABE1300268379 /* mz_zip.c in Sources */,
|
|
475
475
|
6463C82D1EBA0CFB0095B8CD /* CodePushUtils.m in Sources */,
|
|
476
|
-
6463C82E1EBA0CFB0095B8CD /* CodePush.
|
|
476
|
+
6463C82E1EBA0CFB0095B8CD /* CodePush.mm in Sources */,
|
|
477
477
|
6463C82F1EBA0CFB0095B8CD /* CodePushConfig.m in Sources */,
|
|
478
478
|
6463C8301EBA0CFB0095B8CD /* CodePushDownloadHandler.m in Sources */,
|
|
479
479
|
6463C8311EBA0CFB0095B8CD /* CodePushErrorUtils.m in Sources */,
|
package/package.json
CHANGED
|
@@ -1,11 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@bravemobile/react-native-code-push",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "13.0.0",
|
|
4
4
|
"description": "React Native plugin for the CodePush service",
|
|
5
5
|
"main": "src/CodePush.js",
|
|
6
6
|
"react-native": "src/CodePush.js",
|
|
7
7
|
"source": "src/CodePush.js",
|
|
8
8
|
"types": "typings/react-native-code-push.d.ts",
|
|
9
|
+
"codegenConfig": {
|
|
10
|
+
"name": "RNCodePushSpec",
|
|
11
|
+
"type": "modules",
|
|
12
|
+
"jsSrcsDir": "src/specs",
|
|
13
|
+
"android": {
|
|
14
|
+
"javaPackageName": "com.microsoft.codepush.react"
|
|
15
|
+
},
|
|
16
|
+
"ios": {
|
|
17
|
+
"modulesProvider": {
|
|
18
|
+
"CodePush": "CodePush"
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
},
|
|
9
22
|
"homepage": "https://microsoft.github.io/code-push",
|
|
10
23
|
"keywords": [
|
|
11
24
|
"react-native",
|
|
@@ -54,10 +67,11 @@
|
|
|
54
67
|
"setup": "npm install --quiet --no-progress",
|
|
55
68
|
"setup-example-app": "ts-node --project scripts/setupExampleApp/tsconfig.json scripts/setupExampleApp/runSetupExampleApp.ts",
|
|
56
69
|
"setup-expo-example-app": "ts-node --project scripts/setupExampleApp/tsconfig.json scripts/setupExpoExampleApp/runSetupExpoExampleApp.ts",
|
|
70
|
+
"type:src": "tsc --project tsconfig.json --noEmit",
|
|
57
71
|
"type:cli": "npm run --workspace cli typecheck",
|
|
58
72
|
"type:scripts": "tsc --project scripts/tsconfig.json --noEmit",
|
|
59
73
|
"type:e2e": "tsc --project e2e/tsconfig.json --noEmit",
|
|
60
|
-
"typecheck": "npm run type:cli && npm run type:scripts && npm run type:e2e",
|
|
74
|
+
"typecheck": "npm run type:src && npm run type:cli && npm run type:scripts && npm run type:e2e",
|
|
61
75
|
"build:cli": "npm run --workspace cli clean && npm run --workspace cli build",
|
|
62
76
|
"prepack": "npm run build:cli",
|
|
63
77
|
"publish": "npm publish --access=public",
|
|
@@ -94,6 +108,7 @@
|
|
|
94
108
|
"@eslint/js": "^9.13.0",
|
|
95
109
|
"@types/express": "^5.0.6",
|
|
96
110
|
"@types/node": "^18.19.129",
|
|
111
|
+
"@types/react": "19.2.14",
|
|
97
112
|
"@types/semver": "^7.5.8",
|
|
98
113
|
"@types/shelljs": "^0.8.15",
|
|
99
114
|
"@types/yauzl": "^2.10.3",
|
|
@@ -103,6 +118,8 @@
|
|
|
103
118
|
"express": "latest",
|
|
104
119
|
"globals": "^15.11.0",
|
|
105
120
|
"jest": "^29.7.0",
|
|
121
|
+
"react": "19.2.3",
|
|
122
|
+
"react-native": "0.84.1",
|
|
106
123
|
"ts-node": "^10.9.2",
|
|
107
124
|
"typescript": "5.0.4",
|
|
108
125
|
"typescript-eslint": "^8.11.0"
|
package/react-native.config.js
CHANGED
|
@@ -5,7 +5,9 @@ module.exports = {
|
|
|
5
5
|
packageImportPath: "import com.microsoft.codepush.react.CodePush;",
|
|
6
6
|
packageInstance:
|
|
7
7
|
"CodePush.getInstance(getApplicationContext(), BuildConfig.DEBUG)",
|
|
8
|
-
sourceDir: './android/app'
|
|
8
|
+
sourceDir: './android/app',
|
|
9
|
+
libraryName: 'RNCodePushSpec',
|
|
10
|
+
cmakeListsPath: 'build/generated/source/codegen/jni/CMakeLists.txt',
|
|
9
11
|
}
|
|
10
12
|
}
|
|
11
13
|
}
|