Skip to content

Commit d64dc2a

Browse files
authored
Have RCTNetworking.win32 fork RCTNetworking.ios (#12199)
* Have RCTNetworking.win32 fork RCTNetworking.ios * Copy contents from windows to win32 * Change files * Drop overrides newline setting to parent * Make RCTNetworking.win32 a copy of iOS variant
1 parent 8310b79 commit d64dc2a

File tree

7 files changed

+33
-25
lines changed

7 files changed

+33
-25
lines changed

.editorconfig

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,9 @@ end_of_line = crlf
4040
# Shell scripts
4141
[*.{cmd,bat,ps1}]
4242
end_of_line = crlf
43+
44+
[overrides.json]
45+
insert_final_newline = false
46+
47+
[package.json]
48+
insert_final_newline = false
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "prerelease",
3+
"comment": "Have RCTNetworking.win32 fork RCTNetworking.ios",
4+
"packageName": "@office-iss/react-native-win32",
5+
"email": "julio.rocha@microsoft.com",
6+
"dependentChangeType": "patch"
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "prerelease",
3+
"comment": "Have RCTNetworking.win32 fork RCTNetworking.ios",
4+
"packageName": "react-native-windows",
5+
"email": "julio.rocha@microsoft.com",
6+
"dependentChangeType": "patch"
7+
}

packages/@office-iss/react-native-win32/overrides.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -343,10 +343,10 @@
343343
"baseHash": "97b5ae2c84de4ad043dc44a3f647611ba869a03e"
344344
},
345345
{
346-
"type": "derived",
346+
"type": "copy",
347347
"file": "src/Libraries/Network/RCTNetworking.win32.js",
348-
"baseFile": "packages/react-native/Libraries/Network/RCTNetworking.android.js",
349-
"baseHash": "b929de7bbe71dc956a1b33835bb6b0c2ca7b3479",
348+
"baseFile": "packages/react-native/Libraries/Network/RCTNetworking.ios.js",
349+
"baseHash": "39fc8e1003b0f6345ec4fea060f455d06939a321",
350350
"issue": 4318
351351
},
352352
{

packages/@office-iss/react-native-win32/src/Libraries/Network/RCTNetworking.win32.js

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
/**
2-
* Copyright (c) Microsoft Corporation.
3-
* Licensed under the MIT License.
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
46
*
57
* @flow strict-local
68
* @format
@@ -9,11 +11,10 @@
911
'use strict';
1012

1113
import RCTDeviceEventEmitter from '../EventEmitter/RCTDeviceEventEmitter';
12-
const RCTNetworkingNative =
13-
require('../BatchedBridge/NativeModules').Networking; // [Windows]
14+
import {type EventSubscription} from '../vendor/emitter/EventEmitter';
1415
import convertRequestBody, {type RequestBody} from './convertRequestBody';
16+
import NativeNetworkingIOS from './NativeNetworkingIOS';
1517
import {type NativeResponseType} from './XMLHttpRequest';
16-
import {type EventSubscription} from '../vendor/emitter/EventEmitter';
1718

1819
type RCTNetworkingEventDefinitions = $ReadOnly<{
1920
didSendNetworkData: [
@@ -61,11 +62,6 @@ type RCTNetworkingEventDefinitions = $ReadOnly<{
6162
],
6263
}>;
6364

64-
let _requestId = 1;
65-
function generateRequestId(): number {
66-
return _requestId++;
67-
}
68-
6965
const RCTNetworking = {
7066
addListener<K: $Keys<RCTNetworkingEventDefinitions>>(
7167
eventType: K,
@@ -88,13 +84,11 @@ const RCTNetworking = {
8884
callback: (requestId: number) => void,
8985
withCredentials: boolean,
9086
) {
91-
const requestId = generateRequestId();
9287
const body = convertRequestBody(data);
93-
RCTNetworkingNative.sendRequest(
88+
NativeNetworkingIOS.sendRequest(
9489
{
9590
method,
9691
url,
97-
requestId,
9892
data: {...body, trackingName},
9993
headers,
10094
responseType,
@@ -107,11 +101,11 @@ const RCTNetworking = {
107101
},
108102

109103
abortRequest(requestId: number) {
110-
RCTNetworkingNative.abortRequest(requestId);
104+
NativeNetworkingIOS.abortRequest(requestId);
111105
},
112106

113107
clearCookies(callback: (result: boolean) => void) {
114-
RCTNetworkingNative.clearCookies(callback);
108+
NativeNetworkingIOS.clearCookies(callback);
115109
},
116110
};
117111

vnext/.editorconfig

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,3 @@ csharp_prefer_simple_default_expression = false:none
2727
[*.ps1]
2828
indent_style = tab
2929
indent_size = 4
30-
31-
[overrides.json]
32-
insert_final_newline = false
33-
34-
[package.json]
35-
insert_final_newline = false

vnext/overrides.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -504,4 +504,4 @@
504504
"baseHash": "a09b2fdd9859584069281df3311ef188a5640b00"
505505
}
506506
]
507-
}
507+
}

0 commit comments

Comments
 (0)