@srcpush/react-native-code-push 1.0.3-feat-new-architecture.1 → 1.0.3-feat-new-arch.2

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.
Files changed (96) hide show
  1. package/AlertAdapter.js +21 -2
  2. package/CONTRIBUTING.md +20 -9
  3. package/CodePush.js +17 -2
  4. package/LICENSE.md +2 -2
  5. package/README.md +15 -15
  6. package/SECURITY.md +4 -20
  7. package/android/app/build.gradle +20 -14
  8. package/android/app/src/main/java/com/microsoft/codepush/react/CodePush.java +52 -10
  9. package/android/app/src/main/java/com/microsoft/codepush/react/{CodePushDialog.java → CodePushDialogImpl.java} +28 -28
  10. package/android/app/src/main/java/com/microsoft/codepush/react/{CodePushNativeModule.java → CodePushNativeModuleImpl.java} +93 -210
  11. package/android/app/src/newarch/java/com/microsoft/codepush/react/CodePushDialog.java +49 -0
  12. package/android/app/src/newarch/java/com/microsoft/codepush/react/CodePushNativeModule.java +143 -0
  13. package/android/app/src/oldarch/java/com/microsoft/codepush/react/CodePushDialog.java +49 -0
  14. package/android/app/src/oldarch/java/com/microsoft/codepush/react/CodePushNativeModule.java +141 -0
  15. package/docs/api-android.md +10 -10
  16. package/docs/api-ios.md +5 -5
  17. package/docs/api-js.md +17 -17
  18. package/docs/multi-deployment-testing-android.md +2 -2
  19. package/docs/multi-deployment-testing-ios.md +1 -1
  20. package/docs/setup-android.md +7 -7
  21. package/docs/setup-ios.md +9 -9
  22. package/docs/setup-windows.md +6 -6
  23. package/package.json +9 -9
  24. package/src/specs/NativeCodePush.ts +56 -0
  25. package/src/specs/NativeCodePushDialog.ts +19 -0
  26. package/tsconfig.json +4 -2
  27. package/tslint.json +21 -13
  28. package/.azurepipelines/build-rn-code-push-1es.yml +0 -104
  29. package/.azurepipelines/test-rn-code-push.yml +0 -94
  30. package/android/app/src/newarch/java/com/microsoft/codepush/react/CodePushNativeModuleSpec.java +0 -9
  31. package/android/app/src/oldarch/java/com/microsoft/codepush/react/CodePushNativeModuleSpec.java +0 -34
  32. package/src/NativeCodePush.ts +0 -39
  33. package/windows/CodePush/CodePush.def +0 -3
  34. package/windows/CodePush/CodePush.vcxproj +0 -198
  35. package/windows/CodePush/CodePush.vcxproj.filters +0 -91
  36. package/windows/CodePush/CodePushConfig.cpp +0 -104
  37. package/windows/CodePush/CodePushConfig.h +0 -66
  38. package/windows/CodePush/CodePushConfig.idl +0 -12
  39. package/windows/CodePush/CodePushDownloadHandler.cpp +0 -73
  40. package/windows/CodePush/CodePushDownloadHandler.h +0 -32
  41. package/windows/CodePush/CodePushNativeModule.cpp +0 -937
  42. package/windows/CodePush/CodePushNativeModule.h +0 -247
  43. package/windows/CodePush/CodePushPackage.cpp +0 -456
  44. package/windows/CodePush/CodePushPackage.h +0 -49
  45. package/windows/CodePush/CodePushTelemetryManager.cpp +0 -213
  46. package/windows/CodePush/CodePushTelemetryManager.h +0 -29
  47. package/windows/CodePush/CodePushUpdateUtils.cpp +0 -86
  48. package/windows/CodePush/CodePushUpdateUtils.h +0 -38
  49. package/windows/CodePush/CodePushUtils.cpp +0 -29
  50. package/windows/CodePush/CodePushUtils.h +0 -18
  51. package/windows/CodePush/FileUtils.cpp +0 -131
  52. package/windows/CodePush/FileUtils.h +0 -28
  53. package/windows/CodePush/PropertySheet.props +0 -16
  54. package/windows/CodePush/ReactPackageProvider.cpp +0 -15
  55. package/windows/CodePush/ReactPackageProvider.h +0 -22
  56. package/windows/CodePush/ReactPackageProvider.idl +0 -9
  57. package/windows/CodePush/miniz/LICENSE +0 -22
  58. package/windows/CodePush/miniz/miniz.c +0 -7657
  59. package/windows/CodePush/miniz/miniz.h +0 -1338
  60. package/windows/CodePush/miniz/readme.md +0 -37
  61. package/windows/CodePush/packages.config +0 -4
  62. package/windows/CodePush/pch.cpp +0 -1
  63. package/windows/CodePush/pch.h +0 -4
  64. package/windows-legacy/CodePush/CodePush.csproj +0 -128
  65. package/windows-legacy/CodePush/CodePushUtils.cs +0 -47
  66. package/windows-legacy/CodePush/FileUtils.cs +0 -40
  67. package/windows-legacy/CodePush/Properties/AssemblyInfo.cs +0 -29
  68. package/windows-legacy/CodePush/Properties/CodePush.rd.xml +0 -33
  69. package/windows-legacy/CodePush/UpdateManager.cs +0 -305
  70. package/windows-legacy/CodePush/UpdateUtils.cs +0 -46
  71. package/windows-legacy/CodePush.Net46/Adapters/Http/HttpProgress.cs +0 -28
  72. package/windows-legacy/CodePush.Net46/Adapters/Storage/ApplicationDataContainer.cs +0 -106
  73. package/windows-legacy/CodePush.Net46/CodePush.Net46.csproj +0 -103
  74. package/windows-legacy/CodePush.Net46/CodePushUtils.cs +0 -158
  75. package/windows-legacy/CodePush.Net46/FileUtils.cs +0 -55
  76. package/windows-legacy/CodePush.Net46/Properties/AssemblyInfo.cs +0 -36
  77. package/windows-legacy/CodePush.Net46/UpdateManager.cs +0 -330
  78. package/windows-legacy/CodePush.Net46/UpdateUtils.cs +0 -70
  79. package/windows-legacy/CodePush.Net46/packages.config +0 -5
  80. package/windows-legacy/CodePush.Net46.Test/ApplicationDataContainerTest.cs +0 -105
  81. package/windows-legacy/CodePush.Net46.Test/CodePush.Net46.Test.csproj +0 -137
  82. package/windows-legacy/CodePush.Net46.Test/Properties/AssemblyInfo.cs +0 -36
  83. package/windows-legacy/CodePush.Net46.Test/TelemetryManagerTest.cs +0 -117
  84. package/windows-legacy/CodePush.Net46.Test/app.config +0 -11
  85. package/windows-legacy/CodePush.Net46.Test/packages.config +0 -4
  86. package/windows-legacy/CodePush.Shared/CodePush.Shared.projitems +0 -22
  87. package/windows-legacy/CodePush.Shared/CodePush.Shared.shproj +0 -13
  88. package/windows-legacy/CodePush.Shared/CodePushConstants.cs +0 -35
  89. package/windows-legacy/CodePush.Shared/CodePushNativeModule.cs +0 -329
  90. package/windows-legacy/CodePush.Shared/CodePushReactPackage.cs +0 -235
  91. package/windows-legacy/CodePush.Shared/CodePushUtils.cs +0 -70
  92. package/windows-legacy/CodePush.Shared/InstallMode.cs +0 -9
  93. package/windows-legacy/CodePush.Shared/MinimumBackgroundListener.cs +0 -44
  94. package/windows-legacy/CodePush.Shared/SettingsManager.cs +0 -148
  95. package/windows-legacy/CodePush.Shared/TelemetryManager.cs +0 -250
  96. package/windows-legacy/CodePush.Shared/UpdateState.cs +0 -9
