Add files

This commit is contained in:
DoomRye 2022-07-26 10:06:20 -07:00
commit bb80829159
18195 changed files with 2122994 additions and 0 deletions

View file

@ -0,0 +1,30 @@
/**
* 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
*/
'use strict';
// Note(vjeux): this would be better as an interface but flow doesn't
// support them yet
class Animated {
__attach(): void {}
__detach(): void {}
__getValue(): any {}
__getAnimatedValue(): any { return this.__getValue(); }
__addChild(child: Animated) {}
__removeChild(child: Animated) {}
__getChildren(): Array<Animated> { return []; }
}
module.exports = Animated;
// WEBPACK FOOTER //
// ./~/animated/src/Animated.js

View file

@ -0,0 +1,83 @@
/**
* 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
*/
'use strict';
var AnimatedWithChildren = require('./AnimatedWithChildren');
var Animated = require('./Animated');
var AnimatedValue = require('./AnimatedValue');
var Interpolation = require('./Interpolation');
var AnimatedInterpolation = require('./AnimatedInterpolation');
import type { InterpolationConfigType } from './Interpolation';
class AnimatedAddition extends AnimatedWithChildren {
_a: Animated;
_b: Animated;
_aListener: number;
_bListener: number;
_listeners: {[key: number]: ValueListenerCallback};
constructor(a: Animated | number, b: Animated | number) {
super();
this._a = typeof a === 'number' ? new AnimatedValue(a) : a;
this._b = typeof b === 'number' ? new AnimatedValue(b) : b;
this._listeners = {};
}
__getValue(): number {
return this._a.__getValue() + this._b.__getValue();
}
addListener(callback: ValueListenerCallback): string {
if (!this._aListener && this._a.addListener) {
this._aListener = this._a.addListener(() => {
for (var key in this._listeners) {
this._listeners[key]({value: this.__getValue()});
}
})
}
if (!this._bListener && this._b.addListener) {
this._bListener = this._b.addListener(() => {
for (var key in this._listeners) {
this._listeners[key]({value: this.__getValue()});
}
})
}
var id = guid();
this._listeners[id] = callback;
return id;
}
removeListener(id: string): void {
delete this._listeners[id];
}
interpolate(config: InterpolationConfigType): AnimatedInterpolation {
return new AnimatedInterpolation(this, Interpolation.create(config));
}
__attach(): void {
this._a.__addChild(this);
this._b.__addChild(this);
}
__detach(): void {
this._a.__removeChild(this);
this._b.__removeChild(this);
}
}
module.exports = AnimatedAddition;
// WEBPACK FOOTER //
// ./~/animated/src/AnimatedAddition.js

View file

@ -0,0 +1,79 @@
/**
* 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
*/
'use strict';
var Animated = require('./Animated');
var AnimatedWithChildren = require('./AnimatedWithChildren');
var invariant = require('invariant');
var Interpolation = require('./Interpolation');
var guid = require('./guid');
import type { ValueListenerCallback } from './AnimatedValue';
class AnimatedInterpolation extends AnimatedWithChildren {
_parent: Animated;
_interpolation: (input: number) => number | string;
_listeners: {[key: number]: ValueListenerCallback};
_parentListener: number;
constructor(parent: Animated, interpolation: (input: number) => number | string) {
super();
this._parent = parent;
this._interpolation = interpolation;
this._listeners = {};
}
__getValue(): number | string {
var parentValue: number = this._parent.__getValue();
invariant(
typeof parentValue === 'number',
'Cannot interpolate an input which is not a number.'
);
return this._interpolation(parentValue);
}
addListener(callback: ValueListenerCallback): string {
if (!this._parentListener) {
this._parentListener = this._parent.addListener(() => {
for (var key in this._listeners) {
this._listeners[key]({value: this.__getValue()});
}
})
}
var id = guid();
this._listeners[id] = callback;
return id;
}
removeListener(id: string): void {
delete this._listeners[id];
}
interpolate(config: InterpolationConfigType): AnimatedInterpolation {
return new AnimatedInterpolation(this, Interpolation.create(config));
}
__attach(): void {
this._parent.__addChild(this);
}
__detach(): void {
this._parent.__removeChild(this);
this._parentListener = this._parent.removeListener(this._parentListener);
}
}
module.exports = AnimatedInterpolation;
// WEBPACK FOOTER //
// ./~/animated/src/AnimatedInterpolation.js

View file

@ -0,0 +1,72 @@
/**
* 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
*/
'use strict';
var Animated = require('./Animated');
var AnimatedWithChildren = require('./AnimatedWithChildren');
var AnimatedInterpolation = require('./AnimatedInterpolation');
var Interpolation = require('./Interpolation');
import type { InterpolationConfigType } from './Interpolation';
class AnimatedModulo extends AnimatedWithChildren {
_a: Animated;
_modulus: number; // TODO(lmr): Make modulus able to be an animated value
_aListener: number;
_listeners: {[key: number]: ValueListenerCallback};
constructor(a: Animated, modulus: number) {
super();
this._a = a;
this._modulus = modulus;
this._listeners = {};
}
__getValue(): number {
return (this._a.__getValue() % this._modulus + this._modulus) % this._modulus;
}
addListener(callback: ValueListenerCallback): string {
if (!this._aListener) {
this._aListener = this._a.addListener(() => {
for (var key in this._listeners) {
this._listeners[key]({value: this.__getValue()});
}
})
}
var id = guid();
this._listeners[id] = callback;
return id;
}
removeListener(id: string): void {
delete this._listeners[id];
}
interpolate(config: InterpolationConfigType): AnimatedInterpolation {
return new AnimatedInterpolation(this, Interpolation.create(config));
}
__attach(): void {
this._a.__addChild(this);
}
__detach(): void {
this._a.__removeChild(this);
}
}
module.exports = AnimatedModulo;
// WEBPACK FOOTER //
// ./~/animated/src/AnimatedModulo.js

View file

@ -0,0 +1,83 @@
/**
* 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
*/
'use strict';
var AnimatedWithChildren = require('./AnimatedWithChildren');
var Animated = require('./Animated');
var AnimatedValue = require('./AnimatedValue');
var AnimatedInterpolation = require('./AnimatedInterpolation');
var Interpolation = require('./Interpolation');
import type { InterpolationConfigType } from './Interpolation';
class AnimatedMultiplication extends AnimatedWithChildren {
_a: Animated;
_b: Animated;
_aListener: number;
_bListener: number;
_listeners: {[key: number]: ValueListenerCallback};
constructor(a: Animated | number, b: Animated | number) {
super();
this._a = typeof a === 'number' ? new AnimatedValue(a) : a;
this._b = typeof b === 'number' ? new AnimatedValue(b) : b;
this._listeners = {};
}
__getValue(): number {
return this._a.__getValue() * this._b.__getValue();
}
addListener(callback: ValueListenerCallback): string {
if (!this._aListener && this._a.addListener) {
this._aListener = this._a.addListener(() => {
for (var key in this._listeners) {
this._listeners[key]({value: this.__getValue()});
}
})
}
if (!this._bListener && this._b.addListener) {
this._bListener = this._b.addListener(() => {
for (var key in this._listeners) {
this._listeners[key]({value: this.__getValue()});
}
})
}
var id = guid();
this._listeners[id] = callback;
return id;
}
removeListener(id: string): void {
delete this._listeners[id];
}
interpolate(config: InterpolationConfigType): AnimatedInterpolation {
return new AnimatedInterpolation(this, Interpolation.create(config));
}
__attach(): void {
this._a.__addChild(this);
this._b.__addChild(this);
}
__detach(): void {
this._a.__removeChild(this);
this._b.__removeChild(this);
}
}
module.exports = AnimatedMultiplication;
// WEBPACK FOOTER //
// ./~/animated/src/AnimatedMultiplication.js

View file

@ -0,0 +1,88 @@
/**
* 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
*/
'use strict';
var Animated = require('./Animated');
var AnimatedStyle = require('./AnimatedStyle');
class AnimatedProps extends Animated {
_props: Object;
_callback: () => void;
constructor(
props: Object,
callback: () => void,
) {
super();
if (props.style) {
props = {
...props,
style: new AnimatedStyle(props.style),
};
}
this._props = props;
this._callback = callback;
this.__attach();
}
__getValue(): Object {
var props = {};
for (var key in this._props) {
var value = this._props[key];
if (value instanceof Animated) {
props[key] = value.__getValue();
} else {
props[key] = value;
}
}
return props;
}
__getAnimatedValue(): Object {
var props = {};
for (var key in this._props) {
var value = this._props[key];
if (value instanceof Animated) {
props[key] = value.__getAnimatedValue();
}
}
return props;
}
__attach(): void {
for (var key in this._props) {
var value = this._props[key];
if (value instanceof Animated) {
value.__addChild(this);
}
}
}
__detach(): void {
for (var key in this._props) {
var value = this._props[key];
if (value instanceof Animated) {
value.__removeChild(this);
}
}
}
update(): void {
this._callback();
}
}
module.exports = AnimatedProps;
// WEBPACK FOOTER //
// ./~/animated/src/AnimatedProps.js

View file

@ -0,0 +1,81 @@
/**
* 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
*/
'use strict';
var Animated = require('./Animated');
var AnimatedWithChildren = require('./AnimatedWithChildren');
var AnimatedTransform = require('./AnimatedTransform');
var FlattenStyle = require('./injectable/FlattenStyle');
class AnimatedStyle extends AnimatedWithChildren {
_style: Object;
constructor(style: any) {
super();
style = FlattenStyle.current(style) || {};
if (style.transform && !(style.transform instanceof Animated)) {
style = {
...style,
transform: new AnimatedTransform(style.transform),
};
}
this._style = style;
}
__getValue(): Object {
var style = {};
for (var key in this._style) {
var value = this._style[key];
if (value instanceof Animated) {
style[key] = value.__getValue();
} else {
style[key] = value;
}
}
return style;
}
__getAnimatedValue(): Object {
var style = {};
for (var key in this._style) {
var value = this._style[key];
if (value instanceof Animated) {
style[key] = value.__getAnimatedValue();
}
}
return style;
}
__attach(): void {
for (var key in this._style) {
var value = this._style[key];
if (value instanceof Animated) {
value.__addChild(this);
}
}
}
__detach(): void {
for (var key in this._style) {
var value = this._style[key];
if (value instanceof Animated) {
value.__removeChild(this);
}
}
}
}
module.exports = AnimatedStyle;
// WEBPACK FOOTER //
// ./~/animated/src/AnimatedStyle.js

View file

@ -0,0 +1,64 @@
/**
* 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
*/
'use strict';
var Animated = require('./Animated');
var AnimatedWithChildren = require('./AnimatedWithChildren');
class AnimatedTemplate extends AnimatedWithChildren {
_strings: Array<string>;
_values: Array;
constructor(strings, values) {
super();
this._strings = strings;
this._values = values;
}
__transformValue(value): any {
if (value instanceof Animated) {
return value.__getValue();
} else {
return value;
}
}
__getValue(): String {
var value = this._strings[0];
for (var i = 0; i < this._values.length; ++i) {
value += this.__transformValue(this._values[i]) + this._strings[1 + i];
}
return value;
}
__attach(): void {
for (var i = 0; i < this._values.length; ++i) {
if (this._values[i] instanceof Animated) {
this._values[i].__addChild(this);
}
}
}
__detach(): void {
for (var i = 0; i < this._values.length; ++i) {
if (this._values[i] instanceof Animated) {
this._values[i].__removeChild(this);
}
}
}
}
module.exports = AnimatedTemplate;
// WEBPACK FOOTER //
// ./~/animated/src/AnimatedTemplate.js

View file

@ -0,0 +1,66 @@
/**
* 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
*/
'use strict';
var Animated = require('./Animated');
var AnimatedValue = require('./AnimatedValue');
import type { EndCallback } from './Animated';
class AnimatedTracking extends Animated {
_value: AnimatedValue;
_parent: Animated;
_callback: ?EndCallback;
_animationConfig: Object;
_animationClass: any;
constructor(
value: AnimatedValue,
parent: Animated,
animationClass: any,
animationConfig: Object,
callback?: ?EndCallback,
) {
super();
this._value = value;
this._parent = parent;
this._animationClass = animationClass;
this._animationConfig = animationConfig;
this._callback = callback;
this.__attach();
}
__getValue(): Object {
return this._parent.__getValue();
}
__attach(): void {
this._parent.__addChild(this);
}
__detach(): void {
this._parent.__removeChild(this);
}
update(): void {
this._value.animate(new this._animationClass({
...this._animationConfig,
toValue: (this._animationConfig.toValue: any).__getValue(),
}), this._callback);
}
}
module.exports = AnimatedTracking;
// WEBPACK FOOTER //
// ./~/animated/src/AnimatedTracking.js

View file

@ -0,0 +1,83 @@
/**
* 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
*/
'use strict';
var Animated = require('./Animated');
var AnimatedWithChildren = require('./AnimatedWithChildren');
class AnimatedTransform extends AnimatedWithChildren {
_transforms: Array<Object>;
constructor(transforms: Array<Object>) {
super();
this._transforms = transforms;
}
__getValue(): Array<Object> {
return this._transforms.map(transform => {
var result = {};
for (var key in transform) {
var value = transform[key];
if (value instanceof Animated) {
result[key] = value.__getValue();
} else {
result[key] = value;
}
}
return result;
});
}
__getAnimatedValue(): Array<Object> {
return this._transforms.map(transform => {
var result = {};
for (var key in transform) {
var value = transform[key];
if (value instanceof Animated) {
result[key] = value.__getAnimatedValue();
} else {
// All transform components needed to recompose matrix
result[key] = value;
}
}
return result;
});
}
__attach(): void {
this._transforms.forEach(transform => {
for (var key in transform) {
var value = transform[key];
if (value instanceof Animated) {
value.__addChild(this);
}
}
});
}
__detach(): void {
this._transforms.forEach(transform => {
for (var key in transform) {
var value = transform[key];
if (value instanceof Animated) {
value.__removeChild(this);
}
}
});
}
}
module.exports = AnimatedTransform;
// WEBPACK FOOTER //
// ./~/animated/src/AnimatedTransform.js

View file

@ -0,0 +1,217 @@
/**
* 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
*/
'use strict';
var AnimatedWithChildren = require('./AnimatedWithChildren');
var InteractionManager = require('./injectable/InteractionManager');
var AnimatedInterpolation = require('./AnimatedInterpolation');
var Interpolation = require('./Interpolation');
var Animation = require('./Animation');
var guid = require('./guid');
var Set = global.Set || require('./SetPolyfill');
import type { EndCallback } from './Animation';
import type { InterpolationConfigType } from './Interpolation';
export type ValueListenerCallback = (state: {value: number}) => void;
/**
* Animated works by building a directed acyclic graph of dependencies
* transparently when you render your Animated components.
*
* new Animated.Value(0)
* .interpolate() .interpolate() new Animated.Value(1)
* opacity translateY scale
* style transform
* View#234 style
* View#123
*
* A) Top Down phase
* When an Animated.Value is updated, we recursively go down through this
* graph in order to find leaf nodes: the views that we flag as needing
* an update.
*
* B) Bottom Up phase
* When a view is flagged as needing an update, we recursively go back up
* in order to build the new value that it needs. The reason why we need
* this two-phases process is to deal with composite props such as
* transform which can receive values from multiple parents.
*/
function _flush(rootNode: AnimatedValue): void {
var animatedStyles = new Set();
function findAnimatedStyles(node) {
if (typeof node.update === 'function') {
animatedStyles.add(node);
} else {
node.__getChildren().forEach(findAnimatedStyles);
}
}
findAnimatedStyles(rootNode);
animatedStyles.forEach(animatedStyle => animatedStyle.update());
}
/**
* Standard value for driving animations. One `Animated.Value` can drive
* multiple properties in a synchronized fashion, but can only be driven by one
* mechanism at a time. Using a new mechanism (e.g. starting a new animation,
* or calling `setValue`) will stop any previous ones.
*/
class AnimatedValue extends AnimatedWithChildren {
_value: number;
_offset: number;
_animation: ?Animation;
_tracking: ?Animated;
_listeners: {[key: string]: ValueListenerCallback};
constructor(value: number) {
super();
this._value = value;
this._offset = 0;
this._animation = null;
this._listeners = {};
}
__detach() {
this.stopAnimation();
}
__getValue(): number {
return this._value + this._offset;
}
/**
* Directly set the value. This will stop any animations running on the value
* and update all the bound properties.
*/
setValue(value: number): void {
if (this._animation) {
this._animation.stop();
this._animation = null;
}
this._updateValue(value);
}
/**
* Sets an offset that is applied on top of whatever value is set, whether via
* `setValue`, an animation, or `Animated.event`. Useful for compensating
* things like the start of a pan gesture.
*/
setOffset(offset: number): void {
this._offset = offset;
}
/**
* Merges the offset value into the base value and resets the offset to zero.
* The final output of the value is unchanged.
*/
flattenOffset(): void {
this._value += this._offset;
this._offset = 0;
}
/**
* Adds an asynchronous listener to the value so you can observe updates from
* animations. This is useful because there is no way to
* synchronously read the value because it might be driven natively.
*/
addListener(callback: ValueListenerCallback): string {
var id = guid();
this._listeners[id] = callback;
return id;
}
removeListener(id: string): void {
delete this._listeners[id];
}
removeAllListeners(): void {
this._listeners = {};
}
/**
* Stops any running animation or tracking. `callback` is invoked with the
* final value after stopping the animation, which is useful for updating
* state to match the animation position with layout.
*/
stopAnimation(callback?: ?(value: number) => void): void {
this.stopTracking();
this._animation && this._animation.stop();
this._animation = null;
callback && callback(this.__getValue());
}
/**
* Interpolates the value before updating the property, e.g. mapping 0-1 to
* 0-10.
*/
interpolate(config: InterpolationConfigType): AnimatedInterpolation {
return new AnimatedInterpolation(this, Interpolation.create(config));
}
/**
* Typically only used internally, but could be used by a custom Animation
* class.
*/
animate(animation: Animation, callback: ?EndCallback): void {
var handle = null;
if (animation.__isInteraction) {
handle = InteractionManager.current.createInteractionHandle();
}
var previousAnimation = this._animation;
this._animation && this._animation.stop();
this._animation = animation;
animation.start(
this._value,
(value) => {
this._updateValue(value);
},
(result) => {
this._animation = null;
if (handle !== null) {
InteractionManager.current.clearInteractionHandle(handle);
}
callback && callback(result);
},
previousAnimation,
);
}
/**
* Typically only used internally.
*/
stopTracking(): void {
this._tracking && this._tracking.__detach();
this._tracking = null;
}
/**
* Typically only used internally.
*/
track(tracking: Animated): void {
this.stopTracking();
this._tracking = tracking;
}
_updateValue(value: number): void {
this._value = value;
_flush(this);
for (var key in this._listeners) {
this._listeners[key]({value: this.__getValue()});
}
}
}
module.exports = AnimatedValue;
// WEBPACK FOOTER //
// ./~/animated/src/AnimatedValue.js

View file

