@appzung/react-native-code-push 6.3.1 → 7.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/CodePush.js +10 -7
  2. package/CodePush.podspec +2 -2
  3. package/README.md +35 -21
  4. package/SECURITY.md +41 -0
  5. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushNativeModule.java +10 -0
  6. package/android/app/src/main/java/com/microsoft/codepush/react/CodePushUpdateManager.java +14 -0
  7. package/android/app/src/main/java/com/microsoft/codepush/react/FileUtils.java +8 -9
  8. package/android/app/src/main/java/com/microsoft/codepush/react/TLSSocketFactory.java +72 -0
  9. package/android/codepush.gradle +11 -8
  10. package/docs/multi-deployment-testing-android.md +1 -1
  11. package/docs/multi-deployment-testing-ios.md +1 -1
  12. package/docs/setup-android.md +7 -6
  13. package/docs/setup-ios.md +5 -5
  14. package/docs/setup-windows.md +37 -4
  15. package/ios/CodePush/CodePush.m +26 -11
  16. package/ios/CodePush/CodePushUpdateUtils.m +1 -1
  17. package/ios/CodePush.xcodeproj/project.pbxproj +2 -2
  18. package/package.json +16 -16
  19. package/windows/CodePush/CodePush.def +3 -0
  20. package/windows/CodePush/CodePush.vcxproj +199 -0
  21. package/windows/CodePush/CodePush.vcxproj.filters +91 -0
  22. package/windows/CodePush/CodePushConfig.cpp +104 -0
  23. package/windows/CodePush/CodePushConfig.h +66 -0
  24. package/windows/CodePush/CodePushConfig.idl +12 -0
  25. package/windows/CodePush/CodePushDownloadHandler.cpp +73 -0
  26. package/windows/CodePush/CodePushDownloadHandler.h +32 -0
  27. package/windows/CodePush/CodePushNativeModule.cpp +934 -0
  28. package/windows/CodePush/CodePushNativeModule.h +247 -0
  29. package/windows/CodePush/CodePushPackage.cpp +456 -0
  30. package/windows/CodePush/CodePushPackage.h +49 -0
  31. package/windows/CodePush/CodePushTelemetryManager.cpp +213 -0
  32. package/windows/CodePush/CodePushTelemetryManager.h +29 -0
  33. package/windows/CodePush/CodePushUpdateUtils.cpp +86 -0
  34. package/windows/CodePush/CodePushUpdateUtils.h +38 -0
  35. package/windows/CodePush/CodePushUtils.cpp +29 -0
  36. package/windows/CodePush/CodePushUtils.h +18 -0
  37. package/windows/CodePush/FileUtils.cpp +131 -0
  38. package/windows/CodePush/FileUtils.h +28 -0
  39. package/windows/CodePush/PropertySheet.props +16 -0
  40. package/windows/CodePush/ReactPackageProvider.cpp +15 -0
  41. package/windows/CodePush/ReactPackageProvider.h +22 -0
  42. package/windows/CodePush/ReactPackageProvider.idl +9 -0
  43. package/windows/CodePush/miniz/LICENSE +22 -0
  44. package/windows/CodePush/miniz/miniz.c +7657 -0
  45. package/windows/CodePush/miniz/miniz.h +1338 -0
  46. package/windows/CodePush/miniz/readme.md +37 -0
  47. package/windows/CodePush/packages.config +4 -0
  48. package/windows/CodePush/pch.cpp +1 -0
  49. package/windows/CodePush/pch.h +4 -0
  50. package/{windows → windows-legacy}/CodePush/CodePush.csproj +1 -1
  51. package/{windows → windows-legacy}/CodePush.Net46/packages.config +1 -1
  52. package/windows-legacy/CodePush.Net46.Test/ApplicationDataContainerTest.cs +105 -0
  53. package/windows-legacy/CodePush.Net46.Test/CodePush.Net46.Test.csproj +137 -0
  54. package/windows-legacy/CodePush.Net46.Test/Properties/AssemblyInfo.cs +36 -0
  55. package/windows-legacy/CodePush.Net46.Test/TelemetryManagerTest.cs +117 -0
  56. package/windows-legacy/CodePush.Net46.Test/app.config +11 -0
  57. package/windows-legacy/CodePush.Net46.Test/packages.config +4 -0
  58. /package/{windows → windows-legacy}/CodePush/CodePushUtils.cs +0 -0
  59. /package/{windows → windows-legacy}/CodePush/FileUtils.cs +0 -0
  60. /package/{windows → windows-legacy}/CodePush/Properties/AssemblyInfo.cs +0 -0
  61. /package/{windows → windows-legacy}/CodePush/Properties/CodePush.rd.xml +0 -0
  62. /package/{windows → windows-legacy}/CodePush/UpdateManager.cs +0 -0
  63. /package/{windows → windows-legacy}/CodePush/UpdateUtils.cs +0 -0
  64. /package/{windows → windows-legacy}/CodePush.Net46/Adapters/Http/HttpProgress.cs +0 -0
  65. /package/{windows → windows-legacy}/CodePush.Net46/Adapters/Storage/ApplicationDataContainer.cs +0 -0
  66. /package/{windows → windows-legacy}/CodePush.Net46/CodePush.Net46.csproj +0 -0
  67. /package/{windows → windows-legacy}/CodePush.Net46/CodePushUtils.cs +0 -0
  68. /package/{windows → windows-legacy}/CodePush.Net46/FileUtils.cs +0 -0
  69. /package/{windows → windows-legacy}/CodePush.Net46/Properties/AssemblyInfo.cs +0 -0
  70. /package/{windows → windows-legacy}/CodePush.Net46/UpdateManager.cs +0 -0
  71. /package/{windows → windows-legacy}/CodePush.Net46/UpdateUtils.cs +0 -0
  72. /package/{windows → windows-legacy}/CodePush.Shared/CodePush.Shared.projitems +0 -0
  73. /package/{windows → windows-legacy}/CodePush.Shared/CodePush.Shared.shproj +0 -0
  74. /package/{windows → windows-legacy}/CodePush.Shared/CodePushConstants.cs +0 -0
  75. /package/{windows → windows-legacy}/CodePush.Shared/CodePushNativeModule.cs +0 -0
  76. /package/{windows → windows-legacy}/CodePush.Shared/CodePushReactPackage.cs +0 -0
  77. /package/{windows → windows-legacy}/CodePush.Shared/CodePushUtils.cs +0 -0
  78. /package/{windows → windows-legacy}/CodePush.Shared/InstallMode.cs +0 -0
  79. /package/{windows → windows-legacy}/CodePush.Shared/MinimumBackgroundListener.cs +0 -0
  80. /package/{windows → windows-legacy}/CodePush.Shared/SettingsManager.cs +0 -0
  81. /package/{windows → windows-legacy}/CodePush.Shared/TelemetryManager.cs +0 -0
  82. /package/{windows → windows-legacy}/CodePush.Shared/UpdateState.cs +0 -0
