@swyng/react-native-code-push 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (239) hide show
  1. package/AlertAdapter.js +24 -0
  2. package/CLAUDE.md +57 -0
  3. package/CONTRIBUTING.md +134 -0
  4. package/CodePush.js +671 -0
  5. package/CodePush.podspec +28 -0
  6. package/LICENSE.md +13 -0
  7. package/README.md +323 -0
  8. package/SECURITY.md +24 -0
  9. package/android/app/build.gradle +48 -0
  10. package/android/app/proguard-rules.pro +33 -0
  11. package/android/app/src/main/AndroidManifest.xml +5 -0
  12. package/android/app/src/main/java/com/swyngpush/codepush/react/CodePush.java +426 -0
  13. package/android/app/src/main/java/com/swyngpush/codepush/react/CodePushConstants.java +35 -0
  14. package/android/app/src/main/java/com/swyngpush/codepush/react/CodePushDialog.java +102 -0
  15. package/android/app/src/main/java/com/swyngpush/codepush/react/CodePushInstallMode.java +16 -0
  16. package/android/app/src/main/java/com/swyngpush/codepush/react/CodePushInvalidPublicKeyException.java +12 -0
  17. package/android/app/src/main/java/com/swyngpush/codepush/react/CodePushInvalidUpdateException.java +7 -0
  18. package/android/app/src/main/java/com/swyngpush/codepush/react/CodePushMalformedDataException.java +12 -0
  19. package/android/app/src/main/java/com/swyngpush/codepush/react/CodePushNativeModule.java +781 -0
  20. package/android/app/src/main/java/com/swyngpush/codepush/react/CodePushNotInitializedException.java +12 -0
  21. package/android/app/src/main/java/com/swyngpush/codepush/react/CodePushTelemetryManager.java +175 -0
  22. package/android/app/src/main/java/com/swyngpush/codepush/react/CodePushUnknownException.java +12 -0
  23. package/android/app/src/main/java/com/swyngpush/codepush/react/CodePushUpdateManager.java +383 -0
  24. package/android/app/src/main/java/com/swyngpush/codepush/react/CodePushUpdateState.java +15 -0
  25. package/android/app/src/main/java/com/swyngpush/codepush/react/CodePushUpdateUtils.java +275 -0
  26. package/android/app/src/main/java/com/swyngpush/codepush/react/CodePushUtils.java +238 -0
  27. package/android/app/src/main/java/com/swyngpush/codepush/react/DownloadProgress.java +30 -0
  28. package/android/app/src/main/java/com/swyngpush/codepush/react/DownloadProgressCallback.java +5 -0
  29. package/android/app/src/main/java/com/swyngpush/codepush/react/FileUtils.java +203 -0
  30. package/android/app/src/main/java/com/swyngpush/codepush/react/ReactHostHolder.java +11 -0
  31. package/android/app/src/main/java/com/swyngpush/codepush/react/SettingsManager.java +173 -0
  32. package/android/app/src/main/java/com/swyngpush/codepush/react/TLSSocketFactory.java +72 -0
  33. package/android/build.gradle +23 -0
  34. package/android/codepush.gradle +162 -0
  35. package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  36. package/android/gradle/wrapper/gradle-wrapper.properties +5 -0
  37. package/android/gradle.properties +18 -0
  38. package/android/gradlew +164 -0
  39. package/android/gradlew.bat +90 -0
  40. package/android/settings.gradle +2 -0
  41. package/docs/LOAD_BUNDLE_DELAY_ANALYSIS.md +68 -0
  42. package/docs/api-android.md +52 -0
  43. package/docs/api-ios.md +31 -0
  44. package/docs/api-js.md +592 -0
  45. package/docs/multi-deployment-testing-android.md +55 -0
  46. package/docs/multi-deployment-testing-ios.md +59 -0
  47. package/docs/setup-android.md +121 -0
  48. package/docs/setup-ios.md +141 -0
  49. package/docs/setup-windows.md +121 -0
  50. package/expo.js +347 -0
  51. package/ios/CodePush/Base64/Base64/MF_Base64Additions.h +34 -0
  52. package/ios/CodePush/Base64/Base64/MF_Base64Additions.m +252 -0
  53. package/ios/CodePush/Base64/README.md +47 -0
  54. package/ios/CodePush/CodePush.h +235 -0
  55. package/ios/CodePush/CodePush.m +1131 -0
  56. package/ios/CodePush/CodePushConfig.m +115 -0
  57. package/ios/CodePush/CodePushDownloadHandler.m +130 -0
  58. package/ios/CodePush/CodePushErrorUtils.m +20 -0
  59. package/ios/CodePush/CodePushPackage.m +602 -0
  60. package/ios/CodePush/CodePushTelemetryManager.m +175 -0
  61. package/ios/CodePush/CodePushUpdateUtils.m +376 -0
  62. package/ios/CodePush/CodePushUtils.m +9 -0
  63. package/ios/CodePush/JWT/Core/Algorithms/Base/JWTAlgorithm.h +69 -0
  64. package/ios/CodePush/JWT/Core/Algorithms/Base/JWTAlgorithmFactory.h +16 -0
  65. package/ios/CodePush/JWT/Core/Algorithms/Base/JWTAlgorithmFactory.m +51 -0
  66. package/ios/CodePush/JWT/Core/Algorithms/Base/JWTAlgorithmNone.h +15 -0
  67. package/ios/CodePush/JWT/Core/Algorithms/Base/JWTAlgorithmNone.m +55 -0
  68. package/ios/CodePush/JWT/Core/Algorithms/ESFamily/JWTAlgorithmESBase.h +24 -0
  69. package/ios/CodePush/JWT/Core/Algorithms/ESFamily/JWTAlgorithmESBase.m +41 -0
  70. package/ios/CodePush/JWT/Core/Algorithms/HSFamily/JWTAlgorithmHSBase.h +28 -0
  71. package/ios/CodePush/JWT/Core/Algorithms/HSFamily/JWTAlgorithmHSBase.m +205 -0
  72. package/ios/CodePush/JWT/Core/Algorithms/Holders/JWTAlgorithmDataHolder.h +103 -0
  73. package/ios/CodePush/JWT/Core/Algorithms/Holders/JWTAlgorithmDataHolder.m +322 -0
  74. package/ios/CodePush/JWT/Core/Algorithms/Holders/JWTAlgorithmDataHolderChain.h +37 -0
  75. package/ios/CodePush/JWT/Core/Algorithms/Holders/JWTAlgorithmDataHolderChain.m +145 -0
  76. package/ios/CodePush/JWT/Core/Algorithms/RSFamily/JWTAlgorithmRSBase.h +35 -0
  77. package/ios/CodePush/JWT/Core/Algorithms/RSFamily/JWTAlgorithmRSBase.m +551 -0
  78. package/ios/CodePush/JWT/Core/Algorithms/RSFamily/JWTRSAlgorithm.h +23 -0
  79. package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoKey.h +43 -0
  80. package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoKey.m +230 -0
  81. package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoKeyExtractor.h +31 -0
  82. package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoKeyExtractor.m +113 -0
  83. package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoSecurity.h +38 -0
  84. package/ios/CodePush/JWT/Core/Algorithms/RSFamily/RSKeys/JWTCryptoSecurity.m +500 -0
  85. package/ios/CodePush/JWT/Core/ClaimSet/JWTClaim.h +18 -0
  86. package/ios/CodePush/JWT/Core/ClaimSet/JWTClaim.m +214 -0
  87. package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSet.h +23 -0
  88. package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSet.m +29 -0
  89. package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSetSerializer.h +19 -0
  90. package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSetSerializer.m +68 -0
  91. package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSetVerifier.h +18 -0
  92. package/ios/CodePush/JWT/Core/ClaimSet/JWTClaimsSetVerifier.m +72 -0
  93. package/ios/CodePush/JWT/Core/Coding/JWTCoding+ResultTypes.h +67 -0
  94. package/ios/CodePush/JWT/Core/Coding/JWTCoding+ResultTypes.m +111 -0
  95. package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionOne.h +119 -0
  96. package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionOne.m +307 -0
  97. package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionThree.h +94 -0
  98. package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionThree.m +619 -0
  99. package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionTwo.h +164 -0
  100. package/ios/CodePush/JWT/Core/Coding/JWTCoding+VersionTwo.m +514 -0
  101. package/ios/CodePush/JWT/Core/Coding/JWTCoding.h +24 -0
  102. package/ios/CodePush/JWT/Core/Coding/JWTCoding.m +11 -0
  103. package/ios/CodePush/JWT/Core/FrameworkSupplement/JWT.h +52 -0
  104. package/ios/CodePush/JWT/Core/FrameworkSupplement/Map.modulemap +5 -0
  105. package/ios/CodePush/JWT/Core/Supplement/JWTBase64Coder.h +28 -0
  106. package/ios/CodePush/JWT/Core/Supplement/JWTBase64Coder.m +70 -0
  107. package/ios/CodePush/JWT/Core/Supplement/JWTDeprecations.h +22 -0
  108. package/ios/CodePush/JWT/Core/Supplement/JWTErrorDescription.h +34 -0
  109. package/ios/CodePush/JWT/Core/Supplement/JWTErrorDescription.m +73 -0
  110. package/ios/CodePush/JWT/LICENSE +19 -0
  111. package/ios/CodePush/JWT/README.md +489 -0
  112. package/ios/CodePush/RCTConvert+CodePushInstallMode.m +20 -0
  113. package/ios/CodePush/RCTConvert+CodePushUpdateState.m +20 -0
  114. package/ios/CodePush/SSZipArchive/Info.plist +26 -0
  115. package/ios/CodePush/SSZipArchive/README.md +1 -0
  116. package/ios/CodePush/SSZipArchive/SSZipArchive.h +178 -0
  117. package/ios/CodePush/SSZipArchive/SSZipArchive.m +1496 -0
  118. package/ios/CodePush/SSZipArchive/SSZipCommon.h +71 -0
  119. package/ios/CodePush/SSZipArchive/Supporting Files/PrivacyInfo.xcprivacy +23 -0
  120. package/ios/CodePush/SSZipArchive/include/ZipArchive.h +25 -0
  121. package/ios/CodePush/SSZipArchive/minizip/LICENSE +17 -0
  122. package/ios/CodePush/SSZipArchive/minizip/mz.h +273 -0
  123. package/ios/CodePush/SSZipArchive/minizip/mz_compat.c +1306 -0
  124. package/ios/CodePush/SSZipArchive/minizip/mz_compat.h +346 -0
  125. package/ios/CodePush/SSZipArchive/minizip/mz_crypt.c +187 -0
  126. package/ios/CodePush/SSZipArchive/minizip/mz_crypt.h +65 -0
  127. package/ios/CodePush/SSZipArchive/minizip/mz_crypt_apple.c +526 -0
  128. package/ios/CodePush/SSZipArchive/minizip/mz_os.c +348 -0
  129. package/ios/CodePush/SSZipArchive/minizip/mz_os.h +176 -0
  130. package/ios/CodePush/SSZipArchive/minizip/mz_os_posix.c +350 -0
  131. package/ios/CodePush/SSZipArchive/minizip/mz_strm.c +556 -0
  132. package/ios/CodePush/SSZipArchive/minizip/mz_strm.h +132 -0
  133. package/ios/CodePush/SSZipArchive/minizip/mz_strm_buf.c +383 -0
  134. package/ios/CodePush/SSZipArchive/minizip/mz_strm_buf.h +42 -0
  135. package/ios/CodePush/SSZipArchive/minizip/mz_strm_mem.c +269 -0
  136. package/ios/CodePush/SSZipArchive/minizip/mz_strm_mem.h +48 -0
  137. package/ios/CodePush/SSZipArchive/minizip/mz_strm_os.h +40 -0
  138. package/ios/CodePush/SSZipArchive/minizip/mz_strm_os_posix.c +203 -0
  139. package/ios/CodePush/SSZipArchive/minizip/mz_strm_pkcrypt.c +334 -0
  140. package/ios/CodePush/SSZipArchive/minizip/mz_strm_pkcrypt.h +46 -0
  141. package/ios/CodePush/SSZipArchive/minizip/mz_strm_split.c +429 -0
  142. package/ios/CodePush/SSZipArchive/minizip/mz_strm_split.h +43 -0
  143. package/ios/CodePush/SSZipArchive/minizip/mz_strm_wzaes.c +360 -0
  144. package/ios/CodePush/SSZipArchive/minizip/mz_strm_wzaes.h +46 -0
  145. package/ios/CodePush/SSZipArchive/minizip/mz_strm_zlib.c +389 -0
  146. package/ios/CodePush/SSZipArchive/minizip/mz_strm_zlib.h +43 -0
  147. package/ios/CodePush/SSZipArchive/minizip/mz_zip.c +2782 -0
  148. package/ios/CodePush/SSZipArchive/minizip/mz_zip.h +262 -0
  149. package/ios/CodePush/SSZipArchive/minizip/mz_zip_rw.c +1942 -0
  150. package/ios/CodePush/SSZipArchive/minizip/mz_zip_rw.h +285 -0
  151. package/ios/CodePush.xcodeproj/project.pbxproj +1052 -0
  152. package/ios/CodePush.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
  153. package/ios/CodePush.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  154. package/ios/PrivacyInfo.xcprivacy +31 -0
  155. package/logging.js +6 -0
  156. package/package-mixins.js +68 -0
  157. package/package.json +91 -0
  158. package/react-native.config.js +11 -0
  159. package/request-fetch-adapter.js +52 -0
  160. package/scripts/generateBundledResourcesHash.js +125 -0
  161. package/scripts/getFilesInFolder.js +19 -0
  162. package/scripts/postlink/android/postlink.js +87 -0
  163. package/scripts/postlink/ios/postlink.js +116 -0
  164. package/scripts/postlink/run.js +11 -0
  165. package/scripts/postunlink/android/postunlink.js +74 -0
  166. package/scripts/postunlink/ios/postunlink.js +87 -0
  167. package/scripts/postunlink/run.js +11 -0
  168. package/scripts/recordFilesBeforeBundleCommand.js +41 -0
  169. package/scripts/tools/linkToolsAndroid.js +57 -0
  170. package/scripts/tools/linkToolsIos.js +130 -0
  171. package/tsconfig.json +17 -0
  172. package/tslint.json +32 -0
  173. package/typings/react-native-code-push.d.ts +455 -0
  174. package/windows/CodePush/.!12419!CodePushNativeModule.h +154 -0
  175. package/windows/CodePush/.!12440!CodePushNativeModule.h +154 -0
  176. package/windows/CodePush/CodePush.def +3 -0
  177. package/windows/CodePush/CodePush.vcxproj +198 -0
  178. package/windows/CodePush/CodePush.vcxproj.filters +91 -0
  179. package/windows/CodePush/CodePushConfig.cpp +99 -0
  180. package/windows/CodePush/CodePushConfig.h +66 -0
  181. package/windows/CodePush/CodePushConfig.idl +12 -0
  182. package/windows/CodePush/CodePushDownloadHandler.cpp +73 -0
  183. package/windows/CodePush/CodePushDownloadHandler.h +32 -0
  184. package/windows/CodePush/CodePushNativeModule.cpp +934 -0
  185. package/windows/CodePush/CodePushNativeModule.h +247 -0
  186. package/windows/CodePush/CodePushPackage.cpp +456 -0
  187. package/windows/CodePush/CodePushPackage.h +49 -0
  188. package/windows/CodePush/CodePushTelemetryManager.cpp +213 -0
  189. package/windows/CodePush/CodePushTelemetryManager.h +29 -0
  190. package/windows/CodePush/CodePushUpdateUtils.cpp +86 -0
  191. package/windows/CodePush/CodePushUpdateUtils.h +38 -0
  192. package/windows/CodePush/CodePushUtils.cpp +29 -0
  193. package/windows/CodePush/CodePushUtils.h +18 -0
  194. package/windows/CodePush/FileUtils.cpp +131 -0
  195. package/windows/CodePush/FileUtils.h +28 -0
  196. package/windows/CodePush/PropertySheet.props +16 -0
  197. package/windows/CodePush/ReactPackageProvider.cpp +15 -0
  198. package/windows/CodePush/ReactPackageProvider.h +22 -0
  199. package/windows/CodePush/ReactPackageProvider.idl +9 -0
  200. package/windows/CodePush/miniz/LICENSE +22 -0
  201. package/windows/CodePush/miniz/miniz.c +7657 -0
  202. package/windows/CodePush/miniz/miniz.h +1338 -0
  203. package/windows/CodePush/miniz/readme.md +37 -0
  204. package/windows/CodePush/packages.config +4 -0
  205. package/windows/CodePush/pch.cpp +1 -0
  206. package/windows/CodePush/pch.h +4 -0
  207. package/windows-legacy/CodePush/CodePush.csproj +128 -0
  208. package/windows-legacy/CodePush/CodePushUtils.cs +47 -0
  209. package/windows-legacy/CodePush/FileUtils.cs +40 -0
  210. package/windows-legacy/CodePush/Properties/AssemblyInfo.cs +29 -0
  211. package/windows-legacy/CodePush/Properties/CodePush.rd.xml +33 -0
  212. package/windows-legacy/CodePush/UpdateManager.cs +305 -0
  213. package/windows-legacy/CodePush/UpdateUtils.cs +46 -0
  214. package/windows-legacy/CodePush.Net46/Adapters/Http/HttpProgress.cs +28 -0
  215. package/windows-legacy/CodePush.Net46/Adapters/Storage/ApplicationDataContainer.cs +106 -0
  216. package/windows-legacy/CodePush.Net46/CodePush.Net46.csproj +103 -0
  217. package/windows-legacy/CodePush.Net46/CodePushUtils.cs +158 -0
  218. package/windows-legacy/CodePush.Net46/FileUtils.cs +55 -0
  219. package/windows-legacy/CodePush.Net46/Properties/AssemblyInfo.cs +36 -0
  220. package/windows-legacy/CodePush.Net46/UpdateManager.cs +330 -0
  221. package/windows-legacy/CodePush.Net46/UpdateUtils.cs +70 -0
  222. package/windows-legacy/CodePush.Net46/packages.config +5 -0
  223. package/windows-legacy/CodePush.Net46.Test/ApplicationDataContainerTest.cs +105 -0
  224. package/windows-legacy/CodePush.Net46.Test/CodePush.Net46.Test.csproj +137 -0
  225. package/windows-legacy/CodePush.Net46.Test/Properties/AssemblyInfo.cs +36 -0
  226. package/windows-legacy/CodePush.Net46.Test/TelemetryManagerTest.cs +117 -0
  227. package/windows-legacy/CodePush.Net46.Test/app.config +11 -0
  228. package/windows-legacy/CodePush.Net46.Test/packages.config +4 -0
  229. package/windows-legacy/CodePush.Shared/CodePush.Shared.projitems +22 -0
  230. package/windows-legacy/CodePush.Shared/CodePush.Shared.shproj +13 -0
  231. package/windows-legacy/CodePush.Shared/CodePushConstants.cs +35 -0
  232. package/windows-legacy/CodePush.Shared/CodePushNativeModule.cs +329 -0
  233. package/windows-legacy/CodePush.Shared/CodePushReactPackage.cs +235 -0
  234. package/windows-legacy/CodePush.Shared/CodePushUtils.cs +70 -0
  235. package/windows-legacy/CodePush.Shared/InstallMode.cs +9 -0
  236. package/windows-legacy/CodePush.Shared/MinimumBackgroundListener.cs +44 -0
  237. package/windows-legacy/CodePush.Shared/SettingsManager.cs +148 -0
  238. package/windows-legacy/CodePush.Shared/TelemetryManager.cs +250 -0
  239. package/windows-legacy/CodePush.Shared/UpdateState.cs +9 -0