@ -0,0 +1,165 @@
/**
* 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
*/
'use strict';
var Animated = require('./Animated');
var AnimatedValue = require('./AnimatedValue');
var AnimatedWithChildren = require('./AnimatedWithChildren');
var invariant = require('invariant');
var guid = require('./guid');
type ValueXYListenerCallback = (value: {x: number; y: number}) => void;
/**
* 2D Value for driving 2D animations, such as pan gestures. Almost identical
* API to normal `Animated.Value`, but multiplexed. Contains two regular
* `Animated.Value`s under the hood. Example:
*
*```javascript
* class DraggableView extends React.Component {
* constructor(props) {
* super(props);
* this.state = {
* pan: new Animated.ValueXY(), // inits to zero
* };
* this.state.panResponder = PanResponder.create({
* onStartShouldSetPanResponder: () => true,
* onPanResponderMove: Animated.event([null, {
* dx: this.state.pan.x, // x,y are Animated.Value
* dy: this.state.pan.y,
* }]),
* onPanResponderRelease: () => {
* Animated.spring(
* this.state.pan, // Auto-multiplexed
* {toValue: {x: 0, y: 0}} // Back to zero
* ).start();
* },
* });
* }
* render() {
* return (
* <Animated.View
* {...this.state.panResponder.panHandlers}
* style={this.state.pan.getLayout()}>
* {this.props.children}
* </Animated.View>
* );
* }
* }
*```
*/
class AnimatedValueXY extends AnimatedWithChildren {
x: AnimatedValue;
y: AnimatedValue;
_listeners: {[key: string]: {x: string; y: string}};
constructor(valueIn?: ?{x: number | AnimatedValue; y: number | AnimatedValue}) {
super();
var value: any = valueIn || {x: 0, y: 0}; // @flowfixme: shouldn't need `: any`
if (typeof value.x === 'number' && typeof value.y === 'number') {
this.x = new AnimatedValue(value.x);
this.y = new AnimatedValue(value.y);
} else {
invariant(
value.x instanceof AnimatedValue &&
value.y instanceof AnimatedValue,
'AnimatedValueXY must be initalized with an object of numbers or ' +
'AnimatedValues.'
);
this.x = value.x;
this.y = value.y;
}
this._listeners = {};
}
setValue(value: {x: number; y: number}) {
this.x.setValue(value.x);
this.y.setValue(value.y);
}
setOffset(offset: {x: number; y: number}) {
this.x.setOffset(offset.x);
this.y.setOffset(offset.y);
}
flattenOffset(): void {
this.x.flattenOffset();
this.y.flattenOffset();
}
__getValue(): {x: number; y: number} {
return {
x: this.x.__getValue(),
y: this.y.__getValue(),
};
}
stopAnimation(callback?: ?() => number): void {
this.x.stopAnimation();
this.y.stopAnimation();
callback && callback(this.__getValue());
}
addListener(callback: ValueXYListenerCallback): string {
var id = guid();
var jointCallback = ({value: number}) => {
callback(this.__getValue());
};
this._listeners[id] = {
x: this.x.addListener(jointCallback),
y: this.y.addListener(jointCallback),
};
return id;
}
removeListener(id: string): void {
this.x.removeListener(this._listeners[id].x);
this.y.removeListener(this._listeners[id].y);
delete this._listeners[id];
}
/**
* Converts `{x, y}` into `{left, top}` for use in style, e.g.
*
*```javascript
* style={this.state.anim.getLayout()}
*```
*/
getLayout(): {[key: string]: AnimatedValue} {
return {
left: this.x,
top: this.y,
};
}
/**
* Converts `{x, y}` into a useable translation transform, e.g.
*
*```javascript
* style={{
* transform: this.state.anim.getTranslateTransform()
* }}
*```
*/
getTranslateTransform(): Array<{[key: string]: AnimatedValue}> {
return [
{translateX: this.x},
{translateY: this.y}
];
}
}
module.exports = AnimatedValueXY;
// WEBPACK FOOTER //
// ./~/animated/src/AnimatedValueXY.js

View file

@ -0,0 +1,52 @@
/**
* 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
*/
'use strict';
var Animated = require('./Animated');
class AnimatedWithChildren extends Animated {
_children: Array<Animated>;
constructor() {
super();
this._children = [];
}
__addChild(child: Animated): void {
if (this._children.length === 0) {
this.__attach();
}
this._children.push(child);
}
__removeChild(child: Animated): void {
var index = this._children.indexOf(child);
if (index === -1) {
console.warn('Trying to remove a child that doesn\'t exist');
return;
}
this._children.splice(index, 1);
if (this._children.length === 0) {
this.__detach();
}
}
__getChildren(): Array<Animated> {
return this._children;
}
}
module.exports = AnimatedWithChildren;
// WEBPACK FOOTER //
// ./~/animated/src/AnimatedWithChildren.js

View file

@ -0,0 +1,46 @@
/**
* 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
*/
'use strict';
export type EndResult = {finished: bool};
export type EndCallback = (result: EndResult) => void;
export type AnimationConfig = {
isInteraction?: bool;
};
// Important note: start() and stop() will only be called at most once.
// Once an animation has been stopped or finished its course, it will
// not be reused.
class Animation {
__active: bool;
__isInteraction: bool;
__onEnd: ?EndCallback;
start(
fromValue: number,
onUpdate: (value: number) => void,
onEnd: ?EndCallback,
previousAnimation: ?Animation,
): void {}
stop(): void {}
// Helper function for subclasses to make sure onEnd is only called once.
__debouncedOnEnd(result: EndResult) {
var onEnd = this.__onEnd;
this.__onEnd = null;
onEnd && onEnd(result);
}
}
module.exports = Animation;
// WEBPACK FOOTER //
// ./~/animated/src/Animation.js

View file

@ -0,0 +1,88 @@
/**
* 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
*/
'use strict';
var Animation = require('./Animation');
var RequestAnimationFrame = require('./injectable/RequestAnimationFrame');
var CancelAnimationFrame = require('./injectable/CancelAnimationFrame');
import type { AnimationConfig, EndCallback } from './Animation';
type DecayAnimationConfigSingle = AnimationConfig & {
velocity: number;
deceleration?: number;
};
class DecayAnimation extends Animation {
_startTime: number;
_lastValue: number;
_fromValue: number;
_deceleration: number;
_velocity: number;
_onUpdate: (value: number) => void;
_animationFrame: any;
constructor(
config: DecayAnimationConfigSingle,
) {
super();
this._deceleration = config.deceleration !== undefined ? config.deceleration : 0.998;
this._velocity = config.velocity;
this.__isInteraction = config.isInteraction !== undefined ? config.isInteraction : true;
}
start(
fromValue: number,
onUpdate: (value: number) => void,
onEnd: ?EndCallback,
): void {
this.__active = true;
this._lastValue = fromValue;
this._fromValue = fromValue;
this._onUpdate = onUpdate;
this.__onEnd = onEnd;
this._startTime = Date.now();
this._animationFrame = RequestAnimationFrame.current(this.onUpdate.bind(this));
}
onUpdate(): void {
var now = Date.now();
var value = this._fromValue +
(this._velocity / (1 - this._deceleration)) *
(1 - Math.exp(-(1 - this._deceleration) * (now - this._startTime)));
this._onUpdate(value);
if (Math.abs(this._lastValue - value) < 0.1) {
this.__debouncedOnEnd({finished: true});
return;
}
this._lastValue = value;
if (this.__active) {
this._animationFrame = RequestAnimationFrame.current(this.onUpdate.bind(this));
}
}
stop(): void {
this.__active = false;
CancelAnimationFrame.current(this._animationFrame);
this.__debouncedOnEnd({finished: false});
}
}
module.exports = DecayAnimation;
// WEBPACK FOOTER //
// ./~/animated/src/DecayAnimation.js

View file

@ -0,0 +1,150 @@
/**
* 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
*/
'use strict';
var _bezier = require('./bezier');
/**
* This class implements common easing functions. The math is pretty obscure,
* but this cool website has nice visual illustrations of what they represent:
* http://xaedes.de/dev/transitions/
*/
class Easing {
static step0(n) {
return n > 0 ? 1 : 0;
}
static step1(n) {
return n >= 1 ? 1 : 0;
}
static linear(t) {
return t;
}
static ease(t: number): number {
return ease(t);
}
static quad(t) {
return t * t;
}
static cubic(t) {
return t * t * t;
}
static poly(n) {
return (t) => Math.pow(t, n);
}
static sin(t) {
return 1 - Math.cos(t * Math.PI / 2);
}
static circle(t) {
return 1 - Math.sqrt(1 - t * t);
}
static exp(t) {
return Math.pow(2, 10 * (t - 1));
}
/**
* A simple elastic interaction, similar to a spring. Default bounciness
* is 1, which overshoots a little bit once. 0 bounciness doesn't overshoot
* at all, and bounciness of N > 1 will overshoot about N times.
*
* Wolfram Plots:
*
* http://tiny.cc/elastic_b_1 (default bounciness = 1)
* http://tiny.cc/elastic_b_3 (bounciness = 3)
*/
static elastic(bounciness: number = 1): (t: number) => number {
var p = bounciness * Math.PI;
return (t) => 1 - Math.pow(Math.cos(t * Math.PI / 2), 3) * Math.cos(t * p);
}
static back(s: number): (t: number) => number {
if (s === undefined) {
s = 1.70158;
}
return (t) => t * t * ((s + 1) * t - s);
}
static bounce(t: number): number {
if (t < 1 / 2.75) {
return 7.5625 * t * t;
}
if (t < 2 / 2.75) {
t -= 1.5 / 2.75;
return 7.5625 * t * t + 0.75;
}
if (t < 2.5 / 2.75) {
t -= 2.25 / 2.75;
return 7.5625 * t * t + 0.9375;
}
t -= 2.625 / 2.75;
return 7.5625 * t * t + 0.984375;
}
static bezier(
x1: number,
y1: number,
x2: number,
y2: number
): (t: number) => number {
return _bezier(x1, y1, x2, y2);
}
static in(
easing: (t: number) => number,
): (t: number) => number {
return easing;
}
/**
* Runs an easing function backwards.
*/
static out(
easing: (t: number) => number,
): (t: number) => number {
return (t) => 1 - easing(1 - t);
}
/**
* Makes any easing function symmetrical.
*/
static inOut(
easing: (t: number) => number,
): (t: number) => number {
return (t) => {
if (t < 0.5) {
return easing(t * 2) / 2;
}
return 1 - easing((1 - t) * 2) / 2;
};
}
}
var ease = Easing.bezier(0.42, 0, 1, 1);
module.exports = Easing;
// WEBPACK FOOTER //
// ./~/animated/src/Easing.js

View file

@ -0,0 +1,295 @@
/**
* 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
*/
/* eslint no-bitwise: 0 */
'use strict';
var normalizeColor = require('normalize-css-color');
var invariant = require('invariant');
type ExtrapolateType = 'extend' | 'identity' | 'clamp';
export type InterpolationConfigType = {
inputRange: Array<number>;
outputRange: (Array<number> | Array<string>);
easing?: ((input: number) => number);
extrapolate?: ExtrapolateType;
extrapolateLeft?: ExtrapolateType;
extrapolateRight?: ExtrapolateType;
};
var linear = (t) => t;
/**
* Very handy helper to map input ranges to output ranges with an easing
* function and custom behavior outside of the ranges.
*/
class Interpolation {
static create(config: InterpolationConfigType): (input: number) => number | string {
if (config.outputRange && typeof config.outputRange[0] === 'string') {
return createInterpolationFromStringOutputRange(config);
}
var outputRange: Array<number> = (config.outputRange: any);
checkInfiniteRange('outputRange', outputRange);
var inputRange = config.inputRange;
checkInfiniteRange('inputRange', inputRange);
checkValidInputRange(inputRange);
invariant(
inputRange.length === outputRange.length,
'inputRange (' + inputRange.length + ') and outputRange (' +
outputRange.length + ') must have the same length'
);
var easing = config.easing || linear;
var extrapolateLeft: ExtrapolateType = 'extend';
if (config.extrapolateLeft !== undefined) {
extrapolateLeft = config.extrapolateLeft;
} else if (config.extrapolate !== undefined) {
extrapolateLeft = config.extrapolate;
}
var extrapolateRight: ExtrapolateType = 'extend';
if (config.extrapolateRight !== undefined) {
extrapolateRight = config.extrapolateRight;
} else if (config.extrapolate !== undefined) {
extrapolateRight = config.extrapolate;
}
return (input) => {
invariant(
typeof input === 'number',
'Cannot interpolation an input which is not a number'
);
var range = findRange(input, inputRange);
return interpolate(
input,
inputRange[range],
inputRange[range + 1],
outputRange[range],
outputRange[range + 1],
easing,
extrapolateLeft,
extrapolateRight,
);
};
}
}
function interpolate(
input: number,
inputMin: number,
inputMax: number,
outputMin: number,
outputMax: number,
easing: ((input: number) => number),
extrapolateLeft: ExtrapolateType,
extrapolateRight: ExtrapolateType,
) {
var result = input;
// Extrapolate
if (result < inputMin) {
if (extrapolateLeft === 'identity') {
return result;
} else if (extrapolateLeft === 'clamp') {
result = inputMin;
} else if (extrapolateLeft === 'extend') {
// noop
}
}
if (result > inputMax) {
if (extrapolateRight === 'identity') {
return result;
} else if (extrapolateRight === 'clamp') {
result = inputMax;
} else if (extrapolateRight === 'extend') {
// noop
}
}
if (outputMin === outputMax) {
return outputMin;
}
if (inputMin === inputMax) {
if (input <= inputMin) {
return outputMin;
}
return outputMax;
}
// Input Range
if (inputMin === -Infinity) {
result = -result;
} else if (inputMax === Infinity) {
result = result - inputMin;
} else {
result = (result - inputMin) / (inputMax - inputMin);
}
// Easing
result = easing(result);
// Output Range
if (outputMin === -Infinity) {
result = -result;
} else if (outputMax === Infinity) {
result = result + outputMin;
} else {
result = result * (outputMax - outputMin) + outputMin;
}
return result;
}
function colorToRgba(input: string): string {
var int32Color = normalizeColor(input);
if (int32Color === null) {
return input;
}
int32Color = int32Color || 0; // $FlowIssue
var r = (int32Color & 0xff000000) >>> 24;
var g = (int32Color & 0x00ff0000) >>> 16;
var b = (int32Color & 0x0000ff00) >>> 8;
var a = (int32Color & 0x000000ff) / 255;
return `rgba(${r}, ${g}, ${b}, ${a})`;
}
var stringShapeRegex = /[0-9\.-]+/g;
/**
* Supports string shapes by extracting numbers so new values can be computed,
* and recombines those values into new strings of the same shape. Supports
* things like:
*
* rgba(123, 42, 99, 0.36) // colors
* -45deg // values with units
*/
function createInterpolationFromStringOutputRange(
config: InterpolationConfigType,
): (input: number) => string {
var outputRange: Array<string> = (config.outputRange: any);
invariant(outputRange.length >= 2, 'Bad output range');
outputRange = outputRange.map(colorToRgba);
checkPattern(outputRange);
// ['rgba(0, 100, 200, 0)', 'rgba(50, 150, 250, 0.5)']
// ->
// [
// [0, 50],
// [100, 150],
// [200, 250],
// [0, 0.5],
// ]
/* $FlowFixMe(>=0.18.0): `outputRange[0].match()` can return `null`. Need to
* guard against this possibility.
*/
var outputRanges = outputRange[0].match(stringShapeRegex).map(() => []);
outputRange.forEach(value => {
/* $FlowFixMe(>=0.18.0): `value.match()` can return `null`. Need to guard
* against this possibility.
*/
value.match(stringShapeRegex).forEach((number, i) => {
outputRanges[i].push(+number);
});
});
/* $FlowFixMe(>=0.18.0): `outputRange[0].match()` can return `null`. Need to
* guard against this possibility.
*/
var interpolations = outputRange[0].match(stringShapeRegex).map((value, i) => {
return Interpolation.create({
...config,
outputRange: outputRanges[i],
});
});
// rgba requires that the r,g,b are integers.... so we want to round them, but we *dont* want to
// round the opacity (4th column).
const shouldRound = (/^rgb/).test(outputRange[0]);
return (input) => {
var i = 0;
// 'rgba(0, 100, 200, 0)'
// ->
// 'rgba(${interpolations[0](input)}, ${interpolations[1](input)}, ...'
return outputRange[0].replace(stringShapeRegex, () => {
const val = interpolations[i++](input);
return String(shouldRound && i < 4 ? Math.round(val) : val);
});
};
}
function checkPattern(arr: Array<string>) {
var pattern = arr[0].replace(stringShapeRegex, '');
for (var i = 1; i < arr.length; ++i) {
invariant(
pattern === arr[i].replace(stringShapeRegex, ''),
'invalid pattern ' + arr[0] + ' and ' + arr[i],
);
}
}
function findRange(input: number, inputRange: Array<number>) {
for (var i = 1; i < inputRange.length - 1; ++i) {
if (inputRange[i] >= input) {
break;
}
}
return i - 1;
}
function checkValidInputRange(arr: Array<number>) {
invariant(arr.length >= 2, 'inputRange must have at least 2 elements');
for (var i = 1; i < arr.length; ++i) {
invariant(
arr[i] >= arr[i - 1],
/* $FlowFixMe(>=0.13.0) - In the addition expression below this comment,
* one or both of the operands may be something that doesn't cleanly
* convert to a string, like undefined, null, and object, etc. If you really
* mean this implicit string conversion, you can do something like
* String(myThing)
*/
'inputRange must be monotonically increasing ' + arr
);
}
}
function checkInfiniteRange(name: string, arr: Array<number>) {
invariant(arr.length >= 2, name + ' must have at least 2 elements');
invariant(
arr.length !== 2 || arr[0] !== -Infinity || arr[1] !== Infinity,
/* $FlowFixMe(>=0.13.0) - In the addition expression below this comment,
* one or both of the operands may be something that doesn't cleanly convert
* to a string, like undefined, null, and object, etc. If you really mean
* this implicit string conversion, you can do something like
* String(myThing)
*/
name + 'cannot be ]-infinity;+infinity[ ' + arr
);
}
module.exports = Interpolation;
// WEBPACK FOOTER //
// ./~/animated/src/Interpolation.js

View file

