mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-28 20:25:33 +08:00
Migrate "Libraries" from Haste to standard path-based requires (sans vendor & renderers) (#24749)
Summary: This is the next step in moving RN towards standard path-based requires. All the requires in `Libraries` have been rewritten to use relative requires with a few exceptions, namely, `vendor` and `Renderer/oss` since those need to be changed upstream. This commit uses relative requires instead of `react-native/...` so that if Facebook were to stop syncing out certain folders and therefore remove code from the react-native package, internal code at Facebook would not need to change. See the umbrella issue at https://github.com/facebook/react-native/issues/24316 for more detail. [General] [Changed] - Migrate "Libraries" from Haste to standard path-based requires Pull Request resolved: https://github.com/facebook/react-native/pull/24749 Differential Revision: D15258017 Pulled By: cpojer fbshipit-source-id: a1f480ea36c05c659b6f37c8f02f6f9216d5a323
This commit is contained in:
committed by
Facebook Github Bot
parent
59749f527a
commit
0ee5f68929
@@ -10,9 +10,9 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
const NativeEventEmitter = require('NativeEventEmitter');
|
||||
const NativeModules = require('NativeModules');
|
||||
const Platform = require('Platform');
|
||||
const NativeEventEmitter = require('../EventEmitter/NativeEventEmitter');
|
||||
const NativeModules = require('../BatchedBridge/NativeModules');
|
||||
const Platform = require('../Utilities/Platform');
|
||||
const RCTNetInfo = NativeModules.NetInfo;
|
||||
|
||||
const NetInfoEventEmitter = new NativeEventEmitter(RCTNetInfo);
|
||||
|
||||
@@ -12,11 +12,12 @@
|
||||
|
||||
// Do not require the native RCTNetworking module directly! Use this wrapper module instead.
|
||||
// It will add the necessary requestId, so that you don't have to generate it yourself.
|
||||
const NativeEventEmitter = require('NativeEventEmitter');
|
||||
const RCTNetworkingNative = require('NativeModules').Networking;
|
||||
const convertRequestBody = require('convertRequestBody');
|
||||
const NativeEventEmitter = require('../EventEmitter/NativeEventEmitter');
|
||||
const RCTNetworkingNative = require('../BatchedBridge/NativeModules')
|
||||
.Networking;
|
||||
const convertRequestBody = require('./convertRequestBody');
|
||||
|
||||
import type {RequestBody} from 'convertRequestBody';
|
||||
import type {RequestBody} from './convertRequestBody';
|
||||
|
||||
type Header = [string, string];
|
||||
|
||||
|
||||
@@ -10,11 +10,12 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
const NativeEventEmitter = require('NativeEventEmitter');
|
||||
const RCTNetworkingNative = require('NativeModules').Networking;
|
||||
const convertRequestBody = require('convertRequestBody');
|
||||
const NativeEventEmitter = require('../EventEmitter/NativeEventEmitter');
|
||||
const RCTNetworkingNative = require('../BatchedBridge/NativeModules')
|
||||
.Networking;
|
||||
const convertRequestBody = require('./convertRequestBody');
|
||||
|
||||
import type {RequestBody} from 'convertRequestBody';
|
||||
import type {RequestBody} from './convertRequestBody';
|
||||
|
||||
import type {NativeResponseType} from './XMLHttpRequest';
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
const XMLHttpRequest = require('XMLHttpRequest');
|
||||
const XMLHttpRequest = require('./XMLHttpRequest');
|
||||
const originalXHROpen = XMLHttpRequest.prototype.open;
|
||||
const originalXHRSend = XMLHttpRequest.prototype.send;
|
||||
const originalXHRSetRequestHeader = XMLHttpRequest.prototype.setRequestHeader;
|
||||
|
||||
@@ -11,12 +11,12 @@
|
||||
'use strict';
|
||||
|
||||
const EventTarget = require('event-target-shim');
|
||||
const RCTNetworking = require('RCTNetworking');
|
||||
const RCTNetworking = require('./RCTNetworking');
|
||||
|
||||
const base64 = require('base64-js');
|
||||
const invariant = require('invariant');
|
||||
const warning = require('fbjs/lib/warning');
|
||||
const BlobManager = require('BlobManager');
|
||||
const BlobManager = require('../Blob/BlobManager');
|
||||
|
||||
export type NativeResponseType = 'base64' | 'blob' | 'text';
|
||||
export type ResponseType =
|
||||
|
||||
@@ -10,7 +10,7 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
const FormData = require('FormData');
|
||||
const FormData = require('../FormData');
|
||||
|
||||
describe('FormData', function() {
|
||||
var formData;
|
||||
|
||||
@@ -9,8 +9,8 @@
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
jest.unmock('Platform');
|
||||
const Platform = require('Platform');
|
||||
jest.unmock('../../Utilities/Platform');
|
||||
const Platform = require('../../Utilities/Platform');
|
||||
let requestId = 1;
|
||||
|
||||
function setRequestId(id) {
|
||||
@@ -20,21 +20,23 @@ function setRequestId(id) {
|
||||
requestId = id;
|
||||
}
|
||||
|
||||
jest.dontMock('event-target-shim').setMock('NativeModules', {
|
||||
Networking: {
|
||||
addListener: function() {},
|
||||
removeListeners: function() {},
|
||||
sendRequest(options, callback) {
|
||||
if (typeof callback === 'function') {
|
||||
// android does not pass a callback
|
||||
callback(requestId);
|
||||
}
|
||||
jest
|
||||
.dontMock('event-target-shim')
|
||||
.setMock('../../BatchedBridge/NativeModules', {
|
||||
Networking: {
|
||||
addListener: function() {},
|
||||
removeListeners: function() {},
|
||||
sendRequest(options, callback) {
|
||||
if (typeof callback === 'function') {
|
||||
// android does not pass a callback
|
||||
callback(requestId);
|
||||
}
|
||||
},
|
||||
abortRequest: function() {},
|
||||
},
|
||||
abortRequest: function() {},
|
||||
},
|
||||
});
|
||||
});
|
||||
|
||||
const XMLHttpRequest = require('XMLHttpRequest');
|
||||
const XMLHttpRequest = require('../XMLHttpRequest');
|
||||
|
||||
describe('XMLHttpRequest', function() {
|
||||
let xhr;
|
||||
|
||||
@@ -9,10 +9,10 @@
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
const binaryToBase64 = require('binaryToBase64');
|
||||
const binaryToBase64 = require('../Utilities/binaryToBase64');
|
||||
|
||||
const Blob = require('Blob');
|
||||
const FormData = require('FormData');
|
||||
const Blob = require('../Blob/Blob');
|
||||
const FormData = require('./FormData');
|
||||
|
||||
export type RequestBody =
|
||||
| string
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
const whatwg = require('whatwg-fetch');
|
||||
const whatwg = require('../vendor/core/whatwg-fetch');
|
||||
|
||||
if (whatwg && whatwg.fetch) {
|
||||
module.exports = whatwg;
|
||||
|
||||
Reference in New Issue
Block a user