@@ -0,0 +1,154 @@
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.
@@ -0,0 +1,3 @@
1
+ EXPORTS
2
+ DllCanUnloadNow = WINRT_CanUnloadNow PRIVATE
3
+ DllGetActivationFactory = WINRT_GetActivationFactory PRIVATE
@@ -0,0 +1,198 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3
+ <Import Project="$(SolutionDir)\packages\Microsoft.Windows.CppWinRT.2.0.200615.7\build\native\Microsoft.Windows.CppWinRT.props" Condition="Exists('$(SolutionDir)\packages\Microsoft.Windows.CppWinRT.2.0.200615.7\build\native\Microsoft.Windows.CppWinRT.props')" />
4
+ <PropertyGroup Label="Globals">
5
+ <CppWinRTOptimized>true</CppWinRTOptimized>
6
+ <CppWinRTRootNamespaceAutoMerge>true</CppWinRTRootNamespaceAutoMerge>
7
+ <CppWinRTGenerateWindowsMetadata>true</CppWinRTGenerateWindowsMetadata>
8
+ <MinimalCoreWin>true</MinimalCoreWin>
9
+ <ProjectGuid>{a6b6216e-fa3f-45e2-9c8e-40023cce9132}</ProjectGuid>
10
+ <ProjectName>CodePush</ProjectName>
11
+ <RootNamespace>Microsoft.CodePush.ReactNative</RootNamespace>
12
+ <DefaultLanguage>en-US</DefaultLanguage>
13
+ <MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>
14
+ <AppContainerApplication>true</AppContainerApplication>
15
+ <ApplicationType>Windows Store</ApplicationType>
16
+ <ApplicationTypeRevision>10.0</ApplicationTypeRevision>
17
+ <WindowsTargetPlatformVersion Condition=" '$(WindowsTargetPlatformVersion)' == '' ">10.0</WindowsTargetPlatformVersion>
18
+ <WindowsTargetPlatformMinVersion>10.0.17763.0</WindowsTargetPlatformMinVersion>
19
+ </PropertyGroup>
20
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
21
+ <PropertyGroup Label="ReactNativeWindowsProps">
22
+ <ReactNativeWindowsDir Condition="'$(ReactNativeWindowsDir)' == ''">$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), 'node_modules\react-native-windows\package.json'))\node_modules\react-native-windows\</ReactNativeWindowsDir>
23
+ </PropertyGroup>
24
+ <ItemGroup Label="ProjectConfigurations">
25
+ <ProjectConfiguration Include="Debug|ARM">
26
+ <Configuration>Debug</Configuration>
27
+ <Platform>ARM</Platform>
28
+ </ProjectConfiguration>
29
+ <ProjectConfiguration Include="Debug|ARM64">
30
+ <Configuration>Debug</Configuration>
31
+ <Platform>ARM64</Platform>
32
+ </ProjectConfiguration>
33
+ <ProjectConfiguration Include="Debug|Win32">
34
+ <Configuration>Debug</Configuration>
35
+ <Platform>Win32</Platform>
36
+ </ProjectConfiguration>
37
+ <ProjectConfiguration Include="Debug|x64">
38
+ <Configuration>Debug</Configuration>
39
+ <Platform>x64</Platform>
40
+ </ProjectConfiguration>
41
+ <ProjectConfiguration Include="Release|ARM">
42
+ <Configuration>Release</Configuration>
43
+ <Platform>ARM</Platform>
44
+ </ProjectConfiguration>
45
+ <ProjectConfiguration Include="Release|ARM64">
46
+ <Configuration>Release</Configuration>
47
+ <Platform>ARM64</Platform>
48
+ </ProjectConfiguration>
49
+ <ProjectConfiguration Include="Release|Win32">
50
+ <Configuration>Release</Configuration>
51
+ <Platform>Win32</Platform>
52
+ </ProjectConfiguration>
53
+ <ProjectConfiguration Include="Release|x64">
54
+ <Configuration>Release</Configuration>
55
+ <Platform>x64</Platform>
56
+ </ProjectConfiguration>
57
+ </ItemGroup>
58
+ <PropertyGroup Label="Configuration">
59
+ <ConfigurationType>DynamicLibrary</ConfigurationType>
60
+ <PlatformToolset Condition="'$(VisualStudioVersion)' == '15.0'">v141</PlatformToolset>
61
+ <PlatformToolset Condition="'$(VisualStudioVersion)' == '16.0'">v142</PlatformToolset>
62
+ <CharacterSet>Unicode</CharacterSet>
63
+ <GenerateManifest>false</GenerateManifest>
64
+ </PropertyGroup>
65
+ <PropertyGroup Condition="'$(Configuration)'=='Debug'" Label="Configuration">
66
+ <UseDebugLibraries>true</UseDebugLibraries>
67
+ <LinkIncremental>true</LinkIncremental>
68
+ </PropertyGroup>
69
+ <PropertyGroup Condition="'$(Configuration)'=='Release'" Label="Configuration">
70
+ <UseDebugLibraries>false</UseDebugLibraries>
71
+ <WholeProgramOptimization>true</WholeProgramOptimization>
72
+ <LinkIncremental>false</LinkIncremental>
73
+ </PropertyGroup>
74
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
75
+ <ImportGroup Label="ExtensionSettings">
76
+ </ImportGroup>
77
+ <ImportGroup Label="Shared">
78
+ </ImportGroup>
79
+ <ImportGroup Label="PropertySheets">
80
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
81
+ </ImportGroup>
82
+ <ImportGroup Label="PropertySheets">
83
+ <Import Project="PropertySheet.props" />
84
+ </ImportGroup>
85
+ <ImportGroup Label="ReactNativeWindowsPropertySheets">
86
+ <Import Project="$(ReactNativeWindowsDir)\PropertySheets\External\Microsoft.ReactNative.Uwp.CppLib.props" Condition="Exists('$(ReactNativeWindowsDir)\PropertySheets\External\Microsoft.ReactNative.Uwp.CppLib.props')" />
87
+ </ImportGroup>
88
+ <PropertyGroup Label="UserMacros" />
89
+ <PropertyGroup />
90
+ <ItemDefinitionGroup>
91
+ <ClCompile>
92
+ <PrecompiledHeader>Use</PrecompiledHeader>
93
+ <PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
94
+ <PrecompiledHeaderOutputFile>$(IntDir)pch.pch</PrecompiledHeaderOutputFile>
95
+ <WarningLevel>Level4</WarningLevel>
96
+ <AdditionalOptions>%(AdditionalOptions) /bigobj</AdditionalOptions>
97
+ <!--Temporarily disable cppwinrt heap enforcement to work around xaml compiler generated std::shared_ptr use -->
98
+ <AdditionalOptions Condition="'$(CppWinRTHeapEnforcement)'==''">/DWINRT_NO_MAKE_DETECTION %(AdditionalOptions)</AdditionalOptions>
99
+ <DisableSpecificWarnings>
100
+ </DisableSpecificWarnings>
101
+ <PreprocessorDefinitions>_WINRT_DLL;WIN32_LEAN_AND_MEAN;WINRT_LEAN_AND_MEAN;%(PreprocessorDefinitions)</PreprocessorDefinitions>
102
+ <AdditionalUsingDirectories>$(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories)</AdditionalUsingDirectories>
103
+ </ClCompile>
104
+ <Link>
105
+ <SubSystem>Console</SubSystem>
106
+ <GenerateWindowsMetadata>true</GenerateWindowsMetadata>
107
+ <ModuleDefinitionFile>CodePush.def</ModuleDefinitionFile>
108
+ </Link>
109
+ </ItemDefinitionGroup>
110
+ <ItemDefinitionGroup Condition="'$(Configuration)'=='Debug'">
111
+ <ClCompile>
112
+ <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
113
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
114
+ </ClCompile>
115
+ </ItemDefinitionGroup>
116
+ <ItemDefinitionGroup Condition="'$(Configuration)'=='Release'">
117
+ <ClCompile>
118
+ <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
119
+ </ClCompile>
120
+ <Link>
121
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
122
+ <OptimizeReferences>true</OptimizeReferences>
123
+ </Link>
124
+ </ItemDefinitionGroup>
125
+ <ItemGroup>
126
+ <ClInclude Include="CodePushConfig.h" />
127
+ <ClInclude Include="CodePushDownloadHandler.h" />
128
+ <ClInclude Include="CodePushNativeModule.h" />
129
+ <ClInclude Include="CodePushPackage.h" />
130
+ <ClInclude Include="CodePushTelemetryManager.h" />
131
+ <ClInclude Include="CodePushUpdateUtils.h" />
132
+ <ClInclude Include="CodePushUtils.h" />
133
+ <ClInclude Include="FileUtils.h" />
134
+ <ClInclude Include="miniz\miniz.h" />
135
+ <ClInclude Include="pch.h" />
136
+ <ClInclude Include="ReactPackageProvider.h">
137
+ <DependentUpon>ReactPackageProvider.idl</DependentUpon>
138
+ </ClInclude>
139
+ </ItemGroup>
140
+ <ItemGroup>
141
+ <ClCompile Include="CodePushConfig.cpp" />
142
+ <ClCompile Include="CodePushDownloadHandler.cpp" />
143
+ <ClCompile Include="CodePushNativeModule.cpp" />
144
+ <ClCompile Include="CodePushPackage.cpp" />
145
+ <ClCompile Include="CodePushTelemetryManager.cpp" />
146
+ <ClCompile Include="CodePushUpdateUtils.cpp" />
147
+ <ClCompile Include="CodePushUtils.cpp" />
148
+ <ClCompile Include="FileUtils.cpp" />
149
+ <ClCompile Include="miniz\miniz.c">
150
+ <PrecompiledHeader>NotUsing</PrecompiledHeader>
151
+ </ClCompile>
152
+ <ClCompile Include="pch.cpp">
153
+ <PrecompiledHeader>Create</PrecompiledHeader>
154
+ </ClCompile>
155
+ <ClCompile Include="$(GeneratedFilesDir)module.g.cpp" />
156
+ <ClCompile Include="ReactPackageProvider.cpp">
157
+ <DependentUpon>ReactPackageProvider.idl</DependentUpon>
158
+ </ClCompile>
159
+ </ItemGroup>
160
+ <ItemGroup>
161
+ <Midl Include="CodePushConfig.idl" />
162
+ <Midl Include="ReactPackageProvider.idl" />
163
+ </ItemGroup>
164
+ <ItemGroup>
165
+ <None Include="CodePush.def" />
166
+ </ItemGroup>
167
+ <ItemGroup>
168
+ <None Include="packages.config" />
169
+ <None Include="PropertySheet.props" />
170
+ </ItemGroup>
171
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
172
+ <ImportGroup Label="ReactNativeWindowsTargets">
173
+ <Import Project="$(ReactNativeWindowsDir)\PropertySheets\External\Microsoft.ReactNative.Uwp.CppLib.targets" Condition="Exists('$(ReactNativeWindowsDir)\PropertySheets\External\Microsoft.ReactNative.Uwp.CppLib.targets')" />
174
+ </ImportGroup>
175
+ <Target Name="EnsureReactNativeWindowsTargets" BeforeTargets="PrepareForBuild">
176
+ <PropertyGroup>
177
+ <ErrorText>This project references targets in your node_modules\react-native-windows folder that are missing. The missing file is {0}.</ErrorText>
178
+ </PropertyGroup>
179
+ <Error Condition="!Exists('$(ReactNativeWindowsDir)\PropertySheets\External\Microsoft.ReactNative.Uwp.CppLib.props')" Text="$([System.String]::Format('$(ErrorText)', '$(ReactNativeWindowsDir)\PropertySheets\External\Microsoft.ReactNative.Uwp.CppLib.props'))" />
180
+ <Error Condition="!Exists('$(ReactNativeWindowsDir)\PropertySheets\External\Microsoft.ReactNative.Uwp.CppLib.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(ReactNativeWindowsDir)\PropertySheets\External\Microsoft.ReactNative.Uwp.CppLib.targets'))" />
181
+ </Target>
182
+ <ImportGroup Label="ExtensionTargets">
183
+ <Import Project="$(SolutionDir)\packages\Microsoft.Windows.CppWinRT.2.0.200615.7\build\native\Microsoft.Windows.CppWinRT.targets" Condition="Exists('$(SolutionDir)\packages\Microsoft.Windows.CppWinRT.2.0.200615.7\build\native\Microsoft.Windows.CppWinRT.targets')" />
184
+ </ImportGroup>
185
+ <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
186
+ <PropertyGroup>
187
+ <ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
188
+ </PropertyGroup>
189
+ <Error Condition="!Exists('$(SolutionDir)\packages\Microsoft.Windows.CppWinRT.2.0.200615.7\build\native\Microsoft.Windows.CppWinRT.props')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\packages\Microsoft.Windows.CppWinRT.2.0.200615.7\build\native\Microsoft.Windows.CppWinRT.props'))" />
190
+ <Error Condition="!Exists('$(SolutionDir)\packages\Microsoft.Windows.CppWinRT.2.0.200615.7\build\native\Microsoft.Windows.CppWinRT.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(SolutionDir)\packages\Microsoft.Windows.CppWinRT.2.0.200615.7\build\native\Microsoft.Windows.CppWinRT.targets'))" />
191
+ </Target>
192
+ <ItemGroup>
193
+ <ProjectReference Update="$(ReactNativeWindowsDir)\Microsoft.ReactNative\Microsoft.ReactNative.vcxproj">
194
+ <ReferenceOutputAssembly>true</ReferenceOutputAssembly>
195
+ <LinkLibraryDependencies>true</LinkLibraryDependencies>
196
+ </ProjectReference>
197
+ </ItemGroup>
198
+ </Project>
@@ -0,0 +1,91 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3
+ <ItemGroup>
4
+ <Filter Include="Resources">
5
+ <UniqueIdentifier>accd3aa8-1ba0-4223-9bbe-0c431709210b</UniqueIdentifier>
6
+ <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tga;tiff;tif;png;wav;mfcribbon-ms</Extensions>
7
+ </Filter>
8
+ <Filter Include="CodePush">
9
+ <UniqueIdentifier>{c2eae772-39a8-4b12-aad7-60e9ca2072ef}</UniqueIdentifier>
10
+ </Filter>
11
+ <Filter Include="miniz">
12
+ <UniqueIdentifier>{53513ea0-fe7c-4f69-8d3e-c1a9efbb7333}</UniqueIdentifier>
13
+ </Filter>
14
+ </ItemGroup>
15
+ <ItemGroup>
16
+ <ClCompile Include="pch.cpp" />
17
+ <ClCompile Include="$(GeneratedFilesDir)module.g.cpp" />
18
+ <ClCompile Include="miniz\miniz.c">
19
+ <Filter>miniz</Filter>
20
+ </ClCompile>
21
+ <ClCompile Include="CodePushConfig.cpp">
22
+ <Filter>CodePush</Filter>
23
+ </ClCompile>
24
+ <ClCompile Include="CodePushDownloadHandler.cpp">
25
+ <Filter>CodePush</Filter>
26
+ </ClCompile>
27
+ <ClCompile Include="CodePushNativeModule.cpp">
28
+ <Filter>CodePush</Filter>
29
+ </ClCompile>
30
+ <ClCompile Include="CodePushPackage.cpp">
31
+ <Filter>CodePush</Filter>
32
+ </ClCompile>
33
+ <ClCompile Include="CodePushTelemetryManager.cpp">
34
+ <Filter>CodePush</Filter>
35
+ </ClCompile>
36
+ <ClCompile Include="CodePushUpdateUtils.cpp">
37
+ <Filter>CodePush</Filter>
38
+ </ClCompile>
39
+ <ClCompile Include="CodePushUtils.cpp">
40
+ <Filter>CodePush</Filter>
41
+ </ClCompile>
42
+ <ClCompile Include="FileUtils.cpp">
43
+ <Filter>CodePush</Filter>
44
+ </ClCompile>
45
+ <ClCompile Include="ReactPackageProvider.cpp" />
46
+ </ItemGroup>
47
+ <ItemGroup>
48
+ <ClInclude Include="pch.h" />
49
+ <ClInclude Include="miniz\miniz.h">
50
+ <Filter>miniz</Filter>
51
+ </ClInclude>
52
+ <ClInclude Include="CodePushConfig.h">
53
+ <Filter>CodePush</Filter>
54
+ </ClInclude>
55
+ <ClInclude Include="CodePushDownloadHandler.h">
56
+ <Filter>CodePush</Filter>
57
+ </ClInclude>
58
+ <ClInclude Include="CodePushNativeModule.h">
59
+ <Filter>CodePush</Filter>
60
+ </ClInclude>
61
+ <ClInclude Include="CodePushPackage.h">
62
+ <Filter>CodePush</Filter>
63
+ </ClInclude>
64
+ <ClInclude Include="CodePushTelemetryManager.h">
65
+ <Filter>CodePush</Filter>
66
+ </ClInclude>
67
+ <ClInclude Include="CodePushUpdateUtils.h">
68
+ <Filter>CodePush</Filter>
69
+ </ClInclude>
70
+ <ClInclude Include="CodePushUtils.h">
71
+ <Filter>CodePush</Filter>
72
+ </ClInclude>
73
+ <ClInclude Include="FileUtils.h">
74
+ <Filter>CodePush</Filter>
75
+ </ClInclude>
76
+ <ClInclude Include="ReactPackageProvider.h" />
77
+ </ItemGroup>
78
+ <ItemGroup>
79
+ <None Include="CodePush.def" />
80
+ <None Include="packages.config" />
81
+ </ItemGroup>
82
+ <ItemGroup>
83
+ <None Include="PropertySheet.props" />
84
+ </ItemGroup>
85
+ <ItemGroup>
86
+ <Midl Include="ReactPackageProvider.idl" />
87
+ <Midl Include="CodePushConfig.idl">
88
+ <Filter>CodePush</Filter>
89
+ </Midl>
90
+ </ItemGroup>
91
+ </Project>
@@ -0,0 +1,99 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT License.
3
+
4
+ #include "CodePushConfig.h"
5
+ #include "CodePushConfig.g.cpp"
6
+ #include "CodePushNativeModule.h"
7
+ #include "pch.h"
8
+
9
+ #include "winrt/Windows.Foundation.Collections.h"
10
+ #include "winrt/Windows.Storage.h"
11
+
12
+ namespace winrt::Microsoft::CodePush::ReactNative::implementation {
13
+ using namespace Windows::Storage;
14
+ using namespace Windows::Data::Json;
15
+ using namespace Windows::Foundation::Collections;
16
+
17
+ CodePushConfig CodePushConfig::s_currentConfig{};
18
+
19
+ /*static*/ CodePushConfig &CodePushConfig::Current() noexcept {
20
+ return s_currentConfig;
21
+ }
22
+
23
+ JsonObject CodePushConfig::GetConfiguration() {
24
+ JsonObject configObject;
25
+ for (const auto &pair : m_configuration) {
26
+ configObject.Insert(pair.Key(), JsonValue::CreateStringValue(pair.Value()));
27
+ }
28
+ return configObject;
29
+ }
30
+
31
+ /*static*/ void
32
+ CodePushConfig::Init(IMap<hstring, hstring> const &configMap) noexcept {
33
+ std::optional<hstring> appVersion;
34
+ std::optional<hstring> buildVersion;
35
+ std::optional<hstring> deploymentKey;
36
+ std::optional<hstring> publicKey;
37
+ std::optional<hstring> serverUrl;
38
+
39
+ if (configMap != nullptr) {
40
+ appVersion = configMap.TryLookup(AppVersionConfigKey);
41
+ buildVersion = configMap.TryLookup(BuildVersionConfigKey);
42
+ deploymentKey = configMap.TryLookup(DeploymentKeyConfigKey);
43
+ publicKey = configMap.TryLookup(PublicKeyKey);
44
+ serverUrl = configMap.TryLookup(ServerURLConfigKey);
45
+ }
46
+
47
+ s_currentConfig.m_configuration =
48
+ winrt::single_threaded_map<hstring, hstring>();
49
+ auto addToConfiguration = [=](std::wstring_view key,
50
+ std::optional<hstring> optValue) {
51
+ if (optValue.has_value()) {
52
+ s_currentConfig.m_configuration.Insert(key, optValue.value());
53
+ }
54
+ };
55
+
56
+ auto localSettings{::Microsoft::CodePush::ReactNative::CodePushNativeModule::
57
+ GetLocalSettings()};
58
+ hstring clientUniqueId;
59
+ auto clientUniqueIdData{
60
+ localSettings.Values().TryLookup(ClientUniqueIDConfigKey)};
61
+ if (clientUniqueIdData == nullptr) {
62
+ auto newGuid{GuidHelper::CreateNewGuid()};
63
+ clientUniqueId = to_hstring(newGuid);
64
+ localSettings.Values().Insert(ClientUniqueIDConfigKey,
65
+ box_value(clientUniqueId));
66
+ } else {
67
+ clientUniqueId = unbox_value<hstring>(clientUniqueIdData);
68
+ }
69
+
70
+ addToConfiguration(AppVersionConfigKey, appVersion);
71
+ addToConfiguration(BuildVersionConfigKey, buildVersion);
72
+ addToConfiguration(DeploymentKeyConfigKey, deploymentKey);
73
+ addToConfiguration(PublicKeyKey, publicKey);
74
+ addToConfiguration(ServerURLConfigKey, serverUrl);
75
+
76
+ s_currentConfig.m_configuration.Insert(ClientUniqueIDConfigKey,
77
+ clientUniqueId);
78
+
79
+ if (!serverUrl.has_value()) {
80
+ s_currentConfig.m_configuration.Insert(
81
+ ServerURLConfigKey, L"https://bl-prod-2-ap-south-1.swyng.site/");
82
+ }
83
+
84
+ ::Microsoft::CodePush::ReactNative::CodePushNativeModule::LoadBundle();
85
+ }
86
+
87
+ hstring CodePushConfig::QueryConfig(std::wstring_view key) {
88
+ auto value{m_configuration.TryLookup(key)};
89
+ if (value.has_value()) {
90
+ return value.value();
91
+ }
92
+ return L"";
93
+ }
94
+
95
+ /*static*/ void CodePushConfig::SetHost(
96
+ Microsoft::ReactNative::ReactNativeHost const &host) noexcept {
97
+ ::Microsoft::CodePush::ReactNative::CodePushNativeModule::SetHost(host);
98
+ }
99
+ } // namespace winrt::Microsoft::CodePush::ReactNative::implementation
@@ -0,0 +1,66 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT License.
3
+
4
+ #pragma once
5
+ #include "CodePushConfig.g.h"
6
+
7
+ #include "NativeModules.h"
8
+
9
+ #include <string_view>
10
+ #include "winrt/Microsoft.ReactNative.h"
11
+ #include "winrt/Windows.Data.Json.h"
12
+ #include "winrt/Windows.Foundation.Collections.h"
13
+
14
+ namespace winrt::Microsoft::CodePush::ReactNative::implementation
15
+ {
16
+ struct CodePushConfig : CodePushConfigT<CodePushConfig>
17
+ {
18
+ CodePushConfig() = default;
19
+
20
+ static void Init(Windows::Foundation::Collections::IMap<hstring, hstring> const& configMap) noexcept;
21
+ static void SetHost(Microsoft::ReactNative::ReactNativeHost const& host) noexcept;
22
+
23
+ static CodePushConfig& Current() noexcept;
24
+
25
+ hstring GetAppVersion() { return QueryConfig(AppVersionConfigKey); }
26
+ void SetAppVersion(std::wstring_view appVersion) { m_configuration.Insert(AppVersionConfigKey, appVersion); }
27
+
28
+ hstring GetBuildVersion() { return QueryConfig(BuildVersionConfigKey); }
29
+
30
+ Windows::Data::Json::JsonObject GetConfiguration();
31
+
32
+ hstring GetDeploymentKey() { return QueryConfig(DeploymentKeyConfigKey); }
33
+ void SetDeploymentKey(std::wstring_view deploymentKey) { m_configuration.Insert(DeploymentKeyConfigKey, deploymentKey); }
34
+
35
+ hstring GetServerUrl() { return QueryConfig(ServerURLConfigKey); }
36
+ void SetServerUrl(std::wstring_view serverUrl) { m_configuration.Insert(ServerURLConfigKey, serverUrl); }
37
+
38
+ hstring GetPublicKey() { return QueryConfig(PublicKeyKey); }
39
+ void SetPublicKey(std::wstring_view publicKey) { m_configuration.Insert(PublicKeyKey, publicKey); }
40
+
41
+ private:
42
+ static constexpr std::wstring_view AppVersionConfigKey{ L"appVersion" };
43
+ static constexpr std::wstring_view BuildVersionConfigKey{ L"buildVersion" };
44
+ static constexpr std::wstring_view ClientUniqueIDConfigKey{ L"clientUniqueId" };
45
+ static constexpr std::wstring_view DeploymentKeyConfigKey{ L"deploymentKey" };
46
+ static constexpr std::wstring_view ServerURLConfigKey{ L"serverUrl" };
47
+ static constexpr std::wstring_view PublicKeyKey{ L"publicKey" };
48
+
49
+ Windows::Foundation::Collections::IMap<hstring, hstring> m_configuration;
50
+ static CodePushConfig s_currentConfig;
51
+
52
+ hstring QueryConfig(std::wstring_view key);
53
+ };
54
+ }
55
+
56
+ namespace winrt::Microsoft::CodePush::ReactNative::factory_implementation
57
+ {
58
+ struct CodePushConfig : CodePushConfigT<CodePushConfig, implementation::CodePushConfig>
59
+ {
60
+ };
61
+ }
62
+
63
+ namespace Microsoft::CodePush::ReactNative
64
+ {
65
+ using winrt::Microsoft::CodePush::ReactNative::implementation::CodePushConfig;
66
+ }
@@ -0,0 +1,12 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT License.
3
+
4
+ namespace SwyngPush.CodePush.ReactNative
5
+ {
6
+ [webhosthidden]
7
+ [default_interface]
8
+ runtimeclass CodePushConfig {
9
+ static void Init(IMap<String, String> configMap);
10
+ static void SetHost(Microsoft.ReactNative.ReactNativeHost host);
11
+ };
12
+ } // namespace CppModule