@ -0,0 +1,31 @@
/**
* 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';
function SetPolyfill() {
this._cache = [];
}
SetPolyfill.prototype.add = function(e) {
if (this._cache.indexOf(e) === -1) {
this._cache.push(e);
}
};
SetPolyfill.prototype.forEach = function(cb) {
this._cache.forEach(cb);
};
module.exports = SetPolyfill;
// WEBPACK FOOTER //
// ./~/animated/src/SetPolyfill.js

View file

@ -0,0 +1,229 @@
/**
* 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
*/
'use strict';
var Animation = require('./Animation');
var AnimatedValue = require('./AnimatedValue');
var RequestAnimationFrame = require('./injectable/RequestAnimationFrame');
var CancelAnimationFrame = require('./injectable/CancelAnimationFrame');
var invariant = require('invariant');
var SpringConfig = require('./SpringConfig');
import type { AnimationConfig, EndCallback } from './Animation';
type SpringAnimationConfigSingle = AnimationConfig & {
toValue: number | AnimatedValue;
overshootClamping?: bool;
restDisplacementThreshold?: number;
restSpeedThreshold?: number;
velocity?: number;
bounciness?: number;
speed?: number;
tension?: number;
friction?: number;
};
function withDefault<T>(value: ?T, defaultValue: T): T {
if (value === undefined || value === null) {
return defaultValue;
}
return value;
}
class SpringAnimation extends Animation {
_overshootClamping: bool;
_restDisplacementThreshold: number;
_restSpeedThreshold: number;
_initialVelocity: ?number;
_lastVelocity: number;
_startPosition: number;
_lastPosition: number;
_fromValue: number;
_toValue: any;
_tension: number;
_friction: number;
_lastTime: number;
_onUpdate: (value: number) => void;
_animationFrame: any;
constructor(
config: SpringAnimationConfigSingle,
) {
super();
this._overshootClamping = withDefault(config.overshootClamping, false);
this._restDisplacementThreshold = withDefault(config.restDisplacementThreshold, 0.001);
this._restSpeedThreshold = withDefault(config.restSpeedThreshold, 0.001);
this._initialVelocity = config.velocity;
this._lastVelocity = withDefault(config.velocity, 0);
this._toValue = config.toValue;
this.__isInteraction = config.isInteraction !== undefined ? config.isInteraction : true;
var springConfig;
if (config.bounciness !== undefined || config.speed !== undefined) {
invariant(
config.tension === undefined && config.friction === undefined,
'You can only define bounciness/speed or tension/friction but not both',
);
springConfig = SpringConfig.fromBouncinessAndSpeed(
withDefault(config.bounciness, 8),
withDefault(config.speed, 12),
);
} else {
springConfig = SpringConfig.fromOrigamiTensionAndFriction(
withDefault(config.tension, 40),
withDefault(config.friction, 7),
);
}
this._tension = springConfig.tension;
this._friction = springConfig.friction;
}
start(
fromValue: number,
onUpdate: (value: number) => void,
onEnd: ?EndCallback,
previousAnimation: ?Animation,
): void {
this.__active = true;
this._startPosition = fromValue;
this._lastPosition = this._startPosition;
this._onUpdate = onUpdate;
this.__onEnd = onEnd;
this._lastTime = Date.now();
if (previousAnimation instanceof SpringAnimation) {
var internalState = previousAnimation.getInternalState();
this._lastPosition = internalState.lastPosition;
this._lastVelocity = internalState.lastVelocity;
this._lastTime = internalState.lastTime;
}
if (this._initialVelocity !== undefined &&
this._initialVelocity !== null) {
this._lastVelocity = this._initialVelocity;
}
this.onUpdate();
}
getInternalState(): Object {
return {
lastPosition: this._lastPosition,
lastVelocity: this._lastVelocity,
lastTime: this._lastTime,
};
}
onUpdate(): void {
var position = this._lastPosition;
var velocity = this._lastVelocity;
var tempPosition = this._lastPosition;
var tempVelocity = this._lastVelocity;
// If for some reason we lost a lot of frames (e.g. process large payload or
// stopped in the debugger), we only advance by 4 frames worth of
// computation and will continue on the next frame. It's better to have it
// running at faster speed than jumping to the end.
var MAX_STEPS = 64;
var now = Date.now();
if (now > this._lastTime + MAX_STEPS) {
now = this._lastTime + MAX_STEPS;
}
// We are using a fixed time step and a maximum number of iterations.
// The following post provides a lot of thoughts into how to build this
// loop: http://gafferongames.com/game-physics/fix-your-timestep/
var TIMESTEP_MSEC = 1;
var numSteps = Math.floor((now - this._lastTime) / TIMESTEP_MSEC);
for (var i = 0; i < numSteps; ++i) {
// Velocity is based on seconds instead of milliseconds
var step = TIMESTEP_MSEC / 1000;
// This is using RK4. A good blog post to understand how it works:
// http://gafferongames.com/game-physics/integration-basics/
var aVelocity = velocity;
var aAcceleration = this._tension * (this._toValue - tempPosition) - this._friction * tempVelocity;
var tempPosition = position + aVelocity * step / 2;
var tempVelocity = velocity + aAcceleration * step / 2;
var bVelocity = tempVelocity;
var bAcceleration = this._tension * (this._toValue - tempPosition) - this._friction * tempVelocity;
tempPosition = position + bVelocity * step / 2;
tempVelocity = velocity + bAcceleration * step / 2;
var cVelocity = tempVelocity;
var cAcceleration = this._tension * (this._toValue - tempPosition) - this._friction * tempVelocity;
tempPosition = position + cVelocity * step / 2;
tempVelocity = velocity + cAcceleration * step / 2;
var dVelocity = tempVelocity;
var dAcceleration = this._tension * (this._toValue - tempPosition) - this._friction * tempVelocity;
tempPosition = position + cVelocity * step / 2;
tempVelocity = velocity + cAcceleration * step / 2;
var dxdt = (aVelocity + 2 * (bVelocity + cVelocity) + dVelocity) / 6;
var dvdt = (aAcceleration + 2 * (bAcceleration + cAcceleration) + dAcceleration) / 6;
position += dxdt * step;
velocity += dvdt * step;
}
this._lastTime = now;
this._lastPosition = position;
this._lastVelocity = velocity;
this._onUpdate(position);
if (!this.__active) { // a listener might have stopped us in _onUpdate
return;
}
// Conditions for stopping the spring animation
var isOvershooting = false;
if (this._overshootClamping && this._tension !== 0) {
if (this._startPosition < this._toValue) {
isOvershooting = position > this._toValue;
} else {
isOvershooting = position < this._toValue;
}
}
var isVelocity = Math.abs(velocity) <= this._restSpeedThreshold;
var isDisplacement = true;
if (this._tension !== 0) {
isDisplacement = Math.abs(this._toValue - position) <= this._restDisplacementThreshold;
}
if (isOvershooting || (isVelocity && isDisplacement)) {
if (this._tension !== 0) {
// Ensure that we end up with a round value
this._onUpdate(this._toValue);
}
this.__debouncedOnEnd({finished: true});
return;
}
this._animationFrame = RequestAnimationFrame.current(this.onUpdate.bind(this));
}
stop(): void {
this.__active = false;
CancelAnimationFrame.current(this._animationFrame);
this.__debouncedOnEnd({finished: false});
}
}
module.exports = SpringAnimation;
// WEBPACK FOOTER //
// ./~/animated/src/SpringAnimation.js

View file

@ -0,0 +1,106 @@
/**
* 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
*/
'use strict';
type SpringConfigType = {
tension: number,
friction: number,
};
function tensionFromOrigamiValue(oValue) {
return (oValue - 30) * 3.62 + 194;
}
function frictionFromOrigamiValue(oValue) {
return (oValue - 8) * 3 + 25;
}
function fromOrigamiTensionAndFriction(
tension: number,
friction: number,
): SpringConfigType {
return {
tension: tensionFromOrigamiValue(tension),
friction: frictionFromOrigamiValue(friction)
};
}
function fromBouncinessAndSpeed(
bounciness: number,
speed: number,
): SpringConfigType {
function normalize(value, startValue, endValue) {
return (value - startValue) / (endValue - startValue);
}
function projectNormal(n, start, end) {
return start + (n * (end - start));
}
function linearInterpolation(t, start, end) {
return t * end + (1 - t) * start;
}
function quadraticOutInterpolation(t, start, end) {
return linearInterpolation(2 * t - t * t, start, end);
}
function b3Friction1(x) {
return (0.0007 * Math.pow(x, 3)) -
(0.031 * Math.pow(x, 2)) + 0.64 * x + 1.28;
}
function b3Friction2(x) {
return (0.000044 * Math.pow(x, 3)) -
(0.006 * Math.pow(x, 2)) + 0.36 * x + 2;
}
function b3Friction3(x) {
return (0.00000045 * Math.pow(x, 3)) -
(0.000332 * Math.pow(x, 2)) + 0.1078 * x + 5.84;
}
function b3Nobounce(tension) {
if (tension <= 18) {
return b3Friction1(tension);
} else if (tension > 18 && tension <= 44) {
return b3Friction2(tension);
} else {
return b3Friction3(tension);
}
}
var b = normalize(bounciness / 1.7, 0, 20);
b = projectNormal(b, 0, 0.8);
var s = normalize(speed / 1.7, 0, 20);
var bouncyTension = projectNormal(s, 0.5, 200);
var bouncyFriction = quadraticOutInterpolation(
b,
b3Nobounce(bouncyTension),
0.01
);
return {
tension: tensionFromOrigamiValue(bouncyTension),
friction: frictionFromOrigamiValue(bouncyFriction)
};
}
module.exports = {
fromOrigamiTensionAndFriction,
fromBouncinessAndSpeed,
};
// WEBPACK FOOTER //
// ./~/animated/src/SpringConfig.js

View file

@ -0,0 +1,115 @@
/**
* 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
*/
'use strict';
var Animation = require('./Animation');
var AnimatedValue = require('./AnimatedValue');
var Easing = require('./Easing');
var RequestAnimationFrame = require('./injectable/RequestAnimationFrame');
var CancelAnimationFrame = require('./injectable/CancelAnimationFrame');
import type { AnimationConfig, EndCallback } from './Animation';
var easeInOut = Easing.inOut(Easing.ease);
type TimingAnimationConfigSingle = AnimationConfig & {
toValue: number | AnimatedValue;
easing?: (value: number) => number;
duration?: number;
delay?: number;
};
class TimingAnimation extends Animation {
_startTime: number;
_fromValue: number;
_toValue: any;
_duration: number;
_delay: number;
_easing: (value: number) => number;
_onUpdate: (value: number) => void;
_animationFrame: any;
_timeout: any;
constructor(
config: TimingAnimationConfigSingle,
) {
super();
this._toValue = config.toValue;
this._easing = config.easing !== undefined ? config.easing : easeInOut;
this._duration = config.duration !== undefined ? config.duration : 500;
this._delay = config.delay !== undefined ? config.delay : 0;
this.__isInteraction = config.isInteraction !== undefined ? config.isInteraction : true;
}
start(
fromValue: number,
onUpdate: (value: number) => void,
onEnd: ?EndCallback,
): void {
this.__active = true;
this._fromValue = fromValue;
this._onUpdate = onUpdate;
this.__onEnd = onEnd;
var start = () => {
if (this._duration === 0) {
this._onUpdate(this._toValue);
this.__debouncedOnEnd({finished: true});
} else {
this._startTime = Date.now();
this._animationFrame = RequestAnimationFrame.current(this.onUpdate.bind(this));
}
};
if (this._delay) {
this._timeout = setTimeout(start, this._delay);
} else {
start();
}
}
onUpdate(): void {
var now = Date.now();
if (now >= this._startTime + this._duration) {
if (this._duration === 0) {
this._onUpdate(this._toValue);
} else {
this._onUpdate(
this._fromValue + this._easing(1) * (this._toValue - this._fromValue)
);
}
this.__debouncedOnEnd({finished: true});
return;
}
this._onUpdate(
this._fromValue +
this._easing((now - this._startTime) / this._duration) *
(this._toValue - this._fromValue)
);
if (this.__active) {
this._animationFrame = RequestAnimationFrame.current(this.onUpdate.bind(this));
}
}
stop(): void {
this.__active = false;
clearTimeout(this._timeout);
CancelAnimationFrame.current(this._animationFrame);
this.__debouncedOnEnd({finished: false});
}
}
module.exports = TimingAnimation;
// WEBPACK FOOTER //
// ./~/animated/src/TimingAnimation.js

View file

@ -0,0 +1,110 @@
/**
* https://github.com/gre/bezier-easing
* BezierEasing - use bezier curve for transition easing function
* by Gaëtan Renaudeau 2014 - 2015 MIT License
* @nolint
*/
// These values are established by empiricism with tests (tradeoff: performance VS precision)
var NEWTON_ITERATIONS = 4;
var NEWTON_MIN_SLOPE = 0.001;
var SUBDIVISION_PRECISION = 0.0000001;
var SUBDIVISION_MAX_ITERATIONS = 10;
var kSplineTableSize = 11;
var kSampleStepSize = 1.0 / (kSplineTableSize - 1.0);
var float32ArraySupported = typeof Float32Array === 'function';
function A (aA1, aA2) { return 1.0 - 3.0 * aA2 + 3.0 * aA1; }
function B (aA1, aA2) { return 3.0 * aA2 - 6.0 * aA1; }
function C (aA1) { return 3.0 * aA1; }
// Returns x(t) given t, x1, and x2, or y(t) given t, y1, and y2.
function calcBezier (aT, aA1, aA2) { return ((A(aA1, aA2) * aT + B(aA1, aA2)) * aT + C(aA1)) * aT; }
// Returns dx/dt given t, x1, and x2, or dy/dt given t, y1, and y2.
function getSlope (aT, aA1, aA2) { return 3.0 * A(aA1, aA2) * aT * aT + 2.0 * B(aA1, aA2) * aT + C(aA1); }
function binarySubdivide (aX, aA, aB, mX1, mX2) {
var currentX, currentT, i = 0;
do {
currentT = aA + (aB - aA) / 2.0;
currentX = calcBezier(currentT, mX1, mX2) - aX;
if (currentX > 0.0) {
aB = currentT;
} else {
aA = currentT;
}
} while (Math.abs(currentX) > SUBDIVISION_PRECISION && ++i < SUBDIVISION_MAX_ITERATIONS);
return currentT;
}
function newtonRaphsonIterate (aX, aGuessT, mX1, mX2) {
for (var i = 0; i < NEWTON_ITERATIONS; ++i) {
var currentSlope = getSlope(aGuessT, mX1, mX2);
if (currentSlope === 0.0) {
return aGuessT;
}
var currentX = calcBezier(aGuessT, mX1, mX2) - aX;
aGuessT -= currentX / currentSlope;
}
return aGuessT;
}
module.exports = function bezier (mX1, mY1, mX2, mY2) {
if (!(0 <= mX1 && mX1 <= 1 && 0 <= mX2 && mX2 <= 1)) { // eslint-disable-line yoda
throw new Error('bezier x values must be in [0, 1] range');
}
// Precompute samples table
var sampleValues = float32ArraySupported ? new Float32Array(kSplineTableSize) : new Array(kSplineTableSize);
if (mX1 !== mY1 || mX2 !== mY2) {
for (var i = 0; i < kSplineTableSize; ++i) {
sampleValues[i] = calcBezier(i * kSampleStepSize, mX1, mX2);
}
}
function getTForX (aX) {
var intervalStart = 0.0;
var currentSample = 1;
var lastSample = kSplineTableSize - 1;
for (; currentSample !== lastSample && sampleValues[currentSample] <= aX; ++currentSample) {
intervalStart += kSampleStepSize;
}
--currentSample;
// Interpolate to provide an initial guess for t
var dist = (aX - sampleValues[currentSample]) / (sampleValues[currentSample + 1] - sampleValues[currentSample]);
var guessForT = intervalStart + dist * kSampleStepSize;
var initialSlope = getSlope(guessForT, mX1, mX2);
if (initialSlope >= NEWTON_MIN_SLOPE) {
return newtonRaphsonIterate(aX, guessForT, mX1, mX2);
} else if (initialSlope === 0.0) {
return guessForT;
} else {
return binarySubdivide(aX, intervalStart, intervalStart + kSampleStepSize, mX1, mX2);
}
}
return function BezierEasing (x) {
if (mX1 === mY1 && mX2 === mY2) {
return x; // linear
}
// Because JavaScript number are imprecise, we should guarantee the extremes are right.
if (x === 0) {
return 0;
}
if (x === 1) {
return 1;
}
return calcBezier(getTForX(x), mY1, mY2);
};
};
// WEBPACK FOOTER //
// ./~/animated/src/bezier.js

View file

@ -0,0 +1,113 @@
/**
* 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
*/
'use strict';
var React = require('react');
var AnimatedProps = require('./AnimatedProps');
var ApplyAnimatedValues = require('./injectable/ApplyAnimatedValues');
function createAnimatedComponent(Component: any): any {
var refName = 'node';
class AnimatedComponent extends React.Component {
_propsAnimated: AnimatedProps;
componentWillUnmount() {
this._propsAnimated && this._propsAnimated.__detach();
}
setNativeProps(props) {
var didUpdate = ApplyAnimatedValues.current(this.refs[refName], props, this);
if (didUpdate === false) {
this.forceUpdate();
}
}
componentWillMount() {
this.attachProps(this.props);
}
attachProps(nextProps) {
var oldPropsAnimated = this._propsAnimated;
// The system is best designed when setNativeProps is implemented. It is
// able to avoid re-rendering and directly set the attributes that
// changed. However, setNativeProps can only be implemented on leaf
// native components. If you want to animate a composite component, you
// need to re-render it. In this case, we have a fallback that uses
// forceUpdate.
var callback = () => {
var didUpdate = ApplyAnimatedValues.current(this.refs[refName], this._propsAnimated.__getAnimatedValue(), this);
if (didUpdate === false) {
this.forceUpdate();
}
};
this._propsAnimated = new AnimatedProps(
nextProps,
callback,
);
// When you call detach, it removes the element from the parent list
// of children. If it goes to 0, then the parent also detaches itself
// and so on.
// An optimization is to attach the new elements and THEN detach the old
// ones instead of detaching and THEN attaching.
// This way the intermediate state isn't to go to 0 and trigger
// this expensive recursive detaching to then re-attach everything on
// the very next operation.
oldPropsAnimated && oldPropsAnimated.__detach();
}
componentWillReceiveProps(nextProps) {
this.attachProps(nextProps);
}
render() {
return (
<Component
{...this._propsAnimated.__getValue()}
ref={refName}
/>
);
}
}
AnimatedComponent.propTypes = {
style: function(props, propName, componentName) {
if (!Component.propTypes) {
return;
}
// TODO(lmr): We will probably bring this back in at some point, but maybe
// just a subset of the proptypes... We should have a common set of props
// that will be used for all platforms.
//
// for (var key in ViewStylePropTypes) {
// if (!Component.propTypes[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 + ': ... } }`'
// );
// }
// }
}
};
return AnimatedComponent;
}
module.exports = createAnimatedComponent;
// WEBPACK FOOTER //
// ./~/animated/src/createAnimatedComponent.js

View file

@ -0,0 +1,22 @@
/**
* 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
*/
'use strict';
var _uniqueId = 0;
module.exports = function uniqueId(): string {
return String(_uniqueId++);
};
// WEBPACK FOOTER //
// ./~/animated/src/guid.js

View file

