mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
Upgrade Prettier from 1.17 to 2.0.2.
Summary: This gets us on the latest Prettier 2.x: https://prettier.io/blog/2020/03/21/2.0.0.html Notably, this adds support for TypeScript 3.8, which introduces new syntax, such as `import type`. Reviewed By: zertosh Differential Revision: D20636268 fbshipit-source-id: fca5833d003804333a05ba16325bbbe0e06d6c8a
This commit is contained in:
committed by
Facebook GitHub Bot
parent
79c69bea02
commit
cf44650b3f
@@ -39,7 +39,7 @@ class AccessibilityManagerTest extends React.Component<{...}> {
|
||||
accessibilityExtraExtraLarge: 11.0,
|
||||
accessibilityExtraExtraExtraLarge: 12.0,
|
||||
});
|
||||
RCTDeviceEventEmitter.addListener('didUpdateDimensions', update => {
|
||||
RCTDeviceEventEmitter.addListener('didUpdateDimensions', (update) => {
|
||||
TestModule.markTestPassed(update.window.fontScale === 4.0);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -66,7 +66,7 @@ function expectAsyncNoError(place, err) {
|
||||
}
|
||||
|
||||
function testSetAndGet() {
|
||||
AsyncStorage.setItem(KEY_1, VAL_1, err1 => {
|
||||
AsyncStorage.setItem(KEY_1, VAL_1, (err1) => {
|
||||
expectAsyncNoError('testSetAndGet/setItem', err1);
|
||||
AsyncStorage.getItem(KEY_1, (err2, result) => {
|
||||
expectAsyncNoError('testSetAndGet/getItem', err2);
|
||||
@@ -109,7 +109,7 @@ function testRemoveItem() {
|
||||
'Missing KEY_1 or KEY_2 in ' + '(' + result + ')',
|
||||
);
|
||||
updateMessage('testRemoveItem - add two items');
|
||||
AsyncStorage.removeItem(KEY_1, err2 => {
|
||||
AsyncStorage.removeItem(KEY_1, (err2) => {
|
||||
expectAsyncNoError('testRemoveItem/removeItem', err2);
|
||||
updateMessage('delete successful ');
|
||||
AsyncStorage.getItem(KEY_1, (err3, result2) => {
|
||||
@@ -137,9 +137,9 @@ function testRemoveItem() {
|
||||
}
|
||||
|
||||
function testMerge() {
|
||||
AsyncStorage.setItem(KEY_MERGE, JSON.stringify(VAL_MERGE_1), err1 => {
|
||||
AsyncStorage.setItem(KEY_MERGE, JSON.stringify(VAL_MERGE_1), (err1) => {
|
||||
expectAsyncNoError('testMerge/setItem', err1);
|
||||
AsyncStorage.mergeItem(KEY_MERGE, JSON.stringify(VAL_MERGE_2), err2 => {
|
||||
AsyncStorage.mergeItem(KEY_MERGE, JSON.stringify(VAL_MERGE_2), (err2) => {
|
||||
expectAsyncNoError('testMerge/mergeItem', err2);
|
||||
AsyncStorage.getItem(KEY_MERGE, (err3, result) => {
|
||||
expectAsyncNoError('testMerge/setItem', err3);
|
||||
@@ -152,11 +152,14 @@ function testMerge() {
|
||||
}
|
||||
|
||||
function testOptimizedMultiGet() {
|
||||
let batch = [[KEY_1, VAL_1], [KEY_2, VAL_2]];
|
||||
let batch = [
|
||||
[KEY_1, VAL_1],
|
||||
[KEY_2, VAL_2],
|
||||
];
|
||||
let keys = batch.map(([key, value]) => key);
|
||||
AsyncStorage.multiSet(batch, err1 => {
|
||||
AsyncStorage.multiSet(batch, (err1) => {
|
||||
// yes, twice on purpose
|
||||
[1, 2].forEach(i => {
|
||||
[1, 2].forEach((i) => {
|
||||
expectAsyncNoError(`${i} testOptimizedMultiGet/multiSet`, err1);
|
||||
AsyncStorage.multiGet(keys, (err2, result) => {
|
||||
expectAsyncNoError(`${i} testOptimizedMultiGet/multiGet`, err2);
|
||||
@@ -182,7 +185,7 @@ class AsyncStorageTest extends React.Component<{...}, $FlowFixMeState> {
|
||||
this.setState({done: true}, () => {
|
||||
TestModule.markTestCompleted();
|
||||
});
|
||||
updateMessage = msg => {
|
||||
updateMessage = (msg) => {
|
||||
this.setState({messages: this.state.messages.concat('\n' + msg)});
|
||||
DEBUG && console.log(msg);
|
||||
};
|
||||
|
||||
@@ -40,7 +40,7 @@ class ImageCachePolicyTest extends React.Component<Props, $FlowFixMeState> {
|
||||
state: $FlowFixMe | {...} = {};
|
||||
|
||||
shouldComponentUpdate(nextProps: Props, nextState: State): boolean {
|
||||
const results: Array<?boolean> = TESTS.map(x => nextState[x]);
|
||||
const results: Array<?boolean> = TESTS.map((x) => nextState[x]);
|
||||
|
||||
if (!results.includes(undefined)) {
|
||||
const result: boolean = results.reduce(
|
||||
|
||||
@@ -43,7 +43,7 @@ TESTS.forEach(
|
||||
/* $FlowFixMe(>=0.54.0 site=react_native_fb,react_native_oss) This comment
|
||||
* suppresses an error found when Flow v0.54 was deployed. To see the error
|
||||
* delete this comment and run Flow. */
|
||||
test => AppRegistry.registerComponent(test.displayName, () => test),
|
||||
(test) => AppRegistry.registerComponent(test.displayName, () => test),
|
||||
);
|
||||
|
||||
// Modules required for integration tests
|
||||
@@ -76,7 +76,7 @@ class IntegrationTestsApp extends React.Component<{...}, $FlowFixMeState> {
|
||||
</Text>
|
||||
<View style={styles.separator} />
|
||||
<ScrollView>
|
||||
{TESTS.map(test => [
|
||||
{TESTS.map((test) => [
|
||||
<TouchableOpacity
|
||||
onPress={() => this.setState({test})}
|
||||
/* $FlowFixMe(>=0.115.0 site=react_native_fb) This comment
|
||||
|
||||
@@ -141,13 +141,13 @@ class LayoutEventsTest extends React.Component<Props, State> {
|
||||
return (
|
||||
<View style={[styles.container, this.state.containerStyle]}>
|
||||
<View
|
||||
ref={ref => {
|
||||
ref={(ref) => {
|
||||
this._view = ref;
|
||||
}}
|
||||
onLayout={this.onViewLayout}
|
||||
style={viewStyle}>
|
||||
<Image
|
||||
ref={ref => {
|
||||
ref={(ref) => {
|
||||
this._img = ref;
|
||||
}}
|
||||
onLayout={this.onImageLayout}
|
||||
@@ -155,7 +155,7 @@ class LayoutEventsTest extends React.Component<Props, State> {
|
||||
source={{uri: 'uie_thumb_big.png'}}
|
||||
/>
|
||||
<Text
|
||||
ref={ref => {
|
||||
ref={(ref) => {
|
||||
this._txt = ref;
|
||||
}}
|
||||
onLayout={this.onTextLayout}
|
||||
|
||||
@@ -15,24 +15,24 @@ const warning = require('fbjs/lib/warning');
|
||||
const invariant = require('invariant');
|
||||
|
||||
const LoggingTestModule = {
|
||||
logToConsole: function(str) {
|
||||
logToConsole: function (str) {
|
||||
console.log(str);
|
||||
},
|
||||
logToConsoleAfterWait: function(str, timeout_ms) {
|
||||
setTimeout(function() {
|
||||
logToConsoleAfterWait: function (str, timeout_ms) {
|
||||
setTimeout(function () {
|
||||
console.log(str);
|
||||
}, timeout_ms);
|
||||
},
|
||||
warning: function(str) {
|
||||
warning: function (str) {
|
||||
warning(false, str);
|
||||
},
|
||||
invariant: function(str) {
|
||||
invariant: function (str) {
|
||||
invariant(false, str);
|
||||
},
|
||||
logErrorToConsole: function(str) {
|
||||
logErrorToConsole: function (str) {
|
||||
console.error(str);
|
||||
},
|
||||
throwError: function(str) {
|
||||
throwError: function (str) {
|
||||
throw new Error(str);
|
||||
},
|
||||
};
|
||||
|
||||
@@ -28,7 +28,7 @@ const TESTS = [
|
||||
require('./SizeFlexibilityUpdateTest'),
|
||||
];
|
||||
|
||||
TESTS.forEach(test =>
|
||||
TESTS.forEach((test) =>
|
||||
AppRegistry.registerComponent(test.displayName, () => test),
|
||||
);
|
||||
|
||||
@@ -54,7 +54,7 @@ class RCTRootViewIntegrationTestApp extends React.Component {
|
||||
</Text>
|
||||
<View style={styles.separator} />
|
||||
<ScrollView>
|
||||
{TESTS.map(test => [
|
||||
{TESTS.map((test) => [
|
||||
<TouchableOpacity
|
||||
onPress={() => this.setState({test})}
|
||||
style={styles.row}>
|
||||
|
||||
@@ -27,7 +27,7 @@ class SyncMethodTest extends React.Component<{...}> {
|
||||
throw new Error('Something wrong with methodThatReturnsNil sync method');
|
||||
}
|
||||
let response;
|
||||
RNTesterTestModule.methodThatCallsCallbackWithString('test', echo => {
|
||||
RNTesterTestModule.methodThatCallsCallbackWithString('test', (echo) => {
|
||||
response = echo;
|
||||
});
|
||||
requestAnimationFrame(() => {
|
||||
|
||||
@@ -153,7 +153,7 @@ class TimersTest extends React.Component<Props, State> {
|
||||
fails.push(this.setTimeout(() => this._fail('testClearMulti-4'), 0));
|
||||
fails.push(this.setTimeout(() => this._fail('testClearMulti-5'), 10));
|
||||
|
||||
fails.forEach(timeout => this.clearTimeout(timeout));
|
||||
fails.forEach((timeout) => this.clearTimeout(timeout));
|
||||
this.setTimeout(() => this.clearTimeout(delayClear), 20);
|
||||
|
||||
this.setTimeout(this.testOrdering, 50);
|
||||
|
||||
@@ -45,7 +45,7 @@ class WebSocketTest extends React.Component<{...}, State> {
|
||||
|
||||
_waitFor = (condition: any, timeout: any, callback: any) => {
|
||||
let remaining = timeout;
|
||||
const timeoutFunction = function() {
|
||||
const timeoutFunction = function () {
|
||||
if (condition()) {
|
||||
callback(true);
|
||||
return;
|
||||
@@ -62,7 +62,7 @@ class WebSocketTest extends React.Component<{...}, State> {
|
||||
|
||||
_connect = () => {
|
||||
const socket = new WebSocket(this.state.url);
|
||||
WS_EVENTS.forEach(ev => socket.addEventListener(ev, this._onSocketEvent));
|
||||
WS_EVENTS.forEach((ev) => socket.addEventListener(ev, this._onSocketEvent));
|
||||
this.setState({
|
||||
socket,
|
||||
socketState: socket.readyState,
|
||||
@@ -116,7 +116,7 @@ class WebSocketTest extends React.Component<{...}, State> {
|
||||
|
||||
testConnect: () => void = () => {
|
||||
this._connect();
|
||||
this._waitFor(this._socketIsConnected, 5, connectSucceeded => {
|
||||
this._waitFor(this._socketIsConnected, 5, (connectSucceeded) => {
|
||||
if (!connectSucceeded) {
|
||||
TestModule.markTestPassed(false);
|
||||
return;
|
||||
@@ -127,7 +127,7 @@ class WebSocketTest extends React.Component<{...}, State> {
|
||||
|
||||
testSendAndReceive: () => void = () => {
|
||||
this._sendTestMessage();
|
||||
this._waitFor(this._receivedTestExpectedResponse, 5, messageReceived => {
|
||||
this._waitFor(this._receivedTestExpectedResponse, 5, (messageReceived) => {
|
||||
if (!messageReceived) {
|
||||
TestModule.markTestPassed(false);
|
||||
return;
|
||||
@@ -138,7 +138,7 @@ class WebSocketTest extends React.Component<{...}, State> {
|
||||
|
||||
testDisconnect: () => void = () => {
|
||||
this._disconnect();
|
||||
this._waitFor(this._socketIsDisconnected, 5, disconnectSucceeded => {
|
||||
this._waitFor(this._socketIsDisconnected, 5, (disconnectSucceeded) => {
|
||||
TestModule.markTestPassed(disconnectSucceeded);
|
||||
});
|
||||
};
|
||||
|
||||
@@ -97,7 +97,7 @@ class Alert {
|
||||
options && options.onDismiss && options.onDismiss();
|
||||
}
|
||||
};
|
||||
const onError = errorMessage => console.warn(errorMessage);
|
||||
const onError = (errorMessage) => console.warn(errorMessage);
|
||||
NativeDialogManagerAndroid.showAlert(config, onError, onAction);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ import NativeDialogManagerAndroid from '../NativeModules/specs/NativeDialogManag
|
||||
function emptyCallback() {}
|
||||
|
||||
module.exports = {
|
||||
alertWithArgs: function(args, callback) {
|
||||
alertWithArgs: function (args, callback) {
|
||||
// TODO(5998984): Polyfill it correctly with DialogManagerAndroid
|
||||
if (!NativeDialogManagerAndroid) {
|
||||
return;
|
||||
|
||||
@@ -46,7 +46,7 @@ var babelOpts = {
|
||||
}),
|
||||
};
|
||||
|
||||
var buildDist = function(opts) {
|
||||
var buildDist = function (opts) {
|
||||
var webpackOpts = {
|
||||
debug: opts.debug,
|
||||
externals: {
|
||||
@@ -80,7 +80,7 @@ var buildDist = function(opts) {
|
||||
}),
|
||||
);
|
||||
}
|
||||
return webpackStream(webpackOpts, null, function(err, stats) {
|
||||
return webpackStream(webpackOpts, null, function (err, stats) {
|
||||
if (err) {
|
||||
throw new gulpUtil.PluginError('webpack', err);
|
||||
}
|
||||
@@ -101,11 +101,11 @@ var paths = {
|
||||
],
|
||||
};
|
||||
|
||||
gulp.task('clean', function(cb) {
|
||||
gulp.task('clean', function (cb) {
|
||||
del([paths.dist, paths.lib], cb);
|
||||
});
|
||||
|
||||
gulp.task('modules', function() {
|
||||
gulp.task('modules', function () {
|
||||
return gulp
|
||||
.src(paths.src, {cwd: '../'})
|
||||
.pipe(babel(babelOpts))
|
||||
@@ -113,7 +113,7 @@ gulp.task('modules', function() {
|
||||
.pipe(gulp.dest(paths.lib));
|
||||
});
|
||||
|
||||
gulp.task('dist', ['modules'], function() {
|
||||
gulp.task('dist', ['modules'], function () {
|
||||
var distOpts = {
|
||||
debug: true,
|
||||
output: 'animated.js',
|
||||
@@ -130,7 +130,7 @@ gulp.task('dist', ['modules'], function() {
|
||||
.pipe(gulp.dest(paths.dist));
|
||||
});
|
||||
|
||||
gulp.task('dist:min', ['modules'], function() {
|
||||
gulp.task('dist:min', ['modules'], function () {
|
||||
var distOpts = {
|
||||
debug: false,
|
||||
output: 'animated.min.js',
|
||||
@@ -146,10 +146,10 @@ gulp.task('dist:min', ['modules'], function() {
|
||||
.pipe(gulp.dest(paths.dist));
|
||||
});
|
||||
|
||||
gulp.task('watch', function() {
|
||||
gulp.task('watch', function () {
|
||||
gulp.watch(paths.src, ['modules']);
|
||||
});
|
||||
|
||||
gulp.task('default', function(cb) {
|
||||
gulp.task('default', function (cb) {
|
||||
runSequence('clean', 'modules', ['dist', 'dist:min'], cb);
|
||||
});
|
||||
|
||||
@@ -58,7 +58,7 @@ function attachNativeEvent(
|
||||
|
||||
const viewTag = ReactNative.findNodeHandle(viewRef);
|
||||
if (viewTag != null) {
|
||||
eventMappings.forEach(mapping => {
|
||||
eventMappings.forEach((mapping) => {
|
||||
NativeAnimatedHelper.API.addAnimatedEventToView(
|
||||
viewTag,
|
||||
eventName,
|
||||
@@ -70,7 +70,7 @@ function attachNativeEvent(
|
||||
return {
|
||||
detach() {
|
||||
if (viewTag != null) {
|
||||
eventMappings.forEach(mapping => {
|
||||
eventMappings.forEach((mapping) => {
|
||||
NativeAnimatedHelper.API.removeAnimatedEventFromView(
|
||||
viewTag,
|
||||
eventName,
|
||||
@@ -155,7 +155,9 @@ class AnimatedEvent {
|
||||
}
|
||||
|
||||
__removeListener(callback: Function): void {
|
||||
this._listeners = this._listeners.filter(listener => listener !== callback);
|
||||
this._listeners = this._listeners.filter(
|
||||
(listener) => listener !== callback,
|
||||
);
|
||||
}
|
||||
|
||||
__attach(viewRef: any, eventName: string) {
|
||||
@@ -226,7 +228,7 @@ class AnimatedEvent {
|
||||
}
|
||||
|
||||
_callListeners(...args: any) {
|
||||
this._listeners.forEach(listener => listener(...args));
|
||||
this._listeners.forEach((listener) => listener(...args));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -49,39 +49,39 @@ export type CompositeAnimation = {
|
||||
...
|
||||
};
|
||||
|
||||
const add = function(
|
||||
const add = function (
|
||||
a: AnimatedNode | number,
|
||||
b: AnimatedNode | number,
|
||||
): AnimatedAddition {
|
||||
return new AnimatedAddition(a, b);
|
||||
};
|
||||
|
||||
const subtract = function(
|
||||
const subtract = function (
|
||||
a: AnimatedNode | number,
|
||||
b: AnimatedNode | number,
|
||||
): AnimatedSubtraction {
|
||||
return new AnimatedSubtraction(a, b);
|
||||
};
|
||||
|
||||
const divide = function(
|
||||
const divide = function (
|
||||
a: AnimatedNode | number,
|
||||
b: AnimatedNode | number,
|
||||
): AnimatedDivision {
|
||||
return new AnimatedDivision(a, b);
|
||||
};
|
||||
|
||||
const multiply = function(
|
||||
const multiply = function (
|
||||
a: AnimatedNode | number,
|
||||
b: AnimatedNode | number,
|
||||
): AnimatedMultiplication {
|
||||
return new AnimatedMultiplication(a, b);
|
||||
};
|
||||
|
||||
const modulo = function(a: AnimatedNode, modulus: number): AnimatedModulo {
|
||||
const modulo = function (a: AnimatedNode, modulus: number): AnimatedModulo {
|
||||
return new AnimatedModulo(a, modulus);
|
||||
};
|
||||
|
||||
const diffClamp = function(
|
||||
const diffClamp = function (
|
||||
a: AnimatedNode,
|
||||
min: number,
|
||||
max: number,
|
||||
@@ -89,7 +89,7 @@ const diffClamp = function(
|
||||
return new AnimatedDiffClamp(a, min, max);
|
||||
};
|
||||
|
||||
const _combineCallbacks = function(
|
||||
const _combineCallbacks = function (
|
||||
callback: ?EndCallback,
|
||||
config: {...AnimationConfig, ...},
|
||||
) {
|
||||
@@ -103,7 +103,7 @@ const _combineCallbacks = function(
|
||||
}
|
||||
};
|
||||
|
||||
const maybeVectorAnim = function(
|
||||
const maybeVectorAnim = function (
|
||||
value: AnimatedValue | AnimatedValueXY,
|
||||
config: Object,
|
||||
anim: (value: AnimatedValue, config: Object) => CompositeAnimation,
|
||||
@@ -127,11 +127,11 @@ const maybeVectorAnim = function(
|
||||
return null;
|
||||
};
|
||||
|
||||
const spring = function(
|
||||
const spring = function (
|
||||
value: AnimatedValue | AnimatedValueXY,
|
||||
config: SpringAnimationConfig,
|
||||
): CompositeAnimation {
|
||||
const start = function(
|
||||
const start = function (
|
||||
animatedValue: AnimatedValue | AnimatedValueXY,
|
||||
configuration: SpringAnimationConfig,
|
||||
callback?: ?EndCallback,
|
||||
@@ -156,35 +156,35 @@ const spring = function(
|
||||
};
|
||||
return (
|
||||
maybeVectorAnim(value, config, spring) || {
|
||||
start: function(callback?: ?EndCallback): void {
|
||||
start: function (callback?: ?EndCallback): void {
|
||||
start(value, config, callback);
|
||||
},
|
||||
|
||||
stop: function(): void {
|
||||
stop: function (): void {
|
||||
value.stopAnimation();
|
||||
},
|
||||
|
||||
reset: function(): void {
|
||||
reset: function (): void {
|
||||
value.resetAnimation();
|
||||
},
|
||||
|
||||
_startNativeLoop: function(iterations?: number): void {
|
||||
_startNativeLoop: function (iterations?: number): void {
|
||||
const singleConfig = {...config, iterations};
|
||||
start(value, singleConfig);
|
||||
},
|
||||
|
||||
_isUsingNativeDriver: function(): boolean {
|
||||
_isUsingNativeDriver: function (): boolean {
|
||||
return config.useNativeDriver || false;
|
||||
},
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
const timing = function(
|
||||
const timing = function (
|
||||
value: AnimatedValue | AnimatedValueXY,
|
||||
config: TimingAnimationConfig,
|
||||
): CompositeAnimation {
|
||||
const start = function(
|
||||
const start = function (
|
||||
animatedValue: AnimatedValue | AnimatedValueXY,
|
||||
configuration: TimingAnimationConfig,
|
||||
callback?: ?EndCallback,
|
||||
@@ -210,35 +210,35 @@ const timing = function(
|
||||
|
||||
return (
|
||||
maybeVectorAnim(value, config, timing) || {
|
||||
start: function(callback?: ?EndCallback): void {
|
||||
start: function (callback?: ?EndCallback): void {
|
||||
start(value, config, callback);
|
||||
},
|
||||
|
||||
stop: function(): void {
|
||||
stop: function (): void {
|
||||
value.stopAnimation();
|
||||
},
|
||||
|
||||
reset: function(): void {
|
||||
reset: function (): void {
|
||||
value.resetAnimation();
|
||||
},
|
||||
|
||||
_startNativeLoop: function(iterations?: number): void {
|
||||
_startNativeLoop: function (iterations?: number): void {
|
||||
const singleConfig = {...config, iterations};
|
||||
start(value, singleConfig);
|
||||
},
|
||||
|
||||
_isUsingNativeDriver: function(): boolean {
|
||||
_isUsingNativeDriver: function (): boolean {
|
||||
return config.useNativeDriver || false;
|
||||
},
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
const decay = function(
|
||||
const decay = function (
|
||||
value: AnimatedValue | AnimatedValueXY,
|
||||
config: DecayAnimationConfig,
|
||||
): CompositeAnimation {
|
||||
const start = function(
|
||||
const start = function (
|
||||
animatedValue: AnimatedValue | AnimatedValueXY,
|
||||
configuration: DecayAnimationConfig,
|
||||
callback?: ?EndCallback,
|
||||
@@ -252,37 +252,37 @@ const decay = function(
|
||||
|
||||
return (
|
||||
maybeVectorAnim(value, config, decay) || {
|
||||
start: function(callback?: ?EndCallback): void {
|
||||
start: function (callback?: ?EndCallback): void {
|
||||
start(value, config, callback);
|
||||
},
|
||||
|
||||
stop: function(): void {
|
||||
stop: function (): void {
|
||||
value.stopAnimation();
|
||||
},
|
||||
|
||||
reset: function(): void {
|
||||
reset: function (): void {
|
||||
value.resetAnimation();
|
||||
},
|
||||
|
||||
_startNativeLoop: function(iterations?: number): void {
|
||||
_startNativeLoop: function (iterations?: number): void {
|
||||
const singleConfig = {...config, iterations};
|
||||
start(value, singleConfig);
|
||||
},
|
||||
|
||||
_isUsingNativeDriver: function(): boolean {
|
||||
_isUsingNativeDriver: function (): boolean {
|
||||
return config.useNativeDriver || false;
|
||||
},
|
||||
}
|
||||
);
|
||||
};
|
||||
|
||||
const sequence = function(
|
||||
const sequence = function (
|
||||
animations: Array<CompositeAnimation>,
|
||||
): CompositeAnimation {
|
||||
let current = 0;
|
||||
return {
|
||||
start: function(callback?: ?EndCallback) {
|
||||
const onComplete = function(result) {
|
||||
start: function (callback?: ?EndCallback) {
|
||||
const onComplete = function (result) {
|
||||
if (!result.finished) {
|
||||
callback && callback(result);
|
||||
return;
|
||||
@@ -305,13 +305,13 @@ const sequence = function(
|
||||
}
|
||||
},
|
||||
|
||||
stop: function() {
|
||||
stop: function () {
|
||||
if (current < animations.length) {
|
||||
animations[current].stop();
|
||||
}
|
||||
},
|
||||
|
||||
reset: function() {
|
||||
reset: function () {
|
||||
animations.forEach((animation, idx) => {
|
||||
if (idx <= current) {
|
||||
animation.reset();
|
||||
@@ -320,13 +320,13 @@ const sequence = function(
|
||||
current = 0;
|
||||
},
|
||||
|
||||
_startNativeLoop: function() {
|
||||
_startNativeLoop: function () {
|
||||
throw new Error(
|
||||
'Loops run using the native driver cannot contain Animated.sequence animations',
|
||||
);
|
||||
},
|
||||
|
||||
_isUsingNativeDriver: function(): boolean {
|
||||
_isUsingNativeDriver: function (): boolean {
|
||||
return false;
|
||||
},
|
||||
};
|
||||
@@ -337,7 +337,7 @@ type ParallelConfig = {
|
||||
stopTogether?: boolean,
|
||||
...
|
||||
};
|
||||
const parallel = function(
|
||||
const parallel = function (
|
||||
animations: Array<CompositeAnimation>,
|
||||
config?: ?ParallelConfig,
|
||||
): CompositeAnimation {
|
||||
@@ -347,14 +347,14 @@ const parallel = function(
|
||||
const stopTogether = !(config && config.stopTogether === false);
|
||||
|
||||
const result = {
|
||||
start: function(callback?: ?EndCallback) {
|
||||
start: function (callback?: ?EndCallback) {
|
||||
if (doneCount === animations.length) {
|
||||
callback && callback({finished: true});
|
||||
return;
|
||||
}
|
||||
|
||||
animations.forEach((animation, idx) => {
|
||||
const cb = function(endResult) {
|
||||
const cb = function (endResult) {
|
||||
hasEnded[idx] = true;
|
||||
doneCount++;
|
||||
if (doneCount === animations.length) {
|
||||
@@ -376,14 +376,14 @@ const parallel = function(
|
||||
});
|
||||
},
|
||||
|
||||
stop: function(): void {
|
||||
stop: function (): void {
|
||||
animations.forEach((animation, idx) => {
|
||||
!hasEnded[idx] && animation.stop();
|
||||
hasEnded[idx] = true;
|
||||
});
|
||||
},
|
||||
|
||||
reset: function(): void {
|
||||
reset: function (): void {
|
||||
animations.forEach((animation, idx) => {
|
||||
animation.reset();
|
||||
hasEnded[idx] = false;
|
||||
@@ -391,13 +391,13 @@ const parallel = function(
|
||||
});
|
||||
},
|
||||
|
||||
_startNativeLoop: function() {
|
||||
_startNativeLoop: function () {
|
||||
throw new Error(
|
||||
'Loops run using the native driver cannot contain Animated.parallel animations',
|
||||
);
|
||||
},
|
||||
|
||||
_isUsingNativeDriver: function(): boolean {
|
||||
_isUsingNativeDriver: function (): boolean {
|
||||
return false;
|
||||
},
|
||||
};
|
||||
@@ -405,7 +405,7 @@ const parallel = function(
|
||||
return result;
|
||||
};
|
||||
|
||||
const delay = function(time: number): CompositeAnimation {
|
||||
const delay = function (time: number): CompositeAnimation {
|
||||
// Would be nice to make a specialized implementation
|
||||
return timing(new AnimatedValue(0), {
|
||||
toValue: 0,
|
||||
@@ -415,7 +415,7 @@ const delay = function(time: number): CompositeAnimation {
|
||||
});
|
||||
};
|
||||
|
||||
const stagger = function(
|
||||
const stagger = function (
|
||||
time: number,
|
||||
animations: Array<CompositeAnimation>,
|
||||
): CompositeAnimation {
|
||||
@@ -432,15 +432,15 @@ type LoopAnimationConfig = {
|
||||
...
|
||||
};
|
||||
|
||||
const loop = function(
|
||||
const loop = function (
|
||||
animation: CompositeAnimation,
|
||||
{iterations = -1, resetBeforeIteration = true}: LoopAnimationConfig = {},
|
||||
): CompositeAnimation {
|
||||
let isFinished = false;
|
||||
let iterationsSoFar = 0;
|
||||
return {
|
||||
start: function(callback?: ?EndCallback) {
|
||||
const restart = function(result: EndResult = {finished: true}): void {
|
||||
start: function (callback?: ?EndCallback) {
|
||||
const restart = function (result: EndResult = {finished: true}): void {
|
||||
if (
|
||||
isFinished ||
|
||||
iterationsSoFar === iterations ||
|
||||
@@ -464,24 +464,24 @@ const loop = function(
|
||||
}
|
||||
},
|
||||
|
||||
stop: function(): void {
|
||||
stop: function (): void {
|
||||
isFinished = true;
|
||||
animation.stop();
|
||||
},
|
||||
|
||||
reset: function(): void {
|
||||
reset: function (): void {
|
||||
iterationsSoFar = 0;
|
||||
isFinished = false;
|
||||
animation.reset();
|
||||
},
|
||||
|
||||
_startNativeLoop: function() {
|
||||
_startNativeLoop: function () {
|
||||
throw new Error(
|
||||
'Loops run using the native driver cannot contain Animated.loop animations',
|
||||
);
|
||||
},
|
||||
|
||||
_isUsingNativeDriver: function(): boolean {
|
||||
_isUsingNativeDriver: function (): boolean {
|
||||
return animation._isUsingNativeDriver();
|
||||
},
|
||||
};
|
||||
@@ -513,7 +513,7 @@ function unforkEvent(
|
||||
}
|
||||
}
|
||||
|
||||
const event = function(
|
||||
const event = function (
|
||||
argMapping: $ReadOnlyArray<?Mapping>,
|
||||
config: EventConfig,
|
||||
): any {
|
||||
|
||||
@@ -50,7 +50,7 @@ const emptyAnimation = {
|
||||
},
|
||||
};
|
||||
|
||||
const spring = function(
|
||||
const spring = function (
|
||||
value: AnimatedValue | AnimatedValueXY,
|
||||
config: SpringAnimationConfig,
|
||||
): CompositeAnimation {
|
||||
@@ -64,7 +64,7 @@ const spring = function(
|
||||
};
|
||||
};
|
||||
|
||||
const timing = function(
|
||||
const timing = function (
|
||||
value: AnimatedValue | AnimatedValueXY,
|
||||
config: TimingAnimationConfig,
|
||||
): CompositeAnimation {
|
||||
@@ -78,32 +78,32 @@ const timing = function(
|
||||
};
|
||||
};
|
||||
|
||||
const decay = function(
|
||||
const decay = function (
|
||||
value: AnimatedValue | AnimatedValueXY,
|
||||
config: DecayAnimationConfig,
|
||||
): CompositeAnimation {
|
||||
return emptyAnimation;
|
||||
};
|
||||
|
||||
const sequence = function(
|
||||
const sequence = function (
|
||||
animations: Array<CompositeAnimation>,
|
||||
): CompositeAnimation {
|
||||
return emptyAnimation;
|
||||
};
|
||||
|
||||
type ParallelConfig = {stopTogether?: boolean, ...};
|
||||
const parallel = function(
|
||||
const parallel = function (
|
||||
animations: Array<CompositeAnimation>,
|
||||
config?: ?ParallelConfig,
|
||||
): CompositeAnimation {
|
||||
return emptyAnimation;
|
||||
};
|
||||
|
||||
const delay = function(time: number): CompositeAnimation {
|
||||
const delay = function (time: number): CompositeAnimation {
|
||||
return emptyAnimation;
|
||||
};
|
||||
|
||||
const stagger = function(
|
||||
const stagger = function (
|
||||
time: number,
|
||||
animations: Array<CompositeAnimation>,
|
||||
): CompositeAnimation {
|
||||
@@ -116,14 +116,14 @@ type LoopAnimationConfig = {
|
||||
...
|
||||
};
|
||||
|
||||
const loop = function(
|
||||
const loop = function (
|
||||
animation: CompositeAnimation,
|
||||
{iterations = -1}: LoopAnimationConfig = {},
|
||||
): CompositeAnimation {
|
||||
return emptyAnimation;
|
||||
};
|
||||
|
||||
const event = function(argMapping: Array<?Mapping>, config: EventConfig): any {
|
||||
const event = function (argMapping: Array<?Mapping>, config: EventConfig): any {
|
||||
return null;
|
||||
};
|
||||
|
||||
|
||||
@@ -164,7 +164,8 @@ class Easing {
|
||||
*/
|
||||
static elastic(bounciness: number = 1): (t: number) => number {
|
||||
const p = bounciness * Math.PI;
|
||||
return t => 1 - Math.pow(Math.cos((t * Math.PI) / 2), 3) * Math.cos(t * p);
|
||||
return (t) =>
|
||||
1 - Math.pow(Math.cos((t * Math.PI) / 2), 3) * Math.cos(t * p);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -176,7 +177,7 @@ class Easing {
|
||||
* - http://tiny.cc/back_default (s = 1.70158, default)
|
||||
*/
|
||||
static back(s: number = 1.70158): (t: number) => number {
|
||||
return t => t * t * ((s + 1) * t - s);
|
||||
return (t) => t * t * ((s + 1) * t - s);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -231,7 +232,7 @@ class Easing {
|
||||
* Runs an easing function backwards.
|
||||
*/
|
||||
static out(easing: (t: number) => number): (t: number) => number {
|
||||
return t => 1 - easing(1 - t);
|
||||
return (t) => 1 - easing(1 - t);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -240,7 +241,7 @@ class Easing {
|
||||
* duration.
|
||||
*/
|
||||
static inOut(easing: (t: number) => number): (t: number) => number {
|
||||
return t => {
|
||||
return (t) => {
|
||||
if (t < 0.5) {
|
||||
return easing(t * 2) / 2;
|
||||
}
|
||||
|
||||
@@ -35,10 +35,10 @@ let queue = [];
|
||||
* the native module methods
|
||||
*/
|
||||
const API = {
|
||||
enableQueue: function(): void {
|
||||
enableQueue: function (): void {
|
||||
queueConnections = true;
|
||||
},
|
||||
disableQueue: function(): void {
|
||||
disableQueue: function (): void {
|
||||
invariant(NativeAnimatedModule, 'Native animated module is not available');
|
||||
queueConnections = false;
|
||||
for (let q = 0, l = queue.length; q < l; q++) {
|
||||
@@ -47,19 +47,19 @@ const API = {
|
||||
}
|
||||
queue.length = 0;
|
||||
},
|
||||
createAnimatedNode: function(tag: number, config: AnimatedNodeConfig): void {
|
||||
createAnimatedNode: function (tag: number, config: AnimatedNodeConfig): void {
|
||||
invariant(NativeAnimatedModule, 'Native animated module is not available');
|
||||
NativeAnimatedModule.createAnimatedNode(tag, config);
|
||||
},
|
||||
startListeningToAnimatedNodeValue: function(tag: number) {
|
||||
startListeningToAnimatedNodeValue: function (tag: number) {
|
||||
invariant(NativeAnimatedModule, 'Native animated module is not available');
|
||||
NativeAnimatedModule.startListeningToAnimatedNodeValue(tag);
|
||||
},
|
||||
stopListeningToAnimatedNodeValue: function(tag: number) {
|
||||
stopListeningToAnimatedNodeValue: function (tag: number) {
|
||||
invariant(NativeAnimatedModule, 'Native animated module is not available');
|
||||
NativeAnimatedModule.stopListeningToAnimatedNodeValue(tag);
|
||||
},
|
||||
connectAnimatedNodes: function(parentTag: number, childTag: number): void {
|
||||
connectAnimatedNodes: function (parentTag: number, childTag: number): void {
|
||||
invariant(NativeAnimatedModule, 'Native animated module is not available');
|
||||
if (queueConnections) {
|
||||
queue.push([parentTag, childTag]);
|
||||
@@ -67,11 +67,14 @@ const API = {
|
||||
}
|
||||
NativeAnimatedModule.connectAnimatedNodes(parentTag, childTag);
|
||||
},
|
||||
disconnectAnimatedNodes: function(parentTag: number, childTag: number): void {
|
||||
disconnectAnimatedNodes: function (
|
||||
parentTag: number,
|
||||
childTag: number,
|
||||
): void {
|
||||
invariant(NativeAnimatedModule, 'Native animated module is not available');
|
||||
NativeAnimatedModule.disconnectAnimatedNodes(parentTag, childTag);
|
||||
},
|
||||
startAnimatingNode: function(
|
||||
startAnimatingNode: function (
|
||||
animationId: number,
|
||||
nodeTag: number,
|
||||
config: AnimatingNodeConfig,
|
||||
@@ -85,49 +88,49 @@ const API = {
|
||||
endCallback,
|
||||
);
|
||||
},
|
||||
stopAnimation: function(animationId: number) {
|
||||
stopAnimation: function (animationId: number) {
|
||||
invariant(NativeAnimatedModule, 'Native animated module is not available');
|
||||
NativeAnimatedModule.stopAnimation(animationId);
|
||||
},
|
||||
setAnimatedNodeValue: function(nodeTag: number, value: number): void {
|
||||
setAnimatedNodeValue: function (nodeTag: number, value: number): void {
|
||||
invariant(NativeAnimatedModule, 'Native animated module is not available');
|
||||
NativeAnimatedModule.setAnimatedNodeValue(nodeTag, value);
|
||||
},
|
||||
setAnimatedNodeOffset: function(nodeTag: number, offset: number): void {
|
||||
setAnimatedNodeOffset: function (nodeTag: number, offset: number): void {
|
||||
invariant(NativeAnimatedModule, 'Native animated module is not available');
|
||||
NativeAnimatedModule.setAnimatedNodeOffset(nodeTag, offset);
|
||||
},
|
||||
flattenAnimatedNodeOffset: function(nodeTag: number): void {
|
||||
flattenAnimatedNodeOffset: function (nodeTag: number): void {
|
||||
invariant(NativeAnimatedModule, 'Native animated module is not available');
|
||||
NativeAnimatedModule.flattenAnimatedNodeOffset(nodeTag);
|
||||
},
|
||||
extractAnimatedNodeOffset: function(nodeTag: number): void {
|
||||
extractAnimatedNodeOffset: function (nodeTag: number): void {
|
||||
invariant(NativeAnimatedModule, 'Native animated module is not available');
|
||||
NativeAnimatedModule.extractAnimatedNodeOffset(nodeTag);
|
||||
},
|
||||
connectAnimatedNodeToView: function(nodeTag: number, viewTag: number): void {
|
||||
connectAnimatedNodeToView: function (nodeTag: number, viewTag: number): void {
|
||||
invariant(NativeAnimatedModule, 'Native animated module is not available');
|
||||
NativeAnimatedModule.connectAnimatedNodeToView(nodeTag, viewTag);
|
||||
},
|
||||
disconnectAnimatedNodeFromView: function(
|
||||
disconnectAnimatedNodeFromView: function (
|
||||
nodeTag: number,
|
||||
viewTag: number,
|
||||
): void {
|
||||
invariant(NativeAnimatedModule, 'Native animated module is not available');
|
||||
NativeAnimatedModule.disconnectAnimatedNodeFromView(nodeTag, viewTag);
|
||||
},
|
||||
restoreDefaultValues: function(nodeTag: number): void {
|
||||
restoreDefaultValues: function (nodeTag: number): void {
|
||||
invariant(NativeAnimatedModule, 'Native animated module is not available');
|
||||
// Backwards compat with older native runtimes, can be removed later.
|
||||
if (NativeAnimatedModule.restoreDefaultValues != null) {
|
||||
NativeAnimatedModule.restoreDefaultValues(nodeTag);
|
||||
}
|
||||
},
|
||||
dropAnimatedNode: function(tag: number): void {
|
||||
dropAnimatedNode: function (tag: number): void {
|
||||
invariant(NativeAnimatedModule, 'Native animated module is not available');
|
||||
NativeAnimatedModule.dropAnimatedNode(tag);
|
||||
},
|
||||
addAnimatedEventToView: function(
|
||||
addAnimatedEventToView: function (
|
||||
viewTag: number,
|
||||
eventName: string,
|
||||
eventMapping: EventMapping,
|
||||
@@ -232,12 +235,10 @@ function validateTransform(
|
||||
},
|
||||
>,
|
||||
): void {
|
||||
configs.forEach(config => {
|
||||
configs.forEach((config) => {
|
||||
if (!TRANSFORM_WHITELIST.hasOwnProperty(config.property)) {
|
||||
throw new Error(
|
||||
`Property '${
|
||||
config.property
|
||||
}' is not supported by native animated module`,
|
||||
`Property '${config.property}' is not supported by native animated module`,
|
||||
);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -19,8 +19,8 @@ describe('Animated Mock', () => {
|
||||
Object.keys(AnimatedImplementation),
|
||||
);
|
||||
});
|
||||
it('matches implementation params', done => {
|
||||
Object.keys(AnimatedImplementation).forEach(key => {
|
||||
it('matches implementation params', (done) => {
|
||||
Object.keys(AnimatedImplementation).forEach((key) => {
|
||||
if (AnimatedImplementation[key].length !== AnimatedMock[key].length) {
|
||||
done(
|
||||
new Error(
|
||||
|
||||
@@ -346,22 +346,30 @@ describe('Native Animated', () => {
|
||||
{type: 'addition', input: expect.any(Array)},
|
||||
);
|
||||
const additionCalls = NativeAnimatedModule.createAnimatedNode.mock.calls.filter(
|
||||
call => call[1].type === 'addition',
|
||||
(call) => call[1].type === 'addition',
|
||||
);
|
||||
expect(additionCalls.length).toBe(1);
|
||||
const additionCall = additionCalls[0];
|
||||
const additionNodeTag = additionCall[0];
|
||||
const additionConnectionCalls = NativeAnimatedModule.connectAnimatedNodes.mock.calls.filter(
|
||||
call => call[1] === additionNodeTag,
|
||||
(call) => call[1] === additionNodeTag,
|
||||
);
|
||||
expect(additionConnectionCalls.length).toBe(2);
|
||||
expect(NativeAnimatedModule.createAnimatedNode).toBeCalledWith(
|
||||
additionCall[1].input[0],
|
||||
{type: 'value', value: 1, offset: 0},
|
||||
{
|
||||
type: 'value',
|
||||
value: 1,
|
||||
offset: 0,
|
||||
},
|
||||
);
|
||||
expect(NativeAnimatedModule.createAnimatedNode).toBeCalledWith(
|
||||
additionCall[1].input[1],
|
||||
{type: 'value', value: 2, offset: 0},
|
||||
{
|
||||
type: 'value',
|
||||
value: 2,
|
||||
offset: 0,
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
@@ -380,22 +388,30 @@ describe('Native Animated', () => {
|
||||
{type: 'subtraction', input: expect.any(Array)},
|
||||
);
|
||||
const subtractionCalls = NativeAnimatedModule.createAnimatedNode.mock.calls.filter(
|
||||
call => call[1].type === 'subtraction',
|
||||
(call) => call[1].type === 'subtraction',
|
||||
);
|
||||
expect(subtractionCalls.length).toBe(1);
|
||||
const subtractionCall = subtractionCalls[0];
|
||||
const subtractionNodeTag = subtractionCall[0];
|
||||
const subtractionConnectionCalls = NativeAnimatedModule.connectAnimatedNodes.mock.calls.filter(
|
||||
call => call[1] === subtractionNodeTag,
|
||||
(call) => call[1] === subtractionNodeTag,
|
||||
);
|
||||
expect(subtractionConnectionCalls.length).toBe(2);
|
||||
expect(NativeAnimatedModule.createAnimatedNode).toBeCalledWith(
|
||||
subtractionCall[1].input[0],
|
||||
{type: 'value', value: 2, offset: 0},
|
||||
{
|
||||
type: 'value',
|
||||
value: 2,
|
||||
offset: 0,
|
||||
},
|
||||
);
|
||||
expect(NativeAnimatedModule.createAnimatedNode).toBeCalledWith(
|
||||
subtractionCall[1].input[1],
|
||||
{type: 'value', value: 1, offset: 0},
|
||||
{
|
||||
type: 'value',
|
||||
value: 1,
|
||||
offset: 0,
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
@@ -414,22 +430,30 @@ describe('Native Animated', () => {
|
||||
{type: 'multiplication', input: expect.any(Array)},
|
||||
);
|
||||
const multiplicationCalls = NativeAnimatedModule.createAnimatedNode.mock.calls.filter(
|
||||
call => call[1].type === 'multiplication',
|
||||
(call) => call[1].type === 'multiplication',
|
||||
);
|
||||
expect(multiplicationCalls.length).toBe(1);
|
||||
const multiplicationCall = multiplicationCalls[0];
|
||||
const multiplicationNodeTag = multiplicationCall[0];
|
||||
const multiplicationConnectionCalls = NativeAnimatedModule.connectAnimatedNodes.mock.calls.filter(
|
||||
call => call[1] === multiplicationNodeTag,
|
||||
(call) => call[1] === multiplicationNodeTag,
|
||||
);
|
||||
expect(multiplicationConnectionCalls.length).toBe(2);
|
||||
expect(NativeAnimatedModule.createAnimatedNode).toBeCalledWith(
|
||||
multiplicationCall[1].input[0],
|
||||
{type: 'value', value: 2, offset: 0},
|
||||
{
|
||||
type: 'value',
|
||||
value: 2,
|
||||
offset: 0,
|
||||
},
|
||||
);
|
||||
expect(NativeAnimatedModule.createAnimatedNode).toBeCalledWith(
|
||||
multiplicationCall[1].input[1],
|
||||
{type: 'value', value: 1, offset: 0},
|
||||
{
|
||||
type: 'value',
|
||||
value: 1,
|
||||
offset: 0,
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
@@ -448,22 +472,30 @@ describe('Native Animated', () => {
|
||||
{type: 'division', input: expect.any(Array)},
|
||||
);
|
||||
const divisionCalls = NativeAnimatedModule.createAnimatedNode.mock.calls.filter(
|
||||
call => call[1].type === 'division',
|
||||
(call) => call[1].type === 'division',
|
||||
);
|
||||
expect(divisionCalls.length).toBe(1);
|
||||
const divisionCall = divisionCalls[0];
|
||||
const divisionNodeTag = divisionCall[0];
|
||||
const divisionConnectionCalls = NativeAnimatedModule.connectAnimatedNodes.mock.calls.filter(
|
||||
call => call[1] === divisionNodeTag,
|
||||
(call) => call[1] === divisionNodeTag,
|
||||
);
|
||||
expect(divisionConnectionCalls.length).toBe(2);
|
||||
expect(NativeAnimatedModule.createAnimatedNode).toBeCalledWith(
|
||||
divisionCall[1].input[0],
|
||||
{type: 'value', value: 4, offset: 0},
|
||||
{
|
||||
type: 'value',
|
||||
value: 4,
|
||||
offset: 0,
|
||||
},
|
||||
);
|
||||
expect(NativeAnimatedModule.createAnimatedNode).toBeCalledWith(
|
||||
divisionCall[1].input[1],
|
||||
{type: 'value', value: 2, offset: 0},
|
||||
{
|
||||
type: 'value',
|
||||
value: 2,
|
||||
offset: 0,
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
@@ -480,18 +512,22 @@ describe('Native Animated', () => {
|
||||
{type: 'modulus', modulus: 4, input: expect.any(Number)},
|
||||
);
|
||||
const moduloCalls = NativeAnimatedModule.createAnimatedNode.mock.calls.filter(
|
||||
call => call[1].type === 'modulus',
|
||||
(call) => call[1].type === 'modulus',
|
||||
);
|
||||
expect(moduloCalls.length).toBe(1);
|
||||
const moduloCall = moduloCalls[0];
|
||||
const moduloNodeTag = moduloCall[0];
|
||||
const moduloConnectionCalls = NativeAnimatedModule.connectAnimatedNodes.mock.calls.filter(
|
||||
call => call[1] === moduloNodeTag,
|
||||
(call) => call[1] === moduloNodeTag,
|
||||
);
|
||||
expect(moduloConnectionCalls.length).toBe(1);
|
||||
expect(NativeAnimatedModule.createAnimatedNode).toBeCalledWith(
|
||||
moduloCall[1].input,
|
||||
{type: 'value', value: 4, offset: 0},
|
||||
{
|
||||
type: 'value',
|
||||
value: 4,
|
||||
offset: 0,
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
@@ -525,10 +561,10 @@ describe('Native Animated', () => {
|
||||
},
|
||||
);
|
||||
const interpolationNodeTag = NativeAnimatedModule.createAnimatedNode.mock.calls.find(
|
||||
call => call[1].type === 'interpolation',
|
||||
(call) => call[1].type === 'interpolation',
|
||||
)[0];
|
||||
const valueNodeTag = NativeAnimatedModule.createAnimatedNode.mock.calls.find(
|
||||
call => call[1].type === 'value',
|
||||
(call) => call[1].type === 'value',
|
||||
)[0];
|
||||
expect(NativeAnimatedModule.connectAnimatedNodes).toBeCalledWith(
|
||||
valueNodeTag,
|
||||
@@ -577,18 +613,22 @@ describe('Native Animated', () => {
|
||||
{type: 'diffclamp', input: expect.any(Number), max: 20, min: 0},
|
||||
);
|
||||
const diffClampCalls = NativeAnimatedModule.createAnimatedNode.mock.calls.filter(
|
||||
call => call[1].type === 'diffclamp',
|
||||
(call) => call[1].type === 'diffclamp',
|
||||
);
|
||||
expect(diffClampCalls.length).toBe(1);
|
||||
const diffClampCall = diffClampCalls[0];
|
||||
const diffClampNodeTag = diffClampCall[0];
|
||||
const diffClampConnectionCalls = NativeAnimatedModule.connectAnimatedNodes.mock.calls.filter(
|
||||
call => call[1] === diffClampNodeTag,
|
||||
(call) => call[1] === diffClampNodeTag,
|
||||
);
|
||||
expect(diffClampConnectionCalls.length).toBe(1);
|
||||
expect(NativeAnimatedModule.createAnimatedNode).toBeCalledWith(
|
||||
diffClampCall[1].input,
|
||||
{type: 'value', value: 2, offset: 0},
|
||||
{
|
||||
type: 'value',
|
||||
value: 2,
|
||||
offset: 0,
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
@@ -449,8 +449,8 @@ describe('Easing', () => {
|
||||
],
|
||||
};
|
||||
|
||||
Object.keys(Samples).forEach(function(type) {
|
||||
it('should ease ' + type, function() {
|
||||
Object.keys(Samples).forEach(function (type) {
|
||||
it('should ease ' + type, function () {
|
||||
const [modeName, easingName, isFunction] = type.split('_');
|
||||
let easing = Easing[easingName];
|
||||
if (isFunction !== undefined) {
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
const bezier = require('../bezier');
|
||||
|
||||
const identity = function(x) {
|
||||
const identity = function (x) {
|
||||
return x;
|
||||
};
|
||||
|
||||
@@ -28,7 +28,7 @@ function assertClose(a, b, precision = 3) {
|
||||
}
|
||||
|
||||
function makeAssertCloseWithPrecision(precision) {
|
||||
return function(a, b) {
|
||||
return function (a, b) {
|
||||
assertClose(a, b, precision);
|
||||
};
|
||||
}
|
||||
@@ -44,43 +44,43 @@ function allEquals(be1, be2, samples, assertion) {
|
||||
}
|
||||
|
||||
function repeat(n) {
|
||||
return function(f) {
|
||||
return function (f) {
|
||||
for (let i = 0; i < n; ++i) {
|
||||
f();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
describe('bezier', function() {
|
||||
it('should be a function', function() {
|
||||
describe('bezier', function () {
|
||||
it('should be a function', function () {
|
||||
expect(typeof bezier === 'function').toBe(true);
|
||||
});
|
||||
it('should creates an object', function() {
|
||||
it('should creates an object', function () {
|
||||
expect(typeof bezier(0, 0, 1, 1) === 'function').toBe(true);
|
||||
});
|
||||
it('should fail with wrong arguments', function() {
|
||||
expect(function() {
|
||||
it('should fail with wrong arguments', function () {
|
||||
expect(function () {
|
||||
bezier(0.5, 0.5, -5, 0.5);
|
||||
}).toThrow();
|
||||
expect(function() {
|
||||
expect(function () {
|
||||
bezier(0.5, 0.5, 5, 0.5);
|
||||
}).toThrow();
|
||||
expect(function() {
|
||||
expect(function () {
|
||||
bezier(-2, 0.5, 0.5, 0.5);
|
||||
}).toThrow();
|
||||
expect(function() {
|
||||
expect(function () {
|
||||
bezier(2, 0.5, 0.5, 0.5);
|
||||
}).toThrow();
|
||||
});
|
||||
describe('linear curves', function() {
|
||||
it('should be linear', function() {
|
||||
describe('linear curves', function () {
|
||||
it('should be linear', function () {
|
||||
allEquals(bezier(0, 0, 1, 1), bezier(1, 1, 0, 0), 100);
|
||||
allEquals(bezier(0, 0, 1, 1), identity, 100);
|
||||
});
|
||||
});
|
||||
describe('common properties', function() {
|
||||
it('should be the right value at extremes', function() {
|
||||
repeat(10)(function() {
|
||||
describe('common properties', function () {
|
||||
it('should be the right value at extremes', function () {
|
||||
repeat(10)(function () {
|
||||
const a = Math.random(),
|
||||
b = 2 * Math.random() - 0.5,
|
||||
c = Math.random(),
|
||||
@@ -91,24 +91,24 @@ describe('bezier', function() {
|
||||
});
|
||||
});
|
||||
|
||||
it('should approach the projected value of its x=y projected curve', function() {
|
||||
repeat(10)(function() {
|
||||
it('should approach the projected value of its x=y projected curve', function () {
|
||||
repeat(10)(function () {
|
||||
const a = Math.random(),
|
||||
b = Math.random(),
|
||||
c = Math.random(),
|
||||
d = Math.random();
|
||||
const easing = bezier(a, b, c, d);
|
||||
const projected = bezier(b, a, d, c);
|
||||
const composed = function(x) {
|
||||
const composed = function (x) {
|
||||
return projected(easing(x));
|
||||
};
|
||||
allEquals(identity, composed, 100, makeAssertCloseWithPrecision(2));
|
||||
});
|
||||
});
|
||||
});
|
||||
describe('two same instances', function() {
|
||||
it('should be strictly equals', function() {
|
||||
repeat(10)(function() {
|
||||
describe('two same instances', function () {
|
||||
it('should be strictly equals', function () {
|
||||
repeat(10)(function () {
|
||||
const a = Math.random(),
|
||||
b = 2 * Math.random() - 0.5,
|
||||
c = Math.random(),
|
||||
@@ -117,9 +117,9 @@ describe('bezier', function() {
|
||||
});
|
||||
});
|
||||
});
|
||||
describe('symmetric curves', function() {
|
||||
it('should have a central value y~=0.5 at x=0.5', function() {
|
||||
repeat(10)(function() {
|
||||
describe('symmetric curves', function () {
|
||||
it('should have a central value y~=0.5 at x=0.5', function () {
|
||||
repeat(10)(function () {
|
||||
const a = Math.random(),
|
||||
b = 2 * Math.random() - 0.5,
|
||||
c = 1 - a,
|
||||
@@ -128,14 +128,14 @@ describe('bezier', function() {
|
||||
assertClose(easing(0.5), 0.5, 2);
|
||||
});
|
||||
});
|
||||
it('should be symmetrical', function() {
|
||||
repeat(10)(function() {
|
||||
it('should be symmetrical', function () {
|
||||
repeat(10)(function () {
|
||||
const a = Math.random(),
|
||||
b = 2 * Math.random() - 0.5,
|
||||
c = 1 - a,
|
||||
d = 1 - b;
|
||||
const easing = bezier(a, b, c, d);
|
||||
const sym = function(x) {
|
||||
const sym = function (x) {
|
||||
return 1 - easing(1 - x);
|
||||
};
|
||||
allEquals(easing, sym, 100, makeAssertCloseWithPrecision(2));
|
||||
|
||||
@@ -56,7 +56,7 @@ function createAnimatedComponent<Props: {+[string]: mixed, ...}, Instance>(
|
||||
}
|
||||
|
||||
_detachNativeEvents() {
|
||||
this._eventDetachers.forEach(remove => remove());
|
||||
this._eventDetachers.forEach((remove) => remove());
|
||||
this._eventDetachers = [];
|
||||
}
|
||||
|
||||
@@ -140,7 +140,7 @@ function createAnimatedComponent<Props: {+[string]: mixed, ...}, Instance>(
|
||||
|
||||
_setComponentRef = setAndForwardRef({
|
||||
getForwardedRef: () => this.props.forwardedRef,
|
||||
setLocalRef: ref => {
|
||||
setLocalRef: (ref) => {
|
||||
this._prevComponent = this._component;
|
||||
this._component = ref;
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ export type InterpolationConfigType = {
|
||||
extrapolateRight?: ExtrapolateType,
|
||||
};
|
||||
|
||||
const linear = t => t;
|
||||
const linear = (t) => t;
|
||||
|
||||
/**
|
||||
* Very handy helper to map input ranges to output ranges with an easing
|
||||
@@ -75,7 +75,7 @@ function createInterpolation(
|
||||
extrapolateRight = config.extrapolate;
|
||||
}
|
||||
|
||||
return input => {
|
||||
return (input) => {
|
||||
invariant(
|
||||
typeof input === 'number',
|
||||
'Cannot interpolation an input which is not a number',
|
||||
@@ -209,7 +209,7 @@ function createInterpolationFromStringOutputRange(
|
||||
* guard against this possibility.
|
||||
*/
|
||||
const outputRanges = outputRange[0].match(stringShapeRegex).map(() => []);
|
||||
outputRange.forEach(value => {
|
||||
outputRange.forEach((value) => {
|
||||
/* $FlowFixMe(>=0.18.0): `value.match()` can return `null`. Need to guard
|
||||
* against this possibility.
|
||||
*/
|
||||
@@ -233,7 +233,7 @@ function createInterpolationFromStringOutputRange(
|
||||
// round the opacity (4th column).
|
||||
const shouldRound = isRgbOrRgba(outputRange[0]);
|
||||
|
||||
return input => {
|
||||
return (input) => {
|
||||
let i = 0;
|
||||
// 'rgba(0, 100, 200, 0)'
|
||||
// ->
|
||||
|
||||
@@ -121,7 +121,7 @@ class AnimatedNode {
|
||||
NativeAnimatedAPI.startListeningToAnimatedNodeValue(this.__getNativeTag());
|
||||
this.__nativeAnimatedValueListener = NativeAnimatedHelper.nativeEventEmitter.addListener(
|
||||
'onAnimatedValueUpdate',
|
||||
data => {
|
||||
(data) => {
|
||||
if (data.tag !== this.__getNativeTag()) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ class AnimatedTransform extends AnimatedWithChildren {
|
||||
}
|
||||
|
||||
__makeNative() {
|
||||
this._transforms.forEach(transform => {
|
||||
this._transforms.forEach((transform) => {
|
||||
for (const key in transform) {
|
||||
const value = transform[key];
|
||||
if (value instanceof AnimatedNode) {
|
||||
@@ -35,7 +35,7 @@ class AnimatedTransform extends AnimatedWithChildren {
|
||||
}
|
||||
|
||||
__getValue(): $ReadOnlyArray<Object> {
|
||||
return this._transforms.map(transform => {
|
||||
return this._transforms.map((transform) => {
|
||||
const result = {};
|
||||
for (const key in transform) {
|
||||
const value = transform[key];
|
||||
@@ -50,7 +50,7 @@ class AnimatedTransform extends AnimatedWithChildren {
|
||||
}
|
||||
|
||||
__getAnimatedValue(): $ReadOnlyArray<Object> {
|
||||
return this._transforms.map(transform => {
|
||||
return this._transforms.map((transform) => {
|
||||
const result = {};
|
||||
for (const key in transform) {
|
||||
const value = transform[key];
|
||||
@@ -66,7 +66,7 @@ class AnimatedTransform extends AnimatedWithChildren {
|
||||
}
|
||||
|
||||
__attach(): void {
|
||||
this._transforms.forEach(transform => {
|
||||
this._transforms.forEach((transform) => {
|
||||
for (const key in transform) {
|
||||
const value = transform[key];
|
||||
if (value instanceof AnimatedNode) {
|
||||
@@ -77,7 +77,7 @@ class AnimatedTransform extends AnimatedWithChildren {
|
||||
}
|
||||
|
||||
__detach(): void {
|
||||
this._transforms.forEach(transform => {
|
||||
this._transforms.forEach((transform) => {
|
||||
for (const key in transform) {
|
||||
const value = transform[key];
|
||||
if (value instanceof AnimatedNode) {
|
||||
@@ -91,7 +91,7 @@ class AnimatedTransform extends AnimatedWithChildren {
|
||||
__getNativeConfig(): any {
|
||||
const transConfigs = [];
|
||||
|
||||
this._transforms.forEach(transform => {
|
||||
this._transforms.forEach((transform) => {
|
||||
for (const key in transform) {
|
||||
const value = transform[key];
|
||||
if (value instanceof AnimatedNode) {
|
||||
|
||||
@@ -57,7 +57,7 @@ function _flush(rootNode: AnimatedValue): void {
|
||||
}
|
||||
findAnimatedStyles(rootNode);
|
||||
/* $FlowFixMe */
|
||||
animatedStyles.forEach(animatedStyle => animatedStyle.update());
|
||||
animatedStyles.forEach((animatedStyle) => animatedStyle.update());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -208,12 +208,12 @@ class AnimatedValue extends AnimatedWithChildren {
|
||||
this._animation = animation;
|
||||
animation.start(
|
||||
this._value,
|
||||
value => {
|
||||
(value) => {
|
||||
// Natively driven animations will never call into that callback, therefore we can always
|
||||
// pass flush = true to allow the updated value to propagate to native with setNativeProps
|
||||
this._updateValue(value, true /* flush */);
|
||||
},
|
||||
result => {
|
||||
(result) => {
|
||||
this._animation = null;
|
||||
if (handle !== null) {
|
||||
InteractionManager.clearInteractionHandle(handle);
|
||||
|
||||
@@ -10,6 +10,6 @@
|
||||
'use strict';
|
||||
|
||||
module.exports = {
|
||||
createInteractionHandle: function() {},
|
||||
clearInteractionHandle: function() {},
|
||||
createInteractionHandle: function () {},
|
||||
clearInteractionHandle: function () {},
|
||||
};
|
||||
|
||||
@@ -13,13 +13,13 @@ function SetPolyfill() {
|
||||
this._cache = [];
|
||||
}
|
||||
|
||||
SetPolyfill.prototype.add = function(e) {
|
||||
SetPolyfill.prototype.add = function (e) {
|
||||
if (this._cache.indexOf(e) === -1) {
|
||||
this._cache.push(e);
|
||||
}
|
||||
};
|
||||
|
||||
SetPolyfill.prototype.forEach = function(cb) {
|
||||
SetPolyfill.prototype.forEach = function (cb) {
|
||||
this._cache.forEach(cb);
|
||||
};
|
||||
|
||||
|
||||
@@ -8,6 +8,6 @@
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
module.exports = function(style) {
|
||||
module.exports = function (style) {
|
||||
return style;
|
||||
};
|
||||
|
||||
@@ -47,7 +47,7 @@ class AppState extends NativeEventEmitter {
|
||||
// prop is up to date, we have to register an observer that updates it
|
||||
// whenever the state changes, even if nobody cares. We should just
|
||||
// deprecate the `currentState` property and get rid of this.
|
||||
this.addListener('appStateDidChange', appStateData => {
|
||||
this.addListener('appStateDidChange', (appStateData) => {
|
||||
eventUpdated = true;
|
||||
this.currentState = appStateData.app_state;
|
||||
});
|
||||
@@ -55,7 +55,7 @@ class AppState extends NativeEventEmitter {
|
||||
// TODO: see above - this request just populates the value of `currentState`
|
||||
// when the module is first initialized. Would be better to get rid of the
|
||||
// prop and expose `getCurrentAppState` method directly.
|
||||
NativeAppState.getCurrentAppState(appStateData => {
|
||||
NativeAppState.getCurrentAppState((appStateData) => {
|
||||
// It's possible that the state will have changed here & listeners need to be notified
|
||||
if (!eventUpdated && this.currentState !== appStateData.app_state) {
|
||||
this.currentState = appStateData.app_state;
|
||||
@@ -86,7 +86,7 @@ class AppState extends NativeEventEmitter {
|
||||
case 'change': {
|
||||
this._eventHandlers[type].set(
|
||||
handler,
|
||||
this.addListener('appStateDidChange', appStateData => {
|
||||
this.addListener('appStateDidChange', (appStateData) => {
|
||||
handler(appStateData.app_state);
|
||||
}),
|
||||
);
|
||||
@@ -104,7 +104,7 @@ class AppState extends NativeEventEmitter {
|
||||
case 'focus': {
|
||||
this._eventHandlers[type].set(
|
||||
handler,
|
||||
this.addListener('appStateFocusChange', hasFocus => {
|
||||
this.addListener('appStateFocusChange', (hasFocus) => {
|
||||
if (type === 'blur' && !hasFocus) {
|
||||
handler();
|
||||
}
|
||||
|
||||
@@ -86,7 +86,7 @@ class MessageQueue {
|
||||
|
||||
static spy(spyOrToggle: boolean | ((data: SpyData) => void)) {
|
||||
if (spyOrToggle === true) {
|
||||
MessageQueue.prototype.__spy = info => {
|
||||
MessageQueue.prototype.__spy = (info) => {
|
||||
console.log(
|
||||
`${info.type === TO_JS ? 'N->JS' : 'JS->N'} : ` +
|
||||
`${info.module ? info.module + '.' : ''}${info.method}` +
|
||||
@@ -148,7 +148,7 @@ class MessageQueue {
|
||||
this._lazyCallableModules[name] = () => module;
|
||||
}
|
||||
|
||||
registerLazyCallableModule(name: string, factory: void => Object) {
|
||||
registerLazyCallableModule(name: string, factory: (void) => Object) {
|
||||
let module: Object;
|
||||
let getValue: ?(void) => Object = factory;
|
||||
this._lazyCallableModules[name] = () => {
|
||||
@@ -253,7 +253,7 @@ class MessageQueue {
|
||||
// folly-convertible. As a special case, if a prop value is a
|
||||
// function it is permitted here, and special-cased in the
|
||||
// conversion.
|
||||
const isValidArgument = val => {
|
||||
const isValidArgument = (val) => {
|
||||
const t = typeof val;
|
||||
if (
|
||||
t === 'undefined' ||
|
||||
|
||||
@@ -106,8 +106,8 @@ function genMethod(moduleID: number, methodID: number, type: MethodType) {
|
||||
moduleID,
|
||||
methodID,
|
||||
args,
|
||||
data => resolve(data),
|
||||
errorData =>
|
||||
(data) => resolve(data),
|
||||
(errorData) =>
|
||||
reject(updateErrorWithErrorData(errorData, enqueueingFrameError)),
|
||||
);
|
||||
});
|
||||
|
||||
@@ -15,8 +15,8 @@
|
||||
* cases.
|
||||
*/
|
||||
const MessageQueueTestModule = {
|
||||
testHook1: function() {},
|
||||
testHook2: function() {},
|
||||
testHook1: function () {},
|
||||
testHook2: function () {},
|
||||
};
|
||||
|
||||
module.exports = MessageQueueTestModule;
|
||||
|
||||
@@ -30,8 +30,8 @@ const assertQueue = (flushedQueue, index, moduleID, methodID, params) => {
|
||||
//
|
||||
// [ ] Local modules that throw exceptions are gracefully caught. In that case
|
||||
// local callbacks stored by IDs are cleaned up.
|
||||
describe('MessageQueue', function() {
|
||||
beforeEach(function() {
|
||||
describe('MessageQueue', function () {
|
||||
beforeEach(function () {
|
||||
jest.resetModules();
|
||||
MessageQueue = require('../MessageQueue');
|
||||
MessageQueueTestModule = require('../__mocks__/MessageQueueTestModule');
|
||||
@@ -81,13 +81,25 @@ describe('MessageQueue', function() {
|
||||
});
|
||||
|
||||
it('should throw when calling the same callback twice', () => {
|
||||
queue.enqueueNativeCall(0, 1, [], () => {}, () => {});
|
||||
queue.enqueueNativeCall(
|
||||
0,
|
||||
1,
|
||||
[],
|
||||
() => {},
|
||||
() => {},
|
||||
);
|
||||
queue.__invokeCallback(1, []);
|
||||
expect(() => queue.__invokeCallback(1, [])).toThrow();
|
||||
});
|
||||
|
||||
it('should throw when calling both success and failure callback', () => {
|
||||
queue.enqueueNativeCall(0, 1, [], () => {}, () => {});
|
||||
queue.enqueueNativeCall(
|
||||
0,
|
||||
1,
|
||||
[],
|
||||
() => {},
|
||||
() => {},
|
||||
);
|
||||
queue.__invokeCallback(1, []);
|
||||
expect(() => queue.__invokeCallback(0, [])).toThrow();
|
||||
});
|
||||
@@ -128,7 +140,7 @@ describe('MessageQueue', function() {
|
||||
|
||||
it('should check if the global error handler is not overridden by the DebuggerInternal object', () => {
|
||||
const dummyModule = {
|
||||
dummy: function() {},
|
||||
dummy: function () {},
|
||||
};
|
||||
const name = 'emptyModuleName';
|
||||
const factory = jest.fn(() => dummyModule);
|
||||
@@ -140,7 +152,7 @@ describe('MessageQueue', function() {
|
||||
|
||||
it('should check if the global error handler is overridden by the DebuggerInternal object', () => {
|
||||
const dummyModule = {
|
||||
dummy: function() {},
|
||||
dummy: function () {},
|
||||
};
|
||||
const name = 'emptyModuleName';
|
||||
const factory = jest.fn(() => dummyModule);
|
||||
|
||||
@@ -38,8 +38,8 @@ const assertQueue = (flushedQueue, index, moduleID, methodID, params) => {
|
||||
// success callbacks are cleaned up.
|
||||
//
|
||||
// [ ] Remote invocation throws if not supplying an error callback.
|
||||
describe('MessageQueue', function() {
|
||||
beforeEach(function() {
|
||||
describe('MessageQueue', function () {
|
||||
beforeEach(function () {
|
||||
jest.resetModules();
|
||||
|
||||
global.__fbBatchedBridgeConfig = require('../__mocks__/MessageQueueTestConfig');
|
||||
@@ -55,7 +55,7 @@ describe('MessageQueue', function() {
|
||||
assertQueue(flushedQueue, 0, 0, 0, ['foo']);
|
||||
});
|
||||
|
||||
it('should make round trip and clear memory', function() {
|
||||
it('should make round trip and clear memory', function () {
|
||||
const onFail = jest.fn();
|
||||
const onSucc = jest.fn();
|
||||
|
||||
@@ -101,7 +101,7 @@ describe('MessageQueue', function() {
|
||||
// Handle the first remote invocation by signaling failure.
|
||||
BatchedBridge.__invokeCallback(firstFailCBID, ['firstFailure']);
|
||||
// The failure callback was already invoked, the success is no longer valid
|
||||
expect(function() {
|
||||
expect(function () {
|
||||
BatchedBridge.__invokeCallback(firstSuccCBID, ['firstSucc']);
|
||||
}).toThrow();
|
||||
expect(onFail.mock.calls.length).toBe(1);
|
||||
@@ -110,14 +110,14 @@ describe('MessageQueue', function() {
|
||||
// Handle the second remote invocation by signaling success.
|
||||
BatchedBridge.__invokeCallback(secondSuccCBID, ['secondSucc']);
|
||||
// The success callback was already invoked, the fail cb is no longer valid
|
||||
expect(function() {
|
||||
expect(function () {
|
||||
BatchedBridge.__invokeCallback(secondFailCBID, ['secondFail']);
|
||||
}).toThrow();
|
||||
expect(onFail.mock.calls.length).toBe(1);
|
||||
expect(onSucc.mock.calls.length).toBe(1);
|
||||
});
|
||||
|
||||
it('promise-returning methods (type=promise)', async function() {
|
||||
it('promise-returning methods (type=promise)', async function () {
|
||||
// Perform communication
|
||||
const promise1 = NativeModules.RemoteModule1.promiseReturningMethod(
|
||||
'paloAlto',
|
||||
@@ -162,7 +162,7 @@ describe('MessageQueue', function() {
|
||||
// Handle the first remote invocation by signaling failure.
|
||||
BatchedBridge.__invokeCallback(firstFailCBID, [{message: 'firstFailure'}]);
|
||||
// The failure callback was already invoked, the success is no longer valid
|
||||
expect(function() {
|
||||
expect(function () {
|
||||
BatchedBridge.__invokeCallback(firstSuccCBID, ['firstSucc']);
|
||||
}).toThrow();
|
||||
await expect(promise1).rejects.toBeInstanceOf(Error);
|
||||
@@ -171,18 +171,18 @@ describe('MessageQueue', function() {
|
||||
// Handle the second remote invocation by signaling success.
|
||||
BatchedBridge.__invokeCallback(secondSuccCBID, ['secondSucc']);
|
||||
// The success callback was already invoked, the fail cb is no longer valid
|
||||
expect(function() {
|
||||
expect(function () {
|
||||
BatchedBridge.__invokeCallback(secondFailCBID, ['secondFail']);
|
||||
}).toThrow();
|
||||
await promise2;
|
||||
});
|
||||
|
||||
describe('sync methods', () => {
|
||||
afterEach(function() {
|
||||
afterEach(function () {
|
||||
delete global.nativeCallSyncHook;
|
||||
});
|
||||
|
||||
it('throwing an exception', function() {
|
||||
it('throwing an exception', function () {
|
||||
global.nativeCallSyncHook = jest.fn(() => {
|
||||
throw new Error('firstFailure');
|
||||
});
|
||||
@@ -206,7 +206,7 @@ describe('MessageQueue', function() {
|
||||
});
|
||||
});
|
||||
|
||||
it('returning a value', function() {
|
||||
it('returning a value', function () {
|
||||
global.nativeCallSyncHook = jest.fn(() => {
|
||||
return 'secondSucc';
|
||||
});
|
||||
|
||||
@@ -25,7 +25,7 @@ import invariant from 'invariant';
|
||||
* http://stackoverflow.com/questions/105034
|
||||
*/
|
||||
function uuidv4(): string {
|
||||
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, c => {
|
||||
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {
|
||||
const r = (Math.random() * 16) | 0,
|
||||
v = c == 'x' ? r : (r & 0x3) | 0x8;
|
||||
return v.toString(16);
|
||||
@@ -66,7 +66,7 @@ class BlobManager {
|
||||
invariant(NativeBlobModule, 'NativeBlobModule is available.');
|
||||
|
||||
const blobId = uuidv4();
|
||||
const items = parts.map(part => {
|
||||
const items = parts.map((part) => {
|
||||
if (
|
||||
part instanceof ArrayBuffer ||
|
||||
(global.ArrayBufferView && part instanceof global.ArrayBufferView)
|
||||
|
||||
@@ -62,7 +62,7 @@ class FileReader extends (EventTarget(...READER_EVENTS): any) {
|
||||
}
|
||||
|
||||
_clearSubscriptions(): void {
|
||||
this._subscriptions.forEach(sub => sub.remove());
|
||||
this._subscriptions.forEach((sub) => sub.remove());
|
||||
this._subscriptions = [];
|
||||
}
|
||||
|
||||
@@ -102,7 +102,7 @@ class FileReader extends (EventTarget(...READER_EVENTS): any) {
|
||||
this._result = text;
|
||||
this._setReadyState(DONE);
|
||||
},
|
||||
error => {
|
||||
(error) => {
|
||||
if (this._aborted) {
|
||||
return;
|
||||
}
|
||||
@@ -129,7 +129,7 @@ class FileReader extends (EventTarget(...READER_EVENTS): any) {
|
||||
this._result = text;
|
||||
this._setReadyState(DONE);
|
||||
},
|
||||
error => {
|
||||
(error) => {
|
||||
if (this._aborted) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ export class URLSearchParams {
|
||||
|
||||
constructor(params: any) {
|
||||
if (typeof params === 'object') {
|
||||
Object.keys(params).forEach(key => this.append(key, params[key]));
|
||||
Object.keys(params).forEach((key) => this.append(key, params[key]));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -119,9 +119,7 @@ export class URL {
|
||||
if (BLOB_URL_PREFIX === null) {
|
||||
throw new Error('Cannot create URL for blob!');
|
||||
}
|
||||
return `${BLOB_URL_PREFIX}${blob.data.blobId}?offset=${
|
||||
blob.data.offset
|
||||
}&size=${blob.size}`;
|
||||
return `${BLOB_URL_PREFIX}${blob.data.blobId}?offset=${blob.data.offset}&size=${blob.size}`;
|
||||
}
|
||||
|
||||
static revokeObjectURL(url: string) {
|
||||
|
||||
@@ -16,7 +16,7 @@ jest.setMock('../../BatchedBridge/NativeModules', {
|
||||
|
||||
const Blob = require('../Blob');
|
||||
|
||||
describe('Blob', function() {
|
||||
describe('Blob', function () {
|
||||
it('should create empty blob', () => {
|
||||
const blob = new Blob();
|
||||
expect(blob).toBeInstanceOf(Blob);
|
||||
|
||||
@@ -17,7 +17,7 @@ jest.setMock('../../BatchedBridge/NativeModules', {
|
||||
const Blob = require('../Blob');
|
||||
const BlobManager = require('../BlobManager');
|
||||
|
||||
describe('BlobManager', function() {
|
||||
describe('BlobManager', function () {
|
||||
it('should create blob from parts', () => {
|
||||
const blob = BlobManager.createFromParts([], {type: 'text/html'});
|
||||
expect(blob).toBeInstanceOf(Blob);
|
||||
|
||||
@@ -17,8 +17,8 @@ jest.setMock('../../BatchedBridge/NativeModules', {
|
||||
const Blob = require('../Blob');
|
||||
const File = require('../File');
|
||||
|
||||
describe('babel 7 smoke test', function() {
|
||||
it('should be able to extend a class with native name', function() {
|
||||
describe('babel 7 smoke test', function () {
|
||||
it('should be able to extend a class with native name', function () {
|
||||
let called = false;
|
||||
class Array {
|
||||
constructor() {
|
||||
@@ -40,14 +40,14 @@ describe('babel 7 smoke test', function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe('Blob', function() {
|
||||
it('regression caused by circular dep && babel 7', function() {
|
||||
describe('Blob', function () {
|
||||
it('regression caused by circular dep && babel 7', function () {
|
||||
const blob = new Blob([], {type: 'image/jpeg'});
|
||||
expect(blob).toBeInstanceOf(Blob);
|
||||
});
|
||||
});
|
||||
|
||||
describe('File', function() {
|
||||
describe('File', function () {
|
||||
it('should create empty file', () => {
|
||||
const file = new File([], 'test.jpg');
|
||||
expect(file).toBeInstanceOf(File);
|
||||
|
||||
@@ -18,7 +18,7 @@ jest.unmock('event-target-shim').setMock('../../BatchedBridge/NativeModules', {
|
||||
const Blob = require('../Blob');
|
||||
const FileReader = require('../FileReader');
|
||||
|
||||
describe('FileReader', function() {
|
||||
describe('FileReader', function () {
|
||||
it('should read blob as text', async () => {
|
||||
const e = await new Promise((resolve, reject) => {
|
||||
const reader = new FileReader();
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
const URL = require('../URL').URL;
|
||||
|
||||
describe('URL', function() {
|
||||
describe('URL', function () {
|
||||
it('should pass Mozilla Dev Network examples', () => {
|
||||
const a = new URL('/', 'https://developer.mozilla.org');
|
||||
expect(a.href).toBe('https://developer.mozilla.org/');
|
||||
|
||||
@@ -41,25 +41,25 @@ const AccessibilityInfo = {
|
||||
/**
|
||||
* iOS only
|
||||
*/
|
||||
isBoldTextEnabled: function(): Promise<boolean> {
|
||||
isBoldTextEnabled: function (): Promise<boolean> {
|
||||
return Promise.resolve(false);
|
||||
},
|
||||
|
||||
/**
|
||||
* iOS only
|
||||
*/
|
||||
isGrayscaleEnabled: function(): Promise<boolean> {
|
||||
isGrayscaleEnabled: function (): Promise<boolean> {
|
||||
return Promise.resolve(false);
|
||||
},
|
||||
|
||||
/**
|
||||
* iOS only
|
||||
*/
|
||||
isInvertColorsEnabled: function(): Promise<boolean> {
|
||||
isInvertColorsEnabled: function (): Promise<boolean> {
|
||||
return Promise.resolve(false);
|
||||
},
|
||||
|
||||
isReduceMotionEnabled: function(): Promise<boolean> {
|
||||
isReduceMotionEnabled: function (): Promise<boolean> {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (NativeAccessibilityInfo) {
|
||||
NativeAccessibilityInfo.isReduceMotionEnabled(resolve);
|
||||
@@ -72,11 +72,11 @@ const AccessibilityInfo = {
|
||||
/**
|
||||
* iOS only
|
||||
*/
|
||||
isReduceTransparencyEnabled: function(): Promise<boolean> {
|
||||
isReduceTransparencyEnabled: function (): Promise<boolean> {
|
||||
return Promise.resolve(false);
|
||||
},
|
||||
|
||||
isScreenReaderEnabled: function(): Promise<boolean> {
|
||||
isScreenReaderEnabled: function (): Promise<boolean> {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (NativeAccessibilityInfo) {
|
||||
NativeAccessibilityInfo.isTouchExplorationEnabled(resolve);
|
||||
@@ -98,7 +98,7 @@ const AccessibilityInfo = {
|
||||
return this.isScreenReaderEnabled;
|
||||
},
|
||||
|
||||
addEventListener: function(
|
||||
addEventListener: function (
|
||||
eventName: ChangeEventName,
|
||||
handler: Function,
|
||||
): void {
|
||||
@@ -107,14 +107,14 @@ const AccessibilityInfo = {
|
||||
if (eventName === 'change' || eventName === 'screenReaderChanged') {
|
||||
listener = RCTDeviceEventEmitter.addListener(
|
||||
TOUCH_EXPLORATION_EVENT,
|
||||
enabled => {
|
||||
(enabled) => {
|
||||
handler(enabled);
|
||||
},
|
||||
);
|
||||
} else if (eventName === 'reduceMotionChanged') {
|
||||
listener = RCTDeviceEventEmitter.addListener(
|
||||
REDUCE_MOTION_EVENT,
|
||||
enabled => {
|
||||
(enabled) => {
|
||||
handler(enabled);
|
||||
},
|
||||
);
|
||||
@@ -123,7 +123,7 @@ const AccessibilityInfo = {
|
||||
_subscriptions.set(handler, listener);
|
||||
},
|
||||
|
||||
removeEventListener: function(
|
||||
removeEventListener: function (
|
||||
eventName: ChangeEventName,
|
||||
handler: Function,
|
||||
): void {
|
||||
@@ -140,7 +140,7 @@ const AccessibilityInfo = {
|
||||
*
|
||||
* See https://reactnative.dev/docs/accessibilityinfo.html#setaccessibilityfocus
|
||||
*/
|
||||
setAccessibilityFocus: function(reactTag: number): void {
|
||||
setAccessibilityFocus: function (reactTag: number): void {
|
||||
UIManager.sendAccessibilityEvent(
|
||||
reactTag,
|
||||
UIManager.getConstants().AccessibilityEventTypes.typeViewFocused,
|
||||
@@ -152,7 +152,7 @@ const AccessibilityInfo = {
|
||||
*
|
||||
* See https://reactnative.dev/docs/accessibilityinfo.html#announceforaccessibility
|
||||
*/
|
||||
announceForAccessibility: function(announcement: string): void {
|
||||
announceForAccessibility: function (announcement: string): void {
|
||||
if (NativeAccessibilityInfo) {
|
||||
NativeAccessibilityInfo.announceForAccessibility(announcement);
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ const AccessibilityInfo = {
|
||||
*
|
||||
* See https://reactnative.dev/docs/accessibilityinfo.html#isBoldTextEnabled
|
||||
*/
|
||||
isBoldTextEnabled: function(): Promise<boolean> {
|
||||
isBoldTextEnabled: function (): Promise<boolean> {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (NativeAccessibilityManager) {
|
||||
NativeAccessibilityManager.getCurrentBoldTextState(resolve, reject);
|
||||
@@ -75,7 +75,7 @@ const AccessibilityInfo = {
|
||||
*
|
||||
* See https://reactnative.dev/docs/accessibilityinfo.html#isGrayscaleEnabled
|
||||
*/
|
||||
isGrayscaleEnabled: function(): Promise<boolean> {
|
||||
isGrayscaleEnabled: function (): Promise<boolean> {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (NativeAccessibilityManager) {
|
||||
NativeAccessibilityManager.getCurrentGrayscaleState(resolve, reject);
|
||||
@@ -93,7 +93,7 @@ const AccessibilityInfo = {
|
||||
*
|
||||
* See https://reactnative.dev/docs/accessibilityinfo.html#isInvertColorsEnabled
|
||||
*/
|
||||
isInvertColorsEnabled: function(): Promise<boolean> {
|
||||
isInvertColorsEnabled: function (): Promise<boolean> {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (NativeAccessibilityManager) {
|
||||
NativeAccessibilityManager.getCurrentInvertColorsState(resolve, reject);
|
||||
@@ -111,7 +111,7 @@ const AccessibilityInfo = {
|
||||
*
|
||||
* See https://reactnative.dev/docs/accessibilityinfo.html#isReduceMotionEnabled
|
||||
*/
|
||||
isReduceMotionEnabled: function(): Promise<boolean> {
|
||||
isReduceMotionEnabled: function (): Promise<boolean> {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (NativeAccessibilityManager) {
|
||||
NativeAccessibilityManager.getCurrentReduceMotionState(resolve, reject);
|
||||
@@ -129,7 +129,7 @@ const AccessibilityInfo = {
|
||||
*
|
||||
* See https://reactnative.dev/docs/accessibilityinfo.html#isReduceTransparencyEnabled
|
||||
*/
|
||||
isReduceTransparencyEnabled: function(): Promise<boolean> {
|
||||
isReduceTransparencyEnabled: function (): Promise<boolean> {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (NativeAccessibilityManager) {
|
||||
NativeAccessibilityManager.getCurrentReduceTransparencyState(
|
||||
@@ -150,7 +150,7 @@ const AccessibilityInfo = {
|
||||
*
|
||||
* See https://reactnative.dev/docs/accessibilityinfo.html#isScreenReaderEnabled
|
||||
*/
|
||||
isScreenReaderEnabled: function(): Promise<boolean> {
|
||||
isScreenReaderEnabled: function (): Promise<boolean> {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (NativeAccessibilityManager) {
|
||||
NativeAccessibilityManager.getCurrentVoiceOverState(resolve, reject);
|
||||
@@ -203,7 +203,7 @@ const AccessibilityInfo = {
|
||||
*
|
||||
* See https://reactnative.dev/docs/accessibilityinfo.html#addeventlistener
|
||||
*/
|
||||
addEventListener: function(
|
||||
addEventListener: function (
|
||||
eventName: ChangeEventName,
|
||||
handler: Function,
|
||||
): Object {
|
||||
@@ -233,7 +233,7 @@ const AccessibilityInfo = {
|
||||
*
|
||||
* See https://reactnative.dev/docs/accessibilityinfo.html#setaccessibilityfocus
|
||||
*/
|
||||
setAccessibilityFocus: function(reactTag: number): void {
|
||||
setAccessibilityFocus: function (reactTag: number): void {
|
||||
if (NativeAccessibilityManager) {
|
||||
NativeAccessibilityManager.setAccessibilityFocus(reactTag);
|
||||
}
|
||||
@@ -244,7 +244,7 @@ const AccessibilityInfo = {
|
||||
*
|
||||
* See https://reactnative.dev/docs/accessibilityinfo.html#announceforaccessibility
|
||||
*/
|
||||
announceForAccessibility: function(announcement: string): void {
|
||||
announceForAccessibility: function (announcement: string): void {
|
||||
if (NativeAccessibilityManager) {
|
||||
NativeAccessibilityManager.announceForAccessibility(announcement);
|
||||
}
|
||||
@@ -255,7 +255,7 @@ const AccessibilityInfo = {
|
||||
*
|
||||
* See https://reactnative.dev/docs/accessibilityinfo.html#removeeventlistener
|
||||
*/
|
||||
removeEventListener: function(
|
||||
removeEventListener: function (
|
||||
eventName: ChangeEventName,
|
||||
handler: Function,
|
||||
): void {
|
||||
|
||||
@@ -101,10 +101,7 @@ const ActivityIndicator = (props: Props, forwardedRef?: any) => {
|
||||
return (
|
||||
<View
|
||||
onLayout={onLayout}
|
||||
style={StyleSheet.compose(
|
||||
styles.container,
|
||||
style,
|
||||
)}>
|
||||
style={StyleSheet.compose(styles.container, style)}>
|
||||
{Platform.OS === 'android' ? (
|
||||
// $FlowFixMe Flow doesn't know when this is the android component
|
||||
<PlatformActivityIndicator {...nativeProps} {...androidProps} />
|
||||
|
||||
@@ -30,7 +30,7 @@ class TVEventHandler {
|
||||
);
|
||||
this.__nativeTVNavigationEventListener = this.__nativeTVNavigationEventEmitter.addListener(
|
||||
'onHWKeyEvent',
|
||||
data => {
|
||||
(data) => {
|
||||
if (callback) {
|
||||
callback(component, data);
|
||||
}
|
||||
|
||||
@@ -137,7 +137,7 @@ class CheckBox extends React.Component<Props> {
|
||||
_nativeRef: ?React.ElementRef<typeof AndroidCheckBoxNativeComponent> = null;
|
||||
_setNativeRef = setAndForwardRef({
|
||||
getForwardedRef: () => this.props.forwardedRef,
|
||||
setLocalRef: ref => {
|
||||
setLocalRef: (ref) => {
|
||||
this._nativeRef = ref;
|
||||
},
|
||||
});
|
||||
|
||||
@@ -146,7 +146,7 @@ class DatePickerIOS extends React.Component<Props> {
|
||||
<View style={props.style}>
|
||||
<RCTDatePickerNativeComponent
|
||||
testID={props.testID}
|
||||
ref={picker => {
|
||||
ref={(picker) => {
|
||||
this._picker = picker;
|
||||
}}
|
||||
style={styles.datePickerIOS}
|
||||
|
||||
@@ -237,7 +237,7 @@ class DrawerLayoutAndroid extends React.Component<Props, State> {
|
||||
);
|
||||
}
|
||||
|
||||
_onDrawerSlide = event => {
|
||||
_onDrawerSlide = (event) => {
|
||||
if (this.props.onDrawerSlide) {
|
||||
this.props.onDrawerSlide(event);
|
||||
}
|
||||
@@ -258,7 +258,7 @@ class DrawerLayoutAndroid extends React.Component<Props, State> {
|
||||
}
|
||||
};
|
||||
|
||||
_onDrawerStateChanged = event => {
|
||||
_onDrawerStateChanged = (event) => {
|
||||
if (this.props.onDrawerStateChanged) {
|
||||
this.props.onDrawerStateChanged(
|
||||
DRAWER_STATES[event.nativeEvent.drawerState],
|
||||
|
||||
@@ -179,7 +179,7 @@ const Keyboard = {
|
||||
|
||||
// Throw away the dummy object and reassign it to original module
|
||||
KeyboardEventEmitter.dismiss = dismissKeyboard;
|
||||
KeyboardEventEmitter.scheduleLayoutAnimation = function(event: KeyboardEvent) {
|
||||
KeyboardEventEmitter.scheduleLayoutAnimation = function (event: KeyboardEvent) {
|
||||
const {duration, easing} = event;
|
||||
if (duration != null && duration !== 0) {
|
||||
LayoutAnimation.configureNext({
|
||||
|
||||
@@ -138,7 +138,7 @@ class KeyboardAvoidingView extends React.Component<Props, State> {
|
||||
}
|
||||
|
||||
componentWillUnmount(): void {
|
||||
this._subscriptions.forEach(subscription => {
|
||||
this._subscriptions.forEach((subscription) => {
|
||||
subscription.remove();
|
||||
});
|
||||
}
|
||||
@@ -170,10 +170,7 @@ class KeyboardAvoidingView extends React.Component<Props, State> {
|
||||
return (
|
||||
<View
|
||||
ref={this.viewRef}
|
||||
style={StyleSheet.compose(
|
||||
style,
|
||||
heightStyle,
|
||||
)}
|
||||
style={StyleSheet.compose(style, heightStyle)}
|
||||
onLayout={this._onLayout}
|
||||
{...props}>
|
||||
{children}
|
||||
@@ -188,12 +185,9 @@ class KeyboardAvoidingView extends React.Component<Props, State> {
|
||||
onLayout={this._onLayout}
|
||||
{...props}>
|
||||
<View
|
||||
style={StyleSheet.compose(
|
||||
contentContainerStyle,
|
||||
{
|
||||
bottom: bottomHeight,
|
||||
},
|
||||
)}>
|
||||
style={StyleSheet.compose(contentContainerStyle, {
|
||||
bottom: bottomHeight,
|
||||
})}>
|
||||
{children}
|
||||
</View>
|
||||
</View>
|
||||
@@ -203,10 +197,7 @@ class KeyboardAvoidingView extends React.Component<Props, State> {
|
||||
return (
|
||||
<View
|
||||
ref={this.viewRef}
|
||||
style={StyleSheet.compose(
|
||||
style,
|
||||
{paddingBottom: bottomHeight},
|
||||
)}
|
||||
style={StyleSheet.compose(style, {paddingBottom: bottomHeight})}
|
||||
onLayout={this._onLayout}
|
||||
{...props}>
|
||||
{children}
|
||||
|
||||
@@ -67,7 +67,7 @@ describe('Keyboard', () => {
|
||||
});
|
||||
|
||||
describe('animation update type', () => {
|
||||
const assertAnimationUpdateType = type =>
|
||||
const assertAnimationUpdateType = (type) =>
|
||||
expect(LayoutAnimation.configureNext).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
duration: expect.anything(),
|
||||
|
||||
@@ -85,7 +85,7 @@ function PickerAndroid(props: Props): React.Node {
|
||||
if (onValueChange != null) {
|
||||
if (position >= 0) {
|
||||
const children = React.Children.toArray(props.children).filter(
|
||||
item => item != null,
|
||||
(item) => item != null,
|
||||
);
|
||||
const value = children[position].props.value;
|
||||
if (props.selectedValue !== value) {
|
||||
@@ -121,10 +121,7 @@ function PickerAndroid(props: Props): React.Node {
|
||||
prompt: props.prompt,
|
||||
ref: pickerRef,
|
||||
selected,
|
||||
style: StyleSheet.compose(
|
||||
styles.pickerAndroid,
|
||||
props.style,
|
||||
),
|
||||
style: StyleSheet.compose(styles.pickerAndroid, props.style),
|
||||
backgroundColor: props.backgroundColor,
|
||||
testID: props.testID,
|
||||
};
|
||||
|
||||
@@ -83,8 +83,8 @@ class PickerIOS extends React.Component<Props, State> {
|
||||
let selectedIndex = 0;
|
||||
const items = [];
|
||||
React.Children.toArray(props.children)
|
||||
.filter(child => child !== null)
|
||||
.forEach(function(child, index) {
|
||||
.filter((child) => child !== null)
|
||||
.forEach(function (child, index) {
|
||||
if (child.props.value === props.selectedValue) {
|
||||
selectedIndex = index;
|
||||
}
|
||||
@@ -106,7 +106,7 @@ class PickerIOS extends React.Component<Props, State> {
|
||||
return (
|
||||
<View style={this.props.style}>
|
||||
<RCTPickerNativeComponent
|
||||
ref={picker => {
|
||||
ref={(picker) => {
|
||||
this._picker = picker;
|
||||
}}
|
||||
testID={this.props.testID}
|
||||
@@ -136,7 +136,7 @@ class PickerIOS extends React.Component<Props, State> {
|
||||
}
|
||||
}
|
||||
|
||||
_onChange = event => {
|
||||
_onChange = (event) => {
|
||||
if (this.props.onChange) {
|
||||
this.props.onChange(event);
|
||||
}
|
||||
|
||||
@@ -123,7 +123,7 @@ const ScrollResponderMixin = {
|
||||
_subscriptionKeyboardWillHide: (null: ?EmitterSubscription),
|
||||
_subscriptionKeyboardDidShow: (null: ?EmitterSubscription),
|
||||
_subscriptionKeyboardDidHide: (null: ?EmitterSubscription),
|
||||
scrollResponderMixinGetInitialState: function(): State {
|
||||
scrollResponderMixinGetInitialState: function (): State {
|
||||
return {
|
||||
isTouching: false,
|
||||
lastMomentumScrollBeginTime: 0,
|
||||
@@ -142,7 +142,7 @@ const ScrollResponderMixin = {
|
||||
/**
|
||||
* Invoke this from an `onScroll` event.
|
||||
*/
|
||||
scrollResponderHandleScrollShouldSetResponder: function(): boolean {
|
||||
scrollResponderHandleScrollShouldSetResponder: function (): boolean {
|
||||
// Allow any event touch pass through if the default pan responder is disabled
|
||||
if (this.props.disableScrollViewPanResponder === true) {
|
||||
return false;
|
||||
@@ -175,7 +175,7 @@ const ScrollResponderMixin = {
|
||||
* true.
|
||||
*
|
||||
*/
|
||||
scrollResponderHandleStartShouldSetResponder: function(
|
||||
scrollResponderHandleStartShouldSetResponder: function (
|
||||
e: PressEvent,
|
||||
): boolean {
|
||||
// Allow any event touch pass through if the default pan responder is disabled
|
||||
@@ -206,7 +206,7 @@ const ScrollResponderMixin = {
|
||||
*
|
||||
* Invoke this from an `onStartShouldSetResponderCapture` event.
|
||||
*/
|
||||
scrollResponderHandleStartShouldSetResponderCapture: function(
|
||||
scrollResponderHandleStartShouldSetResponderCapture: function (
|
||||
e: PressEvent,
|
||||
): boolean {
|
||||
// The scroll view should receive taps instead of its descendants if:
|
||||
@@ -261,7 +261,7 @@ const ScrollResponderMixin = {
|
||||
* altogether. To improve this, find a way to disable the `UIScrollView` after
|
||||
* a touch has already started.
|
||||
*/
|
||||
scrollResponderHandleResponderReject: function() {},
|
||||
scrollResponderHandleResponderReject: function () {},
|
||||
|
||||
/**
|
||||
* We will allow the scroll view to give up its lock iff it acquired the lock
|
||||
@@ -278,7 +278,7 @@ const ScrollResponderMixin = {
|
||||
* navigation of a swipe gesture higher in the view hierarchy, should be
|
||||
* rejected.
|
||||
*/
|
||||
scrollResponderHandleTerminationRequest: function(): boolean {
|
||||
scrollResponderHandleTerminationRequest: function (): boolean {
|
||||
return !this.state.observedScrollSinceBecomingResponder;
|
||||
},
|
||||
|
||||
@@ -287,7 +287,7 @@ const ScrollResponderMixin = {
|
||||
*
|
||||
* @param {PressEvent} e Event.
|
||||
*/
|
||||
scrollResponderHandleTouchEnd: function(e: PressEvent) {
|
||||
scrollResponderHandleTouchEnd: function (e: PressEvent) {
|
||||
const nativeEvent = e.nativeEvent;
|
||||
this.state.isTouching = nativeEvent.touches.length !== 0;
|
||||
this.props.onTouchEnd && this.props.onTouchEnd(e);
|
||||
@@ -298,7 +298,7 @@ const ScrollResponderMixin = {
|
||||
*
|
||||
* @param {PressEvent} e Event.
|
||||
*/
|
||||
scrollResponderHandleTouchCancel: function(e: PressEvent) {
|
||||
scrollResponderHandleTouchCancel: function (e: PressEvent) {
|
||||
this.state.isTouching = false;
|
||||
this.props.onTouchCancel && this.props.onTouchCancel(e);
|
||||
},
|
||||
@@ -306,7 +306,7 @@ const ScrollResponderMixin = {
|
||||
/**
|
||||
* Invoke this from an `onResponderRelease` event.
|
||||
*/
|
||||
scrollResponderHandleResponderRelease: function(e: PressEvent) {
|
||||
scrollResponderHandleResponderRelease: function (e: PressEvent) {
|
||||
this.props.onResponderRelease && this.props.onResponderRelease(e);
|
||||
|
||||
if (typeof e.target === 'number') {
|
||||
@@ -336,7 +336,7 @@ const ScrollResponderMixin = {
|
||||
}
|
||||
},
|
||||
|
||||
scrollResponderHandleScroll: function(e: ScrollEvent) {
|
||||
scrollResponderHandleScroll: function (e: ScrollEvent) {
|
||||
(this: any).state.observedScrollSinceBecomingResponder = true;
|
||||
(this: any).props.onScroll && (this: any).props.onScroll(e);
|
||||
},
|
||||
@@ -344,7 +344,7 @@ const ScrollResponderMixin = {
|
||||
/**
|
||||
* Invoke this from an `onResponderGrant` event.
|
||||
*/
|
||||
scrollResponderHandleResponderGrant: function(e: ScrollEvent) {
|
||||
scrollResponderHandleResponderGrant: function (e: ScrollEvent) {
|
||||
this.state.observedScrollSinceBecomingResponder = false;
|
||||
this.props.onResponderGrant && this.props.onResponderGrant(e);
|
||||
this.state.becameResponderWhileAnimating = this.scrollResponderIsAnimating();
|
||||
@@ -357,7 +357,7 @@ const ScrollResponderMixin = {
|
||||
*
|
||||
* Invoke this from an `onScrollBeginDrag` event.
|
||||
*/
|
||||
scrollResponderHandleScrollBeginDrag: function(e: ScrollEvent) {
|
||||
scrollResponderHandleScrollBeginDrag: function (e: ScrollEvent) {
|
||||
FrameRateLogger.beginScroll(); // TODO: track all scrolls after implementing onScrollEndAnimation
|
||||
this.props.onScrollBeginDrag && this.props.onScrollBeginDrag(e);
|
||||
},
|
||||
@@ -365,7 +365,7 @@ const ScrollResponderMixin = {
|
||||
/**
|
||||
* Invoke this from an `onScrollEndDrag` event.
|
||||
*/
|
||||
scrollResponderHandleScrollEndDrag: function(e: ScrollEvent) {
|
||||
scrollResponderHandleScrollEndDrag: function (e: ScrollEvent) {
|
||||
const {velocity} = e.nativeEvent;
|
||||
// - If we are animating, then this is a "drag" that is stopping the scrollview and momentum end
|
||||
// will fire.
|
||||
@@ -384,7 +384,7 @@ const ScrollResponderMixin = {
|
||||
/**
|
||||
* Invoke this from an `onMomentumScrollBegin` event.
|
||||
*/
|
||||
scrollResponderHandleMomentumScrollBegin: function(e: ScrollEvent) {
|
||||
scrollResponderHandleMomentumScrollBegin: function (e: ScrollEvent) {
|
||||
this.state.lastMomentumScrollBeginTime = performanceNow();
|
||||
this.props.onMomentumScrollBegin && this.props.onMomentumScrollBegin(e);
|
||||
},
|
||||
@@ -392,7 +392,7 @@ const ScrollResponderMixin = {
|
||||
/**
|
||||
* Invoke this from an `onMomentumScrollEnd` event.
|
||||
*/
|
||||
scrollResponderHandleMomentumScrollEnd: function(e: ScrollEvent) {
|
||||
scrollResponderHandleMomentumScrollEnd: function (e: ScrollEvent) {
|
||||
FrameRateLogger.endScroll();
|
||||
this.state.lastMomentumScrollEndTime = performanceNow();
|
||||
this.props.onMomentumScrollEnd && this.props.onMomentumScrollEnd(e);
|
||||
@@ -409,7 +409,7 @@ const ScrollResponderMixin = {
|
||||
*
|
||||
* @param {PressEvent} e Touch Start event.
|
||||
*/
|
||||
scrollResponderHandleTouchStart: function(e: PressEvent) {
|
||||
scrollResponderHandleTouchStart: function (e: PressEvent) {
|
||||
this.state.isTouching = true;
|
||||
this.props.onTouchStart && this.props.onTouchStart(e);
|
||||
},
|
||||
@@ -425,7 +425,7 @@ const ScrollResponderMixin = {
|
||||
*
|
||||
* @param {PressEvent} e Touch Start event.
|
||||
*/
|
||||
scrollResponderHandleTouchMove: function(e: PressEvent) {
|
||||
scrollResponderHandleTouchMove: function (e: PressEvent) {
|
||||
this.props.onTouchMove && this.props.onTouchMove(e);
|
||||
},
|
||||
|
||||
@@ -434,7 +434,7 @@ const ScrollResponderMixin = {
|
||||
* view is currently animating. This is particularly useful to know when
|
||||
* a touch has just started or ended.
|
||||
*/
|
||||
scrollResponderIsAnimating: function(): boolean {
|
||||
scrollResponderIsAnimating: function (): boolean {
|
||||
const now = performanceNow();
|
||||
const timeSinceLastMomentumScrollEnd =
|
||||
now - this.state.lastMomentumScrollEndTime;
|
||||
@@ -450,7 +450,7 @@ const ScrollResponderMixin = {
|
||||
* Components can pass what node to use by defining a `getScrollableNode`
|
||||
* function otherwise `this` is used.
|
||||
*/
|
||||
scrollResponderGetScrollableNode: function(): ?number {
|
||||
scrollResponderGetScrollableNode: function (): ?number {
|
||||
return this.getScrollableNode
|
||||
? this.getScrollableNode()
|
||||
: ReactNative.findNodeHandle(this);
|
||||
@@ -467,7 +467,7 @@ const ScrollResponderMixin = {
|
||||
* the function also accepts separate arguments as as alternative to the options object.
|
||||
* This is deprecated due to ambiguity (y before x), and SHOULD NOT BE USED.
|
||||
*/
|
||||
scrollResponderScrollTo: function(
|
||||
scrollResponderScrollTo: function (
|
||||
x?:
|
||||
| number
|
||||
| {
|
||||
@@ -507,7 +507,7 @@ const ScrollResponderMixin = {
|
||||
*
|
||||
* `scrollResponderScrollToEnd({animated: true})`
|
||||
*/
|
||||
scrollResponderScrollToEnd: function(options?: {animated?: boolean, ...}) {
|
||||
scrollResponderScrollToEnd: function (options?: {animated?: boolean, ...}) {
|
||||
// Default to true
|
||||
const animated = (options && options.animated) !== false;
|
||||
|
||||
@@ -530,7 +530,7 @@ const ScrollResponderMixin = {
|
||||
*
|
||||
* @platform ios
|
||||
*/
|
||||
scrollResponderZoomTo: function(
|
||||
scrollResponderZoomTo: function (
|
||||
rect: {|
|
||||
x: number,
|
||||
y: number,
|
||||
@@ -565,7 +565,7 @@ const ScrollResponderMixin = {
|
||||
/**
|
||||
* Displays the scroll indicators momentarily.
|
||||
*/
|
||||
scrollResponderFlashScrollIndicators: function() {
|
||||
scrollResponderFlashScrollIndicators: function () {
|
||||
const that: React.ElementRef<ScrollView> = (this: any);
|
||||
invariant(
|
||||
that.getNativeScrollRef != null,
|
||||
@@ -588,7 +588,7 @@ const ScrollResponderMixin = {
|
||||
* @param {bool} preventNegativeScrolling Whether to allow pulling the content
|
||||
* down to make it meet the keyboard's top. Default is false.
|
||||
*/
|
||||
scrollResponderScrollNativeHandleToKeyboard: function<T>(
|
||||
scrollResponderScrollNativeHandleToKeyboard: function <T>(
|
||||
nodeHandle: number | React.ElementRef<HostComponent<T>>,
|
||||
additionalOffset?: number,
|
||||
preventNegativeScrollOffset?: boolean,
|
||||
@@ -628,7 +628,7 @@ const ScrollResponderMixin = {
|
||||
* @param {number} width Width of the text input.
|
||||
* @param {number} height Height of the text input.
|
||||
*/
|
||||
scrollResponderInputMeasureAndScrollToKeyboard: function(
|
||||
scrollResponderInputMeasureAndScrollToKeyboard: function (
|
||||
left: number,
|
||||
top: number,
|
||||
width: number,
|
||||
@@ -654,7 +654,7 @@ const ScrollResponderMixin = {
|
||||
this.preventNegativeScrollOffset = false;
|
||||
},
|
||||
|
||||
scrollResponderTextInputFocusError: function(msg: string) {
|
||||
scrollResponderTextInputFocusError: function (msg: string) {
|
||||
console.error('Error measuring text field: ', msg);
|
||||
},
|
||||
|
||||
@@ -664,7 +664,7 @@ const ScrollResponderMixin = {
|
||||
*
|
||||
* The `keyboardWillShow` is called before input focus.
|
||||
*/
|
||||
UNSAFE_componentWillMount: function() {
|
||||
UNSAFE_componentWillMount: function () {
|
||||
const {keyboardShouldPersistTaps} = ((this: any).props: ScrollViewProps);
|
||||
if (typeof keyboardShouldPersistTaps === 'boolean') {
|
||||
console.warn(
|
||||
@@ -698,7 +698,7 @@ const ScrollResponderMixin = {
|
||||
);
|
||||
},
|
||||
|
||||
componentWillUnmount: function() {
|
||||
componentWillUnmount: function () {
|
||||
if (this._subscriptionKeyboardWillShow != null) {
|
||||
this._subscriptionKeyboardWillShow.remove();
|
||||
}
|
||||
@@ -741,17 +741,17 @@ const ScrollResponderMixin = {
|
||||
* relevant to you. (For example, only if you receive these callbacks after
|
||||
* you had explicitly focused a node etc).
|
||||
*/
|
||||
scrollResponderKeyboardWillShow: function(e: KeyboardEvent) {
|
||||
scrollResponderKeyboardWillShow: function (e: KeyboardEvent) {
|
||||
this.keyboardWillOpenTo = e;
|
||||
this.props.onKeyboardWillShow && this.props.onKeyboardWillShow(e);
|
||||
},
|
||||
|
||||
scrollResponderKeyboardWillHide: function(e: KeyboardEvent) {
|
||||
scrollResponderKeyboardWillHide: function (e: KeyboardEvent) {
|
||||
this.keyboardWillOpenTo = null;
|
||||
this.props.onKeyboardWillHide && this.props.onKeyboardWillHide(e);
|
||||
},
|
||||
|
||||
scrollResponderKeyboardDidShow: function(e: KeyboardEvent) {
|
||||
scrollResponderKeyboardDidShow: function (e: KeyboardEvent) {
|
||||
// TODO(7693961): The event for DidShow is not available on iOS yet.
|
||||
// Use the one from WillShow and do not assign.
|
||||
if (e) {
|
||||
@@ -760,7 +760,7 @@ const ScrollResponderMixin = {
|
||||
this.props.onKeyboardDidShow && this.props.onKeyboardDidShow(e);
|
||||
},
|
||||
|
||||
scrollResponderKeyboardDidHide: function(e: KeyboardEvent) {
|
||||
scrollResponderKeyboardDidHide: function (e: KeyboardEvent) {
|
||||
this.keyboardWillOpenTo = null;
|
||||
this.props.onKeyboardDidHide && this.props.onKeyboardDidHide(e);
|
||||
},
|
||||
|
||||
@@ -368,7 +368,7 @@ type VRProps = $ReadOnly<{|
|
||||
|
||||
type StickyHeaderComponentType = React.AbstractComponent<
|
||||
ScrollViewStickyHeaderProps,
|
||||
$ReadOnly<{setNextHeaderY: number => void, ...}>,
|
||||
$ReadOnly<{setNextHeaderY: (number) => void, ...}>,
|
||||
>;
|
||||
|
||||
export type Props = $ReadOnly<{|
|
||||
@@ -691,8 +691,8 @@ class ScrollView extends React.Component<Props, State> {
|
||||
* instance.
|
||||
*/
|
||||
Object.keys(ScrollResponder.Mixin)
|
||||
.filter(key => typeof ScrollResponder.Mixin[key] !== 'function')
|
||||
.forEach(key => {
|
||||
.filter((key) => typeof ScrollResponder.Mixin[key] !== 'function')
|
||||
.forEach((key) => {
|
||||
// $FlowFixMe - dynamically adding properties to a class
|
||||
(this: any)[key] = ScrollResponder.Mixin[key];
|
||||
});
|
||||
@@ -966,7 +966,7 @@ class ScrollView extends React.Component<Props, State> {
|
||||
_innerViewRef: ?React.ElementRef<typeof View> = null;
|
||||
_setInnerViewRef = setAndForwardRef({
|
||||
getForwardedRef: () => this.props.innerViewRef,
|
||||
setLocalRef: ref => {
|
||||
setLocalRef: (ref) => {
|
||||
this._innerViewRef = ref;
|
||||
},
|
||||
});
|
||||
@@ -1004,7 +1004,7 @@ class ScrollView extends React.Component<Props, State> {
|
||||
if (__DEV__ && this.props.style !== undefined) {
|
||||
const style = flattenStyle(this.props.style);
|
||||
const childLayoutProps = ['alignItems', 'justifyContent'].filter(
|
||||
prop => style && style[prop] !== undefined,
|
||||
(prop) => style && style[prop] !== undefined,
|
||||
);
|
||||
invariant(
|
||||
childLayoutProps.length === 0,
|
||||
@@ -1037,11 +1037,13 @@ class ScrollView extends React.Component<Props, State> {
|
||||
return (
|
||||
<StickyHeaderComponent
|
||||
key={key}
|
||||
ref={ref => this._setStickyHeaderRef(key, ref)}
|
||||
ref={(ref) => this._setStickyHeaderRef(key, ref)}
|
||||
nextHeaderLayoutY={this._headerLayoutYs.get(
|
||||
this._getKeyForIndex(nextIndex, childArray),
|
||||
)}
|
||||
onLayout={event => this._onStickyHeaderLayout(index, event, key)}
|
||||
onLayout={(event) =>
|
||||
this._onStickyHeaderLayout(index, event, key)
|
||||
}
|
||||
scrollAnimatedValue={this._scrollAnimatedValue}
|
||||
inverted={this.props.invertStickyHeaders}
|
||||
scrollViewHeight={this.state.layoutHeight}>
|
||||
|
||||
@@ -52,7 +52,7 @@ class ScrollViewStickyHeader extends React.Component<Props, State> {
|
||||
this.setState({nextHeaderLayoutY: y});
|
||||
}
|
||||
|
||||
_onLayout = event => {
|
||||
_onLayout = (event) => {
|
||||
this.setState({
|
||||
measured: true,
|
||||
layoutY: event.nativeEvent.layout.y,
|
||||
|
||||
@@ -198,10 +198,7 @@ const Slider = (
|
||||
props: Props,
|
||||
forwardedRef?: ?React.Ref<typeof SliderNativeComponent>,
|
||||
) => {
|
||||
const style = StyleSheet.compose(
|
||||
styles.slider,
|
||||
props.style,
|
||||
);
|
||||
const style = StyleSheet.compose(styles.slider, props.style);
|
||||
|
||||
const {
|
||||
disabled = false,
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
import NativeSoundManager from './NativeSoundManager';
|
||||
|
||||
const SoundManager = {
|
||||
playTouchSound: function(): void {
|
||||
playTouchSound: function (): void {
|
||||
if (NativeSoundManager) {
|
||||
NativeSoundManager.playTouchSound();
|
||||
}
|
||||
|
||||
@@ -467,9 +467,7 @@ class StatusBar extends React.Component<Props> {
|
||||
const processedColor = processColor(mergedProps.backgroundColor.value);
|
||||
if (processedColor == null) {
|
||||
console.warn(
|
||||
`\`StatusBar._updatePropsStack\`: Color ${
|
||||
mergedProps.backgroundColor.value
|
||||
} parsed to null or undefined`,
|
||||
`\`StatusBar._updatePropsStack\`: Color ${mergedProps.backgroundColor.value} parsed to null or undefined`,
|
||||
);
|
||||
} else {
|
||||
invariant(
|
||||
|
||||
@@ -945,7 +945,7 @@ function InternalTextInput(props: Props): React.Node {
|
||||
|
||||
const _setNativeRef = setAndForwardRef({
|
||||
getForwardedRef: () => props.forwardedRef,
|
||||
setLocalRef: ref => {
|
||||
setLocalRef: (ref) => {
|
||||
inputRef.current = ref;
|
||||
|
||||
/*
|
||||
|
||||
@@ -41,11 +41,11 @@ describe('TextInput tests', () => {
|
||||
<TextInput
|
||||
ref={inputRef}
|
||||
value={state.text}
|
||||
onChangeText={text => {
|
||||
onChangeText={(text) => {
|
||||
onChangeTextListener(text);
|
||||
setState({text});
|
||||
}}
|
||||
onChange={event => {
|
||||
onChange={(event) => {
|
||||
onChangeListener(event);
|
||||
}}
|
||||
/>
|
||||
@@ -86,7 +86,7 @@ describe('TextInput tests', () => {
|
||||
ReactTestRenderer.create(<TextInput ref={textInputRef} value="value1" />);
|
||||
|
||||
expect(textInputRef.current.isFocused()).toBe(false);
|
||||
ReactNative.findNodeHandle = jest.fn().mockImplementation(ref => {
|
||||
ReactNative.findNodeHandle = jest.fn().mockImplementation((ref) => {
|
||||
if (ref == null) {
|
||||
return null;
|
||||
}
|
||||
@@ -125,7 +125,7 @@ describe('TextInput tests', () => {
|
||||
<TextInput ref={textInputRe2} value="value2" />
|
||||
</>,
|
||||
);
|
||||
ReactNative.findNodeHandle = jest.fn().mockImplementation(ref => {
|
||||
ReactNative.findNodeHandle = jest.fn().mockImplementation((ref) => {
|
||||
if (
|
||||
ref === textInputRe1.current ||
|
||||
ref === textInputRe1.current.getNativeRef()
|
||||
|
||||
@@ -41,11 +41,11 @@ const ToastAndroid = {
|
||||
BOTTOM: (NativeToastAndroid.getConstants().BOTTOM: number),
|
||||
CENTER: (NativeToastAndroid.getConstants().CENTER: number),
|
||||
|
||||
show: function(message: string, duration: number): void {
|
||||
show: function (message: string, duration: number): void {
|
||||
NativeToastAndroid.show(message, duration);
|
||||
},
|
||||
|
||||
showWithGravity: function(
|
||||
showWithGravity: function (
|
||||
message: string,
|
||||
duration: number,
|
||||
gravity: number,
|
||||
@@ -53,7 +53,7 @@ const ToastAndroid = {
|
||||
NativeToastAndroid.showWithGravity(message, duration, gravity);
|
||||
},
|
||||
|
||||
showWithGravityAndOffset: function(
|
||||
showWithGravityAndOffset: function (
|
||||
message: string,
|
||||
duration: number,
|
||||
gravity: number,
|
||||
|
||||
@@ -13,11 +13,11 @@
|
||||
const warning = require('fbjs/lib/warning');
|
||||
|
||||
const ToastAndroid = {
|
||||
show: function(message: string, duration: number): void {
|
||||
show: function (message: string, duration: number): void {
|
||||
warning(false, 'ToastAndroid is not supported on this platform.');
|
||||
},
|
||||
|
||||
showWithGravity: function(
|
||||
showWithGravity: function (
|
||||
message: string,
|
||||
duration: number,
|
||||
gravity: number,
|
||||
@@ -25,7 +25,7 @@ const ToastAndroid = {
|
||||
warning(false, 'ToastAndroid is not supported on this platform.');
|
||||
},
|
||||
|
||||
showWithGravityAndOffset: function(
|
||||
showWithGravityAndOffset: function (
|
||||
message: string,
|
||||
duration: number,
|
||||
gravity: number,
|
||||
|
||||
@@ -25,7 +25,7 @@ function BoundingDimensions(width, height) {
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
BoundingDimensions.prototype.destructor = function() {
|
||||
BoundingDimensions.prototype.destructor = function () {
|
||||
this.width = null;
|
||||
this.height = null;
|
||||
};
|
||||
@@ -34,7 +34,7 @@ BoundingDimensions.prototype.destructor = function() {
|
||||
* @param {HTMLElement} element Element to return `BoundingDimensions` for.
|
||||
* @return {BoundingDimensions} Bounding dimensions of `element`.
|
||||
*/
|
||||
BoundingDimensions.getPooledFromElement = function(element) {
|
||||
BoundingDimensions.getPooledFromElement = function (element) {
|
||||
return BoundingDimensions.getPooled(
|
||||
element.offsetWidth,
|
||||
element.offsetHeight,
|
||||
|
||||
@@ -19,7 +19,7 @@ const invariant = require('invariant');
|
||||
* the Class itself, not an instance. If any others are needed, simply add them
|
||||
* here, or in their own files.
|
||||
*/
|
||||
const oneArgumentPooler = function(copyFieldsFrom) {
|
||||
const oneArgumentPooler = function (copyFieldsFrom) {
|
||||
const Klass = this;
|
||||
if (Klass.instancePool.length) {
|
||||
const instance = Klass.instancePool.pop();
|
||||
@@ -30,7 +30,7 @@ const oneArgumentPooler = function(copyFieldsFrom) {
|
||||
}
|
||||
};
|
||||
|
||||
const twoArgumentPooler = function(a1, a2) {
|
||||
const twoArgumentPooler = function (a1, a2) {
|
||||
const Klass = this;
|
||||
if (Klass.instancePool.length) {
|
||||
const instance = Klass.instancePool.pop();
|
||||
@@ -41,7 +41,7 @@ const twoArgumentPooler = function(a1, a2) {
|
||||
}
|
||||
};
|
||||
|
||||
const threeArgumentPooler = function(a1, a2, a3) {
|
||||
const threeArgumentPooler = function (a1, a2, a3) {
|
||||
const Klass = this;
|
||||
if (Klass.instancePool.length) {
|
||||
const instance = Klass.instancePool.pop();
|
||||
@@ -52,7 +52,7 @@ const threeArgumentPooler = function(a1, a2, a3) {
|
||||
}
|
||||
};
|
||||
|
||||
const fourArgumentPooler = function(a1, a2, a3, a4) {
|
||||
const fourArgumentPooler = function (a1, a2, a3, a4) {
|
||||
const Klass = this;
|
||||
if (Klass.instancePool.length) {
|
||||
const instance = Klass.instancePool.pop();
|
||||
@@ -63,7 +63,7 @@ const fourArgumentPooler = function(a1, a2, a3, a4) {
|
||||
}
|
||||
};
|
||||
|
||||
const standardReleaser = function(instance) {
|
||||
const standardReleaser = function (instance) {
|
||||
const Klass = this;
|
||||
invariant(
|
||||
instance instanceof Klass,
|
||||
@@ -89,7 +89,7 @@ type Pooler = any;
|
||||
* @param {Function} CopyConstructor Constructor that can be used to reset.
|
||||
* @param {Function} pooler Customizable pooler.
|
||||
*/
|
||||
const addPoolingTo = function<T>(
|
||||
const addPoolingTo = function <T>(
|
||||
CopyConstructor: Class<T>,
|
||||
pooler: Pooler,
|
||||
): Class<T> & {
|
||||
|
||||
@@ -26,7 +26,7 @@ function Position(left, top) {
|
||||
this.top = top;
|
||||
}
|
||||
|
||||
Position.prototype.destructor = function() {
|
||||
Position.prototype.destructor = function () {
|
||||
this.left = null;
|
||||
this.top = null;
|
||||
};
|
||||
|
||||
@@ -27,7 +27,7 @@ const normalizeColor = require('../../StyleSheet/normalizeColor');
|
||||
import type {EdgeInsetsProp} from '../../StyleSheet/EdgeInsetsPropType';
|
||||
import type {PressEvent} from '../../Types/CoreEventTypes';
|
||||
|
||||
const extractSingleTouch = nativeEvent => {
|
||||
const extractSingleTouch = (nativeEvent) => {
|
||||
const touches = nativeEvent.touches;
|
||||
const changedTouches = nativeEvent.changedTouches;
|
||||
const hasTouches = touches && touches.length > 0;
|
||||
@@ -367,13 +367,13 @@ const LONG_PRESS_ALLOWED_MOVEMENT = 10;
|
||||
* @lends Touchable.prototype
|
||||
*/
|
||||
const TouchableMixin = {
|
||||
componentDidMount: function() {
|
||||
componentDidMount: function () {
|
||||
if (!Platform.isTV) {
|
||||
return;
|
||||
}
|
||||
|
||||
this._tvEventHandler = new TVEventHandler();
|
||||
this._tvEventHandler.enable(this, function(cmp, evt) {
|
||||
this._tvEventHandler.enable(this, function (cmp, evt) {
|
||||
const myTag = ReactNative.findNodeHandle(cmp);
|
||||
evt.dispatchConfig = {};
|
||||
if (myTag === evt.tag) {
|
||||
@@ -393,7 +393,7 @@ const TouchableMixin = {
|
||||
/**
|
||||
* Clear all timeouts on unmount
|
||||
*/
|
||||
componentWillUnmount: function() {
|
||||
componentWillUnmount: function () {
|
||||
if (this._tvEventHandler) {
|
||||
this._tvEventHandler.disable();
|
||||
delete this._tvEventHandler;
|
||||
@@ -410,7 +410,7 @@ const TouchableMixin = {
|
||||
* @return {object} State object to be placed inside of
|
||||
* `this.state.touchable`.
|
||||
*/
|
||||
touchableGetInitialState: function(): $TEMPORARY$object<{|
|
||||
touchableGetInitialState: function (): $TEMPORARY$object<{|
|
||||
touchable: $TEMPORARY$object<{|responderID: null, touchState: void|}>,
|
||||
|}> {
|
||||
return {
|
||||
@@ -422,21 +422,21 @@ const TouchableMixin = {
|
||||
/**
|
||||
* Must return true if embedded in a native platform scroll view.
|
||||
*/
|
||||
touchableHandleResponderTerminationRequest: function(): any {
|
||||
touchableHandleResponderTerminationRequest: function (): any {
|
||||
return !this.props.rejectResponderTermination;
|
||||
},
|
||||
|
||||
/**
|
||||
* Must return true to start the process of `Touchable`.
|
||||
*/
|
||||
touchableHandleStartShouldSetResponder: function(): any {
|
||||
touchableHandleStartShouldSetResponder: function (): any {
|
||||
return !this.props.disabled;
|
||||
},
|
||||
|
||||
/**
|
||||
* Return true to cancel press on long press.
|
||||
*/
|
||||
touchableLongPressCancelsPress: function(): boolean {
|
||||
touchableLongPressCancelsPress: function (): boolean {
|
||||
return true;
|
||||
},
|
||||
|
||||
@@ -445,7 +445,7 @@ const TouchableMixin = {
|
||||
* @param {SyntheticEvent} e Synthetic event from event system.
|
||||
*
|
||||
*/
|
||||
touchableHandleResponderGrant: function(e: PressEvent) {
|
||||
touchableHandleResponderGrant: function (e: PressEvent) {
|
||||
const dispatchID = e.currentTarget;
|
||||
// Since e is used in a callback invoked on another event loop
|
||||
// (as in setTimeout etc), we need to call e.persist() on the
|
||||
@@ -486,7 +486,7 @@ const TouchableMixin = {
|
||||
/**
|
||||
* Place as callback for a DOM element's `onResponderRelease` event.
|
||||
*/
|
||||
touchableHandleResponderRelease: function(e: PressEvent) {
|
||||
touchableHandleResponderRelease: function (e: PressEvent) {
|
||||
this.pressInLocation = null;
|
||||
this._receiveSignal(Signals.RESPONDER_RELEASE, e);
|
||||
},
|
||||
@@ -494,7 +494,7 @@ const TouchableMixin = {
|
||||
/**
|
||||
* Place as callback for a DOM element's `onResponderTerminate` event.
|
||||
*/
|
||||
touchableHandleResponderTerminate: function(e: PressEvent) {
|
||||
touchableHandleResponderTerminate: function (e: PressEvent) {
|
||||
this.pressInLocation = null;
|
||||
this._receiveSignal(Signals.RESPONDER_TERMINATED, e);
|
||||
},
|
||||
@@ -502,7 +502,7 @@ const TouchableMixin = {
|
||||
/**
|
||||
* Place as callback for a DOM element's `onResponderMove` event.
|
||||
*/
|
||||
touchableHandleResponderMove: function(e: PressEvent) {
|
||||
touchableHandleResponderMove: function (e: PressEvent) {
|
||||
// Measurement may not have returned yet.
|
||||
if (!this.state.touchable.positionOnActivate) {
|
||||
return;
|
||||
@@ -587,7 +587,7 @@ const TouchableMixin = {
|
||||
* element that was blurred just prior to this. This can be overridden when
|
||||
* using `Touchable.Mixin.withoutDefaultFocusAndBlur`.
|
||||
*/
|
||||
touchableHandleFocus: function(e: Event) {
|
||||
touchableHandleFocus: function (e: Event) {
|
||||
this.props.onFocus && this.props.onFocus(e);
|
||||
},
|
||||
|
||||
@@ -599,7 +599,7 @@ const TouchableMixin = {
|
||||
* This can be overridden when using
|
||||
* `Touchable.Mixin.withoutDefaultFocusAndBlur`.
|
||||
*/
|
||||
touchableHandleBlur: function(e: Event) {
|
||||
touchableHandleBlur: function (e: Event) {
|
||||
this.props.onBlur && this.props.onBlur(e);
|
||||
},
|
||||
|
||||
@@ -679,7 +679,7 @@ const TouchableMixin = {
|
||||
* @sideeffects
|
||||
* @private
|
||||
*/
|
||||
_remeasureMetricsOnActivation: function() {
|
||||
_remeasureMetricsOnActivation: function () {
|
||||
const responderID = this.state.touchable.responderID;
|
||||
if (responderID == null) {
|
||||
return;
|
||||
@@ -692,7 +692,7 @@ const TouchableMixin = {
|
||||
}
|
||||
},
|
||||
|
||||
_handleQueryLayout: function(
|
||||
_handleQueryLayout: function (
|
||||
l: number,
|
||||
t: number,
|
||||
w: number,
|
||||
@@ -718,12 +718,12 @@ const TouchableMixin = {
|
||||
);
|
||||
},
|
||||
|
||||
_handleDelay: function(e: PressEvent) {
|
||||
_handleDelay: function (e: PressEvent) {
|
||||
this.touchableDelayTimeout = null;
|
||||
this._receiveSignal(Signals.DELAY, e);
|
||||
},
|
||||
|
||||
_handleLongDelay: function(e: PressEvent) {
|
||||
_handleLongDelay: function (e: PressEvent) {
|
||||
this.longPressDelayTimeout = null;
|
||||
const curState = this.state.touchable.touchState;
|
||||
if (
|
||||
@@ -742,7 +742,7 @@ const TouchableMixin = {
|
||||
* @throws Error if invalid state transition or unrecognized signal.
|
||||
* @sideeffects
|
||||
*/
|
||||
_receiveSignal: function(signal: Signal, e: PressEvent) {
|
||||
_receiveSignal: function (signal: Signal, e: PressEvent) {
|
||||
const responderID = this.state.touchable.responderID;
|
||||
const curState = this.state.touchable.touchState;
|
||||
const nextState = Transitions[curState] && Transitions[curState][signal];
|
||||
@@ -781,19 +781,19 @@ const TouchableMixin = {
|
||||
}
|
||||
},
|
||||
|
||||
_cancelLongPressDelayTimeout: function() {
|
||||
_cancelLongPressDelayTimeout: function () {
|
||||
this.longPressDelayTimeout && clearTimeout(this.longPressDelayTimeout);
|
||||
this.longPressDelayTimeout = null;
|
||||
},
|
||||
|
||||
_isHighlight: function(state: State): boolean {
|
||||
_isHighlight: function (state: State): boolean {
|
||||
return (
|
||||
state === States.RESPONDER_ACTIVE_PRESS_IN ||
|
||||
state === States.RESPONDER_ACTIVE_LONG_PRESS_IN
|
||||
);
|
||||
},
|
||||
|
||||
_savePressInLocation: function(e: PressEvent) {
|
||||
_savePressInLocation: function (e: PressEvent) {
|
||||
const touch = extractSingleTouch(e.nativeEvent);
|
||||
const pageX = touch && touch.pageX;
|
||||
const pageY = touch && touch.pageY;
|
||||
@@ -802,7 +802,7 @@ const TouchableMixin = {
|
||||
this.pressInLocation = {pageX, pageY, locationX, locationY};
|
||||
},
|
||||
|
||||
_getDistanceBetweenPoints: function(
|
||||
_getDistanceBetweenPoints: function (
|
||||
aX: number,
|
||||
aY: number,
|
||||
bX: number,
|
||||
@@ -824,7 +824,7 @@ const TouchableMixin = {
|
||||
* @param {Event} e Native event.
|
||||
* @sideeffects
|
||||
*/
|
||||
_performSideEffectsForTransition: function(
|
||||
_performSideEffectsForTransition: function (
|
||||
curState: State,
|
||||
nextState: State,
|
||||
signal: Signal,
|
||||
@@ -885,12 +885,12 @@ const TouchableMixin = {
|
||||
this.touchableDelayTimeout = null;
|
||||
},
|
||||
|
||||
_startHighlight: function(e: PressEvent) {
|
||||
_startHighlight: function (e: PressEvent) {
|
||||
this._savePressInLocation(e);
|
||||
this.touchableHandleActivePressIn && this.touchableHandleActivePressIn(e);
|
||||
},
|
||||
|
||||
_endHighlight: function(e: PressEvent) {
|
||||
_endHighlight: function (e: PressEvent) {
|
||||
if (this.touchableHandleActivePressOut) {
|
||||
if (
|
||||
this.touchableGetPressOutDelayMS &&
|
||||
|
||||
@@ -55,7 +55,7 @@ class TouchableBounce extends React.Component<Props, State> {
|
||||
delayPressOut: this.props.delayPressOut,
|
||||
pressRectOffset: this.props.pressRetentionOffset,
|
||||
android_disableSound: this.props.touchSoundDisabled,
|
||||
onBlur: event => {
|
||||
onBlur: (event) => {
|
||||
if (Platform.isTV) {
|
||||
this._bounceTo(1, 0.4, 0);
|
||||
}
|
||||
@@ -63,7 +63,7 @@ class TouchableBounce extends React.Component<Props, State> {
|
||||
this.props.onBlur(event);
|
||||
}
|
||||
},
|
||||
onFocus: event => {
|
||||
onFocus: (event) => {
|
||||
if (Platform.isTV) {
|
||||
this._bounceTo(0.93, 0.1, 0);
|
||||
}
|
||||
@@ -71,12 +71,12 @@ class TouchableBounce extends React.Component<Props, State> {
|
||||
this.props.onFocus(event);
|
||||
}
|
||||
},
|
||||
onLongPress: event => {
|
||||
onLongPress: (event) => {
|
||||
if (this.props.onLongPress != null) {
|
||||
this.props.onLongPress(event);
|
||||
}
|
||||
},
|
||||
onPress: event => {
|
||||
onPress: (event) => {
|
||||
const {onPressAnimationComplete, onPressWithCompletion} = this.props;
|
||||
const releaseBounciness = this.props.releaseBounciness ?? 10;
|
||||
const releaseVelocity = this.props.releaseVelocity ?? 10;
|
||||
@@ -104,13 +104,13 @@ class TouchableBounce extends React.Component<Props, State> {
|
||||
this.props.onPress(event);
|
||||
}
|
||||
},
|
||||
onPressIn: event => {
|
||||
onPressIn: (event) => {
|
||||
this._bounceTo(0.93, 0.1, 0);
|
||||
if (this.props.onPressIn != null) {
|
||||
this.props.onPressIn(event);
|
||||
}
|
||||
},
|
||||
onPressOut: event => {
|
||||
onPressOut: (event) => {
|
||||
this._bounceTo(1, 0.4, 0);
|
||||
if (this.props.onPressOut != null) {
|
||||
this.props.onPressOut(event);
|
||||
@@ -179,17 +179,17 @@ class TouchableBounce extends React.Component<Props, State> {
|
||||
if (Platform.isTV) {
|
||||
this._tvTouchable = new TVTouchable(this, {
|
||||
getDisabled: () => this.props.disabled === true,
|
||||
onBlur: event => {
|
||||
onBlur: (event) => {
|
||||
if (this.props.onBlur != null) {
|
||||
this.props.onBlur(event);
|
||||
}
|
||||
},
|
||||
onFocus: event => {
|
||||
onFocus: (event) => {
|
||||
if (this.props.onFocus != null) {
|
||||
this.props.onFocus(event);
|
||||
}
|
||||
},
|
||||
onPress: event => {
|
||||
onPress: (event) => {
|
||||
if (this.props.onPress != null) {
|
||||
this.props.onPress(event);
|
||||
}
|
||||
|
||||
@@ -176,7 +176,7 @@ class TouchableHighlight extends React.Component<Props, State> {
|
||||
delayPressOut: this.props.delayPressOut,
|
||||
pressRectOffset: this.props.pressRetentionOffset,
|
||||
android_disableSound: this.props.touchSoundDisabled,
|
||||
onBlur: event => {
|
||||
onBlur: (event) => {
|
||||
if (Platform.isTV) {
|
||||
this._hideUnderlay();
|
||||
}
|
||||
@@ -184,7 +184,7 @@ class TouchableHighlight extends React.Component<Props, State> {
|
||||
this.props.onBlur(event);
|
||||
}
|
||||
},
|
||||
onFocus: event => {
|
||||
onFocus: (event) => {
|
||||
if (Platform.isTV) {
|
||||
this._showUnderlay();
|
||||
}
|
||||
@@ -192,12 +192,12 @@ class TouchableHighlight extends React.Component<Props, State> {
|
||||
this.props.onFocus(event);
|
||||
}
|
||||
},
|
||||
onLongPress: event => {
|
||||
onLongPress: (event) => {
|
||||
if (this.props.onLongPress != null) {
|
||||
this.props.onLongPress(event);
|
||||
}
|
||||
},
|
||||
onPress: event => {
|
||||
onPress: (event) => {
|
||||
if (this._hideTimeout != null) {
|
||||
clearTimeout(this._hideTimeout);
|
||||
}
|
||||
@@ -211,7 +211,7 @@ class TouchableHighlight extends React.Component<Props, State> {
|
||||
this.props.onPress(event);
|
||||
}
|
||||
},
|
||||
onPressIn: event => {
|
||||
onPressIn: (event) => {
|
||||
if (this._hideTimeout != null) {
|
||||
clearTimeout(this._hideTimeout);
|
||||
this._hideTimeout = null;
|
||||
@@ -221,7 +221,7 @@ class TouchableHighlight extends React.Component<Props, State> {
|
||||
this.props.onPressIn(event);
|
||||
}
|
||||
},
|
||||
onPressOut: event => {
|
||||
onPressOut: (event) => {
|
||||
if (this._hideTimeout == null) {
|
||||
this._hideUnderlay();
|
||||
}
|
||||
@@ -341,17 +341,17 @@ class TouchableHighlight extends React.Component<Props, State> {
|
||||
if (Platform.isTV) {
|
||||
this._tvTouchable = new TVTouchable(this, {
|
||||
getDisabled: () => this.props.disabled === true,
|
||||
onBlur: event => {
|
||||
onBlur: (event) => {
|
||||
if (this.props.onBlur != null) {
|
||||
this.props.onBlur(event);
|
||||
}
|
||||
},
|
||||
onFocus: event => {
|
||||
onFocus: (event) => {
|
||||
if (this.props.onFocus != null) {
|
||||
this.props.onFocus(event);
|
||||
}
|
||||
},
|
||||
onPress: event => {
|
||||
onPress: (event) => {
|
||||
if (this.props.onPress != null) {
|
||||
this.props.onPress(event);
|
||||
}
|
||||
|
||||
@@ -182,7 +182,7 @@ class TouchableNativeFeedback extends React.Component<Props, State> {
|
||||
android_disableSound: this.props.touchSoundDisabled,
|
||||
onLongPress: this.props.onLongPress,
|
||||
onPress: this.props.onPress,
|
||||
onPressIn: event => {
|
||||
onPressIn: (event) => {
|
||||
if (Platform.OS === 'android') {
|
||||
this._dispatchPressedStateChange(true);
|
||||
this._dispatchHotspotUpdate(event);
|
||||
@@ -191,12 +191,12 @@ class TouchableNativeFeedback extends React.Component<Props, State> {
|
||||
this.props.onPressIn(event);
|
||||
}
|
||||
},
|
||||
onPressMove: event => {
|
||||
onPressMove: (event) => {
|
||||
if (Platform.OS === 'android') {
|
||||
this._dispatchHotspotUpdate(event);
|
||||
}
|
||||
},
|
||||
onPressOut: event => {
|
||||
onPressOut: (event) => {
|
||||
if (Platform.OS === 'android') {
|
||||
this._dispatchPressedStateChange(false);
|
||||
}
|
||||
@@ -303,17 +303,17 @@ class TouchableNativeFeedback extends React.Component<Props, State> {
|
||||
if (Platform.isTV) {
|
||||
this._tvTouchable = new TVTouchable(this, {
|
||||
getDisabled: () => this.props.disabled === true,
|
||||
onBlur: event => {
|
||||
onBlur: (event) => {
|
||||
if (this.props.onBlur != null) {
|
||||
this.props.onBlur(event);
|
||||
}
|
||||
},
|
||||
onFocus: event => {
|
||||
onFocus: (event) => {
|
||||
if (this.props.onFocus != null) {
|
||||
this.props.onFocus(event);
|
||||
}
|
||||
},
|
||||
onPress: event => {
|
||||
onPress: (event) => {
|
||||
if (this.props.onPress != null) {
|
||||
this.props.onPress(event);
|
||||
}
|
||||
|
||||
@@ -148,7 +148,7 @@ class TouchableOpacity extends React.Component<Props, State> {
|
||||
delayPressIn: this.props.delayPressIn,
|
||||
delayPressOut: this.props.delayPressOut,
|
||||
pressRectOffset: this.props.pressRetentionOffset,
|
||||
onBlur: event => {
|
||||
onBlur: (event) => {
|
||||
if (Platform.isTV) {
|
||||
this._opacityInactive(250);
|
||||
}
|
||||
@@ -156,7 +156,7 @@ class TouchableOpacity extends React.Component<Props, State> {
|
||||
this.props.onBlur(event);
|
||||
}
|
||||
},
|
||||
onFocus: event => {
|
||||
onFocus: (event) => {
|
||||
if (Platform.isTV) {
|
||||
this._opacityActive(150);
|
||||
}
|
||||
@@ -166,7 +166,7 @@ class TouchableOpacity extends React.Component<Props, State> {
|
||||
},
|
||||
onLongPress: this.props.onLongPress,
|
||||
onPress: this.props.onPress,
|
||||
onPressIn: event => {
|
||||
onPressIn: (event) => {
|
||||
this._opacityActive(
|
||||
event.dispatchConfig.registrationName === 'onResponderGrant'
|
||||
? 0
|
||||
@@ -176,7 +176,7 @@ class TouchableOpacity extends React.Component<Props, State> {
|
||||
this.props.onPressIn(event);
|
||||
}
|
||||
},
|
||||
onPressOut: event => {
|
||||
onPressOut: (event) => {
|
||||
this._opacityInactive(250);
|
||||
if (this.props.onPressOut != null) {
|
||||
this.props.onPressOut(event);
|
||||
@@ -261,17 +261,17 @@ class TouchableOpacity extends React.Component<Props, State> {
|
||||
if (Platform.isTV) {
|
||||
this._tvTouchable = new TVTouchable(this, {
|
||||
getDisabled: () => this.props.disabled === true,
|
||||
onBlur: event => {
|
||||
onBlur: (event) => {
|
||||
if (this.props.onBlur != null) {
|
||||
this.props.onBlur(event);
|
||||
}
|
||||
},
|
||||
onFocus: event => {
|
||||
onFocus: (event) => {
|
||||
if (this.props.onFocus != null) {
|
||||
this.props.onFocus(event);
|
||||
}
|
||||
},
|
||||
onPress: event => {
|
||||
onPress: (event) => {
|
||||
if (this.props.onPress != null) {
|
||||
this.props.onPress(event);
|
||||
}
|
||||
|
||||
@@ -138,17 +138,17 @@ class TouchableWithoutFeedback extends React.Component<Props, State> {
|
||||
if (Platform.isTV) {
|
||||
this._tvTouchable = new TVTouchable(this, {
|
||||
getDisabled: () => this.props.disabled === true,
|
||||
onBlur: event => {
|
||||
onBlur: (event) => {
|
||||
if (this.props.onBlur != null) {
|
||||
this.props.onBlur(event);
|
||||
}
|
||||
},
|
||||
onFocus: event => {
|
||||
onFocus: (event) => {
|
||||
if (this.props.onFocus != null) {
|
||||
this.props.onFocus(event);
|
||||
}
|
||||
},
|
||||
onPress: event => {
|
||||
onPress: (event) => {
|
||||
if (this.props.onPress != null) {
|
||||
this.props.onPress(event);
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
|
||||
const invariant = require('invariant');
|
||||
|
||||
const ensurePositiveDelayProps = function(props: any) {
|
||||
const ensurePositiveDelayProps = function (props: any) {
|
||||
invariant(
|
||||
!(
|
||||
props.delayPressIn < 0 ||
|
||||
|
||||
@@ -16,8 +16,8 @@ function getFakeError() {
|
||||
return new Error('Happy Cat');
|
||||
}
|
||||
|
||||
describe('parseErrorStack', function() {
|
||||
it('parses error stack', function() {
|
||||
describe('parseErrorStack', function () {
|
||||
it('parses error stack', function () {
|
||||
const stack = parseErrorStack(getFakeError());
|
||||
expect(stack.length).toBeGreaterThan(0);
|
||||
|
||||
@@ -26,7 +26,7 @@ describe('parseErrorStack', function() {
|
||||
expect(firstFrame.file).toMatch(/parseErrorStack-test\.js$/);
|
||||
});
|
||||
|
||||
it('does not support framesToPop', function() {
|
||||
it('does not support framesToPop', function () {
|
||||
function getWrappedError() {
|
||||
const error = getFakeError();
|
||||
error.framesToPop = 1;
|
||||
@@ -37,7 +37,7 @@ describe('parseErrorStack', function() {
|
||||
expect(stack[0].methodName).toEqual('getFakeError');
|
||||
});
|
||||
|
||||
it('ignores bad inputs', function() {
|
||||
it('ignores bad inputs', function () {
|
||||
expect(parseErrorStack({})).toEqual([]);
|
||||
expect(parseErrorStack(null)).toEqual([]);
|
||||
});
|
||||
|
||||
@@ -57,7 +57,7 @@ function parseErrorStack(e: ExtendedError): Array<StackFrame> {
|
||||
? e.stack
|
||||
: global.HermesInternal
|
||||
? convertHermesStack(parseHermesStack(e.stack))
|
||||
: stacktraceParser.parse(e.stack).map(frame => ({
|
||||
: stacktraceParser.parse(e.stack).map((frame) => ({
|
||||
...frame,
|
||||
column: frame.column != null ? frame.column - 1 : null,
|
||||
}));
|
||||
|
||||
@@ -18,7 +18,7 @@ class SyntheticError extends Error {
|
||||
name: string = '';
|
||||
}
|
||||
|
||||
type ExceptionDecorator = ExceptionData => ExceptionData;
|
||||
type ExceptionDecorator = (ExceptionData) => ExceptionData;
|
||||
|
||||
let userExceptionDecorator: ?ExceptionDecorator;
|
||||
let inUserExceptionDecorator = false;
|
||||
@@ -130,7 +130,7 @@ function reportException(
|
||||
throw new Error('The stack is null');
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
.catch((error) => {
|
||||
console.log('Unable to symbolicate stack trace: ' + error.message);
|
||||
});
|
||||
}
|
||||
@@ -222,7 +222,7 @@ function reactConsoleErrorHandler() {
|
||||
} else {
|
||||
const stringifySafe = require('../Utilities/stringifySafe').default;
|
||||
const str = Array.prototype.map
|
||||
.call(arguments, value =>
|
||||
.call(arguments, (value) =>
|
||||
typeof value === 'string' ? value : stringifySafe(value),
|
||||
)
|
||||
.join(' ');
|
||||
|
||||
@@ -132,7 +132,7 @@ function _callTimer(timerID: number, frameTime: number, didTimeout: ?boolean) {
|
||||
callback(performanceNow());
|
||||
} else if (type === 'requestIdleCallback') {
|
||||
callback({
|
||||
timeRemaining: function() {
|
||||
timeRemaining: function () {
|
||||
// TODO: Optimisation: allow running for longer than one frame if
|
||||
// there are no pending JS calls on the bridge from native. This
|
||||
// would require a way to check the bridge queue synchronously.
|
||||
@@ -221,7 +221,11 @@ const JSTimers = {
|
||||
* @param {function} func Callback to be invoked after `duration` ms.
|
||||
* @param {number} duration Number of milliseconds.
|
||||
*/
|
||||
setTimeout: function(func: Function, duration: number, ...args: any): number {
|
||||
setTimeout: function (
|
||||
func: Function,
|
||||
duration: number,
|
||||
...args: any
|
||||
): number {
|
||||
if (__DEV__ && IS_ANDROID && duration > MAX_TIMER_DURATION_MS) {
|
||||
console.warn(
|
||||
ANDROID_LONG_TIMER_MESSAGE +
|
||||
@@ -243,7 +247,7 @@ const JSTimers = {
|
||||
* @param {function} func Callback to be invoked every `duration` ms.
|
||||
* @param {number} duration Number of milliseconds.
|
||||
*/
|
||||
setInterval: function(
|
||||
setInterval: function (
|
||||
func: Function,
|
||||
duration: number,
|
||||
...args: any
|
||||
@@ -269,7 +273,7 @@ const JSTimers = {
|
||||
* @param {function} func Callback to be invoked before the end of the
|
||||
* current JavaScript execution loop.
|
||||
*/
|
||||
setImmediate: function(func: Function, ...args: any) {
|
||||
setImmediate: function (func: Function, ...args: any) {
|
||||
const id = _allocateCallback(
|
||||
() => func.apply(undefined, args),
|
||||
'setImmediate',
|
||||
@@ -281,7 +285,7 @@ const JSTimers = {
|
||||
/**
|
||||
* @param {function} func Callback to be invoked every frame.
|
||||
*/
|
||||
requestAnimationFrame: function(func: Function) {
|
||||
requestAnimationFrame: function (func: Function) {
|
||||
const id = _allocateCallback(func, 'requestAnimationFrame');
|
||||
createTimer(id, 1, Date.now(), /* recurring */ false);
|
||||
return id;
|
||||
@@ -292,7 +296,7 @@ const JSTimers = {
|
||||
* with time remaining in frame.
|
||||
* @param {?object} options
|
||||
*/
|
||||
requestIdleCallback: function(func: Function, options: ?Object) {
|
||||
requestIdleCallback: function (func: Function, options: ?Object) {
|
||||
if (requestIdleCallbacks.length === 0) {
|
||||
setSendIdleEvents(true);
|
||||
}
|
||||
@@ -300,7 +304,7 @@ const JSTimers = {
|
||||
const timeout = options && options.timeout;
|
||||
const id = _allocateCallback(
|
||||
timeout != null
|
||||
? deadline => {
|
||||
? (deadline) => {
|
||||
const timeoutId = requestIdleCallbackTimeouts[id];
|
||||
if (timeoutId) {
|
||||
JSTimers.clearTimeout(timeoutId);
|
||||
@@ -330,7 +334,7 @@ const JSTimers = {
|
||||
return id;
|
||||
},
|
||||
|
||||
cancelIdleCallback: function(timerID: number) {
|
||||
cancelIdleCallback: function (timerID: number) {
|
||||
_freeCallback(timerID);
|
||||
const index = requestIdleCallbacks.indexOf(timerID);
|
||||
if (index !== -1) {
|
||||
@@ -348,15 +352,15 @@ const JSTimers = {
|
||||
}
|
||||
},
|
||||
|
||||
clearTimeout: function(timerID: number) {
|
||||
clearTimeout: function (timerID: number) {
|
||||
_freeCallback(timerID);
|
||||
},
|
||||
|
||||
clearInterval: function(timerID: number) {
|
||||
clearInterval: function (timerID: number) {
|
||||
_freeCallback(timerID);
|
||||
},
|
||||
|
||||
clearImmediate: function(timerID: number) {
|
||||
clearImmediate: function (timerID: number) {
|
||||
_freeCallback(timerID);
|
||||
const index = immediates.indexOf(timerID);
|
||||
if (index !== -1) {
|
||||
@@ -364,7 +368,7 @@ const JSTimers = {
|
||||
}
|
||||
},
|
||||
|
||||
cancelAnimationFrame: function(timerID: number) {
|
||||
cancelAnimationFrame: function (timerID: number) {
|
||||
_freeCallback(timerID);
|
||||
},
|
||||
|
||||
@@ -372,7 +376,7 @@ const JSTimers = {
|
||||
* This is called from the native side. We are passed an array of timerIDs,
|
||||
* and
|
||||
*/
|
||||
callTimers: function(timersToCall: Array<number>) {
|
||||
callTimers: function (timersToCall: Array<number>) {
|
||||
invariant(
|
||||
timersToCall.length !== 0,
|
||||
'Cannot call `callTimers` with an empty list of IDs.',
|
||||
@@ -390,7 +394,7 @@ const JSTimers = {
|
||||
// error one at a time
|
||||
for (let ii = 1; ii < errorCount; ii++) {
|
||||
JSTimers.setTimeout(
|
||||
(error => {
|
||||
((error) => {
|
||||
throw error;
|
||||
}).bind(null, errors[ii]),
|
||||
0,
|
||||
@@ -401,7 +405,7 @@ const JSTimers = {
|
||||
}
|
||||
},
|
||||
|
||||
callIdleCallbacks: function(frameTime: number) {
|
||||
callIdleCallbacks: function (frameTime: number) {
|
||||
if (
|
||||
FRAME_DURATION - (performanceNow() - frameTime) <
|
||||
IDLE_CALLBACK_FRAME_DEADLINE
|
||||
@@ -424,7 +428,7 @@ const JSTimers = {
|
||||
}
|
||||
|
||||
if (errors) {
|
||||
errors.forEach(error =>
|
||||
errors.forEach((error) =>
|
||||
JSTimers.setTimeout(() => {
|
||||
throw error;
|
||||
}, 0),
|
||||
@@ -440,7 +444,7 @@ const JSTimers = {
|
||||
errors = (null: ?Array<Error>);
|
||||
while (_callImmediatesPass()) {}
|
||||
if (errors) {
|
||||
errors.forEach(error =>
|
||||
errors.forEach((error) =>
|
||||
JSTimers.setTimeout(() => {
|
||||
throw error;
|
||||
}, 0),
|
||||
|
||||
@@ -29,33 +29,33 @@ jest
|
||||
|
||||
const JSTimers = require('../JSTimers');
|
||||
|
||||
describe('JSTimers', function() {
|
||||
const firstArgumentOfTheLastCallTo = function(func) {
|
||||
describe('JSTimers', function () {
|
||||
const firstArgumentOfTheLastCallTo = function (func) {
|
||||
return func.mock.calls[func.mock.calls.length - 1][0];
|
||||
};
|
||||
|
||||
beforeEach(function() {
|
||||
beforeEach(function () {
|
||||
global.setTimeout = JSTimers.setTimeout;
|
||||
});
|
||||
|
||||
it('should call function with setTimeout', function() {
|
||||
it('should call function with setTimeout', function () {
|
||||
let didCall = false;
|
||||
const id = JSTimers.setTimeout(function() {
|
||||
const id = JSTimers.setTimeout(function () {
|
||||
didCall = true;
|
||||
});
|
||||
JSTimers.callTimers([id]);
|
||||
expect(didCall).toBe(true);
|
||||
});
|
||||
|
||||
it('should call nested setTimeout when cleared', function() {
|
||||
it('should call nested setTimeout when cleared', function () {
|
||||
let id1, id2, id3;
|
||||
let callCount = 0;
|
||||
|
||||
id1 = JSTimers.setTimeout(function() {
|
||||
id1 = JSTimers.setTimeout(function () {
|
||||
JSTimers.clearTimeout(id1);
|
||||
id2 = JSTimers.setTimeout(function() {
|
||||
id2 = JSTimers.setTimeout(function () {
|
||||
JSTimers.clearTimeout(id2);
|
||||
id3 = JSTimers.setTimeout(function() {
|
||||
id3 = JSTimers.setTimeout(function () {
|
||||
callCount += 1;
|
||||
});
|
||||
});
|
||||
@@ -67,15 +67,15 @@ describe('JSTimers', function() {
|
||||
expect(callCount).toBe(1);
|
||||
});
|
||||
|
||||
it('should call nested setImmediate when cleared', function() {
|
||||
it('should call nested setImmediate when cleared', function () {
|
||||
let id1, id2, id3;
|
||||
let callCount = 0;
|
||||
|
||||
id1 = JSTimers.setImmediate(function() {
|
||||
id1 = JSTimers.setImmediate(function () {
|
||||
JSTimers.clearImmediate(id1);
|
||||
id2 = JSTimers.setImmediate(function() {
|
||||
id2 = JSTimers.setImmediate(function () {
|
||||
JSTimers.clearImmediate(id2);
|
||||
id3 = JSTimers.setImmediate(function() {
|
||||
id3 = JSTimers.setImmediate(function () {
|
||||
callCount += 1;
|
||||
});
|
||||
});
|
||||
@@ -87,15 +87,15 @@ describe('JSTimers', function() {
|
||||
expect(callCount).toBe(1);
|
||||
});
|
||||
|
||||
it('should call nested requestAnimationFrame when cleared', function() {
|
||||
it('should call nested requestAnimationFrame when cleared', function () {
|
||||
let id1, id2, id3;
|
||||
let callCount = 0;
|
||||
|
||||
id1 = JSTimers.requestAnimationFrame(function() {
|
||||
id1 = JSTimers.requestAnimationFrame(function () {
|
||||
JSTimers.cancelAnimationFrame(id1);
|
||||
id2 = JSTimers.requestAnimationFrame(function() {
|
||||
id2 = JSTimers.requestAnimationFrame(function () {
|
||||
JSTimers.cancelAnimationFrame(id2);
|
||||
id3 = JSTimers.requestAnimationFrame(function() {
|
||||
id3 = JSTimers.requestAnimationFrame(function () {
|
||||
callCount += 1;
|
||||
});
|
||||
});
|
||||
@@ -107,15 +107,15 @@ describe('JSTimers', function() {
|
||||
expect(callCount).toBe(1);
|
||||
});
|
||||
|
||||
it('should call nested setInterval when cleared', function() {
|
||||
it('should call nested setInterval when cleared', function () {
|
||||
let id1, id2, id3;
|
||||
let callCount = 0;
|
||||
|
||||
id1 = JSTimers.setInterval(function() {
|
||||
id1 = JSTimers.setInterval(function () {
|
||||
JSTimers.clearInterval(id1);
|
||||
id2 = JSTimers.setInterval(function() {
|
||||
id2 = JSTimers.setInterval(function () {
|
||||
JSTimers.clearInterval(id2);
|
||||
id3 = JSTimers.setInterval(function() {
|
||||
id3 = JSTimers.setInterval(function () {
|
||||
callCount += 1;
|
||||
});
|
||||
});
|
||||
@@ -127,21 +127,21 @@ describe('JSTimers', function() {
|
||||
expect(callCount).toBe(1);
|
||||
});
|
||||
|
||||
it('should call function with setInterval', function() {
|
||||
it('should call function with setInterval', function () {
|
||||
const callback = jest.fn();
|
||||
const id = JSTimers.setInterval(callback);
|
||||
JSTimers.callTimers([id]);
|
||||
expect(callback).toBeCalledTimes(1);
|
||||
});
|
||||
|
||||
it('should call function with setImmediate', function() {
|
||||
it('should call function with setImmediate', function () {
|
||||
const callback = jest.fn();
|
||||
JSTimers.setImmediate(callback);
|
||||
JSTimers.callImmediates();
|
||||
expect(callback).toBeCalledTimes(1);
|
||||
});
|
||||
|
||||
it('should not call function with clearImmediate', function() {
|
||||
it('should not call function with clearImmediate', function () {
|
||||
const callback = jest.fn();
|
||||
const id = JSTimers.setImmediate(callback);
|
||||
JSTimers.clearImmediate(id);
|
||||
@@ -149,14 +149,14 @@ describe('JSTimers', function() {
|
||||
expect(callback).not.toBeCalled();
|
||||
});
|
||||
|
||||
it('should call functions in the right order with setImmediate', function() {
|
||||
it('should call functions in the right order with setImmediate', function () {
|
||||
let count = 0;
|
||||
let firstCalled = null;
|
||||
let secondCalled = null;
|
||||
JSTimers.setImmediate(function() {
|
||||
JSTimers.setImmediate(function () {
|
||||
firstCalled = count++;
|
||||
});
|
||||
JSTimers.setImmediate(function() {
|
||||
JSTimers.setImmediate(function () {
|
||||
secondCalled = count++;
|
||||
});
|
||||
JSTimers.callImmediates();
|
||||
@@ -164,14 +164,14 @@ describe('JSTimers', function() {
|
||||
expect(secondCalled).toBe(1);
|
||||
});
|
||||
|
||||
it('should call functions in the right order with nested setImmediate', function() {
|
||||
it('should call functions in the right order with nested setImmediate', function () {
|
||||
let count = 0;
|
||||
let firstCalled = null;
|
||||
let secondCalled = null;
|
||||
let thirdCalled = null;
|
||||
JSTimers.setImmediate(function() {
|
||||
JSTimers.setImmediate(function () {
|
||||
firstCalled = count++;
|
||||
JSTimers.setImmediate(function() {
|
||||
JSTimers.setImmediate(function () {
|
||||
thirdCalled = count++;
|
||||
});
|
||||
secondCalled = count++;
|
||||
@@ -182,12 +182,12 @@ describe('JSTimers', function() {
|
||||
expect(thirdCalled).toBe(2);
|
||||
});
|
||||
|
||||
it('should call nested setImmediate', function() {
|
||||
it('should call nested setImmediate', function () {
|
||||
let firstCalled = false;
|
||||
let secondCalled = false;
|
||||
JSTimers.setImmediate(function() {
|
||||
JSTimers.setImmediate(function () {
|
||||
firstCalled = true;
|
||||
JSTimers.setImmediate(function() {
|
||||
JSTimers.setImmediate(function () {
|
||||
secondCalled = true;
|
||||
});
|
||||
});
|
||||
@@ -196,14 +196,14 @@ describe('JSTimers', function() {
|
||||
expect(secondCalled).toBe(true);
|
||||
});
|
||||
|
||||
it('should call function with requestAnimationFrame', function() {
|
||||
it('should call function with requestAnimationFrame', function () {
|
||||
const callback = jest.fn();
|
||||
const id = JSTimers.requestAnimationFrame(callback);
|
||||
JSTimers.callTimers([id]);
|
||||
expect(callback).toBeCalledTimes(1);
|
||||
});
|
||||
|
||||
it("should not call function if we don't callTimers", function() {
|
||||
it("should not call function if we don't callTimers", function () {
|
||||
const callback = jest.fn();
|
||||
JSTimers.setTimeout(callback, 10);
|
||||
expect(callback).not.toBeCalled();
|
||||
@@ -213,7 +213,7 @@ describe('JSTimers', function() {
|
||||
expect(callback).not.toBeCalled();
|
||||
});
|
||||
|
||||
it('should call setInterval as many times as callTimers is called', function() {
|
||||
it('should call setInterval as many times as callTimers is called', function () {
|
||||
const callback = jest.fn();
|
||||
const id = JSTimers.setInterval(callback, 10);
|
||||
JSTimers.callTimers([id]);
|
||||
@@ -223,13 +223,13 @@ describe('JSTimers', function() {
|
||||
expect(callback).toBeCalledTimes(4);
|
||||
});
|
||||
|
||||
it("should only call the function who's id we pass in", function() {
|
||||
it("should only call the function who's id we pass in", function () {
|
||||
let firstCalled = false;
|
||||
let secondCalled = false;
|
||||
JSTimers.setTimeout(function() {
|
||||
JSTimers.setTimeout(function () {
|
||||
firstCalled = true;
|
||||
});
|
||||
const secondID = JSTimers.setTimeout(function() {
|
||||
const secondID = JSTimers.setTimeout(function () {
|
||||
secondCalled = true;
|
||||
});
|
||||
JSTimers.callTimers([secondID]);
|
||||
@@ -237,13 +237,13 @@ describe('JSTimers', function() {
|
||||
expect(secondCalled).toBe(true);
|
||||
});
|
||||
|
||||
it('should work with calling multiple timers', function() {
|
||||
it('should work with calling multiple timers', function () {
|
||||
let firstCalled = false;
|
||||
let secondCalled = false;
|
||||
const firstID = JSTimers.setTimeout(function() {
|
||||
const firstID = JSTimers.setTimeout(function () {
|
||||
firstCalled = true;
|
||||
});
|
||||
const secondID = JSTimers.setTimeout(function() {
|
||||
const secondID = JSTimers.setTimeout(function () {
|
||||
secondCalled = true;
|
||||
});
|
||||
JSTimers.callTimers([firstID, secondID]);
|
||||
@@ -251,27 +251,27 @@ describe('JSTimers', function() {
|
||||
expect(secondCalled).toBe(true);
|
||||
});
|
||||
|
||||
it('should still execute all callbacks even if one throws', function() {
|
||||
const firstID = JSTimers.setTimeout(function() {
|
||||
it('should still execute all callbacks even if one throws', function () {
|
||||
const firstID = JSTimers.setTimeout(function () {
|
||||
throw new Error('error');
|
||||
}, 10);
|
||||
let secondCalled = false;
|
||||
const secondID = JSTimers.setTimeout(function() {
|
||||
const secondID = JSTimers.setTimeout(function () {
|
||||
secondCalled = true;
|
||||
}, 10);
|
||||
expect(JSTimers.callTimers.bind(null, [firstID, secondID])).toThrow();
|
||||
expect(secondCalled).toBe(true);
|
||||
});
|
||||
|
||||
it('should clear timers even if callback throws', function() {
|
||||
const timerID = JSTimers.setTimeout(function() {
|
||||
it('should clear timers even if callback throws', function () {
|
||||
const timerID = JSTimers.setTimeout(function () {
|
||||
throw new Error('error');
|
||||
}, 10);
|
||||
expect(JSTimers.callTimers.bind(null, [timerID])).toThrow('error');
|
||||
JSTimers.callTimers.bind(null, [timerID]);
|
||||
});
|
||||
|
||||
it('should not warn if callback is called on cancelled timer', function() {
|
||||
it('should not warn if callback is called on cancelled timer', function () {
|
||||
const callback = jest.fn();
|
||||
const timerID = JSTimers.setTimeout(callback, 10);
|
||||
JSTimers.clearTimeout(timerID);
|
||||
@@ -280,12 +280,12 @@ describe('JSTimers', function() {
|
||||
expect(firstArgumentOfTheLastCallTo(warning)).toBe(true);
|
||||
});
|
||||
|
||||
it('should warn when callTimers is called with garbage timer id', function() {
|
||||
it('should warn when callTimers is called with garbage timer id', function () {
|
||||
JSTimers.callTimers([1337]);
|
||||
expect(firstArgumentOfTheLastCallTo(warning)).toBe(false);
|
||||
});
|
||||
|
||||
it('should only call callback once for setTimeout', function() {
|
||||
it('should only call callback once for setTimeout', function () {
|
||||
const callback = jest.fn();
|
||||
const timerID = JSTimers.setTimeout(callback, 10);
|
||||
// First time the timer fires, should call callback
|
||||
@@ -297,7 +297,7 @@ describe('JSTimers', function() {
|
||||
expect(firstArgumentOfTheLastCallTo(warning)).toBe(true);
|
||||
});
|
||||
|
||||
it('should only call callback once for requestAnimationFrame', function() {
|
||||
it('should only call callback once for requestAnimationFrame', function () {
|
||||
const callback = jest.fn();
|
||||
const timerID = JSTimers.requestAnimationFrame(callback, 10);
|
||||
// First time the timer fires, should call callback
|
||||
@@ -309,11 +309,11 @@ describe('JSTimers', function() {
|
||||
expect(firstArgumentOfTheLastCallTo(warning)).toBe(true);
|
||||
});
|
||||
|
||||
it('should re-throw first exception', function() {
|
||||
const timerID1 = JSTimers.setTimeout(function() {
|
||||
it('should re-throw first exception', function () {
|
||||
const timerID1 = JSTimers.setTimeout(function () {
|
||||
throw new Error('first error');
|
||||
});
|
||||
const timerID2 = JSTimers.setTimeout(function() {
|
||||
const timerID2 = JSTimers.setTimeout(function () {
|
||||
throw new Error('second error');
|
||||
});
|
||||
expect(JSTimers.callTimers.bind(null, [timerID1, timerID2])).toThrowError(
|
||||
@@ -321,8 +321,8 @@ describe('JSTimers', function() {
|
||||
);
|
||||
});
|
||||
|
||||
it('should pass along errors thrown from setImmediate', function() {
|
||||
JSTimers.setImmediate(function() {
|
||||
it('should pass along errors thrown from setImmediate', function () {
|
||||
JSTimers.setImmediate(function () {
|
||||
throw new Error('error within setImmediate');
|
||||
});
|
||||
|
||||
@@ -338,12 +338,12 @@ describe('JSTimers', function() {
|
||||
);
|
||||
});
|
||||
|
||||
it('should throw all errors from setImmediate', function() {
|
||||
JSTimers.setImmediate(function() {
|
||||
it('should throw all errors from setImmediate', function () {
|
||||
JSTimers.setImmediate(function () {
|
||||
throw new Error('first error');
|
||||
});
|
||||
|
||||
JSTimers.setImmediate(function() {
|
||||
JSTimers.setImmediate(function () {
|
||||
throw new Error('second error');
|
||||
});
|
||||
|
||||
@@ -363,8 +363,8 @@ describe('JSTimers', function() {
|
||||
);
|
||||
});
|
||||
|
||||
it('should pass along errors thrown from setTimeout', function() {
|
||||
const timerID = JSTimers.setTimeout(function() {
|
||||
it('should pass along errors thrown from setTimeout', function () {
|
||||
const timerID = JSTimers.setTimeout(function () {
|
||||
throw new Error('error within setTimeout');
|
||||
});
|
||||
|
||||
@@ -373,11 +373,11 @@ describe('JSTimers', function() {
|
||||
);
|
||||
});
|
||||
|
||||
it('should throw all errors from setTimeout', function() {
|
||||
const firstTimerID = JSTimers.setTimeout(function() {
|
||||
it('should throw all errors from setTimeout', function () {
|
||||
const firstTimerID = JSTimers.setTimeout(function () {
|
||||
throw new Error('first error');
|
||||
});
|
||||
const secondTimerID = JSTimers.setTimeout(function() {
|
||||
const secondTimerID = JSTimers.setTimeout(function () {
|
||||
throw new Error('second error');
|
||||
});
|
||||
|
||||
@@ -393,8 +393,8 @@ describe('JSTimers', function() {
|
||||
);
|
||||
});
|
||||
|
||||
it('should pass along errors thrown from setInterval', function() {
|
||||
const timerID = JSTimers.setInterval(function() {
|
||||
it('should pass along errors thrown from setInterval', function () {
|
||||
const timerID = JSTimers.setInterval(function () {
|
||||
throw new Error('error within setInterval');
|
||||
});
|
||||
expect(JSTimers.callTimers.bind(null, [timerID])).toThrowError(
|
||||
@@ -402,7 +402,7 @@ describe('JSTimers', function() {
|
||||
);
|
||||
});
|
||||
|
||||
it('should not call to native when clearing a null timer', function() {
|
||||
it('should not call to native when clearing a null timer', function () {
|
||||
const timerID = JSTimers.setTimeout(() => {});
|
||||
JSTimers.clearTimeout(timerID);
|
||||
NativeTiming.deleteTimer = jest.fn();
|
||||
|
||||
@@ -24,7 +24,7 @@ function reportError(error) {
|
||||
const ErrorUtils = {
|
||||
apply: jest.fn(execute),
|
||||
applyWithGuard: jest.fn(execute),
|
||||
guard: jest.fn(callback => callback),
|
||||
guard: jest.fn((callback) => callback),
|
||||
inGuard: jest.fn().mockReturnValue(true),
|
||||
reportError: jest.fn(reportError),
|
||||
setGlobalHandler: jest.fn(),
|
||||
|
||||
@@ -482,7 +482,7 @@ describe('ExceptionsManager', () => {
|
||||
|
||||
test('modifying the exception data', () => {
|
||||
const error = new Error('Some error happened');
|
||||
const decorator = jest.fn().mockImplementation(data => ({
|
||||
const decorator = jest.fn().mockImplementation((data) => ({
|
||||
...data,
|
||||
message: 'decorated: ' + data.message,
|
||||
}));
|
||||
@@ -515,7 +515,7 @@ describe('ExceptionsManager', () => {
|
||||
|
||||
test('clearing a decorator', () => {
|
||||
const error = new Error('Some error happened');
|
||||
const decorator = jest.fn().mockImplementation(data => ({
|
||||
const decorator = jest.fn().mockImplementation((data) => ({
|
||||
...data,
|
||||
message: 'decorated: ' + data.message,
|
||||
}));
|
||||
@@ -530,7 +530,7 @@ describe('ExceptionsManager', () => {
|
||||
|
||||
test('prevents decorator recursion from error handler', () => {
|
||||
const error = new Error('Some error happened');
|
||||
const decorator = jest.fn().mockImplementation(data => {
|
||||
const decorator = jest.fn().mockImplementation((data) => {
|
||||
console.error('Logging an error within the decorator');
|
||||
return {
|
||||
...data,
|
||||
@@ -556,7 +556,7 @@ describe('ExceptionsManager', () => {
|
||||
|
||||
test('prevents decorator recursion from console.error', () => {
|
||||
const error = new Error('Some error happened');
|
||||
const decorator = jest.fn().mockImplementation(data => {
|
||||
const decorator = jest.fn().mockImplementation((data) => {
|
||||
console.error('Logging an error within the decorator');
|
||||
return {
|
||||
...data,
|
||||
@@ -586,7 +586,7 @@ describe('ExceptionsManager', () => {
|
||||
|
||||
test('can handle throwing decorators recursion when exception is thrown', () => {
|
||||
const error = new Error('Some error happened');
|
||||
const decorator = jest.fn().mockImplementation(data => {
|
||||
const decorator = jest.fn().mockImplementation((data) => {
|
||||
throw new Error('Throwing an error within the decorator');
|
||||
});
|
||||
|
||||
@@ -604,7 +604,7 @@ describe('ExceptionsManager', () => {
|
||||
|
||||
test('can handle throwing decorators recursion when exception is logged', () => {
|
||||
const error = new Error('Some error happened');
|
||||
const decorator = jest.fn().mockImplementation(data => {
|
||||
const decorator = jest.fn().mockImplementation((data) => {
|
||||
throw new Error('Throwing an error within the decorator');
|
||||
});
|
||||
|
||||
|
||||
@@ -45,7 +45,7 @@ function _defineCheckVersionTests() {
|
||||
beforeEach(() => {
|
||||
consoleOutput = '';
|
||||
console.error = jest.fn();
|
||||
global.console = {error: jest.fn(error => (consoleOutput += error))};
|
||||
global.console = {error: jest.fn((error) => (consoleOutput += error))};
|
||||
spyOnConsoleError = jest.spyOn(global.console, 'error');
|
||||
});
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
* You can use this module directly, or just require InitializeCore.
|
||||
*/
|
||||
if (!global.alert) {
|
||||
global.alert = function(text) {
|
||||
global.alert = function (text) {
|
||||
// Require Alert on demand. Requiring it too early can lead to issues
|
||||
// with things like Platform not being fully initialized.
|
||||
require('../Alert/Alert').alert('Alert', '' + text);
|
||||
|
||||
@@ -60,9 +60,9 @@ if (__DEV__) {
|
||||
'groupCollapsed',
|
||||
'groupEnd',
|
||||
'debug',
|
||||
].forEach(level => {
|
||||
].forEach((level) => {
|
||||
const originalFunction = console[level];
|
||||
console[level] = function(...args) {
|
||||
console[level] = function (...args) {
|
||||
HMRClient.log(level, args);
|
||||
originalFunction.apply(console, args);
|
||||
};
|
||||
|
||||
@@ -18,7 +18,7 @@ if (!global.RN$Bridgeless) {
|
||||
* Set up timers.
|
||||
* You can use this module directly, or just require InitializeCore.
|
||||
*/
|
||||
const defineLazyTimer = name => {
|
||||
const defineLazyTimer = (name) => {
|
||||
polyfillGlobal(name, () => require('./Timers/JSTimers')[name]);
|
||||
};
|
||||
defineLazyTimer('setTimeout');
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
const normalizeColor = require('../StyleSheet/normalizeColor');
|
||||
|
||||
const colorPropType = function(
|
||||
const colorPropType = function (
|
||||
isRequired,
|
||||
props,
|
||||
propName,
|
||||
|
||||
@@ -18,7 +18,7 @@ function DeprecatedStyleSheetPropType(shape: {
|
||||
...,
|
||||
}): ReactPropsCheckType {
|
||||
const shapePropType = deprecatedCreateStrictShapeTypeChecker(shape);
|
||||
return function(props, propName, componentName, location?, ...rest) {
|
||||
return function (props, propName, componentName, location?, ...rest) {
|
||||
let newProps = props;
|
||||
if (props[propName]) {
|
||||
// Just make a dummy prop object with only the flattened style
|
||||
|
||||
@@ -14,7 +14,7 @@ const ReactPropTypes = require('prop-types');
|
||||
|
||||
const deprecatedPropType = require('../Utilities/deprecatedPropType');
|
||||
|
||||
const TransformMatrixPropType = function(
|
||||
const TransformMatrixPropType = function (
|
||||
props: Object,
|
||||
propName: string,
|
||||
componentName: string,
|
||||
@@ -27,7 +27,7 @@ const TransformMatrixPropType = function(
|
||||
}
|
||||
};
|
||||
|
||||
const DecomposedMatrixPropType = function(
|
||||
const DecomposedMatrixPropType = function (
|
||||
props: Object,
|
||||
propName: string,
|
||||
componentName: string,
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
import NativeJSCHeapCapture from './NativeJSCHeapCapture';
|
||||
|
||||
const HeapCapture = {
|
||||
captureHeap: function(path: string) {
|
||||
captureHeap: function (path: string) {
|
||||
let error = null;
|
||||
try {
|
||||
global.nativeCaptureHeap(path);
|
||||
|
||||
@@ -154,12 +154,12 @@ function getSize(
|
||||
failure?: (error: any) => void,
|
||||
): any {
|
||||
return NativeImageLoaderAndroid.getSize(url)
|
||||
.then(function(sizes) {
|
||||
.then(function (sizes) {
|
||||
success(sizes.width, sizes.height);
|
||||
})
|
||||
.catch(
|
||||
failure ||
|
||||
function() {
|
||||
function () {
|
||||
console.warn('Failed to get size for image: ' + url);
|
||||
},
|
||||
);
|
||||
@@ -178,12 +178,12 @@ function getSizeWithHeaders(
|
||||
failure?: (error: any) => void,
|
||||
): any {
|
||||
return NativeImageLoaderAndroid.getSizeWithHeaders(url, headers)
|
||||
.then(function(sizes) {
|
||||
.then(function (sizes) {
|
||||
success(sizes.width, sizes.height);
|
||||
})
|
||||
.catch(
|
||||
failure ||
|
||||
function() {
|
||||
function () {
|
||||
console.warn('Failed to get size for image: ' + url);
|
||||
},
|
||||
);
|
||||
@@ -289,7 +289,7 @@ let Image = (props: ImagePropsType, forwardedRef) => {
|
||||
|
||||
return (
|
||||
<TextAncestor.Consumer>
|
||||
{hasTextAncestor =>
|
||||
{(hasTextAncestor) =>
|
||||
hasTextAncestor ? (
|
||||
<TextInlineImageNativeComponent {...nativeProps} />
|
||||
) : (
|
||||
|
||||
@@ -34,7 +34,7 @@ function getSize(
|
||||
.then(([width, height]) => success(width, height))
|
||||
.catch(
|
||||
failure ||
|
||||
function() {
|
||||
function () {
|
||||
console.warn('Failed to get size for image ' + uri);
|
||||
},
|
||||
);
|
||||
@@ -47,12 +47,12 @@ function getSizeWithHeaders(
|
||||
failure?: (error: any) => void,
|
||||
): any {
|
||||
return NativeImageLoaderIOS.getSizeWithHeaders(uri, headers)
|
||||
.then(function(sizes) {
|
||||
.then(function (sizes) {
|
||||
success(sizes.width, sizes.height);
|
||||
})
|
||||
.catch(
|
||||
failure ||
|
||||
function() {
|
||||
function () {
|
||||
console.warn('Failed to get size for image: ' + uri);
|
||||
},
|
||||
);
|
||||
|
||||
@@ -50,7 +50,7 @@ class ImageBackground extends React.Component<$FlowFixMeProps> {
|
||||
|
||||
_viewRef: ?React.ElementRef<typeof View> = null;
|
||||
|
||||
_captureRef = ref => {
|
||||
_captureRef = (ref) => {
|
||||
this._viewRef = ref;
|
||||
};
|
||||
|
||||
|
||||
@@ -14,15 +14,15 @@ import NativeImagePickerIOS from './NativeImagePickerIOS';
|
||||
import invariant from 'invariant';
|
||||
|
||||
const ImagePickerIOS = {
|
||||
canRecordVideos: function(callback: (result: boolean) => void): void {
|
||||
canRecordVideos: function (callback: (result: boolean) => void): void {
|
||||
invariant(NativeImagePickerIOS, 'ImagePickerIOS is not available');
|
||||
return NativeImagePickerIOS.canRecordVideos(callback);
|
||||
},
|
||||
canUseCamera: function(callback: (result: boolean) => void): void {
|
||||
canUseCamera: function (callback: (result: boolean) => void): void {
|
||||
invariant(NativeImagePickerIOS, 'ImagePickerIOS is not available');
|
||||
return NativeImagePickerIOS.canUseCamera(callback);
|
||||
},
|
||||
openCameraDialog: function(
|
||||
openCameraDialog: function (
|
||||
config: $ReadOnly<{|
|
||||
unmirrorFrontFacingCamera?: boolean,
|
||||
videoMode?: boolean,
|
||||
@@ -51,7 +51,7 @@ const ImagePickerIOS = {
|
||||
cancelCallback,
|
||||
);
|
||||
},
|
||||
openSelectDialog: function(
|
||||
openSelectDialog: function (
|
||||
config: $ReadOnly<{|
|
||||
showImages?: boolean,
|
||||
showVideos?: boolean,
|
||||
@@ -88,7 +88,7 @@ const ImagePickerIOS = {
|
||||
* It is safe to call this method for urlsthat aren't video URLs;
|
||||
* it will be a no-op.
|
||||
*/
|
||||
removePendingVideo: function(url: string): void {
|
||||
removePendingVideo: function (url: string): void {
|
||||
invariant(NativeImagePickerIOS, 'ImagePickerIOS is not available');
|
||||
NativeImagePickerIOS.removePendingVideo(url);
|
||||
},
|
||||
@@ -96,7 +96,7 @@ const ImagePickerIOS = {
|
||||
* WARNING: In most cases, removePendingVideo should be used instead because
|
||||
* clearAllPendingVideos could clear out pending videos made by other callers.
|
||||
*/
|
||||
clearAllPendingVideos: function(): void {
|
||||
clearAllPendingVideos: function (): void {
|
||||
invariant(NativeImagePickerIOS, 'ImagePickerIOS is not available');
|
||||
NativeImagePickerIOS.clearAllPendingVideos();
|
||||
},
|
||||
|
||||
@@ -298,7 +298,7 @@ describe('resolveAssetSource', () => {
|
||||
});
|
||||
|
||||
it('uses bundled source, event when js is sideloaded', () => {
|
||||
resolveAssetSource.setCustomSourceTransformer(resolver =>
|
||||
resolveAssetSource.setCustomSourceTransformer((resolver) =>
|
||||
resolver.resourceIdentifierWithoutScale(),
|
||||
);
|
||||
expectResolvesAsset(
|
||||
@@ -324,7 +324,7 @@ describe('resolveAssetSource', () => {
|
||||
});
|
||||
|
||||
it('allows any customization', () => {
|
||||
resolveAssetSource.setCustomSourceTransformer(resolver =>
|
||||
resolveAssetSource.setCustomSourceTransformer((resolver) =>
|
||||
resolver.fromSource('TEST'),
|
||||
);
|
||||
expectResolvesAsset(
|
||||
|
||||
@@ -35,7 +35,7 @@ type Props = $ReadOnly<{|
|
||||
},
|
||||
frame?: ?Object,
|
||||
selection?: ?number,
|
||||
setSelection?: number => mixed,
|
||||
setSelection?: (number) => mixed,
|
||||
|}>;
|
||||
|
||||
class ElementProperties extends React.Component<Props> {
|
||||
@@ -75,7 +75,7 @@ class ElementProperties extends React.Component<Props> {
|
||||
<Text style={styles.breadItemText}>{hierarchyItem.name}</Text>
|
||||
</TouchableHighlight>
|
||||
),
|
||||
i => (
|
||||
(i) => (
|
||||
<Text key={'sep-' + i} style={styles.breadSep}>
|
||||
▸
|
||||
</Text>
|
||||
|
||||
@@ -118,7 +118,7 @@ class Inspector extends React.Component<
|
||||
|
||||
componentWillUnmount() {
|
||||
if (this._subs) {
|
||||
this._subs.map(fn => fn());
|
||||
this._subs.map((fn) => fn());
|
||||
}
|
||||
hook.off('react-devtools', this._attachToDevtools);
|
||||
}
|
||||
@@ -149,7 +149,7 @@ class Inspector extends React.Component<
|
||||
}, 100);
|
||||
};
|
||||
|
||||
_onAgentShowNativeHighlight = node => {
|
||||
_onAgentShowNativeHighlight = (node) => {
|
||||
clearTimeout(this._hideTimeoutID);
|
||||
|
||||
node.measure((x, y, width, height, left, top) => {
|
||||
@@ -242,7 +242,7 @@ class Inspector extends React.Component<
|
||||
|
||||
setTouchTargeting(val: boolean) {
|
||||
Touchable.TOUCH_TARGET_DEBUG = val;
|
||||
this.props.onRequestRerenderApp(inspectedView => {
|
||||
this.props.onRequestRerenderApp((inspectedView) => {
|
||||
this.setState({inspectedView});
|
||||
});
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ type Props = $ReadOnly<{|
|
||||
setNetworking: (val: boolean) => void,
|
||||
hierarchy?: ?Array<{|name: string|}>,
|
||||
selection?: ?number,
|
||||
setSelection: number => mixed,
|
||||
setSelection: (number) => mixed,
|
||||
inspected?: ?$ReadOnly<{|
|
||||
style?: ?ViewStyleProp,
|
||||
frame?: ?$ReadOnly<{|
|
||||
|
||||
@@ -360,7 +360,7 @@ class NetworkOverlay extends React.Component<Props, State> {
|
||||
|
||||
_renderItemDetail(id) {
|
||||
const requestItem = this.state.requests[id];
|
||||
const details = Object.keys(requestItem).map(key => {
|
||||
const details = Object.keys(requestItem).map((key) => {
|
||||
if (key === 'id') {
|
||||
return;
|
||||
}
|
||||
@@ -387,7 +387,7 @@ class NetworkOverlay extends React.Component<Props, State> {
|
||||
</TouchableHighlight>
|
||||
<ScrollView
|
||||
style={styles.detailScrollView}
|
||||
ref={scrollRef => (this._detailScrollView = scrollRef)}>
|
||||
ref={(scrollRef) => (this._detailScrollView = scrollRef)}>
|
||||
{details}
|
||||
</ScrollView>
|
||||
</View>
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user