@@ -2,9 +2,42 @@
2
2
 
3
3
  Once you've acquired the CodePush plugin, you need to integrate it into the Visual Studio project of your React Native app and configure it correctly. To do this, take the following steps:
4
4
 
5
- ### Plugin Installation (Windows)
5
+ ### Plugin Installation and Configuration for React Native Windows 0.63.6 version and above
6
6
 
7
- 1. Open the Visual Studio solution located at `windows\<AppName>\<AppName>.sln` within your app
7
+ #### Plugin Installation (Windows-npx)
8
+
9
+ Once the plugin has been downloaded, run `npx react-native autolink-windows` in your application's root directory to automatically add the CodePush c++ project to your application's windows solution file.
10
+
11
+ #### Plugin Configuration (Windows)
12
+
13
+ 1. Replace the following files located at `windows/<app name>` with those in the CodePushDemoAppCpp example app in this repo found at `Examples/CodePushDemoAppCpp/windows/CodePushDemoAppCpp`:
14
+ 1. app.h
15
+ 2. app.cpp
16
+ 3. app.xaml
17
+
18
+ 2. In the above files, replace any occurance of `CodePushDemoAppCpp` with the name of your application
19
+
20
+ 3. Enter your application's app version and deployment key to the `configMap` object at the top of your app's `OnLaunched` method in `App.cpp`:
21
+
22
+ ```c++
23
+ ...
24
+ void App::OnLaunched(activation::LaunchActivatedEventArgs const& e)
25
+ {
26
+ winrt::Microsoft::CodePush::ReactNative::CodePushConfig::SetHost(Host());
27
+ auto configMap{ winrt::single_threaded_map<hstring, hstring>() };
28
+ configMap.Insert(L"appVersion", L"1.0.0");
29
+ configMap.Insert(L"deploymentKey", L"<app deployment key>");
30
+ winrt::Microsoft::CodePush::ReactNative::CodePushConfig::Init(configMap);
31
+ ...
32
+ }
33
+ ...
34
+ ```
35
+
36
+ ### Plugin Installation and Configuration for React Native Windows lower than 0.60
37
+
38
+ #### Plugin Installation (Windows)
39
+
40
+ 1. Open the Visual Studio solution located at `windows-legacy\<AppName>\<AppName>.sln` within your app
8
41
 
9
42
  2. Right-click the solution node in the `Solution Explorer` window and select the `Add -> Existing Project...` menu item
10
43
 
@@ -20,7 +53,7 @@ Once you've acquired the CodePush plugin, you need to integrate it into the Visu
20
53
 
21
54
  ![Add Reference Dialog](https://cloud.githubusercontent.com/assets/116461/14467147/cb805b6e-008e-11e6-964f-f856c59b65af.PNG)
22
55
 
23
- ### Plugin Configuration (Windows)
56
+ #### Plugin Configuration (Windows)
24
57
 
25
58
  After installing the plugin, you need to configure your app to consult CodePush for the location of your JS bundle, since it will "take control" of managing the current and all future versions. To do this, update the `MainReactNativeHost.cs` file to use CodePush via the following changes:
26
59
 
@@ -37,7 +70,7 @@ class MainReactNativeHost : ReactNativeHost
37
70
  // 3. Update the JavaScriptBundleFile property to initalize the CodePush runtime,
38
71
  // specifying the right deployment key, then use it to return the bundle URL from
39
72
  // CodePush instead of statically from the binary. If you don't already have your
40
- // deployment key, you can run "code-push deployment ls <appName> -k" to retrieve it.
73
+ // deployment key, you can run "appcenter codepush deployment list -a <ownerName>/<appName> -k" to retrieve it.
41
74
  protected override string JavaScriptBundleFile
42
75
  {
43
76
  get
@@ -643,28 +643,38 @@ static NSString *const LatestRollbackCountKey = @"count";
643
643
  return @[DownloadProgressEvent];
644
644
  }
645
645
 
646
- #pragma mark - Application lifecycle event handlers
647
-
648
- // These two handlers will only be registered when there is
649
- // a resume-based update still pending installation.
650
- - (void)applicationWillEnterForeground
646
+ // Determine how long the app was in the background
647
+ - (int)getDurationInBackground
651
648
  {
652
- // Determine how long the app was in the background and ensure
653
- // that it meets the minimum duration amount of time.
654
- int durationInBackground = 0;
649
+ int duration = 0;
655
650
  if (_lastResignedDate) {
656
- durationInBackground = [[NSDate date] timeIntervalSinceDate:_lastResignedDate];
651
+ duration = [[NSDate date] timeIntervalSinceDate:_lastResignedDate];
657
652
  }
658
653
 
654
+ return duration;
655
+ }
656
+
657
+ #pragma mark - Application lifecycle event handlers
658
+
659
+ // These three handlers will only be registered when there is
660
+ // a resume-based update still pending installation.
661
+ - (void)applicationDidBecomeActive
662
+ {
659
663
  if (_installMode == CodePushInstallModeOnNextSuspend) {
664
+ int durationInBackground = [self getDurationInBackground];
660
665
  // We shouldn't use loadBundle in this case, because _appSuspendTimer will call loadBundleOnTick.
661
666
  // We should cancel timer for _appSuspendTimer because otherwise, we would call loadBundle two times.
662
667
  if (durationInBackground < _minimumBackgroundDuration) {
663
668
  [_appSuspendTimer invalidate];
664
669
  _appSuspendTimer = nil;
665
670
  }
666
- } else {
667
- // For resume install mode.
671
+ }
672
+ }
673
+
674
+ - (void)applicationWillEnterForeground
675
+ {
676
+ if (_installMode == CodePushInstallModeOnNextResume) {
677
+ int durationInBackground = [self getDurationInBackground];
668
678
  if (durationInBackground >= _minimumBackgroundDuration) {
669
679
  [self restartAppInternal:NO];
670
680
  }
@@ -899,6 +909,11 @@ RCT_EXPORT_METHOD(installUpdate:(NSDictionary*)updatePackage
899
909
  // Ensure we do not add the listener twice.
900
910
  // Register for app resume notifications so that we
901
911
  // can check for pending updates which support "restart on resume"
912
+ [[NSNotificationCenter defaultCenter] addObserver:self
913
+ selector:@selector(applicationDidBecomeActive)
914
+ name:UIApplicationDidBecomeActiveNotification
915
+ object:RCTSharedApplication()];
916
+
902
917
  [[NSNotificationCenter defaultCenter] addObserver:self
903
918
  selector:@selector(applicationWillEnterForeground)
904
919
  name:UIApplicationWillEnterForegroundNotification
@@ -93,7 +93,7 @@ NSString * const IgnoreCodePushMetadata = @".codepushrelease";
93
93
  // The JSON serialization turns path separators into "\/", e.g. "CodePush\/assets\/image.png"
94
94
  manifestString = [manifestString stringByReplacingOccurrencesOfString:@"\\/"
95
95
  withString:@"/"];
96
- return [self computeHashForData:[NSData dataWithBytes:manifestString.UTF8String length:manifestString.length]];
96
+ return [self computeHashForData:[NSData dataWithBytes:manifestString.UTF8String length:[manifestString lengthOfBytesUsingEncoding:NSUTF8StringEncoding]]];
97
97
  }
98
98
 
99
99
  + (NSString *)computeHashForData:(NSData *)inputData
@@ -771,7 +771,7 @@
771
771
  GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
772
772
  GCC_WARN_UNUSED_FUNCTION = YES;
773
773
  GCC_WARN_UNUSED_VARIABLE = YES;
774
- IPHONEOS_DEPLOYMENT_TARGET = 8.0;
774
+ IPHONEOS_DEPLOYMENT_TARGET = 9.0;
775
775
  MTL_ENABLE_DEBUG_INFO = YES;
776
776
  ONLY_ACTIVE_ARCH = YES;
777
777
  SDKROOT = iphoneos;
@@ -817,7 +817,7 @@
817
817
  GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
818
818
  GCC_WARN_UNUSED_FUNCTION = YES;
819
819
  GCC_WARN_UNUSED_VARIABLE = YES;
820
- IPHONEOS_DEPLOYMENT_TARGET = 8.0;
820
+ IPHONEOS_DEPLOYMENT_TARGET = 9.0;
821
821
  MTL_ENABLE_DEBUG_INFO = NO;
822
822
  SDKROOT = iphoneos;
823
823
  USER_HEADER_SEARCH_PATHS = "";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@appzung/react-native-code-push",
3
- "version": "6.3.1",
3
+ "version": "7.1.1",
4
4
  "description": "React Native plugin for the CodePush service",
5
5
  "main": "CodePush.js",
6
6
  "typings": "typings/react-native-code-push.d.ts",
@@ -25,33 +25,33 @@
25
25
  "tslint": "tslint -c tslint.json test/**/*.ts"
26
26
  },
27
27
  "dependencies": {
28
- "code-push": "^3.1.0",
29
- "glob": "^7.1.6",
28
+ "code-push": "^4.1.0",
29
+ "glob": "^7.1.7",
30
30
  "hoist-non-react-statics": "^3.3.2",
31
- "inquirer": "^7.2.0",
32
- "plist": "3.0.1",
33
- "semver": "^7.3.2",
31
+ "inquirer": "^8.1.5",
32
+ "plist": "^3.0.4",
33
+ "semver": "^7.3.5",
34
34
  "xcode": "3.0.1"
35
35
  },
36
36
  "devDependencies": {
37
- "@types/assert": "^1.4.3",
38
- "@types/mkdirp": "^1.0.0",
39
- "@types/mocha": "^7.0.2",
40
- "@types/node": "^14.0.13",
41
- "@types/q": "^1.5.2",
37
+ "@types/assert": "^1.5.2",
38
+ "@types/mkdirp": "^1.0.1",
39
+ "@types/mocha": "^9.0.0",
40
+ "@types/node": "^14.0.27",
41
+ "@types/q": "^1.5.4",
42
42
  "archiver": "latest",
43
43
  "body-parser": "latest",
44
44
  "code-push-plugin-testing-framework": "file:./code-push-plugin-testing-framework",
45
- "del": "latest",
45
+ "del": "v6.0.0",
46
46
  "express": "latest",
47
47
  "mkdirp": "latest",
48
- "mocha": "^8.0.1",
48
+ "mocha": "^9.2.0",
49
49
  "q": "^1.5.1",
50
50
  "run-sequence": "latest",
51
- "shx": "^0.3.2",
51
+ "shx": "^0.3.4",
52
52
  "slash": "^3.0.0",
53
- "tslint": "^6.1.1",
54
- "typescript": "^3.9.5"
53
+ "tslint": "^6.1.3",
54
+ "typescript": "^4.4.3"
55
55
  },
56
56
  "rnpm": {
57
57
  "android": {
@@ -0,0 +1,3 @@
1
+ EXPORTS
2
+ DllCanUnloadNow = WINRT_CanUnloadNow PRIVATE
3
+ DllGetActivationFactory = WINRT_GetActivationFactory PRIVATE
@@ -0,0 +1,199 @@
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.18362.0</WindowsTargetPlatformVersion>
18
+ <WindowsTargetPlatformMinVersion>10.0.17134.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>v140</PlatformToolset>
61
+ <PlatformToolset Condition="'$(VisualStudioVersion)' == '15.0'">v141</PlatformToolset>
62
+ <PlatformToolset Condition="'$(VisualStudioVersion)' == '16.0'">v142</PlatformToolset>
63
+ <CharacterSet>Unicode</CharacterSet>
64
+ <GenerateManifest>false</GenerateManifest>
65
+ </PropertyGroup>
66
+ <PropertyGroup Condition="'$(Configuration)'=='Debug'" Label="Configuration">
67
+ <UseDebugLibraries>true</UseDebugLibraries>
68
+ <LinkIncremental>true</LinkIncremental>
69
+ </PropertyGroup>
70
+ <PropertyGroup Condition="'$(Configuration)'=='Release'" Label="Configuration">
71
+ <UseDebugLibraries>false</UseDebugLibraries>
72
+ <WholeProgramOptimization>true</WholeProgramOptimization>
73
+ <LinkIncremental>false</LinkIncremental>
74
+ </PropertyGroup>
75
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
76
+ <ImportGroup Label="ExtensionSettings">
77
+ </ImportGroup>
78
+ <ImportGroup Label="Shared">
79
+ </ImportGroup>
80
+ <ImportGroup Label="PropertySheets">
81
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
82
+ </ImportGroup>
83
+ <ImportGroup Label="PropertySheets">
84
+ <Import Project="PropertySheet.props" />
85
+ </ImportGroup>
86
+ <ImportGroup Label="ReactNativeWindowsPropertySheets">
87
+ <Import Project="$(ReactNativeWindowsDir)\PropertySheets\External\Microsoft.ReactNative.Uwp.CppLib.props" Condition="Exists('$(ReactNativeWindowsDir)\PropertySheets\External\Microsoft.ReactNative.Uwp.CppLib.props')" />
88
+ </ImportGroup>
89
+ <PropertyGroup Label="UserMacros" />
90
+ <PropertyGroup />
91
+ <ItemDefinitionGroup>
92
+ <ClCompile>
93
+ <PrecompiledHeader>Use</PrecompiledHeader>
94
+ <PrecompiledHeaderFile>pch.h</PrecompiledHeaderFile>
95
+ <PrecompiledHeaderOutputFile>$(IntDir)pch.pch</PrecompiledHeaderOutputFile>
96
+ <WarningLevel>Level4</WarningLevel>
97
+ <AdditionalOptions>%(AdditionalOptions) /bigobj</AdditionalOptions>
98
+ <!--Temporarily disable cppwinrt heap enforcement to work around xaml compiler generated std::shared_ptr use -->
99
+ <AdditionalOptions Condition="'$(CppWinRTHeapEnforcement)'==''">/DWINRT_NO_MAKE_DETECTION %(AdditionalOptions)</AdditionalOptions>
100
+ <DisableSpecificWarnings>
101
+ </DisableSpecificWarnings>
102
+ <PreprocessorDefinitions>_WINRT_DLL;WIN32_LEAN_AND_MEAN;WINRT_LEAN_AND_MEAN;%(PreprocessorDefinitions)</PreprocessorDefinitions>
103
+ <AdditionalUsingDirectories>$(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories)</AdditionalUsingDirectories>
104
+ </ClCompile>
105
+ <Link>
106
+ <SubSystem>Console</SubSystem>
107
+ <GenerateWindowsMetadata>true</GenerateWindowsMetadata>
108
+ <ModuleDefinitionFile>CodePush.def</ModuleDefinitionFile>
109
+ </Link>
110
+ </ItemDefinitionGroup>
111
+ <ItemDefinitionGroup Condition="'$(Configuration)'=='Debug'">
112
+ <ClCompile>
113
+ <PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
114
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
115
+ </ClCompile>
116
+ </ItemDefinitionGroup>
117
+ <ItemDefinitionGroup Condition="'$(Configuration)'=='Release'">
118
+ <ClCompile>
119
+ <PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
120
+ </ClCompile>
121
+ <Link>
122
+ <EnableCOMDATFolding>true</EnableCOMDATFolding>
123
+ <OptimizeReferences>true</OptimizeReferences>
124
+ </Link>
125
+ </ItemDefinitionGroup>
126
+ <ItemGroup>
127
+ <ClInclude Include="CodePushConfig.h" />
128
+ <ClInclude Include="CodePushDownloadHandler.h" />
129
+ <ClInclude Include="CodePushNativeModule.h" />
130
+ <ClInclude Include="CodePushPackage.h" />
131
+ <ClInclude Include="CodePushTelemetryManager.h" />
132
+ <ClInclude Include="CodePushUpdateUtils.h" />
133
+ <ClInclude Include="CodePushUtils.h" />
134
+ <ClInclude Include="FileUtils.h" />
135
+ <ClInclude Include="miniz\miniz.h" />
136
+ <ClInclude Include="pch.h" />
137
+ <ClInclude Include="ReactPackageProvider.h">
138
+ <DependentUpon>ReactPackageProvider.idl</DependentUpon>
139
+ </ClInclude>
140
+ </ItemGroup>
141
+ <ItemGroup>
142
+ <ClCompile Include="CodePushConfig.cpp" />
143
+ <ClCompile Include="CodePushDownloadHandler.cpp" />
144
+ <ClCompile Include="CodePushNativeModule.cpp" />
145
+ <ClCompile Include="CodePushPackage.cpp" />
146
+ <ClCompile Include="CodePushTelemetryManager.cpp" />
147
+ <ClCompile Include="CodePushUpdateUtils.cpp" />
148
+ <ClCompile Include="CodePushUtils.cpp" />
149
+ <ClCompile Include="FileUtils.cpp" />
150
+ <ClCompile Include="miniz\miniz.c">
151
+ <PrecompiledHeader>NotUsing</PrecompiledHeader>
152
+ </ClCompile>
153
+ <ClCompile Include="pch.cpp">
154
+ <PrecompiledHeader>Create</PrecompiledHeader>
155
+ </ClCompile>
156
+ <ClCompile Include="$(GeneratedFilesDir)module.g.cpp" />
157
+ <ClCompile Include="ReactPackageProvider.cpp">
158
+ <DependentUpon>ReactPackageProvider.idl</DependentUpon>
159
+ </ClCompile>
160
+ </ItemGroup>
161
+ <ItemGroup>
162
+ <Midl Include="CodePushConfig.idl" />
163
+ <Midl Include="ReactPackageProvider.idl" />
164
+ </ItemGroup>
165
+ <ItemGroup>
166
+ <None Include="CodePush.def" />
167
+ </ItemGroup>
168
+ <ItemGroup>
169
+ <None Include="packages.config" />
170
+ <None Include="PropertySheet.props" />
171
+ </ItemGroup>
172
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
173
+ <ImportGroup Label="ReactNativeWindowsTargets">
174
+ <Import Project="$(ReactNativeWindowsDir)\PropertySheets\External\Microsoft.ReactNative.Uwp.CppLib.targets" Condition="Exists('$(ReactNativeWindowsDir)\PropertySheets\External\Microsoft.ReactNative.Uwp.CppLib.targets')" />
175
+ </ImportGroup>
176
+ <Target Name="EnsureReactNativeWindowsTargets" BeforeTargets="PrepareForBuild">
177
+ <PropertyGroup>
178
+ <ErrorText>This project references targets in your node_modules\react-native-windows folder that are missing. The missing file is {0}.</ErrorText>
179
+ </PropertyGroup>
180
+ <Error Condition="!Exists('$(ReactNativeWindowsDir)\PropertySheets\External\Microsoft.ReactNative.Uwp.CppLib.props')" Text="$([System.String]::Format('$(ErrorText)', '$(ReactNativeWindowsDir)\PropertySheets\External\Microsoft.ReactNative.Uwp.CppLib.props'))" />
181
+ <Error Condition="!Exists('$(ReactNativeWindowsDir)\PropertySheets\External\Microsoft.ReactNative.Uwp.CppLib.targets')" Text="$([System.String]::Format('$(ErrorText)', '$(ReactNativeWindowsDir)\PropertySheets\External\Microsoft.ReactNative.Uwp.CppLib.targets'))" />
182
+ </Target>
183
+ <ImportGroup Label="ExtensionTargets">
184
+ <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')" />
185
+ </ImportGroup>
186
+ <Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
187
+ <PropertyGroup>
188
+ <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>
189
+ </PropertyGroup>
190
+ <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'))" />
191
+ <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'))" />
192
+ </Target>
193
+ <ItemGroup>
194
+ <ProjectReference Update="$(ReactNativeWindowsDir)\Microsoft.ReactNative\Microsoft.ReactNative.vcxproj">
195
+ <ReferenceOutputAssembly>true</ReferenceOutputAssembly>
196
+ <LinkLibraryDependencies>true</LinkLibraryDependencies>
197
+ </ProjectReference>
198
+ </ItemGroup>
199
+ </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,104 @@
1
+ // Copyright (c) Microsoft Corporation.
2
+ // Licensed under the MIT License.
3
+
4
+ #include "pch.h"
5
+ #include "CodePushConfig.h"
6
+ #include "CodePushConfig.g.cpp"
7
+ #include "CodePushNativeModule.h"
8
+
9
+ #include "winrt/Windows.Foundation.Collections.h"
10
+ #include "winrt/Windows.Storage.h"
11
+
12
+ namespace winrt::Microsoft::CodePush::ReactNative::implementation
13
+ {
14
+ using namespace Windows::Storage;
15
+ using namespace Windows::Data::Json;
16
+ using namespace Windows::Foundation::Collections;
17
+
18
+ CodePushConfig CodePushConfig::s_currentConfig{};
19
+
20
+ /*static*/ CodePushConfig& CodePushConfig::Current() noexcept
21
+ {
22
+ return s_currentConfig;
23
+ }
24
+
25
+ JsonObject CodePushConfig::GetConfiguration()
26
+ {
27
+ JsonObject configObject;
28
+ for (const auto& pair : m_configuration)
29
+ {
30
+ configObject.Insert(pair.Key(), JsonValue::CreateStringValue(pair.Value()));
31
+ }
32
+ return configObject;
33
+ }
34
+
35
+ /*static*/ void CodePushConfig::Init(IMap<hstring, hstring> const& configMap) noexcept
36
+ {
37
+ std::optional<hstring> appVersion;
38
+ std::optional<hstring> buildVersion;
39
+ std::optional<hstring> deploymentKey;
40
+ std::optional<hstring> publicKey;
41
+ std::optional<hstring> serverUrl;
42
+
43
+ if (configMap != nullptr)
44
+ {
45
+ appVersion = configMap.TryLookup(AppVersionConfigKey);
46
+ buildVersion = configMap.TryLookup(BuildVersionConfigKey);
47
+ deploymentKey = configMap.TryLookup(DeploymentKeyConfigKey);
48
+ publicKey = configMap.TryLookup(PublicKeyKey);
49
+ serverUrl = configMap.TryLookup(ServerURLConfigKey);
50
+ }
51
+
52
+ s_currentConfig.m_configuration = winrt::single_threaded_map<hstring, hstring>();
53
+ auto addToConfiguration = [=](std::wstring_view key, std::optional<hstring> optValue) {
54
+ if (optValue.has_value())
55
+ {
56
+ s_currentConfig.m_configuration.Insert(key, optValue.value());
57
+ }
58
+ };
59
+
60
+ auto localSettings{ ::Microsoft::CodePush::ReactNative::CodePushNativeModule::GetLocalSettings() };
61
+ hstring clientUniqueId;
62
+ auto clientUniqueIdData{ localSettings.Values().TryLookup(ClientUniqueIDConfigKey) };
63
+ if (clientUniqueIdData == nullptr)
64
+ {
65
+ auto newGuid{ GuidHelper::CreateNewGuid() };
66
+ clientUniqueId = to_hstring(newGuid);
67
+ localSettings.Values().Insert(ClientUniqueIDConfigKey, box_value(clientUniqueId));
68
+ }
69
+ else
70
+ {
71
+ clientUniqueId = unbox_value<hstring>(clientUniqueIdData);
72
+ }
73
+
74
+ addToConfiguration(AppVersionConfigKey, appVersion);
75
+ addToConfiguration(BuildVersionConfigKey, buildVersion);
76
+ addToConfiguration(DeploymentKeyConfigKey, deploymentKey);
77
+ addToConfiguration(PublicKeyKey, publicKey);
78
+ addToConfiguration(ServerURLConfigKey, serverUrl);
79
+
80
+ s_currentConfig.m_configuration.Insert(ClientUniqueIDConfigKey, clientUniqueId);
81
+
82
+ if (!serverUrl.has_value())
83
+ {
84
+ s_currentConfig.m_configuration.Insert(ServerURLConfigKey, L"https://codepush.appzung.com/");
85
+ }
86
+
87
+ ::Microsoft::CodePush::ReactNative::CodePushNativeModule::LoadBundle();
88
+ }
89
+
90
+ hstring CodePushConfig::QueryConfig(std::wstring_view key)
91
+ {
92
+ auto value{ m_configuration.TryLookup(key) };
93
+ if (value.has_value())
94
+ {
95
+ return value.value();
96
+ }
97
+ return L"";
98
+ }
99
+
100
+ /*static*/ void CodePushConfig::SetHost(Microsoft::ReactNative::ReactNativeHost const& host) noexcept
101
+ {
102
+ ::Microsoft::CodePush::ReactNative::CodePushNativeModule::SetHost(host);
103
+ }
104
+ }