@ -0,0 +1,518 @@
/**
* 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
*/
'use strict';
var invariant = require('invariant');
var Animated = require('./Animated');
var AnimatedValue = require('./AnimatedValue');
var AnimatedValueXY = require('./AnimatedValueXY');
var AnimatedAddition = require('./AnimatedAddition');
var AnimatedMultiplication = require('./AnimatedMultiplication');
var AnimatedModulo = require('./AnimatedModulo');
var AnimatedTemplate = require('./AnimatedTemplate');
var AnimatedTracking = require('./AnimatedTracking');
var isAnimated = require('./isAnimated');
var Animation = require('./Animation');
var TimingAnimation = require('./TimingAnimation');
var DecayAnimation = require('./DecayAnimation');
var SpringAnimation = require('./SpringAnimation');
import type { InterpolationConfigType } from './Interpolation';
import type { AnimationConfig, EndResult, EndCallback } from './Animation';
type TimingAnimationConfig = AnimationConfig & {
toValue: number | AnimatedValue | {x: number, y: number} | AnimatedValueXY;
easing?: (value: number) => number;
duration?: number;
delay?: number;
};
type DecayAnimationConfig = AnimationConfig & {
velocity: number | {x: number, y: number};
deceleration?: number;
};
type SpringAnimationConfig = AnimationConfig & {
toValue: number | AnimatedValue | {x: number, y: number} | AnimatedValueXY;
overshootClamping?: bool;
restDisplacementThreshold?: number;
restSpeedThreshold?: number;
velocity?: number | {x: number, y: number};
bounciness?: number;
speed?: number;
tension?: number;
friction?: number;
};
type CompositeAnimation = {
start: (callback?: ?EndCallback) => void;
stop: () => void;
};
var maybeVectorAnim = function(
value: AnimatedValue | AnimatedValueXY,
config: Object,
anim: (value: AnimatedValue, config: Object) => CompositeAnimation
): ?CompositeAnimation {
if (value instanceof AnimatedValueXY) {
var configX = {...config};
var configY = {...config};
for (var key in config) {
var {x, y} = config[key];
if (x !== undefined && y !== undefined) {
configX[key] = x;
configY[key] = y;
}
}
var aX = anim((value: AnimatedValueXY).x, configX);
var aY = anim((value: AnimatedValueXY).y, configY);
// We use `stopTogether: false` here because otherwise tracking will break
// because the second animation will get stopped before it can update.
return parallel([aX, aY], {stopTogether: false});
}
return null;
};
var spring = function(
value: AnimatedValue | AnimatedValueXY,
config: SpringAnimationConfig,
): CompositeAnimation {
return maybeVectorAnim(value, config, spring) || {
start: function(callback?: ?EndCallback): void {
var singleValue: any = value;
var singleConfig: any = config;
singleValue.stopTracking();
if (config.toValue instanceof Animated) {
singleValue.track(new AnimatedTracking(
singleValue,
config.toValue,
SpringAnimation,
singleConfig,
callback
));
} else {
singleValue.animate(new SpringAnimation(singleConfig), callback);
}
},
stop: function(): void {
value.stopAnimation();
},
};
};
var timing = function(
value: AnimatedValue | AnimatedValueXY,
config: TimingAnimationConfig,
): CompositeAnimation {
return maybeVectorAnim(value, config, timing) || {
start: function(callback?: ?EndCallback): void {
var singleValue: any = value;
var singleConfig: any = config;
singleValue.stopTracking();
if (config.toValue instanceof Animated) {
singleValue.track(new AnimatedTracking(
singleValue,
config.toValue,
TimingAnimation,
singleConfig,
callback
));
} else {
singleValue.animate(new TimingAnimation(singleConfig), callback);
}
},
stop: function(): void {
value.stopAnimation();
},
};
};
var decay = function(
value: AnimatedValue | AnimatedValueXY,
config: DecayAnimationConfig,
): CompositeAnimation {
return maybeVectorAnim(value, config, decay) || {
start: function(callback?: ?EndCallback): void {
var singleValue: any = value;
var singleConfig: any = config;
singleValue.stopTracking();
singleValue.animate(new DecayAnimation(singleConfig), callback);
},
stop: function(): void {
value.stopAnimation();
},
};
};
var sequence = function(
animations: Array<CompositeAnimation>,
): CompositeAnimation {
var current = 0;
return {
start: function(callback?: ?EndCallback) {
var onComplete = function(result) {
if (!result.finished) {
callback && callback(result);
return;
}
current++;
if (current === animations.length) {
callback && callback(result);
return;
}
animations[current].start(onComplete);
};
if (animations.length === 0) {
callback && callback({finished: true});
} else {
animations[current].start(onComplete);
}
},
stop: function() {
if (current < animations.length) {
animations[current].stop();
}
}
};
};
type ParallelConfig = {
stopTogether?: bool; // If one is stopped, stop all. default: true
}
var parallel = function(
animations: Array<CompositeAnimation>,
config?: ?ParallelConfig,
): CompositeAnimation {
var doneCount = 0;
// Make sure we only call stop() at most once for each animation
var hasEnded = {};
var stopTogether = !(config && config.stopTogether === false);
var result = {
start: function(callback?: ?EndCallback) {
if (doneCount === animations.length) {
callback && callback({finished: true});
return;
}
animations.forEach((animation, idx) => {
var cb = function(endResult) {
hasEnded[idx] = true;
doneCount++;
if (doneCount === animations.length) {
doneCount = 0;
callback && callback(endResult);
return;
}
if (!endResult.finished && stopTogether) {
result.stop();
}
};
if (!animation) {
cb({finished: true});
} else {
animation.start(cb);
}
});
},
stop: function(): void {
animations.forEach((animation, idx) => {
!hasEnded[idx] && animation.stop();
hasEnded[idx] = true;
});
}
};
return result;
};
var delay = function(time: number): CompositeAnimation {
// Would be nice to make a specialized implementation
return timing(new AnimatedValue(0), {toValue: 0, delay: time, duration: 0});
};
var stagger = function(
time: number,
animations: Array<CompositeAnimation>,
): CompositeAnimation {
return parallel(animations.map((animation, i) => {
return sequence([
delay(time * i),
animation,
]);
}));
};
type Mapping = {[key: string]: Mapping} | AnimatedValue;
type EventConfig = {listener?: ?Function};
var event = function(
argMapping: Array<?Mapping>,
config?: ?EventConfig,
): () => void {
return function(...args): void {
var traverse = function(recMapping, recEvt, key) {
if (typeof recEvt === 'number') {
invariant(
recMapping instanceof AnimatedValue,
'Bad mapping of type ' + typeof recMapping + ' for key ' + key +
', event value must map to AnimatedValue'
);
recMapping.setValue(recEvt);
return;
}
invariant(
typeof recMapping === 'object',
'Bad mapping of type ' + typeof recMapping + ' for key ' + key
);
invariant(
typeof recEvt === 'object',
'Bad event of type ' + typeof recEvt + ' for key ' + key
);
for (var key in recMapping) {
traverse(recMapping[key], recEvt[key], key);
}
};
argMapping.forEach((mapping, idx) => {
traverse(mapping, args[idx], 'arg' + idx);
});
if (config && config.listener) {
config.listener.apply(null, args);
}
};
};
/**
* Animations are an important part of modern UX, and the `Animated`
* library is designed to make them fluid, powerful, and easy to build and
* maintain.
*
* The simplest workflow is to create an `Animated.Value`, hook it up to one or
* more style attributes of an animated component, and then drive updates either
* via animations, such as `Animated.timing`, or by hooking into gestures like
* panning or scrolling via `Animated.event`. `Animated.Value` can also bind to
* props other than style, and can be interpolated as well. Here is a basic
* example of a container view that will fade in when it's mounted:
*
*```javascript
* class FadeInView extends React.Component {
* constructor(props) {
* super(props);
* this.state = {
* fadeAnim: new Animated.Value(0), // init opacity 0
* };
* }
* componentDidMount() {
* Animated.timing( // Uses easing functions
* this.state.fadeAnim, // The value to drive
* {toValue: 1}, // Configuration
* ).start(); // Don't forget start!
* }
* render() {
* return (
* <Animated.View // Special animatable View
* style={{opacity: this.state.fadeAnim}}> // Binds
* {this.props.children}
* </Animated.View>
* );
* }
* }
*```
*
* Note that only animatable components can be animated. `View`, `Text`, and
* `Image` are already provided, and you can create custom ones with
* `createAnimatedComponent`. These special components do the magic of binding
* the animated values to the properties, and do targeted native updates to
* avoid the cost of the react render and reconciliation process on every frame.
* They also handle cleanup on unmount so they are safe by default.
*
* Animations are heavily configurable. Custom and pre-defined easing
* functions, delays, durations, decay factors, spring constants, and more can
* all be tweaked depending on the type of animation.
*
* A single `Animated.Value` can drive any number of properties, and each
* property can be run through an interpolation first. An interpolation maps
* input ranges to output ranges, typically using a linear interpolation but
* also supports easing functions. By default, it will extrapolate the curve
* beyond the ranges given, but you can also have it clamp the output value.
*
* For example, you may want to think about your `Animated.Value` as going from
* 0 to 1, but animate the position from 150px to 0px and the opacity from 0 to
* 1. This can easily be done by modifying `style` in the example above like so:
*
*```javascript
* style={{
* opacity: this.state.fadeAnim, // Binds directly
* transform: [{
* translateY: this.state.fadeAnim.interpolate({
* inputRange: [0, 1],
* outputRange: [150, 0] // 0 : 150, 0.5 : 75, 1 : 0
* }),
* }],
* }}>
*```
*
* Animations can also be combined in complex ways using composition functions
* such as `sequence` and `parallel`, and can also be chained together simply
* by setting the `toValue` of one animation to be another `Animated.Value`.
*
* `Animated.ValueXY` is handy for 2D animations, like panning, and there are
* other helpful additions like `setOffset` and `getLayout` to aid with typical
* interaction patterns, like drag-and-drop.
*
* You can see more example usage in `AnimationExample.js`, the Gratuitous
* Animation App, and [Animations documentation guide](docs/animations.html).
*
* Note that `Animated` is designed to be fully serializable so that animations
* can be run in a high performance way, independent of the normal JavaScript
* event loop. This does influence the API, so keep that in mind when it seems a
* little trickier to do something compared to a fully synchronous system.
* Checkout `Animated.Value.addListener` as a way to work around some of these
* limitations, but use it sparingly since it might have performance
* implications in the future.
*/
module.exports = {
/**
* Standard value class for driving animations. Typically initialized with
* `new Animated.Value(0);`
*/
Value: AnimatedValue,
/**
* 2D value class for driving 2D animations, such as pan gestures.
*/
ValueXY: AnimatedValueXY,
/**
* Animates a value from an initial velocity to zero based on a decay
* coefficient.
*/
decay,
/**
* Animates a value along a timed easing curve. The `Easing` module has tons
* of pre-defined curves, or you can use your own function.
*/
timing,
/**
* Spring animation based on Rebound and Origami. Tracks velocity state to
* create fluid motions as the `toValue` updates, and can be chained together.
*/
spring,
/**
* Creates a new Animated value composed from two Animated values added
* together.
*/
add: function add(a: Animated, b: Animated): AnimatedAddition {
return new AnimatedAddition(a, b);
},
/**
* Creates a new Animated value composed from two Animated values multiplied
* together.
*/
multiply: function multiply(a: Animated, b: Animated): AnimatedMultiplication {
return new AnimatedMultiplication(a, b);
},
/**
* Creates a new Animated value that is the (non-negative) modulo of the
* provided Animated value
*/
modulo: function modulo(a: Animated, modulus: number): AnimatedModulo {
return new AnimatedModulo(a, modulus);
},
/**
* Creates a new Animated value that is the specified string, with each
* substitution expression being separately animated and interpolated.
*/
template: function template(strings, ...values) {
return new AnimatedTemplate(strings, values);
},
/**
* Starts an animation after the given delay.
*/
delay,
/**
* Starts an array of animations in order, waiting for each to complete
* before starting the next. If the current running animation is stopped, no
* following animations will be started.
*/
sequence,
/**
* Starts an array of animations all at the same time. By default, if one
* of the animations is stopped, they will all be stopped. You can override
* this with the `stopTogether` flag.
*/
parallel,
/**
* Array of animations may run in parallel (overlap), but are started in
* sequence with successive delays. Nice for doing trailing effects.
*/
stagger,
/**
* Takes an array of mappings and extracts values from each arg accordingly,
* then calls `setValue` on the mapped outputs. e.g.
*
*```javascript
* onScroll={Animated.event(
* [{nativeEvent: {contentOffset: {x: this._scrollX}}}]
* {listener}, // Optional async listener
* )
* ...
* onPanResponderMove: Animated.event([
* null, // raw event arg ignored
* {dx: this._panX}, // gestureState arg
* ]),
*```
*/
event,
/**
* Existential test to figure out if an object is an instance of the Animated
* class or not.
*/
isAnimated,
/**
* Make any React component Animatable. Used to create `Animated.View`, etc.
*/
createAnimatedComponent: require('./createAnimatedComponent'),
inject: {
ApplyAnimatedValues: require('./injectable/ApplyAnimatedValues').inject,
InteractionManager: require('./injectable/InteractionManager').inject,
FlattenStyle: require('./injectable/FlattenStyle').inject,
RequestAnimationFrame: require('./injectable/RequestAnimationFrame').inject,
CancelAnimationFrame: require('./injectable/CancelAnimationFrame').inject,
},
__PropsOnlyForTests: require('./AnimatedProps'),
};
// WEBPACK FOOTER //
// ./~/animated/src/index.js

View file

@ -0,0 +1,31 @@
/**
* 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
*/
'use strict';
var ApplyAnimatedValues = {
current: function ApplyAnimatedValues(instance, props) {
if (instance.setNativeProps) {
instance.setNativeProps(props);
} else {
return false;
}
},
inject(apply) {
ApplyAnimatedValues.current = apply;
},
};
module.exports = ApplyAnimatedValues;
// WEBPACK FOOTER //
// ./~/animated/src/injectable/ApplyAnimatedValues.js

View file

@ -0,0 +1,25 @@
/**
* 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
*/
'use strict';
var CancelAnimationFrame = {
current: id => global.cancelAnimationFrame(id),
inject(injected) {
CancelAnimationFrame.current = injected;
},
};
module.exports = CancelAnimationFrame;
// WEBPACK FOOTER //
// ./~/animated/src/injectable/CancelAnimationFrame.js

View file

@ -0,0 +1,25 @@
/**
* 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
*/
'use strict';
var FlattenStyle = {
current: style => style,
inject(flatten) {
FlattenStyle.current = flatten;
},
};
module.exports = FlattenStyle;
// WEBPACK FOOTER //
// ./~/animated/src/injectable/FlattenStyle.js

View file

@ -0,0 +1,28 @@
/**
* 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
*/
'use strict';
var InteractionManager = {
current: {
createInteractionHandle: function() {},
clearInteractionHandle: function() {},
},
inject(manager) {
InteractionManager.current = manager;
},
};
module.exports = InteractionManager;
// WEBPACK FOOTER //
// ./~/animated/src/injectable/InteractionManager.js

View file

@ -0,0 +1,25 @@
/**
* 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
*/
'use strict';
var RequestAnimationFrame = {
current: cb => global.requestAnimationFrame(cb),
inject(injected) {
RequestAnimationFrame.current = injected;
},
};
module.exports = RequestAnimationFrame;
// WEBPACK FOOTER //
// ./~/animated/src/injectable/RequestAnimationFrame.js

View file

@ -0,0 +1,24 @@
/**
* 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
*/
'use strict';
var Animated = require('./Animated');
function isAnimated(obj) {
return obj instanceof Animated;
}
module.exports = isAnimated;
// WEBPACK FOOTER //
// ./~/animated/src/isAnimated.js

View file

