react-native-windows 0.70.1 → 0.70.2
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/Libraries/Network/RCTNetworking.windows.js +117 -1
- package/Microsoft.ReactNative.Managed/Microsoft.ReactNative.Managed.csproj +1 -3
- package/PropertySheets/External/Microsoft.ReactNative.Common.props +0 -9
- package/PropertySheets/External/Microsoft.ReactNative.Uwp.CSharpApp.props +1 -0
- package/PropertySheets/External/Microsoft.ReactNative.Uwp.CSharpLib.props +1 -0
- package/PropertySheets/External/Microsoft.ReactNative.Uwp.CppApp.props +1 -0
- package/PropertySheets/External/Microsoft.ReactNative.Uwp.CppLib.props +1 -0
- package/PropertySheets/External/Microsoft.ReactNative.WinAppSDK.CSharpApp.props +1 -0
- package/PropertySheets/Generated/PackageVersion.g.props +2 -2
- package/PropertySheets/NuGet.CSharp.props +15 -0
- package/PropertySheets/NuGet.Cpp.props +31 -0
- package/PropertySheets/React.Cpp.props +1 -15
- package/Scripts/OfficeReact.Win32.nuspec +1 -0
- package/Shared/Modules/HttpModule.h +1 -1
- package/Shared/Networking/OriginPolicy.h +1 -1
- package/package.json +1 -1
- package/template/cpp-app/proj/MyApp.vcxproj +0 -3
- package/template/cpp-lib/proj/MyLib.vcxproj +0 -3
- package/template/cs-app/proj/MyApp.csproj +0 -3
- package/template/cs-lib/proj/MyLib.csproj +0 -3
- package/Libraries/Network/RCTNetworkingWinShared.js +0 -117
|
@@ -1 +1,117 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) Microsoft Corporation.
|
|
3
|
+
* Licensed under the MIT License.
|
|
4
|
+
*
|
|
5
|
+
* @flow strict-local
|
|
6
|
+
* @format
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
'use strict';
|
|
10
|
+
|
|
11
|
+
import RCTDeviceEventEmitter from '../EventEmitter/RCTDeviceEventEmitter';
|
|
12
|
+
const RCTNetworkingNative =
|
|
13
|
+
require('../BatchedBridge/NativeModules').Networking; // [Windows]
|
|
14
|
+
import {type NativeResponseType} from './XMLHttpRequest';
|
|
15
|
+
import convertRequestBody, {type RequestBody} from './convertRequestBody';
|
|
16
|
+
import {type EventSubscription} from '../vendor/emitter/EventEmitter';
|
|
17
|
+
|
|
18
|
+
type RCTNetworkingEventDefinitions = $ReadOnly<{
|
|
19
|
+
didSendNetworkData: [
|
|
20
|
+
[
|
|
21
|
+
number, // requestId
|
|
22
|
+
number, // progress
|
|
23
|
+
number, // total
|
|
24
|
+
],
|
|
25
|
+
],
|
|
26
|
+
didReceiveNetworkResponse: [
|
|
27
|
+
[
|
|
28
|
+
number, // requestId
|
|
29
|
+
number, // status
|
|
30
|
+
?{[string]: string}, // responseHeaders
|
|
31
|
+
?string, // responseURL
|
|
32
|
+
],
|
|
33
|
+
],
|
|
34
|
+
didReceiveNetworkData: [
|
|
35
|
+
[
|
|
36
|
+
number, // requestId
|
|
37
|
+
string, // response
|
|
38
|
+
],
|
|
39
|
+
],
|
|
40
|
+
didReceiveNetworkIncrementalData: [
|
|
41
|
+
[
|
|
42
|
+
number, // requestId
|
|
43
|
+
string, // responseText
|
|
44
|
+
number, // progress
|
|
45
|
+
number, // total
|
|
46
|
+
],
|
|
47
|
+
],
|
|
48
|
+
didReceiveNetworkDataProgress: [
|
|
49
|
+
[
|
|
50
|
+
number, // requestId
|
|
51
|
+
number, // loaded
|
|
52
|
+
number, // total
|
|
53
|
+
],
|
|
54
|
+
],
|
|
55
|
+
didCompleteNetworkResponse: [
|
|
56
|
+
[
|
|
57
|
+
number, // requestId
|
|
58
|
+
string, // error
|
|
59
|
+
boolean, // timeOutError
|
|
60
|
+
],
|
|
61
|
+
],
|
|
62
|
+
}>;
|
|
63
|
+
|
|
64
|
+
let _requestId = 1;
|
|
65
|
+
function generateRequestId(): number {
|
|
66
|
+
return _requestId++;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
const RCTNetworking = {
|
|
70
|
+
addListener<K: $Keys<RCTNetworkingEventDefinitions>>(
|
|
71
|
+
eventType: K,
|
|
72
|
+
listener: (...$ElementType<RCTNetworkingEventDefinitions, K>) => mixed,
|
|
73
|
+
context?: mixed,
|
|
74
|
+
): EventSubscription {
|
|
75
|
+
return RCTDeviceEventEmitter.addListener(eventType, listener, context);
|
|
76
|
+
},
|
|
77
|
+
|
|
78
|
+
sendRequest(
|
|
79
|
+
method: string,
|
|
80
|
+
trackingName: string,
|
|
81
|
+
url: string,
|
|
82
|
+
headers: {...},
|
|
83
|
+
data: RequestBody,
|
|
84
|
+
responseType: NativeResponseType,
|
|
85
|
+
incrementalUpdates: boolean,
|
|
86
|
+
timeout: number,
|
|
87
|
+
callback: (requestId: number) => void,
|
|
88
|
+
withCredentials: boolean,
|
|
89
|
+
) {
|
|
90
|
+
const requestId = generateRequestId();
|
|
91
|
+
const body = convertRequestBody(data);
|
|
92
|
+
RCTNetworkingNative.sendRequest(
|
|
93
|
+
{
|
|
94
|
+
method,
|
|
95
|
+
url,
|
|
96
|
+
requestId,
|
|
97
|
+
data: {...body, trackingName},
|
|
98
|
+
headers,
|
|
99
|
+
responseType,
|
|
100
|
+
incrementalUpdates,
|
|
101
|
+
timeout,
|
|
102
|
+
withCredentials,
|
|
103
|
+
},
|
|
104
|
+
callback,
|
|
105
|
+
);
|
|
106
|
+
},
|
|
107
|
+
|
|
108
|
+
abortRequest(requestId: number) {
|
|
109
|
+
RCTNetworkingNative.abortRequest(requestId);
|
|
110
|
+
},
|
|
111
|
+
|
|
112
|
+
clearCookies(callback: (result: boolean) => void) {
|
|
113
|
+
RCTNetworkingNative.clearCookies(callback);
|
|
114
|
+
},
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
module.exports = RCTNetworking;
|
|
@@ -25,9 +25,6 @@
|
|
|
25
25
|
<NoWarn>$(NoWarn);1591</NoWarn>
|
|
26
26
|
<!-- Missing XML comment for publicly visible type or member -->
|
|
27
27
|
</PropertyGroup>
|
|
28
|
-
<PropertyGroup Label="NuGet">
|
|
29
|
-
<AssetTargetFallback>$(AssetTargetFallback);native</AssetTargetFallback>
|
|
30
|
-
</PropertyGroup>
|
|
31
28
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
|
|
32
29
|
<PlatformTarget>x86</PlatformTarget>
|
|
33
30
|
<DebugSymbols>true</DebugSymbols>
|
|
@@ -80,6 +77,7 @@
|
|
|
80
77
|
<RestoreProjectStyle>PackageReference</RestoreProjectStyle>
|
|
81
78
|
<RestorePackagesWithLockFile>true</RestorePackagesWithLockFile>
|
|
82
79
|
</PropertyGroup>
|
|
80
|
+
<Import Project="..\PropertySheets\NuGet.CSharp.props" />
|
|
83
81
|
<Import Project="..\PropertySheets\WinUI.props" />
|
|
84
82
|
<ItemGroup>
|
|
85
83
|
<Compile Include="AttributedViewManager.cs" />
|
|
@@ -37,14 +37,5 @@
|
|
|
37
37
|
<HermesNoDLLCopy Condition="'$(UseHermes)' != 'true'">true</HermesNoDLLCopy>
|
|
38
38
|
</PropertyGroup>
|
|
39
39
|
|
|
40
|
-
<!-- Should match entry in $(ReactNativeWindowsDir)vnext\Directory.Build.props -->
|
|
41
|
-
<PropertyGroup Label="NuGet" Condition="'$(MSBuildProjectExtension)' == '.vcxproj'">
|
|
42
|
-
<!--See https://docs.microsoft.com/en-us/nuget/reference/msbuild-targets#restore-target-->
|
|
43
|
-
<RestoreUseStaticGraphEvaluation Condition="'$(BuildingInsideVisualStudio)' == 'true'">true</RestoreUseStaticGraphEvaluation>
|
|
44
|
-
|
|
45
|
-
<!-- Ensure PackageReference compatibility for any consuming projects/apps -->
|
|
46
|
-
<ResolveNuGetPackages>false</ResolveNuGetPackages>
|
|
47
|
-
</PropertyGroup>
|
|
48
|
-
|
|
49
40
|
<Import Project="$(ReactNativeWindowsDir)\PropertySheets\Generated\PackageVersion.g.props" />
|
|
50
41
|
</Project>
|
|
@@ -20,5 +20,6 @@
|
|
|
20
20
|
<Import Project="$(MSBuildThisFileDirectory)Microsoft.ReactNative.Uwp.Common.props" />
|
|
21
21
|
<Import Project="$(ReactNativeWindowsDir)\PropertySheets\Appx.props" />
|
|
22
22
|
<Import Project="$(ReactNativeWindowsDir)\PropertySheets\Autolink.props" />
|
|
23
|
+
<Import Project="$(ReactNativeWindowsDir)\PropertySheets\NuGet.CSharp.props" />
|
|
23
24
|
<Import Project="$(ReactNativeWindowsDir)\PropertySheets\WinUI.props" />
|
|
24
25
|
</Project>
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
<Import Project="$(MSBuildThisFileDirectory)Microsoft.ReactNative.Uwp.Common.props" />
|
|
17
17
|
<Import Project="$(ReactNativeWindowsDir)\PropertySheets\Appx.props" />
|
|
18
18
|
<Import Project="$(ReactNativeWindowsDir)\PropertySheets\Autolink.props" />
|
|
19
|
+
<Import Project="$(ReactNativeWindowsDir)\PropertySheets\NuGet.Cpp.props" />
|
|
19
20
|
<Import Project="$(ReactNativeWindowsDir)\PropertySheets\WinUI.props" />
|
|
20
21
|
<Import Project="$(ReactNativeWindowsDir)\PropertySheets\CppAppConsumeCSharpModule.props" />
|
|
21
22
|
<Import Project="$(ReactNativeWindowsDir)\PropertySheets\PackageVersionDefinitions.props" />
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
<GenerateLibraryLayout>false</GenerateLibraryLayout>
|
|
18
18
|
</PropertyGroup>
|
|
19
19
|
<Import Project="$(MSBuildThisFileDirectory)Microsoft.ReactNative.Uwp.Common.props" />
|
|
20
|
+
<Import Project="$(ReactNativeWindowsDir)\PropertySheets\NuGet.Cpp.props" />
|
|
20
21
|
<Import Project="$(ReactNativeWindowsDir)\PropertySheets\WinUI.props" />
|
|
21
22
|
<Import Project="$(ReactNativeWindowsDir)\PropertySheets\PackageVersionDefinitions.props" />
|
|
22
23
|
</Project>
|
|
@@ -22,5 +22,6 @@
|
|
|
22
22
|
<Import Project="$(MSBuildThisFileDirectory)Microsoft.ReactNative.WinAppSDK.Common.props" />
|
|
23
23
|
<Import Project="$(ReactNativeWindowsDir)\PropertySheets\Appx.props" />
|
|
24
24
|
<Import Project="$(ReactNativeWindowsDir)\PropertySheets\Autolink.props" />
|
|
25
|
+
<Import Project="$(ReactNativeWindowsDir)\PropertySheets\NuGet.CSharp.props" />
|
|
25
26
|
<Import Project="$(ReactNativeWindowsDir)\PropertySheets\WinUI.props" />
|
|
26
27
|
</Project>
|
|
@@ -10,10 +10,10 @@
|
|
|
10
10
|
-->
|
|
11
11
|
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
12
12
|
<PropertyGroup>
|
|
13
|
-
<ReactNativeWindowsVersion>0.70.
|
|
13
|
+
<ReactNativeWindowsVersion>0.70.2</ReactNativeWindowsVersion>
|
|
14
14
|
<ReactNativeWindowsMajor>0</ReactNativeWindowsMajor>
|
|
15
15
|
<ReactNativeWindowsMinor>70</ReactNativeWindowsMinor>
|
|
16
|
-
<ReactNativeWindowsPatch>
|
|
16
|
+
<ReactNativeWindowsPatch>2</ReactNativeWindowsPatch>
|
|
17
17
|
<ReactNativeWindowsCanary>false</ReactNativeWindowsCanary>
|
|
18
18
|
</PropertyGroup>
|
|
19
19
|
</Project>
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<!--
|
|
3
|
+
Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4
|
+
Licensed under the MIT License.
|
|
5
|
+
|
|
6
|
+
Defines NuGet-related properties for C# projects using PackageReference.
|
|
7
|
+
-->
|
|
8
|
+
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
9
|
+
|
|
10
|
+
<PropertyGroup Label="NuGet">
|
|
11
|
+
<!-- https://github.com/NuGet/Home/issues/10511#issuecomment-778400668 -->
|
|
12
|
+
<AssetTargetFallback>$(AssetTargetFallback);native</AssetTargetFallback>
|
|
13
|
+
</PropertyGroup>
|
|
14
|
+
|
|
15
|
+
</Project>
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="utf-8"?>
|
|
2
|
+
<!--
|
|
3
|
+
Copyright (c) Microsoft Corporation. All rights reserved.
|
|
4
|
+
Licensed under the MIT License.
|
|
5
|
+
|
|
6
|
+
Defines NuGet-related properties for C++ projects using PackageReference.
|
|
7
|
+
-->
|
|
8
|
+
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
|
9
|
+
|
|
10
|
+
<PropertyGroup Label="NuGet">
|
|
11
|
+
<!-- Should match entry in $(ReactNativeWindowsDir)vnext\Directory.Build.props -->
|
|
12
|
+
<!--See https://docs.microsoft.com/en-us/nuget/reference/msbuild-targets#restore-target-->
|
|
13
|
+
<RestoreUseStaticGraphEvaluation Condition="'$(BuildingInsideVisualStudio)' == 'true'">true</RestoreUseStaticGraphEvaluation>
|
|
14
|
+
|
|
15
|
+
<!-- Ensure PackageReference compatibility for any consuming projects/apps -->
|
|
16
|
+
<ResolveNuGetPackages>false</ResolveNuGetPackages>
|
|
17
|
+
|
|
18
|
+
<!-- https://github.com/NuGet/Home/issues/10511#issuecomment-778400668 -->
|
|
19
|
+
<AssetTargetFallback>$(AssetTargetFallback);uap10.0.16299</AssetTargetFallback>
|
|
20
|
+
|
|
21
|
+
<!--
|
|
22
|
+
Avoid Visual Studio error message:
|
|
23
|
+
"The project '$(MSBuildProjectName)' ran into a problem during the last operation: The value of the
|
|
24
|
+
'TargetFrameworkMoniker' and 'NuGetTargetMoniker' properties in the '$(Configuration)|$(Platform)' configuration are both
|
|
25
|
+
empty. This configuration will not contribute to NuGet restore, which may result in restore and build errors. You may
|
|
26
|
+
need to reload the solution after fixing the problem."
|
|
27
|
+
-->
|
|
28
|
+
<TargetFrameworkMoniker>native,Version=v0.0</TargetFrameworkMoniker>
|
|
29
|
+
</PropertyGroup>
|
|
30
|
+
|
|
31
|
+
</Project>
|
|
@@ -17,21 +17,7 @@
|
|
|
17
17
|
<EnableWinRtLeanAndMean Condition="'$(EnableWinRtLeanAndMean)' == ''">true</EnableWinRtLeanAndMean>
|
|
18
18
|
</PropertyGroup>
|
|
19
19
|
|
|
20
|
-
<
|
|
21
|
-
<ResolveNuGetPackages>false</ResolveNuGetPackages>
|
|
22
|
-
|
|
23
|
-
<!-- https://github.com/NuGet/Home/issues/10511#issuecomment-778400668 -->
|
|
24
|
-
<AssetTargetFallback>$(AssetTargetFallback);native</AssetTargetFallback>
|
|
25
|
-
|
|
26
|
-
<!--
|
|
27
|
-
Avoid Visual Studio error message:
|
|
28
|
-
"The project '$(MSBuildProjectName)' ran into a problem during the last operation: The value of the
|
|
29
|
-
'TargetFrameworkMoniker' and 'NuGetTargetMoniker' properties in the '$(Configuration)|$(Platform)' configuration are both
|
|
30
|
-
empty. This configuration will not contribute to NuGet restore, which may result in restore and build errors. You may
|
|
31
|
-
need to reload the solution after fixing the problem."
|
|
32
|
-
-->
|
|
33
|
-
<TargetFrameworkMoniker>native,Version=v0.0</TargetFrameworkMoniker>
|
|
34
|
-
</PropertyGroup>
|
|
20
|
+
<Import Project="$(MSBuildThisFileDirectory)NuGet.Cpp.props" />
|
|
35
21
|
|
|
36
22
|
<PropertyGroup Label="Desktop">
|
|
37
23
|
<!-- See https://docs.microsoft.com/en-us/cpp/porting/modifying-winver-and-win32-winnt -->
|
|
@@ -56,6 +56,7 @@
|
|
|
56
56
|
<file src="$nugetroot$\inc\Shared\Modules\I18nModule.h" target="inc"/>
|
|
57
57
|
<file src="$nugetroot$\inc\Shared\NativeModuleProvider.h" target="inc"/>
|
|
58
58
|
<file src="$nugetroot$\inc\Shared\Networking\IWebSocketResource.h" target="inc"/>
|
|
59
|
+
<file src="$nugetroot$\inc\Shared\Networking\OriginPolicy.h" target="inc"/>
|
|
59
60
|
<file src="$nugetroot$\inc\Shared\RuntimeOptions.h" target="inc"/>
|
|
60
61
|
<file src="$nugetroot$\inc\Shared\Tracing.h" target="inc"/>
|
|
61
62
|
|
|
@@ -15,7 +15,7 @@ namespace Microsoft::React {
|
|
|
15
15
|
|
|
16
16
|
///
|
|
17
17
|
/// Realizes <c>NativeModules</c> projection.
|
|
18
|
-
/// <remarks>See src\Libraries\Network\
|
|
18
|
+
/// <remarks>See src\Libraries\Network\RCTNetworking.windows.js</remarks>
|
|
19
19
|
///
|
|
20
20
|
class HttpModule : public facebook::xplat::module::CxxModule {
|
|
21
21
|
public:
|
|
@@ -9,7 +9,7 @@ enum class OriginPolicy : size_t {
|
|
|
9
9
|
None = 0,
|
|
10
10
|
SameOrigin = 1,
|
|
11
11
|
SimpleCrossOriginResourceSharing = 2,
|
|
12
|
-
CrossOriginResourceSharing = 3,
|
|
12
|
+
CrossOriginResourceSharing = 3,
|
|
13
13
|
};
|
|
14
14
|
|
|
15
15
|
} // namespace Microsoft::React::Networking
|
package/package.json
CHANGED
|
@@ -15,9 +15,6 @@
|
|
|
15
15
|
<ApplicationType>Windows Store</ApplicationType>
|
|
16
16
|
<ApplicationTypeRevision>10.0</ApplicationTypeRevision>
|
|
17
17
|
</PropertyGroup>
|
|
18
|
-
<PropertyGroup Label="NuGet">
|
|
19
|
-
<ResolveNuGetPackages>false</ResolveNuGetPackages>
|
|
20
|
-
</PropertyGroup>
|
|
21
18
|
<PropertyGroup Label="ReactNativeWindowsProps">
|
|
22
19
|
<ReactNativeWindowsDir Condition="'$(ReactNativeWindowsDir)' == ''">$([MSBuild]::GetDirectoryNameOfFileAbove($(MSBuildThisFileDirectory), 'node_modules\react-native-windows\package.json'))\node_modules\react-native-windows\</ReactNativeWindowsDir>
|
|
23
20
|
</PropertyGroup>
|
|
@@ -15,9 +15,6 @@
|
|
|
15
15
|
<ApplicationType>Windows Store</ApplicationType>
|
|
16
16
|
<ApplicationTypeRevision>10.0</ApplicationTypeRevision>
|
|
17
17
|
</PropertyGroup>
|
|
18
|
-
<PropertyGroup Label="NuGet">
|
|
19
|
-
<ResolveNuGetPackages>false</ResolveNuGetPackages>
|
|
20
|
-
</PropertyGroup>
|
|
21
18
|
<PropertyGroup Label="ReactNativeWindowsProps">
|
|
22
19
|
<ReactNativeWindowsDir Condition="'$(ReactNativeWindowsDir)' == ''">$([MSBuild]::GetDirectoryNameOfFileAbove($(SolutionDir), 'node_modules\react-native-windows\package.json'))\node_modules\react-native-windows\</ReactNativeWindowsDir>
|
|
23
20
|
</PropertyGroup>
|
|
@@ -25,9 +25,6 @@
|
|
|
25
25
|
<AppxGeneratePrisForPortableLibrariesEnabled>false</AppxGeneratePrisForPortableLibrariesEnabled>
|
|
26
26
|
<LangVersion>7.3</LangVersion>
|
|
27
27
|
</PropertyGroup>
|
|
28
|
-
<PropertyGroup Label="NuGet">
|
|
29
|
-
<AssetTargetFallback>$(AssetTargetFallback);native</AssetTargetFallback>
|
|
30
|
-
</PropertyGroup>
|
|
31
28
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
|
|
32
29
|
<DebugSymbols>true</DebugSymbols>
|
|
33
30
|
<OutputPath>bin\x86\Debug\</OutputPath>
|
|
@@ -24,9 +24,6 @@
|
|
|
24
24
|
<WindowsXamlEnableOverview>true</WindowsXamlEnableOverview>
|
|
25
25
|
<LangVersion>7.3</LangVersion>
|
|
26
26
|
</PropertyGroup>
|
|
27
|
-
<PropertyGroup Label="NuGet">
|
|
28
|
-
<AssetTargetFallback>$(AssetTargetFallback);native</AssetTargetFallback>
|
|
29
|
-
</PropertyGroup>
|
|
30
27
|
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
|
|
31
28
|
<DebugSymbols>true</DebugSymbols>
|
|
32
29
|
<OutputPath>bin\x86\Debug\</OutputPath>
|
|
@@ -1,117 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) Microsoft Corporation.
|
|
3
|
-
* Licensed under the MIT License.
|
|
4
|
-
*
|
|
5
|
-
* @flow strict-local
|
|
6
|
-
* @format
|
|
7
|
-
*/
|
|
8
|
-
|
|
9
|
-
'use strict';
|
|
10
|
-
|
|
11
|
-
import RCTDeviceEventEmitter from '../EventEmitter/RCTDeviceEventEmitter';
|
|
12
|
-
const RCTNetworkingNative =
|
|
13
|
-
require('../BatchedBridge/NativeModules').Networking; // [Windows]
|
|
14
|
-
import {type NativeResponseType} from './XMLHttpRequest';
|
|
15
|
-
import convertRequestBody, {type RequestBody} from './convertRequestBody';
|
|
16
|
-
import {type EventSubscription} from '../vendor/emitter/EventEmitter';
|
|
17
|
-
|
|
18
|
-
type RCTNetworkingEventDefinitions = $ReadOnly<{
|
|
19
|
-
didSendNetworkData: [
|
|
20
|
-
[
|
|
21
|
-
number, // requestId
|
|
22
|
-
number, // progress
|
|
23
|
-
number, // total
|
|
24
|
-
],
|
|
25
|
-
],
|
|
26
|
-
didReceiveNetworkResponse: [
|
|
27
|
-
[
|
|
28
|
-
number, // requestId
|
|
29
|
-
number, // status
|
|
30
|
-
?{[string]: string}, // responseHeaders
|
|
31
|
-
?string, // responseURL
|
|
32
|
-
],
|
|
33
|
-
],
|
|
34
|
-
didReceiveNetworkData: [
|
|
35
|
-
[
|
|
36
|
-
number, // requestId
|
|
37
|
-
string, // response
|
|
38
|
-
],
|
|
39
|
-
],
|
|
40
|
-
didReceiveNetworkIncrementalData: [
|
|
41
|
-
[
|
|
42
|
-
number, // requestId
|
|
43
|
-
string, // responseText
|
|
44
|
-
number, // progress
|
|
45
|
-
number, // total
|
|
46
|
-
],
|
|
47
|
-
],
|
|
48
|
-
didReceiveNetworkDataProgress: [
|
|
49
|
-
[
|
|
50
|
-
number, // requestId
|
|
51
|
-
number, // loaded
|
|
52
|
-
number, // total
|
|
53
|
-
],
|
|
54
|
-
],
|
|
55
|
-
didCompleteNetworkResponse: [
|
|
56
|
-
[
|
|
57
|
-
number, // requestId
|
|
58
|
-
string, // error
|
|
59
|
-
boolean, // timeOutError
|
|
60
|
-
],
|
|
61
|
-
],
|
|
62
|
-
}>;
|
|
63
|
-
|
|
64
|
-
let _requestId = 1;
|
|
65
|
-
function generateRequestId(): number {
|
|
66
|
-
return _requestId++;
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
const RCTNetworking = {
|
|
70
|
-
addListener<K: $Keys<RCTNetworkingEventDefinitions>>(
|
|
71
|
-
eventType: K,
|
|
72
|
-
listener: (...$ElementType<RCTNetworkingEventDefinitions, K>) => mixed,
|
|
73
|
-
context?: mixed,
|
|
74
|
-
): EventSubscription {
|
|
75
|
-
return RCTDeviceEventEmitter.addListener(eventType, listener, context);
|
|
76
|
-
},
|
|
77
|
-
|
|
78
|
-
sendRequest(
|
|
79
|
-
method: string,
|
|
80
|
-
trackingName: string,
|
|
81
|
-
url: string,
|
|
82
|
-
headers: {...},
|
|
83
|
-
data: RequestBody,
|
|
84
|
-
responseType: NativeResponseType,
|
|
85
|
-
incrementalUpdates: boolean,
|
|
86
|
-
timeout: number,
|
|
87
|
-
callback: (requestId: number) => void,
|
|
88
|
-
withCredentials: boolean,
|
|
89
|
-
) {
|
|
90
|
-
const requestId = generateRequestId();
|
|
91
|
-
const body = convertRequestBody(data);
|
|
92
|
-
RCTNetworkingNative.sendRequest(
|
|
93
|
-
{
|
|
94
|
-
method,
|
|
95
|
-
url,
|
|
96
|
-
requestId,
|
|
97
|
-
data: {...body, trackingName},
|
|
98
|
-
headers,
|
|
99
|
-
responseType,
|
|
100
|
-
incrementalUpdates,
|
|
101
|
-
timeout,
|
|
102
|
-
withCredentials,
|
|
103
|
-
},
|
|
104
|
-
callback,
|
|
105
|
-
);
|
|
106
|
-
},
|
|
107
|
-
|
|
108
|
-
abortRequest(requestId: number) {
|
|
109
|
-
RCTNetworkingNative.abortRequest(requestId);
|
|
110
|
-
},
|
|
111
|
-
|
|
112
|
-
clearCookies(callback: (result: boolean) => void) {
|
|
113
|
-
RCTNetworkingNative.clearCookies(callback);
|
|
114
|
-
},
|
|
115
|
-
};
|
|
116
|
-
|
|
117
|
-
module.exports = RCTNetworking;
|