-
Notifications
You must be signed in to change notification settings - Fork 24.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Summary: Split up InitializeCore into a bunch of modules. The idea here is to make it easier for apps to just get the initialization logic they want and leave behind what they don't; for example, if you don't want the Map/Set polyfills, instead of requiring InitializeCore you can require the modules you want from it. Reviewed By: yungsters Differential Revision: D10842564 fbshipit-source-id: 3b12d54fddea8c4ee75886022338c214987a015c
- Loading branch information
1 parent
5d38264
commit df2eaa9
Showing
15 changed files
with
404 additions
and
189 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its 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 | ||
*/ | ||
'use strict'; | ||
|
||
/** | ||
* Check for compatibility between the JS and native code. | ||
* You can use this module directly, or just require InitializeCore. | ||
*/ | ||
const ReactNativeVersionCheck = require('ReactNativeVersionCheck'); | ||
ReactNativeVersionCheck.checkVersions(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its 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 | ||
*/ | ||
'use strict'; | ||
|
||
const {polyfillGlobal} = require('PolyfillFunctions'); | ||
|
||
/** | ||
* Polyfill ES6 collections (Map and Set). | ||
* If you don't need these polyfills, don't use InitializeCore; just directly | ||
* require the modules you need from InitializeCore for setup. | ||
*/ | ||
const _shouldPolyfillCollection = require('_shouldPolyfillES6Collection'); | ||
if (_shouldPolyfillCollection('Map')) { | ||
polyfillGlobal('Map', () => require('Map')); | ||
} | ||
if (_shouldPolyfillCollection('Set')) { | ||
polyfillGlobal('Set', () => require('Set')); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its 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 | ||
*/ | ||
'use strict'; | ||
|
||
const {polyfillGlobal} = require('PolyfillFunctions'); | ||
|
||
/** | ||
* Set up Promise. The native Promise implementation throws the following error: | ||
* ERROR: Event loop not supported. | ||
* | ||
* If you don't need these polyfills, don't use InitializeCore; just directly | ||
* require the modules you need from InitializeCore for setup. | ||
*/ | ||
polyfillGlobal('Promise', () => require('Promise')); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its 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 | ||
*/ | ||
'use strict'; | ||
|
||
/** | ||
* Set up alert(). | ||
* You can use this module directly, or just require InitializeCore. | ||
*/ | ||
if (!global.alert) { | ||
global.alert = function(text) { | ||
// Require Alert on demand. Requiring it too early can lead to issues | ||
// with things like Platform not being fully initialized. | ||
require('Alert').alert('Alert', '' + text); | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its 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 | ||
*/ | ||
'use strict'; | ||
|
||
/** | ||
* Set up the BatchedBridge. This must be done after the other steps in | ||
* InitializeCore to ensure that the JS environment has been initialized. | ||
* You can use this module directly, or just require InitializeCore. | ||
*/ | ||
const BatchedBridge = require('BatchedBridge'); | ||
BatchedBridge.registerLazyCallableModule('Systrace', () => require('Systrace')); | ||
BatchedBridge.registerLazyCallableModule('JSTimers', () => require('JSTimers')); | ||
BatchedBridge.registerLazyCallableModule('HeapCapture', () => | ||
require('HeapCapture'), | ||
); | ||
BatchedBridge.registerLazyCallableModule('SamplingProfiler', () => | ||
require('SamplingProfiler'), | ||
); | ||
BatchedBridge.registerLazyCallableModule('RCTLog', () => require('RCTLog')); | ||
BatchedBridge.registerLazyCallableModule('RCTDeviceEventEmitter', () => | ||
require('RCTDeviceEventEmitter'), | ||
); | ||
BatchedBridge.registerLazyCallableModule('RCTNativeAppEventEmitter', () => | ||
require('RCTNativeAppEventEmitter'), | ||
); | ||
BatchedBridge.registerLazyCallableModule('PerformanceLogger', () => | ||
require('PerformanceLogger'), | ||
); | ||
BatchedBridge.registerLazyCallableModule('JSDevSupportModule', () => | ||
require('JSDevSupportModule'), | ||
); | ||
|
||
if (__DEV__ && !global.__RCTProfileIsProfiling) { | ||
BatchedBridge.registerCallableModule('HMRClient', require('HMRClient')); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/** | ||
* Copyright (c) Facebook, Inc. and its 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 | ||
*/ | ||
'use strict'; | ||
|
||
/** | ||
* Sets up developer tools for React Native. | ||
* You can use this module directly, or just require InitializeCore. | ||
*/ | ||
if (__DEV__) { | ||
if (!global.__RCTProfileIsProfiling) { | ||
// not when debugging in chrome | ||
// TODO(t12832058) This check is broken | ||
if (!window.document) { | ||
require('setupDevtools'); | ||
This comment has been minimized.
Sorry, something went wrong. |
||
} | ||
|
||
// Set up inspector | ||
const JSInspector = require('JSInspector'); | ||
JSInspector.registerAgent(require('NetworkAgent')); | ||
} | ||
} |
Oops, something went wrong.
maybe u guys should also make sure
require('setupDevtools')
is only use inBrowser