@srcpush/react-native-code-push 1.0.1 → 1.0.3-beta

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.
@@ -24,12 +24,12 @@ import com.facebook.react.bridge.ReadableMap;
24
24
  import com.facebook.react.bridge.WritableMap;
25
25
  import com.facebook.react.common.annotations.UnstableReactNativeAPI;
26
26
  import com.facebook.react.devsupport.interfaces.DevSupportManager;
27
- import com.facebook.react.modules.core.ChoreographerCompat;
28
27
  import com.facebook.react.modules.core.DeviceEventManagerModule;
29
28
  import com.facebook.react.modules.core.ReactChoreographer;
30
29
  import com.facebook.react.modules.debug.interfaces.DeveloperSettings;
31
30
  import com.facebook.react.runtime.ReactHostDelegate;
32
31
  import com.facebook.react.runtime.ReactHostImpl;
32
+ import android.view.Choreographer;
33
33
 
34
34
  import org.json.JSONArray;
35
35
  import org.json.JSONException;
@@ -440,7 +440,7 @@ public class CodePushNativeModule extends BaseJavaModule {
440
440
  getReactApplicationContext().runOnUiQueueThread(new Runnable() {
441
441
  @Override
442
442
  public void run() {
443
- ReactChoreographer.getInstance().postFrameCallback(ReactChoreographer.CallbackType.TIMERS_EVENTS, new ChoreographerCompat.FrameCallback() {
443
+ ReactChoreographer.getInstance().postFrameCallback(ReactChoreographer.CallbackType.TIMERS_EVENTS, new Choreographer.FrameCallback() {
444
444
  @Override
445
445
  public void doFrame(long frameTimeNanos) {
446
446
  if (!latestDownloadProgress.isCompleted()) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@srcpush/react-native-code-push",
3
- "version": "1.0.1",
3
+ "version": "1.0.3-beta",
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",
@@ -59,9 +59,9 @@
59
59
  "body-parser": "latest",
60
60
  "code-push-plugin-testing-framework": "file:./code-push-plugin-testing-framework",
61
61
  "del": "v6.0.0",
62
- "express": "latest",
62
+ "express": "^5.1.0",
63
63
  "mkdirp": "latest",
64
- "mocha": "^9.2.0",
64
+ "mocha": "^11.7.2",
65
65
  "q": "^1.5.1",
66
66
  "run-sequence": "latest",
67
67
  "shx": "^0.3.4",
@@ -83,4 +83,4 @@
83
83
  "postunlink": "node node_modules/@srcpush/react-native-code-push/scripts/postunlink/run"
84
84
  }
85
85
  }
86
- }
86
+ }
@@ -31,34 +31,34 @@ namespace Microsoft::CodePush::ReactNative
31
31
 
32
32
  ReactNativeHost CodePushNativeModule::s_host{};
33
33
  CodePushNativeModule::CodePushInstallMode CodePushNativeModule::s_installMode{};
34
- bool CodePushNativeModule::isRunningBinaryVersion{ false };
35
- bool CodePushNativeModule::needToReportRollback{ false };
36
- /*static*/ bool CodePushNativeModule::s_initialized{ false };
37
- /*static*/ hstring CodePushNativeModule::s_javaScriptBundleFileName{ L"index.windows" };
34
+ bool CodePushNativeModule::isRunningBinaryVersion{false};
35
+ bool CodePushNativeModule::needToReportRollback{false};
36
+ /*static*/ bool CodePushNativeModule::s_initialized{false};
37
+ /*static*/ hstring CodePushNativeModule::s_javaScriptBundleFileName{L"index.windows"};
38
38
 
39
39
  /*static*/ IAsyncOperation<StorageFile> CodePushNativeModule::GetBinaryBundleAsync()
40
40
  {
41
- auto appXFolder{ Windows::ApplicationModel::Package::Current().InstalledLocation() };
42
- auto bundleFolder{ (co_await appXFolder.TryGetItemAsync(L"Bundle")).try_as<StorageFolder>() };
41
+ auto appXFolder{Windows::ApplicationModel::Package::Current().InstalledLocation()};
42
+ auto bundleFolder{(co_await appXFolder.TryGetItemAsync(L"Bundle")).try_as<StorageFolder>()};
43
43
  if (bundleFolder == nullptr)
44
44
  {
45
45
  co_return nullptr;
46
46
  }
47
47
 
48
- auto bundleFile{ (co_await bundleFolder.TryGetItemAsync(s_javaScriptBundleFileName + BundleExtension)).try_as<StorageFile>() };
48
+ auto bundleFile{(co_await bundleFolder.TryGetItemAsync(s_javaScriptBundleFileName + BundleExtension)).try_as<StorageFile>()};
49
49
  co_return bundleFile;
50
50
  }
51
51
 
52
52
  /*static*/ IAsyncOperation<StorageFile> CodePushNativeModule::GetBundleFileAsync()
53
53
  {
54
- auto bundleFileName{ s_host.InstanceSettings().JavaScriptBundleFile() };
54
+ auto bundleFileName{s_host.InstanceSettings().JavaScriptBundleFile()};
55
55
  if (!bundleFileName.empty())
56
56
  {
57
57
  s_javaScriptBundleFileName = bundleFileName;
58
58
  }
59
59
 
60
- auto packageBundle{ co_await CodePushPackage::GetCurrentPackageBundleAsync() };
61
- auto binaryBundle{ co_await GetBinaryBundleAsync() };
60
+ auto packageBundle{co_await CodePushPackage::GetCurrentPackageBundleAsync()};
61
+ auto binaryBundle{co_await GetBinaryBundleAsync()};
62
62
 
63
63
  if (packageBundle == nullptr)
64
64
  {
@@ -67,8 +67,8 @@ namespace Microsoft::CodePush::ReactNative
67
67
  co_return binaryBundle;
68
68
  }
69
69
 
70
- auto binaryAppVersion{ CodePushConfig::Current().GetAppVersion() };
71
- auto currentPackageMetadata{ co_await CodePushPackage::GetCurrentPackageAsync() };
70
+ auto binaryAppVersion{CodePushConfig::Current().GetAppVersion()};
71
+ auto currentPackageMetadata{co_await CodePushPackage::GetCurrentPackageAsync()};
72
72
  if (currentPackageMetadata == nullptr)
73
73
  {
74
74
  CodePushUtils::LogBundleUrl(binaryBundle);
@@ -76,8 +76,8 @@ namespace Microsoft::CodePush::ReactNative
76
76
  co_return binaryBundle;
77
77
  }
78
78
 
79
- auto packageDate{ currentPackageMetadata.GetNamedString(BinaryBundleDateKey, L"") };
80
- auto packageAppVersion{ currentPackageMetadata.GetNamedString(AppVersionKey, L"") };
79
+ auto packageDate{currentPackageMetadata.GetNamedString(BinaryBundleDateKey, L"")};
80
+ auto packageAppVersion{currentPackageMetadata.GetNamedString(AppVersionKey, L"")};
81
81
 
82
82
  if ((co_await CodePushUpdateUtils::ModifiedDateStringOfFileAsync(binaryBundle)) == packageDate && binaryAppVersion == packageAppVersion)
83
83
  {
@@ -88,10 +88,10 @@ namespace Microsoft::CodePush::ReactNative
88
88
  }
89
89
  else
90
90
  {
91
- auto isRelease{ false };
92
- #ifndef _DEBUG
91
+ auto isRelease{false};
92
+ #ifndef _DEBUG
93
93
  isRelease = true;
94
- #endif
94
+ #endif
95
95
 
96
96
  if (isRelease || binaryAppVersion != packageAppVersion)
97
97
  {
@@ -106,11 +106,11 @@ namespace Microsoft::CodePush::ReactNative
106
106
 
107
107
  /*static*/ IAsyncOperation<StorageFolder> CodePushNativeModule::GetBundleAssetsFolderAsync()
108
108
  {
109
- auto appXFolder{ Windows::ApplicationModel::Package::Current().InstalledLocation() };
110
- auto bundleFolder{ (co_await appXFolder.TryGetItemAsync(L"Bundle")).try_as<StorageFolder>() };
109
+ auto appXFolder{Windows::ApplicationModel::Package::Current().InstalledLocation()};
110
+ auto bundleFolder{(co_await appXFolder.TryGetItemAsync(L"Bundle")).try_as<StorageFolder>()};
111
111
  if (bundleFolder != nullptr)
112
112
  {
113
- auto bundleAssetsFolder{ (co_await bundleFolder.TryGetItemAsync(CodePushUpdateUtils::AssetsFolderName)).try_as<StorageFolder>() };
113
+ auto bundleAssetsFolder{(co_await bundleFolder.TryGetItemAsync(CodePushUpdateUtils::AssetsFolderName)).try_as<StorageFolder>()};
114
114
  co_return bundleAssetsFolder;
115
115
  }
116
116
  co_return nullptr;
@@ -127,12 +127,12 @@ namespace Microsoft::CodePush::ReactNative
127
127
  return ApplicationData::Current().LocalSettings();
128
128
  }
129
129
 
130
- void CodePushNativeModule::OverrideAppVersion(std::wstring_view appVersion)
130
+ void CodePushNativeModule::OverrideAppVersion(std::wstring_view appVersion)
131
131
  {
132
132
  CodePushConfig::Current().SetAppVersion(appVersion);
133
133
  }
134
134
 
135
- void CodePushNativeModule::SetDeploymentKey(std::wstring_view deploymentKey)
135
+ void CodePushNativeModule::SetDeploymentKey(std::wstring_view deploymentKey)
136
136
  {
137
137
  CodePushConfig::Current().SetDeploymentKey(deploymentKey);
138
138
  }
@@ -141,29 +141,29 @@ namespace Microsoft::CodePush::ReactNative
141
141
  * This method checks to see whether a specific package hash
142
142
  * has previously failed installation.
143
143
  */
144
- bool CodePushNativeModule::IsFailedHash(std::wstring_view packageHash)
145
- {
146
- auto localSettings{ GetLocalSettings() };
147
- auto failedUpdatesData{ localSettings.Values().TryLookup(FailedUpdatesKey) };
144
+ bool CodePushNativeModule::IsFailedHash(std::wstring_view packageHash)
145
+ {
146
+ auto localSettings{GetLocalSettings()};
147
+ auto failedUpdatesData{localSettings.Values().TryLookup(FailedUpdatesKey)};
148
148
  if (failedUpdatesData == nullptr)
149
149
  {
150
150
  return false;
151
151
  }
152
- auto failedUpdatesString{ unbox_value<hstring>(failedUpdatesData) };
152
+ auto failedUpdatesString{unbox_value<hstring>(failedUpdatesData)};
153
153
  JsonArray failedUpdates;
154
- auto success{ JsonArray::TryParse(failedUpdatesString, failedUpdates) };
154
+ auto success{JsonArray::TryParse(failedUpdatesString, failedUpdates)};
155
155
  if (!success || packageHash.empty())
156
156
  {
157
157
  return false;
158
158
  }
159
159
  else
160
160
  {
161
- for (const auto& failedPackage : failedUpdates)
161
+ for (const auto &failedPackage : failedUpdates)
162
162
  {
163
163
  // We don't have to worry about backwards compatability, but just to be safe...
164
164
  if (failedPackage.ValueType() == JsonValueType::Object)
165
165
  {
166
- auto failedPackageHash{ failedPackage.GetObject().GetNamedString(PackageHashKey) };
166
+ auto failedPackageHash{failedPackage.GetObject().GetNamedString(PackageHashKey)};
167
167
  if (packageHash == failedPackageHash)
168
168
  {
169
169
  return true;
@@ -186,15 +186,15 @@ namespace Microsoft::CodePush::ReactNative
186
186
  * This method is used to get the count of rollback for the package
187
187
  * using the latest rollback information.
188
188
  */
189
- int CodePushNativeModule::GetRollbackCountForPackage(std::wstring_view packageHash, const JsonObject& latestRollbackInfo)
189
+ int CodePushNativeModule::GetRollbackCountForPackage(std::wstring_view packageHash, const JsonObject &latestRollbackInfo)
190
190
  {
191
- auto oldPackageHash{ latestRollbackInfo.GetNamedString(LatestRollbackPackageHashKey, L"null") };
191
+ auto oldPackageHash{latestRollbackInfo.GetNamedString(LatestRollbackPackageHashKey, L"null")};
192
192
  if (packageHash == oldPackageHash)
193
193
  {
194
- auto oldCount{ latestRollbackInfo.GetNamedNumber(LatestRollbackCountKey, 0) };
194
+ auto oldCount{latestRollbackInfo.GetNamedNumber(LatestRollbackCountKey, 0)};
195
195
  return static_cast<int>(oldCount);
196
196
  }
197
- return 0;
197
+ return 0;
198
198
  }
199
199
 
200
200
  /*
@@ -203,21 +203,21 @@ namespace Microsoft::CodePush::ReactNative
203
203
  * been applied yet via an app restart.
204
204
  */
205
205
  /*static*/ bool CodePushNativeModule::IsPendingUpdate(std::wstring_view packageHash)
206
- {
207
- auto localSettings{ GetLocalSettings() };
208
- auto pendingUpdateData{ localSettings.Values().TryLookup(PendingUpdateKey) };
206
+ {
207
+ auto localSettings{GetLocalSettings()};
208
+ auto pendingUpdateData{localSettings.Values().TryLookup(PendingUpdateKey)};
209
209
  if (pendingUpdateData != nullptr)
210
210
  {
211
- auto pendingUpdateString{ unbox_value<hstring>(pendingUpdateData) };
211
+ auto pendingUpdateString{unbox_value<hstring>(pendingUpdateData)};
212
212
  JsonObject pendingUpdate;
213
- auto success{ JsonObject::TryParse(pendingUpdateString, pendingUpdate) };
214
-
213
+ auto success{JsonObject::TryParse(pendingUpdateString, pendingUpdate)};
214
+
215
215
  // If there is a pending update whose "state" isn't loading, then we consider it "pending".
216
216
  // Additionally, if a specific hash was provided, we ensure it matches that of the pending update.
217
- auto updateIsPending{ success &&
218
- pendingUpdate != nullptr &&
219
- pendingUpdate.GetNamedBoolean(PendingUpdateIsLoadingKey, false) == false &&
220
- (packageHash.empty() || pendingUpdate.GetNamedString(PendingUpdateHashKey, L"null") == packageHash) };
217
+ auto updateIsPending{success &&
218
+ pendingUpdate != nullptr &&
219
+ pendingUpdate.GetNamedBoolean(PendingUpdateIsLoadingKey, false) == false &&
220
+ (packageHash.empty() || pendingUpdate.GetNamedString(PendingUpdateHashKey, L"null") == packageHash)};
221
221
 
222
222
  return updateIsPending;
223
223
  }
@@ -232,18 +232,18 @@ namespace Microsoft::CodePush::ReactNative
232
232
  */
233
233
  IAsyncAction CodePushNativeModule::ClearDebugUpdates()
234
234
  {
235
- #ifndef BUNDLE
236
- auto binaryAppVersion{ CodePushConfig::Current().GetAppVersion() };
237
- auto currentPackageMetadata{ co_await CodePushPackage::GetCurrentPackageAsync() };
235
+ #ifndef BUNDLE
236
+ auto binaryAppVersion{CodePushConfig::Current().GetAppVersion()};
237
+ auto currentPackageMetadata{co_await CodePushPackage::GetCurrentPackageAsync()};
238
238
  if (currentPackageMetadata != nullptr)
239
239
  {
240
- auto packageAppVersion{ currentPackageMetadata.GetNamedString(AppVersionKey, L"") };
240
+ auto packageAppVersion{currentPackageMetadata.GetNamedString(AppVersionKey, L"")};
241
241
  if (binaryAppVersion.empty() || binaryAppVersion != packageAppVersion)
242
242
  {
243
243
  co_await ClearUpdatesStaticAsync();
244
244
  }
245
245
  }
246
- #endif
246
+ #endif
247
247
  co_return;
248
248
  }
249
249
 
@@ -262,19 +262,19 @@ namespace Microsoft::CodePush::ReactNative
262
262
  L"emit",
263
263
  L"CodePushDownloadProgress",
264
264
  JSValueObject{
265
- {"totalBytes", m_latestExpectedContentLength },
266
- {"receivedBytes", m_latestReceivedContentLength } });
265
+ {"totalBytes", m_latestExpectedContentLength},
266
+ {"receivedBytes", m_latestReceivedContentLength}});
267
267
  }
268
268
 
269
269
  /*static*/ IAsyncAction CodePushNativeModule::LoadBundle()
270
270
  {
271
271
  if (!s_host.InstanceSettings().UseWebDebugger())
272
272
  {
273
- auto bundleFile{ co_await GetBundleFileAsync() };
273
+ auto bundleFile{co_await GetBundleFileAsync()};
274
274
  if (bundleFile != nullptr)
275
275
  {
276
- std::wstring_view bundlePath{ bundleFile.Path() };
277
- hstring bundleRootPath{ bundlePath.substr(0, bundlePath.rfind('\\')) };
276
+ std::wstring_view bundlePath{bundleFile.Path()};
277
+ hstring bundleRootPath{bundlePath.substr(0, bundlePath.rfind('\\'))};
278
278
  s_host.InstanceSettings().BundleRootPath(bundleRootPath);
279
279
  }
280
280
  }
@@ -292,7 +292,7 @@ namespace Microsoft::CodePush::ReactNative
292
292
  */
293
293
  IAsyncAction CodePushNativeModule::RollbackPackage()
294
294
  {
295
- auto failedPackage{ co_await CodePushPackage::GetCurrentPackageAsync() };
295
+ auto failedPackage{co_await CodePushPackage::GetCurrentPackageAsync()};
296
296
  if (failedPackage == nullptr)
297
297
  {
298
298
  CodePushUtils::Log(L"Attempted to perform a rollback when there is no current update.");
@@ -315,7 +315,7 @@ namespace Microsoft::CodePush::ReactNative
315
315
 
316
316
  /*static*/ void CodePushNativeModule::RemoveFailedUpdates()
317
317
  {
318
- auto localSettings{ GetLocalSettings() };
318
+ auto localSettings{GetLocalSettings()};
319
319
  localSettings.Values().TryRemove(FailedUpdatesKey);
320
320
  }
321
321
 
@@ -326,7 +326,7 @@ namespace Microsoft::CodePush::ReactNative
326
326
  /*static*/ void CodePushNativeModule::RemovePendingUpdate()
327
327
  {
328
328
  // remove pending update from LocalSettings
329
- auto localSettings{ GetLocalSettings() };
329
+ auto localSettings{GetLocalSettings()};
330
330
  localSettings.Values().TryRemove(PendingUpdateKey);
331
331
  }
332
332
 
@@ -355,7 +355,7 @@ namespace Microsoft::CodePush::ReactNative
355
355
  m_restartInProgress = false;
356
356
  if (m_restartQueue.size() > 0)
357
357
  {
358
- auto buf{ m_restartQueue[0] };
358
+ auto buf{m_restartQueue[0]};
359
359
  m_restartQueue.erase(m_restartQueue.begin());
360
360
  co_await RestartAppInternal(buf);
361
361
  }
@@ -366,15 +366,15 @@ namespace Microsoft::CodePush::ReactNative
366
366
  * to store its hash so that it can be ignored on future
367
367
  * attempts to check the server for an update.
368
368
  */
369
- void CodePushNativeModule::SaveFailedUpdate(JsonObject& failedPackage)
369
+ void CodePushNativeModule::SaveFailedUpdate(JsonObject &failedPackage)
370
370
  {
371
371
  if (IsFailedHash(failedPackage.GetNamedString(PackageHashKey)))
372
372
  {
373
373
  return;
374
374
  }
375
375
 
376
- auto localSettings{ GetLocalSettings() };
377
- auto failedUpdates{ localSettings.Values().TryLookup(FailedUpdatesKey).try_as<JsonArray>() };
376
+ auto localSettings{GetLocalSettings()};
377
+ auto failedUpdates{localSettings.Values().TryLookup(FailedUpdatesKey).try_as<JsonArray>()};
378
378
  if (failedUpdates == nullptr)
379
379
  {
380
380
  failedUpdates = JsonArray{};
@@ -393,25 +393,25 @@ namespace Microsoft::CodePush::ReactNative
393
393
  {
394
394
  // Since we're not restarting, we need to store the fact that the update
395
395
  // was installed, but hasn't yet become "active".
396
- auto localSettings{ GetLocalSettings() };
396
+ auto localSettings{GetLocalSettings()};
397
397
  JsonObject pendingUpdate{};
398
398
  pendingUpdate.Insert(PendingUpdateHashKey, JsonValue::CreateStringValue(packageHash));
399
399
  pendingUpdate.Insert(PendingUpdateIsLoadingKey, JsonValue::CreateBooleanValue(isLoading));
400
400
  localSettings.Values().Insert(PendingUpdateKey, box_value(pendingUpdate.Stringify()));
401
401
  }
402
402
 
403
- /*static*/ void CodePushNativeModule::SetHost(const ReactNativeHost& host)
403
+ /*static*/ void CodePushNativeModule::SetHost(const ReactNativeHost &host)
404
404
  {
405
405
  s_host = host;
406
406
  }
407
407
 
408
- void CodePushNativeModule::Initialize(ReactContext const& reactContext) noexcept
408
+ void CodePushNativeModule::Initialize(ReactContext const &reactContext) noexcept
409
409
  {
410
410
  m_context = reactContext;
411
411
  InitializeUpdateAfterRestart();
412
412
  }
413
413
 
414
- void CodePushNativeModule::GetConstants(winrt::Microsoft::ReactNative::ReactConstantProvider& constants) noexcept
414
+ void CodePushNativeModule::GetConstants(winrt::Microsoft::ReactNative::ReactConstantProvider &constants) noexcept
415
415
  {
416
416
  constants.Add(L"codePushInstallModeImmediate", CodePushInstallMode::Immediate);
417
417
  constants.Add(L"codePushInstallModeOnNextRestart", CodePushInstallMode::OnNextRestart);
@@ -428,14 +428,14 @@ namespace Microsoft::CodePush::ReactNative
428
428
  */
429
429
  fire_and_forget CodePushNativeModule::DownloadUpdateAsync(JsonObject updatePackage, bool notifyProgress, ReactPromise<IJsonValue> promise) noexcept
430
430
  {
431
- auto binaryBundle{ co_await GetBinaryBundleAsync() };
431
+ auto binaryBundle{co_await GetBinaryBundleAsync()};
432
432
  if (binaryBundle != nullptr)
433
433
  {
434
- auto modifiedDate{ co_await CodePushUpdateUtils::ModifiedDateStringOfFileAsync(binaryBundle) };
434
+ auto modifiedDate{co_await CodePushUpdateUtils::ModifiedDateStringOfFileAsync(binaryBundle)};
435
435
  updatePackage.Insert(BinaryBundleDateKey, JsonValue::CreateStringValue(modifiedDate));
436
436
  }
437
437
 
438
- auto publicKey{ CodePushConfig::Current().GetPublicKey() };
438
+ auto publicKey{CodePushConfig::Current().GetPublicKey()};
439
439
 
440
440
  try
441
441
  {
@@ -443,17 +443,17 @@ namespace Microsoft::CodePush::ReactNative
443
443
  updatePackage,
444
444
  s_javaScriptBundleFileName + BundleExtension,
445
445
  /* publicKey */ publicKey,
446
- /* progressCallback */ [=](int64_t expectedContentLength, int64_t receivedContentLength) {
446
+ /* progressCallback */ [=](int64_t expectedContentLength, int64_t receivedContentLength)
447
+ {
447
448
  // React-Native-Windows doesn't have a frame observer to my knowledge.
448
449
  if (notifyProgress)
449
450
  {
450
451
  m_latestExpectedContentLength = expectedContentLength;
451
452
  m_latestReceivedContentLength = receivedContentLength;
452
453
  DispatchDownloadProgressEvent();
453
- }
454
- });
454
+ } });
455
455
  }
456
- catch (const hresult_error& ex)
456
+ catch (const hresult_error &ex)
457
457
  {
458
458
  SaveFailedUpdate(updatePackage);
459
459
 
@@ -461,7 +461,7 @@ namespace Microsoft::CodePush::ReactNative
461
461
  promise.Reject(ex.message().c_str());
462
462
  }
463
463
 
464
- auto newPackage{ co_await CodePushPackage::GetPackageAsync(updatePackage.GetNamedString(PackageHashKey)) };
464
+ auto newPackage{co_await CodePushPackage::GetPackageAsync(updatePackage.GetNamedString(PackageHashKey))};
465
465
  if (newPackage == nullptr)
466
466
  {
467
467
  promise.Reject(L"An error has occurred retreiving the downloaded package.");
@@ -476,17 +476,17 @@ namespace Microsoft::CodePush::ReactNative
476
476
 
477
477
  /*
478
478
  * This is the native side of the CodePush.getConfiguration method. It isn't
479
- * currently exposed via the "react-native-code-push" module, and is used
479
+ * currently exposed via the "@srcpush/react-native-code-push" module, and is used
480
480
  * internally only by the CodePush.checkForUpdate method in order to get the
481
481
  * app version, as well as the deployment key that was configured in App.cpp.
482
482
  */
483
- fire_and_forget CodePushNativeModule::GetConfiguration(ReactPromise<IJsonValue> promise) noexcept
483
+ fire_and_forget CodePushNativeModule::GetConfiguration(ReactPromise<IJsonValue> promise) noexcept
484
484
  {
485
- auto configuration{ CodePushConfig::Current().GetConfiguration() };
485
+ auto configuration{CodePushConfig::Current().GetConfiguration()};
486
486
  if (isRunningBinaryVersion)
487
487
  {
488
- auto errorMessage{ L"Error: Package hashing is currently unimplemented. Binary hash was not obtained." };
489
- auto error{ hresult_error(E_NOTIMPL, errorMessage) };
488
+ auto errorMessage{L"Error: Package hashing is currently unimplemented. Binary hash was not obtained."};
489
+ auto error{hresult_error(E_NOTIMPL, errorMessage)};
490
490
  CodePushUtils::Log(error);
491
491
  CodePushUtils::Log(L"Error obtaining hash for binary contents.");
492
492
  promise.Resolve(configuration);
@@ -498,9 +498,9 @@ namespace Microsoft::CodePush::ReactNative
498
498
  /*
499
499
  * This method is the native side of the CodePush.getUpdateMetadata method.
500
500
  */
501
- fire_and_forget CodePushNativeModule::GetUpdateMetadataAsync(CodePushUpdateState updateState, ReactPromise<IJsonValue> promise) noexcept
501
+ fire_and_forget CodePushNativeModule::GetUpdateMetadataAsync(CodePushUpdateState updateState, ReactPromise<IJsonValue> promise) noexcept
502
502
  {
503
- auto package{ co_await CodePushPackage::GetCurrentPackageAsync() };
503
+ auto package{co_await CodePushPackage::GetCurrentPackageAsync()};
504
504
  if (package == nullptr)
505
505
  {
506
506
  // The app hasn't downloaded any CodePush updates yet,
@@ -511,24 +511,28 @@ namespace Microsoft::CodePush::ReactNative
511
511
  }
512
512
 
513
513
  // We have a CodePush update, so let's see if it's currently in a pending state.
514
- bool currentUpdateIsPending{ IsPendingUpdate(package.GetNamedString(PackageHashKey)) };
514
+ bool currentUpdateIsPending{IsPendingUpdate(package.GetNamedString(PackageHashKey))};
515
515
 
516
- if (updateState == CodePushUpdateState::Pending && !currentUpdateIsPending) {
516
+ if (updateState == CodePushUpdateState::Pending && !currentUpdateIsPending)
517
+ {
517
518
  // The caller wanted a pending update
518
519
  // but there isn't currently one.
519
520
  promise.Resolve(JsonValue::CreateNullValue());
520
521
  }
521
- else if (updateState == CodePushUpdateState::Running && currentUpdateIsPending) {
522
+ else if (updateState == CodePushUpdateState::Running && currentUpdateIsPending)
523
+ {
522
524
  // The caller wants the running update, but the current
523
525
  // one is pending, so we need to grab the previous.
524
526
  promise.Resolve(co_await CodePushPackage::GetPreviousPackageAsync());
525
527
  }
526
- else {
528
+ else
529
+ {
527
530
  // The current package satisfies the request:
528
531
  // 1) Caller wanted a pending, and there is a pending update
529
532
  // 2) Caller wanted the running update, and there isn't a pending
530
533
  // 3) Caller wants the latest update, regardless if it's pending or not
531
- if (isRunningBinaryVersion) {
534
+ if (isRunningBinaryVersion)
535
+ {
532
536
  // This only matters in Debug builds. Since we do not clear "outdated" updates,
533
537
  // we need to indicate to the JS side that somehow we have a current update on
534
538
  // disk that is not actually running.
@@ -539,45 +543,46 @@ namespace Microsoft::CodePush::ReactNative
539
543
  package.Insert(PackageIsPendingKey, JsonValue::CreateBooleanValue(currentUpdateIsPending));
540
544
  promise.Resolve(package);
541
545
  }
542
- co_return;
546
+ co_return;
543
547
  }
544
548
 
545
549
  /*
546
550
  * This method is the native side of the LocalPackage.install method.
547
551
  */
548
- fire_and_forget CodePushNativeModule::InstallUpdateAsync(JsonObject updatePackage, CodePushInstallMode installMode, int minimumBackgroundDuration, ReactPromise<void> promise) noexcept
549
- {
552
+ fire_and_forget CodePushNativeModule::InstallUpdateAsync(JsonObject updatePackage, CodePushInstallMode installMode, int minimumBackgroundDuration, ReactPromise<void> promise) noexcept
553
+ {
550
554
  try
551
555
  {
552
556
  co_await CodePushPackage::InstallPackageAsync(updatePackage, IsPendingUpdate(L""));
553
557
  }
554
- catch (const hresult_error& ex)
558
+ catch (const hresult_error &ex)
555
559
  {
556
560
  promise.Reject(ex.message().c_str());
557
561
  co_return;
558
562
  }
559
563
  SavePendingUpdate(updatePackage.GetNamedString(PackageHashKey), false);
560
564
  s_installMode = installMode;
561
- if (s_installMode == CodePushInstallMode::OnNextResume || s_installMode == CodePushInstallMode::OnNextSuspend) {
565
+ if (s_installMode == CodePushInstallMode::OnNextResume || s_installMode == CodePushInstallMode::OnNextSuspend)
566
+ {
562
567
  // Essentially, for RNW, InstallMode is currently always Immediate
563
- auto errorMessage{ L"Error: ON_NEXT_RESUME and ON_NEXT_SUSPEND install modes are not currently supported." };
564
- hresult_error error{ E_NOTIMPL, errorMessage };
568
+ auto errorMessage{L"Error: ON_NEXT_RESUME and ON_NEXT_SUSPEND install modes are not currently supported."};
569
+ hresult_error error{E_NOTIMPL, errorMessage};
565
570
  CodePushUtils::Log(error);
566
571
  throw error;
567
572
  }
568
573
 
569
574
  // Signal to JS that the update has been applied.
570
575
  promise.Resolve();
571
- co_return;
576
+ co_return;
572
577
  }
573
578
 
574
579
  /*
575
- * This method isn't publicly exposed via the "react-native-code-push"
580
+ * This method isn't publicly exposed via the "@srcpush/react-native-code-push"
576
581
  * module, and is only used internally to populate the RemotePackage.failedInstall property.
577
582
  */
578
583
  void CodePushNativeModule::IsFailedUpdate(std::wstring packageHash, ReactPromise<bool> promise) noexcept
579
584
  {
580
- auto isFailedHash{ IsFailedHash(packageHash) };
585
+ auto isFailedHash{IsFailedHash(packageHash)};
581
586
  promise.Resolve(isFailedHash);
582
587
  }
583
588
 
@@ -593,18 +598,18 @@ namespace Microsoft::CodePush::ReactNative
593
598
  return;
594
599
  }
595
600
 
596
- auto localSettings{ GetLocalSettings() };
601
+ auto localSettings{GetLocalSettings()};
597
602
  JsonObject latestRollbackInfo;
598
- auto res{ localSettings.Values().TryLookup(LatestRollbackInfoKey) };
603
+ auto res{localSettings.Values().TryLookup(LatestRollbackInfoKey)};
599
604
  if (res != nullptr)
600
605
  {
601
- auto infoString{ unbox_value<hstring>(res) };
606
+ auto infoString{unbox_value<hstring>(res)};
602
607
  JsonObject::TryParse(infoString, latestRollbackInfo);
603
608
  }
604
609
 
605
- auto initialRollbackCount{ GetRollbackCountForPackage(packageHash, latestRollbackInfo) };
606
- auto count{ initialRollbackCount + 1 };
607
- auto currentTimeMillis{ clock::to_time_t(clock::now()) * 1000 };
610
+ auto initialRollbackCount{GetRollbackCountForPackage(packageHash, latestRollbackInfo)};
611
+ auto count{initialRollbackCount + 1};
612
+ auto currentTimeMillis{clock::to_time_t(clock::now()) * 1000};
608
613
 
609
614
  latestRollbackInfo.Insert(LatestRollbackCountKey, JsonValue::CreateNumberValue(count));
610
615
  latestRollbackInfo.Insert(LatestRollbackTimeKey, JsonValue::CreateNumberValue(static_cast<double>(currentTimeMillis)));
@@ -625,17 +630,17 @@ namespace Microsoft::CodePush::ReactNative
625
630
  co_await ClearDebugUpdates();
626
631
  }
627
632
 
628
- auto localSettings{ GetLocalSettings() };
629
- auto pendingUpdateData{ localSettings.Values().TryLookup(PendingUpdateKey) };
633
+ auto localSettings{GetLocalSettings()};
634
+ auto pendingUpdateData{localSettings.Values().TryLookup(PendingUpdateKey)};
630
635
  if (pendingUpdateData != nullptr)
631
636
  {
632
- auto pendingUpdateString{ unbox_value<hstring>(pendingUpdateData) };
637
+ auto pendingUpdateString{unbox_value<hstring>(pendingUpdateData)};
633
638
  JsonObject pendingUpdate;
634
- auto success{ JsonObject::TryParse(pendingUpdateString, pendingUpdate) };
639
+ auto success{JsonObject::TryParse(pendingUpdateString, pendingUpdate)};
635
640
  if (success)
636
641
  {
637
642
  m_isFirstRunAfterUpdate = true;
638
- auto updateIsLoading{ pendingUpdate.GetNamedBoolean(PendingUpdateIsLoadingKey, false) };
643
+ auto updateIsLoading{pendingUpdate.GetNamedBoolean(PendingUpdateIsLoadingKey, false)};
639
644
  if (updateIsLoading)
640
645
  {
641
646
  // Pending update was initialized, but notifyApplicationReady was not called.
@@ -659,13 +664,13 @@ namespace Microsoft::CodePush::ReactNative
659
664
  * This information will be used to decide whether the application
660
665
  * should ignore the update or not.
661
666
  */
662
- void CodePushNativeModule::GetLatestRollbackInfo(ReactPromise<IJsonValue> promise) noexcept
667
+ void CodePushNativeModule::GetLatestRollbackInfo(ReactPromise<IJsonValue> promise) noexcept
663
668
  {
664
- auto localSettings{ GetLocalSettings() };
665
- auto res{ localSettings.Values().TryLookup(LatestRollbackInfoKey) };
666
- auto infoString{ unbox_value<hstring>(res) };
669
+ auto localSettings{GetLocalSettings()};
670
+ auto res{localSettings.Values().TryLookup(LatestRollbackInfoKey)};
671
+ auto infoString{unbox_value<hstring>(res)};
667
672
  JsonObject latestRollbackInfo;
668
- auto success{ JsonObject::TryParse(infoString, latestRollbackInfo) };
673
+ auto success{JsonObject::TryParse(infoString, latestRollbackInfo)};
669
674
  if (success)
670
675
  {
671
676
  promise.Resolve(latestRollbackInfo);
@@ -677,14 +682,12 @@ namespace Microsoft::CodePush::ReactNative
677
682
  }
678
683
 
679
684
  /*
680
- * This method isn't publicly exposed via the "react-native-code-push"
685
+ * This method isn't publicly exposed via the "@srcpush/react-native-code-push"
681
686
  * module, and is only used internally to populate the LocalPackage.isFirstRun property.
682
687
  */
683
688
  fire_and_forget CodePushNativeModule::IsFirstRun(std::wstring packageHash, ReactPromise<bool> promise) noexcept
684
689
  {
685
- auto isFirstRun = m_isFirstRunAfterUpdate
686
- && !packageHash.empty()
687
- && packageHash == co_await CodePushPackage::GetCurrentPackageHashAsync();
690
+ auto isFirstRun = m_isFirstRunAfterUpdate && !packageHash.empty() && packageHash == co_await CodePushPackage::GetCurrentPackageHashAsync();
688
691
 
689
692
  promise.Resolve(isFirstRun);
690
693
  }
@@ -698,7 +701,7 @@ namespace Microsoft::CodePush::ReactNative
698
701
  promise.Resolve(JsonValue::CreateNullValue());
699
702
  }
700
703
 
701
- void CodePushNativeModule::Allow(ReactPromise<JSValue> promise) noexcept
704
+ void CodePushNativeModule::Allow(ReactPromise<JSValue> promise) noexcept
702
705
  {
703
706
  CodePushUtils::Log(L"Re-allowing restarts.");
704
707
  m_allowed = true;
@@ -706,7 +709,7 @@ namespace Microsoft::CodePush::ReactNative
706
709
  if (m_restartQueue.size() > 0)
707
710
  {
708
711
  CodePushUtils::Log(L"Executing pending restart.");
709
- auto buf{ m_restartQueue[0] };
712
+ auto buf{m_restartQueue[0]};
710
713
  m_restartQueue.erase(m_restartQueue.begin());
711
714
  RestartAppInternal(buf);
712
715
  }
@@ -714,7 +717,7 @@ namespace Microsoft::CodePush::ReactNative
714
717
  promise.Resolve(JSValue::Null);
715
718
  }
716
719
 
717
- void CodePushNativeModule::ClearPendingRestart() noexcept
720
+ void CodePushNativeModule::ClearPendingRestart() noexcept
718
721
  {
719
722
  m_restartQueue.clear();
720
723
  }
@@ -729,7 +732,7 @@ namespace Microsoft::CodePush::ReactNative
729
732
  /*
730
733
  * This method is the native side of the CodePush.restartApp() method.
731
734
  */
732
- fire_and_forget CodePushNativeModule::RestartApp(bool onlyIfUpdateIsPending, ReactPromise<JSValue> promise) noexcept
735
+ fire_and_forget CodePushNativeModule::RestartApp(bool onlyIfUpdateIsPending, ReactPromise<JSValue> promise) noexcept
733
736
  {
734
737
  co_await RestartAppInternal(onlyIfUpdateIsPending);
735
738
  promise.Resolve(JSValue::Null);
@@ -738,10 +741,10 @@ namespace Microsoft::CodePush::ReactNative
738
741
  /*
739
742
  * This method clears CodePush's downloaded updates.
740
743
  * It is needed to switch to a different deployment if the current deployment is more recent.
741
- * Note: we don�t recommend to use this method in scenarios other than that (CodePush will call this method
744
+ * Note: we don�t recommend to use this method in scenarios other than that (CodePush will call this method
742
745
  * automatically when needed in other cases) as it could lead to unpredictable behavior.
743
746
  */
744
- fire_and_forget CodePushNativeModule::ClearUpdates() noexcept
747
+ fire_and_forget CodePushNativeModule::ClearUpdates() noexcept
745
748
  {
746
749
  co_await ClearUpdatesStaticAsync();
747
750
  }
@@ -752,10 +755,10 @@ namespace Microsoft::CodePush::ReactNative
752
755
  * removeBundleUrl. It is only to be used during tests and no-ops if the test
753
756
  * configuration flag is not set.
754
757
  */
755
- fire_and_forget CodePushNativeModule::DownloadAndReplaceCurrentBundle(std::wstring remoteBundleUrl) noexcept
758
+ fire_and_forget CodePushNativeModule::DownloadAndReplaceCurrentBundle(std::wstring remoteBundleUrl) noexcept
756
759
  {
757
- auto errorMessage{ L"Error: DownloadAndReplaceCurrentBundle is not currently implmented" };
758
- hresult_error error{ E_NOTIMPL, errorMessage };
760
+ auto errorMessage{L"Error: DownloadAndReplaceCurrentBundle is not currently implmented"};
761
+ hresult_error error{E_NOTIMPL, errorMessage};
759
762
  CodePushUtils::Log(error);
760
763
  throw error;
761
764
  }
@@ -764,21 +767,21 @@ namespace Microsoft::CodePush::ReactNative
764
767
  * This method is checks if a new status update exists (new version was installed,
765
768
  * or an update failed) and return its details (version label, status).
766
769
  */
767
- fire_and_forget CodePushNativeModule::GetNewStatusReportAsync(ReactPromise<IJsonValue> promise) noexcept
770
+ fire_and_forget CodePushNativeModule::GetNewStatusReportAsync(ReactPromise<IJsonValue> promise) noexcept
768
771
  {
769
772
  if (needToReportRollback)
770
773
  {
771
774
  needToReportRollback = false;
772
- auto localSettings{ GetLocalSettings() };
773
- auto failedUpdatesData{ localSettings.Values().TryLookup(FailedUpdatesKey) };
775
+ auto localSettings{GetLocalSettings()};
776
+ auto failedUpdatesData{localSettings.Values().TryLookup(FailedUpdatesKey)};
774
777
  if (failedUpdatesData != nullptr)
775
778
  {
776
- auto failedUpdatesString{ unbox_value<hstring>(failedUpdatesData) };
779
+ auto failedUpdatesString{unbox_value<hstring>(failedUpdatesData)};
777
780
  JsonArray failedUpdates;
778
- auto success{ JsonArray::TryParse(failedUpdatesString, failedUpdates) };
781
+ auto success{JsonArray::TryParse(failedUpdatesString, failedUpdates)};
779
782
  if (success)
780
783
  {
781
- auto lastFailedPackage{ failedUpdates.GetObjectAt(failedUpdates.Size() - 1) };
784
+ auto lastFailedPackage{failedUpdates.GetObjectAt(failedUpdates.Size() - 1)};
782
785
  if (lastFailedPackage != nullptr)
783
786
  {
784
787
  promise.Resolve(CodePushTelemetryManager::GetRollbackReport(lastFailedPackage));
@@ -798,13 +801,13 @@ namespace Microsoft::CodePush::ReactNative
798
801
  }
799
802
  else if (isRunningBinaryVersion)
800
803
  {
801
- auto appVersionString{ CodePushConfig::Current().GetAppVersion() };
804
+ auto appVersionString{CodePushConfig::Current().GetAppVersion()};
802
805
  promise.Resolve(CodePushTelemetryManager::GetBinaryUpdateReport(appVersionString));
803
806
  co_return;
804
807
  }
805
808
  else
806
809
  {
807
- auto retryStatusReport{ CodePushTelemetryManager::GetRetryStatusReport() };
810
+ auto retryStatusReport{CodePushTelemetryManager::GetRetryStatusReport()};
808
811
  if (retryStatusReport != nullptr)
809
812
  {
810
813
  promise.Resolve(retryStatusReport);
@@ -816,12 +819,12 @@ namespace Microsoft::CodePush::ReactNative
816
819
  co_return;
817
820
  }
818
821
 
819
- void CodePushNativeModule::RecordStatusReported(JsonObject statusReport) noexcept
822
+ void CodePushNativeModule::RecordStatusReported(JsonObject statusReport) noexcept
820
823
  {
821
824
  CodePushTelemetryManager::RecordStatusReported(statusReport);
822
825
  }
823
826
 
824
- void CodePushNativeModule::SaveStatusReportForRetry(JsonObject statusReport) noexcept
827
+ void CodePushNativeModule::SaveStatusReportForRetry(JsonObject statusReport) noexcept
825
828
  {
826
829
  CodePushTelemetryManager::SaveStatusReportForRetry(statusReport);
827
830
  }
@@ -833,7 +836,7 @@ namespace winrt::Microsoft::ReactNative
833
836
  {
834
837
  using namespace winrt::Windows::Data::Json;
835
838
 
836
- void WriteValue(IJSValueWriter const& writer, IJsonValue const& value) noexcept
839
+ void WriteValue(IJSValueWriter const &writer, IJsonValue const &value) noexcept
837
840
  {
838
841
  if (value == nullptr)
839
842
  {
@@ -845,7 +848,7 @@ namespace winrt::Microsoft::ReactNative
845
848
  {
846
849
  case JsonValueType::Object:
847
850
  writer.WriteObjectBegin();
848
- for (const auto& pair : value.GetObject())
851
+ for (const auto &pair : value.GetObject())
849
852
  {
850
853
  writer.WritePropertyName(pair.Key());
851
854
  WriteValue(writer, pair.Value());
@@ -854,7 +857,7 @@ namespace winrt::Microsoft::ReactNative
854
857
  break;
855
858
  case JsonValueType::Array:
856
859
  writer.WriteArrayBegin();
857
- for (const auto& elem : value.GetArray())
860
+ for (const auto &elem : value.GetArray())
858
861
  {
859
862
  WriteValue(writer, elem);
860
863
  }
@@ -876,7 +879,7 @@ namespace winrt::Microsoft::ReactNative
876
879
  }
877
880
  }
878
881
 
879
- void ReadValue(IJSValueReader const& reader, /*out*/ JsonObject& value) noexcept
882
+ void ReadValue(IJSValueReader const &reader, /*out*/ JsonObject &value) noexcept
880
883
  {
881
884
  if (reader.ValueType() == JSValueType::Object)
882
885
  {
@@ -888,7 +891,7 @@ namespace winrt::Microsoft::ReactNative
888
891
  }
889
892
  }
890
893
 
891
- void ReadValue(IJSValueReader const& reader, /*out*/ IJsonValue& value) noexcept
894
+ void ReadValue(IJSValueReader const &reader, /*out*/ IJsonValue &value) noexcept
892
895
  {
893
896
  if (reader.ValueType() == JSValueType::Object)
894
897
  {
@@ -12,8 +12,8 @@
12
12
  // Helper functions for reading and sending JsonValues to and from JavaScript
13
13
  namespace winrt::Microsoft::ReactNative
14
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;
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
17
  }
18
18
 
19
19
  namespace Microsoft::CodePush::ReactNative
@@ -37,7 +37,7 @@ namespace Microsoft::CodePush::ReactNative
37
37
  };
38
38
 
39
39
  static winrt::Windows::Foundation::IAsyncAction LoadBundle();
40
- static void SetHost(const winrt::Microsoft::ReactNative::ReactNativeHost& host);
40
+ static void SetHost(const winrt::Microsoft::ReactNative::ReactNativeHost &host);
41
41
 
42
42
  static winrt::Windows::Foundation::IAsyncOperation<winrt::Windows::Storage::StorageFile> GetBinaryBundleAsync();
43
43
  static winrt::Windows::Foundation::IAsyncOperation<winrt::Windows::Storage::StorageFile> GetBundleFileAsync();
@@ -54,17 +54,17 @@ namespace Microsoft::CodePush::ReactNative
54
54
  winrt::Windows::Data::Json::JsonObject GetRollbackInfo();
55
55
  int GetRollbackCountForPackage(
56
56
  std::wstring_view packageHash,
57
- const winrt::Windows::Data::Json::JsonObject& latestRollbackInfo);
57
+ const winrt::Windows::Data::Json::JsonObject &latestRollbackInfo);
58
58
 
59
59
  static bool IsPendingUpdate(std::wstring_view packageHash);
60
60
 
61
61
  winrt::Windows::Foundation::IAsyncAction ClearDebugUpdates();
62
62
 
63
63
  REACT_INIT(Initialize);
64
- void Initialize(winrt::Microsoft::ReactNative::ReactContext const& reactContext) noexcept;
64
+ void Initialize(winrt::Microsoft::ReactNative::ReactContext const &reactContext) noexcept;
65
65
 
66
66
  REACT_CONSTANT_PROVIDER(GetConstants);
67
- void GetConstants(winrt::Microsoft::ReactNative::ReactConstantProvider& constants) noexcept;
67
+ void GetConstants(winrt::Microsoft::ReactNative::ReactConstantProvider &constants) noexcept;
68
68
 
69
69
  /*
70
70
  * This is native-side of the JavaScript RemotePackage.download method
@@ -77,7 +77,7 @@ namespace Microsoft::CodePush::ReactNative
77
77
 
78
78
  /*
79
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
80
+ * currently exposed via the "@srcpush/react-native-code-push" module, and is used
81
81
  * internally only by the CodePush.checkForUpdate method in order to get the
82
82
  * app version, as well as the deployment key that was configured in the Info.plist file.
83
83
  */
@@ -103,7 +103,7 @@ namespace Microsoft::CodePush::ReactNative
103
103
  winrt::Microsoft::ReactNative::ReactPromise<void> promise) noexcept;
104
104
 
105
105
  /*
106
- * This method isn't publicly exposed via the "react-native-code-push"
106
+ * This method isn't publicly exposed via the "@srcpush/react-native-code-push"
107
107
  * module, and is only used internally to populate the RemotePackage.failedInstall property.
108
108
  */
109
109
  REACT_METHOD(IsFailedUpdate, L"isFailedUpdate");
@@ -118,7 +118,7 @@ namespace Microsoft::CodePush::ReactNative
118
118
  void GetLatestRollbackInfo(winrt::Microsoft::ReactNative::ReactPromise<winrt::Windows::Data::Json::IJsonValue> promise) noexcept;
119
119
 
120
120
  /*
121
- * This method isn't publicly exposed via the "react-native-code-push"
121
+ * This method isn't publicly exposed via the "@srcpush/react-native-code-push"
122
122
  * module, and is only used internally to populate the LocalPackage.isFirstRun property.
123
123
  */
124
124
  REACT_METHOD(IsFirstRun, L"isFirstRun");
@@ -152,7 +152,7 @@ namespace Microsoft::CodePush::ReactNative
152
152
  /*
153
153
  * This method clears CodePush's downloaded updates.
154
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
155
+ * Note: we don�t recommend to use this method in scenarios other than that (CodePush will call this method
156
156
  * automatically when needed in other cases) as it could lead to unpredictable behavior.
157
157
  */
158
158
  REACT_METHOD(ClearUpdates, L"clearUpdates");
@@ -181,43 +181,43 @@ namespace Microsoft::CodePush::ReactNative
181
181
  void SaveStatusReportForRetry(winrt::Windows::Data::Json::JsonObject statusReport) noexcept;
182
182
 
183
183
  private:
184
- bool m_isFirstRunAfterUpdate{ false };
184
+ bool m_isFirstRunAfterUpdate{false};
185
185
  static CodePushInstallMode s_installMode;
186
186
 
187
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 };
188
+ uint64_t m_latestExpectedContentLength{0};
189
+ uint64_t m_latestReceivedContentLength{0};
190
+ bool m_didUpdateProgress{false};
191
191
 
192
- bool m_allowed{ true };
193
- bool m_restartInProgress{ false };
192
+ bool m_allowed{true};
193
+ bool m_restartInProgress{false};
194
194
  std::vector<uint8_t> m_restartQueue;
195
195
 
196
- static constexpr std::wstring_view BundleExtension{ L".bundle" };
196
+ static constexpr std::wstring_view BundleExtension{L".bundle"};
197
197
  static winrt::hstring s_javaScriptBundleFileName;
198
198
 
199
199
  // These constants represent emitted events
200
- static constexpr std::wstring_view DownloadProgressEvent{ L"CodePushDownloadProgress" };
200
+ static constexpr std::wstring_view DownloadProgressEvent{L"CodePushDownloadProgress"};
201
201
 
202
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" };
203
+ static constexpr std::wstring_view DeploymentFailed{L"DeploymentFailed"};
204
+ static constexpr std::wstring_view DeploymentSucceeded{L"DeploymentSucceeded"};
205
205
 
206
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" };
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
209
 
210
210
  // These keys are already "namespaced" by the PendingUpdateKey, so
211
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" };
212
+ static constexpr std::wstring_view PendingUpdateHashKey{L"hash"};
213
+ static constexpr std::wstring_view PendingUpdateIsLoadingKey{L"isLoading"};
214
214
 
215
215
  // These keys are used to inspect/augment the metadata
216
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" };
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
221
 
222
222
  static bool isRunningBinaryVersion;
223
223
  static bool needToReportRollback;
@@ -226,10 +226,10 @@ namespace Microsoft::CodePush::ReactNative
226
226
  winrt::Microsoft::ReactNative::ReactContext m_context;
227
227
 
228
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" };
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
233
 
234
234
  // Bool that keeps track of whether the app has been initialized at least once.
235
235
  static bool s_initialized;
@@ -241,7 +241,7 @@ namespace Microsoft::CodePush::ReactNative
241
241
  static void RemoveFailedUpdates();
242
242
  static void RemovePendingUpdate();
243
243
  winrt::Windows::Foundation::IAsyncAction RestartAppInternal(bool onlyIfUpdateIsPending);
244
- void SaveFailedUpdate(winrt::Windows::Data::Json::JsonObject& failedPackage);
244
+ void SaveFailedUpdate(winrt::Windows::Data::Json::JsonObject &failedPackage);
245
245
  void SavePendingUpdate(std::wstring_view packageHash, bool isLoading);
246
246
  };
247
247
  }