You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
148 lines
4.7 KiB
148 lines
4.7 KiB
/** |
|
* Copyright 2013-2015, 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 React |
|
*/ |
|
|
|
/* globals __REACT_DEVTOOLS_GLOBAL_HOOK__*/ |
|
|
|
'use strict'; |
|
|
|
var EventPluginUtils = require("./EventPluginUtils"); |
|
var ReactChildren = require("./ReactChildren"); |
|
var ReactComponent = require("./ReactComponent"); |
|
var ReactClass = require("./ReactClass"); |
|
var ReactContext = require("./ReactContext"); |
|
var ReactCurrentOwner = require("./ReactCurrentOwner"); |
|
var ReactElement = require("./ReactElement"); |
|
var ReactElementValidator = require("./ReactElementValidator"); |
|
var ReactDOM = require("./ReactDOM"); |
|
var ReactDOMTextComponent = require("./ReactDOMTextComponent"); |
|
var ReactDefaultInjection = require("./ReactDefaultInjection"); |
|
var ReactInstanceHandles = require("./ReactInstanceHandles"); |
|
var ReactMount = require("./ReactMount"); |
|
var ReactPerf = require("./ReactPerf"); |
|
var ReactPropTypes = require("./ReactPropTypes"); |
|
var ReactReconciler = require("./ReactReconciler"); |
|
var ReactServerRendering = require("./ReactServerRendering"); |
|
|
|
var assign = require("./Object.assign"); |
|
var findDOMNode = require("./findDOMNode"); |
|
var onlyChild = require("./onlyChild"); |
|
|
|
ReactDefaultInjection.inject(); |
|
|
|
var createElement = ReactElement.createElement; |
|
var createFactory = ReactElement.createFactory; |
|
var cloneElement = ReactElement.cloneElement; |
|
|
|
if ("production" !== process.env.NODE_ENV) { |
|
createElement = ReactElementValidator.createElement; |
|
createFactory = ReactElementValidator.createFactory; |
|
cloneElement = ReactElementValidator.cloneElement; |
|
} |
|
|
|
var render = ReactPerf.measure('React', 'render', ReactMount.render); |
|
|
|
var React = { |
|
Children: { |
|
map: ReactChildren.map, |
|
forEach: ReactChildren.forEach, |
|
count: ReactChildren.count, |
|
only: onlyChild |
|
}, |
|
Component: ReactComponent, |
|
DOM: ReactDOM, |
|
PropTypes: ReactPropTypes, |
|
initializeTouchEvents: function(shouldUseTouch) { |
|
EventPluginUtils.useTouchEvents = shouldUseTouch; |
|
}, |
|
createClass: ReactClass.createClass, |
|
createElement: createElement, |
|
cloneElement: cloneElement, |
|
createFactory: createFactory, |
|
createMixin: function(mixin) { |
|
// Currently a noop. Will be used to validate and trace mixins. |
|
return mixin; |
|
}, |
|
constructAndRenderComponent: ReactMount.constructAndRenderComponent, |
|
constructAndRenderComponentByID: ReactMount.constructAndRenderComponentByID, |
|
findDOMNode: findDOMNode, |
|
render: render, |
|
renderToString: ReactServerRendering.renderToString, |
|
renderToStaticMarkup: ReactServerRendering.renderToStaticMarkup, |
|
unmountComponentAtNode: ReactMount.unmountComponentAtNode, |
|
isValidElement: ReactElement.isValidElement, |
|
withContext: ReactContext.withContext, |
|
|
|
// Hook for JSX spread, don't use this for anything else. |
|
__spread: assign |
|
}; |
|
|
|
// Inject the runtime into a devtools global hook regardless of browser. |
|
// Allows for debugging when the hook is injected on the page. |
|
if ( |
|
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ !== 'undefined' && |
|
typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.inject === 'function') { |
|
__REACT_DEVTOOLS_GLOBAL_HOOK__.inject({ |
|
CurrentOwner: ReactCurrentOwner, |
|
InstanceHandles: ReactInstanceHandles, |
|
Mount: ReactMount, |
|
Reconciler: ReactReconciler, |
|
TextComponent: ReactDOMTextComponent |
|
}); |
|
} |
|
|
|
if ("production" !== process.env.NODE_ENV) { |
|
var ExecutionEnvironment = require("./ExecutionEnvironment"); |
|
if (ExecutionEnvironment.canUseDOM && window.top === window.self) { |
|
|
|
// If we're in Chrome, look for the devtools marker and provide a download |
|
// link if not installed. |
|
if (navigator.userAgent.indexOf('Chrome') > -1) { |
|
if (typeof __REACT_DEVTOOLS_GLOBAL_HOOK__ === 'undefined') { |
|
console.debug( |
|
'Download the React DevTools for a better development experience: ' + |
|
'http://fb.me/react-devtools' |
|
); |
|
} |
|
} |
|
|
|
var expectedFeatures = [ |
|
// shims |
|
Array.isArray, |
|
Array.prototype.every, |
|
Array.prototype.forEach, |
|
Array.prototype.indexOf, |
|
Array.prototype.map, |
|
Date.now, |
|
Function.prototype.bind, |
|
Object.keys, |
|
String.prototype.split, |
|
String.prototype.trim, |
|
|
|
// shams |
|
Object.create, |
|
Object.freeze |
|
]; |
|
|
|
for (var i = 0; i < expectedFeatures.length; i++) { |
|
if (!expectedFeatures[i]) { |
|
console.error( |
|
'One or more ES5 shim/shams expected by React are not available: ' + |
|
'http://fb.me/react-warning-polyfills' |
|
); |
|
break; |
|
} |
|
} |
|
} |
|
} |
|
|
|
React.version = '0.13.2'; |
|
|
|
module.exports = React;
|
|
|