@srcpush/react-native-code-push 1.0.3-develop.1 → 1.0.3-develop.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/.azurepipelines/build-rn-code-push-1es.yml +0 -104
- package/.azurepipelines/test-rn-code-push.yml +0 -94
- package/windows/CodePush/CodePush.def +0 -3
- package/windows/CodePush/CodePush.vcxproj +0 -198
- package/windows/CodePush/CodePush.vcxproj.filters +0 -91
- package/windows/CodePush/CodePushConfig.cpp +0 -104
- package/windows/CodePush/CodePushConfig.h +0 -66
- package/windows/CodePush/CodePushConfig.idl +0 -12
- package/windows/CodePush/CodePushDownloadHandler.cpp +0 -73
- package/windows/CodePush/CodePushDownloadHandler.h +0 -32
- package/windows/CodePush/CodePushNativeModule.cpp +0 -937
- package/windows/CodePush/CodePushNativeModule.h +0 -247
- package/windows/CodePush/CodePushPackage.cpp +0 -456
- package/windows/CodePush/CodePushPackage.h +0 -49
- package/windows/CodePush/CodePushTelemetryManager.cpp +0 -213
- package/windows/CodePush/CodePushTelemetryManager.h +0 -29
- package/windows/CodePush/CodePushUpdateUtils.cpp +0 -86
- package/windows/CodePush/CodePushUpdateUtils.h +0 -38
- package/windows/CodePush/CodePushUtils.cpp +0 -29
- package/windows/CodePush/CodePushUtils.h +0 -18
- package/windows/CodePush/FileUtils.cpp +0 -131
- package/windows/CodePush/FileUtils.h +0 -28
- package/windows/CodePush/PropertySheet.props +0 -16
- package/windows/CodePush/ReactPackageProvider.cpp +0 -15
- package/windows/CodePush/ReactPackageProvider.h +0 -22
- package/windows/CodePush/ReactPackageProvider.idl +0 -9
- package/windows/CodePush/miniz/LICENSE +0 -22
- package/windows/CodePush/miniz/miniz.c +0 -7657
- package/windows/CodePush/miniz/miniz.h +0 -1338
- package/windows/CodePush/miniz/readme.md +0 -37
- package/windows/CodePush/packages.config +0 -4
- package/windows/CodePush/pch.cpp +0 -1
- package/windows/CodePush/pch.h +0 -4
- package/windows-legacy/CodePush/CodePush.csproj +0 -128
- package/windows-legacy/CodePush/CodePushUtils.cs +0 -47
- package/windows-legacy/CodePush/FileUtils.cs +0 -40
- package/windows-legacy/CodePush/Properties/AssemblyInfo.cs +0 -29
- package/windows-legacy/CodePush/Properties/CodePush.rd.xml +0 -33
- package/windows-legacy/CodePush/UpdateManager.cs +0 -305
- package/windows-legacy/CodePush/UpdateUtils.cs +0 -46
- package/windows-legacy/CodePush.Net46/Adapters/Http/HttpProgress.cs +0 -28
- package/windows-legacy/CodePush.Net46/Adapters/Storage/ApplicationDataContainer.cs +0 -106
- package/windows-legacy/CodePush.Net46/CodePush.Net46.csproj +0 -103
- package/windows-legacy/CodePush.Net46/CodePushUtils.cs +0 -158
- package/windows-legacy/CodePush.Net46/FileUtils.cs +0 -55
- package/windows-legacy/CodePush.Net46/Properties/AssemblyInfo.cs +0 -36
- package/windows-legacy/CodePush.Net46/UpdateManager.cs +0 -330
- package/windows-legacy/CodePush.Net46/UpdateUtils.cs +0 -70
- package/windows-legacy/CodePush.Net46/packages.config +0 -5
- package/windows-legacy/CodePush.Net46.Test/ApplicationDataContainerTest.cs +0 -105
- package/windows-legacy/CodePush.Net46.Test/CodePush.Net46.Test.csproj +0 -137
- package/windows-legacy/CodePush.Net46.Test/Properties/AssemblyInfo.cs +0 -36
- package/windows-legacy/CodePush.Net46.Test/TelemetryManagerTest.cs +0 -117
- package/windows-legacy/CodePush.Net46.Test/app.config +0 -11
- package/windows-legacy/CodePush.Net46.Test/packages.config +0 -4
- package/windows-legacy/CodePush.Shared/CodePush.Shared.projitems +0 -22
- package/windows-legacy/CodePush.Shared/CodePush.Shared.shproj +0 -13
- package/windows-legacy/CodePush.Shared/CodePushConstants.cs +0 -35
- package/windows-legacy/CodePush.Shared/CodePushNativeModule.cs +0 -329
- package/windows-legacy/CodePush.Shared/CodePushReactPackage.cs +0 -235
- package/windows-legacy/CodePush.Shared/CodePushUtils.cs +0 -70
- package/windows-legacy/CodePush.Shared/InstallMode.cs +0 -9
- package/windows-legacy/CodePush.Shared/MinimumBackgroundListener.cs +0 -44
- package/windows-legacy/CodePush.Shared/SettingsManager.cs +0 -148
- package/windows-legacy/CodePush.Shared/TelemetryManager.cs +0 -250
- package/windows-legacy/CodePush.Shared/UpdateState.cs +0 -9
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
using System.Reflection;
|
|
2
|
-
using System.Runtime.CompilerServices;
|
|
3
|
-
using System.Runtime.InteropServices;
|
|
4
|
-
|
|
5
|
-
// General Information about an assembly is controlled through the following
|
|
6
|
-
// set of attributes. Change these attribute values to modify the information
|
|
7
|
-
// associated with an assembly.
|
|
8
|
-
[assembly: AssemblyTitle("CodePush.Net46.Test")]
|
|
9
|
-
[assembly: AssemblyDescription("")]
|
|
10
|
-
[assembly: AssemblyConfiguration("")]
|
|
11
|
-
[assembly: AssemblyCompany("")]
|
|
12
|
-
[assembly: AssemblyProduct("CodePush.Net46.Test")]
|
|
13
|
-
[assembly: AssemblyCopyright("Copyright © 2017")]
|
|
14
|
-
[assembly: AssemblyTrademark("")]
|
|
15
|
-
[assembly: AssemblyCulture("")]
|
|
16
|
-
|
|
17
|
-
// Setting ComVisible to false makes the types in this assembly not visible
|
|
18
|
-
// to COM components. If you need to access a type in this assembly from
|
|
19
|
-
// COM, set the ComVisible attribute to true on that type.
|
|
20
|
-
[assembly: ComVisible(false)]
|
|
21
|
-
|
|
22
|
-
// The following GUID is for the ID of the typelib if this project is exposed to COM
|
|
23
|
-
[assembly: Guid("bbb48f0b-af6f-4a14-afa4-306d3fb0b7cf")]
|
|
24
|
-
|
|
25
|
-
// Version information for an assembly consists of the following four values:
|
|
26
|
-
//
|
|
27
|
-
// Major Version
|
|
28
|
-
// Minor Version
|
|
29
|
-
// Build Number
|
|
30
|
-
// Revision
|
|
31
|
-
//
|
|
32
|
-
// You can specify all the values or you can default the Build and Revision Numbers
|
|
33
|
-
// by using the '*' as shown below:
|
|
34
|
-
// [assembly: AssemblyVersion("1.0.*")]
|
|
35
|
-
[assembly: AssemblyVersion("1.0.0.0")]
|
|
36
|
-
[assembly: AssemblyFileVersion("1.0.0.0")]
|
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
using CodePush.ReactNative;
|
|
2
|
-
using Microsoft.VisualStudio.TestTools.UnitTesting;
|
|
3
|
-
using Newtonsoft.Json;
|
|
4
|
-
using Newtonsoft.Json.Linq;
|
|
5
|
-
|
|
6
|
-
namespace CodePush.Net46.Test
|
|
7
|
-
{
|
|
8
|
-
/// <summary>
|
|
9
|
-
/// Some tests for telemetry manager
|
|
10
|
-
/// As implementation of TelemetryManager was ported from android version, we do not test logic here.
|
|
11
|
-
/// Here are tests for some tricky parts of implementation, or check some data transformation that
|
|
12
|
-
/// has no full equvalent in C#
|
|
13
|
-
/// </summary>
|
|
14
|
-
[TestClass]
|
|
15
|
-
public class TelemetryManagerTest
|
|
16
|
-
{
|
|
17
|
-
#region Constants from TelemetryManager
|
|
18
|
-
//private static readonly string APP_VERSION_KEY = "appVersion";
|
|
19
|
-
private static readonly string DEPLOYMENT_FAILED_STATUS = "DeploymentFailed";
|
|
20
|
-
private static readonly string DEPLOYMENT_KEY_KEY = "deploymentKey";
|
|
21
|
-
private static readonly string DEPLOYMENT_SUCCEEDED_STATUS = "DeploymentSucceeded";
|
|
22
|
-
private static readonly string LABEL_KEY = "label";
|
|
23
|
-
private static readonly string LAST_DEPLOYMENT_REPORT_KEY = "CODE_PUSH_LAST_DEPLOYMENT_REPORT";
|
|
24
|
-
//private static readonly string PACKAGE_KEY = "package";
|
|
25
|
-
//private static readonly string PREVIOUS_DEPLOYMENT_KEY_KEY = "previousDeploymentKey";
|
|
26
|
-
//private static readonly string PREVIOUS_LABEL_OR_APP_VERSION_KEY = "previousLabelOrAppVersion";
|
|
27
|
-
private static readonly string RETRY_DEPLOYMENT_REPORT_KEY = "CODE_PUSH_RETRY_DEPLOYMENT_REPORT";
|
|
28
|
-
private static readonly string STATUS_KEY = "status";
|
|
29
|
-
#endregion
|
|
30
|
-
|
|
31
|
-
[TestMethod]
|
|
32
|
-
public void TestGetUpdateReportNoPreviousUpdate()
|
|
33
|
-
{
|
|
34
|
-
var input = new JObject();
|
|
35
|
-
input.Add(DEPLOYMENT_KEY_KEY, "depKeyParam");
|
|
36
|
-
input.Add(LABEL_KEY, "labelParam");
|
|
37
|
-
|
|
38
|
-
var output = TelemetryManager.GetUpdateReport(input);
|
|
39
|
-
Assert.IsNotNull(output);
|
|
40
|
-
Assert.IsTrue(output.ToString(Formatting.None).Contains("\"status\":\"DeploymentSucceeded\""));
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
[TestMethod]
|
|
44
|
-
public void TestGetUpdateReportWithPreviousUpdate()
|
|
45
|
-
{
|
|
46
|
-
SettingsManager.SetString(LAST_DEPLOYMENT_REPORT_KEY, "prevKey:prevLabel");
|
|
47
|
-
var input = new JObject();
|
|
48
|
-
input.Add(DEPLOYMENT_KEY_KEY, "depKeyParam");
|
|
49
|
-
input.Add(LABEL_KEY, "labelParam");
|
|
50
|
-
|
|
51
|
-
var output = TelemetryManager.GetUpdateReport(input);
|
|
52
|
-
Assert.IsNotNull(output);
|
|
53
|
-
Assert.IsTrue(output.ToString(Formatting.None).Contains("\"status\":\"DeploymentSucceeded\""));
|
|
54
|
-
Assert.IsTrue(output.ToString(Formatting.None).Contains("\"previousDeploymentKey\":\"prevKey\",\"previousLabelOrAppVersion\":\"prevLabel\""));
|
|
55
|
-
|
|
56
|
-
//Clean Up
|
|
57
|
-
SettingsManager.RemoveString(LAST_DEPLOYMENT_REPORT_KEY);
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
[TestMethod]
|
|
61
|
-
public void TestGetUpdateReportNegative()
|
|
62
|
-
{
|
|
63
|
-
var inputNoLabel = new JObject();
|
|
64
|
-
inputNoLabel.Add(DEPLOYMENT_KEY_KEY, "depKeyParam");
|
|
65
|
-
Assert.IsNull(TelemetryManager.GetUpdateReport(inputNoLabel));
|
|
66
|
-
|
|
67
|
-
var inputNoKey = new JObject();
|
|
68
|
-
inputNoKey.Add(LABEL_KEY, "labelParam");
|
|
69
|
-
Assert.IsNull(TelemetryManager.GetUpdateReport(inputNoKey));
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
[TestMethod]
|
|
73
|
-
public void TestRecordStatusReportWithRollback()
|
|
74
|
-
{
|
|
75
|
-
var report = new JObject();
|
|
76
|
-
report.Add(STATUS_KEY, DEPLOYMENT_FAILED_STATUS);
|
|
77
|
-
|
|
78
|
-
TelemetryManager.RecordStatusReported(report);
|
|
79
|
-
Assert.IsTrue(true);
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
[TestMethod]
|
|
83
|
-
public void TestRecordStatusReportWithoutRollback()
|
|
84
|
-
{
|
|
85
|
-
var reportSuccess = new JObject();
|
|
86
|
-
reportSuccess.Add(STATUS_KEY, DEPLOYMENT_SUCCEEDED_STATUS);
|
|
87
|
-
TelemetryManager.RecordStatusReported(reportSuccess);
|
|
88
|
-
|
|
89
|
-
var reportNoStatus = new JObject();
|
|
90
|
-
TelemetryManager.RecordStatusReported(reportNoStatus);
|
|
91
|
-
|
|
92
|
-
Assert.IsTrue(true);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
[TestMethod]
|
|
96
|
-
public void TestStatusReportForRetrySerialization()
|
|
97
|
-
{
|
|
98
|
-
SettingsManager.RemoveString(RETRY_DEPLOYMENT_REPORT_KEY);
|
|
99
|
-
var original = new JObject();
|
|
100
|
-
original.Add("keyString", "stringValue");
|
|
101
|
-
original.Add("keyInt", 42);
|
|
102
|
-
original.Add("keyBool", true);
|
|
103
|
-
|
|
104
|
-
TelemetryManager.SaveStatusReportForRetry(original);
|
|
105
|
-
|
|
106
|
-
var stringified = SettingsManager.GetString(RETRY_DEPLOYMENT_REPORT_KEY);
|
|
107
|
-
SettingsManager.RemoveString(RETRY_DEPLOYMENT_REPORT_KEY);
|
|
108
|
-
|
|
109
|
-
Assert.IsNotNull(stringified);
|
|
110
|
-
var result = JObject.Parse(stringified);
|
|
111
|
-
|
|
112
|
-
Assert.IsTrue((bool)result.GetValue("keyBool"));
|
|
113
|
-
Assert.AreEqual(42, (int)result.GetValue("keyInt"));
|
|
114
|
-
Assert.AreEqual("stringValue", (string)result.GetValue("keyString"));
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
-
<configuration>
|
|
3
|
-
<runtime>
|
|
4
|
-
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
|
5
|
-
<dependentAssembly>
|
|
6
|
-
<assemblyIdentity name="System.Reactive.Core" publicKeyToken="94bc3704cddfc263" culture="neutral" />
|
|
7
|
-
<bindingRedirect oldVersion="0.0.0.0-3.0.3000.0" newVersion="3.0.3000.0" />
|
|
8
|
-
</dependentAssembly>
|
|
9
|
-
</assemblyBinding>
|
|
10
|
-
</runtime>
|
|
11
|
-
</configuration>
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
-
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
3
|
-
<PropertyGroup>
|
|
4
|
-
<MSBuildAllProjects>$(MSBuildAllProjects);$(MSBuildThisFileFullPath)</MSBuildAllProjects>
|
|
5
|
-
<HasSharedItems>true</HasSharedItems>
|
|
6
|
-
<SharedGUID>4ad4c826-cc26-4f1d-b60d-b97b22f52e90</SharedGUID>
|
|
7
|
-
</PropertyGroup>
|
|
8
|
-
<PropertyGroup Label="Configuration">
|
|
9
|
-
<Import_RootNamespace>CodePush.Shared</Import_RootNamespace>
|
|
10
|
-
</PropertyGroup>
|
|
11
|
-
<ItemGroup>
|
|
12
|
-
<Compile Include="$(MSBuildThisFileDirectory)CodePushConstants.cs" />
|
|
13
|
-
<Compile Include="$(MSBuildThisFileDirectory)CodePushNativeModule.cs" />
|
|
14
|
-
<Compile Include="$(MSBuildThisFileDirectory)CodePushReactPackage.cs" />
|
|
15
|
-
<Compile Include="$(MSBuildThisFileDirectory)CodePushUtils.cs" />
|
|
16
|
-
<Compile Include="$(MSBuildThisFileDirectory)InstallMode.cs" />
|
|
17
|
-
<Compile Include="$(MSBuildThisFileDirectory)MinimumBackgroundListener.cs" />
|
|
18
|
-
<Compile Include="$(MSBuildThisFileDirectory)SettingsManager.cs" />
|
|
19
|
-
<Compile Include="$(MSBuildThisFileDirectory)TelemetryManager.cs" />
|
|
20
|
-
<Compile Include="$(MSBuildThisFileDirectory)UpdateState.cs" />
|
|
21
|
-
</ItemGroup>
|
|
22
|
-
</Project>
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
-
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
3
|
-
<PropertyGroup Label="Globals">
|
|
4
|
-
<ProjectGuid>4ad4c826-cc26-4f1d-b60d-b97b22f52e90</ProjectGuid>
|
|
5
|
-
<MinimumVisualStudioVersion>14.0</MinimumVisualStudioVersion>
|
|
6
|
-
</PropertyGroup>
|
|
7
|
-
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
|
8
|
-
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.Default.props" />
|
|
9
|
-
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.Common.props" />
|
|
10
|
-
<PropertyGroup />
|
|
11
|
-
<Import Project="CodePush.Shared.projitems" Label="Shared" />
|
|
12
|
-
<Import Project="$(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)\CodeSharing\Microsoft.CodeSharing.CSharp.targets" />
|
|
13
|
-
</Project>
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
namespace CodePush.ReactNative
|
|
2
|
-
{
|
|
3
|
-
internal class CodePushConstants
|
|
4
|
-
{
|
|
5
|
-
internal const string BinaryModifiedTimeKey = "binaryModifiedTime";
|
|
6
|
-
internal const string CodePushServerUrl = "https://codepush.appcenter.ms/";
|
|
7
|
-
internal const string CodePushFolderPrefix = "CodePush";
|
|
8
|
-
internal const string CodePushPreferences = "CodePush";
|
|
9
|
-
internal const string CurrentPackageKey = "currentPackage";
|
|
10
|
-
internal const string DefaultJsBundleName = "index.windows.bundle";
|
|
11
|
-
internal const string DiffManifestFileName = "hotcodepush.json";
|
|
12
|
-
internal const string DownloadFileName = "download.zip";
|
|
13
|
-
internal const string DownloadProgressEventName = "CodePushDownloadProgress";
|
|
14
|
-
internal const string DownloadUrlKey = "downloadUrl";
|
|
15
|
-
internal const string FailedUpdatesKey = "CODE_PUSH_FAILED_UPDATES";
|
|
16
|
-
internal const string PackageFileName = "app.json";
|
|
17
|
-
internal const string PackageHashKey = "packageHash";
|
|
18
|
-
internal const string PendingUpdateHashKey = "hash";
|
|
19
|
-
internal const string PendingUpdateKey = "CODE_PUSH_PENDING_UPDATE";
|
|
20
|
-
internal const string PendingUpdateIsLoadingKey = "isLoading";
|
|
21
|
-
internal const string PreviousPackageKey = "previousPackage";
|
|
22
|
-
// This needs to be kept in sync with https://github.com/ReactWindows/react-native-windows/blob/master/ReactWindows/ReactNative/DevSupport/DevSupportManager.cs#L22
|
|
23
|
-
internal const string ReactDevBundleCacheFileName = "ReactNativeDevBundle.js";
|
|
24
|
-
internal const string ReactNativeLogCategory = "ReactNative";
|
|
25
|
-
internal const string RelativeBundlePathKey = "bundlePath";
|
|
26
|
-
internal const string StatusFileName = "codepush.json";
|
|
27
|
-
internal const string UnzippedFolderName = "unzipped";
|
|
28
|
-
#if WINDOWS_UWP
|
|
29
|
-
internal const string AssetsBundlePrefix = "ms-appx:///ReactAssets/";
|
|
30
|
-
internal const string FileBundlePrefix = "ms-appdata:///local/";
|
|
31
|
-
#else
|
|
32
|
-
internal const string AssetsBundlePrefix = "ReactAssets/";
|
|
33
|
-
#endif
|
|
34
|
-
}
|
|
35
|
-
}
|
|
@@ -1,329 +0,0 @@
|
|
|
1
|
-
using Newtonsoft.Json.Linq;
|
|
2
|
-
using ReactNative;
|
|
3
|
-
using ReactNative.Bridge;
|
|
4
|
-
using ReactNative.Modules.Core;
|
|
5
|
-
using System;
|
|
6
|
-
using System.Collections.Generic;
|
|
7
|
-
using System.IO;
|
|
8
|
-
using System.Reflection;
|
|
9
|
-
using System.Threading;
|
|
10
|
-
using System.Threading.Tasks;
|
|
11
|
-
#if WINDOWS_UWP
|
|
12
|
-
using Windows.Web.Http;
|
|
13
|
-
#else
|
|
14
|
-
using CodePush.Net46.Adapters.Http;
|
|
15
|
-
#endif
|
|
16
|
-
|
|
17
|
-
namespace CodePush.ReactNative
|
|
18
|
-
{
|
|
19
|
-
internal class CodePushNativeModule : ReactContextNativeModuleBase
|
|
20
|
-
{
|
|
21
|
-
private CodePushReactPackage _codePush;
|
|
22
|
-
private MinimumBackgroundListener _minimumBackgroundListener;
|
|
23
|
-
private ReactContext _reactContext;
|
|
24
|
-
|
|
25
|
-
public CodePushNativeModule(ReactContext reactContext, CodePushReactPackage codePush)
|
|
26
|
-
: base(reactContext)
|
|
27
|
-
{
|
|
28
|
-
_reactContext = reactContext;
|
|
29
|
-
_codePush = codePush;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
public override string Name
|
|
33
|
-
{
|
|
34
|
-
get
|
|
35
|
-
{
|
|
36
|
-
return "CodePush";
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
public override IReadOnlyDictionary<string, object> Constants
|
|
41
|
-
{
|
|
42
|
-
get
|
|
43
|
-
{
|
|
44
|
-
return new Dictionary<string, object>
|
|
45
|
-
{
|
|
46
|
-
{ "codePushInstallModeImmediate", InstallMode.Immediate },
|
|
47
|
-
{ "codePushInstallModeOnNextResume", InstallMode.OnNextResume },
|
|
48
|
-
{ "codePushInstallModeOnNextRestart", InstallMode.OnNextRestart },
|
|
49
|
-
{ "codePushUpdateStateRunning", UpdateState.Running },
|
|
50
|
-
{ "codePushUpdateStatePending", UpdateState.Pending },
|
|
51
|
-
{ "codePushUpdateStateLatest", UpdateState.Latest },
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
public override void Initialize()
|
|
57
|
-
{
|
|
58
|
-
_codePush.InitializeUpdateAfterRestart();
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
[ReactMethod]
|
|
62
|
-
public async void downloadUpdate(JObject updatePackage, bool notifyProgress, IPromise promise)
|
|
63
|
-
{
|
|
64
|
-
try
|
|
65
|
-
{
|
|
66
|
-
updatePackage[CodePushConstants.BinaryModifiedTimeKey] = "" + await FileUtils.GetBinaryResourcesModifiedTimeAsync(_codePush.AssetsBundleFileName).ConfigureAwait(false);
|
|
67
|
-
await _codePush.UpdateManager.DownloadPackageAsync(
|
|
68
|
-
updatePackage,
|
|
69
|
-
_codePush.AssetsBundleFileName,
|
|
70
|
-
new Progress<HttpProgress>(
|
|
71
|
-
(HttpProgress progress) =>
|
|
72
|
-
{
|
|
73
|
-
if (!notifyProgress)
|
|
74
|
-
{
|
|
75
|
-
return;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
var downloadProgress = new JObject()
|
|
79
|
-
{
|
|
80
|
-
{ "totalBytes", progress.TotalBytesToReceive },
|
|
81
|
-
{ "receivedBytes", progress.BytesReceived }
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
_reactContext
|
|
85
|
-
.GetJavaScriptModule<RCTDeviceEventEmitter>()
|
|
86
|
-
.emit(CodePushConstants.DownloadProgressEventName, downloadProgress);
|
|
87
|
-
}
|
|
88
|
-
)
|
|
89
|
-
).ConfigureAwait(false);
|
|
90
|
-
|
|
91
|
-
JObject newPackage = await _codePush.UpdateManager.GetPackageAsync((string)updatePackage[CodePushConstants.PackageHashKey]).ConfigureAwait(false);
|
|
92
|
-
promise.Resolve(newPackage);
|
|
93
|
-
}
|
|
94
|
-
catch (InvalidDataException e)
|
|
95
|
-
{
|
|
96
|
-
CodePushUtils.Log(e.ToString());
|
|
97
|
-
SettingsManager.SaveFailedUpdate(updatePackage);
|
|
98
|
-
promise.Reject(e);
|
|
99
|
-
}
|
|
100
|
-
catch (Exception e)
|
|
101
|
-
{
|
|
102
|
-
CodePushUtils.Log(e.ToString());
|
|
103
|
-
promise.Reject(e);
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
[ReactMethod]
|
|
108
|
-
public void getConfiguration(IPromise promise)
|
|
109
|
-
{
|
|
110
|
-
var config = new JObject
|
|
111
|
-
{
|
|
112
|
-
{ "appVersion", _codePush.AppVersion },
|
|
113
|
-
{ "clientUniqueId", CodePushUtils.GetDeviceId() },
|
|
114
|
-
{ "deploymentKey", _codePush.DeploymentKey },
|
|
115
|
-
{ "serverUrl", CodePushConstants.CodePushServerUrl }
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
// TODO generate binary hash
|
|
119
|
-
// string binaryHash = CodePushUpdateUtils.getHashForBinaryContents(mainActivity, isDebugMode);
|
|
120
|
-
/*if (binaryHash != null)
|
|
121
|
-
{
|
|
122
|
-
configMap.putString(PACKAGE_HASH_KEY, binaryHash);
|
|
123
|
-
}*/
|
|
124
|
-
promise.Resolve(config);
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
[ReactMethod]
|
|
128
|
-
public async void getUpdateMetadata(UpdateState updateState, IPromise promise)
|
|
129
|
-
{
|
|
130
|
-
JObject currentPackage = await _codePush.UpdateManager.GetCurrentPackageAsync().ConfigureAwait(false);
|
|
131
|
-
if (currentPackage == null)
|
|
132
|
-
{
|
|
133
|
-
promise.Resolve("");
|
|
134
|
-
return;
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
var currentUpdateIsPending = false;
|
|
138
|
-
|
|
139
|
-
if (currentPackage[CodePushConstants.PackageHashKey] != null)
|
|
140
|
-
{
|
|
141
|
-
var currentHash = (string)currentPackage[CodePushConstants.PackageHashKey];
|
|
142
|
-
currentUpdateIsPending = SettingsManager.IsPendingUpdate(currentHash);
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
if (updateState == UpdateState.Pending && !currentUpdateIsPending)
|
|
146
|
-
{
|
|
147
|
-
// The caller wanted a pending update
|
|
148
|
-
// but there isn't currently one.
|
|
149
|
-
promise.Resolve("");
|
|
150
|
-
}
|
|
151
|
-
else if (updateState == UpdateState.Running && currentUpdateIsPending)
|
|
152
|
-
{
|
|
153
|
-
// The caller wants the running update, but the current
|
|
154
|
-
// one is pending, so we need to grab the previous.
|
|
155
|
-
promise.Resolve(await _codePush.UpdateManager.GetPreviousPackageAsync().ConfigureAwait(false));
|
|
156
|
-
}
|
|
157
|
-
else
|
|
158
|
-
{
|
|
159
|
-
// The current package satisfies the request:
|
|
160
|
-
// 1) Caller wanted a pending, and there is a pending update
|
|
161
|
-
// 2) Caller wanted the running update, and there isn't a pending
|
|
162
|
-
// 3) Caller wants the latest update, regardless if it's pending or not
|
|
163
|
-
if (_codePush.IsRunningBinaryVersion)
|
|
164
|
-
{
|
|
165
|
-
// This only matters in Debug builds. Since we do not clear "outdated" updates,
|
|
166
|
-
// we need to indicate to the JS side that somehow we have a current update on
|
|
167
|
-
// disk that is not actually running.
|
|
168
|
-
currentPackage["_isDebugOnly"] = true;
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
// Enable differentiating pending vs. non-pending updates
|
|
172
|
-
currentPackage["isPending"] = currentUpdateIsPending;
|
|
173
|
-
promise.Resolve(currentPackage);
|
|
174
|
-
}
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
[ReactMethod]
|
|
179
|
-
public async void getNewStatusReport(IPromise promise)
|
|
180
|
-
{
|
|
181
|
-
await Task.Run(() =>
|
|
182
|
-
{
|
|
183
|
-
if (_codePush.NeedToReportRollback)
|
|
184
|
-
{
|
|
185
|
-
_codePush.NeedToReportRollback = false;
|
|
186
|
-
|
|
187
|
-
var failedUpdates = SettingsManager.GetFailedUpdates();
|
|
188
|
-
if (failedUpdates != null && failedUpdates.Count > 0)
|
|
189
|
-
{
|
|
190
|
-
var lastFailedPackage = (JObject)failedUpdates[failedUpdates.Count - 1];
|
|
191
|
-
var failedStatusReport = TelemetryManager.GetRollbackReport(lastFailedPackage);
|
|
192
|
-
if (failedStatusReport != null)
|
|
193
|
-
{
|
|
194
|
-
promise.Resolve(failedStatusReport);
|
|
195
|
-
return;
|
|
196
|
-
}
|
|
197
|
-
}
|
|
198
|
-
}
|
|
199
|
-
else if (_codePush.DidUpdate)
|
|
200
|
-
{
|
|
201
|
-
var currentPackage = _codePush.UpdateManager.GetCurrentPackageAsync().Result;
|
|
202
|
-
if (currentPackage != null)
|
|
203
|
-
{
|
|
204
|
-
var newPackageStatusReport = TelemetryManager.GetUpdateReport(currentPackage);
|
|
205
|
-
if (newPackageStatusReport != null)
|
|
206
|
-
{
|
|
207
|
-
promise.Resolve(newPackageStatusReport);
|
|
208
|
-
return;
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
}
|
|
212
|
-
else if (_codePush.IsRunningBinaryVersion)
|
|
213
|
-
{
|
|
214
|
-
var newAppVersionStatusReport = TelemetryManager.GetBinaryUpdateReport(_codePush.AppVersion);
|
|
215
|
-
if (newAppVersionStatusReport != null)
|
|
216
|
-
{
|
|
217
|
-
promise.Resolve(newAppVersionStatusReport);
|
|
218
|
-
return;
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
else
|
|
222
|
-
{
|
|
223
|
-
var retryStatusReport = TelemetryManager.GetRetryStatusReport();
|
|
224
|
-
if (retryStatusReport != null)
|
|
225
|
-
{
|
|
226
|
-
promise.Resolve(retryStatusReport);
|
|
227
|
-
return;
|
|
228
|
-
}
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
promise.Resolve("");
|
|
232
|
-
}).ConfigureAwait(false);
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
[ReactMethod]
|
|
236
|
-
public async void installUpdate(JObject updatePackage, InstallMode installMode, int minimumBackgroundDuration, IPromise promise)
|
|
237
|
-
{
|
|
238
|
-
await _codePush.UpdateManager.InstallPackageAsync(updatePackage, SettingsManager.IsPendingUpdate(null)).ConfigureAwait(false);
|
|
239
|
-
var pendingHash = (string)updatePackage[CodePushConstants.PackageHashKey];
|
|
240
|
-
SettingsManager.SavePendingUpdate(pendingHash, /* isLoading */false);
|
|
241
|
-
if (installMode == InstallMode.OnNextResume)
|
|
242
|
-
{
|
|
243
|
-
if (_minimumBackgroundListener == null)
|
|
244
|
-
{
|
|
245
|
-
// Ensure we do not add the listener twice.
|
|
246
|
-
Action loadBundleAction = () =>
|
|
247
|
-
{
|
|
248
|
-
Context.RunOnNativeModulesQueueThread(async () =>
|
|
249
|
-
{
|
|
250
|
-
await LoadBundleAsync().ConfigureAwait(false);
|
|
251
|
-
});
|
|
252
|
-
};
|
|
253
|
-
|
|
254
|
-
_minimumBackgroundListener = new MinimumBackgroundListener(loadBundleAction, minimumBackgroundDuration);
|
|
255
|
-
_reactContext.AddLifecycleEventListener(_minimumBackgroundListener);
|
|
256
|
-
}
|
|
257
|
-
else
|
|
258
|
-
{
|
|
259
|
-
_minimumBackgroundListener.MinimumBackgroundDuration = minimumBackgroundDuration;
|
|
260
|
-
}
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
promise.Resolve("");
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
[ReactMethod]
|
|
267
|
-
public void isFailedUpdate(string packageHash, IPromise promise)
|
|
268
|
-
{
|
|
269
|
-
promise.Resolve(SettingsManager.IsFailedHash(packageHash));
|
|
270
|
-
}
|
|
271
|
-
|
|
272
|
-
[ReactMethod]
|
|
273
|
-
public async void isFirstRun(string packageHash, IPromise promise)
|
|
274
|
-
{
|
|
275
|
-
bool isFirstRun = _codePush.DidUpdate
|
|
276
|
-
&& packageHash != null
|
|
277
|
-
&& packageHash.Length > 0
|
|
278
|
-
&& packageHash.Equals(await _codePush.UpdateManager.GetCurrentPackageHashAsync().ConfigureAwait(false));
|
|
279
|
-
promise.Resolve(isFirstRun);
|
|
280
|
-
}
|
|
281
|
-
|
|
282
|
-
[ReactMethod]
|
|
283
|
-
public void notifyApplicationReady(IPromise promise)
|
|
284
|
-
{
|
|
285
|
-
SettingsManager.RemovePendingUpdate();
|
|
286
|
-
promise.Resolve("");
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
[ReactMethod]
|
|
290
|
-
public async void restartApp(bool onlyIfUpdateIsPending)
|
|
291
|
-
{
|
|
292
|
-
// If this is an unconditional restart request, or there
|
|
293
|
-
// is current pending update, then reload the app.
|
|
294
|
-
if (!onlyIfUpdateIsPending || SettingsManager.IsPendingUpdate(null))
|
|
295
|
-
{
|
|
296
|
-
await LoadBundleAsync().ConfigureAwait(false);
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
[ReactMethod]
|
|
301
|
-
public async void recordStatusReported(JObject statusReport)
|
|
302
|
-
{
|
|
303
|
-
await Task.Run(() => TelemetryManager.RecordStatusReported(statusReport)).ConfigureAwait(false);
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
[ReactMethod]
|
|
307
|
-
public async void saveStatusReportForRetry(JObject statusReport)
|
|
308
|
-
{
|
|
309
|
-
await Task.Run(() => TelemetryManager.SaveStatusReportForRetry(statusReport)).ConfigureAwait(false);
|
|
310
|
-
}
|
|
311
|
-
|
|
312
|
-
internal async Task LoadBundleAsync()
|
|
313
|
-
{
|
|
314
|
-
// #1) Get the private ReactInstanceManager, which is what includes
|
|
315
|
-
// the logic to reload the current React context.
|
|
316
|
-
var reactInstanceManager = _codePush.ReactInstanceManager;
|
|
317
|
-
|
|
318
|
-
// #2) Update the locally stored JS bundle file path
|
|
319
|
-
Type reactInstanceManagerType = typeof(ReactInstanceManager);
|
|
320
|
-
string latestJSBundleFile = await _codePush.GetJavaScriptBundleFileAsync(_codePush.AssetsBundleFileName).ConfigureAwait(false);
|
|
321
|
-
reactInstanceManagerType
|
|
322
|
-
.GetField("_jsBundleFile", BindingFlags.NonPublic | BindingFlags.Instance)
|
|
323
|
-
.SetValue(reactInstanceManager, latestJSBundleFile);
|
|
324
|
-
|
|
325
|
-
// #3) Get the context creation method and fire it on the UI thread (which RN enforces)
|
|
326
|
-
Context.RunOnDispatcherQueueThread(() => reactInstanceManager.RecreateReactContextAsync(CancellationToken.None));
|
|
327
|
-
}
|
|
328
|
-
}
|
|
329
|
-
}
|