Fix constructor init (#774)
* Update test app to RN 0.39.0 * Fix getContext in index.js * Add dependency on invariant * Add some comments to getContext * Make invariant a devdependency rather than a dependency
This commit is contained in:
parent
9d858d0329
commit
fa1f22ddc2
40
lib/index.js
40
lib/index.js
|
@ -25,30 +25,40 @@ function nodeRequire(module) {
|
|||
|
||||
|
||||
function getContext() {
|
||||
// If process is an object, we're probably running in Node or Electron
|
||||
// From: http://stackoverflow.com/a/24279593/1417293
|
||||
if (typeof process === 'object' && process + '' === '[object process]') {
|
||||
return process.type === 'renderer' ? 'electron' : 'nodejs';
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof navigator !== 'undefined') {
|
||||
if (navigator.product === 'ReactNative') { // eslint-disable-line no-undef
|
||||
// When running via Jest, the jest object is defined.
|
||||
if (typeof jest === 'object') {
|
||||
return 'nodejs';
|
||||
}
|
||||
|
||||
// If we've already injected the Realm class, we are probably
|
||||
// running in a jscore environment, either directly or via React Native
|
||||
if (typeof Realm !== 'undefined') {
|
||||
if (typeof navigator !== 'undefined' &&
|
||||
navigator.product === 'ReactNative') { // eslint-disable-line no-undef
|
||||
return 'reactnative';
|
||||
}
|
||||
|
||||
if (/Chrome/.test(navigator.userAgent)) { // eslint-disable-line no-undef
|
||||
return 'chromedebugger';
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof global !== 'undefined') {
|
||||
if (global.__debug__) {
|
||||
return 'vscodedebugger';
|
||||
}
|
||||
}
|
||||
|
||||
if (typeof Realm !== 'undefined') {
|
||||
return 'jscore';
|
||||
}
|
||||
|
||||
// Visual Studio Code defines the global.__debug__ object.
|
||||
if (typeof global !== 'undefined' && global.__debug__) {
|
||||
return 'vscodedebugger';
|
||||
}
|
||||
|
||||
// Finally, if the navigator.userAgent contains the string "Chrome", we're likely
|
||||
// running via the chrome debugger.
|
||||
if (typeof navigator !== 'undefined' &&
|
||||
/Chrome/.test(navigator.userAgent)) { // eslint-disable-line no-undef
|
||||
return 'chromedebugger';
|
||||
}
|
||||
|
||||
throw Error("Unknown execution context");
|
||||
}
|
||||
|
||||
|
|
|
@ -6,11 +6,14 @@
|
|||
"start": "react-native start"
|
||||
},
|
||||
"dependencies": {
|
||||
"react": "15.3.2",
|
||||
"react-native": "^0.37.0",
|
||||
"react": "15.4.0",
|
||||
"react-native": "^0.39.0",
|
||||
"react-native-fs": "^1.1.0",
|
||||
"realm": "file:../..",
|
||||
"realm-tests": "file:../js",
|
||||
"xmlbuilder": "^4.2.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"invariant": "^2.2.2"
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue