@srcpush/react-native-code-push 1.0.3-develop.5 → 1.0.3-feat-new-arch.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.
@@ -0,0 +1,49 @@
1
+ package com.microsoft.codepush.react;
2
+
3
+ import com.facebook.react.bridge.Callback;
4
+ import com.facebook.react.bridge.ReactApplicationContext;
5
+ import com.facebook.react.module.annotations.ReactModule;
6
+
7
+ @ReactModule(name = CodePushDialog.NAME)
8
+ public class CodePushDialog extends NativeCodePushDialogSpec {
9
+ public static final String NAME = "CodePushDialog";
10
+
11
+ private final CodePushDialogImpl impl;
12
+
13
+ public CodePushDialog(ReactApplicationContext reactContext) {
14
+ super(reactContext);
15
+ impl = new CodePushDialogImpl(reactContext);
16
+ }
17
+
18
+ @Override
19
+ public String getName() {
20
+ return NAME;
21
+ }
22
+
23
+ @Override
24
+ public void showDialog(
25
+ String title,
26
+ String message,
27
+ String button1Text,
28
+ String button2Text,
29
+ Callback successCallback,
30
+ Callback errorCallback
31
+ ) {
32
+ try {
33
+ impl.showDialog(title, message, button1Text, button2Text, successCallback, errorCallback);
34
+ } catch (Throwable e) {
35
+ if (errorCallback != null) errorCallback.invoke(e.getMessage());
36
+ }
37
+ }
38
+
39
+ @Override
40
+ public void addListener(String eventName) {
41
+ // no-op
42
+ }
43
+
44
+ @Override
45
+ public void removeListeners(double count) {
46
+ // no-op
47
+ }
48
+ }
49
+
@@ -0,0 +1,143 @@
1
+ package com.microsoft.codepush.react;
2
+
3
+ import androidx.annotation.NonNull;
4
+ import androidx.annotation.OptIn;
5
+
6
+ import com.facebook.react.bridge.Promise;
7
+ import com.facebook.react.bridge.ReactApplicationContext;
8
+ import com.facebook.react.bridge.ReadableMap;
9
+ import com.facebook.react.common.annotations.UnstableReactNativeAPI;
10
+ import com.facebook.react.module.annotations.ReactModule;
11
+
12
+ import java.util.Map;
13
+
14
+ @OptIn(markerClass = UnstableReactNativeAPI.class)
15
+ @ReactModule(name = CodePushNativeModule.NAME)
16
+ public class CodePushNativeModule extends NativeCodePushSpec {
17
+ public static final String NAME = "CodePush";
18
+
19
+ private final CodePushNativeModuleImpl impl;
20
+
21
+ public CodePushNativeModule(
22
+ ReactApplicationContext reactContext,
23
+ CodePush codePush,
24
+ CodePushUpdateManager codePushUpdateManager,
25
+ CodePushTelemetryManager codePushTelemetryManager,
26
+ SettingsManager settingsManager
27
+ ) {
28
+ super(reactContext);
29
+ impl = new CodePushNativeModuleImpl(reactContext, codePush, codePushUpdateManager, codePushTelemetryManager, settingsManager);
30
+ }
31
+
32
+ @NonNull
33
+ @Override
34
+ public String getName() {
35
+ return NAME;
36
+ }
37
+
38
+ @Override
39
+ protected Map<String, Object> getTypedExportedConstants() {
40
+ return impl.getConstants();
41
+ }
42
+
43
+ @Override
44
+ public void allow(Promise promise) {
45
+ impl.allow(promise);
46
+ }
47
+
48
+ @Override
49
+ public void clearPendingRestart(Promise promise) {
50
+ impl.clearPendingRestart(promise);
51
+ }
52
+
53
+ @Override
54
+ public void disallow(Promise promise) {
55
+ impl.disallow(promise);
56
+ }
57
+
58
+ @Override
59
+ public void restartApp(boolean onlyIfUpdateIsPending, Promise promise) {
60
+ impl.restartApp(onlyIfUpdateIsPending, promise);
61
+ }
62
+
63
+ @Override
64
+ public void downloadUpdate(ReadableMap updatePackage, boolean notifyProgress, Promise promise) {
65
+ impl.downloadUpdate(updatePackage, notifyProgress, promise);
66
+ }
67
+
68
+ @Override
69
+ public void getConfiguration(Promise promise) {
70
+ impl.getConfiguration(promise);
71
+ }
72
+
73
+ @Override
74
+ public void getUpdateMetadata(double updateState, Promise promise) {
75
+ impl.getUpdateMetadata(updateState, promise);
76
+ }
77
+
78
+ @Override
79
+ public void getNewStatusReport(Promise promise) {
80
+ impl.getNewStatusReport(promise);
81
+ }
82
+
83
+ @Override
84
+ public void installUpdate(ReadableMap updatePackage, double installMode, double minimumBackgroundDuration, Promise promise) {
85
+ impl.installUpdate(updatePackage, installMode, minimumBackgroundDuration, promise);
86
+ }
87
+
88
+ @Override
89
+ public void isFailedUpdate(String packageHash, Promise promise) {
90
+ impl.isFailedUpdate(packageHash, promise);
91
+ }
92
+
93
+ @Override
94
+ public void getLatestRollbackInfo(Promise promise) {
95
+ impl.getLatestRollbackInfo(promise);
96
+ }
97
+
98
+ @Override
99
+ public void setLatestRollbackInfo(String packageHash, Promise promise) {
100
+ impl.setLatestRollbackInfo(packageHash, promise);
101
+ }
102
+
103
+ @Override
104
+ public void isFirstRun(String packageHash, Promise promise) {
105
+ impl.isFirstRun(packageHash, promise);
106
+ }
107
+
108
+ @Override
109
+ public void notifyApplicationReady(Promise promise) {
110
+ impl.notifyApplicationReady(promise);
111
+ }
112
+
113
+ @Override
114
+ public void recordStatusReported(ReadableMap statusReport) {
115
+ impl.recordStatusReported(statusReport);
116
+ }
117
+
118
+ @Override
119
+ public void saveStatusReportForRetry(ReadableMap statusReport) {
120
+ impl.saveStatusReportForRetry(statusReport);
121
+ }
122
+
123
+ @Override
124
+ public void downloadAndReplaceCurrentBundle(String remoteBundleUrl) {
125
+ impl.downloadAndReplaceCurrentBundle(remoteBundleUrl);
126
+ }
127
+
128
+ @Override
129
+ public void clearUpdates() {
130
+ impl.clearUpdates();
131
+ }
132
+
133
+ @Override
134
+ public void addListener(String eventName) {
135
+ impl.addListener(eventName);
136
+ }
137
+
138
+ @Override
139
+ public void removeListeners(double count) {
140
+ impl.removeListeners(count);
141
+ }
142
+ }
143
+
@@ -0,0 +1,49 @@
1
+ package com.microsoft.codepush.react;
2
+
3
+ import com.facebook.react.bridge.BaseJavaModule;
4
+ import com.facebook.react.bridge.Callback;
5
+ import com.facebook.react.bridge.ReactApplicationContext;
6
+ import com.facebook.react.bridge.ReactMethod;
7
+
8
+ public class CodePushDialog extends BaseJavaModule {
9
+ public static final String NAME = "CodePushDialog";
10
+
11
+ private final CodePushDialogImpl impl;
12
+
13
+ public CodePushDialog(ReactApplicationContext reactContext) {
14
+ super(reactContext);
15
+ impl = new CodePushDialogImpl(reactContext);
16
+ }
17
+
18
+ @ReactMethod
19
+ public void showDialog(
20
+ final String title,
21
+ final String message,
22
+ final String button1Text,
23
+ final String button2Text,
24
+ final Callback successCallback,
25
+ Callback errorCallback
26
+ ) {
27
+ try {
28
+ impl.showDialog(title, message, button1Text, button2Text, successCallback, errorCallback);
29
+ } catch (Throwable e) {
30
+ if (errorCallback != null) errorCallback.invoke(e.getMessage());
31
+ }
32
+ }
33
+
34
+ @ReactMethod
35
+ public void addListener(String eventName) {
36
+ // no-op
37
+ }
38
+
39
+ @ReactMethod
40
+ public void removeListeners(double count) {
41
+ // no-op
42
+ }
43
+
44
+ @Override
45
+ public String getName() {
46
+ return NAME;
47
+ }
48
+ }
49
+
@@ -0,0 +1,141 @@
1
+ package com.microsoft.codepush.react;
2
+
3
+ import androidx.annotation.OptIn;
4
+
5
+ import com.facebook.react.bridge.BaseJavaModule;
6
+ import com.facebook.react.bridge.Promise;
7
+ import com.facebook.react.bridge.ReactApplicationContext;
8
+ import com.facebook.react.bridge.ReactMethod;
9
+ import com.facebook.react.bridge.ReadableMap;
10
+ import com.facebook.react.common.annotations.UnstableReactNativeAPI;
11
+
12
+ import java.util.Map;
13
+
14
+ @OptIn(markerClass = UnstableReactNativeAPI.class)
15
+ public class CodePushNativeModule extends BaseJavaModule {
16
+ public static final String NAME = "CodePush";
17
+
18
+ private final CodePushNativeModuleImpl impl;
19
+
20
+ public CodePushNativeModule(
21
+ ReactApplicationContext reactContext,
22
+ CodePush codePush,
23
+ CodePushUpdateManager codePushUpdateManager,
24
+ CodePushTelemetryManager codePushTelemetryManager,
25
+ SettingsManager settingsManager
26
+ ) {
27
+ super(reactContext);
28
+ impl = new CodePushNativeModuleImpl(reactContext, codePush, codePushUpdateManager, codePushTelemetryManager, settingsManager);
29
+ }
30
+
31
+ @Override
32
+ public Map<String, Object> getConstants() {
33
+ return impl.getConstants();
34
+ }
35
+
36
+ @Override
37
+ public String getName() {
38
+ return NAME;
39
+ }
40
+
41
+ @ReactMethod
42
+ public void allow(Promise promise) {
43
+ impl.allow(promise);
44
+ }
45
+
46
+ @ReactMethod
47
+ public void clearPendingRestart(Promise promise) {
48
+ impl.clearPendingRestart(promise);
49
+ }
50
+
51
+ @ReactMethod
52
+ public void disallow(Promise promise) {
53
+ impl.disallow(promise);
54
+ }
55
+
56
+ @ReactMethod
57
+ public void restartApp(boolean onlyIfUpdateIsPending, Promise promise) {
58
+ impl.restartApp(onlyIfUpdateIsPending, promise);
59
+ }
60
+
61
+ @ReactMethod
62
+ public void downloadUpdate(ReadableMap updatePackage, boolean notifyProgress, Promise promise) {
63
+ impl.downloadUpdate(updatePackage, notifyProgress, promise);
64
+ }
65
+
66
+ @ReactMethod
67
+ public void getConfiguration(Promise promise) {
68
+ impl.getConfiguration(promise);
69
+ }
70
+
71
+ @ReactMethod
72
+ public void getUpdateMetadata(double updateState, Promise promise) {
73
+ impl.getUpdateMetadata(updateState, promise);
74
+ }
75
+
76
+ @ReactMethod
77
+ public void getNewStatusReport(Promise promise) {
78
+ impl.getNewStatusReport(promise);
79
+ }
80
+
81
+ @ReactMethod
82
+ public void installUpdate(ReadableMap updatePackage, double installMode, double minimumBackgroundDuration, Promise promise) {
83
+ impl.installUpdate(updatePackage, installMode, minimumBackgroundDuration, promise);
84
+ }
85
+
86
+ @ReactMethod
87
+ public void isFailedUpdate(String packageHash, Promise promise) {
88
+ impl.isFailedUpdate(packageHash, promise);
89
+ }
90
+
91
+ @ReactMethod
92
+ public void getLatestRollbackInfo(Promise promise) {
93
+ impl.getLatestRollbackInfo(promise);
94
+ }
95
+
96
+ @ReactMethod
97
+ public void setLatestRollbackInfo(String packageHash, Promise promise) {
98
+ impl.setLatestRollbackInfo(packageHash, promise);
99
+ }
100
+
101
+ @ReactMethod
102
+ public void isFirstRun(String packageHash, Promise promise) {
103
+ impl.isFirstRun(packageHash, promise);
104
+ }
105
+
106
+ @ReactMethod
107
+ public void notifyApplicationReady(Promise promise) {
108
+ impl.notifyApplicationReady(promise);
109
+ }
110
+
111
+ @ReactMethod
112
+ public void recordStatusReported(ReadableMap statusReport) {
113
+ impl.recordStatusReported(statusReport);
114
+ }
115
+
116
+ @ReactMethod
117
+ public void saveStatusReportForRetry(ReadableMap statusReport) {
118
+ impl.saveStatusReportForRetry(statusReport);
119
+ }
120
+
121
+ @ReactMethod
122
+ public void downloadAndReplaceCurrentBundle(String remoteBundleUrl) {
123
+ impl.downloadAndReplaceCurrentBundle(remoteBundleUrl);
124
+ }
125
+
126
+ @ReactMethod
127
+ public void clearUpdates() {
128
+ impl.clearUpdates();
129
+ }
130
+
131
+ @ReactMethod
132
+ public void addListener(String eventName) {
133
+ impl.addListener(eventName);
134
+ }
135
+
136
+ @ReactMethod
137
+ public void removeListeners(double count) {
138
+ impl.removeListeners(count);
139
+ }
140
+ }
141
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@srcpush/react-native-code-push",
3
- "version": "1.0.3-develop.5",
3
+ "version": "1.0.3-feat-new-arch.1",
4
4
  "description": "React Native plugin for the CodePush service",
