@appzung/react-native-code-push 6.4.2 → 7.1.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/CodePush.js +6 -7
- package/CodePush.podspec +1 -1
- package/README.md +5 -4
- package/SECURITY.md +41 -0
- package/android/app/src/main/java/com/microsoft/codepush/react/CodePushNativeModule.java +10 -0
- package/android/app/src/main/java/com/microsoft/codepush/react/FileUtils.java +8 -9
- package/android/codepush.gradle +11 -8
- package/docs/setup-windows.md +36 -3
- package/ios/CodePush/CodePushUpdateUtils.m +1 -1
- package/ios/CodePush.xcodeproj/project.pbxproj +2 -2
- package/package.json +11 -11
- package/windows/CodePush/CodePush.def +3 -0
- package/windows/CodePush/CodePush.vcxproj +199 -0
- package/windows/CodePush/CodePush.vcxproj.filters +91 -0
- package/windows/CodePush/CodePushConfig.cpp +104 -0
- package/windows/CodePush/CodePushConfig.h +66 -0
- package/windows/CodePush/CodePushConfig.idl +12 -0
- package/windows/CodePush/CodePushDownloadHandler.cpp +73 -0
- package/windows/CodePush/CodePushDownloadHandler.h +32 -0
- package/windows/CodePush/CodePushNativeModule.cpp +934 -0
- package/windows/CodePush/CodePushNativeModule.h +247 -0
- package/windows/CodePush/CodePushPackage.cpp +456 -0
- package/windows/CodePush/CodePushPackage.h +49 -0
- package/windows/CodePush/CodePushTelemetryManager.cpp +213 -0
- package/windows/CodePush/CodePushTelemetryManager.h +29 -0
- package/windows/CodePush/CodePushUpdateUtils.cpp +86 -0
- package/windows/CodePush/CodePushUpdateUtils.h +38 -0
- package/windows/CodePush/CodePushUtils.cpp +29 -0
- package/windows/CodePush/CodePushUtils.h +18 -0
- package/windows/CodePush/FileUtils.cpp +131 -0
- package/windows/CodePush/FileUtils.h +28 -0
- package/windows/CodePush/PropertySheet.props +16 -0
- package/windows/CodePush/ReactPackageProvider.cpp +15 -0
- package/windows/CodePush/ReactPackageProvider.h +22 -0
- package/windows/CodePush/ReactPackageProvider.idl +9 -0
- package/windows/CodePush/miniz/LICENSE +22 -0
- package/windows/CodePush/miniz/miniz.c +7657 -0
- package/windows/CodePush/miniz/miniz.h +1338 -0
- package/windows/CodePush/miniz/readme.md +37 -0
- package/windows/CodePush/packages.config +4 -0
- package/windows/CodePush/pch.cpp +1 -0
- package/windows/CodePush/pch.h +4 -0
- package/{windows → windows-legacy}/CodePush/CodePush.csproj +1 -1
- package/{windows → windows-legacy}/CodePush.Net46/packages.config +1 -1
- package/windows-legacy/CodePush.Net46.Test/ApplicationDataContainerTest.cs +105 -0
- package/windows-legacy/CodePush.Net46.Test/CodePush.Net46.Test.csproj +137 -0
- package/windows-legacy/CodePush.Net46.Test/Properties/AssemblyInfo.cs +36 -0
- package/windows-legacy/CodePush.Net46.Test/TelemetryManagerTest.cs +117 -0
- package/windows-legacy/CodePush.Net46.Test/app.config +11 -0
- package/windows-legacy/CodePush.Net46.Test/packages.config +4 -0
- /package/{windows → windows-legacy}/CodePush/CodePushUtils.cs +0 -0
- /package/{windows → windows-legacy}/CodePush/FileUtils.cs +0 -0
- /package/{windows → windows-legacy}/CodePush/Properties/AssemblyInfo.cs +0 -0
- /package/{windows → windows-legacy}/CodePush/Properties/CodePush.rd.xml +0 -0
- /package/{windows → windows-legacy}/CodePush/UpdateManager.cs +0 -0
- /package/{windows → windows-legacy}/CodePush/UpdateUtils.cs +0 -0
- /package/{windows → windows-legacy}/CodePush.Net46/Adapters/Http/HttpProgress.cs +0 -0
- /package/{windows → windows-legacy}/CodePush.Net46/Adapters/Storage/ApplicationDataContainer.cs +0 -0
- /package/{windows → windows-legacy}/CodePush.Net46/CodePush.Net46.csproj +0 -0
- /package/{windows → windows-legacy}/CodePush.Net46/CodePushUtils.cs +0 -0
- /package/{windows → windows-legacy}/CodePush.Net46/FileUtils.cs +0 -0
- /package/{windows → windows-legacy}/CodePush.Net46/Properties/AssemblyInfo.cs +0 -0
- /package/{windows → windows-legacy}/CodePush.Net46/UpdateManager.cs +0 -0
- /package/{windows → windows-legacy}/CodePush.Net46/UpdateUtils.cs +0 -0
- /package/{windows → windows-legacy}/CodePush.Shared/CodePush.Shared.projitems +0 -0
- /package/{windows → windows-legacy}/CodePush.Shared/CodePush.Shared.shproj +0 -0
- /package/{windows → windows-legacy}/CodePush.Shared/CodePushConstants.cs +0 -0
- /package/{windows → windows-legacy}/CodePush.Shared/CodePushNativeModule.cs +0 -0
- /package/{windows → windows-legacy}/CodePush.Shared/CodePushReactPackage.cs +0 -0
- /package/{windows → windows-legacy}/CodePush.Shared/CodePushUtils.cs +0 -0
- /package/{windows → windows-legacy}/CodePush.Shared/InstallMode.cs +0 -0
- /package/{windows → windows-legacy}/CodePush.Shared/MinimumBackgroundListener.cs +0 -0
- /package/{windows → windows-legacy}/CodePush.Shared/SettingsManager.cs +0 -0
- /package/{windows → windows-legacy}/CodePush.Shared/TelemetryManager.cs +0 -0
- /package/{windows → windows-legacy}/CodePush.Shared/UpdateState.cs +0 -0
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
// Copyright (c) Microsoft Corporation.
|
|
2
|
+
// Licensed under the MIT License.
|
|
3
|
+
|
|
4
|
+
#pragma once
|
|
5
|
+
|
|
6
|
+
#include "NativeModules.h"
|
|
7
|
+
#include "winrt/Windows.Data.Json.h"
|
|
8
|
+
#include "winrt/Windows.Storage.h"
|
|
9
|
+
|
|
10
|
+
#include "CodePushConfig.h"
|
|
11
|
+
|
|
12
|
+
// Helper functions for reading and sending JsonValues to and from JavaScript
|
|
13
|
+
namespace winrt::Microsoft::ReactNative
|
|
14
|
+
{
|
|
15
|
+
void ReadValue(IJSValueReader const& reader, /*out*/ Windows::Data::Json::JsonObject& value) noexcept;
|
|
16
|
+
void ReadValue(IJSValueReader const& reader, /*out*/ Windows::Data::Json::IJsonValue& value) noexcept;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
namespace Microsoft::CodePush::ReactNative
|
|
20
|
+
{
|
|
21
|
+
REACT_MODULE(CodePushNativeModule, L"CodePush");
|
|
22
|
+
struct CodePushNativeModule
|
|
23
|
+
{
|
|
24
|
+
enum class CodePushInstallMode
|
|
25
|
+
{
|
|
26
|
+
Immediate = 0,
|
|
27
|
+
OnNextRestart = 1,
|
|
28
|
+
OnNextResume = 2,
|
|
29
|
+
OnNextSuspend = 3
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
enum class CodePushUpdateState
|
|
33
|
+
{
|
|
34
|
+
Running = 0,
|
|
35
|
+
Pending = 1,
|
|
36
|
+
Latest = 2
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
static winrt::Windows::Foundation::IAsyncAction LoadBundle();
|
|
40
|
+
static void SetHost(const winrt::Microsoft::ReactNative::ReactNativeHost& host);
|
|
41
|
+
|
|
42
|
+
static winrt::Windows::Foundation::IAsyncOperation<winrt::Windows::Storage::StorageFile> GetBinaryBundleAsync();
|
|
43
|
+
static winrt::Windows::Foundation::IAsyncOperation<winrt::Windows::Storage::StorageFile> GetBundleFileAsync();
|
|
44
|
+
|
|
45
|
+
static winrt::Windows::Foundation::IAsyncOperation<winrt::Windows::Storage::StorageFolder> GetBundleAssetsFolderAsync();
|
|
46
|
+
static winrt::Windows::Storage::StorageFolder GetLocalStorageFolder();
|
|
47
|
+
static winrt::Windows::Storage::ApplicationDataContainer GetLocalSettings();
|
|
48
|
+
|
|
49
|
+
void OverrideAppVersion(std::wstring_view appVersion);
|
|
50
|
+
void SetDeploymentKey(std::wstring_view deploymentKey);
|
|
51
|
+
|
|
52
|
+
bool IsFailedHash(std::wstring_view packageHash);
|
|
53
|
+
|
|
54
|
+
winrt::Windows::Data::Json::JsonObject GetRollbackInfo();
|
|
55
|
+
int GetRollbackCountForPackage(
|
|
56
|
+
std::wstring_view packageHash,
|
|
57
|
+
const winrt::Windows::Data::Json::JsonObject& latestRollbackInfo);
|
|
58
|
+
|
|
59
|
+
static bool IsPendingUpdate(std::wstring_view packageHash);
|
|
60
|
+
|
|
61
|
+
winrt::Windows::Foundation::IAsyncAction ClearDebugUpdates();
|
|
62
|
+
|
|
63
|
+
REACT_INIT(Initialize);
|
|
64
|
+
void Initialize(winrt::Microsoft::ReactNative::ReactContext const& reactContext) noexcept;
|
|
65
|
+
|
|
66
|
+
REACT_CONSTANT_PROVIDER(GetConstants);
|
|
67
|
+
void GetConstants(winrt::Microsoft::ReactNative::ReactConstantProvider& constants) noexcept;
|
|
68
|
+
|
|
69
|
+
/*
|
|
70
|
+
* This is native-side of the JavaScript RemotePackage.download method
|
|
71
|
+
*/
|
|
72
|
+
REACT_METHOD(DownloadUpdateAsync, L"downloadUpdate");
|
|
73
|
+
winrt::fire_and_forget DownloadUpdateAsync(
|
|
74
|
+
winrt::Windows::Data::Json::JsonObject updatePackage,
|
|
75
|
+
bool notifyProgress,
|
|
76
|
+
winrt::Microsoft::ReactNative::ReactPromise<winrt::Windows::Data::Json::IJsonValue> promise) noexcept;
|
|
77
|
+
|
|
78
|
+
/*
|
|
79
|
+
* This is the native side of the CodePush.getConfiguration method. It isn't
|
|
80
|
+
* currently exposed via the "react-native-code-push" module, and is used
|
|
81
|
+
* internally only by the CodePush.checkForUpdate method in order to get the
|
|
82
|
+
* app version, as well as the deployment key that was configured in the Info.plist file.
|
|
83
|
+
*/
|
|
84
|
+
REACT_METHOD(GetConfiguration, L"getConfiguration");
|
|
85
|
+
winrt::fire_and_forget GetConfiguration(winrt::Microsoft::ReactNative::ReactPromise<winrt::Windows::Data::Json::IJsonValue> promise) noexcept;
|
|
86
|
+
|
|
87
|
+
/*
|
|
88
|
+
* This method is the native side of the CodePush.getUpdateMetadata method.
|
|
89
|
+
*/
|
|
90
|
+
REACT_METHOD(GetUpdateMetadataAsync, L"getUpdateMetadata");
|
|
91
|
+
winrt::fire_and_forget GetUpdateMetadataAsync(
|
|
92
|
+
CodePushUpdateState updateState,
|
|
93
|
+
winrt::Microsoft::ReactNative::ReactPromise<winrt::Windows::Data::Json::IJsonValue> promise) noexcept;
|
|
94
|
+
|
|
95
|
+
/*
|
|
96
|
+
* This method is the native side of the LocalPackage.install method.
|
|
97
|
+
*/
|
|
98
|
+
REACT_METHOD(InstallUpdateAsync, L"installUpdate");
|
|
99
|
+
winrt::fire_and_forget InstallUpdateAsync(
|
|
100
|
+
winrt::Windows::Data::Json::JsonObject updatePackage,
|
|
101
|
+
CodePushInstallMode installMode,
|
|
102
|
+
int minimumBackgroundDuration,
|
|
103
|
+
winrt::Microsoft::ReactNative::ReactPromise<void> promise) noexcept;
|
|
104
|
+
|
|
105
|
+
/*
|
|
106
|
+
* This method isn't publicly exposed via the "react-native-code-push"
|
|
107
|
+
* module, and is only used internally to populate the RemotePackage.failedInstall property.
|
|
108
|
+
*/
|
|
109
|
+
REACT_METHOD(IsFailedUpdate, L"isFailedUpdate");
|
|
110
|
+
void IsFailedUpdate(
|
|
111
|
+
std::wstring packageHash,
|
|
112
|
+
winrt::Microsoft::ReactNative::ReactPromise<bool> promise) noexcept;
|
|
113
|
+
|
|
114
|
+
REACT_METHOD(SetLatestRollbackInfo, L"setLatestRollbackInfo");
|
|
115
|
+
void SetLatestRollbackInfo(std::wstring packageHash) noexcept;
|
|
116
|
+
|
|
117
|
+
REACT_METHOD(GetLatestRollbackInfo, L"getLatestRollbackInfo");
|
|
118
|
+
void GetLatestRollbackInfo(winrt::Microsoft::ReactNative::ReactPromise<winrt::Windows::Data::Json::IJsonValue> promise) noexcept;
|
|
119
|
+
|
|
120
|
+
/*
|
|
121
|
+
* This method isn't publicly exposed via the "react-native-code-push"
|
|
122
|
+
* module, and is only used internally to populate the LocalPackage.isFirstRun property.
|
|
123
|
+
*/
|
|
124
|
+
REACT_METHOD(IsFirstRun, L"isFirstRun");
|
|
125
|
+
winrt::fire_and_forget IsFirstRun(
|
|
126
|
+
std::wstring packageHash,
|
|
127
|
+
winrt::Microsoft::ReactNative::ReactPromise<bool> promise) noexcept;
|
|
128
|
+
|
|
129
|
+
/*
|
|
130
|
+
* This method is the native side of the CodePush.notifyApplicationReady() method.
|
|
131
|
+
*/
|
|
132
|
+
REACT_METHOD(NotifyApplicationReady, L"notifyApplicationReady");
|
|
133
|
+
void NotifyApplicationReady(winrt::Microsoft::ReactNative::ReactPromise<winrt::Windows::Data::Json::IJsonValue> promise) noexcept;
|
|
134
|
+
|
|
135
|
+
REACT_METHOD(Allow, L"allow");
|
|
136
|
+
void Allow(winrt::Microsoft::ReactNative::ReactPromise<winrt::Microsoft::ReactNative::JSValue> promise) noexcept;
|
|
137
|
+
|
|
138
|
+
REACT_METHOD(ClearPendingRestart, L"clearPendingRestart");
|
|
139
|
+
void ClearPendingRestart() noexcept;
|
|
140
|
+
|
|
141
|
+
REACT_METHOD(Disallow, L"disallow");
|
|
142
|
+
void Disallow(winrt::Microsoft::ReactNative::ReactPromise<winrt::Microsoft::ReactNative::JSValue> promise) noexcept;
|
|
143
|
+
|
|
144
|
+
/*
|
|
145
|
+
* This method is the native side of the CodePush.restartApp() method.
|
|
146
|
+
*/
|
|
147
|
+
REACT_METHOD(RestartApp, L"restartApp");
|
|
148
|
+
winrt::fire_and_forget RestartApp(
|
|
149
|
+
bool onlyIfUpdateIsPending,
|
|
150
|
+
winrt::Microsoft::ReactNative::ReactPromise<winrt::Microsoft::ReactNative::JSValue> promise) noexcept;
|
|
151
|
+
|
|
152
|
+
/*
|
|
153
|
+
* This method clears CodePush's downloaded updates.
|
|
154
|
+
* It is needed to switch to a different deployment if the current deployment is more recent.
|
|
155
|
+
* Note: we don�t recommend to use this method in scenarios other than that (CodePush will call this method
|
|
156
|
+
* automatically when needed in other cases) as it could lead to unpredictable behavior.
|
|
157
|
+
*/
|
|
158
|
+
REACT_METHOD(ClearUpdates, L"clearUpdates");
|
|
159
|
+
winrt::fire_and_forget ClearUpdates() noexcept;
|
|
160
|
+
|
|
161
|
+
/*
|
|
162
|
+
* This method is the native side of the CodePush.downloadAndReplaceCurrentBundle()
|
|
163
|
+
* method, which replaces the current bundle with the one downloaded from
|
|
164
|
+
* removeBundleUrl. It is only to be used during tests and no-ops if the test
|
|
165
|
+
* configuration flag is not set.
|
|
166
|
+
*/
|
|
167
|
+
REACT_METHOD(DownloadAndReplaceCurrentBundle, L"downloadAndReplaceCurrentBundle");
|
|
168
|
+
winrt::fire_and_forget DownloadAndReplaceCurrentBundle(std::wstring remoteBundleUrl) noexcept;
|
|
169
|
+
|
|
170
|
+
/*
|
|
171
|
+
* This method is checks if a new status update exists (new version was installed,
|
|
172
|
+
* or an update failed) and return its details (version label, status).
|
|
173
|
+
*/
|
|
174
|
+
REACT_METHOD(GetNewStatusReportAsync, L"getNewStatusReport");
|
|
175
|
+
winrt::fire_and_forget GetNewStatusReportAsync(winrt::Microsoft::ReactNative::ReactPromise<winrt::Windows::Data::Json::IJsonValue> promise) noexcept;
|
|
176
|
+
|
|
177
|
+
REACT_METHOD(RecordStatusReported, L"recordStatusReported");
|
|
178
|
+
void RecordStatusReported(winrt::Windows::Data::Json::JsonObject statusReport) noexcept;
|
|
179
|
+
|
|
180
|
+
REACT_METHOD(SaveStatusReportForRetry, L"saveStatusReportForRetry");
|
|
181
|
+
void SaveStatusReportForRetry(winrt::Windows::Data::Json::JsonObject statusReport) noexcept;
|
|
182
|
+
|
|
183
|
+
private:
|
|
184
|
+
bool m_isFirstRunAfterUpdate{ false };
|
|
185
|
+
static CodePushInstallMode s_installMode;
|
|
186
|
+
|
|
187
|
+
// Used to coordinate the dispatching of download progress events to JS.
|
|
188
|
+
uint64_t m_latestExpectedContentLength{ 0 };
|
|
189
|
+
uint64_t m_latestReceivedContentLength{ 0 };
|
|
190
|
+
bool m_didUpdateProgress{ false };
|
|
191
|
+
|
|
192
|
+
bool m_allowed{ true };
|
|
193
|
+
bool m_restartInProgress{ false };
|
|
194
|
+
std::vector<uint8_t> m_restartQueue;
|
|
195
|
+
|
|
196
|
+
static constexpr std::wstring_view BundleExtension{ L".bundle" };
|
|
197
|
+
static winrt::hstring s_javaScriptBundleFileName;
|
|
198
|
+
|
|
199
|
+
// These constants represent emitted events
|
|
200
|
+
static constexpr std::wstring_view DownloadProgressEvent{ L"CodePushDownloadProgress" };
|
|
201
|
+
|
|
202
|
+
// These constants represent valid deployment statuses
|
|
203
|
+
static constexpr std::wstring_view DeploymentFailed{ L"DeploymentFailed" };
|
|
204
|
+
static constexpr std::wstring_view DeploymentSucceeded{ L"DeploymentSucceeded" };
|
|
205
|
+
|
|
206
|
+
// These keys represent the names we use to store data in LocalSettings
|
|
207
|
+
static constexpr std::wstring_view FailedUpdatesKey{ L"CODE_PUSH_FAILED_UPDATES" };
|
|
208
|
+
static constexpr std::wstring_view PendingUpdateKey{ L"CODE_PUSH_PENDING_UPDATE" };
|
|
209
|
+
|
|
210
|
+
// These keys are already "namespaced" by the PendingUpdateKey, so
|
|
211
|
+
// their values don't need to be obfuscated to prevent collision with app data
|
|
212
|
+
static constexpr std::wstring_view PendingUpdateHashKey{ L"hash" };
|
|
213
|
+
static constexpr std::wstring_view PendingUpdateIsLoadingKey{ L"isLoading" };
|
|
214
|
+
|
|
215
|
+
// These keys are used to inspect/augment the metadata
|
|
216
|
+
// that is associated with an update's package.
|
|
217
|
+
static constexpr std::wstring_view AppVersionKey{ L"appVersion" };
|
|
218
|
+
static constexpr std::wstring_view BinaryBundleDateKey{ L"binaryDate" }; // The date of the BUILD -> the modified date of the executable
|
|
219
|
+
static constexpr std::wstring_view PackageHashKey{ L"packageHash" };
|
|
220
|
+
static constexpr std::wstring_view PackageIsPendingKey{ L"isPending" };
|
|
221
|
+
|
|
222
|
+
static bool isRunningBinaryVersion;
|
|
223
|
+
static bool needToReportRollback;
|
|
224
|
+
|
|
225
|
+
static winrt::Microsoft::ReactNative::ReactNativeHost s_host;
|
|
226
|
+
winrt::Microsoft::ReactNative::ReactContext m_context;
|
|
227
|
+
|
|
228
|
+
// These keys represent the names we use to store information about the latest rollback
|
|
229
|
+
static constexpr std::wstring_view LatestRollbackInfoKey{ L"LATEST_ROLLBACK_INFO" };
|
|
230
|
+
static constexpr std::wstring_view LatestRollbackPackageHashKey{ L"packageHash" };
|
|
231
|
+
static constexpr std::wstring_view LatestRollbackTimeKey{ L"time" };
|
|
232
|
+
static constexpr std::wstring_view LatestRollbackCountKey{ L"count" };
|
|
233
|
+
|
|
234
|
+
// Bool that keeps track of whether the app has been initialized at least once.
|
|
235
|
+
static bool s_initialized;
|
|
236
|
+
|
|
237
|
+
static winrt::Windows::Foundation::IAsyncAction ClearUpdatesStaticAsync();
|
|
238
|
+
void DispatchDownloadProgressEvent();
|
|
239
|
+
winrt::Windows::Foundation::IAsyncAction InitializeUpdateAfterRestart();
|
|
240
|
+
winrt::Windows::Foundation::IAsyncAction RollbackPackage();
|
|
241
|
+
static void RemoveFailedUpdates();
|
|
242
|
+
static void RemovePendingUpdate();
|
|
243
|
+
winrt::Windows::Foundation::IAsyncAction RestartAppInternal(bool onlyIfUpdateIsPending);
|
|
244
|
+
void SaveFailedUpdate(winrt::Windows::Data::Json::JsonObject& failedPackage);
|
|
245
|
+
void SavePendingUpdate(std::wstring_view packageHash, bool isLoading);
|
|
246
|
+
};
|
|
247
|
+
}
|