@ -0,0 +1,12 @@
'use strict';
module.exports = function () {
return /[\u001b\u009b][[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-PRZcf-nqry=><]/g;
};
//////////////////
// WEBPACK FOOTER
// ./~/ansi-regex/index.js
// module id = 706
// module chunks = 4

View file

@ -0,0 +1,73 @@
'use strict';
function assembleStyles () {
var styles = {
modifiers: {
reset: [0, 0],
bold: [1, 22], // 21 isn't widely supported and 22 does the same thing
dim: [2, 22],
italic: [3, 23],
underline: [4, 24],
inverse: [7, 27],
hidden: [8, 28],
strikethrough: [9, 29]
},
colors: {
black: [30, 39],
red: [31, 39],
green: [32, 39],
yellow: [33, 39],
blue: [34, 39],
magenta: [35, 39],
cyan: [36, 39],
white: [37, 39],
gray: [90, 39]
},
bgColors: {
bgBlack: [40, 49],
bgRed: [41, 49],
bgGreen: [42, 49],
bgYellow: [43, 49],
bgBlue: [44, 49],
bgMagenta: [45, 49],
bgCyan: [46, 49],
bgWhite: [47, 49]
}
};
// fix humans
styles.colors.grey = styles.colors.gray;
Object.keys(styles).forEach(function (groupName) {
var group = styles[groupName];
Object.keys(group).forEach(function (styleName) {
var style = group[styleName];
styles[styleName] = group[styleName] = {
open: '\u001b[' + style[0] + 'm',
close: '\u001b[' + style[1] + 'm'
};
});
Object.defineProperty(styles, groupName, {
value: group,
enumerable: false
});
});
return styles;
}
Object.defineProperty(module, 'exports', {
enumerable: true,
get: assembleStyles
});
//////////////////
// WEBPACK FOOTER
// ./~/ansi-styles/index.js
// module id = 1228
// module chunks = 4

View file

@ -0,0 +1,14 @@
'use strict';
var arrayUniq = require('array-uniq');
module.exports = function () {
return arrayUniq([].concat.apply([], arguments));
};
//////////////////
// WEBPACK FOOTER
// ./~/array-union/index.js
// module id = 1229
// module chunks = 4

View file

@ -0,0 +1,70 @@
'use strict';
// there's 3 implementations written in increasing order of efficiency
// 1 - no Set type is defined
function uniqNoSet(arr) {
var ret = [];
for (var i = 0; i < arr.length; i++) {
if (ret.indexOf(arr[i]) === -1) {
ret.push(arr[i]);
}
}
return ret;
}
// 2 - a simple Set type is defined
function uniqSet(arr) {
var seen = new Set();
return arr.filter(function (el) {
if (!seen.has(el)) {
seen.add(el);
return true;
}
return false;
});
}
// 3 - a standard Set type is defined and it has a forEach method
function uniqSetWithForEach(arr) {
var ret = [];
(new Set(arr)).forEach(function (el) {
ret.push(el);
});
return ret;
}
// V8 currently has a broken implementation
// https://github.com/joyent/node/issues/8449
function doesForEachActuallyWork() {
var ret = false;
(new Set([true])).forEach(function (el) {
ret = el;
});
return ret === true;
}
if ('Set' in global) {
if (typeof Set.prototype.forEach === 'function' && doesForEachActuallyWork()) {
module.exports = uniqSetWithForEach;
} else {
module.exports = uniqSet;
}
} else {
module.exports = uniqNoSet;
}
//////////////////
// WEBPACK FOOTER
// ./~/array-uniq/index.js
// module id = 1230
// module chunks = 4

View file

@ -0,0 +1,498 @@
'use strict';
// compare and isBuffer taken from https://github.com/feross/buffer/blob/680e9e5e488f22aac27599a57dc844a6315928dd/index.js
// original notice:
/*!
* The buffer module from node.js, for the browser.
*
* @author Feross Aboukhadijeh <feross@feross.org> <http://feross.org>
* @license MIT
*/
function compare(a, b) {
if (a === b) {
return 0;
}
var x = a.length;
var y = b.length;
for (var i = 0, len = Math.min(x, y); i < len; ++i) {
if (a[i] !== b[i]) {
x = a[i];
y = b[i];
break;
}
}
if (x < y) {
return -1;
}
if (y < x) {
return 1;
}
return 0;
}
function isBuffer(b) {
if (global.Buffer && typeof global.Buffer.isBuffer === 'function') {
return global.Buffer.isBuffer(b);
}
return !!(b != null && b._isBuffer);
}
// based on node assert, original notice:
// http://wiki.commonjs.org/wiki/Unit_Testing/1.0
//
// THIS IS NOT TESTED NOR LIKELY TO WORK OUTSIDE V8!
//
// Originally from narwhal.js (http://narwhaljs.org)
// Copyright (c) 2009 Thomas Robinson <280north.com>
//
// 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 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.
var util = require('util/');
var hasOwn = Object.prototype.hasOwnProperty;
var pSlice = Array.prototype.slice;
var functionsHaveNames = (function () {
return function foo() {}.name === 'foo';
}());
function pToString (obj) {
return Object.prototype.toString.call(obj);
}
function isView(arrbuf) {
if (isBuffer(arrbuf)) {
return false;
}
if (typeof global.ArrayBuffer !== 'function') {
return false;
}
if (typeof ArrayBuffer.isView === 'function') {
return ArrayBuffer.isView(arrbuf);
}
if (!arrbuf) {
return false;
}
if (arrbuf instanceof DataView) {
return true;
}
if (arrbuf.buffer && arrbuf.buffer instanceof ArrayBuffer) {
return true;
}
return false;
}
// 1. The assert module provides functions that throw
// AssertionError's when particular conditions are not met. The
// assert module must conform to the following interface.
var assert = module.exports = ok;
// 2. The AssertionError is defined in assert.
// new assert.AssertionError({ message: message,
// actual: actual,
// expected: expected })
var regex = /\s*function\s+([^\(\s]*)\s*/;
// based on https://github.com/ljharb/function.prototype.name/blob/adeeeec8bfcc6068b187d7d9fb3d5bb1d3a30899/implementation.js
function getName(func) {
if (!util.isFunction(func)) {
return;
}
if (functionsHaveNames) {
return func.name;
}
var str = func.toString();
var match = str.match(regex);
return match && match[1];
}
assert.AssertionError = function AssertionError(options) {
this.name = 'AssertionError';
this.actual = options.actual;
this.expected = options.expected;
this.operator = options.operator;
if (options.message) {
this.message = options.message;
this.generatedMessage = false;
} else {
this.message = getMessage(this);
this.generatedMessage = true;
}
var stackStartFunction = options.stackStartFunction || fail;
if (Error.captureStackTrace) {
Error.captureStackTrace(this, stackStartFunction);
} else {
// non v8 browsers so we can have a stacktrace
var err = new Error();
if (err.stack) {
var out = err.stack;
// try to strip useless frames
var fn_name = getName(stackStartFunction);
var idx = out.indexOf('\n' + fn_name);
if (idx >= 0) {
// once we have located the function frame
// we need to strip out everything before it (and its line)
var next_line = out.indexOf('\n', idx + 1);
out = out.substring(next_line + 1);
}
this.stack = out;
}
}
};
// assert.AssertionError instanceof Error
util.inherits(assert.AssertionError, Error);
function truncate(s, n) {
if (typeof s === 'string') {
return s.length < n ? s : s.slice(0, n);
} else {
return s;
}
}
function inspect(something) {
if (functionsHaveNames || !util.isFunction(something)) {
return util.inspect(something);
}
var rawname = getName(something);
var name = rawname ? ': ' + rawname : '';
return '[Function' + name + ']';
}
function getMessage(self) {
return truncate(inspect(self.actual), 128) + ' ' +
self.operator + ' ' +
truncate(inspect(self.expected), 128);
}
// At present only the three keys mentioned above are used and
// understood by the spec. Implementations or sub modules can pass
// other keys to the AssertionError's constructor - they will be
// ignored.
// 3. All of the following functions must throw an AssertionError
// when a corresponding condition is not met, with a message that
// may be undefined if not provided. All assertion methods provide
// both the actual and expected values to the assertion error for
// display purposes.
function fail(actual, expected, message, operator, stackStartFunction) {
throw new assert.AssertionError({
message: message,
actual: actual,
expected: expected,
operator: operator,
stackStartFunction: stackStartFunction
});
}
// EXTENSION! allows for well behaved errors defined elsewhere.
assert.fail = fail;
// 4. Pure assertion tests whether a value is truthy, as determined
// by !!guard.
// assert.ok(guard, message_opt);
// This statement is equivalent to assert.equal(true, !!guard,
// message_opt);. To test strictly for the value true, use
// assert.strictEqual(true, guard, message_opt);.
function ok(value, message) {
if (!value) fail(value, true, message, '==', assert.ok);
}
assert.ok = ok;
// 5. The equality assertion tests shallow, coercive equality with
// ==.
// assert.equal(actual, expected, message_opt);
assert.equal = function equal(actual, expected, message) {
if (actual != expected) fail(actual, expected, message, '==', assert.equal);
};
// 6. The non-equality assertion tests for whether two objects are not equal
// with != assert.notEqual(actual, expected, message_opt);
assert.notEqual = function notEqual(actual, expected, message) {
if (actual == expected) {
fail(actual, expected, message, '!=', assert.notEqual);
}
};
// 7. The equivalence assertion tests a deep equality relation.
// assert.deepEqual(actual, expected, message_opt);
assert.deepEqual = function deepEqual(actual, expected, message) {
if (!_deepEqual(actual, expected, false)) {
fail(actual, expected, message, 'deepEqual', assert.deepEqual);
}
};
assert.deepStrictEqual = function deepStrictEqual(actual, expected, message) {
if (!_deepEqual(actual, expected, true)) {
fail(actual, expected, message, 'deepStrictEqual', assert.deepStrictEqual);
}
};
function _deepEqual(actual, expected, strict, memos) {
// 7.1. All identical values are equivalent, as determined by ===.
if (actual === expected) {
return true;
} else if (isBuffer(actual) && isBuffer(expected)) {
return compare(actual, expected) === 0;
// 7.2. If the expected value is a Date object, the actual value is
// equivalent if it is also a Date object that refers to the same time.
} else if (util.isDate(actual) && util.isDate(expected)) {
return actual.getTime() === expected.getTime();
// 7.3 If the expected value is a RegExp object, the actual value is
// equivalent if it is also a RegExp object with the same source and
// properties (`global`, `multiline`, `lastIndex`, `ignoreCase`).
} else if (util.isRegExp(actual) && util.isRegExp(expected)) {
return actual.source === expected.source &&
actual.global === expected.global &&
actual.multiline === expected.multiline &&
actual.lastIndex === expected.lastIndex &&
actual.ignoreCase === expected.ignoreCase;
// 7.4. Other pairs that do not both pass typeof value == 'object',
// equivalence is determined by ==.
} else if ((actual === null || typeof actual !== 'object') &&
(expected === null || typeof expected !== 'object')) {
return strict ? actual === expected : actual == expected;
// If both values are instances of typed arrays, wrap their underlying
// ArrayBuffers in a Buffer each to increase performance
// This optimization requires the arrays to have the same type as checked by
// Object.prototype.toString (aka pToString). Never perform binary
// comparisons for Float*Arrays, though, since e.g. +0 === -0 but their
// bit patterns are not identical.
} else if (isView(actual) && isView(expected) &&
pToString(actual) === pToString(expected) &&
!(actual instanceof Float32Array ||
actual instanceof Float64Array)) {
return compare(new Uint8Array(actual.buffer),
new Uint8Array(expected.buffer)) === 0;
// 7.5 For all other Object pairs, including Array objects, equivalence is
// determined by having the same number of owned properties (as verified
// with Object.prototype.hasOwnProperty.call), the same set of keys
// (although not necessarily the same order), equivalent values for every
// corresponding key, and an identical 'prototype' property. Note: this
// accounts for both named and indexed properties on Arrays.
} else if (isBuffer(actual) !== isBuffer(expected)) {
return false;
} else {
memos = memos || {actual: [], expected: []};
var actualIndex = memos.actual.indexOf(actual);
if (actualIndex !== -1) {
if (actualIndex === memos.expected.indexOf(expected)) {
return true;
}
}
memos.actual.push(actual);
memos.expected.push(expected);
return objEquiv(actual, expected, strict, memos);
}
}
function isArguments(object) {
return Object.prototype.toString.call(object) == '[object Arguments]';
}
function objEquiv(a, b, strict, actualVisitedObjects) {
if (a === null || a === undefined || b === null || b === undefined)
return false;
// if one is a primitive, the other must be same
if (util.isPrimitive(a) || util.isPrimitive(b))
return a === b;
if (strict && Object.getPrototypeOf(a) !== Object.getPrototypeOf(b))
return false;
var aIsArgs = isArguments(a);
var bIsArgs = isArguments(b);
if ((aIsArgs && !bIsArgs) || (!aIsArgs && bIsArgs))
return false;
if (aIsArgs) {
a = pSlice.call(a);
b = pSlice.call(b);
return _deepEqual(a, b, strict);
}
var ka = objectKeys(a);
var kb = objectKeys(b);
var key, i;
// having the same number of owned properties (keys incorporates
// hasOwnProperty)
if (ka.length !== kb.length)
return false;
//the same set of keys (although not necessarily the same order),
ka.sort();
kb.sort();
//~~~cheap key test
for (i = ka.length - 1; i >= 0; i--) {
if (ka[i] !== kb[i])
return false;
}
//equivalent values for every corresponding key, and
//~~~possibly expensive deep test
for (i = ka.length - 1; i >= 0; i--) {
key = ka[i];
if (!_deepEqual(a[key], b[key], strict, actualVisitedObjects))
return false;
}
return true;
}
// 8. The non-equivalence assertion tests for any deep inequality.
// assert.notDeepEqual(actual, expected, message_opt);
assert.notDeepEqual = function notDeepEqual(actual, expected, message) {
if (_deepEqual(actual, expected, false)) {
fail(actual, expected, message, 'notDeepEqual', assert.notDeepEqual);
}
};
assert.notDeepStrictEqual = notDeepStrictEqual;
function notDeepStrictEqual(actual, expected, message) {
if (_deepEqual(actual, expected, true)) {
fail(actual, expected, message, 'notDeepStrictEqual', notDeepStrictEqual);
}
}
// 9. The strict equality assertion tests strict equality, as determined by ===.
// assert.strictEqual(actual, expected, message_opt);
assert.strictEqual = function strictEqual(actual, expected, message) {
if (actual !== expected) {
fail(actual, expected, message, '===', assert.strictEqual);
}
};
// 10. The strict non-equality assertion tests for strict inequality, as
// determined by !==. assert.notStrictEqual(actual, expected, message_opt);
assert.notStrictEqual = function notStrictEqual(actual, expected, message) {
if (actual === expected) {
fail(actual, expected, message, '!==', assert.notStrictEqual);
}
};
function expectedException(actual, expected) {
if (!actual || !expected) {
return false;
}
if (Object.prototype.toString.call(expected) == '[object RegExp]') {
return expected.test(actual);
}
try {
if (actual instanceof expected) {
return true;
}
} catch (e) {
// Ignore. The instanceof check doesn't work for arrow functions.
}
if (Error.isPrototypeOf(expected)) {
return false;
}
return expected.call({}, actual) === true;
}
function _tryBlock(block) {
var error;
try {
block();
} catch (e) {
error = e;
}
return error;
}
function _throws(shouldThrow, block, expected, message) {
var actual;
if (typeof block !== 'function') {
throw new TypeError('"block" argument must be a function');
}
if (typeof expected === 'string') {
message = expected;
expected = null;
}
actual = _tryBlock(block);
message = (expected && expected.name ? ' (' + expected.name + ').' : '.') +
(message ? ' ' + message : '.');
if (shouldThrow && !actual) {
fail(actual, expected, 'Missing expected exception' + message);
}
var userProvidedMessage = typeof message === 'string';
var isUnwantedException = !shouldThrow && util.isError(actual);
var isUnexpectedException = !shouldThrow && actual && !expected;
if ((isUnwantedException &&
userProvidedMessage &&
expectedException(actual, expected)) ||
isUnexpectedException) {
fail(actual, expected, 'Got unwanted exception' + message);
}
if ((shouldThrow && actual && expected &&
!expectedException(actual, expected)) || (!shouldThrow && actual)) {
throw actual;
}
}
// 11. Expected to throw an error:
// assert.throws(block, Error_opt, message_opt);
assert.throws = function(block, /*optional*/error, /*optional*/message) {
_throws(true, block, error, message);
};
// EXTENSION! This is annoying to write outside this module.
assert.doesNotThrow = function(block, /*optional*/error, /*optional*/message) {
_throws(false, block, error, message);
};
assert.ifError = function(err) { if (err) throw err; };
var objectKeys = Object.keys || function (obj) {
var keys = [];
for (var key in obj) {
if (hasOwn.call(obj, key)) keys.push(key);
}
return keys;
};
//////////////////
// WEBPACK FOOTER
// ./~/assert/assert.js
// module id = 707
// module chunks = 4

6830
509bba0_unpacked_with_node_modules/~/async/dist/async.js generated vendored Executable file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,35 @@
"use strict";
require("core-js/shim");
require("regenerator-runtime/runtime");
require("core-js/fn/regexp/escape");
if (global._babelPolyfill) {
throw new Error("only one instance of babel-polyfill is allowed");
}
global._babelPolyfill = true;
var DEFINE_PROPERTY = "defineProperty";
function define(O, key, value) {
O[key] || Object[DEFINE_PROPERTY](O, key, {
writable: true,
configurable: true,
value: value
});
}
define(String.prototype, "padLeft", "".padStart);
define(String.prototype, "padRight", "".padEnd);
"pop,reverse,shift,keys,values,entries,indexOf,every,some,forEach,map,filter,find,findIndex,includes,join,slice,concat,push,splice,unshift,sort,lastIndexOf,reduce,reduceRight,copyWithin,fill".split(",").forEach(function (key) {
[][key] && define(Array, key, Function.call.bind([][key]));
});
//////////////////
// WEBPACK FOOTER
// ./~/babel-polyfill/lib/index.js
// module id = 482
// module chunks = 4

View file

@ -0,0 +1,8 @@
module.exports = { "default": require("core-js/library/fn/get-iterator"), __esModule: true };
//////////////////
// WEBPACK FOOTER
// ./~/babel-runtime/core-js/get-iterator.js
// module id = 1725
// module chunks = 4

View file

@ -0,0 +1,8 @@
module.exports = { "default": require("core-js/library/fn/map"), __esModule: true };
//////////////////
// WEBPACK FOOTER
// ./~/babel-runtime/core-js/map.js
// module id = 1726
// module chunks = 4

View file

@ -0,0 +1,8 @@
module.exports = { "default": require("core-js/library/fn/object/assign"), __esModule: true };
//////////////////
// WEBPACK FOOTER
// ./~/babel-runtime/core-js/object/assign.js
// module id = 1727
// module chunks = 4

View file

@ -0,0 +1,8 @@
module.exports = { "default": require("core-js/library/fn/object/create"), __esModule: true };
//////////////////
// WEBPACK FOOTER
// ./~/babel-runtime/core-js/object/create.js
// module id = 1728
// module chunks = 4

View file

@ -0,0 +1,8 @@
module.exports = { "default": require("core-js/library/fn/object/set-prototype-of"), __esModule: true };
//////////////////
// WEBPACK FOOTER
// ./~/babel-runtime/core-js/object/set-prototype-of.js
// module id = 1729
// module chunks = 4

View file

@ -0,0 +1,8 @@
module.exports = { "default": require("core-js/library/fn/symbol"), __esModule: true };
//////////////////
// WEBPACK FOOTER
// ./~/babel-runtime/core-js/symbol.js
// module id = 1730
// module chunks = 4

View file

@ -0,0 +1,8 @@
module.exports = { "default": require("core-js/library/fn/symbol/iterator"), __esModule: true };
//////////////////
// WEBPACK FOOTER
// ./~/babel-runtime/core-js/symbol/iterator.js
// module id = 1731
// module chunks = 4

View file

@ -0,0 +1,16 @@
"use strict";
exports.__esModule = true;
exports.default = function (instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
};
//////////////////
// WEBPACK FOOTER
// ./~/babel-runtime/helpers/classCallCheck.js
// module id = 1732
// module chunks = 4

View file

@ -0,0 +1,30 @@
"use strict";
exports.__esModule = true;
var _assign = require("../core-js/object/assign");
var _assign2 = _interopRequireDefault(_assign);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
exports.default = _assign2.default || 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;
};
//////////////////
// WEBPACK FOOTER
// ./~/babel-runtime/helpers/extends.js
// module id = 856
// module chunks = 4

View file

@ -0,0 +1,40 @@
"use strict";
exports.__esModule = true;
var _setPrototypeOf = require("../core-js/object/set-prototype-of");
var _setPrototypeOf2 = _interopRequireDefault(_setPrototypeOf);
var _create = require("../core-js/object/create");
var _create2 = _interopRequireDefault(_create);
var _typeof2 = require("../helpers/typeof");
var _typeof3 = _interopRequireDefault(_typeof2);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
exports.default = function (subClass, superClass) {
if (typeof superClass !== "function" && superClass !== null) {
throw new TypeError("Super expression must either be null or a function, not " + (typeof superClass === "undefined" ? "undefined" : (0, _typeof3.default)(superClass)));
}
subClass.prototype = (0, _create2.default)(superClass && superClass.prototype, {
constructor: {
value: subClass,
enumerable: false,
writable: true,
configurable: true
}
});
if (superClass) _setPrototypeOf2.default ? (0, _setPrototypeOf2.default)(subClass, superClass) : subClass.__proto__ = superClass;
};
//////////////////
// WEBPACK FOOTER
// ./~/babel-runtime/helpers/inherits.js
// module id = 1733
// module chunks = 4

View file

@ -0,0 +1,8 @@
module.exports = require("./interopRequireDefault.js");
//////////////////
// WEBPACK FOOTER
// ./~/babel-runtime/helpers/interop-require-default.js
// module id = 1734
// module chunks = 4

View file

@ -0,0 +1,16 @@
"use strict";
exports.__esModule = true;
exports.default = function (obj) {
return obj && obj.__esModule ? obj : {
default: obj
};
};
//////////////////
// WEBPACK FOOTER
// ./~/babel-runtime/helpers/interopRequireDefault.js
// module id = 1735
// module chunks = 4

View file

@ -0,0 +1,8 @@
module.exports = require("./objectWithoutProperties.js");
//////////////////
// WEBPACK FOOTER
// ./~/babel-runtime/helpers/object-without-properties.js
// module id = 1736
// module chunks = 4

View file

@ -0,0 +1,22 @@
"use strict";
exports.__esModule = true;
exports.default = function (obj, keys) {
var target = {};
for (var i in obj) {
if (keys.indexOf(i) >= 0) continue;
if (!Object.prototype.hasOwnProperty.call(obj, i)) continue;
target[i] = obj[i];
}
return target;
};
//////////////////
// WEBPACK FOOTER
// ./~/babel-runtime/helpers/objectWithoutProperties.js
// module id = 857
// module chunks = 4

View file

@ -0,0 +1,24 @@
"use strict";
exports.__esModule = true;
var _typeof2 = require("../helpers/typeof");
var _typeof3 = _interopRequireDefault(_typeof2);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
exports.default = function (self, call) {
if (!self) {
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
}
return call && ((typeof call === "undefined" ? "undefined" : (0, _typeof3.default)(call)) === "object" || typeof call === "function") ? call : self;
};
//////////////////
// WEBPACK FOOTER
// ./~/babel-runtime/helpers/possibleConstructorReturn.js
// module id = 1737
// module chunks = 4

View file

@ -0,0 +1,28 @@
"use strict";
exports.__esModule = true;
var _iterator = require("../core-js/symbol/iterator");
var _iterator2 = _interopRequireDefault(_iterator);
var _symbol = require("../core-js/symbol");
var _symbol2 = _interopRequireDefault(_symbol);
var _typeof = typeof _symbol2.default === "function" && typeof _iterator2.default === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof _symbol2.default === "function" && obj.constructor === _symbol2.default && obj !== _symbol2.default.prototype ? "symbol" : typeof obj; };
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
exports.default = typeof _symbol2.default === "function" && _typeof(_iterator2.default) === "symbol" ? function (obj) {
return typeof obj === "undefined" ? "undefined" : _typeof(obj);
} : function (obj) {
return obj && typeof _symbol2.default === "function" && obj.constructor === _symbol2.default && obj !== _symbol2.default.prototype ? "symbol" : typeof obj === "undefined" ? "undefined" : _typeof(obj);
};
//////////////////
// WEBPACK FOOTER
// ./~/babel-runtime/helpers/typeof.js
// module id = 858
// module chunks = 4