5
5
  "main": "CodePush.js",
6
6
  "typings": "typings/react-native-code-push.d.ts",
@@ -49,6 +49,14 @@
49
49
  "semver": "^7.3.5",
50
50
  "xcode": "3.0.1"
51
51
  },
52
+ "codegenConfig": {
53
+ "name": "SrcPushCodePushSpec",
54
+ "type": "modules",
55
+ "jsSrcsDir": "./src/specs",
56
+ "android": {
57
+ "javaPackageName": "com.microsoft.codepush.react"
58
+ }
59
+ },
52
60
  "devDependencies": {
53
61
  "@types/assert": "^1.5.2",
54
62
  "@types/mkdirp": "^1.0.1",
@@ -0,0 +1,56 @@
1
+ import type { TurboModule } from 'react-native';
2
+ import { TurboModuleRegistry } from 'react-native';
3
+ import type { UnsafeObject } from 'react-native/Libraries/Types/CodegenTypes';
4
+
5
+ export type CodePushConstants = {
6
+ codePushInstallModeImmediate: number;
7
+ codePushInstallModeOnNextRestart: number;
8
+ codePushInstallModeOnNextResume: number;
9
+ codePushInstallModeOnNextSuspend: number;
10
+
11
+ codePushUpdateStateRunning: number;
12
+ codePushUpdateStatePending: number;
13
+ codePushUpdateStateLatest: number;
14
+ };
15
+
16
+ export interface Spec extends TurboModule {
17
+ getConstants(): CodePushConstants;
18
+
19
+ allow(): Promise<void>;
20
+ clearPendingRestart(): Promise<void>;
21
+ disallow(): Promise<void>;
22
+ restartApp(onlyIfUpdateIsPending: boolean): Promise<void>;
23
+
24
+ downloadUpdate(
25
+ updatePackage: UnsafeObject,
26
+ notifyProgress: boolean,
27
+ ): Promise<UnsafeObject>;
28
+
29
+ getConfiguration(): Promise<UnsafeObject>;
30
+ getUpdateMetadata(updateState: number): Promise<UnsafeObject | null>;
31
+ getNewStatusReport(): Promise<UnsafeObject | null>;
32
+ installUpdate(
33
+ updatePackage: UnsafeObject,
34
+ installMode: number,
35
+ minimumBackgroundDuration: number,
36
+ ): Promise<void>;
37
+
38
+ isFailedUpdate(packageHash: string): Promise<boolean>;
39
+ getLatestRollbackInfo(): Promise<UnsafeObject | null>;
40
+ setLatestRollbackInfo(packageHash: string): Promise<void>;
41
+ isFirstRun(packageHash: string): Promise<boolean>;
42
+
43
+ notifyApplicationReady(): Promise<void>;
44
+
45
+ recordStatusReported(statusReport: UnsafeObject): void;
46
+ saveStatusReportForRetry(statusReport: UnsafeObject): void;
47
+
48
+ downloadAndReplaceCurrentBundle(remoteBundleUrl: string): void;
49
+ clearUpdates(): void;
50
+
51
+ addListener(eventName: string): void;
52
+ removeListeners(count: number): void;
53
+ }
54
+
55
+ export default TurboModuleRegistry.getEnforcing<Spec>('CodePush');
56
+
@@ -0,0 +1,19 @@
1
+ import type { TurboModule } from 'react-native';
2
+ import { TurboModuleRegistry } from 'react-native';
3
+
4
+ export interface Spec extends TurboModule {
5
+ showDialog(
6
+ title: string | null,
7
+ message: string | null,
8
+ button1Text: string | null,
9
+ button2Text: string | null,
10
+ successCallback: (buttonId: number) => void,
11
+ errorCallback: (error: string) => void,
12
+ ): void;
13
+
14
+ addListener(eventName: string): void;
15
+ removeListeners(count: number): void;
16
+ }
17
+
18
+ export default TurboModuleRegistry.getEnforcing<Spec>('CodePushDialog');
19
+