mirror of
https://github.com/zhigang1992/react-native-web.git
synced 2026-01-12 22:51:09 +08:00
Smaller production builds
Builds on the exclusion of PropTypes from production builds: - Remove 'lodash' and use smaller modules for equivalent functions. - Remove use of some unnecessary Facebook utilities. - Remove 'TouchableBounce'; it isn't part of React Native anymore. - Remove stray import of 'react-dom/server'. - Exclude 'StyleSheetValidation' from production. Measuring the UMD build (gzip)… Before: ~100KB After: ~60KB
This commit is contained in:
@@ -23,7 +23,7 @@ var {
|
||||
AppRegistry,
|
||||
StyleSheet,
|
||||
Text,
|
||||
TouchableBounce,
|
||||
TouchableOpacity,
|
||||
View,
|
||||
} = ReactNative;
|
||||
|
||||
@@ -139,9 +139,9 @@ class GameEndOverlay extends React.Component {
|
||||
return (
|
||||
<View style={styles.overlay}>
|
||||
<Text style={styles.overlayMessage}>{message}</Text>
|
||||
<TouchableBounce onPress={this.props.onRestart} style={styles.tryAgain}>
|
||||
<TouchableOpacity onPress={this.props.onRestart} style={styles.tryAgain}>
|
||||
<Text style={styles.tryAgainText}>Try Again?</Text>
|
||||
</TouchableBounce>
|
||||
</TouchableOpacity>
|
||||
</View>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -19,11 +19,13 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"animated": "^0.1.3",
|
||||
"array-find-index": "^1.0.2",
|
||||
"babel-plugin-transform-react-remove-prop-types": "^0.2.11",
|
||||
"babel-runtime": "^6.11.6",
|
||||
"debounce": "^1.0.0",
|
||||
"deep-assign": "^2.0.0",
|
||||
"fbjs": "^0.8.4",
|
||||
"inline-style-prefixer": "^2.0.1",
|
||||
"lodash": "^4.15.0",
|
||||
"react-dom": "~15.3.2",
|
||||
"react-textarea-autosize": "^4.0.4",
|
||||
"react-timer-mixin": "^0.13.3",
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
import { Component } from 'react';
|
||||
import invariant from 'fbjs/lib/invariant';
|
||||
import { unmountComponentAtNode } from 'react/lib/ReactMount';
|
||||
import renderApplication, { prerenderApplication } from './renderApplication';
|
||||
import renderApplication, { getApplication } from './renderApplication';
|
||||
|
||||
const runnables = {};
|
||||
|
||||
|
||||
@@ -8,7 +8,6 @@
|
||||
|
||||
import invariant from 'fbjs/lib/invariant';
|
||||
import { render } from 'react/lib/ReactMount';
|
||||
import ReactDOMServer from 'react-dom/server';
|
||||
import ReactNativeApp from './ReactNativeApp';
|
||||
import StyleSheet from '../../apis/StyleSheet';
|
||||
import React, { Component } from 'react';
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import ExecutionEnvironment from 'fbjs/lib/ExecutionEnvironment';
|
||||
import findIndex from 'lodash/findIndex';
|
||||
import findIndex from 'array-find-index';
|
||||
import invariant from 'fbjs/lib/invariant';
|
||||
|
||||
const EVENT_TYPES = [ 'change' ];
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Copyright (c) 2015-present, Facebook, Inc.
|
||||
* All rights reserved.
|
||||
*/
|
||||
import merge from 'lodash/merge';
|
||||
import merge from 'deep-assign';
|
||||
|
||||
const mergeLocalStorageItem = (key, value) => {
|
||||
const oldValue = window.localStorage.getItem(key);
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* @flow
|
||||
*/
|
||||
|
||||
import debounce from 'lodash/debounce';
|
||||
import debounce from 'debounce';
|
||||
import ExecutionEnvironment from 'fbjs/lib/ExecutionEnvironment';
|
||||
import invariant from 'fbjs/lib/invariant';
|
||||
|
||||
|
||||
@@ -6,13 +6,12 @@
|
||||
*/
|
||||
|
||||
import invariant from 'fbjs/lib/invariant';
|
||||
import keyMirror from 'fbjs/lib/keyMirror';
|
||||
|
||||
const InteractionManager = {
|
||||
Events: keyMirror({
|
||||
interactionStart: true,
|
||||
interactionComplete: true
|
||||
}),
|
||||
Events: {
|
||||
interactionStart: 'interactionStart',
|
||||
interactionComplete: 'interactionComplete'
|
||||
},
|
||||
|
||||
/**
|
||||
* Schedule a function to run after all interactions have completed.
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
*/
|
||||
|
||||
import ExecutionEnvironment from 'fbjs/lib/ExecutionEnvironment';
|
||||
import findIndex from 'lodash/findIndex';
|
||||
import findIndex from 'array-find-index';
|
||||
import invariant from 'fbjs/lib/invariant';
|
||||
|
||||
const connection = ExecutionEnvironment.canUseDOM && (
|
||||
|
||||
@@ -1,9 +1,19 @@
|
||||
/* eslint-env jasmine, jest */
|
||||
|
||||
import { getDefaultStyleSheet } from '../css';
|
||||
import isPlainObject from 'lodash/isPlainObject';
|
||||
import StyleSheet from '..';
|
||||
|
||||
const isPlainObject = (x) => {
|
||||
const toString = Object.prototype.toString;
|
||||
let proto;
|
||||
/* eslint-disable */
|
||||
return (
|
||||
toString.call(x) === '[object Object]' &&
|
||||
(proto = Object.getPrototypeOf(x), proto === null || proto === Object.getPrototypeOf({}))
|
||||
);
|
||||
/* eslint-enable */
|
||||
};
|
||||
|
||||
describe('apis/StyleSheet', () => {
|
||||
beforeEach(() => {
|
||||
StyleSheet._reset();
|
||||
|
||||
@@ -4,7 +4,6 @@ import ExecutionEnvironment from 'fbjs/lib/ExecutionEnvironment';
|
||||
import flattenStyle from '../../modules/flattenStyle';
|
||||
import React from 'react';
|
||||
import ReactNativePropRegistry from '../../modules/ReactNativePropRegistry';
|
||||
import StyleSheetValidation from './StyleSheetValidation';
|
||||
|
||||
let styleElement;
|
||||
let shouldInsertStyleSheet = ExecutionEnvironment.canUseDOM;
|
||||
@@ -52,7 +51,9 @@ module.exports = {
|
||||
|
||||
const result = {};
|
||||
for (const key in styles) {
|
||||
StyleSheetValidation.validateStyle(key, styles);
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
require('./StyleSheetValidation').validateStyle(key, styles);
|
||||
}
|
||||
result[key] = ReactNativePropRegistry.register(styles[key]);
|
||||
}
|
||||
return result;
|
||||
|
||||
@@ -1,13 +1,10 @@
|
||||
import applyNativeMethods from '../../modules/applyNativeMethods';
|
||||
import ListViewDataSource from './ListViewDataSource';
|
||||
import ListViewPropTypes from './ListViewPropTypes';
|
||||
import pick from 'lodash/pick';
|
||||
import ScrollView from '../ScrollView';
|
||||
import View from '../View';
|
||||
import React, { Component } from 'react';
|
||||
|
||||
const scrollViewProps = Object.keys(ScrollView.propTypes);
|
||||
|
||||
class ListView extends Component {
|
||||
static propTypes = ListViewPropTypes;
|
||||
|
||||
@@ -90,9 +87,7 @@ class ListView extends Component {
|
||||
}
|
||||
}
|
||||
|
||||
const props = pick(this.props, scrollViewProps);
|
||||
|
||||
return React.cloneElement(this.props.renderScrollComponent(props), {
|
||||
return React.cloneElement(this.props.renderScrollComponent(this.props), {
|
||||
ref: this._setScrollViewRef
|
||||
}, header, children, footer);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
* @flow
|
||||
*/
|
||||
|
||||
import debounce from 'lodash/debounce';
|
||||
import debounce from 'debounce';
|
||||
import View from '../View';
|
||||
import React, { Component, PropTypes } from 'react';
|
||||
|
||||
|
||||
@@ -14,7 +14,6 @@
|
||||
|
||||
/* @edit start */
|
||||
const BoundingDimensions = require('./BoundingDimensions');
|
||||
const keyMirror = require('fbjs/lib/keyMirror');
|
||||
const normalizeColor = require('../../modules/normalizeColor');
|
||||
const Position = require('./Position');
|
||||
const React = require('react');
|
||||
@@ -111,16 +110,16 @@ const View = require('../../components/View');
|
||||
/**
|
||||
* Touchable states.
|
||||
*/
|
||||
var States = keyMirror({
|
||||
NOT_RESPONDER: null, // Not the responder
|
||||
RESPONDER_INACTIVE_PRESS_IN: null, // Responder, inactive, in the `PressRect`
|
||||
RESPONDER_INACTIVE_PRESS_OUT: null, // Responder, inactive, out of `PressRect`
|
||||
RESPONDER_ACTIVE_PRESS_IN: null, // Responder, active, in the `PressRect`
|
||||
RESPONDER_ACTIVE_PRESS_OUT: null, // Responder, active, out of `PressRect`
|
||||
RESPONDER_ACTIVE_LONG_PRESS_IN: null, // Responder, active, in the `PressRect`, after long press threshold
|
||||
RESPONDER_ACTIVE_LONG_PRESS_OUT: null, // Responder, active, out of `PressRect`, after long press threshold
|
||||
ERROR: null
|
||||
});
|
||||
var States = {
|
||||
NOT_RESPONDER: 'NOT_RESPONDER', // Not the responder
|
||||
RESPONDER_INACTIVE_PRESS_IN: 'RESPONDER_INACTIVE_PRESS_IN', // Responder, inactive, in the `PressRect`
|
||||
RESPONDER_INACTIVE_PRESS_OUT: 'RESPONDER_INACTIVE_PRESS_OUT', // Responder, inactive, out of `PressRect`
|
||||
RESPONDER_ACTIVE_PRESS_IN: 'RESPONDER_ACTIVE_PRESS_IN', // Responder, active, in the `PressRect`
|
||||
RESPONDER_ACTIVE_PRESS_OUT: 'RESPONDER_ACTIVE_PRESS_OUT', // Responder, active, out of `PressRect`
|
||||
RESPONDER_ACTIVE_LONG_PRESS_IN: 'RESPONDER_ACTIVE_LONG_PRESS_IN', // Responder, active, in the `PressRect`, after long press threshold
|
||||
RESPONDER_ACTIVE_LONG_PRESS_OUT: 'RESPONDER_ACTIVE_LONG_PRESS_OUT', // Responder, active, out of `PressRect`, after long press threshold
|
||||
ERROR: 'ERROR'
|
||||
};
|
||||
|
||||
/**
|
||||
* Quick lookup map for states that are considered to be "active"
|
||||
@@ -147,15 +146,15 @@ var IsLongPressingIn = {
|
||||
/**
|
||||
* Inputs to the state machine.
|
||||
*/
|
||||
var Signals = keyMirror({
|
||||
DELAY: null,
|
||||
RESPONDER_GRANT: null,
|
||||
RESPONDER_RELEASE: null,
|
||||
RESPONDER_TERMINATED: null,
|
||||
ENTER_PRESS_RECT: null,
|
||||
LEAVE_PRESS_RECT: null,
|
||||
LONG_PRESS_DETECTED: null,
|
||||
});
|
||||
var Signals = {
|
||||
DELAY: 'DELAY',
|
||||
RESPONDER_GRANT: 'RESPONDER_GRANT',
|
||||
RESPONDER_RELEASE: 'RESPONDER_RELEASE',
|
||||
RESPONDER_TERMINATED: 'RESPONDER_TERMINATED',
|
||||
ENTER_PRESS_RECT: 'ENTER_PRESS_RECT',
|
||||
LEAVE_PRESS_RECT: 'LEAVE_PRESS_RECT',
|
||||
LONG_PRESS_DETECTED: 'LONG_PRESS_DETECTED',
|
||||
};
|
||||
|
||||
/**
|
||||
* Mapping from States x Signals => States
|
||||
|
||||
@@ -1,164 +0,0 @@
|
||||
/* eslint-disable */
|
||||
/**
|
||||
* 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('../../apis/Animated');
|
||||
var EdgeInsetsPropType = require('../../propTypes/EdgeInsetsPropType');
|
||||
var NativeMethodsMixin = require('../../modules/NativeMethodsMixin');
|
||||
var React = require('react');
|
||||
var StyleSheet = require('../../apis/StyleSheet');
|
||||
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,
|
||||
/**
|
||||
* This defines how far your touch can start away from the button. This is
|
||||
* added to `pressRetentionOffset` when moving off of the button.
|
||||
* ** NOTE **
|
||||
* The touch area never extends past the parent view bounds and the Z-index
|
||||
* of sibling views always takes precedence if a touch hits two overlapping
|
||||
* views.
|
||||
*/
|
||||
hitSlop: 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;
|
||||
},
|
||||
|
||||
touchableGetHitSlop: function(): ?Object {
|
||||
return this.props.hitSlop;
|
||||
},
|
||||
|
||||
touchableGetHighlightDelayMS: function(): number {
|
||||
return 0;
|
||||
},
|
||||
|
||||
render: function(): ReactElement {
|
||||
const scaleTransform = [{ scale: this.state.scale }];
|
||||
const propsTransform = this.props.style.transform;
|
||||
const transform = propsTransform && Array.isArray(propsTransform) ? propsTransform.concat(scaleTransform) : scaleTransform;
|
||||
|
||||
return (
|
||||
<Animated.View
|
||||
accessible={true}
|
||||
accessibilityLabel={this.props.accessibilityLabel}
|
||||
accessibilityRole={this.props.accessibilityRole || 'button'}
|
||||
testID={this.props.testID}
|
||||
hitSlop={this.props.hitSlop}
|
||||
onStartShouldSetResponder={this.touchableHandleStartShouldSetResponder}
|
||||
onResponderTerminationRequest={this.touchableHandleResponderTerminationRequest}
|
||||
onResponderGrant={this.touchableHandleResponderGrant}
|
||||
onResponderMove={this.touchableHandleResponderMove}
|
||||
onResponderRelease={this.touchableHandleResponderRelease}
|
||||
onResponderTerminate={this.touchableHandleResponderTerminate}
|
||||
style={[styles.root, this.props.style, { transform }]}
|
||||
tabIndex='0'
|
||||
>
|
||||
{this.props.children}
|
||||
</Animated.View>
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
const styles = StyleSheet.create({
|
||||
root: {
|
||||
cursor: 'pointer',
|
||||
userSelect: 'none'
|
||||
}
|
||||
});
|
||||
|
||||
module.exports = TouchableBounce;
|
||||
@@ -26,7 +26,6 @@ var View = require('../View');
|
||||
var ensureComponentIsNative = require('./ensureComponentIsNative');
|
||||
var ensurePositiveDelayProps = require('./ensurePositiveDelayProps');
|
||||
var keyOf = require('fbjs/lib/keyOf');
|
||||
var merge = require('../../modules/merge');
|
||||
|
||||
type Event = Object;
|
||||
|
||||
@@ -115,7 +114,7 @@ var TouchableHighlight = React.createClass({
|
||||
},
|
||||
|
||||
getInitialState: function() {
|
||||
return merge(this.touchableGetInitialState(), this.computeSyntheticState(this.props))
|
||||
return { ...this.touchableGetInitialState(), ...this.computeSyntheticState(this.props) }
|
||||
},
|
||||
|
||||
componentDidMount: function() {
|
||||
|
||||
@@ -28,7 +28,6 @@ import Switch from './components/Switch';
|
||||
import Text from './components/Text';
|
||||
import TextInput from './components/TextInput';
|
||||
import Touchable from './components/Touchable/Touchable';
|
||||
import TouchableBounce from './components/Touchable/TouchableBounce';
|
||||
import TouchableHighlight from './components/Touchable/TouchableHighlight';
|
||||
import TouchableOpacity from './components/Touchable/TouchableOpacity';
|
||||
import TouchableWithoutFeedback from './components/Touchable/TouchableWithoutFeedback';
|
||||
@@ -76,7 +75,6 @@ const ReactNative = {
|
||||
Text,
|
||||
TextInput,
|
||||
Touchable,
|
||||
TouchableBounce,
|
||||
TouchableHighlight,
|
||||
TouchableOpacity,
|
||||
TouchableWithoutFeedback,
|
||||
|
||||
@@ -1,222 +0,0 @@
|
||||
/* eslint-disable */
|
||||
/**
|
||||
* @generated SignedSource<<b68d78236d45828b3f7f7fcc740782a9>>
|
||||
*
|
||||
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
* !! 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.
|
||||
*
|
||||
* 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 mergeHelpers
|
||||
*
|
||||
* requiresPolyfills: Array.isArray
|
||||
*/
|
||||
|
||||
"use strict";
|
||||
|
||||
var invariant = require('fbjs/lib/invariant');
|
||||
var keyMirror = require('fbjs/lib/keyMirror');
|
||||
|
||||
/**
|
||||
* Maximum number of levels to traverse. Will catch circular structures.
|
||||
* @const
|
||||
*/
|
||||
var MAX_MERGE_DEPTH = 36;
|
||||
|
||||
/**
|
||||
* We won't worry about edge cases like new String('x') or new Boolean(true).
|
||||
* Functions are considered terminals, and arrays are not.
|
||||
* @param {*} o The item/object/value to test.
|
||||
* @return {boolean} true iff the argument is a terminal.
|
||||
*/
|
||||
var isTerminal = function(o) {
|
||||
return typeof o !== 'object' || o === null;
|
||||
};
|
||||
|
||||
var mergeHelpers = {
|
||||
|
||||
MAX_MERGE_DEPTH: MAX_MERGE_DEPTH,
|
||||
|
||||
isTerminal: isTerminal,
|
||||
|
||||
/**
|
||||
* Converts null/undefined values into empty object.
|
||||
*
|
||||
* @param {?Object=} arg Argument to be normalized (nullable optional)
|
||||
* @return {!Object}
|
||||
*/
|
||||
normalizeMergeArg: function(arg) {
|
||||
return arg === undefined || arg === null ? {} : arg;
|
||||
},
|
||||
|
||||
/**
|
||||
* If merging Arrays, a merge strategy *must* be supplied. If not, it is
|
||||
* likely the caller's fault. If this function is ever called with anything
|
||||
* but `one` and `two` being `Array`s, it is the fault of the merge utilities.
|
||||
*
|
||||
* @param {*} one Array to merge into.
|
||||
* @param {*} two Array to merge from.
|
||||
*/
|
||||
checkMergeArrayArgs: function(one, two) {
|
||||
invariant(
|
||||
Array.isArray(one) && Array.isArray(two),
|
||||
'Tried to merge arrays, instead got %s and %s.',
|
||||
one,
|
||||
two
|
||||
);
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {*} one Object to merge into.
|
||||
* @param {*} two Object to merge from.
|
||||
*/
|
||||
checkMergeObjectArgs: function(one, two) {
|
||||
mergeHelpers.checkMergeObjectArg(one);
|
||||
mergeHelpers.checkMergeObjectArg(two);
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {*} arg
|
||||
*/
|
||||
checkMergeObjectArg: function(arg) {
|
||||
invariant(
|
||||
!isTerminal(arg) && !Array.isArray(arg),
|
||||
'Tried to merge an object, instead got %s.',
|
||||
arg
|
||||
);
|
||||
},
|
||||
|
||||
/**
|
||||
* @param {*} arg
|
||||
*/
|
||||
checkMergeIntoObjectArg: function(arg) {
|
||||
invariant(
|
||||
(!isTerminal(arg) || typeof arg === 'function') && !Array.isArray(arg),
|
||||
'Tried to merge into an object, instead got %s.',
|
||||
arg
|
||||
);
|
||||
},
|
||||
|
||||
/**
|
||||
* Checks that a merge was not given a circular object or an object that had
|
||||
* too great of depth.
|
||||
*
|
||||
* @param {number} Level of recursion to validate against maximum.
|
||||
*/
|
||||
checkMergeLevel: function(level) {
|
||||
invariant(
|
||||
level < MAX_MERGE_DEPTH,
|
||||
'Maximum deep merge depth exceeded. You may be attempting to merge ' +
|
||||
'circular structures in an unsupported way.'
|
||||
);
|
||||
},
|
||||
|
||||
/**
|
||||
* Checks that the supplied merge strategy is valid.
|
||||
*
|
||||
* @param {string} Array merge strategy.
|
||||
*/
|
||||
checkArrayStrategy: function(strategy) {
|
||||
invariant(
|
||||
strategy === undefined || strategy in mergeHelpers.ArrayStrategies,
|
||||
'You must provide an array strategy to deep merge functions to ' +
|
||||
'instruct the deep merge how to resolve merging two arrays.'
|
||||
);
|
||||
},
|
||||
|
||||
/**
|
||||
* Set of possible behaviors of merge algorithms when encountering two Arrays
|
||||
* that must be merged together.
|
||||
* - `clobber`: The left `Array` is ignored.
|
||||
* - `indexByIndex`: The result is achieved by recursively deep merging at
|
||||
* each index. (not yet supported.)
|
||||
*/
|
||||
ArrayStrategies: keyMirror({
|
||||
Clobber: true,
|
||||
IndexByIndex: true
|
||||
})
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* @generated SignedSource<<d3caa35be27b17ea4dd4c76bef72d1ab>>
|
||||
*
|
||||
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
|
||||
* !! 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.
|
||||
*
|
||||
* 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 mergeInto
|
||||
* @typechecks static-only
|
||||
*/
|
||||
|
||||
var checkMergeObjectArg = mergeHelpers.checkMergeObjectArg;
|
||||
var checkMergeIntoObjectArg = mergeHelpers.checkMergeIntoObjectArg;
|
||||
|
||||
/**
|
||||
* Shallow merges two structures by mutating the first parameter.
|
||||
*
|
||||
* @param {object|function} one Object to be merged into.
|
||||
* @param {?object} two Optional object with properties to merge from.
|
||||
*/
|
||||
function mergeInto(one, two) {
|
||||
checkMergeIntoObjectArg(one);
|
||||
if (two != null) {
|
||||
checkMergeObjectArg(two);
|
||||
for (var key in two) {
|
||||
if (!two.hasOwnProperty(key)) {
|
||||
continue;
|
||||
}
|
||||
one[key] = two[key];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
var merge = function(one, two) {
|
||||
var result = {};
|
||||
mergeInto(result, one);
|
||||
mergeInto(result, two);
|
||||
return result;
|
||||
};
|
||||
|
||||
module.exports = merge;
|
||||
@@ -12,7 +12,6 @@
|
||||
*/
|
||||
|
||||
import invariant from 'fbjs/lib/invariant'
|
||||
import merge from '../modules/merge'
|
||||
import ReactPropTypeLocationNames from 'react/lib/ReactPropTypeLocationNames'
|
||||
import ReactPropTypesSecret from 'react/lib/ReactPropTypesSecret'
|
||||
|
||||
@@ -43,7 +42,7 @@ function createStrictShapeTypeChecker(
|
||||
}
|
||||
// We need to check all keys in case some are required but missing from
|
||||
// props.
|
||||
var allKeys = merge(props[propName], shapeTypes);
|
||||
var allKeys = { ...props[propName], ...shapeTypes };
|
||||
for (var key in allKeys) {
|
||||
var checker = shapeTypes[key];
|
||||
if (!checker) {
|
||||
|
||||
@@ -25,7 +25,10 @@ module.exports = {
|
||||
path: DIST_DIRECTORY
|
||||
},
|
||||
plugins: [
|
||||
new BundleAnalyzerPlugin({ analyzerMode: 'static' }),
|
||||
new BundleAnalyzerPlugin({
|
||||
analyzerMode: 'static',
|
||||
openAnalyzer: false
|
||||
}),
|
||||
new webpack.DefinePlugin({ 'process.env.NODE_ENV': JSON.stringify('production') }),
|
||||
new webpack.optimize.DedupePlugin(),
|
||||
// https://github.com/animatedjs/animated/issues/40
|
||||
|
||||
20
yarn.lock
20
yarn.lock
@@ -253,7 +253,7 @@ array-equal@^1.0.0:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/array-equal/-/array-equal-1.0.0.tgz#8c2a5ef2472fd9ea742b04c77a75093ba2757c93"
|
||||
|
||||
array-find-index@^1.0.1:
|
||||
array-find-index, array-find-index@^1.0.1:
|
||||
version "1.0.2"
|
||||
resolved "https://registry.yarnpkg.com/array-find-index/-/array-find-index-1.0.2.tgz#df010aa1287e164bbda6f9723b0a96a1ec4187a1"
|
||||
|
||||
@@ -1769,6 +1769,16 @@ date-now@^0.1.4:
|
||||
version "0.1.4"
|
||||
resolved "https://registry.yarnpkg.com/date-now/-/date-now-0.1.4.tgz#eaf439fd4d4848ad74e5cc7dbef200672b9e345b"
|
||||
|
||||
date-now@1.0.1:
|
||||
version "1.0.1"
|
||||
resolved "https://registry.yarnpkg.com/date-now/-/date-now-1.0.1.tgz#bb7d086438debe4182a485fb3df3fbfb99d6153c"
|
||||
|
||||
debounce:
|
||||
version "1.0.0"
|
||||
resolved "https://registry.yarnpkg.com/debounce/-/debounce-1.0.0.tgz#0948af513d2e4ce407916f8506a423d3f9cf72d8"
|
||||
dependencies:
|
||||
date-now "1.0.1"
|
||||
|
||||
debug@^2.1.1, debug@^2.2.0:
|
||||
version "2.3.3"
|
||||
resolved "https://registry.yarnpkg.com/debug/-/debug-2.3.3.tgz#40c453e67e6e13c901ddec317af8986cda9eff8c"
|
||||
@@ -1785,6 +1795,12 @@ decamelize@^1.0.0, decamelize@^1.1.1, decamelize@^1.1.2:
|
||||
version "1.2.0"
|
||||
resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-1.2.0.tgz#f6534d15148269b20352e7bee26f501f9a191290"
|
||||
|
||||
deep-assign:
|
||||
version "2.0.0"
|
||||
resolved "https://registry.yarnpkg.com/deep-assign/-/deep-assign-2.0.0.tgz#ebe06b1f07f08dae597620e3dd1622f371a1c572"
|
||||
dependencies:
|
||||
is-obj "^1.0.0"
|
||||
|
||||
deep-equal@^1.0.1:
|
||||
version "1.0.1"
|
||||
resolved "https://registry.yarnpkg.com/deep-equal/-/deep-equal-1.0.1.tgz#f5d260292b660e084eff4cdbc9f08ad3247448b5"
|
||||
@@ -3659,7 +3675,7 @@ lodash.words@^3.0.0:
|
||||
dependencies:
|
||||
lodash._root "^3.0.0"
|
||||
|
||||
lodash@^4.0.0, lodash@^4.15.0, lodash@^4.16.4, lodash@^4.2.0, lodash@^4.2.1, lodash@^4.3.0, lodash@^4.6.1, lodash@4.x.x:
|
||||
lodash@^4.0.0, lodash@^4.16.4, lodash@^4.2.0, lodash@^4.2.1, lodash@^4.3.0, lodash@^4.6.1, lodash@4.x.x:
|
||||
version "4.17.2"
|
||||
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.2.tgz#34a3055babe04ce42467b607d700072c7ff6bf42"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user