View file

@ -0,0 +1,66 @@
module.exports = balanced;
function balanced(a, b, str) {
if (a instanceof RegExp) a = maybeMatch(a, str);
if (b instanceof RegExp) b = maybeMatch(b, str);
var r = range(a, b, str);
return r && {
start: r[0],
end: r[1],
pre: str.slice(0, r[0]),
body: str.slice(r[0] + a.length, r[1]),
post: str.slice(r[1] + b.length)
};
}
function maybeMatch(reg, str) {
var m = str.match(reg);
return m ? m[0] : null;
}
balanced.range = range;
function range(a, b, str) {
var begs, beg, left, right, result;
var ai = str.indexOf(a);
var bi = str.indexOf(b, ai + 1);
var i = ai;
if (ai >= 0 && bi > 0) {
begs = [];
left = str.length;
while (i >= 0 && !result) {
if (i == ai) {
begs.push(i);
ai = str.indexOf(a, i + 1);
} else if (begs.length == 1) {
result = [ begs.pop(), bi ];
} else {
beg = begs.pop();
if (beg < left) {
left = beg;
right = bi;
}
bi = str.indexOf(b, i + 1);
}
i = ai < bi && ai >= 0 ? ai : bi;
}
if (begs.length) {
result = [ left, right ];
}
}
return result;
}
//////////////////
// WEBPACK FOOTER
// ./~/balanced-match/index.js
// module id = 1738
// module chunks = 4

View file

@ -0,0 +1,51 @@
module.exports = function(haystack, needle, comparator, low, high) {
var mid, cmp;
if(low === undefined)
low = 0;
else {
low = low|0;
if(low < 0 || low >= haystack.length)
throw new RangeError("invalid lower bound");
}
if(high === undefined)
high = haystack.length - 1;
else {
high = high|0;
if(high < low || high >= haystack.length)
throw new RangeError("invalid upper bound");
}
while(low <= high) {
/* Note that "(low + high) >>> 1" may overflow, and results in a typecast
* to double (which gives the wrong results). */
mid = low + (high - low >> 1);
cmp = +comparator(haystack[mid], needle, mid, haystack);
/* Too low. */
if(cmp < 0.0)
low = mid + 1;
/* Too high. */
else if(cmp > 0.0)
high = mid - 1;
/* Key found. */
else
return mid;
}
/* Key not found. */
return ~low;
}
//////////////////
// WEBPACK FOOTER
// ./~/binary-search/index.js
// module id = 684
// module chunks = 4

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,209 @@
var concatMap = require('concat-map');
var balanced = require('balanced-match');
module.exports = expandTop;
var escSlash = '\0SLASH'+Math.random()+'\0';
var escOpen = '\0OPEN'+Math.random()+'\0';
var escClose = '\0CLOSE'+Math.random()+'\0';
var escComma = '\0COMMA'+Math.random()+'\0';
var escPeriod = '\0PERIOD'+Math.random()+'\0';
function numeric(str) {
return parseInt(str, 10) == str
? parseInt(str, 10)
: str.charCodeAt(0);
}
function escapeBraces(str) {
return str.split('\\\\').join(escSlash)
.split('\\{').join(escOpen)
.split('\\}').join(escClose)
.split('\\,').join(escComma)
.split('\\.').join(escPeriod);
}
function unescapeBraces(str) {
return str.split(escSlash).join('\\')
.split(escOpen).join('{')
.split(escClose).join('}')
.split(escComma).join(',')
.split(escPeriod).join('.');
}
// Basically just str.split(","), but handling cases
// where we have nested braced sections, which should be
// treated as individual members, like {a,{b,c},d}
function parseCommaParts(str) {
if (!str)
return [''];
var parts = [];
var m = balanced('{', '}', str);
if (!m)
return str.split(',');
var pre = m.pre;
var body = m.body;
var post = m.post;
var p = pre.split(',');
p[p.length-1] += '{' + body + '}';
var postParts = parseCommaParts(post);
if (post.length) {
p[p.length-1] += postParts.shift();
p.push.apply(p, postParts);
}
parts.push.apply(parts, p);
return parts;
}
function expandTop(str) {
if (!str)
return [];
// I don't know why Bash 4.3 does this, but it does.
// Anything starting with {} will have the first two bytes preserved
// but *only* at the top level, so {},a}b will not expand to anything,
// but a{},b}c will be expanded to [a}c,abc].
// One could argue that this is a bug in Bash, but since the goal of
// this module is to match Bash's rules, we escape a leading {}
if (str.substr(0, 2) === '{}') {
str = '\\{\\}' + str.substr(2);
}
return expand(escapeBraces(str), true).map(unescapeBraces);
}
function identity(e) {
return e;
}
function embrace(str) {
return '{' + str + '}';
}
function isPadded(el) {
return /^-?0\d/.test(el);
}
function lte(i, y) {
return i <= y;
}
function gte(i, y) {
return i >= y;
}
function expand(str, isTop) {
var expansions = [];
var m = balanced('{', '}', str);
if (!m || /\$$/.test(m.pre)) return [str];
var isNumericSequence = /^-?\d+\.\.-?\d+(?:\.\.-?\d+)?$/.test(m.body);
var isAlphaSequence = /^[a-zA-Z]\.\.[a-zA-Z](?:\.\.-?\d+)?$/.test(m.body);
var isSequence = isNumericSequence || isAlphaSequence;
var isOptions = m.body.indexOf(',') >= 0;
if (!isSequence && !isOptions) {
// {a},b}
if (m.post.match(/,.*\}/)) {
str = m.pre + '{' + m.body + escClose + m.post;
return expand(str);
}
return [str];
}
var n;
if (isSequence) {
n = m.body.split(/\.\./);
} else {
n = parseCommaParts(m.body);
if (n.length === 1) {
// x{{a,b}}y ==> x{a}y x{b}y
n = expand(n[0], false).map(embrace);
if (n.length === 1) {
var post = m.post.length
? expand(m.post, false)
: [''];
return post.map(function(p) {
return m.pre + n[0] + p;
});
}
}
}
// at this point, n is the parts, and we know it's not a comma set
// with a single entry.
// no need to expand pre, since it is guaranteed to be free of brace-sets
var pre = m.pre;
var post = m.post.length
? expand(m.post, false)
: [''];
var N;
if (isSequence) {
var x = numeric(n[0]);
var y = numeric(n[1]);
var width = Math.max(n[0].length, n[1].length)
var incr = n.length == 3
? Math.abs(numeric(n[2]))
: 1;
var test = lte;
var reverse = y < x;
if (reverse) {
incr *= -1;
test = gte;
}
var pad = n.some(isPadded);
N = [];
for (var i = x; test(i, y); i += incr) {
var c;
if (isAlphaSequence) {
c = String.fromCharCode(i);
if (c === '\\')
c = '';
} else {
c = String(i);
if (pad) {
var need = width - c.length;
if (need > 0) {
var z = new Array(need + 1).join('0');
if (i < 0)
c = '-' + z + c.slice(1);
else
c = z + c;
}
}
}
N.push(c);
}
} else {
N = concatMap(n, function(el) { return expand(el, false) });
}
for (var j = 0; j < N.length; j++) {
for (var k = 0; k < post.length; k++) {
var expansion = pre + N[j] + post[k];
if (!isTop || isSequence || expansion)
expansions.push(expansion);
}
}
return expansions;
}
//////////////////
// WEBPACK FOOTER
// ./~/brace-expansion/index.js
// module id = 1739
// module chunks = 4

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,122 @@
'use strict'
exports.byteLength = byteLength
exports.toByteArray = toByteArray
exports.fromByteArray = fromByteArray
var lookup = []
var revLookup = []
var Arr = typeof Uint8Array !== 'undefined' ? Uint8Array : Array
var code = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
for (var i = 0, len = code.length; i < len; ++i) {
lookup[i] = code[i]
revLookup[code.charCodeAt(i)] = i
}
revLookup['-'.charCodeAt(0)] = 62
revLookup['_'.charCodeAt(0)] = 63
function placeHoldersCount (b64) {
var len = b64.length
if (len % 4 > 0) {
throw new Error('Invalid string. Length must be a multiple of 4')
}
// the number of equal signs (place holders)
// if there are two placeholders, than the two characters before it
// represent one byte
// if there is only one, then the three characters before it represent 2 bytes
// this is just a cheap hack to not do indexOf twice
return b64[len - 2] === '=' ? 2 : b64[len - 1] === '=' ? 1 : 0
}
function byteLength (b64) {
// base64 is 4/3 + up to two characters of the original data
return b64.length * 3 / 4 - placeHoldersCount(b64)
}
function toByteArray (b64) {
var i, j, l, tmp, placeHolders, arr
var len = b64.length
placeHolders = placeHoldersCount(b64)
arr = new Arr(len * 3 / 4 - placeHolders)
// if there are placeholders, only get up to the last complete 4 chars
l = placeHolders > 0 ? len - 4 : len
var L = 0
for (i = 0, j = 0; i < l; i += 4, j += 3) {
tmp = (revLookup[b64.charCodeAt(i)] << 18) | (revLookup[b64.charCodeAt(i + 1)] << 12) | (revLookup[b64.charCodeAt(i + 2)] << 6) | revLookup[b64.charCodeAt(i + 3)]
arr[L++] = (tmp >> 16) & 0xFF
arr[L++] = (tmp >> 8) & 0xFF
arr[L++] = tmp & 0xFF
}
if (placeHolders === 2) {
tmp = (revLookup[b64.charCodeAt(i)] << 2) | (revLookup[b64.charCodeAt(i + 1)] >> 4)
arr[L++] = tmp & 0xFF
} else if (placeHolders === 1) {
tmp = (revLookup[b64.charCodeAt(i)] << 10) | (revLookup[b64.charCodeAt(i + 1)] << 4) | (revLookup[b64.charCodeAt(i + 2)] >> 2)
arr[L++] = (tmp >> 8) & 0xFF
arr[L++] = tmp & 0xFF
}
return arr
}
function tripletToBase64 (num) {
return lookup[num >> 18 & 0x3F] + lookup[num >> 12 & 0x3F] + lookup[num >> 6 & 0x3F] + lookup[num & 0x3F]
}
function encodeChunk (uint8, start, end) {
var tmp
var output = []
for (var i = start; i < end; i += 3) {
tmp = (uint8[i] << 16) + (uint8[i + 1] << 8) + (uint8[i + 2])
output.push(tripletToBase64(tmp))
}
return output.join('')
}
function fromByteArray (uint8) {
var tmp
var len = uint8.length
var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes
var output = ''
var parts = []
var maxChunkLength = 16383 // must be multiple of 3
// go through the array every three bytes, we'll deal with trailing stuff later
for (var i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)))
}
// pad the end with zeros, but make sure to not forget the extra bytes
if (extraBytes === 1) {
tmp = uint8[len - 1]
output += lookup[tmp >> 2]
output += lookup[(tmp << 4) & 0x3F]
output += '=='
} else if (extraBytes === 2) {
tmp = (uint8[len - 2] << 8) + (uint8[len - 1])
output += lookup[tmp >> 10]
output += lookup[(tmp >> 4) & 0x3F]
output += lookup[(tmp << 2) & 0x3F]
output += '='
}
parts.push(output)
return parts.join('')
}
//////////////////
// WEBPACK FOOTER
// ./~/buffer/~/base64-js/index.js
// module id = 1740
// module chunks = 4

View file

@ -0,0 +1,124 @@
'use strict';
var escapeStringRegexp = require('escape-string-regexp');
var ansiStyles = require('ansi-styles');
var stripAnsi = require('strip-ansi');
var hasAnsi = require('has-ansi');
var supportsColor = require('supports-color');
var defineProps = Object.defineProperties;
var isSimpleWindowsTerm = process.platform === 'win32' && !/^xterm/i.test(process.env.TERM);
function Chalk(options) {
// detect mode if not set manually
this.enabled = !options || options.enabled === undefined ? supportsColor : options.enabled;
}
// use bright blue on Windows as the normal blue color is illegible
if (isSimpleWindowsTerm) {
ansiStyles.blue.open = '\u001b[94m';
}
var styles = (function () {
var ret = {};
Object.keys(ansiStyles).forEach(function (key) {
ansiStyles[key].closeRe = new RegExp(escapeStringRegexp(ansiStyles[key].close), 'g');
ret[key] = {
get: function () {
return build.call(this, this._styles.concat(key));
}
};
});
return ret;
})();
var proto = defineProps(function chalk() {}, styles);
function build(_styles) {
var builder = function () {
return applyStyle.apply(builder, arguments);
};
builder._styles = _styles;
builder.enabled = this.enabled;
// __proto__ is used because we must return a function, but there is
// no way to create a function with a different prototype.
/* eslint-disable no-proto */
builder.__proto__ = proto;
return builder;
}
function applyStyle() {
// support varags, but simply cast to string in case there's only one arg
var args = arguments;
var argsLen = args.length;
var str = argsLen !== 0 && String(arguments[0]);
if (argsLen > 1) {
// don't slice `arguments`, it prevents v8 optimizations
for (var a = 1; a < argsLen; a++) {
str += ' ' + args[a];
}
}
if (!this.enabled || !str) {
return str;
}
var nestedStyles = this._styles;
var i = nestedStyles.length;
// Turns out that on Windows dimmed gray text becomes invisible in cmd.exe,
// see https://github.com/chalk/chalk/issues/58
// If we're on Windows and we're dealing with a gray color, temporarily make 'dim' a noop.
var originalDim = ansiStyles.dim.open;
if (isSimpleWindowsTerm && (nestedStyles.indexOf('gray') !== -1 || nestedStyles.indexOf('grey') !== -1)) {
ansiStyles.dim.open = '';
}
while (i--) {
var code = ansiStyles[nestedStyles[i]];
// Replace any instances already present with a re-opening code
// otherwise only the part of the string until said closing code
// will be colored, and the rest will simply be 'plain'.
str = code.open + str.replace(code.closeRe, code.open) + code.close;
}
// Reset the original 'dim' if we changed it to work around the Windows dimmed gray issue.
ansiStyles.dim.open = originalDim;
return str;
}
function init() {
var ret = {};
Object.keys(styles).forEach(function (name) {
ret[name] = {
get: function () {
return build.call(this, [name]);
}
};
});
return ret;
}
defineProps(Chalk.prototype, init());
module.exports = new Chalk();
module.exports.styles = ansiStyles;
module.exports.hasColor = hasAnsi;
module.exports.stripColor = stripAnsi;
module.exports.supportsColor = supportsColor;
//////////////////
// WEBPACK FOOTER
// ./~/chalk/index.js
// module id = 393
// module chunks = 4

View file

@ -0,0 +1,58 @@
'use strict';
var argv = process.argv;
var terminator = argv.indexOf('--');
var hasFlag = function (flag) {
flag = '--' + flag;
var pos = argv.indexOf(flag);
return pos !== -1 && (terminator !== -1 ? pos < terminator : true);
};
module.exports = (function () {
if ('FORCE_COLOR' in process.env) {
return true;
}
if (hasFlag('no-color') ||
hasFlag('no-colors') ||
hasFlag('color=false')) {
return false;
}
if (hasFlag('color') ||
hasFlag('colors') ||
hasFlag('color=true') ||
hasFlag('color=always')) {
return true;
}
if (process.stdout && !process.stdout.isTTY) {
return false;
}
if (process.platform === 'win32') {
return true;
}
if ('COLORTERM' in process.env) {
return true;
}
if (process.env.TERM === 'dumb') {
return false;
}
if (/^screen|^xterm|^vt100|color|ansi|cygwin|linux/i.test(process.env.TERM)) {
return true;
}
return false;
})();
//////////////////
// WEBPACK FOOTER
// ./~/chalk/~/supports-color/index.js
// module id = 1741
// module chunks = 4

View file

@ -0,0 +1,56 @@
/*!
Copyright (c) 2016 Jed Watson.
Licensed under the MIT License (MIT), see
http://jedwatson.github.io/classnames
*/
/* global define */
(function () {
'use strict';
var hasOwn = {}.hasOwnProperty;
function classNames () {
var classes = [];
for (var i = 0; i < arguments.length; i++) {
var arg = arguments[i];
if (!arg) continue;
var argType = typeof arg;
if (argType === 'string' || argType === 'number') {
classes.push(arg);
} else if (Array.isArray(arg)) {
classes.push(classNames.apply(null, arg));
} else if (argType === 'object') {
for (var key in arg) {
if (hasOwn.call(arg, key) && arg[key]) {
classes.push(key);
}
}
}
}
return classes.join(' ');
}
if (typeof module !== 'undefined' && module.exports) {
module.exports = classNames;
} else if (typeof define === 'function' && typeof define.amd === 'object' && define.amd) {
// register as 'classnames', consistent with npm package name
define('classnames', [], function () {
return classNames;
});
} else {
window.classNames = classNames;
}
}());
//////////////////
// WEBPACK FOOTER
// ./~/classnames/index.js
// module id = 5
// module chunks = 4

View file

@ -0,0 +1,104 @@
/* eslint-env node, browser */
'use strict'
module.exports = function (element) {
var self = this
var Combokeys = self.constructor
/**
* a list of all the callbacks setup via Combokeys.bind()
*
* @type {Object}
*/
self.callbacks = {}
/**
* direct map of string combinations to callbacks used for trigger()
*
* @type {Object}
*/
self.directMap = {}
/**
* keeps track of what level each sequence is at since multiple
* sequences can start out with the same sequence
*
* @type {Object}
*/
self.sequenceLevels = {}
/**
* variable to store the setTimeout call
*
* @type {null|number}
*/
self.resetTimer
/**
* temporary state where we will ignore the next keyup
*
* @type {boolean|string}
*/
self.ignoreNextKeyup = false
/**
* temporary state where we will ignore the next keypress
*
* @type {boolean}
*/
self.ignoreNextKeypress = false
/**
* are we currently inside of a sequence?
* type of action ("keyup" or "keydown" or "keypress") or false
*
* @type {boolean|string}
*/
self.nextExpectedAction = false
self.element = element
self.addEvents()
Combokeys.instances.push(self)
return self
}
module.exports.prototype.bind = require('./prototype/bind')
module.exports.prototype.bindMultiple = require('./prototype/bindMultiple')
module.exports.prototype.unbind = require('./prototype/unbind')
module.exports.prototype.trigger = require('./prototype/trigger')
module.exports.prototype.reset = require('./prototype/reset.js')
module.exports.prototype.stopCallback = require('./prototype/stopCallback')
module.exports.prototype.handleKey = require('./prototype/handleKey')
module.exports.prototype.addEvents = require('./prototype/addEvents')
module.exports.prototype.bindSingle = require('./prototype/bindSingle')
module.exports.prototype.getKeyInfo = require('./prototype/getKeyInfo')
module.exports.prototype.pickBestAction = require('./prototype/pickBestAction')
module.exports.prototype.getReverseMap = require('./prototype/getReverseMap')
module.exports.prototype.getMatches = require('./prototype/getMatches')
module.exports.prototype.resetSequences = require('./prototype/resetSequences')
module.exports.prototype.fireCallback = require('./prototype/fireCallback')
module.exports.prototype.bindSequence = require('./prototype/bindSequence')
module.exports.prototype.resetSequenceTimer = require('./prototype/resetSequenceTimer')
module.exports.prototype.detach = require('./prototype/detach')
module.exports.instances = []
module.exports.reset = require('./reset')
/**
* variable to store the flipped version of MAP from above
* needed to check if we should use keypress or not when no action
* is specified
*
* @type {Object|undefined}
*/
module.exports.REVERSE_MAP = null
//////////////////
// WEBPACK FOOTER
// ./~/combokeys/Combokeys/index.js
// module id = 343
// module chunks = 4

