mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
JS: Format with Prettier v2.4.1 [3/n]
Summary: Changelog: [General][Internal] Reviewed By: zertosh Differential Revision: D31883447 fbshipit-source-id: cbbf85e4bf935096d242336f41bf0cc5d6f92359
This commit is contained in:
committed by
Facebook GitHub Bot
parent
4e587a1b7d
commit
77ecc7ede1
@@ -218,11 +218,13 @@ class AsyncStorageTest extends React.Component<{...}, $FlowFixMeState> {
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<Text>
|
||||
{/* $FlowFixMe[incompatible-type] (>=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.
|
||||
*/
|
||||
this.constructor.displayName + ': '}
|
||||
{
|
||||
/* $FlowFixMe[incompatible-type] (>=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.
|
||||
*/
|
||||
this.constructor.displayName + ': '
|
||||
}
|
||||
{this.state.done ? 'Done' : 'Testing...'}
|
||||
{'\n\n' + this.state.messages}
|
||||
</Text>
|
||||
|
||||
@@ -56,11 +56,13 @@ class IntegrationTestHarnessTest extends React.Component<Props, State> {
|
||||
return (
|
||||
<View style={styles.container}>
|
||||
<Text>
|
||||
{/* $FlowFixMe[incompatible-type] (>=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.
|
||||
*/
|
||||
this.constructor.displayName + ': '}
|
||||
{
|
||||
/* $FlowFixMe[incompatible-type] (>=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.
|
||||
*/
|
||||
this.constructor.displayName + ': '
|
||||
}
|
||||
{this.state.done ? 'Done' : 'Testing...'}
|
||||
</Text>
|
||||
</View>
|
||||
|
||||
@@ -13,14 +13,8 @@
|
||||
require('react-native/Libraries/Core/InitializeCore');
|
||||
const React = require('react');
|
||||
const ReactNative = require('react-native');
|
||||
const {
|
||||
AppRegistry,
|
||||
ScrollView,
|
||||
StyleSheet,
|
||||
Text,
|
||||
TouchableOpacity,
|
||||
View,
|
||||
} = ReactNative;
|
||||
const {AppRegistry, ScrollView, StyleSheet, Text, TouchableOpacity, View} =
|
||||
ReactNative;
|
||||
|
||||
// Keep this list in sync with RNTesterIntegrationTests.m
|
||||
const TESTS = [
|
||||
|
||||
@@ -14,24 +14,24 @@ const BatchedBridge = require('react-native/Libraries/BatchedBridge/BatchedBridg
|
||||
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) {
|
||||
console.warn(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);
|
||||
},
|
||||
};
|
||||
|
||||
@@ -12,14 +12,8 @@
|
||||
const React = require('react');
|
||||
const ReactNative = require('react-native');
|
||||
|
||||
const {
|
||||
AppRegistry,
|
||||
ScrollView,
|
||||
StyleSheet,
|
||||
Text,
|
||||
TouchableOpacity,
|
||||
View,
|
||||
} = ReactNative;
|
||||
const {AppRegistry, ScrollView, StyleSheet, Text, TouchableOpacity, View} =
|
||||
ReactNative;
|
||||
|
||||
/* Keep this list in sync with RCTRootViewIntegrationTests.m */
|
||||
const TESTS = [
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -46,8 +46,8 @@ class Alert {
|
||||
if (Platform.OS === 'ios') {
|
||||
Alert.prompt(title, message, buttons, 'default');
|
||||
} else if (Platform.OS === 'android') {
|
||||
const NativeDialogManagerAndroid = require('../NativeModules/specs/NativeDialogManagerAndroid')
|
||||
.default;
|
||||
const NativeDialogManagerAndroid =
|
||||
require('../NativeModules/specs/NativeDialogManagerAndroid').default;
|
||||
if (!NativeDialogManagerAndroid) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -12,7 +12,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;
|
||||
|
||||
@@ -48,39 +48,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,
|
||||
@@ -88,7 +88,7 @@ const diffClamp = function(
|
||||
return new AnimatedDiffClamp(a, min, max);
|
||||
};
|
||||
|
||||
const _combineCallbacks = function(
|
||||
const _combineCallbacks = function (
|
||||
callback: ?EndCallback,
|
||||
config: {...AnimationConfig, ...},
|
||||
) {
|
||||
@@ -102,7 +102,7 @@ const _combineCallbacks = function(
|
||||
}
|
||||
};
|
||||
|
||||
const maybeVectorAnim = function(
|
||||
const maybeVectorAnim = function (
|
||||
value: AnimatedValue | AnimatedValueXY,
|
||||
config: Object,
|
||||
anim: (value: AnimatedValue, config: Object) => CompositeAnimation,
|
||||
@@ -126,11 +126,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,
|
||||
@@ -155,35 +155,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,
|
||||
@@ -209,35 +209,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,
|
||||
@@ -251,37 +251,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;
|
||||
@@ -304,13 +304,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();
|
||||
@@ -319,13 +319,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;
|
||||
},
|
||||
};
|
||||
@@ -336,7 +336,7 @@ type ParallelConfig = {
|
||||
stopTogether?: boolean,
|
||||
...
|
||||
};
|
||||
const parallel = function(
|
||||
const parallel = function (
|
||||
animations: Array<CompositeAnimation>,
|
||||
config?: ?ParallelConfig,
|
||||
): CompositeAnimation {
|
||||
@@ -346,14 +346,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) {
|
||||
@@ -375,14 +375,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;
|
||||
@@ -390,13 +390,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;
|
||||
},
|
||||
};
|
||||
@@ -404,7 +404,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,
|
||||
@@ -414,7 +414,7 @@ const delay = function(time: number): CompositeAnimation {
|
||||
});
|
||||
};
|
||||
|
||||
const stagger = function(
|
||||
const stagger = function (
|
||||
time: number,
|
||||
animations: Array<CompositeAnimation>,
|
||||
): CompositeAnimation {
|
||||
@@ -431,15 +431,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 ||
|
||||
@@ -463,24 +463,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();
|
||||
},
|
||||
};
|
||||
@@ -512,7 +512,7 @@ function unforkEvent(
|
||||
}
|
||||
}
|
||||
|
||||
const event = function(
|
||||
const event = function (
|
||||
argMapping: $ReadOnlyArray<?Mapping>,
|
||||
config: EventConfig,
|
||||
): any {
|
||||
|
||||
@@ -88,7 +88,7 @@ const mockCompositeAnimation = (
|
||||
}),
|
||||
});
|
||||
|
||||
const spring = function(
|
||||
const spring = function (
|
||||
value: AnimatedValue | AnimatedValueXY,
|
||||
config: SpringAnimationConfig,
|
||||
): CompositeAnimation {
|
||||
@@ -102,7 +102,7 @@ const spring = function(
|
||||
};
|
||||
};
|
||||
|
||||
const timing = function(
|
||||
const timing = function (
|
||||
value: AnimatedValue | AnimatedValueXY,
|
||||
config: TimingAnimationConfig,
|
||||
): CompositeAnimation {
|
||||
@@ -116,32 +116,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 mockCompositeAnimation(animations);
|
||||
};
|
||||
|
||||
type ParallelConfig = {stopTogether?: boolean, ...};
|
||||
const parallel = function(
|
||||
const parallel = function (
|
||||
animations: Array<CompositeAnimation>,
|
||||
config?: ?ParallelConfig,
|
||||
): CompositeAnimation {
|
||||
return mockCompositeAnimation(animations);
|
||||
};
|
||||
|
||||
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 {
|
||||
@@ -154,7 +154,7 @@ type LoopAnimationConfig = {
|
||||
...
|
||||
};
|
||||
|
||||
const loop = function(
|
||||
const loop = function (
|
||||
animation: CompositeAnimation,
|
||||
{iterations = -1}: LoopAnimationConfig = {},
|
||||
): CompositeAnimation {
|
||||
|
||||
@@ -42,7 +42,7 @@ let queue: Array<() => void> = [];
|
||||
* the native module methods
|
||||
*/
|
||||
const API = {
|
||||
getValue: function(
|
||||
getValue: function (
|
||||
tag: number,
|
||||
saveValueCallback: (value: number) => void,
|
||||
): void {
|
||||
@@ -51,11 +51,11 @@ const API = {
|
||||
NativeAnimatedModule.getValue(tag, saveValueCallback);
|
||||
});
|
||||
},
|
||||
setWaitingForIdentifier: function(id: string): void {
|
||||
setWaitingForIdentifier: function (id: string): void {
|
||||
waitingForQueuedOperations.add(id);
|
||||
queueOperations = true;
|
||||
},
|
||||
unsetWaitingForIdentifier: function(id: string): void {
|
||||
unsetWaitingForIdentifier: function (id: string): void {
|
||||
waitingForQueuedOperations.delete(id);
|
||||
|
||||
if (waitingForQueuedOperations.size === 0) {
|
||||
@@ -63,7 +63,7 @@ const API = {
|
||||
API.disableQueue();
|
||||
}
|
||||
},
|
||||
disableQueue: function(): void {
|
||||
disableQueue: function (): void {
|
||||
invariant(NativeAnimatedModule, 'Native animated module is not available');
|
||||
|
||||
if (Platform.OS === 'android') {
|
||||
@@ -84,37 +84,40 @@ const API = {
|
||||
fn();
|
||||
}
|
||||
},
|
||||
createAnimatedNode: function(tag: number, config: AnimatedNodeConfig): void {
|
||||
createAnimatedNode: function (tag: number, config: AnimatedNodeConfig): void {
|
||||
invariant(NativeAnimatedModule, 'Native animated module is not available');
|
||||
API.queueOperation(() =>
|
||||
NativeAnimatedModule.createAnimatedNode(tag, config),
|
||||
);
|
||||
},
|
||||
startListeningToAnimatedNodeValue: function(tag: number) {
|
||||
startListeningToAnimatedNodeValue: function (tag: number) {
|
||||
invariant(NativeAnimatedModule, 'Native animated module is not available');
|
||||
API.queueOperation(() =>
|
||||
NativeAnimatedModule.startListeningToAnimatedNodeValue(tag),
|
||||
);
|
||||
},
|
||||
stopListeningToAnimatedNodeValue: function(tag: number) {
|
||||
stopListeningToAnimatedNodeValue: function (tag: number) {
|
||||
invariant(NativeAnimatedModule, 'Native animated module is not available');
|
||||
API.queueOperation(() =>
|
||||
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');
|
||||
API.queueOperation(() =>
|
||||
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');
|
||||
API.queueOperation(() =>
|
||||
NativeAnimatedModule.disconnectAnimatedNodes(parentTag, childTag),
|
||||
);
|
||||
},
|
||||
startAnimatingNode: function(
|
||||
startAnimatingNode: function (
|
||||
animationId: number,
|
||||
nodeTag: number,
|
||||
config: AnimatingNodeConfig,
|
||||
@@ -130,41 +133,41 @@ const API = {
|
||||
),
|
||||
);
|
||||
},
|
||||
stopAnimation: function(animationId: number) {
|
||||
stopAnimation: function (animationId: number) {
|
||||
invariant(NativeAnimatedModule, 'Native animated module is not available');
|
||||
API.queueOperation(() => 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');
|
||||
API.queueOperation(() =>
|
||||
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');
|
||||
API.queueOperation(() =>
|
||||
NativeAnimatedModule.setAnimatedNodeOffset(nodeTag, offset),
|
||||
);
|
||||
},
|
||||
flattenAnimatedNodeOffset: function(nodeTag: number): void {
|
||||
flattenAnimatedNodeOffset: function (nodeTag: number): void {
|
||||
invariant(NativeAnimatedModule, 'Native animated module is not available');
|
||||
API.queueOperation(() =>
|
||||
NativeAnimatedModule.flattenAnimatedNodeOffset(nodeTag),
|
||||
);
|
||||
},
|
||||
extractAnimatedNodeOffset: function(nodeTag: number): void {
|
||||
extractAnimatedNodeOffset: function (nodeTag: number): void {
|
||||
invariant(NativeAnimatedModule, 'Native animated module is not available');
|
||||
API.queueOperation(() =>
|
||||
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');
|
||||
API.queueOperation(() =>
|
||||
NativeAnimatedModule.connectAnimatedNodeToView(nodeTag, viewTag),
|
||||
);
|
||||
},
|
||||
disconnectAnimatedNodeFromView: function(
|
||||
disconnectAnimatedNodeFromView: function (
|
||||
nodeTag: number,
|
||||
viewTag: number,
|
||||
): void {
|
||||
@@ -173,7 +176,7 @@ const API = {
|
||||
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) {
|
||||
@@ -182,11 +185,11 @@ const API = {
|
||||
);
|
||||
}
|
||||
},
|
||||
dropAnimatedNode: function(tag: number): void {
|
||||
dropAnimatedNode: function (tag: number): void {
|
||||
invariant(NativeAnimatedModule, 'Native animated module is not available');
|
||||
API.queueOperation(() => NativeAnimatedModule.dropAnimatedNode(tag));
|
||||
},
|
||||
addAnimatedEventToView: function(
|
||||
addAnimatedEventToView: function (
|
||||
viewTag: number,
|
||||
eventName: string,
|
||||
eventMapping: EventMapping,
|
||||
|
||||
@@ -382,15 +382,17 @@ describe('Native Animated', () => {
|
||||
expect.any(Number),
|
||||
{type: 'addition', input: expect.any(Array)},
|
||||
);
|
||||
const additionCalls = NativeAnimatedModule.createAnimatedNode.mock.calls.filter(
|
||||
call => call[1].type === 'addition',
|
||||
);
|
||||
const additionCalls =
|
||||
NativeAnimatedModule.createAnimatedNode.mock.calls.filter(
|
||||
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,
|
||||
);
|
||||
const additionConnectionCalls =
|
||||
NativeAnimatedModule.connectAnimatedNodes.mock.calls.filter(
|
||||
call => call[1] === additionNodeTag,
|
||||
);
|
||||
expect(additionConnectionCalls.length).toBe(2);
|
||||
expect(NativeAnimatedModule.createAnimatedNode).toBeCalledWith(
|
||||
additionCall[1].input[0],
|
||||
@@ -424,15 +426,17 @@ describe('Native Animated', () => {
|
||||
expect.any(Number),
|
||||
{type: 'subtraction', input: expect.any(Array)},
|
||||
);
|
||||
const subtractionCalls = NativeAnimatedModule.createAnimatedNode.mock.calls.filter(
|
||||
call => call[1].type === 'subtraction',
|
||||
);
|
||||
const subtractionCalls =
|
||||
NativeAnimatedModule.createAnimatedNode.mock.calls.filter(
|
||||
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,
|
||||
);
|
||||
const subtractionConnectionCalls =
|
||||
NativeAnimatedModule.connectAnimatedNodes.mock.calls.filter(
|
||||
call => call[1] === subtractionNodeTag,
|
||||
);
|
||||
expect(subtractionConnectionCalls.length).toBe(2);
|
||||
expect(NativeAnimatedModule.createAnimatedNode).toBeCalledWith(
|
||||
subtractionCall[1].input[0],
|
||||
@@ -466,15 +470,17 @@ describe('Native Animated', () => {
|
||||
expect.any(Number),
|
||||
{type: 'multiplication', input: expect.any(Array)},
|
||||
);
|
||||
const multiplicationCalls = NativeAnimatedModule.createAnimatedNode.mock.calls.filter(
|
||||
call => call[1].type === 'multiplication',
|
||||
);
|
||||
const multiplicationCalls =
|
||||
NativeAnimatedModule.createAnimatedNode.mock.calls.filter(
|
||||
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,
|
||||
);
|
||||
const multiplicationConnectionCalls =
|
||||
NativeAnimatedModule.connectAnimatedNodes.mock.calls.filter(
|
||||
call => call[1] === multiplicationNodeTag,
|
||||
);
|
||||
expect(multiplicationConnectionCalls.length).toBe(2);
|
||||
expect(NativeAnimatedModule.createAnimatedNode).toBeCalledWith(
|
||||
multiplicationCall[1].input[0],
|
||||
@@ -508,15 +514,17 @@ describe('Native Animated', () => {
|
||||
expect.any(Number),
|
||||
{type: 'division', input: expect.any(Array)},
|
||||
);
|
||||
const divisionCalls = NativeAnimatedModule.createAnimatedNode.mock.calls.filter(
|
||||
call => call[1].type === 'division',
|
||||
);
|
||||
const divisionCalls =
|
||||
NativeAnimatedModule.createAnimatedNode.mock.calls.filter(
|
||||
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,
|
||||
);
|
||||
const divisionConnectionCalls =
|
||||
NativeAnimatedModule.connectAnimatedNodes.mock.calls.filter(
|
||||
call => call[1] === divisionNodeTag,
|
||||
);
|
||||
expect(divisionConnectionCalls.length).toBe(2);
|
||||
expect(NativeAnimatedModule.createAnimatedNode).toBeCalledWith(
|
||||
divisionCall[1].input[0],
|
||||
@@ -548,15 +556,17 @@ describe('Native Animated', () => {
|
||||
expect.any(Number),
|
||||
{type: 'modulus', modulus: 4, input: expect.any(Number)},
|
||||
);
|
||||
const moduloCalls = NativeAnimatedModule.createAnimatedNode.mock.calls.filter(
|
||||
call => call[1].type === 'modulus',
|
||||
);
|
||||
const moduloCalls =
|
||||
NativeAnimatedModule.createAnimatedNode.mock.calls.filter(
|
||||
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,
|
||||
);
|
||||
const moduloConnectionCalls =
|
||||
NativeAnimatedModule.connectAnimatedNodes.mock.calls.filter(
|
||||
call => call[1] === moduloNodeTag,
|
||||
);
|
||||
expect(moduloConnectionCalls.length).toBe(1);
|
||||
expect(NativeAnimatedModule.createAnimatedNode).toBeCalledWith(
|
||||
moduloCall[1].input,
|
||||
@@ -597,12 +607,14 @@ describe('Native Animated', () => {
|
||||
extrapolateRight: 'extend',
|
||||
},
|
||||
);
|
||||
const interpolationNodeTag = NativeAnimatedModule.createAnimatedNode.mock.calls.find(
|
||||
call => call[1].type === 'interpolation',
|
||||
)[0];
|
||||
const valueNodeTag = NativeAnimatedModule.createAnimatedNode.mock.calls.find(
|
||||
call => call[1].type === 'value',
|
||||
)[0];
|
||||
const interpolationNodeTag =
|
||||
NativeAnimatedModule.createAnimatedNode.mock.calls.find(
|
||||
call => call[1].type === 'interpolation',
|
||||
)[0];
|
||||
const valueNodeTag =
|
||||
NativeAnimatedModule.createAnimatedNode.mock.calls.find(
|
||||
call => call[1].type === 'value',
|
||||
)[0];
|
||||
expect(NativeAnimatedModule.connectAnimatedNodes).toBeCalledWith(
|
||||
valueNodeTag,
|
||||
interpolationNodeTag,
|
||||
@@ -649,15 +661,17 @@ describe('Native Animated', () => {
|
||||
expect.any(Number),
|
||||
{type: 'diffclamp', input: expect.any(Number), max: 20, min: 0},
|
||||
);
|
||||
const diffClampCalls = NativeAnimatedModule.createAnimatedNode.mock.calls.filter(
|
||||
call => call[1].type === 'diffclamp',
|
||||
);
|
||||
const diffClampCalls =
|
||||
NativeAnimatedModule.createAnimatedNode.mock.calls.filter(
|
||||
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,
|
||||
);
|
||||
const diffClampConnectionCalls =
|
||||
NativeAnimatedModule.connectAnimatedNodes.mock.calls.filter(
|
||||
call => call[1] === diffClampNodeTag,
|
||||
);
|
||||
expect(diffClampConnectionCalls.length).toBe(1);
|
||||
expect(NativeAnimatedModule.createAnimatedNode).toBeCalledWith(
|
||||
diffClampCall[1].input,
|
||||
|
||||
@@ -91,366 +91,145 @@ describe('Easing', () => {
|
||||
|
||||
const Samples = {
|
||||
in_quad: [
|
||||
0,
|
||||
0.0030864197530864196,
|
||||
0.012345679012345678,
|
||||
0.027777777777777776,
|
||||
0.04938271604938271,
|
||||
0.0771604938271605,
|
||||
0.1111111111111111,
|
||||
0.15123456790123457,
|
||||
0.19753086419753085,
|
||||
0.25,
|
||||
0.308641975308642,
|
||||
0.37345679012345684,
|
||||
0.4444444444444444,
|
||||
0.5216049382716049,
|
||||
0.6049382716049383,
|
||||
0.6944444444444445,
|
||||
0.7901234567901234,
|
||||
0.8919753086419753,
|
||||
1,
|
||||
0, 0.0030864197530864196, 0.012345679012345678, 0.027777777777777776,
|
||||
0.04938271604938271, 0.0771604938271605, 0.1111111111111111,
|
||||
0.15123456790123457, 0.19753086419753085, 0.25, 0.308641975308642,
|
||||
0.37345679012345684, 0.4444444444444444, 0.5216049382716049,
|
||||
0.6049382716049383, 0.6944444444444445, 0.7901234567901234,
|
||||
0.8919753086419753, 1,
|
||||
],
|
||||
out_quad: [
|
||||
0,
|
||||
0.10802469135802469,
|
||||
0.20987654320987653,
|
||||
0.3055555555555555,
|
||||
0.3950617283950617,
|
||||
0.47839506172839513,
|
||||
0.5555555555555556,
|
||||
0.6265432098765432,
|
||||
0.691358024691358,
|
||||
0.75,
|
||||
0.8024691358024691,
|
||||
0.8487654320987654,
|
||||
0.888888888888889,
|
||||
0.9228395061728394,
|
||||
0.9506172839506174,
|
||||
0.9722222222222221,
|
||||
0.9876543209876543,
|
||||
0.9969135802469136,
|
||||
1,
|
||||
0, 0.10802469135802469, 0.20987654320987653, 0.3055555555555555,
|
||||
0.3950617283950617, 0.47839506172839513, 0.5555555555555556,
|
||||
0.6265432098765432, 0.691358024691358, 0.75, 0.8024691358024691,
|
||||
0.8487654320987654, 0.888888888888889, 0.9228395061728394,
|
||||
0.9506172839506174, 0.9722222222222221, 0.9876543209876543,
|
||||
0.9969135802469136, 1,
|
||||
],
|
||||
inOut_quad: [
|
||||
0,
|
||||
0.006172839506172839,
|
||||
0.024691358024691357,
|
||||
0.05555555555555555,
|
||||
0.09876543209876543,
|
||||
0.154320987654321,
|
||||
0.2222222222222222,
|
||||
0.30246913580246915,
|
||||
0.3950617283950617,
|
||||
0.5,
|
||||
0.6049382716049383,
|
||||
0.697530864197531,
|
||||
0.7777777777777777,
|
||||
0.845679012345679,
|
||||
0.9012345679012346,
|
||||
0.9444444444444444,
|
||||
0.9753086419753086,
|
||||
0.9938271604938271,
|
||||
1,
|
||||
0, 0.006172839506172839, 0.024691358024691357, 0.05555555555555555,
|
||||
0.09876543209876543, 0.154320987654321, 0.2222222222222222,
|
||||
0.30246913580246915, 0.3950617283950617, 0.5, 0.6049382716049383,
|
||||
0.697530864197531, 0.7777777777777777, 0.845679012345679,
|
||||
0.9012345679012346, 0.9444444444444444, 0.9753086419753086,
|
||||
0.9938271604938271, 1,
|
||||
],
|
||||
in_cubic: [
|
||||
0,
|
||||
0.00017146776406035664,
|
||||
0.0013717421124828531,
|
||||
0.004629629629629629,
|
||||
0.010973936899862825,
|
||||
0.021433470507544586,
|
||||
0.037037037037037035,
|
||||
0.05881344307270234,
|
||||
0.0877914951989026,
|
||||
0.125,
|
||||
0.1714677640603567,
|
||||
0.22822359396433475,
|
||||
0.2962962962962963,
|
||||
0.37671467764060357,
|
||||
0.4705075445816187,
|
||||
0.5787037037037038,
|
||||
0.7023319615912208,
|
||||
0.8424211248285322,
|
||||
1,
|
||||
0, 0.00017146776406035664, 0.0013717421124828531, 0.004629629629629629,
|
||||
0.010973936899862825, 0.021433470507544586, 0.037037037037037035,
|
||||
0.05881344307270234, 0.0877914951989026, 0.125, 0.1714677640603567,
|
||||
0.22822359396433475, 0.2962962962962963, 0.37671467764060357,
|
||||
0.4705075445816187, 0.5787037037037038, 0.7023319615912208,
|
||||
0.8424211248285322, 1,
|
||||
],
|
||||
out_cubic: [
|
||||
0,
|
||||
0.15757887517146785,
|
||||
0.2976680384087792,
|
||||
0.42129629629629617,
|
||||
0.5294924554183813,
|
||||
0.6232853223593964,
|
||||
0.7037037037037036,
|
||||
0.7717764060356652,
|
||||
0.8285322359396433,
|
||||
0.875,
|
||||
0.9122085048010974,
|
||||
0.9411865569272977,
|
||||
0.9629629629629629,
|
||||
0.9785665294924554,
|
||||
0.9890260631001372,
|
||||
0.9953703703703703,
|
||||
0.9986282578875172,
|
||||
0.9998285322359396,
|
||||
1,
|
||||
0, 0.15757887517146785, 0.2976680384087792, 0.42129629629629617,
|
||||
0.5294924554183813, 0.6232853223593964, 0.7037037037037036,
|
||||
0.7717764060356652, 0.8285322359396433, 0.875, 0.9122085048010974,
|
||||
0.9411865569272977, 0.9629629629629629, 0.9785665294924554,
|
||||
0.9890260631001372, 0.9953703703703703, 0.9986282578875172,
|
||||
0.9998285322359396, 1,
|
||||
],
|
||||
inOut_cubic: [
|
||||
0,
|
||||
0.0006858710562414266,
|
||||
0.0054869684499314125,
|
||||
0.018518518518518517,
|
||||
0.0438957475994513,
|
||||
0.08573388203017834,
|
||||
0.14814814814814814,
|
||||
0.23525377229080935,
|
||||
0.3511659807956104,
|
||||
0.5,
|
||||
0.6488340192043895,
|
||||
0.7647462277091908,
|
||||
0.8518518518518519,
|
||||
0.9142661179698217,
|
||||
0.9561042524005487,
|
||||
0.9814814814814815,
|
||||
0.9945130315500685,
|
||||
0.9993141289437586,
|
||||
1,
|
||||
0, 0.0006858710562414266, 0.0054869684499314125, 0.018518518518518517,
|
||||
0.0438957475994513, 0.08573388203017834, 0.14814814814814814,
|
||||
0.23525377229080935, 0.3511659807956104, 0.5, 0.6488340192043895,
|
||||
0.7647462277091908, 0.8518518518518519, 0.9142661179698217,
|
||||
0.9561042524005487, 0.9814814814814815, 0.9945130315500685,
|
||||
0.9993141289437586, 1,
|
||||
],
|
||||
in_sin: [
|
||||
0,
|
||||
0.003805301908254455,
|
||||
0.01519224698779198,
|
||||
0.03407417371093169,
|
||||
0.06030737921409157,
|
||||
0.09369221296335006,
|
||||
0.1339745962155613,
|
||||
0.1808479557110082,
|
||||
0.233955556881022,
|
||||
0.2928932188134524,
|
||||
0.35721239031346064,
|
||||
0.42642356364895384,
|
||||
0.4999999999999999,
|
||||
0.5773817382593005,
|
||||
0.6579798566743311,
|
||||
0.7411809548974793,
|
||||
0.8263518223330696,
|
||||
0.9128442572523416,
|
||||
0.9999999999999999,
|
||||
0, 0.003805301908254455, 0.01519224698779198, 0.03407417371093169,
|
||||
0.06030737921409157, 0.09369221296335006, 0.1339745962155613,
|
||||
0.1808479557110082, 0.233955556881022, 0.2928932188134524,
|
||||
0.35721239031346064, 0.42642356364895384, 0.4999999999999999,
|
||||
0.5773817382593005, 0.6579798566743311, 0.7411809548974793,
|
||||
0.8263518223330696, 0.9128442572523416, 0.9999999999999999,
|
||||
],
|
||||
out_sin: [
|
||||
0,
|
||||
0.08715574274765817,
|
||||
0.17364817766693033,
|
||||
0.25881904510252074,
|
||||
0.3420201433256687,
|
||||
0.42261826174069944,
|
||||
0.49999999999999994,
|
||||
0.573576436351046,
|
||||
0.6427876096865393,
|
||||
0.7071067811865475,
|
||||
0.766044443118978,
|
||||
0.8191520442889918,
|
||||
0.8660254037844386,
|
||||
0.9063077870366499,
|
||||
0.9396926207859083,
|
||||
0.9659258262890683,
|
||||
0.984807753012208,
|
||||
0.9961946980917455,
|
||||
1,
|
||||
0, 0.08715574274765817, 0.17364817766693033, 0.25881904510252074,
|
||||
0.3420201433256687, 0.42261826174069944, 0.49999999999999994,
|
||||
0.573576436351046, 0.6427876096865393, 0.7071067811865475,
|
||||
0.766044443118978, 0.8191520442889918, 0.8660254037844386,
|
||||
0.9063077870366499, 0.9396926207859083, 0.9659258262890683,
|
||||
0.984807753012208, 0.9961946980917455, 1,
|
||||
],
|
||||
inOut_sin: [
|
||||
0,
|
||||
0.00759612349389599,
|
||||
0.030153689607045786,
|
||||
0.06698729810778065,
|
||||
0.116977778440511,
|
||||
0.17860619515673032,
|
||||
0.24999999999999994,
|
||||
0.32898992833716556,
|
||||
0.4131759111665348,
|
||||
0.49999999999999994,
|
||||
0.5868240888334652,
|
||||
0.6710100716628343,
|
||||
0.7499999999999999,
|
||||
0.8213938048432696,
|
||||
0.883022221559489,
|
||||
0.9330127018922194,
|
||||
0.9698463103929542,
|
||||
0.9924038765061041,
|
||||
1,
|
||||
0, 0.00759612349389599, 0.030153689607045786, 0.06698729810778065,
|
||||
0.116977778440511, 0.17860619515673032, 0.24999999999999994,
|
||||
0.32898992833716556, 0.4131759111665348, 0.49999999999999994,
|
||||
0.5868240888334652, 0.6710100716628343, 0.7499999999999999,
|
||||
0.8213938048432696, 0.883022221559489, 0.9330127018922194,
|
||||
0.9698463103929542, 0.9924038765061041, 1,
|
||||
],
|
||||
in_exp: [
|
||||
0,
|
||||
0.0014352875901128893,
|
||||
0.002109491677524035,
|
||||
0.0031003926796253885,
|
||||
0.004556754060844206,
|
||||
0.006697218616039631,
|
||||
0.009843133202303688,
|
||||
0.014466792379488908,
|
||||
0.021262343752724643,
|
||||
0.03125,
|
||||
0.045929202883612456,
|
||||
0.06750373368076916,
|
||||
0.09921256574801243,
|
||||
0.1458161299470146,
|
||||
0.2143109957132682,
|
||||
0.31498026247371835,
|
||||
0.46293735614364506,
|
||||
0.6803950000871883,
|
||||
1,
|
||||
0, 0.0014352875901128893, 0.002109491677524035, 0.0031003926796253885,
|
||||
0.004556754060844206, 0.006697218616039631, 0.009843133202303688,
|
||||
0.014466792379488908, 0.021262343752724643, 0.03125, 0.045929202883612456,
|
||||
0.06750373368076916, 0.09921256574801243, 0.1458161299470146,
|
||||
0.2143109957132682, 0.31498026247371835, 0.46293735614364506,
|
||||
0.6803950000871883, 1,
|
||||
],
|
||||
out_exp: [
|
||||
0,
|
||||
0.31960499991281155,
|
||||
0.5370626438563548,
|
||||
0.6850197375262816,
|
||||
0.7856890042867318,
|
||||
0.8541838700529854,
|
||||
0.9007874342519875,
|
||||
0.9324962663192309,
|
||||
0.9540707971163875,
|
||||
0.96875,
|
||||
0.9787376562472754,
|
||||
0.9855332076205111,
|
||||
0.9901568667976963,
|
||||
0.9933027813839603,
|
||||
0.9954432459391558,
|
||||
0.9968996073203746,
|
||||
0.9978905083224759,
|
||||
0.9985647124098871,
|
||||
1,
|
||||
0, 0.31960499991281155, 0.5370626438563548, 0.6850197375262816,
|
||||
0.7856890042867318, 0.8541838700529854, 0.9007874342519875,
|
||||
0.9324962663192309, 0.9540707971163875, 0.96875, 0.9787376562472754,
|
||||
0.9855332076205111, 0.9901568667976963, 0.9933027813839603,
|
||||
0.9954432459391558, 0.9968996073203746, 0.9978905083224759,
|
||||
0.9985647124098871, 1,
|
||||
],
|
||||
inOut_exp: [
|
||||
0,
|
||||
0.0010547458387620175,
|
||||
0.002278377030422103,
|
||||
0.004921566601151844,
|
||||
0.010631171876362321,
|
||||
0.022964601441806228,
|
||||
0.049606282874006216,
|
||||
0.1071554978566341,
|
||||
0.23146867807182253,
|
||||
0.5,
|
||||
0.7685313219281775,
|
||||
0.892844502143366,
|
||||
0.9503937171259937,
|
||||
0.9770353985581938,
|
||||
0.9893688281236377,
|
||||
0.9950784333988482,
|
||||
0.9977216229695779,
|
||||
0.998945254161238,
|
||||
1,
|
||||
0, 0.0010547458387620175, 0.002278377030422103, 0.004921566601151844,
|
||||
0.010631171876362321, 0.022964601441806228, 0.049606282874006216,
|
||||
0.1071554978566341, 0.23146867807182253, 0.5, 0.7685313219281775,
|
||||
0.892844502143366, 0.9503937171259937, 0.9770353985581938,
|
||||
0.9893688281236377, 0.9950784333988482, 0.9977216229695779,
|
||||
0.998945254161238, 1,
|
||||
],
|
||||
in_circle: [
|
||||
0,
|
||||
0.0015444024660317135,
|
||||
0.006192010000093506,
|
||||
0.013986702816730645,
|
||||
0.025003956956430873,
|
||||
0.03935464078941209,
|
||||
0.057190958417936644,
|
||||
0.07871533601238889,
|
||||
0.10419358352238339,
|
||||
0.1339745962155614,
|
||||
0.1685205807169019,
|
||||
0.20845517506805522,
|
||||
0.2546440075000701,
|
||||
0.3083389112228482,
|
||||
0.37146063894529113,
|
||||
0.4472292016074334,
|
||||
0.5418771527091488,
|
||||
0.6713289009389102,
|
||||
1,
|
||||
0, 0.0015444024660317135, 0.006192010000093506, 0.013986702816730645,
|
||||
0.025003956956430873, 0.03935464078941209, 0.057190958417936644,
|
||||
0.07871533601238889, 0.10419358352238339, 0.1339745962155614,
|
||||
0.1685205807169019, 0.20845517506805522, 0.2546440075000701,
|
||||
0.3083389112228482, 0.37146063894529113, 0.4472292016074334,
|
||||
0.5418771527091488, 0.6713289009389102, 1,
|
||||
],
|
||||
out_circle: [
|
||||
0,
|
||||
0.3286710990610898,
|
||||
0.45812284729085123,
|
||||
0.5527707983925666,
|
||||
0.6285393610547089,
|
||||
0.6916610887771518,
|
||||
0.7453559924999298,
|
||||
0.7915448249319448,
|
||||
0.8314794192830981,
|
||||
0.8660254037844386,
|
||||
0.8958064164776166,
|
||||
0.9212846639876111,
|
||||
0.9428090415820634,
|
||||
0.9606453592105879,
|
||||
0.9749960430435691,
|
||||
0.9860132971832694,
|
||||
0.9938079899999065,
|
||||
0.9984555975339683,
|
||||
1,
|
||||
0, 0.3286710990610898, 0.45812284729085123, 0.5527707983925666,
|
||||
0.6285393610547089, 0.6916610887771518, 0.7453559924999298,
|
||||
0.7915448249319448, 0.8314794192830981, 0.8660254037844386,
|
||||
0.8958064164776166, 0.9212846639876111, 0.9428090415820634,
|
||||
0.9606453592105879, 0.9749960430435691, 0.9860132971832694,
|
||||
0.9938079899999065, 0.9984555975339683, 1,
|
||||
],
|
||||
inOut_circle: [
|
||||
0,
|
||||
0.003096005000046753,
|
||||
0.012501978478215436,
|
||||
0.028595479208968322,
|
||||
0.052096791761191696,
|
||||
0.08426029035845095,
|
||||
0.12732200375003505,
|
||||
0.18573031947264557,
|
||||
0.2709385763545744,
|
||||
0.5,
|
||||
0.7290614236454256,
|
||||
0.8142696805273546,
|
||||
0.8726779962499649,
|
||||
0.915739709641549,
|
||||
0.9479032082388084,
|
||||
0.9714045207910317,
|
||||
0.9874980215217846,
|
||||
0.9969039949999532,
|
||||
1,
|
||||
0, 0.003096005000046753, 0.012501978478215436, 0.028595479208968322,
|
||||
0.052096791761191696, 0.08426029035845095, 0.12732200375003505,
|
||||
0.18573031947264557, 0.2709385763545744, 0.5, 0.7290614236454256,
|
||||
0.8142696805273546, 0.8726779962499649, 0.915739709641549,
|
||||
0.9479032082388084, 0.9714045207910317, 0.9874980215217846,
|
||||
0.9969039949999532, 1,
|
||||
],
|
||||
in_back_: [
|
||||
0,
|
||||
-0.004788556241426612,
|
||||
-0.017301289437585736,
|
||||
-0.0347587962962963,
|
||||
-0.05438167352537723,
|
||||
-0.07339051783264748,
|
||||
-0.08900592592592595,
|
||||
-0.09844849451303156,
|
||||
-0.0989388203017833,
|
||||
-0.08769750000000004,
|
||||
-0.06194513031550073,
|
||||
-0.018902307956104283,
|
||||
0.044210370370370254,
|
||||
0.13017230795610413,
|
||||
0.2417629080932785,
|
||||
0.3817615740740742,
|
||||
0.5529477091906719,
|
||||
0.7581007167352535,
|
||||
0.9999999999999998,
|
||||
0, -0.004788556241426612, -0.017301289437585736, -0.0347587962962963,
|
||||
-0.05438167352537723, -0.07339051783264748, -0.08900592592592595,
|
||||
-0.09844849451303156, -0.0989388203017833, -0.08769750000000004,
|
||||
-0.06194513031550073, -0.018902307956104283, 0.044210370370370254,
|
||||
0.13017230795610413, 0.2417629080932785, 0.3817615740740742,
|
||||
0.5529477091906719, 0.7581007167352535, 0.9999999999999998,
|
||||
],
|
||||
out_back_: [
|
||||
2.220446049250313e-16,
|
||||
0.24189928326474652,
|
||||
0.44705229080932807,
|
||||
0.6182384259259258,
|
||||
0.7582370919067215,
|
||||
0.8698276920438959,
|
||||
0.9557896296296297,
|
||||
1.0189023079561044,
|
||||
1.0619451303155008,
|
||||
1.0876975,
|
||||
1.0989388203017834,
|
||||
1.0984484945130315,
|
||||
1.089005925925926,
|
||||
1.0733905178326475,
|
||||
1.0543816735253773,
|
||||
1.0347587962962963,
|
||||
1.0173012894375857,
|
||||
1.0047885562414267,
|
||||
1,
|
||||
2.220446049250313e-16, 0.24189928326474652, 0.44705229080932807,
|
||||
0.6182384259259258, 0.7582370919067215, 0.8698276920438959,
|
||||
0.9557896296296297, 1.0189023079561044, 1.0619451303155008, 1.0876975,
|
||||
1.0989388203017834, 1.0984484945130315, 1.089005925925926,
|
||||
1.0733905178326475, 1.0543816735253773, 1.0347587962962963,
|
||||
1.0173012894375857, 1.0047885562414267, 1,
|
||||
],
|
||||
};
|
||||
|
||||
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));
|
||||
|
||||
@@ -119,15 +119,16 @@ class AnimatedNode {
|
||||
}
|
||||
|
||||
NativeAnimatedAPI.startListeningToAnimatedNodeValue(this.__getNativeTag());
|
||||
this.__nativeAnimatedValueListener = NativeAnimatedHelper.nativeEventEmitter.addListener(
|
||||
'onAnimatedValueUpdate',
|
||||
data => {
|
||||
if (data.tag !== this.__getNativeTag()) {
|
||||
return;
|
||||
}
|
||||
this._onAnimatedValueUpdateReceived(data.value);
|
||||
},
|
||||
);
|
||||
this.__nativeAnimatedValueListener =
|
||||
NativeAnimatedHelper.nativeEventEmitter.addListener(
|
||||
'onAnimatedValueUpdate',
|
||||
data => {
|
||||
if (data.tag !== this.__getNativeTag()) {
|
||||
return;
|
||||
}
|
||||
this._onAnimatedValueUpdateReceived(data.value);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
_onAnimatedValueUpdateReceived(value: number) {
|
||||
|
||||
@@ -38,7 +38,7 @@ class AnimatedValueXY extends AnimatedWithChildren {
|
||||
y: string,
|
||||
...
|
||||
},
|
||||
...,
|
||||
...
|
||||
};
|
||||
|
||||
constructor(
|
||||
|
||||
@@ -47,11 +47,12 @@ class AppState {
|
||||
} else {
|
||||
this.isAvailable = true;
|
||||
|
||||
const emitter: NativeEventEmitter<NativeAppStateEventDefinitions> = new NativeEventEmitter(
|
||||
// T88715063: NativeEventEmitter only used this parameter on iOS. Now it uses it on all platforms, so this code was modified automatically to preserve its behavior
|
||||
// If you want to use the native module on other platforms, please remove this condition and test its behavior
|
||||
Platform.OS !== 'ios' ? null : NativeAppState,
|
||||
);
|
||||
const emitter: NativeEventEmitter<NativeAppStateEventDefinitions> =
|
||||
new NativeEventEmitter(
|
||||
// T88715063: NativeEventEmitter only used this parameter on iOS. Now it uses it on all platforms, so this code was modified automatically to preserve its behavior
|
||||
// If you want to use the native module on other platforms, please remove this condition and test its behavior
|
||||
Platform.OS !== 'ios' ? null : NativeAppState,
|
||||
);
|
||||
this._emitter = emitter;
|
||||
|
||||
this.currentState = NativeAppState.getConstants().initialAppState;
|
||||
|
||||
@@ -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');
|
||||
@@ -141,7 +141,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);
|
||||
@@ -153,7 +153,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';
|
||||
});
|
||||
|
||||
@@ -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/');
|
||||
|
||||
@@ -44,24 +44,26 @@ type AccessibilityEventDefinitions = {
|
||||
type AccessibilityEventTypes = 'click' | 'focus';
|
||||
|
||||
// Mapping of public event names to platform-specific event names.
|
||||
const EventNames: Map<$Keys<AccessibilityEventDefinitions>, string> =
|
||||
Platform.OS === 'android'
|
||||
? new Map([
|
||||
['change', 'touchExplorationDidChange'],
|
||||
['reduceMotionChanged', 'reduceMotionDidChange'],
|
||||
['screenReaderChanged', 'touchExplorationDidChange'],
|
||||
['accessibilityServiceChanged', 'accessibilityServiceDidChange'],
|
||||
])
|
||||
: new Map([
|
||||
['announcementFinished', 'announcementFinished'],
|
||||
['boldTextChanged', 'boldTextChanged'],
|
||||
['change', 'screenReaderChanged'],
|
||||
['grayscaleChanged', 'grayscaleChanged'],
|
||||
['invertColorsChanged', 'invertColorsChanged'],
|
||||
['reduceMotionChanged', 'reduceMotionChanged'],
|
||||
['reduceTransparencyChanged', 'reduceTransparencyChanged'],
|
||||
['screenReaderChanged', 'screenReaderChanged'],
|
||||
]);
|
||||
const EventNames: Map<
|
||||
$Keys<AccessibilityEventDefinitions>,
|
||||
string,
|
||||
> = Platform.OS === 'android'
|
||||
? new Map([
|
||||
['change', 'touchExplorationDidChange'],
|
||||
['reduceMotionChanged', 'reduceMotionDidChange'],
|
||||
['screenReaderChanged', 'touchExplorationDidChange'],
|
||||
['accessibilityServiceChanged', 'accessibilityServiceDidChange'],
|
||||
])
|
||||
: new Map([
|
||||
['announcementFinished', 'announcementFinished'],
|
||||
['boldTextChanged', 'boldTextChanged'],
|
||||
['change', 'screenReaderChanged'],
|
||||
['grayscaleChanged', 'grayscaleChanged'],
|
||||
['invertColorsChanged', 'invertColorsChanged'],
|
||||
['reduceMotionChanged', 'reduceMotionChanged'],
|
||||
['reduceTransparencyChanged', 'reduceTransparencyChanged'],
|
||||
['screenReaderChanged', 'screenReaderChanged'],
|
||||
]);
|
||||
|
||||
/**
|
||||
* Sometimes it's useful to know whether or not the device has a screen reader
|
||||
|
||||
@@ -162,9 +162,10 @@ class DrawerLayoutAndroid extends React.Component<Props, State> {
|
||||
return {Left: 'left', Right: 'right'};
|
||||
}
|
||||
|
||||
_nativeRef = React.createRef<
|
||||
React.ElementRef<typeof AndroidDrawerLayoutNativeComponent>,
|
||||
>();
|
||||
_nativeRef =
|
||||
React.createRef<
|
||||
React.ElementRef<typeof AndroidDrawerLayoutNativeComponent>,
|
||||
>();
|
||||
|
||||
state: State = {statusBarBackgroundColor: null};
|
||||
|
||||
|
||||
@@ -103,11 +103,12 @@ type KeyboardEventDefinitions = {
|
||||
*/
|
||||
|
||||
class Keyboard {
|
||||
_emitter: NativeEventEmitter<KeyboardEventDefinitions> = new NativeEventEmitter(
|
||||
// T88715063: NativeEventEmitter only used this parameter on iOS. Now it uses it on all platforms, so this code was modified automatically to preserve its behavior
|
||||
// If you want to use the native module on other platforms, please remove this condition and test its behavior
|
||||
Platform.OS !== 'ios' ? null : NativeKeyboardObserver,
|
||||
);
|
||||
_emitter: NativeEventEmitter<KeyboardEventDefinitions> =
|
||||
new NativeEventEmitter(
|
||||
// T88715063: NativeEventEmitter only used this parameter on iOS. Now it uses it on all platforms, so this code was modified automatically to preserve its behavior
|
||||
// If you want to use the native module on other platforms, please remove this condition and test its behavior
|
||||
Platform.OS !== 'ios' ? null : NativeKeyboardObserver,
|
||||
);
|
||||
|
||||
/**
|
||||
* The `addListener` function connects a JavaScript function to an identified native
|
||||
|
||||
@@ -71,4 +71,5 @@ const styles = StyleSheet.create({
|
||||
|
||||
const ProgressViewIOSWithRef = React.forwardRef(ProgressViewIOS);
|
||||
|
||||
module.exports = (ProgressViewIOSWithRef: typeof RCTProgressViewNativeComponent);
|
||||
module.exports =
|
||||
(ProgressViewIOSWithRef: typeof RCTProgressViewNativeComponent);
|
||||
|
||||
@@ -158,13 +158,8 @@ class RefreshControl extends React.Component<RefreshControlProps> {
|
||||
|
||||
render(): React.Node {
|
||||
if (Platform.OS === 'ios') {
|
||||
const {
|
||||
enabled,
|
||||
colors,
|
||||
progressBackgroundColor,
|
||||
size,
|
||||
...props
|
||||
} = this.props;
|
||||
const {enabled, colors, progressBackgroundColor, size, ...props} =
|
||||
this.props;
|
||||
return (
|
||||
<PullToRefreshViewNativeComponent
|
||||
{...props}
|
||||
|
||||
@@ -15,9 +15,8 @@ import requireNativeComponent from '../../../ReactNative/requireNativeComponent'
|
||||
|
||||
import type {HostComponent} from '../../../Renderer/shims/ReactNativeTypes';
|
||||
|
||||
const RCTRefreshControl: HostComponent<mixed> = requireNativeComponent<mixed>(
|
||||
'RCTRefreshControl',
|
||||
);
|
||||
const RCTRefreshControl: HostComponent<mixed> =
|
||||
requireNativeComponent<mixed>('RCTRefreshControl');
|
||||
|
||||
class RefreshControlMock extends React.Component<{...}> {
|
||||
static latestRef: ?RefreshControlMock;
|
||||
|
||||
@@ -42,8 +42,8 @@ if (Platform.OS === 'android') {
|
||||
},
|
||||
);
|
||||
} else {
|
||||
const RCTSafeAreaViewNativeComponent = require('./RCTSafeAreaViewNativeComponent')
|
||||
.default;
|
||||
const RCTSafeAreaViewNativeComponent =
|
||||
require('./RCTSafeAreaViewNativeComponent').default;
|
||||
|
||||
exported = React.forwardRef<Props, React.ElementRef<HostComponent<mixed>>>(
|
||||
function SafeAreaView(props, forwardedRef) {
|
||||
|
||||
@@ -12,9 +12,8 @@ import type {ScrollViewNativeProps as Props} from './ScrollViewNativeComponentTy
|
||||
import type {HostComponent} from '../../Renderer/shims/ReactNativeTypes';
|
||||
import * as NativeComponentRegistry from '../../NativeComponent/NativeComponentRegistry';
|
||||
|
||||
const AndroidHorizontalScrollViewNativeComponent: HostComponent<Props> = NativeComponentRegistry.get<Props>(
|
||||
'AndroidHorizontalScrollView',
|
||||
() => ({
|
||||
const AndroidHorizontalScrollViewNativeComponent: HostComponent<Props> =
|
||||
NativeComponentRegistry.get<Props>('AndroidHorizontalScrollView', () => ({
|
||||
uiViewClassName: 'AndroidHorizontalScrollView',
|
||||
bubblingEventTypes: {},
|
||||
directEventTypes: {},
|
||||
@@ -38,7 +37,6 @@ const AndroidHorizontalScrollViewNativeComponent: HostComponent<Props> = NativeC
|
||||
snapToOffsets: true,
|
||||
contentOffset: true,
|
||||
},
|
||||
}),
|
||||
);
|
||||
}));
|
||||
|
||||
export default AndroidHorizontalScrollViewNativeComponent;
|
||||
|
||||
@@ -12,14 +12,12 @@ import type {HostComponent} from '../../Renderer/shims/ReactNativeTypes';
|
||||
import * as NativeComponentRegistry from '../../NativeComponent/NativeComponentRegistry';
|
||||
import type {ViewProps as Props} from '../View/ViewPropTypes';
|
||||
|
||||
const ScrollContentViewNativeComponent: HostComponent<Props> = NativeComponentRegistry.get<Props>(
|
||||
'RCTScrollContentView',
|
||||
() => ({
|
||||
const ScrollContentViewNativeComponent: HostComponent<Props> =
|
||||
NativeComponentRegistry.get<Props>('RCTScrollContentView', () => ({
|
||||
uiViewClassName: 'RCTScrollContentView',
|
||||
bubblingEventTypes: {},
|
||||
directEventTypes: {},
|
||||
validAttributes: {},
|
||||
}),
|
||||
);
|
||||
}));
|
||||
|
||||
export default ScrollContentViewNativeComponent;
|
||||
|
||||
@@ -721,10 +721,8 @@ class ScrollView extends React.Component<Props, State> {
|
||||
|
||||
_scrollAnimatedValue: AnimatedImplementation.Value;
|
||||
_scrollAnimatedValueAttachment: ?{detach: () => void, ...} = null;
|
||||
_stickyHeaderRefs: Map<
|
||||
string,
|
||||
React.ElementRef<StickyHeaderComponentType>,
|
||||
> = new Map();
|
||||
_stickyHeaderRefs: Map<string, React.ElementRef<StickyHeaderComponentType>> =
|
||||
new Map();
|
||||
_headerLayoutYs: Map<string, number> = new Map();
|
||||
|
||||
_keyboardWillOpenTo: ?KeyboardEvent = null;
|
||||
@@ -845,7 +843,8 @@ class ScrollView extends React.Component<Props, State> {
|
||||
ref.scrollToEnd = this.scrollToEnd;
|
||||
ref.flashScrollIndicators = this.flashScrollIndicators;
|
||||
ref.scrollResponderZoomTo = this.scrollResponderZoomTo;
|
||||
ref.scrollResponderScrollNativeHandleToKeyboard = this.scrollResponderScrollNativeHandleToKeyboard;
|
||||
ref.scrollResponderScrollNativeHandleToKeyboard =
|
||||
this.scrollResponderScrollNativeHandleToKeyboard;
|
||||
}
|
||||
},
|
||||
});
|
||||
@@ -1115,11 +1114,12 @@ class ScrollView extends React.Component<Props, State> {
|
||||
this.props.stickyHeaderIndices &&
|
||||
this.props.stickyHeaderIndices.length > 0
|
||||
) {
|
||||
this._scrollAnimatedValueAttachment = AnimatedImplementation.attachNativeEvent(
|
||||
this._scrollViewRef,
|
||||
'onScroll',
|
||||
[{nativeEvent: {contentOffset: {y: this._scrollAnimatedValue}}}],
|
||||
);
|
||||
this._scrollAnimatedValueAttachment =
|
||||
AnimatedImplementation.attachNativeEvent(
|
||||
this._scrollViewRef,
|
||||
'onScroll',
|
||||
[{nativeEvent: {contentOffset: {y: this._scrollAnimatedValue}}}],
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1721,8 +1721,8 @@ class ScrollView extends React.Component<Props, State> {
|
||||
onScrollEndDrag: this._handleScrollEndDrag,
|
||||
onScrollShouldSetResponder: this._handleScrollShouldSetResponder,
|
||||
onStartShouldSetResponder: this._handleStartShouldSetResponder,
|
||||
onStartShouldSetResponderCapture: this
|
||||
._handleStartShouldSetResponderCapture,
|
||||
onStartShouldSetResponderCapture:
|
||||
this._handleStartShouldSetResponderCapture,
|
||||
onTouchEnd: this._handleTouchEnd,
|
||||
onTouchMove: this._handleTouchMove,
|
||||
onTouchStart: this._handleTouchStart,
|
||||
|
||||
@@ -12,9 +12,8 @@ import type {ScrollViewNativeProps as Props} from './ScrollViewNativeComponentTy
|
||||
import type {HostComponent} from '../../Renderer/shims/ReactNativeTypes';
|
||||
import * as NativeComponentRegistry from '../../NativeComponent/NativeComponentRegistry';
|
||||
|
||||
const ScrollViewNativeComponent: HostComponent<Props> = NativeComponentRegistry.get<Props>(
|
||||
'RCTScrollView',
|
||||
() => ({
|
||||
const ScrollViewNativeComponent: HostComponent<Props> =
|
||||
NativeComponentRegistry.get<Props>('RCTScrollView', () => ({
|
||||
uiViewClassName: 'RCTScrollView',
|
||||
bubblingEventTypes: {},
|
||||
directEventTypes: {
|
||||
@@ -80,7 +79,6 @@ const ScrollViewNativeComponent: HostComponent<Props> = NativeComponentRegistry.
|
||||
snapToStart: true,
|
||||
zoomScale: true,
|
||||
},
|
||||
}),
|
||||
);
|
||||
}));
|
||||
|
||||
export default ScrollViewNativeComponent;
|
||||
|
||||
@@ -87,14 +87,8 @@ class SegmentedControlIOS extends React.Component<Props> {
|
||||
};
|
||||
|
||||
render() {
|
||||
const {
|
||||
enabled,
|
||||
forwardedRef,
|
||||
onValueChange,
|
||||
style,
|
||||
values,
|
||||
...props
|
||||
} = this.props;
|
||||
const {enabled, forwardedRef, onValueChange, style, values, ...props} =
|
||||
this.props;
|
||||
return (
|
||||
<RCTSegmentedControlNativeComponent
|
||||
{...props}
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
import NativeSoundManager from './NativeSoundManager';
|
||||
|
||||
const SoundManager = {
|
||||
playTouchSound: function(): void {
|
||||
playTouchSound: function (): void {
|
||||
if (NativeSoundManager) {
|
||||
NativeSoundManager.playTouchSound();
|
||||
}
|
||||
|
||||
@@ -22,10 +22,11 @@ export const Commands: NativeCommands = codegenNativeCommands<NativeCommands>({
|
||||
supportedCommands: ['focus', 'blur', 'setTextAndSelection'],
|
||||
});
|
||||
|
||||
const MultilineTextInputNativeComponent: HostComponent<mixed> = NativeComponentRegistry.get<mixed>(
|
||||
'RCTMultilineTextInputView',
|
||||
() => RCTTextInputViewConfig,
|
||||
);
|
||||
const MultilineTextInputNativeComponent: HostComponent<mixed> =
|
||||
NativeComponentRegistry.get<mixed>(
|
||||
'RCTMultilineTextInputView',
|
||||
() => RCTTextInputViewConfig,
|
||||
);
|
||||
|
||||
// flowlint-next-line unclear-type:off
|
||||
export default ((MultilineTextInputNativeComponent: any): HostComponent<mixed>);
|
||||
|
||||
@@ -22,10 +22,11 @@ export const Commands: NativeCommands = codegenNativeCommands<NativeCommands>({
|
||||
supportedCommands: ['focus', 'blur', 'setTextAndSelection'],
|
||||
});
|
||||
|
||||
const SinglelineTextInputNativeComponent: HostComponent<mixed> = NativeComponentRegistry.get<mixed>(
|
||||
'RCTSinglelineTextInputView',
|
||||
() => RCTTextInputViewConfig,
|
||||
);
|
||||
const SinglelineTextInputNativeComponent: HostComponent<mixed> =
|
||||
NativeComponentRegistry.get<mixed>(
|
||||
'RCTSinglelineTextInputView',
|
||||
() => RCTTextInputViewConfig,
|
||||
);
|
||||
|
||||
// flowlint-next-line unclear-type:off
|
||||
export default ((SinglelineTextInputNativeComponent: any): HostComponent<mixed>);
|
||||
|
||||
@@ -46,17 +46,17 @@ let RCTMultilineTextInputNativeCommands;
|
||||
|
||||
if (Platform.OS === 'android') {
|
||||
AndroidTextInput = require('./AndroidTextInputNativeComponent').default;
|
||||
AndroidTextInputCommands = require('./AndroidTextInputNativeComponent')
|
||||
.Commands;
|
||||
AndroidTextInputCommands =
|
||||
require('./AndroidTextInputNativeComponent').Commands;
|
||||
} else if (Platform.OS === 'ios') {
|
||||
RCTSinglelineTextInputView = require('./RCTSingelineTextInputNativeComponent')
|
||||
.default;
|
||||
RCTSinglelineTextInputNativeCommands = require('./RCTSingelineTextInputNativeComponent')
|
||||
.Commands;
|
||||
RCTMultilineTextInputView = require('./RCTMultilineTextInputNativeComponent')
|
||||
.default;
|
||||
RCTMultilineTextInputNativeCommands = require('./RCTMultilineTextInputNativeComponent')
|
||||
.Commands;
|
||||
RCTSinglelineTextInputView =
|
||||
require('./RCTSingelineTextInputNativeComponent').default;
|
||||
RCTSinglelineTextInputNativeCommands =
|
||||
require('./RCTSingelineTextInputNativeComponent').Commands;
|
||||
RCTMultilineTextInputView =
|
||||
require('./RCTMultilineTextInputNativeComponent').default;
|
||||
RCTMultilineTextInputNativeCommands =
|
||||
require('./RCTMultilineTextInputNativeComponent').Commands;
|
||||
}
|
||||
|
||||
export type ChangeEvent = SyntheticEvent<
|
||||
@@ -1245,7 +1245,8 @@ const ExportedForwardRef: React.AbstractComponent<
|
||||
* Switch to `deprecated-react-native-prop-types` for compatibility with future
|
||||
* releases. This is deprecated and will be removed in the future.
|
||||
*/
|
||||
ExportedForwardRef.propTypes = require('deprecated-react-native-prop-types').TextInputPropTypes;
|
||||
ExportedForwardRef.propTypes =
|
||||
require('deprecated-react-native-prop-types').TextInputPropTypes;
|
||||
|
||||
// $FlowFixMe[prop-missing]
|
||||
ExportedForwardRef.State = {
|
||||
|
||||
@@ -42,11 +42,11 @@ const ToastAndroid = {
|
||||
BOTTOM: (ToastAndroidConstants.BOTTOM: number),
|
||||
CENTER: (ToastAndroidConstants.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,
|
||||
@@ -54,7 +54,7 @@ const ToastAndroid = {
|
||||
NativeToastAndroid.showWithGravity(message, duration, gravity);
|
||||
},
|
||||
|
||||
showWithGravityAndOffset: function(
|
||||
showWithGravityAndOffset: function (
|
||||
message: string,
|
||||
duration: number,
|
||||
gravity: number,
|
||||
|
||||
@@ -11,11 +11,11 @@
|
||||
'use strict';
|
||||
|
||||
const ToastAndroid = {
|
||||
show: function(message: string, duration: number): void {
|
||||
show: function (message: string, duration: number): void {
|
||||
console.warn('ToastAndroid is not supported on this platform.');
|
||||
},
|
||||
|
||||
showWithGravity: function(
|
||||
showWithGravity: function (
|
||||
message: string,
|
||||
duration: number,
|
||||
gravity: number,
|
||||
@@ -23,7 +23,7 @@ const ToastAndroid = {
|
||||
console.warn('ToastAndroid is not supported on this platform.');
|
||||
},
|
||||
|
||||
showWithGravityAndOffset: function(
|
||||
showWithGravityAndOffset: function (
|
||||
message: string,
|
||||
duration: number,
|
||||
gravity: number,
|
||||
|
||||
@@ -24,7 +24,7 @@ function BoundingDimensions(width, height) {
|
||||
this.height = height;
|
||||
}
|
||||
|
||||
BoundingDimensions.prototype.destructor = function() {
|
||||
BoundingDimensions.prototype.destructor = function () {
|
||||
this.width = null;
|
||||
this.height = null;
|
||||
};
|
||||
@@ -33,7 +33,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,
|
||||
|
||||
@@ -18,7 +18,7 @@ import invariant from '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();
|
||||
@@ -29,7 +29,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();
|
||||
@@ -40,7 +40,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();
|
||||
@@ -51,7 +51,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();
|
||||
@@ -62,7 +62,7 @@ const fourArgumentPooler = function(a1, a2, a3, a4) {
|
||||
}
|
||||
};
|
||||
|
||||
const standardReleaser = function(instance) {
|
||||
const standardReleaser = function (instance) {
|
||||
const Klass = this;
|
||||
invariant(
|
||||
instance instanceof Klass,
|
||||
@@ -88,7 +88,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> & {
|
||||
|
||||
@@ -25,7 +25,7 @@ function Position(left, top) {
|
||||
this.top = top;
|
||||
}
|
||||
|
||||
Position.prototype.destructor = function() {
|
||||
Position.prototype.destructor = function () {
|
||||
this.left = null;
|
||||
this.top = null;
|
||||
};
|
||||
|
||||
@@ -361,7 +361,7 @@ const LONG_PRESS_ALLOWED_MOVEMENT = 10;
|
||||
* @lends Touchable.prototype
|
||||
*/
|
||||
const TouchableMixin = {
|
||||
componentDidMount: function() {
|
||||
componentDidMount: function () {
|
||||
if (!Platform.isTV) {
|
||||
return;
|
||||
}
|
||||
@@ -370,7 +370,7 @@ const TouchableMixin = {
|
||||
/**
|
||||
* Clear all timeouts on unmount
|
||||
*/
|
||||
componentWillUnmount: function() {
|
||||
componentWillUnmount: function () {
|
||||
this.touchableDelayTimeout && clearTimeout(this.touchableDelayTimeout);
|
||||
this.longPressDelayTimeout && clearTimeout(this.longPressDelayTimeout);
|
||||
this.pressOutDelayTimeout && clearTimeout(this.pressOutDelayTimeout);
|
||||
@@ -383,7 +383,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 {
|
||||
@@ -395,21 +395,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;
|
||||
},
|
||||
|
||||
@@ -418,7 +418,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
|
||||
@@ -459,7 +459,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);
|
||||
},
|
||||
@@ -467,7 +467,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);
|
||||
},
|
||||
@@ -475,7 +475,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;
|
||||
@@ -560,7 +560,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);
|
||||
},
|
||||
|
||||
@@ -572,7 +572,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);
|
||||
},
|
||||
|
||||
@@ -652,7 +652,7 @@ const TouchableMixin = {
|
||||
* @sideeffects
|
||||
* @private
|
||||
*/
|
||||
_remeasureMetricsOnActivation: function() {
|
||||
_remeasureMetricsOnActivation: function () {
|
||||
const responderID = this.state.touchable.responderID;
|
||||
if (responderID == null) {
|
||||
return;
|
||||
@@ -665,7 +665,7 @@ const TouchableMixin = {
|
||||
}
|
||||
},
|
||||
|
||||
_handleQueryLayout: function(
|
||||
_handleQueryLayout: function (
|
||||
l: number,
|
||||
t: number,
|
||||
w: number,
|
||||
@@ -691,12 +691,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 (
|
||||
@@ -715,7 +715,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];
|
||||
@@ -754,19 +754,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;
|
||||
@@ -775,7 +775,7 @@ const TouchableMixin = {
|
||||
this.pressInLocation = {pageX, pageY, locationX, locationY};
|
||||
},
|
||||
|
||||
_getDistanceBetweenPoints: function(
|
||||
_getDistanceBetweenPoints: function (
|
||||
aX: number,
|
||||
aY: number,
|
||||
bX: number,
|
||||
@@ -797,7 +797,7 @@ const TouchableMixin = {
|
||||
* @param {Event} e Native event.
|
||||
* @sideeffects
|
||||
*/
|
||||
_performSideEffectsForTransition: function(
|
||||
_performSideEffectsForTransition: function (
|
||||
curState: State,
|
||||
nextState: State,
|
||||
signal: Signal,
|
||||
@@ -858,12 +858,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 &&
|
||||
@@ -892,7 +892,8 @@ const {
|
||||
touchableHandleBlur,
|
||||
...TouchableMixinWithoutDefaultFocusAndBlur
|
||||
} = TouchableMixin;
|
||||
TouchableMixin.withoutDefaultFocusAndBlur = TouchableMixinWithoutDefaultFocusAndBlur;
|
||||
TouchableMixin.withoutDefaultFocusAndBlur =
|
||||
TouchableMixinWithoutDefaultFocusAndBlur;
|
||||
|
||||
const Touchable = {
|
||||
Mixin: TouchableMixin,
|
||||
|
||||
@@ -128,11 +128,8 @@ class TouchableBounce extends React.Component<Props, State> {
|
||||
render(): React.Node {
|
||||
// BACKWARD-COMPATIBILITY: Focus and blur events were never supported before
|
||||
// adopting `Pressability`, so preserve that behavior.
|
||||
const {
|
||||
onBlur,
|
||||
onFocus,
|
||||
...eventHandlersWithoutBlurAndFocus
|
||||
} = this.state.pressability.getEventHandlers();
|
||||
const {onBlur, onFocus, ...eventHandlersWithoutBlurAndFocus} =
|
||||
this.state.pressability.getEventHandlers();
|
||||
|
||||
return (
|
||||
<Animated.View
|
||||
|
||||
@@ -280,11 +280,8 @@ class TouchableHighlight extends React.Component<Props, State> {
|
||||
|
||||
// BACKWARD-COMPATIBILITY: Focus and blur events were never supported before
|
||||
// adopting `Pressability`, so preserve that behavior.
|
||||
const {
|
||||
onBlur,
|
||||
onFocus,
|
||||
...eventHandlersWithoutBlurAndFocus
|
||||
} = this.state.pressability.getEventHandlers();
|
||||
const {onBlur, onFocus, ...eventHandlersWithoutBlurAndFocus} =
|
||||
this.state.pressability.getEventHandlers();
|
||||
|
||||
const accessibilityState =
|
||||
this.props.disabled != null
|
||||
|
||||
@@ -99,9 +99,7 @@ class TouchableNativeFeedback extends React.Component<Props, State> {
|
||||
* Creates a value for the `background` prop that uses the Android theme's
|
||||
* default background for selectable elements.
|
||||
*/
|
||||
static SelectableBackground: (
|
||||
rippleRadius: ?number,
|
||||
) => $ReadOnly<{|
|
||||
static SelectableBackground: (rippleRadius: ?number) => $ReadOnly<{|
|
||||
attribute: 'selectableItemBackground',
|
||||
type: 'ThemeAttrAndroid',
|
||||
rippleRadius: ?number,
|
||||
@@ -115,9 +113,7 @@ class TouchableNativeFeedback extends React.Component<Props, State> {
|
||||
* Creates a value for the `background` prop that uses the Android theme's
|
||||
* default background for borderless selectable elements. Requires API 21+.
|
||||
*/
|
||||
static SelectableBackgroundBorderless: (
|
||||
rippleRadius: ?number,
|
||||
) => $ReadOnly<{|
|
||||
static SelectableBackgroundBorderless: (rippleRadius: ?number) => $ReadOnly<{|
|
||||
attribute: 'selectableItemBackgroundBorderless',
|
||||
type: 'ThemeAttrAndroid',
|
||||
rippleRadius: ?number,
|
||||
@@ -252,11 +248,8 @@ class TouchableNativeFeedback extends React.Component<Props, State> {
|
||||
|
||||
// BACKWARD-COMPATIBILITY: Focus and blur events were never supported before
|
||||
// adopting `Pressability`, so preserve that behavior.
|
||||
const {
|
||||
onBlur,
|
||||
onFocus,
|
||||
...eventHandlersWithoutBlurAndFocus
|
||||
} = this.state.pressability.getEventHandlers();
|
||||
const {onBlur, onFocus, ...eventHandlersWithoutBlurAndFocus} =
|
||||
this.state.pressability.getEventHandlers();
|
||||
|
||||
const accessibilityState =
|
||||
this.props.disabled != null
|
||||
|
||||
@@ -210,11 +210,8 @@ class TouchableOpacity extends React.Component<Props, State> {
|
||||
render(): React.Node {
|
||||
// BACKWARD-COMPATIBILITY: Focus and blur events were never supported before
|
||||
// adopting `Pressability`, so preserve that behavior.
|
||||
const {
|
||||
onBlur,
|
||||
onFocus,
|
||||
...eventHandlersWithoutBlurAndFocus
|
||||
} = this.state.pressability.getEventHandlers();
|
||||
const {onBlur, onFocus, ...eventHandlersWithoutBlurAndFocus} =
|
||||
this.state.pressability.getEventHandlers();
|
||||
|
||||
const accessibilityState =
|
||||
this.props.disabled != null
|
||||
|
||||
@@ -106,11 +106,8 @@ class TouchableWithoutFeedback extends React.Component<Props, State> {
|
||||
|
||||
// BACKWARD-COMPATIBILITY: Focus and blur events were never supported before
|
||||
// adopting `Pressability`, so preserve that behavior.
|
||||
const {
|
||||
onBlur,
|
||||
onFocus,
|
||||
...eventHandlersWithoutBlurAndFocus
|
||||
} = this.state.pressability.getEventHandlers();
|
||||
const {onBlur, onFocus, ...eventHandlersWithoutBlurAndFocus} =
|
||||
this.state.pressability.getEventHandlers();
|
||||
|
||||
const elementProps: {[string]: mixed, ...} = {
|
||||
...eventHandlersWithoutBlurAndFocus,
|
||||
|
||||
@@ -16,13 +16,12 @@ import ReactNativeViewViewConfigAndroid from './ReactNativeViewViewConfigAndroid
|
||||
import {type ViewProps as Props} from './ViewPropTypes';
|
||||
import * as React from 'react';
|
||||
|
||||
const ViewNativeComponent: HostComponent<Props> = NativeComponentRegistry.get<Props>(
|
||||
'RCTView',
|
||||
() =>
|
||||
const ViewNativeComponent: HostComponent<Props> =
|
||||
NativeComponentRegistry.get<Props>('RCTView', () =>
|
||||
Platform.OS === 'android'
|
||||
? ReactNativeViewViewConfigAndroid
|
||||
: {uiViewClassName: 'RCTView'},
|
||||
);
|
||||
);
|
||||
|
||||
interface NativeCommands {
|
||||
+hotspotUpdate: (
|
||||
|
||||
@@ -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().stack);
|
||||
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(undefined)).toEqual([]);
|
||||
expect(parseErrorStack(null)).toEqual([]);
|
||||
});
|
||||
|
||||
@@ -58,7 +58,8 @@ export type HermesParsedStack = {|
|
||||
// 4. source URL (filename)
|
||||
// 5. line number (1 based)
|
||||
// 6. column number (1 based) or virtual offset (0 based)
|
||||
const RE_FRAME = /^ {4}at (.+?)(?: \((native)\)?| \((address at )?(.*?):(\d+):(\d+)\))$/;
|
||||
const RE_FRAME =
|
||||
/^ {4}at (.+?)(?: \((native)\)?| \((address at )?(.*?):(\d+):(\d+)\))$/;
|
||||
|
||||
// Capturing groups:
|
||||
// 1. count of skipped frames
|
||||
|
||||
@@ -102,8 +102,8 @@ function reportException(
|
||||
isComponentError: !!e.isComponentError,
|
||||
});
|
||||
} else if (isFatal || e.type !== 'warn') {
|
||||
const NativeExceptionsManager = require('./NativeExceptionsManager')
|
||||
.default;
|
||||
const NativeExceptionsManager =
|
||||
require('./NativeExceptionsManager').default;
|
||||
if (NativeExceptionsManager) {
|
||||
NativeExceptionsManager.reportException(data);
|
||||
}
|
||||
|
||||
@@ -57,9 +57,8 @@ export interface Spec extends TurboModule {
|
||||
|
||||
const Platform = require('../Utilities/Platform');
|
||||
|
||||
const NativeModule = TurboModuleRegistry.getEnforcing<Spec>(
|
||||
'ExceptionsManager',
|
||||
);
|
||||
const NativeModule =
|
||||
TurboModuleRegistry.getEnforcing<Spec>('ExceptionsManager');
|
||||
|
||||
const ExceptionsManager = {
|
||||
reportFatalException(
|
||||
|
||||
@@ -114,7 +114,7 @@ function _callTimer(timerID: number, frameTime: number, didTimeout: ?boolean) {
|
||||
callback(global.performance.now());
|
||||
} 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.
|
||||
@@ -209,7 +209,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 {
|
||||
const id = _allocateCallback(
|
||||
() => func.apply(undefined, args),
|
||||
'setTimeout',
|
||||
@@ -222,7 +226,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
|
||||
@@ -243,7 +247,7 @@ const JSTimers = {
|
||||
* @param {function} func Callback to be invoked before the end of the
|
||||
* current JavaScript execution loop.
|
||||
*/
|
||||
queueReactNativeMicrotask: function(func: Function, ...args: any) {
|
||||
queueReactNativeMicrotask: function (func: Function, ...args: any) {
|
||||
const id = _allocateCallback(
|
||||
() => func.apply(undefined, args),
|
||||
'queueReactNativeMicrotask',
|
||||
@@ -255,7 +259,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;
|
||||
@@ -266,7 +270,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);
|
||||
}
|
||||
@@ -304,7 +308,7 @@ const JSTimers = {
|
||||
return id;
|
||||
},
|
||||
|
||||
cancelIdleCallback: function(timerID: number) {
|
||||
cancelIdleCallback: function (timerID: number) {
|
||||
_freeCallback(timerID);
|
||||
const index = requestIdleCallbacks.indexOf(timerID);
|
||||
if (index !== -1) {
|
||||
@@ -322,15 +326,15 @@ const JSTimers = {
|
||||
}
|
||||
},
|
||||
|
||||
clearTimeout: function(timerID: number) {
|
||||
clearTimeout: function (timerID: number) {
|
||||
_freeCallback(timerID);
|
||||
},
|
||||
|
||||
clearInterval: function(timerID: number) {
|
||||
clearInterval: function (timerID: number) {
|
||||
_freeCallback(timerID);
|
||||
},
|
||||
|
||||
clearReactNativeMicrotask: function(timerID: number) {
|
||||
clearReactNativeMicrotask: function (timerID: number) {
|
||||
_freeCallback(timerID);
|
||||
const index = reactNativeMicrotasks.indexOf(timerID);
|
||||
if (index !== -1) {
|
||||
@@ -338,7 +342,7 @@ const JSTimers = {
|
||||
}
|
||||
},
|
||||
|
||||
cancelAnimationFrame: function(timerID: number) {
|
||||
cancelAnimationFrame: function (timerID: number) {
|
||||
_freeCallback(timerID);
|
||||
},
|
||||
|
||||
@@ -346,7 +350,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.',
|
||||
@@ -378,7 +382,7 @@ const JSTimers = {
|
||||
}
|
||||
},
|
||||
|
||||
callIdleCallbacks: function(frameTime: number) {
|
||||
callIdleCallbacks: function (frameTime: number) {
|
||||
if (
|
||||
FRAME_DURATION - (global.performance.now() - frameTime) <
|
||||
IDLE_CALLBACK_FRAME_DEADLINE
|
||||
|
||||
@@ -26,8 +26,8 @@ jest
|
||||
|
||||
const JSTimers = require('../JSTimers');
|
||||
|
||||
describe('JSTimers', function() {
|
||||
beforeEach(function() {
|
||||
describe('JSTimers', function () {
|
||||
beforeEach(function () {
|
||||
jest.spyOn(console, 'warn');
|
||||
global.setTimeout = JSTimers.setTimeout;
|
||||
});
|
||||
@@ -36,24 +36,24 @@ describe('JSTimers', function() {
|
||||
console.warn.mockRestore();
|
||||
});
|
||||
|
||||
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;
|
||||
});
|
||||
});
|
||||
@@ -65,15 +65,15 @@ describe('JSTimers', function() {
|
||||
expect(callCount).toBe(1);
|
||||
});
|
||||
|
||||
it('should call nested queueReactNativeMicrotask when cleared', function() {
|
||||
it('should call nested queueReactNativeMicrotask when cleared', function () {
|
||||
let id1, id2, id3;
|
||||
let callCount = 0;
|
||||
|
||||
id1 = JSTimers.queueReactNativeMicrotask(function() {
|
||||
id1 = JSTimers.queueReactNativeMicrotask(function () {
|
||||
JSTimers.clearReactNativeMicrotask(id1);
|
||||
id2 = JSTimers.queueReactNativeMicrotask(function() {
|
||||
id2 = JSTimers.queueReactNativeMicrotask(function () {
|
||||
JSTimers.clearReactNativeMicrotask(id2);
|
||||
id3 = JSTimers.queueReactNativeMicrotask(function() {
|
||||
id3 = JSTimers.queueReactNativeMicrotask(function () {
|
||||
callCount += 1;
|
||||
});
|
||||
});
|
||||
@@ -85,15 +85,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;
|
||||
});
|
||||
});
|
||||
@@ -105,15 +105,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;
|
||||
});
|
||||
});
|
||||
@@ -125,21 +125,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 queueReactNativeMicrotask', function() {
|
||||
it('should call function with queueReactNativeMicrotask', function () {
|
||||
const callback = jest.fn();
|
||||
JSTimers.queueReactNativeMicrotask(callback);
|
||||
JSTimers.callReactNativeMicrotasks();
|
||||
expect(callback).toBeCalledTimes(1);
|
||||
});
|
||||
|
||||
it('should not call function with clearReactNativeMicrotask', function() {
|
||||
it('should not call function with clearReactNativeMicrotask', function () {
|
||||
const callback = jest.fn();
|
||||
const id = JSTimers.queueReactNativeMicrotask(callback);
|
||||
JSTimers.clearReactNativeMicrotask(id);
|
||||
@@ -147,14 +147,14 @@ describe('JSTimers', function() {
|
||||
expect(callback).not.toBeCalled();
|
||||
});
|
||||
|
||||
it('should call functions in the right order with queueReactNativeMicrotask', function() {
|
||||
it('should call functions in the right order with queueReactNativeMicrotask', function () {
|
||||
let count = 0;
|
||||
let firstCalled = null;
|
||||
let secondCalled = null;
|
||||
JSTimers.queueReactNativeMicrotask(function() {
|
||||
JSTimers.queueReactNativeMicrotask(function () {
|
||||
firstCalled = count++;
|
||||
});
|
||||
JSTimers.queueReactNativeMicrotask(function() {
|
||||
JSTimers.queueReactNativeMicrotask(function () {
|
||||
secondCalled = count++;
|
||||
});
|
||||
JSTimers.callReactNativeMicrotasks();
|
||||
@@ -162,14 +162,14 @@ describe('JSTimers', function() {
|
||||
expect(secondCalled).toBe(1);
|
||||
});
|
||||
|
||||
it('should call functions in the right order with nested queueReactNativeMicrotask', function() {
|
||||
it('should call functions in the right order with nested queueReactNativeMicrotask', function () {
|
||||
let count = 0;
|
||||
let firstCalled = null;
|
||||
let secondCalled = null;
|
||||
let thirdCalled = null;
|
||||
JSTimers.queueReactNativeMicrotask(function() {
|
||||
JSTimers.queueReactNativeMicrotask(function () {
|
||||
firstCalled = count++;
|
||||
JSTimers.queueReactNativeMicrotask(function() {
|
||||
JSTimers.queueReactNativeMicrotask(function () {
|
||||
thirdCalled = count++;
|
||||
});
|
||||
secondCalled = count++;
|
||||
@@ -180,12 +180,12 @@ describe('JSTimers', function() {
|
||||
expect(thirdCalled).toBe(2);
|
||||
});
|
||||
|
||||
it('should call nested queueReactNativeMicrotask', function() {
|
||||
it('should call nested queueReactNativeMicrotask', function () {
|
||||
let firstCalled = false;
|
||||
let secondCalled = false;
|
||||
JSTimers.queueReactNativeMicrotask(function() {
|
||||
JSTimers.queueReactNativeMicrotask(function () {
|
||||
firstCalled = true;
|
||||
JSTimers.queueReactNativeMicrotask(function() {
|
||||
JSTimers.queueReactNativeMicrotask(function () {
|
||||
secondCalled = true;
|
||||
});
|
||||
});
|
||||
@@ -194,14 +194,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();
|
||||
@@ -211,7 +211,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]);
|
||||
@@ -221,13 +221,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]);
|
||||
@@ -235,13 +235,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]);
|
||||
@@ -249,27 +249,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);
|
||||
@@ -278,12 +278,12 @@ describe('JSTimers', function() {
|
||||
expect(console.warn).not.toBeCalled();
|
||||
});
|
||||
|
||||
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(console.warn).toBeCalled();
|
||||
});
|
||||
|
||||
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
|
||||
@@ -295,7 +295,7 @@ describe('JSTimers', function() {
|
||||
expect(console.warn).not.toBeCalled();
|
||||
});
|
||||
|
||||
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
|
||||
@@ -307,11 +307,11 @@ describe('JSTimers', function() {
|
||||
expect(console.warn).not.toBeCalled();
|
||||
});
|
||||
|
||||
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(
|
||||
@@ -319,8 +319,8 @@ describe('JSTimers', function() {
|
||||
);
|
||||
});
|
||||
|
||||
it('should pass along errors thrown from queueReactNativeMicrotask', function() {
|
||||
JSTimers.queueReactNativeMicrotask(function() {
|
||||
it('should pass along errors thrown from queueReactNativeMicrotask', function () {
|
||||
JSTimers.queueReactNativeMicrotask(function () {
|
||||
throw new Error('error within queueReactNativeMicrotask');
|
||||
});
|
||||
|
||||
@@ -336,12 +336,12 @@ describe('JSTimers', function() {
|
||||
);
|
||||
});
|
||||
|
||||
it('should throw all errors from queueReactNativeMicrotask', function() {
|
||||
JSTimers.queueReactNativeMicrotask(function() {
|
||||
it('should throw all errors from queueReactNativeMicrotask', function () {
|
||||
JSTimers.queueReactNativeMicrotask(function () {
|
||||
throw new Error('first error');
|
||||
});
|
||||
|
||||
JSTimers.queueReactNativeMicrotask(function() {
|
||||
JSTimers.queueReactNativeMicrotask(function () {
|
||||
throw new Error('second error');
|
||||
});
|
||||
|
||||
@@ -361,8 +361,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');
|
||||
});
|
||||
|
||||
@@ -371,11 +371,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');
|
||||
});
|
||||
|
||||
@@ -391,8 +391,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(
|
||||
@@ -400,7 +400,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();
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -58,7 +58,7 @@ if (__DEV__) {
|
||||
'debug',
|
||||
].forEach(level => {
|
||||
const originalFunction = console[level];
|
||||
console[level] = function(...args) {
|
||||
console[level] = function (...args) {
|
||||
HMRClient.log(level, args);
|
||||
originalFunction.apply(console, args);
|
||||
};
|
||||
|
||||
@@ -19,7 +19,7 @@ if (!global.performance) {
|
||||
* https://developer.mozilla.org/en-US/docs/Web/API/Performance/now
|
||||
*/
|
||||
if (typeof global.performance.now !== 'function') {
|
||||
global.performance.now = function() {
|
||||
global.performance.now = function () {
|
||||
const performanceNow = global.nativePerformanceNow || Date.now;
|
||||
return performanceNow();
|
||||
};
|
||||
|
||||
@@ -22,7 +22,7 @@ let hasNativeGenerator;
|
||||
try {
|
||||
// If this function was lowered by regenerator-transform, it will try to
|
||||
// access `global.regeneratorRuntime` which doesn't exist yet and will throw.
|
||||
hasNativeGenerator = hasNativeConstructor(function*() {},
|
||||
hasNativeGenerator = hasNativeConstructor(function* () {},
|
||||
'GeneratorFunction');
|
||||
} catch {
|
||||
// In this case, we know generators are not provided natively.
|
||||
|
||||
@@ -27,8 +27,8 @@ function __fetchSegment(
|
||||
}>,
|
||||
callback: (?Error) => void,
|
||||
) {
|
||||
const SegmentFetcher = require('./SegmentFetcher/NativeSegmentFetcher')
|
||||
.default;
|
||||
const SegmentFetcher =
|
||||
require('./SegmentFetcher/NativeSegmentFetcher').default;
|
||||
SegmentFetcher.fetchSegment(
|
||||
segmentId,
|
||||
options,
|
||||
@@ -61,8 +61,8 @@ function __getSegment(
|
||||
}>,
|
||||
callback: (?Error, ?string) => void,
|
||||
) {
|
||||
const SegmentFetcher = require('./SegmentFetcher/NativeSegmentFetcher')
|
||||
.default;
|
||||
const SegmentFetcher =
|
||||
require('./SegmentFetcher/NativeSegmentFetcher').default;
|
||||
|
||||
if (!SegmentFetcher.getSegment) {
|
||||
throw new Error('SegmentFetcher.getSegment must be defined');
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
|
||||
const normalizeColor = require('../StyleSheet/normalizeColor');
|
||||
|
||||
const colorPropType = function(
|
||||
const colorPropType = function (
|
||||
isRequired,
|
||||
props,
|
||||
propName,
|
||||
|
||||
@@ -15,10 +15,10 @@ const flattenStyle = require('../StyleSheet/flattenStyle');
|
||||
|
||||
function DeprecatedStyleSheetPropType(shape: {
|
||||
[key: string]: ReactPropsCheckType,
|
||||
...,
|
||||
...
|
||||
}): 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,
|
||||
|
||||
@@ -14,7 +14,7 @@ const invariant = require('invariant');
|
||||
|
||||
function deprecatedCreateStrictShapeTypeChecker(shapeTypes: {
|
||||
[key: string]: ReactPropsCheckType,
|
||||
...,
|
||||
...
|
||||
}): ReactPropsChainableTypeChecker {
|
||||
function checkType(
|
||||
isRequired,
|
||||
|
||||
@@ -36,7 +36,8 @@ export type {EventSubscription};
|
||||
* can theoretically listen to `RCTDeviceEventEmitter` (although discouraged).
|
||||
*/
|
||||
export default class NativeEventEmitter<TEventToArgsMap: {...}>
|
||||
implements IEventEmitter<TEventToArgsMap> {
|
||||
implements IEventEmitter<TEventToArgsMap>
|
||||
{
|
||||
_nativeModule: ?NativeModule;
|
||||
|
||||
constructor(nativeModule: ?NativeModule) {
|
||||
|
||||
@@ -18,7 +18,8 @@ import RCTDeviceEventEmitter from '../RCTDeviceEventEmitter';
|
||||
* Mock `NativeEventEmitter` to ignore Native Modules.
|
||||
*/
|
||||
export default class NativeEventEmitter<TEventToArgsMap: {...}>
|
||||
implements IEventEmitter<TEventToArgsMap> {
|
||||
implements IEventEmitter<TEventToArgsMap>
|
||||
{
|
||||
addListener<TEvent: $Keys<TEventToArgsMap>>(
|
||||
eventType: TEvent,
|
||||
listener: (...args: $ElementType<TEventToArgsMap, TEvent>) => mixed,
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
import NativeJSCHeapCapture from './NativeJSCHeapCapture';
|
||||
|
||||
const HeapCapture = {
|
||||
captureHeap: function(path: string) {
|
||||
captureHeap: function (path: string) {
|
||||
let error = null;
|
||||
try {
|
||||
global.nativeCaptureHeap(path);
|
||||
|
||||
@@ -159,10 +159,8 @@ class AssetSourceResolver {
|
||||
};
|
||||
}
|
||||
|
||||
static pickScale: (
|
||||
scales: Array<number>,
|
||||
deviceScale?: number,
|
||||
) => number = pickScale;
|
||||
static pickScale: (scales: Array<number>, deviceScale?: number) => number =
|
||||
pickScale;
|
||||
}
|
||||
|
||||
module.exports = AssetSourceResolver;
|
||||
|
||||
@@ -40,12 +40,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);
|
||||
},
|
||||
);
|
||||
@@ -64,12 +64,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);
|
||||
},
|
||||
);
|
||||
|
||||
@@ -33,7 +33,7 @@ function getSize(
|
||||
.then(([width, height]) => success(width, height))
|
||||
.catch(
|
||||
failure ||
|
||||
function() {
|
||||
function () {
|
||||
console.warn('Failed to get size for image ' + uri);
|
||||
},
|
||||
);
|
||||
@@ -46,12 +46,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);
|
||||
},
|
||||
);
|
||||
|
||||
@@ -12,9 +12,8 @@ import * as React from 'react';
|
||||
|
||||
type ContextType = ?string;
|
||||
|
||||
const Context: React.Context<ContextType> = React.createContext<ContextType>(
|
||||
null,
|
||||
);
|
||||
const Context: React.Context<ContextType> =
|
||||
React.createContext<ContextType>(null);
|
||||
|
||||
if (__DEV__) {
|
||||
Context.displayName = 'ImageAnalyticsTagContext';
|
||||
|
||||
@@ -12,15 +12,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,
|
||||
@@ -49,7 +49,7 @@ const ImagePickerIOS = {
|
||||
cancelCallback,
|
||||
);
|
||||
},
|
||||
openSelectDialog: function(
|
||||
openSelectDialog: function (
|
||||
config: $ReadOnly<{|
|
||||
showImages?: boolean,
|
||||
showVideos?: boolean,
|
||||
@@ -86,7 +86,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);
|
||||
},
|
||||
@@ -94,7 +94,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();
|
||||
},
|
||||
|
||||
@@ -36,9 +36,8 @@ type Props = $ReadOnly<{
|
||||
loadingIndicatorSrc?: ?string,
|
||||
}>;
|
||||
|
||||
const ImageViewNativeComponent: HostComponent<Props> = NativeComponentRegistry.get<Props>(
|
||||
'RCTImageView',
|
||||
() => ({
|
||||
const ImageViewNativeComponent: HostComponent<Props> =
|
||||
NativeComponentRegistry.get<Props>('RCTImageView', () => ({
|
||||
uiViewClassName: 'RCTImageView',
|
||||
bubblingEventTypes: {},
|
||||
directEventTypes: {
|
||||
@@ -93,7 +92,6 @@ const ImageViewNativeComponent: HostComponent<Props> = NativeComponentRegistry.g
|
||||
process: require('../StyleSheet/processColor'),
|
||||
},
|
||||
},
|
||||
}),
|
||||
);
|
||||
}));
|
||||
|
||||
export default ImageViewNativeComponent;
|
||||
|
||||
@@ -14,9 +14,7 @@ import * as TurboModuleRegistry from '../TurboModule/TurboModuleRegistry';
|
||||
export interface Spec extends TurboModule {
|
||||
+abortRequest: (requestId: number) => void;
|
||||
+getConstants: () => {||};
|
||||
+getSize: (
|
||||
uri: string,
|
||||
) => Promise<
|
||||
+getSize: (uri: string) => Promise<
|
||||
$ReadOnly<{
|
||||
width: number,
|
||||
height: number,
|
||||
|
||||
@@ -39,9 +39,8 @@ type Props = $ReadOnly<{
|
||||
internal_analyticTag?: ?string,
|
||||
}>;
|
||||
|
||||
const TextInlineImage: HostComponent<Props> = NativeComponentRegistry.get<Props>(
|
||||
'RCTTextInlineImage',
|
||||
() => ({
|
||||
const TextInlineImage: HostComponent<Props> =
|
||||
NativeComponentRegistry.get<Props>('RCTTextInlineImage', () => ({
|
||||
uiViewClassName: 'RCTImageView',
|
||||
bubblingEventTypes: {},
|
||||
directEventTypes: {
|
||||
@@ -96,7 +95,6 @@ const TextInlineImage: HostComponent<Props> = NativeComponentRegistry.get<Props>
|
||||
process: require('../StyleSheet/processColor'),
|
||||
},
|
||||
},
|
||||
}),
|
||||
);
|
||||
}));
|
||||
|
||||
module.exports = TextInlineImage;
|
||||
|
||||
@@ -21,8 +21,8 @@ describe('resolveAssetSource', () => {
|
||||
|
||||
AssetRegistry = require('@react-native/assets/registry');
|
||||
resolveAssetSource = require('../resolveAssetSource');
|
||||
NativeSourceCode = require('../../NativeModules/specs/NativeSourceCode')
|
||||
.default;
|
||||
NativeSourceCode =
|
||||
require('../../NativeModules/specs/NativeSourceCode').default;
|
||||
Platform = require('../../Utilities/Platform');
|
||||
});
|
||||
|
||||
@@ -81,8 +81,7 @@ describe('resolveAssetSource', () => {
|
||||
__packager_asset: true,
|
||||
width: 100,
|
||||
height: 200,
|
||||
uri:
|
||||
'http://10.0.0.1:8081/assets/module/a/logo.png?platform=ios&hash=5b6f00f',
|
||||
uri: 'http://10.0.0.1:8081/assets/module/a/logo.png?platform=ios&hash=5b6f00f',
|
||||
scale: 1,
|
||||
},
|
||||
);
|
||||
@@ -105,8 +104,7 @@ describe('resolveAssetSource', () => {
|
||||
__packager_asset: true,
|
||||
width: 100,
|
||||
height: 200,
|
||||
uri:
|
||||
'http://10.0.0.1:8081/assets/module/a/logo@2x.png?platform=ios&hash=5b6f00f',
|
||||
uri: 'http://10.0.0.1:8081/assets/module/a/logo@2x.png?platform=ios&hash=5b6f00f',
|
||||
scale: 2,
|
||||
},
|
||||
);
|
||||
@@ -248,8 +246,7 @@ describe('resolveAssetSource', () => {
|
||||
__packager_asset: true,
|
||||
width: 100,
|
||||
height: 200,
|
||||
uri:
|
||||
'file:///sdcard/Path/To/Simulator/drawable-mdpi/awesomemodule_subdir_logo1_.png',
|
||||
uri: 'file:///sdcard/Path/To/Simulator/drawable-mdpi/awesomemodule_subdir_logo1_.png',
|
||||
scale: 1,
|
||||
},
|
||||
);
|
||||
@@ -281,8 +278,7 @@ describe('resolveAssetSource', () => {
|
||||
__packager_asset: true,
|
||||
width: 100,
|
||||
height: 200,
|
||||
uri:
|
||||
'file:///sdcard/Path/To/Simulator/drawable-mdpi/awesomemodule_subdir_logo1_.png',
|
||||
uri: 'file:///sdcard/Path/To/Simulator/drawable-mdpi/awesomemodule_subdir_logo1_.png',
|
||||
scale: 1,
|
||||
},
|
||||
);
|
||||
|
||||
@@ -397,11 +397,8 @@ class NetworkOverlay extends React.Component<Props, State> {
|
||||
_indicateAdditionalRequests = (): void => {
|
||||
if (this._requestsListView) {
|
||||
const distanceFromEndThreshold = LISTVIEW_CELL_HEIGHT * 2;
|
||||
const {
|
||||
offset,
|
||||
visibleLength,
|
||||
contentLength,
|
||||
} = this._requestsListViewScrollMetrics;
|
||||
const {offset, visibleLength, contentLength} =
|
||||
this._requestsListViewScrollMetrics;
|
||||
const distanceFromEnd = contentLength - visibleLength - offset;
|
||||
const isCloseToEnd = distanceFromEnd <= distanceFromEndThreshold;
|
||||
if (isCloseToEnd) {
|
||||
|
||||
@@ -16,7 +16,7 @@ const MessageQueue = require('../BatchedBridge/MessageQueue');
|
||||
const infoLog = require('../Utilities/infoLog');
|
||||
|
||||
const BridgeSpyStallHandler = {
|
||||
register: function() {
|
||||
register: function () {
|
||||
let spyBuffer = [];
|
||||
MessageQueue.spy(data => {
|
||||
spyBuffer.push(data);
|
||||
|
||||
@@ -33,7 +33,7 @@ const FrameRateLogger = {
|
||||
* Enable `debug` to see local logs of what's going on. `reportStackTraces` will grab stack traces
|
||||
* during UI thread stalls and upload them if the native module supports it.
|
||||
*/
|
||||
setGlobalOptions: function(options: {
|
||||
setGlobalOptions: function (options: {
|
||||
debug?: boolean,
|
||||
reportStackTraces?: boolean,
|
||||
...
|
||||
@@ -58,7 +58,7 @@ const FrameRateLogger = {
|
||||
* Must call `setContext` before any events can be properly tracked, which is done automatically
|
||||
* in `AppRegistry`, but navigation is also a common place to hook in.
|
||||
*/
|
||||
setContext: function(context: string) {
|
||||
setContext: function (context: string) {
|
||||
NativeFrameRateLogger && NativeFrameRateLogger.setContext(context);
|
||||
},
|
||||
|
||||
|
||||
@@ -86,9 +86,7 @@ const InteractionManager = {
|
||||
* Schedule a function to run after all interactions have completed. Returns a cancellable
|
||||
* "promise".
|
||||
*/
|
||||
runAfterInteractions(
|
||||
task: ?Task,
|
||||
): {
|
||||
runAfterInteractions(task: ?Task): {
|
||||
then: <U>(
|
||||
onFulfill?: ?(void) => ?(Promise<U> | U),
|
||||
onReject?: ?(error: mixed) => ?(Promise<U> | U),
|
||||
@@ -122,7 +120,7 @@ const InteractionManager = {
|
||||
);
|
||||
}
|
||||
},
|
||||
cancel: function() {
|
||||
cancel: function () {
|
||||
_taskQueue.cancelTasks(tasks);
|
||||
},
|
||||
};
|
||||
|
||||
@@ -35,20 +35,20 @@ type Handler = {
|
||||
* queried with `getStats`.
|
||||
*/
|
||||
const JSEventLoopWatchdog = {
|
||||
getStats: function(): Object {
|
||||
getStats: function (): Object {
|
||||
return {stallCount, totalStallTime, longestStall, acceptableBusyTime};
|
||||
},
|
||||
reset: function() {
|
||||
reset: function () {
|
||||
infoLog('JSEventLoopWatchdog: reset');
|
||||
totalStallTime = 0;
|
||||
stallCount = 0;
|
||||
longestStall = 0;
|
||||
lastInterval = global.performance.now();
|
||||
},
|
||||
addHandler: function(handler: Handler) {
|
||||
addHandler: function (handler: Handler) {
|
||||
handlers.push(handler);
|
||||
},
|
||||
install: function({thresholdMS}: {thresholdMS: number, ...}) {
|
||||
install: function ({thresholdMS}: {thresholdMS: number, ...}) {
|
||||
acceptableBusyTime = thresholdMS;
|
||||
if (installed) {
|
||||
return;
|
||||
|
||||
@@ -383,9 +383,7 @@ const PanResponder = {
|
||||
* accordingly. (numberActiveTouches) may not be totally accurate unless you
|
||||
* are the responder.
|
||||
*/
|
||||
create(
|
||||
config: PanResponderConfig,
|
||||
): $TEMPORARY$object<{|
|
||||
create(config: PanResponderConfig): $TEMPORARY$object<{|
|
||||
getInteractionHandle: () => ?number,
|
||||
panHandlers: $TEMPORARY$object<{|
|
||||
onMoveShouldSetResponder: (event: PressEvent) => boolean,
|
||||
@@ -462,7 +460,8 @@ const PanResponder = {
|
||||
|
||||
onResponderGrant(event: PressEvent): boolean {
|
||||
if (!interactionState.handle) {
|
||||
interactionState.handle = InteractionManager.createInteractionHandle();
|
||||
interactionState.handle =
|
||||
InteractionManager.createInteractionHandle();
|
||||
}
|
||||
gestureState.x0 = currentCentroidX(event.touchHistory);
|
||||
gestureState.y0 = currentCentroidY(event.touchHistory);
|
||||
|
||||
@@ -24,7 +24,7 @@ const TouchHistoryMath = {
|
||||
* touches vs. previous centroid of now actively moving touches.
|
||||
* @return {number} value of centroid in specified dimension.
|
||||
*/
|
||||
centroidDimension: function(
|
||||
centroidDimension: function (
|
||||
touchHistory,
|
||||
touchesChangedAfter,
|
||||
isXAxis,
|
||||
@@ -81,7 +81,7 @@ const TouchHistoryMath = {
|
||||
return count > 0 ? total / count : TouchHistoryMath.noCentroid;
|
||||
},
|
||||
|
||||
currentCentroidXOfTouchesChangedAfter: function(
|
||||
currentCentroidXOfTouchesChangedAfter: function (
|
||||
touchHistory,
|
||||
touchesChangedAfter,
|
||||
) {
|
||||
@@ -93,7 +93,7 @@ const TouchHistoryMath = {
|
||||
);
|
||||
},
|
||||
|
||||
currentCentroidYOfTouchesChangedAfter: function(
|
||||
currentCentroidYOfTouchesChangedAfter: function (
|
||||
touchHistory,
|
||||
touchesChangedAfter,
|
||||
) {
|
||||
@@ -105,7 +105,7 @@ const TouchHistoryMath = {
|
||||
);
|
||||
},
|
||||
|
||||
previousCentroidXOfTouchesChangedAfter: function(
|
||||
previousCentroidXOfTouchesChangedAfter: function (
|
||||
touchHistory,
|
||||
touchesChangedAfter,
|
||||
) {
|
||||
@@ -117,7 +117,7 @@ const TouchHistoryMath = {
|
||||
);
|
||||
},
|
||||
|
||||
previousCentroidYOfTouchesChangedAfter: function(
|
||||
previousCentroidYOfTouchesChangedAfter: function (
|
||||
touchHistory,
|
||||
touchesChangedAfter,
|
||||
) {
|
||||
@@ -129,7 +129,7 @@ const TouchHistoryMath = {
|
||||
);
|
||||
},
|
||||
|
||||
currentCentroidX: function(touchHistory) {
|
||||
currentCentroidX: function (touchHistory) {
|
||||
return TouchHistoryMath.centroidDimension(
|
||||
touchHistory,
|
||||
0, // touchesChangedAfter
|
||||
@@ -138,7 +138,7 @@ const TouchHistoryMath = {
|
||||
);
|
||||
},
|
||||
|
||||
currentCentroidY: function(touchHistory) {
|
||||
currentCentroidY: function (touchHistory) {
|
||||
return TouchHistoryMath.centroidDimension(
|
||||
touchHistory,
|
||||
0, // touchesChangedAfter
|
||||
|
||||
@@ -275,12 +275,7 @@ class NetworkAgent extends InspectorAgent {
|
||||
this._interceptor = null;
|
||||
}
|
||||
|
||||
getResponseBody({
|
||||
requestId,
|
||||
}: {
|
||||
requestId: RequestId,
|
||||
...
|
||||
}): {
|
||||
getResponseBody({requestId}: {requestId: RequestId, ...}): {
|
||||
body: ?string,
|
||||
base64Encoded: boolean,
|
||||
...
|
||||
|
||||
@@ -70,7 +70,7 @@ function configureNext(
|
||||
config,
|
||||
onAnimationComplete,
|
||||
onAnimationDidFail ??
|
||||
function() {} /* this will only be called if configuration parsing fails */,
|
||||
function () {} /* this will only be called if configuration parsing fails */,
|
||||
);
|
||||
return;
|
||||
}
|
||||
@@ -81,9 +81,9 @@ function configureNext(
|
||||
if (UIManager?.configureNextLayoutAnimation) {
|
||||
UIManager.configureNextLayoutAnimation(
|
||||
config,
|
||||
onAnimationComplete ?? function() {},
|
||||
onAnimationComplete ?? function () {},
|
||||
onAnimationDidFail ??
|
||||
function() {} /* this should never be called in Non-Fabric */,
|
||||
function () {} /* this should never be called in Non-Fabric */,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -54,9 +54,10 @@ class FillRateHelper {
|
||||
_mostlyBlankStartTime = (null: ?number);
|
||||
_samplesStartTime = (null: ?number);
|
||||
|
||||
static addListener(
|
||||
callback: FillRateInfo => void,
|
||||
): {remove: () => void, ...} {
|
||||
static addListener(callback: FillRateInfo => void): {
|
||||
remove: () => void,
|
||||
...
|
||||
} {
|
||||
if (_sampleRate === null) {
|
||||
console.warn('Call `FillRateHelper.setSampleRate` before `addListener`.');
|
||||
}
|
||||
|
||||
@@ -408,14 +408,13 @@ class FlatList<ItemT> extends React.PureComponent<Props<ItemT>, void> {
|
||||
super(props);
|
||||
this._checkProps(this.props);
|
||||
if (this.props.viewabilityConfigCallbackPairs) {
|
||||
this._virtualizedListPairs = this.props.viewabilityConfigCallbackPairs.map(
|
||||
pair => ({
|
||||
this._virtualizedListPairs =
|
||||
this.props.viewabilityConfigCallbackPairs.map(pair => ({
|
||||
viewabilityConfig: pair.viewabilityConfig,
|
||||
onViewableItemsChanged: this._createOnViewableItemsChanged(
|
||||
pair.onViewableItemsChanged,
|
||||
),
|
||||
}),
|
||||
);
|
||||
}));
|
||||
} else if (this.props.onViewableItemsChanged) {
|
||||
this._virtualizedListPairs.push({
|
||||
/* $FlowFixMe[incompatible-call] (>=0.63.0 site=react_native_fb) This
|
||||
|
||||
@@ -102,9 +102,7 @@ class ViewabilityHelper {
|
||||
itemCount: number,
|
||||
scrollOffset: number,
|
||||
viewportHeight: number,
|
||||
getFrameMetrics: (
|
||||
index: number,
|
||||
) => ?{
|
||||
getFrameMetrics: (index: number) => ?{
|
||||
length: number,
|
||||
offset: number,
|
||||
...
|
||||
@@ -116,10 +114,8 @@ class ViewabilityHelper {
|
||||
...
|
||||
},
|
||||
): Array<number> {
|
||||
const {
|
||||
itemVisiblePercentThreshold,
|
||||
viewAreaCoveragePercentThreshold,
|
||||
} = this._config;
|
||||
const {itemVisiblePercentThreshold, viewAreaCoveragePercentThreshold} =
|
||||
this._config;
|
||||
const viewAreaMode = viewAreaCoveragePercentThreshold != null;
|
||||
const viewablePercentThreshold = viewAreaMode
|
||||
? viewAreaCoveragePercentThreshold
|
||||
@@ -179,9 +175,7 @@ class ViewabilityHelper {
|
||||
itemCount: number,
|
||||
scrollOffset: number,
|
||||
viewportHeight: number,
|
||||
getFrameMetrics: (
|
||||
index: number,
|
||||
) => ?{
|
||||
getFrameMetrics: (index: number) => ?{
|
||||
length: number,
|
||||
offset: number,
|
||||
...
|
||||
|
||||
@@ -20,9 +20,7 @@ import invariant from 'invariant';
|
||||
export function elementsThatOverlapOffsets(
|
||||
offsets: Array<number>,
|
||||
itemCount: number,
|
||||
getFrameMetrics: (
|
||||
index: number,
|
||||
) => {
|
||||
getFrameMetrics: (index: number) => {
|
||||
length: number,
|
||||
offset: number,
|
||||
...
|
||||
@@ -96,9 +94,7 @@ export function computeWindowedRenderLimits(
|
||||
last: number,
|
||||
...
|
||||
},
|
||||
getFrameMetricsApprox: (
|
||||
index: number,
|
||||
) => {
|
||||
getFrameMetricsApprox: (index: number) => {
|
||||
length: number,
|
||||
offset: number,
|
||||
...
|
||||
|
||||
@@ -441,9 +441,9 @@ class VirtualizedList extends React.PureComponent<Props, State> {
|
||||
);
|
||||
invariant(
|
||||
index < getItemCount(data),
|
||||
`scrollToIndex out of range: requested index ${index} is out of 0 to ${getItemCount(
|
||||
data,
|
||||
) - 1}`,
|
||||
`scrollToIndex out of range: requested index ${index} is out of 0 to ${
|
||||
getItemCount(data) - 1
|
||||
}`,
|
||||
);
|
||||
if (!getItemLayout && index > this._highestMeasuredFrameIndex) {
|
||||
invariant(
|
||||
@@ -882,11 +882,8 @@ class VirtualizedList extends React.PureComponent<Props, State> {
|
||||
);
|
||||
}
|
||||
}
|
||||
const {
|
||||
ListEmptyComponent,
|
||||
ListFooterComponent,
|
||||
ListHeaderComponent,
|
||||
} = this.props;
|
||||
const {ListEmptyComponent, ListFooterComponent, ListHeaderComponent} =
|
||||
this.props;
|
||||
const {data, horizontal} = this.props;
|
||||
const isVirtualizationDisabled = this._isVirtualizationDisabled();
|
||||
const inversionStyle = this.props.inverted
|
||||
@@ -1496,12 +1493,8 @@ class VirtualizedList extends React.PureComponent<Props, State> {
|
||||
}
|
||||
|
||||
_maybeCallOnEndReached() {
|
||||
const {
|
||||
data,
|
||||
getItemCount,
|
||||
onEndReached,
|
||||
onEndReachedThreshold,
|
||||
} = this.props;
|
||||
const {data, getItemCount, onEndReached, onEndReachedThreshold} =
|
||||
this.props;
|
||||
const {contentLength, visibleLength, offset} = this._scrollMetrics;
|
||||
const distanceFromEnd = contentLength - visibleLength - offset;
|
||||
const threshold =
|
||||
@@ -1588,15 +1581,11 @@ class VirtualizedList extends React.PureComponent<Props, State> {
|
||||
// know our offset from our offset from our parent
|
||||
return;
|
||||
}
|
||||
({
|
||||
visibleLength,
|
||||
contentLength,
|
||||
offset,
|
||||
dOffset,
|
||||
} = this._convertParentScrollMetrics({
|
||||
visibleLength,
|
||||
offset,
|
||||
}));
|
||||
({visibleLength, contentLength, offset, dOffset} =
|
||||
this._convertParentScrollMetrics({
|
||||
visibleLength,
|
||||
offset,
|
||||
}));
|
||||
}
|
||||
|
||||
const dt = this._scrollMetrics.timestamp
|
||||
|
||||
@@ -64,9 +64,8 @@ type Context = $ReadOnly<{
|
||||
debugInfo: ListDebugInfo,
|
||||
}>;
|
||||
|
||||
export const VirtualizedListContext: React.Context<?Context> = React.createContext(
|
||||
null,
|
||||
);
|
||||
export const VirtualizedListContext: React.Context<?Context> =
|
||||
React.createContext(null);
|
||||
if (__DEV__) {
|
||||
VirtualizedListContext.displayName = 'VirtualizedListContext';
|
||||
}
|
||||
|
||||
@@ -240,9 +240,7 @@ class VirtualizedSectionList<
|
||||
return (info && info.key) || String(index);
|
||||
};
|
||||
|
||||
_subExtractor(
|
||||
index: number,
|
||||
): ?{
|
||||
_subExtractor(index: number): ?{
|
||||
section: SectionT,
|
||||
// Key of the section or combined key for section + item
|
||||
key: string,
|
||||
@@ -339,63 +337,58 @@ class VirtualizedSectionList<
|
||||
}
|
||||
};
|
||||
|
||||
_renderItem = (listItemCount: number) => ({
|
||||
item,
|
||||
index,
|
||||
}: {
|
||||
item: Item,
|
||||
index: number,
|
||||
...
|
||||
}) => {
|
||||
const info = this._subExtractor(index);
|
||||
if (!info) {
|
||||
return null;
|
||||
}
|
||||
const infoIndex = info.index;
|
||||
if (infoIndex == null) {
|
||||
const {section} = info;
|
||||
if (info.header === true) {
|
||||
const {renderSectionHeader} = this.props;
|
||||
return renderSectionHeader ? renderSectionHeader({section}) : null;
|
||||
} else {
|
||||
const {renderSectionFooter} = this.props;
|
||||
return renderSectionFooter ? renderSectionFooter({section}) : null;
|
||||
_renderItem =
|
||||
(listItemCount: number) =>
|
||||
({item, index}: {item: Item, index: number, ...}) => {
|
||||
const info = this._subExtractor(index);
|
||||
if (!info) {
|
||||
return null;
|
||||
}
|
||||
} else {
|
||||
const renderItem = info.section.renderItem || this.props.renderItem;
|
||||
const SeparatorComponent = this._getSeparatorComponent(
|
||||
index,
|
||||
info,
|
||||
listItemCount,
|
||||
);
|
||||
invariant(renderItem, 'no renderItem!');
|
||||
return (
|
||||
<ItemWithSeparator
|
||||
SeparatorComponent={SeparatorComponent}
|
||||
LeadingSeparatorComponent={
|
||||
infoIndex === 0 ? this.props.SectionSeparatorComponent : undefined
|
||||
}
|
||||
cellKey={info.key}
|
||||
index={infoIndex}
|
||||
item={item}
|
||||
leadingItem={info.leadingItem}
|
||||
leadingSection={info.leadingSection}
|
||||
prevCellKey={(this._subExtractor(index - 1) || {}).key}
|
||||
// Callback to provide updateHighlight for this item
|
||||
setSelfHighlightCallback={this._setUpdateHighlightFor}
|
||||
setSelfUpdatePropsCallback={this._setUpdatePropsFor}
|
||||
// Provide child ability to set highlight/updateProps for previous item using prevCellKey
|
||||
updateHighlightFor={this._updateHighlightFor}
|
||||
updatePropsFor={this._updatePropsFor}
|
||||
renderItem={renderItem}
|
||||
section={info.section}
|
||||
trailingItem={info.trailingItem}
|
||||
trailingSection={info.trailingSection}
|
||||
inverted={!!this.props.inverted}
|
||||
/>
|
||||
);
|
||||
}
|
||||
};
|
||||
const infoIndex = info.index;
|
||||
if (infoIndex == null) {
|
||||
const {section} = info;
|
||||
if (info.header === true) {
|
||||
const {renderSectionHeader} = this.props;
|
||||
return renderSectionHeader ? renderSectionHeader({section}) : null;
|
||||
} else {
|
||||
const {renderSectionFooter} = this.props;
|
||||
return renderSectionFooter ? renderSectionFooter({section}) : null;
|
||||
}
|
||||
} else {
|
||||
const renderItem = info.section.renderItem || this.props.renderItem;
|
||||
const SeparatorComponent = this._getSeparatorComponent(
|
||||
index,
|
||||
info,
|
||||
listItemCount,
|
||||
);
|
||||
invariant(renderItem, 'no renderItem!');
|
||||
return (
|
||||
<ItemWithSeparator
|
||||
SeparatorComponent={SeparatorComponent}
|
||||
LeadingSeparatorComponent={
|
||||
infoIndex === 0 ? this.props.SectionSeparatorComponent : undefined
|
||||
}
|
||||
cellKey={info.key}
|
||||
index={infoIndex}
|
||||
item={item}
|
||||
leadingItem={info.leadingItem}
|
||||
leadingSection={info.leadingSection}
|
||||
prevCellKey={(this._subExtractor(index - 1) || {}).key}
|
||||
// Callback to provide updateHighlight for this item
|
||||
setSelfHighlightCallback={this._setUpdateHighlightFor}
|
||||
setSelfUpdatePropsCallback={this._setUpdatePropsFor}
|
||||
// Provide child ability to set highlight/updateProps for previous item using prevCellKey
|
||||
updateHighlightFor={this._updateHighlightFor}
|
||||
updatePropsFor={this._updatePropsFor}
|
||||
renderItem={renderItem}
|
||||
section={info.section}
|
||||
trailingItem={info.trailingItem}
|
||||
trailingSection={info.trailingSection}
|
||||
inverted={!!this.props.inverted}
|
||||
/>
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
_updatePropsFor = (cellKey, value) => {
|
||||
const updateProps = this._updatePropsMap[cellKey];
|
||||
@@ -506,10 +499,8 @@ function ItemWithSeparator(props: ItemWithSeparatorProps): React.Node {
|
||||
inverted,
|
||||
} = props;
|
||||
|
||||
const [
|
||||
leadingSeparatorHiglighted,
|
||||
setLeadingSeparatorHighlighted,
|
||||
] = React.useState(false);
|
||||
const [leadingSeparatorHiglighted, setLeadingSeparatorHighlighted] =
|
||||
React.useState(false);
|
||||
|
||||
const [separatorHighlighted, setSeparatorHighlighted] = React.useState(false);
|
||||
|
||||
|
||||
@@ -40,13 +40,13 @@ function computeResult({helper, props, state, scroll}): number {
|
||||
);
|
||||
}
|
||||
|
||||
describe('computeBlankness', function() {
|
||||
describe('computeBlankness', function () {
|
||||
beforeEach(() => {
|
||||
FillRateHelper.setSampleRate(1);
|
||||
FillRateHelper.setMinSampleCount(0);
|
||||
});
|
||||
|
||||
it('computes correct blankness of viewport', function() {
|
||||
it('computes correct blankness of viewport', function () {
|
||||
const helper = new FillRateHelper(getFrameMetrics);
|
||||
rowFramesGlobal = {
|
||||
header: {y: 0, height: 0, inLayout: true},
|
||||
@@ -65,7 +65,7 @@ describe('computeBlankness', function() {
|
||||
expect(blankness).toBe(1);
|
||||
});
|
||||
|
||||
it('skips frames that are not in layout', function() {
|
||||
it('skips frames that are not in layout', function () {
|
||||
const helper = new FillRateHelper(getFrameMetrics);
|
||||
rowFramesGlobal = {
|
||||
header: {y: 0, height: 0, inLayout: false},
|
||||
@@ -79,7 +79,7 @@ describe('computeBlankness', function() {
|
||||
expect(blankness).toBe(0.3);
|
||||
});
|
||||
|
||||
it('sampling rate can disable', function() {
|
||||
it('sampling rate can disable', function () {
|
||||
let helper = new FillRateHelper(getFrameMetrics);
|
||||
rowFramesGlobal = {
|
||||
header: {y: 0, height: 0, inLayout: true},
|
||||
@@ -96,7 +96,7 @@ describe('computeBlankness', function() {
|
||||
expect(blankness).toBe(0);
|
||||
});
|
||||
|
||||
it('can handle multiple listeners and unsubscribe', function() {
|
||||
it('can handle multiple listeners and unsubscribe', function () {
|
||||
const listeners = [jest.fn(), jest.fn(), jest.fn()];
|
||||
const subscriptions = listeners.map(listener =>
|
||||
FillRateHelper.addListener(listener),
|
||||
|
||||
@@ -22,8 +22,8 @@ function createViewToken(index: number, isViewable: boolean) {
|
||||
return {key: data[index].key, isViewable};
|
||||
}
|
||||
|
||||
describe('computeViewableItems', function() {
|
||||
it('returns all 4 entirely visible rows as viewable', function() {
|
||||
describe('computeViewableItems', function () {
|
||||
it('returns all 4 entirely visible rows as viewable', function () {
|
||||
const helper = new ViewabilityHelper({
|
||||
viewAreaCoveragePercentThreshold: 50,
|
||||
});
|
||||
@@ -39,7 +39,7 @@ describe('computeViewableItems', function() {
|
||||
).toEqual([0, 1, 2, 3]);
|
||||
});
|
||||
|
||||
it('returns top 2 rows as viewable (1. entirely visible and 2. majority)', function() {
|
||||
it('returns top 2 rows as viewable (1. entirely visible and 2. majority)', function () {
|
||||
const helper = new ViewabilityHelper({
|
||||
viewAreaCoveragePercentThreshold: 50,
|
||||
});
|
||||
@@ -55,7 +55,7 @@ describe('computeViewableItems', function() {
|
||||
).toEqual([0, 1]);
|
||||
});
|
||||
|
||||
it('returns only 2nd row as viewable (majority)', function() {
|
||||
it('returns only 2nd row as viewable (majority)', function () {
|
||||
const helper = new ViewabilityHelper({
|
||||
viewAreaCoveragePercentThreshold: 50,
|
||||
});
|
||||
@@ -71,7 +71,7 @@ describe('computeViewableItems', function() {
|
||||
).toEqual([1]);
|
||||
});
|
||||
|
||||
it('handles empty input', function() {
|
||||
it('handles empty input', function () {
|
||||
const helper = new ViewabilityHelper({
|
||||
viewAreaCoveragePercentThreshold: 50,
|
||||
});
|
||||
@@ -82,7 +82,7 @@ describe('computeViewableItems', function() {
|
||||
).toEqual([]);
|
||||
});
|
||||
|
||||
it('handles different view area coverage percent thresholds', function() {
|
||||
it('handles different view area coverage percent thresholds', function () {
|
||||
rowFrames = {
|
||||
a: {y: 0, height: 50},
|
||||
b: {y: 50, height: 150},
|
||||
@@ -128,7 +128,7 @@ describe('computeViewableItems', function() {
|
||||
).toEqual([1, 2]);
|
||||
});
|
||||
|
||||
it('handles different item visible percent thresholds', function() {
|
||||
it('handles different item visible percent thresholds', function () {
|
||||
rowFrames = {
|
||||
a: {y: 0, height: 50},
|
||||
b: {y: 50, height: 150},
|
||||
@@ -165,8 +165,8 @@ describe('computeViewableItems', function() {
|
||||
});
|
||||
});
|
||||
|
||||
describe('onUpdate', function() {
|
||||
it('returns 1 visible row as viewable then scrolls away', function() {
|
||||
describe('onUpdate', function () {
|
||||
it('returns 1 visible row as viewable then scrolls away', function () {
|
||||
const helper = new ViewabilityHelper();
|
||||
rowFrames = {
|
||||
a: {y: 0, height: 50},
|
||||
@@ -212,7 +212,7 @@ describe('onUpdate', function() {
|
||||
});
|
||||
});
|
||||
|
||||
it('returns 1st visible row then 1st and 2nd then just 2nd', function() {
|
||||
it('returns 1st visible row then 1st and 2nd then just 2nd', function () {
|
||||
const helper = new ViewabilityHelper();
|
||||
rowFrames = {
|
||||
a: {y: 0, height: 200},
|
||||
@@ -268,7 +268,7 @@ describe('onUpdate', function() {
|
||||
});
|
||||
});
|
||||
|
||||
it('minimumViewTime delays callback', function() {
|
||||
it('minimumViewTime delays callback', function () {
|
||||
const helper = new ViewabilityHelper({
|
||||
minimumViewTime: 350,
|
||||
viewAreaCoveragePercentThreshold: 0,
|
||||
@@ -302,7 +302,7 @@ describe('onUpdate', function() {
|
||||
});
|
||||
});
|
||||
|
||||
it('minimumViewTime skips briefly visible items', function() {
|
||||
it('minimumViewTime skips briefly visible items', function () {
|
||||
const helper = new ViewabilityHelper({
|
||||
minimumViewTime: 350,
|
||||
viewAreaCoveragePercentThreshold: 0,
|
||||
@@ -343,7 +343,7 @@ describe('onUpdate', function() {
|
||||
});
|
||||
});
|
||||
|
||||
it('waitForInteraction blocks callback until interaction', function() {
|
||||
it('waitForInteraction blocks callback until interaction', function () {
|
||||
const helper = new ViewabilityHelper({
|
||||
waitForInteraction: true,
|
||||
viewAreaCoveragePercentThreshold: 0,
|
||||
@@ -385,7 +385,7 @@ describe('onUpdate', function() {
|
||||
});
|
||||
});
|
||||
|
||||
it('returns the right visible row after the underlying data changed', function() {
|
||||
it('returns the right visible row after the underlying data changed', function () {
|
||||
const helper = new ViewabilityHelper();
|
||||
rowFrames = {
|
||||
a: {y: 0, height: 200},
|
||||
|
||||
@@ -12,35 +12,35 @@
|
||||
|
||||
import {elementsThatOverlapOffsets, newRangeCount} from '../VirtualizeUtils';
|
||||
|
||||
describe('newRangeCount', function() {
|
||||
it('handles subset', function() {
|
||||
describe('newRangeCount', function () {
|
||||
it('handles subset', function () {
|
||||
expect(newRangeCount({first: 1, last: 4}, {first: 2, last: 3})).toBe(0);
|
||||
});
|
||||
it('handles forward disjoint set', function() {
|
||||
it('handles forward disjoint set', function () {
|
||||
expect(newRangeCount({first: 1, last: 4}, {first: 6, last: 9})).toBe(4);
|
||||
});
|
||||
it('handles reverse disjoint set', function() {
|
||||
it('handles reverse disjoint set', function () {
|
||||
expect(newRangeCount({first: 6, last: 8}, {first: 1, last: 4})).toBe(4);
|
||||
});
|
||||
it('handles superset', function() {
|
||||
it('handles superset', function () {
|
||||
expect(newRangeCount({first: 1, last: 4}, {first: 0, last: 5})).toBe(2);
|
||||
});
|
||||
it('handles end extension', function() {
|
||||
it('handles end extension', function () {
|
||||
expect(newRangeCount({first: 1, last: 4}, {first: 1, last: 8})).toBe(4);
|
||||
});
|
||||
it('handles front extension', function() {
|
||||
it('handles front extension', function () {
|
||||
expect(newRangeCount({first: 1, last: 4}, {first: 0, last: 4})).toBe(1);
|
||||
});
|
||||
it('handles forward intersect', function() {
|
||||
it('handles forward intersect', function () {
|
||||
expect(newRangeCount({first: 1, last: 4}, {first: 3, last: 6})).toBe(2);
|
||||
});
|
||||
it('handles reverse intersect', function() {
|
||||
it('handles reverse intersect', function () {
|
||||
expect(newRangeCount({first: 3, last: 6}, {first: 1, last: 4})).toBe(2);
|
||||
});
|
||||
});
|
||||
|
||||
describe('elementsThatOverlapOffsets', function() {
|
||||
it('handles fixed length', function() {
|
||||
describe('elementsThatOverlapOffsets', function () {
|
||||
it('handles fixed length', function () {
|
||||
const offsets = [0, 250, 350, 450];
|
||||
function getFrameMetrics(index: number) {
|
||||
return {
|
||||
@@ -49,13 +49,10 @@ describe('elementsThatOverlapOffsets', function() {
|
||||
};
|
||||
}
|
||||
expect(elementsThatOverlapOffsets(offsets, 100, getFrameMetrics)).toEqual([
|
||||
0,
|
||||
2,
|
||||
3,
|
||||
4,
|
||||
0, 2, 3, 4,
|
||||
]);
|
||||
});
|
||||
it('handles variable length', function() {
|
||||
it('handles variable length', function () {
|
||||
const offsets = [150, 250, 900];
|
||||
const frames = [
|
||||
{offset: 0, length: 50},
|
||||
@@ -68,7 +65,7 @@ describe('elementsThatOverlapOffsets', function() {
|
||||
elementsThatOverlapOffsets(offsets, frames.length, ii => frames[ii]),
|
||||
).toEqual([1, 1, 3]);
|
||||
});
|
||||
it('handles out of bounds', function() {
|
||||
it('handles out of bounds', function () {
|
||||
const offsets = [150, 900];
|
||||
const frames = [
|
||||
{offset: 0, length: 50},
|
||||
@@ -79,7 +76,7 @@ describe('elementsThatOverlapOffsets', function() {
|
||||
elementsThatOverlapOffsets(offsets, frames.length, ii => frames[ii]),
|
||||
).toEqual([1]);
|
||||
});
|
||||
it('errors on non-increasing offsets', function() {
|
||||
it('errors on non-increasing offsets', function () {
|
||||
const offsets = [150, 50];
|
||||
const frames = [
|
||||
{offset: 0, length: 50},
|
||||
|
||||
@@ -71,7 +71,7 @@ let updateTimeout = null;
|
||||
let _isDisabled = false;
|
||||
let _selectedIndex = -1;
|
||||
|
||||
let warningFilter: WarningFilter = function(format) {
|
||||
let warningFilter: WarningFilter = function (format) {
|
||||
return {
|
||||
finalFormat: format,
|
||||
forceDialogImmediately: false,
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user