diff --git a/.gitignore b/.gitignore index 662faa49..737a1b78 100644 --- a/.gitignore +++ b/.gitignore @@ -35,3 +35,6 @@ examples/swiper.xcodeproj/xcuserdata # IntelliJ .idea/ + +# Vim +*.sw* diff --git a/README.md b/README.md index 753d1ef2..8e600680 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,7 @@ [![npm version](http://img.shields.io/npm/dm/react-native-swiper.svg?style=flat-square)](https://npmjs.org/package/react-native-swiper "View this project on npm") [![Issue Stats](http://issuestats.com/github/leecade/react-native-swiper/badge/pr?style=flat-square)](https://github.com/leecade/react-native-swiper/pulls?q=is%3Apr+is%3Aclosed) [![Issue Stats](http://issuestats.com/github/leecade/react-native-swiper/badge/issue?style=flat-square)](https://github.com/leecade/react-native-swiper/issues?q=is%3Aissue+is%3Aclosed) +[![Join the chat at https://gitter.im/leecade/react-native-swiper](https://badges.gitter.im/leecade/react-native-swiper.svg)](https://gitter.im/leecade/react-native-swiper?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) ![logo](http://i.imgur.com/P4cRUgD.png) @@ -63,6 +64,12 @@ The best Swiper component for React Native. ## Changelogs +- **[1.4.4]** + + Support for React Native latest(`^0.26.0`) + + Updates examples to work with react-native-swiper 1.4.4 + + Examples now run on Android (some are still buggy, needs more work) + + Removes old examples folder + - **[1.4.3]** + Fixed auto play issue when only a child view @@ -297,7 +304,7 @@ AppRegistry.registerComponent('swiper', () => swiper) | Prop | Params | Type | Description | | :------------ |:---------------:| :---------------:| :-----| -| onMomentumScrollBegin | `e` / `state` / `context` | `function` | When animation begins after letting up | +| onScrollBeginDrag | `e` / `state` / `context` | `function` | When animation begins after letting up | | onMomentumScrollEnd | `e` / `state` / `context` | `function` | Makes no sense why this occurs first during bounce | | onTouchStartCapture | `e` / `state` / `context` | `function` | Immediately after `onMomentumScrollEnd` | | onTouchStart | `e` / `state` / `context` | `function` | Same, but bubble phase | @@ -337,6 +344,7 @@ $ npm start ## Contribution - [@leecade](mailto:leecade@163.com) The main author. +- [@rajkissu](mailto:rajkissu@gmail.com) The secondary contributor. ## Questions diff --git a/dist/index.js b/dist/index.js index 118a9634..59a9906a 100644 --- a/dist/index.js +++ b/dist/index.js @@ -5,12 +5,18 @@ var _extends = Object.assign || function (target) { for (var i = 1; i < argument * @author leecade */ + // Using bare setTimeout, setInterval, setImmediate // and requestAnimationFrame calls is very dangerous // because if you forget to cancel the request before // the component is unmounted, you risk the callback // throwing an exception. + +var _react = require('react'); + +var _react2 = _interopRequireDefault(_react); + var _reactNative = require('react-native'); var _reactNative2 = _interopRequireDefault(_reactNative); @@ -103,32 +109,33 @@ var styles = _reactNative.StyleSheet.create({ // missing `module.exports = exports['default'];` with babel6 // export default React.createClass({ -module.exports = _reactNative2.default.createClass({ +module.exports = _react2.default.createClass({ displayName: 'exports', + /** * Props Validation * @type {Object} */ propTypes: { - horizontal: _reactNative2.default.PropTypes.bool, - children: _reactNative2.default.PropTypes.node.isRequired, + horizontal: _react2.default.PropTypes.bool, + children: _react2.default.PropTypes.node.isRequired, style: _reactNative.View.propTypes.style, - pagingEnabled: _reactNative2.default.PropTypes.bool, - showsHorizontalScrollIndicator: _reactNative2.default.PropTypes.bool, - showsVerticalScrollIndicator: _reactNative2.default.PropTypes.bool, - bounces: _reactNative2.default.PropTypes.bool, - scrollsToTop: _reactNative2.default.PropTypes.bool, - removeClippedSubviews: _reactNative2.default.PropTypes.bool, - automaticallyAdjustContentInsets: _reactNative2.default.PropTypes.bool, - showsPagination: _reactNative2.default.PropTypes.bool, - showsButtons: _reactNative2.default.PropTypes.bool, - loop: _reactNative2.default.PropTypes.bool, - autoplay: _reactNative2.default.PropTypes.bool, - autoplayTimeout: _reactNative2.default.PropTypes.number, - autoplayDirection: _reactNative2.default.PropTypes.bool, - index: _reactNative2.default.PropTypes.number, - renderPagination: _reactNative2.default.PropTypes.func + pagingEnabled: _react2.default.PropTypes.bool, + showsHorizontalScrollIndicator: _react2.default.PropTypes.bool, + showsVerticalScrollIndicator: _react2.default.PropTypes.bool, + bounces: _react2.default.PropTypes.bool, + scrollsToTop: _react2.default.PropTypes.bool, + removeClippedSubviews: _react2.default.PropTypes.bool, + automaticallyAdjustContentInsets: _react2.default.PropTypes.bool, + showsPagination: _react2.default.PropTypes.bool, + showsButtons: _react2.default.PropTypes.bool, + loop: _react2.default.PropTypes.bool, + autoplay: _react2.default.PropTypes.bool, + autoplayTimeout: _react2.default.PropTypes.number, + autoplayDirection: _react2.default.PropTypes.bool, + index: _react2.default.PropTypes.number, + renderPagination: _react2.default.PropTypes.func }, mixins: [_reactTimerMixin2.default], @@ -158,6 +165,7 @@ module.exports = _reactNative2.default.createClass({ }; }, + /** * Init states * @return {object} states @@ -166,6 +174,7 @@ module.exports = _reactNative2.default.createClass({ return this.initState(this.props); }, + /** * autoplay timer * @type {null} @@ -197,12 +206,16 @@ module.exports = _reactNative2.default.createClass({ initState.offset = {}; if (initState.total > 1) { - var setup = props.loop ? 1 : initState.index; + var setup = initState.index; + if (props.loop) { + setup++; + } initState.offset[initState.dir] = initState.dir == 'y' ? initState.height * setup : initState.width * setup; } return initState; }, + /** * Automatic rolling */ @@ -221,6 +234,7 @@ module.exports = _reactNative2.default.createClass({ }, this.props.autoplayTimeout * 1000); }, + /** * Scroll begin handle * @param {object} e native event @@ -238,6 +252,7 @@ module.exports = _reactNative2.default.createClass({ }); }, + /** * Scroll end handle * @param {object} e native event @@ -271,6 +286,7 @@ module.exports = _reactNative2.default.createClass({ }); }, + /** * Update index after scroll * @param {object} offset content offset @@ -306,11 +322,14 @@ module.exports = _reactNative2.default.createClass({ }); }, + /** * Scroll by index * @param {number} index offset index */ scrollTo: function scrollTo(index) { + var _this4 = this; + if (this.state.isScrolling || this.state.total < 2) return; var state = this.state; var diff = (this.props.loop ? 1 : 0) + index + this.state.index; @@ -318,15 +337,35 @@ module.exports = _reactNative2.default.createClass({ var y = 0; if (state.dir == 'x') x = diff * state.width; if (state.dir == 'y') y = diff * state.height; - this.refs.scrollView && this.refs.scrollView.scrollTo(y, x); + + if (_reactNative.Platform.OS === 'android') { + this.refs.scrollView && this.refs.scrollView.setPage(diff); + } else { + this.refs.scrollView && this.refs.scrollView.scrollTo({ + y: y, + x: x + }); + } // update scroll state this.setState({ isScrolling: true, autoplayEnd: false }); + + // trigger onScrollEnd manually in android + if (_reactNative.Platform.OS === 'android') { + this.setTimeout(function () { + _this4.onScrollEnd({ + nativeEvent: { + position: diff + } + }); + }, 50); + } }, + /** * Render pagination * @return {object} react-dom @@ -337,7 +376,7 @@ module.exports = _reactNative2.default.createClass({ if (this.state.total <= 1) return null; var dots = []; - var ActiveDot = this.props.activeDot || _reactNative2.default.createElement(_reactNative.View, { style: { + var ActiveDot = this.props.activeDot || _react2.default.createElement(_reactNative.View, { style: { backgroundColor: '#007aff', width: 8, height: 8, @@ -347,7 +386,7 @@ module.exports = _reactNative2.default.createClass({ marginTop: 3, marginBottom: 3 } }); - var Dot = this.props.dot || _reactNative2.default.createElement(_reactNative.View, { style: { + var Dot = this.props.dot || _react2.default.createElement(_reactNative.View, { style: { backgroundColor: 'rgba(0,0,0,.2)', width: 8, height: 8, @@ -358,10 +397,10 @@ module.exports = _reactNative2.default.createClass({ marginBottom: 3 } }); for (var i = 0; i < this.state.total; i++) { - dots.push(i === this.state.index ? _reactNative2.default.cloneElement(ActiveDot, { key: i }) : _reactNative2.default.cloneElement(Dot, { key: i })); + dots.push(i === this.state.index ? _react2.default.cloneElement(ActiveDot, { key: i }) : _react2.default.cloneElement(Dot, { key: i })); } - return _reactNative2.default.createElement( + return _react2.default.createElement( _reactNative.View, { pointerEvents: 'none', style: [styles['pagination_' + this.state.dir], this.props.paginationStyle] }, dots @@ -370,31 +409,31 @@ module.exports = _reactNative2.default.createClass({ renderTitle: function renderTitle() { var child = this.props.children[this.state.index]; var title = child && child.props.title; - return title ? _reactNative2.default.createElement( + return title ? _react2.default.createElement( _reactNative.View, { style: styles.title }, this.props.children[this.state.index].props.title ) : null; }, renderNextButton: function renderNextButton() { - var _this4 = this; + var _this5 = this; - var button = undefined; + var button = void 0; if (this.props.loop || this.state.index != this.state.total - 1) { - button = this.props.nextButton || _reactNative2.default.createElement( + button = this.props.nextButton || _react2.default.createElement( _reactNative.Text, { style: styles.buttonText }, '›' ); } - return _reactNative2.default.createElement( + return _react2.default.createElement( _reactNative.TouchableOpacity, { onPress: function onPress() { - return button !== null && _this4.scrollTo.call(_this4, 1); + return button !== null && _this5.scrollTo.call(_this5, 1); } }, - _reactNative2.default.createElement( + _react2.default.createElement( _reactNative.View, null, button @@ -402,24 +441,24 @@ module.exports = _reactNative2.default.createClass({ ); }, renderPrevButton: function renderPrevButton() { - var _this5 = this; + var _this6 = this; var button = null; if (this.props.loop || this.state.index != 0) { - button = this.props.prevButton || _reactNative2.default.createElement( + button = this.props.prevButton || _react2.default.createElement( _reactNative.Text, { style: styles.buttonText }, '‹' ); } - return _reactNative2.default.createElement( + return _react2.default.createElement( _reactNative.TouchableOpacity, { onPress: function onPress() { - return button !== null && _this5.scrollTo.call(_this5, -1); + return button !== null && _this6.scrollTo.call(_this6, -1); } }, - _reactNative2.default.createElement( + _react2.default.createElement( _reactNative.View, null, button @@ -427,7 +466,7 @@ module.exports = _reactNative2.default.createClass({ ); }, renderButtons: function renderButtons() { - return _reactNative2.default.createElement( + return _react2.default.createElement( _reactNative.View, { pointerEvents: 'box-none', style: [styles.buttonWrapper, { width: this.state.width, height: this.state.height }, this.props.buttonWrapperStyle] }, this.renderPrevButton(), @@ -435,7 +474,7 @@ module.exports = _reactNative2.default.createClass({ ); }, renderScrollView: function renderScrollView(pages) { - if (_reactNative.Platform.OS === 'ios') return _reactNative2.default.createElement( + if (_reactNative.Platform.OS === 'ios') return _react2.default.createElement( _reactNative.ScrollView, _extends({ ref: 'scrollView' }, this.props, { @@ -445,11 +484,13 @@ module.exports = _reactNative2.default.createClass({ onMomentumScrollEnd: this.onScrollEnd }), pages ); - return _reactNative2.default.createElement( + return _react2.default.createElement( _reactNative.ViewPagerAndroid, - { ref: 'scrollView', + _extends({ ref: 'scrollView' + }, this.props, { + initialPage: this.state.index, onPageSelected: this.onScrollEnd, - style: { flex: 1 } }, + style: { flex: 1 } }), pages ); }, @@ -460,7 +501,7 @@ module.exports = _reactNative2.default.createClass({ * @return {object} props injected props */ injectState: function injectState(props) { - var _this6 = this; + var _this7 = this; /* const scrollResponders = [ 'onMomentumScrollBegin', @@ -476,7 +517,7 @@ module.exports = _reactNative2.default.createClass({ (function () { var originResponder = props[prop]; props[prop] = function (e) { - return originResponder(e, _this6.state, _this6); + return originResponder(e, _this7.state, _this7); }; })(); } @@ -485,6 +526,7 @@ module.exports = _reactNative2.default.createClass({ return props; }, + /** * Default render * @return {object} react-dom @@ -513,19 +555,19 @@ module.exports = _reactNative2.default.createClass({ } pages = pages.map(function (page, i) { - return _reactNative2.default.createElement( + return _react2.default.createElement( _reactNative.View, { style: pageStyle, key: i }, children[page] ); }); - } else pages = _reactNative2.default.createElement( + } else pages = _react2.default.createElement( _reactNative.View, { style: pageStyle }, children ); - return _reactNative2.default.createElement( + return _react2.default.createElement( _reactNative.View, { style: [styles.container, { width: state.width, diff --git a/examples.old/.flowconfig b/examples.old/.flowconfig deleted file mode 100644 index b2a76e02..00000000 --- a/examples.old/.flowconfig +++ /dev/null @@ -1,44 +0,0 @@ -[ignore] - -# We fork some components by platform. -.*/*.web.js -.*/*.android.js - -# Some modules have their own node_modules with overlap -.*/node_modules/node-haste/.* - -# Ignore react-tools where there are overlaps, but don't ignore anything that -# react-native relies on -.*/node_modules/react-tools/src/vendor/core/ExecutionEnvironment.js -.*/node_modules/react-tools/src/browser/eventPlugins/ResponderEventPlugin.js -.*/node_modules/react-tools/src/browser/ui/React.js -.*/node_modules/react-tools/src/core/ReactInstanceHandles.js -.*/node_modules/react-tools/src/event/EventPropagators.js - -# Ignore commoner tests -.*/node_modules/commoner/test/.* - -# See https://github.com/facebook/flow/issues/442 -.*/react-tools/node_modules/commoner/lib/reader.js - -# Ignore jest -.*/react-native/node_modules/jest-cli/.* - -[include] - -[libs] -node_modules/react-native/Libraries/react-native/react-native-interface.js - -[options] -module.system=haste - -suppress_type=$FlowIssue -suppress_type=$FlowFixMe -suppress_type=$FixMe - -suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(1[0-3]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\) -suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(1[0-3]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)? #[0-9]+ -suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy - -[version] -0.13.1 diff --git a/examples.old/.gitignore b/examples.old/.gitignore deleted file mode 100644 index b927355d..00000000 --- a/examples.old/.gitignore +++ /dev/null @@ -1,28 +0,0 @@ -# OSX -# -.DS_Store - -# Xcode -# -build/ -*.pbxuser -!default.pbxuser -*.mode1v3 -!default.mode1v3 -*.mode2v3 -!default.mode2v3 -*.perspectivev3 -!default.perspectivev3 -xcuserdata -*.xccheckout -*.moved-aside -DerivedData -*.hmap -*.ipa -*.xcuserstate -project.xcworkspace - -# node.js -# -node_modules/ -npm-debug.log diff --git a/examples.old/.npmignore b/examples.old/.npmignore deleted file mode 100644 index c39012e9..00000000 --- a/examples.old/.npmignore +++ /dev/null @@ -1,27 +0,0 @@ -# OSX -# -.DS_Store - -# Xcode -# -build/ -*.pbxuser -!default.pbxuser -*.mode1v3 -!default.mode1v3 -*.mode2v3 -!default.mode2v3 -*.perspectivev3 -!default.perspectivev3 -xcuserdata -*.xccheckout -*.moved-aside -DerivedData -*.hmap -*.ipa -*.xcuserstate - -# node.js -# -node_modules/ -npm-debug.log diff --git a/examples.old/examples/basic.js b/examples.old/examples/basic.js deleted file mode 100644 index 6990b700..00000000 --- a/examples.old/examples/basic.js +++ /dev/null @@ -1,62 +0,0 @@ -var React = require('react-native') -var Swiper = require('./') -var { - StyleSheet, - Text, - View, -} = React - -var styles = StyleSheet.create({ - wrapper: { - }, - slide1: { - flex: 1, - justifyContent: 'center', - alignItems: 'center', - backgroundColor: '#9DD6EB', - }, - slide2: { - flex: 1, - justifyContent: 'center', - alignItems: 'center', - backgroundColor: '#97CAE5', - }, - slide3: { - flex: 1, - justifyContent: 'center', - alignItems: 'center', - backgroundColor: '#92BBD9', - }, - text: { - color: '#fff', - fontSize: 30, - fontWeight: 'bold', - } -}) - -var swiper = React.createClass({ - _onMomentumScrollEnd: function (e, state, context) { - // you can get `state` and `this`(ref to swiper's context) from params - console.log(state, context.state) - }, - render: function() { - return ( - - - Hello Swiper - - - Beautiful - - - And simple - - - ) - } -}) - -module.exports = swiper - diff --git a/examples.old/examples/dynamic.js b/examples.old/examples/dynamic.js deleted file mode 100644 index f2b438f2..00000000 --- a/examples.old/examples/dynamic.js +++ /dev/null @@ -1,65 +0,0 @@ -var React = require('react-native') -var Swiper = require('./') -var { - StyleSheet, - Text, - View, -} = React - -var styles = StyleSheet.create({ - wrapper: { - }, - slide1: { - flex: 1, - justifyContent: 'center', - alignItems: 'center', - backgroundColor: '#9DD6EB', - }, - slide2: { - flex: 1, - justifyContent: 'center', - alignItems: 'center', - backgroundColor: '#97CAE5', - }, - slide3: { - flex: 1, - justifyContent: 'center', - alignItems: 'center', - backgroundColor: '#92BBD9', - }, - text: { - color: '#fff', - fontSize: 30, - fontWeight: 'bold', - } -}) - -var swiper = React.createClass({ - getInitialState: function() { - return { - items: [] - }; - }, - componentDidMount: function() { - this.setState({ - items: [ { title: 'Hello Swiper', css: styles.slide1 }, { title: 'Beautiful', css: styles.slide2 }, - { title: 'And simple', css: styles.slide3 } ] - }); - }, - render: function() { - return( - - {this.state.items.map(function(item){ - return ( - - {item.title} - - ); - })} - - ); - } -}) - -module.exports = swiper - diff --git a/examples.old/examples/index.js b/examples.old/examples/index.js deleted file mode 100644 index e120dda4..00000000 --- a/examples.old/examples/index.js +++ /dev/null @@ -1,543 +0,0 @@ -'use strict'; - -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; /* - react-native-swiper - - @author leecade - */ -/*import React, { - StyleSheet, - Text, - View, - ScrollView, - TouchableOpacity, - Dimensions, - ViewPagerAndroid, - Platform -} from 'react-native'*/ - -// Using bare setTimeout, setInterval, setImmediate -// and requestAnimationFrame calls is very dangerous -// because if you forget to cancel the request before -// the component is unmounted, you risk the callback -// throwing an exception. - -var _reactNative = require('react-native'); - -var _reactNative2 = _interopRequireDefault(_reactNative); - -var _React = require('React'); - -var _reactTimerMixin = require('react-timer-mixin'); - -var _reactTimerMixin2 = _interopRequireDefault(_reactTimerMixin); - -function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } - -var _Dimensions$get = _React.Dimensions.get('window'); - -var width = _Dimensions$get.width; -var height = _Dimensions$get.height; - -/** - * Default styles - * @type {StyleSheetPropType} - */ - -var styles = _React.StyleSheet.create({ - container: { - backgroundColor: 'transparent', - position: 'relative' - }, - - wrapper: { - backgroundColor: 'transparent' - }, - - slide: { - backgroundColor: 'transparent' - }, - - pagination_x: { - position: 'absolute', - bottom: 25, - left: 0, - right: 0, - flexDirection: 'row', - flex: 1, - justifyContent: 'center', - alignItems: 'center', - backgroundColor: 'transparent' - }, - - pagination_y: { - position: 'absolute', - right: 15, - top: 0, - bottom: 0, - flexDirection: 'column', - flex: 1, - justifyContent: 'center', - alignItems: 'center', - backgroundColor: 'transparent' - }, - - title: { - height: 30, - justifyContent: 'center', - position: 'absolute', - paddingLeft: 10, - bottom: -30, - left: 0, - flexWrap: 'nowrap', - width: 250, - backgroundColor: 'transparent' - }, - - buttonWrapper: { - backgroundColor: 'transparent', - flexDirection: 'row', - position: 'absolute', - top: 0, - left: 0, - flex: 1, - paddingHorizontal: 10, - paddingVertical: 10, - justifyContent: 'space-between', - alignItems: 'center' - }, - - buttonText: { - fontSize: 50, - color: '#007aff', - fontFamily: 'Arial' - } -}); - -// missing `module.exports = exports['default'];` with babel6 -// export default React.createClass({ -module.exports = _reactNative2.default.createClass({ - displayName: 'exports', - - /** - * Props Validation - * @type {Object} - */ - propTypes: { - horizontal: _reactNative2.default.PropTypes.bool, - children: _reactNative2.default.PropTypes.node.isRequired, - style: _React.View.propTypes.style, - pagingEnabled: _reactNative2.default.PropTypes.bool, - showsHorizontalScrollIndicator: _reactNative2.default.PropTypes.bool, - showsVerticalScrollIndicator: _reactNative2.default.PropTypes.bool, - bounces: _reactNative2.default.PropTypes.bool, - scrollsToTop: _reactNative2.default.PropTypes.bool, - removeClippedSubviews: _reactNative2.default.PropTypes.bool, - automaticallyAdjustContentInsets: _reactNative2.default.PropTypes.bool, - showsPagination: _reactNative2.default.PropTypes.bool, - showsButtons: _reactNative2.default.PropTypes.bool, - loop: _reactNative2.default.PropTypes.bool, - autoplay: _reactNative2.default.PropTypes.bool, - autoplayTimeout: _reactNative2.default.PropTypes.number, - autoplayDirection: _reactNative2.default.PropTypes.bool, - index: _reactNative2.default.PropTypes.number, - renderPagination: _reactNative2.default.PropTypes.func - }, - - mixins: [_reactTimerMixin2.default], - - /** - * Default props - * @return {object} props - * @see http://facebook.github.io/react-native/docs/scrollview.html - */ - getDefaultProps: function getDefaultProps() { - return { - horizontal: true, - pagingEnabled: true, - showsHorizontalScrollIndicator: false, - showsVerticalScrollIndicator: false, - bounces: false, - scrollsToTop: false, - removeClippedSubviews: true, - automaticallyAdjustContentInsets: false, - showsPagination: true, - showsButtons: false, - loop: true, - autoplay: false, - autoplayTimeout: 2.5, - autoplayDirection: true, - index: 0 - }; - }, - - /** - * Init states - * @return {object} states - */ - getInitialState: function getInitialState() { - return this.initState(this.props); - }, - - /** - * autoplay timer - * @type {null} - */ - autoplayTimer: null, - - componentWillMount: function componentWillMount() { - this.props = this.injectState(this.props); - }, - componentWillReceiveProps: function componentWillReceiveProps(props) { - this.setState(this.initState(props)); - }, - componentDidMount: function componentDidMount() { - this.autoplay(); - }, - initState: function initState(props) { - var initState = { - isScrolling: false, - autoplayEnd: false - }; - - initState.total = props.children ? props.children.length || 1 : 0; - initState.index = initState.total > 1 ? Math.min(props.index, initState.total - 1) : 0; - - // Default: horizontal - initState.dir = props.horizontal == false ? 'y' : 'x'; - initState.width = props.width || width; - initState.height = props.height || height; - initState.offset = {}; - - if (initState.total > 1) { - var setup = props.loop ? 1 : initState.index; - initState.offset[initState.dir] = initState.dir == 'y' ? initState.height * setup : initState.width * setup; - } - return initState; - }, - - /** - * Automatic rolling - */ - autoplay: function autoplay() { - var _this = this; - - if (!this.props.autoplay || this.state.isScrolling || this.state.autoplayEnd) return; - - clearTimeout(this.autoplayTimer); - - this.autoplayTimer = this.setTimeout(function () { - if (!_this.props.loop && (_this.props.autoplayDirection ? _this.state.index == _this.state.total - 1 : _this.state.index == 0)) return _this.setState({ - autoplayEnd: true - }); - _this.scrollTo(_this.props.autoplayDirection ? 1 : -1); - }, this.props.autoplayTimeout * 1000); - }, - - /** - * Scroll begin handle - * @param {object} e native event - */ - onScrollBegin: function onScrollBegin(e) { - var _this2 = this; - - // update scroll state - this.setState({ - isScrolling: true - }); - - this.setTimeout(function () { - _this2.props.onScrollBeginDrag && _this2.props.onScrollBeginDrag(e, _this2.state, _this2); - }); - }, - - /** - * Scroll end handle - * @param {object} e native event - */ - onScrollEnd: function onScrollEnd(e) { - var _this3 = this; - - // update scroll state - this.setState({ - isScrolling: false - }); - - this.updateIndex(e.nativeEvent.contentOffset, this.state.dir); - - // Note: `this.setState` is async, so I call the `onMomentumScrollEnd` - // in setTimeout to ensure synchronous update `index` - this.setTimeout(function () { - _this3.autoplay(); - - // if `onMomentumScrollEnd` registered will be called here - _this3.props.onMomentumScrollEnd && _this3.props.onMomentumScrollEnd(e, _this3.state, _this3); - }); - }, - - /** - * Update index after scroll - * @param {object} offset content offset - * @param {string} dir 'x' || 'y' - */ - updateIndex: function updateIndex(offset, dir) { - - var state = this.state; - var index = state.index; - var diff = offset[dir] - state.offset[dir]; - var step = dir == 'x' ? state.width : state.height; - - // Do nothing if offset no change. - if (!diff) return; - - // Note: if touch very very quickly and continuous, - // the variation of `index` more than 1. - index = index + diff / step; - - if (this.props.loop) { - if (index <= -1) { - index = state.total - 1; - offset[dir] = step * state.total; - } else if (index >= state.total) { - index = 0; - offset[dir] = step; - } - } - - this.setState({ - index: index, - offset: offset - }); - }, - - /** - * Scroll by index - * @param {number} index offset index - */ - scrollTo: function scrollTo(index) { - if (this.state.isScrolling) return; - var state = this.state; - var diff = (this.props.loop ? 1 : 0) + index + this.state.index; - var x = 0; - var y = 0; - if (state.dir == 'x') x = diff * state.width; - if (state.dir == 'y') y = diff * state.height; - this.refs.scrollView && this.refs.scrollView.scrollTo(y, x); - - // update scroll state - this.setState({ - isScrolling: true, - autoplayEnd: false - }); - }, - - /** - * Render pagination - * @return {object} react-dom - */ - renderPagination: function renderPagination() { - - // By default, dots only show when `total` > 2 - if (this.state.total <= 1) return null; - - var dots = []; - var ActiveDot = this.props.activeDot || _reactNative2.default.createElement(_React.View, { style: { - backgroundColor: '#007aff', - width: 8, - height: 8, - borderRadius: 4, - marginLeft: 3, - marginRight: 3, - marginTop: 3, - marginBottom: 3 - } }); - var Dot = this.props.dot || _reactNative2.default.createElement(_React.View, { style: { - backgroundColor: 'rgba(0,0,0,.2)', - width: 8, - height: 8, - borderRadius: 4, - marginLeft: 3, - marginRight: 3, - marginTop: 3, - marginBottom: 3 - } }); - for (var i = 0; i < this.state.total; i++) { - dots.push(i === this.state.index ? _reactNative2.default.cloneElement(ActiveDot, { key: i }) : _reactNative2.default.cloneElement(Dot, { key: i })); - } - - return _reactNative2.default.createElement( - _React.View, - { pointerEvents: 'none', style: [styles['pagination_' + this.state.dir], this.props.paginationStyle] }, - dots - ); - }, - renderTitle: function renderTitle() { - var child = this.props.children[this.state.index]; - var title = child && child.props.title; - return title ? _reactNative2.default.createElement( - _React.View, - { style: styles.title }, - this.props.children[this.state.index].props.title - ) : null; - }, - renderNextButton: function renderNextButton() { - var _this4 = this; - - var button = undefined; - - if (this.props.loop || this.state.index != this.state.total - 1) { - button = this.props.nextButton || _reactNative2.default.createElement( - _React.Text, - { style: styles.buttonText }, - '›' - ); - } - - return _reactNative2.default.createElement( - _React.TouchableOpacity, - { onPress: function onPress() { - return button !== null && _this4.scrollTo.call(_this4, 1); - } }, - _reactNative2.default.createElement( - _React.View, - null, - button - ) - ); - }, - renderPrevButton: function renderPrevButton() { - var _this5 = this; - - var button = null; - - if (this.props.loop || this.state.index != 0) { - button = this.props.prevButton || _reactNative2.default.createElement( - _React.Text, - { style: styles.buttonText }, - '‹' - ); - } - - return _reactNative2.default.createElement( - _React.TouchableOpacity, - { onPress: function onPress() { - return button !== null && _this5.scrollTo.call(_this5, -1); - } }, - _reactNative2.default.createElement( - _React.View, - null, - button - ) - ); - }, - renderButtons: function renderButtons() { - return _reactNative2.default.createElement( - _React.View, - { pointerEvents: 'box-none', style: [styles.buttonWrapper, { width: this.state.width, height: this.state.height }, this.props.buttonWrapperStyle] }, - this.renderPrevButton(), - this.renderNextButton() - ); - }, - renderScrollView: function renderScrollView(pages) { - if (_React.Platform.OS === 'ios') return _reactNative2.default.createElement( - _React.ScrollView, - _extends({ ref: 'scrollView' - }, this.props, { - contentContainerStyle: [styles.wrapper, this.props.style], - contentOffset: this.state.offset, - onScrollBeginDrag: this.onScrollBegin, - onMomentumScrollEnd: this.onScrollEnd }), - pages - ); - return _reactNative2.default.createElement( - _React.ViewPagerAndroid, - { ref: 'scrollView', - style: { flex: 1 } }, - pages - ); - }, - - /** - * Inject state to ScrollResponder - * @param {object} props origin props - * @return {object} props injected props - */ - injectState: function injectState(props) { - var _this6 = this; - - /* const scrollResponders = [ - 'onMomentumScrollBegin', - 'onTouchStartCapture', - 'onTouchStart', - 'onTouchEnd', - 'onResponderRelease', - ]*/ - - for (var prop in props) { - // if(~scrollResponders.indexOf(prop) - if (typeof props[prop] === 'function' && prop !== 'onMomentumScrollEnd' && prop !== 'renderPagination' && prop !== 'onScrollBeginDrag') { - (function () { - var originResponder = props[prop]; - props[prop] = function (e) { - return originResponder(e, _this6.state, _this6); - }; - })(); - } - } - - return props; - }, - - /** - * Default render - * @return {object} react-dom - */ - render: function render() { - var state = this.state; - var props = this.props; - var children = props.children; - var index = state.index; - var total = state.total; - var loop = props.loop; - var dir = state.dir; - var key = 0; - - var pages = []; - var pageStyle = [{ width: state.width, height: state.height }, styles.slide]; - - // For make infinite at least total > 1 - if (total > 1) { - - // Re-design a loop model for avoid img flickering - pages = Object.keys(children); - if (loop) { - pages.unshift(total - 1); - pages.push(0); - } - - pages = pages.map(function (page, i) { - return _reactNative2.default.createElement( - _React.View, - { style: pageStyle, key: i }, - children[page] - ); - }); - } else pages = _reactNative2.default.createElement( - _React.View, - { style: pageStyle }, - children - ); - - return _reactNative2.default.createElement( - _React.View, - { style: [styles.container, { - width: state.width, - height: state.height - }] }, - this.renderScrollView(pages), - props.showsPagination && (props.renderPagination ? this.props.renderPagination(state.index, state.total, this) : this.renderPagination()), - this.renderTitle(), - this.props.showsButtons && this.renderButtons() - ); - } -}); diff --git a/examples.old/examples/phone.js b/examples.old/examples/phone.js deleted file mode 100644 index f125bfe8..00000000 --- a/examples.old/examples/phone.js +++ /dev/null @@ -1,51 +0,0 @@ -var React = require('react-native') -var Swiper = require('./') -var { - StyleSheet, - Text, - View, - Image, -} = React - -var styles = StyleSheet.create({ - wrapper: { - // backgroundColor: '#f00', - }, - slide: { - flex: 1, - backgroundColor: 'transparent', - }, - image: { - flex: 1, - } -}) - -var swiper = React.createClass({ - render: function() { - return ( - - - } - activeDot={} - paginationStyle={{ - bottom: 70, - }} - loop={false}> - - - - - - - - - - - - - ) - } -}) - -module.exports = swiper diff --git a/examples.old/examples/swiper.js b/examples.old/examples/swiper.js deleted file mode 100644 index ef9a2f46..00000000 --- a/examples.old/examples/swiper.js +++ /dev/null @@ -1,87 +0,0 @@ -var React = require('react-native') -var Swiper = require('./') -var { - StyleSheet, - Text, - View, - Image, -} = React - -var styles = StyleSheet.create({ - wrapper: { - }, - slide: { - flex: 1, - justifyContent: 'center', - backgroundColor: 'transparent', - }, - slide1: { - flex: 1, - justifyContent: 'center', - alignItems: 'center', - backgroundColor: '#9DD6EB', - }, - slide2: { - flex: 1, - justifyContent: 'center', - alignItems: 'center', - backgroundColor: '#97CAE5', - }, - slide3: { - flex: 1, - justifyContent: 'center', - alignItems: 'center', - backgroundColor: '#92BBD9', - }, - text: { - color: '#fff', - fontSize: 30, - fontWeight: 'bold', - }, - image: { - flex: 1, - } -}) - -var swiper = React.createClass({ - render: function() { - return ( - - - - Hello Swiper - - - Beautiful - - - And simple - - - - } - activeDot={} - paginationStyle={{ - bottom: -23, left: null, right: 10, - }} loop={true}> - Aussie tourist dies at Bali hotel}> - - - Big lie behind Nine’s new show}> - - - Why Stone split from Garfield}> - - - Learn from Kim K to land that job}> - - - - - ) - } -}) - -module.exports = swiper diff --git a/examples.old/examples/swiper_number.js b/examples.old/examples/swiper_number.js deleted file mode 100644 index 8f0144e2..00000000 --- a/examples.old/examples/swiper_number.js +++ /dev/null @@ -1,71 +0,0 @@ -var React = require('react-native') -var Swiper = require('./') -var { - StyleSheet, - Text, - View, - Image, -} = React - -var styles = StyleSheet.create({ - wrapper: { - }, - slide: { - flex: 1, - justifyContent: 'center', - backgroundColor: 'transparent', - }, - text: { - color: '#fff', - fontSize: 30, - fontWeight: 'bold', - }, - image: { - flex: 1, - } -}) - -var renderPagination = function (index, total, context) { - return ( - - {index + 1}/{total} - - ) -} - -var swiper = React.createClass({ - render: function() { - return ( - - - Aussie tourist dies at Bali hotel}> - - - Big lie behind Nine’s new show}> - - - Why Stone split from Garfield}> - - - Learn from Kim K to land that job}> - - - - - ) - } -}) - -module.exports = swiper - diff --git a/examples.old/iOS/AppDelegate.h b/examples.old/iOS/AppDelegate.h deleted file mode 100644 index a9654d5e..00000000 --- a/examples.old/iOS/AppDelegate.h +++ /dev/null @@ -1,16 +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. - */ - -#import - -@interface AppDelegate : UIResponder - -@property (nonatomic, strong) UIWindow *window; - -@end diff --git a/examples.old/iOS/AppDelegate.m b/examples.old/iOS/AppDelegate.m deleted file mode 100644 index 605ba2a5..00000000 --- a/examples.old/iOS/AppDelegate.m +++ /dev/null @@ -1,60 +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. - */ - -#import "AppDelegate.h" - -#import "RCTRootView.h" - -@implementation AppDelegate - -- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions -{ - NSURL *jsCodeLocation; - - /** - * Loading JavaScript code - uncomment the one you want. - * - * OPTION 1 - * Load from development server. Start the server from the repository root: - * - * $ npm start - * - * To run on device, change `localhost` to the IP address of your computer - * (you can get this by typing `ifconfig` into the terminal and selecting the - * `inet` value under `en0:`) and make sure your computer and iOS device are - * on the same Wi-Fi network. - */ - - jsCodeLocation = [NSURL URLWithString:@"http://localhost:8081/index.ios.bundle"]; - - /** - * OPTION 2 - * Load from pre-bundled file on disk. To re-generate the static bundle - * from the root of your project directory, run - * - * $ react-native bundle --minify - * - * see http://facebook.github.io/react-native/docs/runningondevice.html - */ - -// jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"]; - - RCTRootView *rootView = [[RCTRootView alloc] initWithBundleURL:jsCodeLocation - moduleName:@"swiper" - launchOptions:launchOptions]; - - self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; - UIViewController *rootViewController = [[UIViewController alloc] init]; - rootViewController.view = rootView; - self.window.rootViewController = rootViewController; - [self.window makeKeyAndVisible]; - return YES; -} - -@end diff --git a/examples.old/iOS/Base.lproj/LaunchScreen.xib b/examples.old/iOS/Base.lproj/LaunchScreen.xib deleted file mode 100644 index 0adab5dc..00000000 --- a/examples.old/iOS/Base.lproj/LaunchScreen.xib +++ /dev/null @@ -1,42 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples.old/iOS/Images.xcassets/AppIcon.appiconset/Contents.json b/examples.old/iOS/Images.xcassets/AppIcon.appiconset/Contents.json deleted file mode 100644 index 118c98f7..00000000 --- a/examples.old/iOS/Images.xcassets/AppIcon.appiconset/Contents.json +++ /dev/null @@ -1,38 +0,0 @@ -{ - "images" : [ - { - "idiom" : "iphone", - "size" : "29x29", - "scale" : "2x" - }, - { - "idiom" : "iphone", - "size" : "29x29", - "scale" : "3x" - }, - { - "idiom" : "iphone", - "size" : "40x40", - "scale" : "2x" - }, - { - "idiom" : "iphone", - "size" : "40x40", - "scale" : "3x" - }, - { - "idiom" : "iphone", - "size" : "60x60", - "scale" : "2x" - }, - { - "idiom" : "iphone", - "size" : "60x60", - "scale" : "3x" - } - ], - "info" : { - "version" : 1, - "author" : "xcode" - } -} \ No newline at end of file diff --git a/examples.old/iOS/Info.plist b/examples.old/iOS/Info.plist deleted file mode 100644 index 7cd1b348..00000000 --- a/examples.old/iOS/Info.plist +++ /dev/null @@ -1,50 +0,0 @@ - - - - - CFBundleDevelopmentRegion - en - CFBundleExecutable - $(EXECUTABLE_NAME) - CFBundleIdentifier - org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier) - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - $(PRODUCT_NAME) - CFBundlePackageType - APPL - CFBundleShortVersionString - 1.0 - CFBundleSignature - ???? - CFBundleVersion - 1 - LSRequiresIPhoneOS - - UILaunchStoryboardName - LaunchScreen - UIRequiredDeviceCapabilities - - armv7 - - UISupportedInterfaceOrientations - - UIInterfaceOrientationPortrait - UIInterfaceOrientationLandscapeLeft - UIInterfaceOrientationLandscapeRight - - NSAppTransportSecurity - - NSAllowsArbitraryLoads - - NSLocationWhenInUseUsageDescription - - NSAppTransportSecurity - - - NSAllowsArbitraryLoads - - - - diff --git a/examples.old/iOS/main.jsbundle b/examples.old/iOS/main.jsbundle deleted file mode 100644 index b702b30c..00000000 --- a/examples.old/iOS/main.jsbundle +++ /dev/null @@ -1,8 +0,0 @@ -// Offline JS -// To re-generate the offline bundle, run this from the root of your project: -// -// $ react-native bundle --minify -// -// See http://facebook.github.io/react-native/docs/runningondevice.html for more details. - -throw new Error('Offline JS file is empty. See iOS/main.jsbundle for instructions'); diff --git a/examples.old/iOS/main.m b/examples.old/iOS/main.m deleted file mode 100644 index 3d767fcb..00000000 --- a/examples.old/iOS/main.m +++ /dev/null @@ -1,18 +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. - */ - -#import - -#import "AppDelegate.h" - -int main(int argc, char * argv[]) { - @autoreleasepool { - return UIApplicationMain(argc, argv, nil, NSStringFromClass([AppDelegate class])); - } -} diff --git a/examples.old/index.ios.js b/examples.old/index.ios.js deleted file mode 100644 index 65dc9bd9..00000000 --- a/examples.old/index.ios.js +++ /dev/null @@ -1,14 +0,0 @@ -'use strict' - -var React = require('react-native') -var { - AppRegistry, -} = React - -var swiper = require('./examples/basic') -// var swiper = require('./examples/swiper') -// var swiper = require('./examples/swiper_number') -// var swiper = require('./examples/phone') -// var swiper = require('./examples/dynamic') - -AppRegistry.registerComponent('swiper', () => swiper) diff --git a/examples.old/package.json b/examples.old/package.json deleted file mode 100644 index 53b2fda0..00000000 --- a/examples.old/package.json +++ /dev/null @@ -1,12 +0,0 @@ -{ - "name": "swiper", - "version": "0.0.1", - "private": true, - "scripts": { - "start": "node_modules/react-native/packager/packager.sh" - }, - "dependencies": { - "react-native": "^0.8.3", - "react-timer-mixin": "^0.13.3" - } -} diff --git a/examples.old/swiper.xcodeproj/project.pbxproj b/examples.old/swiper.xcodeproj/project.pbxproj deleted file mode 100644 index cb1db630..00000000 --- a/examples.old/swiper.xcodeproj/project.pbxproj +++ /dev/null @@ -1,745 +0,0 @@ -// !$*UTF8*$! -{ - archiveVersion = 1; - classes = { - }; - objectVersion = 46; - objects = { - -/* Begin PBXBuildFile section */ - 008F07F31AC5B25A0029DE68 /* main.jsbundle in Resources */ = {isa = PBXBuildFile; fileRef = 008F07F21AC5B25A0029DE68 /* main.jsbundle */; }; - 00C302E51ABCBA2D00DB3ED1 /* libRCTActionSheet.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302AC1ABCB8CE00DB3ED1 /* libRCTActionSheet.a */; }; - 00C302E71ABCBA2D00DB3ED1 /* libRCTGeolocation.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302BA1ABCB90400DB3ED1 /* libRCTGeolocation.a */; }; - 00C302E81ABCBA2D00DB3ED1 /* libRCTImage.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302C01ABCB91800DB3ED1 /* libRCTImage.a */; }; - 00C302E91ABCBA2D00DB3ED1 /* libRCTNetwork.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302DC1ABCB9D200DB3ED1 /* libRCTNetwork.a */; }; - 00C302EA1ABCBA2D00DB3ED1 /* libRCTVibration.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 00C302E41ABCB9EE00DB3ED1 /* libRCTVibration.a */; }; - 00E356F31AD99517003FC87E /* swiperTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 00E356F21AD99517003FC87E /* swiperTests.m */; }; - 133E29F31AD74F7200F7D852 /* libRCTLinking.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 78C398B91ACF4ADC00677621 /* libRCTLinking.a */; }; - 139105C61AF99C1200B5F7CC /* libRCTSettings.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 139105C11AF99BAD00B5F7CC /* libRCTSettings.a */; }; - 139FDEF61B0652A700C62182 /* libRCTWebSocket.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 139FDEF41B06529B00C62182 /* libRCTWebSocket.a */; }; - 13B07FBC1A68108700A75B9A /* AppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB01A68108700A75B9A /* AppDelegate.m */; }; - 13B07FBD1A68108700A75B9A /* LaunchScreen.xib in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB11A68108700A75B9A /* LaunchScreen.xib */; }; - 13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 13B07FB51A68108700A75B9A /* Images.xcassets */; }; - 13B07FC11A68108700A75B9A /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 13B07FB71A68108700A75B9A /* main.m */; }; - 146834051AC3E58100842450 /* libReact.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 146834041AC3E56700842450 /* libReact.a */; }; - 832341BD1AAA6AB300B99B32 /* libRCTText.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 832341B51AAA6A8300B99B32 /* libRCTText.a */; }; -/* End PBXBuildFile section */ - -/* Begin PBXContainerItemProxy section */ - 00C302AB1ABCB8CE00DB3ED1 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 00C302A71ABCB8CE00DB3ED1 /* RCTActionSheet.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 134814201AA4EA6300B7C361; - remoteInfo = RCTActionSheet; - }; - 00C302B91ABCB90400DB3ED1 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 00C302B51ABCB90400DB3ED1 /* RCTGeolocation.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 134814201AA4EA6300B7C361; - remoteInfo = RCTGeolocation; - }; - 00C302BF1ABCB91800DB3ED1 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 00C302BB1ABCB91800DB3ED1 /* RCTImage.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 58B5115D1A9E6B3D00147676; - remoteInfo = RCTImage; - }; - 00C302DB1ABCB9D200DB3ED1 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 00C302D31ABCB9D200DB3ED1 /* RCTNetwork.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 58B511DB1A9E6C8500147676; - remoteInfo = RCTNetwork; - }; - 00C302E31ABCB9EE00DB3ED1 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 00C302DF1ABCB9EE00DB3ED1 /* RCTVibration.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 832C81801AAF6DEF007FA2F7; - remoteInfo = RCTVibration; - }; - 00E356F41AD99517003FC87E /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 83CBB9F71A601CBA00E9B192 /* Project object */; - proxyType = 1; - remoteGlobalIDString = 13B07F861A680F5B00A75B9A; - remoteInfo = swiper; - }; - 139105C01AF99BAD00B5F7CC /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 139105B61AF99BAD00B5F7CC /* RCTSettings.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 134814201AA4EA6300B7C361; - remoteInfo = RCTSettings; - }; - 139FDEF31B06529B00C62182 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 139FDEE61B06529A00C62182 /* RCTWebSocket.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 3C86DF461ADF2C930047B81A; - remoteInfo = RCTWebSocket; - }; - 146834031AC3E56700842450 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 146833FF1AC3E56700842450 /* React.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 83CBBA2E1A601D0E00E9B192; - remoteInfo = React; - }; - 78C398B81ACF4ADC00677621 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 78C398B01ACF4ADC00677621 /* RCTLinking.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 134814201AA4EA6300B7C361; - remoteInfo = RCTLinking; - }; - 832341B41AAA6A8300B99B32 /* PBXContainerItemProxy */ = { - isa = PBXContainerItemProxy; - containerPortal = 832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */; - proxyType = 2; - remoteGlobalIDString = 58B5119B1A9E6C1200147676; - remoteInfo = RCTText; - }; -/* End PBXContainerItemProxy section */ - -/* Begin PBXFileReference section */ - 008F07F21AC5B25A0029DE68 /* main.jsbundle */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; name = main.jsbundle; path = iOS/main.jsbundle; sourceTree = ""; }; - 00C302A71ABCB8CE00DB3ED1 /* RCTActionSheet.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTActionSheet.xcodeproj; path = node_modules/react-native/Libraries/ActionSheetIOS/RCTActionSheet.xcodeproj; sourceTree = ""; }; - 00C302B51ABCB90400DB3ED1 /* RCTGeolocation.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTGeolocation.xcodeproj; path = node_modules/react-native/Libraries/Geolocation/RCTGeolocation.xcodeproj; sourceTree = ""; }; - 00C302BB1ABCB91800DB3ED1 /* RCTImage.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTImage.xcodeproj; path = node_modules/react-native/Libraries/Image/RCTImage.xcodeproj; sourceTree = ""; }; - 00C302D31ABCB9D200DB3ED1 /* RCTNetwork.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTNetwork.xcodeproj; path = node_modules/react-native/Libraries/Network/RCTNetwork.xcodeproj; sourceTree = ""; }; - 00C302DF1ABCB9EE00DB3ED1 /* RCTVibration.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTVibration.xcodeproj; path = node_modules/react-native/Libraries/Vibration/RCTVibration.xcodeproj; sourceTree = ""; }; - 00E356EE1AD99517003FC87E /* swiperTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = swiperTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; }; - 00E356F11AD99517003FC87E /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - 00E356F21AD99517003FC87E /* swiperTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = swiperTests.m; sourceTree = ""; }; - 139105B61AF99BAD00B5F7CC /* RCTSettings.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTSettings.xcodeproj; path = node_modules/react-native/Libraries/Settings/RCTSettings.xcodeproj; sourceTree = ""; }; - 139FDEE61B06529A00C62182 /* RCTWebSocket.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTWebSocket.xcodeproj; path = node_modules/react-native/Libraries/WebSocket/RCTWebSocket.xcodeproj; sourceTree = ""; }; - 13B07F961A680F5B00A75B9A /* swiper.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = swiper.app; sourceTree = BUILT_PRODUCTS_DIR; }; - 13B07FAF1A68108700A75B9A /* AppDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = AppDelegate.h; path = iOS/AppDelegate.h; sourceTree = ""; }; - 13B07FB01A68108700A75B9A /* AppDelegate.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = AppDelegate.m; path = iOS/AppDelegate.m; sourceTree = ""; }; - 13B07FB21A68108700A75B9A /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = Base; path = Base.lproj/LaunchScreen.xib; sourceTree = ""; }; - 13B07FB51A68108700A75B9A /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Images.xcassets; path = iOS/Images.xcassets; sourceTree = ""; }; - 13B07FB61A68108700A75B9A /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = Info.plist; path = iOS/Info.plist; sourceTree = ""; }; - 13B07FB71A68108700A75B9A /* main.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = main.m; path = iOS/main.m; sourceTree = ""; }; - 146833FF1AC3E56700842450 /* React.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = React.xcodeproj; path = node_modules/react-native/React/React.xcodeproj; sourceTree = ""; }; - 78C398B01ACF4ADC00677621 /* RCTLinking.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTLinking.xcodeproj; path = node_modules/react-native/Libraries/LinkingIOS/RCTLinking.xcodeproj; sourceTree = ""; }; - 832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */ = {isa = PBXFileReference; lastKnownFileType = "wrapper.pb-project"; name = RCTText.xcodeproj; path = node_modules/react-native/Libraries/Text/RCTText.xcodeproj; sourceTree = ""; }; -/* End PBXFileReference section */ - -/* Begin PBXFrameworksBuildPhase section */ - 00E356EB1AD99517003FC87E /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 13B07F8C1A680F5B00A75B9A /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - 146834051AC3E58100842450 /* libReact.a in Frameworks */, - 00C302E51ABCBA2D00DB3ED1 /* libRCTActionSheet.a in Frameworks */, - 00C302E71ABCBA2D00DB3ED1 /* libRCTGeolocation.a in Frameworks */, - 00C302E81ABCBA2D00DB3ED1 /* libRCTImage.a in Frameworks */, - 133E29F31AD74F7200F7D852 /* libRCTLinking.a in Frameworks */, - 00C302E91ABCBA2D00DB3ED1 /* libRCTNetwork.a in Frameworks */, - 139105C61AF99C1200B5F7CC /* libRCTSettings.a in Frameworks */, - 832341BD1AAA6AB300B99B32 /* libRCTText.a in Frameworks */, - 00C302EA1ABCBA2D00DB3ED1 /* libRCTVibration.a in Frameworks */, - 139FDEF61B0652A700C62182 /* libRCTWebSocket.a in Frameworks */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXFrameworksBuildPhase section */ - -/* Begin PBXGroup section */ - 00C302A81ABCB8CE00DB3ED1 /* Products */ = { - isa = PBXGroup; - children = ( - 00C302AC1ABCB8CE00DB3ED1 /* libRCTActionSheet.a */, - ); - name = Products; - sourceTree = ""; - }; - 00C302B61ABCB90400DB3ED1 /* Products */ = { - isa = PBXGroup; - children = ( - 00C302BA1ABCB90400DB3ED1 /* libRCTGeolocation.a */, - ); - name = Products; - sourceTree = ""; - }; - 00C302BC1ABCB91800DB3ED1 /* Products */ = { - isa = PBXGroup; - children = ( - 00C302C01ABCB91800DB3ED1 /* libRCTImage.a */, - ); - name = Products; - sourceTree = ""; - }; - 00C302D41ABCB9D200DB3ED1 /* Products */ = { - isa = PBXGroup; - children = ( - 00C302DC1ABCB9D200DB3ED1 /* libRCTNetwork.a */, - ); - name = Products; - sourceTree = ""; - }; - 00C302E01ABCB9EE00DB3ED1 /* Products */ = { - isa = PBXGroup; - children = ( - 00C302E41ABCB9EE00DB3ED1 /* libRCTVibration.a */, - ); - name = Products; - sourceTree = ""; - }; - 00E356EF1AD99517003FC87E /* swiperTests */ = { - isa = PBXGroup; - children = ( - 00E356F21AD99517003FC87E /* swiperTests.m */, - 00E356F01AD99517003FC87E /* Supporting Files */, - ); - path = swiperTests; - sourceTree = ""; - }; - 00E356F01AD99517003FC87E /* Supporting Files */ = { - isa = PBXGroup; - children = ( - 00E356F11AD99517003FC87E /* Info.plist */, - ); - name = "Supporting Files"; - sourceTree = ""; - }; - 139105B71AF99BAD00B5F7CC /* Products */ = { - isa = PBXGroup; - children = ( - 139105C11AF99BAD00B5F7CC /* libRCTSettings.a */, - ); - name = Products; - sourceTree = ""; - }; - 139FDEE71B06529A00C62182 /* Products */ = { - isa = PBXGroup; - children = ( - 139FDEF41B06529B00C62182 /* libRCTWebSocket.a */, - ); - name = Products; - sourceTree = ""; - }; - 13B07FAE1A68108700A75B9A /* swiper */ = { - isa = PBXGroup; - children = ( - 008F07F21AC5B25A0029DE68 /* main.jsbundle */, - 13B07FAF1A68108700A75B9A /* AppDelegate.h */, - 13B07FB01A68108700A75B9A /* AppDelegate.m */, - 13B07FB51A68108700A75B9A /* Images.xcassets */, - 13B07FB61A68108700A75B9A /* Info.plist */, - 13B07FB11A68108700A75B9A /* LaunchScreen.xib */, - 13B07FB71A68108700A75B9A /* main.m */, - ); - name = swiper; - sourceTree = ""; - }; - 146834001AC3E56700842450 /* Products */ = { - isa = PBXGroup; - children = ( - 146834041AC3E56700842450 /* libReact.a */, - ); - name = Products; - sourceTree = ""; - }; - 78C398B11ACF4ADC00677621 /* Products */ = { - isa = PBXGroup; - children = ( - 78C398B91ACF4ADC00677621 /* libRCTLinking.a */, - ); - name = Products; - sourceTree = ""; - }; - 832341AE1AAA6A7D00B99B32 /* Libraries */ = { - isa = PBXGroup; - children = ( - 146833FF1AC3E56700842450 /* React.xcodeproj */, - 00C302A71ABCB8CE00DB3ED1 /* RCTActionSheet.xcodeproj */, - 00C302B51ABCB90400DB3ED1 /* RCTGeolocation.xcodeproj */, - 00C302BB1ABCB91800DB3ED1 /* RCTImage.xcodeproj */, - 78C398B01ACF4ADC00677621 /* RCTLinking.xcodeproj */, - 00C302D31ABCB9D200DB3ED1 /* RCTNetwork.xcodeproj */, - 139105B61AF99BAD00B5F7CC /* RCTSettings.xcodeproj */, - 832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */, - 00C302DF1ABCB9EE00DB3ED1 /* RCTVibration.xcodeproj */, - 139FDEE61B06529A00C62182 /* RCTWebSocket.xcodeproj */, - ); - name = Libraries; - sourceTree = ""; - }; - 832341B11AAA6A8300B99B32 /* Products */ = { - isa = PBXGroup; - children = ( - 832341B51AAA6A8300B99B32 /* libRCTText.a */, - ); - name = Products; - sourceTree = ""; - }; - 83CBB9F61A601CBA00E9B192 = { - isa = PBXGroup; - children = ( - 13B07FAE1A68108700A75B9A /* swiper */, - 832341AE1AAA6A7D00B99B32 /* Libraries */, - 00E356EF1AD99517003FC87E /* swiperTests */, - 83CBBA001A601CBA00E9B192 /* Products */, - ); - indentWidth = 2; - sourceTree = ""; - tabWidth = 2; - }; - 83CBBA001A601CBA00E9B192 /* Products */ = { - isa = PBXGroup; - children = ( - 13B07F961A680F5B00A75B9A /* swiper.app */, - 00E356EE1AD99517003FC87E /* swiperTests.xctest */, - ); - name = Products; - sourceTree = ""; - }; -/* End PBXGroup section */ - -/* Begin PBXNativeTarget section */ - 00E356ED1AD99517003FC87E /* swiperTests */ = { - isa = PBXNativeTarget; - buildConfigurationList = 00E357021AD99517003FC87E /* Build configuration list for PBXNativeTarget "swiperTests" */; - buildPhases = ( - 00E356EA1AD99517003FC87E /* Sources */, - 00E356EB1AD99517003FC87E /* Frameworks */, - 00E356EC1AD99517003FC87E /* Resources */, - ); - buildRules = ( - ); - dependencies = ( - 00E356F51AD99517003FC87E /* PBXTargetDependency */, - ); - name = swiperTests; - productName = swiperTests; - productReference = 00E356EE1AD99517003FC87E /* swiperTests.xctest */; - productType = "com.apple.product-type.bundle.unit-test"; - }; - 13B07F861A680F5B00A75B9A /* swiper */ = { - isa = PBXNativeTarget; - buildConfigurationList = 13B07F931A680F5B00A75B9A /* Build configuration list for PBXNativeTarget "swiper" */; - buildPhases = ( - 13B07F871A680F5B00A75B9A /* Sources */, - 13B07F8C1A680F5B00A75B9A /* Frameworks */, - 13B07F8E1A680F5B00A75B9A /* Resources */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = swiper; - productName = "Hello World"; - productReference = 13B07F961A680F5B00A75B9A /* swiper.app */; - productType = "com.apple.product-type.application"; - }; -/* End PBXNativeTarget section */ - -/* Begin PBXProject section */ - 83CBB9F71A601CBA00E9B192 /* Project object */ = { - isa = PBXProject; - attributes = { - LastUpgradeCheck = 0610; - ORGANIZATIONNAME = Facebook; - TargetAttributes = { - 00E356ED1AD99517003FC87E = { - CreatedOnToolsVersion = 6.2; - TestTargetID = 13B07F861A680F5B00A75B9A; - }; - }; - }; - buildConfigurationList = 83CBB9FA1A601CBA00E9B192 /* Build configuration list for PBXProject "swiper" */; - compatibilityVersion = "Xcode 3.2"; - developmentRegion = English; - hasScannedForEncodings = 0; - knownRegions = ( - en, - Base, - ); - mainGroup = 83CBB9F61A601CBA00E9B192; - productRefGroup = 83CBBA001A601CBA00E9B192 /* Products */; - projectDirPath = ""; - projectReferences = ( - { - ProductGroup = 00C302A81ABCB8CE00DB3ED1 /* Products */; - ProjectRef = 00C302A71ABCB8CE00DB3ED1 /* RCTActionSheet.xcodeproj */; - }, - { - ProductGroup = 00C302B61ABCB90400DB3ED1 /* Products */; - ProjectRef = 00C302B51ABCB90400DB3ED1 /* RCTGeolocation.xcodeproj */; - }, - { - ProductGroup = 00C302BC1ABCB91800DB3ED1 /* Products */; - ProjectRef = 00C302BB1ABCB91800DB3ED1 /* RCTImage.xcodeproj */; - }, - { - ProductGroup = 78C398B11ACF4ADC00677621 /* Products */; - ProjectRef = 78C398B01ACF4ADC00677621 /* RCTLinking.xcodeproj */; - }, - { - ProductGroup = 00C302D41ABCB9D200DB3ED1 /* Products */; - ProjectRef = 00C302D31ABCB9D200DB3ED1 /* RCTNetwork.xcodeproj */; - }, - { - ProductGroup = 139105B71AF99BAD00B5F7CC /* Products */; - ProjectRef = 139105B61AF99BAD00B5F7CC /* RCTSettings.xcodeproj */; - }, - { - ProductGroup = 832341B11AAA6A8300B99B32 /* Products */; - ProjectRef = 832341B01AAA6A8300B99B32 /* RCTText.xcodeproj */; - }, - { - ProductGroup = 00C302E01ABCB9EE00DB3ED1 /* Products */; - ProjectRef = 00C302DF1ABCB9EE00DB3ED1 /* RCTVibration.xcodeproj */; - }, - { - ProductGroup = 139FDEE71B06529A00C62182 /* Products */; - ProjectRef = 139FDEE61B06529A00C62182 /* RCTWebSocket.xcodeproj */; - }, - { - ProductGroup = 146834001AC3E56700842450 /* Products */; - ProjectRef = 146833FF1AC3E56700842450 /* React.xcodeproj */; - }, - ); - projectRoot = ""; - targets = ( - 13B07F861A680F5B00A75B9A /* swiper */, - 00E356ED1AD99517003FC87E /* swiperTests */, - ); - }; -/* End PBXProject section */ - -/* Begin PBXReferenceProxy section */ - 00C302AC1ABCB8CE00DB3ED1 /* libRCTActionSheet.a */ = { - isa = PBXReferenceProxy; - fileType = archive.ar; - path = libRCTActionSheet.a; - remoteRef = 00C302AB1ABCB8CE00DB3ED1 /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 00C302BA1ABCB90400DB3ED1 /* libRCTGeolocation.a */ = { - isa = PBXReferenceProxy; - fileType = archive.ar; - path = libRCTGeolocation.a; - remoteRef = 00C302B91ABCB90400DB3ED1 /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 00C302C01ABCB91800DB3ED1 /* libRCTImage.a */ = { - isa = PBXReferenceProxy; - fileType = archive.ar; - path = libRCTImage.a; - remoteRef = 00C302BF1ABCB91800DB3ED1 /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 00C302DC1ABCB9D200DB3ED1 /* libRCTNetwork.a */ = { - isa = PBXReferenceProxy; - fileType = archive.ar; - path = libRCTNetwork.a; - remoteRef = 00C302DB1ABCB9D200DB3ED1 /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 00C302E41ABCB9EE00DB3ED1 /* libRCTVibration.a */ = { - isa = PBXReferenceProxy; - fileType = archive.ar; - path = libRCTVibration.a; - remoteRef = 00C302E31ABCB9EE00DB3ED1 /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 139105C11AF99BAD00B5F7CC /* libRCTSettings.a */ = { - isa = PBXReferenceProxy; - fileType = archive.ar; - path = libRCTSettings.a; - remoteRef = 139105C01AF99BAD00B5F7CC /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 139FDEF41B06529B00C62182 /* libRCTWebSocket.a */ = { - isa = PBXReferenceProxy; - fileType = archive.ar; - path = libRCTWebSocket.a; - remoteRef = 139FDEF31B06529B00C62182 /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 146834041AC3E56700842450 /* libReact.a */ = { - isa = PBXReferenceProxy; - fileType = archive.ar; - path = libReact.a; - remoteRef = 146834031AC3E56700842450 /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 78C398B91ACF4ADC00677621 /* libRCTLinking.a */ = { - isa = PBXReferenceProxy; - fileType = archive.ar; - path = libRCTLinking.a; - remoteRef = 78C398B81ACF4ADC00677621 /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; - 832341B51AAA6A8300B99B32 /* libRCTText.a */ = { - isa = PBXReferenceProxy; - fileType = archive.ar; - path = libRCTText.a; - remoteRef = 832341B41AAA6A8300B99B32 /* PBXContainerItemProxy */; - sourceTree = BUILT_PRODUCTS_DIR; - }; -/* End PBXReferenceProxy section */ - -/* Begin PBXResourcesBuildPhase section */ - 00E356EC1AD99517003FC87E /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 13B07F8E1A680F5B00A75B9A /* Resources */ = { - isa = PBXResourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 008F07F31AC5B25A0029DE68 /* main.jsbundle in Resources */, - 13B07FBF1A68108700A75B9A /* Images.xcassets in Resources */, - 13B07FBD1A68108700A75B9A /* LaunchScreen.xib in Resources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXResourcesBuildPhase section */ - -/* Begin PBXSourcesBuildPhase section */ - 00E356EA1AD99517003FC87E /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 00E356F31AD99517003FC87E /* swiperTests.m in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; - 13B07F871A680F5B00A75B9A /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 13B07FBC1A68108700A75B9A /* AppDelegate.m in Sources */, - 13B07FC11A68108700A75B9A /* main.m in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXSourcesBuildPhase section */ - -/* Begin PBXTargetDependency section */ - 00E356F51AD99517003FC87E /* PBXTargetDependency */ = { - isa = PBXTargetDependency; - target = 13B07F861A680F5B00A75B9A /* swiper */; - targetProxy = 00E356F41AD99517003FC87E /* PBXContainerItemProxy */; - }; -/* End PBXTargetDependency section */ - -/* Begin PBXVariantGroup section */ - 13B07FB11A68108700A75B9A /* LaunchScreen.xib */ = { - isa = PBXVariantGroup; - children = ( - 13B07FB21A68108700A75B9A /* Base */, - ); - name = LaunchScreen.xib; - path = iOS; - sourceTree = ""; - }; -/* End PBXVariantGroup section */ - -/* Begin XCBuildConfiguration section */ - 00E356F61AD99517003FC87E /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - BUNDLE_LOADER = "$(TEST_HOST)"; - FRAMEWORK_SEARCH_PATHS = ( - "$(SDKROOT)/Developer/Library/Frameworks", - "$(inherited)", - ); - GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", - "$(inherited)", - ); - INFOPLIST_FILE = swiperTests/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 8.2; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - PRODUCT_NAME = "$(TARGET_NAME)"; - TEST_HOST = "$(BUILT_PRODUCTS_DIR)/swiper.app/swiper"; - }; - name = Debug; - }; - 00E356F71AD99517003FC87E /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - BUNDLE_LOADER = "$(TEST_HOST)"; - COPY_PHASE_STRIP = NO; - FRAMEWORK_SEARCH_PATHS = ( - "$(SDKROOT)/Developer/Library/Frameworks", - "$(inherited)", - ); - INFOPLIST_FILE = swiperTests/Info.plist; - IPHONEOS_DEPLOYMENT_TARGET = 8.2; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - PRODUCT_NAME = "$(TARGET_NAME)"; - TEST_HOST = "$(BUILT_PRODUCTS_DIR)/swiper.app/swiper"; - }; - name = Release; - }; - 13B07F941A680F5B00A75B9A /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - HEADER_SEARCH_PATHS = ( - "$(inherited)", - /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, - "$(SRCROOT)/node_modules/react-native/React/**", - ); - INFOPLIST_FILE = "iOS/Info.plist"; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - OTHER_LDFLAGS = "-ObjC"; - PRODUCT_NAME = swiper; - }; - name = Debug; - }; - 13B07F951A680F5B00A75B9A /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; - HEADER_SEARCH_PATHS = ( - "$(inherited)", - /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, - "$(SRCROOT)/node_modules/react-native/React/**", - ); - INFOPLIST_FILE = "iOS/Info.plist"; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - OTHER_LDFLAGS = "-ObjC"; - PRODUCT_NAME = swiper; - }; - name = Release; - }; - 83CBBA201A601CBA00E9B192 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - COPY_PHASE_STRIP = NO; - ENABLE_STRICT_OBJC_MSGSEND = YES; - GCC_C_LANGUAGE_STANDARD = gnu99; - GCC_DYNAMIC_NO_PIC = NO; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", - "$(inherited)", - ); - GCC_SYMBOLS_PRIVATE_EXTERN = NO; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - HEADER_SEARCH_PATHS = ( - "$(inherited)", - /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, - "$(SRCROOT)/node_modules/react-native/React/**", - ); - IPHONEOS_DEPLOYMENT_TARGET = 7.0; - MTL_ENABLE_DEBUG_INFO = YES; - ONLY_ACTIVE_ARCH = YES; - SDKROOT = iphoneos; - }; - name = Debug; - }; - 83CBBA211A601CBA00E9B192 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; - COPY_PHASE_STRIP = YES; - ENABLE_NS_ASSERTIONS = NO; - ENABLE_STRICT_OBJC_MSGSEND = YES; - GCC_C_LANGUAGE_STANDARD = gnu99; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - HEADER_SEARCH_PATHS = ( - "$(inherited)", - /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, - "$(SRCROOT)/node_modules/react-native/React/**", - ); - IPHONEOS_DEPLOYMENT_TARGET = 7.0; - MTL_ENABLE_DEBUG_INFO = NO; - SDKROOT = iphoneos; - VALIDATE_PRODUCT = YES; - }; - name = Release; - }; -/* End XCBuildConfiguration section */ - -/* Begin XCConfigurationList section */ - 00E357021AD99517003FC87E /* Build configuration list for PBXNativeTarget "swiperTests" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 00E356F61AD99517003FC87E /* Debug */, - 00E356F71AD99517003FC87E /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 13B07F931A680F5B00A75B9A /* Build configuration list for PBXNativeTarget "swiper" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 13B07F941A680F5B00A75B9A /* Debug */, - 13B07F951A680F5B00A75B9A /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 83CBB9FA1A601CBA00E9B192 /* Build configuration list for PBXProject "swiper" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 83CBBA201A601CBA00E9B192 /* Debug */, - 83CBBA211A601CBA00E9B192 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; -/* End XCConfigurationList section */ - }; - rootObject = 83CBB9F71A601CBA00E9B192 /* Project object */; -} diff --git a/examples.old/swiper.xcodeproj/xcshareddata/xcschemes/swiper.xcscheme b/examples.old/swiper.xcodeproj/xcshareddata/xcschemes/swiper.xcscheme deleted file mode 100644 index fa95ee45..00000000 --- a/examples.old/swiper.xcodeproj/xcshareddata/xcschemes/swiper.xcscheme +++ /dev/null @@ -1,112 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/examples.old/swiperTests/Info.plist b/examples.old/swiperTests/Info.plist deleted file mode 100644 index 886825cc..00000000 --- a/examples.old/swiperTests/Info.plist +++ /dev/null @@ -1,24 +0,0 @@ - - - - - CFBundleDevelopmentRegion - en - CFBundleExecutable - $(EXECUTABLE_NAME) - CFBundleIdentifier - org.reactjs.native.example.$(PRODUCT_NAME:rfc1034identifier) - CFBundleInfoDictionaryVersion - 6.0 - CFBundleName - $(PRODUCT_NAME) - CFBundlePackageType - BNDL - CFBundleShortVersionString - 1.0 - CFBundleSignature - ???? - CFBundleVersion - 1 - - diff --git a/examples.old/swiperTests/swiperTests.m b/examples.old/swiperTests/swiperTests.m deleted file mode 100644 index 224ba8d1..00000000 --- a/examples.old/swiperTests/swiperTests.m +++ /dev/null @@ -1,65 +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. - */ - -#import -#import - -#import "RCTAssert.h" -#import "RCTRedBox.h" -#import "RCTRootView.h" - -#define TIMEOUT_SECONDS 240 -#define TEXT_TO_LOOK_FOR @"Welcome to React Native!" - -@interface swiperTests : XCTestCase - -@end - -@implementation swiperTests - - -- (BOOL)findSubviewInView:(UIView *)view matching:(BOOL(^)(UIView *view))test -{ - if (test(view)) { - return YES; - } - for (UIView *subview in [view subviews]) { - if ([self findSubviewInView:subview matching:test]) { - return YES; - } - } - return NO; -} - -- (void)testRendersWelcomeScreen { - UIViewController *vc = [[[[UIApplication sharedApplication] delegate] window] rootViewController]; - NSDate *date = [NSDate dateWithTimeIntervalSinceNow:TIMEOUT_SECONDS]; - BOOL foundElement = NO; - NSString *redboxError = nil; - - while ([date timeIntervalSinceNow] > 0 && !foundElement && !redboxError) { - [[NSRunLoop mainRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]]; - [[NSRunLoop mainRunLoop] runMode:NSRunLoopCommonModes beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]]; - - redboxError = [[RCTRedBox sharedInstance] currentErrorMessage]; - - foundElement = [self findSubviewInView:vc.view matching:^BOOL(UIView *view) { - if ([view.accessibilityLabel isEqualToString:TEXT_TO_LOOK_FOR]) { - return YES; - } - return NO; - }]; - } - - XCTAssertNil(redboxError, @"RedBox error: %@", redboxError); - XCTAssertTrue(foundElement, @"Couldn't find element with text '%@' in %d seconds", TEXT_TO_LOOK_FOR, TIMEOUT_SECONDS); -} - - -@end diff --git a/examples/.buckconfig b/examples/.buckconfig new file mode 100644 index 00000000..934256cb --- /dev/null +++ b/examples/.buckconfig @@ -0,0 +1,6 @@ + +[android] + target = Google Inc.:Google APIs:23 + +[maven_repositories] + central = https://repo1.maven.org/maven2 diff --git a/examples/.flowconfig b/examples/.flowconfig index 71d9905b..8e838d96 100644 --- a/examples/.flowconfig +++ b/examples/.flowconfig @@ -14,17 +14,19 @@ # Ignore react and fbjs where there are overlaps, but don't ignore # anything that react-native relies on -.*/node_modules/fbjs-haste/.*/__tests__/.* -.*/node_modules/fbjs-haste/__forks__/Map.js -.*/node_modules/fbjs-haste/__forks__/Promise.js -.*/node_modules/fbjs-haste/__forks__/fetch.js -.*/node_modules/fbjs-haste/core/ExecutionEnvironment.js -.*/node_modules/fbjs-haste/core/isEmpty.js -.*/node_modules/fbjs-haste/crypto/crc32.js -.*/node_modules/fbjs-haste/stubs/ErrorUtils.js -.*/node_modules/react-haste/React.js -.*/node_modules/react-haste/renderers/dom/ReactDOM.js -.*/node_modules/react-haste/renderers/shared/event/eventPlugins/ResponderEventPlugin.js +.*/node_modules/fbjs/lib/Map.js +.*/node_modules/fbjs/lib/ErrorUtils.js + +# Flow has a built-in definition for the 'react' module which we prefer to use +# over the currently-untyped source +.*/node_modules/react/react.js +.*/node_modules/react/lib/React.js +.*/node_modules/react/lib/ReactDOM.js + +.*/__mocks__/.* +.*/__tests__/.* + +.*/commoner/test/source/widget/share.js # Ignore commoner tests .*/node_modules/commoner/test/.* @@ -38,26 +40,55 @@ # Ignore Website .*/website/.* +# Ignore generators +.*/local-cli/generator.* + +# Ignore BUCK generated folders +.*\.buckd/ + +.*/node_modules/is-my-json-valid/test/.*\.json +.*/node_modules/iconv-lite/encodings/tables/.*\.json +.*/node_modules/y18n/test/.*\.json +.*/node_modules/spdx-license-ids/spdx-license-ids.json +.*/node_modules/spdx-exceptions/index.json +.*/node_modules/resolve/test/subdirs/node_modules/a/b/c/x.json +.*/node_modules/resolve/lib/core.json +.*/node_modules/jsonparse/samplejson/.*\.json +.*/node_modules/json5/test/.*\.json +.*/node_modules/ua-parser-js/test/.*\.json +.*/node_modules/builtin-modules/builtin-modules.json +.*/node_modules/binary-extensions/binary-extensions.json +.*/node_modules/url-regex/tlds.json +.*/node_modules/joi/.*\.json +.*/node_modules/isemail/.*\.json +.*/node_modules/tr46/.*\.json + + [include] [libs] node_modules/react-native/Libraries/react-native/react-native-interface.js +node_modules/react-native/flow +flow/ [options] module.system=haste +esproposal.class_static_fields=enable +esproposal.class_instance_fields=enable + munge_underscores=true module.name_mapper='^image![a-zA-Z0-9$_-]+$' -> 'GlobalImageStub' -module.name_mapper='^[./a-zA-Z0-9$_-]+\.png$' -> 'RelativeImageStub' +module.name_mapper='^[./a-zA-Z0-9$_-]+\.\(bmp\|gif\|jpg\|jpeg\|png\|psd\|svg\|webp\|m4v\|mov\|mp4\|mpeg\|mpg\|webm\|aac\|aiff\|caf\|m4a\|mp3\|wav\|html\|pdf\)$' -> 'RelativeImageStub' suppress_type=$FlowIssue suppress_type=$FlowFixMe suppress_type=$FixMe -suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(1[0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\) -suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(1[0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)? #[0-9]+ +suppress_comment=\\(.\\|\n\\)*\\$FlowFixMe\\($\\|[^(]\\|(\\(>=0\\.\\(2[0-4]\\|1[0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\) +suppress_comment=\\(.\\|\n\\)*\\$FlowIssue\\((\\(>=0\\.\\(2[0-4]\\|1[0-9]\\|[0-9]\\).[0-9]\\)? *\\(site=[a-z,_]*react_native[a-z,_]*\\)?)\\)?:? #[0-9]+ suppress_comment=\\(.\\|\n\\)*\\$FlowFixedInNextDeploy [version] -0.19.0 +0.24.0 diff --git a/examples/.gitignore b/examples/.gitignore index 94fc8671..42c9490e 100644 --- a/examples/.gitignore +++ b/examples/.gitignore @@ -32,3 +32,9 @@ local.properties # node_modules/ npm-debug.log + +# BUCK +buck-out/ +\.buckd/ +android/app/libs +android/keystores/debug.keystore diff --git a/examples/android/app/BUCK b/examples/android/app/BUCK new file mode 100644 index 00000000..545cb05b --- /dev/null +++ b/examples/android/app/BUCK @@ -0,0 +1,66 @@ +import re + +# To learn about Buck see [Docs](https://buckbuild.com/). +# To run your application with Buck: +# - install Buck +# - `npm start` - to start the packager +# - `cd android` +# - `keytool -genkey -v -keystore keystores/debug.keystore -storepass android -alias androiddebugkey -keypass android -dname "CN=Android Debug,O=Android,C=US` +# - `./gradlew :app:copyDownloadableDepsToLibs` - make all Gradle compile dependencies available to Buck +# - `buck install -r android/app` - compile, install and run application +# + +lib_deps = [] +for jarfile in glob(['libs/*.jar']): + name = 'jars__' + re.sub(r'^.*/([^/]+)\.jar$', r'\1', jarfile) + lib_deps.append(':' + name) + prebuilt_jar( + name = name, + binary_jar = jarfile, + ) + +for aarfile in glob(['libs/*.aar']): + name = 'aars__' + re.sub(r'^.*/([^/]+)\.aar$', r'\1', aarfile) + lib_deps.append(':' + name) + android_prebuilt_aar( + name = name, + aar = aarfile, + ) + +android_library( + name = 'all-libs', + exported_deps = lib_deps +) + +android_library( + name = 'app-code', + srcs = glob([ + 'src/main/java/**/*.java', + ]), + deps = [ + ':all-libs', + ':build_config', + ':res', + ], +) + +android_build_config( + name = 'build_config', + package = 'com.swiper', +) + +android_resource( + name = 'res', + res = 'src/main/res', + package = 'com.swiper', +) + +android_binary( + name = 'app', + package_type = 'debug', + manifest = 'src/main/AndroidManifest.xml', + keystore = '//android/keystores:debug', + deps = [ + ':app-code', + ], +) diff --git a/examples/android/app/build.gradle b/examples/android/app/build.gradle index e291746e..316ec4c6 100644 --- a/examples/android/app/build.gradle +++ b/examples/android/app/build.gradle @@ -1,12 +1,15 @@ apply plugin: "com.android.application" +import com.android.build.OutputFile + /** - * The react.gradle file registers two tasks: bundleDebugJsAndAssets and bundleReleaseJsAndAssets. + * The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets + * and bundleReleaseJsAndAssets). * These basically call `react-native bundle` with the correct arguments during the Android build * cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the * bundle directly from the development server. Below you can see all the possible configurations * and their defaults. If you decide to add a configuration block, make sure to add it before the - * `apply from: "react.gradle"` line. + * `apply from: "../../node_modules/react-native/react.gradle"` line. * * project.ext.react = [ * // the name of the generated asset file containing your JS bundle @@ -21,6 +24,15 @@ apply plugin: "com.android.application" * // whether to bundle JS and assets in release mode * bundleInRelease: true, * + * // whether to bundle JS and assets in another build variant (if configured). + * // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants + * // The configuration property can be in the following formats + * // 'bundleIn${productFlavor}${buildType}' + * // 'bundleIn${buildType}' + * // bundleInFreeDebug: true, + * // bundleInPaidRelease: true, + * // bundleInBeta: true, + * * // the root of your project, i.e. where "package.json" lives * root: "../../", * @@ -47,7 +59,22 @@ apply plugin: "com.android.application" * ] */ -apply from: "react.gradle" +apply from: "../../node_modules/react-native/react.gradle" + +/** + * Set this to true to create two separate APKs instead of one: + * - An APK that only works on ARM devices + * - An APK that only works on x86 devices + * The advantage is the size of the APK is reduced by about 4MB. + * Upload all the APKs to the Play Store and people will download + * the correct one based on the CPU architecture of their device. + */ +def enableSeparateBuildPerCPUArchitecture = false + +/** + * Run Proguard to shrink the Java bytecode in release builds. + */ +def enableProguardInReleaseBuilds = false android { compileSdkVersion 23 @@ -63,16 +90,44 @@ android { abiFilters "armeabi-v7a", "x86" } } + splits { + abi { + reset() + enable enableSeparateBuildPerCPUArchitecture + universalApk false // If true, also generate a universal APK + include "armeabi-v7a", "x86" + } + } buildTypes { release { - minifyEnabled false // Set this to true to enable Proguard + minifyEnabled enableProguardInReleaseBuilds proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" } } + // applicationVariants are e.g. debug, release + applicationVariants.all { variant -> + variant.outputs.each { output -> + // For each separate APK per architecture, set a unique version code as described here: + // http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits + def versionCodes = ["armeabi-v7a":1, "x86":2] + def abi = output.getFilter(OutputFile.ABI) + if (abi != null) { // null for the universal-debug, universal-release variants + output.versionCodeOverride = + versionCodes.get(abi) * 1048576 + defaultConfig.versionCode + } + } + } } dependencies { compile fileTree(dir: "libs", include: ["*.jar"]) compile "com.android.support:appcompat-v7:23.0.1" - compile "com.facebook.react:react-native:0.17.+" + compile "com.facebook.react:react-native:+" // From node_modules +} + +// Run this once to be able to run the application with BUCK +// puts all compile dependencies into folder libs for BUCK to use +task copyDownloadableDepsToLibs(type: Copy) { + from configurations.compile + into 'libs' } diff --git a/examples/android/app/proguard-rules.pro b/examples/android/app/proguard-rules.pro index ffa8c9f6..347a13ce 100644 --- a/examples/android/app/proguard-rules.pro +++ b/examples/android/app/proguard-rules.pro @@ -40,9 +40,12 @@ -keep class * extends com.facebook.react.bridge.JavaScriptModule { *; } -keep class * extends com.facebook.react.bridge.NativeModule { *; } +-keepclassmembers,includedescriptorclasses class * { native ; } -keepclassmembers class * { @com.facebook.react.uimanager.UIProp ; } --keepclassmembers class * { @com.facebook.react.uimanager.ReactProp ; } --keepclassmembers class * { @com.facebook.react.uimanager.ReactPropGroup ; } +-keepclassmembers class * { @com.facebook.react.uimanager.annotations.ReactProp ; } +-keepclassmembers class * { @com.facebook.react.uimanager.annotations.ReactPropGroup ; } + +-dontwarn com.facebook.react.** # okhttp diff --git a/examples/android/app/src/main/java/com/swiper/MainActivity.java b/examples/android/app/src/main/java/com/swiper/MainActivity.java index 048098b0..fd4569b8 100644 --- a/examples/android/app/src/main/java/com/swiper/MainActivity.java +++ b/examples/android/app/src/main/java/com/swiper/MainActivity.java @@ -1,78 +1,40 @@ package com.swiper; -import android.app.Activity; -import android.os.Bundle; -import android.view.KeyEvent; - -import com.facebook.react.LifecycleState; -import com.facebook.react.ReactInstanceManager; -import com.facebook.react.ReactRootView; -import com.facebook.react.modules.core.DefaultHardwareBackBtnHandler; +import com.facebook.react.ReactActivity; +import com.facebook.react.ReactPackage; import com.facebook.react.shell.MainReactPackage; -import com.facebook.soloader.SoLoader; - -public class MainActivity extends Activity implements DefaultHardwareBackBtnHandler { - - private ReactInstanceManager mReactInstanceManager; - private ReactRootView mReactRootView; - - @Override - protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - mReactRootView = new ReactRootView(this); - - mReactInstanceManager = ReactInstanceManager.builder() - .setApplication(getApplication()) - .setBundleAssetName("index.android.bundle") - .setJSMainModuleName("index.android") - .addPackage(new MainReactPackage()) - .setUseDeveloperSupport(BuildConfig.DEBUG) - .setInitialLifecycleState(LifecycleState.RESUMED) - .build(); - mReactRootView.startReactApplication(mReactInstanceManager, "swiper", null); +import java.util.Arrays; +import java.util.List; - setContentView(mReactRootView); - } +public class MainActivity extends ReactActivity { + /** + * Returns the name of the main component registered from JavaScript. + * This is used to schedule rendering of the component. + */ @Override - public boolean onKeyUp(int keyCode, KeyEvent event) { - if (keyCode == KeyEvent.KEYCODE_MENU && mReactInstanceManager != null) { - mReactInstanceManager.showDevOptionsDialog(); - return true; - } - return super.onKeyUp(keyCode, event); + protected String getMainComponentName() { + return "swiper"; } + /** + * Returns whether dev mode should be enabled. + * This enables e.g. the dev menu. + */ @Override - public void onBackPressed() { - if (mReactInstanceManager != null) { - mReactInstanceManager.onBackPressed(); - } else { - super.onBackPressed(); - } + protected boolean getUseDeveloperSupport() { + return BuildConfig.DEBUG; } + /** + * A list of packages used by the app. If the app uses additional views + * or modules besides the default ones, add more packages here. + */ @Override - public void invokeDefaultOnBackPressed() { - super.onBackPressed(); - } - - @Override - protected void onPause() { - super.onPause(); - - if (mReactInstanceManager != null) { - mReactInstanceManager.onPause(); - } - } - - @Override - protected void onResume() { - super.onResume(); - - if (mReactInstanceManager != null) { - mReactInstanceManager.onResume(this, this); - } + protected List getPackages() { + return Arrays.asList( + new MainReactPackage() + ); } } diff --git a/examples/android/build.gradle b/examples/android/build.gradle index ccdfc4e3..403a0075 100644 --- a/examples/android/build.gradle +++ b/examples/android/build.gradle @@ -16,5 +16,9 @@ allprojects { repositories { mavenLocal() jcenter() + maven { + // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm + url "$projectDir/../../node_modules/react-native/android" + } } } diff --git a/examples/examples/basic.js b/examples/examples/basic.js index 6990b700..54d44700 100644 --- a/examples/examples/basic.js +++ b/examples/examples/basic.js @@ -1,10 +1,11 @@ -var React = require('react-native') +var React = require('react') +var ReactNative = require('react-native') var Swiper = require('./') var { StyleSheet, Text, View, -} = React +} = ReactNative var styles = StyleSheet.create({ wrapper: { diff --git a/examples/examples/dynamic.js b/examples/examples/dynamic.js index f2b438f2..b7da13f1 100644 --- a/examples/examples/dynamic.js +++ b/examples/examples/dynamic.js @@ -1,10 +1,11 @@ -var React = require('react-native') +var React = require('react') +var ReactNative = require('react-native') var Swiper = require('./') var { StyleSheet, Text, View, -} = React +} = ReactNative var styles = StyleSheet.create({ wrapper: { @@ -49,9 +50,9 @@ var swiper = React.createClass({ render: function() { return( - {this.state.items.map(function(item){ + {this.state.items.map((item, key) => { return ( - + {item.title} ); diff --git a/examples/examples/index.js b/examples/examples/index.js index 737f77dd..59a9906a 100644 --- a/examples/examples/index.js +++ b/examples/examples/index.js @@ -5,12 +5,18 @@ var _extends = Object.assign || function (target) { for (var i = 1; i < argument * @author leecade */ + // Using bare setTimeout, setInterval, setImmediate // and requestAnimationFrame calls is very dangerous // because if you forget to cancel the request before // the component is unmounted, you risk the callback // throwing an exception. + +var _react = require('react'); + +var _react2 = _interopRequireDefault(_react); + var _reactNative = require('react-native'); var _reactNative2 = _interopRequireDefault(_reactNative); @@ -103,32 +109,33 @@ var styles = _reactNative.StyleSheet.create({ // missing `module.exports = exports['default'];` with babel6 // export default React.createClass({ -module.exports = _reactNative2.default.createClass({ +module.exports = _react2.default.createClass({ displayName: 'exports', + /** * Props Validation * @type {Object} */ propTypes: { - horizontal: _reactNative2.default.PropTypes.bool, - children: _reactNative2.default.PropTypes.node.isRequired, + horizontal: _react2.default.PropTypes.bool, + children: _react2.default.PropTypes.node.isRequired, style: _reactNative.View.propTypes.style, - pagingEnabled: _reactNative2.default.PropTypes.bool, - showsHorizontalScrollIndicator: _reactNative2.default.PropTypes.bool, - showsVerticalScrollIndicator: _reactNative2.default.PropTypes.bool, - bounces: _reactNative2.default.PropTypes.bool, - scrollsToTop: _reactNative2.default.PropTypes.bool, - removeClippedSubviews: _reactNative2.default.PropTypes.bool, - automaticallyAdjustContentInsets: _reactNative2.default.PropTypes.bool, - showsPagination: _reactNative2.default.PropTypes.bool, - showsButtons: _reactNative2.default.PropTypes.bool, - loop: _reactNative2.default.PropTypes.bool, - autoplay: _reactNative2.default.PropTypes.bool, - autoplayTimeout: _reactNative2.default.PropTypes.number, - autoplayDirection: _reactNative2.default.PropTypes.bool, - index: _reactNative2.default.PropTypes.number, - renderPagination: _reactNative2.default.PropTypes.func + pagingEnabled: _react2.default.PropTypes.bool, + showsHorizontalScrollIndicator: _react2.default.PropTypes.bool, + showsVerticalScrollIndicator: _react2.default.PropTypes.bool, + bounces: _react2.default.PropTypes.bool, + scrollsToTop: _react2.default.PropTypes.bool, + removeClippedSubviews: _react2.default.PropTypes.bool, + automaticallyAdjustContentInsets: _react2.default.PropTypes.bool, + showsPagination: _react2.default.PropTypes.bool, + showsButtons: _react2.default.PropTypes.bool, + loop: _react2.default.PropTypes.bool, + autoplay: _react2.default.PropTypes.bool, + autoplayTimeout: _react2.default.PropTypes.number, + autoplayDirection: _react2.default.PropTypes.bool, + index: _react2.default.PropTypes.number, + renderPagination: _react2.default.PropTypes.func }, mixins: [_reactTimerMixin2.default], @@ -158,6 +165,7 @@ module.exports = _reactNative2.default.createClass({ }; }, + /** * Init states * @return {object} states @@ -166,6 +174,7 @@ module.exports = _reactNative2.default.createClass({ return this.initState(this.props); }, + /** * autoplay timer * @type {null} @@ -197,12 +206,16 @@ module.exports = _reactNative2.default.createClass({ initState.offset = {}; if (initState.total > 1) { - var setup = props.loop ? 1 : initState.index; + var setup = initState.index; + if (props.loop) { + setup++; + } initState.offset[initState.dir] = initState.dir == 'y' ? initState.height * setup : initState.width * setup; } return initState; }, + /** * Automatic rolling */ @@ -221,6 +234,7 @@ module.exports = _reactNative2.default.createClass({ }, this.props.autoplayTimeout * 1000); }, + /** * Scroll begin handle * @param {object} e native event @@ -238,6 +252,7 @@ module.exports = _reactNative2.default.createClass({ }); }, + /** * Scroll end handle * @param {object} e native event @@ -250,6 +265,15 @@ module.exports = _reactNative2.default.createClass({ isScrolling: false }); + // making our events coming from android compatible to updateIndex logic + if (!e.nativeEvent.contentOffset) { + if (this.state.dir == 'x') { + e.nativeEvent.contentOffset = { x: e.nativeEvent.position * this.state.width }; + } else { + e.nativeEvent.contentOffset = { y: e.nativeEvent.position * this.state.height }; + } + } + this.updateIndex(e.nativeEvent.contentOffset, this.state.dir); // Note: `this.setState` is async, so I call the `onMomentumScrollEnd` @@ -262,6 +286,7 @@ module.exports = _reactNative2.default.createClass({ }); }, + /** * Update index after scroll * @param {object} offset content offset @@ -297,11 +322,14 @@ module.exports = _reactNative2.default.createClass({ }); }, + /** * Scroll by index * @param {number} index offset index */ scrollTo: function scrollTo(index) { + var _this4 = this; + if (this.state.isScrolling || this.state.total < 2) return; var state = this.state; var diff = (this.props.loop ? 1 : 0) + index + this.state.index; @@ -309,15 +337,35 @@ module.exports = _reactNative2.default.createClass({ var y = 0; if (state.dir == 'x') x = diff * state.width; if (state.dir == 'y') y = diff * state.height; - this.refs.scrollView && this.refs.scrollView.scrollTo(y, x); + + if (_reactNative.Platform.OS === 'android') { + this.refs.scrollView && this.refs.scrollView.setPage(diff); + } else { + this.refs.scrollView && this.refs.scrollView.scrollTo({ + y: y, + x: x + }); + } // update scroll state this.setState({ isScrolling: true, autoplayEnd: false }); + + // trigger onScrollEnd manually in android + if (_reactNative.Platform.OS === 'android') { + this.setTimeout(function () { + _this4.onScrollEnd({ + nativeEvent: { + position: diff + } + }); + }, 50); + } }, + /** * Render pagination * @return {object} react-dom @@ -328,7 +376,7 @@ module.exports = _reactNative2.default.createClass({ if (this.state.total <= 1) return null; var dots = []; - var ActiveDot = this.props.activeDot || _reactNative2.default.createElement(_reactNative.View, { style: { + var ActiveDot = this.props.activeDot || _react2.default.createElement(_reactNative.View, { style: { backgroundColor: '#007aff', width: 8, height: 8, @@ -338,7 +386,7 @@ module.exports = _reactNative2.default.createClass({ marginTop: 3, marginBottom: 3 } }); - var Dot = this.props.dot || _reactNative2.default.createElement(_reactNative.View, { style: { + var Dot = this.props.dot || _react2.default.createElement(_reactNative.View, { style: { backgroundColor: 'rgba(0,0,0,.2)', width: 8, height: 8, @@ -349,10 +397,10 @@ module.exports = _reactNative2.default.createClass({ marginBottom: 3 } }); for (var i = 0; i < this.state.total; i++) { - dots.push(i === this.state.index ? _reactNative2.default.cloneElement(ActiveDot, { key: i }) : _reactNative2.default.cloneElement(Dot, { key: i })); + dots.push(i === this.state.index ? _react2.default.cloneElement(ActiveDot, { key: i }) : _react2.default.cloneElement(Dot, { key: i })); } - return _reactNative2.default.createElement( + return _react2.default.createElement( _reactNative.View, { pointerEvents: 'none', style: [styles['pagination_' + this.state.dir], this.props.paginationStyle] }, dots @@ -361,31 +409,31 @@ module.exports = _reactNative2.default.createClass({ renderTitle: function renderTitle() { var child = this.props.children[this.state.index]; var title = child && child.props.title; - return title ? _reactNative2.default.createElement( + return title ? _react2.default.createElement( _reactNative.View, { style: styles.title }, this.props.children[this.state.index].props.title ) : null; }, renderNextButton: function renderNextButton() { - var _this4 = this; + var _this5 = this; - var button = undefined; + var button = void 0; if (this.props.loop || this.state.index != this.state.total - 1) { - button = this.props.nextButton || _reactNative2.default.createElement( + button = this.props.nextButton || _react2.default.createElement( _reactNative.Text, { style: styles.buttonText }, '›' ); } - return _reactNative2.default.createElement( + return _react2.default.createElement( _reactNative.TouchableOpacity, { onPress: function onPress() { - return button !== null && _this4.scrollTo.call(_this4, 1); + return button !== null && _this5.scrollTo.call(_this5, 1); } }, - _reactNative2.default.createElement( + _react2.default.createElement( _reactNative.View, null, button @@ -393,24 +441,24 @@ module.exports = _reactNative2.default.createClass({ ); }, renderPrevButton: function renderPrevButton() { - var _this5 = this; + var _this6 = this; var button = null; if (this.props.loop || this.state.index != 0) { - button = this.props.prevButton || _reactNative2.default.createElement( + button = this.props.prevButton || _react2.default.createElement( _reactNative.Text, { style: styles.buttonText }, '‹' ); } - return _reactNative2.default.createElement( + return _react2.default.createElement( _reactNative.TouchableOpacity, { onPress: function onPress() { - return button !== null && _this5.scrollTo.call(_this5, -1); + return button !== null && _this6.scrollTo.call(_this6, -1); } }, - _reactNative2.default.createElement( + _react2.default.createElement( _reactNative.View, null, button @@ -418,7 +466,7 @@ module.exports = _reactNative2.default.createClass({ ); }, renderButtons: function renderButtons() { - return _reactNative2.default.createElement( + return _react2.default.createElement( _reactNative.View, { pointerEvents: 'box-none', style: [styles.buttonWrapper, { width: this.state.width, height: this.state.height }, this.props.buttonWrapperStyle] }, this.renderPrevButton(), @@ -426,7 +474,7 @@ module.exports = _reactNative2.default.createClass({ ); }, renderScrollView: function renderScrollView(pages) { - if (_reactNative.Platform.OS === 'ios') return _reactNative2.default.createElement( + if (_reactNative.Platform.OS === 'ios') return _react2.default.createElement( _reactNative.ScrollView, _extends({ ref: 'scrollView' }, this.props, { @@ -436,10 +484,13 @@ module.exports = _reactNative2.default.createClass({ onMomentumScrollEnd: this.onScrollEnd }), pages ); - return _reactNative2.default.createElement( + return _react2.default.createElement( _reactNative.ViewPagerAndroid, - { ref: 'scrollView', - style: { flex: 1 } }, + _extends({ ref: 'scrollView' + }, this.props, { + initialPage: this.state.index, + onPageSelected: this.onScrollEnd, + style: { flex: 1 } }), pages ); }, @@ -450,7 +501,7 @@ module.exports = _reactNative2.default.createClass({ * @return {object} props injected props */ injectState: function injectState(props) { - var _this6 = this; + var _this7 = this; /* const scrollResponders = [ 'onMomentumScrollBegin', @@ -466,7 +517,7 @@ module.exports = _reactNative2.default.createClass({ (function () { var originResponder = props[prop]; props[prop] = function (e) { - return originResponder(e, _this6.state, _this6); + return originResponder(e, _this7.state, _this7); }; })(); } @@ -475,6 +526,7 @@ module.exports = _reactNative2.default.createClass({ return props; }, + /** * Default render * @return {object} react-dom @@ -503,19 +555,19 @@ module.exports = _reactNative2.default.createClass({ } pages = pages.map(function (page, i) { - return _reactNative2.default.createElement( + return _react2.default.createElement( _reactNative.View, { style: pageStyle, key: i }, children[page] ); }); - } else pages = _reactNative2.default.createElement( + } else pages = _react2.default.createElement( _reactNative.View, { style: pageStyle }, children ); - return _reactNative2.default.createElement( + return _react2.default.createElement( _reactNative.View, { style: [styles.container, { width: state.width, @@ -527,4 +579,4 @@ module.exports = _reactNative2.default.createClass({ this.props.showsButtons && this.renderButtons() ); } -}); +}); \ No newline at end of file diff --git a/examples/examples/phone.js b/examples/examples/phone.js index f125bfe8..918dbee6 100644 --- a/examples/examples/phone.js +++ b/examples/examples/phone.js @@ -1,11 +1,12 @@ -var React = require('react-native') +var React = require('react') +var ReactNative = require('react-native') var Swiper = require('./') var { StyleSheet, Text, View, Image, -} = React +} = ReactNative var styles = StyleSheet.create({ wrapper: { diff --git a/examples/examples/swiper.js b/examples/examples/swiper.js index ef9a2f46..1843f14b 100644 --- a/examples/examples/swiper.js +++ b/examples/examples/swiper.js @@ -1,11 +1,12 @@ -var React = require('react-native') +var React = require('react') +var ReactNative = require('react-native') var Swiper = require('./') var { StyleSheet, Text, View, Image, -} = React +} = ReactNative var styles = StyleSheet.create({ wrapper: { diff --git a/examples/examples/swiper_number.js b/examples/examples/swiper_number.js index 8f0144e2..2b0b11d9 100644 --- a/examples/examples/swiper_number.js +++ b/examples/examples/swiper_number.js @@ -1,11 +1,12 @@ -var React = require('react-native') +var React = require('react') +var ReactNative = require('react-native') var Swiper = require('./') var { StyleSheet, Text, View, Image, -} = React +} = ReactNative var styles = StyleSheet.create({ wrapper: { diff --git a/examples/index.android.js b/examples/index.android.js index 8af20a88..9bc3e763 100644 --- a/examples/index.android.js +++ b/examples/index.android.js @@ -1,52 +1,14 @@ -/** - * Sample React Native App - * https://github.com/facebook/react-native - */ -'use strict'; +'use strict' -var React = require('react-native'); +var ReactNative = require('react-native') var { AppRegistry, - StyleSheet, - Text, - View, -} = React; +} = ReactNative -var swiper = React.createClass({ - render: function() { - return ( - - - Welcome to React Native! - - - To get started, edit index.android.js - - - Shake or press menu button for dev menu - - - ); - } -}); +var swiper = require('./examples/basic') +// var swiper = require('./examples/swiper') +// var swiper = require('./examples/swiper_number') +// var swiper = require('./examples/phone') +// var swiper = require('./examples/dynamic') -var styles = StyleSheet.create({ - container: { - flex: 1, - justifyContent: 'center', - alignItems: 'center', - backgroundColor: '#F5FCFF', - }, - welcome: { - fontSize: 20, - textAlign: 'center', - margin: 10, - }, - instructions: { - textAlign: 'center', - color: '#333333', - marginBottom: 5, - }, -}); - -AppRegistry.registerComponent('swiper', () => swiper); +AppRegistry.registerComponent('swiper', () => swiper) diff --git a/examples/index.ios.js b/examples/index.ios.js index 65dc9bd9..9bc3e763 100644 --- a/examples/index.ios.js +++ b/examples/index.ios.js @@ -1,9 +1,9 @@ 'use strict' -var React = require('react-native') +var ReactNative = require('react-native') var { AppRegistry, -} = React +} = ReactNative var swiper = require('./examples/basic') // var swiper = require('./examples/swiper') diff --git a/examples/ios/swiper.xcodeproj/project.pbxproj b/examples/ios/swiper.xcodeproj/project.pbxproj index 3445fcba..2fc0ee82 100644 --- a/examples/ios/swiper.xcodeproj/project.pbxproj +++ b/examples/ios/swiper.xcodeproj/project.pbxproj @@ -525,7 +525,7 @@ ); runOnlyForDeploymentPostprocessing = 0; shellPath = /bin/sh; - shellScript = "../node_modules/react-native/packager/react-native-xcode.sh"; + shellScript = "export NODE_BINARY=node\n../node_modules/react-native/packager/react-native-xcode.sh"; showEnvVarsInLog = 1; }; /* End PBXShellScriptBuildPhase section */ @@ -575,10 +575,6 @@ isa = XCBuildConfiguration; buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; - FRAMEWORK_SEARCH_PATHS = ( - "$(SDKROOT)/Developer/Library/Frameworks", - "$(inherited)", - ); GCC_PREPROCESSOR_DEFINITIONS = ( "DEBUG=1", "$(inherited)", @@ -596,10 +592,6 @@ buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; COPY_PHASE_STRIP = NO; - FRAMEWORK_SEARCH_PATHS = ( - "$(SDKROOT)/Developer/Library/Frameworks", - "$(inherited)", - ); INFOPLIST_FILE = swiperTests/Info.plist; IPHONEOS_DEPLOYMENT_TARGET = 8.2; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; @@ -620,7 +612,10 @@ ); INFOPLIST_FILE = "swiper/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - OTHER_LDFLAGS = "-ObjC"; + OTHER_LDFLAGS = ( + "-ObjC", + "-lc++", + ); PRODUCT_NAME = swiper; }; name = Debug; @@ -636,7 +631,10 @@ ); INFOPLIST_FILE = "swiper/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - OTHER_LDFLAGS = "-ObjC"; + OTHER_LDFLAGS = ( + "-ObjC", + "-lc++", + ); PRODUCT_NAME = swiper; }; name = Release; diff --git a/examples/ios/swiper/AppDelegate.m b/examples/ios/swiper/AppDelegate.m index 75cdab69..62ed99fd 100644 --- a/examples/ios/swiper/AppDelegate.m +++ b/examples/ios/swiper/AppDelegate.m @@ -36,7 +36,9 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:( /** * OPTION 2 * Load from pre-bundled file on disk. The static bundle is automatically - * generated by "Bundle React Native code and images" build step. + * generated by the "Bundle React Native code and images" build step when + * running the project on an actual device or running the project on the + * simulator in the "Release" build configuration. */ // jsCodeLocation = [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"]; diff --git a/examples/ios/swiperTests/swiperTests.m b/examples/ios/swiperTests/swiperTests.m index eeafaa37..39508966 100644 --- a/examples/ios/swiperTests/swiperTests.m +++ b/examples/ios/swiperTests/swiperTests.m @@ -13,7 +13,7 @@ #import "RCTLog.h" #import "RCTRootView.h" -#define TIMEOUT_SECONDS 240 +#define TIMEOUT_SECONDS 600 #define TEXT_TO_LOOK_FOR @"Welcome to React Native!" @interface swiperTests : XCTestCase diff --git a/examples/node_modules/react-native/LICENSE b/examples/node_modules/react-native/LICENSE deleted file mode 100644 index 8085fec4..00000000 --- a/examples/node_modules/react-native/LICENSE +++ /dev/null @@ -1,30 +0,0 @@ -BSD License - -For React Native software - -Copyright (c) 2015-present, Facebook, Inc. All rights reserved. - -Redistribution and use in source and binary forms, with or without modification, -are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * Redistributions in binary form must reproduce the above copyright notice, - this list of conditions and the following disclaimer in the documentation - and/or other materials provided with the distribution. - - * Neither the name Facebook nor the names of its contributors may be used to - endorse or promote products derived from this software without specific - prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND -ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED -WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE -DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR -ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES -(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; -LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON -ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS -SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/examples/node_modules/react-native/Libraries/ActionSheetIOS/ActionSheetIOS.js b/examples/node_modules/react-native/Libraries/ActionSheetIOS/ActionSheetIOS.js deleted file mode 100644 index c6361844..00000000 --- a/examples/node_modules/react-native/Libraries/ActionSheetIOS/ActionSheetIOS.js +++ /dev/null @@ -1,60 +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. - * - * @providesModule ActionSheetIOS - * @flow - */ -'use strict'; - -var RCTActionSheetManager = require('NativeModules').ActionSheetManager; - -var invariant = require('invariant'); -var processColor = require('processColor'); - -var ActionSheetIOS = { - showActionSheetWithOptions(options: Object, callback: Function) { - invariant( - typeof options === 'object' && options !== null, - 'Options must a valid object' - ); - invariant( - typeof callback === 'function', - 'Must provide a valid callback' - ); - RCTActionSheetManager.showActionSheetWithOptions( - {...options, tintColor: processColor(options.tintColor)}, - callback - ); - }, - - showShareActionSheetWithOptions( - options: Object, - failureCallback: Function, - successCallback: Function - ) { - invariant( - typeof options === 'object' && options !== null, - 'Options must a valid object' - ); - invariant( - typeof failureCallback === 'function', - 'Must provide a valid failureCallback' - ); - invariant( - typeof successCallback === 'function', - 'Must provide a valid successCallback' - ); - RCTActionSheetManager.showShareActionSheetWithOptions( - {...options, tintColor: processColor(options.tintColor)}, - failureCallback, - successCallback - ); - } -}; - -module.exports = ActionSheetIOS; diff --git a/examples/node_modules/react-native/Libraries/ActionSheetIOS/RCTActionSheet.xcodeproj/project.pbxproj b/examples/node_modules/react-native/Libraries/ActionSheetIOS/RCTActionSheet.xcodeproj/project.pbxproj deleted file mode 100644 index ba116104..00000000 --- a/examples/node_modules/react-native/Libraries/ActionSheetIOS/RCTActionSheet.xcodeproj/project.pbxproj +++ /dev/null @@ -1,268 +0,0 @@ -// !$*UTF8*$! -{ - archiveVersion = 1; - classes = { - }; - objectVersion = 46; - objects = { - -/* Begin PBXBuildFile section */ - 14C644C41AB0DFC900DE3C65 /* RCTActionSheetManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 14C644C21AB0DFC900DE3C65 /* RCTActionSheetManager.m */; }; -/* End PBXBuildFile section */ - -/* Begin PBXCopyFilesBuildPhase section */ - 58B511D91A9E6C8500147676 /* CopyFiles */ = { - isa = PBXCopyFilesBuildPhase; - buildActionMask = 2147483647; - dstPath = "include/$(PRODUCT_NAME)"; - dstSubfolderSpec = 16; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXCopyFilesBuildPhase section */ - -/* Begin PBXFileReference section */ - 134814201AA4EA6300B7C361 /* libRCTActionSheet.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRCTActionSheet.a; sourceTree = BUILT_PRODUCTS_DIR; }; - 14C644C11AB0DFC900DE3C65 /* RCTActionSheetManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTActionSheetManager.h; sourceTree = ""; }; - 14C644C21AB0DFC900DE3C65 /* RCTActionSheetManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTActionSheetManager.m; sourceTree = ""; }; -/* End PBXFileReference section */ - -/* Begin PBXFrameworksBuildPhase section */ - 58B511D81A9E6C8500147676 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXFrameworksBuildPhase section */ - -/* Begin PBXGroup section */ - 134814211AA4EA7D00B7C361 /* Products */ = { - isa = PBXGroup; - children = ( - 134814201AA4EA6300B7C361 /* libRCTActionSheet.a */, - ); - name = Products; - sourceTree = ""; - }; - 58B511D21A9E6C8500147676 = { - isa = PBXGroup; - children = ( - 14C644C11AB0DFC900DE3C65 /* RCTActionSheetManager.h */, - 14C644C21AB0DFC900DE3C65 /* RCTActionSheetManager.m */, - 134814211AA4EA7D00B7C361 /* Products */, - ); - indentWidth = 2; - sourceTree = ""; - tabWidth = 2; - }; -/* End PBXGroup section */ - -/* Begin PBXNativeTarget section */ - 58B511DA1A9E6C8500147676 /* RCTActionSheet */ = { - isa = PBXNativeTarget; - buildConfigurationList = 58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "RCTActionSheet" */; - buildPhases = ( - 58B511D71A9E6C8500147676 /* Sources */, - 58B511D81A9E6C8500147676 /* Frameworks */, - 58B511D91A9E6C8500147676 /* CopyFiles */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = RCTActionSheet; - productName = RCTDataManager; - productReference = 134814201AA4EA6300B7C361 /* libRCTActionSheet.a */; - productType = "com.apple.product-type.library.static"; - }; -/* End PBXNativeTarget section */ - -/* Begin PBXProject section */ - 58B511D31A9E6C8500147676 /* Project object */ = { - isa = PBXProject; - attributes = { - LastUpgradeCheck = 0610; - ORGANIZATIONNAME = Facebook; - TargetAttributes = { - 58B511DA1A9E6C8500147676 = { - CreatedOnToolsVersion = 6.1.1; - }; - }; - }; - buildConfigurationList = 58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "RCTActionSheet" */; - compatibilityVersion = "Xcode 3.2"; - developmentRegion = English; - hasScannedForEncodings = 0; - knownRegions = ( - en, - ); - mainGroup = 58B511D21A9E6C8500147676; - productRefGroup = 58B511D21A9E6C8500147676; - projectDirPath = ""; - projectRoot = ""; - targets = ( - 58B511DA1A9E6C8500147676 /* RCTActionSheet */, - ); - }; -/* End PBXProject section */ - -/* Begin PBXSourcesBuildPhase section */ - 58B511D71A9E6C8500147676 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 14C644C41AB0DFC900DE3C65 /* RCTActionSheetManager.m in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXSourcesBuildPhase section */ - -/* Begin XCBuildConfiguration section */ - 58B511ED1A9E6C8500147676 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - COPY_PHASE_STRIP = NO; - ENABLE_STRICT_OBJC_MSGSEND = YES; - GCC_C_LANGUAGE_STANDARD = gnu99; - GCC_DYNAMIC_NO_PIC = NO; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", - "$(inherited)", - ); - GCC_SYMBOLS_PRIVATE_EXTERN = NO; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES; - GCC_WARN_SHADOW = YES; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 7.0; - MTL_ENABLE_DEBUG_INFO = YES; - ONLY_ACTIVE_ARCH = YES; - SDKROOT = iphoneos; - WARNING_CFLAGS = ( - "-Wextra", - "-Wall", - ); - }; - name = Debug; - }; - 58B511EE1A9E6C8500147676 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - COPY_PHASE_STRIP = YES; - ENABLE_NS_ASSERTIONS = NO; - ENABLE_STRICT_OBJC_MSGSEND = YES; - GCC_C_LANGUAGE_STANDARD = gnu99; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES; - GCC_WARN_SHADOW = YES; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 7.0; - MTL_ENABLE_DEBUG_INFO = NO; - SDKROOT = iphoneos; - VALIDATE_PRODUCT = YES; - WARNING_CFLAGS = ( - "-Wextra", - "-Wall", - ); - }; - name = Release; - }; - 58B511F01A9E6C8500147676 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - CLANG_STATIC_ANALYZER_MODE = deep; - HEADER_SEARCH_PATHS = ( - "$(inherited)", - /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, - "$(SRCROOT)/../../React/**", - ); - LIBRARY_SEARCH_PATHS = "$(inherited)"; - OTHER_LDFLAGS = "-ObjC"; - PRODUCT_NAME = RCTActionSheet; - RUN_CLANG_STATIC_ANALYZER = YES; - SKIP_INSTALL = YES; - }; - name = Debug; - }; - 58B511F11A9E6C8500147676 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - CLANG_STATIC_ANALYZER_MODE = deep; - HEADER_SEARCH_PATHS = ( - "$(inherited)", - /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, - "$(SRCROOT)/../../React/**", - ); - LIBRARY_SEARCH_PATHS = "$(inherited)"; - OTHER_LDFLAGS = "-ObjC"; - PRODUCT_NAME = RCTActionSheet; - RUN_CLANG_STATIC_ANALYZER = NO; - SKIP_INSTALL = YES; - }; - name = Release; - }; -/* End XCBuildConfiguration section */ - -/* Begin XCConfigurationList section */ - 58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "RCTActionSheet" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 58B511ED1A9E6C8500147676 /* Debug */, - 58B511EE1A9E6C8500147676 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "RCTActionSheet" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 58B511F01A9E6C8500147676 /* Debug */, - 58B511F11A9E6C8500147676 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; -/* End XCConfigurationList section */ - }; - rootObject = 58B511D31A9E6C8500147676 /* Project object */; -} diff --git a/examples/node_modules/react-native/Libraries/ActionSheetIOS/RCTActionSheet.xcodeproj/xcuserdata/yuji.xcuserdatad/xcschemes/xcschememanagement.plist b/examples/node_modules/react-native/Libraries/ActionSheetIOS/RCTActionSheet.xcodeproj/xcuserdata/yuji.xcuserdatad/xcschemes/xcschememanagement.plist deleted file mode 100644 index 882a1999..00000000 --- a/examples/node_modules/react-native/Libraries/ActionSheetIOS/RCTActionSheet.xcodeproj/xcuserdata/yuji.xcuserdatad/xcschemes/xcschememanagement.plist +++ /dev/null @@ -1,22 +0,0 @@ - - - - - SchemeUserState - - RCTActionSheet.xcscheme - - orderHint - 2 - - - SuppressBuildableAutocreation - - 58B511DA1A9E6C8500147676 - - primary - - - - - diff --git a/examples/node_modules/react-native/Libraries/ActionSheetIOS/RCTActionSheetManager.h b/examples/node_modules/react-native/Libraries/ActionSheetIOS/RCTActionSheetManager.h deleted file mode 100644 index 4e99f220..00000000 --- a/examples/node_modules/react-native/Libraries/ActionSheetIOS/RCTActionSheetManager.h +++ /dev/null @@ -1,16 +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. - */ - -#import - -#import "RCTBridge.h" - -@interface RCTActionSheetManager : NSObject - -@end diff --git a/examples/node_modules/react-native/Libraries/ActionSheetIOS/RCTActionSheetManager.m b/examples/node_modules/react-native/Libraries/ActionSheetIOS/RCTActionSheetManager.m deleted file mode 100644 index 6d568a0a..00000000 --- a/examples/node_modules/react-native/Libraries/ActionSheetIOS/RCTActionSheetManager.m +++ /dev/null @@ -1,231 +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. - */ - -#import "RCTActionSheetManager.h" - -#import "RCTConvert.h" -#import "RCTLog.h" -#import "RCTUtils.h" -#import "RCTBridge.h" -#import "RCTUIManager.h" - -@interface RCTActionSheetManager () -@end - -@implementation RCTActionSheetManager -{ - // Use NSMapTable, as UIAlertViews do not implement - // which is required for NSDictionary keys - NSMapTable *_callbacks; -} - -RCT_EXPORT_MODULE() - -- (dispatch_queue_t)methodQueue -{ - return dispatch_get_main_queue(); -} - -/* - * The `anchor` option takes a view to set as the anchor for the share - * popup to point to, on iPads running iOS 8. If it is not passed, it - * defaults to centering the share popup on screen without any arrows. - */ -- (CGRect)sourceRectInView:(UIView *)sourceView - anchorViewTag:(NSNumber *)anchorViewTag -{ - if (anchorViewTag) { - UIView *anchorView = [self.bridge.uiManager viewForReactTag:anchorViewTag]; - return [anchorView convertRect:anchorView.bounds toView:sourceView]; - } else { - return (CGRect){sourceView.center, {1, 1}}; - } -} - -RCT_EXPORT_METHOD(showActionSheetWithOptions:(NSDictionary *)options - callback:(RCTResponseSenderBlock)callback) -{ - if (RCTRunningInAppExtension()) { - RCTLogError(@"Unable to show action sheet from app extension"); - return; - } - - if (!_callbacks) { - _callbacks = [NSMapTable strongToStrongObjectsMapTable]; - } - - NSString *title = [RCTConvert NSString:options[@"title"]]; - NSArray *buttons = [RCTConvert NSStringArray:options[@"options"]]; - NSInteger destructiveButtonIndex = options[@"destructiveButtonIndex"] ? [RCTConvert NSInteger:options[@"destructiveButtonIndex"]] : -1; - NSInteger cancelButtonIndex = options[@"cancelButtonIndex"] ? [RCTConvert NSInteger:options[@"cancelButtonIndex"]] : -1; - - UIViewController *controller = RCTKeyWindow().rootViewController; - if (controller == nil) { - RCTLogError(@"Tried to display action sheet but there is no application window. options: %@", options); - return; - } - - /* - * The `anchor` option takes a view to set as the anchor for the share - * popup to point to, on iPads running iOS 8. If it is not passed, it - * defaults to centering the share popup on screen without any arrows. - */ - NSNumber *anchorViewTag = [RCTConvert NSNumber:options[@"anchor"]]; - UIView *sourceView = controller.view; - CGRect sourceRect = [self sourceRectInView:sourceView anchorViewTag:anchorViewTag]; - -#if __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_8_0 - - if ([UIAlertController class] == nil) { - - UIActionSheet *actionSheet = [UIActionSheet new]; - - actionSheet.title = title; - for (NSString *option in buttons) { - [actionSheet addButtonWithTitle:option]; - } - actionSheet.destructiveButtonIndex = destructiveButtonIndex; - actionSheet.cancelButtonIndex = cancelButtonIndex; - actionSheet.delegate = self; - - [_callbacks setObject:callback forKey:actionSheet]; - - if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { - [actionSheet showFromRect:sourceRect inView:sourceView animated:YES]; - } else { - [actionSheet showInView:sourceView]; - } - - } else - -#endif - - { - UIAlertController *alertController = - [UIAlertController alertControllerWithTitle:title - message:nil - preferredStyle:UIAlertControllerStyleActionSheet]; - - NSInteger index = 0; - for (NSString *option in buttons) { - UIAlertActionStyle style = UIAlertActionStyleDefault; - if (index == destructiveButtonIndex) { - style = UIAlertActionStyleDestructive; - } else if (index == cancelButtonIndex) { - style = UIAlertActionStyleCancel; - } - - NSInteger localIndex = index; - [alertController addAction:[UIAlertAction actionWithTitle:option - style:style - handler:^(__unused UIAlertAction *action){ - callback(@[@(localIndex)]); - }]]; - - index++; - } - - alertController.modalPresentationStyle = UIModalPresentationPopover; - alertController.popoverPresentationController.sourceView = sourceView; - alertController.popoverPresentationController.sourceRect = sourceRect; - if (!anchorViewTag) { - alertController.popoverPresentationController.permittedArrowDirections = 0; - } - [controller presentViewController:alertController animated:YES completion:nil]; - - alertController.view.tintColor = [RCTConvert UIColor:options[@"tintColor"]]; - } -} - -RCT_EXPORT_METHOD(showShareActionSheetWithOptions:(NSDictionary *)options - failureCallback:(RCTResponseErrorBlock)failureCallback - successCallback:(RCTResponseSenderBlock)successCallback) -{ - if (RCTRunningInAppExtension()) { - RCTLogError(@"Unable to show action sheet from app extension"); - return; - } - - NSMutableArray *items = [NSMutableArray array]; - NSString *message = [RCTConvert NSString:options[@"message"]]; - if (message) { - [items addObject:message]; - } - NSURL *URL = [RCTConvert NSURL:options[@"url"]]; - if (URL) { - [items addObject:URL]; - } - if (items.count == 0) { - RCTLogError(@"No `url` or `message` to share"); - return; - } - - UIActivityViewController *shareController = [[UIActivityViewController alloc] initWithActivityItems:items applicationActivities:nil]; - - NSString *subject = [RCTConvert NSString:options[@"subject"]]; - if (subject) { - [shareController setValue:subject forKey:@"subject"]; - } - - NSArray *excludedActivityTypes = [RCTConvert NSStringArray:options[@"excludedActivityTypes"]]; - if (excludedActivityTypes) { - shareController.excludedActivityTypes = excludedActivityTypes; - } - - UIViewController *controller = RCTKeyWindow().rootViewController; - -#if __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_8_0 - - if (![UIActivityViewController instancesRespondToSelector:@selector(setCompletionWithItemsHandler:)]) { - // Legacy iOS 7 implementation - shareController.completionHandler = ^(NSString *activityType, BOOL completed) { - successCallback(@[@(completed), RCTNullIfNil(activityType)]); - }; - } else - -#endif - - { - // iOS 8 version - shareController.completionWithItemsHandler = ^(NSString *activityType, BOOL completed, __unused NSArray *returnedItems, NSError *activityError) { - if (activityError) { - failureCallback(activityError); - } else { - successCallback(@[@(completed), RCTNullIfNil(activityType)]); - } - }; - - shareController.modalPresentationStyle = UIModalPresentationPopover; - NSNumber *anchorViewTag = [RCTConvert NSNumber:options[@"anchor"]]; - if (!anchorViewTag) { - shareController.popoverPresentationController.permittedArrowDirections = 0; - } - shareController.popoverPresentationController.sourceView = controller.view; - shareController.popoverPresentationController.sourceRect = [self sourceRectInView:controller.view anchorViewTag:anchorViewTag]; - } - - [controller presentViewController:shareController animated:YES completion:nil]; - - shareController.view.tintColor = [RCTConvert UIColor:options[@"tintColor"]]; -} - -#pragma mark UIActionSheetDelegate Methods - -- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex -{ - RCTResponseSenderBlock callback = [_callbacks objectForKey:actionSheet]; - if (callback) { - callback(@[@(buttonIndex)]); - [_callbacks removeObjectForKey:actionSheet]; - } else { - RCTLogWarn(@"No callback registered for action sheet: %@", actionSheet.title); - } -} - -@end diff --git a/examples/node_modules/react-native/Libraries/AdSupport/AdSupportIOS.js b/examples/node_modules/react-native/Libraries/AdSupport/AdSupportIOS.js deleted file mode 100644 index d9d315a1..00000000 --- a/examples/node_modules/react-native/Libraries/AdSupport/AdSupportIOS.js +++ /dev/null @@ -1,24 +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. - * - * @providesModule AdSupportIOS - * @flow - */ -'use strict'; - -var AdSupport = require('NativeModules').AdSupport; - -module.exports = { - getAdvertisingId: function(onSuccess: Function, onFailure: Function) { - AdSupport.getAdvertisingId(onSuccess, onFailure); - }, - - getAdvertisingTrackingEnabled: function(onSuccess: Function, onFailure: Function) { - AdSupport.getAdvertisingTrackingEnabled(onSuccess, onFailure); - }, -}; diff --git a/examples/node_modules/react-native/Libraries/AdSupport/RCTAdSupport.h b/examples/node_modules/react-native/Libraries/AdSupport/RCTAdSupport.h deleted file mode 100644 index 56e561f7..00000000 --- a/examples/node_modules/react-native/Libraries/AdSupport/RCTAdSupport.h +++ /dev/null @@ -1,14 +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. - */ - -#import "RCTBridgeModule.h" - -@interface RCTAdSupport : NSObject - -@end diff --git a/examples/node_modules/react-native/Libraries/AdSupport/RCTAdSupport.m b/examples/node_modules/react-native/Libraries/AdSupport/RCTAdSupport.m deleted file mode 100644 index 1324e9c9..00000000 --- a/examples/node_modules/react-native/Libraries/AdSupport/RCTAdSupport.m +++ /dev/null @@ -1,36 +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. - */ - -#import - -#import "RCTAdSupport.h" -#import "RCTUtils.h" - -@implementation RCTAdSupport - -RCT_EXPORT_MODULE() - -RCT_EXPORT_METHOD(getAdvertisingId:(RCTResponseSenderBlock)callback - withErrorCallback:(RCTResponseErrorBlock)errorCallback) -{ - NSUUID *advertisingIdentifier = [ASIdentifierManager sharedManager].advertisingIdentifier; - if (advertisingIdentifier) { - callback(@[advertisingIdentifier.UUIDString]); - } else { - errorCallback(RCTErrorWithMessage(@"Advertising identifier is unavailable.")); - } -} - -RCT_EXPORT_METHOD(getAdvertisingTrackingEnabled:(RCTResponseSenderBlock)callback - withErrorCallback:(__unused RCTResponseSenderBlock)errorCallback) -{ - callback(@[@([ASIdentifierManager sharedManager].advertisingTrackingEnabled)]); -} - -@end diff --git a/examples/node_modules/react-native/Libraries/AdSupport/RCTAdSupport.xcodeproj/project.pbxproj b/examples/node_modules/react-native/Libraries/AdSupport/RCTAdSupport.xcodeproj/project.pbxproj deleted file mode 100644 index b4cd622b..00000000 --- a/examples/node_modules/react-native/Libraries/AdSupport/RCTAdSupport.xcodeproj/project.pbxproj +++ /dev/null @@ -1,275 +0,0 @@ -// !$*UTF8*$! -{ - archiveVersion = 1; - classes = { - }; - objectVersion = 46; - objects = { - -/* Begin PBXBuildFile section */ - 832C819C1AAF6E1A007FA2F7 /* RCTAdSupport.m in Sources */ = {isa = PBXBuildFile; fileRef = 832C819B1AAF6E1A007FA2F7 /* RCTAdSupport.m */; }; -/* End PBXBuildFile section */ - -/* Begin PBXCopyFilesBuildPhase section */ - 832C817E1AAF6DEF007FA2F7 /* CopyFiles */ = { - isa = PBXCopyFilesBuildPhase; - buildActionMask = 2147483647; - dstPath = "include/$(PRODUCT_NAME)"; - dstSubfolderSpec = 16; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXCopyFilesBuildPhase section */ - -/* Begin PBXFileReference section */ - 832C81801AAF6DEF007FA2F7 /* libRCTAdSupport.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRCTAdSupport.a; sourceTree = BUILT_PRODUCTS_DIR; }; - 832C819A1AAF6E1A007FA2F7 /* RCTAdSupport.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTAdSupport.h; sourceTree = ""; }; - 832C819B1AAF6E1A007FA2F7 /* RCTAdSupport.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTAdSupport.m; sourceTree = ""; }; -/* End PBXFileReference section */ - -/* Begin PBXFrameworksBuildPhase section */ - 832C817D1AAF6DEF007FA2F7 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXFrameworksBuildPhase section */ - -/* Begin PBXGroup section */ - 832C81771AAF6DEF007FA2F7 = { - isa = PBXGroup; - children = ( - 832C819A1AAF6E1A007FA2F7 /* RCTAdSupport.h */, - 832C819B1AAF6E1A007FA2F7 /* RCTAdSupport.m */, - 832C81811AAF6DEF007FA2F7 /* Products */, - ); - indentWidth = 2; - sourceTree = ""; - tabWidth = 2; - }; - 832C81811AAF6DEF007FA2F7 /* Products */ = { - isa = PBXGroup; - children = ( - 832C81801AAF6DEF007FA2F7 /* libRCTAdSupport.a */, - ); - name = Products; - sourceTree = ""; - }; -/* End PBXGroup section */ - -/* Begin PBXNativeTarget section */ - 832C817F1AAF6DEF007FA2F7 /* RCTAdSupport */ = { - isa = PBXNativeTarget; - buildConfigurationList = 832C81941AAF6DF0007FA2F7 /* Build configuration list for PBXNativeTarget "RCTAdSupport" */; - buildPhases = ( - 832C817C1AAF6DEF007FA2F7 /* Sources */, - 832C817D1AAF6DEF007FA2F7 /* Frameworks */, - 832C817E1AAF6DEF007FA2F7 /* CopyFiles */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = RCTAdSupport; - productName = RCTAdSupport; - productReference = 832C81801AAF6DEF007FA2F7 /* libRCTAdSupport.a */; - productType = "com.apple.product-type.library.static"; - }; -/* End PBXNativeTarget section */ - -/* Begin PBXProject section */ - 832C81781AAF6DEF007FA2F7 /* Project object */ = { - isa = PBXProject; - attributes = { - LastUpgradeCheck = 0620; - ORGANIZATIONNAME = Facebook; - TargetAttributes = { - 832C817F1AAF6DEF007FA2F7 = { - CreatedOnToolsVersion = 6.2; - }; - }; - }; - buildConfigurationList = 832C817B1AAF6DEF007FA2F7 /* Build configuration list for PBXProject "RCTAdSupport" */; - compatibilityVersion = "Xcode 3.2"; - developmentRegion = English; - hasScannedForEncodings = 0; - knownRegions = ( - en, - ); - mainGroup = 832C81771AAF6DEF007FA2F7; - productRefGroup = 832C81811AAF6DEF007FA2F7 /* Products */; - projectDirPath = ""; - projectRoot = ""; - targets = ( - 832C817F1AAF6DEF007FA2F7 /* RCTAdSupport */, - ); - }; -/* End PBXProject section */ - -/* Begin PBXSourcesBuildPhase section */ - 832C817C1AAF6DEF007FA2F7 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 832C819C1AAF6E1A007FA2F7 /* RCTAdSupport.m in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXSourcesBuildPhase section */ - -/* Begin XCBuildConfiguration section */ - 832C81921AAF6DF0007FA2F7 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - COPY_PHASE_STRIP = NO; - ENABLE_STRICT_OBJC_MSGSEND = YES; - GCC_C_LANGUAGE_STANDARD = gnu99; - GCC_DYNAMIC_NO_PIC = NO; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", - "$(inherited)", - ); - GCC_SYMBOLS_PRIVATE_EXTERN = NO; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES; - GCC_WARN_SHADOW = YES; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - HEADER_SEARCH_PATHS = ( - "$(inherited)", - /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, - "$(SRCROOT)/../../React/**", - ); - IPHONEOS_DEPLOYMENT_TARGET = 7.0; - MTL_ENABLE_DEBUG_INFO = YES; - ONLY_ACTIVE_ARCH = YES; - SDKROOT = iphoneos; - WARNING_CFLAGS = ( - "-Werror", - "-Wall", - ); - }; - name = Debug; - }; - 832C81931AAF6DF0007FA2F7 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - COPY_PHASE_STRIP = NO; - ENABLE_NS_ASSERTIONS = NO; - ENABLE_STRICT_OBJC_MSGSEND = YES; - GCC_C_LANGUAGE_STANDARD = gnu99; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES; - GCC_WARN_SHADOW = YES; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - HEADER_SEARCH_PATHS = ( - "$(inherited)", - /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, - "$(SRCROOT)/../../React/**", - ); - IPHONEOS_DEPLOYMENT_TARGET = 7.0; - MTL_ENABLE_DEBUG_INFO = NO; - SDKROOT = iphoneos; - VALIDATE_PRODUCT = YES; - WARNING_CFLAGS = ( - "-Werror", - "-Wall", - ); - }; - name = Release; - }; - 832C81951AAF6DF0007FA2F7 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - CLANG_STATIC_ANALYZER_MODE = deep; - HEADER_SEARCH_PATHS = ( - "$(inherited)", - /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, - "$(SRCROOT)/../../React/**", - ); - OTHER_LDFLAGS = "-ObjC"; - PRODUCT_NAME = "$(TARGET_NAME)"; - RUN_CLANG_STATIC_ANALYZER = YES; - SKIP_INSTALL = YES; - }; - name = Debug; - }; - 832C81961AAF6DF0007FA2F7 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - CLANG_STATIC_ANALYZER_MODE = deep; - HEADER_SEARCH_PATHS = ( - "$(inherited)", - /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, - "$(SRCROOT)/../../React/**", - ); - OTHER_LDFLAGS = "-ObjC"; - PRODUCT_NAME = "$(TARGET_NAME)"; - SKIP_INSTALL = YES; - }; - name = Release; - }; -/* End XCBuildConfiguration section */ - -/* Begin XCConfigurationList section */ - 832C817B1AAF6DEF007FA2F7 /* Build configuration list for PBXProject "RCTAdSupport" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 832C81921AAF6DF0007FA2F7 /* Debug */, - 832C81931AAF6DF0007FA2F7 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 832C81941AAF6DF0007FA2F7 /* Build configuration list for PBXNativeTarget "RCTAdSupport" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 832C81951AAF6DF0007FA2F7 /* Debug */, - 832C81961AAF6DF0007FA2F7 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; -/* End XCConfigurationList section */ - }; - rootObject = 832C81781AAF6DEF007FA2F7 /* Project object */; -} diff --git a/examples/node_modules/react-native/Libraries/AppRegistry/AppRegistry.js b/examples/node_modules/react-native/Libraries/AppRegistry/AppRegistry.js deleted file mode 100644 index 57bafd2d..00000000 --- a/examples/node_modules/react-native/Libraries/AppRegistry/AppRegistry.js +++ /dev/null @@ -1,109 +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. - * - * @providesModule AppRegistry - * @flow - */ -'use strict'; - -var BatchedBridge = require('BatchedBridge'); -var ReactNative = require('ReactNative'); - -var invariant = require('invariant'); -var renderApplication = require('renderApplication'); - -if (__DEV__) { - // In order to use Cmd+P to record/dump perf data, we need to make sure - // this module is available in the bundle - require('RCTRenderingPerf'); -} - -var runnables = {}; - -type ComponentProvider = () => ReactClass; - -type AppConfig = { - appKey: string; - component?: ComponentProvider; - run?: Function; -}; - -/** - * `AppRegistry` is the JS entry point to running all React Native apps. App - * root components should register themselves with - * `AppRegistry.registerComponent`, then the native system can load the bundle - * for the app and then actually run the app when it's ready by invoking - * `AppRegistry.runApplication`. - * - * To "stop" an application when a view should be destroyed, call - * `AppRegistry.unmountApplicationComponentAtRootTag` with the tag that was - * pass into `runApplication`. These should always be used as a pair. - * - * `AppRegistry` should be `require`d early in the `require` sequence to make - * sure the JS execution environment is setup before other modules are - * `require`d. - */ -var AppRegistry = { - registerConfig: function(config: Array) { - for (var i = 0; i < config.length; ++i) { - var appConfig = config[i]; - if (appConfig.run) { - AppRegistry.registerRunnable(appConfig.appKey, appConfig.run); - } else { - invariant(appConfig.component, 'No component provider passed in'); - AppRegistry.registerComponent(appConfig.appKey, appConfig.component); - } - } - }, - - registerComponent: function(appKey: string, getComponentFunc: ComponentProvider): string { - runnables[appKey] = { - run: (appParameters) => - renderApplication(getComponentFunc(), appParameters.initialProps, appParameters.rootTag) - }; - return appKey; - }, - - registerRunnable: function(appKey: string, func: Function): string { - runnables[appKey] = {run: func}; - return appKey; - }, - - getAppKeys: function(): Array { - return Object.keys(runnables); - }, - - runApplication: function(appKey: string, appParameters: any): void { - console.log( - 'Running application "' + appKey + '" with appParams: ' + - JSON.stringify(appParameters) + '. ' + - '__DEV__ === ' + String(__DEV__) + - ', development-level warning are ' + (__DEV__ ? 'ON' : 'OFF') + - ', performance optimizations are ' + (__DEV__ ? 'OFF' : 'ON') - ); - invariant( - runnables[appKey] && runnables[appKey].run, - 'Application ' + appKey + ' has not been registered. This ' + - 'is either due to a require() error during initialization ' + - 'or failure to call AppRegistry.registerComponent.' - ); - runnables[appKey].run(appParameters); - }, - - unmountApplicationComponentAtRootTag: function(rootTag : number) { - ReactNative.unmountComponentAtNodeAndRemoveContainer(rootTag); - }, - -}; - -BatchedBridge.registerCallableModule( - 'AppRegistry', - AppRegistry -); - -module.exports = AppRegistry; diff --git a/examples/node_modules/react-native/Libraries/AppStateIOS/AppStateIOS.android.js b/examples/node_modules/react-native/Libraries/AppStateIOS/AppStateIOS.android.js deleted file mode 100644 index 0f59cbea..00000000 --- a/examples/node_modules/react-native/Libraries/AppStateIOS/AppStateIOS.android.js +++ /dev/null @@ -1,30 +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. - * - * @providesModule AppStateIOS - * @flow - */ -'use strict'; - -var warning = require('warning'); - -class AppStateIOS { - - static addEventListener(type, handler) { - warning(false, 'Cannot listen to AppStateIOS events on Android.'); - } - - static removeEventListener(type, handler) { - warning(false, 'Cannot remove AppStateIOS listener on Android.'); - } - -} - -AppStateIOS.currentState = null; - -module.exports = AppStateIOS; diff --git a/examples/node_modules/react-native/Libraries/AppStateIOS/AppStateIOS.ios.js b/examples/node_modules/react-native/Libraries/AppStateIOS/AppStateIOS.ios.js deleted file mode 100644 index f7dddcd5..00000000 --- a/examples/node_modules/react-native/Libraries/AppStateIOS/AppStateIOS.ios.js +++ /dev/null @@ -1,147 +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. - * - * @providesModule AppStateIOS - * @flow - */ -'use strict'; - -var Map = require('Map'); -var NativeModules = require('NativeModules'); -var RCTDeviceEventEmitter = require('RCTDeviceEventEmitter'); -var RCTAppState = NativeModules.AppState; - -var logError = require('logError'); -var invariant = require('invariant'); - -var _eventHandlers = { - change: new Map(), - memoryWarning: new Map(), -}; - -/** - * `AppStateIOS` can tell you if the app is in the foreground or background, - * and notify you when the state changes. - * - * AppStateIOS is frequently used to determine the intent and proper behavior when - * handling push notifications. - * - * ### iOS App States - * - * - `active` - The app is running in the foreground - * - `background` - The app is running in the background. The user is either - * in another app or on the home screen - * - `inactive` - This is a transition state that currently never happens for - * typical React Native apps. - * - * For more information, see - * [Apple's documentation](https://developer.apple.com/library/ios/documentation/iPhone/Conceptual/iPhoneOSProgrammingGuide/TheAppLifeCycle/TheAppLifeCycle.html) - * - * ### Basic Usage - * - * To see the current state, you can check `AppStateIOS.currentState`, which - * will be kept up-to-date. However, `currentState` will be null at launch - * while `AppStateIOS` retrieves it over the bridge. - * - * ``` - * getInitialState: function() { - * return { - * currentAppState: AppStateIOS.currentState, - * }; - * }, - * componentDidMount: function() { - * AppStateIOS.addEventListener('change', this._handleAppStateChange); - * }, - * componentWillUnmount: function() { - * AppStateIOS.removeEventListener('change', this._handleAppStateChange); - * }, - * _handleAppStateChange: function(currentAppState) { - * this.setState({ currentAppState, }); - * }, - * render: function() { - * return ( - * Current state is: {this.state.currentAppState} - * ); - * }, - * ``` - * - * This example will only ever appear to say "Current state is: active" because - * the app is only visible to the user when in the `active` state, and the null - * state will happen only momentarily. - */ - -var AppStateIOS = { - - /** - * Add a handler to AppState changes by listening to the `change` event type - * and providing the handler - */ - addEventListener: function( - type: string, - handler: Function - ) { - invariant( - ['change', 'memoryWarning'].indexOf(type) !== -1, - 'Trying to subscribe to unknown event: "%s"', type - ); - if (type === 'change') { - _eventHandlers[type].set(handler, RCTDeviceEventEmitter.addListener( - 'appStateDidChange', - (appStateData) => { - handler(appStateData.app_state); - } - )); - } else if (type === 'memoryWarning') { - _eventHandlers[type].set(handler, RCTDeviceEventEmitter.addListener( - 'memoryWarning', - handler - )); - } - }, - - /** - * Remove a handler by passing the `change` event type and the handler - */ - removeEventListener: function( - type: string, - handler: Function - ) { - invariant( - ['change', 'memoryWarning'].indexOf(type) !== -1, - 'Trying to remove listener for unknown event: "%s"', type - ); - if (!_eventHandlers[type].has(handler)) { - return; - } - _eventHandlers[type].get(handler).remove(); - _eventHandlers[type].delete(handler); - }, - - // TODO: getCurrentAppState callback seems to be called at a really late stage - // after app launch. Trying to get currentState when mounting App component - // will likely to have the initial value here. - // Initialize to 'active' instead of null. - currentState: ('active' : ?string), - -}; - -RCTDeviceEventEmitter.addListener( - 'appStateDidChange', - (appStateData) => { - AppStateIOS.currentState = appStateData.app_state; - } -); - -RCTAppState.getCurrentAppState( - (appStateData) => { - AppStateIOS.currentState = appStateData.app_state; - }, - logError -); - -module.exports = AppStateIOS; diff --git a/examples/node_modules/react-native/Libraries/BatchedBridge/BatchedBridgedModules/NativeModules.js b/examples/node_modules/react-native/Libraries/BatchedBridge/BatchedBridgedModules/NativeModules.js deleted file mode 100644 index af1540b7..00000000 --- a/examples/node_modules/react-native/Libraries/BatchedBridge/BatchedBridgedModules/NativeModules.js +++ /dev/null @@ -1,88 +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. - * - * @providesModule NativeModules - * @flow - */ -'use strict'; - -const BatchedBridge = require('BatchedBridge'); -const RemoteModules = BatchedBridge.RemoteModules; - -function normalizePrefix(moduleName: string): string { - return moduleName.replace(/^(RCT|RK)/, ''); -} - -/** - * Dirty hack to support old (RK) and new (RCT) native module name conventions. - */ -Object.keys(RemoteModules).forEach((moduleName) => { - const strippedName = normalizePrefix(moduleName); - if (RemoteModules['RCT' + strippedName] && RemoteModules['RK' + strippedName]) { - throw new Error( - 'Module cannot be registered as both RCT and RK: ' + moduleName - ); - } - if (strippedName !== moduleName) { - RemoteModules[strippedName] = RemoteModules[moduleName]; - delete RemoteModules[moduleName]; - } -}); - -/** - * Define lazy getters for each module. - * These will return the module if already loaded, or load it if not. - */ -const NativeModules = {}; -Object.keys(RemoteModules).forEach((moduleName) => { - Object.defineProperty(NativeModules, moduleName, { - enumerable: true, - get: () => { - let module = RemoteModules[moduleName]; - if (module && typeof module.moduleID === 'number' && global.nativeRequireModuleConfig) { - const json = global.nativeRequireModuleConfig(moduleName); - const config = json && JSON.parse(json); - module = config && BatchedBridge.processModuleConfig(config, module.moduleID); - RemoteModules[moduleName] = module; - } - return module; - }, - }); -}); - -/** - * Copies the ViewManager constants into UIManager. This is only - * needed for iOS, which puts the constants in the ViewManager - * namespace instead of UIManager, unlike Android. - * - * We'll eventually move this logic to UIManager.js, once all - * the call sites accessing NativeModules.UIManager directly have - * been removed #9344445 - */ -const UIManager = NativeModules.UIManager; -UIManager && Object.keys(UIManager).forEach(viewName => { - const viewConfig = UIManager[viewName]; - const constants = {}; - if (viewConfig.Manager) { - Object.defineProperty(viewConfig, 'Constants', { - enumerable: true, - get: () => { - const viewManager = NativeModules[normalizePrefix(viewConfig.Manager)]; - viewManager && Object.keys(viewManager).forEach(key => { - const value = viewManager[key]; - if (typeof value !== 'function') { - constants[key] = value; - } - }); - return constants; - }, - }); - } -}); - -module.exports = NativeModules; diff --git a/examples/node_modules/react-native/Libraries/BatchedBridge/BatchedBridgedModules/RCTAlertManager.ios.js b/examples/node_modules/react-native/Libraries/BatchedBridge/BatchedBridgedModules/RCTAlertManager.ios.js deleted file mode 100644 index 409ecf5c..00000000 --- a/examples/node_modules/react-native/Libraries/BatchedBridge/BatchedBridgedModules/RCTAlertManager.ios.js +++ /dev/null @@ -1,16 +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. - * - * @providesModule RCTAlertManager - * @flow - */ -'use strict'; - -var RCTAlertManager = require('NativeModules').AlertManager; - -module.exports = RCTAlertManager; diff --git a/examples/node_modules/react-native/Libraries/BatchedBridge/BatchedBridgedModules/RCTEventEmitter.js b/examples/node_modules/react-native/Libraries/BatchedBridge/BatchedBridgedModules/RCTEventEmitter.js deleted file mode 100644 index 2b8f578e..00000000 --- a/examples/node_modules/react-native/Libraries/BatchedBridge/BatchedBridgedModules/RCTEventEmitter.js +++ /dev/null @@ -1,23 +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. - * - * @providesModule RCTEventEmitter - * @flow - */ -'use strict'; - -var BatchedBridge = require('BatchedBridge'); -var ReactNativeEventEmitter = require('ReactNativeEventEmitter'); - -BatchedBridge.registerCallableModule( - 'RCTEventEmitter', - ReactNativeEventEmitter -); - -// Completely locally implemented - no native hooks. -module.exports = ReactNativeEventEmitter; diff --git a/examples/node_modules/react-native/Libraries/BatchedBridge/BatchedBridgedModules/__mocks__/NativeModules.js b/examples/node_modules/react-native/Libraries/BatchedBridge/BatchedBridgedModules/__mocks__/NativeModules.js deleted file mode 100644 index 164508dd..00000000 --- a/examples/node_modules/react-native/Libraries/BatchedBridge/BatchedBridgedModules/__mocks__/NativeModules.js +++ /dev/null @@ -1,62 +0,0 @@ -/** - * Copyright 2004-present Facebook. All Rights Reserved. - */ -'use strict'; - -var NativeModules = { - I18n: { - translationsDictionary: JSON.stringify({ - 'Good bye, {name}!|Bye message': '¡Adiós {name}!', - }), - }, - Timing: { - createTimer: jest.genMockFunction(), - deleteTimer: jest.genMockFunction(), - }, - GraphPhotoUpload: { - upload: jest.genMockFunction(), - }, - FacebookSDK: { - login: jest.genMockFunction(), - logout: jest.genMockFunction(), - queryGraphPath: jest.genMockFunction().mockImpl( - (path, method, params, callback) => callback() - ), - }, - DataManager: { - queryData: jest.genMockFunction(), - }, - UIManager: { - customBubblingEventTypes: {}, - customDirectEventTypes: {}, - Dimensions: {}, - RCTModalFullscreenView: { - Constants: {}, - }, - RCTScrollView: { - Constants: {}, - }, - }, - AsyncLocalStorage: { - getItem: jest.genMockFunction(), - setItem: jest.genMockFunction(), - removeItem: jest.genMockFunction(), - clear: jest.genMockFunction(), - }, - SourceCode: { - scriptURL: null, - }, - BuildInfo: { - appVersion: '0', - buildVersion: '0', - }, - ModalFullscreenViewManager: {}, - AlertManager: { - alertWithArgs: jest.genMockFunction(), - }, - Clipboard: { - setString: jest.genMockFunction(), - }, -}; - -module.exports = NativeModules; diff --git a/examples/node_modules/react-native/Libraries/CameraRoll/CameraRoll.js b/examples/node_modules/react-native/Libraries/CameraRoll/CameraRoll.js deleted file mode 100644 index c7e28d95..00000000 --- a/examples/node_modules/react-native/Libraries/CameraRoll/CameraRoll.js +++ /dev/null @@ -1,191 +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. - * - * @providesModule CameraRoll - * @flow - */ -'use strict'; - -var ReactPropTypes = require('ReactPropTypes'); -var RCTCameraRollManager = require('NativeModules').CameraRollManager; - -var createStrictShapeTypeChecker = require('createStrictShapeTypeChecker'); -var deepFreezeAndThrowOnMutationInDev = - require('deepFreezeAndThrowOnMutationInDev'); -var invariant = require('invariant'); - -var GROUP_TYPES_OPTIONS = [ - 'Album', - 'All', - 'Event', - 'Faces', - 'Library', - 'PhotoStream', - 'SavedPhotos', // default -]; - -var ASSET_TYPE_OPTIONS = [ - 'All', - 'Videos', - 'Photos', // default -]; - - -// Flow treats Object and Array as disjoint types, currently. -deepFreezeAndThrowOnMutationInDev((GROUP_TYPES_OPTIONS: any)); -deepFreezeAndThrowOnMutationInDev((ASSET_TYPE_OPTIONS: any)); - -/** - * Shape of the param arg for the `getPhotos` function. - */ -var getPhotosParamChecker = createStrictShapeTypeChecker({ - /** - * The number of photos wanted in reverse order of the photo application - * (i.e. most recent first for SavedPhotos). - */ - first: ReactPropTypes.number.isRequired, - - /** - * A cursor that matches `page_info { end_cursor }` returned from a previous - * call to `getPhotos` - */ - after: ReactPropTypes.string, - - /** - * Specifies which group types to filter the results to. - */ - groupTypes: ReactPropTypes.oneOf(GROUP_TYPES_OPTIONS), - - /** - * Specifies filter on group names, like 'Recent Photos' or custom album - * titles. - */ - groupName: ReactPropTypes.string, - - /** - * Specifies filter on asset type - */ - assetType: ReactPropTypes.oneOf(ASSET_TYPE_OPTIONS), - - /** - * Filter by mimetype (e.g. image/jpeg). - */ - mimeTypes: ReactPropTypes.arrayOf(ReactPropTypes.string), -}); - -/** - * Shape of the return value of the `getPhotos` function. - */ -var getPhotosReturnChecker = createStrictShapeTypeChecker({ - edges: ReactPropTypes.arrayOf(createStrictShapeTypeChecker({ - node: createStrictShapeTypeChecker({ - type: ReactPropTypes.string.isRequired, - group_name: ReactPropTypes.string.isRequired, - image: createStrictShapeTypeChecker({ - uri: ReactPropTypes.string.isRequired, - height: ReactPropTypes.number.isRequired, - width: ReactPropTypes.number.isRequired, - isStored: ReactPropTypes.bool, - }).isRequired, - timestamp: ReactPropTypes.number.isRequired, - location: createStrictShapeTypeChecker({ - latitude: ReactPropTypes.number, - longitude: ReactPropTypes.number, - altitude: ReactPropTypes.number, - heading: ReactPropTypes.number, - speed: ReactPropTypes.number, - }), - }).isRequired, - })).isRequired, - page_info: createStrictShapeTypeChecker({ - has_next_page: ReactPropTypes.bool.isRequired, - start_cursor: ReactPropTypes.string, - end_cursor: ReactPropTypes.string, - }).isRequired, -}); - -/** - * `CameraRoll` provides access to the local camera roll / gallery. - */ -class CameraRoll { - - static GroupTypesOptions: Array; - static AssetTypeOptions: Array; - /** - * Saves the image to the camera roll / gallery. - * - * The CameraRoll API is not yet implemented for Android. - * - * @param {string} tag On Android, this is a local URI, such - * as `"file:///sdcard/img.png"`. - * - * On iOS, the tag can be one of the following: - * - * - local URI - * - assets-library tag - * - a tag not maching any of the above, which means the image data will - * be stored in memory (and consume memory as long as the process is alive) - * - * @param successCallback Invoked with the value of `tag` on success. - * @param errorCallback Invoked with error message on error. - */ - static saveImageWithTag(tag, successCallback, errorCallback) { - invariant( - typeof tag === 'string', - 'CameraRoll.saveImageWithTag tag must be a valid string.' - ); - RCTCameraRollManager.saveImageWithTag( - tag, - (imageTag) => { - successCallback && successCallback(imageTag); - }, - (errorMessage) => { - errorCallback && errorCallback(errorMessage); - }); - } - - /** - * Invokes `callback` with photo identifier objects from the local camera - * roll of the device matching shape defined by `getPhotosReturnChecker`. - * - * @param {object} params See `getPhotosParamChecker`. - * @param {function} callback Invoked with arg of shape defined by - * `getPhotosReturnChecker` on success. - * @param {function} errorCallback Invoked with error message on error. - */ - static getPhotos(params, callback, errorCallback) { - var metaCallback = callback; - if (__DEV__) { - getPhotosParamChecker({params}, 'params', 'CameraRoll.getPhotos'); - invariant( - typeof callback === 'function', - 'CameraRoll.getPhotos callback must be a valid function.' - ); - invariant( - typeof errorCallback === 'function', - 'CameraRoll.getPhotos errorCallback must be a valid function.' - ); - } - if (__DEV__) { - metaCallback = (response) => { - getPhotosReturnChecker( - {response}, - 'response', - 'CameraRoll.getPhotos callback' - ); - callback(response); - }; - } - RCTCameraRollManager.getPhotos(params, metaCallback, errorCallback); - } -} - -CameraRoll.GroupTypesOptions = GROUP_TYPES_OPTIONS; -CameraRoll.AssetTypeOptions = ASSET_TYPE_OPTIONS; - -module.exports = CameraRoll; diff --git a/examples/node_modules/react-native/Libraries/Components/ActivityIndicatorIOS/ActivityIndicatorIOS.ios.js b/examples/node_modules/react-native/Libraries/Components/ActivityIndicatorIOS/ActivityIndicatorIOS.ios.js deleted file mode 100644 index fa97eb83..00000000 --- a/examples/node_modules/react-native/Libraries/Components/ActivityIndicatorIOS/ActivityIndicatorIOS.ios.js +++ /dev/null @@ -1,106 +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. - * - * @providesModule ActivityIndicatorIOS - * @flow - */ -'use strict'; - -var NativeMethodsMixin = require('NativeMethodsMixin'); -var PropTypes = require('ReactPropTypes'); -var React = require('React'); -var StyleSheet = require('StyleSheet'); -var View = require('View'); - -var requireNativeComponent = require('requireNativeComponent'); - -var GRAY = '#999999'; - -type DefaultProps = { - animating: boolean; - color: string; - hidesWhenStopped: boolean; - size: 'small' | 'large'; -}; - -var ActivityIndicatorIOS = React.createClass({ - mixins: [NativeMethodsMixin], - - propTypes: { - ...View.propTypes, - /** - * Whether to show the indicator (true, the default) or hide it (false). - */ - animating: PropTypes.bool, - /** - * The foreground color of the spinner (default is gray). - */ - color: PropTypes.string, - /** - * Whether the indicator should hide when not animating (true by default). - */ - hidesWhenStopped: PropTypes.bool, - /** - * Size of the indicator. Small has a height of 20, large has a height of 36. - */ - size: PropTypes.oneOf([ - 'small', - 'large', - ]), - /** - * Invoked on mount and layout changes with - * - * {nativeEvent: { layout: {x, y, width, height}}}. - */ - onLayout: PropTypes.func, - }, - - getDefaultProps: function(): DefaultProps { - return { - animating: true, - color: GRAY, - hidesWhenStopped: true, - size: 'small', - }; - }, - - render: function() { - var {onLayout, style, ...props} = this.props; - var sizeStyle = (this.props.size === 'large') ? styles.sizeLarge : styles.sizeSmall; - return ( - - - - ); - } -}); - -var styles = StyleSheet.create({ - container: { - alignItems: 'center', - justifyContent: 'center', - }, - sizeSmall: { - width: 20, - height: 20, - }, - sizeLarge: { - width: 36, - height: 36, - } -}); - -var RCTActivityIndicatorView = requireNativeComponent( - 'RCTActivityIndicatorView', - ActivityIndicatorIOS, - {nativeOnly: {activityIndicatorViewStyle: true}}, -); - -module.exports = ActivityIndicatorIOS; diff --git a/examples/node_modules/react-native/Libraries/Components/DatePicker/DatePickerIOS.ios.js b/examples/node_modules/react-native/Libraries/Components/DatePicker/DatePickerIOS.ios.js deleted file mode 100644 index 3516ae35..00000000 --- a/examples/node_modules/react-native/Libraries/Components/DatePicker/DatePickerIOS.ios.js +++ /dev/null @@ -1,154 +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. - * - * @providesModule DatePickerIOS - * @flow - * - * This is a controlled component version of RCTDatePickerIOS - */ -'use strict'; - -var NativeMethodsMixin = require('NativeMethodsMixin'); -var PropTypes = require('ReactPropTypes'); -var React = require('React'); -var RCTDatePickerIOSConsts = require('NativeModules').UIManager.RCTDatePicker.Constants; -var StyleSheet = require('StyleSheet'); -var View = require('View'); - -var requireNativeComponent = require('requireNativeComponent'); - -type DefaultProps = { - mode: 'date' | 'time' | 'datetime'; -}; - -type Event = Object; - -/** - * Use `DatePickerIOS` to render a date/time picker (selector) on iOS. This is - * a controlled component, so you must hook in to the `onDateChange` callback - * and update the `date` prop in order for the component to update, otherwise - * the user's change will be reverted immediately to reflect `props.date` as the - * source of truth. - */ -var DatePickerIOS = React.createClass({ - // TOOD: Put a better type for _picker - _picker: (undefined: ?$FlowFixMe), - - mixins: [NativeMethodsMixin], - - propTypes: { - ...View.propTypes, - /** - * The currently selected date. - */ - date: PropTypes.instanceOf(Date).isRequired, - - /** - * Date change handler. - * - * This is called when the user changes the date or time in the UI. - * The first and only argument is a Date object representing the new - * date and time. - */ - onDateChange: PropTypes.func.isRequired, - - /** - * Maximum date. - * - * Restricts the range of possible date/time values. - */ - maximumDate: PropTypes.instanceOf(Date), - - /** - * Minimum date. - * - * Restricts the range of possible date/time values. - */ - minimumDate: PropTypes.instanceOf(Date), - - /** - * The date picker mode. - */ - mode: PropTypes.oneOf(['date', 'time', 'datetime']), - - /** - * The interval at which minutes can be selected. - */ - minuteInterval: PropTypes.oneOf([1, 2, 3, 4, 5, 6, 10, 12, 15, 20, 30]), - - /** - * Timezone offset in minutes. - * - * By default, the date picker will use the device's timezone. With this - * parameter, it is possible to force a certain timezone offset. For - * instance, to show times in Pacific Standard Time, pass -7 * 60. - */ - timeZoneOffsetInMinutes: PropTypes.number, - }, - - getDefaultProps: function(): DefaultProps { - return { - mode: 'datetime', - }; - }, - - _onChange: function(event: Event) { - var nativeTimeStamp = event.nativeEvent.timestamp; - this.props.onDateChange && this.props.onDateChange( - new Date(nativeTimeStamp) - ); - this.props.onChange && this.props.onChange(event); - - // We expect the onChange* handlers to be in charge of updating our `date` - // prop. That way they can also disallow/undo/mutate the selection of - // certain values. In other words, the embedder of this component should - // be the source of truth, not the native component. - var propsTimeStamp = this.props.date.getTime(); - if (this._picker && nativeTimeStamp !== propsTimeStamp) { - this._picker.setNativeProps({ - date: propsTimeStamp, - }); - } - }, - - render: function() { - var props = this.props; - return ( - - this._picker = picker } - style={styles.datePickerIOS} - date={props.date.getTime()} - maximumDate={ - props.maximumDate ? props.maximumDate.getTime() : undefined - } - minimumDate={ - props.minimumDate ? props.minimumDate.getTime() : undefined - } - mode={props.mode} - minuteInterval={props.minuteInterval} - timeZoneOffsetInMinutes={props.timeZoneOffsetInMinutes} - onChange={this._onChange} - /> - - ); - } -}); - -var styles = StyleSheet.create({ - datePickerIOS: { - height: RCTDatePickerIOSConsts.ComponentHeight, - width: RCTDatePickerIOSConsts.ComponentWidth, - }, -}); - -var RCTDatePickerIOS = requireNativeComponent('RCTDatePicker', DatePickerIOS, { - nativeOnly: { onChange: true }, -}); - -module.exports = DatePickerIOS; diff --git a/examples/node_modules/react-native/Libraries/Components/MapView/MapView.js b/examples/node_modules/react-native/Libraries/Components/MapView/MapView.js deleted file mode 100644 index 012f5790..00000000 --- a/examples/node_modules/react-native/Libraries/Components/MapView/MapView.js +++ /dev/null @@ -1,397 +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. - * - * @providesModule MapView - * @flow - */ -'use strict'; - -var EdgeInsetsPropType = require('EdgeInsetsPropType'); -var Image = require('Image'); -var NativeMethodsMixin = require('NativeMethodsMixin'); -var Platform = require('Platform'); -var RCTMap = require('UIManager').RCTMap; -var RCTMapConstants = RCTMap && RCTMap.Constants; -var React = require('React'); -var ReactNativeViewAttributes = require('ReactNativeViewAttributes'); -var View = require('View'); - -var deepDiffer = require('deepDiffer'); -var insetsDiffer = require('insetsDiffer'); -var merge = require('merge'); -var processColor = require('processColor'); -var resolveAssetSource = require('resolveAssetSource'); -var requireNativeComponent = require('requireNativeComponent'); - -type Event = Object; -type MapRegion = { - latitude: number; - longitude: number; - latitudeDelta: number; - longitudeDelta: number; -}; - -var MapView = React.createClass({ - mixins: [NativeMethodsMixin], - - checkAnnotationIds: function (annotations: Array) { - - var newAnnotations = annotations.map(function (annotation) { - if (!annotation.id) { - // TODO: add a base64 (or similar) encoder here - annotation.id = encodeURIComponent(JSON.stringify(annotation)); - } - return annotation; - }); - - this.setState({ - annotations: newAnnotations - }); - }, - - checkOverlayIds: function (overlays: Array) { - - var newOverlays = overlays.map(function (overlay) { - if (!overlay.id) { - // TODO: add a base64 (or similar) encoder here - overlay.id = encodeURIComponent(JSON.stringify(overlay)); - } - return overlay; - }); - - this.setState({ - overlays: newOverlays - }); - }, - - componentWillMount: function() { - if (this.props.annotations) { - this.checkAnnotationIds(this.props.annotations); - } - if (this.props.overlays) { - this.checkOverlayIds(this.props.overlays); - } - }, - - componentWillReceiveProps: function(nextProps: Object) { - if (nextProps.annotations) { - this.checkAnnotationIds(nextProps.annotations); - } - if (nextProps.overlays) { - this.checkOverlayIds(nextProps.overlays); - } - }, - - propTypes: { - ...View.propTypes, - /** - * Used to style and layout the `MapView`. See `StyleSheet.js` and - * `ViewStylePropTypes.js` for more info. - */ - style: View.propTypes.style, - - /** - * If `true` the app will ask for the user's location and focus on it. - * Default value is `false`. - * - * **NOTE**: You need to add NSLocationWhenInUseUsageDescription key in - * Info.plist to enable geolocation, otherwise it is going - * to *fail silently*! - */ - showsUserLocation: React.PropTypes.bool, - - /** - * If `false` points of interest won't be displayed on the map. - * Default value is `true`. - * @platform ios - */ - showsPointsOfInterest: React.PropTypes.bool, - - /** - * If `false` compass won't be displayed on the map. - * Default value is `true`. - * @platform ios - */ - showsCompass: React.PropTypes.bool, - - /** - * If `false` the user won't be able to pinch/zoom the map. - * Default value is `true`. - */ - zoomEnabled: React.PropTypes.bool, - - /** - * When this property is set to `true` and a valid camera is associated with - * the map, the camera’s heading angle is used to rotate the plane of the - * map around its center point. When this property is set to `false`, the - * camera’s heading angle is ignored and the map is always oriented so - * that true north is situated at the top of the map view - */ - rotateEnabled: React.PropTypes.bool, - - /** - * When this property is set to `true` and a valid camera is associated - * with the map, the camera’s pitch angle is used to tilt the plane - * of the map. When this property is set to `false`, the camera’s pitch - * angle is ignored and the map is always displayed as if the user - * is looking straight down onto it. - */ - pitchEnabled: React.PropTypes.bool, - - /** - * If `false` the user won't be able to change the map region being displayed. - * Default value is `true`. - */ - scrollEnabled: React.PropTypes.bool, - - /** - * The map type to be displayed. - * - * - standard: standard road map (default) - * - satellite: satellite view - * - hybrid: satellite view with roads and points of interest overlayed - */ - mapType: React.PropTypes.oneOf([ - 'standard', - 'satellite', - 'hybrid', - ]), - - /** - * The region to be displayed by the map. - * - * The region is defined by the center coordinates and the span of - * coordinates to display. - */ - region: React.PropTypes.shape({ - /** - * Coordinates for the center of the map. - */ - latitude: React.PropTypes.number.isRequired, - longitude: React.PropTypes.number.isRequired, - - /** - * Distance between the minimun and the maximum latitude/longitude - * to be displayed. - */ - latitudeDelta: React.PropTypes.number.isRequired, - longitudeDelta: React.PropTypes.number.isRequired, - }), - - /** - * Map annotations with title/subtitle. - */ - annotations: React.PropTypes.arrayOf(React.PropTypes.shape({ - /** - * The location of the annotation. - */ - latitude: React.PropTypes.number.isRequired, - longitude: React.PropTypes.number.isRequired, - - /** - * Whether the pin drop should be animated or not - */ - animateDrop: React.PropTypes.bool, - - /** - * Annotation title/subtile. - */ - title: React.PropTypes.string, - subtitle: React.PropTypes.string, - - /** - * Whether the Annotation has callout buttons. - */ - hasLeftCallout: React.PropTypes.bool, - hasRightCallout: React.PropTypes.bool, - - /** - * Event handlers for callout buttons. - */ - onLeftCalloutPress: React.PropTypes.func, - onRightCalloutPress: React.PropTypes.func, - - /** - * The pin color. This can be any valid color string, or you can use one - * of the predefined PinColors constants. Applies to both standard pins - * and custom pin images. - * - * Note that on iOS 8 and earlier, only the standard PinColor constants - * are supported for regualr pins. For custom pin images, any tintColor - * value is supported on all iOS versions. - * @platform ios - */ - tintColor: React.PropTypes.string, - - /** - * Custom pin image. This must be a static image resource inside the app. - * @platform ios - */ - image: Image.propTypes.source, - - /** - * annotation id - */ - id: React.PropTypes.string, - })), - - /** - * Map overlays - */ - overlays: React.PropTypes.arrayOf(React.PropTypes.shape({ - /** - * Polyline coordinates - */ - coordinates: React.PropTypes.arrayOf(React.PropTypes.shape({ - latitude: React.PropTypes.number.isRequired, - longitude: React.PropTypes.number.isRequired - })), - - /** - * Line attributes - */ - lineWidth: React.PropTypes.number, - strokeColor: React.PropTypes.string, - fillColor: React.PropTypes.string, - - /** - * Overlay id - */ - id: React.PropTypes.string - })), - - /** - * Maximum size of area that can be displayed. - */ - maxDelta: React.PropTypes.number, - - /** - * Minimum size of area that can be displayed. - */ - minDelta: React.PropTypes.number, - - /** - * Insets for the map's legal label, originally at bottom left of the map. - * See `EdgeInsetsPropType.js` for more information. - */ - legalLabelInsets: EdgeInsetsPropType, - - /** - * Callback that is called continuously when the user is dragging the map. - */ - onRegionChange: React.PropTypes.func, - - /** - * Callback that is called once, when the user is done moving the map. - */ - onRegionChangeComplete: React.PropTypes.func, - - /** - * Callback that is called once, when the user taps an annotation. - */ - onAnnotationPress: React.PropTypes.func, - - /** - * @platform android - */ - active: React.PropTypes.bool, - }, - - render: function() { - - let {annotations, overlays} = this.props; - annotations = annotations && annotations.map((annotation: Object) => { - let {tintColor, image} = annotation; - return { - ...annotation, - tintColor: tintColor && processColor(tintColor), - image: image && resolveAssetSource(image), - }; - }); - overlays = overlays && overlays.map((overlay: Object) => { - let {strokeColor, fillColor} = overlay; - return { - ...overlay, - strokeColor: strokeColor && processColor(strokeColor), - fillColor: fillColor && processColor(fillColor), - }; - }); - - // TODO: these should be separate events, to reduce bridge traffic - if (annotations) { - var onPress = (event: Event) => { - if (!annotations) { - return; - } - if (event.nativeEvent.action === 'annotation-click') { - this.props.onAnnotationPress && - this.props.onAnnotationPress(event.nativeEvent.annotation); - } else if (event.nativeEvent.action === 'callout-click') { - // Find the annotation with the id that was pressed - for (let i = 0, l = annotations.length; i < l; i++) { - let annotation = annotations[i]; - if (annotation.id === event.nativeEvent.annotationId) { - // Pass the right function - if (event.nativeEvent.side === 'left') { - annotation.onLeftCalloutPress && - annotation.onLeftCalloutPress(event.nativeEvent); - } else if (event.nativeEvent.side === 'right') { - annotation.onRightCalloutPress && - annotation.onRightCalloutPress(event.nativeEvent); - } - break; - } - } - } - }; - } - - // TODO: these should be separate events, to reduce bridge traffic - if (this.props.onRegionChange || this.props.onRegionChangeComplete) { - var onChange = (event: Event) => { - if (event.nativeEvent.continuous) { - this.props.onRegionChange && - this.props.onRegionChange(event.nativeEvent.region); - } else { - this.props.onRegionChangeComplete && - this.props.onRegionChangeComplete(event.nativeEvent.region); - } - }; - } - - return ( - - ); - }, -}); - -/** - * Standard iOS MapView pin color constants, to be used with the - * `annotation.tintColor` property. On iOS 8 and earlier these are the - * only supported values when using regular pins. On iOS 9 and later - * you are not obliged to use these, but they are useful for matching - * the standard iOS look and feel. - */ -let PinColors = RCTMapConstants && RCTMapConstants.PinColors; -MapView.PinColors = PinColors && { - RED: PinColors.RED, - GREEN: PinColors.GREEN, - PURPLE: PinColors.PURPLE, -}; - -var RCTMap = requireNativeComponent('RCTMap', MapView, { - nativeOnly: {onChange: true, onPress: true} -}); - -module.exports = MapView; diff --git a/examples/node_modules/react-native/Libraries/Components/Navigation/NavigatorIOS.ios.js b/examples/node_modules/react-native/Libraries/Components/Navigation/NavigatorIOS.ios.js deleted file mode 100644 index 37cc1899..00000000 --- a/examples/node_modules/react-native/Libraries/Components/Navigation/NavigatorIOS.ios.js +++ /dev/null @@ -1,681 +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. - * - * @providesModule NavigatorIOS - * @flow - */ -'use strict'; - -var EventEmitter = require('EventEmitter'); -var Image = require('Image'); -var NavigationContext = require('NavigationContext'); -var RCTNavigatorManager = require('NativeModules').NavigatorManager; -var React = require('React'); -var StaticContainer = require('StaticContainer.react'); -var StyleSheet = require('StyleSheet'); -var View = require('View'); - -var invariant = require('invariant'); -var logError = require('logError'); -var requireNativeComponent = require('requireNativeComponent'); -var resolveAssetSource = require('resolveAssetSource'); - -var TRANSITIONER_REF = 'transitionerRef'; - -var PropTypes = React.PropTypes; - -var __uid = 0; -function getuid() { - return __uid++; -} - -var NavigatorTransitionerIOS = React.createClass({ - requestSchedulingNavigation: function(cb) { - RCTNavigatorManager.requestSchedulingJavaScriptNavigation( - React.findNodeHandle(this), - logError, - cb - ); - }, - - render: function() { - return ( - - ); - }, -}); - -type Route = { - component: Function; - title: string; - passProps?: Object; - backButtonTitle?: string; - backButtonIcon?: Object; - leftButtonTitle?: string; - leftButtonIcon?: Object; - onLeftButtonPress?: Function; - rightButtonTitle?: string; - rightButtonIcon?: Object; - onRightButtonPress?: Function; - wrapperStyle?: any; -}; - -type State = { - idStack: Array; - routeStack: Array; - requestedTopOfStack: number; - observedTopOfStack: number; - progress: number; - fromIndex: number; - toIndex: number; - makingNavigatorRequest: boolean; - updatingAllIndicesAtOrBeyond: ?number; -} - -type Event = Object; - -/** - * Think of `` as simply a component that renders an - * `RCTNavigator`, and moves the `RCTNavigator`'s `requestedTopOfStack` pointer - * forward and backward. The `RCTNavigator` interprets changes in - * `requestedTopOfStack` to be pushes and pops of children that are rendered. - * `` always ensures that whenever the `requestedTopOfStack` - * pointer is moved, that we've also rendered enough children so that the - * `RCTNavigator` can carry out the push/pop with those children. - * `` also removes children that will no longer be needed - * (after the pop of a child has been fully completed/animated out). - */ - -/** - * NavigatorIOS wraps UIKit navigation and allows you to add back-swipe - * functionality across your app. - * - * > **NOTE**: This Component is not maintained by Facebook - * > - * > This component is under community responsibility. - * > If a pure JavaScript solution fits your needs you may try the `Navigator` - * > component instead. - * - * #### Routes - * A route is an object used to describe each page in the navigator. The first - * route is provided to NavigatorIOS as `initialRoute`: - * - * ``` - * render: function() { - * return ( - * - * ); - * }, - * ``` - * - * Now MyView will be rendered by the navigator. It will recieve the route - * object in the `route` prop, a navigator, and all of the props specified in - * `passProps`. - * - * See the initialRoute propType for a complete definition of a route. - * - * #### Navigator - * - * A `navigator` is an object of navigation functions that a view can call. It - * is passed as a prop to any component rendered by NavigatorIOS. - * - * ``` - * var MyView = React.createClass({ - * _handleBackButtonPress: function() { - * this.props.navigator.pop(); - * }, - * _handleNextButtonPress: function() { - * this.props.navigator.push(nextRoute); - * }, - * ... - * }); - * ``` - * - * A navigation object contains the following functions: - * - * - `push(route)` - Navigate forward to a new route - * - `pop()` - Go back one page - * - `popN(n)` - Go back N pages at once. When N=1, behavior matches `pop()` - * - `replace(route)` - Replace the route for the current page and immediately - * load the view for the new route - * - `replacePrevious(route)` - Replace the route/view for the previous page - * - `replacePreviousAndPop(route)` - Replaces the previous route/view and - * transitions back to it - * - `resetTo(route)` - Replaces the top item and popToTop - * - `popToRoute(route)` - Go back to the item for a particular route object - * - `popToTop()` - Go back to the top item - * - * Navigator functions are also available on the NavigatorIOS component: - * - * ``` - * var MyView = React.createClass({ - * _handleNavigationRequest: function() { - * this.refs.nav.push(otherRoute); - * }, - * render: () => ( - * - * ), - * }); - * ``` - * - */ -var NavigatorIOS = React.createClass({ - - propTypes: { - - /** - * NavigatorIOS uses "route" objects to identify child views, their props, - * and navigation bar configuration. "push" and all the other navigation - * operations expect routes to be like this: - */ - initialRoute: PropTypes.shape({ - /** - * The React Class to render for this route - */ - component: PropTypes.func.isRequired, - - /** - * The title displayed in the nav bar and back button for this route - */ - title: PropTypes.string.isRequired, - - /** - * Specify additional props passed to the component. NavigatorIOS will - * automatically provide "route" and "navigator" components - */ - passProps: PropTypes.object, - - /** - * If set, the left header button image will appear with this source. Note - * that this doesn't apply for the header of the current view, but the - * ones of the views that are pushed afterward. - */ - backButtonIcon: Image.propTypes.source, - - /** - * If set, the left header button will appear with this name. Note that - * this doesn't apply for the header of the current view, but the ones - * of the views that are pushed afterward. - */ - backButtonTitle: PropTypes.string, - - /** - * If set, the left header button image will appear with this source - */ - leftButtonIcon: Image.propTypes.source, - - /** - * If set, the left header button will appear with this name - */ - leftButtonTitle: PropTypes.string, - - /** - * Called when the left header button is pressed - */ - onLeftButtonPress: PropTypes.func, - - /** - * If set, the right header button image will appear with this source - */ - rightButtonIcon: Image.propTypes.source, - - /** - * If set, the right header button will appear with this name - */ - rightButtonTitle: PropTypes.string, - - /** - * Called when the right header button is pressed - */ - onRightButtonPress: PropTypes.func, - - /** - * Styles for the navigation item containing the component - */ - wrapperStyle: View.propTypes.style, - - }).isRequired, - - /** - * A Boolean value that indicates whether the navigation bar is hidden - */ - navigationBarHidden: PropTypes.bool, - - /** - * A Boolean value that indicates whether to hide the 1px hairline shadow - */ - shadowHidden: PropTypes.bool, - - /** - * The default wrapper style for components in the navigator. - * A common use case is to set the backgroundColor for every page - */ - itemWrapperStyle: View.propTypes.style, - - /** - * The color used for buttons in the navigation bar - */ - tintColor: PropTypes.string, - - /** - * The background color of the navigation bar - */ - barTintColor: PropTypes.string, - - /** - * The text color of the navigation bar title - */ - titleTextColor: PropTypes.string, - - /** - * A Boolean value that indicates whether the navigation bar is translucent - */ - translucent: PropTypes.bool, - - }, - - navigator: (undefined: ?Object), - navigationContext: new NavigationContext(), - - componentWillMount: function() { - // Precompute a pack of callbacks that's frequently generated and passed to - // instances. - this.navigator = { - push: this.push, - pop: this.pop, - popN: this.popN, - replace: this.replace, - replacePrevious: this.replacePrevious, - replacePreviousAndPop: this.replacePreviousAndPop, - resetTo: this.resetTo, - popToRoute: this.popToRoute, - popToTop: this.popToTop, - navigationContext: this.navigationContext, - }; - this._emitWillFocus(this.state.routeStack[this.state.observedTopOfStack]); - }, - - componentDidMount: function() { - this._emitDidFocus(this.state.routeStack[this.state.observedTopOfStack]); - }, - - componentWillUnmount: function() { - this.navigationContext.dispose(); - this.navigationContext = new NavigationContext(); - }, - - getDefaultProps: function(): Object { - return { - translucent: true, - }; - }, - - getInitialState: function(): State { - return { - idStack: [getuid()], - routeStack: [this.props.initialRoute], - // The navigation index that we wish to push/pop to. - requestedTopOfStack: 0, - // The last index that native has sent confirmation of completed push/pop - // for. At this point, we can discard any views that are beyond the - // `requestedTopOfStack`. A value of `null` means we have not received - // any confirmation, ever. We may receive an `observedTopOfStack` without - // ever requesting it - native can instigate pops of its own with the - // backswipe gesture. - observedTopOfStack: 0, - progress: 1, - fromIndex: 0, - toIndex: 0, - // Whether or not we are making a navigator request to push/pop. (Used - // for performance optimization). - makingNavigatorRequest: false, - // Whether or not we are updating children of navigator and if so (not - // `null`) which index marks the beginning of all updates. Used for - // performance optimization. - updatingAllIndicesAtOrBeyond: 0, - }; - }, - - _toFocusOnNavigationComplete: (undefined: any), - - _handleFocusRequest: function(item: any) { - if (this.state.makingNavigatorRequest) { - this._toFocusOnNavigationComplete = item; - } else { - this._getFocusEmitter().emit('focus', item); - } - }, - - _focusEmitter: (undefined: ?EventEmitter), - - _getFocusEmitter: function(): EventEmitter { - // Flow not yet tracking assignments to instance fields. - var focusEmitter = this._focusEmitter; - if (!focusEmitter) { - focusEmitter = new EventEmitter(); - this._focusEmitter = focusEmitter; - } - return focusEmitter; - }, - - getChildContext: function(): { - onFocusRequested: Function; - focusEmitter: EventEmitter; - } { - return { - onFocusRequested: this._handleFocusRequest, - focusEmitter: this._getFocusEmitter(), - }; - }, - - childContextTypes: { - onFocusRequested: React.PropTypes.func, - focusEmitter: React.PropTypes.instanceOf(EventEmitter), - }, - - _tryLockNavigator: function(cb: () => void) { - this.refs[TRANSITIONER_REF].requestSchedulingNavigation( - (acquiredLock) => acquiredLock && cb() - ); - }, - - _handleNavigatorStackChanged: function(e: Event) { - var newObservedTopOfStack = e.nativeEvent.stackLength - 1; - this._emitDidFocus(this.state.routeStack[newObservedTopOfStack]); - - invariant( - newObservedTopOfStack <= this.state.requestedTopOfStack, - 'No navigator item should be pushed without JS knowing about it %s %s', newObservedTopOfStack, this.state.requestedTopOfStack - ); - var wasWaitingForConfirmation = - this.state.requestedTopOfStack !== this.state.observedTopOfStack; - if (wasWaitingForConfirmation) { - invariant( - newObservedTopOfStack === this.state.requestedTopOfStack, - 'If waiting for observedTopOfStack to reach requestedTopOfStack, ' + - 'the only valid observedTopOfStack should be requestedTopOfStack.' - ); - } - // Mark the most recent observation regardless of if we can lock the - // navigator. `observedTopOfStack` merely represents what we've observed - // and this first `setState` is only executed to update debugging - // overlays/navigation bar. - // Also reset progress, toIndex, and fromIndex as they might not end - // in the correct states for a two possible reasons: - // Progress isn't always 0 or 1 at the end, the system rounds - // If the Navigator is offscreen these values won't be updated - // TOOD: Revisit this decision when no longer relying on native navigator. - var nextState = { - observedTopOfStack: newObservedTopOfStack, - makingNavigatorRequest: false, - updatingAllIndicesAtOrBeyond: null, - progress: 1, - toIndex: newObservedTopOfStack, - fromIndex: newObservedTopOfStack, - }; - this.setState(nextState, this._eliminateUnneededChildren); - }, - - _eliminateUnneededChildren: function() { - // Updating the indices that we're deleting and that's all. (Truth: Nothing - // even uses the indices in this case, but let's make this describe the - // truth anyways). - var updatingAllIndicesAtOrBeyond = - this.state.routeStack.length > this.state.observedTopOfStack + 1 ? - this.state.observedTopOfStack + 1 : - null; - this.setState({ - idStack: this.state.idStack.slice(0, this.state.observedTopOfStack + 1), - routeStack: this.state.routeStack.slice(0, this.state.observedTopOfStack + 1), - // Now we rerequest the top of stack that we observed. - requestedTopOfStack: this.state.observedTopOfStack, - makingNavigatorRequest: true, - updatingAllIndicesAtOrBeyond: updatingAllIndicesAtOrBeyond, - }); - }, - - _emitDidFocus: function(route: Route) { - this.navigationContext.emit('didfocus', {route: route}); - }, - - _emitWillFocus: function(route: Route) { - this.navigationContext.emit('willfocus', {route: route}); - }, - - push: function(route: Route) { - invariant(!!route, 'Must supply route to push'); - // Make sure all previous requests are caught up first. Otherwise reject. - if (this.state.requestedTopOfStack === this.state.observedTopOfStack) { - this._tryLockNavigator(() => { - this._emitWillFocus(route); - - var nextStack = this.state.routeStack.concat([route]); - var nextIDStack = this.state.idStack.concat([getuid()]); - this.setState({ - // We have to make sure that we've also supplied enough views to - // satisfy our request to adjust the `requestedTopOfStack`. - idStack: nextIDStack, - routeStack: nextStack, - requestedTopOfStack: nextStack.length - 1, - makingNavigatorRequest: true, - updatingAllIndicesAtOrBeyond: nextStack.length - 1, - }); - }); - } - }, - - popN: function(n: number) { - if (n === 0) { - return; - } - // Make sure all previous requests are caught up first. Otherwise reject. - if (this.state.requestedTopOfStack === this.state.observedTopOfStack) { - if (this.state.requestedTopOfStack > 0) { - this._tryLockNavigator(() => { - var newRequestedTopOfStack = this.state.requestedTopOfStack - n; - invariant(newRequestedTopOfStack >= 0, 'Cannot pop below 0'); - this._emitWillFocus(this.state.routeStack[newRequestedTopOfStack]); - this.setState({ - requestedTopOfStack: newRequestedTopOfStack, - makingNavigatorRequest: true, - // Not actually updating the indices yet until we get the native - // `onNavigationComplete`. - updatingAllIndicesAtOrBeyond: null, - }); - }); - } - } - }, - - pop: function() { - this.popN(1); - }, - - /** - * Replace a route in the navigation stack. - * - * `index` specifies the route in the stack that should be replaced. - * If it's negative, it counts from the back. - */ - replaceAtIndex: function(route: Route, index: number) { - invariant(!!route, 'Must supply route to replace'); - if (index < 0) { - index += this.state.routeStack.length; - } - - if (this.state.routeStack.length <= index) { - return; - } - - // I don't believe we need to lock for a replace since there's no - // navigation actually happening - var nextIDStack = this.state.idStack.slice(); - var nextRouteStack = this.state.routeStack.slice(); - nextIDStack[index] = getuid(); - nextRouteStack[index] = route; - - this.setState({ - idStack: nextIDStack, - routeStack: nextRouteStack, - makingNavigatorRequest: false, - updatingAllIndicesAtOrBeyond: index, - }); - - this._emitWillFocus(route); - this._emitDidFocus(route); - }, - - /** - * Replaces the top of the navigation stack. - */ - replace: function(route: Route) { - this.replaceAtIndex(route, -1); - }, - - /** - * Replace the current route's parent. - */ - replacePrevious: function(route: Route) { - this.replaceAtIndex(route, -2); - }, - - popToTop: function() { - this.popToRoute(this.state.routeStack[0]); - }, - - popToRoute: function(route: Route) { - var indexOfRoute = this.state.routeStack.indexOf(route); - invariant( - indexOfRoute !== -1, - 'Calling pop to route for a route that doesn\'t exist!' - ); - var numToPop = this.state.routeStack.length - indexOfRoute - 1; - this.popN(numToPop); - }, - - replacePreviousAndPop: function(route: Route) { - // Make sure all previous requests are caught up first. Otherwise reject. - if (this.state.requestedTopOfStack !== this.state.observedTopOfStack) { - return; - } - if (this.state.routeStack.length < 2) { - return; - } - this._tryLockNavigator(() => { - this.replacePrevious(route); - this.setState({ - requestedTopOfStack: this.state.requestedTopOfStack - 1, - makingNavigatorRequest: true, - }); - }); - }, - - resetTo: function(route: Route) { - invariant(!!route, 'Must supply route to push'); - // Make sure all previous requests are caught up first. Otherwise reject. - if (this.state.requestedTopOfStack !== this.state.observedTopOfStack) { - return; - } - this.replaceAtIndex(route, 0); - this.popToRoute(route); - }, - - handleNavigationComplete: function(e: Event) { - if (this._toFocusOnNavigationComplete) { - this._getFocusEmitter().emit('focus', this._toFocusOnNavigationComplete); - this._toFocusOnNavigationComplete = null; - } - this._handleNavigatorStackChanged(e); - }, - - _routeToStackItem: function(route: Route, i: number) { - var {component, wrapperStyle, passProps, ...route} = route; - var {itemWrapperStyle, ...props} = this.props; - var shouldUpdateChild = - this.state.updatingAllIndicesAtOrBeyond && - this.state.updatingAllIndicesAtOrBeyond >= i; - var Component = component; - return ( - - - - - - ); - }, - - renderNavigationStackItems: function() { - var shouldRecurseToNavigator = - this.state.makingNavigatorRequest || - this.state.updatingAllIndicesAtOrBeyond !== null; - // If not recursing update to navigator at all, may as well avoid - // computation of navigator children. - var items = shouldRecurseToNavigator ? - this.state.routeStack.map(this._routeToStackItem) : null; - return ( - - - {items} - - - ); - }, - - render: function() { - return ( - - {this.renderNavigationStackItems()} - - ); - }, -}); - -var styles = StyleSheet.create({ - stackItem: { - backgroundColor: 'white', - overflow: 'hidden', - position: 'absolute', - top: 0, - left: 0, - right: 0, - bottom: 0, - }, - transitioner: { - flex: 1, - }, -}); - -var RCTNavigator = requireNativeComponent('RCTNavigator'); -var RCTNavigatorItem = requireNativeComponent('RCTNavItem'); - -module.exports = NavigatorIOS; diff --git a/examples/node_modules/react-native/Libraries/Components/ScrollResponder.js b/examples/node_modules/react-native/Libraries/Components/ScrollResponder.js deleted file mode 100644 index 3374cf22..00000000 --- a/examples/node_modules/react-native/Libraries/Components/ScrollResponder.js +++ /dev/null @@ -1,528 +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. - * - * @providesModule ScrollResponder - * @flow - */ -'use strict'; - -var Dimensions = require('Dimensions'); -var Platform = require('Platform'); -var RCTDeviceEventEmitter = require('RCTDeviceEventEmitter'); -var React = require('React'); -var Subscribable = require('Subscribable'); -var TextInputState = require('TextInputState'); - -var { UIManager, ScrollViewManager } = require('NativeModules'); - -var invariant = require('invariant'); -var warning = require('warning'); - -import type ReactComponent from 'ReactComponent'; - -/** - * Mixin that can be integrated in order to handle scrolling that plays well - * with `ResponderEventPlugin`. Integrate with your platform specific scroll - * views, or even your custom built (every-frame animating) scroll views so that - * all of these systems play well with the `ResponderEventPlugin`. - * - * iOS scroll event timing nuances: - * =============================== - * - * - * Scrolling without bouncing, if you touch down: - * ------------------------------- - * - * 1. `onMomentumScrollBegin` (when animation begins after letting up) - * ... physical touch starts ... - * 2. `onTouchStartCapture` (when you press down to stop the scroll) - * 3. `onTouchStart` (same, but bubble phase) - * 4. `onResponderRelease` (when lifting up - you could pause forever before * lifting) - * 5. `onMomentumScrollEnd` - * - * - * Scrolling with bouncing, if you touch down: - * ------------------------------- - * - * 1. `onMomentumScrollBegin` (when animation begins after letting up) - * ... bounce begins ... - * ... some time elapses ... - * ... physical touch during bounce ... - * 2. `onMomentumScrollEnd` (Makes no sense why this occurs first during bounce) - * 3. `onTouchStartCapture` (immediately after `onMomentumScrollEnd`) - * 4. `onTouchStart` (same, but bubble phase) - * 5. `onTouchEnd` (You could hold the touch start for a long time) - * 6. `onMomentumScrollBegin` (When releasing the view starts bouncing back) - * - * So when we receive an `onTouchStart`, how can we tell if we are touching - * *during* an animation (which then causes the animation to stop)? The only way - * to tell is if the `touchStart` occurred immediately after the - * `onMomentumScrollEnd`. - * - * This is abstracted out for you, so you can just call this.scrollResponderIsAnimating() if - * necessary - * - * `ScrollResponder` also includes logic for blurring a currently focused input - * if one is focused while scrolling. The `ScrollResponder` is a natural place - * to put this logic since it can support not dismissing the keyboard while - * scrolling, unless a recognized "tap"-like gesture has occurred. - * - * The public lifecycle API includes events for keyboard interaction, responder - * interaction, and scrolling (among others). The keyboard callbacks - * `onKeyboardWill/Did/*` are *global* events, but are invoked on scroll - * responder's props so that you can guarantee that the scroll responder's - * internal state has been updated accordingly (and deterministically) by - * the time the props callbacks are invoke. Otherwise, you would always wonder - * if the scroll responder is currently in a state where it recognizes new - * keyboard positions etc. If coordinating scrolling with keyboard movement, - * *always* use these hooks instead of listening to your own global keyboard - * events. - * - * Public keyboard lifecycle API: (props callbacks) - * - * Standard Keyboard Appearance Sequence: - * - * this.props.onKeyboardWillShow - * this.props.onKeyboardDidShow - * - * `onScrollResponderKeyboardDismissed` will be invoked if an appropriate - * tap inside the scroll responder's scrollable region was responsible - * for the dismissal of the keyboard. There are other reasons why the - * keyboard could be dismissed. - * - * this.props.onScrollResponderKeyboardDismissed - * - * Standard Keyboard Hide Sequence: - * - * this.props.onKeyboardWillHide - * this.props.onKeyboardDidHide - */ - -var IS_ANIMATING_TOUCH_START_THRESHOLD_MS = 16; - -type State = { - isTouching: boolean; - lastMomentumScrollBeginTime: number; - lastMomentumScrollEndTime: number; - observedScrollSinceBecomingResponder: boolean; - becameResponderWhileAnimating: boolean; -}; -type Event = Object; - -var ScrollResponderMixin = { - mixins: [Subscribable.Mixin], - scrollResponderMixinGetInitialState: function(): State { - return { - isTouching: false, - lastMomentumScrollBeginTime: 0, - lastMomentumScrollEndTime: 0, - - // Reset to false every time becomes responder. This is used to: - // - Determine if the scroll view has been scrolled and therefore should - // refuse to give up its responder lock. - // - Determine if releasing should dismiss the keyboard when we are in - // tap-to-dismiss mode (!this.props.keyboardShouldPersistTaps). - observedScrollSinceBecomingResponder: false, - becameResponderWhileAnimating: false, - }; - }, - - /** - * Invoke this from an `onScroll` event. - */ - scrollResponderHandleScrollShouldSetResponder: function(): boolean { - return this.state.isTouching; - }, - - /** - * Merely touch starting is not sufficient for a scroll view to become the - * responder. Being the "responder" means that the very next touch move/end - * event will result in an action/movement. - * - * Invoke this from an `onStartShouldSetResponder` event. - * - * `onStartShouldSetResponder` is used when the next move/end will trigger - * some UI movement/action, but when you want to yield priority to views - * nested inside of the view. - * - * There may be some cases where scroll views actually should return `true` - * from `onStartShouldSetResponder`: Any time we are detecting a standard tap - * that gives priority to nested views. - * - * - If a single tap on the scroll view triggers an action such as - * recentering a map style view yet wants to give priority to interaction - * views inside (such as dropped pins or labels), then we would return true - * from this method when there is a single touch. - * - * - Similar to the previous case, if a two finger "tap" should trigger a - * zoom, we would check the `touches` count, and if `>= 2`, we would return - * true. - * - */ - scrollResponderHandleStartShouldSetResponder: function(): boolean { - return false; - }, - - /** - * There are times when the scroll view wants to become the responder - * (meaning respond to the next immediate `touchStart/touchEnd`), in a way - * that *doesn't* give priority to nested views (hence the capture phase): - * - * - Currently animating. - * - Tapping anywhere that is not the focused input, while the keyboard is - * up (which should dismiss the keyboard). - * - * Invoke this from an `onStartShouldSetResponderCapture` event. - */ - scrollResponderHandleStartShouldSetResponderCapture: function(e: Event): boolean { - // First see if we want to eat taps while the keyboard is up - var currentlyFocusedTextInput = TextInputState.currentlyFocusedField(); - if (!this.props.keyboardShouldPersistTaps && - currentlyFocusedTextInput != null && - e.target !== currentlyFocusedTextInput) { - return true; - } - return this.scrollResponderIsAnimating(); - }, - - /** - * Invoke this from an `onResponderReject` event. - * - * Some other element is not yielding its role as responder. Normally, we'd - * just disable the `UIScrollView`, but a touch has already began on it, the - * `UIScrollView` will not accept being disabled after that. The easiest - * solution for now is to accept the limitation of disallowing this - * altogether. To improve this, find a way to disable the `UIScrollView` after - * a touch has already started. - */ - scrollResponderHandleResponderReject: function() { - warning(false, "ScrollView doesn't take rejection well - scrolls anyway"); - }, - - /** - * We will allow the scroll view to give up its lock iff it acquired the lock - * during an animation. This is a very useful default that happens to satisfy - * many common user experiences. - * - * - Stop a scroll on the left edge, then turn that into an outer view's - * backswipe. - * - Stop a scroll mid-bounce at the top, continue pulling to have the outer - * view dismiss. - * - However, without catching the scroll view mid-bounce (while it is - * motionless), if you drag far enough for the scroll view to become - * responder (and therefore drag the scroll view a bit), any backswipe - * navigation of a swipe gesture higher in the view hierarchy, should be - * rejected. - */ - scrollResponderHandleTerminationRequest: function(): boolean { - return !this.state.observedScrollSinceBecomingResponder; - }, - - /** - * Invoke this from an `onTouchEnd` event. - * - * @param {SyntheticEvent} e Event. - */ - scrollResponderHandleTouchEnd: function(e: Event) { - var nativeEvent = e.nativeEvent; - this.state.isTouching = nativeEvent.touches.length !== 0; - this.props.onTouchEnd && this.props.onTouchEnd(e); - }, - - /** - * Invoke this from an `onResponderRelease` event. - */ - scrollResponderHandleResponderRelease: function(e: Event) { - this.props.onResponderRelease && this.props.onResponderRelease(e); - - // By default scroll views will unfocus a textField - // if another touch occurs outside of it - var currentlyFocusedTextInput = TextInputState.currentlyFocusedField(); - if (!this.props.keyboardShouldPersistTaps && - currentlyFocusedTextInput != null && - e.target !== currentlyFocusedTextInput && - !this.state.observedScrollSinceBecomingResponder && - !this.state.becameResponderWhileAnimating) { - this.props.onScrollResponderKeyboardDismissed && - this.props.onScrollResponderKeyboardDismissed(e); - TextInputState.blurTextInput(currentlyFocusedTextInput); - } - }, - - scrollResponderHandleScroll: function(e: Event) { - this.state.observedScrollSinceBecomingResponder = true; - this.props.onScroll && this.props.onScroll(e); - }, - - /** - * Invoke this from an `onResponderGrant` event. - */ - scrollResponderHandleResponderGrant: function(e: Event) { - this.state.observedScrollSinceBecomingResponder = false; - this.props.onResponderGrant && this.props.onResponderGrant(e); - this.state.becameResponderWhileAnimating = this.scrollResponderIsAnimating(); - }, - - /** - * Unfortunately, `onScrollBeginDrag` also fires when *stopping* the scroll - * animation, and there's not an easy way to distinguish a drag vs. stopping - * momentum. - * - * Invoke this from an `onScrollBeginDrag` event. - */ - scrollResponderHandleScrollBeginDrag: function(e: Event) { - this.props.onScrollBeginDrag && this.props.onScrollBeginDrag(e); - }, - - /** - * Invoke this from an `onScrollEndDrag` event. - */ - scrollResponderHandleScrollEndDrag: function(e: Event) { - this.props.onScrollEndDrag && this.props.onScrollEndDrag(e); - }, - - /** - * Invoke this from an `onMomentumScrollBegin` event. - */ - scrollResponderHandleMomentumScrollBegin: function(e: Event) { - this.state.lastMomentumScrollBeginTime = Date.now(); - this.props.onMomentumScrollBegin && this.props.onMomentumScrollBegin(e); - }, - - /** - * Invoke this from an `onMomentumScrollEnd` event. - */ - scrollResponderHandleMomentumScrollEnd: function(e: Event) { - this.state.lastMomentumScrollEndTime = Date.now(); - this.props.onMomentumScrollEnd && this.props.onMomentumScrollEnd(e); - }, - - /** - * Invoke this from an `onTouchStart` event. - * - * Since we know that the `SimpleEventPlugin` occurs later in the plugin - * order, after `ResponderEventPlugin`, we can detect that we were *not* - * permitted to be the responder (presumably because a contained view became - * responder). The `onResponderReject` won't fire in that case - it only - * fires when a *current* responder rejects our request. - * - * @param {SyntheticEvent} e Touch Start event. - */ - scrollResponderHandleTouchStart: function(e: Event) { - this.state.isTouching = true; - this.props.onTouchStart && this.props.onTouchStart(e); - }, - - /** - * Invoke this from an `onTouchMove` event. - * - * Since we know that the `SimpleEventPlugin` occurs later in the plugin - * order, after `ResponderEventPlugin`, we can detect that we were *not* - * permitted to be the responder (presumably because a contained view became - * responder). The `onResponderReject` won't fire in that case - it only - * fires when a *current* responder rejects our request. - * - * @param {SyntheticEvent} e Touch Start event. - */ - scrollResponderHandleTouchMove: function(e: Event) { - this.props.onTouchMove && this.props.onTouchMove(e); - }, - - /** - * A helper function for this class that lets us quickly determine if the - * view is currently animating. This is particularly useful to know when - * a touch has just started or ended. - */ - scrollResponderIsAnimating: function(): boolean { - var now = Date.now(); - var timeSinceLastMomentumScrollEnd = now - this.state.lastMomentumScrollEndTime; - var isAnimating = timeSinceLastMomentumScrollEnd < IS_ANIMATING_TOUCH_START_THRESHOLD_MS || - this.state.lastMomentumScrollEndTime < this.state.lastMomentumScrollBeginTime; - return isAnimating; - }, - - /** - * A helper function to scroll to a specific point in the scrollview. - * This is currently used to help focus on child textview's, but this - * can also be used to quickly scroll to any element we want to focus - */ - scrollResponderScrollTo: function(offsetX: number, offsetY: number) { - if (Platform.OS === 'android') { - UIManager.dispatchViewManagerCommand( - React.findNodeHandle(this), - UIManager.RCTScrollView.Commands.scrollTo, - [Math.round(offsetX), Math.round(offsetY)], - ); - } else { - ScrollViewManager.scrollTo( - React.findNodeHandle(this), - { x: offsetX, y: offsetY } - ); - } - }, - - /** - * Like `scrollResponderScrollTo` but immediately scrolls to the given - * position - */ - scrollResponderScrollWithouthAnimationTo: function(offsetX: number, offsetY: number) { - if (Platform.OS === 'android') { - UIManager.dispatchViewManagerCommand( - React.findNodeHandle(this), - UIManager.RCTScrollView.Commands.scrollWithoutAnimationTo, - [offsetX, offsetY], - ); - } else { - ScrollViewManager.scrollWithoutAnimationTo( - React.findNodeHandle(this), - { x: offsetX, y: offsetY } - ); - } - }, - - /** - * A helper function to zoom to a specific rect in the scrollview. - * @param {object} rect Should have shape {x, y, width, height} - */ - scrollResponderZoomTo: function(rect: { x: number; y: number; width: number; height: number; }) { - if (Platform.OS === 'android') { - invariant('zoomToRect is not implemented'); - } else { - ScrollViewManager.zoomToRect(React.findNodeHandle(this), rect); - } - }, - - /** - * This method should be used as the callback to onFocus in a TextInputs' - * parent view. Note that any module using this mixin needs to return - * the parent view's ref in getScrollViewRef() in order to use this method. - * @param {any} nodeHandle The TextInput node handle - * @param {number} additionalOffset The scroll view's top "contentInset". - * Default is 0. - * @param {bool} preventNegativeScrolling Whether to allow pulling the content - * down to make it meet the keyboard's top. Default is false. - */ - scrollResponderScrollNativeHandleToKeyboard: function(nodeHandle: any, additionalOffset?: number, preventNegativeScrollOffset?: bool) { - this.additionalScrollOffset = additionalOffset || 0; - this.preventNegativeScrollOffset = !!preventNegativeScrollOffset; - UIManager.measureLayout( - nodeHandle, - React.findNodeHandle(this.getInnerViewNode()), - this.scrollResponderTextInputFocusError, - this.scrollResponderInputMeasureAndScrollToKeyboard - ); - }, - - /** - * The calculations performed here assume the scroll view takes up the entire - * screen - even if has some content inset. We then measure the offsets of the - * keyboard, and compensate both for the scroll view's "contentInset". - * - * @param {number} left Position of input w.r.t. table view. - * @param {number} top Position of input w.r.t. table view. - * @param {number} width Width of the text input. - * @param {number} height Height of the text input. - */ - scrollResponderInputMeasureAndScrollToKeyboard: function(left: number, top: number, width: number, height: number) { - var keyboardScreenY = Dimensions.get('window').height; - if (this.keyboardWillOpenTo) { - keyboardScreenY = this.keyboardWillOpenTo.endCoordinates.screenY; - } - var scrollOffsetY = top - keyboardScreenY + height + this.additionalScrollOffset; - - // By default, this can scroll with negative offset, pulling the content - // down so that the target component's bottom meets the keyboard's top. - // If requested otherwise, cap the offset at 0 minimum to avoid content - // shifting down. - if (this.preventNegativeScrollOffset) { - scrollOffsetY = Math.max(0, scrollOffsetY); - } - this.scrollResponderScrollTo(0, scrollOffsetY); - - this.additionalOffset = 0; - this.preventNegativeScrollOffset = false; - }, - - scrollResponderTextInputFocusError: function(e: Event) { - console.error('Error measuring text field: ', e); - }, - - /** - * `componentWillMount` is the closest thing to a standard "constructor" for - * React components. - * - * The `keyboardWillShow` is called before input focus. - */ - componentWillMount: function() { - this.keyboardWillOpenTo = null; - this.additionalScrollOffset = 0; - this.addListenerOn(RCTDeviceEventEmitter, 'keyboardWillShow', this.scrollResponderKeyboardWillShow); - this.addListenerOn(RCTDeviceEventEmitter, 'keyboardWillHide', this.scrollResponderKeyboardWillHide); - this.addListenerOn(RCTDeviceEventEmitter, 'keyboardDidShow', this.scrollResponderKeyboardDidShow); - this.addListenerOn(RCTDeviceEventEmitter, 'keyboardDidHide', this.scrollResponderKeyboardDidHide); - }, - - /** - * Warning, this may be called several times for a single keyboard opening. - * It's best to store the information in this method and then take any action - * at a later point (either in `keyboardDidShow` or other). - * - * Here's the order that events occur in: - * - focus - * - willShow {startCoordinates, endCoordinates} several times - * - didShow several times - * - blur - * - willHide {startCoordinates, endCoordinates} several times - * - didHide several times - * - * The `ScrollResponder` providesModule callbacks for each of these events. - * Even though any user could have easily listened to keyboard events - * themselves, using these `props` callbacks ensures that ordering of events - * is consistent - and not dependent on the order that the keyboard events are - * subscribed to. This matters when telling the scroll view to scroll to where - * the keyboard is headed - the scroll responder better have been notified of - * the keyboard destination before being instructed to scroll to where the - * keyboard will be. Stick to the `ScrollResponder` callbacks, and everything - * will work. - * - * WARNING: These callbacks will fire even if a keyboard is displayed in a - * different navigation pane. Filter out the events to determine if they are - * relevant to you. (For example, only if you receive these callbacks after - * you had explicitly focused a node etc). - */ - scrollResponderKeyboardWillShow: function(e: Event) { - this.keyboardWillOpenTo = e; - this.props.onKeyboardWillShow && this.props.onKeyboardWillShow(e); - }, - - scrollResponderKeyboardWillHide: function(e: Event) { - this.keyboardWillOpenTo = null; - this.props.onKeyboardWillHide && this.props.onKeyboardWillHide(e); - }, - - scrollResponderKeyboardDidShow: function(e: Event) { - // TODO(7693961): The event for DidShow is not available on iOS yet. - // Use the one from WillShow and do not assign. - if (e) { - this.keyboardWillOpenTo = e; - } - this.props.onKeyboardDidShow && this.props.onKeyboardDidShow(e); - }, - - scrollResponderKeyboardDidHide: function(e: Event) { - this.keyboardWillOpenTo = null; - this.props.onKeyboardDidHide && this.props.onKeyboardDidHide(e); - } - -}; - -var ScrollResponder = { - Mixin: ScrollResponderMixin, -}; - -module.exports = ScrollResponder; diff --git a/examples/node_modules/react-native/Libraries/Components/ScrollView/ScrollView.js b/examples/node_modules/react-native/Libraries/Components/ScrollView/ScrollView.js deleted file mode 100644 index 8069b964..00000000 --- a/examples/node_modules/react-native/Libraries/Components/ScrollView/ScrollView.js +++ /dev/null @@ -1,518 +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. - * - * @providesModule ScrollView - * @flow - */ -'use strict'; - -var EdgeInsetsPropType = require('EdgeInsetsPropType'); -var Platform = require('Platform'); -var PointPropType = require('PointPropType'); -var RCTScrollView = require('NativeModules').UIManager.RCTScrollView; -var RCTScrollViewManager = require('NativeModules').ScrollViewManager; -var React = require('React'); -var ReactNativeViewAttributes = require('ReactNativeViewAttributes'); -var ScrollResponder = require('ScrollResponder'); -var StyleSheet = require('StyleSheet'); -var StyleSheetPropType = require('StyleSheetPropType'); -var View = require('View'); -var ViewStylePropTypes = require('ViewStylePropTypes'); - -var deepDiffer = require('deepDiffer'); -var dismissKeyboard = require('dismissKeyboard'); -var flattenStyle = require('flattenStyle'); -var insetsDiffer = require('insetsDiffer'); -var invariant = require('invariant'); -var pointsDiffer = require('pointsDiffer'); -var requireNativeComponent = require('requireNativeComponent'); - -var PropTypes = React.PropTypes; - -var SCROLLVIEW = 'ScrollView'; -var INNERVIEW = 'InnerScrollView'; - -/** - * Component that wraps platform ScrollView while providing - * integration with touch locking "responder" system. - * - * Keep in mind that ScrollViews must have a bounded height in order to work, - * since they contain unbounded-height children into a bounded container (via - * a scroll interaction). In order to bound the height of a ScrollView, either - * set the height of the view directly (discouraged) or make sure all parent - * views have bounded height. Forgetting to transfer `{flex: 1}` down the - * view stack can lead to errors here, which the element inspector makes - * easy to debug. - * - * Doesn't yet support other contained responders from blocking this scroll - * view from becoming the responder. - */ -var ScrollView = React.createClass({ - propTypes: { - ...View.propTypes, - /** - * Controls whether iOS should automatically adjust the content inset - * for scroll views that are placed behind a navigation bar or - * tab bar/ toolbar. The default value is true. - * @platform ios - */ - automaticallyAdjustContentInsets: PropTypes.bool, - /** - * The amount by which the scroll view content is inset from the edges - * of the scroll view. Defaults to `{0, 0, 0, 0}`. - * @platform ios - */ - contentInset: EdgeInsetsPropType, - /** - * Used to manually set the starting scroll offset. - * The default value is `{x: 0, y: 0}`. - * @platform ios - */ - contentOffset: PointPropType, - /** - * When true, the scroll view bounces when it reaches the end of the - * content if the content is larger then the scroll view along the axis of - * the scroll direction. When false, it disables all bouncing even if - * the `alwaysBounce*` props are true. The default value is true. - * @platform ios - */ - bounces: PropTypes.bool, - /** - * When true, gestures can drive zoom past min/max and the zoom will animate - * to the min/max value at gesture end, otherwise the zoom will not exceed - * the limits. - * @platform ios - */ - bouncesZoom: PropTypes.bool, - /** - * When true, the scroll view bounces horizontally when it reaches the end - * even if the content is smaller than the scroll view itself. The default - * value is true when `horizontal={true}` and false otherwise. - * @platform ios - */ - alwaysBounceHorizontal: PropTypes.bool, - /** - * When true, the scroll view bounces vertically when it reaches the end - * even if the content is smaller than the scroll view itself. The default - * value is false when `horizontal={true}` and true otherwise. - * @platform ios - */ - alwaysBounceVertical: PropTypes.bool, - /** - * When true, the scroll view automatically centers the content when the - * content is smaller than the scroll view bounds; when the content is - * larger than the scroll view, this property has no effect. The default - * value is false. - * @platform ios - */ - centerContent: PropTypes.bool, - /** - * These styles will be applied to the scroll view content container which - * wraps all of the child views. Example: - * - * return ( - * - * - * ); - * ... - * var styles = StyleSheet.create({ - * contentContainer: { - * paddingVertical: 20 - * } - * }); - */ - contentContainerStyle: StyleSheetPropType(ViewStylePropTypes), - /** - * A floating-point number that determines how quickly the scroll view - * decelerates after the user lifts their finger. Reasonable choices include - * - Normal: 0.998 (the default) - * - Fast: 0.9 - * @platform ios - */ - decelerationRate: PropTypes.number, - /** - * When true, the scroll view's children are arranged horizontally in a row - * instead of vertically in a column. The default value is false. - */ - horizontal: PropTypes.bool, - /** - * When true, the ScrollView will try to lock to only vertical or horizontal - * scrolling while dragging. The default value is false. - * @platform ios - */ - directionalLockEnabled: PropTypes.bool, - /** - * When false, once tracking starts, won't try to drag if the touch moves. - * The default value is true. - * @platform ios - */ - canCancelContentTouches: PropTypes.bool, - /** - * Determines whether the keyboard gets dismissed in response to a drag. - * - 'none' (the default), drags do not dismiss the keyboard. - * - 'on-drag', the keyboard is dismissed when a drag begins. - * - 'interactive', the keyboard is dismissed interactively with the drag and moves in - * synchrony with the touch; dragging upwards cancels the dismissal. - * On android this is not supported and it will have the same behavior as 'none'. - */ - keyboardDismissMode: PropTypes.oneOf([ - 'none', // default - 'interactive', - 'on-drag', - ]), - /** - * When false, tapping outside of the focused text input when the keyboard - * is up dismisses the keyboard. When true, the scroll view will not catch - * taps, and the keyboard will not dismiss automatically. The default value - * is false. - */ - keyboardShouldPersistTaps: PropTypes.bool, - /** - * The maximum allowed zoom scale. The default value is 1.0. - * @platform ios - */ - maximumZoomScale: PropTypes.number, - /** - * The minimum allowed zoom scale. The default value is 1.0. - * @platform ios - */ - minimumZoomScale: PropTypes.number, - /** - * Fires at most once per frame during scrolling. The frequency of the - * events can be contolled using the `scrollEventThrottle` prop. - */ - onScroll: PropTypes.func, - /** - * Called when a scrolling animation ends. - * @platform ios - */ - onScrollAnimationEnd: PropTypes.func, - /** - * Called when scrollable content view of the ScrollView changes. It's - * implemented using onLayout handler attached to the content container - * which this ScrollView renders. - */ - onContentSizeChange: PropTypes.func, - /** - * When true, the scroll view stops on multiples of the scroll view's size - * when scrolling. This can be used for horizontal pagination. The default - * value is false. - * @platform ios - */ - pagingEnabled: PropTypes.bool, - /** - * When false, the content does not scroll. - * The default value is true. - * @platform ios - */ - scrollEnabled: PropTypes.bool, - /** - * This controls how often the scroll event will be fired while scrolling - * (in events per seconds). A higher number yields better accuracy for code - * that is tracking the scroll position, but can lead to scroll performance - * problems due to the volume of information being send over the bridge. - * The default value is zero, which means the scroll event will be sent - * only once each time the view is scrolled. - * @platform ios - */ - scrollEventThrottle: PropTypes.number, - /** - * The amount by which the scroll view indicators are inset from the edges - * of the scroll view. This should normally be set to the same value as - * the `contentInset`. Defaults to `{0, 0, 0, 0}`. - * @platform ios - */ - scrollIndicatorInsets: EdgeInsetsPropType, - /** - * When true, the scroll view scrolls to top when the status bar is tapped. - * The default value is true. - * @platform ios - */ - scrollsToTop: PropTypes.bool, - /** - * When true, shows a horizontal scroll indicator. - */ - showsHorizontalScrollIndicator: PropTypes.bool, - /** - * When true, shows a vertical scroll indicator. - */ - showsVerticalScrollIndicator: PropTypes.bool, - /** - * An array of child indices determining which children get docked to the - * top of the screen when scrolling. For example, passing - * `stickyHeaderIndices={[0]}` will cause the first child to be fixed to the - * top of the scroll view. This property is not supported in conjunction - * with `horizontal={true}`. - * @platform ios - */ - stickyHeaderIndices: PropTypes.arrayOf(PropTypes.number), - style: StyleSheetPropType(ViewStylePropTypes), - /** - * When set, causes the scroll view to stop at multiples of the value of - * `snapToInterval`. This can be used for paginating through children - * that have lengths smaller than the scroll view. Used in combination - * with `snapToAlignment`. - * @platform ios - */ - snapToInterval: PropTypes.number, - /** - * When `snapToInterval` is set, `snapToAlignment` will define the relationship - * of the the snapping to the scroll view. - * - `start` (the default) will align the snap at the left (horizontal) or top (vertical) - * - `center` will align the snap in the center - * - `end` will align the snap at the right (horizontal) or bottom (vertical) - * @platform ios - */ - snapToAlignment: PropTypes.oneOf([ - 'start', // default - 'center', - 'end', - ]), - /** - * Experimental: When true, offscreen child views (whose `overflow` value is - * `hidden`) are removed from their native backing superview when offscreen. - * This can improve scrolling performance on long lists. The default value is - * true. - */ - removeClippedSubviews: PropTypes.bool, - /** - * The current scale of the scroll view content. The default value is 1.0. - * @platform ios - */ - zoomScale: PropTypes.number, - - /** - * When defined, displays a UIRefreshControl. - * Invoked with a function to stop refreshing when the UIRefreshControl is animating. - * - * ``` - * (endRefreshing) => { - * endRefreshing(); - * } - * ``` - * - * @platform ios - */ - onRefreshStart: PropTypes.func, - - }, - - mixins: [ScrollResponder.Mixin], - - getInitialState: function() { - return this.scrollResponderMixinGetInitialState(); - }, - - setNativeProps: function(props: Object) { - this.refs[SCROLLVIEW].setNativeProps(props); - }, - - endRefreshing: function() { - RCTScrollViewManager.endRefreshing( - React.findNodeHandle(this) - ); - }, - - /** - * Returns a reference to the underlying scroll responder, which supports - * operations like `scrollTo`. All ScrollView-like components should - * implement this method so that they can be composed while providing access - * to the underlying scroll responder's methods. - */ - getScrollResponder: function(): ReactComponent { - return this; - }, - - getInnerViewNode: function(): any { - return React.findNodeHandle(this.refs[INNERVIEW]); - }, - - scrollTo: function(destY?: number, destX?: number) { - // $FlowFixMe - Don't know how to pass Mixin correctly. Postpone for now - this.getScrollResponder().scrollResponderScrollTo(destX || 0, destY || 0); - }, - - scrollWithoutAnimationTo: function(destY?: number, destX?: number) { - // $FlowFixMe - Don't know how to pass Mixin correctly. Postpone for now - this.getScrollResponder().scrollResponderScrollWithouthAnimationTo( - destX || 0, - destY || 0, - ); - }, - - handleScroll: function(e: Object) { - if (__DEV__) { - if (this.props.onScroll && !this.props.scrollEventThrottle) { - console.log( - 'You specified `onScroll` on a but not ' + - '`scrollEventThrottle`. You will only receive one event. ' + - 'Using `16` you get all the events but be aware that it may ' + - 'cause frame drops, use a bigger number if you don\'t need as ' + - 'much precision.' - ); - } - } - if (Platform.OS === 'android') { - if (this.props.keyboardDismissMode === 'on-drag') { - dismissKeyboard(); - } - } - this.scrollResponderHandleScroll(e); - }, - - _handleContentOnLayout: function(e: Object) { - var {width, height} = e.nativeEvent.layout; - this.props.onContentSizeChange && this.props.onContentSizeChange(width, height); - }, - - render: function() { - var contentContainerStyle = [ - this.props.horizontal && styles.contentContainerHorizontal, - this.props.contentContainerStyle, - ]; - if (__DEV__ && this.props.style) { - var style = flattenStyle(this.props.style); - var childLayoutProps = ['alignItems', 'justifyContent'] - .filter((prop) => style && style[prop] !== undefined); - invariant( - childLayoutProps.length === 0, - 'ScrollView child layout (' + JSON.stringify(childLayoutProps) + - ') must by applied through the contentContainerStyle prop.' - ); - } - - var contentSizeChangeProps = {}; - if (this.props.onContentSizeChange) { - contentSizeChangeProps = { - onLayout: this._handleContentOnLayout, - }; - } - - var contentContainer = - - {this.props.children} - ; - - var alwaysBounceHorizontal = - this.props.alwaysBounceHorizontal !== undefined ? - this.props.alwaysBounceHorizontal : - this.props.horizontal; - - var alwaysBounceVertical = - this.props.alwaysBounceVertical !== undefined ? - this.props.alwaysBounceVertical : - !this.props.horizontal; - - var props = { - ...this.props, - alwaysBounceHorizontal, - alwaysBounceVertical, - style: ([styles.base, this.props.style]: ?Array), - onTouchStart: this.scrollResponderHandleTouchStart, - onTouchMove: this.scrollResponderHandleTouchMove, - onTouchEnd: this.scrollResponderHandleTouchEnd, - onScrollBeginDrag: this.scrollResponderHandleScrollBeginDrag, - onScrollEndDrag: this.scrollResponderHandleScrollEndDrag, - onMomentumScrollBegin: this.scrollResponderHandleMomentumScrollBegin, - onMomentumScrollEnd: this.scrollResponderHandleMomentumScrollEnd, - onStartShouldSetResponder: this.scrollResponderHandleStartShouldSetResponder, - onStartShouldSetResponderCapture: this.scrollResponderHandleStartShouldSetResponderCapture, - onScrollShouldSetResponder: this.scrollResponderHandleScrollShouldSetResponder, - onScroll: this.handleScroll, - onResponderGrant: this.scrollResponderHandleResponderGrant, - onResponderTerminationRequest: this.scrollResponderHandleTerminationRequest, - onResponderTerminate: this.scrollResponderHandleTerminate, - onResponderRelease: this.scrollResponderHandleResponderRelease, - onResponderReject: this.scrollResponderHandleResponderReject, - }; - - var onRefreshStart = this.props.onRefreshStart; - // this is necessary because if we set it on props, even when empty, - // it'll trigger the default pull-to-refresh behaviour on native. - props.onRefreshStart = onRefreshStart - ? function() { onRefreshStart && onRefreshStart(this.endRefreshing); }.bind(this) - : null; - - var ScrollViewClass; - if (Platform.OS === 'ios') { - ScrollViewClass = RCTScrollView; - } else if (Platform.OS === 'android') { - if (this.props.horizontal) { - ScrollViewClass = AndroidHorizontalScrollView; - } else { - ScrollViewClass = AndroidScrollView; - } - } - invariant( - ScrollViewClass !== undefined, - 'ScrollViewClass must not be undefined' - ); - - return ( - - {contentContainer} - - ); - } -}); - -var styles = StyleSheet.create({ - base: { - flex: 1, - }, - contentContainerHorizontal: { - alignSelf: 'flex-start', - flexDirection: 'row', - }, -}); - -var validAttributes = { - ...ReactNativeViewAttributes.UIView, - alwaysBounceHorizontal: true, - alwaysBounceVertical: true, - automaticallyAdjustContentInsets: true, - bounces: true, - centerContent: true, - contentInset: {diff: insetsDiffer}, - contentOffset: {diff: pointsDiffer}, - decelerationRate: true, - horizontal: true, - keyboardDismissMode: true, - keyboardShouldPersistTaps: true, - maximumZoomScale: true, - minimumZoomScale: true, - pagingEnabled: true, - removeClippedSubviews: true, - scrollEnabled: true, - scrollIndicatorInsets: {diff: insetsDiffer}, - scrollsToTop: true, - showsHorizontalScrollIndicator: true, - showsVerticalScrollIndicator: true, - snapToInterval: true, - snapToAlignment: true, - stickyHeaderIndices: {diff: deepDiffer}, - scrollEventThrottle: true, - zoomScale: true, -}; - -if (Platform.OS === 'android') { - var AndroidScrollView = requireNativeComponent('RCTScrollView', ScrollView); - var AndroidHorizontalScrollView = requireNativeComponent( - 'AndroidHorizontalScrollView', - ScrollView - ); -} else if (Platform.OS === 'ios') { - var RCTScrollView = requireNativeComponent('RCTScrollView', ScrollView); -} - -module.exports = ScrollView; diff --git a/examples/node_modules/react-native/Libraries/Components/StaticRenderer.js b/examples/node_modules/react-native/Libraries/Components/StaticRenderer.js deleted file mode 100644 index 8f6cabde..00000000 --- a/examples/node_modules/react-native/Libraries/Components/StaticRenderer.js +++ /dev/null @@ -1,31 +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. - * - * @providesModule StaticRenderer - * @flow - */ -'use strict'; - -var React = require('React'); - -var StaticRenderer = React.createClass({ - propTypes: { - shouldUpdate: React.PropTypes.bool.isRequired, - render: React.PropTypes.func.isRequired, - }, - - shouldComponentUpdate: function(nextProps: { shouldUpdate: boolean }): boolean { - return nextProps.shouldUpdate; - }, - - render: function(): ReactElement { - return this.props.render(); - }, -}); - -module.exports = StaticRenderer; diff --git a/examples/node_modules/react-native/Libraries/Components/StatusBar/StatusBarIOS.ios.js b/examples/node_modules/react-native/Libraries/Components/StatusBar/StatusBarIOS.ios.js deleted file mode 100644 index 59369ef1..00000000 --- a/examples/node_modules/react-native/Libraries/Components/StatusBar/StatusBarIOS.ios.js +++ /dev/null @@ -1,44 +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. - * - * @providesModule StatusBarIOS - * @flow - */ -'use strict'; - -var RCTStatusBarManager = require('NativeModules').StatusBarManager; - -type StatusBarStyle = $Enum<{ - 'default': string, - 'light-content': string, -}>; - -type StatusBarAnimation = $Enum<{ - 'none': string, - 'fade': string, - 'slide': string, -}>; - -var StatusBarIOS = { - - setStyle(style: StatusBarStyle, animated?: boolean) { - animated = animated || false; - RCTStatusBarManager.setStyle(style, animated); - }, - - setHidden(hidden: boolean, animation?: StatusBarAnimation) { - animation = animation || 'none'; - RCTStatusBarManager.setHidden(hidden, animation); - }, - - setNetworkActivityIndicatorVisible(visible: boolean) { - RCTStatusBarManager.setNetworkActivityIndicatorVisible(visible); - }, -}; - -module.exports = StatusBarIOS; diff --git a/examples/node_modules/react-native/Libraries/Components/Subscribable.js b/examples/node_modules/react-native/Libraries/Components/Subscribable.js deleted file mode 100644 index 8474b214..00000000 --- a/examples/node_modules/react-native/Libraries/Components/Subscribable.js +++ /dev/null @@ -1,64 +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. - * - * @providesModule Subscribable - * @flow - */ -'use strict'; - -import type EventEmitter from 'EventEmitter'; - -/** - * Subscribable provides a mixin for safely subscribing a component to an - * eventEmitter - * - * This will be replaced with the observe interface that will be coming soon to - * React Core - */ - -var Subscribable = {}; - -Subscribable.Mixin = { - - componentWillMount: function() { - this._subscribableSubscriptions = []; - }, - - componentWillUnmount: function() { - this._subscribableSubscriptions.forEach( - (subscription) => subscription.remove() - ); - this._subscribableSubscriptions = null; - }, - - /** - * Special form of calling `addListener` that *guarantees* that a - * subscription *must* be tied to a component instance, and therefore will - * be cleaned up when the component is unmounted. It is impossible to create - * the subscription and pass it in - this method must be the one to create - * the subscription and therefore can guarantee it is retained in a way that - * will be cleaned up. - * - * @param {EventEmitter} eventEmitter emitter to subscribe to. - * @param {string} eventType Type of event to listen to. - * @param {function} listener Function to invoke when event occurs. - * @param {object} context Object to use as listener context. - */ - addListenerOn: function( - eventEmitter: EventEmitter, - eventType: string, - listener: Function, - context: Object - ) { - this._subscribableSubscriptions.push( - eventEmitter.addListener(eventType, listener, context) - ); - } -}; - -module.exports = Subscribable; diff --git a/examples/node_modules/react-native/Libraries/Components/SwitchIOS/SwitchIOS.android.js b/examples/node_modules/react-native/Libraries/Components/SwitchIOS/SwitchIOS.android.js deleted file mode 100644 index 9fde1a65..00000000 --- a/examples/node_modules/react-native/Libraries/Components/SwitchIOS/SwitchIOS.android.js +++ /dev/null @@ -1,46 +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. - * - * @providesModule SwitchIOS - */ - -'use strict'; - -var React = require('React'); -var StyleSheet = require('StyleSheet'); -var Text = require('Text'); -var View = require('View'); - -var DummySwitchIOS = React.createClass({ - render: function() { - return ( - - SwitchIOS is not supported on this platform! - - ); - }, -}); - -var styles = StyleSheet.create({ - dummySwitchIOS: { - width: 120, - height: 50, - backgroundColor: '#ffbcbc', - borderWidth: 1, - borderColor: 'red', - alignItems: 'center', - justifyContent: 'center', - }, - text: { - color: '#333333', - margin: 5, - fontSize: 10, - } -}); - -module.exports = DummySwitchIOS; diff --git a/examples/node_modules/react-native/Libraries/Components/SwitchIOS/SwitchIOS.ios.js b/examples/node_modules/react-native/Libraries/Components/SwitchIOS/SwitchIOS.ios.js deleted file mode 100644 index 35514f66..00000000 --- a/examples/node_modules/react-native/Libraries/Components/SwitchIOS/SwitchIOS.ios.js +++ /dev/null @@ -1,121 +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. - * - * @providesModule SwitchIOS - * @flow - * - * This is a controlled component version of RCTSwitch. - */ -'use strict'; - -var NativeMethodsMixin = require('NativeMethodsMixin'); -var PropTypes = require('ReactPropTypes'); -var React = require('React'); -var StyleSheet = require('StyleSheet'); -var View = require('View'); - -var requireNativeComponent = require('requireNativeComponent'); - -var SWITCH = 'switch'; - -type DefaultProps = { - value: boolean; - disabled: boolean; -}; - -type Event = Object; - -/** - * Use `SwitchIOS` to render a boolean input on iOS. This is - * a controlled component, so you must hook in to the `onValueChange` callback - * and update the `value` prop in order for the component to update, otherwise - * the user's change will be reverted immediately to reflect `props.value` as the - * source of truth. - */ -var SwitchIOS = React.createClass({ - mixins: [NativeMethodsMixin], - - propTypes: { - ...View.propTypes, - /** - * The value of the switch, if true the switch will be turned on. - * Default value is false. - */ - value: PropTypes.bool, - - /** - * If true the user won't be able to toggle the switch. - * Default value is false. - */ - disabled: PropTypes.bool, - - /** - * Callback that is called when the user toggles the switch. - */ - onValueChange: PropTypes.func, - - /** - * Background color when the switch is turned on. - */ - onTintColor: PropTypes.string, - - /** - * Background color for the switch round button. - */ - thumbTintColor: PropTypes.string, - - /** - * Background color when the switch is turned off. - */ - tintColor: PropTypes.string, - }, - - getDefaultProps: function(): DefaultProps { - return { - value: false, - disabled: false, - }; - }, - - _onChange: function(event: Event) { - // The underlying switch might have changed, but we're controlled, - // and so want to ensure it represents our value. - this.refs[SWITCH].setNativeProps({value: this.props.value}); - - if (this.props.value === event.nativeEvent.value || this.props.disabled) { - return; - } - - this.props.onChange && this.props.onChange(event); - this.props.onValueChange && this.props.onValueChange(event.nativeEvent.value); - }, - - render: function() { - return ( - - ); - } -}); - -var styles = StyleSheet.create({ - rkSwitch: { - height: 31, - width: 51, - }, -}); - -var RCTSwitch = requireNativeComponent('RCTSwitch', SwitchIOS, { - nativeOnly: { onChange: true } -}); - -module.exports = SwitchIOS; diff --git a/examples/node_modules/react-native/Libraries/Components/TabBarIOS/TabBarIOS.android.js b/examples/node_modules/react-native/Libraries/Components/TabBarIOS/TabBarIOS.android.js deleted file mode 100644 index 95b820f5..00000000 --- a/examples/node_modules/react-native/Libraries/Components/TabBarIOS/TabBarIOS.android.js +++ /dev/null @@ -1,34 +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. - * - * @providesModule TabBarIOS - */ - -'use strict'; - -var React = require('React'); -var View = require('View'); -var StyleSheet = require('StyleSheet'); - -var DummyTabBarIOS = React.createClass({ - render: function() { - return ( - - {this.props.children} - - ); - } -}); - -var styles = StyleSheet.create({ - tabGroup: { - flex: 1, - } -}); - -module.exports = DummyTabBarIOS; diff --git a/examples/node_modules/react-native/Libraries/Components/TabBarIOS/TabBarIOS.ios.js b/examples/node_modules/react-native/Libraries/Components/TabBarIOS/TabBarIOS.ios.js deleted file mode 100644 index 660c8c62..00000000 --- a/examples/node_modules/react-native/Libraries/Components/TabBarIOS/TabBarIOS.ios.js +++ /dev/null @@ -1,64 +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. - * - * @providesModule TabBarIOS - * @flow - */ -'use strict'; - -var React = require('React'); -var StyleSheet = require('StyleSheet'); -var TabBarItemIOS = require('TabBarItemIOS'); -var View = require('View'); - -var requireNativeComponent = require('requireNativeComponent'); - -var TabBarIOS = React.createClass({ - statics: { - Item: TabBarItemIOS, - }, - - propTypes: { - ...View.propTypes, - style: View.propTypes.style, - /** - * Color of the currently selected tab icon - */ - tintColor: React.PropTypes.string, - /** - * Background color of the tab bar - */ - barTintColor: React.PropTypes.string, - /** - * A Boolean value that indicates whether the tab bar is translucent - */ - translucent: React.PropTypes.bool, - }, - - render: function() { - return ( - - {this.props.children} - - ); - } -}); - -var styles = StyleSheet.create({ - tabGroup: { - flex: 1, - } -}); - -var RCTTabBar = requireNativeComponent('RCTTabBar', TabBarIOS); - -module.exports = TabBarIOS; diff --git a/examples/node_modules/react-native/Libraries/Components/TabBarIOS/TabBarItemIOS.android.js b/examples/node_modules/react-native/Libraries/Components/TabBarIOS/TabBarItemIOS.android.js deleted file mode 100644 index 6eb46c36..00000000 --- a/examples/node_modules/react-native/Libraries/Components/TabBarIOS/TabBarItemIOS.android.js +++ /dev/null @@ -1,44 +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. - * - * @providesModule TabBarItemIOS - */ - -'use strict'; - -var React = require('React'); -var View = require('View'); -var StyleSheet = require('StyleSheet'); - -var DummyTab = React.createClass({ - render: function() { - if (!this.props.selected) { - return ; - } - return ( - - {this.props.children} - - ); - } -}); - -var styles = StyleSheet.create({ - tab: { - // TODO(5405356): Implement overflow: visible so position: absolute isn't useless - // position: 'absolute', - top: 0, - right: 0, - bottom: 0, - left: 0, - borderColor: 'red', - borderWidth: 1, - } -}); - -module.exports = DummyTab; diff --git a/examples/node_modules/react-native/Libraries/Components/TabBarIOS/TabBarItemIOS.ios.js b/examples/node_modules/react-native/Libraries/Components/TabBarIOS/TabBarItemIOS.ios.js deleted file mode 100644 index f3fb6964..00000000 --- a/examples/node_modules/react-native/Libraries/Components/TabBarIOS/TabBarItemIOS.ios.js +++ /dev/null @@ -1,135 +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. - * - * @providesModule TabBarItemIOS - * @noflow - */ -'use strict'; - -var Image = require('Image'); -var React = require('React'); -var StaticContainer = require('StaticContainer.react'); -var StyleSheet = require('StyleSheet'); -var View = require('View'); - -var requireNativeComponent = require('requireNativeComponent'); - -var TabBarItemIOS = React.createClass({ - propTypes: { - ...View.propTypes, - /** - * Little red bubble that sits at the top right of the icon. - */ - badge: React.PropTypes.oneOfType([ - React.PropTypes.string, - React.PropTypes.number, - ]), - /** - * Items comes with a few predefined system icons. Note that if you are - * using them, the title and selectedIcon will be overriden with the - * system ones. - */ - systemIcon: React.PropTypes.oneOf([ - 'bookmarks', - 'contacts', - 'downloads', - 'favorites', - 'featured', - 'history', - 'more', - 'most-recent', - 'most-viewed', - 'recents', - 'search', - 'top-rated', - ]), - /** - * A custom icon for the tab. It is ignored when a system icon is defined. - */ - icon: Image.propTypes.source, - /** - * A custom icon when the tab is selected. It is ignored when a system - * icon is defined. If left empty, the icon will be tinted in blue. - */ - selectedIcon: Image.propTypes.source, - /** - * Callback when this tab is being selected, you should change the state of your - * component to set selected={true}. - */ - onPress: React.PropTypes.func, - /** - * It specifies whether the children are visible or not. If you see a - * blank content, you probably forgot to add a selected one. - */ - selected: React.PropTypes.bool, - /** - * React style object. - */ - style: View.propTypes.style, - /** - * Text that appears under the icon. It is ignored when a system icon - * is defined. - */ - title: React.PropTypes.string, - }, - - getInitialState: function() { - return { - hasBeenSelected: false, - }; - }, - - componentWillMount: function() { - if (this.props.selected) { - this.setState({hasBeenSelected: true}); - } - }, - - componentWillReceiveProps: function(nextProps: { selected?: boolean }) { - if (this.state.hasBeenSelected || nextProps.selected) { - this.setState({hasBeenSelected: true}); - } - }, - - render: function() { - var {style, children, ...props} = this.props; - - // if the tab has already been shown once, always continue to show it so we - // preserve state between tab transitions - if (this.state.hasBeenSelected) { - var tabContents = - - {children} - ; - } else { - var tabContents = ; - } - - return ( - - {tabContents} - - ); - } -}); - -var styles = StyleSheet.create({ - tab: { - position: 'absolute', - top: 0, - right: 0, - bottom: 0, - left: 0, - } -}); - -var RCTTabBarItem = requireNativeComponent('RCTTabBarItem', TabBarItemIOS); - -module.exports = TabBarItemIOS; diff --git a/examples/node_modules/react-native/Libraries/Components/TextInput/TextInput.js b/examples/node_modules/react-native/Libraries/Components/TextInput/TextInput.js deleted file mode 100644 index 9f8f44ed..00000000 --- a/examples/node_modules/react-native/Libraries/Components/TextInput/TextInput.js +++ /dev/null @@ -1,594 +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. - * - * @providesModule TextInput - * @flow - */ -'use strict'; - -var DocumentSelectionState = require('DocumentSelectionState'); -var EventEmitter = require('EventEmitter'); -var NativeMethodsMixin = require('NativeMethodsMixin'); -var Platform = require('Platform'); -var PropTypes = require('ReactPropTypes'); -var React = require('React'); -var ReactChildren = require('ReactChildren'); -var StyleSheet = require('StyleSheet'); -var Text = require('Text'); -var TextInputState = require('TextInputState'); -var TimerMixin = require('react-timer-mixin'); -var TouchableWithoutFeedback = require('TouchableWithoutFeedback'); -var UIManager = require('UIManager'); -var View = require('View'); - -var createReactNativeComponentClass = require('createReactNativeComponentClass'); -var emptyFunction = require('emptyFunction'); -var invariant = require('invariant'); -var requireNativeComponent = require('requireNativeComponent'); - -var onlyMultiline = { - onTextInput: true, // not supported in Open Source yet - children: true, -}; - -var notMultiline = { - // nothing yet -}; - -if (Platform.OS === 'android') { - var AndroidTextInput = requireNativeComponent('AndroidTextInput', null); -} else if (Platform.OS === 'ios') { - var RCTTextView = requireNativeComponent('RCTTextView', null); - var RCTTextField = requireNativeComponent('RCTTextField', null); -} - -type Event = Object; - -/** - * A foundational component for inputting text into the app via a - * keyboard. Props provide configurability for several features, such as - * auto-correction, auto-capitalization, placeholder text, and different keyboard - * types, such as a numeric keypad. - * - * The simplest use case is to plop down a `TextInput` and subscribe to the - * `onChangeText` events to read the user input. There are also other events, - * such as `onSubmitEditing` and `onFocus` that can be subscribed to. A simple - * example: - * - * ``` - * this.setState({text})} - * value={this.state.text} - * /> - * ``` - * - * Note that some props are only available with `multiline={true/false}`: - */ -var TextInput = React.createClass({ - statics: { - /* TODO(brentvatne) docs are needed for this */ - State: TextInputState, - }, - - propTypes: { - ...View.propTypes, - /** - * Can tell TextInput to automatically capitalize certain characters. - * - * - characters: all characters, - * - words: first letter of each word - * - sentences: first letter of each sentence (default) - * - none: don't auto capitalize anything - */ - autoCapitalize: PropTypes.oneOf([ - 'none', - 'sentences', - 'words', - 'characters', - ]), - /** - * If false, disables auto-correct. The default value is true. - */ - autoCorrect: PropTypes.bool, - /** - * If true, focuses the input on componentDidMount. - * The default value is false. - */ - autoFocus: PropTypes.bool, - /** - * Set the position of the cursor from where editing will begin. - * @platform android - */ - textAlign: PropTypes.oneOf([ - 'start', - 'center', - 'end', - ]), - /** - * Aligns text vertically within the TextInput. - * @platform android - */ - textAlignVertical: PropTypes.oneOf([ - 'top', - 'center', - 'bottom', - ]), - /** - * If false, text is not editable. The default value is true. - */ - editable: PropTypes.bool, - /** - * Determines which keyboard to open, e.g.`numeric`. - * - * The following values work across platforms: - * - default - * - numeric - * - email-address - */ - keyboardType: PropTypes.oneOf([ - // Cross-platform - 'default', - 'numeric', - 'email-address', - // iOS-only - 'ascii-capable', - 'numbers-and-punctuation', - 'url', - 'number-pad', - 'phone-pad', - 'name-phone-pad', - 'decimal-pad', - 'twitter', - 'web-search', - ]), - /** - * Determines the color of the keyboard. - * @platform ios - */ - keyboardAppearance: PropTypes.oneOf([ - 'default', - 'light', - 'dark', - ]), - /** - * Determines how the return key should look. - * @platform ios - */ - returnKeyType: PropTypes.oneOf([ - 'default', - 'go', - 'google', - 'join', - 'next', - 'route', - 'search', - 'send', - 'yahoo', - 'done', - 'emergency-call', - ]), - /** - * Limits the maximum number of characters that can be entered. Use this - * instead of implementing the logic in JS to avoid flicker. - */ - maxLength: PropTypes.number, - /** - * Sets the number of lines for a TextInput. Use it with multiline set to - * true to be able to fill the lines. - * @platform android - */ - numberOfLines: PropTypes.number, - /** - * If true, the keyboard disables the return key when there is no text and - * automatically enables it when there is text. The default value is false. - * @platform ios - */ - enablesReturnKeyAutomatically: PropTypes.bool, - /** - * If true, the text input can be multiple lines. - * The default value is false. - */ - multiline: PropTypes.bool, - /** - * Callback that is called when the text input is blurred - */ - onBlur: PropTypes.func, - /** - * Callback that is called when the text input is focused - */ - onFocus: PropTypes.func, - /** - * Callback that is called when the text input's text changes. - */ - onChange: PropTypes.func, - /** - * Callback that is called when the text input's text changes. - * Changed text is passed as an argument to the callback handler. - */ - onChangeText: PropTypes.func, - /** - * Callback that is called when text input ends. - */ - onEndEditing: PropTypes.func, - /** - * Callback that is called when the text input's submit button is pressed. - * Invalid if multiline={true} is specified. - */ - onSubmitEditing: PropTypes.func, - /** - * Callback that is called when a key is pressed. - * Pressed key value is passed as an argument to the callback handler. - * Fires before onChange callbacks. - * @platform ios - */ - onKeyPress: PropTypes.func, - /** - * Invoked on mount and layout changes with `{x, y, width, height}`. - */ - onLayout: PropTypes.func, - /** - * The string that will be rendered before text input has been entered - */ - placeholder: PropTypes.string, - /** - * The text color of the placeholder string - */ - placeholderTextColor: PropTypes.string, - /** - * If true, the text input obscures the text entered so that sensitive text - * like passwords stay secure. The default value is false. - */ - secureTextEntry: PropTypes.bool, - /** - * See DocumentSelectionState.js, some state that is responsible for - * maintaining selection information for a document - * @platform ios - */ - selectionState: PropTypes.instanceOf(DocumentSelectionState), - /** - * The value to show for the text input. TextInput is a controlled - * component, which means the native value will be forced to match this - * value prop if provided. For most uses this works great, but in some - * cases this may cause flickering - one common cause is preventing edits - * by keeping value the same. In addition to simply setting the same value, - * either set `editable={false}`, or set/update `maxLength` to prevent - * unwanted edits without flicker. - */ - value: PropTypes.string, - /** - * Provides an initial value that will change when the user starts typing. - * Useful for simple use-cases where you don't want to deal with listening - * to events and updating the value prop to keep the controlled state in sync. - */ - defaultValue: PropTypes.string, - /** - * When the clear button should appear on the right side of the text view - * @platform ios - */ - clearButtonMode: PropTypes.oneOf([ - 'never', - 'while-editing', - 'unless-editing', - 'always', - ]), - /** - * If true, clears the text field automatically when editing begins - * @platform ios - */ - clearTextOnFocus: PropTypes.bool, - /** - * If true, all text will automatically be selected on focus - * @platform ios - */ - selectTextOnFocus: PropTypes.bool, - /** - * If true, the text field will blur when submitted. - * The default value is true for single-line fields and false for - * multiline fields. Note that for multiline fields, setting blurOnSubmit - * to true means that pressing return will blur the field and trigger the - * onSubmitEditing event instead of inserting a newline into the field. - * @platform ios - */ - blurOnSubmit: PropTypes.bool, - /** - * Styles - */ - style: Text.propTypes.style, - /** - * Used to locate this view in end-to-end tests - */ - testID: PropTypes.string, - /** - * The color of the textInput underline. - * @platform android - */ - underlineColorAndroid: PropTypes.string, - }, - - /** - * `NativeMethodsMixin` will look for this when invoking `setNativeProps`. We - * make `this` look like an actual native component class. - */ - mixins: [NativeMethodsMixin, TimerMixin], - - viewConfig: - ((Platform.OS === 'ios' && RCTTextField ? - RCTTextField.viewConfig : - (Platform.OS === 'android' && AndroidTextInput ? - AndroidTextInput.viewConfig : - {})) : Object), - - isFocused: function(): boolean { - return TextInputState.currentlyFocusedField() === - React.findNodeHandle(this.refs.input); - }, - - getInitialState: function() { - return { - mostRecentEventCount: 0, - }; - }, - - contextTypes: { - onFocusRequested: React.PropTypes.func, - focusEmitter: React.PropTypes.instanceOf(EventEmitter), - }, - - _focusSubscription: (undefined: ?Function), - - componentDidMount: function() { - if (!this.context.focusEmitter) { - if (this.props.autoFocus) { - this.requestAnimationFrame(this.focus); - } - return; - } - this._focusSubscription = this.context.focusEmitter.addListener( - 'focus', - (el) => { - if (this === el) { - this.requestAnimationFrame(this.focus); - } else if (this.isFocused()) { - this.blur(); - } - } - ); - if (this.props.autoFocus) { - this.context.onFocusRequested(this); - } - }, - - componentWillUnmount: function() { - this._focusSubscription && this._focusSubscription.remove(); - if (this.isFocused()) { - this.blur(); - } - }, - - getChildContext: function(): Object { - return {isInAParentText: true}; - }, - - childContextTypes: { - isInAParentText: React.PropTypes.bool - }, - - clear: function() { - this.setNativeProps({text: ''}); - }, - - render: function() { - if (Platform.OS === 'ios') { - return this._renderIOS(); - } else if (Platform.OS === 'android') { - return this._renderAndroid(); - } - }, - - _getText: function(): ?string { - return typeof this.props.value === 'string' ? - this.props.value : - this.props.defaultValue; - }, - - _renderIOS: function() { - var textContainer; - - var onSelectionChange; - if (this.props.selectionState || this.props.onSelectionChange) { - onSelectionChange = (event: Event) => { - if (this.props.selectionState) { - var selection = event.nativeEvent.selection; - this.props.selectionState.update(selection.start, selection.end); - } - this.props.onSelectionChange && this.props.onSelectionChange(event); - }; - } - - var props = Object.assign({}, this.props); - props.style = [styles.input, this.props.style]; - if (!props.multiline) { - for (var propKey in onlyMultiline) { - if (props[propKey]) { - throw new Error( - 'TextInput prop `' + propKey + '` is only supported with multiline.' - ); - } - } - textContainer = - ; - } else { - for (var propKey in notMultiline) { - if (props[propKey]) { - throw new Error( - 'TextInput prop `' + propKey + '` cannot be used with multiline.' - ); - } - } - - var children = props.children; - var childCount = 0; - ReactChildren.forEach(children, () => ++childCount); - invariant( - !(props.value && childCount), - 'Cannot specify both value and children.' - ); - if (childCount > 1) { - children = {children}; - } - if (props.inputView) { - children = [children, props.inputView]; - } - textContainer = - ; - } - - return ( - - {textContainer} - - ); - }, - - _renderAndroid: function() { - var autoCapitalize = UIManager.UIText.AutocapitalizationType[this.props.autoCapitalize]; - var textAlign = - UIManager.AndroidTextInput.Constants.TextAlign[this.props.textAlign]; - var textAlignVertical = - UIManager.AndroidTextInput.Constants.TextAlignVertical[this.props.textAlignVertical]; - var children = this.props.children; - var childCount = 0; - ReactChildren.forEach(children, () => ++childCount); - invariant( - !(this.props.value && childCount), - 'Cannot specify both value and children.' - ); - if (childCount > 1) { - children = {children}; - } - var textContainer = - ; - - return ( - - {textContainer} - - ); - }, - - _onFocus: function(event: Event) { - if (this.props.onFocus) { - this.props.onFocus(event); - } - }, - - _onPress: function(event: Event) { - if (this.props.editable || this.props.editable === undefined) { - this.focus(); - } - }, - - _onChange: function(event: Event) { - if (Platform.OS === 'android') { - // Android expects the event count to be updated as soon as possible. - this.refs.input.setNativeProps({ - mostRecentEventCount: event.nativeEvent.eventCount, - }); - } - var text = event.nativeEvent.text; - var eventCount = event.nativeEvent.eventCount; - this.props.onChange && this.props.onChange(event); - this.props.onChangeText && this.props.onChangeText(text); - this.setState({mostRecentEventCount: eventCount}, () => { - // NOTE: this doesn't seem to be needed on iOS - keeping for now in case it's required on Android - if (Platform.OS === 'android') { - // This is a controlled component, so make sure to force the native value - // to match. Most usage shouldn't need this, but if it does this will be - // more correct but might flicker a bit and/or cause the cursor to jump. - if (text !== this.props.value && typeof this.props.value === 'string') { - this.refs.input.setNativeProps({ - text: this.props.value, - }); - } - } - }); - }, - - _onBlur: function(event: Event) { - this.blur(); - if (this.props.onBlur) { - this.props.onBlur(event); - } - }, - - _onTextInput: function(event: Event) { - this.props.onTextInput && this.props.onTextInput(event); - }, -}); - -var styles = StyleSheet.create({ - input: { - alignSelf: 'stretch', - }, -}); - -module.exports = TextInput; diff --git a/examples/node_modules/react-native/Libraries/Components/TextInput/TextInputState.js b/examples/node_modules/react-native/Libraries/Components/TextInput/TextInputState.js deleted file mode 100644 index 276bba0d..00000000 --- a/examples/node_modules/react-native/Libraries/Components/TextInput/TextInputState.js +++ /dev/null @@ -1,76 +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. - * - * @providesModule TextInputState - * @flow - * - * This class is responsible for coordinating the "focused" - * state for TextInputs. All calls relating to the keyboard - * should be funneled through here - */ -'use strict'; - -var Platform = require('Platform'); -var UIManager = require('UIManager'); - -var TextInputState = { - /** - * Internal state - */ - _currentlyFocusedID: (null: ?number), - - /** - * Returns the ID of the currently focused text field, if one exists - * If no text field is focused it returns null - */ - currentlyFocusedField: function(): ?number { - return this._currentlyFocusedID; - }, - - /** - * @param {number} TextInputID id of the text field to focus - * Focuses the specified text field - * noop if the text field was already focused - */ - focusTextInput: function(textFieldID: ?number) { - if (this._currentlyFocusedID !== textFieldID && textFieldID !== null) { - this._currentlyFocusedID = textFieldID; - if (Platform.OS === 'ios') { - UIManager.focus(textFieldID); - } else if (Platform.OS === 'android') { - UIManager.dispatchViewManagerCommand( - textFieldID, - UIManager.AndroidTextInput.Commands.focusTextInput, - null - ); - } - } - }, - - /** - * @param {number} textFieldID id of the text field to focus - * Unfocuses the specified text field - * noop if it wasn't focused - */ - blurTextInput: function(textFieldID: ?number) { - if (this._currentlyFocusedID === textFieldID && textFieldID !== null) { - this._currentlyFocusedID = null; - if (Platform.OS === 'ios') { - UIManager.blur(textFieldID); - } else if (Platform.OS === 'android') { - UIManager.dispatchViewManagerCommand( - textFieldID, - UIManager.AndroidTextInput.Commands.blurTextInput, - null - ); - } - } - } -}; - -module.exports = TextInputState; diff --git a/examples/node_modules/react-native/Libraries/Components/Touchable/TouchableBounce.js b/examples/node_modules/react-native/Libraries/Components/Touchable/TouchableBounce.js deleted file mode 100644 index d3c16967..00000000 --- a/examples/node_modules/react-native/Libraries/Components/Touchable/TouchableBounce.js +++ /dev/null @@ -1,133 +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. - * - * @providesModule TouchableBounce - * @flow - */ -'use strict'; - -var Animated = require('Animated'); -var EdgeInsetsPropType = require('EdgeInsetsPropType'); -var NativeMethodsMixin = require('NativeMethodsMixin'); -var React = require('React'); -var Touchable = require('Touchable'); - -type Event = Object; - -type State = { - animationID: ?number; - scale: Animated.Value; -}; - -var PRESS_RETENTION_OFFSET = {top: 20, left: 20, right: 20, bottom: 30}; - -/** - * Example of using the `TouchableMixin` to play well with other responder - * locking views including `ScrollView`. `TouchableMixin` provides touchable - * hooks (`this.touchableHandle*`) that we forward events to. In turn, - * `TouchableMixin` expects us to implement some abstract methods to handle - * interesting interactions such as `handleTouchablePress`. - */ -var TouchableBounce = React.createClass({ - mixins: [Touchable.Mixin, NativeMethodsMixin], - - propTypes: { - onPress: React.PropTypes.func, - onPressIn: React.PropTypes.func, - onPressOut: React.PropTypes.func, - // The function passed takes a callback to start the animation which should - // be run after this onPress handler is done. You can use this (for example) - // to update UI before starting the animation. - onPressWithCompletion: React.PropTypes.func, - // the function passed is called after the animation is complete - onPressAnimationComplete: React.PropTypes.func, - /** - * When the scroll view is disabled, this defines how far your touch may - * move off of the button, before deactivating the button. Once deactivated, - * try moving it back and you'll see that the button is once again - * reactivated! Move it back and forth several times while the scroll view - * is disabled. Ensure you pass in a constant to reduce memory allocations. - */ - pressRetentionOffset: EdgeInsetsPropType, - }, - - getInitialState: function(): State { - return { - ...this.touchableGetInitialState(), - scale: new Animated.Value(1), - }; - }, - - bounceTo: function( - value: number, - velocity: number, - bounciness: number, - callback?: ?Function - ) { - Animated.spring(this.state.scale, { - toValue: value, - velocity, - bounciness, - }).start(callback); - }, - - /** - * `Touchable.Mixin` self callbacks. The mixin will invoke these if they are - * defined on your component. - */ - touchableHandleActivePressIn: function(e: Event) { - this.bounceTo(0.93, 0.1, 0); - this.props.onPressIn && this.props.onPressIn(e); - }, - - touchableHandleActivePressOut: function(e: Event) { - this.bounceTo(1, 0.4, 0); - this.props.onPressOut && this.props.onPressOut(e); - }, - - touchableHandlePress: function(e: Event) { - var onPressWithCompletion = this.props.onPressWithCompletion; - if (onPressWithCompletion) { - onPressWithCompletion(() => { - this.state.scale.setValue(0.93); - this.bounceTo(1, 10, 10, this.props.onPressAnimationComplete); - }); - return; - } - - this.bounceTo(1, 10, 10, this.props.onPressAnimationComplete); - this.props.onPress && this.props.onPress(e); - }, - - touchableGetPressRectOffset: function(): typeof PRESS_RETENTION_OFFSET { - return this.props.pressRetentionOffset || PRESS_RETENTION_OFFSET; - }, - - touchableGetHighlightDelayMS: function(): number { - return 0; - }, - - render: function(): ReactElement { - return ( - - {this.props.children} - - ); - } -}); - -module.exports = TouchableBounce; diff --git a/examples/node_modules/react-native/Libraries/Components/Touchable/TouchableHighlight.js b/examples/node_modules/react-native/Libraries/Components/Touchable/TouchableHighlight.js deleted file mode 100644 index 67c1e55a..00000000 --- a/examples/node_modules/react-native/Libraries/Components/Touchable/TouchableHighlight.js +++ /dev/null @@ -1,249 +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. - * - * @providesModule TouchableHighlight - * @noflow - */ -'use strict'; - -// Note (avik): add @flow when Flow supports spread properties in propTypes - -var NativeMethodsMixin = require('NativeMethodsMixin'); -var React = require('React'); -var ReactNativeViewAttributes = require('ReactNativeViewAttributes'); -var StyleSheet = require('StyleSheet'); -var TimerMixin = require('react-timer-mixin'); -var Touchable = require('Touchable'); -var TouchableWithoutFeedback = require('TouchableWithoutFeedback'); -var View = require('View'); - -var ensureComponentIsNative = require('ensureComponentIsNative'); -var ensurePositiveDelayProps = require('ensurePositiveDelayProps'); -var keyOf = require('keyOf'); -var merge = require('merge'); -var onlyChild = require('onlyChild'); - -type Event = Object; - -var DEFAULT_PROPS = { - activeOpacity: 0.8, - underlayColor: 'black', -}; - -var PRESS_RETENTION_OFFSET = {top: 20, left: 20, right: 20, bottom: 30}; - -/** - * A wrapper for making views respond properly to touches. - * On press down, the opacity of the wrapped view is decreased, which allows - * the underlay color to show through, darkening or tinting the view. The - * underlay comes from adding a view to the view hierarchy, which can sometimes - * cause unwanted visual artifacts if not used correctly, for example if the - * backgroundColor of the wrapped view isn't explicitly set to an opaque color. - * - * Example: - * - * ``` - * renderButton: function() { - * return ( - * - * - * - * ); - * }, - * ``` - * > **NOTE**: TouchableHighlight supports only one child - * > - * > If you wish to have several child components, wrap them in a View. - */ - -var TouchableHighlight = React.createClass({ - propTypes: { - ...TouchableWithoutFeedback.propTypes, - /** - * Determines what the opacity of the wrapped view should be when touch is - * active. - */ - activeOpacity: React.PropTypes.number, - /** - * The color of the underlay that will show through when the touch is - * active. - */ - underlayColor: React.PropTypes.string, - style: View.propTypes.style, - /** - * Called immediately after the underlay is shown - */ - onShowUnderlay: React.PropTypes.func, - /** - * Called immediately after the underlay is hidden - */ - onHideUnderlay: React.PropTypes.func, - }, - - mixins: [NativeMethodsMixin, TimerMixin, Touchable.Mixin], - - getDefaultProps: () => DEFAULT_PROPS, - - // Performance optimization to avoid constantly re-generating these objects. - computeSyntheticState: function(props) { - return { - activeProps: { - style: { - opacity: props.activeOpacity, - } - }, - activeUnderlayProps: { - style: { - backgroundColor: props.underlayColor, - } - }, - underlayStyle: [ - INACTIVE_UNDERLAY_PROPS.style, - props.style, - ] - }; - }, - - getInitialState: function() { - return merge( - this.touchableGetInitialState(), this.computeSyntheticState(this.props) - ); - }, - - componentDidMount: function() { - ensurePositiveDelayProps(this.props); - ensureComponentIsNative(this.refs[CHILD_REF]); - }, - - componentDidUpdate: function() { - ensureComponentIsNative(this.refs[CHILD_REF]); - }, - - componentWillReceiveProps: function(nextProps) { - ensurePositiveDelayProps(nextProps); - if (nextProps.activeOpacity !== this.props.activeOpacity || - nextProps.underlayColor !== this.props.underlayColor || - nextProps.style !== this.props.style) { - this.setState(this.computeSyntheticState(nextProps)); - } - }, - - viewConfig: { - uiViewClassName: 'RCTView', - validAttributes: ReactNativeViewAttributes.RCTView - }, - - /** - * `Touchable.Mixin` self callbacks. The mixin will invoke these if they are - * defined on your component. - */ - touchableHandleActivePressIn: function(e: Event) { - this.clearTimeout(this._hideTimeout); - this._hideTimeout = null; - this._showUnderlay(); - this.props.onPressIn && this.props.onPressIn(e); - }, - - touchableHandleActivePressOut: function(e: Event) { - if (!this._hideTimeout) { - this._hideUnderlay(); - } - this.props.onPressOut && this.props.onPressOut(e); - }, - - touchableHandlePress: function(e: Event) { - this.clearTimeout(this._hideTimeout); - this._showUnderlay(); - this._hideTimeout = this.setTimeout(this._hideUnderlay, - this.props.delayPressOut || 100); - this.props.onPress && this.props.onPress(e); - }, - - touchableHandleLongPress: function(e: Event) { - this.props.onLongPress && this.props.onLongPress(e); - }, - - touchableGetPressRectOffset: function() { - return this.props.pressRetentionOffset || PRESS_RETENTION_OFFSET; - }, - - touchableGetHighlightDelayMS: function() { - return this.props.delayPressIn; - }, - - touchableGetLongPressDelayMS: function() { - return this.props.delayLongPress; - }, - - touchableGetPressOutDelayMS: function() { - return this.props.delayPressOut; - }, - - _showUnderlay: function() { - if (!this.isMounted()) { - return; - } - - this.refs[UNDERLAY_REF].setNativeProps(this.state.activeUnderlayProps); - this.refs[CHILD_REF].setNativeProps(this.state.activeProps); - this.props.onShowUnderlay && this.props.onShowUnderlay(); - }, - - _hideUnderlay: function() { - this.clearTimeout(this._hideTimeout); - this._hideTimeout = null; - if (this.refs[UNDERLAY_REF]) { - this.refs[CHILD_REF].setNativeProps(INACTIVE_CHILD_PROPS); - this.refs[UNDERLAY_REF].setNativeProps({ - ...INACTIVE_UNDERLAY_PROPS, - style: this.state.underlayStyle, - }); - this.props.onHideUnderlay && this.props.onHideUnderlay(); - } - }, - - render: function() { - return ( - - {React.cloneElement( - onlyChild(this.props.children), - { - ref: CHILD_REF, - } - )} - - ); - } -}); - -var CHILD_REF = keyOf({childRef: null}); -var UNDERLAY_REF = keyOf({underlayRef: null}); -var INACTIVE_CHILD_PROPS = { - style: StyleSheet.create({x: {opacity: 1.0}}).x, -}; -var INACTIVE_UNDERLAY_PROPS = { - style: StyleSheet.create({x: {backgroundColor: 'transparent'}}).x, -}; - -module.exports = TouchableHighlight; diff --git a/examples/node_modules/react-native/Libraries/Components/Touchable/TouchableOpacity.js b/examples/node_modules/react-native/Libraries/Components/Touchable/TouchableOpacity.js deleted file mode 100644 index 627dd120..00000000 --- a/examples/node_modules/react-native/Libraries/Components/Touchable/TouchableOpacity.js +++ /dev/null @@ -1,174 +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. - * - * @providesModule TouchableOpacity - * @noflow - */ -'use strict'; - -// Note (avik): add @flow when Flow supports spread properties in propTypes - -var Animated = require('Animated'); -var NativeMethodsMixin = require('NativeMethodsMixin'); -var React = require('React'); -var TimerMixin = require('react-timer-mixin'); -var Touchable = require('Touchable'); -var TouchableWithoutFeedback = require('TouchableWithoutFeedback'); - -var ensurePositiveDelayProps = require('ensurePositiveDelayProps'); -var flattenStyle = require('flattenStyle'); - -type Event = Object; - -var PRESS_RETENTION_OFFSET = {top: 20, left: 20, right: 20, bottom: 30}; - -/** - * A wrapper for making views respond properly to touches. - * On press down, the opacity of the wrapped view is decreased, dimming it. - * This is done without actually changing the view hierarchy, and in general is - * easy to add to an app without weird side-effects. - * - * Example: - * - * ``` - * renderButton: function() { - * return ( - * - * - * - * ); - * }, - * ``` - */ -var TouchableOpacity = React.createClass({ - mixins: [TimerMixin, Touchable.Mixin, NativeMethodsMixin], - - propTypes: { - ...TouchableWithoutFeedback.propTypes, - /** - * Determines what the opacity of the wrapped view should be when touch is - * active. - */ - activeOpacity: React.PropTypes.number, - }, - - getDefaultProps: function() { - return { - activeOpacity: 0.2, - }; - }, - - getInitialState: function() { - return { - ...this.touchableGetInitialState(), - anim: new Animated.Value(1), - }; - }, - - componentDidMount: function() { - ensurePositiveDelayProps(this.props); - }, - - componentWillReceiveProps: function(nextProps) { - ensurePositiveDelayProps(nextProps); - }, - - setOpacityTo: function(value) { - Animated.timing( - this.state.anim, - {toValue: value, duration: 150} - ).start(); - }, - - /** - * `Touchable.Mixin` self callbacks. The mixin will invoke these if they are - * defined on your component. - */ - touchableHandleActivePressIn: function(e: Event) { - this.clearTimeout(this._hideTimeout); - this._hideTimeout = null; - this._opacityActive(); - this.props.onPressIn && this.props.onPressIn(e); - }, - - touchableHandleActivePressOut: function(e: Event) { - if (!this._hideTimeout) { - this._opacityInactive(); - } - this.props.onPressOut && this.props.onPressOut(e); - }, - - touchableHandlePress: function(e: Event) { - this.clearTimeout(this._hideTimeout); - this._opacityActive(); - this._hideTimeout = this.setTimeout( - this._opacityInactive, - this.props.delayPressOut || 100 - ); - this.props.onPress && this.props.onPress(e); - }, - - touchableHandleLongPress: function(e: Event) { - this.props.onLongPress && this.props.onLongPress(e); - }, - - touchableGetPressRectOffset: function() { - return this.props.pressRetentionOffset || PRESS_RETENTION_OFFSET; - }, - - touchableGetHighlightDelayMS: function() { - return this.props.delayPressIn || 0; - }, - - touchableGetLongPressDelayMS: function() { - return this.props.delayLongPress === 0 ? 0 : - this.props.delayLongPress || 500; - }, - - touchableGetPressOutDelayMS: function() { - return this.props.delayPressOut; - }, - - _opacityActive: function() { - this.setOpacityTo(this.props.activeOpacity); - }, - - _opacityInactive: function() { - this.clearTimeout(this._hideTimeout); - this._hideTimeout = null; - var childStyle = flattenStyle(this.props.style) || {}; - this.setOpacityTo( - childStyle.opacity === undefined ? 1 : childStyle.opacity - ); - }, - - render: function() { - return ( - - {this.props.children} - - ); - }, -}); - -module.exports = TouchableOpacity; diff --git a/examples/node_modules/react-native/Libraries/Components/Touchable/TouchableWithoutFeedback.js b/examples/node_modules/react-native/Libraries/Components/Touchable/TouchableWithoutFeedback.js deleted file mode 100755 index 8c04c945..00000000 --- a/examples/node_modules/react-native/Libraries/Components/Touchable/TouchableWithoutFeedback.js +++ /dev/null @@ -1,148 +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. - * - * @providesModule TouchableWithoutFeedback - * @flow - */ -'use strict'; - -var EdgeInsetsPropType = require('EdgeInsetsPropType'); -var React = require('React'); -var TimerMixin = require('react-timer-mixin'); -var Touchable = require('Touchable'); -var View = require('View'); -var ensurePositiveDelayProps = require('ensurePositiveDelayProps'); -var invariant = require('invariant'); -var onlyChild = require('onlyChild'); - -type Event = Object; - -var PRESS_RETENTION_OFFSET = {top: 20, left: 20, right: 20, bottom: 30}; - -/** - * Do not use unless you have a very good reason. All the elements that - * respond to press should have a visual feedback when touched. This is - * one of the primary reason a "web" app doesn't feel "native". - */ -var TouchableWithoutFeedback = React.createClass({ - mixins: [TimerMixin, Touchable.Mixin], - - propTypes: { - accessible: React.PropTypes.bool, - accessibilityComponentType: React.PropTypes.oneOf(View.AccessibilityComponentType), - accessibilityTraits: React.PropTypes.oneOfType([ - React.PropTypes.oneOf(View.AccessibilityTraits), - React.PropTypes.arrayOf(React.PropTypes.oneOf(View.AccessibilityTraits)), - ]), - /** - * Called when the touch is released, but not if cancelled (e.g. by a scroll - * that steals the responder lock). - */ - onPress: React.PropTypes.func, - onPressIn: React.PropTypes.func, - onPressOut: React.PropTypes.func, - /** - * Invoked on mount and layout changes with - * - * `{nativeEvent: {layout: {x, y, width, height}}}` - */ - onLayout: React.PropTypes.func, - - onLongPress: React.PropTypes.func, - - /** - * Delay in ms, from the start of the touch, before onPressIn is called. - */ - delayPressIn: React.PropTypes.number, - /** - * Delay in ms, from the release of the touch, before onPressOut is called. - */ - delayPressOut: React.PropTypes.number, - /** - * Delay in ms, from onPressIn, before onLongPress is called. - */ - delayLongPress: React.PropTypes.number, - /** - * When the scroll view is disabled, this defines how far your touch may - * move off of the button, before deactivating the button. Once deactivated, - * try moving it back and you'll see that the button is once again - * reactivated! Move it back and forth several times while the scroll view - * is disabled. Ensure you pass in a constant to reduce memory allocations. - */ - pressRetentionOffset: EdgeInsetsPropType, - }, - - getInitialState: function() { - return this.touchableGetInitialState(); - }, - - componentDidMount: function() { - ensurePositiveDelayProps(this.props); - }, - - componentWillReceiveProps: function(nextProps: Object) { - ensurePositiveDelayProps(nextProps); - }, - - /** - * `Touchable.Mixin` self callbacks. The mixin will invoke these if they are - * defined on your component. - */ - touchableHandlePress: function(e: Event) { - this.props.onPress && this.props.onPress(e); - }, - - touchableHandleActivePressIn: function(e: Event) { - this.props.onPressIn && this.props.onPressIn(e); - }, - - touchableHandleActivePressOut: function(e: Event) { - this.props.onPressOut && this.props.onPressOut(e); - }, - - touchableHandleLongPress: function(e: Event) { - this.props.onLongPress && this.props.onLongPress(e); - }, - - touchableGetPressRectOffset: function(): typeof PRESS_RETENTION_OFFSET { - return this.props.pressRetentionOffset || PRESS_RETENTION_OFFSET; - }, - - touchableGetHighlightDelayMS: function(): number { - return this.props.delayPressIn || 0; - }, - - touchableGetLongPressDelayMS: function(): number { - return this.props.delayLongPress === 0 ? 0 : - this.props.delayLongPress || 500; - }, - - touchableGetPressOutDelayMS: function(): number { - return this.props.delayPressOut || 0; - }, - - render: function(): ReactElement { - // Note(avik): remove dynamic typecast once Flow has been upgraded - return (React: any).cloneElement(onlyChild(this.props.children), { - accessible: this.props.accessible !== false, - accessibilityComponentType: this.props.accessibilityComponentType, - accessibilityTraits: this.props.accessibilityTraits, - testID: this.props.testID, - onLayout: this.props.onLayout, - onStartShouldSetResponder: this.touchableHandleStartShouldSetResponder, - onResponderTerminationRequest: this.touchableHandleResponderTerminationRequest, - onResponderGrant: this.touchableHandleResponderGrant, - onResponderMove: this.touchableHandleResponderMove, - onResponderRelease: this.touchableHandleResponderRelease, - onResponderTerminate: this.touchableHandleResponderTerminate - }); - } -}); - -module.exports = TouchableWithoutFeedback; diff --git a/examples/node_modules/react-native/Libraries/Components/Touchable/ensureComponentIsNative.js b/examples/node_modules/react-native/Libraries/Components/Touchable/ensureComponentIsNative.js deleted file mode 100644 index 944093f7..00000000 --- a/examples/node_modules/react-native/Libraries/Components/Touchable/ensureComponentIsNative.js +++ /dev/null @@ -1,24 +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. - * - * @providesModule ensureComponentIsNative - * @flow - */ -'use strict'; - -var invariant = require('invariant'); - -var ensureComponentIsNative = function(component: any) { - invariant( - component && typeof component.setNativeProps === 'function', - 'Touchable child must either be native or forward setNativeProps to a ' + - 'native component' - ); -}; - -module.exports = ensureComponentIsNative; diff --git a/examples/node_modules/react-native/Libraries/Components/UnimplementedViews/UnimplementedView.js b/examples/node_modules/react-native/Libraries/Components/UnimplementedViews/UnimplementedView.js deleted file mode 100644 index 1870f495..00000000 --- a/examples/node_modules/react-native/Libraries/Components/UnimplementedViews/UnimplementedView.js +++ /dev/null @@ -1,38 +0,0 @@ -/** - * Common implementation for a simple stubbed view. Simply applies the view's styles to the inner - * View component and renders its children. - * - * @providesModule UnimplementedView - */ - -'use strict'; - -var React = require('React'); -var StyleSheet = require('StyleSheet'); - -var UnimplementedView = React.createClass({ - setNativeProps: function() { - // Do nothing. - // This method is required in order to use this view as a Touchable* child. - // See ensureComponentIsNative.js for more info - }, - render: function() { - // Workaround require cycle from requireNativeComponent - var View = require('View'); - return ( - - {this.props.children} - - ); - }, -}); - -var styles = StyleSheet.create({ - unimplementedView: { - borderWidth: 1, - borderColor: 'red', - alignSelf: 'flex-start', - } -}); - -module.exports = UnimplementedView; diff --git a/examples/node_modules/react-native/Libraries/Components/View/View.js b/examples/node_modules/react-native/Libraries/Components/View/View.js deleted file mode 100644 index beaffb75..00000000 --- a/examples/node_modules/react-native/Libraries/Components/View/View.js +++ /dev/null @@ -1,346 +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. - * - * @providesModule View - * @flow - */ -'use strict'; - -var NativeMethodsMixin = require('NativeMethodsMixin'); -var PropTypes = require('ReactPropTypes'); -var React = require('React'); -var ReactNativeStyleAttributes = require('ReactNativeStyleAttributes'); -var ReactNativeViewAttributes = require('ReactNativeViewAttributes'); -var StyleSheetPropType = require('StyleSheetPropType'); -var UIManager = require('UIManager'); -var ViewStylePropTypes = require('ViewStylePropTypes'); - -var requireNativeComponent = require('requireNativeComponent'); - -var stylePropType = StyleSheetPropType(ViewStylePropTypes); - -var AccessibilityTraits = [ - 'none', - 'button', - 'link', - 'header', - 'search', - 'image', - 'selected', - 'plays', - 'key', - 'text', - 'summary', - 'disabled', - 'frequentUpdates', - 'startsMedia', - 'adjustable', - 'allowsDirectInteraction', - 'pageTurn', -]; - -var AccessibilityComponentType = [ - 'none', - 'button', - 'radiobutton_checked', - 'radiobutton_unchecked', -]; - -/** - * The most fundamental component for building UI, `View` is a - * container that supports layout with flexbox, style, some touch handling, and - * accessibility controls, and is designed to be nested inside other views and - * to have 0 to many children of any type. `View` maps directly to the native - * view equivalent on whatever platform React is running on, whether that is a - * `UIView`, `
`, `android.view`, etc. This example creates a `View` that - * wraps two colored boxes and custom component in a row with padding. - * - * ``` - * - * - * - * - * - * ``` - * - * `View`s are designed to be used with `StyleSheet`s for clarity and - * performance, although inline styles are also supported. - */ -var View = React.createClass({ - mixins: [NativeMethodsMixin], - - /** - * `NativeMethodsMixin` will look for this when invoking `setNativeProps`. We - * make `this` look like an actual native component class. - */ - viewConfig: { - uiViewClassName: 'RCTView', - validAttributes: ReactNativeViewAttributes.RCTView - }, - - statics: { - AccessibilityTraits, - AccessibilityComponentType, - }, - - propTypes: { - /** - * When true, indicates that the view is an accessibility element. By default, - * all the touchable elements are accessible. - */ - accessible: PropTypes.bool, - - /** - * Overrides the text that's read by the screen reader when the user interacts - * with the element. By default, the label is constructed by traversing all the - * children and accumulating all the Text nodes separated by space. - */ - accessibilityLabel: PropTypes.string, - - /** - * Indicates to accessibility services to treat UI component like a - * native one. Works for Android only. - * @platform android - */ - accessibilityComponentType: PropTypes.oneOf(AccessibilityComponentType), - - /** - * Indicates to accessibility services whether the user should be notified - * when this view changes. Works for Android API >= 19 only. - * See http://developer.android.com/reference/android/view/View.html#attr_android:accessibilityLiveRegion - * for references. - * @platform android - */ - accessibilityLiveRegion: PropTypes.oneOf([ - 'none', - 'polite', - 'assertive', - ]), - - /** - * Controls how view is important for accessibility which is if it - * fires accessibility events and if it is reported to accessibility services - * that query the screen. Works for Android only. - * See http://developer.android.com/reference/android/R.attr.html#importantForAccessibility - * for references. - * Possible values: - * 'auto' - The system determines whether the view is important for accessibility - - * default (recommended). - * 'yes' - The view is important for accessibility. - * 'no' - The view is not important for accessibility. - * 'no-hide-descendants' - The view is not important for accessibility, - * nor are any of its descendant views. - * - * @platform android - */ - importantForAccessibility: PropTypes.oneOf([ - 'auto', - 'yes', - 'no', - 'no-hide-descendants', - ]), - - /** - * Provides additional traits to screen reader. By default no traits are - * provided unless specified otherwise in element - * @platform ios - */ - accessibilityTraits: PropTypes.oneOfType([ - PropTypes.oneOf(AccessibilityTraits), - PropTypes.arrayOf(PropTypes.oneOf(AccessibilityTraits)), - ]), - - /** - * When `accessible` is true, the system will try to invoke this function - * when the user performs accessibility tap gesture. - */ - onAccessibilityTap: PropTypes.func, - - /** - * When `accessible` is true, the system will invoke this function when the - * user performs the magic tap gesture. - */ - onMagicTap: PropTypes.func, - - /** - * Used to locate this view in end-to-end tests. NB: disables the 'layout-only - * view removal' optimization for this view! - */ - testID: PropTypes.string, - - /** - * For most touch interactions, you'll simply want to wrap your component in - * `TouchableHighlight` or `TouchableOpacity`. Check out `Touchable.js`, - * `ScrollResponder.js` and `ResponderEventPlugin.js` for more discussion. - */ - onResponderGrant: PropTypes.func, - onResponderMove: PropTypes.func, - onResponderReject: PropTypes.func, - onResponderRelease: PropTypes.func, - onResponderTerminate: PropTypes.func, - onResponderTerminationRequest: PropTypes.func, - onStartShouldSetResponder: PropTypes.func, - onStartShouldSetResponderCapture: PropTypes.func, - onMoveShouldSetResponder: PropTypes.func, - onMoveShouldSetResponderCapture: PropTypes.func, - - /** - * Invoked on mount and layout changes with - * - * {nativeEvent: { layout: {x, y, width, height}}}. - * - * This event is fired immediately once the layout has been calculated, but - * the new layout may not yet be reflected on the screen at the time the - * event is received, especially if a layout animation is in progress. - */ - onLayout: PropTypes.func, - - /** - * In the absence of `auto` property, `none` is much like `CSS`'s `none` - * value. `box-none` is as if you had applied the `CSS` class: - * - * ``` - * .box-none { - * pointer-events: none; - * } - * .box-none * { - * pointer-events: all; - * } - * ``` - * - * `box-only` is the equivalent of - * - * ``` - * .box-only { - * pointer-events: all; - * } - * .box-only * { - * pointer-events: none; - * } - * ``` - * - * But since `pointerEvents` does not affect layout/appearance, and we are - * already deviating from the spec by adding additional modes, we opt to not - * include `pointerEvents` on `style`. On some platforms, we would need to - * implement it as a `className` anyways. Using `style` or not is an - * implementation detail of the platform. - */ - pointerEvents: PropTypes.oneOf([ - 'box-none', - 'none', - 'box-only', - 'auto', - ]), - style: stylePropType, - - /** - * This is a special performance property exposed by RCTView and is useful - * for scrolling content when there are many subviews, most of which are - * offscreen. For this property to be effective, it must be applied to a - * view that contains many subviews that extend outside its bound. The - * subviews must also have overflow: hidden, as should the containing view - * (or one of its superviews). - */ - removeClippedSubviews: PropTypes.bool, - - /** - * Whether this view should render itself (and all of its children) into a - * single hardware texture on the GPU. - * - * On Android, this is useful for animations and interactions that only - * modify opacity, rotation, translation, and/or scale: in those cases, the - * view doesn't have to be redrawn and display lists don't need to be - * re-executed. The texture can just be re-used and re-composited with - * different parameters. The downside is that this can use up limited video - * memory, so this prop should be set back to false at the end of the - * interaction/animation. - * @platform android - */ - renderToHardwareTextureAndroid: PropTypes.bool, - - /** - * Whether this view should be rendered as a bitmap before compositing. - * - * On iOS, this is useful for animations and interactions that do not - * modify this component's dimensions nor its children; for example, when - * translating the position of a static view, rasterization allows the - * renderer to reuse a cached bitmap of a static view and quickly composite - * it during each frame. - * - * Rasterization incurs an off-screen drawing pass and the bitmap consumes - * memory. Test and measure when using this property. - * @platform ios - */ - shouldRasterizeIOS: PropTypes.bool, - - /** - * Views that are only used to layout their children or otherwise don't draw - * anything may be automatically removed from the native hierarchy as an - * optimization. Set this property to `false` to disable this optimization and - * ensure that this View exists in the native view hierarchy. - * @platform android - */ - collapsable: PropTypes.bool, - - /** - * Whether this view needs to rendered offscreen and composited with an alpha - * in order to preserve 100% correct colors and blending behavior. The default - * (false) falls back to drawing the component and its children with an alpha - * applied to the paint used to draw each element instead of rendering the full - * component offscreen and compositing it back with an alpha value. This default - * may be noticeable and undesired in the case where the View you are setting - * an opacity on has multiple overlapping elements (e.g. multiple overlapping - * Views, or text and a background). - * - * Rendering offscreen to preserve correct alpha behavior is extremely - * expensive and hard to debug for non-native developers, which is why it is - * not turned on by default. If you do need to enable this property for an - * animation, consider combining it with renderToHardwareTextureAndroid if the - * view **contents** are static (i.e. it doesn't need to be redrawn each frame). - * If that property is enabled, this View will be rendered off-screen once, - * saved in a hardware texture, and then composited onto the screen with an alpha - * each frame without having to switch rendering targets on the GPU. - * - * @platform android - */ - needsOffscreenAlphaCompositing: PropTypes.bool, - }, - - render: function() { - // WARNING: This method will not be used in production mode as in that mode we - // replace wrapper component View with generated native wrapper RCTView. Avoid - // adding functionality this component that you'd want to be available in both - // dev and prod modes. - return ; - }, -}); - -var RCTView = requireNativeComponent('RCTView', View, { - nativeOnly: { - nativeBackgroundAndroid: true, - } -}); - -if (__DEV__) { - var viewConfig = UIManager.viewConfigs && UIManager.viewConfigs.RCTView || {}; - for (var prop in viewConfig.nativeProps) { - var viewAny: any = View; // Appease flow - if (!viewAny.propTypes[prop] && !ReactNativeStyleAttributes[prop]) { - throw new Error( - 'View is missing propType for native prop `' + prop + '`' - ); - } - } -} - -var ViewToExport = RCTView; -if (__DEV__) { - ViewToExport = View; -} - -module.exports = ViewToExport; diff --git a/examples/node_modules/react-native/Libraries/Components/View/ViewStylePropTypes.js b/examples/node_modules/react-native/Libraries/Components/View/ViewStylePropTypes.js deleted file mode 100644 index 95767970..00000000 --- a/examples/node_modules/react-native/Libraries/Components/View/ViewStylePropTypes.js +++ /dev/null @@ -1,60 +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. - * - * @providesModule ViewStylePropTypes - * @flow - */ -'use strict'; - -var LayoutPropTypes = require('LayoutPropTypes'); -var ReactPropTypes = require('ReactPropTypes'); -var TransformPropTypes = require('TransformPropTypes'); - -/** - * Warning: Some of these properties may not be supported in all releases. - */ -var ViewStylePropTypes = { - ...LayoutPropTypes, - ...TransformPropTypes, - backfaceVisibility: ReactPropTypes.oneOf(['visible', 'hidden']), - backgroundColor: ReactPropTypes.string, - borderColor: ReactPropTypes.string, - borderTopColor: ReactPropTypes.string, - borderRightColor: ReactPropTypes.string, - borderBottomColor: ReactPropTypes.string, - borderLeftColor: ReactPropTypes.string, - borderRadius: ReactPropTypes.number, - borderTopLeftRadius: ReactPropTypes.number, - borderTopRightRadius: ReactPropTypes.number, - borderBottomLeftRadius: ReactPropTypes.number, - borderBottomRightRadius: ReactPropTypes.number, - borderStyle: ReactPropTypes.oneOf(['solid', 'dotted', 'dashed']), - borderWidth: ReactPropTypes.number, - borderTopWidth: ReactPropTypes.number, - borderRightWidth: ReactPropTypes.number, - borderBottomWidth: ReactPropTypes.number, - borderLeftWidth: ReactPropTypes.number, - opacity: ReactPropTypes.number, - overflow: ReactPropTypes.oneOf(['visible', 'hidden']), - shadowColor: ReactPropTypes.string, - shadowOffset: ReactPropTypes.shape( - {width: ReactPropTypes.number, height: ReactPropTypes.number} - ), - shadowOpacity: ReactPropTypes.number, - shadowRadius: ReactPropTypes.number, - /** - * (Android-only) Sets the elevation of a view, using Android's underlying - * [elevation API](https://developer.android.com/training/material/shadows-clipping.html#Elevation). - * This adds a drop shadow to the item and affects z-order for overlapping views. - * Only supported on Android 5.0+, has no effect on earlier versions. - * @platform android - */ - elevation: ReactPropTypes.number, -}; - -module.exports = ViewStylePropTypes; diff --git a/examples/node_modules/react-native/Libraries/Components/WebView/WebView.android.js b/examples/node_modules/react-native/Libraries/Components/WebView/WebView.android.js deleted file mode 100644 index f4bc5204..00000000 --- a/examples/node_modules/react-native/Libraries/Components/WebView/WebView.android.js +++ /dev/null @@ -1,208 +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. - * - * @providesModule WebView - */ -'use strict'; - -var EdgeInsetsPropType = require('EdgeInsetsPropType'); -var React = require('React'); -var ReactNativeViewAttributes = require('ReactNativeViewAttributes'); -var StyleSheet = require('StyleSheet'); -var UIManager = require('UIManager'); -var View = require('View'); - -var keyMirror = require('keyMirror'); -var merge = require('merge'); -var requireNativeComponent = require('requireNativeComponent'); - -var PropTypes = React.PropTypes; - -var RCT_WEBVIEW_REF = 'webview'; - -var WebViewState = keyMirror({ - IDLE: null, - LOADING: null, - ERROR: null, -}); - -/** - * Renders a native WebView. - */ -var WebView = React.createClass({ - - propTypes: { - ...View.propTypes, - renderError: PropTypes.func, - renderLoading: PropTypes.func, - url: PropTypes.string, - html: PropTypes.string, - automaticallyAdjustContentInsets: PropTypes.bool, - contentInset: EdgeInsetsPropType, - onNavigationStateChange: PropTypes.func, - startInLoadingState: PropTypes.bool, // force WebView to show loadingView on first load - style: View.propTypes.style, - - /** - * Used on Android only, JS is enabled by default for WebView on iOS - * @platform android - */ - javaScriptEnabledAndroid: PropTypes.bool, - - /** - * Sets the JS to be injected when the webpage loads. - */ - injectedJavaScript: PropTypes.string, - - /** - * Sets the user-agent for this WebView. The user-agent can also be set in native using - * WebViewConfig. This prop will overwrite that config. - */ - userAgent: PropTypes.string, - - /** - * Used to locate this view in end-to-end tests. - */ - testID: PropTypes.string, - }, - - getInitialState: function() { - return { - viewState: WebViewState.IDLE, - lastErrorEvent: null, - startInLoadingState: true, - }; - }, - - componentWillMount: function() { - if (this.props.startInLoadingState) { - this.setState({viewState: WebViewState.LOADING}); - } - }, - - render: function() { - var otherView = null; - - if (this.state.viewState === WebViewState.LOADING) { - otherView = this.props.renderLoading && this.props.renderLoading(); - } else if (this.state.viewState === WebViewState.ERROR) { - var errorEvent = this.state.lastErrorEvent; - otherView = this.props.renderError && this.props.renderError( - errorEvent.domain, - errorEvent.code, - errorEvent.description); - } else if (this.state.viewState !== WebViewState.IDLE) { - console.error('RCTWebView invalid state encountered: ' + this.state.loading); - } - - var webViewStyles = [styles.container, this.props.style]; - if (this.state.viewState === WebViewState.LOADING || - this.state.viewState === WebViewState.ERROR) { - // if we're in either LOADING or ERROR states, don't show the webView - webViewStyles.push(styles.hidden); - } - - var webView = - ; - - return ( - - {webView} - {otherView} - - ); - }, - - goForward: function() { - UIManager.dispatchViewManagerCommand( - this.getWebWiewHandle(), - UIManager.RCTWebView.Commands.goForward, - null - ); - }, - - goBack: function() { - UIManager.dispatchViewManagerCommand( - this.getWebWiewHandle(), - UIManager.RCTWebView.Commands.goBack, - null - ); - }, - - reload: function() { - UIManager.dispatchViewManagerCommand( - this.getWebWiewHandle(), - UIManager.RCTWebView.Commands.reload, - null - ); - }, - - /** - * We return an event with a bunch of fields including: - * url, title, loading, canGoBack, canGoForward - */ - updateNavigationState: function(event) { - if (this.props.onNavigationStateChange) { - this.props.onNavigationStateChange(event.nativeEvent); - } - }, - - getWebWiewHandle: function() { - return React.findNodeHandle(this.refs[RCT_WEBVIEW_REF]); - }, - - onLoadingStart: function(event) { - this.updateNavigationState(event); - }, - - onLoadingError: function(event) { - event.persist(); // persist this event because we need to store it - console.error('Encountered an error loading page', event.nativeEvent); - - this.setState({ - lastErrorEvent: event.nativeEvent, - viewState: WebViewState.ERROR - }); - }, - - onLoadingFinish: function(event) { - this.setState({ - viewState: WebViewState.IDLE, - }); - this.updateNavigationState(event); - }, -}); - -var RCTWebView = requireNativeComponent('RCTWebView', WebView); - -var styles = StyleSheet.create({ - container: { - flex: 1, - }, - hidden: { - height: 0, - flex: 0, // disable 'flex:1' when hiding a View - }, -}); - -module.exports = WebView; diff --git a/examples/node_modules/react-native/Libraries/Components/WebView/WebView.ios.js b/examples/node_modules/react-native/Libraries/Components/WebView/WebView.ios.js deleted file mode 100644 index a51ed3fc..00000000 --- a/examples/node_modules/react-native/Libraries/Components/WebView/WebView.ios.js +++ /dev/null @@ -1,317 +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. - * - * @providesModule WebView - * @flow - */ -'use strict'; - -var ActivityIndicatorIOS = require('ActivityIndicatorIOS'); -var EdgeInsetsPropType = require('EdgeInsetsPropType'); -var React = require('React'); -var StyleSheet = require('StyleSheet'); -var Text = require('Text'); -var View = require('View'); - -var invariant = require('invariant'); -var keyMirror = require('keyMirror'); -var requireNativeComponent = require('requireNativeComponent'); - -var PropTypes = React.PropTypes; -var RCTWebViewManager = require('NativeModules').WebViewManager; - -var BGWASH = 'rgba(255,255,255,0.8)'; -var RCT_WEBVIEW_REF = 'webview'; - -var WebViewState = keyMirror({ - IDLE: null, - LOADING: null, - ERROR: null, -}); - -var NavigationType = { - click: RCTWebViewManager.NavigationType.LinkClicked, - formsubmit: RCTWebViewManager.NavigationType.FormSubmitted, - backforward: RCTWebViewManager.NavigationType.BackForward, - reload: RCTWebViewManager.NavigationType.Reload, - formresubmit: RCTWebViewManager.NavigationType.FormResubmitted, - other: RCTWebViewManager.NavigationType.Other, -}; - -var JSNavigationScheme = RCTWebViewManager.JSNavigationScheme; - -type ErrorEvent = { - domain: any; - code: any; - description: any; -} - -type Event = Object; - -var defaultRenderLoading = () => ( - - - -); -var defaultRenderError = (errorDomain, errorCode, errorDesc) => ( - - - Error loading page - - - {'Domain: ' + errorDomain} - - - {'Error Code: ' + errorCode} - - - {'Description: ' + errorDesc} - - -); - -/** - * Renders a native WebView. - */ -var WebView = React.createClass({ - statics: { - JSNavigationScheme: JSNavigationScheme, - NavigationType: NavigationType, - }, - - propTypes: { - ...View.propTypes, - url: PropTypes.string, - html: PropTypes.string, - /** - * Function that returns a view to show if there's an error. - */ - renderError: PropTypes.func, // view to show if there's an error - /** - * Function that returns a loading indicator. - */ - renderLoading: PropTypes.func, - /** - * @platform ios - */ - bounces: PropTypes.bool, - /** - * @platform ios - */ - scrollEnabled: PropTypes.bool, - automaticallyAdjustContentInsets: PropTypes.bool, - contentInset: EdgeInsetsPropType, - onNavigationStateChange: PropTypes.func, - startInLoadingState: PropTypes.bool, // force WebView to show loadingView on first load - style: View.propTypes.style, - - /** - * Used on Android only, JS is enabled by default for WebView on iOS - * @platform android - */ - javaScriptEnabledAndroid: PropTypes.bool, - - /** - * Sets the JS to be injected when the webpage loads. - */ - injectedJavaScript: PropTypes.string, - - /** - * Sets whether the webpage scales to fit the view and the user can change the scale. - * @platform ios - */ - scalesPageToFit: PropTypes.bool, - - /** - * Allows custom handling of any webview requests by a JS handler. Return true - * or false from this method to continue loading the request. - * @platform ios - */ - onShouldStartLoadWithRequest: PropTypes.func, - - /** - * Determines whether HTML5 videos play inline or use the native full-screen - * controller. - * default value `false` - * **NOTE** : "In order for video to play inline, not only does this - * property need to be set to true, but the video element in the HTML - * document must also include the webkit-playsinline attribute." - * @platform ios - */ - allowsInlineMediaPlayback: PropTypes.bool, - }, - - getInitialState: function() { - return { - viewState: WebViewState.IDLE, - lastErrorEvent: (null: ?ErrorEvent), - startInLoadingState: true, - }; - }, - - componentWillMount: function() { - if (this.props.startInLoadingState) { - this.setState({viewState: WebViewState.LOADING}); - } - }, - - render: function() { - var otherView = null; - - if (this.state.viewState === WebViewState.LOADING) { - otherView = (this.props.renderLoading || defaultRenderLoading)(); - } else if (this.state.viewState === WebViewState.ERROR) { - var errorEvent = this.state.lastErrorEvent; - invariant( - errorEvent != null, - 'lastErrorEvent expected to be non-null' - ); - otherView = (this.props.renderError || defaultRenderError)( - errorEvent.domain, - errorEvent.code, - errorEvent.description - ); - } else if (this.state.viewState !== WebViewState.IDLE) { - console.error( - 'RCTWebView invalid state encountered: ' + this.state.loading - ); - } - - var webViewStyles = [styles.container, styles.webView, this.props.style]; - if (this.state.viewState === WebViewState.LOADING || - this.state.viewState === WebViewState.ERROR) { - // if we're in either LOADING or ERROR states, don't show the webView - webViewStyles.push(styles.hidden); - } - - var onShouldStartLoadWithRequest = this.props.onShouldStartLoadWithRequest && ((event: Event) => { - var shouldStart = this.props.onShouldStartLoadWithRequest && - this.props.onShouldStartLoadWithRequest(event.nativeEvent); - RCTWebViewManager.startLoadWithResult(!!shouldStart, event.nativeEvent.lockIdentifier); - }); - - var webView = - ; - - return ( - - {webView} - {otherView} - - ); - }, - - goForward: function() { - RCTWebViewManager.goForward(this.getWebViewHandle()); - }, - - goBack: function() { - RCTWebViewManager.goBack(this.getWebViewHandle()); - }, - - reload: function() { - RCTWebViewManager.reload(this.getWebViewHandle()); - }, - - /** - * We return an event with a bunch of fields including: - * url, title, loading, canGoBack, canGoForward - */ - updateNavigationState: function(event: Event) { - if (this.props.onNavigationStateChange) { - this.props.onNavigationStateChange(event.nativeEvent); - } - }, - - getWebViewHandle: function(): any { - return React.findNodeHandle(this.refs[RCT_WEBVIEW_REF]); - }, - - onLoadingStart: function(event: Event) { - this.updateNavigationState(event); - }, - - onLoadingError: function(event: Event) { - event.persist(); // persist this event because we need to store it - console.warn('Encountered an error loading page', event.nativeEvent); - - this.setState({ - lastErrorEvent: event.nativeEvent, - viewState: WebViewState.ERROR - }); - }, - - onLoadingFinish: function(event: Event) { - this.setState({ - viewState: WebViewState.IDLE, - }); - this.updateNavigationState(event); - }, -}); - -var RCTWebView = requireNativeComponent('RCTWebView', WebView, { - nativeOnly: { - onLoadingStart: true, - onLoadingError: true, - onLoadingFinish: true, - }, -}); - -var styles = StyleSheet.create({ - container: { - flex: 1, - }, - errorContainer: { - flex: 1, - justifyContent: 'center', - alignItems: 'center', - backgroundColor: BGWASH, - }, - errorText: { - fontSize: 14, - textAlign: 'center', - marginBottom: 2, - }, - errorTextTitle: { - fontSize: 15, - fontWeight: '500', - marginBottom: 10, - }, - hidden: { - height: 0, - flex: 0, // disable 'flex:1' when hiding a View - }, - loadingView: { - backgroundColor: BGWASH, - flex: 1, - justifyContent: 'center', - alignItems: 'center', - }, - webView: { - backgroundColor: '#ffffff', - } -}); - -module.exports = WebView; diff --git a/examples/node_modules/react-native/Libraries/CustomComponents/LICENSE b/examples/node_modules/react-native/Libraries/CustomComponents/LICENSE deleted file mode 100644 index ef4ae136..00000000 --- a/examples/node_modules/react-native/Libraries/CustomComponents/LICENSE +++ /dev/null @@ -1,9 +0,0 @@ -LICENSE AGREEMENT - -For React Native Custom Components software - -Copyright (c) 2015, Facebook, Inc. All rights reserved. - -Facebook, Inc. ("Facebook") owns all right, title and interest, including all intellectual property and other proprietary rights, in and to the React Native Custom Components software (the "Software"). Subject to your compliance with these terms, you are hereby granted a non-exclusive, worldwide, royalty-free copyright license to (1) use and copy the Software; and (2) reproduce and distribute the Software as part of your own software ("Your Software"). Facebook reserves all rights not expressly granted to you in this license agreement. - -THE SOFTWARE AND DOCUMENTATION, IF ANY, ARE PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES (INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE) ARE DISCLAIMED. IN NO EVENT SHALL FACEBOOK OR ITS AFFILIATES, OFFICERS, DIRECTORS OR EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THE SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/examples/node_modules/react-native/Libraries/CustomComponents/ListView/ListView.js b/examples/node_modules/react-native/Libraries/CustomComponents/ListView/ListView.js deleted file mode 100644 index fa29da5d..00000000 --- a/examples/node_modules/react-native/Libraries/CustomComponents/ListView/ListView.js +++ /dev/null @@ -1,607 +0,0 @@ -/** - * Copyright (c) 2015, Facebook, Inc. All rights reserved. - * - * Facebook, Inc. ("Facebook") owns all right, title and interest, including - * all intellectual property and other proprietary rights, in and to the React - * Native CustomComponents software (the "Software"). Subject to your - * compliance with these terms, you are hereby granted a non-exclusive, - * worldwide, royalty-free copyright license to (1) use and copy the Software; - * and (2) reproduce and distribute the Software as part of your own software - * ("Your Software"). Facebook reserves all rights not expressly granted to - * you in this license agreement. - * - * THE SOFTWARE AND DOCUMENTATION, IF ANY, ARE PROVIDED "AS IS" AND ANY EXPRESS - * OR IMPLIED WARRANTIES (INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE) ARE DISCLAIMED. - * IN NO EVENT SHALL FACEBOOK OR ITS AFFILIATES, OFFICERS, DIRECTORS OR - * EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THE SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * @providesModule ListView - */ -'use strict'; - -var ListViewDataSource = require('ListViewDataSource'); -var React = require('React'); -var RCTScrollViewManager = require('NativeModules').ScrollViewManager; -var ScrollView = require('ScrollView'); -var ScrollResponder = require('ScrollResponder'); -var StaticRenderer = require('StaticRenderer'); -var TimerMixin = require('react-timer-mixin'); - -var isEmpty = require('isEmpty'); -var logError = require('logError'); -var merge = require('merge'); - -var PropTypes = React.PropTypes; - -var DEFAULT_PAGE_SIZE = 1; -var DEFAULT_INITIAL_ROWS = 10; -var DEFAULT_SCROLL_RENDER_AHEAD = 1000; -var DEFAULT_END_REACHED_THRESHOLD = 1000; -var DEFAULT_SCROLL_CALLBACK_THROTTLE = 50; -var SCROLLVIEW_REF = 'listviewscroll'; - - -/** - * ListView - A core component designed for efficient display of vertically - * scrolling lists of changing data. The minimal API is to create a - * `ListView.DataSource`, populate it with a simple array of data blobs, and - * instantiate a `ListView` component with that data source and a `renderRow` - * callback which takes a blob from the data array and returns a renderable - * component. - * - * Minimal example: - * - * ``` - * getInitialState: function() { - * var ds = new ListView.DataSource({rowHasChanged: (r1, r2) => r1 !== r2}); - * return { - * dataSource: ds.cloneWithRows(['row 1', 'row 2']), - * }; - * }, - * - * render: function() { - * return ( - * {rowData}} - * /> - * ); - * }, - * ``` - * - * ListView also supports more advanced features, including sections with sticky - * section headers, header and footer support, callbacks on reaching the end of - * the available data (`onEndReached`) and on the set of rows that are visible - * in the device viewport change (`onChangeVisibleRows`), and several - * performance optimizations. - * - * There are a few performance operations designed to make ListView scroll - * smoothly while dynamically loading potentially very large (or conceptually - * infinite) data sets: - * - * * Only re-render changed rows - the rowHasChanged function provided to the - * data source tells the ListView if it needs to re-render a row because the - * source data has changed - see ListViewDataSource for more details. - * - * * Rate-limited row rendering - By default, only one row is rendered per - * event-loop (customizable with the `pageSize` prop). This breaks up the - * work into smaller chunks to reduce the chance of dropping frames while - * rendering rows. - */ - -var ListView = React.createClass({ - mixins: [ScrollResponder.Mixin, TimerMixin], - - statics: { - DataSource: ListViewDataSource, - }, - - /** - * You must provide a renderRow function. If you omit any of the other render - * functions, ListView will simply skip rendering them. - * - * - renderRow(rowData, sectionID, rowID, highlightRow); - * - renderSectionHeader(sectionData, sectionID); - */ - propTypes: { - ...ScrollView.propTypes, - - dataSource: PropTypes.instanceOf(ListViewDataSource).isRequired, - /** - * (sectionID, rowID, adjacentRowHighlighted) => renderable - * - * If provided, a renderable component to be rendered as the separator - * below each row but not the last row if there is a section header below. - * Take a sectionID and rowID of the row above and whether its adjacent row - * is highlighted. - */ - renderSeparator: PropTypes.func, - /** - * (rowData, sectionID, rowID, highlightRow) => renderable - * - * Takes a data entry from the data source and its ids and should return - * a renderable component to be rendered as the row. By default the data - * is exactly what was put into the data source, but it's also possible to - * provide custom extractors. ListView can be notified when a row is - * being highlighted by calling highlightRow function. The separators above and - * below will be hidden when a row is highlighted. The highlighted state of - * a row can be reset by calling highlightRow(null). - */ - renderRow: PropTypes.func.isRequired, - /** - * How many rows to render on initial component mount. Use this to make - * it so that the first screen worth of data apears at one time instead of - * over the course of multiple frames. - */ - initialListSize: PropTypes.number, - /** - * Called when all rows have been rendered and the list has been scrolled - * to within onEndReachedThreshold of the bottom. The native scroll - * event is provided. - */ - onEndReached: PropTypes.func, - /** - * Threshold in pixels for onEndReached. - */ - onEndReachedThreshold: PropTypes.number, - /** - * Number of rows to render per event loop. - */ - pageSize: PropTypes.number, - /** - * () => renderable - * - * The header and footer are always rendered (if these props are provided) - * on every render pass. If they are expensive to re-render, wrap them - * in StaticContainer or other mechanism as appropriate. Footer is always - * at the bottom of the list, and header at the top, on every render pass. - */ - renderFooter: PropTypes.func, - renderHeader: PropTypes.func, - /** - * (sectionData, sectionID) => renderable - * - * If provided, a sticky header is rendered for this section. The sticky - * behavior means that it will scroll with the content at the top of the - * section until it reaches the top of the screen, at which point it will - * stick to the top until it is pushed off the screen by the next section - * header. - */ - renderSectionHeader: PropTypes.func, - /** - * (props) => renderable - * - * A function that returns the scrollable component in which the list rows - * are rendered. Defaults to returning a ScrollView with the given props. - */ - renderScrollComponent: React.PropTypes.func.isRequired, - /** - * How early to start rendering rows before they come on screen, in - * pixels. - */ - scrollRenderAheadDistance: React.PropTypes.number, - /** - * (visibleRows, changedRows) => void - * - * Called when the set of visible rows changes. `visibleRows` maps - * { sectionID: { rowID: true }} for all the visible rows, and - * `changedRows` maps { sectionID: { rowID: true | false }} for the rows - * that have changed their visibility, with true indicating visible, and - * false indicating the view has moved out of view. - */ - onChangeVisibleRows: React.PropTypes.func, - /** - * An experimental performance optimization for improving scroll perf of - * large lists, used in conjunction with overflow: 'hidden' on the row - * containers. Use at your own risk. - */ - removeClippedSubviews: React.PropTypes.bool, - }, - - /** - * Exports some data, e.g. for perf investigations or analytics. - */ - getMetrics: function() { - return { - contentLength: this.scrollProperties.contentLength, - totalRows: this.props.dataSource.getRowCount(), - renderedRows: this.state.curRenderedRowsCount, - visibleRows: Object.keys(this._visibleRows).length, - }; - }, - - /** - * Provides a handle to the underlying scroll responder to support operations - * such as scrollTo. - */ - getScrollResponder: function() { - return this.refs[SCROLLVIEW_REF] && - this.refs[SCROLLVIEW_REF].getScrollResponder && - this.refs[SCROLLVIEW_REF].getScrollResponder(); - }, - - setNativeProps: function(props) { - this.refs[SCROLLVIEW_REF].setNativeProps(props); - }, - - /** - * React life cycle hooks. - */ - - getDefaultProps: function() { - return { - initialListSize: DEFAULT_INITIAL_ROWS, - pageSize: DEFAULT_PAGE_SIZE, - renderScrollComponent: props => , - scrollRenderAheadDistance: DEFAULT_SCROLL_RENDER_AHEAD, - onEndReachedThreshold: DEFAULT_END_REACHED_THRESHOLD, - }; - }, - - getInitialState: function() { - return { - curRenderedRowsCount: this.props.initialListSize, - prevRenderedRowsCount: 0, - highlightedRow: {}, - }; - }, - - getInnerViewNode: function() { - return this.refs[SCROLLVIEW_REF].getInnerViewNode(); - }, - - componentWillMount: function() { - // this data should never trigger a render pass, so don't put in state - this.scrollProperties = { - visibleLength: null, - contentLength: null, - offset: 0 - }; - this._childFrames = []; - this._visibleRows = {}; - }, - - componentDidMount: function() { - // do this in animation frame until componentDidMount actually runs after - // the component is laid out - this.requestAnimationFrame(() => { - this._measureAndUpdateScrollProps(); - }); - }, - - componentWillReceiveProps: function(nextProps) { - if (this.props.dataSource !== nextProps.dataSource) { - this.setState((state, props) => { - var rowsToRender = Math.min( - state.curRenderedRowsCount + props.pageSize, - props.dataSource.getRowCount() - ); - return { - prevRenderedRowsCount: 0, - curRenderedRowsCount: rowsToRender, - }; - }); - } - }, - - componentDidUpdate: function() { - this.requestAnimationFrame(() => { - this._measureAndUpdateScrollProps(); - }); - }, - - onRowHighlighted: function(sectionID, rowID) { - this.setState({highlightedRow: {sectionID, rowID}}); - }, - - render: function() { - var bodyComponents = []; - - var dataSource = this.props.dataSource; - var allRowIDs = dataSource.rowIdentities; - var rowCount = 0; - var sectionHeaderIndices = []; - - var header = this.props.renderHeader && this.props.renderHeader(); - var footer = this.props.renderFooter && this.props.renderFooter(); - var totalIndex = header ? 1 : 0; - - for (var sectionIdx = 0; sectionIdx < allRowIDs.length; sectionIdx++) { - var sectionID = dataSource.sectionIdentities[sectionIdx]; - var rowIDs = allRowIDs[sectionIdx]; - if (rowIDs.length === 0) { - continue; - } - - if (this.props.renderSectionHeader) { - var shouldUpdateHeader = rowCount >= this.state.prevRenderedRowsCount && - dataSource.sectionHeaderShouldUpdate(sectionIdx); - bodyComponents.push( - - ); - sectionHeaderIndices.push(totalIndex++); - } - - for (var rowIdx = 0; rowIdx < rowIDs.length; rowIdx++) { - var rowID = rowIDs[rowIdx]; - var comboID = sectionID + '_' + rowID; - var shouldUpdateRow = rowCount >= this.state.prevRenderedRowsCount && - dataSource.rowShouldUpdate(sectionIdx, rowIdx); - var row = - ; - bodyComponents.push(row); - totalIndex++; - - if (this.props.renderSeparator && - (rowIdx !== rowIDs.length - 1 || sectionIdx === allRowIDs.length - 1)) { - var adjacentRowHighlighted = - this.state.highlightedRow.sectionID === sectionID && ( - this.state.highlightedRow.rowID === rowID || - this.state.highlightedRow.rowID === rowIDs[rowIdx + 1] - ); - var separator = this.props.renderSeparator( - sectionID, - rowID, - adjacentRowHighlighted - ); - bodyComponents.push(separator); - totalIndex++; - } - if (++rowCount === this.state.curRenderedRowsCount) { - break; - } - } - if (rowCount >= this.state.curRenderedRowsCount) { - break; - } - } - - var { - renderScrollComponent, - ...props, - } = this.props; - if (!props.scrollEventThrottle) { - props.scrollEventThrottle = DEFAULT_SCROLL_CALLBACK_THROTTLE; - } - if (props.removeClippedSubviews === undefined) { - props.removeClippedSubviews = true; - } - Object.assign(props, { - onScroll: this._onScroll, - stickyHeaderIndices: sectionHeaderIndices, - - // Do not pass these events downstream to ScrollView since they will be - // registered in ListView's own ScrollResponder.Mixin - onKeyboardWillShow: undefined, - onKeyboardWillHide: undefined, - onKeyboardDidShow: undefined, - onKeyboardDidHide: undefined, - }); - - // TODO(ide): Use function refs so we can compose with the scroll - // component's original ref instead of clobbering it - return React.cloneElement(renderScrollComponent(props), { - ref: SCROLLVIEW_REF, - onContentSizeChange: this._onContentSizeChange, - onLayout: this._onLayout, - }, header, bodyComponents, footer); - }, - - /** - * Private methods - */ - - _measureAndUpdateScrollProps: function() { - var scrollComponent = this.getScrollResponder(); - if (!scrollComponent || !scrollComponent.getInnerViewNode) { - return; - } - - // RCTScrollViewManager.calculateChildFrames is not available on - // every platform - RCTScrollViewManager && RCTScrollViewManager.calculateChildFrames && - RCTScrollViewManager.calculateChildFrames( - React.findNodeHandle(scrollComponent), - this._updateChildFrames, - ); - }, - - _onContentSizeChange: function(width, height) { - this.scrollProperties.contentLength = !this.props.horizontal ? - height : width; - this._updateVisibleRows(); - this._renderMoreRowsIfNeeded(); - }, - - _onLayout: function(event) { - var {width, height} = event.nativeEvent.layout; - this.scrollProperties.visibleLength = !this.props.horizontal ? - height : width; - this._updateVisibleRows(); - this._renderMoreRowsIfNeeded(); - }, - - _setScrollVisibleLength: function(left, top, width, height) { - this.scrollProperties.visibleLength = !this.props.horizontal ? - height : width; - this._updateVisibleRows(); - this._renderMoreRowsIfNeeded(); - }, - - _updateChildFrames: function(childFrames) { - this._updateVisibleRows(childFrames); - }, - - _maybeCallOnEndReached: function(event) { - if (this.props.onEndReached && - this.scrollProperties.contentLength !== this._sentEndForContentLength && - this._getDistanceFromEnd(this.scrollProperties) < this.props.onEndReachedThreshold && - this.state.curRenderedRowsCount === this.props.dataSource.getRowCount()) { - this._sentEndForContentLength = this.scrollProperties.contentLength; - this.props.onEndReached(event); - return true; - } - return false; - }, - - _renderMoreRowsIfNeeded: function() { - if (this.scrollProperties.contentLength === null || - this.scrollProperties.visibleLength === null || - this.state.curRenderedRowsCount === this.props.dataSource.getRowCount()) { - this._maybeCallOnEndReached(); - return; - } - - var distanceFromEnd = this._getDistanceFromEnd(this.scrollProperties); - if (distanceFromEnd < this.props.scrollRenderAheadDistance) { - this._pageInNewRows(); - } - }, - - _pageInNewRows: function() { - this.setState((state, props) => { - var rowsToRender = Math.min( - state.curRenderedRowsCount + props.pageSize, - props.dataSource.getRowCount() - ); - return { - prevRenderedRowsCount: state.curRenderedRowsCount, - curRenderedRowsCount: rowsToRender - }; - }, () => { - this._measureAndUpdateScrollProps(); - this.setState(state => ({ - prevRenderedRowsCount: state.curRenderedRowsCount, - })); - }); - }, - - _getDistanceFromEnd: function(scrollProperties) { - var maxLength = Math.max( - scrollProperties.contentLength, - scrollProperties.visibleLength - ); - return maxLength - scrollProperties.visibleLength - scrollProperties.offset; - }, - - _updateVisibleRows: function(updatedFrames) { - if (!this.props.onChangeVisibleRows) { - return; // No need to compute visible rows if there is no callback - } - if (updatedFrames) { - updatedFrames.forEach((newFrame) => { - this._childFrames[newFrame.index] = merge(newFrame); - }); - } - var isVertical = !this.props.horizontal; - var dataSource = this.props.dataSource; - var visibleMin = this.scrollProperties.offset; - var visibleMax = visibleMin + this.scrollProperties.visibleLength; - var allRowIDs = dataSource.rowIdentities; - - var header = this.props.renderHeader && this.props.renderHeader(); - var totalIndex = header ? 1 : 0; - var visibilityChanged = false; - var changedRows = {}; - for (var sectionIdx = 0; sectionIdx < allRowIDs.length; sectionIdx++) { - var rowIDs = allRowIDs[sectionIdx]; - if (rowIDs.length === 0) { - continue; - } - var sectionID = dataSource.sectionIdentities[sectionIdx]; - if (this.props.renderSectionHeader) { - totalIndex++; - } - var visibleSection = this._visibleRows[sectionID]; - if (!visibleSection) { - visibleSection = {}; - } - for (var rowIdx = 0; rowIdx < rowIDs.length; rowIdx++) { - var rowID = rowIDs[rowIdx]; - var frame = this._childFrames[totalIndex]; - totalIndex++; - if (!frame) { - break; - } - var rowVisible = visibleSection[rowID]; - var min = isVertical ? frame.y : frame.x; - var max = min + (isVertical ? frame.height : frame.width); - if (min > visibleMax || max < visibleMin) { - if (rowVisible) { - visibilityChanged = true; - delete visibleSection[rowID]; - if (!changedRows[sectionID]) { - changedRows[sectionID] = {}; - } - changedRows[sectionID][rowID] = false; - } - } else if (!rowVisible) { - visibilityChanged = true; - visibleSection[rowID] = true; - if (!changedRows[sectionID]) { - changedRows[sectionID] = {}; - } - changedRows[sectionID][rowID] = true; - } - } - if (!isEmpty(visibleSection)) { - this._visibleRows[sectionID] = visibleSection; - } else if (this._visibleRows[sectionID]) { - delete this._visibleRows[sectionID]; - } - } - visibilityChanged && this.props.onChangeVisibleRows(this._visibleRows, changedRows); - }, - - _onScroll: function(e) { - var isVertical = !this.props.horizontal; - this.scrollProperties.visibleLength = e.nativeEvent.layoutMeasurement[ - isVertical ? 'height' : 'width' - ]; - this.scrollProperties.contentLength = e.nativeEvent.contentSize[ - isVertical ? 'height' : 'width' - ]; - this.scrollProperties.offset = e.nativeEvent.contentOffset[ - isVertical ? 'y' : 'x' - ]; - this._updateVisibleRows(e.nativeEvent.updatedChildFrames); - if (!this._maybeCallOnEndReached(e)) { - this._renderMoreRowsIfNeeded(); - } - - if (this.props.onEndReached && - this._getDistanceFromEnd(this.scrollProperties) > this.props.onEndReachedThreshold) { - // Scrolled out of the end zone, so it should be able to trigger again. - this._sentEndForContentLength = null; - } - - this.props.onScroll && this.props.onScroll(e); - }, -}); - -module.exports = ListView; diff --git a/examples/node_modules/react-native/Libraries/CustomComponents/ListView/ListViewDataSource.js b/examples/node_modules/react-native/Libraries/CustomComponents/ListView/ListViewDataSource.js deleted file mode 100644 index 0b1f0ecd..00000000 --- a/examples/node_modules/react-native/Libraries/CustomComponents/ListView/ListViewDataSource.js +++ /dev/null @@ -1,407 +0,0 @@ -/** - * Copyright (c) 2015, Facebook, Inc. All rights reserved. - * - * Facebook, Inc. ("Facebook") owns all right, title and interest, including - * all intellectual property and other proprietary rights, in and to the React - * Native CustomComponents software (the "Software"). Subject to your - * compliance with these terms, you are hereby granted a non-exclusive, - * worldwide, royalty-free copyright license to (1) use and copy the Software; - * and (2) reproduce and distribute the Software as part of your own software - * ("Your Software"). Facebook reserves all rights not expressly granted to - * you in this license agreement. - * - * THE SOFTWARE AND DOCUMENTATION, IF ANY, ARE PROVIDED "AS IS" AND ANY EXPRESS - * OR IMPLIED WARRANTIES (INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE) ARE DISCLAIMED. - * IN NO EVENT SHALL FACEBOOK OR ITS AFFILIATES, OFFICERS, DIRECTORS OR - * EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THE SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * @providesModule ListViewDataSource - * @typechecks - * @flow - */ -'use strict'; - -var invariant = require('invariant'); -var isEmpty = require('isEmpty'); -var warning = require('warning'); - -function defaultGetRowData( - dataBlob: any, - sectionID: number | string, - rowID: number | string -): any { - return dataBlob[sectionID][rowID]; -} - -function defaultGetSectionHeaderData( - dataBlob: any, - sectionID: number | string -): any { - return dataBlob[sectionID]; -} - -type differType = (data1: any, data2: any) => bool; - -type ParamType = { - rowHasChanged: differType; - getRowData: ?typeof defaultGetRowData; - sectionHeaderHasChanged: ?differType; - getSectionHeaderData: ?typeof defaultGetSectionHeaderData; -} - -/** - * Provides efficient data processing and access to the - * `ListView` component. A `ListViewDataSource` is created with functions for - * extracting data from the input blob, and comparing elements (with default - * implementations for convenience). The input blob can be as simple as an - * array of strings, or an object with rows nested inside section objects. - * - * To update the data in the datasource, use `cloneWithRows` (or - * `cloneWithRowsAndSections` if you care about sections). The data in the - * data source is immutable, so you can't modify it directly. The clone methods - * suck in the new data and compute a diff for each row so ListView knows - * whether to re-render it or not. - * - * In this example, a component receives data in chunks, handled by - * `_onDataArrived`, which concats the new data onto the old data and updates the - * data source. We use `concat` to create a new array - mutating `this._data`, - * e.g. with `this._data.push(newRowData)`, would be an error. `_rowHasChanged` - * understands the shape of the row data and knows how to efficiently compare - * it. - * - * ``` - * getInitialState: function() { - * var ds = new ListViewDataSource({rowHasChanged: this._rowHasChanged}); - * return {ds}; - * }, - * _onDataArrived(newData) { - * this._data = this._data.concat(newData); - * this.setState({ - * ds: this.state.ds.cloneWithRows(this._data) - * }); - * } - * ``` - */ - -class ListViewDataSource { - - /** - * You can provide custom extraction and `hasChanged` functions for section - * headers and rows. If absent, data will be extracted with the - * `defaultGetRowData` and `defaultGetSectionHeaderData` functions. - * - * The default extractor expects data of one of the following forms: - * - * { sectionID_1: { rowID_1: , ... }, ... } - * - * or - * - * { sectionID_1: [ , , ... ], ... } - * - * or - * - * [ [ , , ... ], ... ] - * - * The constructor takes in a params argument that can contain any of the - * following: - * - * - getRowData(dataBlob, sectionID, rowID); - * - getSectionHeaderData(dataBlob, sectionID); - * - rowHasChanged(prevRowData, nextRowData); - * - sectionHeaderHasChanged(prevSectionData, nextSectionData); - */ - constructor(params: ParamType) { - invariant( - params && typeof params.rowHasChanged === 'function', - 'Must provide a rowHasChanged function.' - ); - this._rowHasChanged = params.rowHasChanged; - this._getRowData = params.getRowData || defaultGetRowData; - this._sectionHeaderHasChanged = params.sectionHeaderHasChanged; - this._getSectionHeaderData = - params.getSectionHeaderData || defaultGetSectionHeaderData; - - this._dataBlob = null; - this._dirtyRows = []; - this._dirtySections = []; - this._cachedRowCount = 0; - - // These two private variables are accessed by outsiders because ListView - // uses them to iterate over the data in this class. - this.rowIdentities = []; - this.sectionIdentities = []; - } - - /** - * Clones this `ListViewDataSource` with the specified `dataBlob` and - * `rowIdentities`. The `dataBlob` is just an aribitrary blob of data. At - * construction an extractor to get the interesting information was defined - * (or the default was used). - * - * The `rowIdentities` is is a 2D array of identifiers for rows. - * ie. [['a1', 'a2'], ['b1', 'b2', 'b3'], ...]. If not provided, it's - * assumed that the keys of the section data are the row identities. - * - * Note: This function does NOT clone the data in this data source. It simply - * passes the functions defined at construction to a new data source with - * the data specified. If you wish to maintain the existing data you must - * handle merging of old and new data separately and then pass that into - * this function as the `dataBlob`. - */ - cloneWithRows( - dataBlob: Array | {[key: string]: any}, - rowIdentities: ?Array - ): ListViewDataSource { - var rowIds = rowIdentities ? [rowIdentities] : null; - if (!this._sectionHeaderHasChanged) { - this._sectionHeaderHasChanged = () => false; - } - return this.cloneWithRowsAndSections({s1: dataBlob}, ['s1'], rowIds); - } - - /** - * This performs the same function as the `cloneWithRows` function but here - * you also specify what your `sectionIdentities` are. If you don't care - * about sections you should safely be able to use `cloneWithRows`. - * - * `sectionIdentities` is an array of identifiers for sections. - * ie. ['s1', 's2', ...]. If not provided, it's assumed that the - * keys of dataBlob are the section identities. - * - * Note: this returns a new object! - */ - cloneWithRowsAndSections( - dataBlob: any, - sectionIdentities: ?Array, - rowIdentities: ?Array> - ): ListViewDataSource { - invariant( - typeof this._sectionHeaderHasChanged === 'function', - 'Must provide a sectionHeaderHasChanged function with section data.' - ); - var newSource = new ListViewDataSource({ - getRowData: this._getRowData, - getSectionHeaderData: this._getSectionHeaderData, - rowHasChanged: this._rowHasChanged, - sectionHeaderHasChanged: this._sectionHeaderHasChanged, - }); - newSource._dataBlob = dataBlob; - if (sectionIdentities) { - newSource.sectionIdentities = sectionIdentities; - } else { - newSource.sectionIdentities = Object.keys(dataBlob); - } - if (rowIdentities) { - newSource.rowIdentities = rowIdentities; - } else { - newSource.rowIdentities = []; - newSource.sectionIdentities.forEach((sectionID) => { - newSource.rowIdentities.push(Object.keys(dataBlob[sectionID])); - }); - } - newSource._cachedRowCount = countRows(newSource.rowIdentities); - - newSource._calculateDirtyArrays( - this._dataBlob, - this.sectionIdentities, - this.rowIdentities - ); - - return newSource; - } - - getRowCount(): number { - return this._cachedRowCount; - } - - /** - * Returns if the row is dirtied and needs to be rerendered - */ - rowShouldUpdate(sectionIndex: number, rowIndex: number): bool { - var needsUpdate = this._dirtyRows[sectionIndex][rowIndex]; - warning(needsUpdate !== undefined, - 'missing dirtyBit for section, row: ' + sectionIndex + ', ' + rowIndex); - return needsUpdate; - } - - /** - * Gets the data required to render the row. - */ - getRowData(sectionIndex: number, rowIndex: number): any { - var sectionID = this.sectionIdentities[sectionIndex]; - var rowID = this.rowIdentities[sectionIndex][rowIndex]; - warning( - sectionID !== undefined && rowID !== undefined, - 'rendering invalid section, row: ' + sectionIndex + ', ' + rowIndex - ); - return this._getRowData(this._dataBlob, sectionID, rowID); - } - - /** - * Gets the rowID at index provided if the dataSource arrays were flattened, - * or null of out of range indexes. - */ - getRowIDForFlatIndex(index: number): ?string { - var accessIndex = index; - for (var ii = 0; ii < this.sectionIdentities.length; ii++) { - if (accessIndex >= this.rowIdentities[ii].length) { - accessIndex -= this.rowIdentities[ii].length; - } else { - return this.rowIdentities[ii][accessIndex]; - } - } - return null; - } - - /** - * Gets the sectionID at index provided if the dataSource arrays were flattened, - * or null for out of range indexes. - */ - getSectionIDForFlatIndex(index: number): ?string { - var accessIndex = index; - for (var ii = 0; ii < this.sectionIdentities.length; ii++) { - if (accessIndex >= this.rowIdentities[ii].length) { - accessIndex -= this.rowIdentities[ii].length; - } else { - return this.sectionIdentities[ii]; - } - } - return null; - } - - /** - * Returns an array containing the number of rows in each section - */ - getSectionLengths(): Array { - var results = []; - for (var ii = 0; ii < this.sectionIdentities.length; ii++) { - results.push(this.rowIdentities[ii].length); - } - return results; - } - - /** - * Returns if the section header is dirtied and needs to be rerendered - */ - sectionHeaderShouldUpdate(sectionIndex: number): bool { - var needsUpdate = this._dirtySections[sectionIndex]; - warning(needsUpdate !== undefined, - 'missing dirtyBit for section: ' + sectionIndex); - return needsUpdate; - } - - /** - * Gets the data required to render the section header - */ - getSectionHeaderData(sectionIndex: number): any { - if (!this._getSectionHeaderData) { - return null; - } - var sectionID = this.sectionIdentities[sectionIndex]; - warning(sectionID !== undefined, - 'renderSection called on invalid section: ' + sectionIndex); - return this._getSectionHeaderData(this._dataBlob, sectionID); - } - - /** - * Private members and methods. - */ - - _getRowData: typeof defaultGetRowData; - _getSectionHeaderData: typeof defaultGetSectionHeaderData; - _rowHasChanged: differType; - _sectionHeaderHasChanged: ?differType; - - _dataBlob: any; - _dirtyRows: Array>; - _dirtySections: Array; - _cachedRowCount: number; - - // These two 'protected' variables are accessed by ListView to iterate over - // the data in this class. - rowIdentities: Array>; - sectionIdentities: Array; - - _calculateDirtyArrays( - prevDataBlob: any, - prevSectionIDs: Array, - prevRowIDs: Array> - ): void { - // construct a hashmap of the existing (old) id arrays - var prevSectionsHash = keyedDictionaryFromArray(prevSectionIDs); - var prevRowsHash = {}; - for (var ii = 0; ii < prevRowIDs.length; ii++) { - var sectionID = prevSectionIDs[ii]; - warning( - !prevRowsHash[sectionID], - 'SectionID appears more than once: ' + sectionID - ); - prevRowsHash[sectionID] = keyedDictionaryFromArray(prevRowIDs[ii]); - } - - // compare the 2 identity array and get the dirtied rows - this._dirtySections = []; - this._dirtyRows = []; - - var dirty; - for (var sIndex = 0; sIndex < this.sectionIdentities.length; sIndex++) { - var sectionID = this.sectionIdentities[sIndex]; - // dirty if the sectionHeader is new or _sectionHasChanged is true - dirty = !prevSectionsHash[sectionID]; - var sectionHeaderHasChanged = this._sectionHeaderHasChanged; - if (!dirty && sectionHeaderHasChanged) { - dirty = sectionHeaderHasChanged( - this._getSectionHeaderData(prevDataBlob, sectionID), - this._getSectionHeaderData(this._dataBlob, sectionID) - ); - } - this._dirtySections.push(!!dirty); - - this._dirtyRows[sIndex] = []; - for (var rIndex = 0; rIndex < this.rowIdentities[sIndex].length; rIndex++) { - var rowID = this.rowIdentities[sIndex][rIndex]; - // dirty if the section is new, row is new or _rowHasChanged is true - dirty = - !prevSectionsHash[sectionID] || - !prevRowsHash[sectionID][rowID] || - this._rowHasChanged( - this._getRowData(prevDataBlob, sectionID, rowID), - this._getRowData(this._dataBlob, sectionID, rowID) - ); - this._dirtyRows[sIndex].push(!!dirty); - } - } - } -} - -function countRows(allRowIDs) { - var totalRows = 0; - for (var sectionIdx = 0; sectionIdx < allRowIDs.length; sectionIdx++) { - var rowIDs = allRowIDs[sectionIdx]; - totalRows += rowIDs.length; - } - return totalRows; -} - -function keyedDictionaryFromArray(arr) { - if (isEmpty(arr)) { - return {}; - } - var result = {}; - for (var ii = 0; ii < arr.length; ii++) { - var key = arr[ii]; - warning(!result[key], 'Value appears more than once in array: ' + key); - result[key] = true; - } - return result; -} - - -module.exports = ListViewDataSource; diff --git a/examples/node_modules/react-native/Libraries/CustomComponents/Navigator/Navigator.js b/examples/node_modules/react-native/Libraries/CustomComponents/Navigator/Navigator.js deleted file mode 100644 index 22bb8436..00000000 --- a/examples/node_modules/react-native/Libraries/CustomComponents/Navigator/Navigator.js +++ /dev/null @@ -1,1137 +0,0 @@ -/** - * Copyright (c) 2015, Facebook, Inc. All rights reserved. - * - * Facebook, Inc. ("Facebook") owns all right, title and interest, including - * all intellectual property and other proprietary rights, in and to the React - * Native CustomComponents software (the "Software"). Subject to your - * compliance with these terms, you are hereby granted a non-exclusive, - * worldwide, royalty-free copyright license to (1) use and copy the Software; - * and (2) reproduce and distribute the Software as part of your own software - * ("Your Software"). Facebook reserves all rights not expressly granted to - * you in this license agreement. - * - * THE SOFTWARE AND DOCUMENTATION, IF ANY, ARE PROVIDED "AS IS" AND ANY EXPRESS - * OR IMPLIED WARRANTIES (INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE) ARE DISCLAIMED. - * IN NO EVENT SHALL FACEBOOK OR ITS AFFILIATES, OFFICERS, DIRECTORS OR - * EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THE SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * @providesModule Navigator - */ - /* eslint-disable no-extra-boolean-cast*/ -'use strict'; - -var AnimationsDebugModule = require('NativeModules').AnimationsDebugModule; -var Dimensions = require('Dimensions'); -var InteractionMixin = require('InteractionMixin'); -var Map = require('Map'); -var NavigationContext = require('NavigationContext'); -var NavigatorBreadcrumbNavigationBar = require('NavigatorBreadcrumbNavigationBar'); -var NavigatorNavigationBar = require('NavigatorNavigationBar'); -var NavigatorSceneConfigs = require('NavigatorSceneConfigs'); -var PanResponder = require('PanResponder'); -var React = require('React'); -var StyleSheet = require('StyleSheet'); -var Subscribable = require('Subscribable'); -var TimerMixin = require('react-timer-mixin'); -var View = require('View'); - -var clamp = require('clamp'); -var flattenStyle = require('flattenStyle'); -var invariant = require('invariant'); -var rebound = require('rebound'); - -var PropTypes = React.PropTypes; - -// TODO: this is not ideal because there is no guarantee that the navigator -// is full screen, hwoever we don't have a good way to measure the actual -// size of the navigator right now, so this is the next best thing. -var SCREEN_WIDTH = Dimensions.get('window').width; -var SCREEN_HEIGHT = Dimensions.get('window').height; -var SCENE_DISABLED_NATIVE_PROPS = { - pointerEvents: 'none', - style: { - top: SCREEN_HEIGHT, - bottom: -SCREEN_HEIGHT, - opacity: 0, - }, -}; - -var __uid = 0; -function getuid() { - return __uid++; -} - -function getRouteID(route) { - if (route === null || typeof route !== 'object') { - return String(route); - } - - var key = '__navigatorRouteID'; - - if (!route.hasOwnProperty(key)) { - Object.defineProperty(route, key, { - enumerable: false, - configurable: false, - writable: false, - value: getuid(), - }); - } - return route[key]; -} - -// styles moved to the top of the file so getDefaultProps can refer to it -var styles = StyleSheet.create({ - container: { - flex: 1, - overflow: 'hidden', - }, - defaultSceneStyle: { - position: 'absolute', - left: 0, - right: 0, - bottom: 0, - top: 0, - }, - baseScene: { - position: 'absolute', - overflow: 'hidden', - left: 0, - right: 0, - bottom: 0, - top: 0, - }, - disabledScene: { - top: SCREEN_HEIGHT, - bottom: -SCREEN_HEIGHT, - }, - transitioner: { - flex: 1, - backgroundColor: 'transparent', - overflow: 'hidden', - } -}); - -var GESTURE_ACTIONS = [ - 'pop', - 'jumpBack', - 'jumpForward', -]; - -/** - * Use `Navigator` to transition between different scenes in your app. To - * accomplish this, provide route objects to the navigator to identify each - * scene, and also a `renderScene` function that the navigator can use to - * render the scene for a given route. - * - * To change the animation or gesture properties of the scene, provide a - * `configureScene` prop to get the config object for a given route. See - * `Navigator.SceneConfigs` for default animations and more info on - * scene config options. - * - * ### Basic Usage - * - * ``` - * - * { - * var nextIndex = route.index + 1; - * navigator.push({ - * name: 'Scene ' + nextIndex, - * index: nextIndex, - * }); - * }} - * onBack={() => { - * if (route.index > 0) { - * navigator.pop(); - * } - * }} - * /> - * } - * /> - * ``` - * - * ### Navigator Methods - * - * If you have a ref to the Navigator element, you can invoke several methods - * on it to trigger navigation: - * - * - `getCurrentRoutes()` - returns the current list of routes - * - `jumpBack()` - Jump backward without unmounting the current scene - * - `jumpForward()` - Jump forward to the next scene in the route stack - * - `jumpTo(route)` - Transition to an existing scene without unmounting - * - `push(route)` - Navigate forward to a new scene, squashing any scenes - * that you could `jumpForward` to - * - `pop()` - Transition back and unmount the current scene - * - `replace(route)` - Replace the current scene with a new route - * - `replaceAtIndex(route, index)` - Replace a scene as specified by an index - * - `replacePrevious(route)` - Replace the previous scene - * - `immediatelyResetRouteStack(routeStack)` - Reset every scene with an - * array of routes - * - `popToRoute(route)` - Pop to a particular scene, as specified by its - * route. All scenes after it will be unmounted - * - `popToTop()` - Pop to the first scene in the stack, unmounting every - * other scene - * - */ -var Navigator = React.createClass({ - - propTypes: { - /** - * Optional function that allows configuration about scene animations and - * gestures. Will be invoked with the route and should return a scene - * configuration object - * - * ``` - * (route) => Navigator.SceneConfigs.FloatFromRight - * ``` - */ - configureScene: PropTypes.func, - - /** - * Required function which renders the scene for a given route. Will be - * invoked with the route and the navigator object - * - * ``` - * (route, navigator) => - * - * ``` - */ - renderScene: PropTypes.func.isRequired, - - /** - * Specify a route to start on. A route is an object that the navigator - * will use to identify each scene to render. `initialRoute` must be - * a route in the `initialRouteStack` if both props are provided. The - * `initialRoute` will default to the last item in the `initialRouteStack`. - */ - initialRoute: PropTypes.object, - - /** - * Provide a set of routes to initially mount. Required if no initialRoute - * is provided. Otherwise, it will default to an array containing only the - * `initialRoute` - */ - initialRouteStack: PropTypes.arrayOf(PropTypes.object), - - /** - * @deprecated - * Use `navigationContext.addListener('willfocus', callback)` instead. - * - * Will emit the target route upon mounting and before each nav transition - */ - onWillFocus: PropTypes.func, - - /** - * @deprecated - * Use `navigationContext.addListener('didfocus', callback)` instead. - * - * Will be called with the new route of each scene after the transition is - * complete or after the initial mounting - */ - onDidFocus: PropTypes.func, - - /** - * Optionally provide a navigation bar that persists across scene - * transitions - */ - navigationBar: PropTypes.node, - - /** - * Optionally provide the navigator object from a parent Navigator - */ - navigator: PropTypes.object, - - /** - * Styles to apply to the container of each scene - */ - sceneStyle: View.propTypes.style, - }, - - statics: { - BreadcrumbNavigationBar: NavigatorBreadcrumbNavigationBar, - NavigationBar: NavigatorNavigationBar, - SceneConfigs: NavigatorSceneConfigs, - }, - - mixins: [TimerMixin, InteractionMixin, Subscribable.Mixin], - - getDefaultProps: function() { - return { - configureScene: () => NavigatorSceneConfigs.PushFromRight, - sceneStyle: styles.defaultSceneStyle, - }; - }, - - getInitialState: function() { - this._navigationBarNavigator = this.props.navigationBarNavigator || this; - - this._renderedSceneMap = new Map(); - - var routeStack = this.props.initialRouteStack || [this.props.initialRoute]; - invariant( - routeStack.length >= 1, - 'Navigator requires props.initialRoute or props.initialRouteStack.' - ); - var initialRouteIndex = routeStack.length - 1; - if (this.props.initialRoute) { - initialRouteIndex = routeStack.indexOf(this.props.initialRoute); - invariant( - initialRouteIndex !== -1, - 'initialRoute is not in initialRouteStack.' - ); - } - return { - sceneConfigStack: routeStack.map( - (route) => this.props.configureScene(route) - ), - routeStack, - presentedIndex: initialRouteIndex, - transitionFromIndex: null, - activeGesture: null, - pendingGestureProgress: null, - transitionQueue: [], - }; - }, - - componentWillMount: function() { - // TODO(t7489503): Don't need this once ES6 Class landed. - this.__defineGetter__('navigationContext', this._getNavigationContext); - - this._subRouteFocus = []; - this.parentNavigator = this.props.navigator; - this._handlers = {}; - this.springSystem = new rebound.SpringSystem(); - this.spring = this.springSystem.createSpring(); - this.spring.setRestSpeedThreshold(0.05); - this.spring.setCurrentValue(0).setAtRest(); - this.spring.addListener({ - onSpringEndStateChange: () => { - if (!this._interactionHandle) { - this._interactionHandle = this.createInteractionHandle(); - } - }, - onSpringUpdate: () => { - this._handleSpringUpdate(); - }, - onSpringAtRest: () => { - this._completeTransition(); - }, - }); - this.panGesture = PanResponder.create({ - onMoveShouldSetPanResponder: this._handleMoveShouldSetPanResponder, - onPanResponderRelease: this._handlePanResponderRelease, - onPanResponderMove: this._handlePanResponderMove, - onPanResponderTerminate: this._handlePanResponderTerminate, - }); - this._interactionHandle = null; - this._emitWillFocus(this.state.routeStack[this.state.presentedIndex]); - }, - - componentDidMount: function() { - this._handleSpringUpdate(); - this._emitDidFocus(this.state.routeStack[this.state.presentedIndex]); - }, - - componentWillUnmount: function() { - if (this._navigationContext) { - this._navigationContext.dispose(); - this._navigationContext = null; - } - - this.spring.destroy(); - - if (this._interactionHandle) { - this.clearInteractionHandle(this._interactionHandle); - } - }, - - /** - * @param {RouteStack} nextRouteStack Next route stack to reinitialize. This - * doesn't accept stack item `id`s, which implies that all existing items are - * destroyed, and then potentially recreated according to `routeStack`. Does - * not animate, immediately replaces and rerenders navigation bar and stack - * items. - */ - immediatelyResetRouteStack: function(nextRouteStack) { - var destIndex = nextRouteStack.length - 1; - this.setState({ - routeStack: nextRouteStack, - sceneConfigStack: nextRouteStack.map( - this.props.configureScene - ), - presentedIndex: destIndex, - activeGesture: null, - transitionFromIndex: null, - transitionQueue: [], - }, () => { - this._handleSpringUpdate(); - }); - }, - - _transitionTo: function(destIndex, velocity, jumpSpringTo, cb) { - if (destIndex === this.state.presentedIndex) { - return; - } - if (this.state.transitionFromIndex !== null) { - this.state.transitionQueue.push({ - destIndex, - velocity, - cb, - }); - return; - } - this.state.transitionFromIndex = this.state.presentedIndex; - this.state.presentedIndex = destIndex; - this.state.transitionCb = cb; - this._onAnimationStart(); - if (AnimationsDebugModule) { - AnimationsDebugModule.startRecordingFps(); - } - var sceneConfig = this.state.sceneConfigStack[this.state.transitionFromIndex] || - this.state.sceneConfigStack[this.state.presentedIndex]; - invariant( - sceneConfig, - 'Cannot configure scene at index ' + this.state.transitionFromIndex - ); - if (jumpSpringTo != null) { - this.spring.setCurrentValue(jumpSpringTo); - } - this.spring.setOvershootClampingEnabled(true); - this.spring.getSpringConfig().friction = sceneConfig.springFriction; - this.spring.getSpringConfig().tension = sceneConfig.springTension; - this.spring.setVelocity(velocity || sceneConfig.defaultTransitionVelocity); - this.spring.setEndValue(1); - }, - - /** - * This happens for each frame of either a gesture or a transition. If both are - * happening, we only set values for the transition and the gesture will catch up later - */ - _handleSpringUpdate: function() { - if (!this.isMounted()) { - return; - } - // Prioritize handling transition in progress over a gesture: - if (this.state.transitionFromIndex != null) { - this._transitionBetween( - this.state.transitionFromIndex, - this.state.presentedIndex, - this.spring.getCurrentValue() - ); - } else if (this.state.activeGesture != null) { - var presentedToIndex = this.state.presentedIndex + this._deltaForGestureAction(this.state.activeGesture); - this._transitionBetween( - this.state.presentedIndex, - presentedToIndex, - this.spring.getCurrentValue() - ); - } - }, - - /** - * This happens at the end of a transition started by transitionTo, and when the spring catches up to a pending gesture - */ - _completeTransition: function() { - if (!this.isMounted()) { - return; - } - - if (this.spring.getCurrentValue() !== 1 && this.spring.getCurrentValue() !== 0) { - // The spring has finished catching up to a gesture in progress. Remove the pending progress - // and we will be in a normal activeGesture state - if (this.state.pendingGestureProgress) { - this.state.pendingGestureProgress = null; - } - return; - } - this._onAnimationEnd(); - var presentedIndex = this.state.presentedIndex; - var didFocusRoute = this._subRouteFocus[presentedIndex] || this.state.routeStack[presentedIndex]; - this._emitDidFocus(didFocusRoute); - if (AnimationsDebugModule) { - AnimationsDebugModule.stopRecordingFps(Date.now()); - } - this.state.transitionFromIndex = null; - this.spring.setCurrentValue(0).setAtRest(); - this._hideScenes(); - if (this.state.transitionCb) { - this.state.transitionCb(); - this.state.transitionCb = null; - } - if (this._interactionHandle) { - this.clearInteractionHandle(this._interactionHandle); - this._interactionHandle = null; - } - if (this.state.pendingGestureProgress) { - // A transition completed, but there is already another gesture happening. - // Enable the scene and set the spring to catch up with the new gesture - var gestureToIndex = this.state.presentedIndex + this._deltaForGestureAction(this.state.activeGesture); - this._enableScene(gestureToIndex); - this.spring.setEndValue(this.state.pendingGestureProgress); - return; - } - if (this.state.transitionQueue.length) { - var queuedTransition = this.state.transitionQueue.shift(); - this._enableScene(queuedTransition.destIndex); - this._emitWillFocus(this.state.routeStack[queuedTransition.destIndex]); - this._transitionTo( - queuedTransition.destIndex, - queuedTransition.velocity, - null, - queuedTransition.cb - ); - } - }, - - _emitDidFocus: function(route) { - this.navigationContext.emit('didfocus', {route: route}); - - if (this.props.onDidFocus) { - this.props.onDidFocus(route); - } - }, - - _emitWillFocus: function(route) { - this.navigationContext.emit('willfocus', {route: route}); - - var navBar = this._navBar; - if (navBar && navBar.handleWillFocus) { - navBar.handleWillFocus(route); - } - if (this.props.onWillFocus) { - this.props.onWillFocus(route); - } - }, - - /** - * Hides all scenes that we are not currently on, gesturing to, or transitioning from - */ - _hideScenes: function() { - var gesturingToIndex = null; - if (this.state.activeGesture) { - gesturingToIndex = this.state.presentedIndex + this._deltaForGestureAction(this.state.activeGesture); - } - for (var i = 0; i < this.state.routeStack.length; i++) { - if (i === this.state.presentedIndex || - i === this.state.transitionFromIndex || - i === gesturingToIndex) { - continue; - } - this._disableScene(i); - } - }, - - /** - * Push a scene off the screen, so that opacity:0 scenes will not block touches sent to the presented scenes - */ - _disableScene: function(sceneIndex) { - this.refs['scene_' + sceneIndex] && - this.refs['scene_' + sceneIndex].setNativeProps(SCENE_DISABLED_NATIVE_PROPS); - }, - - /** - * Put the scene back into the state as defined by props.sceneStyle, so transitions can happen normally - */ - _enableScene: function(sceneIndex) { - // First, determine what the defined styles are for scenes in this navigator - var sceneStyle = flattenStyle([styles.baseScene, this.props.sceneStyle]); - // Then restore the pointer events and top value for this scene - var enabledSceneNativeProps = { - pointerEvents: 'auto', - style: { - top: sceneStyle.top, - bottom: sceneStyle.bottom, - }, - }; - if (sceneIndex !== this.state.transitionFromIndex && - sceneIndex !== this.state.presentedIndex) { - // If we are not in a transition from this index, make sure opacity is 0 - // to prevent the enabled scene from flashing over the presented scene - enabledSceneNativeProps.style.opacity = 0; - } - this.refs['scene_' + sceneIndex] && - this.refs['scene_' + sceneIndex].setNativeProps(enabledSceneNativeProps); - }, - - _onAnimationStart: function() { - var fromIndex = this.state.presentedIndex; - var toIndex = this.state.presentedIndex; - if (this.state.transitionFromIndex != null) { - fromIndex = this.state.transitionFromIndex; - } else if (this.state.activeGesture) { - toIndex = this.state.presentedIndex + this._deltaForGestureAction(this.state.activeGesture); - } - this._setRenderSceneToHardwareTextureAndroid(fromIndex, true); - this._setRenderSceneToHardwareTextureAndroid(toIndex, true); - var navBar = this._navBar; - if (navBar && navBar.onAnimationStart) { - navBar.onAnimationStart(fromIndex, toIndex); - } - }, - - _onAnimationEnd: function() { - var max = this.state.routeStack.length - 1; - for (var index = 0; index <= max; index++) { - this._setRenderSceneToHardwareTextureAndroid(index, false); - } - - var navBar = this._navBar; - if (navBar && navBar.onAnimationEnd) { - navBar.onAnimationEnd(); - } - }, - - _setRenderSceneToHardwareTextureAndroid: function(sceneIndex, shouldRenderToHardwareTexture) { - var viewAtIndex = this.refs['scene_' + sceneIndex]; - if (viewAtIndex === null || viewAtIndex === undefined) { - return; - } - viewAtIndex.setNativeProps({renderToHardwareTextureAndroid: shouldRenderToHardwareTexture}); - }, - - _handleTouchStart: function() { - this._eligibleGestures = GESTURE_ACTIONS; - }, - - _handleMoveShouldSetPanResponder: function(e, gestureState) { - var sceneConfig = this.state.sceneConfigStack[this.state.presentedIndex]; - if (!sceneConfig) { - return false; - } - this._expectingGestureGrant = - this._matchGestureAction(this._eligibleGestures, sceneConfig.gestures, gestureState); - return !!this._expectingGestureGrant; - }, - - _doesGestureOverswipe: function(gestureName) { - var wouldOverswipeBack = this.state.presentedIndex <= 0 && - (gestureName === 'pop' || gestureName === 'jumpBack'); - var wouldOverswipeForward = this.state.presentedIndex >= this.state.routeStack.length - 1 && - gestureName === 'jumpForward'; - return wouldOverswipeForward || wouldOverswipeBack; - }, - - _deltaForGestureAction: function(gestureAction) { - switch (gestureAction) { - case 'pop': - case 'jumpBack': - return -1; - case 'jumpForward': - return 1; - default: - invariant(false, 'Unsupported gesture action ' + gestureAction); - return; - } - }, - - _handlePanResponderRelease: function(e, gestureState) { - var sceneConfig = this.state.sceneConfigStack[this.state.presentedIndex]; - var releaseGestureAction = this.state.activeGesture; - if (!releaseGestureAction) { - // The gesture may have been detached while responder, so there is no action here - return; - } - var releaseGesture = sceneConfig.gestures[releaseGestureAction]; - var destIndex = this.state.presentedIndex + this._deltaForGestureAction(this.state.activeGesture); - if (this.spring.getCurrentValue() === 0) { - // The spring is at zero, so the gesture is already complete - this.spring.setCurrentValue(0).setAtRest(); - this._completeTransition(); - return; - } - var isTravelVertical = releaseGesture.direction === 'top-to-bottom' || releaseGesture.direction === 'bottom-to-top'; - var isTravelInverted = releaseGesture.direction === 'right-to-left' || releaseGesture.direction === 'bottom-to-top'; - var velocity, gestureDistance; - if (isTravelVertical) { - velocity = isTravelInverted ? -gestureState.vy : gestureState.vy; - gestureDistance = isTravelInverted ? -gestureState.dy : gestureState.dy; - } else { - velocity = isTravelInverted ? -gestureState.vx : gestureState.vx; - gestureDistance = isTravelInverted ? -gestureState.dx : gestureState.dx; - } - var transitionVelocity = clamp(-10, velocity, 10); - if (Math.abs(velocity) < releaseGesture.notMoving) { - // The gesture velocity is so slow, is "not moving" - var hasGesturedEnoughToComplete = gestureDistance > releaseGesture.fullDistance * releaseGesture.stillCompletionRatio; - transitionVelocity = hasGesturedEnoughToComplete ? releaseGesture.snapVelocity : -releaseGesture.snapVelocity; - } - if (transitionVelocity < 0 || this._doesGestureOverswipe(releaseGestureAction)) { - // This gesture is to an overswiped region or does not have enough velocity to complete - // If we are currently mid-transition, then this gesture was a pending gesture. Because this gesture takes no action, we can stop here - if (this.state.transitionFromIndex == null) { - // There is no current transition, so we need to transition back to the presented index - var transitionBackToPresentedIndex = this.state.presentedIndex; - // slight hack: change the presented index for a moment in order to transitionTo correctly - this.state.presentedIndex = destIndex; - this._transitionTo( - transitionBackToPresentedIndex, - -transitionVelocity, - 1 - this.spring.getCurrentValue() - ); - } - } else { - // The gesture has enough velocity to complete, so we transition to the gesture's destination - this._emitWillFocus(this.state.routeStack[destIndex]); - this._transitionTo( - destIndex, - transitionVelocity, - null, - () => { - if (releaseGestureAction === 'pop') { - this._cleanScenesPastIndex(destIndex); - } - } - ); - } - this._detachGesture(); - }, - - _handlePanResponderTerminate: function(e, gestureState) { - if (this.state.activeGesture == null) { - return; - } - var destIndex = this.state.presentedIndex + this._deltaForGestureAction(this.state.activeGesture); - this._detachGesture(); - var transitionBackToPresentedIndex = this.state.presentedIndex; - // slight hack: change the presented index for a moment in order to transitionTo correctly - this.state.presentedIndex = destIndex; - this._transitionTo( - transitionBackToPresentedIndex, - null, - 1 - this.spring.getCurrentValue() - ); - }, - - _attachGesture: function(gestureId) { - this.state.activeGesture = gestureId; - var gesturingToIndex = this.state.presentedIndex + this._deltaForGestureAction(this.state.activeGesture); - this._enableScene(gesturingToIndex); - }, - - _detachGesture: function() { - this.state.activeGesture = null; - this.state.pendingGestureProgress = null; - this._hideScenes(); - }, - - _handlePanResponderMove: function(e, gestureState) { - if (this._isMoveGestureAttached !== undefined) { - invariant( - this._expectingGestureGrant, - 'Responder granted unexpectedly.' - ); - this._attachGesture(this._expectingGestureGrant); - this._onAnimationStart(); - this._expectingGestureGrant = undefined; - } - - var sceneConfig = this.state.sceneConfigStack[this.state.presentedIndex]; - if (this.state.activeGesture) { - var gesture = sceneConfig.gestures[this.state.activeGesture]; - return this._moveAttachedGesture(gesture, gestureState); - } - var matchedGesture = this._matchGestureAction(GESTURE_ACTIONS, sceneConfig.gestures, gestureState); - if (matchedGesture) { - this._attachGesture(matchedGesture); - } - }, - - _moveAttachedGesture: function(gesture, gestureState) { - var isTravelVertical = gesture.direction === 'top-to-bottom' || gesture.direction === 'bottom-to-top'; - var isTravelInverted = gesture.direction === 'right-to-left' || gesture.direction === 'bottom-to-top'; - var distance = isTravelVertical ? gestureState.dy : gestureState.dx; - distance = isTravelInverted ? -distance : distance; - var gestureDetectMovement = gesture.gestureDetectMovement; - var nextProgress = (distance - gestureDetectMovement) / - (gesture.fullDistance - gestureDetectMovement); - if (nextProgress < 0 && gesture.isDetachable) { - var gesturingToIndex = this.state.presentedIndex + this._deltaForGestureAction(this.state.activeGesture); - this._transitionBetween(this.state.presentedIndex, gesturingToIndex, 0); - this._detachGesture(); - if (this.state.pendingGestureProgress != null) { - this.spring.setCurrentValue(0); - } - return; - } - if (this._doesGestureOverswipe(this.state.activeGesture)) { - var frictionConstant = gesture.overswipe.frictionConstant; - var frictionByDistance = gesture.overswipe.frictionByDistance; - var frictionRatio = 1 / ((frictionConstant) + (Math.abs(nextProgress) * frictionByDistance)); - nextProgress *= frictionRatio; - } - nextProgress = clamp(0, nextProgress, 1); - if (this.state.transitionFromIndex != null) { - this.state.pendingGestureProgress = nextProgress; - } else if (this.state.pendingGestureProgress) { - this.spring.setEndValue(nextProgress); - } else { - this.spring.setCurrentValue(nextProgress); - } - }, - - _matchGestureAction: function(eligibleGestures, gestures, gestureState) { - if (!gestures) { - return null; - } - var matchedGesture = null; - eligibleGestures.some((gestureName, gestureIndex) => { - var gesture = gestures[gestureName]; - if (!gesture) { - return; - } - if (gesture.overswipe == null && this._doesGestureOverswipe(gestureName)) { - // cannot swipe past first or last scene without overswiping - return false; - } - var isTravelVertical = gesture.direction === 'top-to-bottom' || gesture.direction === 'bottom-to-top'; - var isTravelInverted = gesture.direction === 'right-to-left' || gesture.direction === 'bottom-to-top'; - var currentLoc = isTravelVertical ? gestureState.moveY : gestureState.moveX; - var travelDist = isTravelVertical ? gestureState.dy : gestureState.dx; - var oppositeAxisTravelDist = - isTravelVertical ? gestureState.dx : gestureState.dy; - var edgeHitWidth = gesture.edgeHitWidth; - if (isTravelInverted) { - currentLoc = -currentLoc; - travelDist = -travelDist; - oppositeAxisTravelDist = -oppositeAxisTravelDist; - edgeHitWidth = isTravelVertical ? - -(SCREEN_HEIGHT - edgeHitWidth) : - -(SCREEN_WIDTH - edgeHitWidth); - } - var moveStartedInRegion = gesture.edgeHitWidth == null || - currentLoc < edgeHitWidth; - if (!moveStartedInRegion) { - return false; - } - var moveTravelledFarEnough = travelDist >= gesture.gestureDetectMovement; - if (!moveTravelledFarEnough) { - return false; - } - var directionIsCorrect = Math.abs(travelDist) > Math.abs(oppositeAxisTravelDist) * gesture.directionRatio; - if (directionIsCorrect) { - matchedGesture = gestureName; - return true; - } else { - this._eligibleGestures = this._eligibleGestures.slice().splice(gestureIndex, 1); - } - }); - return matchedGesture || null; - }, - - _transitionSceneStyle: function(fromIndex, toIndex, progress, index) { - var viewAtIndex = this.refs['scene_' + index]; - if (viewAtIndex === null || viewAtIndex === undefined) { - return; - } - // Use toIndex animation when we move forwards. Use fromIndex when we move back - var sceneConfigIndex = fromIndex < toIndex ? toIndex : fromIndex; - var sceneConfig = this.state.sceneConfigStack[sceneConfigIndex]; - // this happens for overswiping when there is no scene at toIndex - if (!sceneConfig) { - sceneConfig = this.state.sceneConfigStack[sceneConfigIndex - 1]; - } - var styleToUse = {}; - var useFn = index < fromIndex || index < toIndex ? - sceneConfig.animationInterpolators.out : - sceneConfig.animationInterpolators.into; - var directionAdjustedProgress = fromIndex < toIndex ? progress : 1 - progress; - var didChange = useFn(styleToUse, directionAdjustedProgress); - if (didChange) { - viewAtIndex.setNativeProps({style: styleToUse}); - } - }, - - _transitionBetween: function(fromIndex, toIndex, progress) { - this._transitionSceneStyle(fromIndex, toIndex, progress, fromIndex); - this._transitionSceneStyle(fromIndex, toIndex, progress, toIndex); - var navBar = this._navBar; - if (navBar && navBar.updateProgress && toIndex >= 0 && fromIndex >= 0) { - navBar.updateProgress(progress, fromIndex, toIndex); - } - }, - - _handleResponderTerminationRequest: function() { - return false; - }, - - _getDestIndexWithinBounds: function(n) { - var currentIndex = this.state.presentedIndex; - var destIndex = currentIndex + n; - invariant( - destIndex >= 0, - 'Cannot jump before the first route.' - ); - var maxIndex = this.state.routeStack.length - 1; - invariant( - maxIndex >= destIndex, - 'Cannot jump past the last route.' - ); - return destIndex; - }, - - _jumpN: function(n) { - var destIndex = this._getDestIndexWithinBounds(n); - this._enableScene(destIndex); - this._emitWillFocus(this.state.routeStack[destIndex]); - this._transitionTo(destIndex); - }, - - jumpTo: function(route) { - var destIndex = this.state.routeStack.indexOf(route); - invariant( - destIndex !== -1, - 'Cannot jump to route that is not in the route stack' - ); - this._jumpN(destIndex - this.state.presentedIndex); - }, - - jumpForward: function() { - this._jumpN(1); - }, - - jumpBack: function() { - this._jumpN(-1); - }, - - push: function(route) { - invariant(!!route, 'Must supply route to push'); - var activeLength = this.state.presentedIndex + 1; - var activeStack = this.state.routeStack.slice(0, activeLength); - var activeAnimationConfigStack = this.state.sceneConfigStack.slice(0, activeLength); - var nextStack = activeStack.concat([route]); - var destIndex = nextStack.length - 1; - var nextAnimationConfigStack = activeAnimationConfigStack.concat([ - this.props.configureScene(route), - ]); - this._emitWillFocus(nextStack[destIndex]); - this.setState({ - routeStack: nextStack, - sceneConfigStack: nextAnimationConfigStack, - }, () => { - this._enableScene(destIndex); - this._transitionTo(destIndex); - }); - }, - - _popN: function(n) { - if (n === 0) { - return; - } - invariant( - this.state.presentedIndex - n >= 0, - 'Cannot pop below zero' - ); - var popIndex = this.state.presentedIndex - n; - this._enableScene(popIndex); - this._emitWillFocus(this.state.routeStack[popIndex]); - this._transitionTo( - popIndex, - null, // default velocity - null, // no spring jumping - () => { - this._cleanScenesPastIndex(popIndex); - } - ); - }, - - pop: function() { - if (this.state.transitionQueue.length) { - // This is the workaround to prevent user from firing multiple `pop()` - // calls that may pop the routes beyond the limit. - // Because `this.state.presentedIndex` does not update until the - // transition starts, we can't reliably use `this.state.presentedIndex` - // to know whether we can safely keep popping the routes or not at this - // moment. - return; - } - - if (this.state.presentedIndex > 0) { - this._popN(1); - } - }, - - /** - * Replace a route in the navigation stack. - * - * `index` specifies the route in the stack that should be replaced. - * If it's negative, it counts from the back. - */ - replaceAtIndex: function(route, index, cb) { - invariant(!!route, 'Must supply route to replace'); - if (index < 0) { - index += this.state.routeStack.length; - } - - if (this.state.routeStack.length <= index) { - return; - } - - var nextRouteStack = this.state.routeStack.slice(); - var nextAnimationModeStack = this.state.sceneConfigStack.slice(); - nextRouteStack[index] = route; - nextAnimationModeStack[index] = this.props.configureScene(route); - - if (index === this.state.presentedIndex) { - this._emitWillFocus(route); - } - this.setState({ - routeStack: nextRouteStack, - sceneConfigStack: nextAnimationModeStack, - }, () => { - if (index === this.state.presentedIndex) { - this._emitDidFocus(route); - } - cb && cb(); - }); - }, - - /** - * Replaces the current scene in the stack. - */ - replace: function(route) { - this.replaceAtIndex(route, this.state.presentedIndex); - }, - - /** - * Replace the current route's parent. - */ - replacePrevious: function(route) { - this.replaceAtIndex(route, this.state.presentedIndex - 1); - }, - - popToTop: function() { - this.popToRoute(this.state.routeStack[0]); - }, - - popToRoute: function(route) { - var indexOfRoute = this.state.routeStack.indexOf(route); - invariant( - indexOfRoute !== -1, - 'Calling popToRoute for a route that doesn\'t exist!' - ); - var numToPop = this.state.presentedIndex - indexOfRoute; - this._popN(numToPop); - }, - - replacePreviousAndPop: function(route) { - if (this.state.routeStack.length < 2) { - return; - } - this.replacePrevious(route); - this.pop(); - }, - - resetTo: function(route) { - invariant(!!route, 'Must supply route to push'); - this.replaceAtIndex(route, 0, () => { - // Do not use popToRoute here, because race conditions could prevent the - // route from existing at this time. Instead, just go to index 0 - if (this.state.presentedIndex > 0) { - this._popN(this.state.presentedIndex); - } - }); - }, - - getCurrentRoutes: function() { - // Clone before returning to avoid caller mutating the stack - return this.state.routeStack.slice(); - }, - - _cleanScenesPastIndex: function(index) { - var newStackLength = index + 1; - // Remove any unneeded rendered routes. - if (newStackLength < this.state.routeStack.length) { - this.setState({ - sceneConfigStack: this.state.sceneConfigStack.slice(0, newStackLength), - routeStack: this.state.routeStack.slice(0, newStackLength), - }); - } - }, - - _renderScene: function(route, i) { - var disabledSceneStyle = null; - var disabledScenePointerEvents = 'auto'; - if (i !== this.state.presentedIndex) { - disabledSceneStyle = styles.disabledScene; - disabledScenePointerEvents = 'none'; - } - return ( - { - return (this.state.transitionFromIndex != null) || (this.state.transitionFromIndex != null); - }} - pointerEvents={disabledScenePointerEvents} - style={[styles.baseScene, this.props.sceneStyle, disabledSceneStyle]}> - {this.props.renderScene( - route, - this - )} - - ); - }, - - _renderNavigationBar: function() { - if (!this.props.navigationBar) { - return null; - } - return React.cloneElement(this.props.navigationBar, { - ref: (navBar) => { - this.props.navigationBar.ref instanceof Function && this.props.navigationBar.ref(navBar); - this._navBar = navBar; - }, - navigator: this._navigationBarNavigator, - navState: this.state, - }); - }, - - render: function() { - var newRenderedSceneMap = new Map(); - var scenes = this.state.routeStack.map((route, index) => { - var renderedScene; - if (this._renderedSceneMap.has(route) && - index !== this.state.presentedIndex) { - renderedScene = this._renderedSceneMap.get(route); - } else { - renderedScene = this._renderScene(route, index); - } - newRenderedSceneMap.set(route, renderedScene); - return renderedScene; - }); - this._renderedSceneMap = newRenderedSceneMap; - return ( - - - {scenes} - - {this._renderNavigationBar()} - - ); - }, - - _getNavigationContext: function() { - if (!this._navigationContext) { - this._navigationContext = new NavigationContext(); - } - return this._navigationContext; - } -}); - -module.exports = Navigator; diff --git a/examples/node_modules/react-native/Libraries/CustomComponents/Navigator/NavigatorBreadcrumbNavigationBar.js b/examples/node_modules/react-native/Libraries/CustomComponents/Navigator/NavigatorBreadcrumbNavigationBar.js deleted file mode 100644 index b142b18f..00000000 --- a/examples/node_modules/react-native/Libraries/CustomComponents/Navigator/NavigatorBreadcrumbNavigationBar.js +++ /dev/null @@ -1,290 +0,0 @@ -/** - * Copyright (c) 2015, Facebook, Inc. All rights reserved. - * - * Facebook, Inc. ("Facebook") owns all right, title and interest, including - * all intellectual property and other proprietary rights, in and to the React - * Native CustomComponents software (the "Software"). Subject to your - * compliance with these terms, you are hereby granted a non-exclusive, - * worldwide, royalty-free copyright license to (1) use and copy the Software; - * and (2) reproduce and distribute the Software as part of your own software - * ("Your Software"). Facebook reserves all rights not expressly granted to - * you in this license agreement. - * - * THE SOFTWARE AND DOCUMENTATION, IF ANY, ARE PROVIDED "AS IS" AND ANY EXPRESS - * OR IMPLIED WARRANTIES (INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE) ARE DISCLAIMED. - * IN NO EVENT SHALL FACEBOOK OR ITS AFFILIATES, OFFICERS, DIRECTORS OR - * EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THE SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * @providesModule NavigatorBreadcrumbNavigationBar - */ -'use strict'; - -var NavigatorBreadcrumbNavigationBarStyles = require('NavigatorBreadcrumbNavigationBarStyles'); -var NavigatorNavigationBarStylesAndroid = require('NavigatorNavigationBarStylesAndroid'); -var NavigatorNavigationBarStylesIOS = require('NavigatorNavigationBarStylesIOS'); -var Platform = require('Platform'); -var React = require('React'); -var StyleSheet = require('StyleSheet'); -var View = require('View'); - -var { Map } = require('immutable'); - -var invariant = require('invariant'); - -var Interpolators = NavigatorBreadcrumbNavigationBarStyles.Interpolators; -var NavigatorNavigationBarStyles = Platform.OS === 'android' ? - NavigatorNavigationBarStylesAndroid : NavigatorNavigationBarStylesIOS; -var PropTypes = React.PropTypes; - -/** - * Reusable props objects. - */ -var CRUMB_PROPS = Interpolators.map(() => ({style: {}})); -var ICON_PROPS = Interpolators.map(() => ({style: {}})); -var SEPARATOR_PROPS = Interpolators.map(() => ({style: {}})); -var TITLE_PROPS = Interpolators.map(() => ({style: {}})); -var RIGHT_BUTTON_PROPS = Interpolators.map(() => ({style: {}})); - - -var navStatePresentedIndex = function(navState) { - if (navState.presentedIndex !== undefined) { - return navState.presentedIndex; - } - // TODO: rename `observedTopOfStack` to `presentedIndex` in `NavigatorIOS` - return navState.observedTopOfStack; -}; - - -/** - * The first route is initially rendered using a different style than all - * future routes. - * - * @param {number} index Index of breadcrumb. - * @return {object} Style config for initial rendering of index. - */ -var initStyle = function(index, presentedIndex) { - return index === presentedIndex ? NavigatorBreadcrumbNavigationBarStyles.Center[index] : - index < presentedIndex ? NavigatorBreadcrumbNavigationBarStyles.Left[index] : - NavigatorBreadcrumbNavigationBarStyles.Right[index]; -}; - -var NavigatorBreadcrumbNavigationBar = React.createClass({ - propTypes: { - navigator: PropTypes.shape({ - push: PropTypes.func, - pop: PropTypes.func, - replace: PropTypes.func, - popToRoute: PropTypes.func, - popToTop: PropTypes.func, - }), - routeMapper: PropTypes.shape({ - rightContentForRoute: PropTypes.func, - titleContentForRoute: PropTypes.func, - iconForRoute: PropTypes.func, - }), - navState: React.PropTypes.shape({ - routeStack: React.PropTypes.arrayOf(React.PropTypes.object), - presentedIndex: React.PropTypes.number, - }), - style: View.propTypes.style, - }, - - statics: { - Styles: NavigatorBreadcrumbNavigationBarStyles, - }, - - _updateIndexProgress: function(progress, index, fromIndex, toIndex) { - var amount = toIndex > fromIndex ? progress : (1 - progress); - var oldDistToCenter = index - fromIndex; - var newDistToCenter = index - toIndex; - var interpolate; - invariant( - Interpolators[index], - 'Cannot find breadcrumb interpolators for ' + index - ); - if (oldDistToCenter > 0 && newDistToCenter === 0 || - newDistToCenter > 0 && oldDistToCenter === 0) { - interpolate = Interpolators[index].RightToCenter; - } else if (oldDistToCenter < 0 && newDistToCenter === 0 || - newDistToCenter < 0 && oldDistToCenter === 0) { - interpolate = Interpolators[index].CenterToLeft; - } else if (oldDistToCenter === newDistToCenter) { - interpolate = Interpolators[index].RightToCenter; - } else { - interpolate = Interpolators[index].RightToLeft; - } - - if (interpolate.Crumb(CRUMB_PROPS[index].style, amount)) { - this._setPropsIfExists('crumb_' + index, CRUMB_PROPS[index]); - } - if (interpolate.Icon(ICON_PROPS[index].style, amount)) { - this._setPropsIfExists('icon_' + index, ICON_PROPS[index]); - } - if (interpolate.Separator(SEPARATOR_PROPS[index].style, amount)) { - this._setPropsIfExists('separator_' + index, SEPARATOR_PROPS[index]); - } - if (interpolate.Title(TITLE_PROPS[index].style, amount)) { - this._setPropsIfExists('title_' + index, TITLE_PROPS[index]); - } - var right = this.refs['right_' + index]; - if (right && - interpolate.RightItem(RIGHT_BUTTON_PROPS[index].style, amount)) { - right.setNativeProps(RIGHT_BUTTON_PROPS[index]); - } - }, - - updateProgress: function(progress, fromIndex, toIndex) { - var max = Math.max(fromIndex, toIndex); - var min = Math.min(fromIndex, toIndex); - for (var index = min; index <= max; index++) { - this._updateIndexProgress(progress, index, fromIndex, toIndex); - } - }, - - onAnimationStart: function(fromIndex, toIndex) { - var max = Math.max(fromIndex, toIndex); - var min = Math.min(fromIndex, toIndex); - for (var index = min; index <= max; index++) { - this._setRenderViewsToHardwareTextureAndroid(index, true); - } - }, - - onAnimationEnd: function() { - var max = this.props.navState.routeStack.length - 1; - for (var index = 0; index <= max; index++) { - this._setRenderViewsToHardwareTextureAndroid(index, false); - } - }, - - _setRenderViewsToHardwareTextureAndroid: function(index, renderToHardwareTexture) { - var props = { - renderToHardwareTextureAndroid: renderToHardwareTexture, - }; - - this._setPropsIfExists('icon_' + index, props); - this._setPropsIfExists('separator_' + index, props); - this._setPropsIfExists('title_' + index, props); - this._setPropsIfExists('right_' + index, props); - }, - - componentWillMount: function() { - this._descriptors = { - crumb: new Map(), - title: new Map(), - right: new Map(), - }; - }, - - render: function() { - var navState = this.props.navState; - var icons = navState && navState.routeStack.map(this._getBreadcrumb); - var titles = navState.routeStack.map(this._getTitle); - var buttons = navState.routeStack.map(this._getRightButton); - return ( - - {titles} - {icons} - {buttons} - - ); - }, - - _getBreadcrumb: function(route, index) { - if (this._descriptors.crumb.has(route)) { - return this._descriptors.crumb.get(route); - } - - var navBarRouteMapper = this.props.routeMapper; - var firstStyles = initStyle(index, navStatePresentedIndex(this.props.navState)); - - var breadcrumbDescriptor = ( - - - {navBarRouteMapper.iconForRoute(route, this.props.navigator)} - - - {navBarRouteMapper.separatorForRoute(route, this.props.navigator)} - - - ); - - this._descriptors.crumb = this._descriptors.crumb.set(route, breadcrumbDescriptor); - return breadcrumbDescriptor; - }, - - _getTitle: function(route, index) { - if (this._descriptors.title.has(route)) { - return this._descriptors.title.get(route); - } - - var titleContent = this.props.routeMapper.titleContentForRoute( - this.props.navState.routeStack[index], - this.props.navigator - ); - var firstStyles = initStyle(index, navStatePresentedIndex(this.props.navState)); - - var titleDescriptor = ( - - {titleContent} - - ); - this._descriptors.title = this._descriptors.title.set(route, titleDescriptor); - return titleDescriptor; - }, - - _getRightButton: function(route, index) { - if (this._descriptors.right.has(route)) { - return this._descriptors.right.get(route); - } - var rightContent = this.props.routeMapper.rightContentForRoute( - this.props.navState.routeStack[index], - this.props.navigator - ); - if (!rightContent) { - this._descriptors.right = this._descriptors.right.set(route, null); - return null; - } - var firstStyles = initStyle(index, navStatePresentedIndex(this.props.navState)); - var rightButtonDescriptor = ( - - {rightContent} - - ); - this._descriptors.right = this._descriptors.right.set(route, rightButtonDescriptor); - return rightButtonDescriptor; - }, - - _setPropsIfExists: function(ref, props) { - var ref = this.refs[ref]; - ref && ref.setNativeProps(props); - }, -}); - -var styles = StyleSheet.create({ - breadCrumbContainer: { - overflow: 'hidden', - position: 'absolute', - height: NavigatorNavigationBarStyles.General.TotalNavHeight, - top: 0, - left: 0, - right: 0, - }, -}); - -module.exports = NavigatorBreadcrumbNavigationBar; diff --git a/examples/node_modules/react-native/Libraries/CustomComponents/Navigator/NavigatorBreadcrumbNavigationBarStyles.ios.js b/examples/node_modules/react-native/Libraries/CustomComponents/Navigator/NavigatorBreadcrumbNavigationBarStyles.ios.js deleted file mode 100644 index eea15eee..00000000 --- a/examples/node_modules/react-native/Libraries/CustomComponents/Navigator/NavigatorBreadcrumbNavigationBarStyles.ios.js +++ /dev/null @@ -1,227 +0,0 @@ -/** - * Copyright (c) 2015, Facebook, Inc. All rights reserved. - * - * Facebook, Inc. ("Facebook") owns all right, title and interest, including - * all intellectual property and other proprietary rights, in and to the React - * Native CustomComponents software (the "Software"). Subject to your - * compliance with these terms, you are hereby granted a non-exclusive, - * worldwide, royalty-free copyright license to (1) use and copy the Software; - * and (2) reproduce and distribute the Software as part of your own software - * ("Your Software"). Facebook reserves all rights not expressly granted to - * you in this license agreement. - * - * THE SOFTWARE AND DOCUMENTATION, IF ANY, ARE PROVIDED "AS IS" AND ANY EXPRESS - * OR IMPLIED WARRANTIES (INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE) ARE DISCLAIMED. - * IN NO EVENT SHALL FACEBOOK OR ITS AFFILIATES, OFFICERS, DIRECTORS OR - * EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THE SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * @providesModule NavigatorBreadcrumbNavigationBarStyles - */ -'use strict'; - -var Dimensions = require('Dimensions'); -var NavigatorNavigationBarStylesIOS = require('NavigatorNavigationBarStylesIOS'); - -var buildStyleInterpolator = require('buildStyleInterpolator'); -var merge = require('merge'); - -var SCREEN_WIDTH = Dimensions.get('window').width; -var STATUS_BAR_HEIGHT = NavigatorNavigationBarStylesIOS.General.StatusBarHeight; -var NAV_BAR_HEIGHT = NavigatorNavigationBarStylesIOS.General.NavBarHeight; - -var SPACING = 4; -var ICON_WIDTH = 40; -var SEPARATOR_WIDTH = 9; -var CRUMB_WIDTH = ICON_WIDTH + SEPARATOR_WIDTH; - -var OPACITY_RATIO = 100; -var ICON_INACTIVE_OPACITY = 0.6; -var MAX_BREADCRUMBS = 10; - -var CRUMB_BASE = { - position: 'absolute', - flexDirection: 'row', - top: STATUS_BAR_HEIGHT, - width: CRUMB_WIDTH, - height: NAV_BAR_HEIGHT, - backgroundColor: 'transparent', -}; - -var ICON_BASE = { - width: ICON_WIDTH, - height: NAV_BAR_HEIGHT, -}; - -var SEPARATOR_BASE = { - width: SEPARATOR_WIDTH, - height: NAV_BAR_HEIGHT, -}; - -var TITLE_BASE = { - position: 'absolute', - top: STATUS_BAR_HEIGHT, - height: NAV_BAR_HEIGHT, - backgroundColor: 'transparent', -}; - -// For first title styles, make sure first title is centered -var FIRST_TITLE_BASE = merge(TITLE_BASE, { - left: 0, - right: 0, - alignItems: 'center', - height: NAV_BAR_HEIGHT, -}); - -var RIGHT_BUTTON_BASE = { - position: 'absolute', - top: STATUS_BAR_HEIGHT, - right: SPACING, - overflow: 'hidden', - opacity: 1, - height: NAV_BAR_HEIGHT, - backgroundColor: 'transparent', -}; - -/** - * Precompute crumb styles so that they don't need to be recomputed on every - * interaction. - */ -var LEFT = []; -var CENTER = []; -var RIGHT = []; -for (var i = 0; i < MAX_BREADCRUMBS; i++) { - var crumbLeft = CRUMB_WIDTH * i + SPACING; - LEFT[i] = { - Crumb: merge(CRUMB_BASE, { left: crumbLeft }), - Icon: merge(ICON_BASE, { opacity: ICON_INACTIVE_OPACITY }), - Separator: merge(SEPARATOR_BASE, { opacity: 1 }), - Title: merge(TITLE_BASE, { left: crumbLeft, opacity: 0 }), - RightItem: merge(RIGHT_BUTTON_BASE, { opacity: 0 }), - }; - CENTER[i] = { - Crumb: merge(CRUMB_BASE, { left: crumbLeft }), - Icon: merge(ICON_BASE, { opacity: 1 }), - Separator: merge(SEPARATOR_BASE, { opacity: 0 }), - Title: merge(TITLE_BASE, { - left: crumbLeft + ICON_WIDTH, - opacity: 1, - }), - RightItem: merge(RIGHT_BUTTON_BASE, { opacity: 1 }), - }; - var crumbRight = SCREEN_WIDTH - 100; - RIGHT[i] = { - Crumb: merge(CRUMB_BASE, { left: crumbRight}), - Icon: merge(ICON_BASE, { opacity: 0 }), - Separator: merge(SEPARATOR_BASE, { opacity: 0 }), - Title: merge(TITLE_BASE, { - left: crumbRight + ICON_WIDTH, - opacity: 0, - }), - RightItem: merge(RIGHT_BUTTON_BASE, { opacity: 0 }), - }; -} - -// Special case the CENTER state of the first scene. -CENTER[0] = { - Crumb: merge(CRUMB_BASE, {left: SCREEN_WIDTH / 4}), - Icon: merge(ICON_BASE, {opacity: 0}), - Separator: merge(SEPARATOR_BASE, {opacity: 0}), - Title: merge(FIRST_TITLE_BASE, {opacity: 1}), - RightItem: CENTER[0].RightItem, -}; -LEFT[0].Title = merge(FIRST_TITLE_BASE, {left: -SCREEN_WIDTH / 4, opacity: 0}); -RIGHT[0].Title = merge(FIRST_TITLE_BASE, {opacity: 0}); - - -var buildIndexSceneInterpolator = function(startStyles, endStyles) { - return { - Crumb: buildStyleInterpolator({ - left: { - type: 'linear', - from: startStyles.Crumb.left, - to: endStyles.Crumb.left, - min: 0, - max: 1, - extrapolate: true, - }, - }), - Icon: buildStyleInterpolator({ - opacity: { - type: 'linear', - from: startStyles.Icon.opacity, - to: endStyles.Icon.opacity, - min: 0, - max: 1, - }, - }), - Separator: buildStyleInterpolator({ - opacity: { - type: 'linear', - from: startStyles.Separator.opacity, - to: endStyles.Separator.opacity, - min: 0, - max: 1, - }, - }), - Title: buildStyleInterpolator({ - opacity: { - type: 'linear', - from: startStyles.Title.opacity, - to: endStyles.Title.opacity, - min: 0, - max: 1, - }, - left: { - type: 'linear', - from: startStyles.Title.left, - to: endStyles.Title.left, - min: 0, - max: 1, - extrapolate: true, - }, - }), - RightItem: buildStyleInterpolator({ - opacity: { - type: 'linear', - from: startStyles.RightItem.opacity, - to: endStyles.RightItem.opacity, - min: 0, - max: 1, - round: OPACITY_RATIO, - }, - }), - }; -}; - -var Interpolators = CENTER.map(function(_, ii) { - return { - // Animating *into* the center stage from the right - RightToCenter: buildIndexSceneInterpolator(RIGHT[ii], CENTER[ii]), - // Animating out of the center stage, to the left - CenterToLeft: buildIndexSceneInterpolator(CENTER[ii], LEFT[ii]), - // Both stages (animating *past* the center stage) - RightToLeft: buildIndexSceneInterpolator(RIGHT[ii], LEFT[ii]), - }; -}); - -/** - * Contains constants that are used in constructing both `StyleSheet`s and - * inline styles during transitions. - */ -module.exports = { - Interpolators, - Left: LEFT, - Center: CENTER, - Right: RIGHT, - IconWidth: ICON_WIDTH, - IconHeight: NAV_BAR_HEIGHT, - SeparatorWidth: SEPARATOR_WIDTH, - SeparatorHeight: NAV_BAR_HEIGHT, -}; diff --git a/examples/node_modules/react-native/Libraries/CustomComponents/Navigator/NavigatorNavigationBar.js b/examples/node_modules/react-native/Libraries/CustomComponents/Navigator/NavigatorNavigationBar.js deleted file mode 100644 index b6fbcdc3..00000000 --- a/examples/node_modules/react-native/Libraries/CustomComponents/Navigator/NavigatorNavigationBar.js +++ /dev/null @@ -1,220 +0,0 @@ -/** - * Copyright (c) 2015, Facebook, Inc. All rights reserved. - * - * Facebook, Inc. ("Facebook") owns all right, title and interest, including - * all intellectual property and other proprietary rights, in and to the React - * Native CustomComponents software (the "Software"). Subject to your - * compliance with these terms, you are hereby granted a non-exclusive, - * worldwide, royalty-free copyright license to (1) use and copy the Software; - * and (2) reproduce and distribute the Software as part of your own software - * ("Your Software"). Facebook reserves all rights not expressly granted to - * you in this license agreement. - * - * THE SOFTWARE AND DOCUMENTATION, IF ANY, ARE PROVIDED "AS IS" AND ANY EXPRESS - * OR IMPLIED WARRANTIES (INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE) ARE DISCLAIMED. - * IN NO EVENT SHALL FACEBOOK OR ITS AFFILIATES, OFFICERS, DIRECTORS OR - * EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THE SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * @providesModule NavigatorNavigationBar - */ -'use strict'; - -var React = require('React'); -var NavigatorNavigationBarStylesAndroid = require('NavigatorNavigationBarStylesAndroid'); -var NavigatorNavigationBarStylesIOS = require('NavigatorNavigationBarStylesIOS'); -var Platform = require('Platform'); -var StyleSheet = require('StyleSheet'); -var View = require('View'); - -var { Map } = require('immutable'); - -var COMPONENT_NAMES = ['Title', 'LeftButton', 'RightButton']; - -var NavigatorNavigationBarStyles = Platform.OS === 'android' ? - NavigatorNavigationBarStylesAndroid : NavigatorNavigationBarStylesIOS; - -var navStatePresentedIndex = function(navState) { - if (navState.presentedIndex !== undefined) { - return navState.presentedIndex; - } - // TODO: rename `observedTopOfStack` to `presentedIndex` in `NavigatorIOS` - return navState.observedTopOfStack; -}; - -var NavigatorNavigationBar = React.createClass({ - - propTypes: { - navigator: React.PropTypes.object, - routeMapper: React.PropTypes.shape({ - Title: React.PropTypes.func.isRequired, - LeftButton: React.PropTypes.func.isRequired, - RightButton: React.PropTypes.func.isRequired, - }).isRequired, - navState: React.PropTypes.shape({ - routeStack: React.PropTypes.arrayOf(React.PropTypes.object), - presentedIndex: React.PropTypes.number, - }), - navigationStyles: React.PropTypes.object, - style: View.propTypes.style, - }, - - statics: { - Styles: NavigatorNavigationBarStyles, - StylesAndroid: NavigatorNavigationBarStylesAndroid, - StylesIOS: NavigatorNavigationBarStylesIOS, - }, - - getDefaultProps() { - return { - navigationStyles: NavigatorNavigationBarStyles, - }; - }, - - componentWillMount: function() { - this._components = {}; - this._descriptors = {}; - - COMPONENT_NAMES.forEach(componentName => { - this._components[componentName] = new Map(); - this._descriptors[componentName] = new Map(); - }); - }, - - _getReusableProps: function( - /*string*/componentName, - /*number*/index - ) /*object*/ { - if (!this._reusableProps) { - this._reusableProps = {}; - } - var propStack = this._reusableProps[componentName]; - if (!propStack) { - propStack = this._reusableProps[componentName] = []; - } - var props = propStack[index]; - if (!props) { - props = propStack[index] = {style:{}}; - } - return props; - }, - - _updateIndexProgress: function( - /*number*/progress, - /*number*/index, - /*number*/fromIndex, - /*number*/toIndex - ) { - var amount = toIndex > fromIndex ? progress : (1 - progress); - var oldDistToCenter = index - fromIndex; - var newDistToCenter = index - toIndex; - var interpolate; - if (oldDistToCenter > 0 && newDistToCenter === 0 || - newDistToCenter > 0 && oldDistToCenter === 0) { - interpolate = this.props.navigationStyles.Interpolators.RightToCenter; - } else if (oldDistToCenter < 0 && newDistToCenter === 0 || - newDistToCenter < 0 && oldDistToCenter === 0) { - interpolate = this.props.navigationStyles.Interpolators.CenterToLeft; - } else if (oldDistToCenter === newDistToCenter) { - interpolate = this.props.navigationStyles.Interpolators.RightToCenter; - } else { - interpolate = this.props.navigationStyles.Interpolators.RightToLeft; - } - - COMPONENT_NAMES.forEach(function (componentName) { - var component = this._components[componentName].get(this.props.navState.routeStack[index]); - var props = this._getReusableProps(componentName, index); - if (component && interpolate[componentName](props.style, amount)) { - component.setNativeProps(props); - } - }, this); - }, - - updateProgress: function( - /*number*/progress, - /*number*/fromIndex, - /*number*/toIndex - ) { - var max = Math.max(fromIndex, toIndex); - var min = Math.min(fromIndex, toIndex); - for (var index = min; index <= max; index++) { - this._updateIndexProgress(progress, index, fromIndex, toIndex); - } - }, - - render: function() { - var navBarStyle = { - height: this.props.navigationStyles.General.TotalNavHeight, - }; - var navState = this.props.navState; - var components = COMPONENT_NAMES.map(function (componentName) { - return navState.routeStack.map( - this._getComponent.bind(this, componentName) - ); - }, this); - - return ( - - {components} - - ); - }, - - _getComponent: function( - /*string*/componentName, - /*object*/route, - /*number*/index - ) /*?Object*/ { - if (this._descriptors[componentName].includes(route)) { - return this._descriptors[componentName].get(route); - } - - var rendered = null; - - var content = this.props.routeMapper[componentName]( - this.props.navState.routeStack[index], - this.props.navigator, - index, - this.props.navState - ); - if (!content) { - return null; - } - - var initialStage = index === navStatePresentedIndex(this.props.navState) ? - this.props.navigationStyles.Stages.Center : - this.props.navigationStyles.Stages.Left; - rendered = ( - { - this._components[componentName] = this._components[componentName].set(route, ref); - }} - style={initialStage[componentName]}> - {content} - - ); - - this._descriptors[componentName] = this._descriptors[componentName].set(route, rendered); - return rendered; - }, - -}); - - -var styles = StyleSheet.create({ - navBarContainer: { - position: 'absolute', - top: 0, - left: 0, - right: 0, - backgroundColor: 'transparent', - }, -}); - -module.exports = NavigatorNavigationBar; diff --git a/examples/node_modules/react-native/Libraries/CustomComponents/Navigator/NavigatorSceneConfigs.js b/examples/node_modules/react-native/Libraries/CustomComponents/Navigator/NavigatorSceneConfigs.js deleted file mode 100644 index 32cd3363..00000000 --- a/examples/node_modules/react-native/Libraries/CustomComponents/Navigator/NavigatorSceneConfigs.js +++ /dev/null @@ -1,621 +0,0 @@ -/** - * Copyright (c) 2015, Facebook, Inc. All rights reserved. - * - * Facebook, Inc. ("Facebook") owns all right, title and interest, including - * all intellectual property and other proprietary rights, in and to the React - * Native CustomComponents software (the "Software"). Subject to your - * compliance with these terms, you are hereby granted a non-exclusive, - * worldwide, royalty-free copyright license to (1) use and copy the Software; - * and (2) reproduce and distribute the Software as part of your own software - * ("Your Software"). Facebook reserves all rights not expressly granted to - * you in this license agreement. - * - * THE SOFTWARE AND DOCUMENTATION, IF ANY, ARE PROVIDED "AS IS" AND ANY EXPRESS - * OR IMPLIED WARRANTIES (INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES - * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE) ARE DISCLAIMED. - * IN NO EVENT SHALL FACEBOOK OR ITS AFFILIATES, OFFICERS, DIRECTORS OR - * EMPLOYEES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; - * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, - * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR - * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THE SOFTWARE, EVEN IF - * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - * @providesModule NavigatorSceneConfigs - */ -'use strict'; - -var Dimensions = require('Dimensions'); -var PixelRatio = require('PixelRatio'); - -var buildStyleInterpolator = require('buildStyleInterpolator'); - -var SCREEN_WIDTH = Dimensions.get('window').width; -var SCREEN_HEIGHT = Dimensions.get('window').height; - -var FadeToTheLeft = { - // Rotate *requires* you to break out each individual component of - // rotation (x, y, z, w) - transformTranslate: { - from: {x: 0, y: 0, z: 0}, - to: {x: -Math.round(Dimensions.get('window').width * 0.3), y: 0, z: 0}, - min: 0, - max: 1, - type: 'linear', - extrapolate: true, - round: PixelRatio.get(), - }, - // Uncomment to try rotation: - // Quick guide to reasoning about rotations: - // http://www.opengl-tutorial.org/intermediate-tutorials/tutorial-17-quaternions/#Quaternions - // transformRotateRadians: { - // from: {x: 0, y: 0, z: 0, w: 1}, - // to: {x: 0, y: 0, z: -0.47, w: 0.87}, - // min: 0, - // max: 1, - // type: 'linear', - // extrapolate: true - // }, - transformScale: { - from: {x: 1, y: 1, z: 1}, - to: {x: 0.95, y: 0.95, z: 1}, - min: 0, - max: 1, - type: 'linear', - extrapolate: true - }, - opacity: { - from: 1, - to: 0.3, - min: 0, - max: 1, - type: 'linear', - extrapolate: false, - round: 100, - }, - translateX: { - from: 0, - to: -Math.round(Dimensions.get('window').width * 0.3), - min: 0, - max: 1, - type: 'linear', - extrapolate: true, - round: PixelRatio.get(), - }, - scaleX: { - from: 1, - to: 0.95, - min: 0, - max: 1, - type: 'linear', - extrapolate: true - }, - scaleY: { - from: 1, - to: 0.95, - min: 0, - max: 1, - type: 'linear', - extrapolate: true - }, -}; - -var FadeToTheRight = { - ...FadeToTheLeft, - transformTranslate: { - from: {x: 0, y: 0, z: 0}, - to: {x: Math.round(SCREEN_WIDTH * 0.3), y: 0, z: 0}, - }, - translateX: { - from: 0, - to: Math.round(SCREEN_WIDTH * 0.3), - } -}; - -var FadeIn = { - opacity: { - from: 0, - to: 1, - min: 0.5, - max: 1, - type: 'linear', - extrapolate: false, - round: 100, - }, -}; - -var FadeOut = { - opacity: { - from: 1, - to: 0, - min: 0, - max: 0.5, - type: 'linear', - extrapolate: false, - round: 100, - }, -}; - -var ToTheLeft = { - transformTranslate: { - from: {x: 0, y: 0, z: 0}, - to: {x: -Dimensions.get('window').width, y: 0, z: 0}, - min: 0, - max: 1, - type: 'linear', - extrapolate: true, - round: PixelRatio.get(), - }, - opacity: { - value: 1.0, - type: 'constant', - }, - - translateX: { - from: 0, - to: -Dimensions.get('window').width, - min: 0, - max: 1, - type: 'linear', - extrapolate: true, - round: PixelRatio.get(), - }, -}; - -var ToTheUp = { - transformTranslate: { - from: {x: 0, y: 0, z: 0}, - to: {x: 0, y: -Dimensions.get('window').height, z: 0}, - min: 0, - max: 1, - type: 'linear', - extrapolate: true, - round: PixelRatio.get(), - }, - opacity: { - value: 1.0, - type: 'constant', - }, - translateY: { - from: 0, - to: -Dimensions.get('window').height, - min: 0, - max: 1, - type: 'linear', - extrapolate: true, - round: PixelRatio.get(), - }, -}; - -var ToTheDown = { - transformTranslate: { - from: {x: 0, y: 0, z: 0}, - to: {x: 0, y: Dimensions.get('window').height, z: 0}, - min: 0, - max: 1, - type: 'linear', - extrapolate: true, - round: PixelRatio.get(), - }, - opacity: { - value: 1.0, - type: 'constant', - }, - translateY: { - from: 0, - to: Dimensions.get('window').height, - min: 0, - max: 1, - type: 'linear', - extrapolate: true, - round: PixelRatio.get(), - }, -}; - -var FromTheRight = { - opacity: { - value: 1.0, - type: 'constant', - }, - - transformTranslate: { - from: {x: Dimensions.get('window').width, y: 0, z: 0}, - to: {x: 0, y: 0, z: 0}, - min: 0, - max: 1, - type: 'linear', - extrapolate: true, - round: PixelRatio.get(), - }, - - translateX: { - from: Dimensions.get('window').width, - to: 0, - min: 0, - max: 1, - type: 'linear', - extrapolate: true, - round: PixelRatio.get(), - }, - - scaleX: { - value: 1, - type: 'constant', - }, - scaleY: { - value: 1, - type: 'constant', - }, -}; - -var FromTheLeft = { - ...FromTheRight, - transformTranslate: { - from: {x: -SCREEN_WIDTH, y: 0, z: 0}, - to: {x: 0, y: 0, z: 0}, - min: 0, - max: 1, - type: 'linear', - extrapolate: true, - round: PixelRatio.get(), - }, - translateX: { - from: -SCREEN_WIDTH, - to: 0, - min: 0, - max: 1, - type: 'linear', - extrapolate: true, - round: PixelRatio.get(), - }, -}; - -var FromTheDown = { - ...FromTheRight, - transformTranslate: { - from: {y: SCREEN_HEIGHT, x: 0, z: 0}, - to: {x: 0, y: 0, z: 0}, - min: 0, - max: 1, - type: 'linear', - extrapolate: true, - round: PixelRatio.get(), - }, - translateY: { - from: SCREEN_HEIGHT, - to: 0, - min: 0, - max: 1, - type: 'linear', - extrapolate: true, - round: PixelRatio.get(), - }, -}; - -var FromTheTop = { - ...FromTheRight, - transformTranslate: { - from: {y: -SCREEN_HEIGHT, x: 0, z: 0}, - to: {x: 0, y: 0, z: 0}, - min: 0, - max: 1, - type: 'linear', - extrapolate: true, - round: PixelRatio.get(), - }, - translateY: { - from: -SCREEN_HEIGHT, - to: 0, - min: 0, - max: 1, - type: 'linear', - extrapolate: true, - round: PixelRatio.get(), - }, -}; - -var ToTheBack = { - // Rotate *requires* you to break out each individual component of - // rotation (x, y, z, w) - transformTranslate: { - from: {x: 0, y: 0, z: 0}, - to: {x: 0, y: 0, z: 0}, - min: 0, - max: 1, - type: 'linear', - extrapolate: true, - round: PixelRatio.get(), - }, - transformScale: { - from: {x: 1, y: 1, z: 1}, - to: {x: 0.95, y: 0.95, z: 1}, - min: 0, - max: 1, - type: 'linear', - extrapolate: true - }, - opacity: { - from: 1, - to: 0.3, - min: 0, - max: 1, - type: 'linear', - extrapolate: false, - round: 100, - }, - scaleX: { - from: 1, - to: 0.95, - min: 0, - max: 1, - type: 'linear', - extrapolate: true - }, - scaleY: { - from: 1, - to: 0.95, - min: 0, - max: 1, - type: 'linear', - extrapolate: true - }, -}; - -var FromTheFront = { - opacity: { - value: 1.0, - type: 'constant', - }, - - transformTranslate: { - from: {x: 0, y: Dimensions.get('window').height, z: 0}, - to: {x: 0, y: 0, z: 0}, - min: 0, - max: 1, - type: 'linear', - extrapolate: true, - round: PixelRatio.get(), - }, - translateY: { - from: Dimensions.get('window').height, - to: 0, - min: 0, - max: 1, - type: 'linear', - extrapolate: true, - round: PixelRatio.get(), - }, - scaleX: { - value: 1, - type: 'constant', - }, - scaleY: { - value: 1, - type: 'constant', - }, -}; - -var ToTheBackAndroid = { - opacity: { - value: 1, - type: 'constant', - }, -}; - -var FromTheFrontAndroid = { - opacity: { - from: 0, - to: 1, - min: 0.5, - max: 1, - type: 'linear', - extrapolate: false, - round: 100, - }, - transformTranslate: { - from: {x: 0, y: 100, z: 0}, - to: {x: 0, y: 0, z: 0}, - min: 0, - max: 1, - type: 'linear', - extrapolate: true, - round: PixelRatio.get(), - }, - translateY: { - from: 100, - to: 0, - min: 0, - max: 1, - type: 'linear', - extrapolate: true, - round: PixelRatio.get(), - }, -}; - -var BaseOverswipeConfig = { - frictionConstant: 1, - frictionByDistance: 1.5, -}; - -var BaseLeftToRightGesture = { - - // If the gesture can end and restart during one continuous touch - isDetachable: false, - - // How far the swipe must drag to start transitioning - gestureDetectMovement: 2, - - // Amplitude of release velocity that is considered still - notMoving: 0.3, - - // Fraction of directional move required. - directionRatio: 0.66, - - // Velocity to transition with when the gesture release was "not moving" - snapVelocity: 2, - - // Region that can trigger swipe. iOS default is 30px from the left edge - edgeHitWidth: 30, - - // Ratio of gesture completion when non-velocity release will cause action - stillCompletionRatio: 3 / 5, - - fullDistance: SCREEN_WIDTH, - - direction: 'left-to-right', - -}; - -var BaseRightToLeftGesture = { - ...BaseLeftToRightGesture, - direction: 'right-to-left', -}; - -var BaseDownUpGesture = { - ...BaseLeftToRightGesture, - fullDistance: SCREEN_HEIGHT, - direction: 'down-to-up', -}; - -var BaseUpDownGesture = { - ...BaseLeftToRightGesture, - fullDistance: SCREEN_HEIGHT, - direction: 'up-to-down', -}; - -var BaseConfig = { - // A list of all gestures that are enabled on this scene - gestures: { - pop: BaseLeftToRightGesture, - }, - - // Rebound spring parameters when transitioning FROM this scene - springFriction: 26, - springTension: 200, - - // Velocity to start at when transitioning without gesture - defaultTransitionVelocity: 1.5, - - // Animation interpolators for horizontal transitioning: - animationInterpolators: { - into: buildStyleInterpolator(FromTheRight), - out: buildStyleInterpolator(FadeToTheLeft), - }, -}; - -var NavigatorSceneConfigs = { - PushFromRight: { - ...BaseConfig, - // We will want to customize this soon - }, - FloatFromRight: { - ...BaseConfig, - // We will want to customize this soon - }, - FloatFromLeft: { - ...BaseConfig, - animationInterpolators: { - into: buildStyleInterpolator(FromTheLeft), - out: buildStyleInterpolator(FadeToTheRight), - }, - }, - FloatFromBottom: { - ...BaseConfig, - gestures: { - pop: { - ...BaseLeftToRightGesture, - edgeHitWidth: 150, - direction: 'top-to-bottom', - fullDistance: SCREEN_HEIGHT, - } - }, - animationInterpolators: { - into: buildStyleInterpolator(FromTheFront), - out: buildStyleInterpolator(ToTheBack), - }, - }, - FloatFromBottomAndroid: { - ...BaseConfig, - gestures: null, - defaultTransitionVelocity: 3, - springFriction: 20, - animationInterpolators: { - into: buildStyleInterpolator(FromTheFrontAndroid), - out: buildStyleInterpolator(ToTheBackAndroid), - }, - }, - FadeAndroid: { - ...BaseConfig, - gestures: null, - animationInterpolators: { - into: buildStyleInterpolator(FadeIn), - out: buildStyleInterpolator(FadeOut), - }, - }, - HorizontalSwipeJump: { - ...BaseConfig, - gestures: { - jumpBack: { - ...BaseLeftToRightGesture, - overswipe: BaseOverswipeConfig, - edgeHitWidth: null, - isDetachable: true, - }, - jumpForward: { - ...BaseRightToLeftGesture, - overswipe: BaseOverswipeConfig, - edgeHitWidth: null, - isDetachable: true, - }, - }, - animationInterpolators: { - into: buildStyleInterpolator(FromTheRight), - out: buildStyleInterpolator(ToTheLeft), - }, - }, - VerticalUpSwipeJump: { - ...BaseConfig, - gestures: { - jumpBack: { - ...BaseDownUpGesture, - overswipe: BaseOverswipeConfig, - edgeHitWidth: null, - isDetachable: true, - }, - jumpForward: { - ...BaseDownUpGesture, - overswipe: BaseOverswipeConfig, - edgeHitWidth: null, - isDetachable: true, - }, - }, - animationInterpolators: { - into: buildStyleInterpolator(FromTheDown), - out: buildStyleInterpolator(ToTheUp), - }, - }, - VerticalDownSwipeJump: { - ...BaseConfig, - gestures: { - jumpBack: { - ...BaseUpDownGesture, - overswipe: BaseOverswipeConfig, - edgeHitWidth: null, - isDetachable: true, - }, - jumpForward: { - ...BaseUpDownGesture, - overswipe: BaseOverswipeConfig, - edgeHitWidth: null, - isDetachable: true, - }, - }, - animationInterpolators: { - into: buildStyleInterpolator(FromTheTop), - out: buildStyleInterpolator(ToTheDown), - }, - }, -}; - -module.exports = NavigatorSceneConfigs; diff --git a/examples/node_modules/react-native/Libraries/Device/RCTDeviceEventEmitter.js b/examples/node_modules/react-native/Libraries/Device/RCTDeviceEventEmitter.js deleted file mode 100644 index 41e4d408..00000000 --- a/examples/node_modules/react-native/Libraries/Device/RCTDeviceEventEmitter.js +++ /dev/null @@ -1,24 +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. - * - * @providesModule RCTDeviceEventEmitter - * @flow - */ -'use strict'; - -var EventEmitter = require('EventEmitter'); -var BatchedBridge = require('BatchedBridge'); - -var RCTDeviceEventEmitter = new EventEmitter(); - -BatchedBridge.registerCallableModule( - 'RCTDeviceEventEmitter', - RCTDeviceEventEmitter -); - -module.exports = RCTDeviceEventEmitter; diff --git a/examples/node_modules/react-native/Libraries/Fetch/fetch.js b/examples/node_modules/react-native/Libraries/Fetch/fetch.js deleted file mode 100644 index ff5ef29b..00000000 --- a/examples/node_modules/react-native/Libraries/Fetch/fetch.js +++ /dev/null @@ -1,409 +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 polyfill grabbed from: - * https://github.com/github/fetch - * - * @providesModule fetch - * @nolint - */ -/* eslint-disable */ -'use strict'; - -var self = {}; - -/** - * Copyright (c) 2014 GitHub, Inc. - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * @preserve-header - */ -(function() { - 'use strict'; - - if (self.fetch) { - return - } - - function normalizeName(name) { - if (typeof name !== 'string') { - name = String(name) - } - if (/[^a-z0-9\-#$%&'*+.\^_`|~]/i.test(name)) { - throw new TypeError('Invalid character in header field name') - } - return name.toLowerCase() - } - - function normalizeValue(value) { - if (typeof value !== 'string') { - value = String(value) - } - return value - } - - function Headers(headers) { - this.map = {} - - if (headers instanceof Headers) { - headers.forEach(function(value, name) { - this.append(name, value) - }, this) - - } else if (headers) { - Object.getOwnPropertyNames(headers).forEach(function(name) { - this.append(name, headers[name]) - }, this) - } - } - - Headers.prototype.append = function(name, value) { - name = normalizeName(name) - value = normalizeValue(value) - var list = this.map[name] - if (!list) { - list = [] - this.map[name] = list - } - list.push(value) - } - - Headers.prototype['delete'] = function(name) { - delete this.map[normalizeName(name)] - } - - Headers.prototype.get = function(name) { - var values = this.map[normalizeName(name)] - return values ? values[0] : null - } - - Headers.prototype.getAll = function(name) { - return this.map[normalizeName(name)] || [] - } - - Headers.prototype.has = function(name) { - return this.map.hasOwnProperty(normalizeName(name)) - } - - Headers.prototype.set = function(name, value) { - this.map[normalizeName(name)] = [normalizeValue(value)] - } - - Headers.prototype.forEach = function(callback, thisArg) { - Object.getOwnPropertyNames(this.map).forEach(function(name) { - this.map[name].forEach(function(value) { - callback.call(thisArg, value, name, this) - }, this) - }, this) - } - - function consumed(body) { - if (body.bodyUsed) { - return Promise.reject(new TypeError('Already read')) - } - body.bodyUsed = true - } - - function fileReaderReady(reader) { - return new Promise(function(resolve, reject) { - reader.onload = function() { - resolve(reader.result) - } - reader.onerror = function() { - reject(reader.error) - } - }) - } - - function readBlobAsArrayBuffer(blob) { - var reader = new FileReader() - reader.readAsArrayBuffer(blob) - return fileReaderReady(reader) - } - - function readBlobAsText(blob) { - var reader = new FileReader() - reader.readAsText(blob) - return fileReaderReady(reader) - } - - var support = { - blob: typeof FileReader === 'function' && typeof Blob === 'function' && (function() { - try { - new Blob(); - return true - } catch(e) { - return false - } - })(), - formData: typeof FormData === 'function' - } - - function Body() { - this.bodyUsed = false - - - this._initBody = function(body) { - this._bodyInit = body - if (typeof body === 'string') { - this._bodyText = body - } else if (support.blob && Blob.prototype.isPrototypeOf(body)) { - this._bodyBlob = body - } else if (support.formData && FormData.prototype.isPrototypeOf(body)) { - this._bodyFormData = body - } else if (!body) { - this._bodyText = '' - } else { - throw new Error('unsupported BodyInit type') - } - } - - if (support.blob) { - this.blob = function() { - var rejected = consumed(this) - if (rejected) { - return rejected - } - - if (this._bodyBlob) { - return Promise.resolve(this._bodyBlob) - } else if (this._bodyFormData) { - throw new Error('could not read FormData body as blob') - } else { - return Promise.resolve(new Blob([this._bodyText])) - } - } - - this.arrayBuffer = function() { - return this.blob().then(readBlobAsArrayBuffer) - } - - this.text = function() { - var rejected = consumed(this) - if (rejected) { - return rejected - } - - if (this._bodyBlob) { - return readBlobAsText(this._bodyBlob) - } else if (this._bodyFormData) { - throw new Error('could not read FormData body as text') - } else { - return Promise.resolve(this._bodyText) - } - } - } else { - this.text = function() { - var rejected = consumed(this) - return rejected ? rejected : Promise.resolve(this._bodyText) - } - } - - if (support.formData) { - this.formData = function() { - return this.text().then(decode) - } - } - - this.json = function() { - return this.text().then(JSON.parse) - } - - return this - } - - // HTTP methods whose capitalization should be normalized - var methods = ['DELETE', 'GET', 'HEAD', 'OPTIONS', 'POST', 'PUT'] - - function normalizeMethod(method) { - var upcased = method.toUpperCase() - return (methods.indexOf(upcased) > -1) ? upcased : method - } - - function Request(input, options) { - options = options || {} - var body = options.body - if (Request.prototype.isPrototypeOf(input)) { - if (input.bodyUsed) { - throw new TypeError('Already read') - } - this.url = input.url - this.credentials = input.credentials - if (!options.headers) { - this.headers = new Headers(input.headers) - } - this.method = input.method - this.mode = input.mode - if (!body) { - body = input._bodyInit - input.bodyUsed = true - } - } else { - this.url = input - } - - this.credentials = options.credentials || this.credentials || 'omit' - if (options.headers || !this.headers) { - this.headers = new Headers(options.headers) - } - this.method = normalizeMethod(options.method || this.method || 'GET') - this.mode = options.mode || this.mode || null - this.referrer = null - - if ((this.method === 'GET' || this.method === 'HEAD') && body) { - throw new TypeError('Body not allowed for GET or HEAD requests') - } - this._initBody(body) - } - - Request.prototype.clone = function() { - return new Request(this) - } - - function decode(body) { - var form = new FormData() - body.trim().split('&').forEach(function(bytes) { - if (bytes) { - var split = bytes.split('=') - var name = split.shift().replace(/\+/g, ' ') - var value = split.join('=').replace(/\+/g, ' ') - form.append(decodeURIComponent(name), decodeURIComponent(value)) - } - }) - return form - } - - function headers(xhr) { - var head = new Headers() - var pairs = xhr.getAllResponseHeaders().trim().split('\n') - pairs.forEach(function(header) { - var split = header.trim().split(':') - var key = split.shift().trim() - var value = split.join(':').trim() - head.append(key, value) - }) - return head - } - - Body.call(Request.prototype) - - function Response(bodyInit, options) { - if (!options) { - options = {} - } - - this._initBody(bodyInit) - this.type = 'default' - this.url = null - this.status = options.status - this.ok = this.status >= 200 && this.status < 300 - this.statusText = options.statusText - this.headers = options.headers instanceof Headers ? options.headers : new Headers(options.headers) - this.url = options.url || '' - } - - Response.prototype.clone = function() { - return new Response(this._bodyInit, { - status: this.status, - statusText: this.statusText, - headers: new Headers(this.headers), - url: this.url - }) - } - - Body.call(Response.prototype) - - self.Headers = Headers; - self.Request = Request; - self.Response = Response; - - self.fetch = function(input, init) { - var request - if (Request.prototype.isPrototypeOf(input) && !init) { - request = input - } else { - request = new Request(input, init) - } - - return new Promise(function(resolve, reject) { - var xhr = new XMLHttpRequest() - - function responseURL() { - if ('responseURL' in xhr) { - return xhr.responseURL - } - - // Avoid security warnings on getResponseHeader when not allowed by CORS - if (/^X-Request-URL:/m.test(xhr.getAllResponseHeaders())) { - return xhr.getResponseHeader('X-Request-URL') - } - - return; - } - - xhr.onload = function() { - var status = (xhr.status === 1223) ? 204 : xhr.status - if (status < 100 || status > 599) { - reject(new TypeError('Network request failed')) - return - } - var options = { - status: status, - statusText: xhr.statusText, - headers: headers(xhr), - url: responseURL() - } - var body = 'response' in xhr ? xhr.response : xhr.responseText; - resolve(new Response(body, options)) - } - - xhr.onerror = function() { - reject(new TypeError('Network request failed')) - } - - xhr.open(request.method, request.url, true) - - if (request.credentials === 'include') { - xhr.withCredentials = true - } - - if ('responseType' in xhr && support.blob) { - xhr.responseType = 'blob' - } - - request.headers.forEach(function(value, name) { - xhr.setRequestHeader(name, value) - }) - - xhr.send(typeof request._bodyInit === 'undefined' ? null : request._bodyInit) - }) - } - self.fetch.polyfill = true -})(); - -/** End of the third-party code */ - -module.exports = self; diff --git a/examples/node_modules/react-native/Libraries/GeoLocation/Geolocation.js b/examples/node_modules/react-native/Libraries/GeoLocation/Geolocation.js deleted file mode 100644 index 681a5f77..00000000 --- a/examples/node_modules/react-native/Libraries/GeoLocation/Geolocation.js +++ /dev/null @@ -1,136 +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. - * - * @providesModule Geolocation - * @flow - */ -'use strict'; - -var RCTDeviceEventEmitter = require('RCTDeviceEventEmitter'); -var RCTLocationObserver = require('NativeModules').LocationObserver; - -var invariant = require('invariant'); -var logError = require('logError'); -var warning = require('warning'); - -var subscriptions = []; - -var updatesEnabled = false; - -type GeoOptions = { - timeout: number; - maximumAge: number; - enableHighAccuracy: bool; -} - -/** - * The Geolocation API follows the web spec: - * https://developer.mozilla.org/en-US/docs/Web/API/Geolocation - * - * ### iOS - * You need to include the `NSLocationWhenInUseUsageDescription` key - * in Info.plist to enable geolocation. Geolocation is enabled by default - * when you create a project with `react-native init`. - * - * ### Android - * To request access to location, you need to add the following line to your - * app's `AndroidManifest.xml`: - * - * `` - * - * Geolocation support for Android is planned but not yet open sourced. See - * [Known Issues](http://facebook.github.io/react-native/docs/known-issues.html#missing-modules-and-native-views). - * - */ -var Geolocation = { - - /* - * Invokes the success callback once with the latest location info. Supported - * options: timeout (ms), maximumAge (ms), enableHighAccuracy (bool) - */ - getCurrentPosition: function( - geo_success: Function, - geo_error?: Function, - geo_options?: GeoOptions - ) { - invariant( - typeof geo_success === 'function', - 'Must provide a valid geo_success callback.' - ); - RCTLocationObserver.getCurrentPosition( - geo_options || {}, - geo_success, - geo_error || logError - ); - }, - - /* - * Invokes the success callback whenever the location changes. Supported - * options: timeout (ms), maximumAge (ms), enableHighAccuracy (bool) - */ - watchPosition: function(success: Function, error?: Function, options?: GeoOptions): number { - if (!updatesEnabled) { - RCTLocationObserver.startObserving(options || {}); - updatesEnabled = true; - } - var watchID = subscriptions.length; - subscriptions.push([ - RCTDeviceEventEmitter.addListener( - 'geolocationDidChange', - success - ), - error ? RCTDeviceEventEmitter.addListener( - 'geolocationError', - error - ) : null, - ]); - return watchID; - }, - - clearWatch: function(watchID: number) { - var sub = subscriptions[watchID]; - if (!sub) { - // Silently exit when the watchID is invalid or already cleared - // This is consistent with timers - return; - } - - sub[0].remove(); - // array element refinements not yet enabled in Flow - var sub1 = sub[1]; sub1 && sub1.remove(); - subscriptions[watchID] = undefined; - var noWatchers = true; - for (var ii = 0; ii < subscriptions.length; ii++) { - if (subscriptions[ii]) { - noWatchers = false; // still valid subscriptions - } - } - if (noWatchers) { - Geolocation.stopObserving(); - } - }, - - stopObserving: function() { - if (updatesEnabled) { - RCTLocationObserver.stopObserving(); - updatesEnabled = false; - for (var ii = 0; ii < subscriptions.length; ii++) { - var sub = subscriptions[ii]; - if (sub) { - warning('Called stopObserving with existing subscriptions.'); - sub[0].remove(); - // array element refinements not yet enabled in Flow - var sub1 = sub[1]; sub1 && sub1.remove(); - } - } - subscriptions = []; - } - } -}; - -module.exports = Geolocation; diff --git a/examples/node_modules/react-native/Libraries/GeoLocation/RCTGeolocation.xcodeproj/project.pbxproj b/examples/node_modules/react-native/Libraries/GeoLocation/RCTGeolocation.xcodeproj/project.pbxproj deleted file mode 100644 index 0295e541..00000000 --- a/examples/node_modules/react-native/Libraries/GeoLocation/RCTGeolocation.xcodeproj/project.pbxproj +++ /dev/null @@ -1,267 +0,0 @@ -// !$*UTF8*$! -{ - archiveVersion = 1; - classes = { - }; - objectVersion = 46; - objects = { - -/* Begin PBXBuildFile section */ - 134814061AA4E45400B7C361 /* RCTLocationObserver.m in Sources */ = {isa = PBXBuildFile; fileRef = 134814051AA4E45400B7C361 /* RCTLocationObserver.m */; }; -/* End PBXBuildFile section */ - -/* Begin PBXCopyFilesBuildPhase section */ - 58B511D91A9E6C8500147676 /* CopyFiles */ = { - isa = PBXCopyFilesBuildPhase; - buildActionMask = 2147483647; - dstPath = "include/$(PRODUCT_NAME)"; - dstSubfolderSpec = 16; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXCopyFilesBuildPhase section */ - -/* Begin PBXFileReference section */ - 134814041AA4E45400B7C361 /* RCTLocationObserver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTLocationObserver.h; sourceTree = ""; }; - 134814051AA4E45400B7C361 /* RCTLocationObserver.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTLocationObserver.m; sourceTree = ""; }; - 134814201AA4EA6300B7C361 /* libRCTGeolocation.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRCTGeolocation.a; sourceTree = BUILT_PRODUCTS_DIR; }; -/* End PBXFileReference section */ - -/* Begin PBXFrameworksBuildPhase section */ - 58B511D81A9E6C8500147676 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXFrameworksBuildPhase section */ - -/* Begin PBXGroup section */ - 134814211AA4EA7D00B7C361 /* Products */ = { - isa = PBXGroup; - children = ( - 134814201AA4EA6300B7C361 /* libRCTGeolocation.a */, - ); - name = Products; - sourceTree = ""; - }; - 58B511D21A9E6C8500147676 = { - isa = PBXGroup; - children = ( - 134814041AA4E45400B7C361 /* RCTLocationObserver.h */, - 134814051AA4E45400B7C361 /* RCTLocationObserver.m */, - 134814211AA4EA7D00B7C361 /* Products */, - ); - indentWidth = 2; - sourceTree = ""; - tabWidth = 2; - }; -/* End PBXGroup section */ - -/* Begin PBXNativeTarget section */ - 58B511DA1A9E6C8500147676 /* RCTGeolocation */ = { - isa = PBXNativeTarget; - buildConfigurationList = 58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "RCTGeolocation" */; - buildPhases = ( - 58B511D71A9E6C8500147676 /* Sources */, - 58B511D81A9E6C8500147676 /* Frameworks */, - 58B511D91A9E6C8500147676 /* CopyFiles */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = RCTGeolocation; - productName = RCTDataManager; - productReference = 134814201AA4EA6300B7C361 /* libRCTGeolocation.a */; - productType = "com.apple.product-type.library.static"; - }; -/* End PBXNativeTarget section */ - -/* Begin PBXProject section */ - 58B511D31A9E6C8500147676 /* Project object */ = { - isa = PBXProject; - attributes = { - LastUpgradeCheck = 0610; - ORGANIZATIONNAME = Facebook; - TargetAttributes = { - 58B511DA1A9E6C8500147676 = { - CreatedOnToolsVersion = 6.1.1; - }; - }; - }; - buildConfigurationList = 58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "RCTGeolocation" */; - compatibilityVersion = "Xcode 3.2"; - developmentRegion = English; - hasScannedForEncodings = 0; - knownRegions = ( - en, - ); - mainGroup = 58B511D21A9E6C8500147676; - productRefGroup = 58B511D21A9E6C8500147676; - projectDirPath = ""; - projectRoot = ""; - targets = ( - 58B511DA1A9E6C8500147676 /* RCTGeolocation */, - ); - }; -/* End PBXProject section */ - -/* Begin PBXSourcesBuildPhase section */ - 58B511D71A9E6C8500147676 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 134814061AA4E45400B7C361 /* RCTLocationObserver.m in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXSourcesBuildPhase section */ - -/* Begin XCBuildConfiguration section */ - 58B511ED1A9E6C8500147676 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - COPY_PHASE_STRIP = NO; - ENABLE_STRICT_OBJC_MSGSEND = YES; - GCC_C_LANGUAGE_STANDARD = gnu99; - GCC_DYNAMIC_NO_PIC = NO; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", - "$(inherited)", - ); - GCC_SYMBOLS_PRIVATE_EXTERN = NO; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES; - GCC_WARN_SHADOW = YES; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 7.0; - MTL_ENABLE_DEBUG_INFO = YES; - ONLY_ACTIVE_ARCH = YES; - SDKROOT = iphoneos; - WARNING_CFLAGS = ( - "-Werror", - "-Wall", - ); - }; - name = Debug; - }; - 58B511EE1A9E6C8500147676 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - COPY_PHASE_STRIP = YES; - ENABLE_NS_ASSERTIONS = NO; - ENABLE_STRICT_OBJC_MSGSEND = YES; - GCC_C_LANGUAGE_STANDARD = gnu99; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES; - GCC_WARN_SHADOW = YES; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 7.0; - MTL_ENABLE_DEBUG_INFO = NO; - SDKROOT = iphoneos; - VALIDATE_PRODUCT = YES; - WARNING_CFLAGS = ( - "-Werror", - "-Wall", - ); - }; - name = Release; - }; - 58B511F01A9E6C8500147676 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - CLANG_STATIC_ANALYZER_MODE = deep; - HEADER_SEARCH_PATHS = ( - "$(inherited)", - /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, - "$(SRCROOT)/../../React/**", - ); - LIBRARY_SEARCH_PATHS = "$(inherited)"; - OTHER_LDFLAGS = "-ObjC"; - PRODUCT_NAME = RCTGeolocation; - RUN_CLANG_STATIC_ANALYZER = YES; - SKIP_INSTALL = YES; - }; - name = Debug; - }; - 58B511F11A9E6C8500147676 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - CLANG_STATIC_ANALYZER_MODE = deep; - HEADER_SEARCH_PATHS = ( - "$(inherited)", - /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, - "$(SRCROOT)/../../React/**", - ); - LIBRARY_SEARCH_PATHS = "$(inherited)"; - OTHER_LDFLAGS = "-ObjC"; - PRODUCT_NAME = RCTGeolocation; - SKIP_INSTALL = YES; - }; - name = Release; - }; -/* End XCBuildConfiguration section */ - -/* Begin XCConfigurationList section */ - 58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "RCTGeolocation" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 58B511ED1A9E6C8500147676 /* Debug */, - 58B511EE1A9E6C8500147676 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "RCTGeolocation" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 58B511F01A9E6C8500147676 /* Debug */, - 58B511F11A9E6C8500147676 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; -/* End XCConfigurationList section */ - }; - rootObject = 58B511D31A9E6C8500147676 /* Project object */; -} diff --git a/examples/node_modules/react-native/Libraries/GeoLocation/RCTGeolocation.xcodeproj/xcuserdata/yuji.xcuserdatad/xcschemes/xcschememanagement.plist b/examples/node_modules/react-native/Libraries/GeoLocation/RCTGeolocation.xcodeproj/xcuserdata/yuji.xcuserdatad/xcschemes/xcschememanagement.plist deleted file mode 100644 index 1f2a863c..00000000 --- a/examples/node_modules/react-native/Libraries/GeoLocation/RCTGeolocation.xcodeproj/xcuserdata/yuji.xcuserdatad/xcschemes/xcschememanagement.plist +++ /dev/null @@ -1,22 +0,0 @@ - - - - - SchemeUserState - - RCTGeolocation.xcscheme - - orderHint - 3 - - - SuppressBuildableAutocreation - - 58B511DA1A9E6C8500147676 - - primary - - - - - diff --git a/examples/node_modules/react-native/Libraries/GeoLocation/RCTLocationObserver.h b/examples/node_modules/react-native/Libraries/GeoLocation/RCTLocationObserver.h deleted file mode 100644 index 873eeff6..00000000 --- a/examples/node_modules/react-native/Libraries/GeoLocation/RCTLocationObserver.h +++ /dev/null @@ -1,14 +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. - */ - -#import "RCTBridgeModule.h" - -@interface RCTLocationObserver : NSObject - -@end diff --git a/examples/node_modules/react-native/Libraries/GeoLocation/RCTLocationObserver.m b/examples/node_modules/react-native/Libraries/GeoLocation/RCTLocationObserver.m deleted file mode 100644 index 9f9d57aa..00000000 --- a/examples/node_modules/react-native/Libraries/GeoLocation/RCTLocationObserver.m +++ /dev/null @@ -1,333 +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. - */ - -#import "RCTLocationObserver.h" - -#import -#import -#import - -#import "RCTAssert.h" -#import "RCTBridge.h" -#import "RCTConvert.h" -#import "RCTEventDispatcher.h" -#import "RCTLog.h" - -typedef NS_ENUM(NSInteger, RCTPositionErrorCode) { - RCTPositionErrorDenied = 1, - RCTPositionErrorUnavailable, - RCTPositionErrorTimeout, -}; - -#define RCT_DEFAULT_LOCATION_ACCURACY kCLLocationAccuracyHundredMeters - -typedef struct { - double timeout; - double maximumAge; - double accuracy; -} RCTLocationOptions; - -@implementation RCTConvert (RCTLocationOptions) - -+ (RCTLocationOptions)RCTLocationOptions:(id)json -{ - NSDictionary *options = [RCTConvert NSDictionary:json]; - return (RCTLocationOptions){ - .timeout = [RCTConvert NSTimeInterval:options[@"timeout"]] ?: INFINITY, - .maximumAge = [RCTConvert NSTimeInterval:options[@"maximumAge"]] ?: INFINITY, - .accuracy = [RCTConvert BOOL:options[@"enableHighAccuracy"]] ? kCLLocationAccuracyBest : RCT_DEFAULT_LOCATION_ACCURACY - }; -} - -@end - -static NSDictionary *RCTPositionError(RCTPositionErrorCode code, NSString *msg /* nil for default */) -{ - if (!msg) { - switch (code) { - case RCTPositionErrorDenied: - msg = @"User denied access to location services."; - break; - case RCTPositionErrorUnavailable: - msg = @"Unable to retrieve location."; - break; - case RCTPositionErrorTimeout: - msg = @"The location request timed out."; - break; - } - } - - return @{ - @"code": @(code), - @"message": msg, - @"PERMISSION_DENIED": @(RCTPositionErrorDenied), - @"POSITION_UNAVAILABLE": @(RCTPositionErrorUnavailable), - @"TIMEOUT": @(RCTPositionErrorTimeout) - }; -} - -@interface RCTLocationRequest : NSObject - -@property (nonatomic, copy) RCTResponseSenderBlock successBlock; -@property (nonatomic, copy) RCTResponseSenderBlock errorBlock; -@property (nonatomic, assign) RCTLocationOptions options; -@property (nonatomic, strong) NSTimer *timeoutTimer; - -@end - -@implementation RCTLocationRequest - -- (void)dealloc -{ - if (_timeoutTimer.valid) { - [_timeoutTimer invalidate]; - } -} - -@end - -@interface RCTLocationObserver () - -@end - -@implementation RCTLocationObserver -{ - CLLocationManager *_locationManager; - NSDictionary *_lastLocationEvent; - NSMutableArray *_pendingRequests; - BOOL _observingLocation; - RCTLocationOptions _observerOptions; -} - -RCT_EXPORT_MODULE() - -@synthesize bridge = _bridge; - -#pragma mark - Lifecycle - -- (void)dealloc -{ - [_locationManager stopUpdatingLocation]; - _locationManager.delegate = nil; -} - -- (dispatch_queue_t)methodQueue -{ - return dispatch_get_main_queue(); -} - -#pragma mark - Private API - -- (void)beginLocationUpdates -{ - if (!_locationManager) { - _locationManager = [CLLocationManager new]; - _locationManager.distanceFilter = RCT_DEFAULT_LOCATION_ACCURACY; - _locationManager.delegate = self; - _pendingRequests = [NSMutableArray new]; - } - - // Request location access permission - if ([_locationManager respondsToSelector:@selector(requestWhenInUseAuthorization)]) { - [_locationManager requestWhenInUseAuthorization]; - } - - // Start observing location - [_locationManager startUpdatingLocation]; -} - -#pragma mark - Timeout handler - -- (void)timeout:(NSTimer *)timer -{ - RCTLocationRequest *request = timer.userInfo; - NSString *message = [NSString stringWithFormat: @"Unable to fetch location within %zds.", (NSInteger)(timer.timeInterval * 1000.0)]; - request.errorBlock(@[RCTPositionError(RCTPositionErrorTimeout, message)]); - [_pendingRequests removeObject:request]; - - // Stop updating if no pending requests - if (_pendingRequests.count == 0 && !_observingLocation) { - [_locationManager stopUpdatingLocation]; - } -} - -#pragma mark - Public API - -RCT_EXPORT_METHOD(startObserving:(RCTLocationOptions)options) -{ - [self checkLocationConfig]; - - // Select best options - _observerOptions = options; - for (RCTLocationRequest *request in _pendingRequests) { - _observerOptions.accuracy = MIN(_observerOptions.accuracy, request.options.accuracy); - } - - _locationManager.desiredAccuracy = _observerOptions.accuracy; - [self beginLocationUpdates]; - _observingLocation = YES; -} - -RCT_EXPORT_METHOD(stopObserving) -{ - // Stop observing - _observingLocation = NO; - - // Stop updating if no pending requests - if (_pendingRequests.count == 0) { - [_locationManager stopUpdatingLocation]; - } -} - -RCT_EXPORT_METHOD(getCurrentPosition:(RCTLocationOptions)options - withSuccessCallback:(RCTResponseSenderBlock)successBlock - errorCallback:(RCTResponseSenderBlock)errorBlock) -{ - [self checkLocationConfig]; - - if (!successBlock) { - RCTLogError(@"%@.getCurrentPosition called with nil success parameter.", [self class]); - return; - } - - if (![CLLocationManager locationServicesEnabled]) { - if (errorBlock) { - errorBlock(@[ - RCTPositionError(RCTPositionErrorUnavailable, @"Location services disabled.") - ]); - return; - } - } - - if ([CLLocationManager authorizationStatus] == kCLAuthorizationStatusDenied) { - if (errorBlock) { - errorBlock(@[ - RCTPositionError(RCTPositionErrorDenied, nil) - ]); - return; - } - } - - // Check if previous recorded location exists and is good enough - if (_lastLocationEvent && - CFAbsoluteTimeGetCurrent() - [RCTConvert NSTimeInterval:_lastLocationEvent[@"timestamp"]] < options.maximumAge && - [_lastLocationEvent[@"coords"][@"accuracy"] doubleValue] >= options.accuracy) { - - // Call success block with most recent known location - successBlock(@[_lastLocationEvent]); - return; - } - - // Create request - RCTLocationRequest *request = [RCTLocationRequest new]; - request.successBlock = successBlock; - request.errorBlock = errorBlock ?: ^(NSArray *args){}; - request.options = options; - request.timeoutTimer = [NSTimer scheduledTimerWithTimeInterval:options.timeout - target:self - selector:@selector(timeout:) - userInfo:request - repeats:NO]; - [_pendingRequests addObject:request]; - - // Configure location manager and begin updating location - _locationManager.desiredAccuracy = MIN(_locationManager.desiredAccuracy, options.accuracy); - [self beginLocationUpdates]; -} - -#pragma mark - CLLocationManagerDelegate - -- (void)locationManager:(CLLocationManager *)manager - didUpdateLocations:(NSArray *)locations -{ - // Create event - CLLocation *location = locations.lastObject; - _lastLocationEvent = @{ - @"coords": @{ - @"latitude": @(location.coordinate.latitude), - @"longitude": @(location.coordinate.longitude), - @"altitude": @(location.altitude), - @"accuracy": @(location.horizontalAccuracy), - @"altitudeAccuracy": @(location.verticalAccuracy), - @"heading": @(location.course), - @"speed": @(location.speed), - }, - @"timestamp": @(CFAbsoluteTimeGetCurrent() * 1000.0) // in ms - }; - - // Send event - if (_observingLocation) { - [_bridge.eventDispatcher sendDeviceEventWithName:@"geolocationDidChange" - body:_lastLocationEvent]; - } - - // Fire all queued callbacks - for (RCTLocationRequest *request in _pendingRequests) { - request.successBlock(@[_lastLocationEvent]); - [request.timeoutTimer invalidate]; - } - [_pendingRequests removeAllObjects]; - - // Stop updating if not not observing - if (!_observingLocation) { - [_locationManager stopUpdatingLocation]; - } - - // Reset location accuracy if desiredAccuracy is changed. - // Otherwise update accuracy will force triggering didUpdateLocations, watchPosition would keeping receiving location updates, even there's no location changes. - if (ABS(_locationManager.desiredAccuracy - RCT_DEFAULT_LOCATION_ACCURACY) > 0.000001) { - _locationManager.desiredAccuracy = RCT_DEFAULT_LOCATION_ACCURACY; - } -} - -- (void)locationManager:(CLLocationManager *)manager didFailWithError:(NSError *)error -{ - // Check error type - NSDictionary *jsError = nil; - switch (error.code) { - case kCLErrorDenied: - jsError = RCTPositionError(RCTPositionErrorDenied, nil); - break; - case kCLErrorNetwork: - jsError = RCTPositionError(RCTPositionErrorUnavailable, @"Unable to retrieve location due to a network failure"); - break; - case kCLErrorLocationUnknown: - default: - jsError = RCTPositionError(RCTPositionErrorUnavailable, nil); - break; - } - - // Send event - if (_observingLocation) { - [_bridge.eventDispatcher sendDeviceEventWithName:@"geolocationError" - body:jsError]; - } - - // Fire all queued error callbacks - for (RCTLocationRequest *request in _pendingRequests) { - request.errorBlock(@[jsError]); - [request.timeoutTimer invalidate]; - } - [_pendingRequests removeAllObjects]; - - // Reset location accuracy if desiredAccuracy is changed. - // Otherwise update accuracy will force triggering didUpdateLocations, watchPosition would keeping receiving location updates, even there's no location changes. - if (ABS(_locationManager.desiredAccuracy - RCT_DEFAULT_LOCATION_ACCURACY) > 0.000001) { - _locationManager.desiredAccuracy = RCT_DEFAULT_LOCATION_ACCURACY; - } -} - -- (void)checkLocationConfig -{ - if (![[NSBundle mainBundle] objectForInfoDictionaryKey:@"NSLocationWhenInUseUsageDescription"]) { - RCTLogError(@"NSLocationWhenInUseUsageDescription key must be present in Info.plist to use geolocation."); - } -} - -@end diff --git a/examples/node_modules/react-native/Libraries/Image/Image.ios.js b/examples/node_modules/react-native/Libraries/Image/Image.ios.js deleted file mode 100644 index 2b649bf9..00000000 --- a/examples/node_modules/react-native/Libraries/Image/Image.ios.js +++ /dev/null @@ -1,202 +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. - * - * @providesModule Image - * @flow - */ -'use strict'; - -var EdgeInsetsPropType = require('EdgeInsetsPropType'); -var ImageResizeMode = require('ImageResizeMode'); -var ImageStylePropTypes = require('ImageStylePropTypes'); -var NativeMethodsMixin = require('NativeMethodsMixin'); -var NativeModules = require('NativeModules'); -var PropTypes = require('ReactPropTypes'); -var React = require('React'); -var ReactNativeViewAttributes = require('ReactNativeViewAttributes'); -var View = require('View'); -var StyleSheet = require('StyleSheet'); -var StyleSheetPropType = require('StyleSheetPropType'); - -var flattenStyle = require('flattenStyle'); -var invariant = require('invariant'); -var requireNativeComponent = require('requireNativeComponent'); -var resolveAssetSource = require('resolveAssetSource'); -var warning = require('warning'); - -/** - * A React component for displaying different types of images, - * including network images, static resources, temporary local images, and - * images from local disk, such as the camera roll. - * - * Example usage: - * - * ``` - * renderImages: function() { - * return ( - * - * - * - * - * ); - * }, - * ``` - */ -var Image = React.createClass({ - propTypes: { - style: StyleSheetPropType(ImageStylePropTypes), - /** - * `uri` is a string representing the resource identifier for the image, which - * could be an http address, a local file path, or the name of a static image - * resource (which should be wrapped in the `require('image!name')` function). - */ - source: PropTypes.oneOfType([ - PropTypes.shape({ - uri: PropTypes.string, - }), - // Opaque type returned by require('./image.jpg') - PropTypes.number, - ]), - /** - * A static image to display while loading the image source. - * @platform ios - */ - defaultSource: PropTypes.oneOfType([ - PropTypes.shape({ - uri: PropTypes.string, - }), - // Opaque type returned by require('./image.jpg') - PropTypes.number, - ]), - /** - * When true, indicates the image is an accessibility element. - * @platform ios - */ - accessible: PropTypes.bool, - /** - * The text that's read by the screen reader when the user interacts with - * the image. - * @platform ios - */ - accessibilityLabel: PropTypes.string, - /** - * When the image is resized, the corners of the size specified - * by capInsets will stay a fixed size, but the center content and borders - * of the image will be stretched. This is useful for creating resizable - * rounded buttons, shadows, and other resizable assets. More info on - * [Apple documentation](https://developer.apple.com/library/ios/documentation/UIKit/Reference/UIImage_Class/index.html#//apple_ref/occ/instm/UIImage/resizableImageWithCapInsets) - * @platform ios - */ - capInsets: EdgeInsetsPropType, - /** - * Determines how to resize the image when the frame doesn't match the raw - * image dimensions. - */ - resizeMode: PropTypes.oneOf(['cover', 'contain', 'stretch']), - /** - * A unique identifier for this element to be used in UI Automation - * testing scripts. - */ - testID: PropTypes.string, - /** - * Invoked on mount and layout changes with - * `{nativeEvent: {layout: {x, y, width, height}}}`. - */ - onLayout: PropTypes.func, - /** - * Invoked on load start - */ - onLoadStart: PropTypes.func, - /** - * Invoked on download progress with `{nativeEvent: {loaded, total}}` - * @platform ios - */ - onProgress: PropTypes.func, - /** - * Invoked on load error with `{nativeEvent: {error}}` - * @platform ios - */ - onError: PropTypes.func, - /** - * Invoked when load completes successfully - */ - onLoad: PropTypes.func, - /** - * Invoked when load either succeeds or fails - */ - onLoadEnd: PropTypes.func, - }, - - statics: { - resizeMode: ImageResizeMode, - }, - - mixins: [NativeMethodsMixin], - - /** - * `NativeMethodsMixin` will look for this when invoking `setNativeProps`. We - * make `this` look like an actual native component class. - */ - viewConfig: { - uiViewClassName: 'UIView', - validAttributes: ReactNativeViewAttributes.UIView - }, - - contextTypes: { - isInAParentText: React.PropTypes.bool - }, - - render: function() { - var source = resolveAssetSource(this.props.source) || {}; - var {width, height} = source; - var style = flattenStyle([{width, height}, styles.base, this.props.style]) || {}; - - var isNetwork = source.uri && source.uri.match(/^https?:/); - var RawImage = isNetwork ? RCTNetworkImageView : RCTImageView; - var resizeMode = this.props.resizeMode || (style || {}).resizeMode || 'cover'; // Workaround for flow bug t7737108 - var tintColor = (style || {}).tintColor; // Workaround for flow bug t7737108 - - // This is a workaround for #8243665. RCTNetworkImageView does not support tintColor - // TODO: Remove this hack once we have one image implementation #8389274 - if (isNetwork && tintColor) { - RawImage = RCTImageView; - } - - if (this.context.isInAParentText) { - return ; - } else { - return ( - - ); - } - } -}); - -var styles = StyleSheet.create({ - base: { - overflow: 'hidden', - }, -}); - -var RCTImageView = requireNativeComponent('RCTImageView', Image); -var RCTNetworkImageView = NativeModules.NetworkImageViewManager ? requireNativeComponent('RCTNetworkImageView', Image) : RCTImageView; -var RCTVirtualImage = requireNativeComponent('RCTVirtualImage', Image); - -module.exports = Image; diff --git a/examples/node_modules/react-native/Libraries/Image/ImageResizeMode.js b/examples/node_modules/react-native/Libraries/Image/ImageResizeMode.js deleted file mode 100644 index b947b952..00000000 --- a/examples/node_modules/react-native/Libraries/Image/ImageResizeMode.js +++ /dev/null @@ -1,39 +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. - * - * @providesModule ImageResizeMode - * @flow - */ -'use strict'; - -var keyMirror = require('keyMirror'); - -/** - * ImageResizeMode - Enum for different image resizing modes, set via - * `resizeMode` style property on `` components. - */ -var ImageResizeMode = keyMirror({ - /** - * contain - The image will be resized such that it will be completely - * visible, contained within the frame of the View. - */ - contain: null, - /** - * cover - The image will be resized such that the entire area of the view - * is covered by the image, potentially clipping parts of the image. - */ - cover: null, - /** - * stretch - The image will be stretched to fill the entire frame of the - * view without clipping. This may change the aspect ratio of the image, - * distoring it. - */ - stretch: null, -}); - -module.exports = ImageResizeMode; diff --git a/examples/node_modules/react-native/Libraries/Image/ImageSource.js b/examples/node_modules/react-native/Libraries/Image/ImageSource.js deleted file mode 100644 index 66ae67c7..00000000 --- a/examples/node_modules/react-native/Libraries/Image/ImageSource.js +++ /dev/null @@ -1,16 +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. - * - * @providesModule ImageSource - * @flow - */ -'use strict'; - -type ImageSource = { - uri: string; -}; diff --git a/examples/node_modules/react-native/Libraries/Image/ImageStylePropTypes.js b/examples/node_modules/react-native/Libraries/Image/ImageStylePropTypes.js deleted file mode 100644 index c4ccfb57..00000000 --- a/examples/node_modules/react-native/Libraries/Image/ImageStylePropTypes.js +++ /dev/null @@ -1,35 +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. - * - * @providesModule ImageStylePropTypes - * @flow - */ -'use strict'; - -var ImageResizeMode = require('ImageResizeMode'); -var LayoutPropTypes = require('LayoutPropTypes'); -var ReactPropTypes = require('ReactPropTypes'); -var TransformPropTypes = require('TransformPropTypes'); - -var ImageStylePropTypes = { - ...LayoutPropTypes, - ...TransformPropTypes, - resizeMode: ReactPropTypes.oneOf(Object.keys(ImageResizeMode)), - backgroundColor: ReactPropTypes.string, - borderColor: ReactPropTypes.string, - borderWidth: ReactPropTypes.number, - borderRadius: ReactPropTypes.number, - overflow: ReactPropTypes.oneOf(['visible', 'hidden']), - - // iOS-Specific style to "tint" an image. - // It changes the color of all the non-transparent pixels to the tintColor - tintColor: ReactPropTypes.string, - opacity: ReactPropTypes.number, -}; - -module.exports = ImageStylePropTypes; diff --git a/examples/node_modules/react-native/Libraries/Image/RCTImage.xcodeproj/project.pbxproj b/examples/node_modules/react-native/Libraries/Image/RCTImage.xcodeproj/project.pbxproj deleted file mode 100644 index 0c404f31..00000000 --- a/examples/node_modules/react-native/Libraries/Image/RCTImage.xcodeproj/project.pbxproj +++ /dev/null @@ -1,330 +0,0 @@ -// !$*UTF8*$! -{ - archiveVersion = 1; - classes = { - }; - objectVersion = 46; - objects = { - -/* Begin PBXBuildFile section */ - 1304D5AB1AA8C4A30002E2BE /* RCTImageView.m in Sources */ = {isa = PBXBuildFile; fileRef = 1304D5A81AA8C4A30002E2BE /* RCTImageView.m */; }; - 1304D5AC1AA8C4A30002E2BE /* RCTImageViewManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 1304D5AA1AA8C4A30002E2BE /* RCTImageViewManager.m */; }; - 1304D5B21AA8C50D0002E2BE /* RCTGIFImageDecoder.m in Sources */ = {isa = PBXBuildFile; fileRef = 1304D5B11AA8C50D0002E2BE /* RCTGIFImageDecoder.m */; }; - 134B00A21B54232B00EC8DFB /* RCTImageUtils.m in Sources */ = {isa = PBXBuildFile; fileRef = 134B00A11B54232B00EC8DFB /* RCTImageUtils.m */; }; - 13EF7F0B1BC42D4E003F47DD /* RCTShadowVirtualImage.m in Sources */ = {isa = PBXBuildFile; fileRef = 13EF7F081BC42D4E003F47DD /* RCTShadowVirtualImage.m */; settings = {ASSET_TAGS = (); }; }; - 13EF7F0C1BC42D4E003F47DD /* RCTVirtualImageManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 13EF7F0A1BC42D4E003F47DD /* RCTVirtualImageManager.m */; settings = {ASSET_TAGS = (); }; }; - 13EF7F7F1BC825B1003F47DD /* RCTXCAssetImageLoader.m in Sources */ = {isa = PBXBuildFile; fileRef = 13EF7F7E1BC825B1003F47DD /* RCTXCAssetImageLoader.m */; settings = {ASSET_TAGS = (); }; }; - 143879381AAD32A300F088A5 /* RCTImageLoader.m in Sources */ = {isa = PBXBuildFile; fileRef = 143879371AAD32A300F088A5 /* RCTImageLoader.m */; }; - 35123E6B1B59C99D00EBAD80 /* RCTImageStoreManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 35123E6A1B59C99D00EBAD80 /* RCTImageStoreManager.m */; }; - 354631681B69857700AA0B86 /* RCTImageEditingManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 354631671B69857700AA0B86 /* RCTImageEditingManager.m */; }; -/* End PBXBuildFile section */ - -/* Begin PBXCopyFilesBuildPhase section */ - 58B5115B1A9E6B3D00147676 /* CopyFiles */ = { - isa = PBXCopyFilesBuildPhase; - buildActionMask = 2147483647; - dstPath = "include/$(PRODUCT_NAME)"; - dstSubfolderSpec = 16; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXCopyFilesBuildPhase section */ - -/* Begin PBXFileReference section */ - 1304D5A71AA8C4A30002E2BE /* RCTImageView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTImageView.h; sourceTree = ""; }; - 1304D5A81AA8C4A30002E2BE /* RCTImageView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTImageView.m; sourceTree = ""; }; - 1304D5A91AA8C4A30002E2BE /* RCTImageViewManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTImageViewManager.h; sourceTree = ""; }; - 1304D5AA1AA8C4A30002E2BE /* RCTImageViewManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTImageViewManager.m; sourceTree = ""; }; - 1304D5B01AA8C50D0002E2BE /* RCTGIFImageDecoder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTGIFImageDecoder.h; sourceTree = ""; }; - 1304D5B11AA8C50D0002E2BE /* RCTGIFImageDecoder.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTGIFImageDecoder.m; sourceTree = ""; }; - 134B00A01B54232B00EC8DFB /* RCTImageUtils.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTImageUtils.h; sourceTree = ""; }; - 134B00A11B54232B00EC8DFB /* RCTImageUtils.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTImageUtils.m; sourceTree = ""; }; - 13EF7F071BC42D4E003F47DD /* RCTShadowVirtualImage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTShadowVirtualImage.h; sourceTree = ""; }; - 13EF7F081BC42D4E003F47DD /* RCTShadowVirtualImage.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTShadowVirtualImage.m; sourceTree = ""; }; - 13EF7F091BC42D4E003F47DD /* RCTVirtualImageManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTVirtualImageManager.h; sourceTree = ""; }; - 13EF7F0A1BC42D4E003F47DD /* RCTVirtualImageManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTVirtualImageManager.m; sourceTree = ""; }; - 13EF7F7D1BC825B1003F47DD /* RCTXCAssetImageLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTXCAssetImageLoader.h; sourceTree = ""; }; - 13EF7F7E1BC825B1003F47DD /* RCTXCAssetImageLoader.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTXCAssetImageLoader.m; sourceTree = ""; }; - 143879361AAD32A300F088A5 /* RCTImageLoader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTImageLoader.h; sourceTree = ""; }; - 143879371AAD32A300F088A5 /* RCTImageLoader.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTImageLoader.m; sourceTree = ""; }; - 35123E691B59C99D00EBAD80 /* RCTImageStoreManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTImageStoreManager.h; sourceTree = ""; }; - 35123E6A1B59C99D00EBAD80 /* RCTImageStoreManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTImageStoreManager.m; sourceTree = ""; }; - 354631661B69857700AA0B86 /* RCTImageEditingManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTImageEditingManager.h; sourceTree = ""; }; - 354631671B69857700AA0B86 /* RCTImageEditingManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTImageEditingManager.m; sourceTree = ""; }; - 58B5115D1A9E6B3D00147676 /* libRCTImage.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRCTImage.a; sourceTree = BUILT_PRODUCTS_DIR; }; -/* End PBXFileReference section */ - -/* Begin PBXFrameworksBuildPhase section */ - 58B5115A1A9E6B3D00147676 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXFrameworksBuildPhase section */ - -/* Begin PBXGroup section */ - 58B511541A9E6B3D00147676 = { - isa = PBXGroup; - children = ( - 13EF7F7D1BC825B1003F47DD /* RCTXCAssetImageLoader.h */, - 13EF7F7E1BC825B1003F47DD /* RCTXCAssetImageLoader.m */, - 1304D5B01AA8C50D0002E2BE /* RCTGIFImageDecoder.h */, - 1304D5B11AA8C50D0002E2BE /* RCTGIFImageDecoder.m */, - 354631661B69857700AA0B86 /* RCTImageEditingManager.h */, - 354631671B69857700AA0B86 /* RCTImageEditingManager.m */, - 143879361AAD32A300F088A5 /* RCTImageLoader.h */, - 143879371AAD32A300F088A5 /* RCTImageLoader.m */, - 1304D5A71AA8C4A30002E2BE /* RCTImageView.h */, - 1304D5A81AA8C4A30002E2BE /* RCTImageView.m */, - 1304D5A91AA8C4A30002E2BE /* RCTImageViewManager.h */, - 1304D5AA1AA8C4A30002E2BE /* RCTImageViewManager.m */, - 35123E691B59C99D00EBAD80 /* RCTImageStoreManager.h */, - 35123E6A1B59C99D00EBAD80 /* RCTImageStoreManager.m */, - 134B00A01B54232B00EC8DFB /* RCTImageUtils.h */, - 134B00A11B54232B00EC8DFB /* RCTImageUtils.m */, - 13EF7F071BC42D4E003F47DD /* RCTShadowVirtualImage.h */, - 13EF7F081BC42D4E003F47DD /* RCTShadowVirtualImage.m */, - 13EF7F091BC42D4E003F47DD /* RCTVirtualImageManager.h */, - 13EF7F0A1BC42D4E003F47DD /* RCTVirtualImageManager.m */, - 58B5115E1A9E6B3D00147676 /* Products */, - ); - indentWidth = 2; - sourceTree = ""; - tabWidth = 2; - }; - 58B5115E1A9E6B3D00147676 /* Products */ = { - isa = PBXGroup; - children = ( - 58B5115D1A9E6B3D00147676 /* libRCTImage.a */, - ); - name = Products; - sourceTree = ""; - }; -/* End PBXGroup section */ - -/* Begin PBXNativeTarget section */ - 58B5115C1A9E6B3D00147676 /* RCTImage */ = { - isa = PBXNativeTarget; - buildConfigurationList = 58B511711A9E6B3D00147676 /* Build configuration list for PBXNativeTarget "RCTImage" */; - buildPhases = ( - 58B511591A9E6B3D00147676 /* Sources */, - 58B5115A1A9E6B3D00147676 /* Frameworks */, - 58B5115B1A9E6B3D00147676 /* CopyFiles */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = RCTImage; - productName = RCTNetworkImage; - productReference = 58B5115D1A9E6B3D00147676 /* libRCTImage.a */; - productType = "com.apple.product-type.library.static"; - }; -/* End PBXNativeTarget section */ - -/* Begin PBXProject section */ - 58B511551A9E6B3D00147676 /* Project object */ = { - isa = PBXProject; - attributes = { - LastUpgradeCheck = 0610; - ORGANIZATIONNAME = Facebook; - TargetAttributes = { - 58B5115C1A9E6B3D00147676 = { - CreatedOnToolsVersion = 6.1.1; - }; - }; - }; - buildConfigurationList = 58B511581A9E6B3D00147676 /* Build configuration list for PBXProject "RCTImage" */; - compatibilityVersion = "Xcode 3.2"; - developmentRegion = English; - hasScannedForEncodings = 0; - knownRegions = ( - en, - ); - mainGroup = 58B511541A9E6B3D00147676; - productRefGroup = 58B5115E1A9E6B3D00147676 /* Products */; - projectDirPath = ""; - projectRoot = ""; - targets = ( - 58B5115C1A9E6B3D00147676 /* RCTImage */, - ); - }; -/* End PBXProject section */ - -/* Begin PBXSourcesBuildPhase section */ - 58B511591A9E6B3D00147676 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 13EF7F0C1BC42D4E003F47DD /* RCTVirtualImageManager.m in Sources */, - 35123E6B1B59C99D00EBAD80 /* RCTImageStoreManager.m in Sources */, - 1304D5AC1AA8C4A30002E2BE /* RCTImageViewManager.m in Sources */, - 1304D5B21AA8C50D0002E2BE /* RCTGIFImageDecoder.m in Sources */, - 143879381AAD32A300F088A5 /* RCTImageLoader.m in Sources */, - 354631681B69857700AA0B86 /* RCTImageEditingManager.m in Sources */, - 1304D5AB1AA8C4A30002E2BE /* RCTImageView.m in Sources */, - 13EF7F0B1BC42D4E003F47DD /* RCTShadowVirtualImage.m in Sources */, - 13EF7F7F1BC825B1003F47DD /* RCTXCAssetImageLoader.m in Sources */, - 134B00A21B54232B00EC8DFB /* RCTImageUtils.m in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXSourcesBuildPhase section */ - -/* Begin XCBuildConfiguration section */ - 58B5116F1A9E6B3D00147676 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - COPY_PHASE_STRIP = NO; - ENABLE_STRICT_OBJC_MSGSEND = YES; - GCC_C_LANGUAGE_STANDARD = gnu99; - GCC_DYNAMIC_NO_PIC = NO; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", - "$(inherited)", - ); - GCC_SYMBOLS_PRIVATE_EXTERN = NO; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES; - GCC_WARN_SHADOW = YES; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 7.0; - MTL_ENABLE_DEBUG_INFO = YES; - ONLY_ACTIVE_ARCH = YES; - SDKROOT = iphoneos; - WARNING_CFLAGS = ( - "-Werror", - "-Wall", - ); - }; - name = Debug; - }; - 58B511701A9E6B3D00147676 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - COPY_PHASE_STRIP = YES; - ENABLE_NS_ASSERTIONS = NO; - ENABLE_STRICT_OBJC_MSGSEND = YES; - GCC_C_LANGUAGE_STANDARD = gnu99; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES; - GCC_WARN_SHADOW = YES; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 7.0; - MTL_ENABLE_DEBUG_INFO = NO; - SDKROOT = iphoneos; - VALIDATE_PRODUCT = YES; - WARNING_CFLAGS = ( - "-Werror", - "-Wall", - ); - }; - name = Release; - }; - 58B511721A9E6B3D00147676 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - CLANG_STATIC_ANALYZER_MODE = deep; - HEADER_SEARCH_PATHS = ( - "$(inherited)", - /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, - "$(SRCROOT)/../../React/**", - "$(SRCROOT)/../Network/**", - ); - LIBRARY_SEARCH_PATHS = ( - "$(inherited)", - "$(USER_LIBRARY_DIR)/Developer/Xcode/DerivedData/UIExplorer-gjaibsjtheitasdxdtcvxxqavkvy/Build/Products/Debug-iphoneos", - ); - OTHER_LDFLAGS = "-ObjC"; - PRODUCT_NAME = RCTImage; - RUN_CLANG_STATIC_ANALYZER = YES; - SKIP_INSTALL = YES; - }; - name = Debug; - }; - 58B511731A9E6B3D00147676 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - CLANG_STATIC_ANALYZER_MODE = deep; - HEADER_SEARCH_PATHS = ( - "$(inherited)", - /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, - "$(SRCROOT)/../../React/**", - "$(SRCROOT)/../Network/**", - ); - LIBRARY_SEARCH_PATHS = ( - "$(inherited)", - "$(USER_LIBRARY_DIR)/Developer/Xcode/DerivedData/UIExplorer-gjaibsjtheitasdxdtcvxxqavkvy/Build/Products/Debug-iphoneos", - ); - OTHER_LDFLAGS = "-ObjC"; - PRODUCT_NAME = RCTImage; - RUN_CLANG_STATIC_ANALYZER = NO; - SKIP_INSTALL = YES; - }; - name = Release; - }; -/* End XCBuildConfiguration section */ - -/* Begin XCConfigurationList section */ - 58B511581A9E6B3D00147676 /* Build configuration list for PBXProject "RCTImage" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 58B5116F1A9E6B3D00147676 /* Debug */, - 58B511701A9E6B3D00147676 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 58B511711A9E6B3D00147676 /* Build configuration list for PBXNativeTarget "RCTImage" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 58B511721A9E6B3D00147676 /* Debug */, - 58B511731A9E6B3D00147676 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; -/* End XCConfigurationList section */ - }; - rootObject = 58B511551A9E6B3D00147676 /* Project object */; -} diff --git a/examples/node_modules/react-native/Libraries/Image/RCTImage.xcodeproj/xcuserdata/yuji.xcuserdatad/xcschemes/xcschememanagement.plist b/examples/node_modules/react-native/Libraries/Image/RCTImage.xcodeproj/xcuserdata/yuji.xcuserdatad/xcschemes/xcschememanagement.plist deleted file mode 100644 index f2cf9908..00000000 --- a/examples/node_modules/react-native/Libraries/Image/RCTImage.xcodeproj/xcuserdata/yuji.xcuserdatad/xcschemes/xcschememanagement.plist +++ /dev/null @@ -1,22 +0,0 @@ - - - - - SchemeUserState - - RCTImage.xcscheme - - orderHint - 4 - - - SuppressBuildableAutocreation - - 58B5115C1A9E6B3D00147676 - - primary - - - - - diff --git a/examples/node_modules/react-native/Libraries/Image/RCTImageLoader.h b/examples/node_modules/react-native/Libraries/Image/RCTImageLoader.h deleted file mode 100644 index 77074745..00000000 --- a/examples/node_modules/react-native/Libraries/Image/RCTImageLoader.h +++ /dev/null @@ -1,144 +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. - */ - -#import - -#import "RCTBridge.h" -#import "RCTURLRequestHandler.h" - -@class ALAssetsLibrary; - -typedef void (^RCTImageLoaderProgressBlock)(int64_t progress, int64_t total); -typedef void (^RCTImageLoaderCompletionBlock)(NSError *error, UIImage *image); -typedef void (^RCTImageLoaderCancellationBlock)(void); - -@interface UIImage (React) - -@property (nonatomic, copy) CAKeyframeAnimation *reactKeyframeAnimation; - -@end - -@interface RCTImageLoader : NSObject - -/** - * Loads the specified image at the highest available resolution. - * Can be called from any thread, will call back on an unspecified thread. - */ -- (RCTImageLoaderCancellationBlock)loadImageWithTag:(NSString *)imageTag - callback:(RCTImageLoaderCompletionBlock)callback; - -/** - * As above, but includes target size, scale and resizeMode, which are used to - * select the optimal dimensions for the loaded image. - */ -- (RCTImageLoaderCancellationBlock)loadImageWithTag:(NSString *)imageTag - size:(CGSize)size - scale:(CGFloat)scale - resizeMode:(UIViewContentMode)resizeMode - progressBlock:(RCTImageLoaderProgressBlock)progressBlock - completionBlock:(RCTImageLoaderCompletionBlock)completionBlock; - -/** - * Finds an appropriate image decoder and passes the target size, scale and - * resizeMode for optimal image decoding. Can be called from any thread, - * will call callback on an unspecified thread. - */ -- (RCTImageLoaderCancellationBlock)decodeImageData:(NSData *)imageData - size:(CGSize)size - scale:(CGFloat)scale - resizeMode:(UIViewContentMode)resizeMode - completionBlock:(RCTImageLoaderCompletionBlock)completionBlock; - -@end - -@interface RCTBridge (RCTImageLoader) - -/** - * The shared image loader instance - */ -@property (nonatomic, readonly) RCTImageLoader *imageLoader; - -@end - -/** - * Provides the interface needed to register an image loader. Image data - * loaders are also bridge modules, so should be registered using - * RCT_EXPORT_MODULE(). - */ -@protocol RCTImageURLLoader - -/** - * Indicates whether this data loader is capable of processing the specified - * request URL. Typically the handler would examine the scheme/protocol of the - * URL to determine this. - */ -- (BOOL)canLoadImageURL:(NSURL *)requestURL; - -/** - * Send a network request to load the request URL. The method should call the - * progressHandler (if applicable) and the completionHandler when the request - * has finished. The method should also return a cancellation block, if - * applicable. - */ -- (RCTImageLoaderCancellationBlock)loadImageForURL:(NSURL *)imageURL - size:(CGSize)size - scale:(CGFloat)scale - resizeMode:(UIViewContentMode)resizeMode - progressHandler:(RCTImageLoaderProgressBlock)progressHandler - completionHandler:(RCTImageLoaderCompletionBlock)completionHandler; - -@optional - -/** - * If more than one RCTImageURLLoader responds YES to `-canLoadImageURL:` - * then `loaderPriority` is used to determine which one to use. The loader - * with the highest priority will be selected. Default priority is zero. If - * two or more valid loaders have the same priority, the selection order is - * undefined. - */ -- (float)loaderPriority; - -@end - -/** - * Provides the interface needed to register an image decoder. Image decoders - * are also bridge modules, so should be registered using RCT_EXPORT_MODULE(). - */ -@protocol RCTImageDataDecoder - -/** - * Indicates whether this handler is capable of decoding the specified data. - * Typically the handler would examine some sort of header data to determine - * this. - */ -- (BOOL)canDecodeImageData:(NSData *)imageData; - -/** - * Decode an image from the data object. The method should call the - * completionHandler when the decoding operation has finished. The method - * should also return a cancellation block, if applicable. - */ -- (RCTImageLoaderCancellationBlock)decodeImageData:(NSData *)imageData - size:(CGSize)size - scale:(CGFloat)scale - resizeMode:(UIViewContentMode)resizeMode - completionHandler:(RCTImageLoaderCompletionBlock)completionHandler; - -@optional - -/** - * If more than one RCTImageDataDecoder responds YES to `-canDecodeImageData:` - * then `decoderPriority` is used to determine which one to use. The decoder - * with the highest priority will be selected. Default priority is zero. - * If two or more valid decoders have the same priority, the selection order is - * undefined. - */ -- (float)decoderPriority; - -@end diff --git a/examples/node_modules/react-native/Libraries/Image/RCTImageLoader.m b/examples/node_modules/react-native/Libraries/Image/RCTImageLoader.m deleted file mode 100644 index acee9dbe..00000000 --- a/examples/node_modules/react-native/Libraries/Image/RCTImageLoader.m +++ /dev/null @@ -1,452 +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. - */ - -#import "RCTImageLoader.h" - -#import -#import - -#import "RCTConvert.h" -#import "RCTDefines.h" -#import "RCTImageUtils.h" -#import "RCTLog.h" -#import "RCTNetworking.h" -#import "RCTUtils.h" - -@implementation UIImage (React) - -- (CAKeyframeAnimation *)reactKeyframeAnimation -{ - return objc_getAssociatedObject(self, _cmd); -} - -- (void)setReactKeyframeAnimation:(CAKeyframeAnimation *)reactKeyframeAnimation -{ - objc_setAssociatedObject(self, @selector(reactKeyframeAnimation), reactKeyframeAnimation, OBJC_ASSOCIATION_COPY_NONATOMIC); -} - -@end - -@implementation RCTImageLoader -{ - NSArray> *_loaders; - NSArray> *_decoders; - dispatch_queue_t _URLCacheQueue; - NSURLCache *_URLCache; -} - -@synthesize bridge = _bridge; - -RCT_EXPORT_MODULE() - -- (void)setUp -{ - // Get image loaders and decoders - NSMutableArray> *loaders = [NSMutableArray array]; - NSMutableArray> *decoders = [NSMutableArray array]; - for (Class moduleClass in _bridge.moduleClasses) { - if ([moduleClass conformsToProtocol:@protocol(RCTImageURLLoader)]) { - [loaders addObject:[_bridge moduleForClass:moduleClass]]; - } - if ([moduleClass conformsToProtocol:@protocol(RCTImageDataDecoder)]) { - [decoders addObject:[_bridge moduleForClass:moduleClass]]; - } - } - - // Sort loaders in reverse priority order (highest priority first) - [loaders sortUsingComparator:^NSComparisonResult(id a, id b) { - float priorityA = [a respondsToSelector:@selector(loaderPriority)] ? [a loaderPriority] : 0; - float priorityB = [b respondsToSelector:@selector(loaderPriority)] ? [b loaderPriority] : 0; - if (priorityA > priorityB) { - return NSOrderedAscending; - } else if (priorityA < priorityB) { - return NSOrderedDescending; - } else { - return NSOrderedSame; - } - }]; - - // Sort decoders in reverse priority order (highest priority first) - [decoders sortUsingComparator:^NSComparisonResult(id a, id b) { - float priorityA = [a respondsToSelector:@selector(decoderPriority)] ? [a decoderPriority] : 0; - float priorityB = [b respondsToSelector:@selector(decoderPriority)] ? [b decoderPriority] : 0; - if (priorityA > priorityB) { - return NSOrderedAscending; - } else if (priorityA < priorityB) { - return NSOrderedDescending; - } else { - return NSOrderedSame; - } - }]; - - _loaders = loaders; - _decoders = decoders; -} - -- (id)imageURLLoaderForURL:(NSURL *)URL -{ - if (!_loaders) { - [self setUp]; - } - - if (RCT_DEBUG) { - // Check for handler conflicts - float previousPriority = 0; - id previousLoader = nil; - for (id loader in _loaders) { - float priority = [loader respondsToSelector:@selector(loaderPriority)] ? [loader loaderPriority] : 0; - if (previousLoader && priority < previousPriority) { - return previousLoader; - } - if ([loader canLoadImageURL:URL]) { - if (previousLoader) { - if (priority == previousPriority) { - RCTLogError(@"The RCTImageURLLoaders %@ and %@ both reported that" - " they can load the URL %@, and have equal priority" - " (%g). This could result in non-deterministic behavior.", - loader, previousLoader, URL, priority); - } - } else { - previousLoader = loader; - previousPriority = priority; - } - } - } - return previousLoader; - } - - // Normal code path - for (id loader in _loaders) { - if ([loader canLoadImageURL:URL]) { - return loader; - } - } - return nil; -} - -- (id)imageDataDecoderForData:(NSData *)data -{ - if (!_decoders) { - [self setUp]; - } - - if (RCT_DEBUG) { - // Check for handler conflicts - float previousPriority = 0; - id previousDecoder = nil; - for (id decoder in _decoders) { - float priority = [decoder respondsToSelector:@selector(decoderPriority)] ? [decoder decoderPriority] : 0; - if (previousDecoder && priority < previousPriority) { - return previousDecoder; - } - if ([decoder canDecodeImageData:data]) { - if (previousDecoder) { - if (priority == previousPriority) { - RCTLogError(@"The RCTImageDataDecoders %@ and %@ both reported that" - " they can decode the data , and" - " have equal priority (%g). This could result in" - " non-deterministic behavior.", - decoder, previousDecoder, data, data.length, priority); - } - } else { - previousDecoder = decoder; - previousPriority = priority; - } - } - } - return previousDecoder; - } - - // Normal code path - for (id decoder in _decoders) { - if ([decoder canDecodeImageData:data]) { - return decoder; - } - } - return nil; -} - -- (RCTImageLoaderCancellationBlock)loadImageWithTag:(NSString *)imageTag - callback:(RCTImageLoaderCompletionBlock)callback -{ - return [self loadImageWithTag:imageTag - size:CGSizeZero - scale:1 - resizeMode:UIViewContentModeScaleToFill - progressBlock:nil - completionBlock:callback]; -} - -- (RCTImageLoaderCancellationBlock)loadImageWithTag:(NSString *)imageTag - size:(CGSize)size - scale:(CGFloat)scale - resizeMode:(UIViewContentMode)resizeMode - progressBlock:(RCTImageLoaderProgressBlock)progressHandler - completionBlock:(RCTImageLoaderCompletionBlock)completionBlock -{ - __block volatile uint32_t cancelled = 0; - __block void(^cancelLoad)(void) = nil; - __weak RCTImageLoader *weakSelf = self; - - RCTImageLoaderCompletionBlock completionHandler = ^(NSError *error, UIImage *image) { - if ([NSThread isMainThread]) { - - // Most loaders do not return on the main thread, so caller is probably not - // expecting it, and may do expensive post-processing in the callback - dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ - if (!cancelled) { - completionBlock(error, image); - } - }); - } else if (!cancelled) { - completionBlock(error, image); - } - }; - - if (imageTag.length == 0) { - completionHandler(RCTErrorWithMessage(@"source.uri should not be an empty string"), nil); - return ^{}; - } - - // All access to URL cache must be serialized - if (!_URLCacheQueue) { - _URLCacheQueue = dispatch_queue_create("com.facebook.react.ImageLoaderURLCacheQueue", DISPATCH_QUEUE_SERIAL); - } - dispatch_async(_URLCacheQueue, ^{ - - if (!_URLCache) { - _URLCache = [[NSURLCache alloc] initWithMemoryCapacity:5 * 1024 * 1024 // 5MB - diskCapacity:200 * 1024 * 1024 // 200MB - diskPath:@"React/RCTImageDownloader"]; - } - - RCTImageLoader *strongSelf = weakSelf; - if (cancelled || !strongSelf) { - return; - } - - // Find suitable image URL loader - NSURLRequest *request = [RCTConvert NSURLRequest:imageTag]; - id loadHandler = [strongSelf imageURLLoaderForURL:request.URL]; - if (loadHandler) { - cancelLoad = [loadHandler loadImageForURL:request.URL - size:size - scale:scale - resizeMode:resizeMode - progressHandler:progressHandler - completionHandler:completionHandler] ?: ^{}; - return; - } - - // Check if networking module is available - if (RCT_DEBUG && ![_bridge respondsToSelector:@selector(networking)]) { - RCTLogError(@"No suitable image URL loader found for %@. You may need to " - " import the RCTNetworking library in order to load images.", - imageTag); - return; - } - - // Check if networking module can load image - if (RCT_DEBUG && ![_bridge.networking canHandleRequest:request]) { - RCTLogError(@"No suitable image URL loader found for %@", imageTag); - return; - } - - // Use networking module to load image - __block RCTImageLoaderCancellationBlock cancelDecode = nil; - RCTURLRequestCompletionBlock processResponse = - ^(NSURLResponse *response, NSData *data, NSError *error) { - - // Check for system errors - if (error) { - completionHandler(error, nil); - return; - } else if (!data) { - completionHandler(RCTErrorWithMessage(@"Unknown image download error"), nil); - return; - } - - // Check for http errors - if ([response isKindOfClass:[NSHTTPURLResponse class]]) { - NSInteger statusCode = ((NSHTTPURLResponse *)response).statusCode; - if (statusCode != 200) { - completionHandler([[NSError alloc] initWithDomain:NSURLErrorDomain - code:statusCode - userInfo:nil], nil); - return; - } - } - - // Decode image - cancelDecode = [strongSelf decodeImageData:data - size:size - scale:scale - resizeMode:resizeMode - completionBlock:completionHandler]; - }; - - // Add missing png extension - if (request.URL.fileURL && request.URL.pathExtension.length == 0) { - NSMutableURLRequest *mutableRequest = [request mutableCopy]; - mutableRequest.URL = [NSURL fileURLWithPath:[request.URL.path stringByAppendingPathExtension:@"png"]]; - request = mutableRequest; - } - - // Check for cached response before reloading - // TODO: move URL cache out of RCTImageLoader into its own module - NSCachedURLResponse *cachedResponse = [_URLCache cachedResponseForRequest:request]; - if (cachedResponse) { - processResponse(cachedResponse.response, cachedResponse.data, nil); - return; - } - - // Download image - RCTNetworkTask *task = [_bridge.networking networkTaskWithRequest:request completionBlock: - ^(NSURLResponse *response, NSData *data, NSError *error) { - if (error) { - completionHandler(error, nil); - return; - } - - dispatch_async(_URLCacheQueue, ^{ - - // Cache the response - // TODO: move URL cache out of RCTImageLoader into its own module - BOOL isHTTPRequest = [request.URL.scheme hasPrefix:@"http"]; - [strongSelf->_URLCache storeCachedResponse: - [[NSCachedURLResponse alloc] initWithResponse:response - data:data - userInfo:nil - storagePolicy:isHTTPRequest ? NSURLCacheStorageAllowed: NSURLCacheStorageAllowedInMemoryOnly] - forRequest:request]; - - // Process image data - processResponse(response, data, nil); - - }); - - }]; - task.downloadProgressBlock = progressHandler; - [task start]; - - cancelLoad = ^{ - [task cancel]; - if (cancelDecode) { - cancelDecode(); - } - }; - - }); - - return ^{ - if (cancelLoad) { - cancelLoad(); - } - OSAtomicOr32Barrier(1, &cancelled); - }; -} - -- (RCTImageLoaderCancellationBlock)decodeImageData:(NSData *)data - size:(CGSize)size - scale:(CGFloat)scale - resizeMode:(UIViewContentMode)resizeMode - completionBlock:(RCTImageLoaderCompletionBlock)completionHandler -{ - if (data.length == 0) { - completionHandler(RCTErrorWithMessage(@"No image data"), nil); - return ^{}; - } - - id imageDecoder = [self imageDataDecoderForData:data]; - if (imageDecoder) { - - return [imageDecoder decodeImageData:data - size:size - scale:scale - resizeMode:resizeMode - completionHandler:completionHandler]; - } else { - - __block volatile uint32_t cancelled = 0; - dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ - if (cancelled) { - return; - } - UIImage *image = RCTDecodeImageWithData(data, size, scale, resizeMode); - if (image) { - completionHandler(nil, image); - } else { - NSString *errorMessage = [NSString stringWithFormat:@"Error decoding image data ", data, data.length]; - NSError *finalError = RCTErrorWithMessage(errorMessage); - completionHandler(finalError, nil); - } - }); - - return ^{ - OSAtomicOr32Barrier(1, &cancelled); - }; - } -} - -#pragma mark - RCTURLRequestHandler - -- (BOOL)canHandleRequest:(NSURLRequest *)request -{ - return [self imageURLLoaderForURL:request.URL] != nil; -} - -- (id)sendRequest:(NSURLRequest *)request withDelegate:(id)delegate -{ - __block RCTImageLoaderCancellationBlock requestToken; - requestToken = [self loadImageWithTag:request.URL.absoluteString callback:^(NSError *error, UIImage *image) { - if (error) { - [delegate URLRequest:requestToken didCompleteWithError:error]; - return; - } - - NSString *mimeType = nil; - NSData *imageData = nil; - if (RCTImageHasAlpha(image.CGImage)) { - mimeType = @"image/png"; - imageData = UIImagePNGRepresentation(image); - } else { - mimeType = @"image/jpeg"; - imageData = UIImageJPEGRepresentation(image, 1.0); - } - - NSURLResponse *response = [[NSURLResponse alloc] initWithURL:request.URL - MIMEType:mimeType - expectedContentLength:imageData.length - textEncodingName:nil]; - - [delegate URLRequest:requestToken didReceiveResponse:response]; - [delegate URLRequest:requestToken didReceiveData:imageData]; - [delegate URLRequest:requestToken didCompleteWithError:nil]; - }]; - - return requestToken; -} - -- (void)cancelRequest:(id)requestToken -{ - if (requestToken) { - ((RCTImageLoaderCancellationBlock)requestToken)(); - } -} - -@end - -@implementation RCTBridge (RCTImageLoader) - -- (RCTImageLoader *)imageLoader -{ - return [self moduleForClass:[RCTImageLoader class]]; -} - -@end diff --git a/examples/node_modules/react-native/Libraries/Image/__tests__/resolveAssetSource-test.js b/examples/node_modules/react-native/Libraries/Image/__tests__/resolveAssetSource-test.js deleted file mode 100644 index 81fdb2b0..00000000 --- a/examples/node_modules/react-native/Libraries/Image/__tests__/resolveAssetSource-test.js +++ /dev/null @@ -1,174 +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. - */ -'use strict'; - -jest - .dontMock('AssetRegistry') - .dontMock('../resolveAssetSource'); - -var AssetRegistry = require('AssetRegistry'); -var Platform = require('Platform'); -var NativeModules = require('NativeModules'); -var resolveAssetSource = require('../resolveAssetSource'); - -function expectResolvesAsset(input, expectedSource) { - var assetId = AssetRegistry.registerAsset(input); - expect(resolveAssetSource(assetId)).toEqual(expectedSource); -} - -describe('resolveAssetSource', () => { - beforeEach(() => { - jest.resetModuleRegistry(); - }); - - it('returns same source for simple static and network images', () => { - var source1 = {uri: 'https://www.facebook.com/logo'}; - expect(resolveAssetSource(source1)).toBe(source1); - - var source2 = {uri: 'logo'}; - expect(resolveAssetSource(source2)).toBe(source2); - }); - - it('does not change deprecated assets', () => { - expect(resolveAssetSource({ - deprecated: true, - width: 100, - height: 200, - uri: 'logo', - })).toEqual({ - deprecated: true, - width: 100, - height: 200, - uri: 'logo', - }); - }); - - it('ignores any weird data', () => { - expect(resolveAssetSource(null)).toBe(null); - expect(resolveAssetSource(42)).toBe(null); - expect(resolveAssetSource('nonsense')).toBe(null); - }); - - describe('bundle was loaded from network (DEV)', () => { - beforeEach(() => { - NativeModules.SourceCode.scriptURL = - 'http://10.0.0.1:8081/main.bundle'; - Platform.OS = 'ios'; - }); - - it('uses network image', () => { - expectResolvesAsset({ - __packager_asset: true, - fileSystemLocation: '/root/app/module/a', - httpServerLocation: '/assets/module/a', - width: 100, - height: 200, - scales: [1], - hash: '5b6f00f', - name: 'logo', - type: 'png', - }, { - __packager_asset: true, - width: 100, - height: 200, - uri: 'http://10.0.0.1:8081/assets/module/a/logo.png?platform=ios&hash=5b6f00f', - scale: 1, - }); - }); - - it('picks matching scale', () => { - expectResolvesAsset({ - __packager_asset: true, - fileSystemLocation: '/root/app/module/a', - httpServerLocation: '/assets/module/a', - width: 100, - height: 200, - scales: [1, 2, 3], - hash: '5b6f00f', - name: 'logo', - type: 'png', - }, { - __packager_asset: true, - width: 100, - height: 200, - uri: 'http://10.0.0.1:8081/assets/module/a/logo@2x.png?platform=ios&hash=5b6f00f', - scale: 2, - }); - }); - - }); - - describe('bundle was loaded from file on iOS', () => { - beforeEach(() => { - NativeModules.SourceCode.scriptURL = - 'file:///Path/To/Sample.app/main.bundle'; - Platform.OS = 'ios'; - }); - - it('uses pre-packed image', () => { - expectResolvesAsset({ - __packager_asset: true, - fileSystemLocation: '/root/app/module/a', - httpServerLocation: '/assets/module/a', - width: 100, - height: 200, - scales: [1], - hash: '5b6f00f', - name: 'logo', - type: 'png', - }, { - __packager_asset: true, - width: 100, - height: 200, - uri: '/Path/To/Sample.app/assets/module/a/logo.png', - scale: 1, - }); - }); - }); - - describe('bundle was loaded from file on Android', () => { - beforeEach(() => { - NativeModules.SourceCode.scriptURL = - 'file:///Path/To/Simulator/main.bundle'; - Platform.OS = 'android'; - }); - - it('uses pre-packed image', () => { - expectResolvesAsset({ - __packager_asset: true, - fileSystemLocation: '/root/app/module/a', - httpServerLocation: '/assets/AwesomeModule/Subdir', - width: 100, - height: 200, - scales: [1], - hash: '5b6f00f', - name: '!@Logo#1_€', // Invalid chars shouldn't get passed to native - type: 'png', - }, { - __packager_asset: true, - width: 100, - height: 200, - uri: 'awesomemodule_subdir_logo1_', - scale: 1, - }); - }); - }); - -}); - -describe('resolveAssetSource.pickScale', () => { - it('picks matching scale', () => { - expect(resolveAssetSource.pickScale([1], 2)).toBe(1); - expect(resolveAssetSource.pickScale([1, 2, 3], 2)).toBe(2); - expect(resolveAssetSource.pickScale([1, 2], 3)).toBe(2); - expect(resolveAssetSource.pickScale([1, 2, 3, 4], 3.5)).toBe(4); - expect(resolveAssetSource.pickScale([3, 4], 2)).toBe(3); - expect(resolveAssetSource.pickScale([], 2)).toBe(1); - }); -}); diff --git a/examples/node_modules/react-native/Libraries/Image/resolveAssetSource.js b/examples/node_modules/react-native/Libraries/Image/resolveAssetSource.js deleted file mode 100644 index 638b72ce..00000000 --- a/examples/node_modules/react-native/Libraries/Image/resolveAssetSource.js +++ /dev/null @@ -1,151 +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. - * - * @providesModule resolveAssetSource - * @flow - * - * Resolves an asset into a `source` for `Image`. - */ -'use strict'; - -export type ResolvedAssetSource = { - __packager_asset: boolean, - width: number, - height: number, - uri: string, - scale: number, -}; - -var AssetRegistry = require('AssetRegistry'); -var PixelRatio = require('PixelRatio'); -var Platform = require('Platform'); -var SourceCode = require('NativeModules').SourceCode; - -var _serverURL, _offlinePath; - -function getDevServerURL() { - if (_serverURL === undefined) { - var scriptURL = SourceCode.scriptURL; - var match = scriptURL && scriptURL.match(/^https?:\/\/.*?\//); - if (match) { - // Bundle was loaded from network - _serverURL = match[0]; - } else { - // Bundle was loaded from file - _serverURL = null; - } - } - - return _serverURL; -} - -function getOfflinePath() { - if (_offlinePath === undefined) { - var scriptURL = SourceCode.scriptURL; - var match = scriptURL && scriptURL.match(/^file:\/\/(\/.*\/)/); - if (match) { - _offlinePath = match[1]; - } else { - _offlinePath = ''; - } - } - - return _offlinePath; -} - -/** - * Returns the path at which the asset can be found in the archive - */ -function getPathInArchive(asset) { - if (Platform.OS === 'android') { - var assetDir = getBasePath(asset); - // E.g. 'assets_awesomemodule_icon' - // The Android resource system picks the correct scale. - return (assetDir + '/' + asset.name) - .toLowerCase() - .replace(/\//g, '_') // Encode folder structure in file name - .replace(/([^a-z0-9_])/g, '') // Remove illegal chars - .replace(/^assets_/, ''); // Remove "assets_" prefix - } else { - // E.g. 'assets/AwesomeModule/icon@2x.png' - return getOfflinePath() + getScaledAssetPath(asset); - } -} - -/** - * Returns an absolute URL which can be used to fetch the asset - * from the devserver - */ -function getPathOnDevserver(devServerUrl, asset) { - return devServerUrl + getScaledAssetPath(asset) + '?platform=' + Platform.OS + - '&hash=' + asset.hash; -} - -/** - * Returns a path like 'assets/AwesomeModule' - */ -function getBasePath(asset) { - // TODO(frantic): currently httpServerLocation is used both as - // path in http URL and path within IPA. Should we have zipArchiveLocation? - var path = asset.httpServerLocation; - if (path[0] === '/') { - path = path.substr(1); - } - return path; -} - -/** - * Returns a path like 'assets/AwesomeModule/icon@2x.png' - */ -function getScaledAssetPath(asset) { - var scale = pickScale(asset.scales, PixelRatio.get()); - var scaleSuffix = scale === 1 ? '' : '@' + scale + 'x'; - var assetDir = getBasePath(asset); - return assetDir + '/' + asset.name + scaleSuffix + '.' + asset.type; -} - -function pickScale(scales: Array, deviceScale: number): number { - // Packager guarantees that `scales` array is sorted - for (var i = 0; i < scales.length; i++) { - if (scales[i] >= deviceScale) { - return scales[i]; - } - } - - // If nothing matches, device scale is larger than any available - // scales, so we return the biggest one. Unless the array is empty, - // in which case we default to 1 - return scales[scales.length - 1] || 1; -} - -function resolveAssetSource(source: any): ?ResolvedAssetSource { - if (typeof source === 'object') { - return source; - } - - var asset = AssetRegistry.getAssetByID(source); - if (asset) { - return assetToImageSource(asset); - } - - return null; -} - -function assetToImageSource(asset): ResolvedAssetSource { - var devServerURL = getDevServerURL(); - return { - __packager_asset: true, - width: asset.width, - height: asset.height, - uri: devServerURL ? getPathOnDevserver(devServerURL, asset) : getPathInArchive(asset), - scale: pickScale(asset.scales, PixelRatio.get()), - }; -} - -module.exports = resolveAssetSource; -module.exports.pickScale = pickScale; diff --git a/examples/node_modules/react-native/Libraries/Interaction/InteractionManager.js b/examples/node_modules/react-native/Libraries/Interaction/InteractionManager.js deleted file mode 100644 index fd4ab67c..00000000 --- a/examples/node_modules/react-native/Libraries/Interaction/InteractionManager.js +++ /dev/null @@ -1,157 +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. - * - * @providesModule InteractionManager - * @flow - */ -'use strict'; - -var ErrorUtils = require('ErrorUtils'); -var EventEmitter = require('EventEmitter'); -var Set = require('Set'); - -var invariant = require('invariant'); -var keyMirror = require('keyMirror'); -var setImmediate = require('setImmediate'); - -type Handle = number; - -var _emitter = new EventEmitter(); -var _interactionSet = new Set(); -var _addInteractionSet = new Set(); -var _deleteInteractionSet = new Set(); -var _nextUpdateHandle = null; -var _queue = []; -var _inc = 0; - -/** - * InteractionManager allows long-running work to be scheduled after any - * interactions/animations have completed. In particular, this allows JavaScript - * animations to run smoothly. - * - * Applications can schedule tasks to run after interactions with the following: - * - * ``` - * InteractionManager.runAfterInteractions(() => { - * // ...long-running synchronous task... - * }); - * ``` - * - * Compare this to other scheduling alternatives: - * - * - requestAnimationFrame(): for code that animates a view over time. - * - setImmediate/setTimeout(): run code later, note this may delay animations. - * - runAfterInteractions(): run code later, without delaying active animations. - * - * The touch handling system considers one or more active touches to be an - * 'interaction' and will delay `runAfterInteractions()` callbacks until all - * touches have ended or been cancelled. - * - * InteractionManager also allows applications to register animations by - * creating an interaction 'handle' on animation start, and clearing it upon - * completion: - * - * ``` - * var handle = InteractionManager.createInteractionHandle(); - * // run animation... (`runAfterInteractions` tasks are queued) - * // later, on animation completion: - * InteractionManager.clearInteractionHandle(handle); - * // queued tasks run if all handles were cleared - * ``` - */ -var InteractionManager = { - Events: keyMirror({ - interactionStart: true, - interactionComplete: true, - }), - - /** - * Schedule a function to run after all interactions have completed. - */ - runAfterInteractions(callback: ?Function): Promise { - return new Promise(resolve => { - scheduleUpdate(); - if (callback) { - _queue.push(callback); - } - _queue.push(resolve); - }); - }, - - /** - * Notify manager that an interaction has started. - */ - createInteractionHandle(): Handle { - scheduleUpdate(); - var handle = ++_inc; - _addInteractionSet.add(handle); - return handle; - }, - - /** - * Notify manager that an interaction has completed. - */ - clearInteractionHandle(handle: Handle) { - invariant( - !!handle, - 'Must provide a handle to clear.' - ); - scheduleUpdate(); - _addInteractionSet.delete(handle); - _deleteInteractionSet.add(handle); - }, - - addListener: _emitter.addListener.bind(_emitter), -}; - -/** - * Schedule an asynchronous update to the interaction state. - */ -function scheduleUpdate() { - if (!_nextUpdateHandle) { - _nextUpdateHandle = setImmediate(processUpdate); - } -} - -/** - * Notify listeners, process queue, etc - */ -function processUpdate() { - _nextUpdateHandle = null; - - var interactionCount = _interactionSet.size; - _addInteractionSet.forEach(handle => - _interactionSet.add(handle) - ); - _deleteInteractionSet.forEach(handle => - _interactionSet.delete(handle) - ); - var nextInteractionCount = _interactionSet.size; - - if (interactionCount !== 0 && nextInteractionCount === 0) { - // transition from 1+ --> 0 interactions - _emitter.emit(InteractionManager.Events.interactionComplete); - } else if (interactionCount === 0 && nextInteractionCount !== 0) { - // transition from 0 --> 1+ interactions - _emitter.emit(InteractionManager.Events.interactionStart); - } - - // process the queue regardless of a transition - if (nextInteractionCount === 0) { - var queue = _queue; - _queue = []; - queue.forEach(callback => { - ErrorUtils.applyWithGuard(callback); - }); - } - - _addInteractionSet.clear(); - _deleteInteractionSet.clear(); -} - -module.exports = InteractionManager; diff --git a/examples/node_modules/react-native/Libraries/Interaction/InteractionMixin.js b/examples/node_modules/react-native/Libraries/Interaction/InteractionMixin.js deleted file mode 100644 index b92120f9..00000000 --- a/examples/node_modules/react-native/Libraries/Interaction/InteractionMixin.js +++ /dev/null @@ -1,50 +0,0 @@ -/** - * Copyright 2004-present Facebook. All Rights Reserved. - * - * @providesModule InteractionMixin - * @flow - */ -'use strict'; - -var InteractionManager = require('InteractionManager'); - -/** - * This mixin provides safe versions of InteractionManager start/end methods - * that ensures `clearInteractionHandle` is always called - * once per start, even if the component is unmounted. - */ -var InteractionMixin = { - componentWillUnmount: function() { - while (this._interactionMixinHandles.length) { - InteractionManager.clearInteractionHandle( - this._interactionMixinHandles.pop() - ); - } - }, - - _interactionMixinHandles: ([]: Array), - - createInteractionHandle: function() { - var handle = InteractionManager.createInteractionHandle(); - this._interactionMixinHandles.push(handle); - return handle; - }, - - clearInteractionHandle: function(clearHandle: number) { - InteractionManager.clearInteractionHandle(clearHandle); - this._interactionMixinHandles = this._interactionMixinHandles.filter( - handle => handle !== clearHandle - ); - }, - - /** - * Schedule work for after all interactions have completed. - * - * @param {function} callback - */ - runAfterInteractions: function(callback: Function) { - InteractionManager.runAfterInteractions(callback); - }, -}; - -module.exports = InteractionMixin; diff --git a/examples/node_modules/react-native/Libraries/JavaScriptAppEngine/Initialization/ExceptionsManager.js b/examples/node_modules/react-native/Libraries/JavaScriptAppEngine/Initialization/ExceptionsManager.js deleted file mode 100644 index 8e652caf..00000000 --- a/examples/node_modules/react-native/Libraries/JavaScriptAppEngine/Initialization/ExceptionsManager.js +++ /dev/null @@ -1,103 +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. - * - * @providesModule ExceptionsManager - * @flow - */ -'use strict'; - -var RCTExceptionsManager = require('NativeModules').ExceptionsManager; - -var loadSourceMap = require('loadSourceMap'); -var parseErrorStack = require('parseErrorStack'); -var stringifySafe = require('stringifySafe'); - -var sourceMapPromise; - -var exceptionID = 0; - -/** - * Handles the developer-visible aspect of errors and exceptions - */ -function reportException(e: Error, isFatal: bool) { - var currentExceptionID = ++exceptionID; - if (RCTExceptionsManager) { - var stack = parseErrorStack(e); - if (isFatal) { - RCTExceptionsManager.reportFatalException(e.message, stack, currentExceptionID); - } else { - RCTExceptionsManager.reportSoftException(e.message, stack, currentExceptionID); - } - if (__DEV__) { - (sourceMapPromise = sourceMapPromise || loadSourceMap()) - .then(map => { - var prettyStack = parseErrorStack(e, map); - RCTExceptionsManager.updateExceptionMessage(e.message, prettyStack, currentExceptionID); - }) - .catch(error => { - // This can happen in a variety of normal situations, such as - // Network module not being available, or when running locally - console.warn('Unable to load source map: ' + error.message); - }); - } - } -} - -/** - * Logs exceptions to the (native) console and displays them - */ -function handleException(e: Error, isFatal: boolean) { - // Workaround for reporting errors caused by `throw 'some string'` - // Unfortunately there is no way to figure out the stacktrace in this - // case, so if you ended up here trying to trace an error, look for - // `throw ''` somewhere in your codebase. - if (!e.message) { - e = new Error(e); - } - - (console._errorOriginal || console.error)(e.message); - reportException(e, isFatal); -} - -/** - * Shows a redbox with stacktrace for all console.error messages. Disable by - * setting `console.reportErrorsAsExceptions = false;` in your app. - */ -function installConsoleErrorReporter() { - // Enable reportErrorsAsExceptions - if (console._errorOriginal) { - return; // already installed - } - console._errorOriginal = console.error.bind(console); - console.error = function reactConsoleError() { - console._errorOriginal.apply(null, arguments); - if (!console.reportErrorsAsExceptions) { - return; - } - - if (arguments[0] && arguments[0].stack) { - reportException(arguments[0], /* isFatal */ false); - } else { - var str = Array.prototype.map.call(arguments, stringifySafe).join(', '); - if (str.slice(0, 10) === '"Warning: ') { - // React warnings use console.error so that a stack trace is shown, but - // we don't (currently) want these to show a redbox - // (Note: Logic duplicated in polyfills/console.js.) - return; - } - var error : any = new Error('console.error: ' + str); - error.framesToPop = 1; - reportException(error, /* isFatal */ false); - } - }; - if (console.reportErrorsAsExceptions === undefined) { - console.reportErrorsAsExceptions = true; // Individual apps can disable this - } -} - -module.exports = { handleException, installConsoleErrorReporter }; diff --git a/examples/node_modules/react-native/Libraries/JavaScriptAppEngine/Initialization/InitializeJavaScriptAppEngine.js b/examples/node_modules/react-native/Libraries/JavaScriptAppEngine/Initialization/InitializeJavaScriptAppEngine.js deleted file mode 100644 index 141ea704..00000000 --- a/examples/node_modules/react-native/Libraries/JavaScriptAppEngine/Initialization/InitializeJavaScriptAppEngine.js +++ /dev/null @@ -1,218 +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. - * - * Sets up global variables typical in most JavaScript environments. - * - * 1. Global timers (via `setTimeout` etc). - * 2. Global console object. - * 3. Hooks for printing stack traces with source maps. - * - * Leaves enough room in the environment for implementing your own: - * 1. Require system. - * 2. Bridged modules. - * - * @providesModule InitializeJavaScriptAppEngine - */ - -/* eslint strict: 0 */ -/* globals GLOBAL: true, window: true */ - -require('regenerator/runtime'); - -if (typeof GLOBAL === 'undefined') { - GLOBAL = this; -} - -if (typeof window === 'undefined') { - window = GLOBAL; -} - -function setUpConsole() { - // ExceptionsManager transitively requires Promise so we install it after - var ExceptionsManager = require('ExceptionsManager'); - ExceptionsManager.installConsoleErrorReporter(); -} - -/** - * Assigns a new global property, replacing the existing one if there is one. - * - * Existing properties are preserved as `originalPropertyName`. Both properties - * will maintain the same enumerability & configurability. - * - * This allows you to undo the more aggressive polyfills, should you need to. - * For example, if you want to route network requests through DevTools (to trace - * them): - * - * global.XMLHttpRequest = global.originalXMLHttpRequest; - * - * For more info on that particular case, see: - * https://github.com/facebook/react-native/issues/934 - */ -function polyfillGlobal(name, newValue, scope = GLOBAL) { - var descriptor = Object.getOwnPropertyDescriptor(scope, name) || { - // jest for some bad reasons runs the polyfill code multiple times. In jest - // environment, XmlHttpRequest doesn't exist so getOwnPropertyDescriptor - // returns undefined and defineProperty default for writable is false. - // Therefore, the second time it runs, defineProperty will fatal :( - writable: true, - }; - - if (scope[name] !== undefined) { - var backupName = `original${name[0].toUpperCase()}${name.substr(1)}`; - Object.defineProperty(scope, backupName, {...descriptor, value: scope[name]}); - } - - Object.defineProperty(scope, name, {...descriptor, value: newValue}); -} - -function setUpErrorHandler() { - if (global.__fbDisableExceptionsManager) { - return; - } - - function handleError(e, isFatal) { - try { - require('ExceptionsManager').handleException(e, isFatal); - } catch(ee) { - console.log('Failed to print error: ', ee.message); - } - } - - var ErrorUtils = require('ErrorUtils'); - ErrorUtils.setGlobalHandler(handleError); -} - -function setUpFlowChecker() { - if (__DEV__) { - var checkFlowAtRuntime = require('checkFlowAtRuntime'); - checkFlowAtRuntime(); - } -} - -/** - * Sets up a set of window environment wrappers that ensure that the - * BatchedBridge is flushed after each tick. In both the case of the - * `UIWebView` based `RCTJavaScriptCaller` and `RCTContextCaller`, we - * implement our own custom timing bridge that should be immune to - * unexplainably dropped timing signals. - */ -function setUpTimers() { - var JSTimers = require('JSTimers'); - GLOBAL.setTimeout = JSTimers.setTimeout; - GLOBAL.setInterval = JSTimers.setInterval; - GLOBAL.setImmediate = JSTimers.setImmediate; - GLOBAL.clearTimeout = JSTimers.clearTimeout; - GLOBAL.clearInterval = JSTimers.clearInterval; - GLOBAL.clearImmediate = JSTimers.clearImmediate; - GLOBAL.cancelAnimationFrame = JSTimers.clearInterval; - GLOBAL.requestAnimationFrame = function(cb) { - /*requestAnimationFrame() { [native code] };*/ // Trick scroller library - return JSTimers.requestAnimationFrame(cb); // into thinking it's native - }; -} - -function setUpAlert() { - var RCTAlertManager = require('NativeModules').AlertManager; - if (!GLOBAL.alert) { - GLOBAL.alert = function(text) { - var alertOpts = { - title: 'Alert', - message: '' + text, - buttons: [{'cancel': 'OK'}], - }; - RCTAlertManager.alertWithArgs(alertOpts, function () {}); - }; - } -} - -function setUpPromise() { - // The native Promise implementation throws the following error: - // ERROR: Event loop not supported. - GLOBAL.Promise = require('Promise'); -} - -function setUpXHR() { - // The native XMLHttpRequest in Chrome dev tools is CORS aware and won't - // let you fetch anything from the internet - polyfillGlobal('XMLHttpRequest', require('XMLHttpRequest')); - polyfillGlobal('FormData', require('FormData')); - - var fetchPolyfill = require('fetch'); - polyfillGlobal('fetch', fetchPolyfill.fetch); - polyfillGlobal('Headers', fetchPolyfill.Headers); - polyfillGlobal('Request', fetchPolyfill.Request); - polyfillGlobal('Response', fetchPolyfill.Response); -} - -function setUpGeolocation() { - GLOBAL.navigator = GLOBAL.navigator || {}; - polyfillGlobal('geolocation', require('Geolocation'), GLOBAL.navigator); -} - -function setUpProduct() { - Object.defineProperty(GLOBAL.navigator, 'product', {value: 'ReactNative'}); -} - - -function setUpWebSockets() { - polyfillGlobal('WebSocket', require('WebSocket')); -} - -function setUpProfile() { - if (__DEV__) { - var BridgeProfiling = require('BridgeProfiling'); - BridgeProfiling.swizzleReactPerf(); - } -} - -function setUpProcessEnv() { - GLOBAL.process = GLOBAL.process || {}; - GLOBAL.process.env = GLOBAL.process.env || {}; - if (!GLOBAL.process.env.NODE_ENV) { - GLOBAL.process.env.NODE_ENV = __DEV__ ? 'development' : 'production'; - } -} - -function setUpNumber() { - Number.EPSILON = Number.EPSILON || Math.pow(2, -52); - Number.MAX_SAFE_INTEGER = Number.MAX_SAFE_INTEGER || Math.pow(2, 53) - 1; - Number.MIN_SAFE_INTEGER = Number.MIN_SAFE_INTEGER || -(Math.pow(2, 53) - 1); -} - -function setUpDevTools() { - // not when debugging in chrome - if (__DEV__) { // TODO(9123099) Strip `__DEV__ &&` - if (!window.document && require('Platform').OS === 'ios') { - var setupDevtools = require('setupDevtools'); - setupDevtools(); - } - } -} - -setUpProcessEnv(); -setUpConsole(); -setUpTimers(); -setUpAlert(); -setUpPromise(); -setUpErrorHandler(); -setUpXHR(); -setUpGeolocation(); -setUpProduct(); -setUpWebSockets(); -setUpProfile(); -setUpFlowChecker(); -setUpNumber(); -setUpDevTools(); - -// Just to make sure the JS gets packaged up. Wait until the JS environment has -// been initialized before requiring them. -if (__DEV__) { - require('RCTDebugComponentOwnership'); -} -require('RCTDeviceEventEmitter'); -require('PerformanceLogger'); diff --git a/examples/node_modules/react-native/Libraries/JavaScriptAppEngine/Initialization/SourceMap.js b/examples/node_modules/react-native/Libraries/JavaScriptAppEngine/Initialization/SourceMap.js deleted file mode 100644 index 53d08f82..00000000 --- a/examples/node_modules/react-native/Libraries/JavaScriptAppEngine/Initialization/SourceMap.js +++ /dev/null @@ -1,1966 +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. - * - * @providesModule SourceMap - * @generated - * @extern - * - * This module was generated from `node_modules/source-map` by running - * - * $ npm install dryice - * $ node Makefile.dryice.js - * $ cat dist/source-map.js - * - * and wrapping resulting file into `wrapper` function. - * - */ -/*eslint-disable */ - -var scope = {}; -wrapper.call(scope); - -module.exports = scope.sourceMap; - -function wrapper() { - -/* -*- Mode: js; js-indent-level: 2; -*- */ -/* - * Copyright 2011 Mozilla Foundation and contributors - * Licensed under the New BSD license. See LICENSE or: - * http://opensource.org/licenses/BSD-3-Clause - */ - -/** - * Define a module along with a payload. - * @param {string} moduleName Name for the payload - * @param {ignored} deps Ignored. For compatibility with CommonJS AMD Spec - * @param {function} payload Function with (require, exports, module) params - */ -function define(moduleName, deps, payload) { - if (typeof moduleName != "string") { - throw new TypeError('Expected string, got: ' + moduleName); - } - - if (arguments.length == 2) { - payload = deps; - } - - if (moduleName in define.modules) { - throw new Error("Module already defined: " + moduleName); - } - define.modules[moduleName] = payload; -}; - -/** - * The global store of un-instantiated modules - */ -define.modules = {}; - - -/** - * We invoke require() in the context of a Domain so we can have multiple - * sets of modules running separate from each other. - * This contrasts with JSMs which are singletons, Domains allows us to - * optionally load a CommonJS module twice with separate data each time. - * Perhaps you want 2 command lines with a different set of commands in each, - * for example. - */ -function Domain() { - this.modules = {}; - this._currentModule = null; -} - -(function () { - - /** - * Lookup module names and resolve them by calling the definition function if - * needed. - * There are 2 ways to call this, either with an array of dependencies and a - * callback to call when the dependencies are found (which can happen - * asynchronously in an in-page context) or with a single string an no callback - * where the dependency is resolved synchronously and returned. - * The API is designed to be compatible with the CommonJS AMD spec and - * RequireJS. - * @param {string[]|string} deps A name, or names for the payload - * @param {function|undefined} callback Function to call when the dependencies - * are resolved - * @return {undefined|object} The module required or undefined for - * array/callback method - */ - Domain.prototype.require = function(deps, callback) { - if (Array.isArray(deps)) { - var params = deps.map(function(dep) { - return this.lookup(dep); - }, this); - if (callback) { - callback.apply(null, params); - } - return undefined; - } - else { - return this.lookup(deps); - } - }; - - function normalize(path) { - var bits = path.split('/'); - var i = 1; - while (i < bits.length) { - if (bits[i] === '..') { - bits.splice(i-1, 1); - } else if (bits[i] === '.') { - bits.splice(i, 1); - } else { - i++; - } - } - return bits.join('/'); - } - - function join(a, b) { - a = a.trim(); - b = b.trim(); - if (/^\//.test(b)) { - return b; - } else { - return a.replace(/\/*$/, '/') + b; - } - } - - function dirname(path) { - var bits = path.split('/'); - bits.pop(); - return bits.join('/'); - } - - /** - * Lookup module names and resolve them by calling the definition function if - * needed. - * @param {string} moduleName A name for the payload to lookup - * @return {object} The module specified by aModuleName or null if not found. - */ - Domain.prototype.lookup = function(moduleName) { - if (/^\./.test(moduleName)) { - moduleName = normalize(join(dirname(this._currentModule), moduleName)); - } - - if (moduleName in this.modules) { - var module = this.modules[moduleName]; - return module; - } - - if (!(moduleName in define.modules)) { - throw new Error("Module not defined: " + moduleName); - } - - var module = define.modules[moduleName]; - - if (typeof module == "function") { - var exports = {}; - var previousModule = this._currentModule; - this._currentModule = moduleName; - module(this.require.bind(this), exports, { id: moduleName, uri: "" }); - this._currentModule = previousModule; - module = exports; - } - - // cache the resulting module object for next time - this.modules[moduleName] = module; - - return module; - }; - -}()); - -define.Domain = Domain; -define.globalDomain = new Domain(); -var require = define.globalDomain.require.bind(define.globalDomain); -/* -*- Mode: js; js-indent-level: 2; -*- */ -/* - * Copyright 2011 Mozilla Foundation and contributors - * Licensed under the New BSD license. See LICENSE or: - * http://opensource.org/licenses/BSD-3-Clause - */ -define('source-map/source-map-generator', ['require', 'exports', 'module' , 'source-map/base64-vlq', 'source-map/util', 'source-map/array-set'], function(require, exports, module) { - - var base64VLQ = require('./base64-vlq'); - var util = require('./util'); - var ArraySet = require('./array-set').ArraySet; - - /** - * An instance of the SourceMapGenerator represents a source map which is - * being built incrementally. To create a new one, you must pass an object - * with the following properties: - * - * - file: The filename of the generated source. - * - sourceRoot: An optional root for all URLs in this source map. - */ - function SourceMapGenerator(aArgs) { - this._file = util.getArg(aArgs, 'file'); - this._sourceRoot = util.getArg(aArgs, 'sourceRoot', null); - this._sources = new ArraySet(); - this._names = new ArraySet(); - this._mappings = []; - this._sourcesContents = null; - } - - SourceMapGenerator.prototype._version = 3; - - /** - * Creates a new SourceMapGenerator based on a SourceMapConsumer - * - * @param aSourceMapConsumer The SourceMap. - */ - SourceMapGenerator.fromSourceMap = - function SourceMapGenerator_fromSourceMap(aSourceMapConsumer) { - var sourceRoot = aSourceMapConsumer.sourceRoot; - var generator = new SourceMapGenerator({ - file: aSourceMapConsumer.file, - sourceRoot: sourceRoot - }); - aSourceMapConsumer.eachMapping(function (mapping) { - var newMapping = { - generated: { - line: mapping.generatedLine, - column: mapping.generatedColumn - } - }; - - if (mapping.source) { - newMapping.source = mapping.source; - if (sourceRoot) { - newMapping.source = util.relative(sourceRoot, newMapping.source); - } - - newMapping.original = { - line: mapping.originalLine, - column: mapping.originalColumn - }; - - if (mapping.name) { - newMapping.name = mapping.name; - } - } - - generator.addMapping(newMapping); - }); - aSourceMapConsumer.sources.forEach(function (sourceFile) { - var content = aSourceMapConsumer.sourceContentFor(sourceFile); - if (content) { - generator.setSourceContent(sourceFile, content); - } - }); - return generator; - }; - - /** - * Add a single mapping from original source line and column to the generated - * source's line and column for this source map being created. The mapping - * object should have the following properties: - * - * - generated: An object with the generated line and column positions. - * - original: An object with the original line and column positions. - * - source: The original source file (relative to the sourceRoot). - * - name: An optional original token name for this mapping. - */ - SourceMapGenerator.prototype.addMapping = - function SourceMapGenerator_addMapping(aArgs) { - var generated = util.getArg(aArgs, 'generated'); - var original = util.getArg(aArgs, 'original', null); - var source = util.getArg(aArgs, 'source', null); - var name = util.getArg(aArgs, 'name', null); - - this._validateMapping(generated, original, source, name); - - if (source && !this._sources.has(source)) { - this._sources.add(source); - } - - if (name && !this._names.has(name)) { - this._names.add(name); - } - - this._mappings.push({ - generatedLine: generated.line, - generatedColumn: generated.column, - originalLine: original != null && original.line, - originalColumn: original != null && original.column, - source: source, - name: name - }); - }; - - /** - * Set the source content for a source file. - */ - SourceMapGenerator.prototype.setSourceContent = - function SourceMapGenerator_setSourceContent(aSourceFile, aSourceContent) { - var source = aSourceFile; - if (this._sourceRoot) { - source = util.relative(this._sourceRoot, source); - } - - if (aSourceContent !== null) { - // Add the source content to the _sourcesContents map. - // Create a new _sourcesContents map if the property is null. - if (!this._sourcesContents) { - this._sourcesContents = {}; - } - this._sourcesContents[util.toSetString(source)] = aSourceContent; - } else { - // Remove the source file from the _sourcesContents map. - // If the _sourcesContents map is empty, set the property to null. - delete this._sourcesContents[util.toSetString(source)]; - if (Object.keys(this._sourcesContents).length === 0) { - this._sourcesContents = null; - } - } - }; - - /** - * Applies the mappings of a sub-source-map for a specific source file to the - * source map being generated. Each mapping to the supplied source file is - * rewritten using the supplied source map. Note: The resolution for the - * resulting mappings is the minimium of this map and the supplied map. - * - * @param aSourceMapConsumer The source map to be applied. - * @param aSourceFile Optional. The filename of the source file. - * If omitted, SourceMapConsumer's file property will be used. - */ - SourceMapGenerator.prototype.applySourceMap = - function SourceMapGenerator_applySourceMap(aSourceMapConsumer, aSourceFile) { - // If aSourceFile is omitted, we will use the file property of the SourceMap - if (!aSourceFile) { - aSourceFile = aSourceMapConsumer.file; - } - var sourceRoot = this._sourceRoot; - // Make "aSourceFile" relative if an absolute Url is passed. - if (sourceRoot) { - aSourceFile = util.relative(sourceRoot, aSourceFile); - } - // Applying the SourceMap can add and remove items from the sources and - // the names array. - var newSources = new ArraySet(); - var newNames = new ArraySet(); - - // Find mappings for the "aSourceFile" - this._mappings.forEach(function (mapping) { - if (mapping.source === aSourceFile && mapping.originalLine) { - // Check if it can be mapped by the source map, then update the mapping. - var original = aSourceMapConsumer.originalPositionFor({ - line: mapping.originalLine, - column: mapping.originalColumn - }); - if (original.source !== null) { - // Copy mapping - if (sourceRoot) { - mapping.source = util.relative(sourceRoot, original.source); - } else { - mapping.source = original.source; - } - mapping.originalLine = original.line; - mapping.originalColumn = original.column; - if (original.name !== null && mapping.name !== null) { - // Only use the identifier name if it's an identifier - // in both SourceMaps - mapping.name = original.name; - } - } - } - - var source = mapping.source; - if (source && !newSources.has(source)) { - newSources.add(source); - } - - var name = mapping.name; - if (name && !newNames.has(name)) { - newNames.add(name); - } - - }, this); - this._sources = newSources; - this._names = newNames; - - // Copy sourcesContents of applied map. - aSourceMapConsumer.sources.forEach(function (sourceFile) { - var content = aSourceMapConsumer.sourceContentFor(sourceFile); - if (content) { - if (sourceRoot) { - sourceFile = util.relative(sourceRoot, sourceFile); - } - this.setSourceContent(sourceFile, content); - } - }, this); - }; - - /** - * A mapping can have one of the three levels of data: - * - * 1. Just the generated position. - * 2. The Generated position, original position, and original source. - * 3. Generated and original position, original source, as well as a name - * token. - * - * To maintain consistency, we validate that any new mapping being added falls - * in to one of these categories. - */ - SourceMapGenerator.prototype._validateMapping = - function SourceMapGenerator_validateMapping(aGenerated, aOriginal, aSource, - aName) { - if (aGenerated && 'line' in aGenerated && 'column' in aGenerated - && aGenerated.line > 0 && aGenerated.column >= 0 - && !aOriginal && !aSource && !aName) { - // Case 1. - return; - } - else if (aGenerated && 'line' in aGenerated && 'column' in aGenerated - && aOriginal && 'line' in aOriginal && 'column' in aOriginal - && aGenerated.line > 0 && aGenerated.column >= 0 - && aOriginal.line > 0 && aOriginal.column >= 0 - && aSource) { - // Cases 2 and 3. - return; - } - else { - throw new Error('Invalid mapping: ' + JSON.stringify({ - generated: aGenerated, - source: aSource, - orginal: aOriginal, - name: aName - })); - } - }; - - /** - * Serialize the accumulated mappings in to the stream of base 64 VLQs - * specified by the source map format. - */ - SourceMapGenerator.prototype._serializeMappings = - function SourceMapGenerator_serializeMappings() { - var previousGeneratedColumn = 0; - var previousGeneratedLine = 1; - var previousOriginalColumn = 0; - var previousOriginalLine = 0; - var previousName = 0; - var previousSource = 0; - var result = ''; - var mapping; - - // The mappings must be guaranteed to be in sorted order before we start - // serializing them or else the generated line numbers (which are defined - // via the ';' separators) will be all messed up. Note: it might be more - // performant to maintain the sorting as we insert them, rather than as we - // serialize them, but the big O is the same either way. - this._mappings.sort(util.compareByGeneratedPositions); - - for (var i = 0, len = this._mappings.length; i < len; i++) { - mapping = this._mappings[i]; - - if (mapping.generatedLine !== previousGeneratedLine) { - previousGeneratedColumn = 0; - while (mapping.generatedLine !== previousGeneratedLine) { - result += ';'; - previousGeneratedLine++; - } - } - else { - if (i > 0) { - if (!util.compareByGeneratedPositions(mapping, this._mappings[i - 1])) { - continue; - } - result += ','; - } - } - - result += base64VLQ.encode(mapping.generatedColumn - - previousGeneratedColumn); - previousGeneratedColumn = mapping.generatedColumn; - - if (mapping.source) { - result += base64VLQ.encode(this._sources.indexOf(mapping.source) - - previousSource); - previousSource = this._sources.indexOf(mapping.source); - - // lines are stored 0-based in SourceMap spec version 3 - result += base64VLQ.encode(mapping.originalLine - 1 - - previousOriginalLine); - previousOriginalLine = mapping.originalLine - 1; - - result += base64VLQ.encode(mapping.originalColumn - - previousOriginalColumn); - previousOriginalColumn = mapping.originalColumn; - - if (mapping.name) { - result += base64VLQ.encode(this._names.indexOf(mapping.name) - - previousName); - previousName = this._names.indexOf(mapping.name); - } - } - } - - return result; - }; - - SourceMapGenerator.prototype._generateSourcesContent = - function SourceMapGenerator_generateSourcesContent(aSources, aSourceRoot) { - return aSources.map(function (source) { - if (!this._sourcesContents) { - return null; - } - if (aSourceRoot) { - source = util.relative(aSourceRoot, source); - } - var key = util.toSetString(source); - return Object.prototype.hasOwnProperty.call(this._sourcesContents, - key) - ? this._sourcesContents[key] - : null; - }, this); - }; - - /** - * Externalize the source map. - */ - SourceMapGenerator.prototype.toJSON = - function SourceMapGenerator_toJSON() { - var map = { - version: this._version, - file: this._file, - sources: this._sources.toArray(), - names: this._names.toArray(), - mappings: this._serializeMappings() - }; - if (this._sourceRoot) { - map.sourceRoot = this._sourceRoot; - } - if (this._sourcesContents) { - map.sourcesContent = this._generateSourcesContent(map.sources, map.sourceRoot); - } - - return map; - }; - - /** - * Render the source map being generated to a string. - */ - SourceMapGenerator.prototype.toString = - function SourceMapGenerator_toString() { - return JSON.stringify(this); - }; - - exports.SourceMapGenerator = SourceMapGenerator; - -}); -/* -*- Mode: js; js-indent-level: 2; -*- */ -/* - * Copyright 2011 Mozilla Foundation and contributors - * Licensed under the New BSD license. See LICENSE or: - * http://opensource.org/licenses/BSD-3-Clause - * - * Based on the Base 64 VLQ implementation in Closure Compiler: - * https://code.google.com/p/closure-compiler/source/browse/trunk/src/com/google/debugging/sourcemap/Base64VLQ.java - * - * Copyright 2011 The Closure Compiler Authors. All rights reserved. - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following - * disclaimer in the documentation and/or other materials provided - * with the distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -define('source-map/base64-vlq', ['require', 'exports', 'module' , 'source-map/base64'], function(require, exports, module) { - - var base64 = require('./base64'); - - // A single base 64 digit can contain 6 bits of data. For the base 64 variable - // length quantities we use in the source map spec, the first bit is the sign, - // the next four bits are the actual value, and the 6th bit is the - // continuation bit. The continuation bit tells us whether there are more - // digits in this value following this digit. - // - // Continuation - // | Sign - // | | - // V V - // 101011 - - var VLQ_BASE_SHIFT = 5; - - // binary: 100000 - var VLQ_BASE = 1 << VLQ_BASE_SHIFT; - - // binary: 011111 - var VLQ_BASE_MASK = VLQ_BASE - 1; - - // binary: 100000 - var VLQ_CONTINUATION_BIT = VLQ_BASE; - - /** - * Converts from a two-complement value to a value where the sign bit is - * is placed in the least significant bit. For example, as decimals: - * 1 becomes 2 (10 binary), -1 becomes 3 (11 binary) - * 2 becomes 4 (100 binary), -2 becomes 5 (101 binary) - */ - function toVLQSigned(aValue) { - return aValue < 0 - ? ((-aValue) << 1) + 1 - : (aValue << 1) + 0; - } - - /** - * Converts to a two-complement value from a value where the sign bit is - * is placed in the least significant bit. For example, as decimals: - * 2 (10 binary) becomes 1, 3 (11 binary) becomes -1 - * 4 (100 binary) becomes 2, 5 (101 binary) becomes -2 - */ - function fromVLQSigned(aValue) { - var isNegative = (aValue & 1) === 1; - var shifted = aValue >> 1; - return isNegative - ? -shifted - : shifted; - } - - /** - * Returns the base 64 VLQ encoded value. - */ - exports.encode = function base64VLQ_encode(aValue) { - var encoded = ""; - var digit; - - var vlq = toVLQSigned(aValue); - - do { - digit = vlq & VLQ_BASE_MASK; - vlq >>>= VLQ_BASE_SHIFT; - if (vlq > 0) { - // There are still more digits in this value, so we must make sure the - // continuation bit is marked. - digit |= VLQ_CONTINUATION_BIT; - } - encoded += base64.encode(digit); - } while (vlq > 0); - - return encoded; - }; - - /** - * Decodes the next base 64 VLQ value from the given string and returns the - * value and the rest of the string. - */ - exports.decode = function base64VLQ_decode(aStr) { - var i = 0; - var strLen = aStr.length; - var result = 0; - var shift = 0; - var continuation, digit; - - do { - if (i >= strLen) { - throw new Error("Expected more digits in base 64 VLQ value."); - } - digit = base64.decode(aStr.charAt(i++)); - continuation = !!(digit & VLQ_CONTINUATION_BIT); - digit &= VLQ_BASE_MASK; - result = result + (digit << shift); - shift += VLQ_BASE_SHIFT; - } while (continuation); - - return { - value: fromVLQSigned(result), - rest: aStr.slice(i) - }; - }; - -}); -/* -*- Mode: js; js-indent-level: 2; -*- */ -/* - * Copyright 2011 Mozilla Foundation and contributors - * Licensed under the New BSD license. See LICENSE or: - * http://opensource.org/licenses/BSD-3-Clause - */ -define('source-map/base64', ['require', 'exports', 'module' , ], function(require, exports, module) { - - var charToIntMap = {}; - var intToCharMap = {}; - - 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/' - .split('') - .forEach(function (ch, index) { - charToIntMap[ch] = index; - intToCharMap[index] = ch; - }); - - /** - * Encode an integer in the range of 0 to 63 to a single base 64 digit. - */ - exports.encode = function base64_encode(aNumber) { - if (aNumber in intToCharMap) { - return intToCharMap[aNumber]; - } - throw new TypeError("Must be between 0 and 63: " + aNumber); - }; - - /** - * Decode a single base 64 digit to an integer. - */ - exports.decode = function base64_decode(aChar) { - if (aChar in charToIntMap) { - return charToIntMap[aChar]; - } - throw new TypeError("Not a valid base 64 digit: " + aChar); - }; - -}); -/* -*- Mode: js; js-indent-level: 2; -*- */ -/* - * Copyright 2011 Mozilla Foundation and contributors - * Licensed under the New BSD license. See LICENSE or: - * http://opensource.org/licenses/BSD-3-Clause - */ -define('source-map/util', ['require', 'exports', 'module' , ], function(require, exports, module) { - - /** - * This is a helper function for getting values from parameter/options - * objects. - * - * @param args The object we are extracting values from - * @param name The name of the property we are getting. - * @param defaultValue An optional value to return if the property is missing - * from the object. If this is not specified and the property is missing, an - * error will be thrown. - */ - function getArg(aArgs, aName, aDefaultValue) { - if (aName in aArgs) { - return aArgs[aName]; - } else if (arguments.length === 3) { - return aDefaultValue; - } else { - throw new Error('"' + aName + '" is a required argument.'); - } - } - exports.getArg = getArg; - - var urlRegexp = /([\w+\-.]+):\/\/((\w+:\w+)@)?([\w.]+)?(:(\d+))?(\S+)?/; - var dataUrlRegexp = /^data:.+\,.+/; - - function urlParse(aUrl) { - var match = aUrl.match(urlRegexp); - if (!match) { - return null; - } - return { - scheme: match[1], - auth: match[3], - host: match[4], - port: match[6], - path: match[7] - }; - } - exports.urlParse = urlParse; - - function urlGenerate(aParsedUrl) { - var url = aParsedUrl.scheme + "://"; - if (aParsedUrl.auth) { - url += aParsedUrl.auth + "@" - } - if (aParsedUrl.host) { - url += aParsedUrl.host; - } - if (aParsedUrl.port) { - url += ":" + aParsedUrl.port - } - if (aParsedUrl.path) { - url += aParsedUrl.path; - } - return url; - } - exports.urlGenerate = urlGenerate; - - function join(aRoot, aPath) { - var url; - - if (aPath.match(urlRegexp) || aPath.match(dataUrlRegexp)) { - return aPath; - } - - if (aPath.charAt(0) === '/' && (url = urlParse(aRoot))) { - url.path = aPath; - return urlGenerate(url); - } - - return aRoot.replace(/\/$/, '') + '/' + aPath; - } - exports.join = join; - - /** - * Because behavior goes wacky when you set `__proto__` on objects, we - * have to prefix all the strings in our set with an arbitrary character. - * - * See https://github.com/mozilla/source-map/pull/31 and - * https://github.com/mozilla/source-map/issues/30 - * - * @param String aStr - */ - function toSetString(aStr) { - return '$' + aStr; - } - exports.toSetString = toSetString; - - function fromSetString(aStr) { - return aStr.substr(1); - } - exports.fromSetString = fromSetString; - - function relative(aRoot, aPath) { - aRoot = aRoot.replace(/\/$/, ''); - - var url = urlParse(aRoot); - if (aPath.charAt(0) == "/" && url && url.path == "/") { - return aPath.slice(1); - } - - return aPath.indexOf(aRoot + '/') === 0 - ? aPath.substr(aRoot.length + 1) - : aPath; - } - exports.relative = relative; - - function strcmp(aStr1, aStr2) { - var s1 = aStr1 || ""; - var s2 = aStr2 || ""; - return (s1 > s2) - (s1 < s2); - } - - /** - * Comparator between two mappings where the original positions are compared. - * - * Optionally pass in `true` as `onlyCompareGenerated` to consider two - * mappings with the same original source/line/column, but different generated - * line and column the same. Useful when searching for a mapping with a - * stubbed out mapping. - */ - function compareByOriginalPositions(mappingA, mappingB, onlyCompareOriginal) { - var cmp; - - cmp = strcmp(mappingA.source, mappingB.source); - if (cmp) { - return cmp; - } - - cmp = mappingA.originalLine - mappingB.originalLine; - if (cmp) { - return cmp; - } - - cmp = mappingA.originalColumn - mappingB.originalColumn; - if (cmp || onlyCompareOriginal) { - return cmp; - } - - cmp = strcmp(mappingA.name, mappingB.name); - if (cmp) { - return cmp; - } - - cmp = mappingA.generatedLine - mappingB.generatedLine; - if (cmp) { - return cmp; - } - - return mappingA.generatedColumn - mappingB.generatedColumn; - }; - exports.compareByOriginalPositions = compareByOriginalPositions; - - /** - * Comparator between two mappings where the generated positions are - * compared. - * - * Optionally pass in `true` as `onlyCompareGenerated` to consider two - * mappings with the same generated line and column, but different - * source/name/original line and column the same. Useful when searching for a - * mapping with a stubbed out mapping. - */ - function compareByGeneratedPositions(mappingA, mappingB, onlyCompareGenerated) { - var cmp; - - cmp = mappingA.generatedLine - mappingB.generatedLine; - if (cmp) { - return cmp; - } - - cmp = mappingA.generatedColumn - mappingB.generatedColumn; - if (cmp || onlyCompareGenerated) { - return cmp; - } - - cmp = strcmp(mappingA.source, mappingB.source); - if (cmp) { - return cmp; - } - - cmp = mappingA.originalLine - mappingB.originalLine; - if (cmp) { - return cmp; - } - - cmp = mappingA.originalColumn - mappingB.originalColumn; - if (cmp) { - return cmp; - } - - return strcmp(mappingA.name, mappingB.name); - }; - exports.compareByGeneratedPositions = compareByGeneratedPositions; - -}); -/* -*- Mode: js; js-indent-level: 2; -*- */ -/* - * Copyright 2011 Mozilla Foundation and contributors - * Licensed under the New BSD license. See LICENSE or: - * http://opensource.org/licenses/BSD-3-Clause - */ -define('source-map/array-set', ['require', 'exports', 'module' , 'source-map/util'], function(require, exports, module) { - - var util = require('./util'); - - /** - * A data structure which is a combination of an array and a set. Adding a new - * member is O(1), testing for membership is O(1), and finding the index of an - * element is O(1). Removing elements from the set is not supported. Only - * strings are supported for membership. - */ - function ArraySet() { - this._array = []; - this._set = {}; - } - - /** - * Static method for creating ArraySet instances from an existing array. - */ - ArraySet.fromArray = function ArraySet_fromArray(aArray, aAllowDuplicates) { - var set = new ArraySet(); - for (var i = 0, len = aArray.length; i < len; i++) { - set.add(aArray[i], aAllowDuplicates); - } - return set; - }; - - /** - * Add the given string to this set. - * - * @param String aStr - */ - ArraySet.prototype.add = function ArraySet_add(aStr, aAllowDuplicates) { - var isDuplicate = this.has(aStr); - var idx = this._array.length; - if (!isDuplicate || aAllowDuplicates) { - this._array.push(aStr); - } - if (!isDuplicate) { - this._set[util.toSetString(aStr)] = idx; - } - }; - - /** - * Is the given string a member of this set? - * - * @param String aStr - */ - ArraySet.prototype.has = function ArraySet_has(aStr) { - return Object.prototype.hasOwnProperty.call(this._set, - util.toSetString(aStr)); - }; - - /** - * What is the index of the given string in the array? - * - * @param String aStr - */ - ArraySet.prototype.indexOf = function ArraySet_indexOf(aStr) { - if (this.has(aStr)) { - return this._set[util.toSetString(aStr)]; - } - throw new Error('"' + aStr + '" is not in the set.'); - }; - - /** - * What is the element at the given index? - * - * @param Number aIdx - */ - ArraySet.prototype.at = function ArraySet_at(aIdx) { - if (aIdx >= 0 && aIdx < this._array.length) { - return this._array[aIdx]; - } - throw new Error('No element indexed by ' + aIdx); - }; - - /** - * Returns the array representation of this set (which has the proper indices - * indicated by indexOf). Note that this is a copy of the internal array used - * for storing the members so that no one can mess with internal state. - */ - ArraySet.prototype.toArray = function ArraySet_toArray() { - return this._array.slice(); - }; - - exports.ArraySet = ArraySet; - -}); -/* -*- Mode: js; js-indent-level: 2; -*- */ -/* - * Copyright 2011 Mozilla Foundation and contributors - * Licensed under the New BSD license. See LICENSE or: - * http://opensource.org/licenses/BSD-3-Clause - */ -define('source-map/source-map-consumer', ['require', 'exports', 'module' , 'source-map/util', 'source-map/binary-search', 'source-map/array-set', 'source-map/base64-vlq'], function(require, exports, module) { - - var util = require('./util'); - var binarySearch = require('./binary-search'); - var ArraySet = require('./array-set').ArraySet; - var base64VLQ = require('./base64-vlq'); - - /** - * A SourceMapConsumer instance represents a parsed source map which we can - * query for information about the original file positions by giving it a file - * position in the generated source. - * - * The only parameter is the raw source map (either as a JSON string, or - * already parsed to an object). According to the spec, source maps have the - * following attributes: - * - * - version: Which version of the source map spec this map is following. - * - sources: An array of URLs to the original source files. - * - names: An array of identifiers which can be referrenced by individual mappings. - * - sourceRoot: Optional. The URL root from which all sources are relative. - * - sourcesContent: Optional. An array of contents of the original source files. - * - mappings: A string of base64 VLQs which contain the actual mappings. - * - file: The generated file this source map is associated with. - * - * Here is an example source map, taken from the source map spec[0]: - * - * { - * version : 3, - * file: "out.js", - * sourceRoot : "", - * sources: ["foo.js", "bar.js"], - * names: ["src", "maps", "are", "fun"], - * mappings: "AA,AB;;ABCDE;" - * } - * - * [0]: https://docs.google.com/document/d/1U1RGAehQwRypUTovF1KRlpiOFze0b-_2gc6fAH0KY0k/edit?pli=1# - */ - function SourceMapConsumer(aSourceMap) { - var sourceMap = aSourceMap; - if (typeof aSourceMap === 'string') { - sourceMap = JSON.parse(aSourceMap.replace(/^\)\]\}'/, '')); - } - - var version = util.getArg(sourceMap, 'version'); - var sources = util.getArg(sourceMap, 'sources'); - // Sass 3.3 leaves out the 'names' array, so we deviate from the spec (which - // requires the array) to play nice here. - var names = util.getArg(sourceMap, 'names', []); - var sourceRoot = util.getArg(sourceMap, 'sourceRoot', null); - var sourcesContent = util.getArg(sourceMap, 'sourcesContent', null); - var mappings = util.getArg(sourceMap, 'mappings'); - var file = util.getArg(sourceMap, 'file', null); - - // Once again, Sass deviates from the spec and supplies the version as a - // string rather than a number, so we use loose equality checking here. - if (version != this._version) { - throw new Error('Unsupported version: ' + version); - } - - // Pass `true` below to allow duplicate names and sources. While source maps - // are intended to be compressed and deduplicated, the TypeScript compiler - // sometimes generates source maps with duplicates in them. See Github issue - // #72 and bugzil.la/889492. - this._names = ArraySet.fromArray(names, true); - this._sources = ArraySet.fromArray(sources, true); - - this.sourceRoot = sourceRoot; - this.sourcesContent = sourcesContent; - this._mappings = mappings; - this.file = file; - } - - /** - * Create a SourceMapConsumer from a SourceMapGenerator. - * - * @param SourceMapGenerator aSourceMap - * The source map that will be consumed. - * @returns SourceMapConsumer - */ - SourceMapConsumer.fromSourceMap = - function SourceMapConsumer_fromSourceMap(aSourceMap) { - var smc = Object.create(SourceMapConsumer.prototype); - - smc._names = ArraySet.fromArray(aSourceMap._names.toArray(), true); - smc._sources = ArraySet.fromArray(aSourceMap._sources.toArray(), true); - smc.sourceRoot = aSourceMap._sourceRoot; - smc.sourcesContent = aSourceMap._generateSourcesContent(smc._sources.toArray(), - smc.sourceRoot); - smc.file = aSourceMap._file; - - smc.__generatedMappings = aSourceMap._mappings.slice() - .sort(util.compareByGeneratedPositions); - smc.__originalMappings = aSourceMap._mappings.slice() - .sort(util.compareByOriginalPositions); - - return smc; - }; - - /** - * The version of the source mapping spec that we are consuming. - */ - SourceMapConsumer.prototype._version = 3; - - /** - * The list of original sources. - */ - Object.defineProperty(SourceMapConsumer.prototype, 'sources', { - get: function () { - return this._sources.toArray().map(function (s) { - return this.sourceRoot ? util.join(this.sourceRoot, s) : s; - }, this); - } - }); - - // `__generatedMappings` and `__originalMappings` are arrays that hold the - // parsed mapping coordinates from the source map's "mappings" attribute. They - // are lazily instantiated, accessed via the `_generatedMappings` and - // `_originalMappings` getters respectively, and we only parse the mappings - // and create these arrays once queried for a source location. We jump through - // these hoops because there can be many thousands of mappings, and parsing - // them is expensive, so we only want to do it if we must. - // - // Each object in the arrays is of the form: - // - // { - // generatedLine: The line number in the generated code, - // generatedColumn: The column number in the generated code, - // source: The path to the original source file that generated this - // chunk of code, - // originalLine: The line number in the original source that - // corresponds to this chunk of generated code, - // originalColumn: The column number in the original source that - // corresponds to this chunk of generated code, - // name: The name of the original symbol which generated this chunk of - // code. - // } - // - // All properties except for `generatedLine` and `generatedColumn` can be - // `null`. - // - // `_generatedMappings` is ordered by the generated positions. - // - // `_originalMappings` is ordered by the original positions. - - SourceMapConsumer.prototype.__generatedMappings = null; - Object.defineProperty(SourceMapConsumer.prototype, '_generatedMappings', { - get: function () { - if (!this.__generatedMappings) { - this.__generatedMappings = []; - this.__originalMappings = []; - this._parseMappings(this._mappings, this.sourceRoot); - } - - return this.__generatedMappings; - } - }); - - SourceMapConsumer.prototype.__originalMappings = null; - Object.defineProperty(SourceMapConsumer.prototype, '_originalMappings', { - get: function () { - if (!this.__originalMappings) { - this.__generatedMappings = []; - this.__originalMappings = []; - this._parseMappings(this._mappings, this.sourceRoot); - } - - return this.__originalMappings; - } - }); - - /** - * Parse the mappings in a string in to a data structure which we can easily - * query (the ordered arrays in the `this.__generatedMappings` and - * `this.__originalMappings` properties). - */ - SourceMapConsumer.prototype._parseMappings = - function SourceMapConsumer_parseMappings(aStr, aSourceRoot) { - var generatedLine = 1; - var previousGeneratedColumn = 0; - var previousOriginalLine = 0; - var previousOriginalColumn = 0; - var previousSource = 0; - var previousName = 0; - var mappingSeparator = /^[,;]/; - var str = aStr; - var mapping; - var temp; - - while (str.length > 0) { - if (str.charAt(0) === ';') { - generatedLine++; - str = str.slice(1); - previousGeneratedColumn = 0; - } - else if (str.charAt(0) === ',') { - str = str.slice(1); - } - else { - mapping = {}; - mapping.generatedLine = generatedLine; - - // Generated column. - temp = base64VLQ.decode(str); - mapping.generatedColumn = previousGeneratedColumn + temp.value; - previousGeneratedColumn = mapping.generatedColumn; - str = temp.rest; - - if (str.length > 0 && !mappingSeparator.test(str.charAt(0))) { - // Original source. - temp = base64VLQ.decode(str); - mapping.source = this._sources.at(previousSource + temp.value); - previousSource += temp.value; - str = temp.rest; - if (str.length === 0 || mappingSeparator.test(str.charAt(0))) { - throw new Error('Found a source, but no line and column'); - } - - // Original line. - temp = base64VLQ.decode(str); - mapping.originalLine = previousOriginalLine + temp.value; - previousOriginalLine = mapping.originalLine; - // Lines are stored 0-based - mapping.originalLine += 1; - str = temp.rest; - if (str.length === 0 || mappingSeparator.test(str.charAt(0))) { - throw new Error('Found a source and line, but no column'); - } - - // Original column. - temp = base64VLQ.decode(str); - mapping.originalColumn = previousOriginalColumn + temp.value; - previousOriginalColumn = mapping.originalColumn; - str = temp.rest; - - if (str.length > 0 && !mappingSeparator.test(str.charAt(0))) { - // Original name. - temp = base64VLQ.decode(str); - mapping.name = this._names.at(previousName + temp.value); - previousName += temp.value; - str = temp.rest; - } - } - - this.__generatedMappings.push(mapping); - if (typeof mapping.originalLine === 'number') { - this.__originalMappings.push(mapping); - } - } - } - - this.__originalMappings.sort(util.compareByOriginalPositions); - }; - - /** - * Find the mapping that best matches the hypothetical "needle" mapping that - * we are searching for in the given "haystack" of mappings. - */ - SourceMapConsumer.prototype._findMapping = - function SourceMapConsumer_findMapping(aNeedle, aMappings, aLineName, - aColumnName, aComparator) { - // To return the position we are searching for, we must first find the - // mapping for the given position and then return the opposite position it - // points to. Because the mappings are sorted, we can use binary search to - // find the best mapping. - - if (aNeedle[aLineName] <= 0) { - throw new TypeError('Line must be greater than or equal to 1, got ' - + aNeedle[aLineName]); - } - if (aNeedle[aColumnName] < 0) { - throw new TypeError('Column must be greater than or equal to 0, got ' - + aNeedle[aColumnName]); - } - - return binarySearch.search(aNeedle, aMappings, aComparator); - }; - - /** - * Returns the original source, line, and column information for the generated - * source's line and column positions provided. The only argument is an object - * with the following properties: - * - * - line: The line number in the generated source. - * - column: The column number in the generated source. - * - * and an object is returned with the following properties: - * - * - source: The original source file, or null. - * - line: The line number in the original source, or null. - * - column: The column number in the original source, or null. - * - name: The original identifier, or null. - */ - SourceMapConsumer.prototype.originalPositionFor = - function SourceMapConsumer_originalPositionFor(aArgs) { - var needle = { - generatedLine: util.getArg(aArgs, 'line'), - generatedColumn: util.getArg(aArgs, 'column') - }; - - var mapping = this._findMapping(needle, - this._generatedMappings, - "generatedLine", - "generatedColumn", - util.compareByGeneratedPositions); - - if (mapping) { - var source = util.getArg(mapping, 'source', null); - if (source && this.sourceRoot) { - source = util.join(this.sourceRoot, source); - } - return { - source: source, - line: util.getArg(mapping, 'originalLine', null), - column: util.getArg(mapping, 'originalColumn', null), - name: util.getArg(mapping, 'name', null) - }; - } - - return { - source: null, - line: null, - column: null, - name: null - }; - }; - - /** - * Returns the original source content. The only argument is the url of the - * original source file. Returns null if no original source content is - * availible. - */ - SourceMapConsumer.prototype.sourceContentFor = - function SourceMapConsumer_sourceContentFor(aSource) { - if (!this.sourcesContent) { - return null; - } - - if (this.sourceRoot) { - aSource = util.relative(this.sourceRoot, aSource); - } - - if (this._sources.has(aSource)) { - return this.sourcesContent[this._sources.indexOf(aSource)]; - } - - var url; - if (this.sourceRoot - && (url = util.urlParse(this.sourceRoot))) { - // XXX: file:// URIs and absolute paths lead to unexpected behavior for - // many users. We can help them out when they expect file:// URIs to - // behave like it would if they were running a local HTTP server. See - // https://bugzilla.mozilla.org/show_bug.cgi?id=885597. - var fileUriAbsPath = aSource.replace(/^file:\/\//, ""); - if (url.scheme == "file" - && this._sources.has(fileUriAbsPath)) { - return this.sourcesContent[this._sources.indexOf(fileUriAbsPath)] - } - - if ((!url.path || url.path == "/") - && this._sources.has("/" + aSource)) { - return this.sourcesContent[this._sources.indexOf("/" + aSource)]; - } - } - - throw new Error('"' + aSource + '" is not in the SourceMap.'); - }; - - /** - * Returns the generated line and column information for the original source, - * line, and column positions provided. The only argument is an object with - * the following properties: - * - * - source: The filename of the original source. - * - line: The line number in the original source. - * - column: The column number in the original source. - * - * and an object is returned with the following properties: - * - * - line: The line number in the generated source, or null. - * - column: The column number in the generated source, or null. - */ - SourceMapConsumer.prototype.generatedPositionFor = - function SourceMapConsumer_generatedPositionFor(aArgs) { - var needle = { - source: util.getArg(aArgs, 'source'), - originalLine: util.getArg(aArgs, 'line'), - originalColumn: util.getArg(aArgs, 'column') - }; - - if (this.sourceRoot) { - needle.source = util.relative(this.sourceRoot, needle.source); - } - - var mapping = this._findMapping(needle, - this._originalMappings, - "originalLine", - "originalColumn", - util.compareByOriginalPositions); - - if (mapping) { - return { - line: util.getArg(mapping, 'generatedLine', null), - column: util.getArg(mapping, 'generatedColumn', null) - }; - } - - return { - line: null, - column: null - }; - }; - - SourceMapConsumer.GENERATED_ORDER = 1; - SourceMapConsumer.ORIGINAL_ORDER = 2; - - /** - * Iterate over each mapping between an original source/line/column and a - * generated line/column in this source map. - * - * @param Function aCallback - * The function that is called with each mapping. - * @param Object aContext - * Optional. If specified, this object will be the value of `this` every - * time that `aCallback` is called. - * @param aOrder - * Either `SourceMapConsumer.GENERATED_ORDER` or - * `SourceMapConsumer.ORIGINAL_ORDER`. Specifies whether you want to - * iterate over the mappings sorted by the generated file's line/column - * order or the original's source/line/column order, respectively. Defaults to - * `SourceMapConsumer.GENERATED_ORDER`. - */ - SourceMapConsumer.prototype.eachMapping = - function SourceMapConsumer_eachMapping(aCallback, aContext, aOrder) { - var context = aContext || null; - var order = aOrder || SourceMapConsumer.GENERATED_ORDER; - - var mappings; - switch (order) { - case SourceMapConsumer.GENERATED_ORDER: - mappings = this._generatedMappings; - break; - case SourceMapConsumer.ORIGINAL_ORDER: - mappings = this._originalMappings; - break; - default: - throw new Error("Unknown order of iteration."); - } - - var sourceRoot = this.sourceRoot; - mappings.map(function (mapping) { - var source = mapping.source; - if (source && sourceRoot) { - source = util.join(sourceRoot, source); - } - return { - source: source, - generatedLine: mapping.generatedLine, - generatedColumn: mapping.generatedColumn, - originalLine: mapping.originalLine, - originalColumn: mapping.originalColumn, - name: mapping.name - }; - }).forEach(aCallback, context); - }; - - exports.SourceMapConsumer = SourceMapConsumer; - -}); -/* -*- Mode: js; js-indent-level: 2; -*- */ -/* - * Copyright 2011 Mozilla Foundation and contributors - * Licensed under the New BSD license. See LICENSE or: - * http://opensource.org/licenses/BSD-3-Clause - */ -define('source-map/binary-search', ['require', 'exports', 'module' , ], function(require, exports, module) { - - /** - * Recursive implementation of binary search. - * - * @param aLow Indices here and lower do not contain the needle. - * @param aHigh Indices here and higher do not contain the needle. - * @param aNeedle The element being searched for. - * @param aHaystack The non-empty array being searched. - * @param aCompare Function which takes two elements and returns -1, 0, or 1. - */ - function recursiveSearch(aLow, aHigh, aNeedle, aHaystack, aCompare) { - // This function terminates when one of the following is true: - // - // 1. We find the exact element we are looking for. - // - // 2. We did not find the exact element, but we can return the next - // closest element that is less than that element. - // - // 3. We did not find the exact element, and there is no next-closest - // element which is less than the one we are searching for, so we - // return null. - var mid = Math.floor((aHigh - aLow) / 2) + aLow; - var cmp = aCompare(aNeedle, aHaystack[mid], true); - if (cmp === 0) { - // Found the element we are looking for. - return aHaystack[mid]; - } - else if (cmp > 0) { - // aHaystack[mid] is greater than our needle. - if (aHigh - mid > 1) { - // The element is in the upper half. - return recursiveSearch(mid, aHigh, aNeedle, aHaystack, aCompare); - } - // We did not find an exact match, return the next closest one - // (termination case 2). - return aHaystack[mid]; - } - else { - // aHaystack[mid] is less than our needle. - if (mid - aLow > 1) { - // The element is in the lower half. - return recursiveSearch(aLow, mid, aNeedle, aHaystack, aCompare); - } - // The exact needle element was not found in this haystack. Determine if - // we are in termination case (2) or (3) and return the appropriate thing. - return aLow < 0 - ? null - : aHaystack[aLow]; - } - } - - /** - * This is an implementation of binary search which will always try and return - * the next lowest value checked if there is no exact hit. This is because - * mappings between original and generated line/col pairs are single points, - * and there is an implicit region between each of them, so a miss just means - * that you aren't on the very start of a region. - * - * @param aNeedle The element you are looking for. - * @param aHaystack The array that is being searched. - * @param aCompare A function which takes the needle and an element in the - * array and returns -1, 0, or 1 depending on whether the needle is less - * than, equal to, or greater than the element, respectively. - */ - exports.search = function search(aNeedle, aHaystack, aCompare) { - return aHaystack.length > 0 - ? recursiveSearch(-1, aHaystack.length, aNeedle, aHaystack, aCompare) - : null; - }; - -}); -/* -*- Mode: js; js-indent-level: 2; -*- */ -/* - * Copyright 2011 Mozilla Foundation and contributors - * Licensed under the New BSD license. See LICENSE or: - * http://opensource.org/licenses/BSD-3-Clause - */ -define('source-map/source-node', ['require', 'exports', 'module' , 'source-map/source-map-generator', 'source-map/util'], function(require, exports, module) { - - var SourceMapGenerator = require('./source-map-generator').SourceMapGenerator; - var util = require('./util'); - - /** - * SourceNodes provide a way to abstract over interpolating/concatenating - * snippets of generated JavaScript source code while maintaining the line and - * column information associated with the original source code. - * - * @param aLine The original line number. - * @param aColumn The original column number. - * @param aSource The original source's filename. - * @param aChunks Optional. An array of strings which are snippets of - * generated JS, or other SourceNodes. - * @param aName The original identifier. - */ - function SourceNode(aLine, aColumn, aSource, aChunks, aName) { - this.children = []; - this.sourceContents = {}; - this.line = aLine === undefined ? null : aLine; - this.column = aColumn === undefined ? null : aColumn; - this.source = aSource === undefined ? null : aSource; - this.name = aName === undefined ? null : aName; - if (aChunks != null) this.add(aChunks); - } - - /** - * Creates a SourceNode from generated code and a SourceMapConsumer. - * - * @param aGeneratedCode The generated code - * @param aSourceMapConsumer The SourceMap for the generated code - */ - SourceNode.fromStringWithSourceMap = - function SourceNode_fromStringWithSourceMap(aGeneratedCode, aSourceMapConsumer) { - // The SourceNode we want to fill with the generated code - // and the SourceMap - var node = new SourceNode(); - - // The generated code - // Processed fragments are removed from this array. - var remainingLines = aGeneratedCode.split('\n'); - - // We need to remember the position of "remainingLines" - var lastGeneratedLine = 1, lastGeneratedColumn = 0; - - // The generate SourceNodes we need a code range. - // To extract it current and last mapping is used. - // Here we store the last mapping. - var lastMapping = null; - - aSourceMapConsumer.eachMapping(function (mapping) { - if (lastMapping === null) { - // We add the generated code until the first mapping - // to the SourceNode without any mapping. - // Each line is added as separate string. - while (lastGeneratedLine < mapping.generatedLine) { - node.add(remainingLines.shift() + "\n"); - lastGeneratedLine++; - } - if (lastGeneratedColumn < mapping.generatedColumn) { - var nextLine = remainingLines[0]; - node.add(nextLine.substr(0, mapping.generatedColumn)); - remainingLines[0] = nextLine.substr(mapping.generatedColumn); - lastGeneratedColumn = mapping.generatedColumn; - } - } else { - // We add the code from "lastMapping" to "mapping": - // First check if there is a new line in between. - if (lastGeneratedLine < mapping.generatedLine) { - var code = ""; - // Associate full lines with "lastMapping" - do { - code += remainingLines.shift() + "\n"; - lastGeneratedLine++; - lastGeneratedColumn = 0; - } while (lastGeneratedLine < mapping.generatedLine); - // When we reached the correct line, we add code until we - // reach the correct column too. - if (lastGeneratedColumn < mapping.generatedColumn) { - var nextLine = remainingLines[0]; - code += nextLine.substr(0, mapping.generatedColumn); - remainingLines[0] = nextLine.substr(mapping.generatedColumn); - lastGeneratedColumn = mapping.generatedColumn; - } - // Create the SourceNode. - addMappingWithCode(lastMapping, code); - } else { - // There is no new line in between. - // Associate the code between "lastGeneratedColumn" and - // "mapping.generatedColumn" with "lastMapping" - var nextLine = remainingLines[0]; - var code = nextLine.substr(0, mapping.generatedColumn - - lastGeneratedColumn); - remainingLines[0] = nextLine.substr(mapping.generatedColumn - - lastGeneratedColumn); - lastGeneratedColumn = mapping.generatedColumn; - addMappingWithCode(lastMapping, code); - } - } - lastMapping = mapping; - }, this); - // We have processed all mappings. - // Associate the remaining code in the current line with "lastMapping" - // and add the remaining lines without any mapping - addMappingWithCode(lastMapping, remainingLines.join("\n")); - - // Copy sourcesContent into SourceNode - aSourceMapConsumer.sources.forEach(function (sourceFile) { - var content = aSourceMapConsumer.sourceContentFor(sourceFile); - if (content) { - node.setSourceContent(sourceFile, content); - } - }); - - return node; - - function addMappingWithCode(mapping, code) { - if (mapping === null || mapping.source === undefined) { - node.add(code); - } else { - node.add(new SourceNode(mapping.originalLine, - mapping.originalColumn, - mapping.source, - code, - mapping.name)); - } - } - }; - - /** - * Add a chunk of generated JS to this source node. - * - * @param aChunk A string snippet of generated JS code, another instance of - * SourceNode, or an array where each member is one of those things. - */ - SourceNode.prototype.add = function SourceNode_add(aChunk) { - if (Array.isArray(aChunk)) { - aChunk.forEach(function (chunk) { - this.add(chunk); - }, this); - } - else if (aChunk instanceof SourceNode || typeof aChunk === "string") { - if (aChunk) { - this.children.push(aChunk); - } - } - else { - throw new TypeError( - "Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk - ); - } - return this; - }; - - /** - * Add a chunk of generated JS to the beginning of this source node. - * - * @param aChunk A string snippet of generated JS code, another instance of - * SourceNode, or an array where each member is one of those things. - */ - SourceNode.prototype.prepend = function SourceNode_prepend(aChunk) { - if (Array.isArray(aChunk)) { - for (var i = aChunk.length-1; i >= 0; i--) { - this.prepend(aChunk[i]); - } - } - else if (aChunk instanceof SourceNode || typeof aChunk === "string") { - this.children.unshift(aChunk); - } - else { - throw new TypeError( - "Expected a SourceNode, string, or an array of SourceNodes and strings. Got " + aChunk - ); - } - return this; - }; - - /** - * Walk over the tree of JS snippets in this node and its children. The - * walking function is called once for each snippet of JS and is passed that - * snippet and the its original associated source's line/column location. - * - * @param aFn The traversal function. - */ - SourceNode.prototype.walk = function SourceNode_walk(aFn) { - var chunk; - for (var i = 0, len = this.children.length; i < len; i++) { - chunk = this.children[i]; - if (chunk instanceof SourceNode) { - chunk.walk(aFn); - } - else { - if (chunk !== '') { - aFn(chunk, { source: this.source, - line: this.line, - column: this.column, - name: this.name }); - } - } - } - }; - - /** - * Like `String.prototype.join` except for SourceNodes. Inserts `aStr` between - * each of `this.children`. - * - * @param aSep The separator. - */ - SourceNode.prototype.join = function SourceNode_join(aSep) { - var newChildren; - var i; - var len = this.children.length; - if (len > 0) { - newChildren = []; - for (i = 0; i < len-1; i++) { - newChildren.push(this.children[i]); - newChildren.push(aSep); - } - newChildren.push(this.children[i]); - this.children = newChildren; - } - return this; - }; - - /** - * Call String.prototype.replace on the very right-most source snippet. Useful - * for trimming whitespace from the end of a source node, etc. - * - * @param aPattern The pattern to replace. - * @param aReplacement The thing to replace the pattern with. - */ - SourceNode.prototype.replaceRight = function SourceNode_replaceRight(aPattern, aReplacement) { - var lastChild = this.children[this.children.length - 1]; - if (lastChild instanceof SourceNode) { - lastChild.replaceRight(aPattern, aReplacement); - } - else if (typeof lastChild === 'string') { - this.children[this.children.length - 1] = lastChild.replace(aPattern, aReplacement); - } - else { - this.children.push(''.replace(aPattern, aReplacement)); - } - return this; - }; - - /** - * Set the source content for a source file. This will be added to the SourceMapGenerator - * in the sourcesContent field. - * - * @param aSourceFile The filename of the source file - * @param aSourceContent The content of the source file - */ - SourceNode.prototype.setSourceContent = - function SourceNode_setSourceContent(aSourceFile, aSourceContent) { - this.sourceContents[util.toSetString(aSourceFile)] = aSourceContent; - }; - - /** - * Walk over the tree of SourceNodes. The walking function is called for each - * source file content and is passed the filename and source content. - * - * @param aFn The traversal function. - */ - SourceNode.prototype.walkSourceContents = - function SourceNode_walkSourceContents(aFn) { - for (var i = 0, len = this.children.length; i < len; i++) { - if (this.children[i] instanceof SourceNode) { - this.children[i].walkSourceContents(aFn); - } - } - - var sources = Object.keys(this.sourceContents); - for (var i = 0, len = sources.length; i < len; i++) { - aFn(util.fromSetString(sources[i]), this.sourceContents[sources[i]]); - } - }; - - /** - * Return the string representation of this source node. Walks over the tree - * and concatenates all the various snippets together to one string. - */ - SourceNode.prototype.toString = function SourceNode_toString() { - var str = ""; - this.walk(function (chunk) { - str += chunk; - }); - return str; - }; - - /** - * Returns the string representation of this source node along with a source - * map. - */ - SourceNode.prototype.toStringWithSourceMap = function SourceNode_toStringWithSourceMap(aArgs) { - var generated = { - code: "", - line: 1, - column: 0 - }; - var map = new SourceMapGenerator(aArgs); - var sourceMappingActive = false; - var lastOriginalSource = null; - var lastOriginalLine = null; - var lastOriginalColumn = null; - var lastOriginalName = null; - this.walk(function (chunk, original) { - generated.code += chunk; - if (original.source !== null - && original.line !== null - && original.column !== null) { - if(lastOriginalSource !== original.source - || lastOriginalLine !== original.line - || lastOriginalColumn !== original.column - || lastOriginalName !== original.name) { - map.addMapping({ - source: original.source, - original: { - line: original.line, - column: original.column - }, - generated: { - line: generated.line, - column: generated.column - }, - name: original.name - }); - } - lastOriginalSource = original.source; - lastOriginalLine = original.line; - lastOriginalColumn = original.column; - lastOriginalName = original.name; - sourceMappingActive = true; - } else if (sourceMappingActive) { - map.addMapping({ - generated: { - line: generated.line, - column: generated.column - } - }); - lastOriginalSource = null; - sourceMappingActive = false; - } - chunk.split('').forEach(function (ch) { - if (ch === '\n') { - generated.line++; - generated.column = 0; - } else { - generated.column++; - } - }); - }); - this.walkSourceContents(function (sourceFile, sourceContent) { - map.setSourceContent(sourceFile, sourceContent); - }); - - return { code: generated.code, map: map }; - }; - - exports.SourceNode = SourceNode; - -}); -/* -*- Mode: js; js-indent-level: 2; -*- */ -/////////////////////////////////////////////////////////////////////////////// - -this.sourceMap = { - SourceMapConsumer: require('source-map/source-map-consumer').SourceMapConsumer, - SourceMapGenerator: require('source-map/source-map-generator').SourceMapGenerator, - SourceNode: require('source-map/source-node').SourceNode -}; - -} diff --git a/examples/node_modules/react-native/Libraries/JavaScriptAppEngine/Initialization/loadSourceMap.js b/examples/node_modules/react-native/Libraries/JavaScriptAppEngine/Initialization/loadSourceMap.js deleted file mode 100644 index de96ad2b..00000000 --- a/examples/node_modules/react-native/Libraries/JavaScriptAppEngine/Initialization/loadSourceMap.js +++ /dev/null @@ -1,66 +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. - * - * @providesModule loadSourceMap - * @flow - */ - -'use strict'; - -var Promise = require('Promise'); -var NativeModules = require('NativeModules'); -var SourceMapConsumer = require('SourceMap').SourceMapConsumer; -var SourceMapURL = require('./source-map-url'); - -var RCTSourceCode = NativeModules.SourceCode; -var RCTNetworking = NativeModules.Networking; - -function loadSourceMap(): Promise { - return fetchSourceMap() - .then(map => new SourceMapConsumer(map)); -} - -function fetchSourceMap(): Promise { - if (global.RAW_SOURCE_MAP) { - return Promise.resolve(global.RAW_SOURCE_MAP); - } - - if (!RCTSourceCode) { - return Promise.reject(new Error('RCTSourceCode module is not available')); - } - - if (!RCTNetworking) { - // Used internally by fetch - return Promise.reject(new Error('RCTNetworking module is not available')); - } - - return new Promise(RCTSourceCode.getScriptText) - .then(extractSourceMapURL) - .then((url) => { - if (url === null) { - return Promise.reject(new Error('No source map URL found. May be running from bundled file.')); - } - return Promise.resolve(url); - }) - .then(fetch) - .then(response => response.text()); -} - -function extractSourceMapURL({url, text, fullSourceMappingURL}): ?string { - if (fullSourceMappingURL) { - return fullSourceMappingURL; - } - var mapURL = SourceMapURL.getFrom(text); - if (!mapURL) { - return null; - } - var baseURL = url.match(/(.+:\/\/.*?)\//)[1]; - return baseURL + mapURL; -} - -module.exports = loadSourceMap; diff --git a/examples/node_modules/react-native/Libraries/JavaScriptAppEngine/Initialization/parseErrorStack.js b/examples/node_modules/react-native/Libraries/JavaScriptAppEngine/Initialization/parseErrorStack.js deleted file mode 100644 index 63076c7b..00000000 --- a/examples/node_modules/react-native/Libraries/JavaScriptAppEngine/Initialization/parseErrorStack.js +++ /dev/null @@ -1,49 +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. - * - * @providesModule parseErrorStack - */ -'use strict'; - -var stacktraceParser = require('stacktrace-parser'); - -function resolveSourceMaps(sourceMapInstance, stackFrame) { - try { - var orig = sourceMapInstance.originalPositionFor({ - line: stackFrame.lineNumber, - column: stackFrame.column, - }); - if (orig) { - stackFrame.file = orig.source; - stackFrame.lineNumber = orig.line; - stackFrame.column = orig.column; - } - } catch (innerEx) { - } -} - -function parseErrorStack(e, sourceMapInstance) { - if (!e || !e.stack) { - return []; - } - - var stack = Array.isArray(e.stack) ? e.stack : stacktraceParser.parse(e.stack); - - var framesToPop = e.framesToPop || 0; - while (framesToPop--) { - stack.shift(); - } - - if (sourceMapInstance) { - stack.forEach(resolveSourceMaps.bind(null, sourceMapInstance)); - } - - return stack; -} - -module.exports = parseErrorStack; diff --git a/examples/node_modules/react-native/Libraries/JavaScriptAppEngine/Initialization/source-map-url.js b/examples/node_modules/react-native/Libraries/JavaScriptAppEngine/Initialization/source-map-url.js deleted file mode 100644 index 8342a5a9..00000000 --- a/examples/node_modules/react-native/Libraries/JavaScriptAppEngine/Initialization/source-map-url.js +++ /dev/null @@ -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 = /[#@] sourceMappingURL=([^\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 */ - -})(); diff --git a/examples/node_modules/react-native/Libraries/JavaScriptAppEngine/System/JSTimers/JSTimers.js b/examples/node_modules/react-native/Libraries/JavaScriptAppEngine/System/JSTimers/JSTimers.js deleted file mode 100644 index f6a8bddc..00000000 --- a/examples/node_modules/react-native/Libraries/JavaScriptAppEngine/System/JSTimers/JSTimers.js +++ /dev/null @@ -1,137 +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. - * - * @providesModule JSTimers - */ -'use strict'; - -// Note that the module JSTimers is split into two in order to solve a cycle -// in dependencies. NativeModules > BatchedBridge > MessageQueue > JSTimersExecution -var RCTTiming = require('NativeModules').Timing; -var JSTimersExecution = require('JSTimersExecution'); - -/** - * JS implementation of timer functions. Must be completely driven by an - * external clock signal, all that's stored here is timerID, timer type, and - * callback. - */ -var JSTimers = { - Types: JSTimersExecution.Types, - - /** - * Returns a free index if one is available, and the next consecutive index - * otherwise. - */ - _getFreeIndex: function() { - var freeIndex = JSTimersExecution.timerIDs.indexOf(null); - if (freeIndex === -1) { - freeIndex = JSTimersExecution.timerIDs.length; - } - return freeIndex; - }, - - /** - * @param {function} func Callback to be invoked after `duration` ms. - * @param {number} duration Number of milliseconds. - */ - setTimeout: function(func, duration, ...args) { - var newID = JSTimersExecution.GUID++; - var freeIndex = JSTimers._getFreeIndex(); - JSTimersExecution.timerIDs[freeIndex] = newID; - JSTimersExecution.callbacks[freeIndex] = function() { - return func.apply(undefined, args); - }; - JSTimersExecution.types[freeIndex] = JSTimersExecution.Type.setTimeout; - RCTTiming.createTimer(newID, duration || 0, Date.now(), /** recurring */ false); - return newID; - }, - - /** - * @param {function} func Callback to be invoked every `duration` ms. - * @param {number} duration Number of milliseconds. - */ - setInterval: function(func, duration, ...args) { - var newID = JSTimersExecution.GUID++; - var freeIndex = JSTimers._getFreeIndex(); - JSTimersExecution.timerIDs[freeIndex] = newID; - JSTimersExecution.callbacks[freeIndex] = function() { - return func.apply(undefined, args); - }; - JSTimersExecution.types[freeIndex] = JSTimersExecution.Type.setInterval; - RCTTiming.createTimer(newID, duration || 0, Date.now(), /** recurring */ true); - return newID; - }, - - /** - * @param {function} func Callback to be invoked before the end of the - * current JavaScript execution loop. - */ - setImmediate: function(func, ...args) { - var newID = JSTimersExecution.GUID++; - var freeIndex = JSTimers._getFreeIndex(); - JSTimersExecution.timerIDs[freeIndex] = newID; - JSTimersExecution.callbacks[freeIndex] = function() { - return func.apply(undefined, args); - }; - JSTimersExecution.types[freeIndex] = JSTimersExecution.Type.setImmediate; - JSTimersExecution.immediates.push(newID); - return newID; - }, - - /** - * @param {function} func Callback to be invoked every frame. - */ - requestAnimationFrame: function(func) { - var newID = JSTimersExecution.GUID++; - var freeIndex = JSTimers._getFreeIndex(); - JSTimersExecution.timerIDs[freeIndex] = newID; - JSTimersExecution.callbacks[freeIndex] = func; - JSTimersExecution.types[freeIndex] = JSTimersExecution.Type.requestAnimationFrame; - RCTTiming.createTimer(newID, 1, Date.now(), /** recurring */ false); - return newID; - }, - - clearTimeout: function(timerID) { - JSTimers._clearTimerID(timerID); - }, - - clearInterval: function(timerID) { - JSTimers._clearTimerID(timerID); - }, - - clearImmediate: function(timerID) { - JSTimers._clearTimerID(timerID); - JSTimersExecution.immediates.splice( - JSTimersExecution.immediates.indexOf(timerID), - 1 - ); - }, - - cancelAnimationFrame: function(timerID) { - JSTimers._clearTimerID(timerID); - }, - - _clearTimerID: function(timerID) { - // JSTimersExecution.timerIDs contains nulls after timers have been removed; - // ignore nulls upfront so indexOf doesn't find them - if (timerID == null) { - return; - } - - var index = JSTimersExecution.timerIDs.indexOf(timerID); - // See corresponding comment in `callTimers` for reasoning behind this - if (index !== -1) { - JSTimersExecution._clearIndex(index); - if (JSTimersExecution.types[index] !== JSTimersExecution.Type.setImmediate) { - RCTTiming.deleteTimer(timerID); - } - } - }, -}; - -module.exports = JSTimers; diff --git a/examples/node_modules/react-native/Libraries/JavaScriptAppEngine/System/JSTimers/JSTimersExecution.js b/examples/node_modules/react-native/Libraries/JavaScriptAppEngine/System/JSTimers/JSTimersExecution.js deleted file mode 100644 index 07a324d4..00000000 --- a/examples/node_modules/react-native/Libraries/JavaScriptAppEngine/System/JSTimers/JSTimersExecution.js +++ /dev/null @@ -1,157 +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. - * - * @providesModule JSTimersExecution - */ -'use strict'; - -var invariant = require('invariant'); -var keyMirror = require('keyMirror'); -var performanceNow = require('performanceNow'); -var warning = require('warning'); -var BridgeProfiling = require('BridgeProfiling'); - -/** - * JS implementation of timer functions. Must be completely driven by an - * external clock signal, all that's stored here is timerID, timer type, and - * callback. - */ -var JSTimersExecution = { - GUID: 1, - Type: keyMirror({ - setTimeout: null, - setInterval: null, - requestAnimationFrame: null, - setImmediate: null, - }), - - // Parallel arrays: - callbacks: [], - types: [], - timerIDs: [], - immediates: [], - - /** - * Calls the callback associated with the ID. Also unregister that callback - * if it was a one time timer (setTimeout), and not unregister it if it was - * recurring (setInterval). - */ - callTimer: function(timerID) { - warning(timerID <= JSTimersExecution.GUID, 'Tried to call timer with ID ' + timerID + ' but no such timer exists'); - var timerIndex = JSTimersExecution.timerIDs.indexOf(timerID); - // timerIndex of -1 means that no timer with that ID exists. There are - // two situations when this happens, when a garbage timer ID was given - // and when a previously existing timer was deleted before this callback - // fired. In both cases we want to ignore the timer id, but in the former - // case we warn as well. - if (timerIndex === -1) { - return; - } - var type = JSTimersExecution.types[timerIndex]; - var callback = JSTimersExecution.callbacks[timerIndex]; - - // Clear the metadata - if (type === JSTimersExecution.Type.setTimeout || - type === JSTimersExecution.Type.setImmediate || - type === JSTimersExecution.Type.requestAnimationFrame) { - JSTimersExecution._clearIndex(timerIndex); - } - - try { - if (type === JSTimersExecution.Type.setTimeout || - type === JSTimersExecution.Type.setInterval || - type === JSTimersExecution.Type.setImmediate) { - callback(); - } else if (type === JSTimersExecution.Type.requestAnimationFrame) { - var currentTime = performanceNow(); - callback(currentTime); - } else { - console.error('Tried to call a callback with invalid type: ' + type); - return; - } - } catch (e) { - // Don't rethrow so that we can run every other timer. - JSTimersExecution.errors = JSTimersExecution.errors || []; - JSTimersExecution.errors.push(e); - } - }, - - /** - * This is called from the native side. We are passed an array of timerIDs, - * and - */ - callTimers: function(timerIDs) { - invariant(timerIDs.length !== 0, 'Probably shouldn\'t call "callTimers" with no timerIDs'); - - JSTimersExecution.errors = null; - timerIDs.forEach(JSTimersExecution.callTimer); - - var errors = JSTimersExecution.errors; - if (errors) { - var errorCount = errors.length; - if (errorCount > 1) { - // Throw all the other errors in a setTimeout, which will throw each - // error one at a time - for (var ii = 1; ii < errorCount; ii++) { - require('JSTimers').setTimeout( - ((error) => { throw error; }).bind(null, errors[ii]), - 0 - ); - } - } - throw errors[0]; - } - }, - - /** - * Performs a single pass over the enqueued immediates. Returns whether - * more immediates are queued up (can be used as a condition a while loop). - */ - callImmediatesPass: function() { - BridgeProfiling.profile('JSTimersExecution.callImmediatesPass()'); - - // The main reason to extract a single pass is so that we can track - // in the system trace - if (JSTimersExecution.immediates.length > 0) { - var passImmediates = JSTimersExecution.immediates.slice(); - JSTimersExecution.immediates = []; - - // Use for loop rather than forEach as per @vjeux's advice - // https://github.com/facebook/react-native/commit/c8fd9f7588ad02d2293cac7224715f4af7b0f352#commitcomment-14570051 - for (var i = 0; i < passImmediates.length; ++i) { - JSTimersExecution.callTimer(passImmediates[i]); - } - } - - BridgeProfiling.profileEnd(); - - return JSTimersExecution.immediates.length > 0; - }, - - /** - * This is called after we execute any command we receive from native but - * before we hand control back to native. - */ - callImmediates: function() { - JSTimersExecution.errors = null; - while (JSTimersExecution.callImmediatesPass()) {} - if (JSTimersExecution.errors) { - JSTimersExecution.errors.forEach((error) => - require('JSTimers').setTimeout(() => { throw error; }, 0) - ); - } - }, - - _clearIndex: function(i) { - JSTimersExecution.timerIDs[i] = null; - JSTimersExecution.callbacks[i] = null; - JSTimersExecution.types[i] = null; - }, -}; - -module.exports = JSTimersExecution; diff --git a/examples/node_modules/react-native/Libraries/LinkingIOS/LinkingIOS.js b/examples/node_modules/react-native/Libraries/LinkingIOS/LinkingIOS.js deleted file mode 100644 index 1d186ccb..00000000 --- a/examples/node_modules/react-native/Libraries/LinkingIOS/LinkingIOS.js +++ /dev/null @@ -1,172 +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. - * - * @providesModule LinkingIOS - * @flow - */ -'use strict'; - -var RCTDeviceEventEmitter = require('RCTDeviceEventEmitter'); -var RCTLinkingManager = require('NativeModules').LinkingManager; -var Map = require('Map'); -var invariant = require('invariant'); - -var _notifHandlers = new Map(); -var _initialURL = RCTLinkingManager && - RCTLinkingManager.initialURL; - -var DEVICE_NOTIF_EVENT = 'openURL'; - -/** - * `LinkingIOS` gives you a general interface to interact with both incoming - * and outgoing app links. - * - * ### Basic Usage - * - * #### Handling deep links - * - * If your app was launched from an external url registered to your app you can - * access and handle it from any component you want with - * - * ``` - * componentDidMount() { - * var url = LinkingIOS.popInitialURL(); - * } - * ``` - * - * In case you also want to listen to incoming app links during your app's - * execution you'll need to add the following lines to you `*AppDelegate.m`: - * - * ``` - * - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url - * sourceApplication:(NSString *)sourceApplication annotation:(id)annotation - * { - * return [RCTLinkingManager application:application openURL:url - * sourceApplication:sourceApplication annotation:annotation]; - * } - * - * // Only if your app is using [Universal Links](https://developer.apple.com/library/prerelease/ios/documentation/General/Conceptual/AppSearch/UniversalLinks.html). - * - (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity - * restorationHandler:(void (^)(NSArray * _Nullable))restorationHandler - * { - * return [RCTLinkingManager application:application - * continueUserActivity:userActivity - * restorationHandler:restorationHandler]; - * } - * - * ``` - * - * And then on your React component you'll be able to listen to the events on - * `LinkingIOS` as follows - * - * ``` - * componentDidMount() { - * LinkingIOS.addEventListener('url', this._handleOpenURL); - * }, - * componentWillUnmount() { - * LinkingIOS.removeEventListener('url', this._handleOpenURL); - * }, - * _handleOpenURL(event) { - * console.log(event.url); - * } - * ``` - * - * #### Triggering App links - * - * To trigger an app link (browser, email or custom schemas), call - * - * ``` - * LinkingIOS.openURL(url) - * ``` - * - * If you want to check if any installed app can handle a given URL beforehand, call - * ``` - * LinkingIOS.canOpenURL(url, (supported) => { - * if (!supported) { - * AlertIOS.alert('Can\'t handle url: ' + url); - * } else { - * LinkingIOS.openURL(url); - * } - * }); - * ``` - */ -class LinkingIOS { - /** - * Add a handler to LinkingIOS changes by listening to the `url` event type - * and providing the handler - */ - static addEventListener(type: string, handler: Function) { - invariant( - type === 'url', - 'LinkingIOS only supports `url` events' - ); - var listener = RCTDeviceEventEmitter.addListener( - DEVICE_NOTIF_EVENT, - handler - ); - _notifHandlers.set(handler, listener); - } - - /** - * Remove a handler by passing the `url` event type and the handler - */ - static removeEventListener(type: string, handler: Function ) { - invariant( - type === 'url', - 'LinkingIOS only supports `url` events' - ); - var listener = _notifHandlers.get(handler); - if (!listener) { - return; - } - listener.remove(); - _notifHandlers.delete(handler); - } - - /** - * Try to open the given `url` with any of the installed apps. - */ - static openURL(url: string) { - invariant( - typeof url === 'string', - 'Invalid url: should be a string' - ); - RCTLinkingManager.openURL(url); - } - - /** - * Determine whether or not an installed app can handle a given URL. - * The callback function will be called with `bool supported` as the only argument - * - * NOTE: As of iOS 9, your app needs to provide the `LSApplicationQueriesSchemes` key - * inside `Info.plist`. - */ - static canOpenURL(url: string, callback: Function) { - invariant( - typeof url === 'string', - 'Invalid url: should be a string' - ); - invariant( - typeof callback === 'function', - 'A valid callback function is required' - ); - RCTLinkingManager.canOpenURL(url, callback); - } - - /** - * If the app launch was triggered by an app link, it will pop the link url, - * otherwise it will return `null` - */ - static popInitialURL(): ?string { - var initialURL = _initialURL; - _initialURL = null; - return initialURL; - } -} - -module.exports = LinkingIOS; diff --git a/examples/node_modules/react-native/Libraries/LinkingIOS/RCTLinking.xcodeproj/project.pbxproj b/examples/node_modules/react-native/Libraries/LinkingIOS/RCTLinking.xcodeproj/project.pbxproj deleted file mode 100644 index 844d94cf..00000000 --- a/examples/node_modules/react-native/Libraries/LinkingIOS/RCTLinking.xcodeproj/project.pbxproj +++ /dev/null @@ -1,252 +0,0 @@ -// !$*UTF8*$! -{ - archiveVersion = 1; - classes = { - }; - objectVersion = 46; - objects = { - -/* Begin PBXBuildFile section */ - 148699CF1ABD045300480536 /* RCTLinkingManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 148699CE1ABD045300480536 /* RCTLinkingManager.m */; }; -/* End PBXBuildFile section */ - -/* Begin PBXCopyFilesBuildPhase section */ - 58B511D91A9E6C8500147676 /* CopyFiles */ = { - isa = PBXCopyFilesBuildPhase; - buildActionMask = 2147483647; - dstPath = "include/$(PRODUCT_NAME)"; - dstSubfolderSpec = 16; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXCopyFilesBuildPhase section */ - -/* Begin PBXFileReference section */ - 134814201AA4EA6300B7C361 /* libRCTLinking.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRCTLinking.a; sourceTree = BUILT_PRODUCTS_DIR; }; - 148699CD1ABD045300480536 /* RCTLinkingManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTLinkingManager.h; sourceTree = ""; }; - 148699CE1ABD045300480536 /* RCTLinkingManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTLinkingManager.m; sourceTree = ""; }; -/* End PBXFileReference section */ - -/* Begin PBXFrameworksBuildPhase section */ - 58B511D81A9E6C8500147676 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXFrameworksBuildPhase section */ - -/* Begin PBXGroup section */ - 134814211AA4EA7D00B7C361 /* Products */ = { - isa = PBXGroup; - children = ( - 134814201AA4EA6300B7C361 /* libRCTLinking.a */, - ); - name = Products; - sourceTree = ""; - }; - 58B511D21A9E6C8500147676 = { - isa = PBXGroup; - children = ( - 148699CD1ABD045300480536 /* RCTLinkingManager.h */, - 148699CE1ABD045300480536 /* RCTLinkingManager.m */, - 134814211AA4EA7D00B7C361 /* Products */, - ); - sourceTree = ""; - }; -/* End PBXGroup section */ - -/* Begin PBXNativeTarget section */ - 58B511DA1A9E6C8500147676 /* RCTLinking */ = { - isa = PBXNativeTarget; - buildConfigurationList = 58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "RCTLinking" */; - buildPhases = ( - 58B511D71A9E6C8500147676 /* Sources */, - 58B511D81A9E6C8500147676 /* Frameworks */, - 58B511D91A9E6C8500147676 /* CopyFiles */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = RCTLinking; - productName = RCTDataManager; - productReference = 134814201AA4EA6300B7C361 /* libRCTLinking.a */; - productType = "com.apple.product-type.library.static"; - }; -/* End PBXNativeTarget section */ - -/* Begin PBXProject section */ - 58B511D31A9E6C8500147676 /* Project object */ = { - isa = PBXProject; - attributes = { - LastUpgradeCheck = 0610; - ORGANIZATIONNAME = Facebook; - TargetAttributes = { - 58B511DA1A9E6C8500147676 = { - CreatedOnToolsVersion = 6.1.1; - }; - }; - }; - buildConfigurationList = 58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "RCTLinking" */; - compatibilityVersion = "Xcode 3.2"; - developmentRegion = English; - hasScannedForEncodings = 0; - knownRegions = ( - en, - ); - mainGroup = 58B511D21A9E6C8500147676; - productRefGroup = 58B511D21A9E6C8500147676; - projectDirPath = ""; - projectRoot = ""; - targets = ( - 58B511DA1A9E6C8500147676 /* RCTLinking */, - ); - }; -/* End PBXProject section */ - -/* Begin PBXSourcesBuildPhase section */ - 58B511D71A9E6C8500147676 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 148699CF1ABD045300480536 /* RCTLinkingManager.m in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXSourcesBuildPhase section */ - -/* Begin XCBuildConfiguration section */ - 58B511ED1A9E6C8500147676 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - COPY_PHASE_STRIP = NO; - ENABLE_STRICT_OBJC_MSGSEND = YES; - GCC_C_LANGUAGE_STANDARD = gnu99; - GCC_DYNAMIC_NO_PIC = NO; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", - "$(inherited)", - ); - GCC_SYMBOLS_PRIVATE_EXTERN = NO; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_SHADOW = YES; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 7.0; - MTL_ENABLE_DEBUG_INFO = YES; - ONLY_ACTIVE_ARCH = YES; - SDKROOT = iphoneos; - }; - name = Debug; - }; - 58B511EE1A9E6C8500147676 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - COPY_PHASE_STRIP = YES; - ENABLE_NS_ASSERTIONS = NO; - ENABLE_STRICT_OBJC_MSGSEND = YES; - GCC_C_LANGUAGE_STANDARD = gnu99; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_SHADOW = YES; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 7.0; - MTL_ENABLE_DEBUG_INFO = NO; - SDKROOT = iphoneos; - VALIDATE_PRODUCT = YES; - }; - name = Release; - }; - 58B511F01A9E6C8500147676 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - HEADER_SEARCH_PATHS = ( - "$(inherited)", - /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, - "$(SRCROOT)/../../React/**", - ); - LIBRARY_SEARCH_PATHS = "$(inherited)"; - OTHER_LDFLAGS = "-ObjC"; - PRODUCT_NAME = RCTLinking; - SKIP_INSTALL = YES; - }; - name = Debug; - }; - 58B511F11A9E6C8500147676 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - HEADER_SEARCH_PATHS = ( - "$(inherited)", - /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, - "$(SRCROOT)/../../React/**", - ); - LIBRARY_SEARCH_PATHS = "$(inherited)"; - OTHER_LDFLAGS = "-ObjC"; - PRODUCT_NAME = RCTLinking; - SKIP_INSTALL = YES; - }; - name = Release; - }; -/* End XCBuildConfiguration section */ - -/* Begin XCConfigurationList section */ - 58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "RCTLinking" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 58B511ED1A9E6C8500147676 /* Debug */, - 58B511EE1A9E6C8500147676 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "RCTLinking" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 58B511F01A9E6C8500147676 /* Debug */, - 58B511F11A9E6C8500147676 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; -/* End XCConfigurationList section */ - }; - rootObject = 58B511D31A9E6C8500147676 /* Project object */; -} diff --git a/examples/node_modules/react-native/Libraries/LinkingIOS/RCTLinking.xcodeproj/xcuserdata/yuji.xcuserdatad/xcschemes/xcschememanagement.plist b/examples/node_modules/react-native/Libraries/LinkingIOS/RCTLinking.xcodeproj/xcuserdata/yuji.xcuserdatad/xcschemes/xcschememanagement.plist deleted file mode 100644 index d76e5628..00000000 --- a/examples/node_modules/react-native/Libraries/LinkingIOS/RCTLinking.xcodeproj/xcuserdata/yuji.xcuserdatad/xcschemes/xcschememanagement.plist +++ /dev/null @@ -1,22 +0,0 @@ - - - - - SchemeUserState - - RCTLinking.xcscheme - - orderHint - 5 - - - SuppressBuildableAutocreation - - 58B511DA1A9E6C8500147676 - - primary - - - - - diff --git a/examples/node_modules/react-native/Libraries/LinkingIOS/RCTLinkingManager.h b/examples/node_modules/react-native/Libraries/LinkingIOS/RCTLinkingManager.h deleted file mode 100644 index 092ca990..00000000 --- a/examples/node_modules/react-native/Libraries/LinkingIOS/RCTLinkingManager.h +++ /dev/null @@ -1,25 +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. - */ - -#import - -#import "RCTBridgeModule.h" - -@interface RCTLinkingManager : NSObject - -+ (BOOL)application:(UIApplication *)application - openURL:(NSURL *)URL - sourceApplication:(NSString *)sourceApplication - annotation:(id)annotation; - -+ (BOOL)application:(UIApplication *)application -continueUserActivity:(NSUserActivity *)userActivity - restorationHandler:(void (^)(NSArray *))restorationHandler; - -@end diff --git a/examples/node_modules/react-native/Libraries/LinkingIOS/RCTLinkingManager.m b/examples/node_modules/react-native/Libraries/LinkingIOS/RCTLinkingManager.m deleted file mode 100644 index 749d2c27..00000000 --- a/examples/node_modules/react-native/Libraries/LinkingIOS/RCTLinkingManager.m +++ /dev/null @@ -1,98 +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. - */ - -#import "RCTLinkingManager.h" - -#import "RCTBridge.h" -#import "RCTEventDispatcher.h" -#import "RCTUtils.h" - -NSString *const RCTOpenURLNotification = @"RCTOpenURLNotification"; - -@implementation RCTLinkingManager - -@synthesize bridge = _bridge; - -RCT_EXPORT_MODULE() - -- (void)setBridge:(RCTBridge *)bridge -{ - _bridge = bridge; - - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(handleOpenURLNotification:) - name:RCTOpenURLNotification - object:nil]; -} - -- (NSDictionary *)constantsToExport -{ - NSURL *initialURL = _bridge.launchOptions[UIApplicationLaunchOptionsURLKey]; - return @{@"initialURL": RCTNullIfNil(initialURL.absoluteString)}; -} - -- (void)dealloc -{ - [[NSNotificationCenter defaultCenter] removeObserver:self]; -} - -+ (BOOL)application:(UIApplication *)application - openURL:(NSURL *)URL - sourceApplication:(NSString *)sourceApplication - annotation:(id)annotation -{ - NSDictionary *payload = @{@"url": URL.absoluteString}; - [[NSNotificationCenter defaultCenter] postNotificationName:RCTOpenURLNotification - object:self - userInfo:payload]; - return YES; -} - -+ (BOOL)application:(UIApplication *)application -continueUserActivity:(NSUserActivity *)userActivity - restorationHandler:(void (^)(NSArray *))restorationHandler -{ - if ([userActivity.activityType isEqualToString:NSUserActivityTypeBrowsingWeb]) { - NSDictionary *payload = @{@"url": userActivity.webpageURL.absoluteString}; - [[NSNotificationCenter defaultCenter] postNotificationName:RCTOpenURLNotification - object:self - userInfo:payload]; - } - return YES; -} - -- (void)handleOpenURLNotification:(NSNotification *)notification -{ - [_bridge.eventDispatcher sendDeviceEventWithName:@"openURL" - body:notification.userInfo]; -} - -RCT_EXPORT_METHOD(openURL:(NSURL *)URL) -{ - // TODO: we should really return success/failure via a callback here - // Doesn't really matter what thread we call this on since it exits the app - [RCTSharedApplication() openURL:URL]; -} - -RCT_EXPORT_METHOD(canOpenURL:(NSURL *)URL - callback:(RCTResponseSenderBlock)callback) -{ - if (RCTRunningInAppExtension()) { - // Technically Today widgets can open urls, but supporting that would require - // a reference to the NSExtensionContext - callback(@[@NO]); - return; - } - - // This can be expensive, so we deliberately don't call on main thread - BOOL canOpen = [RCTSharedApplication() canOpenURL:URL]; - callback(@[@(canOpen)]); -} - -@end diff --git a/examples/node_modules/react-native/Libraries/Network/NetInfo.js b/examples/node_modules/react-native/Libraries/Network/NetInfo.js deleted file mode 100644 index fff16c59..00000000 --- a/examples/node_modules/react-native/Libraries/Network/NetInfo.js +++ /dev/null @@ -1,248 +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. - * - * @providesModule NetInfo - * @flow - */ -'use strict'; - -const Map = require('Map'); -const NativeModules = require('NativeModules'); -const Platform = require('Platform'); -const RCTDeviceEventEmitter = require('RCTDeviceEventEmitter'); -const RCTNetInfo = NativeModules.NetInfo; - -const DEVICE_CONNECTIVITY_EVENT = 'networkStatusDidChange'; - -type ChangeEventName = $Enum<{ - change: string; -}>; - -type ReachabilityStateIOS = $Enum<{ - cell: string; - none: string; - unknown: string; - wifi: string; -}>; - -type ConnectivityStateAndroid = $Enum<{ - NONE: string; - MOBILE: string; - WIFI: string; - MOBILE_MMS: string; - MOBILE_SUPL: string; - MOBILE_DUN: string; - MOBILE_HIPRI: string; - WIMAX: string; - BLUETOOTH: string; - DUMMY: string; - ETHERNET: string; - MOBILE_FOTA: string; - MOBILE_IMS: string; - MOBILE_CBS: string; - WIFI_P2P: string; - MOBILE_IA: string; - MOBILE_EMERGENCY: string; - PROXY: string; - VPN: string; - UNKNOWN: string; -}>; - - -const _subscriptions = new Map(); - -let _isConnected; -if (Platform.OS === 'ios') { - _isConnected = function( - reachability: ReachabilityStateIOS, - ): bool { - return reachability !== 'none' && reachability !== 'unknown'; - }; -} else if (Platform.OS === 'android') { - _isConnected = function( - connectionType: ConnectivityStateAndroid, - ): bool { - return connectionType !== 'NONE' && connectionType !== 'UNKNOWN'; - }; -} - -const _isConnectedSubscriptions = new Map(); - -/** - * NetInfo exposes info about online/offline status - * - * ``` - * NetInfo.fetch().done((reach) => { - * console.log('Initial: ' + reach); - * }); - * function handleFirstConnectivityChange(reach) { - * console.log('First change: ' + reach); - * NetInfo.removeEventListener( - * 'change', - * handleFirstConnectivityChange - * ); - * } - * NetInfo.addEventListener( - * 'change', - * handleFirstConnectivityChange - * ); - * ``` - * - * ### IOS - * - * Asynchronously determine if the device is online and on a cellular network. - * - * - `none` - device is offline - * - `wifi` - device is online and connected via wifi, or is the iOS simulator - * - `cell` - device is connected via Edge, 3G, WiMax, or LTE - * - `unknown` - error case and the network status is unknown - * - * ### Android - * - * To request network info, you need to add the following line to your - * app's `AndroidManifest.xml`: - * - * `` - * Asynchronously determine if the device is connected and details about that connection. - * - * Android Connectivity Types. - * - * - `NONE` - device is offline - * - `BLUETOOTH` - The Bluetooth data connection. - * - `DUMMY` - Dummy data connection. - * - `ETHERNET` - The Ethernet data connection. - * - `MOBILE` - The Mobile data connection. - * - `MOBILE_DUN` - A DUN-specific Mobile data connection. - * - `MOBILE_HIPRI` - A High Priority Mobile data connection. - * - `MOBILE_MMS` - An MMS-specific Mobile data connection. - * - `MOBILE_SUPL` - A SUPL-specific Mobile data connection. - * - `VPN` - A virtual network using one or more native bearers. Requires API Level 21 - * - `WIFI` - The WIFI data connection. - * - `WIMAX` - The WiMAX data connection. - * - `UNKNOWN` - Unknown data connection. - * - * The rest ConnectivityStates are hidden by the Android API, but can be used if necessary. - * - * ### isConnectionExpensive - * - * Available on Android. Detect if the current active connection is metered or not. A network is - * classified as metered when the user is sensitive to heavy data usage on that connection due to - * monetary costs, data limitations or battery/performance issues. - * - * ``` - * NetInfo.isConnectionExpensive((isConnectionExpensive) => { - * console.log('Connection is ' + (isConnectionExpensive ? 'Expensive' : 'Not Expensive')); - * }); - * ``` - * - * ### isConnected - * - * Available on all platforms. Asynchronously fetch a boolean to determine - * internet connectivity. - * - * ``` - * NetInfo.isConnected.fetch().done((isConnected) => { - * console.log('First, is ' + (isConnected ? 'online' : 'offline')); - * }); - * function handleFirstConnectivityChange(isConnected) { - * console.log('Then, is ' + (isConnected ? 'online' : 'offline')); - * NetInfo.isConnected.removeEventListener( - * 'change', - * handleFirstConnectivityChange - * ); - * } - * NetInfo.isConnected.addEventListener( - * 'change', - * handleFirstConnectivityChange - * ); - * ``` - */ -const NetInfo = { - addEventListener( - eventName: ChangeEventName, - handler: Function - ): void { - const listener = RCTDeviceEventEmitter.addListener( - DEVICE_CONNECTIVITY_EVENT, - (appStateData) => { - handler(appStateData.network_info); - } - ); - _subscriptions.set(handler, listener); - }, - - removeEventListener( - eventName: ChangeEventName, - handler: Function - ): void { - const listener = _subscriptions.get(handler); - if (!listener) { - return; - } - listener.remove(); - _subscriptions.delete(handler); - }, - - fetch(): Promise { - return new Promise((resolve, reject) => { - RCTNetInfo.getCurrentConnectivity( - function(resp) { - resolve(resp.network_info); - }, - reject - ); - }); - }, - - isConnected: { - addEventListener( - eventName: ChangeEventName, - handler: Function - ): void { - const listener = (connection) => { - handler(_isConnected(connection)); - }; - _isConnectedSubscriptions.set(handler, listener); - NetInfo.addEventListener( - eventName, - listener - ); - }, - - removeEventListener( - eventName: ChangeEventName, - handler: Function - ): void { - const listener = _isConnectedSubscriptions.get(handler); - NetInfo.removeEventListener( - eventName, - listener - ); - _isConnectedSubscriptions.delete(handler); - }, - - fetch(): Promise { - return NetInfo.fetch().then( - (connection) => _isConnected(connection) - ); - }, - }, - - isConnectionExpensive(callback: (metered: ?boolean, error?: string) => void): void { - if (Platform.OS === 'android') { - RCTNetInfo.isConnectionMetered((_isMetered) => { - callback(_isMetered); - }); - } else { - // TODO t9296080 consider polyfill and more features later on - callback(null, "Unsupported"); - } - }, -}; - -module.exports = NetInfo; diff --git a/examples/node_modules/react-native/Libraries/Network/RCTNetwork.xcodeproj/project.pbxproj b/examples/node_modules/react-native/Libraries/Network/RCTNetwork.xcodeproj/project.pbxproj deleted file mode 100644 index f0f23f9b..00000000 --- a/examples/node_modules/react-native/Libraries/Network/RCTNetwork.xcodeproj/project.pbxproj +++ /dev/null @@ -1,299 +0,0 @@ -// !$*UTF8*$! -{ - archiveVersion = 1; - classes = { - }; - objectVersion = 46; - objects = { - -/* Begin PBXBuildFile section */ - 134E969A1BCEB7F800AFFDA1 /* RCTDataRequestHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = 134E96991BCEB7F800AFFDA1 /* RCTDataRequestHandler.m */; settings = {ASSET_TAGS = (); }; }; - 1372B7371AB03E7B00659ED6 /* RCTNetInfo.m in Sources */ = {isa = PBXBuildFile; fileRef = 1372B7361AB03E7B00659ED6 /* RCTNetInfo.m */; }; - 13D6D66A1B5FCF8200883BE9 /* RCTNetworkTask.m in Sources */ = {isa = PBXBuildFile; fileRef = 13D6D6691B5FCF8200883BE9 /* RCTNetworkTask.m */; }; - 13EF800E1BCBE015003F47DD /* RCTFileRequestHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = 13EF800D1BCBE015003F47DD /* RCTFileRequestHandler.m */; settings = {ASSET_TAGS = (); }; }; - 352DA0BA1B17855800AA15A8 /* RCTHTTPRequestHandler.m in Sources */ = {isa = PBXBuildFile; fileRef = 352DA0B81B17855800AA15A8 /* RCTHTTPRequestHandler.m */; }; - 58B512081A9E6CE300147676 /* RCTNetworking.m in Sources */ = {isa = PBXBuildFile; fileRef = 58B512071A9E6CE300147676 /* RCTNetworking.m */; }; -/* End PBXBuildFile section */ - -/* Begin PBXCopyFilesBuildPhase section */ - 58B511D91A9E6C8500147676 /* CopyFiles */ = { - isa = PBXCopyFilesBuildPhase; - buildActionMask = 2147483647; - dstPath = "include/$(PRODUCT_NAME)"; - dstSubfolderSpec = 16; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXCopyFilesBuildPhase section */ - -/* Begin PBXFileReference section */ - 134E96981BCEB7F800AFFDA1 /* RCTDataRequestHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTDataRequestHandler.h; sourceTree = ""; }; - 134E96991BCEB7F800AFFDA1 /* RCTDataRequestHandler.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTDataRequestHandler.m; sourceTree = ""; }; - 1372B7351AB03E7B00659ED6 /* RCTNetInfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; lineEnding = 0; path = RCTNetInfo.h; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objcpp; }; - 1372B7361AB03E7B00659ED6 /* RCTNetInfo.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; lineEnding = 0; path = RCTNetInfo.m; sourceTree = ""; xcLanguageSpecificationIdentifier = xcode.lang.objc; }; - 13D6D6681B5FCF8200883BE9 /* RCTNetworkTask.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTNetworkTask.h; sourceTree = ""; }; - 13D6D6691B5FCF8200883BE9 /* RCTNetworkTask.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTNetworkTask.m; sourceTree = ""; }; - 13EF800C1BCBE015003F47DD /* RCTFileRequestHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTFileRequestHandler.h; sourceTree = ""; }; - 13EF800D1BCBE015003F47DD /* RCTFileRequestHandler.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTFileRequestHandler.m; sourceTree = ""; }; - 352DA0B71B17855800AA15A8 /* RCTHTTPRequestHandler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTHTTPRequestHandler.h; sourceTree = ""; }; - 352DA0B81B17855800AA15A8 /* RCTHTTPRequestHandler.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTHTTPRequestHandler.m; sourceTree = ""; }; - 58B511DB1A9E6C8500147676 /* libRCTNetwork.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRCTNetwork.a; sourceTree = BUILT_PRODUCTS_DIR; }; - 58B512061A9E6CE300147676 /* RCTNetworking.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTNetworking.h; sourceTree = ""; }; - 58B512071A9E6CE300147676 /* RCTNetworking.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTNetworking.m; sourceTree = ""; }; -/* End PBXFileReference section */ - -/* Begin PBXFrameworksBuildPhase section */ - 58B511D81A9E6C8500147676 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXFrameworksBuildPhase section */ - -/* Begin PBXGroup section */ - 58B511D21A9E6C8500147676 = { - isa = PBXGroup; - children = ( - 13D6D6681B5FCF8200883BE9 /* RCTNetworkTask.h */, - 13D6D6691B5FCF8200883BE9 /* RCTNetworkTask.m */, - 352DA0B71B17855800AA15A8 /* RCTHTTPRequestHandler.h */, - 352DA0B81B17855800AA15A8 /* RCTHTTPRequestHandler.m */, - 13EF800C1BCBE015003F47DD /* RCTFileRequestHandler.h */, - 13EF800D1BCBE015003F47DD /* RCTFileRequestHandler.m */, - 134E96981BCEB7F800AFFDA1 /* RCTDataRequestHandler.h */, - 134E96991BCEB7F800AFFDA1 /* RCTDataRequestHandler.m */, - 1372B7351AB03E7B00659ED6 /* RCTNetInfo.h */, - 1372B7361AB03E7B00659ED6 /* RCTNetInfo.m */, - 58B512061A9E6CE300147676 /* RCTNetworking.h */, - 58B512071A9E6CE300147676 /* RCTNetworking.m */, - 58B511DC1A9E6C8500147676 /* Products */, - ); - indentWidth = 2; - sourceTree = ""; - tabWidth = 2; - }; - 58B511DC1A9E6C8500147676 /* Products */ = { - isa = PBXGroup; - children = ( - 58B511DB1A9E6C8500147676 /* libRCTNetwork.a */, - ); - name = Products; - sourceTree = ""; - }; -/* End PBXGroup section */ - -/* Begin PBXNativeTarget section */ - 58B511DA1A9E6C8500147676 /* RCTNetwork */ = { - isa = PBXNativeTarget; - buildConfigurationList = 58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "RCTNetwork" */; - buildPhases = ( - 58B511D71A9E6C8500147676 /* Sources */, - 58B511D81A9E6C8500147676 /* Frameworks */, - 58B511D91A9E6C8500147676 /* CopyFiles */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = RCTNetwork; - productName = RCTDataManager; - productReference = 58B511DB1A9E6C8500147676 /* libRCTNetwork.a */; - productType = "com.apple.product-type.library.static"; - }; -/* End PBXNativeTarget section */ - -/* Begin PBXProject section */ - 58B511D31A9E6C8500147676 /* Project object */ = { - isa = PBXProject; - attributes = { - LastUpgradeCheck = 0610; - ORGANIZATIONNAME = Facebook; - TargetAttributes = { - 58B511DA1A9E6C8500147676 = { - CreatedOnToolsVersion = 6.1.1; - }; - }; - }; - buildConfigurationList = 58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "RCTNetwork" */; - compatibilityVersion = "Xcode 3.2"; - developmentRegion = English; - hasScannedForEncodings = 0; - knownRegions = ( - en, - ); - mainGroup = 58B511D21A9E6C8500147676; - productRefGroup = 58B511DC1A9E6C8500147676 /* Products */; - projectDirPath = ""; - projectRoot = ""; - targets = ( - 58B511DA1A9E6C8500147676 /* RCTNetwork */, - ); - }; -/* End PBXProject section */ - -/* Begin PBXSourcesBuildPhase section */ - 58B511D71A9E6C8500147676 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 13D6D66A1B5FCF8200883BE9 /* RCTNetworkTask.m in Sources */, - 13EF800E1BCBE015003F47DD /* RCTFileRequestHandler.m in Sources */, - 134E969A1BCEB7F800AFFDA1 /* RCTDataRequestHandler.m in Sources */, - 1372B7371AB03E7B00659ED6 /* RCTNetInfo.m in Sources */, - 58B512081A9E6CE300147676 /* RCTNetworking.m in Sources */, - 352DA0BA1B17855800AA15A8 /* RCTHTTPRequestHandler.m in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXSourcesBuildPhase section */ - -/* Begin XCBuildConfiguration section */ - 58B511ED1A9E6C8500147676 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - COPY_PHASE_STRIP = NO; - ENABLE_STRICT_OBJC_MSGSEND = YES; - GCC_C_LANGUAGE_STANDARD = gnu99; - GCC_DYNAMIC_NO_PIC = NO; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", - "$(inherited)", - ); - GCC_SYMBOLS_PRIVATE_EXTERN = NO; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES; - GCC_WARN_SHADOW = YES; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 7.0; - MTL_ENABLE_DEBUG_INFO = YES; - ONLY_ACTIVE_ARCH = YES; - SDKROOT = iphoneos; - WARNING_CFLAGS = ( - "-Werror", - "-Wall", - ); - }; - name = Debug; - }; - 58B511EE1A9E6C8500147676 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - COPY_PHASE_STRIP = YES; - ENABLE_NS_ASSERTIONS = NO; - ENABLE_STRICT_OBJC_MSGSEND = YES; - GCC_C_LANGUAGE_STANDARD = gnu99; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES; - GCC_WARN_SHADOW = YES; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 7.0; - MTL_ENABLE_DEBUG_INFO = NO; - SDKROOT = iphoneos; - VALIDATE_PRODUCT = YES; - WARNING_CFLAGS = ( - "-Werror", - "-Wall", - ); - }; - name = Release; - }; - 58B511F01A9E6C8500147676 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - CLANG_STATIC_ANALYZER_MODE = deep; - HEADER_SEARCH_PATHS = ( - "$(inherited)", - /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, - "$(SRCROOT)/../../React/**", - "$(SRCROOT)/../Image/**", - ); - LIBRARY_SEARCH_PATHS = "$(inherited)"; - OTHER_LDFLAGS = "-ObjC"; - PRODUCT_NAME = RCTNetwork; - RUN_CLANG_STATIC_ANALYZER = YES; - SKIP_INSTALL = YES; - }; - name = Debug; - }; - 58B511F11A9E6C8500147676 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - CLANG_STATIC_ANALYZER_MODE = deep; - HEADER_SEARCH_PATHS = ( - "$(inherited)", - /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, - "$(SRCROOT)/../../React/**", - "$(SRCROOT)/../Image/**", - ); - LIBRARY_SEARCH_PATHS = "$(inherited)"; - OTHER_LDFLAGS = "-ObjC"; - PRODUCT_NAME = RCTNetwork; - SKIP_INSTALL = YES; - }; - name = Release; - }; -/* End XCBuildConfiguration section */ - -/* Begin XCConfigurationList section */ - 58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "RCTNetwork" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 58B511ED1A9E6C8500147676 /* Debug */, - 58B511EE1A9E6C8500147676 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "RCTNetwork" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 58B511F01A9E6C8500147676 /* Debug */, - 58B511F11A9E6C8500147676 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; -/* End XCConfigurationList section */ - }; - rootObject = 58B511D31A9E6C8500147676 /* Project object */; -} diff --git a/examples/node_modules/react-native/Libraries/Network/RCTNetwork.xcodeproj/xcuserdata/yuji.xcuserdatad/xcschemes/xcschememanagement.plist b/examples/node_modules/react-native/Libraries/Network/RCTNetwork.xcodeproj/xcuserdata/yuji.xcuserdatad/xcschemes/xcschememanagement.plist deleted file mode 100644 index 79d39c3a..00000000 --- a/examples/node_modules/react-native/Libraries/Network/RCTNetwork.xcodeproj/xcuserdata/yuji.xcuserdatad/xcschemes/xcschememanagement.plist +++ /dev/null @@ -1,22 +0,0 @@ - - - - - SchemeUserState - - RCTNetwork.xcscheme - - orderHint - 6 - - - SuppressBuildableAutocreation - - 58B511DA1A9E6C8500147676 - - primary - - - - - diff --git a/examples/node_modules/react-native/Libraries/Network/XMLHttpRequest.ios.js b/examples/node_modules/react-native/Libraries/Network/XMLHttpRequest.ios.js deleted file mode 100644 index 21614ff3..00000000 --- a/examples/node_modules/react-native/Libraries/Network/XMLHttpRequest.ios.js +++ /dev/null @@ -1,45 +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. - * - * @providesModule XMLHttpRequest - * @flow - */ -'use strict'; - -var FormData = require('FormData'); -var RCTNetworking = require('RCTNetworking'); - -var XMLHttpRequestBase = require('XMLHttpRequestBase'); - -class XMLHttpRequest extends XMLHttpRequestBase { - constructor() { - super(); - // iOS supports upload - this.upload = {}; - } - - sendImpl(method: ?string, url: ?string, headers: Object, data: any): void { - if (typeof data === 'string') { - data = {string: data}; - } else if (data instanceof FormData) { - data = {formData: data.getParts()}; - } - RCTNetworking.sendRequest( - { - method, - url, - data, - headers, - incrementalUpdates: this.onreadystatechange ? true : false, - }, - this.didCreateRequest.bind(this) - ); - } -} - -module.exports = XMLHttpRequest; diff --git a/examples/node_modules/react-native/Libraries/Network/XMLHttpRequestBase.js b/examples/node_modules/react-native/Libraries/Network/XMLHttpRequestBase.js deleted file mode 100644 index 6c7bb8b4..00000000 --- a/examples/node_modules/react-native/Libraries/Network/XMLHttpRequestBase.js +++ /dev/null @@ -1,256 +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. - * - * @providesModule XMLHttpRequestBase - * @flow - */ -'use strict'; - -var RCTNetworking = require('RCTNetworking'); -var RCTDeviceEventEmitter = require('RCTDeviceEventEmitter'); - -/** - * Shared base for platform-specific XMLHttpRequest implementations. - */ -class XMLHttpRequestBase { - - UNSENT: number; - OPENED: number; - HEADERS_RECEIVED: number; - LOADING: number; - DONE: number; - - onreadystatechange: ?Function; - onload: ?Function; - upload: any; - readyState: number; - responseHeaders: ?Object; - responseText: ?string; - status: number; - - upload: ?{ - onprogress?: (event: Object) => void; - }; - - _requestId: ?number; - _subscriptions: [any]; - - _method: ?string; - _url: ?string; - _headers: Object; - _sent: boolean; - _aborted: boolean; - _lowerCaseResponseHeaders: Object; - - constructor() { - this.UNSENT = 0; - this.OPENED = 1; - this.HEADERS_RECEIVED = 2; - this.LOADING = 3; - this.DONE = 4; - - this.onreadystatechange = null; - this.onload = null; - this.upload = undefined; /* Upload not supported yet */ - - this._reset(); - this._method = null; - this._url = null; - this._aborted = false; - } - - _reset() { - this.readyState = this.UNSENT; - this.responseHeaders = undefined; - this.responseText = ''; - this.status = 0; - - this._requestId = null; - - this._headers = {}; - this._sent = false; - this._lowerCaseResponseHeaders = {}; - - this._clearSubscriptions(); - } - - didCreateRequest(requestId: number): void { - this._requestId = requestId; - this._subscriptions.push(RCTDeviceEventEmitter.addListener( - 'didSendNetworkData', - (args) => this._didUploadProgress.call(this, ...args) - )); - this._subscriptions.push(RCTDeviceEventEmitter.addListener( - 'didReceiveNetworkResponse', - (args) => this._didReceiveResponse.call(this, ...args) - )); - this._subscriptions.push(RCTDeviceEventEmitter.addListener( - 'didReceiveNetworkData', - (args) => this._didReceiveData.call(this, ...args) - )); - this._subscriptions.push(RCTDeviceEventEmitter.addListener( - 'didCompleteNetworkResponse', - (args) => this._didCompleteResponse.call(this, ...args) - )); - } - - _didUploadProgress(requestId: number, progress: number, total: number): void { - if (requestId === this._requestId && this.upload && this.upload.onprogress) { - var event = { - lengthComputable: true, - loaded: progress, - total, - }; - this.upload.onprogress(event); - } - } - - _didReceiveResponse(requestId: number, status: number, responseHeaders: ?Object): void { - if (requestId === this._requestId) { - this.status = status; - this.setResponseHeaders(responseHeaders); - this.setReadyState(this.HEADERS_RECEIVED); - } - } - - _didReceiveData(requestId: number, responseText: string): void { - if (requestId === this._requestId) { - if (!this.responseText) { - this.responseText = responseText; - } else { - this.responseText += responseText; - } - this.setReadyState(this.LOADING); - } - } - - _didCompleteResponse(requestId: number, error: string): void { - if (requestId === this._requestId) { - if (error) { - this.responseText = error; - } - this._clearSubscriptions(); - this._requestId = null; - this.setReadyState(this.DONE); - } - } - - _clearSubscriptions(): void { - (this._subscriptions || []).forEach(sub => { - sub.remove(); - }); - this._subscriptions = []; - } - - getAllResponseHeaders(): ?string { - if (!this.responseHeaders) { - // according to the spec, return null if no response has been received - return null; - } - var headers = this.responseHeaders || {}; - return Object.keys(headers).map((headerName) => { - return headerName + ': ' + headers[headerName]; - }).join('\n'); - } - - getResponseHeader(header: string): ?string { - var value = this._lowerCaseResponseHeaders[header.toLowerCase()]; - return value !== undefined ? value : null; - } - - setRequestHeader(header: string, value: any): void { - if (this.readyState !== this.OPENED) { - throw new Error('Request has not been opened'); - } - this._headers[header.toLowerCase()] = value; - } - - open(method: string, url: string, async: ?boolean): void { - /* Other optional arguments are not supported yet */ - if (this.readyState !== this.UNSENT) { - throw new Error('Cannot open, already sending'); - } - if (async !== undefined && !async) { - // async is default - throw new Error('Synchronous http requests are not supported'); - } - this._reset(); - this._method = method; - this._url = url; - this._aborted = false; - this.setReadyState(this.OPENED); - } - - sendImpl(method: ?string, url: ?string, headers: Object, data: any): void { - throw new Error('Subclass must define sendImpl method'); - } - - send(data: any): void { - if (this.readyState !== this.OPENED) { - throw new Error('Request has not been opened'); - } - if (this._sent) { - throw new Error('Request has already been sent'); - } - this._sent = true; - this.sendImpl(this._method, this._url, this._headers, data); - } - - abort(): void { - this._aborted = true; - if (this._requestId) { - RCTNetworking.abortRequest(this._requestId); - } - // only call onreadystatechange if there is something to abort, - // below logic is per spec - if (!(this.readyState === this.UNSENT || - (this.readyState === this.OPENED && !this._sent) || - this.readyState === this.DONE)) { - this._reset(); - this.setReadyState(this.DONE); - } - // Reset again after, in case modified in handler - this._reset(); - } - - setResponseHeaders(responseHeaders: ?Object): void { - this.responseHeaders = responseHeaders || null; - var headers = responseHeaders || {}; - this._lowerCaseResponseHeaders = - Object.keys(headers).reduce((lcaseHeaders, headerName) => { - lcaseHeaders[headerName.toLowerCase()] = headers[headerName]; - return lcaseHeaders; - }, {}); - } - - setReadyState(newState: number): void { - this.readyState = newState; - // TODO: workaround flow bug with nullable function checks - var onreadystatechange = this.onreadystatechange; - if (onreadystatechange) { - // We should send an event to handler, but since we don't process that - // event anywhere, let's leave it empty - onreadystatechange(null); - } - if (newState === this.DONE && !this._aborted) { - this._sendLoad(); - } - } - - _sendLoad(): void { - // TODO: workaround flow bug with nullable function checks - var onload = this.onload; - if (onload) { - // We should send an event to handler, but since we don't process that - // event anywhere, let's leave it empty - onload(null); - } - } -} - -module.exports = XMLHttpRequestBase; diff --git a/examples/node_modules/react-native/Libraries/Picker/PickerIOS.android.js b/examples/node_modules/react-native/Libraries/Picker/PickerIOS.android.js deleted file mode 100644 index 7c5b3911..00000000 --- a/examples/node_modules/react-native/Libraries/Picker/PickerIOS.android.js +++ /dev/null @@ -1,15 +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. - * - * @providesModule PickerIOS - * - * This is a controlled component version of RCTPickerIOS - */ -'use strict'; - -module.exports = require('UnimplementedView'); diff --git a/examples/node_modules/react-native/Libraries/Picker/PickerIOS.ios.js b/examples/node_modules/react-native/Libraries/Picker/PickerIOS.ios.js deleted file mode 100644 index 0aa82bb5..00000000 --- a/examples/node_modules/react-native/Libraries/Picker/PickerIOS.ios.js +++ /dev/null @@ -1,127 +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. - * - * @providesModule PickerIOS - * - * This is a controlled component version of RCTPickerIOS - */ -'use strict'; - -var NativeMethodsMixin = require('NativeMethodsMixin'); -var React = require('React'); -var ReactChildren = require('ReactChildren'); -var RCTPickerIOSConsts = require('NativeModules').UIManager.RCTPicker.Constants; -var StyleSheet = require('StyleSheet'); -var StyleSheetPropType = require('StyleSheetPropType'); -var TextStylePropTypes = require('TextStylePropTypes'); -var View = require('View'); - -var itemStylePropType = StyleSheetPropType(TextStylePropTypes); -var requireNativeComponent = require('requireNativeComponent'); - -var PickerIOS = React.createClass({ - mixins: [NativeMethodsMixin], - - propTypes: { - ...View.propTypes, - itemStyle: itemStylePropType, - onValueChange: React.PropTypes.func, - selectedValue: React.PropTypes.any, // string or integer basically - }, - - getInitialState: function() { - return this._stateFromProps(this.props); - }, - - componentWillReceiveProps: function(nextProps) { - this.setState(this._stateFromProps(nextProps)); - }, - - // Translate PickerIOS prop and children into stuff that RCTPickerIOS understands. - _stateFromProps: function(props) { - var selectedIndex = 0; - var items = []; - ReactChildren.forEach(props.children, function (child, index) { - if (child.props.value === props.selectedValue) { - selectedIndex = index; - } - items.push({value: child.props.value, label: child.props.label}); - }); - return {selectedIndex, items}; - }, - - render: function() { - return ( - - this._picker = picker} - style={[styles.pickerIOS, this.props.itemStyle]} - items={this.state.items} - selectedIndex={this.state.selectedIndex} - onChange={this._onChange} - /> - - ); - }, - - _onChange: function(event) { - if (this.props.onChange) { - this.props.onChange(event); - } - if (this.props.onValueChange) { - this.props.onValueChange(event.nativeEvent.newValue); - } - - // The picker is a controlled component. This means we expect the - // on*Change handlers to be in charge of updating our - // `selectedValue` prop. That way they can also - // disallow/undo/mutate the selection of certain values. In other - // words, the embedder of this component should be the source of - // truth, not the native component. - if (this._picker && this.state.selectedIndex !== event.nativeEvent.newIndex) { - this._picker.setNativeProps({ - selectedIndex: this.state.selectedIndex - }); - } - }, -}); - -PickerIOS.Item = React.createClass({ - propTypes: { - value: React.PropTypes.any, // string or integer basically - label: React.PropTypes.string, - }, - - render: function() { - // These items don't get rendered directly. - return null; - }, -}); - -var styles = StyleSheet.create({ - pickerIOS: { - // The picker will conform to whatever width is given, but we do - // have to set the component's height explicitly on the - // surrounding view to ensure it gets rendered. - height: RCTPickerIOSConsts.ComponentHeight, - }, -}); - -var RCTPickerIOS = requireNativeComponent('RCTPicker', { - propTypes: { - style: itemStylePropType, - }, -}, { - nativeOnly: { - items: true, - onChange: true, - selectedIndex: true, - }, -}); - -module.exports = PickerIOS; diff --git a/examples/node_modules/react-native/Libraries/Promise.js b/examples/node_modules/react-native/Libraries/Promise.js deleted file mode 100644 index 7cef2042..00000000 --- a/examples/node_modules/react-native/Libraries/Promise.js +++ /dev/null @@ -1,37 +0,0 @@ -/** - * - * Copyright 2013-2014 Facebook, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * - * @providesModule Promise - * - * This module wraps and augments the minimally ES6-compliant Promise - * implementation provided by the promise npm package. - */ - -'use strict'; - -global.setImmediate = require('setImmediate'); -var Promise = require('promise/setimmediate/es6-extensions'); -require('promise/setimmediate/done'); - -/** - * Handle either fulfillment or rejection with the same callback. - */ -Promise.prototype.finally = function(onSettled) { - return this.then(onSettled, onSettled); -}; - - -module.exports = Promise; diff --git a/examples/node_modules/react-native/Libraries/PushNotificationIOS/PushNotificationIOS.js b/examples/node_modules/react-native/Libraries/PushNotificationIOS/PushNotificationIOS.js deleted file mode 100644 index d4735fb4..00000000 --- a/examples/node_modules/react-native/Libraries/PushNotificationIOS/PushNotificationIOS.js +++ /dev/null @@ -1,298 +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. - * - * @providesModule PushNotificationIOS - * @flow - */ -'use strict'; - -var Map = require('Map'); -var RCTDeviceEventEmitter = require('RCTDeviceEventEmitter'); -var RCTPushNotificationManager = require('NativeModules').PushNotificationManager; -var invariant = require('invariant'); - -var _notifHandlers = new Map(); -var _initialNotification = RCTPushNotificationManager && - RCTPushNotificationManager.initialNotification; - -var DEVICE_NOTIF_EVENT = 'remoteNotificationReceived'; -var NOTIF_REGISTER_EVENT = 'remoteNotificationsRegistered'; - -/** - * Handle push notifications for your app, including permission handling and - * icon badge number. - * - * To get up and running, [configure your notifications with Apple](https://developer.apple.com/library/ios/documentation/IDEs/Conceptual/AppDistributionGuide/AddingCapabilities/AddingCapabilities.html#//apple_ref/doc/uid/TP40012582-CH26-SW6) - * and your server-side system. To get an idea, [this is the Parse guide](https://parse.com/tutorials/ios-push-notifications). - * - * To enable support for `notification` and `register` events you need to augment your AppDelegate. - * - * At the top of your `AppDelegate.m`: - * - * `#import "RCTPushNotificationManager.h"` - * - * And then in your AppDelegate implementation add the following: - * - * ``` - * // Required for the register event. - * - (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken - * { - * [RCTPushNotificationManager application:application didRegisterForRemoteNotificationsWithDeviceToken:deviceToken]; - * } - * // Required for the notification event. - * - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)notification - * { - * [RCTPushNotificationManager application:application didReceiveRemoteNotification:notification]; - * } - * ``` - */ -class PushNotificationIOS { - _data: Object; - _alert: string | Object; - _sound: string; - _badgeCount: number; - - /** - * Schedules the localNotification for immediate presentation. - * - * details is an object containing: - * - * - `alertBody` : The message displayed in the notification alert. - * - */ - static presentLocalNotification(details: Object) { - RCTPushNotificationManager.presentLocalNotification(details); - } - - /** - * Schedules the localNotification for future presentation. - * - * details is an object containing: - * - * - `fireDate` : The date and time when the system should deliver the notification. - * - `alertBody` : The message displayed in the notification alert. - * - */ - static scheduleLocalNotification(details: Object) { - RCTPushNotificationManager.scheduleLocalNotification(details); - } - - /** - * Cancels all scheduled localNotifications - */ - static cancelAllLocalNotifications() { - RCTPushNotificationManager.cancelAllLocalNotifications(); - } - - /** - * Sets the badge number for the app icon on the home screen - */ - static setApplicationIconBadgeNumber(number: number) { - RCTPushNotificationManager.setApplicationIconBadgeNumber(number); - } - - /** - * Gets the current badge number for the app icon on the home screen - */ - static getApplicationIconBadgeNumber(callback: Function) { - RCTPushNotificationManager.getApplicationIconBadgeNumber(callback); - } - - /** - * Attaches a listener to remote notification events while the app is running - * in the foreground or the background. - * - * Valid events are: - * - * - `notification` : Fired when a remote notification is received. The - * handler will be invoked with an instance of `PushNotificationIOS`. - * - `register`: Fired when the user registers for remote notifications. The - * handler will be invoked with a hex string representing the deviceToken. - */ - static addEventListener(type: string, handler: Function) { - invariant( - type === 'notification' || type === 'register', - 'PushNotificationIOS only supports `notification` and `register` events' - ); - var listener; - if (type === 'notification') { - listener = RCTDeviceEventEmitter.addListener( - DEVICE_NOTIF_EVENT, - (notifData) => { - handler(new PushNotificationIOS(notifData)); - } - ); - } else if (type === 'register') { - listener = RCTDeviceEventEmitter.addListener( - NOTIF_REGISTER_EVENT, - (registrationInfo) => { - handler(registrationInfo.deviceToken); - } - ); - } - _notifHandlers.set(handler, listener); - } - - /** - * Requests notification permissions from iOS, prompting the user's - * dialog box. By default, it will request all notification permissions, but - * a subset of these can be requested by passing a map of requested - * permissions. - * The following permissions are supported: - * - * - `alert` - * - `badge` - * - `sound` - * - * If a map is provided to the method, only the permissions with truthy values - * will be requested. - */ - static requestPermissions(permissions?: { - alert?: boolean, - badge?: boolean, - sound?: boolean - }) { - var requestedPermissions = {}; - if (permissions) { - requestedPermissions = { - alert: !!permissions.alert, - badge: !!permissions.badge, - sound: !!permissions.sound - }; - } else { - requestedPermissions = { - alert: true, - badge: true, - sound: true - }; - } - RCTPushNotificationManager.requestPermissions(requestedPermissions); - } - - /** - * Unregister for all remote notifications received via Apple Push Notification service. - * - * You should call this method in rare circumstances only, such as when a new version of - * the app removes support for all types of remote notifications. Users can temporarily - * prevent apps from receiving remote notifications through the Notifications section of - * the Settings app. Apps unregistered through this method can always re-register. - */ - static abandonPermissions() { - RCTPushNotificationManager.abandonPermissions(); - } - - /** - * See what push permissions are currently enabled. `callback` will be - * invoked with a `permissions` object: - * - * - `alert` :boolean - * - `badge` :boolean - * - `sound` :boolean - */ - static checkPermissions(callback: Function) { - invariant( - typeof callback === 'function', - 'Must provide a valid callback' - ); - RCTPushNotificationManager.checkPermissions(callback); - } - - /** - * Removes the event listener. Do this in `componentWillUnmount` to prevent - * memory leaks - */ - static removeEventListener(type: string, handler: Function) { - invariant( - type === 'notification' || type === 'register', - 'PushNotificationIOS only supports `notification` and `register` events' - ); - var listener = _notifHandlers.get(handler); - if (!listener) { - return; - } - listener.remove(); - _notifHandlers.delete(handler); - } - - - /** - * An initial notification will be available if the app was cold-launched - * from a notification. - * - * The first caller of `popInitialNotification` will get the initial - * notification object, or `null`. Subsequent invocations will return null. - */ - static popInitialNotification() { - var initialNotification = _initialNotification && - new PushNotificationIOS(_initialNotification); - _initialNotification = null; - return initialNotification; - } - - /** - * You will never need to instansiate `PushNotificationIOS` yourself. - * Listening to the `notification` event and invoking - * `popInitialNotification` is sufficient - */ - constructor(nativeNotif: Object) { - this._data = {}; - - // Extract data from Apple's `aps` dict as defined: - - // https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/ApplePushService.html - - Object.keys(nativeNotif).forEach((notifKey) => { - var notifVal = nativeNotif[notifKey]; - if (notifKey === 'aps') { - this._alert = notifVal.alert; - this._sound = notifVal.sound; - this._badgeCount = notifVal.badge; - } else { - this._data[notifKey] = notifVal; - } - }); - } - - /** - * An alias for `getAlert` to get the notification's main message string - */ - getMessage(): ?string | ?Object { - // alias because "alert" is an ambiguous name - return this._alert; - } - - /** - * Gets the sound string from the `aps` object - */ - getSound(): ?string { - return this._sound; - } - - /** - * Gets the notification's main message from the `aps` object - */ - getAlert(): ?string | ?Object { - return this._alert; - } - - /** - * Gets the badge count number from the `aps` object - */ - getBadgeCount(): ?number { - return this._badgeCount; - } - - /** - * Gets the data object on the notif - */ - getData(): ?Object { - return this._data; - } -} - -module.exports = PushNotificationIOS; diff --git a/examples/node_modules/react-native/Libraries/PushNotificationIOS/RCTPushNotification.xcodeproj/project.pbxproj b/examples/node_modules/react-native/Libraries/PushNotificationIOS/RCTPushNotification.xcodeproj/project.pbxproj deleted file mode 100644 index 4281a469..00000000 --- a/examples/node_modules/react-native/Libraries/PushNotificationIOS/RCTPushNotification.xcodeproj/project.pbxproj +++ /dev/null @@ -1,266 +0,0 @@ -// !$*UTF8*$! -{ - archiveVersion = 1; - classes = { - }; - objectVersion = 46; - objects = { - -/* Begin PBXBuildFile section */ - 148699CF1ABD045300480536 /* RCTPushNotificationManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 148699CE1ABD045300480536 /* RCTPushNotificationManager.m */; }; -/* End PBXBuildFile section */ - -/* Begin PBXCopyFilesBuildPhase section */ - 58B511D91A9E6C8500147676 /* CopyFiles */ = { - isa = PBXCopyFilesBuildPhase; - buildActionMask = 2147483647; - dstPath = "include/$(PRODUCT_NAME)"; - dstSubfolderSpec = 16; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXCopyFilesBuildPhase section */ - -/* Begin PBXFileReference section */ - 134814201AA4EA6300B7C361 /* libRCTPushNotification.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRCTPushNotification.a; sourceTree = BUILT_PRODUCTS_DIR; }; - 148699CD1ABD045300480536 /* RCTPushNotificationManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTPushNotificationManager.h; sourceTree = ""; }; - 148699CE1ABD045300480536 /* RCTPushNotificationManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTPushNotificationManager.m; sourceTree = ""; }; -/* End PBXFileReference section */ - -/* Begin PBXFrameworksBuildPhase section */ - 58B511D81A9E6C8500147676 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXFrameworksBuildPhase section */ - -/* Begin PBXGroup section */ - 134814211AA4EA7D00B7C361 /* Products */ = { - isa = PBXGroup; - children = ( - 134814201AA4EA6300B7C361 /* libRCTPushNotification.a */, - ); - name = Products; - sourceTree = ""; - }; - 58B511D21A9E6C8500147676 = { - isa = PBXGroup; - children = ( - 148699CD1ABD045300480536 /* RCTPushNotificationManager.h */, - 148699CE1ABD045300480536 /* RCTPushNotificationManager.m */, - 134814211AA4EA7D00B7C361 /* Products */, - ); - indentWidth = 2; - sourceTree = ""; - tabWidth = 2; - }; -/* End PBXGroup section */ - -/* Begin PBXNativeTarget section */ - 58B511DA1A9E6C8500147676 /* RCTPushNotification */ = { - isa = PBXNativeTarget; - buildConfigurationList = 58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "RCTPushNotification" */; - buildPhases = ( - 58B511D71A9E6C8500147676 /* Sources */, - 58B511D81A9E6C8500147676 /* Frameworks */, - 58B511D91A9E6C8500147676 /* CopyFiles */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = RCTPushNotification; - productName = RCTDataManager; - productReference = 134814201AA4EA6300B7C361 /* libRCTPushNotification.a */; - productType = "com.apple.product-type.library.static"; - }; -/* End PBXNativeTarget section */ - -/* Begin PBXProject section */ - 58B511D31A9E6C8500147676 /* Project object */ = { - isa = PBXProject; - attributes = { - LastUpgradeCheck = 0610; - ORGANIZATIONNAME = Facebook; - TargetAttributes = { - 58B511DA1A9E6C8500147676 = { - CreatedOnToolsVersion = 6.1.1; - }; - }; - }; - buildConfigurationList = 58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "RCTPushNotification" */; - compatibilityVersion = "Xcode 3.2"; - developmentRegion = English; - hasScannedForEncodings = 0; - knownRegions = ( - en, - ); - mainGroup = 58B511D21A9E6C8500147676; - productRefGroup = 58B511D21A9E6C8500147676; - projectDirPath = ""; - projectRoot = ""; - targets = ( - 58B511DA1A9E6C8500147676 /* RCTPushNotification */, - ); - }; -/* End PBXProject section */ - -/* Begin PBXSourcesBuildPhase section */ - 58B511D71A9E6C8500147676 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 148699CF1ABD045300480536 /* RCTPushNotificationManager.m in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXSourcesBuildPhase section */ - -/* Begin XCBuildConfiguration section */ - 58B511ED1A9E6C8500147676 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - COPY_PHASE_STRIP = NO; - ENABLE_STRICT_OBJC_MSGSEND = YES; - GCC_C_LANGUAGE_STANDARD = gnu99; - GCC_DYNAMIC_NO_PIC = NO; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PREPROCESSOR_DEFINITIONS = "DEBUG=1"; - GCC_SYMBOLS_PRIVATE_EXTERN = NO; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES; - GCC_WARN_SHADOW = YES; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 7.0; - MTL_ENABLE_DEBUG_INFO = YES; - ONLY_ACTIVE_ARCH = YES; - SDKROOT = iphoneos; - WARNING_CFLAGS = ( - "-Wextra", - "-Wall", - ); - }; - name = Debug; - }; - 58B511EE1A9E6C8500147676 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - COPY_PHASE_STRIP = YES; - ENABLE_NS_ASSERTIONS = NO; - ENABLE_STRICT_OBJC_MSGSEND = YES; - GCC_C_LANGUAGE_STANDARD = gnu99; - GCC_PREPROCESSOR_DEFINITIONS = ""; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES; - GCC_WARN_SHADOW = YES; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 7.0; - MTL_ENABLE_DEBUG_INFO = NO; - SDKROOT = iphoneos; - VALIDATE_PRODUCT = YES; - WARNING_CFLAGS = ( - "-Wextra", - "-Wall", - ); - }; - name = Release; - }; - 58B511F01A9E6C8500147676 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - CLANG_STATIC_ANALYZER_MODE = deep; - GCC_PREPROCESSOR_DEFINITIONS = "$(inherited)"; - HEADER_SEARCH_PATHS = ( - "$(inherited)", - /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, - "$(SRCROOT)/../../React/**", - ); - LIBRARY_SEARCH_PATHS = "$(inherited)"; - OTHER_LDFLAGS = "-ObjC"; - PRODUCT_NAME = RCTPushNotification; - RUN_CLANG_STATIC_ANALYZER = YES; - SKIP_INSTALL = YES; - }; - name = Debug; - }; - 58B511F11A9E6C8500147676 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - CLANG_STATIC_ANALYZER_MODE = deep; - HEADER_SEARCH_PATHS = ( - "$(inherited)", - /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, - "$(SRCROOT)/../../React/**", - ); - LIBRARY_SEARCH_PATHS = "$(inherited)"; - OTHER_LDFLAGS = "-ObjC"; - PRODUCT_NAME = RCTPushNotification; - SKIP_INSTALL = YES; - }; - name = Release; - }; -/* End XCBuildConfiguration section */ - -/* Begin XCConfigurationList section */ - 58B511D61A9E6C8500147676 /* Build configuration list for PBXProject "RCTPushNotification" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 58B511ED1A9E6C8500147676 /* Debug */, - 58B511EE1A9E6C8500147676 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 58B511EF1A9E6C8500147676 /* Build configuration list for PBXNativeTarget "RCTPushNotification" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 58B511F01A9E6C8500147676 /* Debug */, - 58B511F11A9E6C8500147676 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; -/* End XCConfigurationList section */ - }; - rootObject = 58B511D31A9E6C8500147676 /* Project object */; -} diff --git a/examples/node_modules/react-native/Libraries/PushNotificationIOS/RCTPushNotificationManager.h b/examples/node_modules/react-native/Libraries/PushNotificationIOS/RCTPushNotificationManager.h deleted file mode 100644 index 194bbc5d..00000000 --- a/examples/node_modules/react-native/Libraries/PushNotificationIOS/RCTPushNotificationManager.h +++ /dev/null @@ -1,20 +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. - */ - -#import - -#import "RCTBridgeModule.h" - -@interface RCTPushNotificationManager : NSObject - -+ (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings; -+ (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken; -+ (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)notification; - -@end diff --git a/examples/node_modules/react-native/Libraries/PushNotificationIOS/RCTPushNotificationManager.m b/examples/node_modules/react-native/Libraries/PushNotificationIOS/RCTPushNotificationManager.m deleted file mode 100644 index 0fda6ee1..00000000 --- a/examples/node_modules/react-native/Libraries/PushNotificationIOS/RCTPushNotificationManager.m +++ /dev/null @@ -1,214 +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. - */ - -#import "RCTPushNotificationManager.h" - -#import "RCTBridge.h" -#import "RCTConvert.h" -#import "RCTEventDispatcher.h" -#import "RCTUtils.h" - -#if __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_8_0 - -#define UIUserNotificationTypeAlert UIRemoteNotificationTypeAlert -#define UIUserNotificationTypeBadge UIRemoteNotificationTypeBadge -#define UIUserNotificationTypeSound UIRemoteNotificationTypeSound -#define UIUserNotificationTypeNone UIRemoteNotificationTypeNone -#define UIUserNotificationType UIRemoteNotificationType - -#endif - -NSString *const RCTRemoteNotificationReceived = @"RemoteNotificationReceived"; -NSString *const RCTRemoteNotificationsRegistered = @"RemoteNotificationsRegistered"; - -@implementation RCTConvert (UILocalNotification) - -+ (UILocalNotification *)UILocalNotification:(id)json -{ - NSDictionary *details = [self NSDictionary:json]; - UILocalNotification *notification = [UILocalNotification new]; - notification.fireDate = [RCTConvert NSDate:details[@"fireDate"]] ?: [NSDate date]; - notification.alertBody = [RCTConvert NSString:details[@"alertBody"]]; - return notification; -} - -@end - -@implementation RCTPushNotificationManager - -RCT_EXPORT_MODULE() - -@synthesize bridge = _bridge; - -- (void)dealloc -{ - [[NSNotificationCenter defaultCenter] removeObserver:self]; -} - -- (void)setBridge:(RCTBridge *)bridge -{ - _bridge = bridge; - - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(handleRemoteNotificationReceived:) - name:RCTRemoteNotificationReceived - object:nil]; - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(handleRemoteNotificationsRegistered:) - name:RCTRemoteNotificationsRegistered - object:nil]; -} - -- (NSDictionary *)constantsToExport -{ - NSDictionary *initialNotification = [_bridge.launchOptions[UIApplicationLaunchOptionsRemoteNotificationKey] copy]; - return @{@"initialNotification": RCTNullIfNil(initialNotification)}; -} - -+ (void)application:(__unused UIApplication *)application didRegisterUserNotificationSettings:(__unused UIUserNotificationSettings *)notificationSettings -{ - if ([application respondsToSelector:@selector(registerForRemoteNotifications)]) { - [application registerForRemoteNotifications]; - } -} - -+ (void)application:(__unused UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken -{ - NSMutableString *hexString = [NSMutableString string]; - NSUInteger deviceTokenLength = deviceToken.length; - const unsigned char *bytes = deviceToken.bytes; - for (NSUInteger i = 0; i < deviceTokenLength; i++) { - [hexString appendFormat:@"%02x", bytes[i]]; - } - NSDictionary *userInfo = @{ - @"deviceToken" : [hexString copy] - }; - [[NSNotificationCenter defaultCenter] postNotificationName:RCTRemoteNotificationsRegistered - object:self - userInfo:userInfo]; -} - -+ (void)application:(__unused UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)notification -{ - [[NSNotificationCenter defaultCenter] postNotificationName:RCTRemoteNotificationReceived - object:self - userInfo:notification]; -} - -- (void)handleRemoteNotificationReceived:(NSNotification *)notification -{ - [_bridge.eventDispatcher sendDeviceEventWithName:@"remoteNotificationReceived" - body:notification.userInfo]; -} - -- (void)handleRemoteNotificationsRegistered:(NSNotification *)notification -{ - [_bridge.eventDispatcher sendDeviceEventWithName:@"remoteNotificationsRegistered" - body:notification.userInfo]; -} - -/** - * Update the application icon badge number on the home screen - */ -RCT_EXPORT_METHOD(setApplicationIconBadgeNumber:(NSInteger)number) -{ - RCTSharedApplication().applicationIconBadgeNumber = number; -} - -/** - * Get the current application icon badge number on the home screen - */ -RCT_EXPORT_METHOD(getApplicationIconBadgeNumber:(RCTResponseSenderBlock)callback) -{ - callback(@[ - @(RCTSharedApplication().applicationIconBadgeNumber) - ]); -} - -RCT_EXPORT_METHOD(requestPermissions:(NSDictionary *)permissions) -{ - if (RCTRunningInAppExtension()) { - return; - } - - UIUserNotificationType types = UIUserNotificationTypeNone; - if (permissions) { - if ([permissions[@"alert"] boolValue]) { - types |= UIUserNotificationTypeAlert; - } - if ([permissions[@"badge"] boolValue]) { - types |= UIUserNotificationTypeBadge; - } - if ([permissions[@"sound"] boolValue]) { - types |= UIUserNotificationTypeSound; - } - } else { - types = UIUserNotificationTypeAlert | UIUserNotificationTypeBadge | UIUserNotificationTypeSound; - } - - UIApplication *app = RCTSharedApplication(); - if ([app respondsToSelector:@selector(registerUserNotificationSettings:)]) { - UIUserNotificationSettings *notificationSettings = [UIUserNotificationSettings settingsForTypes:(NSUInteger)types categories:nil]; - [app registerUserNotificationSettings:notificationSettings]; - [app registerForRemoteNotifications]; - } else { - [app registerForRemoteNotificationTypes:(NSUInteger)types]; - } -} - -RCT_EXPORT_METHOD(abandonPermissions) -{ - [RCTSharedApplication() unregisterForRemoteNotifications]; -} - -RCT_EXPORT_METHOD(checkPermissions:(RCTResponseSenderBlock)callback) -{ - if (RCTRunningInAppExtension()) { - NSDictionary *permissions = @{@"alert": @NO, @"badge": @NO, @"sound": @NO}; - callback(@[permissions]); - return; - } - - NSUInteger types = 0; - if ([UIApplication instancesRespondToSelector:@selector(currentUserNotificationSettings)]) { - types = [RCTSharedApplication() currentUserNotificationSettings].types; - } else { - -#if __IPHONE_OS_VERSION_MIN_REQUIRED < __IPHONE_8_0 - - types = [RCTSharedApplication() enabledRemoteNotificationTypes]; - -#endif - - } - - NSMutableDictionary *permissions = [NSMutableDictionary new]; - permissions[@"alert"] = @((types & UIUserNotificationTypeAlert) > 0); - permissions[@"badge"] = @((types & UIUserNotificationTypeBadge) > 0); - permissions[@"sound"] = @((types & UIUserNotificationTypeSound) > 0); - - callback(@[permissions]); -} - -RCT_EXPORT_METHOD(presentLocalNotification:(UILocalNotification *)notification) -{ - [RCTSharedApplication() presentLocalNotificationNow:notification]; -} - -RCT_EXPORT_METHOD(scheduleLocalNotification:(UILocalNotification *)notification) -{ - [RCTSharedApplication() scheduleLocalNotification:notification]; -} - -RCT_EXPORT_METHOD(cancelAllLocalNotifications) -{ - [RCTSharedApplication() cancelAllLocalNotifications]; -} - -@end diff --git a/examples/node_modules/react-native/Libraries/RCTTest/FBSnapshotTestCase/FBSnapshotTestCase.h b/examples/node_modules/react-native/Libraries/RCTTest/FBSnapshotTestCase/FBSnapshotTestCase.h deleted file mode 100644 index 063e32a4..00000000 --- a/examples/node_modules/react-native/Libraries/RCTTest/FBSnapshotTestCase/FBSnapshotTestCase.h +++ /dev/null @@ -1,99 +0,0 @@ -/* - * Copyright (c) 2013, 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. - * - */ - -#import - -#import - -#import - -#ifndef FB_REFERENCE_IMAGE_DIR -#define FB_REFERENCE_IMAGE_DIR "\"$(SOURCE_ROOT)/$(PROJECT_NAME)Tests/ReferenceImages\"" -#endif - -/** - Similar to our much-loved XCTAssert() macros. Use this to perform your test. No need to write an explanation, though. - @param view The view to snapshot - @param identifier An optional identifier, used if there are multiple snapshot tests in a given -test method. - @param referenceImageDirectorySuffix An optional suffix, appended to the reference image directory path, such as "_iOS8" - */ -#define FBSnapshotVerifyViewWithReferenceDirectorySuffix(view__, identifier__, referenceImagesDirectorySuffix__) \ -{ \ -NSError *error__ = nil; \ -NSString *referenceImagesDirectory__ = [NSString stringWithFormat:@"%s%@", FB_REFERENCE_IMAGE_DIR, referenceImagesDirectorySuffix__]; \ -BOOL comparisonSuccess__ = [self compareSnapshotOfView:(view__) referenceImagesDirectory:referenceImagesDirectory__ identifier:(identifier__) error:&error__]; \ -XCTAssertTrue(comparisonSuccess__, @"Snapshot comparison failed: %@", error__); \ -} - -#define FBSnapshotVerifyView(view__, identifier__) \ -{ \ -FBSnapshotVerifyViewWithReferenceDirectorySuffix(view__, identifier__, @""); \ -} - -/** - Similar to our much-loved XCTAssert() macros. Use this to perform your test. No need to write an explanation, though. - @param layer The layer to snapshot - @param identifier An optional identifier, used is there are multiple snapshot tests in a given -test method. - @param referenceImageDirectorySuffix An optional suffix, appended to the reference image directory path, such as "_iOS8" - */ -#define FBSnapshotVerifyLayerWithReferenceDirectorySuffix(layer__, identifier__, referenceImagesDirectorySuffix__) \ -{ \ -NSError *error__ = nil; \ -NSString *referenceImagesDirectory__ = [NSString stringWithFormat:@"%s%@", FB_REFERENCE_IMAGE_DIR, referenceImagesDirectorySuffix__]; \ -BOOL comparisonSuccess__ = [self compareSnapshotOfLayer:(layer__) referenceImagesDirectory:referenceImagesDirectory__ identifier:(identifier__) error:&error__]; \ -XCTAssertTrue(comparisonSuccess__, @"Snapshot comparison failed: %@", error__); \ -} - -#define FBSnapshotVerifyLayer(layer__, identifier__) \ -{ \ -FBSnapshotVerifyLayerWithReferenceDirectorySuffix(layer__, identifier__, @""); \ -} - -/** - The base class of view snapshotting tests. If you have small UI component, it's often easier to configure it in a test - and compare an image of the view to a reference image that write lots of complex layout-code tests. - - In order to flip the tests in your subclass to record the reference images set `recordMode` to YES before calling - -[super setUp]. - */ -@interface FBSnapshotTestCase : XCTestCase - -/** - When YES, the test macros will save reference images, rather than performing an actual test. - */ -@property (readwrite, nonatomic, assign) BOOL recordMode; - -/** - Performs the comparisong or records a snapshot of the layer if recordMode is YES. - @param layer The Layer to snapshot - @param referenceImagesDirectory The directory in which reference images are stored. - @param identifier An optional identifier, used if there are multiple snapshot tests in a given -test method. - @param error An error to log in an XCTAssert() macro if the method fails (missing reference image, images differ, etc). - @returns YES if the comparison (or saving of the reference image) succeeded. - */ -- (BOOL)compareSnapshotOfLayer:(CALayer *)layer - referenceImagesDirectory:(NSString *)referenceImagesDirectory - identifier:(NSString *)identifier - error:(NSError **)errorPtr; - -/** - Performs the comparisong or records a snapshot of the view if recordMode is YES. - @param view The view to snapshot - @param referenceImagesDirectory The directory in which reference images are stored. - @param identifier An optional identifier, used if there are multiple snapshot tests in a given -test method. - @param error An error to log in an XCTAssert() macro if the method fails (missing reference image, images differ, etc). - @returns YES if the comparison (or saving of the reference image) succeeded. - */ -- (BOOL)compareSnapshotOfView:(UIView *)view - referenceImagesDirectory:(NSString *)referenceImagesDirectory - identifier:(NSString *)identifier - error:(NSError **)errorPtr; - -@end diff --git a/examples/node_modules/react-native/Libraries/RCTTest/FBSnapshotTestCase/FBSnapshotTestCase.m b/examples/node_modules/react-native/Libraries/RCTTest/FBSnapshotTestCase/FBSnapshotTestCase.m deleted file mode 100644 index ebd311c6..00000000 --- a/examples/node_modules/react-native/Libraries/RCTTest/FBSnapshotTestCase/FBSnapshotTestCase.m +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Copyright (c) 2013, 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. - * - */ - -#import "FBSnapshotTestCase.h" - -#import "FBSnapshotTestController.h" - -@interface FBSnapshotTestCase () - -@property (readwrite, nonatomic, retain) FBSnapshotTestController *snapshotController; - -@end - -@implementation FBSnapshotTestCase - -- (void)setUp -{ - [super setUp]; - self.snapshotController = [[FBSnapshotTestController alloc] initWithTestName:NSStringFromClass([self class])]; -} - -- (void)tearDown -{ - self.snapshotController = nil; - [super tearDown]; -} - -- (BOOL)recordMode -{ - return self.snapshotController.recordMode; -} - -- (void)setRecordMode:(BOOL)recordMode -{ - self.snapshotController.recordMode = recordMode; -} - -- (BOOL)compareSnapshotOfLayer:(CALayer *)layer - referenceImagesDirectory:(NSString *)referenceImagesDirectory - identifier:(NSString *)identifier - error:(NSError **)errorPtr -{ - return [self _compareSnapshotOfViewOrLayer:layer - referenceImagesDirectory:referenceImagesDirectory - identifier:identifier - error:errorPtr]; -} - -- (BOOL)compareSnapshotOfView:(UIView *)view - referenceImagesDirectory:(NSString *)referenceImagesDirectory - identifier:(NSString *)identifier - error:(NSError **)errorPtr -{ - return [self _compareSnapshotOfViewOrLayer:view - referenceImagesDirectory:referenceImagesDirectory - identifier:identifier - error:errorPtr]; -} - -#pragma mark - -#pragma mark Private API - -- (BOOL)_compareSnapshotOfViewOrLayer:(id)viewOrLayer - referenceImagesDirectory:(NSString *)referenceImagesDirectory - identifier:(NSString *)identifier - error:(NSError **)errorPtr -{ - _snapshotController.referenceImagesDirectory = referenceImagesDirectory; - return [_snapshotController compareSnapshotOfViewOrLayer:viewOrLayer - selector:self.invocation.selector - identifier:identifier - error:errorPtr]; -} - -@end diff --git a/examples/node_modules/react-native/Libraries/RCTTest/FBSnapshotTestCase/FBSnapshotTestController.h b/examples/node_modules/react-native/Libraries/RCTTest/FBSnapshotTestCase/FBSnapshotTestController.h deleted file mode 100644 index 349384d8..00000000 --- a/examples/node_modules/react-native/Libraries/RCTTest/FBSnapshotTestCase/FBSnapshotTestController.h +++ /dev/null @@ -1,152 +0,0 @@ -/* - * Copyright (c) 2013, 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. - * - */ - -#import -#import - -typedef NS_ENUM(NSInteger, FBSnapshotTestControllerErrorCode) { - FBSnapshotTestControllerErrorCodeUnknown, - FBSnapshotTestControllerErrorCodeNeedsRecord, - FBSnapshotTestControllerErrorCodePNGCreationFailed, - FBSnapshotTestControllerErrorCodeImagesDifferentSizes, - FBSnapshotTestControllerErrorCodeImagesDifferent, -}; -/** - Errors returned by the methods of FBSnapshotTestController use this domain. - */ -extern NSString *const FBSnapshotTestControllerErrorDomain; - -/** - Errors returned by the methods of FBSnapshotTestController sometimes contain this key in the `userInfo` dictionary. - */ -extern NSString *const FBReferenceImageFilePathKey; - -/** - Provides the heavy-lifting for FBSnapshotTestCase. It loads and saves images, along with performing the actual pixel- - by-pixel comparison of images. - Instances are initialized with the test class, and directories to read and write to. - */ -@interface FBSnapshotTestController : NSObject - -/** - Record snapshots. - **/ -@property(readwrite, nonatomic, assign) BOOL recordMode; - -/** - @param testClass The subclass of FBSnapshotTestCase that is using this controller. - @param referenceImagesDirectory The directory where the reference images are stored. - @returns An instance of FBSnapshotTestController. - */ -- (id)initWithTestClass:(Class)testClass; - -/** - Designated initializer. - @param testName The name of the tests. - @param referenceImagesDirectory The directory where the reference images are stored. - @returns An instance of FBSnapshotTestController. - */ -- (id)initWithTestName:(NSString *)testName; - - -/** - Performs the comparison of the layer. - @param layer The Layer to snapshot. - @param referenceImagesDirectory The directory in which reference images are stored. - @param identifier An optional identifier, used is there are muliptle snapshot tests in a given -test method. - @param error An error to log in an XCTAssert() macro if the method fails (missing reference image, images differ, etc). - @returns YES if the comparison (or saving of the reference image) succeeded. - */ -- (BOOL)compareSnapshotOfLayer:(CALayer *)layer - selector:(SEL)selector - identifier:(NSString *)identifier - error:(NSError **)errorPtr; - -/** - Performs the comparison of the view. - @param view The view to snapshot. - @param referenceImagesDirectory The directory in which reference images are stored. - @param identifier An optional identifier, used is there are muliptle snapshot tests in a given -test method. - @param error An error to log in an XCTAssert() macro if the method fails (missing reference image, images differ, etc). - @returns YES if the comparison (or saving of the reference image) succeeded. - */ -- (BOOL)compareSnapshotOfView:(UIView *)view - selector:(SEL)selector - identifier:(NSString *)identifier - error:(NSError **)errorPtr; - -/** - Performs the comparison of a view or layer. - @param view The view or layer to snapshot. - @param referenceImagesDirectory The directory in which reference images are stored. - @param identifier An optional identifier, used is there are muliptle snapshot tests in a given -test method. - @param error An error to log in an XCTAssert() macro if the method fails (missing reference image, images differ, etc). - @returns YES if the comparison (or saving of the reference image) succeeded. - */ -- (BOOL)compareSnapshotOfViewOrLayer:(id)viewOrLayer - selector:(SEL)selector - identifier:(NSString *)identifier - error:(NSError **)errorPtr; - - -/** - The directory in which referfence images are stored. - */ -@property (readwrite, nonatomic, copy) NSString *referenceImagesDirectory; - -/** - Loads a reference image. - @param selector The test method being run. - @param identifier The optional identifier, used when multiple images are tested in a single -test method. - @param error An error, if this methods returns nil, the error will be something useful. - @returns An image. - */ -- (UIImage *)referenceImageForSelector:(SEL)selector - identifier:(NSString *)identifier - error:(NSError **)error; - -/** - Saves a reference image. - @param selector The test method being run. - @param identifier The optional identifier, used when multiple images are tested in a single -test method. - @param error An error, if this methods returns NO, the error will be something useful. - @returns An image. - */ -- (BOOL)saveReferenceImage:(UIImage *)image - selector:(SEL)selector - identifier:(NSString *)identifier - error:(NSError **)errorPtr; - -/** - Performs a pixel-by-pixel comparison of the two images. - @param referenceImage The reference (correct) image. - @param image The image to test against the reference. - @param error An error that indicates why the comparison failed if it does. - @param YES if the comparison succeeded and the images are the same. - */ -- (BOOL)compareReferenceImage:(UIImage *)referenceImage - toImage:(UIImage *)image - error:(NSError **)errorPtr; - -/** - Saves the reference image and the test image to `failedOutputDirectory`. - @param referenceImage The reference (correct) image. - @param testImage The image to test against the reference. - @param selector The test method being run. - @param identifier The optional identifier, used when multiple images are tested in a single -test method. - @param error An error that indicates why the comparison failed if it does. - @param YES if the save succeeded. - */ -- (BOOL)saveFailedReferenceImage:(UIImage *)referenceImage - testImage:(UIImage *)testImage - selector:(SEL)selector - identifier:(NSString *)identifier - error:(NSError **)errorPtr; -@end diff --git a/examples/node_modules/react-native/Libraries/RCTTest/FBSnapshotTestCase/FBSnapshotTestController.m b/examples/node_modules/react-native/Libraries/RCTTest/FBSnapshotTestCase/FBSnapshotTestController.m deleted file mode 100644 index 7d7d3294..00000000 --- a/examples/node_modules/react-native/Libraries/RCTTest/FBSnapshotTestCase/FBSnapshotTestController.m +++ /dev/null @@ -1,392 +0,0 @@ -/* - * Copyright (c) 2013, 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. - * - */ - -#import "FBSnapshotTestController.h" - -#import "UIImage+Compare.h" -#import "UIImage+Diff.h" - -#import - -#import - -NSString *const FBSnapshotTestControllerErrorDomain = @"FBSnapshotTestControllerErrorDomain"; - -NSString *const FBReferenceImageFilePathKey = @"FBReferenceImageFilePathKey"; - -typedef struct RGBAPixel { - char r; - char g; - char b; - char a; -} RGBAPixel; - -@interface FBSnapshotTestController () - -@property (readonly, nonatomic, copy) NSString *testName; - -@end - -@implementation FBSnapshotTestController -{ - NSFileManager *_fileManager; -} - -#pragma mark - -#pragma mark Lifecycle - -- (id)initWithTestClass:(Class)testClass; -{ - return [self initWithTestName:NSStringFromClass(testClass)]; -} - -- (id)initWithTestName:(NSString *)testName -{ - if ((self = [super init])) { - _testName = [testName copy]; - _fileManager = [NSFileManager new]; - } - return self; -} - -#pragma mark - -#pragma mark Properties - -- (NSString *)description -{ - return [NSString stringWithFormat:@"%@ %@", [super description], _referenceImagesDirectory]; -} - -#pragma mark - -#pragma mark Public API - -- (UIImage *)referenceImageForSelector:(SEL)selector - identifier:(NSString *)identifier - error:(NSError **)errorPtr -{ - NSString *filePath = [self _referenceFilePathForSelector:selector identifier:identifier]; - UIImage *image = [UIImage imageWithContentsOfFile:filePath]; - if (nil == image && NULL != errorPtr) { - BOOL exists = [_fileManager fileExistsAtPath:filePath]; - if (!exists) { - *errorPtr = [NSError errorWithDomain:FBSnapshotTestControllerErrorDomain - code:FBSnapshotTestControllerErrorCodeNeedsRecord - userInfo:@{ - FBReferenceImageFilePathKey: filePath, - NSLocalizedDescriptionKey: @"Unable to load reference image.", - NSLocalizedFailureReasonErrorKey: @"Reference image not found. You need to run the test in record mode", - }]; - } else { - *errorPtr = [NSError errorWithDomain:FBSnapshotTestControllerErrorDomain - code:FBSnapshotTestControllerErrorCodeUnknown - userInfo:nil]; - } - } - return image; -} - -- (BOOL)saveReferenceImage:(UIImage *)image - selector:(SEL)selector - identifier:(NSString *)identifier - error:(NSError **)errorPtr -{ - BOOL didWrite = NO; - if (nil != image) { - NSString *filePath = [self _referenceFilePathForSelector:selector identifier:identifier]; - NSData *pngData = UIImagePNGRepresentation(image); - if (nil != pngData) { - NSError *creationError = nil; - BOOL didCreateDir = [_fileManager createDirectoryAtPath:[filePath stringByDeletingLastPathComponent] - withIntermediateDirectories:YES - attributes:nil - error:&creationError]; - if (!didCreateDir) { - if (NULL != errorPtr) { - *errorPtr = creationError; - } - return NO; - } - didWrite = [pngData writeToFile:filePath options:NSDataWritingAtomic error:errorPtr]; - if (didWrite) { - NSLog(@"Reference image save at: %@", filePath); - } - } else { - if (nil != errorPtr) { - *errorPtr = [NSError errorWithDomain:FBSnapshotTestControllerErrorDomain - code:FBSnapshotTestControllerErrorCodePNGCreationFailed - userInfo:@{ - FBReferenceImageFilePathKey: filePath, - }]; - } - } - } - return didWrite; -} - -- (BOOL)saveFailedReferenceImage:(UIImage *)referenceImage - testImage:(UIImage *)testImage - selector:(SEL)selector - identifier:(NSString *)identifier - error:(NSError **)errorPtr -{ - NSData *referencePNGData = UIImagePNGRepresentation(referenceImage); - NSData *testPNGData = UIImagePNGRepresentation(testImage); - - NSString *referencePath = [self _failedFilePathForSelector:selector - identifier:identifier - fileNameType:FBTestSnapshotFileNameTypeFailedReference]; - - NSError *creationError = nil; - BOOL didCreateDir = [_fileManager createDirectoryAtPath:[referencePath stringByDeletingLastPathComponent] - withIntermediateDirectories:YES - attributes:nil - error:&creationError]; - if (!didCreateDir) { - if (NULL != errorPtr) { - *errorPtr = creationError; - } - return NO; - } - - if (![referencePNGData writeToFile:referencePath options:NSDataWritingAtomic error:errorPtr]) { - return NO; - } - - NSString *testPath = [self _failedFilePathForSelector:selector - identifier:identifier - fileNameType:FBTestSnapshotFileNameTypeFailedTest]; - - if (![testPNGData writeToFile:testPath options:NSDataWritingAtomic error:errorPtr]) { - return NO; - } - - NSString *diffPath = [self _failedFilePathForSelector:selector - identifier:identifier - fileNameType:FBTestSnapshotFileNameTypeFailedTestDiff]; - - UIImage *diffImage = [referenceImage diffWithImage:testImage]; - NSData *diffImageData = UIImagePNGRepresentation(diffImage); - - if (![diffImageData writeToFile:diffPath options:NSDataWritingAtomic error:errorPtr]) { - return NO; - } - - NSLog(@"If you have Kaleidoscope installed you can run this command to see an image diff:\n" - @"ksdiff \"%@\" \"%@\"", referencePath, testPath); - - return YES; -} - -- (BOOL)compareReferenceImage:(UIImage *)referenceImage toImage:(UIImage *)image error:(NSError **)errorPtr -{ - if (CGSizeEqualToSize(referenceImage.size, image.size)) { - - BOOL imagesEqual = [referenceImage compareWithImage:image]; - if (NULL != errorPtr) { - *errorPtr = [NSError errorWithDomain:FBSnapshotTestControllerErrorDomain - code:FBSnapshotTestControllerErrorCodeImagesDifferent - userInfo:@{ - NSLocalizedDescriptionKey: @"Images different", - }]; - } - return imagesEqual; - } - if (NULL != errorPtr) { - *errorPtr = [NSError errorWithDomain:FBSnapshotTestControllerErrorDomain - code:FBSnapshotTestControllerErrorCodeImagesDifferentSizes - userInfo:@{ - NSLocalizedDescriptionKey: @"Images different sizes", - NSLocalizedFailureReasonErrorKey: [NSString stringWithFormat:@"referenceImage:%@, image:%@", - NSStringFromCGSize(referenceImage.size), - NSStringFromCGSize(image.size)], - }]; - } - return NO; -} - -#pragma mark - -#pragma mark Private API - -typedef NS_ENUM(NSUInteger, FBTestSnapshotFileNameType) { - FBTestSnapshotFileNameTypeReference, - FBTestSnapshotFileNameTypeFailedReference, - FBTestSnapshotFileNameTypeFailedTest, - FBTestSnapshotFileNameTypeFailedTestDiff, -}; - -- (NSString *)_fileNameForSelector:(SEL)selector - identifier:(NSString *)identifier - fileNameType:(FBTestSnapshotFileNameType)fileNameType -{ - NSString *fileName = nil; - switch (fileNameType) { - case FBTestSnapshotFileNameTypeFailedReference: - fileName = @"reference_"; - break; - case FBTestSnapshotFileNameTypeFailedTest: - fileName = @"failed_"; - break; - case FBTestSnapshotFileNameTypeFailedTestDiff: - fileName = @"diff_"; - break; - default: - fileName = @""; - break; - } - fileName = [fileName stringByAppendingString:NSStringFromSelector(selector)]; - if (0 < identifier.length) { - fileName = [fileName stringByAppendingFormat:@"_%@", identifier]; - } - if ([[UIScreen mainScreen] scale] > 1.0) { - fileName = [fileName stringByAppendingFormat:@"@%.fx", [[UIScreen mainScreen] scale]]; - } - fileName = [fileName stringByAppendingPathExtension:@"png"]; - return fileName; -} - -- (NSString *)_referenceFilePathForSelector:(SEL)selector identifier:(NSString *)identifier -{ - NSString *fileName = [self _fileNameForSelector:selector - identifier:identifier - fileNameType:FBTestSnapshotFileNameTypeReference]; - NSString *filePath = [_referenceImagesDirectory stringByAppendingPathComponent:_testName]; - filePath = [filePath stringByAppendingPathComponent:fileName]; - return filePath; -} - -- (NSString *)_failedFilePathForSelector:(SEL)selector - identifier:(NSString *)identifier - fileNameType:(FBTestSnapshotFileNameType)fileNameType -{ - NSString *fileName = [self _fileNameForSelector:selector - identifier:identifier - fileNameType:fileNameType]; - NSString *folderPath = NSTemporaryDirectory(); - if (getenv("IMAGE_DIFF_DIR")) { - folderPath = @(getenv("IMAGE_DIFF_DIR")); - } - NSString *filePath = [folderPath stringByAppendingPathComponent:_testName]; - filePath = [filePath stringByAppendingPathComponent:fileName]; - return filePath; -} - -- (BOOL)compareSnapshotOfLayer:(CALayer *)layer - selector:(SEL)selector - identifier:(NSString *)identifier - error:(NSError **)errorPtr -{ - return [self compareSnapshotOfViewOrLayer:layer - selector:selector - identifier:identifier - error:errorPtr]; -} - -- (BOOL)compareSnapshotOfView:(UIView *)view - selector:(SEL)selector - identifier:(NSString *)identifier - error:(NSError **)errorPtr -{ - return [self compareSnapshotOfViewOrLayer:view - selector:selector - identifier:identifier - error:errorPtr]; -} - -- (BOOL)compareSnapshotOfViewOrLayer:(id)viewOrLayer - selector:(SEL)selector - identifier:(NSString *)identifier - error:(NSError **)errorPtr -{ - if (self.recordMode) { - return [self _recordSnapshotOfViewOrLayer:viewOrLayer selector:selector identifier:identifier error:errorPtr]; - } else { - return [self _performPixelComparisonWithViewOrLayer:viewOrLayer selector:selector identifier:identifier error:errorPtr]; - } -} - -#pragma mark - -#pragma mark Private API - -- (BOOL)_performPixelComparisonWithViewOrLayer:(UIView *)viewOrLayer - selector:(SEL)selector - identifier:(NSString *)identifier - error:(NSError **)errorPtr -{ - UIImage *referenceImage = [self referenceImageForSelector:selector identifier:identifier error:errorPtr]; - if (nil != referenceImage) { - UIImage *snapshot = [self _snapshotViewOrLayer:viewOrLayer]; - BOOL imagesSame = [self compareReferenceImage:referenceImage toImage:snapshot error:errorPtr]; - if (!imagesSame) { - [self saveFailedReferenceImage:referenceImage - testImage:snapshot - selector:selector - identifier:identifier - error:errorPtr]; - } - return imagesSame; - } - return NO; -} - -- (BOOL)_recordSnapshotOfViewOrLayer:(id)viewOrLayer - selector:(SEL)selector - identifier:(NSString *)identifier - error:(NSError **)errorPtr -{ - UIImage *snapshot = [self _snapshotViewOrLayer:viewOrLayer]; - return [self saveReferenceImage:snapshot selector:selector identifier:identifier error:errorPtr]; -} - -- (UIImage *)_snapshotViewOrLayer:(id)viewOrLayer -{ - CALayer *layer = nil; - - if ([viewOrLayer isKindOfClass:[UIView class]]) { - return [self _renderView:viewOrLayer]; - } else if ([viewOrLayer isKindOfClass:[CALayer class]]) { - layer = (CALayer *)viewOrLayer; - [layer layoutIfNeeded]; - return [self _renderLayer:layer]; - } else { - [NSException raise:@"Only UIView and CALayer classes can be snapshotted" format:@"%@", viewOrLayer]; - } - return nil; -} - -- (UIImage *)_renderLayer:(CALayer *)layer -{ - CGRect bounds = layer.bounds; - - NSAssert1(CGRectGetWidth(bounds), @"Zero width for layer %@", layer); - NSAssert1(CGRectGetHeight(bounds), @"Zero height for layer %@", layer); - - UIGraphicsBeginImageContextWithOptions(bounds.size, NO, 0); - CGContextRef context = UIGraphicsGetCurrentContext(); - NSAssert1(context, @"Could not generate context for layer %@", layer); - - CGContextSaveGState(context); - { - [layer renderInContext:context]; - } - CGContextRestoreGState(context); - - UIImage *snapshot = UIGraphicsGetImageFromCurrentImageContext(); - UIGraphicsEndImageContext(); - - return snapshot; -} - -- (UIImage *)_renderView:(UIView *)view -{ - [view layoutIfNeeded]; - return [self _renderLayer:view.layer]; -} - -@end diff --git a/examples/node_modules/react-native/Libraries/RCTTest/FBSnapshotTestCase/UIImage+Compare.h b/examples/node_modules/react-native/Libraries/RCTTest/FBSnapshotTestCase/UIImage+Compare.h deleted file mode 100644 index 11c6fa63..00000000 --- a/examples/node_modules/react-native/Libraries/RCTTest/FBSnapshotTestCase/UIImage+Compare.h +++ /dev/null @@ -1,37 +0,0 @@ -// -// Created by Gabriel Handford on 3/1/09. -// Copyright 2009-2013. All rights reserved. -// Created by John Boiles on 10/20/11. -// Copyright (c) 2011. All rights reserved -// Modified by Felix Schulze on 2/11/13. -// Copyright 2013. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person -// obtaining a copy of this software and associated documentation -// files (the "Software"), to deal in the Software without -// restriction, including without limitation the rights to use, -// copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following -// conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -// OTHER DEALINGS IN THE SOFTWARE. -// - -#import - -@interface UIImage (Compare) - -- (BOOL)compareWithImage:(UIImage *)image; - -@end diff --git a/examples/node_modules/react-native/Libraries/RCTTest/FBSnapshotTestCase/UIImage+Compare.m b/examples/node_modules/react-native/Libraries/RCTTest/FBSnapshotTestCase/UIImage+Compare.m deleted file mode 100644 index 0bd83ba3..00000000 --- a/examples/node_modules/react-native/Libraries/RCTTest/FBSnapshotTestCase/UIImage+Compare.m +++ /dev/null @@ -1,91 +0,0 @@ -// -// Created by Gabriel Handford on 3/1/09. -// Copyright 2009-2013. All rights reserved. -// Created by John Boiles on 10/20/11. -// Copyright (c) 2011. All rights reserved -// Modified by Felix Schulze on 2/11/13. -// Copyright 2013. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person -// obtaining a copy of this software and associated documentation -// files (the "Software"), to deal in the Software without -// restriction, including without limitation the rights to use, -// copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following -// conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -// OTHER DEALINGS IN THE SOFTWARE. -// - -#import "UIImage+Compare.h" - -@implementation UIImage (Compare) - -- (BOOL)compareWithImage:(UIImage *)image -{ - NSAssert(CGSizeEqualToSize(self.size, image.size), @"Images must be same size."); - - // The images have the equal size, so we could use the smallest amount of bytes because of byte padding - size_t minBytesPerRow = MIN(CGImageGetBytesPerRow(self.CGImage), CGImageGetBytesPerRow(image.CGImage)); - size_t referenceImageSizeBytes = CGImageGetHeight(self.CGImage) * minBytesPerRow; - void *referenceImagePixels = calloc(1, referenceImageSizeBytes); - void *imagePixels = calloc(1, referenceImageSizeBytes); - - if (!referenceImagePixels || !imagePixels) { - free(referenceImagePixels); - free(imagePixels); - return NO; - } - - CGContextRef referenceImageContext = CGBitmapContextCreate(referenceImagePixels, - CGImageGetWidth(self.CGImage), - CGImageGetHeight(self.CGImage), - CGImageGetBitsPerComponent(self.CGImage), - minBytesPerRow, - CGImageGetColorSpace(self.CGImage), - (CGBitmapInfo)kCGImageAlphaPremultipliedLast - ); - CGContextRef imageContext = CGBitmapContextCreate(imagePixels, - CGImageGetWidth(image.CGImage), - CGImageGetHeight(image.CGImage), - CGImageGetBitsPerComponent(image.CGImage), - minBytesPerRow, - CGImageGetColorSpace(image.CGImage), - (CGBitmapInfo)kCGImageAlphaPremultipliedLast - ); - - CGFloat scaleFactor = [UIScreen mainScreen].scale; - CGContextScaleCTM(referenceImageContext, scaleFactor, scaleFactor); - CGContextScaleCTM(imageContext, scaleFactor, scaleFactor); - - if (!referenceImageContext || !imageContext) { - CGContextRelease(referenceImageContext); - CGContextRelease(imageContext); - free(referenceImagePixels); - free(imagePixels); - return NO; - } - - CGContextDrawImage(referenceImageContext, CGRectMake(0.0f, 0.0f, self.size.width, self.size.height), self.CGImage); - CGContextDrawImage(imageContext, CGRectMake(0.0f, 0.0f, image.size.width, image.size.height), image.CGImage); - CGContextRelease(referenceImageContext); - CGContextRelease(imageContext); - - BOOL imageEqual = (memcmp(referenceImagePixels, imagePixels, referenceImageSizeBytes) == 0); - free(referenceImagePixels); - free(imagePixels); - return imageEqual; -} - -@end diff --git a/examples/node_modules/react-native/Libraries/RCTTest/FBSnapshotTestCase/UIImage+Diff.h b/examples/node_modules/react-native/Libraries/RCTTest/FBSnapshotTestCase/UIImage+Diff.h deleted file mode 100644 index 35595843..00000000 --- a/examples/node_modules/react-native/Libraries/RCTTest/FBSnapshotTestCase/UIImage+Diff.h +++ /dev/null @@ -1,37 +0,0 @@ -// -// Created by Gabriel Handford on 3/1/09. -// Copyright 2009-2013. All rights reserved. -// Created by John Boiles on 10/20/11. -// Copyright (c) 2011. All rights reserved -// Modified by Felix Schulze on 2/11/13. -// Copyright 2013. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person -// obtaining a copy of this software and associated documentation -// files (the "Software"), to deal in the Software without -// restriction, including without limitation the rights to use, -// copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following -// conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -// OTHER DEALINGS IN THE SOFTWARE. -// - -#import - -@interface UIImage (Diff) - -- (UIImage *)diffWithImage:(UIImage *)image; - -@end diff --git a/examples/node_modules/react-native/Libraries/RCTTest/FBSnapshotTestCase/UIImage+Diff.m b/examples/node_modules/react-native/Libraries/RCTTest/FBSnapshotTestCase/UIImage+Diff.m deleted file mode 100644 index 44ecb59e..00000000 --- a/examples/node_modules/react-native/Libraries/RCTTest/FBSnapshotTestCase/UIImage+Diff.m +++ /dev/null @@ -1,56 +0,0 @@ -// -// Created by Gabriel Handford on 3/1/09. -// Copyright 2009-2013. All rights reserved. -// Created by John Boiles on 10/20/11. -// Copyright (c) 2011. All rights reserved -// Modified by Felix Schulze on 2/11/13. -// Copyright 2013. All rights reserved. -// -// Permission is hereby granted, free of charge, to any person -// obtaining a copy of this software and associated documentation -// files (the "Software"), to deal in the Software without -// restriction, including without limitation the rights to use, -// copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the -// Software is furnished to do so, subject to the following -// conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES -// OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT -// HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, -// WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING -// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR -// OTHER DEALINGS IN THE SOFTWARE. -// - -#import "UIImage+Diff.h" - -@implementation UIImage (Diff) - -- (UIImage *)diffWithImage:(UIImage *)image -{ - if (!image) { - return nil; - } - CGSize imageSize = CGSizeMake(MAX(self.size.width, image.size.width), MAX(self.size.height, image.size.height)); - UIGraphicsBeginImageContextWithOptions(imageSize, YES, 0.0); - CGContextRef context = UIGraphicsGetCurrentContext(); - [self drawInRect:CGRectMake(0, 0, self.size.width, self.size.height)]; - CGContextSetAlpha(context, 0.5f); - CGContextBeginTransparencyLayer(context, NULL); - [image drawInRect:CGRectMake(0, 0, image.size.width, image.size.height)]; - CGContextSetBlendMode(context, kCGBlendModeDifference); - CGContextSetFillColorWithColor(context,[UIColor whiteColor].CGColor); - CGContextFillRect(context, CGRectMake(0, 0, self.size.width, self.size.height)); - CGContextEndTransparencyLayer(context); - UIImage *returnImage = UIGraphicsGetImageFromCurrentImageContext(); - UIGraphicsEndImageContext(); - return returnImage; -} - -@end diff --git a/examples/node_modules/react-native/Libraries/RCTTest/RCTTest.xcodeproj/project.pbxproj b/examples/node_modules/react-native/Libraries/RCTTest/RCTTest.xcodeproj/project.pbxproj deleted file mode 100644 index d6aa333e..00000000 --- a/examples/node_modules/react-native/Libraries/RCTTest/RCTTest.xcodeproj/project.pbxproj +++ /dev/null @@ -1,327 +0,0 @@ -// !$*UTF8*$! -{ - archiveVersion = 1; - classes = { - }; - objectVersion = 46; - objects = { - -/* Begin PBXBuildFile section */ - 585135371AB3C56F00882537 /* RCTTestModule.m in Sources */ = {isa = PBXBuildFile; fileRef = 585135341AB3C56F00882537 /* RCTTestModule.m */; }; - 585135381AB3C57000882537 /* RCTTestRunner.m in Sources */ = {isa = PBXBuildFile; fileRef = 585135361AB3C56F00882537 /* RCTTestRunner.m */; }; - 585135391AB3C59A00882537 /* RCTTestRunner.h in CopyFiles */ = {isa = PBXBuildFile; fileRef = 585135351AB3C56F00882537 /* RCTTestRunner.h */; }; - 58E64FED1AB964CD007446E2 /* FBSnapshotTestController.m in Sources */ = {isa = PBXBuildFile; fileRef = 58E64FE71AB964CD007446E2 /* FBSnapshotTestController.m */; }; - 58E64FEE1AB964CD007446E2 /* UIImage+Compare.m in Sources */ = {isa = PBXBuildFile; fileRef = 58E64FE91AB964CD007446E2 /* UIImage+Compare.m */; }; - 58E64FEF1AB964CD007446E2 /* UIImage+Diff.m in Sources */ = {isa = PBXBuildFile; fileRef = 58E64FEB1AB964CD007446E2 /* UIImage+Diff.m */; }; - 9913A84B1BBE833400D70E66 /* RCTSnapshotManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 9913A84A1BBE833400D70E66 /* RCTSnapshotManager.m */; }; -/* End PBXBuildFile section */ - -/* Begin PBXCopyFilesBuildPhase section */ - 580C376D1AB104AF0015E709 /* CopyFiles */ = { - isa = PBXCopyFilesBuildPhase; - buildActionMask = 2147483647; - dstPath = "include/$(PRODUCT_NAME)"; - dstSubfolderSpec = 16; - files = ( - 585135391AB3C59A00882537 /* RCTTestRunner.h in CopyFiles */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXCopyFilesBuildPhase section */ - -/* Begin PBXFileReference section */ - 580C376F1AB104AF0015E709 /* libRCTTest.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRCTTest.a; sourceTree = BUILT_PRODUCTS_DIR; }; - 585135331AB3C56F00882537 /* RCTTestModule.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTTestModule.h; sourceTree = ""; }; - 585135341AB3C56F00882537 /* RCTTestModule.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTTestModule.m; sourceTree = ""; }; - 585135351AB3C56F00882537 /* RCTTestRunner.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTTestRunner.h; sourceTree = ""; }; - 585135361AB3C56F00882537 /* RCTTestRunner.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTTestRunner.m; sourceTree = ""; }; - 58E64FE41AB964CD007446E2 /* FBSnapshotTestCase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FBSnapshotTestCase.h; sourceTree = ""; }; - 58E64FE51AB964CD007446E2 /* FBSnapshotTestCase.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FBSnapshotTestCase.m; sourceTree = ""; }; - 58E64FE61AB964CD007446E2 /* FBSnapshotTestController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FBSnapshotTestController.h; sourceTree = ""; }; - 58E64FE71AB964CD007446E2 /* FBSnapshotTestController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = FBSnapshotTestController.m; sourceTree = ""; }; - 58E64FE81AB964CD007446E2 /* UIImage+Compare.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIImage+Compare.h"; sourceTree = ""; }; - 58E64FE91AB964CD007446E2 /* UIImage+Compare.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIImage+Compare.m"; sourceTree = ""; }; - 58E64FEA1AB964CD007446E2 /* UIImage+Diff.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIImage+Diff.h"; sourceTree = ""; }; - 58E64FEB1AB964CD007446E2 /* UIImage+Diff.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIImage+Diff.m"; sourceTree = ""; }; - 9913A8491BBE833400D70E66 /* RCTSnapshotManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTSnapshotManager.h; sourceTree = ""; }; - 9913A84A1BBE833400D70E66 /* RCTSnapshotManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTSnapshotManager.m; sourceTree = ""; }; -/* End PBXFileReference section */ - -/* Begin PBXFrameworksBuildPhase section */ - 580C376C1AB104AF0015E709 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXFrameworksBuildPhase section */ - -/* Begin PBXGroup section */ - 580C37661AB104AF0015E709 = { - isa = PBXGroup; - children = ( - 58E64FE31AB964CD007446E2 /* FBSnapshotTestCase */, - 9913A8491BBE833400D70E66 /* RCTSnapshotManager.h */, - 9913A84A1BBE833400D70E66 /* RCTSnapshotManager.m */, - 585135331AB3C56F00882537 /* RCTTestModule.h */, - 585135341AB3C56F00882537 /* RCTTestModule.m */, - 585135351AB3C56F00882537 /* RCTTestRunner.h */, - 585135361AB3C56F00882537 /* RCTTestRunner.m */, - 580C37701AB104AF0015E709 /* Products */, - ); - indentWidth = 2; - sourceTree = ""; - tabWidth = 2; - }; - 580C37701AB104AF0015E709 /* Products */ = { - isa = PBXGroup; - children = ( - 580C376F1AB104AF0015E709 /* libRCTTest.a */, - ); - name = Products; - sourceTree = ""; - }; - 58E64FE31AB964CD007446E2 /* FBSnapshotTestCase */ = { - isa = PBXGroup; - children = ( - 58E64FE41AB964CD007446E2 /* FBSnapshotTestCase.h */, - 58E64FE51AB964CD007446E2 /* FBSnapshotTestCase.m */, - 58E64FE61AB964CD007446E2 /* FBSnapshotTestController.h */, - 58E64FE71AB964CD007446E2 /* FBSnapshotTestController.m */, - 58E64FE81AB964CD007446E2 /* UIImage+Compare.h */, - 58E64FE91AB964CD007446E2 /* UIImage+Compare.m */, - 58E64FEA1AB964CD007446E2 /* UIImage+Diff.h */, - 58E64FEB1AB964CD007446E2 /* UIImage+Diff.m */, - ); - path = FBSnapshotTestCase; - sourceTree = ""; - }; -/* End PBXGroup section */ - -/* Begin PBXNativeTarget section */ - 580C376E1AB104AF0015E709 /* RCTTest */ = { - isa = PBXNativeTarget; - buildConfigurationList = 580C37831AB104AF0015E709 /* Build configuration list for PBXNativeTarget "RCTTest" */; - buildPhases = ( - 580C376B1AB104AF0015E709 /* Sources */, - 580C376C1AB104AF0015E709 /* Frameworks */, - 580C376D1AB104AF0015E709 /* CopyFiles */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = RCTTest; - productName = RCTTest; - productReference = 580C376F1AB104AF0015E709 /* libRCTTest.a */; - productType = "com.apple.product-type.library.static"; - }; -/* End PBXNativeTarget section */ - -/* Begin PBXProject section */ - 580C37671AB104AF0015E709 /* Project object */ = { - isa = PBXProject; - attributes = { - LastUpgradeCheck = 0610; - ORGANIZATIONNAME = Facebook; - TargetAttributes = { - 580C376E1AB104AF0015E709 = { - CreatedOnToolsVersion = 6.1.1; - }; - }; - }; - buildConfigurationList = 580C376A1AB104AF0015E709 /* Build configuration list for PBXProject "RCTTest" */; - compatibilityVersion = "Xcode 3.2"; - developmentRegion = English; - hasScannedForEncodings = 0; - knownRegions = ( - en, - ); - mainGroup = 580C37661AB104AF0015E709; - productRefGroup = 580C37701AB104AF0015E709 /* Products */; - projectDirPath = ""; - projectRoot = ""; - targets = ( - 580C376E1AB104AF0015E709 /* RCTTest */, - ); - }; -/* End PBXProject section */ - -/* Begin PBXSourcesBuildPhase section */ - 580C376B1AB104AF0015E709 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 58E64FEE1AB964CD007446E2 /* UIImage+Compare.m in Sources */, - 9913A84B1BBE833400D70E66 /* RCTSnapshotManager.m in Sources */, - 585135371AB3C56F00882537 /* RCTTestModule.m in Sources */, - 58E64FEF1AB964CD007446E2 /* UIImage+Diff.m in Sources */, - 58E64FED1AB964CD007446E2 /* FBSnapshotTestController.m in Sources */, - 585135381AB3C57000882537 /* RCTTestRunner.m in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXSourcesBuildPhase section */ - -/* Begin XCBuildConfiguration section */ - 580C37811AB104AF0015E709 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - COPY_PHASE_STRIP = NO; - ENABLE_STRICT_OBJC_MSGSEND = YES; - GCC_C_LANGUAGE_STANDARD = gnu99; - GCC_DYNAMIC_NO_PIC = NO; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", - "$(inherited)", - ); - GCC_SYMBOLS_PRIVATE_EXTERN = NO; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES; - GCC_WARN_SHADOW = YES; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - HEADER_SEARCH_PATHS = ( - "$(inherited)", - /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, - "$(SRCROOT)/../../React/**", - ); - IPHONEOS_DEPLOYMENT_TARGET = 8.1; - MTL_ENABLE_DEBUG_INFO = YES; - ONLY_ACTIVE_ARCH = YES; - SDKROOT = iphoneos; - WARNING_CFLAGS = ( - "-Werror", - "-Wall", - ); - }; - name = Debug; - }; - 580C37821AB104AF0015E709 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - COPY_PHASE_STRIP = YES; - ENABLE_NS_ASSERTIONS = NO; - ENABLE_STRICT_OBJC_MSGSEND = YES; - GCC_C_LANGUAGE_STANDARD = gnu99; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES; - GCC_WARN_SHADOW = YES; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - HEADER_SEARCH_PATHS = ( - "$(inherited)", - /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, - "$(SRCROOT)/../../React/**", - ); - IPHONEOS_DEPLOYMENT_TARGET = 8.1; - MTL_ENABLE_DEBUG_INFO = NO; - SDKROOT = iphoneos; - VALIDATE_PRODUCT = YES; - WARNING_CFLAGS = ( - "-Werror", - "-Wall", - ); - }; - name = Release; - }; - 580C37841AB104AF0015E709 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - CLANG_STATIC_ANALYZER_MODE = deep; - HEADER_SEARCH_PATHS = ( - "$(inherited)", - /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, - "$(SRCROOT)/../../React/**", - ); - OTHER_LDFLAGS = ( - "-ObjC", - "-framework", - XCTest, - ); - PRODUCT_NAME = "$(TARGET_NAME)"; - RUN_CLANG_STATIC_ANALYZER = YES; - SKIP_INSTALL = YES; - }; - name = Debug; - }; - 580C37851AB104AF0015E709 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - CLANG_STATIC_ANALYZER_MODE = deep; - HEADER_SEARCH_PATHS = ( - "$(inherited)", - /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, - "$(SRCROOT)/../../React/**", - ); - OTHER_LDFLAGS = ( - "-ObjC", - "-framework", - XCTest, - ); - PRODUCT_NAME = "$(TARGET_NAME)"; - SKIP_INSTALL = YES; - }; - name = Release; - }; -/* End XCBuildConfiguration section */ - -/* Begin XCConfigurationList section */ - 580C376A1AB104AF0015E709 /* Build configuration list for PBXProject "RCTTest" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 580C37811AB104AF0015E709 /* Debug */, - 580C37821AB104AF0015E709 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 580C37831AB104AF0015E709 /* Build configuration list for PBXNativeTarget "RCTTest" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 580C37841AB104AF0015E709 /* Debug */, - 580C37851AB104AF0015E709 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; -/* End XCConfigurationList section */ - }; - rootObject = 580C37671AB104AF0015E709 /* Project object */; -} diff --git a/examples/node_modules/react-native/Libraries/RCTTest/RCTTestModule.h b/examples/node_modules/react-native/Libraries/RCTTest/RCTTestModule.h deleted file mode 100644 index 06c408be..00000000 --- a/examples/node_modules/react-native/Libraries/RCTTest/RCTTestModule.h +++ /dev/null @@ -1,45 +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. - */ - -#import - -#import "RCTBridgeModule.h" -#import "RCTDefines.h" - -typedef NS_ENUM(NSInteger, RCTTestStatus) { - RCTTestStatusPending = 0, - RCTTestStatusPassed, - RCTTestStatusFailed -}; - -@class FBSnapshotTestController; - -@interface RCTTestModule : NSObject - -/** - * The snapshot test controller for this module. - */ -@property (nonatomic, strong) FBSnapshotTestController *controller; - -/** - * This is the view to be snapshotted. - */ -@property (nonatomic, strong) UIView *view; - -/** - * This is used to give meaningful names to snapshot image files. - */ -@property (nonatomic, assign) SEL testSelector; - -/** - * This is polled while running the runloop until true. - */ -@property (nonatomic, readonly) RCTTestStatus status; - -@end diff --git a/examples/node_modules/react-native/Libraries/RCTTest/RCTTestModule.m b/examples/node_modules/react-native/Libraries/RCTTest/RCTTestModule.m deleted file mode 100644 index 0692543e..00000000 --- a/examples/node_modules/react-native/Libraries/RCTTest/RCTTestModule.m +++ /dev/null @@ -1,80 +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. - */ - -#import "RCTTestModule.h" - -#import "FBSnapshotTestController.h" -#import "RCTAssert.h" -#import "RCTEventDispatcher.h" -#import "RCTLog.h" -#import "RCTUIManager.h" - -@implementation RCTTestModule -{ - NSMutableDictionary *_snapshotCounter; -} - -@synthesize bridge = _bridge; - -RCT_EXPORT_MODULE() - -- (dispatch_queue_t)methodQueue -{ - return _bridge.uiManager.methodQueue; -} - -RCT_EXPORT_METHOD(verifySnapshot:(RCTResponseSenderBlock)callback) -{ - RCTAssert(_controller != nil, @"No snapshot controller configured."); - - [_bridge.uiManager addUIBlock:^(RCTUIManager *uiManager, NSDictionary *viewRegistry) { - - NSString *testName = NSStringFromSelector(_testSelector); - if (!_snapshotCounter) { - _snapshotCounter = [NSMutableDictionary new]; - } - _snapshotCounter[testName] = (@([_snapshotCounter[testName] integerValue] + 1)).stringValue; - - NSError *error = nil; - BOOL success = [_controller compareSnapshotOfView:_view - selector:_testSelector - identifier:_snapshotCounter[testName] - error:&error]; - callback(@[@(success)]); - }]; -} - -RCT_EXPORT_METHOD(sendAppEvent:(NSString *)name body:(nullable id)body) -{ - [_bridge.eventDispatcher sendAppEventWithName:name body:body]; -} - -RCT_REMAP_METHOD(shouldResolve, shouldResolve_resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject) -{ - resolve(@1); -} - -RCT_REMAP_METHOD(shouldReject, shouldReject_resolve:(RCTPromiseResolveBlock)resolve reject:(RCTPromiseRejectBlock)reject) -{ - reject(nil); -} - -RCT_EXPORT_METHOD(markTestCompleted) -{ - [self markTestPassed:YES]; -} - -RCT_EXPORT_METHOD(markTestPassed:(BOOL)success) -{ - [_bridge.uiManager addUIBlock:^(__unused RCTUIManager *uiManager, __unused NSDictionary *viewRegistry) { - _status = success ? RCTTestStatusPassed : RCTTestStatusFailed; - }]; -} - -@end diff --git a/examples/node_modules/react-native/Libraries/RCTTest/RCTTestRunner.h b/examples/node_modules/react-native/Libraries/RCTTest/RCTTestRunner.h deleted file mode 100644 index b5e8430c..00000000 --- a/examples/node_modules/react-native/Libraries/RCTTest/RCTTestRunner.h +++ /dev/null @@ -1,115 +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. - */ - -#import - -#ifndef FB_REFERENCE_IMAGE_DIR -#define FB_REFERENCE_IMAGE_DIR "" -#endif - -/** - * Use the RCTInitRunnerForApp macro for typical usage. See FBSnapshotTestCase.h for more information - * on how to configure the snapshotting system. - */ -#define RCTInitRunnerForApp(app__, moduleProvider__) \ -[[RCTTestRunner alloc] initWithApp:(app__) \ - referenceDirectory:@FB_REFERENCE_IMAGE_DIR \ - moduleProvider:(moduleProvider__)] - -@protocol RCTBridgeModule; -@class RCTBridge; - -@class RCTRootView; - -@interface RCTTestRunner : NSObject - -/** - * Controls the mode snapshots are run in. If set to true, new snapshots are written to disk, - * otherwise, the UI will be compared to the existing snapshot. - */ -@property (nonatomic, assign) BOOL recordMode; - -@property (nonatomic, readonly) NSURL *scriptURL; - -/** - * Initialize a runner. It's recommended that you use the RCTInitRunnerForApp - * macro instead of calling this directly. - * - * @param app The path to the app bundle without suffixes, e.g. IntegrationTests/IntegrationTestsApp - * @param referenceDirectory The path for snapshot references images. - * @param block A block that returns an array of extra modules to be used by the test runner. - */ -- (instancetype)initWithApp:(NSString *)app - referenceDirectory:(NSString *)referenceDirectory - moduleProvider:(NSArray> *(^)(void))block NS_DESIGNATED_INITIALIZER; - -/** - * Simplest runTest function simply mounts the specified JS module with no - * initialProps and waits for it to call - * - * RCTTestModule.markTestCompleted() - * - * JS errors/exceptions and timeouts will fail the test. Snapshot tests call - * RCTTestModule.verifySnapshot whenever they want to verify what has been - * rendered (typically via requestAnimationFrame to make sure the latest state - * has been rendered in native. - * - * @param test Selector of the test, usually just `_cmd`. - * @param moduleName Name of the JS component as registered by `AppRegistry.registerComponent` in JS. - */ -- (void)runTest:(SEL)test module:(NSString *)moduleName; - -/** - * Same as runTest:, but allows for passing initialProps for providing mock data - * or requesting different behaviors, configurationBlock provides arbitrary logic for the hosting - * root view manipulation. - * - * @param test Selector of the test, usually just `_cmd`. - * @param moduleName Name of the JS component as registered by `AppRegistry.registerComponent` in JS. - * @param initialProps props that are passed into the component when rendered. - * @param configurationBlock A block that takes the hosting root view and performs arbitrary manipulation after its creation. - */ -- (void)runTest:(SEL)test module:(NSString *)moduleName - initialProps:(NSDictionary *)initialProps -configurationBlock:(void(^)(RCTRootView *rootView))configurationBlock; - -/** - * Same as runTest:, but allows for passing initialProps for providing mock data - * or requesting different behaviors, configurationBlock provides arbitrary logic for the hosting - * root view manipulation, and expectErrorRegex verifies that the error you expected was thrown. - * - * @param test Selector of the test, usually just `_cmd`. - * @param moduleName Name of the JS component as registered by `AppRegistry.registerComponent` in JS. - * @param initialProps props that are passed into the component when rendered. - * @param configurationBlock A block that takes the hosting root view and performs arbitrary manipulation after its creation. - * @param expectErrorRegex A regex that must match the error thrown. If no error is thrown, the test fails. - */ -- (void)runTest:(SEL)test module:(NSString *)moduleName - initialProps:(NSDictionary *)initialProps -configurationBlock:(void(^)(RCTRootView *rootView))configurationBlock -expectErrorRegex:(NSString *)expectErrorRegex; - -/** - * Same as runTest:, but allows for passing initialProps for providing mock data - * or requesting different behaviors, configurationBlock provides arbitrary logic for the hosting - * root view manipulation, and expectErrorBlock provides arbitrary - * logic for processing errors (nil will cause any error to fail the test). - * - * @param test Selector of the test, usually just `_cmd`. - * @param moduleName Name of the JS component as registered by `AppRegistry.registerComponent` in JS. - * @param initialProps props that are passed into the component when rendered. - * @param configurationBlock A block that takes the hosting root view and performs arbitrary manipulation after its creation. - * @param expectErrorBlock A block that takes the error message and returns NO to fail the test. - */ -- (void)runTest:(SEL)test module:(NSString *)moduleName - initialProps:(NSDictionary *)initialProps -configurationBlock:(void(^)(RCTRootView *rootView))configurationBlock -expectErrorBlock:(BOOL(^)(NSString *error))expectErrorBlock; - -@end diff --git a/examples/node_modules/react-native/Libraries/RCTTest/RCTTestRunner.m b/examples/node_modules/react-native/Libraries/RCTTest/RCTTestRunner.m deleted file mode 100644 index 6c2e9b5d..00000000 --- a/examples/node_modules/react-native/Libraries/RCTTest/RCTTestRunner.m +++ /dev/null @@ -1,169 +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. - */ - -#import "RCTTestRunner.h" - -#import "FBSnapshotTestController.h" -#import "RCTAssert.h" -#import "RCTLog.h" -#import "RCTRootView.h" -#import "RCTTestModule.h" -#import "RCTUtils.h" -#import "RCTContextExecutor.h" - -static const NSTimeInterval kTestTimeoutSeconds = 60; -static const NSTimeInterval kTestTeardownTimeoutSeconds = 30; - -@implementation RCTTestRunner -{ - FBSnapshotTestController *_testController; - RCTBridgeModuleProviderBlock _moduleProvider; -} - -- (instancetype)initWithApp:(NSString *)app - referenceDirectory:(NSString *)referenceDirectory - moduleProvider:(RCTBridgeModuleProviderBlock)block -{ - RCTAssertParam(app); - RCTAssertParam(referenceDirectory); - - if ((self = [super init])) { - if (!referenceDirectory.length) { - referenceDirectory = [[NSBundle bundleForClass:self.class].resourcePath stringByAppendingPathComponent:@"ReferenceImages"]; - } - - NSString *sanitizedAppName = [app stringByReplacingOccurrencesOfString:@"/" withString:@"-"]; - sanitizedAppName = [sanitizedAppName stringByReplacingOccurrencesOfString:@"\\" withString:@"-"]; - _testController = [[FBSnapshotTestController alloc] initWithTestName:sanitizedAppName]; - _testController.referenceImagesDirectory = referenceDirectory; - _moduleProvider = [block copy]; - -#if RUNNING_ON_CI - _scriptURL = [[NSBundle bundleForClass:[RCTBridge class]] URLForResource:@"main" withExtension:@"jsbundle"]; - RCTAssert(_scriptURL != nil, @"Could not locate main.jsBundle"); -#else - _scriptURL = [NSURL URLWithString:[NSString stringWithFormat:@"http://localhost:8081/%@.bundle?platform=ios&dev=true", app]]; -#endif - } - return self; -} - -RCT_NOT_IMPLEMENTED(- (instancetype)init) - -- (void)setRecordMode:(BOOL)recordMode -{ - _testController.recordMode = recordMode; -} - -- (BOOL)recordMode -{ - return _testController.recordMode; -} - -- (void)runTest:(SEL)test module:(NSString *)moduleName -{ - [self runTest:test module:moduleName initialProps:nil configurationBlock:nil expectErrorBlock:nil]; -} - -- (void)runTest:(SEL)test module:(NSString *)moduleName - initialProps:(NSDictionary *)initialProps -configurationBlock:(void(^)(RCTRootView *rootView))configurationBlock -{ - [self runTest:test module:moduleName initialProps:initialProps configurationBlock:configurationBlock expectErrorBlock:nil]; -} - -- (void)runTest:(SEL)test module:(NSString *)moduleName - initialProps:(NSDictionary *)initialProps -configurationBlock:(void(^)(RCTRootView *rootView))configurationBlock -expectErrorRegex:(NSString *)errorRegex -{ - BOOL(^expectErrorBlock)(NSString *error) = ^BOOL(NSString *error){ - return [error rangeOfString:errorRegex options:NSRegularExpressionSearch].location != NSNotFound; - }; - - [self runTest:test module:moduleName initialProps:initialProps configurationBlock:configurationBlock expectErrorBlock:expectErrorBlock]; -} - -- (void)runTest:(SEL)test module:(NSString *)moduleName - initialProps:(NSDictionary *)initialProps -configurationBlock:(void(^)(RCTRootView *rootView))configurationBlock -expectErrorBlock:(BOOL(^)(NSString *error))expectErrorBlock -{ - __weak id weakJSContext; - - @autoreleasepool { - __block NSString *error = nil; - RCTSetLogFunction(^(RCTLogLevel level, RCTLogSource source, NSString *fileName, NSNumber *lineNumber, NSString *message) { - if (level >= RCTLogLevelError) { - error = message; - } - }); - - RCTBridge *bridge = [[RCTBridge alloc] initWithBundleURL:_scriptURL - moduleProvider:_moduleProvider - launchOptions:nil]; - - RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge moduleName:moduleName initialProperties:initialProps]; - rootView.frame = CGRectMake(0, 0, 320, 2000); // Constant size for testing on multiple devices - - RCTTestModule *testModule = [rootView.bridge moduleForClass:[RCTTestModule class]]; - RCTAssert(_testController != nil, @"_testController should not be nil"); - testModule.controller = _testController; - testModule.testSelector = test; - testModule.view = rootView; - - UIViewController *vc = [UIApplication sharedApplication].delegate.window.rootViewController; - vc.view = [UIView new]; - [vc.view addSubview:rootView]; // Add as subview so it doesn't get resized - - if (configurationBlock) { - configurationBlock(rootView); - } - - NSDate *date = [NSDate dateWithTimeIntervalSinceNow:kTestTimeoutSeconds]; - while (date.timeIntervalSinceNow > 0 && testModule.status == RCTTestStatusPending && error == nil) { - [[NSRunLoop mainRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]]; - [[NSRunLoop mainRunLoop] runMode:NSRunLoopCommonModes beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]]; - } - - // Take a weak reference to the JS context, so we track its deallocation later - // (we can only do this now, since it's been lazily initialized) - id jsExecutor = [bridge valueForKeyPath:@"batchedBridge.javaScriptExecutor"]; - if ([jsExecutor isKindOfClass:[RCTContextExecutor class]]) { - weakJSContext = [jsExecutor valueForKey:@"context"]; - } - [rootView removeFromSuperview]; - - RCTSetLogFunction(RCTDefaultLogFunction); - - NSArray *nonLayoutSubviews = [vc.view.subviews filteredArrayUsingPredicate:[NSPredicate predicateWithBlock:^BOOL(id subview, NSDictionary *bindings) { - return ![NSStringFromClass([subview class]) isEqualToString:@"_UILayoutGuide"]; - }]]; - RCTAssert(nonLayoutSubviews.count == 0, @"There shouldn't be any other views: %@", nonLayoutSubviews); - - if (expectErrorBlock) { - RCTAssert(expectErrorBlock(error), @"Expected an error but nothing matched."); - } else { - RCTAssert(error == nil, @"RedBox error: %@", error); - RCTAssert(testModule.status != RCTTestStatusPending, @"Test didn't finish within %0.f seconds", kTestTimeoutSeconds); - RCTAssert(testModule.status == RCTTestStatusPassed, @"Test failed"); - } - [bridge invalidate]; - } - - // Wait for the executor to have shut down completely before returning - NSDate *teardownTimeout = [NSDate dateWithTimeIntervalSinceNow:kTestTeardownTimeoutSeconds]; - while (teardownTimeout.timeIntervalSinceNow > 0 && weakJSContext) { - [[NSRunLoop mainRunLoop] runMode:NSDefaultRunLoopMode beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]]; - [[NSRunLoop mainRunLoop] runMode:NSRunLoopCommonModes beforeDate:[NSDate dateWithTimeIntervalSinceNow:0.1]]; - } - RCTAssert(!weakJSContext, @"JS context was not deallocated after being invalidated"); -} - -@end diff --git a/examples/node_modules/react-native/Libraries/RKBackendNode/queryLayoutByID.js b/examples/node_modules/react-native/Libraries/RKBackendNode/queryLayoutByID.js deleted file mode 100644 index 5d038c23..00000000 --- a/examples/node_modules/react-native/Libraries/RKBackendNode/queryLayoutByID.js +++ /dev/null @@ -1,60 +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. - * - * @providesModule queryLayoutByID - * @flow - */ -'use strict'; - -var ReactNativeTagHandles = require('ReactNativeTagHandles'); -var UIManager = require('UIManager'); - -type OnSuccessCallback = ( - left: number, - top: number, - width: number, - height: number, - pageX: number, - pageY: number -) => void - -// I don't know what type error is... -type OnErrorCallback = (error: any) => void - -/** - * Queries the layout of a view. The layout does not reflect the element as - * seen by the user, rather it reflects the position within the layout system, - * before any transforms are applied. - * - * The only other requirement is that the `pageX, pageY` values be in the same - * coordinate system that events' `pageX/Y` are reported. That means that for - * the web, `pageXOffset/pageYOffset` should be added to to - * getBoundingClientRect to make consistent with touches. - * - * var pageXOffset = window.pageXOffset; - * var pageYOffset = window.pageYOffset; - * - * This is an IOS specific implementation. - * - * @param {string} rootNodeID ID of the platform specific node to be measured. - * @param {function} onError `func(error)` - * @param {function} onSuccess `func(left, top, width, height, pageX, pageY)` - */ -var queryLayoutByID = function( - rootNodeID: string, - onError: OnErrorCallback, - onSuccess: OnSuccessCallback -): void { - // Native bridge doesn't *yet* surface errors. - UIManager.measure( - ReactNativeTagHandles.rootNodeIDToTag[rootNodeID], - onSuccess - ); -}; - -module.exports = queryLayoutByID; diff --git a/examples/node_modules/react-native/Libraries/ReactIOS/IOSDefaultEventPluginOrder.js b/examples/node_modules/react-native/Libraries/ReactIOS/IOSDefaultEventPluginOrder.js deleted file mode 100644 index 80098fc4..00000000 --- a/examples/node_modules/react-native/Libraries/ReactIOS/IOSDefaultEventPluginOrder.js +++ /dev/null @@ -1,19 +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. - * - * @providesModule IOSDefaultEventPluginOrder - * @flow - */ -'use strict'; - -var IOSDefaultEventPluginOrder = [ - 'ResponderEventPlugin', - 'IOSNativeBridgeEventPlugin' -]; - -module.exports = IOSDefaultEventPluginOrder; diff --git a/examples/node_modules/react-native/Libraries/ReactIOS/IOSNativeBridgeEventPlugin.js b/examples/node_modules/react-native/Libraries/ReactIOS/IOSNativeBridgeEventPlugin.js deleted file mode 100644 index 6c1d887e..00000000 --- a/examples/node_modules/react-native/Libraries/ReactIOS/IOSNativeBridgeEventPlugin.js +++ /dev/null @@ -1,75 +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. - * - * @providesModule IOSNativeBridgeEventPlugin - * @flow - */ -'use strict'; - -var EventPropagators = require('EventPropagators'); -var SyntheticEvent = require('SyntheticEvent'); -var UIManager = require('UIManager'); - -var merge = require('merge'); -var warning = require('warning'); - -var customBubblingEventTypes = UIManager.customBubblingEventTypes; -var customDirectEventTypes = UIManager.customDirectEventTypes; - -var allTypesByEventName = {}; - -for (var bubblingTypeName in customBubblingEventTypes) { - allTypesByEventName[bubblingTypeName] = customBubblingEventTypes[bubblingTypeName]; -} - -for (var directTypeName in customDirectEventTypes) { - warning( - !customBubblingEventTypes[directTypeName], - 'Event cannot be both direct and bubbling: %s', - directTypeName - ); - allTypesByEventName[directTypeName] = customDirectEventTypes[directTypeName]; -} - -var IOSNativeBridgeEventPlugin = { - - eventTypes: merge(customBubblingEventTypes, customDirectEventTypes), - - /** - * @param {string} topLevelType Record from `EventConstants`. - * @param {DOMEventTarget} topLevelTarget The listening component root node. - * @param {string} topLevelTargetID ID of `topLevelTarget`. - * @param {object} nativeEvent Native browser event. - * @return {*} An accumulation of synthetic events. - * @see {EventPluginHub.extractEvents} - */ - extractEvents: function( - topLevelType: string, - topLevelTarget: EventTarget, - topLevelTargetID: string, - nativeEvent: Event - ): ?Object { - var bubbleDispatchConfig = customBubblingEventTypes[topLevelType]; - var directDispatchConfig = customDirectEventTypes[topLevelType]; - var event = SyntheticEvent.getPooled( - bubbleDispatchConfig || directDispatchConfig, - topLevelTargetID, - nativeEvent - ); - if (bubbleDispatchConfig) { - EventPropagators.accumulateTwoPhaseDispatches(event); - } else if (directDispatchConfig) { - EventPropagators.accumulateDirectDispatches(event); - } else { - return null; - } - return event; - } -}; - -module.exports = IOSNativeBridgeEventPlugin; diff --git a/examples/node_modules/react-native/Libraries/ReactIOS/NativeMethodsMixin.js b/examples/node_modules/react-native/Libraries/ReactIOS/NativeMethodsMixin.js deleted file mode 100644 index 33b99994..00000000 --- a/examples/node_modules/react-native/Libraries/ReactIOS/NativeMethodsMixin.js +++ /dev/null @@ -1,190 +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. - * - * @providesModule NativeMethodsMixin - * @flow - */ -'use strict'; - -var ReactNativeAttributePayload = require('ReactNativeAttributePayload'); -var TextInputState = require('TextInputState'); -var UIManager = require('UIManager'); - -var findNodeHandle = require('findNodeHandle'); -var invariant = require('invariant'); - -type MeasureOnSuccessCallback = ( - x: number, - y: number, - width: number, - height: number, - pageX: number, - pageY: number -) => void - -type MeasureLayoutOnSuccessCallback = ( - left: number, - top: number, - width: number, - height: number -) => void - -function warnForStyleProps(props, validAttributes) { - for (var key in validAttributes.style) { - if (!(validAttributes[key] || props[key] === undefined)) { - console.error( - 'You are setting the style `{ ' + key + ': ... }` as a prop. You ' + - 'should nest it in a style object. ' + - 'E.g. `{ style: { ' + key + ': ... } }`' - ); - } - } -} - -/** - * `NativeMethodsMixin` provides methods to access the underlying native - * component directly. This can be useful in cases when you want to focus - * a view or measure its on-screen dimensions, for example. - * - * The methods described here are available on most of the default components - * provided by React Native. Note, however, that they are *not* available on - * composite components that aren't directly backed by a native view. This will - * generally include most components that you define in your own app. For more - * information, see [Direct - * Manipulation](/react-native/docs/direct-manipulation.html). - */ -var NativeMethodsMixin = { - /** - * Determines the location on screen, width, and height of the given view and - * returns the values via an async callback. If successful, the callback will - * be called with the following arguments: - * - * - x - * - y - * - width - * - height - * - pageX - * - pageY - * - * Note that these measurements are not available until after the rendering - * has been completed in native. If you need the measurements as soon as - * possible, consider using the [`onLayout` - * prop](/react-native/docs/view.html#onlayout) instead. - */ - measure: function(callback: MeasureOnSuccessCallback) { - UIManager.measure( - findNodeHandle(this), - mountSafeCallback(this, callback) - ); - }, - - /** - * Like [`measure()`](#measure), but measures the view relative an ancestor, - * specified as `relativeToNativeNode`. This means that the returned x, y - * are relative to the origin x, y of the ancestor view. - * - * As always, to obtain a native node handle for a component, you can use - * `React.findNodeHandle(component)`. - */ - measureLayout: function( - relativeToNativeNode: number, - onSuccess: MeasureLayoutOnSuccessCallback, - onFail: () => void /* currently unused */ - ) { - UIManager.measureLayout( - findNodeHandle(this), - relativeToNativeNode, - mountSafeCallback(this, onFail), - mountSafeCallback(this, onSuccess) - ); - }, - - /** - * This function sends props straight to native. They will not participate in - * future diff process - this means that if you do not include them in the - * next render, they will remain active (see [Direct - * Manipulation](/react-native/docs/direct-manipulation.html)). - */ - setNativeProps: function(nativeProps: Object) { - if (__DEV__) { - warnForStyleProps(nativeProps, this.viewConfig.validAttributes); - } - - var updatePayload = ReactNativeAttributePayload.create( - nativeProps, - this.viewConfig.validAttributes - ); - - UIManager.updateView( - findNodeHandle(this), - this.viewConfig.uiViewClassName, - updatePayload - ); - }, - - /** - * Requests focus for the given input or view. The exact behavior triggered - * will depend on the platform and type of view. - */ - focus: function() { - TextInputState.focusTextInput(findNodeHandle(this)); - }, - - /** - * Removes focus from an input or view. This is the opposite of `focus()`. - */ - blur: function() { - TextInputState.blurTextInput(findNodeHandle(this)); - } -}; - -function throwOnStylesProp(component, props) { - if (props.styles !== undefined) { - var owner = component._owner || null; - var name = component.constructor.displayName; - var msg = '`styles` is not a supported property of `' + name + '`, did ' + - 'you mean `style` (singular)?'; - if (owner && owner.constructor && owner.constructor.displayName) { - msg += '\n\nCheck the `' + owner.constructor.displayName + '` parent ' + - ' component.'; - } - throw new Error(msg); - } -} -if (__DEV__) { - // hide this from Flow since we can't define these properties outside of - // __DEV__ without actually implementing them (setting them to undefined - // isn't allowed by ReactClass) - var NativeMethodsMixin_DEV = (NativeMethodsMixin: any); - invariant( - !NativeMethodsMixin_DEV.componentWillMount && - !NativeMethodsMixin_DEV.componentWillReceiveProps, - 'Do not override existing functions.' - ); - NativeMethodsMixin_DEV.componentWillMount = function () { - throwOnStylesProp(this, this.props); - }; - NativeMethodsMixin_DEV.componentWillReceiveProps = function (newProps) { - throwOnStylesProp(this, newProps); - }; -} - -/** - * In the future, we should cleanup callbacks by cancelling them instead of - * using this. - */ -var mountSafeCallback = function(context: ReactComponent, callback: ?Function): any { - return function() { - if (!callback || (context.isMounted && !context.isMounted())) { - return; - } - return callback.apply(context, arguments); - }; -}; - -module.exports = NativeMethodsMixin; diff --git a/examples/node_modules/react-native/Libraries/ReactIOS/renderApplication.ios.js b/examples/node_modules/react-native/Libraries/ReactIOS/renderApplication.ios.js deleted file mode 100644 index ad000f64..00000000 --- a/examples/node_modules/react-native/Libraries/ReactIOS/renderApplication.ios.js +++ /dev/null @@ -1,96 +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. - * - * @providesModule renderApplication - * @noflow - */ - -'use strict'; - -var RCTDeviceEventEmitter = require('RCTDeviceEventEmitter'); -var React = require('React'); -var StyleSheet = require('StyleSheet'); -var Subscribable = require('Subscribable'); -var View = require('View'); - -var invariant = require('invariant'); - -var Inspector = __DEV__ ? require('Inspector') : null; -var YellowBox = __DEV__ ? require('YellowBox') : null; - -var AppContainer = React.createClass({ - mixins: [Subscribable.Mixin], - - getInitialState: function() { - return { inspector: null }; - }, - - toggleElementInspector: function() { - var inspector = !__DEV__ || this.state.inspector - ? null - : ; - this.setState({inspector}); - }, - - componentDidMount: function() { - this.addListenerOn( - RCTDeviceEventEmitter, - 'toggleElementInspector', - this.toggleElementInspector - ); - }, - - render: function() { - let yellowBox = null; - if (__DEV__) { - yellowBox = ; - } - return ( - - - {this.props.children} - - {yellowBox} - {this.state.inspector} - - ); - } -}); - -function renderApplication( - RootComponent: ReactClass, - initialProps: P, - rootTag: any -) { - invariant( - rootTag, - 'Expect to have a valid rootTag, instead got ', rootTag - ); - /* eslint-disable jsx-no-undef-with-namespace */ - React.render( - - - , - rootTag - ); - /* eslint-enable jsx-no-undef-with-namespace */ -} - -var styles = StyleSheet.create({ - appContainer: { - flex: 1, - }, -}); - -module.exports = renderApplication; diff --git a/examples/node_modules/react-native/Libraries/ReactIOS/requireNativeComponent.js b/examples/node_modules/react-native/Libraries/ReactIOS/requireNativeComponent.js deleted file mode 100644 index 84789e6c..00000000 --- a/examples/node_modules/react-native/Libraries/ReactIOS/requireNativeComponent.js +++ /dev/null @@ -1,122 +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. - * - * @providesModule requireNativeComponent - * @flow - */ -'use strict'; - -var ReactNativeStyleAttributes = require('ReactNativeStyleAttributes'); -var UIManager = require('UIManager'); -var UnimplementedView = require('UnimplementedView'); - -var createReactNativeComponentClass = require('createReactNativeComponentClass'); - -var insetsDiffer = require('insetsDiffer'); -var pointsDiffer = require('pointsDiffer'); -var matricesDiffer = require('matricesDiffer'); -var processColor = require('processColor'); -var resolveAssetSource = require('resolveAssetSource'); -var sizesDiffer = require('sizesDiffer'); -var verifyPropTypes = require('verifyPropTypes'); -var warning = require('warning'); - -/** - * Used to create React components that directly wrap native component - * implementations. Config information is extracted from data exported from the - * UIManager module. You should also wrap the native component in a - * hand-written component with full propTypes definitions and other - * documentation - pass the hand-written component in as `componentInterface` to - * verify all the native props are documented via `propTypes`. - * - * If some native props shouldn't be exposed in the wrapper interface, you can - * pass null for `componentInterface` and call `verifyPropTypes` directly - * with `nativePropsToIgnore`; - * - * Common types are lined up with the appropriate prop differs with - * `TypeToDifferMap`. Non-scalar types not in the map default to `deepDiffer`. - */ -import type { ComponentInterface } from 'verifyPropTypes'; - -function requireNativeComponent( - viewName: string, - componentInterface?: ?ComponentInterface, - extraConfig?: ?{nativeOnly?: Object}, -): Function { - var viewConfig = UIManager[viewName]; - if (!viewConfig || !viewConfig.NativeProps) { - warning(false, 'Native component for "%s" does not exist', viewName); - return UnimplementedView; - } - var nativeProps = { - ...UIManager.RCTView.NativeProps, - ...viewConfig.NativeProps, - }; - viewConfig.uiViewClassName = viewName; - viewConfig.validAttributes = {}; - viewConfig.propTypes = componentInterface && componentInterface.propTypes; - for (var key in nativeProps) { - var useAttribute = false; - var attribute = {}; - - var differ = TypeToDifferMap[nativeProps[key]]; - if (differ) { - attribute.diff = differ; - useAttribute = true; - } - - var processor = TypeToProcessorMap[nativeProps[key]]; - if (processor) { - attribute.process = processor; - useAttribute = true; - } - - viewConfig.validAttributes[key] = useAttribute ? attribute : true; - } - - // Unfortunately, the current set up puts the style properties on the top - // level props object. We also need to add the nested form for API - // compatibility. This allows these props on both the top level and the - // nested style level. TODO: Move these to nested declarations on the - // native side. - viewConfig.validAttributes.style = ReactNativeStyleAttributes; - - if (__DEV__) { - componentInterface && verifyPropTypes( - componentInterface, - viewConfig, - extraConfig && extraConfig.nativeOnly - ); - } - return createReactNativeComponentClass(viewConfig); -} - -var TypeToDifferMap = { - // iOS Types - CATransform3D: matricesDiffer, - CGPoint: pointsDiffer, - CGSize: sizesDiffer, - UIEdgeInsets: insetsDiffer, - // Android Types - // (not yet implemented) -}; - -var TypeToProcessorMap = { - // iOS Types - CGColor: processColor, - CGColorArray: processColor, - UIColor: processColor, - UIColorArray: processColor, - CGImage: resolveAssetSource, - UIImage: resolveAssetSource, - RCTImageSource: resolveAssetSource, - // Android Types - Color: processColor, -}; - -module.exports = requireNativeComponent; diff --git a/examples/node_modules/react-native/Libraries/ReactIOS/verifyPropTypes.js b/examples/node_modules/react-native/Libraries/ReactIOS/verifyPropTypes.js deleted file mode 100644 index 1974716b..00000000 --- a/examples/node_modules/react-native/Libraries/ReactIOS/verifyPropTypes.js +++ /dev/null @@ -1,58 +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. - * - * @providesModule verifyPropTypes - * @flow - */ -'use strict'; - -var ReactNativeStyleAttributes = require('ReactNativeStyleAttributes'); - -export type ComponentInterface = ReactClass | { - name?: string; - displayName?: string; - propTypes: Object; -}; - -function verifyPropTypes( - componentInterface: ComponentInterface, - viewConfig: Object, - nativePropsToIgnore?: ?Object -) { - if (!viewConfig) { - return; // This happens for UnimplementedView. - } - var componentName = componentInterface.name || - componentInterface.displayName || - 'unknown'; - if (!componentInterface.propTypes) { - throw new Error( - '`' + componentName + '` has no propTypes defined`' - ); - } - - var nativeProps = viewConfig.NativeProps; - for (var prop in nativeProps) { - if (!componentInterface.propTypes[prop] && - !ReactNativeStyleAttributes[prop] && - (!nativePropsToIgnore || !nativePropsToIgnore[prop])) { - var message; - if (componentInterface.propTypes.hasOwnProperty(prop)) { - message = '`' + componentName + '` has incorrectly defined propType for native prop `' + - viewConfig.uiViewClassName + '.' + prop + '` of native type `' + nativeProps[prop]; - } else { - message = '`' + componentName + '` has no propType for native prop `' + - viewConfig.uiViewClassName + '.' + prop + '` of native type `' + - nativeProps[prop] + '`'; - }; - throw new Error(message); - } - } -} - -module.exports = verifyPropTypes; diff --git a/examples/node_modules/react-native/Libraries/StyleSheet/EdgeInsetsPropType.js b/examples/node_modules/react-native/Libraries/StyleSheet/EdgeInsetsPropType.js deleted file mode 100644 index 1850ae61..00000000 --- a/examples/node_modules/react-native/Libraries/StyleSheet/EdgeInsetsPropType.js +++ /dev/null @@ -1,25 +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. - * - * @providesModule EdgeInsetsPropType - * @flow - */ -'use strict'; - -var PropTypes = require('ReactPropTypes'); - -var createStrictShapeTypeChecker = require('createStrictShapeTypeChecker'); - -var EdgeInsetsPropType = createStrictShapeTypeChecker({ - top: PropTypes.number, - left: PropTypes.number, - bottom: PropTypes.number, - right: PropTypes.number, -}); - -module.exports = EdgeInsetsPropType; diff --git a/examples/node_modules/react-native/Libraries/StyleSheet/LayoutPropTypes.js b/examples/node_modules/react-native/Libraries/StyleSheet/LayoutPropTypes.js deleted file mode 100644 index 825db546..00000000 --- a/examples/node_modules/react-native/Libraries/StyleSheet/LayoutPropTypes.js +++ /dev/null @@ -1,109 +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. - * - * @providesModule LayoutPropTypes - * @flow - */ -'use strict'; - -var ReactPropTypes = require('ReactPropTypes'); - -/** - * React Native's layout system is based on Flexbox and is powered both - * on iOS and Android by an open source project called css-layout: - * https://github.com/facebook/css-layout - * - * The implementation in css-layout is slightly different from what the - * Flexbox spec defines - for example, we chose more sensible default - * values. Please refer to the css-layout README for details. - * - * These properties are a subset of our styles that are consumed by the layout - * algorithm and affect the positioning and sizing of views. - */ -var LayoutPropTypes = { - width: ReactPropTypes.number, - maxWidth: ReactPropTypes.number, - minWidth: ReactPropTypes.number, - height: ReactPropTypes.number, - maxHeight: ReactPropTypes.number, - minHeight: ReactPropTypes.number, - top: ReactPropTypes.number, - left: ReactPropTypes.number, - right: ReactPropTypes.number, - bottom: ReactPropTypes.number, - margin: ReactPropTypes.number, - marginVertical: ReactPropTypes.number, - marginHorizontal: ReactPropTypes.number, - marginTop: ReactPropTypes.number, - marginBottom: ReactPropTypes.number, - marginLeft: ReactPropTypes.number, - marginRight: ReactPropTypes.number, - padding: ReactPropTypes.number, - paddingVertical: ReactPropTypes.number, - paddingHorizontal: ReactPropTypes.number, - paddingTop: ReactPropTypes.number, - paddingBottom: ReactPropTypes.number, - paddingLeft: ReactPropTypes.number, - paddingRight: ReactPropTypes.number, - borderWidth: ReactPropTypes.number, - borderTopWidth: ReactPropTypes.number, - borderRightWidth: ReactPropTypes.number, - borderBottomWidth: ReactPropTypes.number, - borderLeftWidth: ReactPropTypes.number, - - position: ReactPropTypes.oneOf([ - 'absolute', - 'relative' - ]), - - // https://developer.mozilla.org/en-US/docs/Web/CSS/flex-direction - flexDirection: ReactPropTypes.oneOf([ - 'row', - 'column' - ]), - - // https://developer.mozilla.org/en-US/docs/Web/CSS/flex-wrap - flexWrap: ReactPropTypes.oneOf([ - 'wrap', - 'nowrap' - ]), - - // How to align children in the main direction - // https://developer.mozilla.org/en-US/docs/Web/CSS/justify-content - justifyContent: ReactPropTypes.oneOf([ - 'flex-start', - 'flex-end', - 'center', - 'space-between', - 'space-around' - ]), - - // How to align children in the cross direction - // https://developer.mozilla.org/en-US/docs/Web/CSS/align-items - alignItems: ReactPropTypes.oneOf([ - 'flex-start', - 'flex-end', - 'center', - 'stretch' - ]), - - // How to align the element in the cross direction - // https://developer.mozilla.org/en-US/docs/Web/CSS/align-items - alignSelf: ReactPropTypes.oneOf([ - 'auto', - 'flex-start', - 'flex-end', - 'center', - 'stretch' - ]), - - // https://developer.mozilla.org/en-US/docs/Web/CSS/flex - flex: ReactPropTypes.number, -}; - -module.exports = LayoutPropTypes; diff --git a/examples/node_modules/react-native/Libraries/StyleSheet/PointPropType.js b/examples/node_modules/react-native/Libraries/StyleSheet/PointPropType.js deleted file mode 100644 index 606482dd..00000000 --- a/examples/node_modules/react-native/Libraries/StyleSheet/PointPropType.js +++ /dev/null @@ -1,23 +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. - * - * @providesModule PointPropType - * @flow - */ -'use strict'; - -var PropTypes = require('ReactPropTypes'); - -var createStrictShapeTypeChecker = require('createStrictShapeTypeChecker'); - -var PointPropType = createStrictShapeTypeChecker({ - x: PropTypes.number, - y: PropTypes.number, -}); - -module.exports = PointPropType; diff --git a/examples/node_modules/react-native/Libraries/StyleSheet/StyleSheet.js b/examples/node_modules/react-native/Libraries/StyleSheet/StyleSheet.js deleted file mode 100644 index aa997b0a..00000000 --- a/examples/node_modules/react-native/Libraries/StyleSheet/StyleSheet.js +++ /dev/null @@ -1,78 +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. - * - * @providesModule StyleSheet - * @flow - */ -'use strict'; - -var StyleSheetRegistry = require('StyleSheetRegistry'); -var StyleSheetValidation = require('StyleSheetValidation'); -var flattenStyle = require('flattenStyle'); - -/** - * A StyleSheet is an abstraction similar to CSS StyleSheets - * - * Create a new StyleSheet: - * - * ``` - * var styles = StyleSheet.create({ - * container: { - * borderRadius: 4, - * borderWidth: 0.5, - * borderColor: '#d6d7da', - * }, - * title: { - * fontSize: 19, - * fontWeight: 'bold', - * }, - * activeTitle: { - * color: 'red', - * }, - * }); - * ``` - * - * Use a StyleSheet: - * - * ``` - * - * - * - * ``` - * - * Code quality: - * - * - By moving styles away from the render function, you're making the code - * easier to understand. - * - Naming the styles is a good way to add meaning to the low level components - * in the render function. - * - * Performance: - * - * - Making a stylesheet from a style object makes it possible to refer to it - * by ID instead of creating a new style object every time. - * - It also allows to send the style only once through the bridge. All - * subsequent uses are going to refer an id (not implemented yet). - */ -class StyleSheet { - static flatten: typeof flattenStyle; - - static create(obj: {[key: string]: any}): {[key: string]: number} { - var result = {}; - for (var key in obj) { - StyleSheetValidation.validateStyle(key, obj); - result[key] = StyleSheetRegistry.registerStyle(obj[key]); - } - return result; - } -} - -/* TODO(brentvatne) docs are needed for this */ -StyleSheet.flatten = flattenStyle; - -module.exports = StyleSheet; diff --git a/examples/node_modules/react-native/Libraries/StyleSheet/StyleSheetPropType.js b/examples/node_modules/react-native/Libraries/StyleSheet/StyleSheetPropType.js deleted file mode 100644 index 5980b8e3..00000000 --- a/examples/node_modules/react-native/Libraries/StyleSheet/StyleSheetPropType.js +++ /dev/null @@ -1,32 +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. - * - * @providesModule StyleSheetPropType - * @flow - */ -'use strict'; - -var createStrictShapeTypeChecker = require('createStrictShapeTypeChecker'); -var flattenStyle = require('flattenStyle'); - -function StyleSheetPropType( - shape: {[key: string]: ReactPropsCheckType} -): ReactPropsCheckType { - var shapePropType = createStrictShapeTypeChecker(shape); - return function(props, propName, componentName, location?) { - var newProps = props; - if (props[propName]) { - // Just make a dummy prop object with only the flattened style - newProps = {}; - newProps[propName] = flattenStyle(props[propName]); - } - return shapePropType(newProps, propName, componentName, location); - }; -} - -module.exports = StyleSheetPropType; diff --git a/examples/node_modules/react-native/Libraries/StyleSheet/StyleSheetRegistry.js b/examples/node_modules/react-native/Libraries/StyleSheet/StyleSheetRegistry.js deleted file mode 100644 index a05254fd..00000000 --- a/examples/node_modules/react-native/Libraries/StyleSheet/StyleSheetRegistry.js +++ /dev/null @@ -1,44 +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. - * - * @providesModule StyleSheetRegistry - * @flow - */ -'use strict'; - -var styles = {}; -var uniqueID = 1; -var emptyStyle = {}; - -class StyleSheetRegistry { - static registerStyle(style: Object): number { - var id = ++uniqueID; - if (__DEV__) { - Object.freeze(style); - } - styles[id] = style; - return id; - } - - static getStyleByID(id: number): Object { - if (!id) { - // Used in the style={[condition && id]} pattern, - // we want it to be a no-op when the value is false or null - return emptyStyle; - } - - var style = styles[id]; - if (!style) { - console.warn('Invalid style with id `' + id + '`. Skipping ...'); - return emptyStyle; - } - return style; - } -} - -module.exports = StyleSheetRegistry; diff --git a/examples/node_modules/react-native/Libraries/StyleSheet/StyleSheetValidation.js b/examples/node_modules/react-native/Libraries/StyleSheet/StyleSheetValidation.js deleted file mode 100644 index f61decb3..00000000 --- a/examples/node_modules/react-native/Libraries/StyleSheet/StyleSheetValidation.js +++ /dev/null @@ -1,73 +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. - * - * @providesModule StyleSheetValidation - * @flow - */ -'use strict'; - -var ImageStylePropTypes = require('ImageStylePropTypes'); -var ReactPropTypeLocations = require('ReactPropTypeLocations'); -var TextStylePropTypes = require('TextStylePropTypes'); -var ViewStylePropTypes = require('ViewStylePropTypes'); - -var invariant = require('invariant'); - -class StyleSheetValidation { - static validateStyleProp(prop, style, caller) { - if (!__DEV__) { - return; - } - if (allStylePropTypes[prop] === undefined) { - var message1 = '"' + prop + '" is not a valid style property.'; - var message2 = '\nValid style props: ' + - JSON.stringify(Object.keys(allStylePropTypes).sort(), null, ' '); - styleError(message1, style, caller, message2); - } - var error = allStylePropTypes[prop]( - style, - prop, - caller, - ReactPropTypeLocations.prop - ); - if (error) { - styleError(error.message, style, caller); - } - } - - static validateStyle(name, styles) { - if (!__DEV__) { - return; - } - for (var prop in styles[name]) { - StyleSheetValidation.validateStyleProp(prop, styles[name], 'StyleSheet ' + name); - } - } - - static addValidStylePropTypes(stylePropTypes) { - for (var key in stylePropTypes) { - allStylePropTypes[key] = stylePropTypes[key]; - } - } -} - -var styleError = function(message1, style, caller?, message2?) { - invariant( - false, - message1 + '\n' + (caller || '<>') + ': ' + - JSON.stringify(style, null, ' ') + (message2 || '') - ); -}; - -var allStylePropTypes = {}; - -StyleSheetValidation.addValidStylePropTypes(ImageStylePropTypes); -StyleSheetValidation.addValidStylePropTypes(TextStylePropTypes); -StyleSheetValidation.addValidStylePropTypes(ViewStylePropTypes); - -module.exports = StyleSheetValidation; diff --git a/examples/node_modules/react-native/Libraries/StyleSheet/flattenStyle.js b/examples/node_modules/react-native/Libraries/StyleSheet/flattenStyle.js deleted file mode 100644 index 621c614f..00000000 --- a/examples/node_modules/react-native/Libraries/StyleSheet/flattenStyle.js +++ /dev/null @@ -1,52 +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. - * - * @providesModule flattenStyle - * @flow - */ -'use strict'; - -var StyleSheetRegistry = require('StyleSheetRegistry'); -var invariant = require('invariant'); - -import type { StyleObj } from 'StyleSheetTypes'; - -function getStyle(style) { - if (typeof style === 'number') { - return StyleSheetRegistry.getStyleByID(style); - } - return style; -} - -function flattenStyle(style: ?StyleObj): ?Object { - if (!style) { - return undefined; - } - invariant(style !== true, 'style may be false but not true'); - - if (!Array.isArray(style)) { - return getStyle(style); - } - - var result = {}; - for (var i = 0; i < style.length; ++i) { - var computedStyle = flattenStyle(style[i]); - if (computedStyle) { - for (var key in computedStyle) { - result[key] = computedStyle[key]; - - if (__DEV__) { - var value = computedStyle[key]; - } - } - } - } - return result; -} - -module.exports = flattenStyle; diff --git a/examples/node_modules/react-native/Libraries/StyleSheet/styleDiffer.js b/examples/node_modules/react-native/Libraries/StyleSheet/styleDiffer.js deleted file mode 100644 index d2e80493..00000000 --- a/examples/node_modules/react-native/Libraries/StyleSheet/styleDiffer.js +++ /dev/null @@ -1,61 +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. - * - * @providesModule styleDiffer - * @flow - */ -'use strict'; - -var deepDiffer = require('deepDiffer'); - -function styleDiffer(a: any, b: any): bool { - return !styleEqual(a, b); -} - -function styleEqual(a: any, b: any): bool { - if (!a) { - return !b; - } - if (!b) { - return !a; - } - if (typeof a !== typeof b) { - return false; - } - if (typeof a === 'number') { - return a === b; - } - - if (Array.isArray(a)) { - if (!Array.isArray(b) || a.length !== b.length) { - return false; - } - for (var i = 0; i < a.length; ++i) { - if (!styleEqual(a[i], b[i])) { - return false; - } - } - return true; - } - - for (var key in a) { - if (deepDiffer(a[key], b[key])) { - return false; - } - } - - for (var key in b) { - if (!a.hasOwnProperty(key)) { - return false; - } - } - - return true; -} - -module.exports = styleDiffer; diff --git a/examples/node_modules/react-native/Libraries/Text/RCTRawTextManager.h b/examples/node_modules/react-native/Libraries/Text/RCTRawTextManager.h deleted file mode 100644 index 2f1a8482..00000000 --- a/examples/node_modules/react-native/Libraries/Text/RCTRawTextManager.h +++ /dev/null @@ -1,14 +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. - */ - -#import "RCTViewManager.h" - -@interface RCTRawTextManager : RCTViewManager - -@end diff --git a/examples/node_modules/react-native/Libraries/Text/RCTRawTextManager.m b/examples/node_modules/react-native/Libraries/Text/RCTRawTextManager.m deleted file mode 100644 index 460b127b..00000000 --- a/examples/node_modules/react-native/Libraries/Text/RCTRawTextManager.m +++ /dev/null @@ -1,25 +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. - */ - -#import "RCTRawTextManager.h" - -#import "RCTShadowRawText.h" - -@implementation RCTRawTextManager - -RCT_EXPORT_MODULE() - -- (RCTShadowView *)shadowView -{ - return [RCTShadowRawText new]; -} - -RCT_EXPORT_SHADOW_PROPERTY(text, NSString) - -@end diff --git a/examples/node_modules/react-native/Libraries/Text/RCTShadowRawText.h b/examples/node_modules/react-native/Libraries/Text/RCTShadowRawText.h deleted file mode 100644 index 7e47d8fa..00000000 --- a/examples/node_modules/react-native/Libraries/Text/RCTShadowRawText.h +++ /dev/null @@ -1,16 +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. - */ - -#import "RCTShadowView.h" - -@interface RCTShadowRawText : RCTShadowView - -@property (nonatomic, copy) NSString *text; - -@end diff --git a/examples/node_modules/react-native/Libraries/Text/RCTShadowRawText.m b/examples/node_modules/react-native/Libraries/Text/RCTShadowRawText.m deleted file mode 100644 index 6d1dd6d2..00000000 --- a/examples/node_modules/react-native/Libraries/Text/RCTShadowRawText.m +++ /dev/null @@ -1,53 +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. - */ - -#import "RCTShadowRawText.h" - -#import "RCTUIManager.h" - -@implementation RCTShadowRawText - -- (instancetype)init -{ - if ((self = [super init])) { - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(contentSizeMultiplierDidChange:) - name:RCTUIManagerWillUpdateViewsDueToContentSizeMultiplierChangeNotification - object:nil]; - } - return self; -} - -- (void)dealloc -{ - [[NSNotificationCenter defaultCenter] removeObserver:self]; -} - -- (void)contentSizeMultiplierDidChange:(NSNotification *)note -{ - [self dirtyLayout]; - [self dirtyText]; -} - -- (void)setText:(NSString *)text -{ - if (_text != text && ![_text isEqualToString:text]) { - _text = [text copy]; - [self dirtyLayout]; - [self dirtyText]; - } -} - -- (NSString *)description -{ - NSString *superDescription = super.description; - return [[superDescription substringToIndex:superDescription.length - 1] stringByAppendingFormat:@"; text: %@>", self.text]; -} - -@end diff --git a/examples/node_modules/react-native/Libraries/Text/RCTShadowText.h b/examples/node_modules/react-native/Libraries/Text/RCTShadowText.h deleted file mode 100644 index 1ded47c9..00000000 --- a/examples/node_modules/react-native/Libraries/Text/RCTShadowText.h +++ /dev/null @@ -1,39 +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. - */ - -#import "RCTShadowView.h" -#import "RCTTextDecorationLineType.h" - -extern NSString *const RCTIsHighlightedAttributeName; -extern NSString *const RCTReactTagAttributeName; - -@interface RCTShadowText : RCTShadowView - -@property (nonatomic, strong) UIColor *color; -@property (nonatomic, copy) NSString *fontFamily; -@property (nonatomic, assign) CGFloat fontSize; -@property (nonatomic, copy) NSString *fontWeight; -@property (nonatomic, copy) NSString *fontStyle; -@property (nonatomic, assign) BOOL isHighlighted; -@property (nonatomic, assign) CGFloat letterSpacing; -@property (nonatomic, assign) CGFloat lineHeight; -@property (nonatomic, assign) NSUInteger numberOfLines; -@property (nonatomic, assign) CGSize shadowOffset; -@property (nonatomic, assign) NSTextAlignment textAlign; -@property (nonatomic, assign) NSWritingDirection writingDirection; -@property (nonatomic, strong) UIColor *textDecorationColor; -@property (nonatomic, assign) NSUnderlineStyle textDecorationStyle; -@property (nonatomic, assign) RCTTextDecorationLineType textDecorationLine; -@property (nonatomic, assign) CGFloat fontSizeMultiplier; -@property (nonatomic, assign) BOOL allowFontScaling; -@property (nonatomic, assign) CGFloat opacity; - -- (void)recomputeText; - -@end diff --git a/examples/node_modules/react-native/Libraries/Text/RCTShadowText.m b/examples/node_modules/react-native/Libraries/Text/RCTShadowText.m deleted file mode 100644 index a8087b1d..00000000 --- a/examples/node_modules/react-native/Libraries/Text/RCTShadowText.m +++ /dev/null @@ -1,397 +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. - */ - -#import "RCTShadowText.h" - -#import "RCTAccessibilityManager.h" -#import "RCTUIManager.h" -#import "RCTBridge.h" -#import "RCTConvert.h" -#import "RCTImageComponent.h" -#import "RCTLog.h" -#import "RCTShadowRawText.h" -#import "RCTText.h" -#import "RCTUtils.h" - -NSString *const RCTIsHighlightedAttributeName = @"IsHighlightedAttributeName"; -NSString *const RCTReactTagAttributeName = @"ReactTagAttributeName"; - -@implementation RCTShadowText -{ - NSTextStorage *_cachedTextStorage; - CGFloat _cachedTextStorageWidth; - NSAttributedString *_cachedAttributedString; - CGFloat _effectiveLetterSpacing; -} - -static css_dim_t RCTMeasure(void *context, float width) -{ - RCTShadowText *shadowText = (__bridge RCTShadowText *)context; - NSTextStorage *textStorage = [shadowText buildTextStorageForWidth:width]; - NSLayoutManager *layoutManager = textStorage.layoutManagers.firstObject; - NSTextContainer *textContainer = layoutManager.textContainers.firstObject; - CGSize computedSize = [layoutManager usedRectForTextContainer:textContainer].size; - - css_dim_t result; - result.dimensions[CSS_WIDTH] = RCTCeilPixelValue(computedSize.width); - if (shadowText->_effectiveLetterSpacing < 0) { - result.dimensions[CSS_WIDTH] -= shadowText->_effectiveLetterSpacing; - } - result.dimensions[CSS_HEIGHT] = RCTCeilPixelValue(computedSize.height); - return result; -} - -- (instancetype)init -{ - if ((self = [super init])) { - _fontSize = NAN; - _letterSpacing = NAN; - _isHighlighted = NO; - _textDecorationStyle = NSUnderlineStyleSingle; - _opacity = 1.0; - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(contentSizeMultiplierDidChange:) - name:RCTUIManagerWillUpdateViewsDueToContentSizeMultiplierChangeNotification - object:nil]; - } - return self; -} - -- (void)dealloc -{ - [[NSNotificationCenter defaultCenter] removeObserver:self]; -} - -- (NSString *)description -{ - NSString *superDescription = super.description; - return [[superDescription substringToIndex:superDescription.length - 1] stringByAppendingFormat:@"; text: %@>", [self attributedString].string]; -} - -- (void)contentSizeMultiplierDidChange:(NSNotification *)note -{ - [self dirtyLayout]; - [self dirtyText]; -} - -- (NSDictionary *)processUpdatedProperties:(NSMutableSet *)applierBlocks - parentProperties:(NSDictionary *)parentProperties -{ - parentProperties = [super processUpdatedProperties:applierBlocks - parentProperties:parentProperties]; - - UIEdgeInsets padding = self.paddingAsInsets; - CGFloat width = self.frame.size.width - (padding.left + padding.right); - - NSTextStorage *textStorage = [self buildTextStorageForWidth:width]; - [applierBlocks addObject:^(NSDictionary *viewRegistry) { - RCTText *view = viewRegistry[self.reactTag]; - view.textStorage = textStorage; - }]; - - return parentProperties; -} - -- (void)applyLayoutNode:(css_node_t *)node - viewsWithNewFrame:(NSMutableSet *)viewsWithNewFrame - absolutePosition:(CGPoint)absolutePosition -{ - [super applyLayoutNode:node viewsWithNewFrame:viewsWithNewFrame absolutePosition:absolutePosition]; - [self dirtyPropagation]; -} - -- (NSTextStorage *)buildTextStorageForWidth:(CGFloat)width -{ - if (_cachedTextStorage && width == _cachedTextStorageWidth) { - return _cachedTextStorage; - } - - NSLayoutManager *layoutManager = [NSLayoutManager new]; - - NSTextStorage *textStorage = [[NSTextStorage alloc] initWithAttributedString:self.attributedString]; - [textStorage addLayoutManager:layoutManager]; - - NSTextContainer *textContainer = [NSTextContainer new]; - textContainer.lineFragmentPadding = 0.0; - textContainer.lineBreakMode = _numberOfLines > 0 ? NSLineBreakByTruncatingTail : NSLineBreakByClipping; - textContainer.maximumNumberOfLines = _numberOfLines; - textContainer.size = (CGSize){isnan(width) ? CGFLOAT_MAX : width, CGFLOAT_MAX}; - - [layoutManager addTextContainer:textContainer]; - [layoutManager ensureLayoutForTextContainer:textContainer]; - - _cachedTextStorageWidth = width; - _cachedTextStorage = textStorage; - - return textStorage; -} - -- (void)dirtyText -{ - [super dirtyText]; - _cachedTextStorage = nil; -} - -- (void)recomputeText -{ - [self attributedString]; - [self setTextComputed]; - [self dirtyPropagation]; -} - -- (NSAttributedString *)attributedString -{ - return [self _attributedStringWithFontFamily:nil - fontSize:nil - fontWeight:nil - fontStyle:nil - letterSpacing:nil - useBackgroundColor:NO - foregroundColor:self.color ?: [UIColor blackColor] - backgroundColor:self.backgroundColor - opacity:self.opacity]; -} - -- (NSAttributedString *)_attributedStringWithFontFamily:(NSString *)fontFamily - fontSize:(NSNumber *)fontSize - fontWeight:(NSString *)fontWeight - fontStyle:(NSString *)fontStyle - letterSpacing:(NSNumber *)letterSpacing - useBackgroundColor:(BOOL)useBackgroundColor - foregroundColor:(UIColor *)foregroundColor - backgroundColor:(UIColor *)backgroundColor - opacity:(CGFloat)opacity -{ - if (![self isTextDirty] && _cachedAttributedString) { - return _cachedAttributedString; - } - - if (_fontSize && !isnan(_fontSize)) { - fontSize = @(_fontSize); - } - if (_fontWeight) { - fontWeight = _fontWeight; - } - if (_fontStyle) { - fontStyle = _fontStyle; - } - if (_fontFamily) { - fontFamily = _fontFamily; - } - if (!isnan(_letterSpacing)) { - letterSpacing = @(_letterSpacing); - } - - _effectiveLetterSpacing = letterSpacing.doubleValue; - - NSMutableAttributedString *attributedString = [NSMutableAttributedString new]; - for (RCTShadowView *child in [self reactSubviews]) { - if ([child isKindOfClass:[RCTShadowText class]]) { - RCTShadowText *shadowText = (RCTShadowText *)child; - [attributedString appendAttributedString: - [shadowText _attributedStringWithFontFamily:fontFamily - fontSize:fontSize - fontWeight:fontWeight - fontStyle:fontStyle - letterSpacing:letterSpacing - useBackgroundColor:YES - foregroundColor:shadowText.color ?: foregroundColor - backgroundColor:shadowText.backgroundColor ?: backgroundColor - opacity:opacity * shadowText.opacity]]; - } else if ([child isKindOfClass:[RCTShadowRawText class]]) { - RCTShadowRawText *shadowRawText = (RCTShadowRawText *)child; - [attributedString appendAttributedString:[[NSAttributedString alloc] initWithString:shadowRawText.text ?: @""]]; - } else if ([child conformsToProtocol:@protocol(RCTImageComponent)]) { - UIImage *image = ((id)child).image; - if (image) { - NSTextAttachment *imageAttachment = [NSTextAttachment new]; - imageAttachment.image = image; - [attributedString appendAttributedString:[NSAttributedString attributedStringWithAttachment:imageAttachment]]; - } else { - //TODO: add placeholder image? - } - } else { - RCTLogError(@" can't have any children except , or raw strings"); - } - - [child setTextComputed]; - } - - [self _addAttribute:NSForegroundColorAttributeName - withValue:[foregroundColor colorWithAlphaComponent:CGColorGetAlpha(foregroundColor.CGColor) * opacity] - toAttributedString:attributedString]; - - if (_isHighlighted) { - [self _addAttribute:RCTIsHighlightedAttributeName withValue:@YES toAttributedString:attributedString]; - } - if (useBackgroundColor && backgroundColor) { - [self _addAttribute:NSBackgroundColorAttributeName - withValue:[backgroundColor colorWithAlphaComponent:CGColorGetAlpha(backgroundColor.CGColor) * opacity] - toAttributedString:attributedString]; - } - - UIFont *font = [RCTConvert UIFont:nil withFamily:fontFamily - size:fontSize weight:fontWeight style:fontStyle - scaleMultiplier:(_allowFontScaling && _fontSizeMultiplier > 0.0 ? _fontSizeMultiplier : 1.0)]; - [self _addAttribute:NSFontAttributeName withValue:font toAttributedString:attributedString]; - [self _addAttribute:NSKernAttributeName withValue:letterSpacing toAttributedString:attributedString]; - [self _addAttribute:RCTReactTagAttributeName withValue:self.reactTag toAttributedString:attributedString]; - [self _setParagraphStyleOnAttributedString:attributedString]; - - // create a non-mutable attributedString for use by the Text system which avoids copies down the line - _cachedAttributedString = [[NSAttributedString alloc] initWithAttributedString:attributedString]; - [self dirtyLayout]; - - return _cachedAttributedString; -} - -- (void)_addAttribute:(NSString *)attribute withValue:(id)attributeValue toAttributedString:(NSMutableAttributedString *)attributedString -{ - [attributedString enumerateAttribute:attribute inRange:NSMakeRange(0, attributedString.length) options:0 usingBlock:^(id value, NSRange range, BOOL *stop) { - if (!value && attributeValue) { - [attributedString addAttribute:attribute value:attributeValue range:range]; - } - }]; -} - -/* - * LineHeight works the same way line-height works in the web: if children and self have - * varying lineHeights, we simply take the max. - */ -- (void)_setParagraphStyleOnAttributedString:(NSMutableAttributedString *)attributedString -{ - // check if we have lineHeight set on self - __block BOOL hasParagraphStyle = NO; - if (_lineHeight || _textAlign) { - hasParagraphStyle = YES; - } - - if (!_lineHeight) { - self.lineHeight = 0.0; - } - - // check for lineHeight on each of our children, update the max as we go (in self.lineHeight) - [attributedString enumerateAttribute:NSParagraphStyleAttributeName inRange:(NSRange){0, attributedString.length} options:0 usingBlock:^(id value, NSRange range, BOOL *stop) { - if (value) { - NSParagraphStyle *paragraphStyle = (NSParagraphStyle *)value; - CGFloat maximumLineHeight = round(paragraphStyle.maximumLineHeight / self.fontSizeMultiplier); - if (maximumLineHeight > self.lineHeight) { - self.lineHeight = maximumLineHeight; - } - hasParagraphStyle = YES; - } - }]; - - self.textAlign = _textAlign ?: NSTextAlignmentNatural; - self.writingDirection = _writingDirection ?: NSWritingDirectionNatural; - - // if we found anything, set it :D - if (hasParagraphStyle) { - NSMutableParagraphStyle *paragraphStyle = [NSMutableParagraphStyle new]; - paragraphStyle.alignment = _textAlign; - paragraphStyle.baseWritingDirection = _writingDirection; - CGFloat lineHeight = round(_lineHeight * (_allowFontScaling && self.fontSizeMultiplier > 0.0 ? self.fontSizeMultiplier : 1.0)); - paragraphStyle.minimumLineHeight = lineHeight; - paragraphStyle.maximumLineHeight = lineHeight; - [attributedString addAttribute:NSParagraphStyleAttributeName - value:paragraphStyle - range:(NSRange){0, attributedString.length}]; - } - - // Text decoration - if(_textDecorationLine == RCTTextDecorationLineTypeUnderline || - _textDecorationLine == RCTTextDecorationLineTypeUnderlineStrikethrough) { - [self _addAttribute:NSUnderlineStyleAttributeName withValue:@(_textDecorationStyle) - toAttributedString:attributedString]; - } - if(_textDecorationLine == RCTTextDecorationLineTypeStrikethrough || - _textDecorationLine == RCTTextDecorationLineTypeUnderlineStrikethrough){ - [self _addAttribute:NSStrikethroughStyleAttributeName withValue:@(_textDecorationStyle) - toAttributedString:attributedString]; - } - if(_textDecorationColor) { - [self _addAttribute:NSStrikethroughColorAttributeName withValue:_textDecorationColor - toAttributedString:attributedString]; - [self _addAttribute:NSUnderlineColorAttributeName withValue:_textDecorationColor - toAttributedString:attributedString]; - } -} - -- (void)fillCSSNode:(css_node_t *)node -{ - [super fillCSSNode:node]; - node->measure = RCTMeasure; - node->children_count = 0; -} - -- (void)insertReactSubview:(RCTShadowView *)subview atIndex:(NSInteger)atIndex -{ - [super insertReactSubview:subview atIndex:atIndex]; - self.cssNode->children_count = 0; -} - -- (void)removeReactSubview:(RCTShadowView *)subview -{ - [super removeReactSubview:subview]; - self.cssNode->children_count = 0; -} - -- (void)setBackgroundColor:(UIColor *)backgroundColor -{ - super.backgroundColor = backgroundColor; - [self dirtyText]; -} - -#define RCT_TEXT_PROPERTY(setProp, ivar, type) \ -- (void)set##setProp:(type)value; \ -{ \ - ivar = value; \ - [self dirtyText]; \ -} - -RCT_TEXT_PROPERTY(Color, _color, UIColor *) -RCT_TEXT_PROPERTY(FontFamily, _fontFamily, NSString *) -RCT_TEXT_PROPERTY(FontSize, _fontSize, CGFloat) -RCT_TEXT_PROPERTY(FontWeight, _fontWeight, NSString *) -RCT_TEXT_PROPERTY(FontStyle, _fontStyle, NSString *) -RCT_TEXT_PROPERTY(IsHighlighted, _isHighlighted, BOOL) -RCT_TEXT_PROPERTY(LetterSpacing, _letterSpacing, CGFloat) -RCT_TEXT_PROPERTY(LineHeight, _lineHeight, CGFloat) -RCT_TEXT_PROPERTY(NumberOfLines, _numberOfLines, NSUInteger) -RCT_TEXT_PROPERTY(ShadowOffset, _shadowOffset, CGSize) -RCT_TEXT_PROPERTY(TextAlign, _textAlign, NSTextAlignment) -RCT_TEXT_PROPERTY(TextDecorationColor, _textDecorationColor, UIColor *); -RCT_TEXT_PROPERTY(TextDecorationLine, _textDecorationLine, RCTTextDecorationLineType); -RCT_TEXT_PROPERTY(TextDecorationStyle, _textDecorationStyle, NSUnderlineStyle); -RCT_TEXT_PROPERTY(WritingDirection, _writingDirection, NSWritingDirection) -RCT_TEXT_PROPERTY(Opacity, _opacity, CGFloat) - -- (void)setAllowFontScaling:(BOOL)allowFontScaling -{ - _allowFontScaling = allowFontScaling; - for (RCTShadowView *child in [self reactSubviews]) { - if ([child isKindOfClass:[RCTShadowText class]]) { - ((RCTShadowText *)child).allowFontScaling = allowFontScaling; - } - } - [self dirtyText]; -} - -- (void)setFontSizeMultiplier:(CGFloat)fontSizeMultiplier -{ - _fontSizeMultiplier = fontSizeMultiplier; - for (RCTShadowView *child in [self reactSubviews]) { - if ([child isKindOfClass:[RCTShadowText class]]) { - ((RCTShadowText *)child).fontSizeMultiplier = fontSizeMultiplier; - } - } - [self dirtyText]; -} - -@end diff --git a/examples/node_modules/react-native/Libraries/Text/RCTText.h b/examples/node_modules/react-native/Libraries/Text/RCTText.h deleted file mode 100644 index 487954f8..00000000 --- a/examples/node_modules/react-native/Libraries/Text/RCTText.h +++ /dev/null @@ -1,17 +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. - */ - -#import - -@interface RCTText : UIView - -@property (nonatomic, assign) UIEdgeInsets contentInset; -@property (nonatomic, strong) NSTextStorage *textStorage; - -@end diff --git a/examples/node_modules/react-native/Libraries/Text/RCTText.m b/examples/node_modules/react-native/Libraries/Text/RCTText.m deleted file mode 100644 index c4528791..00000000 --- a/examples/node_modules/react-native/Libraries/Text/RCTText.m +++ /dev/null @@ -1,159 +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. - */ - -#import "RCTText.h" - -#import "RCTShadowText.h" -#import "RCTUtils.h" -#import "UIView+React.h" - -@implementation RCTText -{ - NSTextStorage *_textStorage; - NSMutableArray *_reactSubviews; - CAShapeLayer *_highlightLayer; -} - -- (instancetype)initWithFrame:(CGRect)frame -{ - if ((self = [super initWithFrame:frame])) { - _textStorage = [NSTextStorage new]; - _reactSubviews = [NSMutableArray array]; - - self.isAccessibilityElement = YES; - self.accessibilityTraits |= UIAccessibilityTraitStaticText; - - self.opaque = NO; - self.contentMode = UIViewContentModeRedraw; - } - return self; -} - -- (NSString *)description -{ - NSString *superDescription = super.description; - NSRange semicolonRange = [superDescription rangeOfString:@";"]; - NSString *replacement = [NSString stringWithFormat:@"; reactTag: %@; text: %@", self.reactTag, self.textStorage.string]; - return [superDescription stringByReplacingCharactersInRange:semicolonRange withString:replacement]; -} - -- (void)reactSetFrame:(CGRect)frame -{ - // Text looks super weird if its frame is animated. - // This disables the frame animation, without affecting opacity, etc. - [UIView performWithoutAnimation:^{ - [super reactSetFrame:frame]; - }]; -} - -- (void)insertReactSubview:(UIView *)subview atIndex:(NSInteger)atIndex -{ - [_reactSubviews insertObject:subview atIndex:atIndex]; -} - -- (void)removeReactSubview:(UIView *)subview -{ - [_reactSubviews removeObject:subview]; -} - -- (NSArray *)reactSubviews -{ - return _reactSubviews; -} - -- (void)setTextStorage:(NSTextStorage *)textStorage -{ - _textStorage = textStorage; - [self setNeedsDisplay]; -} - -- (void)drawRect:(CGRect)rect -{ - NSLayoutManager *layoutManager = _textStorage.layoutManagers.firstObject; - NSTextContainer *textContainer = layoutManager.textContainers.firstObject; - CGRect textFrame = UIEdgeInsetsInsetRect(self.bounds, _contentInset); - NSRange glyphRange = [layoutManager glyphRangeForTextContainer:textContainer]; - - [layoutManager drawBackgroundForGlyphRange:glyphRange atPoint:textFrame.origin]; - [layoutManager drawGlyphsForGlyphRange:glyphRange atPoint:textFrame.origin]; - - __block UIBezierPath *highlightPath = nil; - NSRange characterRange = [layoutManager characterRangeForGlyphRange:glyphRange actualGlyphRange:NULL]; - [layoutManager.textStorage enumerateAttribute:RCTIsHighlightedAttributeName inRange:characterRange options:0 usingBlock:^(NSNumber *value, NSRange range, BOOL *_) { - if (!value.boolValue) { - return; - } - - [layoutManager enumerateEnclosingRectsForGlyphRange:range withinSelectedGlyphRange:range inTextContainer:textContainer usingBlock:^(CGRect enclosingRect, __unused BOOL *__) { - UIBezierPath *path = [UIBezierPath bezierPathWithRoundedRect:CGRectInset(enclosingRect, -2, -2) cornerRadius:2]; - if (highlightPath) { - [highlightPath appendPath:path]; - } else { - highlightPath = path; - } - }]; - }]; - - if (highlightPath) { - if (!_highlightLayer) { - _highlightLayer = [CAShapeLayer layer]; - _highlightLayer.fillColor = [UIColor colorWithWhite:0 alpha:0.25].CGColor; - [self.layer addSublayer:_highlightLayer]; - } - _highlightLayer.position = (CGPoint){_contentInset.left, _contentInset.top}; - _highlightLayer.path = highlightPath.CGPath; - } else { - [_highlightLayer removeFromSuperlayer]; - _highlightLayer = nil; - } -} - -- (NSNumber *)reactTagAtPoint:(CGPoint)point -{ - NSNumber *reactTag = self.reactTag; - - CGFloat fraction; - NSLayoutManager *layoutManager = _textStorage.layoutManagers.firstObject; - NSTextContainer *textContainer = layoutManager.textContainers.firstObject; - NSUInteger characterIndex = [layoutManager characterIndexForPoint:point - inTextContainer:textContainer - fractionOfDistanceBetweenInsertionPoints:&fraction]; - - // If the point is not before (fraction == 0.0) the first character and not - // after (fraction == 1.0) the last character, then the attribute is valid. - if (_textStorage.length > 0 && (fraction > 0 || characterIndex > 0) && (fraction < 1 || characterIndex < _textStorage.length - 1)) { - reactTag = [_textStorage attribute:RCTReactTagAttributeName atIndex:characterIndex effectiveRange:NULL]; - } - return reactTag; -} - - -- (void)didMoveToWindow -{ - [super didMoveToWindow]; - - if (!self.window) { - self.layer.contents = nil; - if (_highlightLayer) { - [_highlightLayer removeFromSuperlayer]; - _highlightLayer = nil; - } - } else if (_textStorage.length) { - [self setNeedsDisplay]; - } -} - -#pragma mark - Accessibility - -- (NSString *)accessibilityLabel -{ - return _textStorage.string; -} - -@end diff --git a/examples/node_modules/react-native/Libraries/Text/RCTText.xcodeproj/project.pbxproj b/examples/node_modules/react-native/Libraries/Text/RCTText.xcodeproj/project.pbxproj deleted file mode 100644 index 3e9af673..00000000 --- a/examples/node_modules/react-native/Libraries/Text/RCTText.xcodeproj/project.pbxproj +++ /dev/null @@ -1,313 +0,0 @@ -// !$*UTF8*$! -{ - archiveVersion = 1; - classes = { - }; - objectVersion = 46; - objects = { - -/* Begin PBXBuildFile section */ - 131B6AC01AF0CD0600FFC3E0 /* RCTTextView.m in Sources */ = {isa = PBXBuildFile; fileRef = 131B6ABD1AF0CD0600FFC3E0 /* RCTTextView.m */; }; - 131B6AC11AF0CD0600FFC3E0 /* RCTTextViewManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 131B6ABF1AF0CD0600FFC3E0 /* RCTTextViewManager.m */; }; - 1362F1001B4D51F400E06D8C /* RCTTextField.m in Sources */ = {isa = PBXBuildFile; fileRef = 1362F0FD1B4D51F400E06D8C /* RCTTextField.m */; }; - 1362F1011B4D51F400E06D8C /* RCTTextFieldManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 1362F0FF1B4D51F400E06D8C /* RCTTextFieldManager.m */; }; - 58B511CE1A9E6C5C00147676 /* RCTRawTextManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 58B511C71A9E6C5C00147676 /* RCTRawTextManager.m */; }; - 58B511CF1A9E6C5C00147676 /* RCTShadowRawText.m in Sources */ = {isa = PBXBuildFile; fileRef = 58B511C91A9E6C5C00147676 /* RCTShadowRawText.m */; }; - 58B511D01A9E6C5C00147676 /* RCTShadowText.m in Sources */ = {isa = PBXBuildFile; fileRef = 58B511CB1A9E6C5C00147676 /* RCTShadowText.m */; }; - 58B511D11A9E6C5C00147676 /* RCTTextManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 58B511CD1A9E6C5C00147676 /* RCTTextManager.m */; }; - 58B512161A9E6EFF00147676 /* RCTText.m in Sources */ = {isa = PBXBuildFile; fileRef = 58B512141A9E6EFF00147676 /* RCTText.m */; }; -/* End PBXBuildFile section */ - -/* Begin PBXCopyFilesBuildPhase section */ - 58B511991A9E6C1200147676 /* CopyFiles */ = { - isa = PBXCopyFilesBuildPhase; - buildActionMask = 2147483647; - dstPath = "include/$(PRODUCT_NAME)"; - dstSubfolderSpec = 16; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXCopyFilesBuildPhase section */ - -/* Begin PBXFileReference section */ - 131B6ABC1AF0CD0600FFC3E0 /* RCTTextView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTTextView.h; sourceTree = ""; }; - 131B6ABD1AF0CD0600FFC3E0 /* RCTTextView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTTextView.m; sourceTree = ""; }; - 131B6ABE1AF0CD0600FFC3E0 /* RCTTextViewManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTTextViewManager.h; sourceTree = ""; }; - 131B6ABF1AF0CD0600FFC3E0 /* RCTTextViewManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTTextViewManager.m; sourceTree = ""; }; - 1362F0FC1B4D51F400E06D8C /* RCTTextField.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTTextField.h; sourceTree = ""; }; - 1362F0FD1B4D51F400E06D8C /* RCTTextField.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTTextField.m; sourceTree = ""; }; - 1362F0FE1B4D51F400E06D8C /* RCTTextFieldManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTTextFieldManager.h; sourceTree = ""; }; - 1362F0FF1B4D51F400E06D8C /* RCTTextFieldManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTTextFieldManager.m; sourceTree = ""; }; - 58B5119B1A9E6C1200147676 /* libRCTText.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRCTText.a; sourceTree = BUILT_PRODUCTS_DIR; }; - 58B511C61A9E6C5C00147676 /* RCTRawTextManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTRawTextManager.h; sourceTree = ""; }; - 58B511C71A9E6C5C00147676 /* RCTRawTextManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTRawTextManager.m; sourceTree = ""; }; - 58B511C81A9E6C5C00147676 /* RCTShadowRawText.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTShadowRawText.h; sourceTree = ""; }; - 58B511C91A9E6C5C00147676 /* RCTShadowRawText.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTShadowRawText.m; sourceTree = ""; }; - 58B511CA1A9E6C5C00147676 /* RCTShadowText.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTShadowText.h; sourceTree = ""; }; - 58B511CB1A9E6C5C00147676 /* RCTShadowText.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTShadowText.m; sourceTree = ""; }; - 58B511CC1A9E6C5C00147676 /* RCTTextManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTTextManager.h; sourceTree = ""; }; - 58B511CD1A9E6C5C00147676 /* RCTTextManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTTextManager.m; sourceTree = ""; }; - 58B512141A9E6EFF00147676 /* RCTText.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTText.m; sourceTree = ""; }; - 58B512151A9E6EFF00147676 /* RCTText.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTText.h; sourceTree = ""; }; -/* End PBXFileReference section */ - -/* Begin PBXFrameworksBuildPhase section */ - 58B511981A9E6C1200147676 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXFrameworksBuildPhase section */ - -/* Begin PBXGroup section */ - 58B511921A9E6C1200147676 = { - isa = PBXGroup; - children = ( - 58B511C61A9E6C5C00147676 /* RCTRawTextManager.h */, - 58B511C71A9E6C5C00147676 /* RCTRawTextManager.m */, - 58B511C81A9E6C5C00147676 /* RCTShadowRawText.h */, - 58B511C91A9E6C5C00147676 /* RCTShadowRawText.m */, - 58B511CA1A9E6C5C00147676 /* RCTShadowText.h */, - 58B511CB1A9E6C5C00147676 /* RCTShadowText.m */, - 58B512151A9E6EFF00147676 /* RCTText.h */, - 58B512141A9E6EFF00147676 /* RCTText.m */, - 58B511CC1A9E6C5C00147676 /* RCTTextManager.h */, - 58B511CD1A9E6C5C00147676 /* RCTTextManager.m */, - 1362F0FC1B4D51F400E06D8C /* RCTTextField.h */, - 1362F0FD1B4D51F400E06D8C /* RCTTextField.m */, - 1362F0FE1B4D51F400E06D8C /* RCTTextFieldManager.h */, - 1362F0FF1B4D51F400E06D8C /* RCTTextFieldManager.m */, - 131B6ABC1AF0CD0600FFC3E0 /* RCTTextView.h */, - 131B6ABD1AF0CD0600FFC3E0 /* RCTTextView.m */, - 131B6ABE1AF0CD0600FFC3E0 /* RCTTextViewManager.h */, - 131B6ABF1AF0CD0600FFC3E0 /* RCTTextViewManager.m */, - 58B5119C1A9E6C1200147676 /* Products */, - ); - indentWidth = 2; - sourceTree = ""; - tabWidth = 2; - }; - 58B5119C1A9E6C1200147676 /* Products */ = { - isa = PBXGroup; - children = ( - 58B5119B1A9E6C1200147676 /* libRCTText.a */, - ); - name = Products; - sourceTree = ""; - }; -/* End PBXGroup section */ - -/* Begin PBXNativeTarget section */ - 58B5119A1A9E6C1200147676 /* RCTText */ = { - isa = PBXNativeTarget; - buildConfigurationList = 58B511AF1A9E6C1300147676 /* Build configuration list for PBXNativeTarget "RCTText" */; - buildPhases = ( - 58B511971A9E6C1200147676 /* Sources */, - 58B511981A9E6C1200147676 /* Frameworks */, - 58B511991A9E6C1200147676 /* CopyFiles */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = RCTText; - productName = RCTText; - productReference = 58B5119B1A9E6C1200147676 /* libRCTText.a */; - productType = "com.apple.product-type.library.static"; - }; -/* End PBXNativeTarget section */ - -/* Begin PBXProject section */ - 58B511931A9E6C1200147676 /* Project object */ = { - isa = PBXProject; - attributes = { - LastUpgradeCheck = 0610; - ORGANIZATIONNAME = Facebook; - TargetAttributes = { - 58B5119A1A9E6C1200147676 = { - CreatedOnToolsVersion = 6.1.1; - }; - }; - }; - buildConfigurationList = 58B511961A9E6C1200147676 /* Build configuration list for PBXProject "RCTText" */; - compatibilityVersion = "Xcode 3.2"; - developmentRegion = English; - hasScannedForEncodings = 0; - knownRegions = ( - en, - ); - mainGroup = 58B511921A9E6C1200147676; - productRefGroup = 58B5119C1A9E6C1200147676 /* Products */; - projectDirPath = ""; - projectRoot = ""; - targets = ( - 58B5119A1A9E6C1200147676 /* RCTText */, - ); - }; -/* End PBXProject section */ - -/* Begin PBXSourcesBuildPhase section */ - 58B511971A9E6C1200147676 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 58B511D11A9E6C5C00147676 /* RCTTextManager.m in Sources */, - 131B6AC01AF0CD0600FFC3E0 /* RCTTextView.m in Sources */, - 58B511CE1A9E6C5C00147676 /* RCTRawTextManager.m in Sources */, - 1362F1001B4D51F400E06D8C /* RCTTextField.m in Sources */, - 58B512161A9E6EFF00147676 /* RCTText.m in Sources */, - 1362F1011B4D51F400E06D8C /* RCTTextFieldManager.m in Sources */, - 131B6AC11AF0CD0600FFC3E0 /* RCTTextViewManager.m in Sources */, - 58B511CF1A9E6C5C00147676 /* RCTShadowRawText.m in Sources */, - 58B511D01A9E6C5C00147676 /* RCTShadowText.m in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXSourcesBuildPhase section */ - -/* Begin XCBuildConfiguration section */ - 58B511AD1A9E6C1300147676 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - COPY_PHASE_STRIP = NO; - ENABLE_STRICT_OBJC_MSGSEND = YES; - GCC_C_LANGUAGE_STANDARD = gnu99; - GCC_DYNAMIC_NO_PIC = NO; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", - "$(inherited)", - ); - GCC_SYMBOLS_PRIVATE_EXTERN = NO; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES; - GCC_WARN_SHADOW = YES; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 7.0; - MTL_ENABLE_DEBUG_INFO = YES; - ONLY_ACTIVE_ARCH = YES; - SDKROOT = iphoneos; - WARNING_CFLAGS = ( - "-Werror", - "-Wall", - ); - }; - name = Debug; - }; - 58B511AE1A9E6C1300147676 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - COPY_PHASE_STRIP = YES; - ENABLE_NS_ASSERTIONS = NO; - ENABLE_STRICT_OBJC_MSGSEND = YES; - GCC_C_LANGUAGE_STANDARD = gnu99; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES; - GCC_WARN_SHADOW = YES; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 7.0; - MTL_ENABLE_DEBUG_INFO = NO; - SDKROOT = iphoneos; - VALIDATE_PRODUCT = YES; - WARNING_CFLAGS = ( - "-Werror", - "-Wall", - ); - }; - name = Release; - }; - 58B511B01A9E6C1300147676 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - CLANG_STATIC_ANALYZER_MODE = deep; - HEADER_SEARCH_PATHS = ( - "$(inherited)", - /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, - "$(SRCROOT)/../../React/**", - ); - OTHER_LDFLAGS = "-ObjC"; - PRODUCT_NAME = "$(TARGET_NAME)"; - RUN_CLANG_STATIC_ANALYZER = YES; - SKIP_INSTALL = YES; - }; - name = Debug; - }; - 58B511B11A9E6C1300147676 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - CLANG_STATIC_ANALYZER_MODE = deep; - HEADER_SEARCH_PATHS = ( - "$(inherited)", - /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, - "$(SRCROOT)/../../React/**", - ); - OTHER_LDFLAGS = "-ObjC"; - PRODUCT_NAME = "$(TARGET_NAME)"; - SKIP_INSTALL = YES; - }; - name = Release; - }; -/* End XCBuildConfiguration section */ - -/* Begin XCConfigurationList section */ - 58B511961A9E6C1200147676 /* Build configuration list for PBXProject "RCTText" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 58B511AD1A9E6C1300147676 /* Debug */, - 58B511AE1A9E6C1300147676 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 58B511AF1A9E6C1300147676 /* Build configuration list for PBXNativeTarget "RCTText" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 58B511B01A9E6C1300147676 /* Debug */, - 58B511B11A9E6C1300147676 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; -/* End XCConfigurationList section */ - }; - rootObject = 58B511931A9E6C1200147676 /* Project object */; -} diff --git a/examples/node_modules/react-native/Libraries/Text/RCTText.xcodeproj/xcuserdata/yuji.xcuserdatad/xcschemes/xcschememanagement.plist b/examples/node_modules/react-native/Libraries/Text/RCTText.xcodeproj/xcuserdata/yuji.xcuserdatad/xcschemes/xcschememanagement.plist deleted file mode 100644 index 780b61ed..00000000 --- a/examples/node_modules/react-native/Libraries/Text/RCTText.xcodeproj/xcuserdata/yuji.xcuserdatad/xcschemes/xcschememanagement.plist +++ /dev/null @@ -1,22 +0,0 @@ - - - - - SchemeUserState - - RCTText.xcscheme - - orderHint - 8 - - - SuppressBuildableAutocreation - - 58B5119A1A9E6C1200147676 - - primary - - - - - diff --git a/examples/node_modules/react-native/Libraries/Text/RCTTextManager.h b/examples/node_modules/react-native/Libraries/Text/RCTTextManager.h deleted file mode 100644 index 91ac87ba..00000000 --- a/examples/node_modules/react-native/Libraries/Text/RCTTextManager.h +++ /dev/null @@ -1,14 +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. - */ - -#import "RCTViewManager.h" - -@interface RCTTextManager : RCTViewManager - -@end diff --git a/examples/node_modules/react-native/Libraries/Text/RCTTextManager.m b/examples/node_modules/react-native/Libraries/Text/RCTTextManager.m deleted file mode 100644 index 5496b3b8..00000000 --- a/examples/node_modules/react-native/Libraries/Text/RCTTextManager.m +++ /dev/null @@ -1,173 +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. - */ - -#import "RCTTextManager.h" - -#import "RCTAccessibilityManager.h" -#import "RCTAssert.h" -#import "RCTConvert.h" -#import "RCTLog.h" -#import "RCTShadowRawText.h" -#import "RCTShadowText.h" -#import "RCTText.h" -#import "RCTTextView.h" -#import "UIView+React.h" - -@interface RCTShadowText (Private) - -- (NSTextStorage *)buildTextStorageForWidth:(CGFloat)width; - -@end - - -@implementation RCTTextManager - -RCT_EXPORT_MODULE() - -- (UIView *)view -{ - return [RCTText new]; -} - -- (RCTShadowView *)shadowView -{ - return [RCTShadowText new]; -} - -#pragma mark - Shadow properties - -RCT_EXPORT_SHADOW_PROPERTY(color, UIColor) -RCT_EXPORT_SHADOW_PROPERTY(fontFamily, NSString) -RCT_EXPORT_SHADOW_PROPERTY(fontSize, CGFloat) -RCT_EXPORT_SHADOW_PROPERTY(fontWeight, NSString) -RCT_EXPORT_SHADOW_PROPERTY(fontStyle, NSString) -RCT_EXPORT_SHADOW_PROPERTY(isHighlighted, BOOL) -RCT_EXPORT_SHADOW_PROPERTY(letterSpacing, CGFloat) -RCT_EXPORT_SHADOW_PROPERTY(lineHeight, CGFloat) -RCT_EXPORT_SHADOW_PROPERTY(numberOfLines, NSUInteger) -RCT_EXPORT_SHADOW_PROPERTY(shadowOffset, CGSize) -RCT_EXPORT_SHADOW_PROPERTY(textAlign, NSTextAlignment) -RCT_EXPORT_SHADOW_PROPERTY(textDecorationStyle, NSUnderlineStyle) -RCT_EXPORT_SHADOW_PROPERTY(textDecorationColor, UIColor) -RCT_EXPORT_SHADOW_PROPERTY(textDecorationLine, RCTTextDecorationLineType) -RCT_EXPORT_SHADOW_PROPERTY(writingDirection, NSWritingDirection) -RCT_EXPORT_SHADOW_PROPERTY(allowFontScaling, BOOL) -RCT_EXPORT_SHADOW_PROPERTY(opacity, CGFloat) - -- (RCTViewManagerUIBlock)uiBlockToAmendWithShadowViewRegistry:(NSDictionary *)shadowViewRegistry -{ - NSMutableSet *textViewTagsToUpdate = [NSMutableSet new]; - for (RCTShadowView *rootView in shadowViewRegistry.allValues) { - if (![rootView isReactRootView]) { - // This isn't a root view - continue; - } - - if (![rootView isTextDirty]) { - // No text processing to be done - continue; - } - - NSMutableArray *queue = [NSMutableArray arrayWithObject:rootView]; - for (NSInteger i = 0; i < queue.count; i++) { - RCTShadowView *shadowView = queue[i]; - RCTAssert([shadowView isTextDirty], @"Don't process any nodes that don't have dirty text"); - - if ([shadowView isKindOfClass:[RCTShadowText class]]) { - ((RCTShadowText *)shadowView).fontSizeMultiplier = self.bridge.accessibilityManager.multiplier; - [(RCTShadowText *)shadowView recomputeText]; - } else if ([shadowView isKindOfClass:[RCTShadowRawText class]]) { - RCTLogError(@"Raw text cannot be used outside of a tag. Not rendering string: '%@'", - [(RCTShadowRawText *)shadowView text]); - } else { - NSNumber *reactTag = shadowView.reactTag; - // This isn't pretty, but hopefully it's temporary - // the problem is, there's no easy way (besides the viewName) - // to tell from the shadowView if the view is an RKTextView - if ([shadowView.viewName hasSuffix:@"TextView"]) { - // Add to textViewTagsToUpdate only if has a RCTShadowText subview - for (RCTShadowView *subview in shadowView.reactSubviews) { - if ([subview isKindOfClass:[RCTShadowText class]]) { - [textViewTagsToUpdate addObject:reactTag]; - break; - } - } - } - for (RCTShadowView *child in [shadowView reactSubviews]) { - if ([child isTextDirty]) { - [queue addObject:child]; - } - } - } - - [shadowView setTextComputed]; - } - } - - /** - * NOTE: this logic is included to support rich text editing inside multiline - * `` controls, a feature which is not yet supported in open source. - * It is required in order to ensure that the textStorage (aka attributed - * string) is copied over from the RCTShadowText to the RCTText view in time - * to be used to update the editable text content. - */ - if (textViewTagsToUpdate.count) { - - NSMutableArray *uiBlocks = [NSMutableArray new]; - for (NSNumber *reactTag in textViewTagsToUpdate) { - RCTShadowView *shadowTextView = shadowViewRegistry[reactTag]; - RCTShadowText *shadowText; - for (RCTShadowText *subview in shadowTextView.reactSubviews) { - if ([subview isKindOfClass:[RCTShadowText class]]) { - shadowText = subview; - break; - } - } - - UIEdgeInsets padding = shadowText.paddingAsInsets; - CGFloat width = shadowText.frame.size.width - (padding.left + padding.right); - NSTextStorage *textStorage = [shadowText buildTextStorageForWidth:width]; - - [uiBlocks addObject:^(RCTUIManager *uiManager, NSDictionary *viewRegistry) { - RCTTextView *textView = viewRegistry[reactTag]; - RCTText *text; - for (RCTText *subview in textView.reactSubviews) { - if ([subview isKindOfClass:[RCTText class]]) { - text = subview; - break; - } - } - - text.textStorage = textStorage; - [textView performTextUpdate]; - }]; - } - - return ^(RCTUIManager *uiManager, NSDictionary *viewRegistry) { - for (RCTViewManagerUIBlock uiBlock in uiBlocks) { - uiBlock(uiManager, viewRegistry); - } - }; - } else { - return nil; - } -} - -- (RCTViewManagerUIBlock)uiBlockToAmendWithShadowView:(RCTShadowText *)shadowView -{ - NSNumber *reactTag = shadowView.reactTag; - UIEdgeInsets padding = shadowView.paddingAsInsets; - - return ^(RCTUIManager *uiManager, NSDictionary *viewRegistry) { - RCTText *text = viewRegistry[reactTag]; - text.contentInset = padding; - }; -} - -@end diff --git a/examples/node_modules/react-native/Libraries/Text/Text.js b/examples/node_modules/react-native/Libraries/Text/Text.js deleted file mode 100644 index 8d9f68fb..00000000 --- a/examples/node_modules/react-native/Libraries/Text/Text.js +++ /dev/null @@ -1,250 +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. - * - * @providesModule Text - * @flow - */ -'use strict'; - -const NativeMethodsMixin = require('NativeMethodsMixin'); -const Platform = require('Platform'); -const React = require('React'); -const ReactInstanceMap = require('ReactInstanceMap'); -const ReactNativeViewAttributes = require('ReactNativeViewAttributes'); -const StyleSheetPropType = require('StyleSheetPropType'); -const TextStylePropTypes = require('TextStylePropTypes'); -const Touchable = require('Touchable'); - -const createReactNativeComponentClass = - require('createReactNativeComponentClass'); -const merge = require('merge'); - -const stylePropType = StyleSheetPropType(TextStylePropTypes); - -const viewConfig = { - validAttributes: merge(ReactNativeViewAttributes.UIView, { - isHighlighted: true, - numberOfLines: true, - allowFontScaling: true, - }), - uiViewClassName: 'RCTText', -}; - -/** - * A React component for displaying text which supports nesting, - * styling, and touch handling. In the following example, the nested title and - * body text will inherit the `fontFamily` from `styles.baseText`, but the title - * provides its own additional styles. The title and body will stack on top of - * each other on account of the literal newlines: - * - * ``` - * renderText: function() { - * return ( - * - * - * {this.state.titleText + '\n\n'} - * - * - * {this.state.bodyText} - * - * - * ); - * }, - * ... - * var styles = StyleSheet.create({ - * baseText: { - * fontFamily: 'Cochin', - * }, - * titleText: { - * fontSize: 20, - * fontWeight: 'bold', - * }, - * }; - * ``` - */ - -const Text = React.createClass({ - propTypes: { - /** - * Used to truncate the text with an elipsis after computing the text - * layout, including line wrapping, such that the total number of lines - * does not exceed this number. - */ - numberOfLines: React.PropTypes.number, - /** - * Invoked on mount and layout changes with - * - * `{nativeEvent: {layout: {x, y, width, height}}}` - */ - onLayout: React.PropTypes.func, - /** - * This function is called on press. - */ - onPress: React.PropTypes.func, - /** - * When true, no visual change is made when text is pressed down. By - * default, a gray oval highlights the text on press down. - * @platform ios - */ - suppressHighlighting: React.PropTypes.bool, - style: stylePropType, - /** - * Used to locate this view in end-to-end tests. - */ - testID: React.PropTypes.string, - /** - * Specifies should fonts scale to respect Text Size accessibility setting on iOS. - */ - allowFontScaling: React.PropTypes.bool, - }, - getDefaultProps(): Object { - return { - accessible: true, - allowFontScaling: true, - }; - }, - getInitialState: function(): Object { - return merge(Touchable.Mixin.touchableGetInitialState(), { - isHighlighted: false, - }); - }, - mixins: [NativeMethodsMixin], - viewConfig: viewConfig, - getChildContext(): Object { - return {isInAParentText: true}; - }, - childContextTypes: { - isInAParentText: React.PropTypes.bool - }, - contextTypes: { - isInAParentText: React.PropTypes.bool - }, - /** - * Only assigned if touch is needed. - */ - _handlers: (null: ?Object), - /** - * These are assigned lazily the first time the responder is set to make plain - * text nodes as cheap as possible. - */ - touchableHandleActivePressIn: (null: ?Function), - touchableHandleActivePressOut: (null: ?Function), - touchableHandlePress: (null: ?Function), - touchableGetPressRectOffset: (null: ?Function), - render(): ReactElement { - let newProps = this.props; - if (this.props.onStartShouldSetResponder || this.props.onPress) { - if (!this._handlers) { - this._handlers = { - onStartShouldSetResponder: (): bool => { - const shouldSetFromProps = this.props.onStartShouldSetResponder && - this.props.onStartShouldSetResponder(); - const setResponder = shouldSetFromProps || !!this.props.onPress; - if (setResponder && !this.touchableHandleActivePressIn) { - // Attach and bind all the other handlers only the first time a touch - // actually happens. - for (let key in Touchable.Mixin) { - if (typeof Touchable.Mixin[key] === 'function') { - (this: any)[key] = Touchable.Mixin[key].bind(this); - } - } - this.touchableHandleActivePressIn = () => { - if (this.props.suppressHighlighting || !this.props.onPress) { - return; - } - this.setState({ - isHighlighted: true, - }); - }; - - this.touchableHandleActivePressOut = () => { - if (this.props.suppressHighlighting || !this.props.onPress) { - return; - } - this.setState({ - isHighlighted: false, - }); - }; - - this.touchableHandlePress = () => { - this.props.onPress && this.props.onPress(); - }; - - this.touchableGetPressRectOffset = function(): RectOffset { - return PRESS_RECT_OFFSET; - }; - } - return setResponder; - }, - onResponderGrant: function(e: SyntheticEvent, dispatchID: string) { - this.touchableHandleResponderGrant(e, dispatchID); - this.props.onResponderGrant && - this.props.onResponderGrant.apply(this, arguments); - }.bind(this), - onResponderMove: function(e: SyntheticEvent) { - this.touchableHandleResponderMove(e); - this.props.onResponderMove && - this.props.onResponderMove.apply(this, arguments); - }.bind(this), - onResponderRelease: function(e: SyntheticEvent) { - this.touchableHandleResponderRelease(e); - this.props.onResponderRelease && - this.props.onResponderRelease.apply(this, arguments); - }.bind(this), - onResponderTerminate: function(e: SyntheticEvent) { - this.touchableHandleResponderTerminate(e); - this.props.onResponderTerminate && - this.props.onResponderTerminate.apply(this, arguments); - }.bind(this), - onResponderTerminationRequest: function(): bool { - // Allow touchable or props.onResponderTerminationRequest to deny - // the request - var allowTermination = this.touchableHandleResponderTerminationRequest(); - if (allowTermination && this.props.onResponderTerminationRequest) { - allowTermination = this.props.onResponderTerminationRequest.apply(this, arguments); - } - return allowTermination; - }.bind(this), - }; - } - newProps = { - ...this.props, - ...this._handlers, - isHighlighted: this.state.isHighlighted, - }; - } - if (this.context.isInAParentText) { - return ; - } else { - return ; - } - }, -}); - -type RectOffset = { - top: number; - left: number; - right: number; - bottom: number; -} - -var PRESS_RECT_OFFSET = {top: 20, left: 20, right: 20, bottom: 30}; - -var RCTText = createReactNativeComponentClass(viewConfig); -var RCTVirtualText = RCTText; - -if (Platform.OS === 'android') { - RCTVirtualText = createReactNativeComponentClass({ - validAttributes: merge(ReactNativeViewAttributes.UIView, { - isHighlighted: true, - }), - uiViewClassName: 'RCTVirtualText', - }); -} - -module.exports = Text; diff --git a/examples/node_modules/react-native/Libraries/Text/TextStylePropTypes.js b/examples/node_modules/react-native/Libraries/Text/TextStylePropTypes.js deleted file mode 100644 index cbd62493..00000000 --- a/examples/node_modules/react-native/Libraries/Text/TextStylePropTypes.js +++ /dev/null @@ -1,82 +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. - * - * @providesModule TextStylePropTypes - * @flow - */ -'use strict'; - -var ReactPropTypes = require('ReactPropTypes'); -var ViewStylePropTypes = require('ViewStylePropTypes'); - -// TODO: use spread instead of Object.assign/create after #6560135 is fixed -var TextStylePropTypes = Object.assign(Object.create(ViewStylePropTypes), { - color: ReactPropTypes.string, - fontFamily: ReactPropTypes.string, - fontSize: ReactPropTypes.number, - fontStyle: ReactPropTypes.oneOf(['normal', 'italic']), - /** - * Specifies font weight. The values 'normal' and 'bold' are supported for - * most fonts. Not all fonts have a variant for each of the numeric values, - * in that case the closest one is chosen. - */ - fontWeight: ReactPropTypes.oneOf( - ['normal' /*default*/, 'bold', - '100', '200', '300', '400', '500', '600', '700', '800', '900'] - ), - /** - * @platform ios - */ - letterSpacing: ReactPropTypes.number, - lineHeight: ReactPropTypes.number, - /** - * Specifies text alignment. The value 'justify' is only supported on iOS. - */ - textAlign: ReactPropTypes.oneOf( - ['auto' /*default*/, 'left', 'right', 'center', 'justify'] - ), - /** - * @platform ios - */ - textDecorationLine: ReactPropTypes.oneOf( - ['none' /*default*/, 'underline', 'line-through', 'underline line-through'] - ), - /** - * @platform ios - */ - textDecorationStyle: ReactPropTypes.oneOf( - ['solid' /*default*/, 'double', 'dotted','dashed'] - ), - /** - * @platform ios - */ - textDecorationColor: ReactPropTypes.string, - /** - * @platform ios - */ - writingDirection: ReactPropTypes.oneOf( - ['auto' /*default*/, 'ltr', 'rtl'] - ), -}); - -// Text doesn't support padding correctly (#4841912) -var unsupportedProps = Object.keys({ - padding: null, - paddingTop: null, - paddingLeft: null, - paddingRight: null, - paddingBottom: null, - paddingVertical: null, - paddingHorizontal: null, -}); - -for (var ii = 0; ii < unsupportedProps.length; ii++) { - delete TextStylePropTypes[unsupportedProps[ii]]; -} - -module.exports = TextStylePropTypes; diff --git a/examples/node_modules/react-native/Libraries/Utilities/AlertIOS.js b/examples/node_modules/react-native/Libraries/Utilities/AlertIOS.js deleted file mode 100644 index 38fd0f88..00000000 --- a/examples/node_modules/react-native/Libraries/Utilities/AlertIOS.js +++ /dev/null @@ -1,124 +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. - * - * @providesModule AlertIOS - * @flow - */ -'use strict'; - -var RCTAlertManager = require('NativeModules').AlertManager; -var invariant = require('invariant'); - -export type AlertType = $Enum<{ - 'default': string; - 'plain-text': string; - 'secure-text': string; - 'login-password': string; -}>; - -export type AlertButtonStyle = $Enum<{ - 'default': string; - 'cancel': string; - 'destructive': string; -}>; - -/** - * Launches an alert dialog with the specified title and message. - * - * Optionally provide a list of buttons. Tapping any button will fire the - * respective onPress callback and dismiss the alert. By default, the only - * button will be an 'OK' button. - * - * ``` - * AlertIOS.alert( - * 'Foo Title', - * 'My Alert Msg', - * [ - * {text: 'OK', onPress: () => console.log('OK Pressed')}, - * {text: 'Cancel', onPress: () => console.log('Cancel Pressed'), style: 'cancel'}, - * ] - * ) - * ``` - */ -class AlertIOS { - static alert( - title: ?string, - message?: ?string, - buttons?: Array<{ - text?: string; - onPress?: ?Function; - style?: AlertButtonStyle; - }>, - type?: ?AlertType - ): void { - var callbacks = []; - var buttonsSpec = []; - var cancelButtonKey; - var destructiveButtonKey; - buttons && buttons.forEach((btn, index) => { - callbacks[index] = btn.onPress; - if (btn.style == 'cancel') { - cancelButtonKey = String(index); - } else if (btn.style == 'destructive') { - destructiveButtonKey = String(index); - } - if (btn.text || index < (buttons || []).length - 1) { - var btnDef = {}; - btnDef[index] = btn.text || ''; - buttonsSpec.push(btnDef); - } - }); - RCTAlertManager.alertWithArgs({ - title: title || undefined, - message: message || undefined, - buttons: buttonsSpec, - type: type || undefined, - cancelButtonKey, - destructiveButtonKey, - }, (id, value) => { - var cb = callbacks[id]; - cb && cb(value); - }); - } - - static prompt( - title: string, - value?: string, - buttons?: Array<{ - text?: string; - onPress?: ?Function; - style?: AlertButtonStyle; - }>, - callback?: ?Function - ): void { - if (arguments.length === 2) { - if (typeof value === 'object') { - buttons = value; - value = undefined; - } else if (typeof value === 'function') { - callback = value; - value = undefined; - } - } else if (arguments.length === 3 && typeof buttons === 'function') { - callback = buttons; - buttons = undefined; - } - - invariant( - !(callback && buttons) && (callback || buttons), - 'Must provide either a button list or a callback, but not both' - ); - - if (!buttons) { - buttons = [{ onPress: callback }]; - } - this.alert(title, value, buttons, 'plain-text'); - } -} - -module.exports = AlertIOS; diff --git a/examples/node_modules/react-native/Libraries/Utilities/BackAndroid.ios.js b/examples/node_modules/react-native/Libraries/Utilities/BackAndroid.ios.js deleted file mode 100644 index a2461755..00000000 --- a/examples/node_modules/react-native/Libraries/Utilities/BackAndroid.ios.js +++ /dev/null @@ -1,24 +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. - * - * iOS stub for BackAndroid.android.js - * - * @providesModule BackAndroid - */ - -'use strict'; - -function emptyFunction() {} - -const BackAndroid = { - exitApp: emptyFunction, - addEventListener: emptyFunction, - removeEventListener: emptyFunction, -}; - -module.exports = BackAndroid; diff --git a/examples/node_modules/react-native/Libraries/Utilities/CSSVarConfig.js b/examples/node_modules/react-native/Libraries/Utilities/CSSVarConfig.js deleted file mode 100644 index cb018be0..00000000 --- a/examples/node_modules/react-native/Libraries/Utilities/CSSVarConfig.js +++ /dev/null @@ -1,62 +0,0 @@ -/** - * Copyright 2004-present Facebook. All Rights Reserved. - * - * @providesModule CSSVarConfig - */ -'use strict'; - -// this a partial list of the contants in CSSConstants:: from PHP that are applicable to mobile - -module.exports = { - 'fbui-accent-blue': '#5890ff', - 'fbui-blue-90': '#4e69a2', - 'fbui-blue-80': '#627aad', - 'fbui-blue-70': '#758ab7', - 'fbui-blue-60': '#899bc1', - 'fbui-blue-50': '#9daccb', - 'fbui-blue-40': '#b1bdd6', - 'fbui-blue-30': '#c4cde0', - 'fbui-blue-20': '#d8deea', - 'fbui-blue-10': '#ebeef4', - 'fbui-blue-5': '#f5f7fa', - 'fbui-blue-2': '#fbfcfd', - 'fbui-blueblack-90': '#06090f', - 'fbui-blueblack-80': '#0c121e', - 'fbui-blueblack-70': '#121b2e', - 'fbui-blueblack-60': '#18243d', - 'fbui-blueblack-50': '#1e2d4c', - 'fbui-blueblack-40': '#23355b', - 'fbui-blueblack-30': '#293e6b', - 'fbui-blueblack-20': '#2f477a', - 'fbui-blueblack-10': '#355089', - 'fbui-blueblack-5': '#385490', - 'fbui-blueblack-2': '#3a5795', - 'fbui-bluegray-90': '#080a10', - 'fbui-bluegray-80': '#141823', - 'fbui-bluegray-70': '#232937', - 'fbui-bluegray-60': '#373e4d', - 'fbui-bluegray-50': '#4e5665', - 'fbui-bluegray-40': '#6a7180', - 'fbui-bluegray-30': '#9197a3', - 'fbui-bluegray-20': '#bdc1c9', - 'fbui-bluegray-10': '#dcdee3', - 'fbui-bluegray-5': '#e9eaed', - 'fbui-bluegray-2': '#f6f7f8', - 'fbui-gray-90': '#191919', - 'fbui-gray-80': '#333333', - 'fbui-gray-70': '#4c4c4c', - 'fbui-gray-60': '#666666', - 'fbui-gray-50': '#7f7f7f', - 'fbui-gray-40': '#999999', - 'fbui-gray-30': '#b2b2b2', - 'fbui-gray-20': '#cccccc', - 'fbui-gray-10': '#e5e5e5', - 'fbui-gray-5': '#f2f2f2', - 'fbui-gray-2': '#fafafa', - 'fbui-red': '#da2929', - 'fbui-error': '#ce0d24', - 'x-mobile-dark-text': '#4e5665', - 'x-mobile-medium-text': '#6a7180', - 'x-mobile-light-text': '#9197a3', - 'x-mobile-base-wash': '#dcdee3', -}; diff --git a/examples/node_modules/react-native/Libraries/Utilities/Dimensions.js b/examples/node_modules/react-native/Libraries/Utilities/Dimensions.js deleted file mode 100644 index 319aa846..00000000 --- a/examples/node_modules/react-native/Libraries/Utilities/Dimensions.js +++ /dev/null @@ -1,69 +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. - * - * @providesModule Dimensions - * @flow - */ -'use strict'; - -var UIManager = require('UIManager'); - -var invariant = require('invariant'); - -var dimensions = UIManager.Dimensions; - -// We calculate the window dimensions in JS so that we don't encounter loss of -// precision in transferring the dimensions (which could be non-integers) over -// the bridge. -if (dimensions && dimensions.windowPhysicalPixels) { - // parse/stringify => Clone hack - dimensions = JSON.parse(JSON.stringify(dimensions)); - - var windowPhysicalPixels = dimensions.windowPhysicalPixels; - dimensions.window = { - width: windowPhysicalPixels.width / windowPhysicalPixels.scale, - height: windowPhysicalPixels.height / windowPhysicalPixels.scale, - scale: windowPhysicalPixels.scale, - fontScale: windowPhysicalPixels.fontScale, - }; - - // delete so no callers rely on this existing - delete dimensions.windowPhysicalPixels; -} - -class Dimensions { - /** - * This should only be called from native code. - * - * @param {object} dims Simple string-keyed object of dimensions to set - */ - static set(dims: {[key:string]: any}): bool { - Object.assign(dimensions, dims); - return true; - } - - /** - * Initial dimensions are set before `runApplication` is called so they should - * be available before any other require's are run, but may be updated later. - * - * Note: Although dimensions are available immediately, they may change (e.g - * due to device rotation) so any rendering logic or styles that depend on - * these constants should try to call this function on every render, rather - * than caching the value (for example, using inline styles rather than - * setting a value in a `StyleSheet`). - * - * @param {string} dim Name of dimension as defined when calling `set`. - * @returns {Object?} Value for the dimension. - */ - static get(dim: string): Object { - invariant(dimensions[dim], 'No dimension set for key ' + dim); - return dimensions[dim]; - } -} - -module.exports = Dimensions; diff --git a/examples/node_modules/react-native/Libraries/Utilities/ErrorUtils.js b/examples/node_modules/react-native/Libraries/Utilities/ErrorUtils.js deleted file mode 100644 index 3f15ce2c..00000000 --- a/examples/node_modules/react-native/Libraries/Utilities/ErrorUtils.js +++ /dev/null @@ -1,27 +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. - * - * @providesModule ErrorUtils - */ -/* eslint-disable consistent-this, global-strict */ - -var GLOBAL = this; - -/** - * The particular require runtime that we are using looks for a global - * `ErrorUtils` object and if it exists, then it requires modules with the - * error handler specified via ErrorUtils.setGlobalHandler by calling the - * require function with applyWithGuard. Since the require module is loaded - * before any of the modules, this ErrorUtils must be defined (and the handler - * set) globally before requiring anything. - * - * However, we still want to treat ErrorUtils as a module so that other modules - * that use it aren't just using a global variable, so simply export the global - * variable here. ErrorUtils is originally defined in a file named error-guard.js. - */ -module.exports = GLOBAL.ErrorUtils; diff --git a/examples/node_modules/react-native/Libraries/Utilities/MatrixMath.js b/examples/node_modules/react-native/Libraries/Utilities/MatrixMath.js deleted file mode 100755 index addc8660..00000000 --- a/examples/node_modules/react-native/Libraries/Utilities/MatrixMath.js +++ /dev/null @@ -1,597 +0,0 @@ -/** - * Copyright 2004-present Facebook. All Rights Reserved. - * - * @providesModule MatrixMath - * @noflow - */ -/* eslint-disable space-infix-ops */ -'use strict'; - -var invariant = require('invariant'); - -/** - * Memory conservative (mutative) matrix math utilities. Uses "command" - * matrices, which are reusable. - */ -var MatrixMath = { - createIdentityMatrix: function() { - return [ - 1,0,0,0, - 0,1,0,0, - 0,0,1,0, - 0,0,0,1 - ]; - }, - - createCopy: function(m) { - return [ - m[0], m[1], m[2], m[3], - m[4], m[5], m[6], m[7], - m[8], m[9], m[10], m[11], - m[12], m[13], m[14], m[15], - ]; - }, - - createOrthographic: function(left, right, bottom, top, near, far) { - var a = 2 / (right - left); - var b = 2 / (top - bottom); - var c = -2 / (far - near); - - var tx = -(right + left) / (right - left); - var ty = -(top + bottom) / (top - bottom); - var tz = -(far + near) / (far - near); - - return [ - a, 0, 0, 0, - 0, b, 0, 0, - 0, 0, c, 0, - tx, ty, tz, 1 - ]; - }, - - createFrustum: function(left, right, bottom, top, near, far) { - var r_width = 1 / (right - left); - var r_height = 1 / (top - bottom); - var r_depth = 1 / (near - far); - var x = 2 * (near * r_width); - var y = 2 * (near * r_height); - var A = (right + left) * r_width; - var B = (top + bottom) * r_height; - var C = (far + near) * r_depth; - var D = 2 * (far * near * r_depth); - return [ - x, 0, 0, 0, - 0, y, 0, 0, - A, B, C,-1, - 0, 0, D, 0, - ]; - }, - - createPerspective: function(fovInRadians, aspect, near, far) { - var h = 1 / Math.tan(fovInRadians); - var r_depth = 1 / (near - far); - var C = (far + near) * r_depth; - var D = 2 * (far * near * r_depth); - return [ - h/aspect, 0, 0, 0, - 0, h, 0, 0, - 0, 0, C,-1, - 0, 0, D, 0, - ]; - }, - - createTranslate2d: function(x, y) { - var mat = MatrixMath.createIdentityMatrix(); - MatrixMath.reuseTranslate2dCommand(mat, x, y); - return mat; - }, - - reuseTranslate2dCommand: function(matrixCommand, x, y) { - matrixCommand[12] = x; - matrixCommand[13] = y; - }, - - reuseTranslate3dCommand: function(matrixCommand, x, y, z) { - matrixCommand[12] = x; - matrixCommand[13] = y; - matrixCommand[14] = z; - }, - - createScale: function(factor) { - var mat = MatrixMath.createIdentityMatrix(); - MatrixMath.reuseScaleCommand(mat, factor); - return mat; - }, - - reuseScaleCommand: function(matrixCommand, factor) { - matrixCommand[0] = factor; - matrixCommand[5] = factor; - }, - - reuseScale3dCommand: function(matrixCommand, x, y, z) { - matrixCommand[0] = x; - matrixCommand[5] = y; - matrixCommand[10] = z; - }, - - reusePerspectiveCommand: function(matrixCommand, p) { - matrixCommand[11] = -1 / p; - }, - - reuseScaleXCommand(matrixCommand, factor) { - matrixCommand[0] = factor; - }, - - reuseScaleYCommand(matrixCommand, factor) { - matrixCommand[5] = factor; - }, - - reuseScaleZCommand(matrixCommand, factor) { - matrixCommand[10] = factor; - }, - - reuseRotateXCommand: function(matrixCommand, radians) { - matrixCommand[5] = Math.cos(radians); - matrixCommand[6] = Math.sin(radians); - matrixCommand[9] = -Math.sin(radians); - matrixCommand[10] = Math.cos(radians); - }, - - reuseRotateYCommand: function(matrixCommand, amount) { - matrixCommand[0] = Math.cos(amount); - matrixCommand[2] = -Math.sin(amount); - matrixCommand[8] = Math.sin(amount); - matrixCommand[10] = Math.cos(amount); - }, - - // http://www.w3.org/TR/css3-transforms/#recomposing-to-a-2d-matrix - reuseRotateZCommand: function(matrixCommand, radians) { - matrixCommand[0] = Math.cos(radians); - matrixCommand[1] = Math.sin(radians); - matrixCommand[4] = -Math.sin(radians); - matrixCommand[5] = Math.cos(radians); - }, - - createRotateZ: function(radians) { - var mat = MatrixMath.createIdentityMatrix(); - MatrixMath.reuseRotateZCommand(mat, radians); - return mat; - }, - - reuseSkewXCommand: function(matrixCommand, radians) { - matrixCommand[4] = Math.sin(radians); - matrixCommand[5] = Math.cos(radians); - }, - - reuseSkewYCommand: function(matrixCommand, radians) { - matrixCommand[0] = Math.cos(radians); - matrixCommand[1] = Math.sin(radians); - }, - - multiplyInto: function(out, a, b) { - var a00 = a[0], a01 = a[1], a02 = a[2], a03 = a[3], - a10 = a[4], a11 = a[5], a12 = a[6], a13 = a[7], - a20 = a[8], a21 = a[9], a22 = a[10], a23 = a[11], - a30 = a[12], a31 = a[13], a32 = a[14], a33 = a[15]; - - var b0 = b[0], b1 = b[1], b2 = b[2], b3 = b[3]; - out[0] = b0*a00 + b1*a10 + b2*a20 + b3*a30; - out[1] = b0*a01 + b1*a11 + b2*a21 + b3*a31; - out[2] = b0*a02 + b1*a12 + b2*a22 + b3*a32; - out[3] = b0*a03 + b1*a13 + b2*a23 + b3*a33; - - b0 = b[4]; b1 = b[5]; b2 = b[6]; b3 = b[7]; - out[4] = b0*a00 + b1*a10 + b2*a20 + b3*a30; - out[5] = b0*a01 + b1*a11 + b2*a21 + b3*a31; - out[6] = b0*a02 + b1*a12 + b2*a22 + b3*a32; - out[7] = b0*a03 + b1*a13 + b2*a23 + b3*a33; - - b0 = b[8]; b1 = b[9]; b2 = b[10]; b3 = b[11]; - out[8] = b0*a00 + b1*a10 + b2*a20 + b3*a30; - out[9] = b0*a01 + b1*a11 + b2*a21 + b3*a31; - out[10] = b0*a02 + b1*a12 + b2*a22 + b3*a32; - out[11] = b0*a03 + b1*a13 + b2*a23 + b3*a33; - - b0 = b[12]; b1 = b[13]; b2 = b[14]; b3 = b[15]; - out[12] = b0*a00 + b1*a10 + b2*a20 + b3*a30; - out[13] = b0*a01 + b1*a11 + b2*a21 + b3*a31; - out[14] = b0*a02 + b1*a12 + b2*a22 + b3*a32; - out[15] = b0*a03 + b1*a13 + b2*a23 + b3*a33; - }, - - determinant(matrix: Array): number { - var [ - m00, m01, m02, m03, - m10, m11, m12, m13, - m20, m21, m22, m23, - m30, m31, m32, m33 - ] = matrix; - return ( - m03 * m12 * m21 * m30 - m02 * m13 * m21 * m30 - - m03 * m11 * m22 * m30 + m01 * m13 * m22 * m30 + - m02 * m11 * m23 * m30 - m01 * m12 * m23 * m30 - - m03 * m12 * m20 * m31 + m02 * m13 * m20 * m31 + - m03 * m10 * m22 * m31 - m00 * m13 * m22 * m31 - - m02 * m10 * m23 * m31 + m00 * m12 * m23 * m31 + - m03 * m11 * m20 * m32 - m01 * m13 * m20 * m32 - - m03 * m10 * m21 * m32 + m00 * m13 * m21 * m32 + - m01 * m10 * m23 * m32 - m00 * m11 * m23 * m32 - - m02 * m11 * m20 * m33 + m01 * m12 * m20 * m33 + - m02 * m10 * m21 * m33 - m00 * m12 * m21 * m33 - - m01 * m10 * m22 * m33 + m00 * m11 * m22 * m33 - ); - }, - - /** - * Inverse of a matrix. Multiplying by the inverse is used in matrix math - * instead of division. - * - * Formula from: - * http://www.euclideanspace.com/maths/algebra/matrix/functions/inverse/fourD/index.htm - */ - inverse(matrix: Array): Array { - var det = MatrixMath.determinant(matrix); - if (!det) { - return matrix; - } - var [ - m00, m01, m02, m03, - m10, m11, m12, m13, - m20, m21, m22, m23, - m30, m31, m32, m33 - ] = matrix; - return [ - (m12*m23*m31 - m13*m22*m31 + m13*m21*m32 - m11*m23*m32 - m12*m21*m33 + m11*m22*m33) / det, - (m03*m22*m31 - m02*m23*m31 - m03*m21*m32 + m01*m23*m32 + m02*m21*m33 - m01*m22*m33) / det, - (m02*m13*m31 - m03*m12*m31 + m03*m11*m32 - m01*m13*m32 - m02*m11*m33 + m01*m12*m33) / det, - (m03*m12*m21 - m02*m13*m21 - m03*m11*m22 + m01*m13*m22 + m02*m11*m23 - m01*m12*m23) / det, - (m13*m22*m30 - m12*m23*m30 - m13*m20*m32 + m10*m23*m32 + m12*m20*m33 - m10*m22*m33) / det, - (m02*m23*m30 - m03*m22*m30 + m03*m20*m32 - m00*m23*m32 - m02*m20*m33 + m00*m22*m33) / det, - (m03*m12*m30 - m02*m13*m30 - m03*m10*m32 + m00*m13*m32 + m02*m10*m33 - m00*m12*m33) / det, - (m02*m13*m20 - m03*m12*m20 + m03*m10*m22 - m00*m13*m22 - m02*m10*m23 + m00*m12*m23) / det, - (m11*m23*m30 - m13*m21*m30 + m13*m20*m31 - m10*m23*m31 - m11*m20*m33 + m10*m21*m33) / det, - (m03*m21*m30 - m01*m23*m30 - m03*m20*m31 + m00*m23*m31 + m01*m20*m33 - m00*m21*m33) / det, - (m01*m13*m30 - m03*m11*m30 + m03*m10*m31 - m00*m13*m31 - m01*m10*m33 + m00*m11*m33) / det, - (m03*m11*m20 - m01*m13*m20 - m03*m10*m21 + m00*m13*m21 + m01*m10*m23 - m00*m11*m23) / det, - (m12*m21*m30 - m11*m22*m30 - m12*m20*m31 + m10*m22*m31 + m11*m20*m32 - m10*m21*m32) / det, - (m01*m22*m30 - m02*m21*m30 + m02*m20*m31 - m00*m22*m31 - m01*m20*m32 + m00*m21*m32) / det, - (m02*m11*m30 - m01*m12*m30 - m02*m10*m31 + m00*m12*m31 + m01*m10*m32 - m00*m11*m32) / det, - (m01*m12*m20 - m02*m11*m20 + m02*m10*m21 - m00*m12*m21 - m01*m10*m22 + m00*m11*m22) / det - ]; - }, - - /** - * Turns columns into rows and rows into columns. - */ - transpose(m: Array): Array { - return [ - m[0], m[4], m[8], m[12], - m[1], m[5], m[9], m[13], - m[2], m[6], m[10], m[14], - m[3], m[7], m[11], m[15] - ]; - }, - - /** - * Based on: http://tog.acm.org/resources/GraphicsGems/gemsii/unmatrix.c - */ - multiplyVectorByMatrix( - v: Array, - m: Array - ): Array { - var [vx, vy, vz, vw] = v; - return [ - vx * m[0] + vy * m[4] + vz * m[8] + vw * m[12], - vx * m[1] + vy * m[5] + vz * m[9] + vw * m[13], - vx * m[2] + vy * m[6] + vz * m[10] + vw * m[14], - vx * m[3] + vy * m[7] + vz * m[11] + vw * m[15] - ]; - }, - - /** - * From: https://code.google.com/p/webgl-mjs/source/browse/mjs.js - */ - v3Length(a: Array): number { - return Math.sqrt(a[0]*a[0] + a[1]*a[1] + a[2]*a[2]); - }, - - /** - * Based on: https://code.google.com/p/webgl-mjs/source/browse/mjs.js - */ - v3Normalize( - vector: Array, - v3Length: number - ): Array { - var im = 1 / (v3Length || MatrixMath.v3Length(vector)); - return [ - vector[0] * im, - vector[1] * im, - vector[2] * im - ]; - }, - - /** - * The dot product of a and b, two 3-element vectors. - * From: https://code.google.com/p/webgl-mjs/source/browse/mjs.js - */ - v3Dot(a, b) { - return a[0] * b[0] + - a[1] * b[1] + - a[2] * b[2]; - }, - - /** - * From: - * http://www.opensource.apple.com/source/WebCore/WebCore-514/platform/graphics/transforms/TransformationMatrix.cpp - */ - v3Combine( - a: Array, - b: Array, - aScale: number, - bScale: number - ): Array { - return [ - aScale * a[0] + bScale * b[0], - aScale * a[1] + bScale * b[1], - aScale * a[2] + bScale * b[2] - ]; - }, - - /** - * From: - * http://www.opensource.apple.com/source/WebCore/WebCore-514/platform/graphics/transforms/TransformationMatrix.cpp - */ - v3Cross(a: Array, b: Array): Array { - return [ - a[1] * b[2] - a[2] * b[1], - a[2] * b[0] - a[0] * b[2], - a[0] * b[1] - a[1] * b[0] - ]; - }, - - /** - * Based on: - * http://www.euclideanspace.com/maths/geometry/rotations/conversions/quaternionToEuler/ - * and: - * http://quat.zachbennett.com/ - * - * Note that this rounds degrees to the thousandth of a degree, due to - * floating point errors in the creation of the quaternion. - * - * Also note that this expects the qw value to be last, not first. - * - * Also, when researching this, remember that: - * yaw === heading === z-axis - * pitch === elevation/attitude === y-axis - * roll === bank === x-axis - */ - quaternionToDegreesXYZ(q: Array, matrix, row): Array { - var [qx, qy, qz, qw] = q; - var qw2 = qw * qw; - var qx2 = qx * qx; - var qy2 = qy * qy; - var qz2 = qz * qz; - var test = qx * qy + qz * qw; - var unit = qw2 + qx2 + qy2 + qz2; - var conv = 180 / Math.PI; - - if (test > 0.49999 * unit) { - return [0, 2 * Math.atan2(qx, qw) * conv, 90]; - } - if (test < -0.49999 * unit) { - return [0, -2 * Math.atan2(qx, qw) * conv, -90]; - } - - return [ - MatrixMath.roundTo3Places( - Math.atan2(2*qx*qw-2*qy*qz,1-2*qx2-2*qz2) * conv - ), - MatrixMath.roundTo3Places( - Math.atan2(2*qy*qw-2*qx*qz,1-2*qy2-2*qz2) * conv - ), - MatrixMath.roundTo3Places( - Math.asin(2*qx*qy+2*qz*qw) * conv - ) - ]; - }, - - /** - * Based on: - * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/round - */ - roundTo3Places(n: number): number { - var arr = n.toString().split('e'); - return Math.round(arr[0] + 'e' + (arr[1] ? (+arr[1] - 3) : 3)) * 0.001; - }, - - /** - * Decompose a matrix into separate transform values, for use on platforms - * where applying a precomposed matrix is not possible, and transforms are - * applied in an inflexible ordering (e.g. Android). - * - * Implementation based on - * http://www.w3.org/TR/css3-transforms/#decomposing-a-2d-matrix - * http://www.w3.org/TR/css3-transforms/#decomposing-a-3d-matrix - * which was based on - * http://tog.acm.org/resources/GraphicsGems/gemsii/unmatrix.c - */ - decomposeMatrix(transformMatrix: Array): ?Object { - - invariant( - transformMatrix.length === 16, - 'Matrix decomposition needs a list of 3d matrix values, received %s', - transformMatrix - ); - - // output values - var perspective = []; - var quaternion = []; - var scale = []; - var skew = []; - var translation = []; - - // create normalized, 2d array matrix - // and normalized 1d array perspectiveMatrix with redefined 4th column - if (!transformMatrix[15]) { - return; - } - var matrix = []; - var perspectiveMatrix = []; - for (var i = 0; i < 4; i++) { - matrix.push([]); - for (var j = 0; j < 4; j++) { - var value = transformMatrix[(i * 4) + j] / transformMatrix[15]; - matrix[i].push(value); - perspectiveMatrix.push(j === 3 ? 0 : value); - } - } - perspectiveMatrix[15] = 1; - - // test for singularity of upper 3x3 part of the perspective matrix - if (!MatrixMath.determinant(perspectiveMatrix)) { - return; - } - - // isolate perspective - if (matrix[0][3] !== 0 || matrix[1][3] !== 0 || matrix[2][3] !== 0) { - // rightHandSide is the right hand side of the equation. - // rightHandSide is a vector, or point in 3d space relative to the origin. - var rightHandSide = [ - matrix[0][3], - matrix[1][3], - matrix[2][3], - matrix[3][3] - ]; - - // Solve the equation by inverting perspectiveMatrix and multiplying - // rightHandSide by the inverse. - var inversePerspectiveMatrix = MatrixMath.inverse( - perspectiveMatrix - ); - var transposedInversePerspectiveMatrix = MatrixMath.transpose( - inversePerspectiveMatrix - ); - var perspective = MatrixMath.multiplyVectorByMatrix( - rightHandSide, - transposedInversePerspectiveMatrix - ); - } else { - // no perspective - perspective[0] = perspective[1] = perspective[2] = 0; - perspective[3] = 1; - } - - // translation is simple - for (var i = 0; i < 3; i++) { - translation[i] = matrix[3][i]; - } - - // Now get scale and shear. - // 'row' is a 3 element array of 3 component vectors - var row = []; - for (i = 0; i < 3; i++) { - row[i] = [ - matrix[i][0], - matrix[i][1], - matrix[i][2] - ]; - } - - // Compute X scale factor and normalize first row. - scale[0] = MatrixMath.v3Length(row[0]); - row[0] = MatrixMath.v3Normalize(row[0], scale[0]); - - // Compute XY shear factor and make 2nd row orthogonal to 1st. - skew[0] = MatrixMath.v3Dot(row[0], row[1]); - row[1] = MatrixMath.v3Combine(row[1], row[0], 1.0, -skew[0]); - - // Compute XY shear factor and make 2nd row orthogonal to 1st. - skew[0] = MatrixMath.v3Dot(row[0], row[1]); - row[1] = MatrixMath.v3Combine(row[1], row[0], 1.0, -skew[0]); - - // Now, compute Y scale and normalize 2nd row. - scale[1] = MatrixMath.v3Length(row[1]); - row[1] = MatrixMath.v3Normalize(row[1], scale[1]); - skew[0] /= scale[1]; - - // Compute XZ and YZ shears, orthogonalize 3rd row - skew[1] = MatrixMath.v3Dot(row[0], row[2]); - row[2] = MatrixMath.v3Combine(row[2], row[0], 1.0, -skew[1]); - skew[2] = MatrixMath.v3Dot(row[1], row[2]); - row[2] = MatrixMath.v3Combine(row[2], row[1], 1.0, -skew[2]); - - // Next, get Z scale and normalize 3rd row. - scale[2] = MatrixMath.v3Length(row[2]); - row[2] = MatrixMath.v3Normalize(row[2], scale[2]); - skew[1] /= scale[2]; - skew[2] /= scale[2]; - - // At this point, the matrix (in rows) is orthonormal. - // Check for a coordinate system flip. If the determinant - // is -1, then negate the matrix and the scaling factors. - var pdum3 = MatrixMath.v3Cross(row[1], row[2]); - if (MatrixMath.v3Dot(row[0], pdum3) < 0) { - for (i = 0; i < 3; i++) { - scale[i] *= -1; - row[i][0] *= -1; - row[i][1] *= -1; - row[i][2] *= -1; - } - } - - // Now, get the rotations out - quaternion[0] = - 0.5 * Math.sqrt(Math.max(1 + row[0][0] - row[1][1] - row[2][2], 0)); - quaternion[1] = - 0.5 * Math.sqrt(Math.max(1 - row[0][0] + row[1][1] - row[2][2], 0)); - quaternion[2] = - 0.5 * Math.sqrt(Math.max(1 - row[0][0] - row[1][1] + row[2][2], 0)); - quaternion[3] = - 0.5 * Math.sqrt(Math.max(1 + row[0][0] + row[1][1] + row[2][2], 0)); - - if (row[2][1] > row[1][2]) { - quaternion[0] = -quaternion[0]; - } - if (row[0][2] > row[2][0]) { - quaternion[1] = -quaternion[1]; - } - if (row[1][0] > row[0][1]) { - quaternion[2] = -quaternion[2]; - } - - // correct for occasional, weird Euler synonyms for 2d rotation - var rotationDegrees; - if ( - quaternion[0] < 0.001 && quaternion[0] >= 0 && - quaternion[1] < 0.001 && quaternion[1] >= 0 - ) { - // this is a 2d rotation on the z-axis - rotationDegrees = [0, 0, MatrixMath.roundTo3Places( - Math.atan2(row[0][1], row[0][0]) * 180 / Math.PI - )]; - } else { - rotationDegrees = MatrixMath.quaternionToDegreesXYZ(quaternion, matrix, row); - } - - // expose both base data and convenience names - return { - rotationDegrees, - perspective, - quaternion, - scale, - skew, - translation, - - rotate: rotationDegrees[2], - rotateX: rotationDegrees[0], - rotateY: rotationDegrees[1], - scaleX: scale[0], - scaleY: scale[1], - translateX: translation[0], - translateY: translation[1], - }; - }, - -}; - -module.exports = MatrixMath; diff --git a/examples/node_modules/react-native/Libraries/Utilities/MessageQueue.js b/examples/node_modules/react-native/Libraries/Utilities/MessageQueue.js deleted file mode 100644 index adf9376e..00000000 --- a/examples/node_modules/react-native/Libraries/Utilities/MessageQueue.js +++ /dev/null @@ -1,365 +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. - * - * @providesModule MessageQueue - */ - -/*eslint no-bitwise: 0*/ - -'use strict'; - -let BridgeProfiling = require('BridgeProfiling'); -let ErrorUtils = require('ErrorUtils'); -let JSTimersExecution = require('JSTimersExecution'); - -let invariant = require('invariant'); -let keyMirror = require('keyMirror'); -let stringifySafe = require('stringifySafe'); - -let MODULE_IDS = 0; -let METHOD_IDS = 1; -let PARAMS = 2; -let MIN_TIME_BETWEEN_FLUSHES_MS = 5; - -let SPY_MODE = false; - -let MethodTypes = keyMirror({ - remote: null, - remoteAsync: null, -}); - -var guard = (fn) => { - try { - fn(); - } catch (error) { - ErrorUtils.reportFatalError(error); - } -}; - -class MessageQueue { - - constructor(remoteModules, localModules) { - this.RemoteModules = {}; - - this._callableModules = {}; - this._queue = [[],[],[]]; - this._moduleTable = {}; - this._methodTable = {}; - this._callbacks = []; - this._callbackID = 0; - this._lastFlush = 0; - - [ - 'invokeCallbackAndReturnFlushedQueue', - 'callFunctionReturnFlushedQueue', - 'flushedQueue', - ].forEach((fn) => this[fn] = this[fn].bind(this)); - - let modulesConfig = this._genModulesConfig(remoteModules); - this._genModules(modulesConfig); - localModules && this._genLookupTables( - this._genModulesConfig(localModules),this._moduleTable, this._methodTable - ); - - this._debugInfo = {}; - this._remoteModuleTable = {}; - this._remoteMethodTable = {}; - this._genLookupTables( - modulesConfig, this._remoteModuleTable, this._remoteMethodTable - ); - } - - /** - * Public APIs - */ - callFunctionReturnFlushedQueue(module, method, args) { - guard(() => { - this.__callFunction(module, method, args); - this.__callImmediates(); - }); - - return this.flushedQueue(); - } - - invokeCallbackAndReturnFlushedQueue(cbID, args) { - guard(() => { - this.__invokeCallback(cbID, args); - this.__callImmediates(); - }); - - return this.flushedQueue(); - } - - flushedQueue() { - this.__callImmediates(); - - let queue = this._queue; - this._queue = [[],[],[]]; - return queue[0].length ? queue : null; - } - - processModuleConfig(config, moduleID) { - const module = this._genModule(config, moduleID); - this._genLookup(config, moduleID, this._remoteModuleTable, this._remoteMethodTable) - return module; - } - - /** - * "Private" methods - */ - - __callImmediates() { - BridgeProfiling.profile('JSTimersExecution.callImmediates()'); - guard(() => JSTimersExecution.callImmediates()); - BridgeProfiling.profileEnd(); - } - - __nativeCall(module, method, params, onFail, onSucc) { - if (onFail || onSucc) { - // eventually delete old debug info - (this._callbackID > (1 << 5)) && - (this._debugInfo[this._callbackID >> 5] = null); - - this._debugInfo[this._callbackID >> 1] = [module, method]; - onFail && params.push(this._callbackID); - this._callbacks[this._callbackID++] = onFail; - onSucc && params.push(this._callbackID); - this._callbacks[this._callbackID++] = onSucc; - } - this._queue[MODULE_IDS].push(module); - this._queue[METHOD_IDS].push(method); - this._queue[PARAMS].push(params); - - var now = new Date().getTime(); - if (global.nativeFlushQueueImmediate && - now - this._lastFlush >= MIN_TIME_BETWEEN_FLUSHES_MS) { - global.nativeFlushQueueImmediate(this._queue); - this._queue = [[],[],[]]; - this._lastFlush = now; - } - if (__DEV__ && SPY_MODE && isFinite(module)) { - console.log('JS->N : ' + this._remoteModuleTable[module] + '.' + - this._remoteMethodTable[module][method] + '(' + JSON.stringify(params) + ')'); - } - } - - __callFunction(module, method, args) { - this._lastFlush = new Date().getTime(); - if (isFinite(module)) { - method = this._methodTable[module][method]; - module = this._moduleTable[module]; - } - BridgeProfiling.profile(() => `${module}.${method}(${stringifySafe(args)})`); - if (__DEV__ && SPY_MODE) { - console.log('N->JS : ' + module + '.' + method + '(' + JSON.stringify(args) + ')'); - } - var moduleMethods = this._callableModules[module]; - if (!moduleMethods) { - // TODO: Register all the remaining test modules and make this an invariant. #9317773 - // Fallback to require temporarily. A follow up diff will clean up the remaining - // modules and make this an invariant. - console.warn('Module is not registered:', module); - moduleMethods = require(module); - /* - invariant( - !!moduleMethods, - 'Module %s is not a registered callable module.', - module - ); - */ - } - moduleMethods[method].apply(moduleMethods, args); - BridgeProfiling.profileEnd(); - } - - __invokeCallback(cbID, args) { - BridgeProfiling.profile( - () => `MessageQueue.invokeCallback(${cbID}, ${stringifySafe(args)})`); - this._lastFlush = new Date().getTime(); - let callback = this._callbacks[cbID]; - if (!callback || __DEV__) { - let debug = this._debugInfo[cbID >> 1]; - let module = debug && this._remoteModuleTable[debug[0]]; - let method = debug && this._remoteMethodTable[debug[0]][debug[1]]; - invariant( - callback, - `Callback with id ${cbID}: ${module}.${method}() not found` - ); - if (callback && SPY_MODE) { - console.log('N->JS : (' + JSON.stringify(args) + ')'); - } - } - this._callbacks[cbID & ~1] = null; - this._callbacks[cbID | 1] = null; - callback.apply(null, args); - BridgeProfiling.profileEnd(); - } - - /** - * Private helper methods - */ - - /** - * Converts the old, object-based module structure to the new - * array-based structure. TODO (t8823865) Removed this - * function once Android has been updated. - */ - _genModulesConfig(modules /* array or object */) { - if (Array.isArray(modules)) { - return modules; - } else { - let moduleArray = []; - let moduleNames = Object.keys(modules); - for (var i = 0, l = moduleNames.length; i < l; i++) { - let moduleName = moduleNames[i]; - let moduleConfig = modules[moduleName]; - let module = [moduleName]; - if (moduleConfig.constants) { - module.push(moduleConfig.constants); - } - let methodsConfig = moduleConfig.methods; - if (methodsConfig) { - let methods = []; - let asyncMethods = []; - let methodNames = Object.keys(methodsConfig); - for (var j = 0, ll = methodNames.length; j < ll; j++) { - let methodName = methodNames[j]; - let methodConfig = methodsConfig[methodName]; - methods[methodConfig.methodID] = methodName; - if (methodConfig.type === MethodTypes.remoteAsync) { - asyncMethods.push(methodConfig.methodID); - } - } - if (methods.length) { - module.push(methods); - if (asyncMethods.length) { - module.push(asyncMethods); - } - } - } - moduleArray[moduleConfig.moduleID] = module; - } - return moduleArray; - } - } - - _genLookupTables(modulesConfig, moduleTable, methodTable) { - modulesConfig.forEach((config, moduleID) => { - this._genLookup(config, moduleID, moduleTable, methodTable); - }); - } - - _genLookup(config, moduleID, moduleTable, methodTable) { - if (!config) { - return; - } - - let moduleName, methods; - if (moduleHasConstants(config)) { - [moduleName, , methods] = config; - } else { - [moduleName, methods] = config; - } - - moduleTable[moduleID] = moduleName; - methodTable[moduleID] = Object.assign({}, methods); - } - - _genModules(remoteModules) { - remoteModules.forEach((config, moduleID) => { - this._genModule(config, moduleID); - }); - } - - _genModule(config, moduleID) { - if (!config) { - return; - } - - let moduleName, constants, methods, asyncMethods; - if (moduleHasConstants(config)) { - [moduleName, constants, methods, asyncMethods] = config; - } else { - [moduleName, methods, asyncMethods] = config; - } - - let module = {}; - methods && methods.forEach((methodName, methodID) => { - const methodType = - asyncMethods && arrayContains(asyncMethods, methodID) ? - MethodTypes.remoteAsync : MethodTypes.remote; - module[methodName] = this._genMethod(moduleID, methodID, methodType); - }); - Object.assign(module, constants); - - if (!constants && !methods && !asyncMethods) { - module.moduleID = moduleID; - } - - this.RemoteModules[moduleName] = module; - return module; - } - - _genMethod(module, method, type) { - let fn = null; - let self = this; - if (type === MethodTypes.remoteAsync) { - fn = function(...args) { - return new Promise((resolve, reject) => { - self.__nativeCall(module, method, args, resolve, (errorData) => { - var error = createErrorFromErrorData(errorData); - reject(error); - }); - }); - }; - } else { - fn = function(...args) { - let lastArg = args.length > 0 ? args[args.length - 1] : null; - let secondLastArg = args.length > 1 ? args[args.length - 2] : null; - let hasSuccCB = typeof lastArg === 'function'; - let hasErrorCB = typeof secondLastArg === 'function'; - hasErrorCB && invariant( - hasSuccCB, - 'Cannot have a non-function arg after a function arg.' - ); - let numCBs = hasSuccCB + hasErrorCB; - let onSucc = hasSuccCB ? lastArg : null; - let onFail = hasErrorCB ? secondLastArg : null; - args = args.slice(0, args.length - numCBs); - return self.__nativeCall(module, method, args, onFail, onSucc); - }; - } - fn.type = type; - return fn; - } - - registerCallableModule(name, methods) { - this._callableModules[name] = methods; - } - -} - -function moduleHasConstants(moduleArray: Array>): boolean { - return !Array.isArray(moduleArray[1]); -} - -function arrayContains(array: Array, value: T): boolean { - return array.indexOf(value) !== -1; -} - -function createErrorFromErrorData(errorData: {message: string}): Error { - var { - message, - ...extraErrorInfo, - } = errorData; - var error = new Error(message); - error.framesToPop = 1; - return Object.assign(error, extraErrorInfo); -} - -module.exports = MessageQueue; diff --git a/examples/node_modules/react-native/Libraries/Utilities/PixelRatio.js b/examples/node_modules/react-native/Libraries/Utilities/PixelRatio.js deleted file mode 100644 index 940890cc..00000000 --- a/examples/node_modules/react-native/Libraries/Utilities/PixelRatio.js +++ /dev/null @@ -1,98 +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. - * - * @providesModule PixelRatio - * @flow - */ -'use strict'; - -var Dimensions = require('Dimensions'); - -/** - * PixelRatio class gives access to the device pixel density. - * - * There are a few use cases for using PixelRatio: - * - * ### Displaying a line that's as thin as the device permits - * - * A width of 1 is actually pretty thick on devices with high pixel density - * (such as iPhone 4+ and many Android devices), we can make one that's - * thinner using a width of `1 / PixelRatio.get()`. - * It's a technique that works on all the devices independent of their - * pixel density. - * - * ``` - * style={{ borderWidth: 1 / PixelRatio.get() }} - * ``` - * - * ### Fetching a correctly sized image - * - * You should get a higher resolution image if you are on a high pixel density - * device. A good rule of thumb is to multiply the size of the image you display - * by the pixel ratio. - * - * ``` - * var image = getImage({ - * width: PixelRatio.getPixelSizeForLayoutSize(200), - * height: PixelRatio.getPixelSizeForLayoutSize(100), - * }); - * - * ``` - */ -class PixelRatio { - /** - * Returns the device pixel density. Some examples: - * - * - PixelRatio.get() === 1 - * - mdpi Android devices (160 dpi) - * - PixelRatio.get() === 1.5 - * - hdpi Android devices (240 dpi) - * - PixelRatio.get() === 2 - * - iPhone 4, 4S - * - iPhone 5, 5c, 5s - * - iPhone 6 - * - xhdpi Android devices (320 dpi) - * - PixelRatio.get() === 3 - * - iPhone 6 plus - * - xxhdpi Android devices (480 dpi) - * - PixelRatio.get() === 3.5 - * - Nexus 6 - */ - static get(): number { - return Dimensions.get('window').scale; - } - - /** - * Returns the scaling factor for font sizes. This is the ratio that is used to calculate the - * absolute font size, so any elements that heavily depend on that should use this to do - * calculations. - * - * If a font scale is not set, this returns the device pixel ratio. - * - * Currently this is only implemented on Android and reflects the user preference set in - * Settings > Display > Font size, on iOS it will always return the default pixel ratio. - * @platform android - */ - static getFontScale(): number { - return Dimensions.get('window').fontScale || PixelRatio.get(); - } - - /** - * Converts a layout size (dp) to pixel size (px). - * - * Guaranteed to return an integer number. - */ - static getPixelSizeForLayoutSize(layoutSize: number): number { - return Math.round(layoutSize * PixelRatio.get()); - } - - // No-op for iOS, but used on the web. Should not be documented. - static startDetecting() {} -} - -module.exports = PixelRatio; diff --git a/examples/node_modules/react-native/Libraries/Utilities/Platform.ios.js b/examples/node_modules/react-native/Libraries/Utilities/Platform.ios.js deleted file mode 100644 index d02e6fde..00000000 --- a/examples/node_modules/react-native/Libraries/Utilities/Platform.ios.js +++ /dev/null @@ -1,19 +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. - * - * @providesModule Platform - * @flow - */ - -'use strict'; - -var Platform = { - OS: 'ios', -}; - -module.exports = Platform; diff --git a/examples/node_modules/react-native/Libraries/Utilities/RCTLog.js b/examples/node_modules/react-native/Libraries/Utilities/RCTLog.js deleted file mode 100644 index 65abc588..00000000 --- a/examples/node_modules/react-native/Libraries/Utilities/RCTLog.js +++ /dev/null @@ -1,49 +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. - * - * @providesModule RCTLog - * @flow - */ -'use strict'; - -var BatchedBridge = require('BatchedBridge'); - -var invariant = require('invariant'); - -var levelsMap = { - log: 'log', - info: 'info', - warn: 'warn', - error: 'error', - fatal: 'error', -}; - -class RCTLog { - // level one of log, info, warn, error, mustfix - static logIfNoNativeHook() { - var args = Array.prototype.slice.call(arguments); - var level = args.shift(); - var logFn = levelsMap[level]; - invariant( - logFn, - 'Level "' + level + '" not one of ' + Object.keys(levelsMap) - ); - if (typeof global.nativeLoggingHook === 'undefined') { - // We already printed in xcode, so only log here if using a js debugger - console[logFn].apply(console, args); - } - return true; - } -} - -BatchedBridge.registerCallableModule( - 'RCTLog', - RCTLog -); - -module.exports = RCTLog; diff --git a/examples/node_modules/react-native/Libraries/Utilities/RCTRenderingPerf.js b/examples/node_modules/react-native/Libraries/Utilities/RCTRenderingPerf.js deleted file mode 100644 index 126c8a03..00000000 --- a/examples/node_modules/react-native/Libraries/Utilities/RCTRenderingPerf.js +++ /dev/null @@ -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. - * - * @providesModule RCTRenderingPerf - * @flow - */ -'use strict'; - -var ReactDefaultPerf = require('ReactDefaultPerf'); - -var invariant = require('invariant'); - -type perfModule = { - start: () => void; - stop: () => void; -} - -var perfModules = []; -var enabled = false; - -var RCTRenderingPerf = { - // Once perf is enabled, it stays enabled - toggle: function() { - console.log('Render perfomance measurements enabled'); - enabled = true; - }, - - start: function() { - if (!enabled) { - return; - } - - ReactDefaultPerf.start(); - perfModules.forEach((module) => module.start()); - }, - - stop: function() { - if (!enabled) { - return; - } - - ReactDefaultPerf.stop(); - ReactDefaultPerf.printInclusive(); - ReactDefaultPerf.printWasted(); - - var totalRender = 0; - var totalTime = 0; - var measurements = ReactDefaultPerf.getLastMeasurements(); - for (var ii = 0; ii < measurements.length; ii++) { - var render = measurements[ii].render; - for (var nodeName in render) { - totalRender += render[nodeName]; - } - totalTime += measurements[ii].totalTime; - } - console.log('Total time spent in render(): ' + totalRender + 'ms'); - - perfModules.forEach((module) => module.stop()); - }, - - register: function(module: perfModule) { - invariant( - typeof module.start === 'function', - 'Perf module should have start() function' - ); - invariant( - typeof module.stop === 'function', - 'Perf module should have stop() function' - ); - perfModules.push(module); - } -}; - -module.exports = RCTRenderingPerf; diff --git a/examples/node_modules/react-native/Libraries/Utilities/__mocks__/ErrorUtils.js b/examples/node_modules/react-native/Libraries/Utilities/__mocks__/ErrorUtils.js deleted file mode 100644 index 59fbbafb..00000000 --- a/examples/node_modules/react-native/Libraries/Utilities/__mocks__/ErrorUtils.js +++ /dev/null @@ -1,23 +0,0 @@ -// 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 -// don't use this mock. -'use strict'; - -function execute(fun, context, args) { - return fun.apply(context, args); -} - -function reportError(error) { - throw error; -} - -var ErrorUtils = { - apply: jest.genMockFunction().mockImplementation(execute), - applyWithGuard: jest.genMockFunction().mockImplementation(execute), - inGuard: jest.genMockFunction().mockReturnValue(true), - reportError: jest.genMockFunction().mockImplementation(reportError), - setGlobalHandler: jest.genMockFunction(), -}; - -module.exports = ErrorUtils; diff --git a/examples/node_modules/react-native/Libraries/Utilities/__mocks__/PixelRatio.js b/examples/node_modules/react-native/Libraries/Utilities/__mocks__/PixelRatio.js deleted file mode 100644 index bcf04d7f..00000000 --- a/examples/node_modules/react-native/Libraries/Utilities/__mocks__/PixelRatio.js +++ /dev/null @@ -1,20 +0,0 @@ -/** - * Copyright 2004-present Facebook. All Rights Reserved. - */ -'use strict'; - -var PixelRatio = { - startDetecting: function () { - // noop for our implementation - }, - - get: function() { - return 2; - }, - - getPixelSizeForLayoutSize: function (layoutSize) { - return Math.round(layoutSize * PixelRatio.get()); - } -}; - -module.exports = PixelRatio; diff --git a/examples/node_modules/react-native/Libraries/Utilities/buildStyleInterpolator.js b/examples/node_modules/react-native/Libraries/Utilities/buildStyleInterpolator.js deleted file mode 100644 index 1ff93d10..00000000 --- a/examples/node_modules/react-native/Libraries/Utilities/buildStyleInterpolator.js +++ /dev/null @@ -1,567 +0,0 @@ -/** - * Copyright 2004-present Facebook. All Rights Reserved. - * - * @providesModule buildStyleInterpolator - */ - -/** - * Cannot "use strict" because we must use eval in this file. - */ -/* eslint-disable global-strict */ - -var keyOf = require('keyOf'); - -var X_DIM = keyOf({x: null}); -var Y_DIM = keyOf({y: null}); -var Z_DIM = keyOf({z: null}); -var W_DIM = keyOf({w: null}); - -var TRANSFORM_ROTATE_NAME = keyOf({transformRotateRadians: null}); - -var ShouldAllocateReusableOperationVars = { - transformRotateRadians: true, - transformScale: true, - transformTranslate: true, -}; - -var InitialOperationField = { - transformRotateRadians: [0, 0, 0, 1], - transformTranslate: [0, 0, 0], - transformScale: [1, 1, 1], -}; - - -/** - * Creates a highly specialized animation function that may be evaluated every - * frame. For example: - * - * var ToTheLeft = { - * opacity: { - * from: 1, - * to: 0.7, - * min: 0, - * max: 1, - * type: 'linear', - * extrapolate: false, - * round: 100, - * }, - * left: { - * from: 0, - * to: -SCREEN_WIDTH * 0.3, - * min: 0, - * max: 1, - * type: 'linear', - * extrapolate: true, - * round: PixelRatio.get(), - * }, - * }; - * - * var toTheLeft = buildStyleInterpolator(ToTheLeft); - * - * Would returns a specialized function of the form: - * - * function(result, value) { - * var didChange = false; - * var nextScalarVal; - * var ratio; - * ratio = (value - 0) / 1; - * ratio = ratio > 1 ? 1 : (ratio < 0 ? 0 : ratio); - * nextScalarVal = Math.round(100 * (1 * (1 - ratio) + 0.7 * ratio)) / 100; - * if (!didChange) { - * var prevVal = result.opacity; - * result.opacity = nextScalarVal; - * didChange = didChange || (nextScalarVal !== prevVal); - * } else { - * result.opacity = nextScalarVal; - * } - * ratio = (value - 0) / 1; - * nextScalarVal = Math.round(2 * (0 * (1 - ratio) + -30 * ratio)) / 2; - * if (!didChange) { - * var prevVal = result.left; - * result.left = nextScalarVal; - * didChange = didChange || (nextScalarVal !== prevVal); - * } else { - * result.left = nextScalarVal; - * } - * return didChange; - * } - */ - -var ARGUMENT_NAMES_RE = /([^\s,]+)/g; -/** - * This is obviously a huge hack. Proper tooling would allow actual inlining. - * This only works in a few limited cases (where there is no function return - * value, and the function operates mutatively on parameters). - * - * Example: - * - * - * var inlineMe(a, b) { - * a = b + b; - * }; - * - * inline(inlineMe, ['hi', 'bye']); // "hi = bye + bye;" - * - * @param {function} func Any simple function whos arguments can be replaced via a regex. - * @param {array} replaceWithArgs Corresponding names of variables - * within an environment, to replace `func` args with. - * @return {string} Resulting function body string. - */ -var inline = function(func, replaceWithArgs) { - var fnStr = func.toString(); - var parameterNames = fnStr.slice(fnStr.indexOf('(') + 1, fnStr.indexOf(')')) - .match(ARGUMENT_NAMES_RE) || - []; - var replaceRegexStr = parameterNames.map(function(paramName) { - return '\\b' + paramName + '\\b'; - }).join('|'); - var replaceRegex = new RegExp(replaceRegexStr, 'g'); - var fnBody = fnStr.substring(fnStr.indexOf('{') + 1, fnStr.lastIndexOf('}')); - var newFnBody = fnBody.replace(replaceRegex, function(parameterName) { - var indexInParameterNames = parameterNames.indexOf(parameterName); - var replacementName = replaceWithArgs[indexInParameterNames]; - return replacementName; - }); - return newFnBody.split('\n'); -}; - -/** - * Simply a convenient way to inline functions using the function's toString - * method. - */ -var MatrixOps = { - unroll: function(matVar, m0, m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, m11, m12, m13, m14, m15) { - m0 = matVar[0]; - m1 = matVar[1]; - m2 = matVar[2]; - m3 = matVar[3]; - m4 = matVar[4]; - m5 = matVar[5]; - m6 = matVar[6]; - m7 = matVar[7]; - m8 = matVar[8]; - m9 = matVar[9]; - m10 = matVar[10]; - m11 = matVar[11]; - m12 = matVar[12]; - m13 = matVar[13]; - m14 = matVar[14]; - m15 = matVar[15]; - }, - - matrixDiffers: function(retVar, matVar, m0, m1, m2, m3, m4, m5, m6, m7, m8, m9, m10, m11, m12, m13, m14, m15) { - retVar = retVar || - m0 !== matVar[0] || - m1 !== matVar[1] || - m2 !== matVar[2] || - m3 !== matVar[3] || - m4 !== matVar[4] || - m5 !== matVar[5] || - m6 !== matVar[6] || - m7 !== matVar[7] || - m8 !== matVar[8] || - m9 !== matVar[9] || - m10 !== matVar[10] || - m11 !== matVar[11] || - m12 !== matVar[12] || - m13 !== matVar[13] || - m14 !== matVar[14] || - m15 !== matVar[15]; - }, - - transformScale: function(matVar, opVar) { - // Scaling matVar by opVar - var x = opVar[0]; - var y = opVar[1]; - var z = opVar[2]; - matVar[0] = matVar[0] * x; - matVar[1] = matVar[1] * x; - matVar[2] = matVar[2] * x; - matVar[3] = matVar[3] * x; - matVar[4] = matVar[4] * y; - matVar[5] = matVar[5] * y; - matVar[6] = matVar[6] * y; - matVar[7] = matVar[7] * y; - matVar[8] = matVar[8] * z; - matVar[9] = matVar[9] * z; - matVar[10] = matVar[10] * z; - matVar[11] = matVar[11] * z; - matVar[12] = matVar[12]; - matVar[13] = matVar[13]; - matVar[14] = matVar[14]; - matVar[15] = matVar[15]; - }, - - /** - * All of these matrix transforms are not general purpose utilities, and are - * only suitable for being inlined for the use of building up interpolators. - */ - transformTranslate: function(matVar, opVar) { - // Translating matVar by opVar - var x = opVar[0]; - var y = opVar[1]; - var z = opVar[2]; - matVar[12] = matVar[0] * x + matVar[4] * y + matVar[8] * z + matVar[12]; - matVar[13] = matVar[1] * x + matVar[5] * y + matVar[9] * z + matVar[13]; - matVar[14] = matVar[2] * x + matVar[6] * y + matVar[10] * z + matVar[14]; - matVar[15] = matVar[3] * x + matVar[7] * y + matVar[11] * z + matVar[15]; - }, - - /** - * @param {array} matVar Both the input, and the output matrix. - * @param {quaternion specification} q Four element array describing rotation. - */ - transformRotateRadians: function(matVar, q) { - // Rotating matVar by q - var xQuat = q[0], yQuat = q[1], zQuat = q[2], wQuat = q[3]; - var x2Quat = xQuat + xQuat; - var y2Quat = yQuat + yQuat; - var z2Quat = zQuat + zQuat; - var xxQuat = xQuat * x2Quat; - var xyQuat = xQuat * y2Quat; - var xzQuat = xQuat * z2Quat; - var yyQuat = yQuat * y2Quat; - var yzQuat = yQuat * z2Quat; - var zzQuat = zQuat * z2Quat; - var wxQuat = wQuat * x2Quat; - var wyQuat = wQuat * y2Quat; - var wzQuat = wQuat * z2Quat; - // Step 1: Inlines the construction of a quaternion matrix (`quatMat`) - var quatMat0 = 1 - (yyQuat + zzQuat); - var quatMat1 = xyQuat + wzQuat; - var quatMat2 = xzQuat - wyQuat; - var quatMat4 = xyQuat - wzQuat; - var quatMat5 = 1 - (xxQuat + zzQuat); - var quatMat6 = yzQuat + wxQuat; - var quatMat8 = xzQuat + wyQuat; - var quatMat9 = yzQuat - wxQuat; - var quatMat10 = 1 - (xxQuat + yyQuat); - // quatMat3/7/11/12/13/14 = 0, quatMat15 = 1 - - // Step 2: Inlines multiplication, takes advantage of constant quatMat cells - var a00 = matVar[0]; - var a01 = matVar[1]; - var a02 = matVar[2]; - var a03 = matVar[3]; - var a10 = matVar[4]; - var a11 = matVar[5]; - var a12 = matVar[6]; - var a13 = matVar[7]; - var a20 = matVar[8]; - var a21 = matVar[9]; - var a22 = matVar[10]; - var a23 = matVar[11]; - - var b0 = quatMat0, b1 = quatMat1, b2 = quatMat2; - matVar[0] = b0 * a00 + b1 * a10 + b2 * a20; - matVar[1] = b0 * a01 + b1 * a11 + b2 * a21; - matVar[2] = b0 * a02 + b1 * a12 + b2 * a22; - matVar[3] = b0 * a03 + b1 * a13 + b2 * a23; - b0 = quatMat4; b1 = quatMat5; b2 = quatMat6; - matVar[4] = b0 * a00 + b1 * a10 + b2 * a20; - matVar[5] = b0 * a01 + b1 * a11 + b2 * a21; - matVar[6] = b0 * a02 + b1 * a12 + b2 * a22; - matVar[7] = b0 * a03 + b1 * a13 + b2 * a23; - b0 = quatMat8; b1 = quatMat9; b2 = quatMat10; - matVar[8] = b0 * a00 + b1 * a10 + b2 * a20; - matVar[9] = b0 * a01 + b1 * a11 + b2 * a21; - matVar[10] = b0 * a02 + b1 * a12 + b2 * a22; - matVar[11] = b0 * a03 + b1 * a13 + b2 * a23; - } -}; - -// Optimized version of general operation applications that can be used when -// the target matrix is known to be the identity matrix. -var MatrixOpsInitial = { - transformScale: function(matVar, opVar) { - // Scaling matVar known to be identity by opVar - matVar[0] = opVar[0]; - matVar[1] = 0; - matVar[2] = 0; - matVar[3] = 0; - matVar[4] = 0; - matVar[5] = opVar[1]; - matVar[6] = 0; - matVar[7] = 0; - matVar[8] = 0; - matVar[9] = 0; - matVar[10] = opVar[2]; - matVar[11] = 0; - matVar[12] = 0; - matVar[13] = 0; - matVar[14] = 0; - matVar[15] = 1; - }, - - transformTranslate: function(matVar, opVar) { - // Translating matVar known to be identity by opVar'; - matVar[0] = 1; - matVar[1] = 0; - matVar[2] = 0; - matVar[3] = 0; - matVar[4] = 0; - matVar[5] = 1; - matVar[6] = 0; - matVar[7] = 0; - matVar[8] = 0; - matVar[9] = 0; - matVar[10] = 1; - matVar[11] = 0; - matVar[12] = opVar[0]; - matVar[13] = opVar[1]; - matVar[14] = opVar[2]; - matVar[15] = 1; - }, - - /** - * @param {array} matVar Both the input, and the output matrix - assumed to be - * identity. - * @param {quaternion specification} q Four element array describing rotation. - */ - transformRotateRadians: function(matVar, q) { - - // Rotating matVar which is known to be identity by q - var xQuat = q[0], yQuat = q[1], zQuat = q[2], wQuat = q[3]; - var x2Quat = xQuat + xQuat; - var y2Quat = yQuat + yQuat; - var z2Quat = zQuat + zQuat; - var xxQuat = xQuat * x2Quat; - var xyQuat = xQuat * y2Quat; - var xzQuat = xQuat * z2Quat; - var yyQuat = yQuat * y2Quat; - var yzQuat = yQuat * z2Quat; - var zzQuat = zQuat * z2Quat; - var wxQuat = wQuat * x2Quat; - var wyQuat = wQuat * y2Quat; - var wzQuat = wQuat * z2Quat; - // Step 1: Inlines the construction of a quaternion matrix (`quatMat`) - var quatMat0 = 1 - (yyQuat + zzQuat); - var quatMat1 = xyQuat + wzQuat; - var quatMat2 = xzQuat - wyQuat; - var quatMat4 = xyQuat - wzQuat; - var quatMat5 = 1 - (xxQuat + zzQuat); - var quatMat6 = yzQuat + wxQuat; - var quatMat8 = xzQuat + wyQuat; - var quatMat9 = yzQuat - wxQuat; - var quatMat10 = 1 - (xxQuat + yyQuat); - // quatMat3/7/11/12/13/14 = 0, quatMat15 = 1 - - // Step 2: Inlines the multiplication with identity matrix. - var b0 = quatMat0, b1 = quatMat1, b2 = quatMat2; - matVar[0] = b0; - matVar[1] = b1; - matVar[2] = b2; - matVar[3] = 0; - b0 = quatMat4; b1 = quatMat5; b2 = quatMat6; - matVar[4] = b0; - matVar[5] = b1; - matVar[6] = b2; - matVar[7] = 0; - b0 = quatMat8; b1 = quatMat9; b2 = quatMat10; - matVar[8] = b0; - matVar[9] = b1; - matVar[10] = b2; - matVar[11] = 0; - matVar[12] = 0; - matVar[13] = 0; - matVar[14] = 0; - matVar[15] = 1; - } -}; - - -var setNextValAndDetectChange = function(name, tmpVarName) { - return ( - ' if (!didChange) {\n' + - ' var prevVal = result.' + name + ';\n' + - ' result.' + name + ' = ' + tmpVarName + ';\n' + - ' didChange = didChange || (' + tmpVarName + ' !== prevVal);\n' + - ' } else {\n' + - ' result.' + name + ' = ' + tmpVarName + ';\n' + - ' }\n' - ); -}; - -var computeNextValLinear = function(anim, from, to, tmpVarName) { - var hasRoundRatio = 'round' in anim; - var roundRatio = anim.round; - var fn = ' ratio = (value - ' + anim.min + ') / ' + (anim.max - anim.min) + ';\n'; - if (!anim.extrapolate) { - fn += ' ratio = ratio > 1 ? 1 : (ratio < 0 ? 0 : ratio);\n'; - } - - var roundOpen = (hasRoundRatio ? 'Math.round(' + roundRatio + ' * ' : '' ); - var roundClose = (hasRoundRatio ? ') / ' + roundRatio : '' ); - fn += - ' ' + tmpVarName + ' = ' + - roundOpen + - '(' + from + ' * (1 - ratio) + ' + to + ' * ratio)' + - roundClose + ';\n'; - return fn; -}; - -var computeNextValLinearScalar = function(anim) { - return computeNextValLinear(anim, anim.from, anim.to, 'nextScalarVal'); -}; - -var computeNextValConstant = function(anim) { - var constantExpression = JSON.stringify(anim.value); - return ' nextScalarVal = ' + constantExpression + ';\n'; -}; - -var computeNextValStep = function(anim) { - return ( - ' nextScalarVal = value >= ' + - (anim.threshold + ' ? ' + anim.to + ' : ' + anim.from) + ';\n' - ); -}; - -var computeNextValIdentity = function(anim) { - return ' nextScalarVal = value;\n'; -}; - -var operationVar = function(name) { - return name + 'ReuseOp'; -}; - -var createReusableOperationVars = function(anims) { - var ret = ''; - for (var name in anims) { - if (ShouldAllocateReusableOperationVars[name]) { - ret += 'var ' + operationVar(name) + ' = [];\n'; - } - } - return ret; -}; - -var newlines = function(statements) { - return '\n' + statements.join('\n') + '\n'; -}; - -/** - * @param {Animation} anim Configuration entry. - * @param {key} dimension Key to examine in `from`/`to`. - * @param {number} index Field in operationVar to set. - * @return {string} Code that sets the operation variable's field. - */ -var computeNextMatrixOperationField = function(anim, name, dimension, index) { - var fieldAccess = operationVar(name) + '[' + index + ']'; - if (anim.from[dimension] !== undefined && anim.to[dimension] !== undefined) { - return ' ' + anim.from[dimension] !== anim.to[dimension] ? - computeNextValLinear(anim, anim.from[dimension], anim.to[dimension], fieldAccess) : - fieldAccess + ' = ' + anim.from[dimension] + ';'; - } else { - return ' ' + fieldAccess + ' = ' + InitialOperationField[name][index] + ';'; - } -}; - -var unrolledVars = []; -for (var varIndex = 0; varIndex < 16; varIndex++) { - unrolledVars.push('m' + varIndex); -} -var setNextMatrixAndDetectChange = function(orderedMatrixOperations) { - var fn = [ - ' var transformMatrix = result.transformMatrix !== undefined ? ' + - 'result.transformMatrix : (result.transformMatrix = []);' - ]; - fn.push.apply( - fn, - inline(MatrixOps.unroll, ['transformMatrix'].concat(unrolledVars)) - ); - for (var i = 0; i < orderedMatrixOperations.length; i++) { - var opName = orderedMatrixOperations[i]; - if (i === 0) { - fn.push.apply( - fn, - inline(MatrixOpsInitial[opName], ['transformMatrix', operationVar(opName)]) - ); - } else { - fn.push.apply( - fn, - inline(MatrixOps[opName], ['transformMatrix', operationVar(opName)]) - ); - } - } - fn.push.apply( - fn, - inline(MatrixOps.matrixDiffers, ['didChange', 'transformMatrix'].concat(unrolledVars)) - ); - return fn; -}; - -var InterpolateMatrix = { - transformTranslate: true, - transformRotateRadians: true, - transformScale: true, -}; - -var createFunctionString = function(anims) { - // We must track the order they appear in so transforms are applied in the - // correct order. - var orderedMatrixOperations = []; - - // Wrapping function allows the final function to contain state (for - // caching). - var fn = 'return (function() {\n'; - fn += createReusableOperationVars(anims); - fn += 'return function(result, value) {\n'; - fn += ' var didChange = false;\n'; - fn += ' var nextScalarVal;\n'; - fn += ' var ratio;\n'; - - for (var name in anims) { - var anim = anims[name]; - if (anim.type === 'linear') { - if (InterpolateMatrix[name]) { - orderedMatrixOperations.push(name); - var setOperations = [ - computeNextMatrixOperationField(anim, name, X_DIM, 0), - computeNextMatrixOperationField(anim, name, Y_DIM, 1), - computeNextMatrixOperationField(anim, name, Z_DIM, 2) - ]; - if (name === TRANSFORM_ROTATE_NAME) { - setOperations.push(computeNextMatrixOperationField(anim, name, W_DIM, 3)); - } - fn += newlines(setOperations); - } else { - fn += computeNextValLinearScalar(anim, 'nextScalarVal'); - fn += setNextValAndDetectChange(name, 'nextScalarVal'); - } - } else if (anim.type === 'constant') { - fn += computeNextValConstant(anim); - fn += setNextValAndDetectChange(name, 'nextScalarVal'); - } else if (anim.type === 'step') { - fn += computeNextValStep(anim); - fn += setNextValAndDetectChange(name, 'nextScalarVal'); - } else if (anim.type === 'identity') { - fn += computeNextValIdentity(anim); - fn += setNextValAndDetectChange(name, 'nextScalarVal'); - } - } - if (orderedMatrixOperations.length) { - fn += newlines(setNextMatrixAndDetectChange(orderedMatrixOperations)); - } - fn += ' return didChange;\n'; - fn += '};\n'; - fn += '})()'; - return fn; -}; - -/** - * @param {object} anims Animation configuration by style property name. - * @return {function} Function accepting style object, that mutates that style - * object and returns a boolean describing if any update was actually applied. - */ -var buildStyleInterpolator = function(anims) { - // Defer compiling this method until we really need it. - var interpolator = null; - function lazyStyleInterpolator(result, value) { - if (interpolator === null) { - interpolator = Function(createFunctionString(anims))(); - } - return interpolator(result, value); - } - return lazyStyleInterpolator; -}; - -module.exports = buildStyleInterpolator; diff --git a/examples/node_modules/react-native/Libraries/Utilities/createStrictShapeTypeChecker.js b/examples/node_modules/react-native/Libraries/Utilities/createStrictShapeTypeChecker.js deleted file mode 100644 index 883da245..00000000 --- a/examples/node_modules/react-native/Libraries/Utilities/createStrictShapeTypeChecker.js +++ /dev/null @@ -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. - * - * @providesModule createStrictShapeTypeChecker - * @flow - */ -'use strict'; - -var ReactPropTypeLocationNames = require('ReactPropTypeLocationNames'); - -var invariant = require('invariant'); -var merge = require('merge'); - -function createStrictShapeTypeChecker( - shapeTypes: {[key: string]: ReactPropsCheckType} -): ReactPropsChainableTypeChecker { - function checkType(isRequired, props, propName, componentName, location?) { - if (!props[propName]) { - if (isRequired) { - invariant( - false, - `Required object \`${propName}\` was not specified in ` + - `\`${componentName}\`.` - ); - } - return; - } - var propValue = props[propName]; - var propType = typeof propValue; - var locationName = - location && ReactPropTypeLocationNames[location] || '(unknown)'; - if (propType !== 'object') { - invariant( - false, - `Invalid ${locationName} \`${propName}\` of type \`${propType}\` ` + - `supplied to \`${componentName}\`, expected \`object\`.` - ); - } - // We need to check all keys in case some are required but missing from - // props. - var allKeys = merge(props[propName], shapeTypes); - for (var key in allKeys) { - var checker = shapeTypes[key]; - if (!checker) { - invariant( - false, - `Invalid props.${propName} key \`${key}\` supplied to \`${componentName}\`.` + - `\nBad object: ` + JSON.stringify(props[propName], null, ' ') + - `\nValid keys: ` + JSON.stringify(Object.keys(shapeTypes), null, ' ') - ); - } - var error = checker(propValue, key, componentName, location); - if (error) { - invariant( - false, - error.message + - `\nBad object: ` + JSON.stringify(props[propName], null, ' ') - ); - } - } - } - function chainedCheckType( - props: {[key: string]: any}, - propName: string, - componentName: string, - location?: string - ): ?Error { - return checkType(false, props, propName, componentName, location); - } - chainedCheckType.isRequired = checkType.bind(null, true); - return chainedCheckType; -} - -module.exports = createStrictShapeTypeChecker; diff --git a/examples/node_modules/react-native/Libraries/Utilities/cssVar.js b/examples/node_modules/react-native/Libraries/Utilities/cssVar.js deleted file mode 100644 index 0ab64e7f..00000000 --- a/examples/node_modules/react-native/Libraries/Utilities/cssVar.js +++ /dev/null @@ -1,18 +0,0 @@ -/** - * Copyright 2004-present Facebook. All Rights Reserved. - * - * @providesModule cssVar - * @typechecks - */ -'use strict'; - -var invariant = require('invariant'); -var CSSVarConfig = require('CSSVarConfig'); - -var cssVar = function(/*string*/ key) /*string*/ { - invariant(CSSVarConfig[key], 'invalid css variable ' + key); - - return CSSVarConfig[key]; -}; - -module.exports = cssVar; diff --git a/examples/node_modules/react-native/Libraries/Utilities/deepFreezeAndThrowOnMutationInDev.js b/examples/node_modules/react-native/Libraries/Utilities/deepFreezeAndThrowOnMutationInDev.js deleted file mode 100644 index 9263116e..00000000 --- a/examples/node_modules/react-native/Libraries/Utilities/deepFreezeAndThrowOnMutationInDev.js +++ /dev/null @@ -1,65 +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. - * - * @providesModule deepFreezeAndThrowOnMutationInDev - * @flow - */ - -'use strict'; - -/** - * If your application is accepting different values for the same field over - * time and is doing a diff on them, you can either (1) create a copy or - * (2) ensure that those values are not mutated behind two passes. - * This function helps you with (2) by freezing the object and throwing if - * the user subsequently modifies the value. - * - * There are two caveats with this function: - * - If the call site is not in strict mode, it will only throw when - * mutating existing fields, adding a new one - * will unfortunately fail silently :( - * - If the object is already frozen or sealed, it will not continue the - * deep traversal and will leave leaf nodes unfrozen. - * - * Freezing the object and adding the throw mechanism is expensive and will - * only be used in DEV. - */ -function deepFreezeAndThrowOnMutationInDev(object: Object) { - if (__DEV__) { - if (typeof object !== 'object' || - object === null || - Object.isFrozen(object) || - Object.isSealed(object)) { - return; - } - - for (var key in object) { - if (object.hasOwnProperty(key)) { - object.__defineGetter__(key, identity.bind(null, object[key])); - object.__defineSetter__(key, throwOnImmutableMutation.bind(null, key)); - deepFreezeAndThrowOnMutationInDev(object[key]); - } - } - Object.freeze(object); - Object.seal(object); - } -} - -function throwOnImmutableMutation(key, value) { - throw Error( - 'You attempted to set the key `' + key + '` with the value `' + - JSON.stringify(value) + '` on an object that is meant to be immutable ' + - 'and has been frozen.' - ); -} - -function identity(value) { - return value; -} - -module.exports = deepFreezeAndThrowOnMutationInDev; diff --git a/examples/node_modules/react-native/Libraries/Utilities/differ/__tests__/deepDiffer-test.js b/examples/node_modules/react-native/Libraries/Utilities/differ/__tests__/deepDiffer-test.js deleted file mode 100644 index 745b83ab..00000000 --- a/examples/node_modules/react-native/Libraries/Utilities/differ/__tests__/deepDiffer-test.js +++ /dev/null @@ -1,102 +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. - */ -'use strict'; - -jest.dontMock('deepDiffer'); -var deepDiffer = require('deepDiffer'); - -describe('deepDiffer', function() { - it('should diff primitives of the same type', () => { - expect(deepDiffer(1, 2)).toBe(true); - expect(deepDiffer(42, 42)).toBe(false); - expect(deepDiffer('foo', 'bar')).toBe(true); - expect(deepDiffer('foo', 'foo')).toBe(false); - expect(deepDiffer(true, false)).toBe(true); - expect(deepDiffer(false, true)).toBe(true); - expect(deepDiffer(true, true)).toBe(false); - expect(deepDiffer(false, false)).toBe(false); - expect(deepDiffer(null, null)).toBe(false); - expect(deepDiffer(undefined, undefined)).toBe(false); - }); - it('should diff primitives of different types', () => { - expect(deepDiffer(1, '1')).toBe(true); - expect(deepDiffer(true, 'true')).toBe(true); - expect(deepDiffer(true, 1)).toBe(true); - expect(deepDiffer(false, 0)).toBe(true); - expect(deepDiffer(null, undefined)).toBe(true); - expect(deepDiffer(null, 0)).toBe(true); - expect(deepDiffer(null, false)).toBe(true); - expect(deepDiffer(null, '')).toBe(true); - expect(deepDiffer(undefined, 0)).toBe(true); - expect(deepDiffer(undefined, false)).toBe(true); - expect(deepDiffer(undefined, '')).toBe(true); - }); - it('should diff Objects', () => { - expect(deepDiffer({}, {})).toBe(false); - expect(deepDiffer({}, null)).toBe(true); - expect(deepDiffer(null, {})).toBe(true); - expect(deepDiffer({a: 1}, {a: 1})).toBe(false); - expect(deepDiffer({a: 1}, {a: 2})).toBe(true); - expect(deepDiffer({a: 1}, {a: 1, b: null})).toBe(true); - expect(deepDiffer({a: 1}, {a: 1, b: 1})).toBe(true); - expect(deepDiffer({a: 1, b: 1}, {a: 1})).toBe(true); - expect(deepDiffer({a: {A: 1}, b: 1}, {a: {A: 1}, b: 1})).toBe(false); - expect(deepDiffer({a: {A: 1}, b: 1}, {a: {A: 2}, b: 1})).toBe(true); - expect(deepDiffer( - {a: {A: {aA: 1, bB: 1}}, b: 1}, - {a: {A: {aA: 1, bB: 1}}, b: 1} - )).toBe(false); - expect(deepDiffer( - {a: {A: {aA: 1, bB: 1}}, b: 1}, - {a: {A: {aA: 1, cC: 1}}, b: 1} - )).toBe(true); - }); - it('should diff Arrays', () => { - expect(deepDiffer([], [])).toBe(false); - expect(deepDiffer([], null)).toBe(true); - expect(deepDiffer(null, [])).toBe(true); - expect(deepDiffer([42], [42])).toBe(false); - expect(deepDiffer([1], [2])).toBe(true); - expect(deepDiffer([1, 2, 3], [1, 2, 3])).toBe(false); - expect(deepDiffer([1, 2, 3], [1, 2, 4])).toBe(true); - expect(deepDiffer([1, 2, 3], [1, 4, 3])).toBe(true); - expect(deepDiffer([1, 2, 3, 4], [1, 2, 3])).toBe(true); - expect(deepDiffer([1, 2, 3], [1, 2, 3, 4])).toBe(true); - expect(deepDiffer([0, null, false, ''], [0, null, false, ''])).toBe(false); - expect(deepDiffer([0, null, false, ''], ['', false, null, 0])).toBe(true); - }); - it('should diff mixed types', () => { - expect(deepDiffer({}, [])).toBe(true); - expect(deepDiffer([], {})).toBe(true); - expect(deepDiffer( - {a: [{A: {aA: 1, bB: 1}}, 'bar'], c: [1, [false]]}, - {a: [{A: {aA: 1, bB: 1}}, 'bar'], c: [1, [false]]} - )).toBe(false); - expect(deepDiffer( - {a: [{A: {aA: 1, bB: 1}}, 'bar'], c: [1, [false]]}, - {a: [{A: {aA: 1, bB: 2}}, 'bar'], c: [1, [false]]} - )).toBe(true); - expect(deepDiffer( - {a: [{A: {aA: 1, bB: 1}}, 'bar'], c: [1, [false]]}, - {a: [{A: {aA: 1, bB: 1}}, 'bar'], c: [1, [false], null]} - )).toBe(true); - expect(deepDiffer( - {a: [{A: {aA: 1, bB: 1}}, 'bar'], c: [1, [false]]}, - {a: [{A: {aA: 1, bB: 1}}, ['bar']], c: [1, [false]]} - )).toBe(true); - }); - it('should distinguish between proper Array and Object', () => { - expect(deepDiffer(['a', 'b'], {0: 'a', 1: 'b', length: 2})).toBe(true); - expect(deepDiffer(['a', 'b'], {length: 2, 0: 'a', 1: 'b'})).toBe(true); - }); - it('should diff same object', () => { - var obj = [1,[2,3]]; - expect(deepDiffer(obj, obj)).toBe(false); - }); -}); diff --git a/examples/node_modules/react-native/Libraries/Utilities/differ/deepDiffer.js b/examples/node_modules/react-native/Libraries/Utilities/differ/deepDiffer.js deleted file mode 100644 index 4dec6bd7..00000000 --- a/examples/node_modules/react-native/Libraries/Utilities/differ/deepDiffer.js +++ /dev/null @@ -1,66 +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. - * - * @providesModule deepDiffer - * @flow - */ -'use strict'; - -/* - * @returns {bool} true if different, false if equal - */ -var deepDiffer = function(one: any, two: any): bool { - if (one === two) { - // Short circuit on identical object references instead of traversing them. - return false; - } - if ((typeof one === 'function') && (typeof two === 'function')) { - // We consider all functions equal - return false; - } - if ((typeof one !== 'object') || (one === null)) { - // Primitives can be directly compared - return one !== two; - } - if ((typeof two !== 'object') || (two === null)) { - // We know they are different because the previous case would have triggered - // otherwise. - return true; - } - if (one.constructor !== two.constructor) { - return true; - } - if (Array.isArray(one)) { - // We know two is also an array because the constructors are equal - var len = one.length; - if (two.length !== len) { - return true; - } - for (var ii = 0; ii < len; ii++) { - if (deepDiffer(one[ii], two[ii])) { - return true; - } - } - } else { - for (var key in one) { - if (deepDiffer(one[key], two[key])) { - return true; - } - } - for (var twoKey in two) { - // The only case we haven't checked yet is keys that are in two but aren't - // in one, which means they are different. - if (one[twoKey] === undefined && two[twoKey] !== undefined) { - return true; - } - } - } - return false; -}; - -module.exports = deepDiffer; diff --git a/examples/node_modules/react-native/Libraries/Utilities/differ/insetsDiffer.js b/examples/node_modules/react-native/Libraries/Utilities/differ/insetsDiffer.js deleted file mode 100644 index b0a40947..00000000 --- a/examples/node_modules/react-native/Libraries/Utilities/differ/insetsDiffer.js +++ /dev/null @@ -1,42 +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. - * - * @providesModule insetsDiffer - * @flow - */ -'use strict'; - -type Inset = { - top: ?number; - left: ?number; - right: ?number; - bottom: ?number; -} - -var dummyInsets = { - top: undefined, - left: undefined, - right: undefined, - bottom: undefined, -}; - -var insetsDiffer = function( - one: ?Inset, - two: ?Inset -): bool { - one = one || dummyInsets; - two = two || dummyInsets; - return one !== two && ( - one.top !== two.top || - one.left !== two.left || - one.right !== two.right || - one.bottom !== two.bottom - ); -}; - -module.exports = insetsDiffer; diff --git a/examples/node_modules/react-native/Libraries/Utilities/differ/matricesDiffer.js b/examples/node_modules/react-native/Libraries/Utilities/differ/matricesDiffer.js deleted file mode 100644 index 948cc4cd..00000000 --- a/examples/node_modules/react-native/Libraries/Utilities/differ/matricesDiffer.js +++ /dev/null @@ -1,44 +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. - * - * @providesModule matricesDiffer - */ -'use strict'; - -/** - * Unrolls an array comparison specially for matrices. Prioritizes - * checking of indices that are most likely to change so that the comparison - * bails as early as possible. - * - * @param {MatrixMath.Matrix} one First matrix. - * @param {MatrixMath.Matrix} two Second matrix. - * @return {boolean} Whether or not the two matrices differ. - */ -var matricesDiffer = function(one, two) { - if (one === two) { - return false; - } - return !one || !two || - one[12] !== two[12] || - one[13] !== two[13] || - one[14] !== two[14] || - one[5] !== two[5] || - one[10] !== two[10] || - one[1] !== two[1] || - one[2] !== two[2] || - one[3] !== two[3] || - one[4] !== two[4] || - one[6] !== two[6] || - one[7] !== two[7] || - one[8] !== two[8] || - one[9] !== two[9] || - one[11] !== two[11] || - one[15] !== two[15]; -}; - -module.exports = matricesDiffer; diff --git a/examples/node_modules/react-native/Libraries/Utilities/differ/pointsDiffer.js b/examples/node_modules/react-native/Libraries/Utilities/differ/pointsDiffer.js deleted file mode 100644 index c4939199..00000000 --- a/examples/node_modules/react-native/Libraries/Utilities/differ/pointsDiffer.js +++ /dev/null @@ -1,30 +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. - * - * @providesModule pointsDiffer - * @flow - */ -'use strict'; - -type Point = { - x: ?number; - y: ?number; -} - -var dummyPoint = {x: undefined, y: undefined}; - -var pointsDiffer = function(one: ?Point, two: ?Point): bool { - one = one || dummyPoint; - two = two || dummyPoint; - return one !== two && ( - one.x !== two.x || - one.y !== two.y - ); -}; - -module.exports = pointsDiffer; diff --git a/examples/node_modules/react-native/Libraries/Utilities/differ/sizesDiffer.js b/examples/node_modules/react-native/Libraries/Utilities/differ/sizesDiffer.js deleted file mode 100644 index a431cd07..00000000 --- a/examples/node_modules/react-native/Libraries/Utilities/differ/sizesDiffer.js +++ /dev/null @@ -1,19 +0,0 @@ -/** - * Copyright 2004-present Facebook. All Rights Reserved. - * - * @providesModule sizesDiffer - */ -'use strict'; - -var dummySize = {width: undefined, height: undefined}; - -var sizesDiffer = function(one, two) { - one = one || dummySize; - two = two || dummySize; - return one !== two && ( - one.width !== two.width || - one.height !== two.height - ); -}; - -module.exports = sizesDiffer; diff --git a/examples/node_modules/react-native/Libraries/Utilities/groupByEveryN.js b/examples/node_modules/react-native/Libraries/Utilities/groupByEveryN.js deleted file mode 100644 index a8b353ad..00000000 --- a/examples/node_modules/react-native/Libraries/Utilities/groupByEveryN.js +++ /dev/null @@ -1,52 +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. - * - * @providesModule groupByEveryN - * @flow - */ - -/** - * Useful method to split an array into groups of the same number of elements. - * You can use it to generate grids, rows, pages... - * - * If the input length is not a multiple of the count, it'll fill the last - * array with null so you can display a placeholder. - * - * Example: - * groupByEveryN([1, 2, 3, 4, 5], 3) - * => [[1, 2, 3], [4, 5, null]] - * - * groupByEveryN([1, 2, 3], 2).map(elems => { - * return {elems.map(elem => {elem})}; - * }) - */ -'use strict'; - -function groupByEveryN(array: Array, n: number): Array> { - var result = []; - var temp = []; - - for (var i = 0; i < array.length; ++i) { - if (i > 0 && i % n === 0) { - result.push(temp); - temp = []; - } - temp.push(array[i]); - } - - if (temp.length > 0) { - while (temp.length !== n) { - temp.push(null); - } - result.push(temp); - } - - return result; -} - -module.exports = groupByEveryN; diff --git a/examples/node_modules/react-native/Libraries/Utilities/logError.js b/examples/node_modules/react-native/Libraries/Utilities/logError.js deleted file mode 100644 index aac41be0..00000000 --- a/examples/node_modules/react-native/Libraries/Utilities/logError.js +++ /dev/null @@ -1,28 +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. - * - * @providesModule logError - * @flow - */ -'use strict'; - -/** - * Small utility that can be used as an error handler. You cannot just pass - * `console.error` as a failure callback - it's not properly bound. If passes an - * `Error` object, it will print the message and stack. - */ -var logError = function() { - if (arguments.length === 1 && arguments[0] instanceof Error) { - var err = arguments[0]; - console.error('Error: "' + err.message + '". Stack:\n' + err.stack); - } else { - console.error.apply(console, arguments); - } -}; - -module.exports = logError; diff --git a/examples/node_modules/react-native/Libraries/Utilities/mergeFast.js b/examples/node_modules/react-native/Libraries/Utilities/mergeFast.js deleted file mode 100644 index 78a06cb4..00000000 --- a/examples/node_modules/react-native/Libraries/Utilities/mergeFast.js +++ /dev/null @@ -1,34 +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. - * - * @providesModule mergeFast - * @flow - */ -'use strict'; - -/** - * Faster version of `merge` that doesn't check its arguments and - * also merges prototype inherited properties. - * - * @param {object} one Any non-null object. - * @param {object} two Any non-null object. - * @return {object} Merging of two objects, including prototype - * inherited properties. - */ -var mergeFast = function(one: Object, two: Object): Object { - var ret = {}; - for (var keyOne in one) { - ret[keyOne] = one[keyOne]; - } - for (var keyTwo in two) { - ret[keyTwo] = two[keyTwo]; - } - return ret; -}; - -module.exports = mergeFast; diff --git a/examples/node_modules/react-native/Libraries/Utilities/mergeIntoFast.js b/examples/node_modules/react-native/Libraries/Utilities/mergeIntoFast.js deleted file mode 100644 index 1a97d07b..00000000 --- a/examples/node_modules/react-native/Libraries/Utilities/mergeIntoFast.js +++ /dev/null @@ -1,27 +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. - * - * @providesModule mergeIntoFast - * @flow - */ -'use strict'; - -/** - * Faster version of `mergeInto` that doesn't check its arguments and - * also copies over prototye inherited properties. - * - * @param {object} one Object to assign to. - * @param {object} two Object to assign from. - */ -var mergeIntoFast = function(one: Object, two: Object): void { - for (var keyTwo in two) { - one[keyTwo] = two[keyTwo]; - } -}; - -module.exports = mergeIntoFast; diff --git a/examples/node_modules/react-native/Libraries/Utilities/truncate.js b/examples/node_modules/react-native/Libraries/Utilities/truncate.js deleted file mode 100644 index a15da571..00000000 --- a/examples/node_modules/react-native/Libraries/Utilities/truncate.js +++ /dev/null @@ -1,47 +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. - * - * @providesModule truncate - * @flow - */ -'use strict'; - -var merge = require('merge'); - -type truncateOptions = { - breakOnWords: boolean; - minDelta: number; - elipsis: string; -} - -var defaultOptions = { - breakOnWords: true, - minDelta: 10, // Prevents truncating a tiny bit off the end - elipsis: '...', -}; - -// maxChars (including elipsis) -var truncate = function( - str: ?string, - maxChars: number, - options: truncateOptions -): ?string { - options = merge(defaultOptions, options); - if (str && str.length && - str.length - options.minDelta + options.elipsis.length >= maxChars) { - str = str.slice(0, maxChars - options.elipsis.length + 1); - if (options.breakOnWords) { - var ii = Math.max(str.lastIndexOf(' '), str.lastIndexOf('\n')); - str = str.slice(0, ii); - } - str = str.trim() + options.elipsis; - } - return str; -}; - -module.exports = truncate; diff --git a/examples/node_modules/react-native/Libraries/Vibration/RCTVibration.h b/examples/node_modules/react-native/Libraries/Vibration/RCTVibration.h deleted file mode 100644 index c82901e9..00000000 --- a/examples/node_modules/react-native/Libraries/Vibration/RCTVibration.h +++ /dev/null @@ -1,14 +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. - */ - -#import "RCTBridgeModule.h" - -@interface RCTVibration : NSObject - -@end diff --git a/examples/node_modules/react-native/Libraries/Vibration/RCTVibration.m b/examples/node_modules/react-native/Libraries/Vibration/RCTVibration.m deleted file mode 100644 index f2544d76..00000000 --- a/examples/node_modules/react-native/Libraries/Vibration/RCTVibration.m +++ /dev/null @@ -1,23 +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. - */ - -#import "RCTVibration.h" - -#import - -@implementation RCTVibration - -RCT_EXPORT_MODULE() - -RCT_EXPORT_METHOD(vibrate) -{ - AudioServicesPlaySystemSound(kSystemSoundID_Vibrate); -} - -@end diff --git a/examples/node_modules/react-native/Libraries/Vibration/RCTVibration.xcodeproj/project.pbxproj b/examples/node_modules/react-native/Libraries/Vibration/RCTVibration.xcodeproj/project.pbxproj deleted file mode 100644 index 30613f87..00000000 --- a/examples/node_modules/react-native/Libraries/Vibration/RCTVibration.xcodeproj/project.pbxproj +++ /dev/null @@ -1,275 +0,0 @@ -// !$*UTF8*$! -{ - archiveVersion = 1; - classes = { - }; - objectVersion = 46; - objects = { - -/* Begin PBXBuildFile section */ - 832C819C1AAF6E1A007FA2F7 /* RCTVibration.m in Sources */ = {isa = PBXBuildFile; fileRef = 832C819B1AAF6E1A007FA2F7 /* RCTVibration.m */; }; -/* End PBXBuildFile section */ - -/* Begin PBXCopyFilesBuildPhase section */ - 832C817E1AAF6DEF007FA2F7 /* CopyFiles */ = { - isa = PBXCopyFilesBuildPhase; - buildActionMask = 2147483647; - dstPath = "include/$(PRODUCT_NAME)"; - dstSubfolderSpec = 16; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXCopyFilesBuildPhase section */ - -/* Begin PBXFileReference section */ - 832C81801AAF6DEF007FA2F7 /* libRCTVibration.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = libRCTVibration.a; sourceTree = BUILT_PRODUCTS_DIR; }; - 832C819A1AAF6E1A007FA2F7 /* RCTVibration.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RCTVibration.h; sourceTree = ""; }; - 832C819B1AAF6E1A007FA2F7 /* RCTVibration.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = RCTVibration.m; sourceTree = ""; }; -/* End PBXFileReference section */ - -/* Begin PBXFrameworksBuildPhase section */ - 832C817D1AAF6DEF007FA2F7 /* Frameworks */ = { - isa = PBXFrameworksBuildPhase; - buildActionMask = 2147483647; - files = ( - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXFrameworksBuildPhase section */ - -/* Begin PBXGroup section */ - 832C81771AAF6DEF007FA2F7 = { - isa = PBXGroup; - children = ( - 832C819A1AAF6E1A007FA2F7 /* RCTVibration.h */, - 832C819B1AAF6E1A007FA2F7 /* RCTVibration.m */, - 832C81811AAF6DEF007FA2F7 /* Products */, - ); - indentWidth = 2; - sourceTree = ""; - tabWidth = 2; - }; - 832C81811AAF6DEF007FA2F7 /* Products */ = { - isa = PBXGroup; - children = ( - 832C81801AAF6DEF007FA2F7 /* libRCTVibration.a */, - ); - name = Products; - sourceTree = ""; - }; -/* End PBXGroup section */ - -/* Begin PBXNativeTarget section */ - 832C817F1AAF6DEF007FA2F7 /* RCTVibration */ = { - isa = PBXNativeTarget; - buildConfigurationList = 832C81941AAF6DF0007FA2F7 /* Build configuration list for PBXNativeTarget "RCTVibration" */; - buildPhases = ( - 832C817C1AAF6DEF007FA2F7 /* Sources */, - 832C817D1AAF6DEF007FA2F7 /* Frameworks */, - 832C817E1AAF6DEF007FA2F7 /* CopyFiles */, - ); - buildRules = ( - ); - dependencies = ( - ); - name = RCTVibration; - productName = RCTVibration; - productReference = 832C81801AAF6DEF007FA2F7 /* libRCTVibration.a */; - productType = "com.apple.product-type.library.static"; - }; -/* End PBXNativeTarget section */ - -/* Begin PBXProject section */ - 832C81781AAF6DEF007FA2F7 /* Project object */ = { - isa = PBXProject; - attributes = { - LastUpgradeCheck = 0620; - ORGANIZATIONNAME = Facebook; - TargetAttributes = { - 832C817F1AAF6DEF007FA2F7 = { - CreatedOnToolsVersion = 6.2; - }; - }; - }; - buildConfigurationList = 832C817B1AAF6DEF007FA2F7 /* Build configuration list for PBXProject "RCTVibration" */; - compatibilityVersion = "Xcode 3.2"; - developmentRegion = English; - hasScannedForEncodings = 0; - knownRegions = ( - en, - ); - mainGroup = 832C81771AAF6DEF007FA2F7; - productRefGroup = 832C81811AAF6DEF007FA2F7 /* Products */; - projectDirPath = ""; - projectRoot = ""; - targets = ( - 832C817F1AAF6DEF007FA2F7 /* RCTVibration */, - ); - }; -/* End PBXProject section */ - -/* Begin PBXSourcesBuildPhase section */ - 832C817C1AAF6DEF007FA2F7 /* Sources */ = { - isa = PBXSourcesBuildPhase; - buildActionMask = 2147483647; - files = ( - 832C819C1AAF6E1A007FA2F7 /* RCTVibration.m in Sources */, - ); - runOnlyForDeploymentPostprocessing = 0; - }; -/* End PBXSourcesBuildPhase section */ - -/* Begin XCBuildConfiguration section */ - 832C81921AAF6DF0007FA2F7 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - COPY_PHASE_STRIP = NO; - ENABLE_STRICT_OBJC_MSGSEND = YES; - GCC_C_LANGUAGE_STANDARD = gnu99; - GCC_DYNAMIC_NO_PIC = NO; - GCC_OPTIMIZATION_LEVEL = 0; - GCC_PREPROCESSOR_DEFINITIONS = ( - "DEBUG=1", - "$(inherited)", - ); - GCC_SYMBOLS_PRIVATE_EXTERN = NO; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES; - GCC_WARN_SHADOW = YES; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - HEADER_SEARCH_PATHS = ( - "$(inherited)", - /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, - "$(SRCROOT)/../../React/**", - ); - IPHONEOS_DEPLOYMENT_TARGET = 7.0; - MTL_ENABLE_DEBUG_INFO = YES; - ONLY_ACTIVE_ARCH = YES; - SDKROOT = iphoneos; - WARNING_CFLAGS = ( - "-Werror", - "-Wall", - ); - }; - name = Debug; - }; - 832C81931AAF6DF0007FA2F7 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - ALWAYS_SEARCH_USER_PATHS = NO; - CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; - CLANG_CXX_LIBRARY = "libc++"; - CLANG_ENABLE_MODULES = YES; - CLANG_ENABLE_OBJC_ARC = YES; - CLANG_WARN_BOOL_CONVERSION = YES; - CLANG_WARN_CONSTANT_CONVERSION = YES; - CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; - CLANG_WARN_EMPTY_BODY = YES; - CLANG_WARN_ENUM_CONVERSION = YES; - CLANG_WARN_INT_CONVERSION = YES; - CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; - CLANG_WARN_UNREACHABLE_CODE = YES; - CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; - COPY_PHASE_STRIP = NO; - ENABLE_NS_ASSERTIONS = NO; - ENABLE_STRICT_OBJC_MSGSEND = YES; - GCC_C_LANGUAGE_STANDARD = gnu99; - GCC_WARN_64_TO_32_BIT_CONVERSION = YES; - GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; - GCC_WARN_INITIALIZER_NOT_FULLY_BRACKETED = YES; - GCC_WARN_SHADOW = YES; - GCC_WARN_UNDECLARED_SELECTOR = YES; - GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; - GCC_WARN_UNUSED_FUNCTION = YES; - GCC_WARN_UNUSED_VARIABLE = YES; - HEADER_SEARCH_PATHS = ( - "$(inherited)", - /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, - "$(SRCROOT)/../../React/**", - ); - IPHONEOS_DEPLOYMENT_TARGET = 7.0; - MTL_ENABLE_DEBUG_INFO = NO; - SDKROOT = iphoneos; - VALIDATE_PRODUCT = YES; - WARNING_CFLAGS = ( - "-Werror", - "-Wall", - ); - }; - name = Release; - }; - 832C81951AAF6DF0007FA2F7 /* Debug */ = { - isa = XCBuildConfiguration; - buildSettings = { - CLANG_STATIC_ANALYZER_MODE = deep; - HEADER_SEARCH_PATHS = ( - "$(inherited)", - /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, - "$(SRCROOT)/../../React/**", - ); - OTHER_LDFLAGS = "-ObjC"; - PRODUCT_NAME = "$(TARGET_NAME)"; - RUN_CLANG_STATIC_ANALYZER = YES; - SKIP_INSTALL = YES; - }; - name = Debug; - }; - 832C81961AAF6DF0007FA2F7 /* Release */ = { - isa = XCBuildConfiguration; - buildSettings = { - CLANG_STATIC_ANALYZER_MODE = deep; - HEADER_SEARCH_PATHS = ( - "$(inherited)", - /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include, - "$(SRCROOT)/../../React/**", - ); - OTHER_LDFLAGS = "-ObjC"; - PRODUCT_NAME = "$(TARGET_NAME)"; - SKIP_INSTALL = YES; - }; - name = Release; - }; -/* End XCBuildConfiguration section */ - -/* Begin XCConfigurationList section */ - 832C817B1AAF6DEF007FA2F7 /* Build configuration list for PBXProject "RCTVibration" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 832C81921AAF6DF0007FA2F7 /* Debug */, - 832C81931AAF6DF0007FA2F7 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; - 832C81941AAF6DF0007FA2F7 /* Build configuration list for PBXNativeTarget "RCTVibration" */ = { - isa = XCConfigurationList; - buildConfigurations = ( - 832C81951AAF6DF0007FA2F7 /* Debug */, - 832C81961AAF6DF0007FA2F7 /* Release */, - ); - defaultConfigurationIsVisible = 0; - defaultConfigurationName = Release; - }; -/* End XCConfigurationList section */ - }; - rootObject = 832C81781AAF6DEF007FA2F7 /* Project object */; -} diff --git a/examples/node_modules/react-native/Libraries/Vibration/RCTVibration.xcodeproj/xcuserdata/yuji.xcuserdatad/xcschemes/xcschememanagement.plist b/examples/node_modules/react-native/Libraries/Vibration/RCTVibration.xcodeproj/xcuserdata/yuji.xcuserdatad/xcschemes/xcschememanagement.plist deleted file mode 100644 index a7e4b7e6..00000000 --- a/examples/node_modules/react-native/Libraries/Vibration/RCTVibration.xcodeproj/xcuserdata/yuji.xcuserdatad/xcschemes/xcschememanagement.plist +++ /dev/null @@ -1,22 +0,0 @@ - - - - - SchemeUserState - - RCTVibration.xcscheme - - orderHint - 9 - - - SuppressBuildableAutocreation - - 832C817F1AAF6DEF007FA2F7 - - primary - - - - - diff --git a/examples/node_modules/react-native/Libraries/Vibration/VibrationIOS.android.js b/examples/node_modules/react-native/Libraries/Vibration/VibrationIOS.android.js deleted file mode 100644 index f52be6b7..00000000 --- a/examples/node_modules/react-native/Libraries/Vibration/VibrationIOS.android.js +++ /dev/null @@ -1,23 +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. - * - * Stub of VibrationIOS for Android. - * - * @providesModule VibrationIOS - */ -'use strict'; - -var warning = require('warning'); - -var VibrationIOS = { - vibrate: function() { - warning('VibrationIOS is not supported on this platform!'); - } -}; - -module.exports = VibrationIOS; diff --git a/examples/node_modules/react-native/Libraries/Vibration/VibrationIOS.ios.js b/examples/node_modules/react-native/Libraries/Vibration/VibrationIOS.ios.js deleted file mode 100644 index 2a1dc701..00000000 --- a/examples/node_modules/react-native/Libraries/Vibration/VibrationIOS.ios.js +++ /dev/null @@ -1,39 +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. - * - * @providesModule VibrationIOS - * @flow - */ -'use strict'; - -var RCTVibration = require('NativeModules').Vibration; - -var invariant = require('invariant'); - -/** - * The Vibration API is exposed at `VibrationIOS.vibrate()`. On iOS, calling this - * function will trigger a one second vibration. The vibration is asynchronous - * so this method will return immediately. - * - * There will be no effect on devices that do not support Vibration, eg. the iOS - * simulator. - * - * Vibration patterns are currently unsupported. - */ - -var VibrationIOS = { - vibrate: function() { - invariant( - arguments[0] === undefined, - 'Vibration patterns not supported.' - ); - RCTVibration.vibrate(); - } -}; - -module.exports = VibrationIOS; diff --git a/examples/node_modules/react-native/Libraries/react-native/react-native-interface.js b/examples/node_modules/react-native/Libraries/react-native/react-native-interface.js deleted file mode 100644 index 623ffd98..00000000 --- a/examples/node_modules/react-native/Libraries/react-native/react-native-interface.js +++ /dev/null @@ -1,26 +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. - * - * @flow - */ - -// see also react-native.js - -declare var __DEV__: boolean; - -declare var __REACT_DEVTOOLS_GLOBAL_HOOK__: any; /*?{ - inject: ?((stuff: Object) => void) -};*/ - -declare var fetch: any; -declare var Headers: any; -declare var Request: any; -declare var Response: any; -declare module requestAnimationFrame { - declare var exports: (callback: any) => any; -} diff --git a/examples/node_modules/react-native/Libraries/react-native/react-native.js b/examples/node_modules/react-native/Libraries/react-native/react-native.js deleted file mode 100644 index 130c4439..00000000 --- a/examples/node_modules/react-native/Libraries/react-native/react-native.js +++ /dev/null @@ -1,121 +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. - * - * @noflow - get/set properties not yet supported by flow. also `...require(x)` is broken #6560135 - */ -'use strict'; - -// Export React, plus some native additions. -var ReactNative = { - // Components - get ActivityIndicatorIOS() { return require('ActivityIndicatorIOS'); }, - get ART() { return require('ReactNativeART'); }, - get DatePickerIOS() { return require('DatePickerIOS'); }, - get DrawerLayoutAndroid() { return require('DrawerLayoutAndroid'); }, - get Image() { return require('Image'); }, - get ListView() { return require('ListView'); }, - get MapView() { return require('MapView'); }, - get Modal() { return require('Modal'); }, - get Navigator() { return require('Navigator'); }, - get NavigatorIOS() { return require('NavigatorIOS'); }, - get PickerIOS() { return require('PickerIOS'); }, - get ProgressBarAndroid() { return require('ProgressBarAndroid'); }, - get ProgressViewIOS() { return require('ProgressViewIOS'); }, - get ScrollView() { return require('ScrollView'); }, - get SegmentedControlIOS() { return require('SegmentedControlIOS'); }, - get SliderIOS() { return require('SliderIOS'); }, - get SnapshotViewIOS() { return require('SnapshotViewIOS'); }, - get Switch() { return require('Switch'); }, - get PullToRefreshViewAndroid() { return require('PullToRefreshViewAndroid'); }, - get SwitchAndroid() { return require('SwitchAndroid'); }, - get SwitchIOS() { return require('SwitchIOS'); }, - get TabBarIOS() { return require('TabBarIOS'); }, - get Text() { return require('Text'); }, - get TextInput() { return require('TextInput'); }, - get ToastAndroid() { return require('ToastAndroid'); }, - get ToolbarAndroid() { return require('ToolbarAndroid'); }, - get Touchable() { return require('Touchable'); }, - get TouchableHighlight() { return require('TouchableHighlight'); }, - get TouchableNativeFeedback() { return require('TouchableNativeFeedback'); }, - get TouchableOpacity() { return require('TouchableOpacity'); }, - get TouchableWithoutFeedback() { return require('TouchableWithoutFeedback'); }, - get View() { return require('View'); }, - get ViewPagerAndroid() { return require('ViewPagerAndroid'); }, - get WebView() { return require('WebView'); }, - - // APIs - get ActionSheetIOS() { return require('ActionSheetIOS'); }, - get AdSupportIOS() { return require('AdSupportIOS'); }, - get Alert() { return require('Alert'); }, - get AlertIOS() { return require('AlertIOS'); }, - get Animated() { return require('Animated'); }, - get AppRegistry() { return require('AppRegistry'); }, - get AppStateIOS() { return require('AppStateIOS'); }, - get AsyncStorage() { return require('AsyncStorage'); }, - get BackAndroid() { return require('BackAndroid'); }, - get CameraRoll() { return require('CameraRoll'); }, - get Clipboard() { return require('Clipboard'); }, - get Dimensions() { return require('Dimensions'); }, - get Easing() { return require('Easing'); }, - get ImagePickerIOS() { return require('ImagePickerIOS'); }, - get IntentAndroid() { return require('IntentAndroid'); }, - get InteractionManager() { return require('InteractionManager'); }, - get LayoutAnimation() { return require('LayoutAnimation'); }, - get LinkingIOS() { return require('LinkingIOS'); }, - get NetInfo() { return require('NetInfo'); }, - get PanResponder() { return require('PanResponder'); }, - get PixelRatio() { return require('PixelRatio'); }, - get PushNotificationIOS() { return require('PushNotificationIOS'); }, - get Settings() { return require('Settings'); }, - get StatusBarIOS() { return require('StatusBarIOS'); }, - get StyleSheet() { return require('StyleSheet'); }, - get UIManager() { return require('UIManager'); }, - get VibrationIOS() { return require('VibrationIOS'); }, - - // Plugins - get DeviceEventEmitter() { return require('RCTDeviceEventEmitter'); }, - get NativeAppEventEmitter() { return require('RCTNativeAppEventEmitter'); }, - get NativeModules() { return require('NativeModules'); }, - get Platform() { return require('Platform'); }, - get processColor() { return require('processColor'); }, - get requireNativeComponent() { return require('requireNativeComponent'); }, - - // Prop Types - get EdgeInsetsPropType() { return require('EdgeInsetsPropType'); }, - get PointPropType() { return require('PointPropType'); }, - - // See http://facebook.github.io/react/docs/addons.html - addons: { - get LinkedStateMixin() { return require('LinkedStateMixin'); }, - Perf: undefined, - get PureRenderMixin() { return require('ReactComponentWithPureRenderMixin'); }, - get TestModule() { return require('NativeModules').TestModule; }, - TestUtils: undefined, - get batchedUpdates() { return require('ReactUpdates').batchedUpdates; }, - get cloneWithProps() { return require('cloneWithProps'); }, - get createFragment() { return require('ReactFragment').create; }, - get update() { return require('update'); }, - }, - - // Note: this must be placed last to prevent eager - // evaluation of the getter-wrapped submodules above - ...require('React'), -}; - -if (__DEV__) { - Object.defineProperty(ReactNative.addons, 'Perf', { - enumerable: true, - get: () => require('ReactDefaultPerf'), - }); - Object.defineProperty(ReactNative.addons, 'TestUtils', { - enumerable: true, - get: () => require('ReactTestUtils'), - }); -} - -module.exports = ReactNative; diff --git a/examples/node_modules/react-native/Libraries/vendor/core/Map.js b/examples/node_modules/react-native/Libraries/vendor/core/Map.js deleted file mode 100644 index 114add77..00000000 --- a/examples/node_modules/react-native/Libraries/vendor/core/Map.js +++ /dev/null @@ -1,626 +0,0 @@ -/** - * @generated SignedSource<<375749f44ce7c0f681fc1297943eaf74>> - * - * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - * !! This file is a check-in of a static_upstream project! !! - * !! !! - * !! You should not modify this file directly. Instead: !! - * !! 1) Use `fjs use-upstream` to temporarily replace this with !! - * !! the latest version from upstream. !! - * !! 2) Make your changes, test them, etc. !! - * !! 3) Use `fjs push-upstream` to copy your changes back to !! - * !! static_upstream. !! - * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - * - * Copyright 2013-2014 Facebook, Inc. - * @providesModule Map - * @preventMunge - * @typechecks - */ - -var guid = require('guid'); -var isNode = require('isNode'); -var toIterator = require('toIterator'); -var _shouldPolyfillES6Collection = require('_shouldPolyfillES6Collection'); - -module.exports = (function(global, undefined) { - // Since our implementation is spec-compliant for the most part we can safely - // delegate to a built-in version if exists and is implemented correctly. - // Firefox had gotten a few implementation details wrong across different - // versions so we guard against that. - if (!_shouldPolyfillES6Collection('Map')) { - return global.Map; - } - - /** - * == ES6 Map Collection == - * - * This module is meant to implement a Map collection as described in chapter - * 23.1 of the ES6 specification. - * - * Map objects are collections of key/value pairs where both the keys and - * values may be arbitrary ECMAScript language values. A distinct key value - * may only occur in one key/value pair within the Map's collection. - * - * https://people.mozilla.org/~jorendorff/es6-draft.html#sec-map-objects - * - * There only two -- rather small -- diviations from the spec: - * - * 1. The use of frozen objects as keys. - * We decided not to allow and simply throw an error. The reason being is - * we store a "hash" on the object for fast access to it's place in the - * internal map entries. - * If this turns out to be a popular use case it's possible to implement by - * overiding `Object.freeze` to store a "hash" property on the object - * for later use with the map. - * - * 2. The `size` property on a map object is a regular property and not a - * computed property on the prototype as described by the spec. - * The reason being is that we simply want to support ES3 environments - * which doesn't implement computed properties. - * - * == Usage == - * - * var map = new Map(iterable); - * - * map.set(key, value); - * map.get(key); // value - * map.has(key); // true - * map.delete(key); // true - * - * var iterator = map.keys(); - * iterator.next(); // {value: key, done: false} - * - * var iterator = map.values(); - * iterator.next(); // {value: value, done: false} - * - * var iterator = map.entries(); - * iterator.next(); // {value: [key, value], done: false} - * - * map.forEach(function(value, key){ this === thisArg }, thisArg); - * - * map.clear(); // resets map. - */ - - /** - * Constants - */ - - // Kinds of map iterations 23.1.5.3 - var KIND_KEY = 'key'; - var KIND_VALUE = 'value'; - var KIND_KEY_VALUE = 'key+value'; - - // In older browsers we can't create a null-prototype object so we have to - // defend against key collisions with built-in methods. - var KEY_PREFIX = '$map_'; - - // This property will be used as the internal size variable to disallow - // writing and to issue warnings for writings in development. - var SECRET_SIZE_PROP; - if (__DEV__) { - SECRET_SIZE_PROP = '$size' + guid(); - } - - // In oldIE we use the DOM Node `uniqueID` property to get create the hash. - var OLD_IE_HASH_PREFIX = 'IE_HASH_'; - - class Map { - - /** - * 23.1.1.1 - * Takes an `iterable` which is basically any object that implements a - * Symbol.iterator (@@iterator) method. The iterable is expected to be a - * collection of pairs. Each pair is a key/value pair that will be used - * to instantiate the map. - * - * @param {*} iterable - */ - constructor(iterable) { - if (!isObject(this)) { - throw new TypeError('Wrong map object type.'); - } - - initMap(this); - - if (iterable != null) { - var it = toIterator(iterable); - var next; - while (!(next = it.next()).done) { - if (!isObject(next.value)) { - throw new TypeError('Expected iterable items to be pair objects.'); - } - this.set(next.value[0], next.value[1]); - } - } - } - - /** - * 23.1.3.1 - * Clears the map from all keys and values. - */ - clear() { - initMap(this); - } - - /** - * 23.1.3.7 - * Check if a key exists in the collection. - * - * @param {*} key - * @return {boolean} - */ - has(key) { - var index = getIndex(this, key); - return !!(index != null && this._mapData[index]); - } - - /** - * 23.1.3.9 - * Adds a key/value pair to the collection. - * - * @param {*} key - * @param {*} value - * @return {map} - */ - set(key, value) { - var index = getIndex(this, key); - - if (index != null && this._mapData[index]) { - this._mapData[index][1] = value; - } else { - index = this._mapData.push([ - key, - value - ]) - 1; - setIndex(this, key, index); - if (__DEV__) { - this[SECRET_SIZE_PROP] += 1; - } else { - this.size += 1; - } - } - - return this; - } - - /** - * 23.1.3.6 - * Gets a value associated with a key in the collection. - * - * @param {*} key - * @return {*} - */ - get(key) { - var index = getIndex(this, key); - if (index == null) { - return undefined; - } else { - return this._mapData[index][1]; - } - } - - - /** - * 23.1.3.3 - * Delete a key/value from the collection. - * - * @param {*} key - * @return {boolean} Whether the key was found and deleted. - */ - delete(key) { - var index = getIndex(this, key); - if (index != null && this._mapData[index]) { - setIndex(this, key, undefined); - this._mapData[index] = undefined; - if (__DEV__) { - this[SECRET_SIZE_PROP] -= 1; - } else { - this.size -= 1; - } - return true; - } else { - return false; - } - } - - /** - * 23.1.3.4 - * Returns an iterator over the key/value pairs (in the form of an Array) in - * the collection. - * - * @return {MapIterator} - */ - entries() { - return new MapIterator(this, KIND_KEY_VALUE); - } - - /** - * 23.1.3.8 - * Returns an iterator over the keys in the collection. - * - * @return {MapIterator} - */ - keys() { - return new MapIterator(this, KIND_KEY); - } - - /** - * 23.1.3.11 - * Returns an iterator over the values pairs in the collection. - * - * @return {MapIterator} - */ - values() { - return new MapIterator(this, KIND_VALUE); - } - - /** - * 23.1.3.5 - * Iterates over the key/value pairs in the collection calling `callback` - * with [value, key, map]. An optional `thisArg` can be passed to set the - * context when `callback` is called. - * - * @param {function} callback - * @param {?object} thisArg - */ - forEach(callback, thisArg) { - if (typeof callback !== 'function') { - throw new TypeError('Callback must be callable.'); - } - - var boundCallback = callback.bind(thisArg || undefined); - var mapData = this._mapData; - - // Note that `mapData.length` should be computed on each iteration to - // support iterating over new items in the map that were added after the - // start of the iteration. - for (var i = 0; i < mapData.length; i++) { - var entry = mapData[i]; - if (entry != null) { - boundCallback(entry[1], entry[0], this); - } - } - } - } - - // 23.1.3.12 - Map.prototype[toIterator.ITERATOR_SYMBOL] = Map.prototype.entries; - - class MapIterator { - - /** - * 23.1.5.1 - * Create a `MapIterator` for a given `map`. While this class is private it - * will create objects that will be passed around publicily. - * - * @param {map} map - * @param {string} kind - */ - constructor(map, kind) { - if (!(isObject(map) && map['_mapData'])) { - throw new TypeError('Object is not a map.'); - } - - if ([KIND_KEY, KIND_KEY_VALUE, KIND_VALUE].indexOf(kind) === -1) { - throw new Error('Invalid iteration kind.'); - } - - this._map = map; - this._nextIndex = 0; - this._kind = kind; - } - - /** - * 23.1.5.2.1 - * Get the next iteration. - * - * @return {object} - */ - next() { - if (!this instanceof Map) { - throw new TypeError('Expected to be called on a MapIterator.'); - } - - var map = this._map; - var index = this._nextIndex; - var kind = this._kind; - - if (map == null) { - return createIterResultObject(undefined, true); - } - - var entries = map['_mapData']; - - while (index < entries.length) { - var record = entries[index]; - - index += 1; - this._nextIndex = index; - - if (record) { - if (kind === KIND_KEY) { - return createIterResultObject(record[0], false); - } else if (kind === KIND_VALUE) { - return createIterResultObject(record[1], false); - } else if (kind) { - return createIterResultObject(record, false); - } - } - } - - this._map = undefined; - - return createIterResultObject(undefined, true); - } - } - - // We can put this in the class definition once we have computed props - // transform. - // 23.1.5.2.2 - MapIterator.prototype[toIterator.ITERATOR_SYMBOL] = function() { - return this; - } - - /** - * Helper Functions. - */ - - /** - * Return an index to map.[[MapData]] array for a given Key. - * - * @param {map} map - * @param {*} key - * @return {?number} - */ - function getIndex(map, key) { - if (isObject(key)) { - var hash = getHash(key); - return map._objectIndex[hash]; - } else { - var prefixedKey = KEY_PREFIX + key; - if (typeof key === 'string') { - return map._stringIndex[prefixedKey]; - } else { - return map._otherIndex[prefixedKey]; - } - } - } - - /** - * Setup an index that refer to the key's location in map.[[MapData]]. - * - * @param {map} map - * @param {*} key - */ - function setIndex(map, key, index) { - var shouldDelete = index == null; - - if (isObject(key)) { - var hash = getHash(key); - if (shouldDelete) { - delete map._objectIndex[hash]; - } else { - map._objectIndex[hash] = index; - } - } else { - var prefixedKey = KEY_PREFIX + key; - if (typeof key === 'string') { - if (shouldDelete) { - delete map._stringIndex[prefixedKey]; - } else { - map._stringIndex[prefixedKey] = index; - } - } else { - if (shouldDelete) { - delete map._otherIndex[prefixedKey]; - } else { - map._otherIndex[prefixedKey] = index; - } - } - } - } - - /** - * Instantiate a map with internal slots. - * - * @param {map} map - */ - function initMap(map) { - // Data structure design inspired by Traceur's Map implementation. - // We maintain an internal array for all the entries. The array is needed - // to remember order. However, to have a reasonable HashMap performance - // i.e. O(1) for insertion, deletion, and retrieval. We maintain indices - // in objects for fast look ups. Indices are split up according to data - // types to avoid collisions. - map._mapData = []; - - // Object index maps from an object "hash" to index. The hash being a unique - // property of our choosing that we associate with the object. Association - // is done by ways of keeping a non-enumerable property on the object. - // Ideally these would be `Object.create(null)` objects but since we're - // trying to support ES3 we'll have to gaurd against collisions using - // prefixes on the keys rather than rely on null prototype objects. - map._objectIndex = {}; - - // String index maps from strings to index. - map._stringIndex = {}; - - // Numbers, booleans, undefined, and null. - map._otherIndex = {}; - - // Unfortunately we have to support ES3 and cannot have `Map.prototype.size` - // be a getter method but just a regular method. The biggest problem with - // this is safety. Clients can change the size property easily and possibly - // without noticing (e.g. `if (map.size = 1) {..}` kind of typo). What we - // can do to mitigate use getters and setters in development to disallow - // and issue a warning for changing the `size` property. - if (__DEV__) { - if (isES5) { - // If the `SECRET_SIZE_PROP` property is already defined then we're not - // in the first call to `initMap` (e.g. coming from `map.clear()`) so - // all we need to do is reset the size without defining the properties. - if (map.hasOwnProperty(SECRET_SIZE_PROP)) { - map[SECRET_SIZE_PROP] = 0; - } else { - Object.defineProperty(map, SECRET_SIZE_PROP, { - value: 0, - writable: true - }); - Object.defineProperty(map, 'size', { - set: (v) => { - console.error( - 'PLEASE FIX ME: You are changing the map size property which ' + - 'should not be writable and will break in production.' - ); - throw new Error('The map size property is not writable.'); - }, - get: () => map[SECRET_SIZE_PROP] - }); - } - - // NOTE: Early return to implement immutable `.size` in DEV. - return; - } - } - - // This is a diviation from the spec. `size` should be a getter on - // `Map.prototype`. However, we have to support IE8. - map.size = 0; - } - - /** - * Check if something is an object. - * - * @param {*} o - * @return {boolean} - */ - function isObject(o) { - return o != null && (typeof o === 'object' || typeof o === 'function'); - } - - /** - * Create an iteration object. - * - * @param {*} value - * @param {boolean} done - * @return {object} - */ - function createIterResultObject(value, done) { - return {value, done}; - } - - // Are we in a legit ES5 environment. Spoiler alert: that doesn't include IE8. - var isES5 = (function() { - try { - Object.defineProperty({}, 'x', {}); - return true; - } catch(e) { - return false; - } - })(); - - /** - * Check if an object can be extended. - * - * @param {object|array|function|regexp} o - * @return {boolean} - */ - function isExtensible(o) { - if (!isES5) { - return true; - } else { - return Object.isExtensible(o); - } - } - - /** - * IE has a `uniqueID` set on every DOM node. So we construct the hash from - * this uniqueID to avoid memory leaks and the IE cloneNode bug where it - * clones properties in addition to the attributes. - * - * @param {object} node - * @return {?string} - */ - function getIENodeHash(node) { - var uniqueID; - switch (node.nodeType) { - case 1: // Element - uniqueID = node.uniqueID; - break; - case 9: // Document - uniqueID = node.documentElement.uniqueID; - break; - default: - return null; - } - - if (uniqueID) { - return OLD_IE_HASH_PREFIX + uniqueID; - } else { - return null; - } - } - - var getHash = (function() { - var propIsEnumerable = Object.prototype.propertyIsEnumerable; - var hashProperty = guid(); - var hashCounter = 0; - - /** - * Get the "hash" associated with an object. - * - * @param {object|array|function|regexp} o - * @return {number} - */ - return function getHash(o) { - if (o[hashProperty]) { - return o[hashProperty]; - } else if (!isES5 && - o.propertyIsEnumerable && - o.propertyIsEnumerable[hashProperty]) { - return o.propertyIsEnumerable[hashProperty]; - } else if (!isES5 && - isNode(o) && - getIENodeHash(o)) { - return getIENodeHash(o); - } else if (!isES5 && o[hashProperty]) { - return o[hashProperty]; - } - - if (isExtensible(o)) { - hashCounter += 1; - if (isES5) { - Object.defineProperty(o, hashProperty, { - enumerable: false, - writable: false, - configurable: false, - value: hashCounter - }); - } else if (o.propertyIsEnumerable) { - // Since we can't define a non-enumerable property on the object - // we'll hijack one of the less-used non-enumerable properties to - // save our hash on it. Addiotionally, since this is a function it - // will not show up in `JSON.stringify` which is what we want. - o.propertyIsEnumerable = function() { - return propIsEnumerable.apply(this, arguments); - }; - o.propertyIsEnumerable[hashProperty] = hashCounter; - } else if (isNode(o)) { - // At this point we couldn't get the IE `uniqueID` to use as a hash - // and we couldn't use a non-enumerable property to exploit the - // dontEnum bug so we simply add the `hashProperty` on the node - // itself. - o[hashProperty] = hashCounter; - } else { - throw new Error('Unable to set a non-enumerable property on object.'); - } - return hashCounter; - } else { - throw new Error('Non-extensible objects are not allowed as keys.'); - } - }; - })(); - - return Map; -})(/* jslint evil: true */ Function('return this')()); diff --git a/examples/node_modules/react-native/Libraries/vendor/core/Set.js b/examples/node_modules/react-native/Libraries/vendor/core/Set.js deleted file mode 100644 index 3bd019ae..00000000 --- a/examples/node_modules/react-native/Libraries/vendor/core/Set.js +++ /dev/null @@ -1,201 +0,0 @@ -/** - * @generated SignedSource<<1fe20877e83ba5d4d0ea68ab240df21c>> - * - * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - * !! This file is a check-in of a static_upstream project! !! - * !! !! - * !! You should not modify this file directly. Instead: !! - * !! 1) Use `fjs use-upstream` to temporarily replace this with !! - * !! the latest version from upstream. !! - * !! 2) Make your changes, test them, etc. !! - * !! 3) Use `fjs push-upstream` to copy your changes back to !! - * !! static_upstream. !! - * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - * - * Copyright 2013-2014 Facebook, Inc. - * @providesModule Set - * @preventMunge - * @typechecks - */ - -var Map = require('Map'); -var toIterator = require('toIterator'); -var _shouldPolyfillES6Collection = require('_shouldPolyfillES6Collection'); - -module.exports = (function(global, undefined) { - // Since our implementation is spec-compliant for the most part we can safely - // delegate to a built-in version if exists and is implemented correctly. - // Firefox had gotten a few implementation details wrong across different - // versions so we guard against that. - // These checks are adapted from es6-shim https://fburl.com/34437854 - if (!_shouldPolyfillES6Collection('Set')) { - return global.Set; - } - - /** - * == ES6 Set Collection == - * - * This module is meant to implement a Set collection as described in chapter - * 23.2 of the ES6 specification. - * - * Set objects are collections of unique values. Where values can be any - * JavaScript value. - * https://people.mozilla.org/~jorendorff/es6-draft.html#sec-map-objects - * - * There only two -- rather small -- diviations from the spec: - * - * 1. The use of frozen objects as keys. @see Map module for more on this. - * - * 2. The `size` property on a map object is a regular property and not a - * computed property on the prototype as described by the spec. - * The reason being is that we simply want to support ES3 environments - * which doesn't implement computed properties. - * - * == Usage == - * - * var set = new set(iterable); - * - * set.set(value); - * set.has(value); // true - * set.delete(value); // true - * - * var iterator = set.keys(); - * iterator.next(); // {value: value, done: false} - * - * var iterator = set.values(); - * iterator.next(); // {value: value, done: false} - * - * var iterator = set.entries(); - * iterator.next(); // {value: [value, value], done: false} - * - * set.forEach(function(value, value){ this === thisArg }, thisArg); - * - * set.clear(); // resets set. - */ - - class Set { - - /** - * 23.2.1.1 - * - * Takes an optional `iterable` (which is basically any object that - * implements a Symbol.iterator (@@iterator) method). That is a collection - * of values used to instantiate the set. - * - * @param {*} iterable - */ - constructor(iterable) { - if (this == null || - (typeof this !== 'object' && typeof this !== 'function')) { - throw new TypeError('Wrong set object type.'); - } - - initSet(this); - - if (iterable != null) { - var it = toIterator(iterable); - var next; - while (!(next = it.next()).done) { - this.add(next.value); - } - } - } - - /** - * 23.2.3.1 - * - * If it doesn't already exist in the collection a `value` is added. - * - * @param {*} value - * @return {set} - */ - add(value) { - this._map.set(value, value); - this.size = this._map.size; - return this; - } - - /** - * 23.2.3.2 - * - * Clears the set. - */ - clear() { - initSet(this); - } - - /** - * 23.2.3.4 - * - * Deletes a `value` from the collection if it exists. - * Returns true if the value was found and deleted and false otherwise. - * - * @param {*} value - * @return {boolean} - */ - delete(value) { - var ret = this._map.delete(value); - this.size = this._map.size; - return ret; - } - - /** - * 23.2.3.5 - * - * Returns an iterator over a collection of [value, value] tuples. - */ - entries() { - return this._map.entries(); - } - - /** - * 23.2.3.6 - * - * Iterate over the collection calling `callback` with (value, value, set). - * - * @param {function} callback - */ - forEach(callback) { - var thisArg = arguments[1]; - var it = this._map.keys(); - var next; - while (!(next = it.next()).done) { - callback.call(thisArg, next.value, next.value, this); - } - } - - /** - * 23.2.3.7 - * - * Iterate over the collection calling `callback` with (value, value, set). - * - * @param {*} value - * @return {boolean} - */ - has(value) { - return this._map.has(value); - } - - /** - * 23.2.3.7 - * - * Returns an iterator over the colleciton of values. - */ - values() { - return this._map.values(); - } - } - - // 23.2.3.11 - Set.prototype[toIterator.ITERATOR_SYMBOL] = Set.prototype.values; - - // 23.2.3.7 - Set.prototype.keys = Set.prototype.values; - - function initSet(set) { - set._map = new Map(); - set.size = set._map.size; - } - - return Set; -})(/* jslint evil: true */ Function('return this')()); diff --git a/examples/node_modules/react-native/Libraries/vendor/core/_shouldPolyfillES6Collection.js b/examples/node_modules/react-native/Libraries/vendor/core/_shouldPolyfillES6Collection.js deleted file mode 100644 index 4a9aecd8..00000000 --- a/examples/node_modules/react-native/Libraries/vendor/core/_shouldPolyfillES6Collection.js +++ /dev/null @@ -1,53 +0,0 @@ -/** - * @generated SignedSource<> - * - * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - * !! This file is a check-in of a static_upstream project! !! - * !! !! - * !! You should not modify this file directly. Instead: !! - * !! 1) Use `fjs use-upstream` to temporarily replace this with !! - * !! the latest version from upstream. !! - * !! 2) Make your changes, test them, etc. !! - * !! 3) Use `fjs push-upstream` to copy your changes back to !! - * !! static_upstream. !! - * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - * - * Copyright 2004-present Facebook. All Rights Reserved. - * - * @providesModule _shouldPolyfillES6Collection - * @preventMunge - * @flow - */ - -/** - * Checks whether a collection name (e.g. "Map" or "Set") has a native polyfill - * that is safe to be used. - */ -function shouldPolyfillES6Collection(collectionName: string): boolean { - var Collection = global[collectionName]; - if (Collection == null) { - return true; - } - - // The iterator protocol depends on `Symbol.iterator`. If a collection is - // implemented, but `Symbol` is not, it's going to break iteration because - // we'll be using custom "@@iterator" instead, which is not implemented on - // native collections. - if (typeof global.Symbol !== 'function') { - return true; - } - - var proto = Collection.prototype; - - // These checks are adapted from es6-shim: https://fburl.com/34437854 - // NOTE: `isCallableWithoutNew` and `!supportsSubclassing` are not checked - // because they make debugging with "break on exceptions" difficult. - return Collection == null || - typeof Collection !== 'function' || - typeof proto.clear !== 'function' || - new Collection().size !== 0 || - typeof proto.keys !== 'function' || - typeof proto.forEach !== 'function'; -} - -module.exports = shouldPolyfillES6Collection; diff --git a/examples/node_modules/react-native/Libraries/vendor/core/clearImmediate.js b/examples/node_modules/react-native/Libraries/vendor/core/clearImmediate.js deleted file mode 100644 index 06014745..00000000 --- a/examples/node_modules/react-native/Libraries/vendor/core/clearImmediate.js +++ /dev/null @@ -1,19 +0,0 @@ -/** - * @generated SignedSource<<4595f3986407fd02332cf9f5fc12e70f>> - * - * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - * !! This file is a check-in of a static_upstream project! !! - * !! !! - * !! You should not modify this file directly. Instead: !! - * !! 1) Use `fjs use-upstream` to temporarily replace this with !! - * !! the latest version from upstream. !! - * !! 2) Make your changes, test them, etc. !! - * !! 3) Use `fjs push-upstream` to copy your changes back to !! - * !! static_upstream. !! - * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - * - * @providesModule clearImmediate - */ - -module.exports = global.clearImmediate || - require('ImmediateImplementation').clearImmediate; diff --git a/examples/node_modules/react-native/Libraries/vendor/core/copyProperties.js b/examples/node_modules/react-native/Libraries/vendor/core/copyProperties.js deleted file mode 100644 index e5a2638d..00000000 --- a/examples/node_modules/react-native/Libraries/vendor/core/copyProperties.js +++ /dev/null @@ -1,53 +0,0 @@ -/** - * @generated SignedSource<> - * - * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - * !! This file is a check-in of a static_upstream project! !! - * !! !! - * !! You should not modify this file directly. Instead: !! - * !! 1) Use `fjs use-upstream` to temporarily replace this with !! - * !! the latest version from upstream. !! - * !! 2) Make your changes, test them, etc. !! - * !! 3) Use `fjs push-upstream` to copy your changes back to !! - * !! static_upstream. !! - * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - * - * @providesModule copyProperties - */ - -/** - * Copy properties from one or more objects (up to 5) into the first object. - * This is a shallow copy. It mutates the first object and also returns it. - * - * NOTE: `arguments` has a very significant performance penalty, which is why - * we don't support unlimited arguments. - */ -function copyProperties(obj, a, b, c, d, e, f) { - obj = obj || {}; - - if (__DEV__) { - if (f) { - throw new Error('Too many arguments passed to copyProperties'); - } - } - - var args = [a, b, c, d, e]; - var ii = 0, v; - while (args[ii]) { - v = args[ii++]; - for (var k in v) { - obj[k] = v[k]; - } - - // IE ignores toString in object iteration.. See: - // webreflection.blogspot.com/2007/07/quick-fix-internet-explorer-and.html - if (v.hasOwnProperty && v.hasOwnProperty('toString') && - (typeof v.toString != 'undefined') && (obj.toString !== v.toString)) { - obj.toString = v.toString; - } - } - - return obj; -} - -module.exports = copyProperties; diff --git a/examples/node_modules/react-native/Libraries/vendor/core/getObjectValues.js b/examples/node_modules/react-native/Libraries/vendor/core/getObjectValues.js deleted file mode 100644 index a7c9448b..00000000 --- a/examples/node_modules/react-native/Libraries/vendor/core/getObjectValues.js +++ /dev/null @@ -1,36 +0,0 @@ -/** - * @generated SignedSource<> - * - * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - * !! This file is a check-in of a static_upstream project! !! - * !! !! - * !! You should not modify this file directly. Instead: !! - * !! 1) Use `fjs use-upstream` to temporarily replace this with !! - * !! the latest version from upstream. !! - * !! 2) Make your changes, test them, etc. !! - * !! 3) Use `fjs push-upstream` to copy your changes back to !! - * !! static_upstream. !! - * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - * - * @providesModule getObjectValues - * @typechecks - */ - -/** - * Retrieve an object's values as an array. - * - * If you are looking for a function that creates an Array instance based - * on an "Array-like" object, use createArrayFrom instead. - * - * @param {object} obj An object. - * @return {array} The object's values. - */ -function getObjectValues(obj) { - var values = []; - for (var key in obj) { - values.push(obj[key]); - } - return values; -} - -module.exports = getObjectValues; diff --git a/examples/node_modules/react-native/Libraries/vendor/core/guid.js b/examples/node_modules/react-native/Libraries/vendor/core/guid.js deleted file mode 100644 index 7f66e64d..00000000 --- a/examples/node_modules/react-native/Libraries/vendor/core/guid.js +++ /dev/null @@ -1,31 +0,0 @@ -/** - * @generated SignedSource<<4425c6f5a34b56ee4707e090f43fd075>> - * - * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - * !! This file is a check-in of a static_upstream project! !! - * !! !! - * !! You should not modify this file directly. Instead: !! - * !! 1) Use `fjs use-upstream` to temporarily replace this with !! - * !! the latest version from upstream. !! - * !! 2) Make your changes, test them, etc. !! - * !! 3) Use `fjs push-upstream` to copy your changes back to !! - * !! static_upstream. !! - * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - * - * Copyright 2004-present Facebook. All Rights Reserved. - * - * Module that provides a function for creating a unique identifier. - * The returned value does not conform to the GUID standard, but should - * be globally unique in the context of the browser. - * - * @providesModule guid - * - */ - -/*jshint bitwise: false*/ - -function guid() { - return 'f' + (Math.random() * (1 << 30)).toString(16).replace('.', ''); -} - -module.exports = guid; diff --git a/examples/node_modules/react-native/Libraries/vendor/core/immediate/setImmediate.js b/examples/node_modules/react-native/Libraries/vendor/core/immediate/setImmediate.js deleted file mode 100644 index 1040712a..00000000 --- a/examples/node_modules/react-native/Libraries/vendor/core/immediate/setImmediate.js +++ /dev/null @@ -1,201 +0,0 @@ -/** - * @generated SignedSource<<57d0446bbd1186485d372efe6b323dca>> - * - * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - * !! This file is a check-in of a static_upstream project! !! - * !! !! - * !! You should not modify this file directly. Instead: !! - * !! 1) Use `fjs use-upstream` to temporarily replace this with !! - * !! the latest version from upstream. !! - * !! 2) Make your changes, test them, etc. !! - * !! 3) Use `fjs push-upstream` to copy your changes back to !! - * !! static_upstream. !! - * !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! - * - * Copyright (c) 2012 Barnesandnoble.com, llc, Donavon West, and Domenic - * Denicola - * - * Permission is hereby granted, free of charge, to any person obtaining - * a copy of this software and associated documentation files (the - * "Software"), to deal in the Software without restriction, including - * without limitation the rights to use, copy, modify, merge, publish, - * distribute, sublicense, and/or sell copies of the Software, and to - * permit persons to whom the Software is furnished to do so, subject to - * the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE - * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION - * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION - * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - * - * @preserve-header - * @providesModule ImmediateImplementation - */ - -(function(global, undefined) { - "use strict"; - - var nextHandle = 1; // Spec says greater than zero - var tasksByHandle = {}; - var queueHead = {}; - var queueTail = queueHead; - var currentlyRunningATask = false; - var doc = global.document; - var setImmediate; - - function addFromSetImmediateArguments(args) { - var handler = args[0]; - args = Array.prototype.slice.call(args, 1); - tasksByHandle[nextHandle] = function() { - handler.apply(undefined, args); - }; - queueTail = (queueTail.next = { handle: nextHandle++ }); - return queueTail.handle; - } - - function flushQueue() { - var next, task; - while (!currentlyRunningATask && (next = queueHead.next)) { - queueHead = next; // If this task fails, don't retry it. - if ((task = tasksByHandle[next.handle])) { - currentlyRunningATask = true; - try { - task(); - currentlyRunningATask = false; - } finally { - clearImmediate(next.handle); - if (currentlyRunningATask) { - currentlyRunningATask = false; - // The call to task() must have thrown an - // exception if we reach this point, so, just in - // case there are tasks remaining to be executed, - // we schedule another flushQueue in a later tick - // of the event loop, and let the exception - // propagate uncaught. - if (queueHead.next) { - setImmediate(flushQueue); - } - } - } - } - } - } - - function clearImmediate(handle) { - delete tasksByHandle[handle]; - } - - function canUsePostMessage() { - // The test against `importScripts` prevents this implementation from being installed inside a web worker, - // where `global.postMessage` means something completely different and can't be used for this purpose. - if (global.postMessage && !global.importScripts) { - var postMessageIsAsynchronous = true; - - var onMessage = function() { - postMessageIsAsynchronous = false; - if (global.removeEventListener) { - global.removeEventListener("message", onMessage, false); - } else { - global.detachEvent("onmessage", onMessage); - } - }; - - if (global.addEventListener) { - global.addEventListener("message", onMessage, false); - } else if (global.attachEvent) { - global.attachEvent("onmessage", onMessage); - } else { - return false; - } - - global.postMessage("", "*"); - return postMessageIsAsynchronous; - } - } - - function installPostMessageImplementation() { - // Installs an event handler on `global` for the `message` event: see - // * https://developer.mozilla.org/en/DOM/window.postMessage - var messagePrefix = "setImmediate$" + Math.random() + "$"; - var onGlobalMessage = function(event) { - if (event.source === global && - typeof event.data === "string" && - event.data.indexOf(messagePrefix) === 0) { - flushQueue(); - } - }; - - if (global.addEventListener) { - global.addEventListener("message", onGlobalMessage, false); - } else { - global.attachEvent("onmessage", onGlobalMessage); - } - - setImmediate = function() { - var handle = addFromSetImmediateArguments(arguments); - global.postMessage(messagePrefix + handle, "*"); - return handle; - }; - } - - function installMessageChannelImplementation() { - var channel = new MessageChannel(); - channel.port1.onmessage = flushQueue; - setImmediate = function() { - var handle = addFromSetImmediateArguments(arguments); - channel.port2.postMessage(handle); - return handle; - }; - } - - function installReadyStateChangeImplementation() { - var html = doc.documentElement; - setImmediate = function() { - var handle = addFromSetImmediateArguments(arguments); - // Create a