View file

@ -0,0 +1,21 @@
/* eslint-env node, browser */
'use strict'
module.exports = function () {
var self = this
var on = require('./dom-event')
var element = self.element
self.eventHandler = require('./handleKeyEvent').bind(self)
on(element, 'keypress', self.eventHandler)
on(element, 'keydown', self.eventHandler)
on(element, 'keyup', self.eventHandler)
}
//////////////////
// WEBPACK FOOTER
// ./~/combokeys/Combokeys/prototype/addEvents.js
// module id = 1742
// module chunks = 4

View file

@ -0,0 +1,31 @@
/* eslint-env node, browser */
'use strict'
/**
* binds an event to Combokeys
*
* can be a single key, a combination of keys separated with +,
* an array of keys, or a sequence of keys separated by spaces
*
* be sure to list the modifier keys first to make sure that the
* correct key ends up getting bound (the last key in the pattern)
*
* @param {string|Array} keys
* @param {Function} callback
* @param {string=} action - "keypress", "keydown", or "keyup"
* @returns void
*/
module.exports = function (keys, callback, action) {
var self = this
keys = keys instanceof Array ? keys : [keys]
self.bindMultiple(keys, callback, action)
return self
}
//////////////////
// WEBPACK FOOTER
// ./~/combokeys/Combokeys/prototype/bind.js
// module id = 1743
// module chunks = 4

View file

@ -0,0 +1,26 @@
/* eslint-env node, browser */
'use strict'
/**
* binds multiple combinations to the same callback
*
* @param {Array} combinations
* @param {Function} callback
* @param {string|undefined} action
* @returns void
*/
module.exports = function (combinations, callback, action) {
var self = this
for (var j = 0; j < combinations.length; ++j) {
self.bindSingle(combinations[j], callback, action)
}
}
//////////////////
// WEBPACK FOOTER
// ./~/combokeys/Combokeys/prototype/bindMultiple.js
// module id = 1744
// module chunks = 4

View file

@ -0,0 +1,86 @@
/* eslint-env node, browser */
'use strict'
/**
* binds a key sequence to an event
*
* @param {string} combo - combo specified in bind call
* @param {Array} keys
* @param {Function} callback
* @param {string=} action
* @returns void
*/
module.exports = function (combo, keys, callback, action) {
var self = this
// start off by adding a sequence level record for this combination
// and setting the level to 0
self.sequenceLevels[combo] = 0
/**
* callback to increase the sequence level for this sequence and reset
* all other sequences that were active
*
* @param {string} nextAction
* @returns {Function}
*/
function increaseSequence (nextAction) {
return function () {
self.nextExpectedAction = nextAction
++self.sequenceLevels[combo]
self.resetSequenceTimer()
}
}
/**
* wraps the specified callback inside of another function in order
* to reset all sequence counters as soon as this sequence is done
*
* @param {Event} e
* @returns void
*/
function callbackAndReset (e) {
var characterFromEvent
self.fireCallback(callback, e, combo)
// we should ignore the next key up if the action is key down
// or keypress. this is so if you finish a sequence and
// release the key the final key will not trigger a keyup
if (action !== 'keyup') {
characterFromEvent = require('../../helpers/characterFromEvent')
self.ignoreNextKeyup = characterFromEvent(e)
}
// weird race condition if a sequence ends with the key
// another sequence begins with
setTimeout(
function () {
self.resetSequences()
},
10
)
}
// loop through keys one at a time and bind the appropriate callback
// function. for any key leading up to the final one it should
// increase the sequence. after the final, it should reset all sequences
//
// if an action is specified in the original bind call then that will
// be used throughout. otherwise we will pass the action that the
// next key in the sequence should match. this allows a sequence
// to mix and match keypress and keydown events depending on which
// ones are better suited to the key provided
for (var j = 0; j < keys.length; ++j) {
var isFinal = j + 1 === keys.length
var wrappedCallback = isFinal ? callbackAndReset : increaseSequence(action || self.getKeyInfo(keys[j + 1]).action)
self.bindSingle(keys[j], wrappedCallback, action, combo, j)
}
}
//////////////////
// WEBPACK FOOTER
// ./~/combokeys/Combokeys/prototype/bindSequence.js
// module id = 1745
// module chunks = 4

View file

@ -0,0 +1,64 @@
/* eslint-env node, browser */
'use strict'
/**
* binds a single keyboard combination
*
* @param {string} combination
* @param {Function} callback
* @param {string=} action
* @param {string=} sequenceName - name of sequence if part of sequence
* @param {number=} level - what part of the sequence the command is
* @returns void
*/
module.exports = function (combination, callback, action, sequenceName, level) {
var self = this
// store a direct mapped reference for use with Combokeys.trigger
self.directMap[combination + ':' + action] = callback
// make sure multiple spaces in a row become a single space
combination = combination.replace(/\s+/g, ' ')
var sequence = combination.split(' ')
var info
// if this pattern is a sequence of keys then run through this method
// to reprocess each pattern one key at a time
if (sequence.length > 1) {
self.bindSequence(combination, sequence, callback, action)
return
}
info = self.getKeyInfo(combination, action)
// make sure to initialize array if this is the first time
// a callback is added for this key
self.callbacks[info.key] = self.callbacks[info.key] || []
// remove an existing match if there is one
self.getMatches(info.key, info.modifiers, {type: info.action}, sequenceName, combination, level)
// add this call back to the array
// if it is a sequence put it at the beginning
// if not put it at the end
//
// this is important because the way these are processed expects
// the sequence ones to come first
self.callbacks[info.key][sequenceName ? 'unshift' : 'push']({
callback: callback,
modifiers: info.modifiers,
action: info.action,
seq: sequenceName,
level: level,
combo: combination
})
}
//////////////////
// WEBPACK FOOTER
// ./~/combokeys/Combokeys/prototype/bindSingle.js
// module id = 1746
// module chunks = 4

View file

@ -0,0 +1,17 @@
var off = require('./dom-event').off
module.exports = function () {
var self = this
var element = self.element
off(element, 'keypress', self.eventHandler)
off(element, 'keydown', self.eventHandler)
off(element, 'keyup', self.eventHandler)
}
//////////////////
// WEBPACK FOOTER
// ./~/combokeys/Combokeys/prototype/detach.js
// module id = 1747
// module chunks = 4

View file

@ -0,0 +1,23 @@
module.exports = on
module.exports.on = on
module.exports.off = off
function on (element, event, callback, capture) {
!element.addEventListener && (event = 'on' + event)
;(element.addEventListener || element.attachEvent).call(element, event, callback, capture)
return callback
}
function off (element, event, callback, capture) {
!element.removeEventListener && (event = 'on' + event)
;(element.removeEventListener || element.detachEvent).call(element, event, callback, capture)
return callback
}
//////////////////
// WEBPACK FOOTER
// ./~/combokeys/Combokeys/prototype/dom-event.js
// module id = 859
// module chunks = 4

View file

@ -0,0 +1,38 @@
/* eslint-env node, browser */
'use strict'
/**
* actually calls the callback function
*
* if your callback function returns false this will use the jquery
* convention - prevent default and stop propogation on the event
*
* @param {Function} callback
* @param {Event} e
* @returns void
*/
module.exports = function (callback, e, combo, sequence) {
var self = this
var preventDefault
var stopPropagation
// if this event should not happen stop here
if (self.stopCallback(e, e.target || e.srcElement, combo, sequence)) {
return
}
if (callback(e, combo) === false) {
preventDefault = require('../../helpers/preventDefault')
preventDefault(e)
stopPropagation = require('../../helpers/stopPropagation')
stopPropagation(e)
}
}
//////////////////
// WEBPACK FOOTER
// ./~/combokeys/Combokeys/prototype/fireCallback.js
// module id = 1748
// module chunks = 4

View file

@ -0,0 +1,69 @@
/* eslint-env node, browser */
'use strict'
/**
* Gets info for a specific key combination
*
* @param {string} combination key combination ("command+s" or "a" or "*")
* @param {string=} action
* @returns {Object}
*/
module.exports = function (combination, action) {
var self = this
var keysFromString
var keys
var key
var j
var modifiers = []
var SPECIAL_ALIASES
var SHIFT_MAP
var isModifier
keysFromString = require('../../helpers/keysFromString')
// take the keys from this pattern and figure out what the actual
// pattern is all about
keys = keysFromString(combination)
SPECIAL_ALIASES = require('../../helpers/special-aliases')
SHIFT_MAP = require('../../helpers/shift-map')
isModifier = require('../../helpers/isModifier')
for (j = 0; j < keys.length; ++j) {
key = keys[j]
// normalize key names
if (SPECIAL_ALIASES[key]) {
key = SPECIAL_ALIASES[key]
}
// if this is not a keypress event then we should
// be smart about using shift keys
// this will only work for US keyboards however
if (action && action !== 'keypress' && SHIFT_MAP[key]) {
key = SHIFT_MAP[key]
modifiers.push('shift')
}
// if this key is a modifier then add it to the list of modifiers
if (isModifier(key)) {
modifiers.push(key)
}
}
// depending on what the key combination is
// we will try to pick the best event for it
action = self.pickBestAction(key, modifiers, action)
return {
key: key,
modifiers: modifiers,
action: action
}
}
//////////////////
// WEBPACK FOOTER
// ./~/combokeys/Combokeys/prototype/getKeyInfo.js
// module id = 1749
// module chunks = 4

View file

@ -0,0 +1,95 @@
/* eslint-env node, browser */
'use strict'
/**
* finds all callbacks that match based on the keycode, modifiers,
* and action
*
* @param {string} character
* @param {Array} modifiers
* @param {Event|Object} e
* @param {string=} sequenceName - name of the sequence we are looking for
* @param {string=} combination
* @param {number=} level
* @returns {Array}
*/
module.exports = function (character, modifiers, e, sequenceName, combination, level) {
var self = this
var j
var callback
var matches = []
var action = e.type
var isModifier
var modifiersMatch
if (
action === 'keypress' &&
// Firefox fires keypress for arrows
!(e.code && e.code.slice(0, 5) === 'Arrow')
) {
// 'any-character' callbacks are only on `keypress`
var anyCharCallbacks = self.callbacks['any-character'] || []
anyCharCallbacks.forEach(function (callback) {
matches.push(callback)
})
}
if (!self.callbacks[character]) { return matches }
isModifier = require('../../helpers/isModifier')
// if a modifier key is coming up on its own we should allow it
if (action === 'keyup' && isModifier(character)) {
modifiers = [character]
}
// loop through all callbacks for the key that was pressed
// and see if any of them match
for (j = 0; j < self.callbacks[character].length; ++j) {
callback = self.callbacks[character][j]
// if a sequence name is not specified, but this is a sequence at
// the wrong level then move onto the next match
if (!sequenceName && callback.seq && self.sequenceLevels[callback.seq] !== callback.level) {
continue
}
// if the action we are looking for doesn't match the action we got
// then we should keep going
if (action !== callback.action) {
continue
}
// if this is a keypress event and the meta key and control key
// are not pressed that means that we need to only look at the
// character, otherwise check the modifiers as well
//
// chrome will not fire a keypress if meta or control is down
// safari will fire a keypress if meta or meta+shift is down
// firefox will fire a keypress if meta or control is down
modifiersMatch = require('./modifiersMatch')
if ((action === 'keypress' && !e.metaKey && !e.ctrlKey) || modifiersMatch(modifiers, callback.modifiers)) {
// when you bind a combination or sequence a second time it
// should overwrite the first one. if a sequenceName or
// combination is specified in this call it does just that
//
// @todo make deleting its own method?
var deleteCombo = !sequenceName && callback.combo === combination
var deleteSequence = sequenceName && callback.seq === sequenceName && callback.level === level
if (deleteCombo || deleteSequence) {
self.callbacks[character].splice(j, 1)
}
matches.push(callback)
}
}
return matches
}
//////////////////
// WEBPACK FOOTER
// ./~/combokeys/Combokeys/prototype/getMatches.js
// module id = 1750
// module chunks = 4

View file

@ -0,0 +1,39 @@
/* eslint-env node, browser */
'use strict'
/**
* reverses the map lookup so that we can look for specific keys
* to see what can and can't use keypress
*
* @return {Object}
*/
module.exports = function () {
var self = this
var constructor = self.constructor
var SPECIAL_KEYS_MAP
if (!constructor.REVERSE_MAP) {
constructor.REVERSE_MAP = {}
SPECIAL_KEYS_MAP = require('../../helpers/special-keys-map')
for (var key in SPECIAL_KEYS_MAP) {
// pull out the numeric keypad from here cause keypress should
// be able to detect the keys from the character
if (key > 95 && key < 112) {
continue
}
if (SPECIAL_KEYS_MAP.hasOwnProperty(key)) {
constructor.REVERSE_MAP[SPECIAL_KEYS_MAP[key]] = key
}
}
}
return constructor.REVERSE_MAP
}
//////////////////
// WEBPACK FOOTER
// ./~/combokeys/Combokeys/prototype/getReverseMap.js
// module id = 1751
// module chunks = 4

View file

@ -0,0 +1,101 @@
/* eslint-env node, browser */
'use strict'
/**
* handles a character key event
*
* @param {string} character
* @param {Array} modifiers
* @param {Event} e
* @returns void
*/
module.exports = function (character, modifiers, e) {
var self = this
var callbacks
var j
var doNotReset = {}
var maxLevel = 0
var processedSequenceCallback = false
var isModifier
var ignoreThisKeypress
callbacks = self.getMatches(character, modifiers, e)
// Calculate the maxLevel for sequences so we can only execute the longest callback sequence
for (j = 0; j < callbacks.length; ++j) {
if (callbacks[j].seq) {
maxLevel = Math.max(maxLevel, callbacks[j].level)
}
}
// loop through matching callbacks for this key event
for (j = 0; j < callbacks.length; ++j) {
// fire for all sequence callbacks
// this is because if for example you have multiple sequences
// bound such as "g i" and "g t" they both need to fire the
// callback for matching g cause otherwise you can only ever
// match the first one
if (callbacks[j].seq) {
// only fire callbacks for the maxLevel to prevent
// subsequences from also firing
//
// for example 'a option b' should not cause 'option b' to fire
// even though 'option b' is part of the other sequence
//
// any sequences that do not match here will be discarded
// below by the resetSequences call
if (callbacks[j].level !== maxLevel) {
continue
}
processedSequenceCallback = true
// keep a list of which sequences were matches for later
doNotReset[callbacks[j].seq] = 1
self.fireCallback(callbacks[j].callback, e, callbacks[j].combo, callbacks[j].seq)
continue
}
// if there were no sequence matches but we are still here
// that means this is a regular match so we should fire that
if (!processedSequenceCallback) {
self.fireCallback(callbacks[j].callback, e, callbacks[j].combo)
}
}
// if the key you pressed matches the type of sequence without
// being a modifier (ie "keyup" or "keypress") then we should
// reset all sequences that were not matched by this event
//
// this is so, for example, if you have the sequence "h a t" and you
// type "h e a r t" it does not match. in this case the "e" will
// cause the sequence to reset
//
// modifier keys are ignored because you can have a sequence
// that contains modifiers such as "enter ctrl+space" and in most
// cases the modifier key will be pressed before the next key
//
// also if you have a sequence such as "ctrl+b a" then pressing the
// "b" key will trigger a "keypress" and a "keydown"
//
// the "keydown" is expected when there is a modifier, but the
// "keypress" ends up matching the nextExpectedAction since it occurs
// after and that causes the sequence to reset
//
// we ignore keypresses in a sequence that directly follow a keydown
// for the same character
ignoreThisKeypress = e.type === 'keypress' && self.ignoreNextKeypress
isModifier = require('../../helpers/isModifier')
if (e.type === self.nextExpectedAction && !isModifier(character) && !ignoreThisKeypress) {
self.resetSequences(doNotReset)
}
self.ignoreNextKeypress = processedSequenceCallback && e.type === 'keydown'
}
//////////////////
// WEBPACK FOOTER
// ./~/combokeys/Combokeys/prototype/handleKey.js
// module id = 1752
// module chunks = 4

View file

@ -0,0 +1,44 @@
/* eslint-env node, browser */
'use strict'
/**
* handles a keydown event
*
* @param {Event} e
* @returns void
*/
module.exports = function (e) {
var self = this
var characterFromEvent
var eventModifiers
// normalize e.which for key events
// @see http://stackoverflow.com/questions/4285627/javascript-keycode-vs-charcode-utter-confusion
if (typeof e.which !== 'number') {
e.which = e.keyCode
}
characterFromEvent = require('../../helpers/characterFromEvent')
var character = characterFromEvent(e)
// no character found then stop
if (!character) {
return
}
// need to use === for the character check because the character can be 0
if (e.type === 'keyup' && self.ignoreNextKeyup === character) {
self.ignoreNextKeyup = false
return
}
eventModifiers = require('../../helpers/eventModifiers')
self.handleKey(character, eventModifiers(e), e)
}
//////////////////
// WEBPACK FOOTER
// ./~/combokeys/Combokeys/prototype/handleKeyEvent.js
// module id = 1753
// module chunks = 4

View file

@ -0,0 +1,21 @@
/* eslint-env node, browser */
'use strict'
/**
* checks if two arrays are equal
*
* @param {Array} modifiers1
* @param {Array} modifiers2
* @returns {boolean}
*/
module.exports = function (modifiers1, modifiers2) {
return modifiers1.sort().join(',') === modifiers2.sort().join(',')
}
//////////////////
// WEBPACK FOOTER
// ./~/combokeys/Combokeys/prototype/modifiersMatch.js
// module id = 1754
// module chunks = 4

View file

@ -0,0 +1,35 @@
/* eslint-env node, browser */
'use strict'
/**
* picks the best action based on the key combination
*
* @param {string} key - character for key
* @param {Array} modifiers
* @param {string=} action passed in
*/
module.exports = function (key, modifiers, action) {
var self = this
// if no action was picked in we should try to pick the one
// that we think would work best for this key
if (!action) {
action = self.getReverseMap()[key] ? 'keydown' : 'keypress'
}
// modifier keys don't work as expected with keypress,
// switch to keydown
if (action === 'keypress' && modifiers.length) {
action = 'keydown'
}
return action
}
//////////////////
// WEBPACK FOOTER
// ./~/combokeys/Combokeys/prototype/pickBestAction.js
// module id = 1755
// module chunks = 4

View file

@ -0,0 +1,24 @@
/* eslint-env node, browser */
'use strict'
/**
* resets the library back to its initial state. This is useful
* if you want to clear out the current keyboard shortcuts and bind
* new ones - for example if you switch to another page
*
* @returns void
*/
module.exports = function () {
var self = this
self.callbacks = {}
self.directMap = {}
return this
}
//////////////////
// WEBPACK FOOTER
// ./~/combokeys/Combokeys/prototype/reset.js
// module id = 1756
// module chunks = 4

