Skip to content

Commit

Permalink
[0.72] Have RCTNetworking.win32 fork RCTNetworking.ios (#12202)
Browse files Browse the repository at this point in the history
* 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

* Change files
  • Loading branch information
JunielKatarn committed Oct 3, 2023
1 parent 99f0ce7 commit 2255827
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 25 deletions.
6 changes: 6 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,9 @@ end_of_line = crlf
# Shell scripts
[*.{cmd,bat,ps1}]
end_of_line = crlf

[overrides.json]
insert_final_newline = false

[package.json]
insert_final_newline = false
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "Have RCTNetworking.win32 fork RCTNetworking.ios (#12199)",
"packageName": "@office-iss/react-native-win32",
"email": "julio.rocha@microsoft.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"type": "patch",
"comment": "Have RCTNetworking.win32 fork RCTNetworking.ios (#12199)",
"packageName": "react-native-windows",
"email": "julio.rocha@microsoft.com",
"dependentChangeType": "patch"
}
6 changes: 3 additions & 3 deletions packages/@office-iss/react-native-win32/overrides.json
Original file line number Diff line number Diff line change
Expand Up @@ -343,10 +343,10 @@
"baseHash": "daeb879969c322e67efcb9595d6bb171b9dad6d8"
},
{
"type": "derived",
"type": "copy",
"file": "src/Libraries/Network/RCTNetworking.win32.js",
"baseFile": "packages/react-native/Libraries/Network/RCTNetworking.android.js",
"baseHash": "67d0d4757fcd7a1c2c0f6de642f713f0fa300e28",
"baseFile": "packages/react-native/Libraries/Network/RCTNetworking.ios.js",
"baseHash": "39fc8e1003b0f6345ec4fea060f455d06939a321",
"issue": 4318
},
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/**
* Copyright (c) Microsoft Corporation.
* Licensed under the MIT License.
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*
* @flow strict-local
* @format
Expand All @@ -9,11 +11,10 @@
'use strict';

import RCTDeviceEventEmitter from '../EventEmitter/RCTDeviceEventEmitter';
const RCTNetworkingNative =
require('../BatchedBridge/NativeModules').Networking; // [Windows]
import {type NativeResponseType} from './XMLHttpRequest';
import convertRequestBody, {type RequestBody} from './convertRequestBody';
import {type EventSubscription} from '../vendor/emitter/EventEmitter';
import convertRequestBody, {type RequestBody} from './convertRequestBody';
import NativeNetworkingIOS from './NativeNetworkingIOS';
import {type NativeResponseType} from './XMLHttpRequest';

type RCTNetworkingEventDefinitions = $ReadOnly<{
didSendNetworkData: [
Expand Down Expand Up @@ -61,11 +62,6 @@ type RCTNetworkingEventDefinitions = $ReadOnly<{
],
}>;

let _requestId = 1;
function generateRequestId(): number {
return _requestId++;
}

const RCTNetworking = {
addListener<K: $Keys<RCTNetworkingEventDefinitions>>(
eventType: K,
Expand All @@ -88,13 +84,11 @@ const RCTNetworking = {
callback: (requestId: number) => void,
withCredentials: boolean,
) {
const requestId = generateRequestId();
const body = convertRequestBody(data);
RCTNetworkingNative.sendRequest(
NativeNetworkingIOS.sendRequest(
{
method,
url,
requestId,
data: {...body, trackingName},
headers,
responseType,
Expand All @@ -107,11 +101,11 @@ const RCTNetworking = {
},

abortRequest(requestId: number) {
RCTNetworkingNative.abortRequest(requestId);
NativeNetworkingIOS.abortRequest(requestId);
},

clearCookies(callback: (result: boolean) => void) {
RCTNetworkingNative.clearCookies(callback);
NativeNetworkingIOS.clearCookies(callback);
},
};

Expand Down
6 changes: 0 additions & 6 deletions vnext/.editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,3 @@ csharp_prefer_simple_default_expression = false:none
[*.ps1]
indent_style = tab
indent_size = 4

[overrides.json]
insert_final_newline = false

[package.json]
insert_final_newline = false

0 comments on commit 2255827

Please sign in to comment.