mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-01-12 22:50:10 +08:00
Reorganize core JS files
Reviewed By: lexs Differential Revision: D3987463 fbshipit-source-id: fa8f1d1bea7ed699120b9705ddc1c83767fcf8e4
This commit is contained in:
committed by
Facebook Github Bot
parent
d1f8add4d0
commit
292cc82d0e
@@ -24,7 +24,7 @@ type Buttons = Array<{
|
||||
}>;
|
||||
|
||||
type Options = {
|
||||
cancelable?: ?boolean;
|
||||
cancelable?: ?boolean,
|
||||
};
|
||||
|
||||
/**
|
||||
25
Libraries/Alert/RCTAlertManager.android.js
Normal file
25
Libraries/Alert/RCTAlertManager.android.js
Normal file
@@ -0,0 +1,25 @@
|
||||
/**
|
||||
* Copyright (c) 2013-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*
|
||||
* @providesModule RCTAlertManager
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
var DialogManager = require('NativeModules').DialogManagerAndroid;
|
||||
|
||||
function emptyCallback() {}
|
||||
|
||||
module.exports = {
|
||||
alertWithArgs: function(args, callback) {
|
||||
// TODO(5998984): Polyfill it correctly with DialogManagerAndroid
|
||||
DialogManager.showAlert(
|
||||
args,
|
||||
emptyCallback,
|
||||
callback || emptyCallback);
|
||||
},
|
||||
};
|
||||
@@ -11,8 +11,8 @@
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
var Platform = require('Platform');
|
||||
var NativeModules = require('NativeModules');
|
||||
var Platform = require('Platform');
|
||||
|
||||
function setupDevtools() {
|
||||
var messageListeners = [];
|
||||
@@ -11,9 +11,10 @@
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
const {fetch} = require('fetch');
|
||||
const getDevServer = require('getDevServer');
|
||||
|
||||
const {SourceCode} = require('NativeModules');
|
||||
const {fetch} = require('fetch');
|
||||
|
||||
import type {StackFrame} from 'parseErrorStack';
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
* 1. Require system.
|
||||
* 2. Bridged modules.
|
||||
*
|
||||
* @providesModule InitializeJavaScriptAppEngine
|
||||
* @providesModule InitializeCore
|
||||
* @flow
|
||||
*/
|
||||
|
||||
@@ -1,3 +1,12 @@
|
||||
/**
|
||||
* Copyright (c) 2013-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*/
|
||||
|
||||
// This mock only provides short-circuited methods of applyWithGuard and guard.
|
||||
// A lot of modules rely on these two functions. This mock relieves their tests
|
||||
// from depending on the real ErrorUtils module. If you need real error handling
|
||||
@@ -1,79 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) 2015-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*
|
||||
* This source code is licensed under the BSD-style license found in the
|
||||
* LICENSE file in the root directory of this source tree. An additional grant
|
||||
* of patent rights can be found in the PATENTS file in the same directory.
|
||||
*
|
||||
* This is a third-party micro-library grabbed from:
|
||||
* https://github.com/lydell/source-map-url
|
||||
*
|
||||
* @nolint
|
||||
*/
|
||||
/* eslint-disable */
|
||||
|
||||
(function() {
|
||||
var define = null; // Hack to make it work with our packager
|
||||
|
||||
// Copyright 2014 Simon Lydell
|
||||
// X11 ("MIT") Licensed. (See LICENSE.)
|
||||
|
||||
void (function(root, factory) {
|
||||
if (typeof define === "function" && define.amd) {
|
||||
define(factory)
|
||||
} else if (typeof exports === "object") {
|
||||
module.exports = factory()
|
||||
} else {
|
||||
root.sourceMappingURL = factory()
|
||||
}
|
||||
}(this, function() {
|
||||
|
||||
var innerRegex = /[#@] source(?:Mapping)?URL=([^\s'"]*)/
|
||||
|
||||
var regex = RegExp(
|
||||
"(?:" +
|
||||
"/\\*" +
|
||||
"(?:\\s*\r?\n(?://)?)?" +
|
||||
"(?:" + innerRegex.source + ")" +
|
||||
"\\s*" +
|
||||
"\\*/" +
|
||||
"|" +
|
||||
"//(?:" + innerRegex.source + ")" +
|
||||
")" +
|
||||
"\\s*$"
|
||||
)
|
||||
|
||||
return {
|
||||
|
||||
regex: regex,
|
||||
_innerRegex: innerRegex,
|
||||
|
||||
getFrom: function(code) {
|
||||
var match = code.match(regex)
|
||||
return (match ? match[1] || match[2] || "" : null)
|
||||
},
|
||||
|
||||
existsIn: function(code) {
|
||||
return regex.test(code)
|
||||
},
|
||||
|
||||
removeFrom: function(code) {
|
||||
return code.replace(regex, "")
|
||||
},
|
||||
|
||||
insertBefore: function(code, string) {
|
||||
var match = code.match(regex)
|
||||
if (match) {
|
||||
return code.slice(0, match.index) + string + code.slice(match.index)
|
||||
} else {
|
||||
return code + string
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}));
|
||||
|
||||
/** End of the third-party code */
|
||||
|
||||
})();
|
||||
@@ -11,8 +11,8 @@
|
||||
*/
|
||||
'use strict';
|
||||
|
||||
var ReactPerf = require('react/lib/ReactPerf');
|
||||
var ReactDebugTool = require('react/lib/ReactDebugTool');
|
||||
var ReactPerf = require('react/lib/ReactPerf');
|
||||
|
||||
var invariant = require('fbjs/lib/invariant');
|
||||
var performanceNow = require('fbjs/lib/performanceNow');
|
||||
@@ -15,8 +15,8 @@
|
||||
var RCTDeviceEventEmitter = require('RCTDeviceEventEmitter');
|
||||
var React = require('React');
|
||||
var ReactNative = require('react/lib/ReactNative');
|
||||
var Subscribable = require('Subscribable');
|
||||
var StyleSheet = require('StyleSheet');
|
||||
var Subscribable = require('Subscribable');
|
||||
var View = require('View');
|
||||
|
||||
var Inspector = __DEV__ ? require('Inspector') : null;
|
||||
@@ -16,10 +16,9 @@ var UIManager = require('UIManager');
|
||||
var UnimplementedView = require('UnimplementedView');
|
||||
|
||||
var createReactNativeComponentClass = require('react/lib/createReactNativeComponentClass');
|
||||
|
||||
var insetsDiffer = require('insetsDiffer');
|
||||
var pointsDiffer = require('pointsDiffer');
|
||||
var matricesDiffer = require('matricesDiffer');
|
||||
var pointsDiffer = require('pointsDiffer');
|
||||
var processColor = require('processColor');
|
||||
var resolveAssetSource = require('resolveAssetSource');
|
||||
var sizesDiffer = require('sizesDiffer');
|
||||
@@ -12,6 +12,7 @@
|
||||
|
||||
const RCTWebSocketModule = require('NativeModules').WebSocketModule;
|
||||
const NativeEventEmitter = require('NativeEventEmitter');
|
||||
|
||||
const base64 = require('base64-js');
|
||||
|
||||
const originalRCTWebSocketConnect = RCTWebSocketModule.connect;
|
||||
@@ -72,7 +72,7 @@ To revert the `User Search Header Paths` and `Header Search Paths` build setting
|
||||
|
||||
### No transports available
|
||||
|
||||
React Native implements a polyfill for WebSockets. These [polyfills](https://github.com/facebook/react-native/blob/master/Libraries/JavaScriptAppEngine/Initialization/InitializeJavaScriptAppEngine.js) are initialized as part of the react-native module that you include in your application through `import React from 'react'`. If you load another module that requires WebSockets, such as [Firebase](https://github.com/facebook/react-native/issues/3645), be sure to load/require it after react-native:
|
||||
React Native implements a polyfill for WebSockets. These [polyfills](https://github.com/facebook/react-native/blob/master/Libraries/Core/InitializeCore.js) are initialized as part of the react-native module that you include in your application through `import React from 'react'`. If you load another module that requires WebSockets, such as [Firebase](https://github.com/facebook/react-native/issues/3645), be sure to load/require it after react-native:
|
||||
|
||||
```
|
||||
import React from 'react';
|
||||
|
||||
@@ -12,4 +12,4 @@
|
||||
|
||||
// This is a forwarding module to allow React to require React Native internals
|
||||
// as node dependency
|
||||
module.exports = require('InitializeJavaScriptAppEngine');
|
||||
module.exports = require('InitializeCore');
|
||||
|
||||
1
lib/README
Normal file
1
lib/README
Normal file
@@ -0,0 +1 @@
|
||||
JS modules in this folder are forwarding modules to allow React to require React Native internals as node dependencies.
|
||||
@@ -212,7 +212,7 @@ describe('Bundle', () => {
|
||||
}).then(() => {
|
||||
otherBundle.setMainModuleId('foo');
|
||||
otherBundle.finalize({
|
||||
runBeforeMainModule: ['InitializeJavaScriptAppEngine'],
|
||||
runBeforeMainModule: ['InitializeCore'],
|
||||
runMainModule: true,
|
||||
});
|
||||
|
||||
@@ -243,11 +243,11 @@ describe('Bundle', () => {
|
||||
line: 6
|
||||
},
|
||||
map: {
|
||||
file: 'require-InitializeJavaScriptAppEngine.js',
|
||||
file: 'require-InitializeCore.js',
|
||||
mappings: 'AAAA;',
|
||||
names: [],
|
||||
sources: [ 'require-InitializeJavaScriptAppEngine.js' ],
|
||||
sourcesContent: [';require("InitializeJavaScriptAppEngine");'],
|
||||
sources: [ 'require-InitializeCore.js' ],
|
||||
sourcesContent: [';require("InitializeCore");'],
|
||||
version: 3,
|
||||
}
|
||||
},
|
||||
|
||||
@@ -160,7 +160,7 @@ describe('processRequest', () => {
|
||||
dev: true,
|
||||
platform: undefined,
|
||||
onProgress: jasmine.any(Function),
|
||||
runBeforeMainModule: ['InitializeJavaScriptAppEngine'],
|
||||
runBeforeMainModule: ['InitializeCore'],
|
||||
unbundle: false,
|
||||
entryModuleOnly: false,
|
||||
isolateModuleIDs: false,
|
||||
@@ -185,7 +185,7 @@ describe('processRequest', () => {
|
||||
dev: true,
|
||||
platform: 'ios',
|
||||
onProgress: jasmine.any(Function),
|
||||
runBeforeMainModule: ['InitializeJavaScriptAppEngine'],
|
||||
runBeforeMainModule: ['InitializeCore'],
|
||||
unbundle: false,
|
||||
entryModuleOnly: false,
|
||||
isolateModuleIDs: false,
|
||||
@@ -210,7 +210,7 @@ describe('processRequest', () => {
|
||||
dev: true,
|
||||
platform: undefined,
|
||||
onProgress: jasmine.any(Function),
|
||||
runBeforeMainModule: ['InitializeJavaScriptAppEngine'],
|
||||
runBeforeMainModule: ['InitializeCore'],
|
||||
unbundle: false,
|
||||
entryModuleOnly: false,
|
||||
isolateModuleIDs: false,
|
||||
@@ -440,7 +440,7 @@ describe('processRequest', () => {
|
||||
runModule: true,
|
||||
dev: true,
|
||||
platform: undefined,
|
||||
runBeforeMainModule: ['InitializeJavaScriptAppEngine'],
|
||||
runBeforeMainModule: ['InitializeCore'],
|
||||
unbundle: false,
|
||||
entryModuleOnly: false,
|
||||
isolateModuleIDs: false,
|
||||
@@ -463,7 +463,7 @@ describe('processRequest', () => {
|
||||
sourceMapUrl: '/path/to/foo.map?dev=false&runModule=false',
|
||||
dev: false,
|
||||
platform: undefined,
|
||||
runBeforeMainModule: ['InitializeJavaScriptAppEngine'],
|
||||
runBeforeMainModule: ['InitializeCore'],
|
||||
unbundle: false,
|
||||
entryModuleOnly: false,
|
||||
isolateModuleIDs: false,
|
||||
|
||||
2
packager/react-packager/src/Server/index.js
vendored
2
packager/react-packager/src/Server/index.js
vendored
@@ -130,7 +130,7 @@ const bundleOpts = declareOpts({
|
||||
type: 'array',
|
||||
default: [
|
||||
// Ensures essential globals are available and are patched correctly.
|
||||
'InitializeJavaScriptAppEngine'
|
||||
'InitializeCore'
|
||||
],
|
||||
},
|
||||
unbundle: {
|
||||
|
||||
Reference in New Issue
Block a user