package/AlertAdapter.js CHANGED
@@ -2,7 +2,22 @@ import React, { Platform } from "react-native";
2
2
  let { Alert } = React;
3
3
 
4
4
  if (Platform.OS === "android") {
5
- const { NativeModules: { CodePushDialog } } = React;
5
+ function resolveNativeModule(name) {
6
+ const ReactNative = require("react-native");
7
+ try {
8
+ const turboModule =
9
+ ReactNative.TurboModuleRegistry && ReactNative.TurboModuleRegistry.get
10
+ ? ReactNative.TurboModuleRegistry.get(name)
11
+ : null;
12
+ if (turboModule) return turboModule;
13
+ } catch (_e) {
14
+ // Ignore and fall back to legacy NativeModules.
15
+ }
16
+
17
+ return ReactNative.NativeModules ? ReactNative.NativeModules[name] : null;
18
+ }
19
+
20
+ const CodePushDialog = resolveNativeModule("CodePushDialog");
6
21
 
7
22
  Alert = {
8
23
  alert(title, message, buttons) {
@@ -13,6 +28,10 @@ if (Platform.OS === "android") {
13
28
  const button1Text = buttons[0] ? buttons[0].text : null,
14
29
  button2Text = buttons[1] ? buttons[1].text : null;
15
30
 
31
+ if (!CodePushDialog) {
32
+ throw "CodePushDialog native module is not installed.";
33
+ }
34
+
16
35
  CodePushDialog.showDialog(
17
36
  title, message, button1Text, button2Text,
18
37
  (buttonId) => { buttons[buttonId].onPress && buttons[buttonId].onPress(); },
@@ -21,4 +40,4 @@ if (Platform.OS === "android") {
21
40
  };
22
41
  }
23
42
 
24
- module.exports = { Alert };
43
+ module.exports = { Alert };
package/CONTRIBUTING.md CHANGED
@@ -4,7 +4,7 @@
4
4
 
5
5
  ### Environment setup
6
6
 
7
- `node.js` and `npm` are needed for using this project. `npm` comes bundled with the `node.js` installer. You can download the `node.js` installer here: https://nodejs.org/download/.
7
+ `node.js` and `npm` are needed for using this project. `npm` comes bundled with the `node.js` installer. You can download the `node.js` installer here: <https://nodejs.org/download/>.
8
8
 
9
9
  Once you have installed `node.js` and `npm`, install the dev dependencies for the project.
10
10
 
@@ -15,19 +15,22 @@ npm install
15
15
  ### Using the plugin manually
16
16
 
17
17
  Follow these steps to test your modifications to the plugin manually:
18
+
18
19
  - clone this repository
19
20
  - install the dependencies
20
21
 
21
- Navigate to the root folder from your command line console and run:
22
- ```
23
- npm install
24
- ```
22
+ Navigate to the root folder from your command line console and run:
23
+ ```
24
+ npm install
25
+ ```
26
+
25
27
  - install the plugin in a React-Native project
26
28
 
27
- Navigate to the root folder of your React-Native project from your command line console and run:
28
- ```
29
- npm install local_path_to_your_clone_of_this_repo
30
- ```
29
+ Navigate to the root folder of your React-Native project from your command line console and run:
30
+ ```
31
+ npm install local_path_to_your_clone_of_this_repo
32
+ ```
33
+
31
34
  - configure the plugin using the steps in the README.md
32
35
  - build and run your app on an emulator or device
33
36
 
@@ -81,6 +84,7 @@ If you would like to pull the plugin from NPM rather than running the tests on t
81
84
  #### Default
82
85
 
83
86
  To run all of the unit tests on Android and iOS:
87
+
84
88
  ```
85
89
  npm run test
86
90
  ```
@@ -88,6 +92,7 @@ npm run test
88
92
  #### iOS
89
93
 
90
94
  To run all of the unit tests on iOS:
95
+
91
96
  ```
92
97
  npm run test:ios
93
98
  ```
@@ -95,6 +100,7 @@ npm run test:ios
95
100
  #### Android
96
101
 
97
102
  To run all of the unit tests on Android:
103
+
98
104
  ```
99
105
  npm run test:android
100
106
  ```
@@ -107,26 +113,31 @@ The platforms are ordered as follows, and ran in that order:
107
113
  android, ios
108
114
 
109
115
  To run the core unit tests on Android:
116
+
110
117
  ```
111
118
  CORE=true npm run test:android
112
119
  ```
113
120
 
114
121
  To run all of the unit tests on iOS and pull the plugin from NPM:
122
+
115
123
  ```
116
124
  NPM=true npm run test:ios
117
125
  ```
118
126
 
119
127
  To run all of the unit tests on Android and iOS without building first:
128
+
120
129
  ```
121
130
  npm run test:fast
122
131
  ```
123
132
 
124
133
  To run all of the unit tests on iOS and restart the emulators:
134
+
125
135
  ```
126
136
  CLEAN=true npm run test:ios
127
137
  ```
128
138
 
129
139
  To run the core unit tests on Android and pull the plugin from NPM:
140
+
130
141
  ```
131
142
  NPM=true CORE=true npm run test:android
132
143
  ```
package/CodePush.js CHANGED
@@ -1,11 +1,26 @@
1
1
  import { AcquisitionManager as Sdk } from "code-push/script/acquisition-sdk";
2
2
  import { Alert } from "./AlertAdapter";
3
3
  import requestFetchAdapter from "./request-fetch-adapter";
4
- import { AppState, Platform, TurboModuleRegistry } from "react-native";
4
+ import { AppState, Platform } from "react-native";
5
5
  import log from "./logging";
6
6
  import hoistStatics from 'hoist-non-react-statics';
7
7
 
8
- let NativeCodePush = (TurboModuleRegistry?.get('CodePush')) || require("react-native").NativeModules.CodePush;
8
+ function resolveNativeModule(name) {
9
+ const ReactNative = require("react-native");
10
+ try {
11
+ const turboModule =
12
+ ReactNative.TurboModuleRegistry && ReactNative.TurboModuleRegistry.get
13
+ ? ReactNative.TurboModuleRegistry.get(name)
14
+ : null;
15
+ if (turboModule) return turboModule;
16
+ } catch (_e) {
17
+ // Ignore and fall back to legacy NativeModules.
18
+ }
19
+
20
+ return ReactNative.NativeModules ? ReactNative.NativeModules[name] : null;
21
+ }
22
+
23
+ let NativeCodePush = resolveNativeModule("CodePush");
9
24
  const PackageMixins = require("./package-mixins")(NativeCodePush);
10
25
 
11
26
  async function checkForUpdate(deploymentKey = null, handleBinaryVersionMismatchCallback = null) {
package/LICENSE.md CHANGED
@@ -2,7 +2,7 @@ Microsoft CodePush Plugin for React Native
2
2
 
3
3
  Copyright (c) Microsoft Corporation
4
4
 
5
- All rights reserved.
5
+ All rights reserved.
6
6
 
7
7
  MIT License
8
8
 
@@ -10,4 +10,4 @@ Permission is hereby granted, free of charge, to any person obtaining a copy of
10
10
 
11
11
  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
12
12
 
13
- THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
13
+ THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md CHANGED
@@ -1,8 +1,8 @@
1
- #### [Sign up With Source Push](https://console.srcpush.com/register) to use CodePush SDK
1
+ #### [Sign up With Source Push](https://console.srcpush.com/register) to use Source Push SDK
2
2
 
3
3
  # React Native SDK for Source Push (CodePush compatible service)
4
4
 
5
- This plugin provides client-side integration for the [CodePush service](https://srcpush.com/), allowing you to easily add a dynamic update experience to your React Native app(s).
5
+ This plugin provides client-side integration for the [Source Push service](https://srcpush.com/), allowing you to easily add a dynamic update experience to your React Native app(s).
6
6
 
7
7
  <!-- React Native Catalog -->
8
8
 
@@ -34,20 +34,20 @@ This plugin provides client-side integration for the [CodePush service](https://
34
34
 
35
35
  A React Native app is composed of JavaScript files and any accompanying [images](https://reactnative.dev/docs/image), which are bundled together by the [metro bundler](https://github.com/facebook/metro) and distributed as part of a platform-specific binary (i.e. an `.ipa` or `.apk` file). Once the app is released, updating either the JavaScript code (e.g. making bug fixes, adding new features) or image assets, requires you to recompile and redistribute the entire binary, which of course, includes any review time associated with the store(s) you are publishing to.
36
36
 
37
- The CodePush plugin helps get product improvements in front of your end users instantly, by keeping your JavaScript and images synchronized with updates you release to the CodePush server. This way, your app gets the benefits of an offline mobile experience, as well as the "web-like" agility of side-loading updates as soon as they are available. It's a win-win!
37
+ The Source Push plugin helps get product improvements in front of your end users instantly, by keeping your JavaScript and images synchronized with updates you release to the Source Push server. This way, your app gets the benefits of an offline mobile experience, as well as the "web-like" agility of side-loading updates as soon as they are available. It's a win-win!
38
38
 
39
- In order to ensure that your end users always have a functioning version of your app, the CodePush plugin maintains a copy of the previous update, so that in the event that you accidentally push an update which includes a crash, it can automatically roll back. This way, you can rest assured that your newfound release agility won't result in users becoming blocked before you have a chance to roll back on the server. It's a win-win-win!
39
+ In order to ensure that your end users always have a functioning version of your app, the Source Push plugin maintains a copy of the previous update, so that in the event that you accidentally push an update which includes a crash, it can automatically roll back. This way, you can rest assured that your newfound release agility won't result in users becoming blocked before you have a chance to roll back on the server. It's a win-win-win!
40
40
 
41
- *Note: Any product changes which touch native code (e.g. modifying your `AppDelegate.m`/`MainActivity.java` file, adding a new plugin) cannot be distributed via CodePush, and therefore, must be updated via the appropriate store(s).*
41
+ *Note: Any product changes which touch native code (e.g. modifying your `AppDelegate.m`/`MainActivity.java` file, adding a new plugin) cannot be distributed via Source Push, and therefore, must be updated via the appropriate store(s).*
42
42
 
43
43
  ## Supported React Native platforms
44
44
 
45
45
  * iOS (7+)
46
46
  * Android (4.1+) on TLS 1.2 compatible devices
47
47
 
48
- We try our best to maintain backwards compatibility of our plugin with previous versions of React Native, but due to the nature of the platform, and the existence of breaking changes between releases, it is possible that you need to use a specific version of the CodePush plugin in order to support the exact version of React Native you are using. The following table outlines which CodePush plugin versions officially support the respective React Native versions:
48
+ We try our best to maintain backwards compatibility of our plugin with previous versions of React Native, but due to the nature of the platform, and the existence of breaking changes between releases, it is possible that you need to use a specific version of the Source Push plugin in order to support the exact version of React Native you are using. The following table outlines which Source Push plugin versions officially support the respective React Native versions:
49
49
 
50
- | React Native version(s) | Supporting CodePush version(s) |
50
+ | React Native version(s) | Supporting Source Push version(s) |
51
51
  |-------------------------|---------------------------------------------------------------------------------------------|
52
52
  | <v0.76 | Use [microsoft/code-push-react-native](https://github.com/microsoft/react-native-code-push) |
53
53
  | v0.76, v0.77, 0.78 | v1.0+ *(Support both New and Old Architectures)* |
@@ -56,7 +56,7 @@ We work hard to respond to new RN releases, but they do occasionally break us. W
56
56
 
57
57
  ### Supported Components
58
58
 
59
- When using the React Native assets system (i.e. using the `require("./foo.png")` syntax), the following list represents the set of core components (and props) that support having their referenced images and videos updated via CodePush:
59
+ When using the React Native assets system (i.e. using the `require("./foo.png")` syntax), the following list represents the set of core components (and props) that support having their referenced images and videos updated via Source Push:
60
60
 
61
61
  | Component | Prop(s) |
62
62
  |-------------------------------------------------|------------------------------------------|
@@ -67,16 +67,16 @@ When using the React Native assets system (i.e. using the `require("./foo.png")`
67
67
  | `ToolbarAndroid` <br />*(React Native 0.21.0+)* | `actions[].icon`, `logo`, `overflowIcon` |
68
68
  | `Video` | `source` |
69
69
 
70
- The following list represents the set of components (and props) that don't currently support their assets being updated via CodePush, due to their dependency on static images and videos (i.e. using the `{ uri: "foo" }` syntax):
70
+ The following list represents the set of components (and props) that don't currently support their assets being updated via Source Push, due to their dependency on static images and videos (i.e. using the `{ uri: "foo" }` syntax):
71
71
 
72
72
  | Component | Prop(s) |
73
73
  |-------------|----------------------------------------------------------------------|
74
74
  | `SliderIOS` | `maximumTrackImage`, `minimumTrackImage`, `thumbImage`, `trackImage` |
75
75
  | `Video` | `source` |
76
76
 
77
- As new core components are released, which support referencing assets, we'll update this list to ensure users know what exactly they can expect to update using CodePush.
77
+ As new core components are released, which support referencing assets, we'll update this list to ensure users know what exactly they can expect to update using Source Push.
78
78
 
79
- *Note: CodePush only works with Video components when using `require` in the source prop. For example:*
79
+ *Note: Source Push only works with Video components when using `require` in the source prop. For example:*
80
80
 
81
81
  ```javascript
82
82
  <Video source={require("./foo.mp4")} />
@@ -84,13 +84,13 @@ As new core components are released, which support referencing assets, we'll upd
84
84
 
85
85
  ## Getting Started
86
86
 
87
- After you've created an account on [Source Push](https://console.srcpush.com/register), you can start CodePush-ifying your React Native app by running the following command from within your app's root directory:
87
+ After you've created an account on [Source Push](https://console.srcpush.com/register), you can start Source Push-ifying your React Native app by running the following command from within your app's root directory:
88
88
 
89
89
  ```shell
90
90
  npm install --save @srcpush/react-native-code-push
91
91
  ```
92
92
 
93
- As with all other React Native plugins, the integration experience is different for iOS and Android, so perform the following setup steps depending on which platform(s) you are targeting. Note, if you are targeting both platforms it is recommended to create separate CodePush applications for each platform.
93
+ As with all other React Native plugins, the integration experience is different for iOS and Android, so perform the following setup steps depending on which platform(s) you are targeting. Note, if you are targeting both platforms it is recommended to create separate Source Push applications for each platform.
94
94
 
95
95
  *NOTE: This guide assumes you have used the `@react-native-community/cli init` command to initialize your React Native project.*
96
96
 
@@ -101,13 +101,13 @@ Then continue with installing the native module
101
101
 
102
102
  ## Plugin Usage
103
103
 
104
- With the CodePush plugin downloaded and linked, and your app asking CodePush where to get the right JS bundle from, the only thing left is to add the necessary code to your app to control the following policies:
104
+ With the Source Push plugin downloaded and linked, and your app asking Source Push where to get the right JS bundle from, the only thing left is to add the necessary code to your app to control the following policies:
105
105
 
106
106
  1. When (and how often) to check for an update? (for example app start, in response to clicking a button in a settings page, periodically at some fixed interval)
107
107
 
108
108
  2. When an update is available, how to present it to the end user?
109
109
 
110
- The simplest way to do this is to "CodePush-ify" your app's root component. To do so, you can choose one of the following two options:
110
+ The simplest way to do this is to "Source Push-ify" your app's root component. To do so, you can choose one of the following two options:
111
111
 
112
112
  * **Option 1: Wrap your root component with the `codePush` higher-order component:**
113
113
 
package/SECURITY.md CHANGED
@@ -1,20 +1,16 @@
1
- <!-- BEGIN MICROSOFT SECURITY.MD V0.0.5 BLOCK -->
2
-
3
1
  ## Security
4
2
 
5
- Microsoft takes the security of our software products and services seriously, which includes all source code repositories managed through our GitHub organizations, which include [Microsoft](https://github.com/Microsoft), [Azure](https://github.com/Azure), [DotNet](https://github.com/dotnet), [AspNet](https://github.com/aspnet), [Xamarin](https://github.com/xamarin), and [our GitHub organizations](https://opensource.microsoft.com/).
3
+ Source Push takes the security of our software products and services seriously.
6
4
 
7
- If you believe you have found a security vulnerability in any Microsoft-owned repository that meets [Microsoft's definition of a security vulnerability](https://docs.microsoft.com/en-us/previous-versions/tn-archive/cc751383(v=technet.10)), please report it to us as described below.
5
+ If you believe you have found a security vulnerability in this repository, please report it to us as described below.
8
6
 
9
7
  ## Reporting Security Issues
10
8
 
11
9
  **Please do not report security vulnerabilities through public GitHub issues.**
12
10
 
13
- Instead, please report them to the Microsoft Security Response Center (MSRC) at [https://msrc.microsoft.com/create-report](https://msrc.microsoft.com/create-report).
14
-
15
- If you prefer to submit without logging in, send email to [secure@microsoft.com](mailto:secure@microsoft.com). If possible, encrypt your message with our PGP key; please download it from the [Microsoft Security Response Center PGP Key page](https://www.microsoft.com/en-us/msrc/pgp-key-msrc).
11
+ Instead, please report them to us via email at [security@srcpush.com](mailto:security@srcpush.com).
16
12
 
17
- You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Additional information can be found at [microsoft.com/msrc](https://www.microsoft.com/msrc).
13
+ You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message.
18
14
 
19
15
  Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue:
20
16
 
@@ -27,15 +23,3 @@ Please include the requested information listed below (as much as you can provid
27
23
  * Impact of the issue, including how an attacker might exploit the issue
28
24
 
29
25
  This information will help us triage your report more quickly.
30
-
31
- If you are reporting for a bug bounty, more complete reports can contribute to a higher bounty award. Please visit our [Microsoft Bug Bounty Program](https://microsoft.com/msrc/bounty) page for more details about our active programs.
32
-
33
- ## Preferred Languages
34
-
35
- We prefer all communications to be in English.
36
-
37
- ## Policy
38
-
39
- Microsoft follows the principle of [Coordinated Vulnerability Disclosure](https://www.microsoft.com/en-us/msrc/cvd).
40
-
41
- <!-- END MICROSOFT SECURITY.MD BLOCK -->
@@ -1,5 +1,9 @@
1
1
  apply plugin: "com.android.library"
2
2
 
3
+ def safeExtGet(prop, fallback) {
4
+ return rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
5
+ }
6
+
3
7
  def isNewArchitectureEnabled() {
4
8
  // To opt-in for the New Architecture, you can either:
5
9
  // - Set `newArchEnabled` to true inside the `gradle.properties` file
@@ -22,37 +26,39 @@ def DEFAULT_MIN_SDK_VERSION = 16
22
26
  android {
23
27
  namespace "com.microsoft.codepush.react"
24
28
 
25
- compileSdkVersion rootProject.hasProperty('compileSdkVersion') ? rootProject.compileSdkVersion : DEFAULT_COMPILE_SDK_VERSION
26
- buildToolsVersion rootProject.hasProperty('buildToolsVersion') ? rootProject.buildToolsVersion : DEFAULT_BUILD_TOOLS_VERSION
29
+ compileSdkVersion safeExtGet("compileSdkVersion", DEFAULT_COMPILE_SDK_VERSION)
30
+ buildToolsVersion safeExtGet("buildToolsVersion", DEFAULT_BUILD_TOOLS_VERSION)
31
+
32
+ buildFeatures {
33
+ buildConfig true
34
+ }
27
35
 
28
36
  defaultConfig {
29
- minSdkVersion rootProject.hasProperty('minSdkVersion') ? rootProject.minSdkVersion : DEFAULT_MIN_SDK_VERSION
30
- targetSdkVersion rootProject.hasProperty('targetSdkVersion') ? rootProject.targetSdkVersion : DEFAULT_TARGET_SDK_VERSION
37
+ minSdkVersion safeExtGet("minSdkVersion", DEFAULT_MIN_SDK_VERSION)
38
+ targetSdkVersion safeExtGet("targetSdkVersion", DEFAULT_TARGET_SDK_VERSION)
31
39
  versionCode 1
32
40
  versionName "1.0"
33
41
  buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", IS_NEW_ARCHITECTURE_ENABLED.toString()
34
- }
35
-
36
- lintOptions {
37
- abortOnError false
38
- }
39
-
40
- defaultConfig {
41
42
  consumerProguardFiles 'proguard-rules.pro'
42
43
  }
43
44
 
44
45
  sourceSets {
45
46
  main {
46
47
  if (IS_NEW_ARCHITECTURE_ENABLED) {
47
- java.srcDirs += ['src/newarch/java']
48
+ java.srcDirs += ["src/newarch/java"]
49
+ java.srcDirs += ["$buildDir/generated/source/codegen/java"]
48
50
  } else {
49
- java.srcDirs += ['src/oldarch/java']
51
+ java.srcDirs += ["src/oldarch/java"]
50
52
  }
51
53
  }
52
54
  }
55
+
56
+ lintOptions {
57
+ abortOnError false
58
+ }
53
59
  }
54
60
 
55
61
  dependencies {
56
- implementation "com.facebook.react:react-native:+"
62
+ implementation("com.facebook.react:react-android")
57
63
  implementation 'com.nimbusds:nimbus-jose-jwt:9.37.3'
58
64
  }
@@ -7,10 +7,12 @@ import android.content.res.Resources;
7
7
 
8
8
  import com.facebook.react.ReactHost;
9
9
  import com.facebook.react.ReactInstanceManager;
10
- import com.facebook.react.ReactPackage;
10
+ import com.facebook.react.BaseReactPackage;
11
11
  import com.facebook.react.bridge.JavaScriptModule;
12
12
  import com.facebook.react.bridge.NativeModule;
13
13
  import com.facebook.react.bridge.ReactApplicationContext;
14
+ import com.facebook.react.module.model.ReactModuleInfo;
15
+ import com.facebook.react.module.model.ReactModuleInfoProvider;
14
16
  import com.facebook.react.uimanager.ViewManager;
15
17
 
16
18
  import org.json.JSONException;
@@ -18,9 +20,11 @@ import org.json.JSONObject;
18
20
 
19
21
  import java.io.File;
20
22
  import java.util.ArrayList;
23
+ import java.util.HashMap;
21
24
  import java.util.List;
25
+ import java.util.Map;
22
26
 
23
- public class CodePush implements ReactPackage {
27
+ public class CodePush extends BaseReactPackage {
24
28
  private static final Object LOCK = new Object();
25
29
  private static volatile CodePush mCurrentInstance;
26
30
  public static CodePush getInstance(String deploymentKey, Context context, boolean isDebugMode) {
@@ -422,14 +426,14 @@ public class CodePush implements ReactPackage {
422
426
  }
423
427
 
424
428
  @Override
425
- public List<NativeModule> createNativeModules(ReactApplicationContext reactApplicationContext) {
426
- CodePushNativeModule codePushModule = new CodePushNativeModule(reactApplicationContext, this, mUpdateManager, mTelemetryManager, mSettingsManager);
427
- CodePushDialog dialogModule = new CodePushDialog(reactApplicationContext);
428
-
429
- List<NativeModule> nativeModules = new ArrayList<>();
430
- nativeModules.add(codePushModule);
431
- nativeModules.add(dialogModule);
432
- return nativeModules;
429
+ public NativeModule getModule(String name, ReactApplicationContext reactApplicationContext) {
430
+ if (CodePushNativeModule.NAME.equals(name)) {
431
+ return new CodePushNativeModule(reactApplicationContext, this, mUpdateManager, mTelemetryManager, mSettingsManager);
432
+ }
433
+ if (CodePushDialog.NAME.equals(name)) {
434
+ return new CodePushDialog(reactApplicationContext);
435
+ }
436
+ return null;
433
437
  }
434
438
 
435
439
  // Deprecated in RN v0.47.
@@ -441,4 +445,42 @@ public class CodePush implements ReactPackage {
441
445
  public List<ViewManager> createViewManagers(ReactApplicationContext reactApplicationContext) {
442
446
  return new ArrayList<>();
443
447
  }
448
+
449
+ @Override
450
+ public ReactModuleInfoProvider getReactModuleInfoProvider() {
451
+ return new ReactModuleInfoProvider() {
452
+ @Override
453
+ public Map<String, ReactModuleInfo> getReactModuleInfos() {
454
+ boolean isTurboModule = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED;
455
+
456
+ Map<String, ReactModuleInfo> map = new HashMap<>();
457
+ map.put(
458
+ CodePushNativeModule.NAME,
459
+ new ReactModuleInfo(
460
+ CodePushNativeModule.NAME,
461
+ CodePushNativeModule.NAME,
462
+ false,
463
+ false,
464
+ true,
465
+ false,
466
+ isTurboModule
467
+ )
468
+ );
469
+ map.put(
470
+ CodePushDialog.NAME,
471
+ new ReactModuleInfo(
472
+ CodePushDialog.NAME,
473
+ CodePushDialog.NAME,
474
+ false,
475
+ false,
476
+ false,
477
+ false,
478
+ isTurboModule
479
+ )
480
+ );
481
+
482
+ return map;
483
+ }
484
+ };
485
+ }
444
486
  }
@@ -4,43 +4,43 @@ import android.app.Activity;
4
4
  import android.app.AlertDialog;
5
5
  import android.content.DialogInterface;
6
6
 
7
- import com.facebook.react.bridge.BaseJavaModule;
8
7
  import com.facebook.react.bridge.Callback;
9
8
  import com.facebook.react.bridge.LifecycleEventListener;
10
9
  import com.facebook.react.bridge.ReactApplicationContext;
11
- import com.facebook.react.bridge.ReactMethod;
12
10
 
13
- public class CodePushDialog extends BaseJavaModule {
11
+ final class CodePushDialogImpl {
12
+ private final ReactApplicationContext reactContext;
14
13
 
15
- public CodePushDialog(ReactApplicationContext reactContext) {
16
- super(reactContext);
14
+ CodePushDialogImpl(ReactApplicationContext reactContext) {
15
+ this.reactContext = reactContext;
17
16
  }
18
17
 
19
- @ReactMethod
20
- public void showDialog(final String title, final String message, final String button1Text,
21
- final String button2Text, final Callback successCallback, Callback errorCallback) {
22
- Activity currentActivity = getReactApplicationContext().getCurrentActivity();
18
+ void showDialog(
19
+ final String title,
20
+ final String message,
21
+ final String button1Text,
22
+ final String button2Text,
23
+ final Callback successCallback,
24
+ final Callback errorCallback
25
+ ) {
26
+ Activity currentActivity = reactContext.getCurrentActivity();
23
27
  if (currentActivity == null || currentActivity.isFinishing()) {
24
- // If getCurrentActivity is null, it could be because the app is backgrounded,
25
- // so we show the dialog when the app resumes)
26
- getReactApplicationContext().addLifecycleEventListener(new LifecycleEventListener() {
28
+ reactContext.addLifecycleEventListener(new LifecycleEventListener() {
27
29
  @Override
28
30
  public void onHostResume() {
29
- Activity currentActivity = getReactApplicationContext().getCurrentActivity();
30
- if (currentActivity != null) {
31
- getReactApplicationContext().removeLifecycleEventListener(this);
32
- showDialogInternal(title, message, button1Text, button2Text, successCallback, currentActivity);
31
+ Activity resumedActivity = reactContext.getCurrentActivity();
32
+ if (resumedActivity != null && !resumedActivity.isFinishing()) {
33
+ reactContext.removeLifecycleEventListener(this);
34
+ showDialogInternal(title, message, button1Text, button2Text, successCallback, resumedActivity);
33
35
  }
34
36
  }
35
37
 
36
38
  @Override
37
39
  public void onHostPause() {
38
-
39
40
  }
40
41
 
41
42
  @Override
42
43
  public void onHostDestroy() {
43
-
44
44
  }
45
45
  });
46
46
  } else {
@@ -48,10 +48,15 @@ public class CodePushDialog extends BaseJavaModule {
48
48
  }
49
49
  }
50
50
 
51
- private void showDialogInternal(String title, String message, String button1Text,
52
- String button2Text, final Callback successCallback, Activity currentActivity) {
51
+ private void showDialogInternal(
52
+ String title,
53
+ String message,
54
+ String button1Text,
55
+ String button2Text,
56
+ final Callback successCallback,
57
+ Activity currentActivity
58
+ ) {
53
59
  AlertDialog.Builder builder = new AlertDialog.Builder(currentActivity);
54
-
55
60
  builder.setCancelable(false);
56
61
 
57
62
  DialogInterface.OnClickListener clickListener = new DialogInterface.OnClickListener() {
@@ -61,10 +66,10 @@ public class CodePushDialog extends BaseJavaModule {
61
66
  dialog.cancel();
62
67
  switch (which) {
63
68
  case DialogInterface.BUTTON_POSITIVE:
64
- successCallback.invoke(0);
69
+ if (successCallback != null) successCallback.invoke(0);
65
70
  break;
66
71
  case DialogInterface.BUTTON_NEGATIVE:
67
- successCallback.invoke(1);
72
+ if (successCallback != null) successCallback.invoke(1);
68
73
  break;
69
74
  default:
70
75
  throw new CodePushUnknownException("Unknown button ID pressed.");
@@ -94,9 +99,4 @@ public class CodePushDialog extends BaseJavaModule {
94
99
  AlertDialog dialog = builder.create();
95
100
  dialog.show();
96
101
  }
97
-
98
- @Override
99
- public String getName() {
100
- return "CodePushDialog";
101
- }
102
102
  }