View file

@ -0,0 +1,29 @@
/* eslint-env node, browser */
'use strict'
/**
* called to set a 1 second timeout on the specified sequence
*
* this is so after each key press in the sequence you have 1 second
* to press the next key before you have to start over
*
* @returns void
*/
module.exports = function () {
var self = this
clearTimeout(self.resetTimer)
self.resetTimer = setTimeout(
function () {
self.resetSequences()
},
1000
)
}
//////////////////
// WEBPACK FOOTER
// ./~/combokeys/Combokeys/prototype/resetSequenceTimer.js
// module id = 1757
// module chunks = 4

View file

@ -0,0 +1,37 @@
/* eslint-env node, browser */
'use strict'
/**
* resets all sequence counters except for the ones passed in
*
* @param {Object} doNotReset
* @returns void
*/
module.exports = function (doNotReset) {
var self = this
doNotReset = doNotReset || {}
var activeSequences = false
var key
for (key in self.sequenceLevels) {
if (doNotReset[key]) {
activeSequences = true
continue
}
self.sequenceLevels[key] = 0
}
if (!activeSequences) {
self.nextExpectedAction = false
}
}
//////////////////
// WEBPACK FOOTER
// ./~/combokeys/Combokeys/prototype/resetSequences.js
// module id = 1758
// module chunks = 4

View file

@ -0,0 +1,29 @@
/* eslint-env node, browser */
'use strict'
/**
* should we stop this event before firing off callbacks
*
* @param {Event} e
* @param {Element} element
* @return {boolean}
*/
module.exports = function (e, element) {
// if the element has the class "combokeys" then no need to stop
if ((' ' + element.className + ' ').indexOf(' combokeys ') > -1) {
return false
}
var tagName = element.tagName.toLowerCase()
// stop for input, select, and textarea
return tagName === 'input' || tagName === 'select' || tagName === 'textarea' || element.isContentEditable
}
//////////////////
// WEBPACK FOOTER
// ./~/combokeys/Combokeys/prototype/stopCallback.js
// module id = 1759
// module chunks = 4

View file

@ -0,0 +1,24 @@
/* eslint-env node, browser */
'use strict'
/**
* triggers an event that has already been bound
*
* @param {string} keys
* @param {string=} action
* @returns void
*/
module.exports = function (keys, action) {
var self = this
if (self.directMap[keys + ':' + action]) {
self.directMap[keys + ':' + action]({}, keys)
}
return this
}
//////////////////
// WEBPACK FOOTER
// ./~/combokeys/Combokeys/prototype/trigger.js
// module id = 1760
// module chunks = 4

View file

@ -0,0 +1,32 @@
/* eslint-env node, browser */
'use strict'
/**
* unbinds an event to Combokeys
*
* the unbinding sets the callback function of the specified key combo
* to an empty function and deletes the corresponding key in the
* directMap dict.
*
* TODO: actually remove this from the callbacks dictionary instead
* of binding an empty function
*
* the keycombo+action has to be exactly the same as
* it was defined in the bind method
*
* @param {string|Array} keys
* @param {string} action
* @returns void
*/
module.exports = function (keys, action) {
var self = this
return self.bind(keys, function () {}, action)
}
//////////////////
// WEBPACK FOOTER
// ./~/combokeys/Combokeys/prototype/unbind.js
// module id = 1761
// module chunks = 4

View file

@ -0,0 +1,18 @@
/* eslint-env node, browser */
'use strict'
module.exports = function () {
var self = this
self.instances.forEach(function (combokeys) {
combokeys.reset()
})
}
//////////////////
// WEBPACK FOOTER
// ./~/combokeys/Combokeys/reset.js
// module id = 1762
// module chunks = 4

View file

@ -0,0 +1,59 @@
/* eslint-env node, browser */
'use strict'
/**
* takes the event and returns the key character
*
* @param {Event} e
* @return {string}
*/
module.exports = function (e) {
var SPECIAL_KEYS_MAP,
SPECIAL_CHARACTERS_MAP
SPECIAL_KEYS_MAP = require('./special-keys-map')
SPECIAL_CHARACTERS_MAP = require('./special-characters-map')
// for keypress events we should return the character as is
if (e.type === 'keypress') {
var character = String.fromCharCode(e.which)
// if the shift key is not pressed then it is safe to assume
// that we want the character to be lowercase. this means if
// you accidentally have caps lock on then your key bindings
// will continue to work
//
// the only side effect that might not be desired is if you
// bind something like 'A' cause you want to trigger an
// event when capital A is pressed caps lock will no longer
// trigger the event. shift+a will though.
if (!e.shiftKey) {
character = character.toLowerCase()
}
return character
}
// for non keypress events the special maps are needed
if (SPECIAL_KEYS_MAP[e.which]) {
return SPECIAL_KEYS_MAP[e.which]
}
if (SPECIAL_CHARACTERS_MAP[e.which]) {
return SPECIAL_CHARACTERS_MAP[e.which]
}
// if it is not in the special map
// with keydown and keyup events the character seems to always
// come in as an uppercase character whether you are pressing shift
// or not. we should make sure it is always lowercase for comparisons
return String.fromCharCode(e.which).toLowerCase()
}
//////////////////
// WEBPACK FOOTER
// ./~/combokeys/helpers/characterFromEvent.js
// module id = 860
// module chunks = 4

View file

@ -0,0 +1,38 @@
/* eslint-env node, browser */
'use strict'
/**
* takes a key event and figures out what the modifiers are
*
* @param {Event} e
* @returns {Array}
*/
module.exports = function (e) {
var modifiers = []
if (e.shiftKey) {
modifiers.push('shift')
}
if (e.altKey) {
modifiers.push('alt')
}
if (e.ctrlKey) {
modifiers.push('ctrl')
}
if (e.metaKey) {
modifiers.push('meta')
}
return modifiers
}
//////////////////
// WEBPACK FOOTER
// ./~/combokeys/helpers/eventModifiers.js
// module id = 1763
// module chunks = 4

View file

@ -0,0 +1,20 @@
/* eslint-env node, browser */
'use strict'
/**
* determines if the keycode specified is a modifier key or not
*
* @param {string} key
* @returns {boolean}
*/
module.exports = function (key) {
return key === 'shift' || key === 'ctrl' || key === 'alt' || key === 'meta'
}
//////////////////
// WEBPACK FOOTER
// ./~/combokeys/helpers/isModifier.js
// module id = 547
// module chunks = 4

View file

@ -0,0 +1,24 @@
/* eslint-env node, browser */
'use strict'
/**
* Converts from a string key combination to an array
*
* @param {string} combination like "command+shift+l"
* @return {Array}
*/
module.exports = function (combination) {
if (combination === '+') {
return ['+']
}
return combination.split('+')
}
//////////////////
// WEBPACK FOOTER
// ./~/combokeys/helpers/keysFromString.js
// module id = 1764
// module chunks = 4

View file

@ -0,0 +1,25 @@
/* eslint-env node, browser */
'use strict'
/**
* prevents default for this event
*
* @param {Event} e
* @returns void
*/
module.exports = function (e) {
if (e.preventDefault) {
e.preventDefault()
return
}
e.returnValue = false
}
//////////////////
// WEBPACK FOOTER
// ./~/combokeys/helpers/preventDefault.js
// module id = 1765
// module chunks = 4

View file

@ -0,0 +1,41 @@
/* eslint-env node, browser */
'use strict'
/**
* this is a mapping of keys that require shift on a US keypad
* back to the non shift equivelents
*
* this is so you can use keyup events with these keys
*
* note that this will only work reliably on US keyboards
*
* @type {Object}
*/
module.exports = {
'~': '`',
'!': '1',
'@': '2',
'#': '3',
'$': '4',
'%': '5',
'^': '6',
'&': '7',
'*': '8',
'(': '9',
')': '0',
'_': '-',
'+': '=',
':': ';',
'"': "'",
'<': ',',
'>': '.',
'?': '/',
'|': '\\'
}
//////////////////
// WEBPACK FOOTER
// ./~/combokeys/helpers/shift-map.js
// module id = 1766
// module chunks = 4

View file

@ -0,0 +1,23 @@
/* eslint-env node, browser */
'use strict'
/**
* this is a list of special strings you can use to map
* to modifier keys when you specify your keyboard shortcuts
*
* @type {Object}
*/
module.exports = {
'option': 'alt',
'command': 'meta',
'return': 'enter',
'escape': 'esc',
'mod': /Mac|iPod|iPhone|iPad/.test(navigator.platform) ? 'meta' : 'ctrl'
}
//////////////////
// WEBPACK FOOTER
// ./~/combokeys/helpers/special-aliases.js
// module id = 1767
// module chunks = 4

View file

@ -0,0 +1,36 @@
/* eslint-env node, browser */
'use strict'
/**
* mapping for special characters so they can support
*
* this dictionary is only used incase you want to bind a
* keyup or keydown event to one of these keys
*
* @type {Object}
*/
module.exports = {
106: '*',
107: '+',
109: '-',
110: '.',
111: '/',
186: ';',
187: '=',
188: ',',
189: '-',
190: '.',
191: '/',
192: '`',
219: '[',
220: '\\',
221: ']',
222: "'"
}
//////////////////
// WEBPACK FOOTER
// ./~/combokeys/helpers/special-characters-map.js
// module id = 1768
// module chunks = 4

View file

@ -0,0 +1,60 @@
/* eslint-env node, browser */
'use strict'
/**
* mapping of special keycodes to their corresponding keys
*
* everything in this dictionary cannot use keypress events
* so it has to be here to map to the correct keycodes for
* keyup/keydown events
*
* @type {Object}
*/
module.exports = {
8: 'backspace',
9: 'tab',
13: 'enter',
16: 'shift',
17: 'ctrl',
18: 'alt',
20: 'capslock',
27: 'esc',
32: 'space',
33: 'pageup',
34: 'pagedown',
35: 'end',
36: 'home',
37: 'left',
38: 'up',
39: 'right',
40: 'down',
45: 'ins',
46: 'del',
91: 'meta',
93: 'meta',
187: 'plus',
189: 'minus',
224: 'meta'
}
/**
* loop through the f keys, f1 to f19 and add them to the map
* programatically
*/
for (var i = 1; i < 20; ++i) {
module.exports[111 + i] = 'f' + i
}
/**
* loop through to map numbers on the numeric keypad
*/
for (i = 0; i <= 9; ++i) {
module.exports[i + 96] = i
}
//////////////////
// WEBPACK FOOTER
// ./~/combokeys/helpers/special-keys-map.js
// module id = 861
// module chunks = 4

View file

@ -0,0 +1,25 @@
/* eslint-env node, browser */
'use strict'
/**
* stops propogation for this event
*
* @param {Event} e
* @returns void
*/
module.exports = function (e) {
if (e.stopPropagation) {
e.stopPropagation()
return
}
e.cancelBubble = true
}
//////////////////
// WEBPACK FOOTER
// ./~/combokeys/helpers/stopPropagation.js
// module id = 1769
// module chunks = 4

View file

@ -0,0 +1,45 @@
/* eslint-env node, browser */
'use strict'
/**
* adds a bindGlobal method to Combokeys that allows you to
* bind specific keyboard shortcuts that will still work
* inside a text input field
*
* usage:
* Combokeys.bindGlobal("ctrl+s", _saveChanges)
*/
module.exports = function (Combokeys) {
var globalCallbacks = {}
var originalStopCallback = Combokeys.stopCallback
Combokeys.stopCallback = function (e, element, combo, sequence) {
if (globalCallbacks[combo] || globalCallbacks[sequence]) {
return false
}
return originalStopCallback(e, element, combo)
}
Combokeys.bindGlobal = function (keys, callback, action) {
this.bind(keys, callback, action)
if (keys instanceof Array) {
for (var i = 0; i < keys.length; i++) {
globalCallbacks[keys[i]] = true
}
return
}
globalCallbacks[keys] = true
}
return Combokeys
}
//////////////////
// WEBPACK FOOTER
// ./~/combokeys/plugins/global-bind/index.js
// module id = 862
// module chunks = 2

View file

@ -0,0 +1,172 @@
/**
* Expose `Emitter`.
*/
module.exports = Emitter;
/**
* Initialize a new `Emitter`.
*
* @api public
*/
function Emitter(obj) {
if (obj) return mixin(obj);
};
/**
* Mixin the emitter properties.
*
* @param {Object} obj
* @return {Object}
* @api private
*/
function mixin(obj) {
for (var key in Emitter.prototype) {
obj[key] = Emitter.prototype[key];
}
return obj;
}
/**
* Listen on the given `event` with `fn`.
*
* @param {String} event
* @param {Function} fn
* @return {Emitter}
* @api public
*/
Emitter.prototype.on =
Emitter.prototype.addEventListener = function(event, fn){
this._callbacks = this._callbacks || {};
(this._callbacks[event] = this._callbacks[event] || [])
.push(fn);
return this;
};
/**
* Adds an `event` listener that will be invoked a single
* time then automatically removed.
*
* @param {String} event
* @param {Function} fn
* @return {Emitter}
* @api public
*/
Emitter.prototype.once = function(event, fn){
var self = this;
this._callbacks = this._callbacks || {};
function on() {
self.off(event, on);
fn.apply(this, arguments);
}
on.fn = fn;
this.on(event, on);
return this;
};
/**
* Remove the given callback for `event` or all
* registered callbacks.
*
* @param {String} event
* @param {Function} fn
* @return {Emitter}
* @api public
*/
Emitter.prototype.off =
Emitter.prototype.removeListener =
Emitter.prototype.removeAllListeners =
Emitter.prototype.removeEventListener = function(event, fn){
this._callbacks = this._callbacks || {};
// all
if (0 == arguments.length) {
this._callbacks = {};
return this;
}
// specific event
var callbacks = this._callbacks[event];
if (!callbacks) return this;
// remove all handlers
if (1 == arguments.length) {
delete this._callbacks[event];
return this;
}
// remove specific handler
var cb;
for (var i = 0; i < callbacks.length; i++) {
cb = callbacks[i];
if (cb === fn || cb.fn === fn) {
callbacks.splice(i, 1);
break;
}
}
return this;
};
/**
* Emit `event` with the given args.
*
* @param {String} event
* @param {Mixed} ...
* @return {Emitter}
*/
Emitter.prototype.emit = function(event){
this._callbacks = this._callbacks || {};
var args = [].slice.call(arguments, 1)
, callbacks = this._callbacks[event];
if (callbacks) {
callbacks = callbacks.slice(0);
for (var i = 0, len = callbacks.length; i < len; ++i) {
callbacks[i].apply(this, args);
}
}
return this;
};
/**
* Return array of callbacks for `event`.
*
* @param {String} event
* @return {Array}
* @api public
*/
Emitter.prototype.listeners = function(event){
this._callbacks = this._callbacks || {};
return this._callbacks[event] || [];
};
/**
* Check if this emitter has `event` handlers.
*
* @param {String} event
* @return {Boolean}
* @api public
*/
Emitter.prototype.hasListeners = function(event){
return !! this.listeners(event).length;
};
//////////////////
// WEBPACK FOOTER
// ./~/component-emitter/index.js
// module id = 1770
// module chunks = 4

View file

@ -0,0 +1,21 @@
module.exports = function (xs, fn) {
var res = [];
for (var i = 0; i < xs.length; i++) {
var x = fn(xs[i], i);
if (isArray(x)) res.push.apply(res, x);
else res.push(x);
}
return res;
};
var isArray = Array.isArray || function (xs) {
return Object.prototype.toString.call(xs) === '[object Array]';
};
//////////////////
// WEBPACK FOOTER
// ./~/concat-map/index.js
// module id = 1771
// module chunks = 4

View file

@ -0,0 +1,166 @@
/*!
* cookie
* Copyright(c) 2012-2014 Roman Shtylman
* Copyright(c) 2015 Douglas Christopher Wilson
* MIT Licensed
*/
/**
* Module exports.
* @public
*/
exports.parse = parse;
exports.serialize = serialize;
/**
* Module variables.
* @private
*/
var decode = decodeURIComponent;
var encode = encodeURIComponent;
var pairSplitRegExp = /; */;
/**
* RegExp to match field-content in RFC 7230 sec 3.2
*
* field-content = field-vchar [ 1*( SP / HTAB ) field-vchar ]
* field-vchar = VCHAR / obs-text
* obs-text = %x80-FF
*/
var fieldContentRegExp = /^[\u0009\u0020-\u007e\u0080-\u00ff]+$/;
/**
* Parse a cookie header.
*
* Parse the given cookie header string into an object
* The object has the various cookies as keys(names) => values
*
* @param {string} str
* @param {object} [options]
* @return {object}
* @public
*/
function parse(str, options) {
if (typeof str !== 'string') {
throw new TypeError('argument str must be a string');
}
var obj = {}
var opt = options || {};
var pairs = str.split(pairSplitRegExp);
var dec = opt.decode || decode;
pairs.forEach(function(pair) {
var eq_idx = pair.indexOf('=')
// skip things that don't look like key=value
if (eq_idx < 0) {
return;
}
var key = pair.substr(0, eq_idx).trim()
var val = pair.substr(++eq_idx, pair.length).trim();
// quoted values
if ('"' == val[0]) {
val = val.slice(1, -1);
}
// only assign once
if (undefined == obj[key]) {
obj[key] = tryDecode(val, dec);
}
});
return obj;
}
/**
* Serialize data into a cookie header.
*
* Serialize the a name value pair into a cookie string suitable for
* http headers. An optional options object specified cookie parameters.
*
* serialize('foo', 'bar', { httpOnly: true })
* => "foo=bar; httpOnly"
*
* @param {string} name
* @param {string} val
* @param {object} [options]
* @return {string}
* @public
*/
function serialize(name, val, options) {
var opt = options || {};
var enc = opt.encode || encode;
if (!fieldContentRegExp.test(name)) {
throw new TypeError('argument name is invalid');
}
var value = enc(val);
if (value && !fieldContentRegExp.test(value)) {
throw new TypeError('argument val is invalid');
}
var pairs = [name + '=' + value];
if (null != opt.maxAge) {
var maxAge = opt.maxAge - 0;
if (isNaN(maxAge)) throw new Error('maxAge should be a Number');
pairs.push('Max-Age=' + Math.floor(maxAge));
}
if (opt.domain) {
if (!fieldContentRegExp.test(opt.domain)) {
throw new TypeError('option domain is invalid');
}
pairs.push('Domain=' + opt.domain);
}
if (opt.path) {
if (!fieldContentRegExp.test(opt.path)) {
throw new TypeError('option path is invalid');
}
pairs.push('Path=' + opt.path);
}
if (opt.expires) pairs.push('Expires=' + opt.expires.toUTCString());
if (opt.httpOnly) pairs.push('HttpOnly');
if (opt.secure) pairs.push('Secure');
if (opt.firstPartyOnly) pairs.push('First-Party-Only');
return pairs.join('; ');
}
/**
* Try decoding a string using a decoding function.
*
* @param {string} str
* @param {function} decode
* @private
*/
function tryDecode(str, decode) {
try {
return decode(str);
} catch (e) {
return str;
}
}
//////////////////
// WEBPACK FOOTER
// ./~/cookie/index.js
// module id = 1198
// module chunks = 4

Some files were not shown because too many files have changed in this diff Show more