feat(smart-app): implement complete mobile app MVP

- App.tsx: full navigation (Auth stack + Main tabs with 5 screens)
- Auth: LoginScreen, RegisterScreen, ForgotPasswordScreen
- HomeScreen: dashboard with IoT metrics, weather widget, alerts, quick actions, sensors
- MapScreen: interactive map with layer toggles (6 layers)
- MarketplaceScreen: categories (6), products (5), search
- ChatScreen: AI chat with quick prompts (4), bot responses
- ProfileScreen: user info, stats, menu (9 items), logout
- AlertsScreen: alert list with severity, acknowledge
- SensorsScreen: sensor list with type filters (6 types), search
- ZonesScreen: zone cards with stats
- SettingsScreen: language picker (FR/EN/ES/DE), privacy, about
- Stores: iotStore (sensors, zones, alerts), notificationStore, uiStore + i18n
- Hooks: useSensors, useAlerts, useNotifications, useLocation
- Components: Card, Button, LoadingSpinner, ErrorBoundary, Header
- Services: iotService, notificationService (with axios API client)
- Utils: formatters (temp, AQI, noise, dates), validators (email, password, IBAN)
- Theme: colors.ts with full design system (Blue Ocean palette)
- Ditto: fixed MongoDB connection, new JWT secrets, official gateway image
This commit is contained in:
Eric FELIXINE
2026-06-01 18:00:35 -04:00
parent 08ca495bde
commit e30ae8ed09
35578 changed files with 3703534 additions and 43 deletions

View File

@@ -0,0 +1,11 @@
import createHandler from './createHandler';
import { baseGestureHandlerProps } from './gestureHandlerCommon';
export const flingGestureHandlerProps = ['numberOfPointers', 'direction'];
export const flingHandlerName = 'FlingGestureHandler';
// eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; see description on the top of gestureHandlerCommon.ts file
export const FlingGestureHandler = createHandler({
name: flingHandlerName,
allowedProps: [...baseGestureHandlerProps, ...flingGestureHandlerProps],
config: {}
});
//# sourceMappingURL=FlingGestureHandler.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["FlingGestureHandler.ts"],"names":["createHandler","baseGestureHandlerProps","flingGestureHandlerProps","flingHandlerName","FlingGestureHandler","name","allowedProps","config"],"mappings":"AAAA,OAAOA,aAAP,MAA0B,iBAA1B;AACA,SAEEC,uBAFF,QAGO,wBAHP;AAKA,OAAO,MAAMC,wBAAwB,GAAG,CACtC,kBADsC,EAEtC,WAFsC,CAAjC;AAsCP,OAAO,MAAMC,gBAAgB,GAAG,qBAAzB;AAGP;AACA,OAAO,MAAMC,mBAAmB,GAAGJ,aAAa,CAG9C;AACAK,EAAAA,IAAI,EAAEF,gBADN;AAEAG,EAAAA,YAAY,EAAE,CACZ,GAAGL,uBADS,EAEZ,GAAGC,wBAFS,CAFd;AAMAK,EAAAA,MAAM,EAAE;AANR,CAH8C,CAAzC","sourcesContent":["import createHandler from './createHandler';\nimport {\n BaseGestureHandlerProps,\n baseGestureHandlerProps,\n} from './gestureHandlerCommon';\n\nexport const flingGestureHandlerProps = [\n 'numberOfPointers',\n 'direction',\n] as const;\n\nexport type FlingGestureHandlerEventPayload = {\n x: number;\n y: number;\n absoluteX: number;\n absoluteY: number;\n};\nexport interface FlingGestureConfig {\n /**\n * Expressed allowed direction of movement. It's possible to pass one or many\n * directions in one parameter:\n *\n * ```js\n * direction={Directions.RIGHT | Directions.LEFT}\n * ```\n *\n * or\n *\n * ```js\n * direction={Directions.DOWN}\n * ```\n */\n direction?: number;\n\n /**\n * Determine exact number of points required to handle the fling gesture.\n */\n numberOfPointers?: number;\n}\n\nexport interface FlingGestureHandlerProps\n extends BaseGestureHandlerProps<FlingGestureHandlerEventPayload>,\n FlingGestureConfig {}\n\nexport const flingHandlerName = 'FlingGestureHandler';\n\nexport type FlingGestureHandler = typeof FlingGestureHandler;\n// eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; see description on the top of gestureHandlerCommon.ts file\nexport const FlingGestureHandler = createHandler<\n FlingGestureHandlerProps,\n FlingGestureHandlerEventPayload\n>({\n name: flingHandlerName,\n allowedProps: [\n ...baseGestureHandlerProps,\n ...flingGestureHandlerProps,\n ] as const,\n config: {},\n});\n"]}

View File

@@ -0,0 +1,31 @@
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
import React from 'react';
import { tagMessage } from '../utils';
import PlatformConstants from '../PlatformConstants';
import createHandler from './createHandler';
import { baseGestureHandlerProps } from './gestureHandlerCommon';
export const forceTouchGestureHandlerProps = ['minForce', 'maxForce', 'feedbackOnActivation']; // implicit `children` prop has been removed in @types/react^18.0.0
class ForceTouchFallback extends React.Component {
componentDidMount() {
console.warn(tagMessage('ForceTouchGestureHandler is not available on this platform. Please use ForceTouchGestureHandler.forceTouchAvailable to conditionally render other components that would provide a fallback behavior specific to your usecase'));
}
render() {
return this.props.children;
}
}
_defineProperty(ForceTouchFallback, "forceTouchAvailable", false);
export const forceTouchHandlerName = 'ForceTouchGestureHandler'; // eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; see description on the top of gestureHandlerCommon.ts file
export const ForceTouchGestureHandler = PlatformConstants !== null && PlatformConstants !== void 0 && PlatformConstants.forceTouchAvailable ? createHandler({
name: forceTouchHandlerName,
allowedProps: [...baseGestureHandlerProps, ...forceTouchGestureHandlerProps],
config: {}
}) : ForceTouchFallback;
ForceTouchGestureHandler.forceTouchAvailable = (PlatformConstants === null || PlatformConstants === void 0 ? void 0 : PlatformConstants.forceTouchAvailable) || false;
//# sourceMappingURL=ForceTouchGestureHandler.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["ForceTouchGestureHandler.ts"],"names":["React","tagMessage","PlatformConstants","createHandler","baseGestureHandlerProps","forceTouchGestureHandlerProps","ForceTouchFallback","Component","componentDidMount","console","warn","render","props","children","forceTouchHandlerName","ForceTouchGestureHandler","forceTouchAvailable","name","allowedProps","config"],"mappings":";;AAAA,OAAOA,KAAP,MAAyC,OAAzC;AACA,SAASC,UAAT,QAA2B,UAA3B;AACA,OAAOC,iBAAP,MAA8B,sBAA9B;AACA,OAAOC,aAAP,MAA0B,iBAA1B;AACA,SAEEC,uBAFF,QAGO,wBAHP;AAKA,OAAO,MAAMC,6BAA6B,GAAG,CAC3C,UAD2C,EAE3C,UAF2C,EAG3C,sBAH2C,CAAtC,C,CAMP;;AACA,MAAMC,kBAAN,SAAiCN,KAAK,CAACO,SAAvC,CAA6E;AAE3EC,EAAAA,iBAAiB,GAAG;AAClBC,IAAAA,OAAO,CAACC,IAAR,CACET,UAAU,CACR,8NADQ,CADZ;AAKD;;AACDU,EAAAA,MAAM,GAAG;AACP,WAAO,KAAKC,KAAL,CAAWC,QAAlB;AACD;;AAX0E;;gBAAvEP,kB,yBACyB,K;;AAsD/B,OAAO,MAAMQ,qBAAqB,GAAG,0BAA9B,C,CAEP;;AACA,OAAO,MAAMC,wBAAwB,GAAGb,iBAAiB,SAAjB,IAAAA,iBAAiB,WAAjB,IAAAA,iBAAiB,CAAEc,mBAAnB,GACpCb,aAAa,CAGX;AACAc,EAAAA,IAAI,EAAEH,qBADN;AAEAI,EAAAA,YAAY,EAAE,CACZ,GAAGd,uBADS,EAEZ,GAAGC,6BAFS,CAFd;AAMAc,EAAAA,MAAM,EAAE;AANR,CAHW,CADuB,GAYpCb,kBAZG;AAcNS,wBAAD,CAAuDC,mBAAvD,GACE,CAAAd,iBAAiB,SAAjB,IAAAA,iBAAiB,WAAjB,YAAAA,iBAAiB,CAAEc,mBAAnB,KAA0C,KAD5C","sourcesContent":["import React, { PropsWithChildren } from 'react';\nimport { tagMessage } from '../utils';\nimport PlatformConstants from '../PlatformConstants';\nimport createHandler from './createHandler';\nimport {\n BaseGestureHandlerProps,\n baseGestureHandlerProps,\n} from './gestureHandlerCommon';\n\nexport const forceTouchGestureHandlerProps = [\n 'minForce',\n 'maxForce',\n 'feedbackOnActivation',\n] as const;\n\n// implicit `children` prop has been removed in @types/react^18.0.0\nclass ForceTouchFallback extends React.Component<PropsWithChildren<unknown>> {\n static forceTouchAvailable = false;\n componentDidMount() {\n console.warn(\n tagMessage(\n 'ForceTouchGestureHandler is not available on this platform. Please use ForceTouchGestureHandler.forceTouchAvailable to conditionally render other components that would provide a fallback behavior specific to your usecase'\n )\n );\n }\n render() {\n return this.props.children;\n }\n}\n\nexport type ForceTouchGestureHandlerEventPayload = {\n x: number;\n y: number;\n absoluteX: number;\n absoluteY: number;\n\n /**\n * The pressure of a touch.\n */\n force: number;\n};\n\nexport interface ForceTouchGestureConfig {\n /**\n *\n * A minimal pressure that is required before handler can activate. Should be a\n * value from range `[0.0, 1.0]`. Default is `0.2`.\n */\n minForce?: number;\n\n /**\n * A maximal pressure that could be applied for handler. If the pressure is\n * greater, handler fails. Should be a value from range `[0.0, 1.0]`.\n */\n maxForce?: number;\n\n /**\n * Boolean value defining if haptic feedback has to be performed on\n * activation.\n */\n feedbackOnActivation?: boolean;\n}\n\nexport interface ForceTouchGestureHandlerProps\n extends BaseGestureHandlerProps<ForceTouchGestureHandlerEventPayload>,\n ForceTouchGestureConfig {}\n\nexport type ForceTouchGestureHandler = typeof ForceTouchGestureHandler & {\n forceTouchAvailable: boolean;\n};\n\nexport const forceTouchHandlerName = 'ForceTouchGestureHandler';\n\n// eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; see description on the top of gestureHandlerCommon.ts file\nexport const ForceTouchGestureHandler = PlatformConstants?.forceTouchAvailable\n ? createHandler<\n ForceTouchGestureHandlerProps,\n ForceTouchGestureHandlerEventPayload\n >({\n name: forceTouchHandlerName,\n allowedProps: [\n ...baseGestureHandlerProps,\n ...forceTouchGestureHandlerProps,\n ] as const,\n config: {},\n })\n : ForceTouchFallback;\n\n(ForceTouchGestureHandler as ForceTouchGestureHandler).forceTouchAvailable =\n PlatformConstants?.forceTouchAvailable || false;\n"]}

View File

@@ -0,0 +1,13 @@
import createHandler from './createHandler';
import { baseGestureHandlerProps } from './gestureHandlerCommon';
export const longPressGestureHandlerProps = ['minDurationMs', 'maxDist'];
export const longPressHandlerName = 'LongPressGestureHandler';
// eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; see description on the top of gestureHandlerCommon.ts file
export const LongPressGestureHandler = createHandler({
name: longPressHandlerName,
allowedProps: [...baseGestureHandlerProps, ...longPressGestureHandlerProps],
config: {
shouldCancelWhenOutside: true
}
});
//# sourceMappingURL=LongPressGestureHandler.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["LongPressGestureHandler.ts"],"names":["createHandler","baseGestureHandlerProps","longPressGestureHandlerProps","longPressHandlerName","LongPressGestureHandler","name","allowedProps","config","shouldCancelWhenOutside"],"mappings":"AAAA,OAAOA,aAAP,MAA0B,iBAA1B;AACA,SAEEC,uBAFF,QAGO,wBAHP;AAKA,OAAO,MAAMC,4BAA4B,GAAG,CAC1C,eAD0C,EAE1C,SAF0C,CAArC;AAiEP,OAAO,MAAMC,oBAAoB,GAAG,yBAA7B;AAGP;AACA,OAAO,MAAMC,uBAAuB,GAAGJ,aAAa,CAGlD;AACAK,EAAAA,IAAI,EAAEF,oBADN;AAEAG,EAAAA,YAAY,EAAE,CACZ,GAAGL,uBADS,EAEZ,GAAGC,4BAFS,CAFd;AAMAK,EAAAA,MAAM,EAAE;AACNC,IAAAA,uBAAuB,EAAE;AADnB;AANR,CAHkD,CAA7C","sourcesContent":["import createHandler from './createHandler';\nimport {\n BaseGestureHandlerProps,\n baseGestureHandlerProps,\n} from './gestureHandlerCommon';\n\nexport const longPressGestureHandlerProps = [\n 'minDurationMs',\n 'maxDist',\n] as const;\n\nexport type LongPressGestureHandlerEventPayload = {\n /**\n * X coordinate, expressed in points, of the current position of the pointer\n * (finger or a leading pointer when there are multiple fingers placed)\n * relative to the view attached to the handler.\n */\n x: number;\n\n /**\n * Y coordinate, expressed in points, of the current position of the pointer\n * (finger or a leading pointer when there are multiple fingers placed)\n * relative to the view attached to the handler.\n */\n y: number;\n\n /**\n * X coordinate, expressed in points, of the current position of the pointer\n * (finger or a leading pointer when there are multiple fingers placed)\n * relative to the window. It is recommended to use `absoluteX` instead of\n * `x` in cases when the view attached to the handler can be transformed as an\n * effect of the gesture.\n */\n absoluteX: number;\n\n /**\n * Y coordinate, expressed in points, of the current position of the pointer\n * (finger or a leading pointer when there are multiple fingers placed)\n * relative to the window. It is recommended to use `absoluteY` instead of\n * `y` in cases when the view attached to the handler can be transformed as an\n * effect of the gesture.\n */\n absoluteY: number;\n\n /**\n * Duration of the long press (time since the start of the event), expressed\n * in milliseconds.\n */\n duration: number;\n};\n\nexport interface LongPressGestureConfig {\n /**\n * Minimum time, expressed in milliseconds, that a finger must remain pressed on\n * the corresponding view. The default value is 500.\n */\n minDurationMs?: number;\n\n /**\n * Maximum distance, expressed in points, that defines how far the finger is\n * allowed to travel during a long press gesture. If the finger travels\n * further than the defined distance and the handler hasn't yet activated, it\n * will fail to recognize the gesture. The default value is 10.\n */\n maxDist?: number;\n}\n\nexport interface LongPressGestureHandlerProps\n extends BaseGestureHandlerProps<LongPressGestureHandlerEventPayload>,\n LongPressGestureConfig {}\n\nexport const longPressHandlerName = 'LongPressGestureHandler';\n\nexport type LongPressGestureHandler = typeof LongPressGestureHandler;\n// eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; see description on the top of gestureHandlerCommon.ts file\nexport const LongPressGestureHandler = createHandler<\n LongPressGestureHandlerProps,\n LongPressGestureHandlerEventPayload\n>({\n name: longPressHandlerName,\n allowedProps: [\n ...baseGestureHandlerProps,\n ...longPressGestureHandlerProps,\n ] as const,\n config: {\n shouldCancelWhenOutside: true,\n },\n});\n"]}

View File

@@ -0,0 +1,12 @@
import createHandler from './createHandler';
import { baseGestureHandlerProps } from './gestureHandlerCommon';
export const nativeViewGestureHandlerProps = ['shouldActivateOnStart', 'disallowInterruption'];
export const nativeViewProps = [...baseGestureHandlerProps, ...nativeViewGestureHandlerProps];
export const nativeViewHandlerName = 'NativeViewGestureHandler';
// eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; see description on the top of gestureHandlerCommon.ts file
export const NativeViewGestureHandler = createHandler({
name: nativeViewHandlerName,
allowedProps: nativeViewProps,
config: {}
});
//# sourceMappingURL=NativeViewGestureHandler.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["NativeViewGestureHandler.ts"],"names":["createHandler","baseGestureHandlerProps","nativeViewGestureHandlerProps","nativeViewProps","nativeViewHandlerName","NativeViewGestureHandler","name","allowedProps","config"],"mappings":"AAAA,OAAOA,aAAP,MAA0B,iBAA1B;AACA,SAEEC,uBAFF,QAGO,wBAHP;AAKA,OAAO,MAAMC,6BAA6B,GAAG,CAC3C,uBAD2C,EAE3C,sBAF2C,CAAtC;AAgCP,OAAO,MAAMC,eAAe,GAAG,CAC7B,GAAGF,uBAD0B,EAE7B,GAAGC,6BAF0B,CAAxB;AAKP,OAAO,MAAME,qBAAqB,GAAG,0BAA9B;AAGP;AACA,OAAO,MAAMC,wBAAwB,GAAGL,aAAa,CAGnD;AACAM,EAAAA,IAAI,EAAEF,qBADN;AAEAG,EAAAA,YAAY,EAAEJ,eAFd;AAGAK,EAAAA,MAAM,EAAE;AAHR,CAHmD,CAA9C","sourcesContent":["import createHandler from './createHandler';\nimport {\n BaseGestureHandlerProps,\n baseGestureHandlerProps,\n} from './gestureHandlerCommon';\n\nexport const nativeViewGestureHandlerProps = [\n 'shouldActivateOnStart',\n 'disallowInterruption',\n] as const;\n\nexport interface NativeViewGestureConfig {\n /**\n * Android only.\n *\n * Determines whether the handler should check for an existing touch event on\n * instantiation.\n */\n shouldActivateOnStart?: boolean;\n\n /**\n * When `true`, cancels all other gesture handlers when this\n * `NativeViewGestureHandler` receives an `ACTIVE` state event.\n */\n disallowInterruption?: boolean;\n}\n\nexport interface NativeViewGestureHandlerProps\n extends BaseGestureHandlerProps<NativeViewGestureHandlerPayload>,\n NativeViewGestureConfig {}\n\nexport type NativeViewGestureHandlerPayload = {\n /**\n * True if gesture was performed inside of containing view, false otherwise.\n */\n pointerInside: boolean;\n};\n\nexport const nativeViewProps = [\n ...baseGestureHandlerProps,\n ...nativeViewGestureHandlerProps,\n] as const;\n\nexport const nativeViewHandlerName = 'NativeViewGestureHandler';\n\nexport type NativeViewGestureHandler = typeof NativeViewGestureHandler;\n// eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; see description on the top of gestureHandlerCommon.ts file\nexport const NativeViewGestureHandler = createHandler<\n NativeViewGestureHandlerProps,\n NativeViewGestureHandlerPayload\n>({\n name: nativeViewHandlerName,\n allowedProps: nativeViewProps,\n config: {},\n});\n"]}

View File

@@ -0,0 +1,107 @@
import createHandler from './createHandler';
import { baseGestureHandlerProps } from './gestureHandlerCommon';
export const panGestureHandlerProps = ['activeOffsetY', 'activeOffsetX', 'failOffsetY', 'failOffsetX', 'minDist', 'minVelocity', 'minVelocityX', 'minVelocityY', 'minPointers', 'maxPointers', 'avgTouches', 'enableTrackpadTwoFingerGesture', 'activateAfterLongPress'];
export const panGestureHandlerCustomNativeProps = ['activeOffsetYStart', 'activeOffsetYEnd', 'activeOffsetXStart', 'activeOffsetXEnd', 'failOffsetYStart', 'failOffsetYEnd', 'failOffsetXStart', 'failOffsetXEnd'];
export const panHandlerName = 'PanGestureHandler';
// eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; see description on the top of gestureHandlerCommon.ts file
export const PanGestureHandler = createHandler({
name: panHandlerName,
allowedProps: [...baseGestureHandlerProps, ...panGestureHandlerProps],
config: {},
transformProps: managePanProps,
customNativeProps: panGestureHandlerCustomNativeProps
});
function validatePanGestureHandlerProps(props) {
if (Array.isArray(props.activeOffsetX) && (props.activeOffsetX[0] > 0 || props.activeOffsetX[1] < 0)) {
throw new Error(`First element of activeOffsetX should be negative, a the second one should be positive`);
}
if (Array.isArray(props.activeOffsetY) && (props.activeOffsetY[0] > 0 || props.activeOffsetY[1] < 0)) {
throw new Error(`First element of activeOffsetY should be negative, a the second one should be positive`);
}
if (Array.isArray(props.failOffsetX) && (props.failOffsetX[0] > 0 || props.failOffsetX[1] < 0)) {
throw new Error(`First element of failOffsetX should be negative, a the second one should be positive`);
}
if (Array.isArray(props.failOffsetY) && (props.failOffsetY[0] > 0 || props.failOffsetY[1] < 0)) {
throw new Error(`First element of failOffsetY should be negative, a the second one should be positive`);
}
if (props.minDist && (props.failOffsetX || props.failOffsetY)) {
throw new Error(`It is not supported to use minDist with failOffsetX or failOffsetY, use activeOffsetX and activeOffsetY instead`);
}
if (props.minDist && (props.activeOffsetX || props.activeOffsetY)) {
throw new Error(`It is not supported to use minDist with activeOffsetX or activeOffsetY`);
}
}
function transformPanGestureHandlerProps(props) {
const res = { ...props
};
if (props.activeOffsetX !== undefined) {
delete res.activeOffsetX;
if (Array.isArray(props.activeOffsetX)) {
res.activeOffsetXStart = props.activeOffsetX[0];
res.activeOffsetXEnd = props.activeOffsetX[1];
} else if (props.activeOffsetX < 0) {
res.activeOffsetXStart = props.activeOffsetX;
} else {
res.activeOffsetXEnd = props.activeOffsetX;
}
}
if (props.activeOffsetY !== undefined) {
delete res.activeOffsetY;
if (Array.isArray(props.activeOffsetY)) {
res.activeOffsetYStart = props.activeOffsetY[0];
res.activeOffsetYEnd = props.activeOffsetY[1];
} else if (props.activeOffsetY < 0) {
res.activeOffsetYStart = props.activeOffsetY;
} else {
res.activeOffsetYEnd = props.activeOffsetY;
}
}
if (props.failOffsetX !== undefined) {
delete res.failOffsetX;
if (Array.isArray(props.failOffsetX)) {
res.failOffsetXStart = props.failOffsetX[0];
res.failOffsetXEnd = props.failOffsetX[1];
} else if (props.failOffsetX < 0) {
res.failOffsetXStart = props.failOffsetX;
} else {
res.failOffsetXEnd = props.failOffsetX;
}
}
if (props.failOffsetY !== undefined) {
delete res.failOffsetY;
if (Array.isArray(props.failOffsetY)) {
res.failOffsetYStart = props.failOffsetY[0];
res.failOffsetYEnd = props.failOffsetY[1];
} else if (props.failOffsetY < 0) {
res.failOffsetYStart = props.failOffsetY;
} else {
res.failOffsetYEnd = props.failOffsetY;
}
}
return res;
}
export function managePanProps(props) {
if (__DEV__) {
validatePanGestureHandlerProps(props);
}
return transformPanGestureHandlerProps(props);
}
//# sourceMappingURL=PanGestureHandler.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,10 @@
import createHandler from './createHandler';
import { baseGestureHandlerProps } from './gestureHandlerCommon';
export const pinchHandlerName = 'PinchGestureHandler';
// eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; see description on the top of gestureHandlerCommon.ts file
export const PinchGestureHandler = createHandler({
name: pinchHandlerName,
allowedProps: baseGestureHandlerProps,
config: {}
});
//# sourceMappingURL=PinchGestureHandler.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["PinchGestureHandler.ts"],"names":["createHandler","baseGestureHandlerProps","pinchHandlerName","PinchGestureHandler","name","allowedProps","config"],"mappings":"AAAA,OAAOA,aAAP,MAA0B,iBAA1B;AACA,SAEEC,uBAFF,QAGO,wBAHP;AAmCA,OAAO,MAAMC,gBAAgB,GAAG,qBAAzB;AAGP;AACA,OAAO,MAAMC,mBAAmB,GAAGH,aAAa,CAG9C;AACAI,EAAAA,IAAI,EAAEF,gBADN;AAEAG,EAAAA,YAAY,EAAEJ,uBAFd;AAGAK,EAAAA,MAAM,EAAE;AAHR,CAH8C,CAAzC","sourcesContent":["import createHandler from './createHandler';\nimport {\n BaseGestureHandlerProps,\n baseGestureHandlerProps,\n} from './gestureHandlerCommon';\n\nexport type PinchGestureHandlerEventPayload = {\n /**\n * The scale factor relative to the points of the two touches in screen\n * coordinates.\n */\n scale: number;\n\n /**\n * Position expressed in points along X axis of center anchor point of\n * gesture.\n */\n focalX: number;\n\n /**\n * Position expressed in points along Y axis of center anchor point of\n * gesture.\n */\n focalY: number;\n\n /**\n *\n * Velocity of the pan gesture the current moment. The value is expressed in\n * point units per second.\n */\n velocity: number;\n};\n\nexport interface PinchGestureHandlerProps\n extends BaseGestureHandlerProps<PinchGestureHandlerEventPayload> {}\n\nexport const pinchHandlerName = 'PinchGestureHandler';\n\nexport type PinchGestureHandler = typeof PinchGestureHandler;\n// eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; see description on the top of gestureHandlerCommon.ts file\nexport const PinchGestureHandler = createHandler<\n PinchGestureHandlerProps,\n PinchGestureHandlerEventPayload\n>({\n name: pinchHandlerName,\n allowedProps: baseGestureHandlerProps,\n config: {},\n});\n"]}

View File

@@ -0,0 +1,3 @@
// @ts-ignore it's not exported so we need to import it from path
export { PressabilityDebugView } from 'react-native/Libraries/Pressability/PressabilityDebug';
//# sourceMappingURL=PressabilityDebugView.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["PressabilityDebugView.tsx"],"names":["PressabilityDebugView"],"mappings":"AAAA;AACA,SAASA,qBAAT,QAAsC,uDAAtC","sourcesContent":["// @ts-ignore it's not exported so we need to import it from path\nexport { PressabilityDebugView } from 'react-native/Libraries/Pressability/PressabilityDebug';\n"]}

View File

@@ -0,0 +1,5 @@
// PressabilityDebugView is not implemented in react-native-web
export function PressabilityDebugView() {
return null;
}
//# sourceMappingURL=PressabilityDebugView.web.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["PressabilityDebugView.web.tsx"],"names":["PressabilityDebugView"],"mappings":"AAAA;AACA,OAAO,SAASA,qBAAT,GAAiC;AACtC,SAAO,IAAP;AACD","sourcesContent":["// PressabilityDebugView is not implemented in react-native-web\nexport function PressabilityDebugView() {\n return null;\n}\n"]}

View File

@@ -0,0 +1,10 @@
import createHandler from './createHandler';
import { baseGestureHandlerProps } from './gestureHandlerCommon';
export const rotationHandlerName = 'RotationGestureHandler';
// eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; see description on the top of gestureHandlerCommon.ts file
export const RotationGestureHandler = createHandler({
name: rotationHandlerName,
allowedProps: baseGestureHandlerProps,
config: {}
});
//# sourceMappingURL=RotationGestureHandler.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["RotationGestureHandler.ts"],"names":["createHandler","baseGestureHandlerProps","rotationHandlerName","RotationGestureHandler","name","allowedProps","config"],"mappings":"AAAA,OAAOA,aAAP,MAA0B,iBAA1B;AACA,SAEEC,uBAFF,QAGO,wBAHP;AAmCA,OAAO,MAAMC,mBAAmB,GAAG,wBAA5B;AAGP;AACA,OAAO,MAAMC,sBAAsB,GAAGH,aAAa,CAGjD;AACAI,EAAAA,IAAI,EAAEF,mBADN;AAEAG,EAAAA,YAAY,EAAEJ,uBAFd;AAGAK,EAAAA,MAAM,EAAE;AAHR,CAHiD,CAA5C","sourcesContent":["import createHandler from './createHandler';\nimport {\n BaseGestureHandlerProps,\n baseGestureHandlerProps,\n} from './gestureHandlerCommon';\n\nexport type RotationGestureHandlerEventPayload = {\n /**\n * Amount rotated, expressed in radians, from the gesture's focal point\n * (anchor).\n */\n rotation: number;\n\n /**\n * X coordinate, expressed in points, of the gesture's central focal point\n * (anchor).\n */\n anchorX: number;\n\n /**\n * Y coordinate, expressed in points, of the gesture's central focal point\n * (anchor).\n */\n anchorY: number;\n\n /**\n *\n * Instantaneous velocity, expressed in point units per second, of the\n * gesture.\n */\n velocity: number;\n};\n\nexport interface RotationGestureHandlerProps\n extends BaseGestureHandlerProps<RotationGestureHandlerEventPayload> {}\n\nexport const rotationHandlerName = 'RotationGestureHandler';\n\nexport type RotationGestureHandler = typeof RotationGestureHandler;\n// eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; see description on the top of gestureHandlerCommon.ts file\nexport const RotationGestureHandler = createHandler<\n RotationGestureHandlerProps,\n RotationGestureHandlerEventPayload\n>({\n name: rotationHandlerName,\n allowedProps: baseGestureHandlerProps,\n config: {},\n});\n"]}

View File

@@ -0,0 +1,13 @@
import createHandler from './createHandler';
import { baseGestureHandlerProps } from './gestureHandlerCommon';
export const tapGestureHandlerProps = ['maxDurationMs', 'maxDelayMs', 'numberOfTaps', 'maxDeltaX', 'maxDeltaY', 'maxDist', 'minPointers'];
export const tapHandlerName = 'TapGestureHandler';
// eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; see description on the top of gestureHandlerCommon.ts file
export const TapGestureHandler = createHandler({
name: tapHandlerName,
allowedProps: [...baseGestureHandlerProps, ...tapGestureHandlerProps],
config: {
shouldCancelWhenOutside: true
}
});
//# sourceMappingURL=TapGestureHandler.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["TapGestureHandler.ts"],"names":["createHandler","baseGestureHandlerProps","tapGestureHandlerProps","tapHandlerName","TapGestureHandler","name","allowedProps","config","shouldCancelWhenOutside"],"mappings":"AAAA,OAAOA,aAAP,MAA0B,iBAA1B;AACA,SAEEC,uBAFF,QAGO,wBAHP;AAKA,OAAO,MAAMC,sBAAsB,GAAG,CACpC,eADoC,EAEpC,YAFoC,EAGpC,cAHoC,EAIpC,WAJoC,EAKpC,WALoC,EAMpC,SANoC,EAOpC,aAPoC,CAA/B;AAuEP,OAAO,MAAMC,cAAc,GAAG,mBAAvB;AAGP;AACA,OAAO,MAAMC,iBAAiB,GAAGJ,aAAa,CAG5C;AACAK,EAAAA,IAAI,EAAEF,cADN;AAEAG,EAAAA,YAAY,EAAE,CACZ,GAAGL,uBADS,EAEZ,GAAGC,sBAFS,CAFd;AAMAK,EAAAA,MAAM,EAAE;AACNC,IAAAA,uBAAuB,EAAE;AADnB;AANR,CAH4C,CAAvC","sourcesContent":["import createHandler from './createHandler';\nimport {\n BaseGestureHandlerProps,\n baseGestureHandlerProps,\n} from './gestureHandlerCommon';\n\nexport const tapGestureHandlerProps = [\n 'maxDurationMs',\n 'maxDelayMs',\n 'numberOfTaps',\n 'maxDeltaX',\n 'maxDeltaY',\n 'maxDist',\n 'minPointers',\n] as const;\n\nexport type TapGestureHandlerEventPayload = {\n x: number;\n y: number;\n absoluteX: number;\n absoluteY: number;\n};\nexport interface TapGestureConfig {\n /**\n * Minimum number of pointers (fingers) required to be placed before the\n * handler activates. Should be a positive integer.\n * The default value is 1.\n */\n minPointers?: number;\n\n /**\n * Maximum time, expressed in milliseconds, that defines how fast a finger\n * must be released after a touch. The default value is 500.\n */\n maxDurationMs?: number;\n\n /**\n * Maximum time, expressed in milliseconds, that can pass before the next tap\n * if many taps are required. The default value is 500.\n */\n maxDelayMs?: number;\n\n /**\n * Number of tap gestures required to activate the handler. The default value\n * is 1.\n */\n numberOfTaps?: number;\n\n /**\n * Maximum distance, expressed in points, that defines how far the finger is\n * allowed to travel along the X axis during a tap gesture. If the finger\n * travels further than the defined distance along the X axis and the handler\n * hasn't yet activated, it will fail to recognize the gesture.\n */\n maxDeltaX?: number;\n\n /**\n * Maximum distance, expressed in points, that defines how far the finger is\n * allowed to travel along the Y axis during a tap gesture. If the finger\n * travels further than the defined distance along the Y axis and the handler\n * hasn't yet activated, it will fail to recognize the gesture.\n */\n maxDeltaY?: number;\n\n /**\n * Maximum distance, expressed in points, that defines how far the finger is\n * allowed to travel during a tap gesture. If the finger travels further than\n * the defined distance and the handler hasn't yet\n * activated, it will fail to recognize the gesture.\n */\n maxDist?: number;\n}\n\nexport interface TapGestureHandlerProps\n extends BaseGestureHandlerProps<TapGestureHandlerEventPayload>,\n TapGestureConfig {}\n\nexport const tapHandlerName = 'TapGestureHandler';\n\nexport type TapGestureHandler = typeof TapGestureHandler;\n// eslint-disable-next-line @typescript-eslint/no-redeclare -- backward compatibility; see description on the top of gestureHandlerCommon.ts file\nexport const TapGestureHandler = createHandler<\n TapGestureHandlerProps,\n TapGestureHandlerEventPayload\n>({\n name: tapHandlerName,\n allowedProps: [\n ...baseGestureHandlerProps,\n ...tapGestureHandlerProps,\n ] as const,\n config: {\n shouldCancelWhenOutside: true,\n },\n});\n"]}

View File

@@ -0,0 +1,443 @@
var _UIManagerAny$getView, _UIManagerAny$getView2, _UIManagerAny$getCons;
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
import * as React from 'react';
import { Platform, UIManager, DeviceEventEmitter } from 'react-native';
import { customDirectEventTypes } from './customDirectEventTypes'; // @ts-ignore - it isn't typed by TS & don't have definitelyTyped types
import deepEqual from 'lodash/isEqual';
import RNGestureHandlerModule from '../RNGestureHandlerModule';
import { State } from '../State';
import { handlerIDToTag, getNextHandlerTag, registerOldGestureHandler } from './handlersRegistry';
import { filterConfig, findNodeHandle, scheduleFlushOperations } from './gestureHandlerCommon';
import { isFabric, isJestEnv, tagMessage } from '../utils';
import { ActionType } from '../ActionType';
import { PressabilityDebugView } from './PressabilityDebugView';
import GestureHandlerRootViewContext from '../GestureHandlerRootViewContext';
import { ghQueueMicrotask } from '../ghQueueMicrotask';
const UIManagerAny = UIManager;
customDirectEventTypes.topGestureHandlerEvent = {
registrationName: 'onGestureHandlerEvent'
};
const customGHEventsConfigFabricAndroid = {
topOnGestureHandlerEvent: {
registrationName: 'onGestureHandlerEvent'
},
topOnGestureHandlerStateChange: {
registrationName: 'onGestureHandlerStateChange'
}
};
const customGHEventsConfig = {
onGestureHandlerEvent: {
registrationName: 'onGestureHandlerEvent'
},
onGestureHandlerStateChange: {
registrationName: 'onGestureHandlerStateChange'
},
// When using React Native Gesture Handler for Animated.event with useNativeDriver: true
// on Android with Fabric enabled, the native part still sends the native events to JS
// but prefixed with "top". We cannot simply rename the events above so they are prefixed
// with "top" instead of "on" because in such case Animated.events would not be registered.
// That's why we need to register another pair of event names.
// The incoming events will be queued but never handled.
// Without this piece of code below, you'll get the following JS error:
// Unsupported top level event type "topOnGestureHandlerEvent" dispatched
...(isFabric() && Platform.OS === 'android' && customGHEventsConfigFabricAndroid)
}; // Add gesture specific events to genericDirectEventTypes object exported from UIManager
// native module.
// Once new event types are registered with react it is possible to dispatch these
// events to all kind of native views.
UIManagerAny.genericDirectEventTypes = { ...UIManagerAny.genericDirectEventTypes,
...customGHEventsConfig
}; // In newer versions of RN the `genericDirectEventTypes` is located in the object
// returned by UIManager.getViewManagerConfig('getConstants') or in older RN UIManager.getConstants(), we need to add it there as well to make
// it compatible with RN 61+
const UIManagerConstants = (_UIManagerAny$getView = (_UIManagerAny$getView2 = UIManagerAny.getViewManagerConfig) === null || _UIManagerAny$getView2 === void 0 ? void 0 : _UIManagerAny$getView2.call(UIManagerAny, 'getConstants')) !== null && _UIManagerAny$getView !== void 0 ? _UIManagerAny$getView : (_UIManagerAny$getCons = UIManagerAny.getConstants) === null || _UIManagerAny$getCons === void 0 ? void 0 : _UIManagerAny$getCons.call(UIManagerAny);
if (UIManagerConstants) {
UIManagerConstants.genericDirectEventTypes = { ...UIManagerConstants.genericDirectEventTypes,
...customGHEventsConfig
};
} // Wrap JS responder calls and notify gesture handler manager
const {
setJSResponder: oldSetJSResponder = () => {//no operation
},
clearJSResponder: oldClearJSResponder = () => {//no operation
}
} = UIManagerAny;
UIManagerAny.setJSResponder = (tag, blockNativeResponder) => {
RNGestureHandlerModule.handleSetJSResponder(tag, blockNativeResponder);
oldSetJSResponder(tag, blockNativeResponder);
};
UIManagerAny.clearJSResponder = () => {
RNGestureHandlerModule.handleClearJSResponder();
oldClearJSResponder();
};
let allowTouches = true;
const DEV_ON_ANDROID = __DEV__ && Platform.OS === 'android'; // Toggled inspector blocks touch events in order to allow inspecting on Android
// This needs to be a global variable in order to set initial state for `allowTouches` property in Handler component
if (DEV_ON_ANDROID) {
DeviceEventEmitter.addListener('toggleElementInspector', () => {
allowTouches = !allowTouches;
});
}
function hasUnresolvedRefs(props) {
// TODO(TS) - add type for extract arg
const extract = refs => {
if (!Array.isArray(refs)) {
return refs && refs.current === null;
}
return refs.some(r => r && r.current === null);
};
return extract(props['simultaneousHandlers']) || extract(props['waitFor']);
}
const stateToPropMappings = {
[State.UNDETERMINED]: undefined,
[State.BEGAN]: 'onBegan',
[State.FAILED]: 'onFailed',
[State.CANCELLED]: 'onCancelled',
[State.ACTIVE]: 'onActivated',
[State.END]: 'onEnded'
};
const UNRESOLVED_REFS_RETRY_LIMIT = 1; // TODO(TS) - make sure that BaseGestureHandlerProps doesn't need other generic parameter to work with custom properties.
export default function createHandler({
name,
allowedProps = [],
config = {},
transformProps,
customNativeProps = []
}) {
class Handler extends React.Component {
constructor(props) {
super(props);
_defineProperty(this, "handlerTag", void 0);
_defineProperty(this, "config", void 0);
_defineProperty(this, "propsRef", void 0);
_defineProperty(this, "isMountedRef", void 0);
_defineProperty(this, "viewNode", void 0);
_defineProperty(this, "viewTag", void 0);
_defineProperty(this, "inspectorToggleListener", void 0);
_defineProperty(this, "onGestureHandlerEvent", event => {
if (event.nativeEvent.handlerTag === this.handlerTag) {
if (typeof this.props.onGestureEvent === 'function') {
var _this$props$onGesture, _this$props;
(_this$props$onGesture = (_this$props = this.props).onGestureEvent) === null || _this$props$onGesture === void 0 ? void 0 : _this$props$onGesture.call(_this$props, event);
}
} else {
var _this$props$onGesture2, _this$props2;
(_this$props$onGesture2 = (_this$props2 = this.props).onGestureHandlerEvent) === null || _this$props$onGesture2 === void 0 ? void 0 : _this$props$onGesture2.call(_this$props2, event);
}
});
_defineProperty(this, "onGestureHandlerStateChange", event => {
if (event.nativeEvent.handlerTag === this.handlerTag) {
if (typeof this.props.onHandlerStateChange === 'function') {
var _this$props$onHandler, _this$props3;
(_this$props$onHandler = (_this$props3 = this.props).onHandlerStateChange) === null || _this$props$onHandler === void 0 ? void 0 : _this$props$onHandler.call(_this$props3, event);
}
const state = event.nativeEvent.state;
const stateEventName = stateToPropMappings[state];
const eventHandler = stateEventName && this.props[stateEventName];
if (eventHandler && typeof eventHandler === 'function') {
eventHandler(event);
}
} else {
var _this$props$onGesture3, _this$props4;
(_this$props$onGesture3 = (_this$props4 = this.props).onGestureHandlerStateChange) === null || _this$props$onGesture3 === void 0 ? void 0 : _this$props$onGesture3.call(_this$props4, event);
}
});
_defineProperty(this, "refHandler", node => {
this.viewNode = node;
const child = React.Children.only(this.props.children); // TODO(TS) fix ref type
const {
ref
} = child;
if (ref !== null) {
if (typeof ref === 'function') {
ref(node);
} else {
ref.current = node;
}
}
});
_defineProperty(this, "createGestureHandler", newConfig => {
this.config = newConfig;
RNGestureHandlerModule.createGestureHandler(name, this.handlerTag, newConfig);
});
_defineProperty(this, "attachGestureHandler", newViewTag => {
this.viewTag = newViewTag;
if (Platform.OS === 'web') {
// typecast due to dynamic resolution, attachGestureHandler should have web version signature in this branch
RNGestureHandlerModule.attachGestureHandler(this.handlerTag, newViewTag, ActionType.JS_FUNCTION_OLD_API, // ignored on web
this.propsRef);
} else {
registerOldGestureHandler(this.handlerTag, {
onGestureEvent: this.onGestureHandlerEvent,
onGestureStateChange: this.onGestureHandlerStateChange
});
const actionType = (() => {
var _this$props5, _this$props6;
const onGestureEvent = (_this$props5 = this.props) === null || _this$props5 === void 0 ? void 0 : _this$props5.onGestureEvent;
const isGestureHandlerWorklet = onGestureEvent && ('current' in onGestureEvent || 'workletEventHandler' in onGestureEvent);
const onHandlerStateChange = (_this$props6 = this.props) === null || _this$props6 === void 0 ? void 0 : _this$props6.onHandlerStateChange;
const isStateChangeHandlerWorklet = onHandlerStateChange && ('current' in onHandlerStateChange || 'workletEventHandler' in onHandlerStateChange);
const isReanimatedHandler = isGestureHandlerWorklet || isStateChangeHandlerWorklet;
if (isReanimatedHandler) {
// Reanimated worklet
return ActionType.REANIMATED_WORKLET;
} else if (onGestureEvent && '__isNative' in onGestureEvent) {
// Animated.event with useNativeDriver: true
return ActionType.NATIVE_ANIMATED_EVENT;
} else {
// JS callback or Animated.event with useNativeDriver: false
return ActionType.JS_FUNCTION_OLD_API;
}
})();
RNGestureHandlerModule.attachGestureHandler(this.handlerTag, newViewTag, actionType);
}
scheduleFlushOperations();
});
_defineProperty(this, "updateGestureHandler", newConfig => {
this.config = newConfig;
RNGestureHandlerModule.updateGestureHandler(this.handlerTag, newConfig);
scheduleFlushOperations();
});
this.handlerTag = getNextHandlerTag();
this.config = {};
this.propsRef = /*#__PURE__*/React.createRef();
this.isMountedRef = /*#__PURE__*/React.createRef();
this.state = {
allowTouches
};
if (props.id) {
if (handlerIDToTag[props.id] !== undefined) {
throw new Error(`Handler with ID "${props.id}" already registered`);
}
handlerIDToTag[props.id] = this.handlerTag;
}
}
componentDidMount() {
const props = this.props;
this.isMountedRef.current = true;
if (DEV_ON_ANDROID) {
this.inspectorToggleListener = DeviceEventEmitter.addListener('toggleElementInspector', () => {
this.setState(_ => ({
allowTouches
}));
this.update(UNRESOLVED_REFS_RETRY_LIMIT);
});
}
if (hasUnresolvedRefs(props)) {
// If there are unresolved refs (e.g. ".current" has not yet been set)
// passed as `simultaneousHandlers` or `waitFor`, we enqueue a call to
// _update method that will try to update native handler props using
// queueMicrotask. This makes it so update() function gets called after all
// react components are mounted and we expect the missing ref object to
// be resolved by then.
ghQueueMicrotask(() => {
this.update(UNRESOLVED_REFS_RETRY_LIMIT);
});
}
this.createGestureHandler(filterConfig(transformProps ? transformProps(this.props) : this.props, [...allowedProps, ...customNativeProps], config));
this.attachGestureHandler(findNodeHandle(this.viewNode)); // TODO(TS) - check if this can be null
}
componentDidUpdate() {
const viewTag = findNodeHandle(this.viewNode);
if (this.viewTag !== viewTag) {
this.attachGestureHandler(viewTag); // TODO(TS) - check interaction between _viewTag & findNodeHandle
}
this.update(UNRESOLVED_REFS_RETRY_LIMIT);
}
componentWillUnmount() {
var _this$inspectorToggle;
(_this$inspectorToggle = this.inspectorToggleListener) === null || _this$inspectorToggle === void 0 ? void 0 : _this$inspectorToggle.remove();
this.isMountedRef.current = false;
RNGestureHandlerModule.dropGestureHandler(this.handlerTag);
scheduleFlushOperations(); // We can't use this.props.id directly due to TS generic type narrowing bug, see https://github.com/microsoft/TypeScript/issues/13995 for more context
const handlerID = this.props.id;
if (handlerID) {
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
delete handlerIDToTag[handlerID];
}
}
update(remainingTries) {
if (!this.isMountedRef.current) {
return;
}
const props = this.props; // When ref is set via a function i.e. `ref={(r) => refObject.current = r}` instead of
// `ref={refObject}` it's possible that it won't be resolved in time. Seems like trying
// again is easy enough fix.
if (hasUnresolvedRefs(props) && remainingTries > 0) {
ghQueueMicrotask(() => {
this.update(remainingTries - 1);
});
} else {
const newConfig = filterConfig(transformProps ? transformProps(this.props) : this.props, [...allowedProps, ...customNativeProps], config);
if (!deepEqual(this.config, newConfig)) {
this.updateGestureHandler(newConfig);
}
}
}
setNativeProps(updates) {
const mergedProps = { ...this.props,
...updates
};
const newConfig = filterConfig(transformProps ? transformProps(mergedProps) : mergedProps, [...allowedProps, ...customNativeProps], config);
this.updateGestureHandler(newConfig);
}
render() {
var _this$props$testID;
if (__DEV__ && !this.context && !isJestEnv() && Platform.OS !== 'web') {
throw new Error(name + ' must be used as a descendant of GestureHandlerRootView. Otherwise the gestures will not be recognized. See https://docs.swmansion.com/react-native-gesture-handler/docs/installation for more details.');
}
let gestureEventHandler = this.onGestureHandlerEvent; // Another instance of https://github.com/microsoft/TypeScript/issues/13995
const {
onGestureEvent,
onGestureHandlerEvent
} = this.props;
if (onGestureEvent && typeof onGestureEvent !== 'function') {
// If it's not a method it should be an native Animated.event
// object. We set it directly as the handler for the view
// In this case nested handlers are not going to be supported
if (onGestureHandlerEvent) {
throw new Error('Nesting touch handlers with native animated driver is not supported yet');
}
gestureEventHandler = onGestureEvent;
} else {
if (onGestureHandlerEvent && typeof onGestureHandlerEvent !== 'function') {
throw new Error('Nesting touch handlers with native animated driver is not supported yet');
}
}
let gestureStateEventHandler = this.onGestureHandlerStateChange; // Another instance of https://github.com/microsoft/TypeScript/issues/13995
const {
onHandlerStateChange,
onGestureHandlerStateChange
} = this.props;
if (onHandlerStateChange && typeof onHandlerStateChange !== 'function') {
// If it's not a method it should be an native Animated.event
// object. We set it directly as the handler for the view
// In this case nested handlers are not going to be supported
if (onGestureHandlerStateChange) {
throw new Error('Nesting touch handlers with native animated driver is not supported yet');
}
gestureStateEventHandler = onHandlerStateChange;
} else {
if (onGestureHandlerStateChange && typeof onGestureHandlerStateChange !== 'function') {
throw new Error('Nesting touch handlers with native animated driver is not supported yet');
}
}
const events = {
onGestureHandlerEvent: this.state.allowTouches ? gestureEventHandler : undefined,
onGestureHandlerStateChange: this.state.allowTouches ? gestureStateEventHandler : undefined
};
this.propsRef.current = events;
let child = null;
try {
child = React.Children.only(this.props.children);
} catch (e) {
throw new Error(tagMessage(`${name} got more than one view as a child. If you want the gesture to work on multiple views, wrap them with a common parent and attach the gesture to that view.`));
}
let grandChildren = child.props.children;
if (__DEV__ && child.type && (child.type === 'RNGestureHandlerButton' || child.type.name === 'View' || child.type.displayName === 'View')) {
grandChildren = React.Children.toArray(grandChildren);
grandChildren.push( /*#__PURE__*/React.createElement(PressabilityDebugView, {
key: "pressabilityDebugView",
color: "mediumspringgreen",
hitSlop: child.props.hitSlop
}));
}
return /*#__PURE__*/React.cloneElement(child, {
ref: this.refHandler,
collapsable: false,
...(isJestEnv() ? {
handlerType: name,
handlerTag: this.handlerTag
} : {}),
testID: (_this$props$testID = this.props.testID) !== null && _this$props$testID !== void 0 ? _this$props$testID : child.props.testID,
...events
}, grandChildren);
}
}
_defineProperty(Handler, "displayName", name);
_defineProperty(Handler, "contextType", GestureHandlerRootViewContext);
return Handler;
}
//# sourceMappingURL=createHandler.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,62 @@
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
import * as React from 'react';
import { useImperativeHandle, useRef } from 'react';
import { NativeViewGestureHandler, nativeViewProps } from './NativeViewGestureHandler';
/*
* This array should consist of:
* - All keys in propTypes from NativeGestureHandler
* (and all keys in GestureHandlerPropTypes)
* - 'onGestureHandlerEvent'
* - 'onGestureHandlerStateChange'
*/
const NATIVE_WRAPPER_PROPS_FILTER = [...nativeViewProps, 'onGestureHandlerEvent', 'onGestureHandlerStateChange'];
export default function createNativeWrapper(Component, config = {}) {
var _Component$render;
const ComponentWrapper = /*#__PURE__*/React.forwardRef((props, ref) => {
// filter out props that should be passed to gesture handler wrapper
const gestureHandlerProps = Object.keys(props).reduce((res, key) => {
// TS being overly protective with it's types, see https://github.com/microsoft/TypeScript/issues/26255#issuecomment-458013731 for more info
const allowedKeys = NATIVE_WRAPPER_PROPS_FILTER;
if (allowedKeys.includes(key)) {
// @ts-ignore FIXME(TS)
res[key] = props[key];
}
return res;
}, { ...config
} // watch out not to modify config
);
const _ref = useRef();
const _gestureHandlerRef = useRef();
useImperativeHandle(ref, // @ts-ignore TODO(TS) decide how nulls work in this context
() => {
const node = _gestureHandlerRef.current; // add handlerTag for relations config
if (_ref.current && node) {
// @ts-ignore FIXME(TS) think about createHandler return type
_ref.current.handlerTag = node.handlerTag;
return _ref.current;
}
return null;
}, [_ref, _gestureHandlerRef]);
return /*#__PURE__*/React.createElement(NativeViewGestureHandler, _extends({}, gestureHandlerProps, {
// @ts-ignore TODO(TS)
ref: _gestureHandlerRef
}), /*#__PURE__*/React.createElement(Component, _extends({}, props, {
ref: _ref
})));
}); // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
ComponentWrapper.displayName = (Component === null || Component === void 0 ? void 0 : Component.displayName) || ( // @ts-ignore if render doesn't exist it will return undefined and go further
Component === null || Component === void 0 ? void 0 : (_Component$render = Component.render) === null || _Component$render === void 0 ? void 0 : _Component$render.name) || typeof Component === 'string' && Component || 'ComponentWrapper';
return ComponentWrapper;
}
//# sourceMappingURL=createNativeWrapper.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["createNativeWrapper.tsx"],"names":["React","useImperativeHandle","useRef","NativeViewGestureHandler","nativeViewProps","NATIVE_WRAPPER_PROPS_FILTER","createNativeWrapper","Component","config","ComponentWrapper","forwardRef","props","ref","gestureHandlerProps","Object","keys","reduce","res","key","allowedKeys","includes","_ref","_gestureHandlerRef","node","current","handlerTag","displayName","render","name"],"mappings":";;AAAA,OAAO,KAAKA,KAAZ,MAAuB,OAAvB;AACA,SAASC,mBAAT,EAA8BC,MAA9B,QAA4C,OAA5C;AAEA,SACEC,wBADF,EAGEC,eAHF,QAIO,4BAJP;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,MAAMC,2BAA2B,GAAG,CAClC,GAAGD,eAD+B,EAElC,uBAFkC,EAGlC,6BAHkC,CAApC;AAMA,eAAe,SAASE,mBAAT,CACbC,SADa,EAEbC,MAA+C,GAAG,EAFrC,EAGb;AAAA;;AACA,QAAMC,gBAAgB,gBAAGT,KAAK,CAACU,UAAN,CAGvB,CAACC,KAAD,EAAQC,GAAR,KAAgB;AAChB;AACA,UAAMC,mBAAmB,GAAGC,MAAM,CAACC,IAAP,CAAYJ,KAAZ,EAAmBK,MAAnB,CAC1B,CAACC,GAAD,EAAMC,GAAN,KAAc;AACZ;AACA,YAAMC,WAA8B,GAAGd,2BAAvC;;AACA,UAAIc,WAAW,CAACC,QAAZ,CAAqBF,GAArB,CAAJ,EAA+B;AAC7B;AACAD,QAAAA,GAAG,CAACC,GAAD,CAAH,GAAWP,KAAK,CAACO,GAAD,CAAhB;AACD;;AACD,aAAOD,GAAP;AACD,KATyB,EAU1B,EAAE,GAAGT;AAAL,KAV0B,CAUZ;AAVY,KAA5B;;AAYA,UAAMa,IAAI,GAAGnB,MAAM,EAAnB;;AACA,UAAMoB,kBAAkB,GAAGpB,MAAM,EAAjC;;AACAD,IAAAA,mBAAmB,CACjBW,GADiB,EAEjB;AACA,UAAM;AACJ,YAAMW,IAAI,GAAGD,kBAAkB,CAACE,OAAhC,CADI,CAEJ;;AACA,UAAIH,IAAI,CAACG,OAAL,IAAgBD,IAApB,EAA0B;AACxB;AACAF,QAAAA,IAAI,CAACG,OAAL,CAAaC,UAAb,GAA0BF,IAAI,CAACE,UAA/B;AACA,eAAOJ,IAAI,CAACG,OAAZ;AACD;;AACD,aAAO,IAAP;AACD,KAZgB,EAajB,CAACH,IAAD,EAAOC,kBAAP,CAbiB,CAAnB;AAeA,wBACE,oBAAC,wBAAD,eACMT,mBADN;AAEE;AACA,MAAA,GAAG,EAAES;AAHP,qBAIE,oBAAC,SAAD,eAAeX,KAAf;AAAsB,MAAA,GAAG,EAAEU;AAA3B,OAJF,CADF;AAQD,GA1CwB,CAAzB,CADA,CA6CA;;AACAZ,EAAAA,gBAAgB,CAACiB,WAAjB,GACE,CAAAnB,SAAS,SAAT,IAAAA,SAAS,WAAT,YAAAA,SAAS,CAAEmB,WAAX,OACA;AACAnB,EAAAA,SAFA,aAEAA,SAFA,4CAEAA,SAAS,CAAEoB,MAFX,sDAEA,kBAAmBC,IAFnB,KAGC,OAAOrB,SAAP,KAAqB,QAArB,IAAiCA,SAHlC,IAIA,kBALF;AAOA,SAAOE,gBAAP;AACD","sourcesContent":["import * as React from 'react';\nimport { useImperativeHandle, useRef } from 'react';\n\nimport {\n NativeViewGestureHandler,\n NativeViewGestureHandlerProps,\n nativeViewProps,\n} from './NativeViewGestureHandler';\n\n/*\n * This array should consist of:\n * - All keys in propTypes from NativeGestureHandler\n * (and all keys in GestureHandlerPropTypes)\n * - 'onGestureHandlerEvent'\n * - 'onGestureHandlerStateChange'\n */\nconst NATIVE_WRAPPER_PROPS_FILTER = [\n ...nativeViewProps,\n 'onGestureHandlerEvent',\n 'onGestureHandlerStateChange',\n] as const;\n\nexport default function createNativeWrapper<P>(\n Component: React.ComponentType<P>,\n config: Readonly<NativeViewGestureHandlerProps> = {}\n) {\n const ComponentWrapper = React.forwardRef<\n React.ComponentType<any>,\n P & NativeViewGestureHandlerProps\n >((props, ref) => {\n // filter out props that should be passed to gesture handler wrapper\n const gestureHandlerProps = Object.keys(props).reduce(\n (res, key) => {\n // TS being overly protective with it's types, see https://github.com/microsoft/TypeScript/issues/26255#issuecomment-458013731 for more info\n const allowedKeys: readonly string[] = NATIVE_WRAPPER_PROPS_FILTER;\n if (allowedKeys.includes(key)) {\n // @ts-ignore FIXME(TS)\n res[key] = props[key];\n }\n return res;\n },\n { ...config } // watch out not to modify config\n );\n const _ref = useRef<React.ComponentType<P>>();\n const _gestureHandlerRef = useRef<React.ComponentType<P>>();\n useImperativeHandle(\n ref,\n // @ts-ignore TODO(TS) decide how nulls work in this context\n () => {\n const node = _gestureHandlerRef.current;\n // add handlerTag for relations config\n if (_ref.current && node) {\n // @ts-ignore FIXME(TS) think about createHandler return type\n _ref.current.handlerTag = node.handlerTag;\n return _ref.current;\n }\n return null;\n },\n [_ref, _gestureHandlerRef]\n );\n return (\n <NativeViewGestureHandler\n {...gestureHandlerProps}\n // @ts-ignore TODO(TS)\n ref={_gestureHandlerRef}>\n <Component {...props} ref={_ref} />\n </NativeViewGestureHandler>\n );\n });\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n ComponentWrapper.displayName =\n Component?.displayName ||\n // @ts-ignore if render doesn't exist it will return undefined and go further\n Component?.render?.name ||\n (typeof Component === 'string' && Component) ||\n 'ComponentWrapper';\n\n return ComponentWrapper;\n}\n"]}

View File

@@ -0,0 +1,3 @@
// @ts-ignore - its taken straight from RN
export { customDirectEventTypes } from 'react-native/Libraries/Renderer/shims/ReactNativeViewConfigRegistry';
//# sourceMappingURL=customDirectEventTypes.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["customDirectEventTypes.ts"],"names":["customDirectEventTypes"],"mappings":"AAAA;AACA,SAASA,sBAAT,QAAuC,qEAAvC","sourcesContent":["// @ts-ignore - its taken straight from RN\nexport { customDirectEventTypes } from 'react-native/Libraries/Renderer/shims/ReactNativeViewConfigRegistry';\n"]}

View File

@@ -0,0 +1,5 @@
// customDirectEventTypes doesn't exist in react-native-web, therefore importing it
// directly in createHandler.tsx would end in crash.
const customDirectEventTypes = {};
export { customDirectEventTypes };
//# sourceMappingURL=customDirectEventTypes.web.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["customDirectEventTypes.web.ts"],"names":["customDirectEventTypes"],"mappings":"AAAA;AACA;AACA,MAAMA,sBAAsB,GAAG,EAA/B;AAEA,SAASA,sBAAT","sourcesContent":["// customDirectEventTypes doesn't exist in react-native-web, therefore importing it\n// directly in createHandler.tsx would end in crash.\nconst customDirectEventTypes = {};\n\nexport { customDirectEventTypes };\n"]}

View File

@@ -0,0 +1,91 @@
// Previous types exported gesture handlers as classes which creates an interface and variable, both named the same as class.
// Without those types, we'd introduce breaking change, forcing users to prefix every handler type specification with typeof
// e.g. React.createRef<TapGestureHandler> -> React.createRef<typeof TapGestureHandler>.
// See https://www.typescriptlang.org/docs/handbook/classes.html#constructor-functions for reference.
import { Platform, findNodeHandle as findNodeHandleRN } from 'react-native';
import { handlerIDToTag } from './handlersRegistry';
import { toArray } from '../utils';
import RNGestureHandlerModule from '../RNGestureHandlerModule';
import { ghQueueMicrotask } from '../ghQueueMicrotask';
const commonProps = ['id', 'enabled', 'shouldCancelWhenOutside', 'hitSlop', 'cancelsTouchesInView', 'userSelect', 'activeCursor', 'mouseButton', 'enableContextMenu', 'touchAction'];
const componentInteractionProps = ['waitFor', 'simultaneousHandlers', 'blocksHandlers'];
export const baseGestureHandlerProps = [...commonProps, ...componentInteractionProps, 'onBegan', 'onFailed', 'onCancelled', 'onActivated', 'onEnded', 'onGestureEvent', 'onHandlerStateChange'];
export const baseGestureHandlerWithMonitorProps = [...commonProps, 'needsPointerData', 'manualActivation'];
export let MouseButton;
(function (MouseButton) {
MouseButton[MouseButton["LEFT"] = 1] = "LEFT";
MouseButton[MouseButton["RIGHT"] = 2] = "RIGHT";
MouseButton[MouseButton["MIDDLE"] = 4] = "MIDDLE";
MouseButton[MouseButton["BUTTON_4"] = 8] = "BUTTON_4";
MouseButton[MouseButton["BUTTON_5"] = 16] = "BUTTON_5";
MouseButton[MouseButton["ALL"] = 31] = "ALL";
})(MouseButton || (MouseButton = {}));
function isConfigParam(param, name) {
// param !== Object(param) returns false if `param` is a function
// or an object and returns true if `param` is null
return param !== undefined && (param !== Object(param) || !('__isNative' in param)) && name !== 'onHandlerStateChange' && name !== 'onGestureEvent';
}
export function filterConfig(props, validProps, defaults = {}) {
const filteredConfig = { ...defaults
};
for (const key of validProps) {
let value = props[key];
if (isConfigParam(value, key)) {
if (key === 'simultaneousHandlers' || key === 'waitFor') {
value = transformIntoHandlerTags(props[key]);
} else if (key === 'hitSlop' && typeof value !== 'object') {
value = {
top: value,
left: value,
bottom: value,
right: value
};
}
filteredConfig[key] = value;
}
}
return filteredConfig;
}
function transformIntoHandlerTags(handlerIDs) {
handlerIDs = toArray(handlerIDs);
if (Platform.OS === 'web') {
return handlerIDs.map(({
current
}) => current).filter(handle => handle);
} // converts handler string IDs into their numeric tags
return handlerIDs.map(handlerID => {
var _handlerID$current;
return handlerIDToTag[handlerID] || ((_handlerID$current = handlerID.current) === null || _handlerID$current === void 0 ? void 0 : _handlerID$current.handlerTag) || -1;
}).filter(handlerTag => handlerTag > 0);
}
export function findNodeHandle(node) {
if (Platform.OS === 'web') {
return node;
}
return findNodeHandleRN(node);
}
let flushOperationsScheduled = false;
export function scheduleFlushOperations() {
if (!flushOperationsScheduled) {
flushOperationsScheduled = true;
ghQueueMicrotask(() => {
RNGestureHandlerModule.flushOperations();
flushOperationsScheduled = false;
});
}
}
//# sourceMappingURL=gestureHandlerCommon.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=gestureHandlerTypesCompat.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[]}

View File

@@ -0,0 +1,654 @@
var _Reanimated$default$c, _Reanimated$default;
import React, { useContext, useEffect, useRef, useState } from 'react';
import { BaseGesture, CALLBACK_TYPE } from './gesture';
import { Reanimated } from './reanimatedWrapper';
import { registerHandler, unregisterHandler } from '../handlersRegistry';
import RNGestureHandlerModule from '../../RNGestureHandlerModule';
import { baseGestureHandlerWithMonitorProps, filterConfig, findNodeHandle, scheduleFlushOperations } from '../gestureHandlerCommon';
import { GestureStateManager } from './gestureStateManager';
import { flingGestureHandlerProps } from '../FlingGestureHandler';
import { forceTouchGestureHandlerProps } from '../ForceTouchGestureHandler';
import { longPressGestureHandlerProps } from '../LongPressGestureHandler';
import { panGestureHandlerProps, panGestureHandlerCustomNativeProps } from '../PanGestureHandler';
import { tapGestureHandlerProps } from '../TapGestureHandler';
import { hoverGestureHandlerProps } from './hoverGesture';
import { State } from '../../State';
import { TouchEventType } from '../../TouchEventType';
import { ActionType } from '../../ActionType';
import { isFabric, isJestEnv, tagMessage } from '../../utils';
import { getReactNativeVersion } from '../../getReactNativeVersion';
import { getShadowNodeFromRef } from '../../getShadowNodeFromRef';
import { Platform } from 'react-native';
import { onGestureHandlerEvent } from './eventReceiver';
import { RNRenderer } from '../../RNRenderer';
import { isNewWebImplementationEnabled } from '../../EnableNewWebImplementation';
import { nativeViewGestureHandlerProps } from '../NativeViewGestureHandler';
import GestureHandlerRootViewContext from '../../GestureHandlerRootViewContext';
import { ghQueueMicrotask } from '../../ghQueueMicrotask';
const ALLOWED_PROPS = [...baseGestureHandlerWithMonitorProps, ...tapGestureHandlerProps, ...panGestureHandlerProps, ...panGestureHandlerCustomNativeProps, ...longPressGestureHandlerProps, ...forceTouchGestureHandlerProps, ...flingGestureHandlerProps, ...hoverGestureHandlerProps, ...nativeViewGestureHandlerProps];
function convertToHandlerTag(ref) {
if (typeof ref === 'number') {
return ref;
} else if (ref instanceof BaseGesture) {
return ref.handlerTag;
} else {
var _ref$current$handlerT, _ref$current;
// @ts-ignore in this case it should be a ref either to gesture object or
// a gesture handler component, in both cases handlerTag property exists
return (_ref$current$handlerT = (_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.handlerTag) !== null && _ref$current$handlerT !== void 0 ? _ref$current$handlerT : -1;
}
}
function extractValidHandlerTags(interactionGroup) {
var _interactionGroup$map, _interactionGroup$map2;
return (_interactionGroup$map = interactionGroup === null || interactionGroup === void 0 ? void 0 : (_interactionGroup$map2 = interactionGroup.map(convertToHandlerTag)) === null || _interactionGroup$map2 === void 0 ? void 0 : _interactionGroup$map2.filter(tag => tag > 0)) !== null && _interactionGroup$map !== void 0 ? _interactionGroup$map : [];
}
function dropHandlers(preparedGesture) {
for (const handler of preparedGesture.config) {
RNGestureHandlerModule.dropGestureHandler(handler.handlerTag);
unregisterHandler(handler.handlerTag, handler.config.testId);
}
scheduleFlushOperations();
}
function checkGestureCallbacksForWorklets(gesture) {
// if a gesture is explicitly marked to run on the JS thread there is no need to check
// if callbacks are worklets as the user is aware they will be ran on the JS thread
if (gesture.config.runOnJS) {
return;
}
const areSomeNotWorklets = gesture.handlers.isWorklet.includes(false);
const areSomeWorklets = gesture.handlers.isWorklet.includes(true); // if some of the callbacks are worklets and some are not, and the gesture is not
// explicitly marked with `.runOnJS(true)` show an error
if (areSomeNotWorklets && areSomeWorklets) {
console.error(tagMessage(`Some of the callbacks in the gesture are worklets and some are not. Either make sure that all calbacks are marked as 'worklet' if you wish to run them on the UI thread or use '.runOnJS(true)' modifier on the gesture explicitly to run all callbacks on the JS thread.`));
}
}
function attachHandlers({
preparedGesture,
gestureConfig,
gesture,
viewTag,
webEventHandlersRef,
mountedRef
}) {
if (!preparedGesture.firstExecution) {
gestureConfig.initialize();
} else {
preparedGesture.firstExecution = false;
} // use queueMicrotask to extract handlerTags, because all refs should be initialized
// when it's ran
ghQueueMicrotask(() => {
if (!mountedRef.current) {
return;
}
gestureConfig.prepare();
});
for (const handler of gesture) {
checkGestureCallbacksForWorklets(handler);
RNGestureHandlerModule.createGestureHandler(handler.handlerName, handler.handlerTag, filterConfig(handler.config, ALLOWED_PROPS));
registerHandler(handler.handlerTag, handler, handler.config.testId);
} // use queueMicrotask to extract handlerTags, because all refs should be initialized
// when it's ran
ghQueueMicrotask(() => {
if (!mountedRef.current) {
return;
}
for (const handler of gesture) {
let requireToFail = [];
if (handler.config.requireToFail) {
requireToFail = extractValidHandlerTags(handler.config.requireToFail);
}
let simultaneousWith = [];
if (handler.config.simultaneousWith) {
simultaneousWith = extractValidHandlerTags(handler.config.simultaneousWith);
}
let blocksHandlers = [];
if (handler.config.blocksHandlers) {
blocksHandlers = extractValidHandlerTags(handler.config.blocksHandlers);
}
RNGestureHandlerModule.updateGestureHandler(handler.handlerTag, filterConfig(handler.config, ALLOWED_PROPS, {
simultaneousHandlers: simultaneousWith,
waitFor: requireToFail,
blocksHandlers: blocksHandlers
}));
}
scheduleFlushOperations();
});
preparedGesture.config = gesture;
for (const gesture of preparedGesture.config) {
const actionType = gesture.shouldUseReanimated ? ActionType.REANIMATED_WORKLET : ActionType.JS_FUNCTION_NEW_API;
if (Platform.OS === 'web') {
RNGestureHandlerModule.attachGestureHandler(gesture.handlerTag, viewTag, ActionType.JS_FUNCTION_OLD_API, // ignored on web
webEventHandlersRef);
} else {
RNGestureHandlerModule.attachGestureHandler(gesture.handlerTag, viewTag, actionType);
}
}
if (preparedGesture.animatedHandlers) {
const isAnimatedGesture = g => g.shouldUseReanimated;
preparedGesture.animatedHandlers.value = gesture.filter(isAnimatedGesture).map(g => g.handlers);
}
}
function updateHandlers(preparedGesture, gestureConfig, gesture, mountedRef) {
gestureConfig.prepare();
for (let i = 0; i < gesture.length; i++) {
const handler = preparedGesture.config[i];
checkGestureCallbacksForWorklets(handler); // only update handlerTag when it's actually different, it may be the same
// if gesture config object is wrapped with useMemo
if (gesture[i].handlerTag !== handler.handlerTag) {
gesture[i].handlerTag = handler.handlerTag;
gesture[i].handlers.handlerTag = handler.handlerTag;
}
} // use queueMicrotask to extract handlerTags, because when it's ran, all refs should be updated
// and handlerTags in BaseGesture references should be updated in the loop above (we need to wait
// in case of external relations)
ghQueueMicrotask(() => {
if (!mountedRef.current) {
return;
}
for (let i = 0; i < gesture.length; i++) {
const handler = preparedGesture.config[i];
handler.config = gesture[i].config;
handler.handlers = gesture[i].handlers;
const requireToFail = extractValidHandlerTags(handler.config.requireToFail);
const simultaneousWith = extractValidHandlerTags(handler.config.simultaneousWith);
RNGestureHandlerModule.updateGestureHandler(handler.handlerTag, filterConfig(handler.config, ALLOWED_PROPS, {
simultaneousHandlers: simultaneousWith,
waitFor: requireToFail
}));
registerHandler(handler.handlerTag, handler, handler.config.testId);
}
if (preparedGesture.animatedHandlers) {
var _preparedGesture$anim;
const previousHandlersValue = (_preparedGesture$anim = preparedGesture.animatedHandlers.value) !== null && _preparedGesture$anim !== void 0 ? _preparedGesture$anim : [];
const newHandlersValue = preparedGesture.config.filter(g => g.shouldUseReanimated) // ignore gestures that shouldn't run on UI
.map(g => g.handlers); // if amount of gesture configs changes, we need to update the callbacks in shared value
let shouldUpdateSharedValue = previousHandlersValue.length !== newHandlersValue.length;
if (!shouldUpdateSharedValue) {
// if the amount is the same, we need to check if any of the configs inside has changed
for (let i = 0; i < newHandlersValue.length; i++) {
if ( // we can use the `gestureId` prop as it's unique for every config instance
newHandlersValue[i].gestureId !== previousHandlersValue[i].gestureId) {
shouldUpdateSharedValue = true;
break;
}
}
}
if (shouldUpdateSharedValue) {
preparedGesture.animatedHandlers.value = newHandlersValue;
}
}
scheduleFlushOperations();
});
}
function needsToReattach(preparedGesture, gesture) {
if (gesture.length !== preparedGesture.config.length) {
return true;
}
for (let i = 0; i < gesture.length; i++) {
if (gesture[i].handlerName !== preparedGesture.config[i].handlerName || gesture[i].shouldUseReanimated !== preparedGesture.config[i].shouldUseReanimated) {
return true;
}
}
return false;
}
function isStateChangeEvent(event) {
'worklet'; // @ts-ignore Yes, the oldState prop is missing on GestureTouchEvent, that's the point
return event.oldState != null;
}
function isTouchEvent(event) {
'worklet';
return event.eventType != null;
}
function getHandler(type, gesture) {
'worklet';
switch (type) {
case CALLBACK_TYPE.BEGAN:
return gesture.onBegin;
case CALLBACK_TYPE.START:
return gesture.onStart;
case CALLBACK_TYPE.UPDATE:
return gesture.onUpdate;
case CALLBACK_TYPE.CHANGE:
return gesture.onChange;
case CALLBACK_TYPE.END:
return gesture.onEnd;
case CALLBACK_TYPE.FINALIZE:
return gesture.onFinalize;
case CALLBACK_TYPE.TOUCHES_DOWN:
return gesture.onTouchesDown;
case CALLBACK_TYPE.TOUCHES_MOVE:
return gesture.onTouchesMove;
case CALLBACK_TYPE.TOUCHES_UP:
return gesture.onTouchesUp;
case CALLBACK_TYPE.TOUCHES_CANCELLED:
return gesture.onTouchesCancelled;
}
}
function touchEventTypeToCallbackType(eventType) {
'worklet';
switch (eventType) {
case TouchEventType.TOUCHES_DOWN:
return CALLBACK_TYPE.TOUCHES_DOWN;
case TouchEventType.TOUCHES_MOVE:
return CALLBACK_TYPE.TOUCHES_MOVE;
case TouchEventType.TOUCHES_UP:
return CALLBACK_TYPE.TOUCHES_UP;
case TouchEventType.TOUCHES_CANCELLED:
return CALLBACK_TYPE.TOUCHES_CANCELLED;
}
return CALLBACK_TYPE.UNDEFINED;
}
function runWorklet(type, gesture, event, ...args) {
'worklet';
const handler = getHandler(type, gesture);
if (gesture.isWorklet[type]) {
// @ts-ignore Logic below makes sure the correct event is send to the
// correct handler.
handler === null || handler === void 0 ? void 0 : handler(event, ...args);
} else if (handler) {
console.warn(tagMessage('Animated gesture callback must be a worklet'));
}
}
function useAnimatedGesture(preparedGesture, needsRebuild) {
if (!Reanimated) {
return;
} // Hooks are called conditionally, but the condition is whether the
// react-native-reanimated is installed, which shouldn't change while running
// eslint-disable-next-line react-hooks/rules-of-hooks
const sharedHandlersCallbacks = Reanimated.useSharedValue(null); // eslint-disable-next-line react-hooks/rules-of-hooks
const lastUpdateEvent = Reanimated.useSharedValue([]); // not every gesture needs a state controller, init them lazily
const stateControllers = [];
const callback = event => {
'worklet';
const currentCallback = sharedHandlersCallbacks.value;
if (!currentCallback) {
return;
}
for (let i = 0; i < currentCallback.length; i++) {
const gesture = currentCallback[i];
if (event.handlerTag === gesture.handlerTag) {
if (isStateChangeEvent(event)) {
if (event.oldState === State.UNDETERMINED && event.state === State.BEGAN) {
runWorklet(CALLBACK_TYPE.BEGAN, gesture, event);
} else if ((event.oldState === State.BEGAN || event.oldState === State.UNDETERMINED) && event.state === State.ACTIVE) {
runWorklet(CALLBACK_TYPE.START, gesture, event);
lastUpdateEvent.value[gesture.handlerTag] = undefined;
} else if (event.oldState !== event.state && event.state === State.END) {
if (event.oldState === State.ACTIVE) {
runWorklet(CALLBACK_TYPE.END, gesture, event, true);
}
runWorklet(CALLBACK_TYPE.FINALIZE, gesture, event, true);
} else if ((event.state === State.FAILED || event.state === State.CANCELLED) && event.state !== event.oldState) {
if (event.oldState === State.ACTIVE) {
runWorklet(CALLBACK_TYPE.END, gesture, event, false);
}
runWorklet(CALLBACK_TYPE.FINALIZE, gesture, event, false);
}
} else if (isTouchEvent(event)) {
if (!stateControllers[i]) {
stateControllers[i] = GestureStateManager.create(event.handlerTag);
}
if (event.eventType !== TouchEventType.UNDETERMINED) {
runWorklet(touchEventTypeToCallbackType(event.eventType), gesture, event, stateControllers[i]);
}
} else {
runWorklet(CALLBACK_TYPE.UPDATE, gesture, event);
if (gesture.onChange && gesture.changeEventCalculator) {
var _gesture$changeEventC;
runWorklet(CALLBACK_TYPE.CHANGE, gesture, (_gesture$changeEventC = gesture.changeEventCalculator) === null || _gesture$changeEventC === void 0 ? void 0 : _gesture$changeEventC.call(gesture, event, lastUpdateEvent.value[gesture.handlerTag]));
lastUpdateEvent.value[gesture.handlerTag] = event;
}
}
}
}
}; // eslint-disable-next-line react-hooks/rules-of-hooks
const event = Reanimated.useEvent(callback, ['onGestureHandlerStateChange', 'onGestureHandlerEvent'], needsRebuild);
preparedGesture.animatedEventHandler = event;
preparedGesture.animatedHandlers = sharedHandlersCallbacks;
} // eslint-disable-next-line @typescript-eslint/no-explicit-any
function validateDetectorChildren(ref) {
// finds the first native view under the Wrap component and traverses the fiber tree upwards
// to check whether there is more than one native view as a pseudo-direct child of GestureDetector
// i.e. this is not ok:
// Wrap
// |
// / \
// / \
// / \
// / \
// NativeView NativeView
//
// but this is fine:
// Wrap
// |
// NativeView
// |
// / \
// / \
// / \
// / \
// NativeView NativeView
if (__DEV__ && Platform.OS !== 'web') {
const REACT_NATIVE_VERSION = getReactNativeVersion(); // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
const wrapType = REACT_NATIVE_VERSION.minor > 63 || REACT_NATIVE_VERSION.major > 0 ? // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
ref._reactInternals.elementType : // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
ref._reactInternalFiber.elementType; // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
let instance = RNRenderer.findHostInstance_DEPRECATED(ref)._internalFiberInstanceHandleDEV; // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
while (instance && instance.elementType !== wrapType) {
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
if (instance.sibling) {
throw new Error('GestureDetector has more than one native view as its children. This can happen if you are using a custom component that renders multiple views, like React.Fragment. You should wrap content of GestureDetector with a <View> or <Animated.View>.');
} // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access
instance = instance.return;
}
}
}
const applyUserSelectProp = (userSelect, gesture) => {
for (const g of gesture.toGestureArray()) {
g.config.userSelect = userSelect;
}
};
const applyEnableContextMenuProp = (enableContextMenu, gesture) => {
for (const g of gesture.toGestureArray()) {
g.config.enableContextMenu = enableContextMenu;
}
};
const applyTouchActionProp = (touchAction, gesture) => {
for (const g of gesture.toGestureArray()) {
g.config.touchAction = touchAction;
}
};
/**
* `GestureDetector` is responsible for creating and updating native gesture handlers based on the config of provided gesture.
*
* ### Props
* - `gesture`
* - `userSelect` (**Web only**)
* - `enableContextMenu` (**Web only**)
* - `touchAction` (**Web only**)
*
* ### Remarks
* - Gesture Detector will use first native view in its subtree to recognize gestures, however if this view is used only to group its children it may get automatically collapsed.
* - Using the same instance of a gesture across multiple Gesture Detectors is not possible.
*
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/gesture-detector
*/
export const GestureDetector = props => {
const rootViewContext = useContext(GestureHandlerRootViewContext);
if (__DEV__ && !rootViewContext && !isJestEnv() && Platform.OS !== 'web') {
throw new Error('GestureDetector must be used as a descendant of GestureHandlerRootView. Otherwise the gestures will not be recognized. See https://docs.swmansion.com/react-native-gesture-handler/docs/installation for more details.');
}
const gestureConfig = props.gesture;
if (props.userSelect) {
applyUserSelectProp(props.userSelect, gestureConfig);
}
if (props.enableContextMenu !== undefined) {
applyEnableContextMenuProp(props.enableContextMenu, gestureConfig);
}
if (props.touchAction !== undefined) {
applyTouchActionProp(props.touchAction, gestureConfig);
}
const gesture = gestureConfig.toGestureArray();
const useReanimatedHook = gesture.some(g => g.shouldUseReanimated); // store state in ref to prevent unnecessary renders
const state = useRef({
firstRender: true,
viewRef: null,
previousViewTag: -1,
forceReattach: false
}).current;
const mountedRef = useRef(false);
const webEventHandlersRef = useRef({
onGestureHandlerEvent: e => {
onGestureHandlerEvent(e.nativeEvent);
},
onGestureHandlerStateChange: isNewWebImplementationEnabled() ? e => {
onGestureHandlerEvent(e.nativeEvent);
} : undefined
});
const [renderState, setRenderState] = useState(false);
function forceRender() {
setRenderState(!renderState);
}
const preparedGesture = React.useRef({
config: gesture,
animatedEventHandler: null,
animatedHandlers: null,
firstExecution: true,
useReanimatedHook: useReanimatedHook
}).current;
if (useReanimatedHook !== preparedGesture.useReanimatedHook) {
throw new Error(tagMessage('You cannot change the thread the callbacks are ran on while the app is running'));
}
function onHandlersUpdate(skipConfigUpdate) {
// if the underlying view has changed we need to reattach handlers to the new view
const viewTag = findNodeHandle(state.viewRef);
const forceReattach = viewTag !== state.previousViewTag;
if (forceReattach || needsToReattach(preparedGesture, gesture)) {
validateDetectorChildren(state.viewRef);
dropHandlers(preparedGesture);
attachHandlers({
preparedGesture,
gestureConfig,
gesture,
webEventHandlersRef,
viewTag,
mountedRef
});
state.previousViewTag = viewTag;
state.forceReattach = forceReattach;
if (forceReattach) {
forceRender();
}
} else if (!skipConfigUpdate) {
updateHandlers(preparedGesture, gestureConfig, gesture, mountedRef);
}
} // Reanimated event should be rebuilt only when gestures are reattached, otherwise
// config update will be enough as all necessary items are stored in shared values anyway
const needsToRebuildReanimatedEvent = preparedGesture.firstExecution || needsToReattach(preparedGesture, gesture) || state.forceReattach;
state.forceReattach = false;
if (preparedGesture.firstExecution) {
gestureConfig.initialize();
}
if (useReanimatedHook) {
// Whether animatedGesture or gesture is used shouldn't change while the app is running
// eslint-disable-next-line react-hooks/rules-of-hooks
useAnimatedGesture(preparedGesture, needsToRebuildReanimatedEvent);
}
useEffect(() => {
const viewTag = findNodeHandle(state.viewRef);
state.firstRender = true;
mountedRef.current = true;
validateDetectorChildren(state.viewRef);
attachHandlers({
preparedGesture,
gestureConfig,
gesture,
webEventHandlersRef,
viewTag,
mountedRef
});
return () => {
mountedRef.current = false;
dropHandlers(preparedGesture);
};
}, []);
useEffect(() => {
if (!state.firstRender) {
onHandlersUpdate();
} else {
state.firstRender = false;
}
}, [props]);
const refFunction = ref => {
if (ref !== null) {
// @ts-ignore Just setting the view ref
state.viewRef = ref; // if it's the first render, also set the previousViewTag to prevent reattaching gestures when not needed
if (state.previousViewTag === -1) {
state.previousViewTag = findNodeHandle(state.viewRef);
} // pass true as `skipConfigUpdate`, here we only want to trigger the eventual reattaching of handlers
// in case the view has changed, while config update would be handled be the `useEffect` above
onHandlersUpdate(true);
if (isFabric() && global.isFormsStackingContext) {
const node = getShadowNodeFromRef(ref);
if (global.isFormsStackingContext(node) === false) {
console.error(tagMessage('GestureDetector has received a child that may get view-flattened. ' + '\nTo prevent it from misbehaving you need to wrap the child with a `<View collapsable={false}>`.'));
}
}
}
};
if (useReanimatedHook) {
return /*#__PURE__*/React.createElement(AnimatedWrap, {
ref: refFunction,
onGestureHandlerEvent: preparedGesture.animatedEventHandler
}, props.children);
} else {
return /*#__PURE__*/React.createElement(Wrap, {
ref: refFunction
}, props.children);
}
};
class Wrap extends React.Component {
render() {
try {
// I don't think that fighting with types over such a simple function is worth it
// The only thing it does is add 'collapsable: false' to the child component
// to make sure it is in the native view hierarchy so the detector can find
// correct viewTag to attach to.
// eslint-disable-next-line @typescript-eslint/no-explicit-any
const child = React.Children.only(this.props.children);
return /*#__PURE__*/React.cloneElement(child, {
collapsable: false
}, // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
child.props.children);
} catch (e) {
throw new Error(tagMessage(`GestureDetector got more than one view as a child. If you want the gesture to work on multiple views, wrap them with a common parent and attach the gesture to that view.`));
}
}
}
const AnimatedWrap = (_Reanimated$default$c = Reanimated === null || Reanimated === void 0 ? void 0 : (_Reanimated$default = Reanimated.default) === null || _Reanimated$default === void 0 ? void 0 : _Reanimated$default.createAnimatedComponent(Wrap)) !== null && _Reanimated$default$c !== void 0 ? _Reanimated$default$c : Wrap;
//# sourceMappingURL=GestureDetector.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,131 @@
import { DeviceEventEmitter } from 'react-native';
import { State } from '../../State';
import { TouchEventType } from '../../TouchEventType';
import { findHandler, findOldGestureHandler } from '../handlersRegistry';
import { GestureStateManager } from './gestureStateManager';
let gestureHandlerEventSubscription = null;
let gestureHandlerStateChangeEventSubscription = null;
const gestureStateManagers = new Map();
const lastUpdateEvent = [];
function isStateChangeEvent(event) {
// @ts-ignore oldState doesn't exist on GestureTouchEvent and that's the point
return event.oldState != null;
}
function isTouchEvent(event) {
return event.eventType != null;
}
export function onGestureHandlerEvent(event) {
var _handler$handlers7, _handler$handlers7$on, _handler$handlers8, _handler$handlers8$on, _handler$handlers9, _handler$handlers9$on, _handler$handlers10, _handler$handlers10$o;
const handler = findHandler(event.handlerTag);
if (handler) {
if (isStateChangeEvent(event)) {
if (event.oldState === State.UNDETERMINED && event.state === State.BEGAN) {
var _handler$handlers$onB, _handler$handlers;
(_handler$handlers$onB = (_handler$handlers = handler.handlers).onBegin) === null || _handler$handlers$onB === void 0 ? void 0 : _handler$handlers$onB.call(_handler$handlers, event);
} else if ((event.oldState === State.BEGAN || event.oldState === State.UNDETERMINED) && event.state === State.ACTIVE) {
var _handler$handlers$onS, _handler$handlers2;
(_handler$handlers$onS = (_handler$handlers2 = handler.handlers).onStart) === null || _handler$handlers$onS === void 0 ? void 0 : _handler$handlers$onS.call(_handler$handlers2, event);
lastUpdateEvent[handler.handlers.handlerTag] = event;
} else if (event.oldState !== event.state && event.state === State.END) {
var _handler$handlers$onF, _handler$handlers4;
if (event.oldState === State.ACTIVE) {
var _handler$handlers$onE, _handler$handlers3;
(_handler$handlers$onE = (_handler$handlers3 = handler.handlers).onEnd) === null || _handler$handlers$onE === void 0 ? void 0 : _handler$handlers$onE.call(_handler$handlers3, event, true);
}
(_handler$handlers$onF = (_handler$handlers4 = handler.handlers).onFinalize) === null || _handler$handlers$onF === void 0 ? void 0 : _handler$handlers$onF.call(_handler$handlers4, event, true);
lastUpdateEvent[handler.handlers.handlerTag] = undefined;
} else if ((event.state === State.FAILED || event.state === State.CANCELLED) && event.oldState !== event.state) {
var _handler$handlers$onF2, _handler$handlers6;
if (event.oldState === State.ACTIVE) {
var _handler$handlers$onE2, _handler$handlers5;
(_handler$handlers$onE2 = (_handler$handlers5 = handler.handlers).onEnd) === null || _handler$handlers$onE2 === void 0 ? void 0 : _handler$handlers$onE2.call(_handler$handlers5, event, false);
}
(_handler$handlers$onF2 = (_handler$handlers6 = handler.handlers).onFinalize) === null || _handler$handlers$onF2 === void 0 ? void 0 : _handler$handlers$onF2.call(_handler$handlers6, event, false);
gestureStateManagers.delete(event.handlerTag);
lastUpdateEvent[handler.handlers.handlerTag] = undefined;
}
} else if (isTouchEvent(event)) {
if (!gestureStateManagers.has(event.handlerTag)) {
gestureStateManagers.set(event.handlerTag, GestureStateManager.create(event.handlerTag));
} // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const manager = gestureStateManagers.get(event.handlerTag);
switch (event.eventType) {
case TouchEventType.TOUCHES_DOWN:
(_handler$handlers7 = handler.handlers) === null || _handler$handlers7 === void 0 ? void 0 : (_handler$handlers7$on = _handler$handlers7.onTouchesDown) === null || _handler$handlers7$on === void 0 ? void 0 : _handler$handlers7$on.call(_handler$handlers7, event, manager);
break;
case TouchEventType.TOUCHES_MOVE:
(_handler$handlers8 = handler.handlers) === null || _handler$handlers8 === void 0 ? void 0 : (_handler$handlers8$on = _handler$handlers8.onTouchesMove) === null || _handler$handlers8$on === void 0 ? void 0 : _handler$handlers8$on.call(_handler$handlers8, event, manager);
break;
case TouchEventType.TOUCHES_UP:
(_handler$handlers9 = handler.handlers) === null || _handler$handlers9 === void 0 ? void 0 : (_handler$handlers9$on = _handler$handlers9.onTouchesUp) === null || _handler$handlers9$on === void 0 ? void 0 : _handler$handlers9$on.call(_handler$handlers9, event, manager);
break;
case TouchEventType.TOUCHES_CANCELLED:
(_handler$handlers10 = handler.handlers) === null || _handler$handlers10 === void 0 ? void 0 : (_handler$handlers10$o = _handler$handlers10.onTouchesCancelled) === null || _handler$handlers10$o === void 0 ? void 0 : _handler$handlers10$o.call(_handler$handlers10, event, manager);
break;
}
} else {
var _handler$handlers$onU, _handler$handlers11;
(_handler$handlers$onU = (_handler$handlers11 = handler.handlers).onUpdate) === null || _handler$handlers$onU === void 0 ? void 0 : _handler$handlers$onU.call(_handler$handlers11, event);
if (handler.handlers.onChange && handler.handlers.changeEventCalculator) {
var _handler$handlers$onC, _handler$handlers12, _handler$handlers$cha, _handler$handlers13;
(_handler$handlers$onC = (_handler$handlers12 = handler.handlers).onChange) === null || _handler$handlers$onC === void 0 ? void 0 : _handler$handlers$onC.call(_handler$handlers12, (_handler$handlers$cha = (_handler$handlers13 = handler.handlers).changeEventCalculator) === null || _handler$handlers$cha === void 0 ? void 0 : _handler$handlers$cha.call(_handler$handlers13, event, lastUpdateEvent[handler.handlers.handlerTag]));
lastUpdateEvent[handler.handlers.handlerTag] = event;
}
}
} else {
const oldHandler = findOldGestureHandler(event.handlerTag);
if (oldHandler) {
const nativeEvent = {
nativeEvent: event
};
if (isStateChangeEvent(event)) {
oldHandler.onGestureStateChange(nativeEvent);
} else {
oldHandler.onGestureEvent(nativeEvent);
}
return;
}
}
}
export function startListening() {
stopListening();
gestureHandlerEventSubscription = DeviceEventEmitter.addListener('onGestureHandlerEvent', onGestureHandlerEvent);
gestureHandlerStateChangeEventSubscription = DeviceEventEmitter.addListener('onGestureHandlerStateChange', onGestureHandlerEvent);
}
export function stopListening() {
if (gestureHandlerEventSubscription) {
gestureHandlerEventSubscription.remove();
gestureHandlerEventSubscription = null;
}
if (gestureHandlerStateChangeEventSubscription) {
gestureHandlerStateChangeEventSubscription.remove();
gestureHandlerStateChangeEventSubscription = null;
}
}
//# sourceMappingURL=eventReceiver.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,37 @@
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
import { BaseGesture } from './gesture';
export class FlingGesture extends BaseGesture {
constructor() {
super();
_defineProperty(this, "config", {});
this.handlerName = 'FlingGestureHandler';
}
/**
* Determine exact number of points required to handle the fling gesture.
* @param pointers
*/
numberOfPointers(pointers) {
this.config.numberOfPointers = pointers;
return this;
}
/**
* Expressed allowed direction of movement.
* Expected values are exported as constants in the Directions object.
* Arguments can be combined using `|` operator. Default value is set to `MouseButton.LEFT`.
* @param direction
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/fling-gesture/#directionvalue-directions
*/
direction(direction) {
this.config.direction = direction;
return this;
}
}
//# sourceMappingURL=flingGesture.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["flingGesture.ts"],"names":["BaseGesture","FlingGesture","constructor","handlerName","numberOfPointers","pointers","config","direction"],"mappings":";;AAAA,SAASA,WAAT,QAA+C,WAA/C;AAMA,OAAO,MAAMC,YAAN,SAA2BD,WAA3B,CAAwE;AAG7EE,EAAAA,WAAW,GAAG;AACZ;;AADY,oCAF0C,EAE1C;;AAGZ,SAAKC,WAAL,GAAmB,qBAAnB;AACD;AAED;AACF;AACA;AACA;;;AACEC,EAAAA,gBAAgB,CAACC,QAAD,EAAmB;AACjC,SAAKC,MAAL,CAAYF,gBAAZ,GAA+BC,QAA/B;AACA,WAAO,IAAP;AACD;AAED;AACF;AACA;AACA;AACA;AACA;AACA;;;AACEE,EAAAA,SAAS,CAACA,SAAD,EAAoB;AAC3B,SAAKD,MAAL,CAAYC,SAAZ,GAAwBA,SAAxB;AACA,WAAO,IAAP;AACD;;AA5B4E","sourcesContent":["import { BaseGesture, BaseGestureConfig } from './gesture';\nimport {\n FlingGestureConfig,\n FlingGestureHandlerEventPayload,\n} from '../FlingGestureHandler';\n\nexport class FlingGesture extends BaseGesture<FlingGestureHandlerEventPayload> {\n public config: BaseGestureConfig & FlingGestureConfig = {};\n\n constructor() {\n super();\n\n this.handlerName = 'FlingGestureHandler';\n }\n\n /**\n * Determine exact number of points required to handle the fling gesture.\n * @param pointers\n */\n numberOfPointers(pointers: number) {\n this.config.numberOfPointers = pointers;\n return this;\n }\n\n /**\n * Expressed allowed direction of movement.\n * Expected values are exported as constants in the Directions object.\n * Arguments can be combined using `|` operator. Default value is set to `MouseButton.LEFT`.\n * @param direction\n * @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/fling-gesture/#directionvalue-directions\n */\n direction(direction: number) {\n this.config.direction = direction;\n return this;\n }\n}\n\nexport type FlingGestureType = InstanceType<typeof FlingGesture>;\n"]}

View File

@@ -0,0 +1,73 @@
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
import { ContinousBaseGesture } from './gesture';
function changeEventCalculator(current, previous) {
'worklet';
let changePayload;
if (previous === undefined) {
changePayload = {
forceChange: current.force
};
} else {
changePayload = {
forceChange: current.force - previous.force
};
}
return { ...current,
...changePayload
};
}
export class ForceTouchGesture extends ContinousBaseGesture {
constructor() {
super();
_defineProperty(this, "config", {});
this.handlerName = 'ForceTouchGestureHandler';
}
/**
* A minimal pressure that is required before gesture can activate.
* Should be a value from range [0.0, 1.0]. Default is 0.2.
* @param force
*/
minForce(force) {
this.config.minForce = force;
return this;
}
/**
* A maximal pressure that could be applied for gesture.
* If the pressure is greater, gesture fails. Should be a value from range [0.0, 1.0].
* @param force
*/
maxForce(force) {
this.config.maxForce = force;
return this;
}
/**
* Value defining if haptic feedback has to be performed on activation.
* @param value
*/
feedbackOnActivation(value) {
this.config.feedbackOnActivation = value;
return this;
}
onChange(callback) {
// @ts-ignore TS being overprotective, ForceTouchGestureHandlerEventPayload is Record
this.handlers.changeEventCalculator = changeEventCalculator;
return super.onChange(callback);
}
}
//# sourceMappingURL=forceTouchGesture.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["forceTouchGesture.ts"],"names":["ContinousBaseGesture","changeEventCalculator","current","previous","changePayload","undefined","forceChange","force","ForceTouchGesture","constructor","handlerName","minForce","config","maxForce","feedbackOnActivation","value","onChange","callback","handlers"],"mappings":";;AAAA,SAA4BA,oBAA5B,QAAwD,WAAxD;;AAWA,SAASC,qBAAT,CACEC,OADF,EAEEC,QAFF,EAGE;AACA;;AACA,MAAIC,aAAJ;;AACA,MAAID,QAAQ,KAAKE,SAAjB,EAA4B;AAC1BD,IAAAA,aAAa,GAAG;AACdE,MAAAA,WAAW,EAAEJ,OAAO,CAACK;AADP,KAAhB;AAGD,GAJD,MAIO;AACLH,IAAAA,aAAa,GAAG;AACdE,MAAAA,WAAW,EAAEJ,OAAO,CAACK,KAAR,GAAgBJ,QAAQ,CAACI;AADxB,KAAhB;AAGD;;AAED,SAAO,EAAE,GAAGL,OAAL;AAAc,OAAGE;AAAjB,GAAP;AACD;;AAED,OAAO,MAAMI,iBAAN,SAAgCR,oBAAhC,CAGL;AAGAS,EAAAA,WAAW,GAAG;AACZ;;AADY,oCAF+C,EAE/C;;AAGZ,SAAKC,WAAL,GAAmB,0BAAnB;AACD;AAED;AACF;AACA;AACA;AACA;;;AACEC,EAAAA,QAAQ,CAACJ,KAAD,EAAgB;AACtB,SAAKK,MAAL,CAAYD,QAAZ,GAAuBJ,KAAvB;AACA,WAAO,IAAP;AACD;AAED;AACF;AACA;AACA;AACA;;;AACEM,EAAAA,QAAQ,CAACN,KAAD,EAAgB;AACtB,SAAKK,MAAL,CAAYC,QAAZ,GAAuBN,KAAvB;AACA,WAAO,IAAP;AACD;AAED;AACF;AACA;AACA;;;AACEO,EAAAA,oBAAoB,CAACC,KAAD,EAAiB;AACnC,SAAKH,MAAL,CAAYE,oBAAZ,GAAmCC,KAAnC;AACA,WAAO,IAAP;AACD;;AAEDC,EAAAA,QAAQ,CACNC,QADM,EASN;AACA;AACA,SAAKC,QAAL,CAAcjB,qBAAd,GAAsCA,qBAAtC;AACA,WAAO,MAAMe,QAAN,CAAeC,QAAf,CAAP;AACD;;AAnDD","sourcesContent":["import { BaseGestureConfig, ContinousBaseGesture } from './gesture';\nimport {\n ForceTouchGestureConfig,\n ForceTouchGestureHandlerEventPayload,\n} from '../ForceTouchGestureHandler';\nimport { GestureUpdateEvent } from '../gestureHandlerCommon';\n\nexport type ForceTouchGestureChangeEventPayload = {\n forceChange: number;\n};\n\nfunction changeEventCalculator(\n current: GestureUpdateEvent<ForceTouchGestureHandlerEventPayload>,\n previous?: GestureUpdateEvent<ForceTouchGestureHandlerEventPayload>\n) {\n 'worklet';\n let changePayload: ForceTouchGestureChangeEventPayload;\n if (previous === undefined) {\n changePayload = {\n forceChange: current.force,\n };\n } else {\n changePayload = {\n forceChange: current.force - previous.force,\n };\n }\n\n return { ...current, ...changePayload };\n}\n\nexport class ForceTouchGesture extends ContinousBaseGesture<\n ForceTouchGestureHandlerEventPayload,\n ForceTouchGestureChangeEventPayload\n> {\n public config: BaseGestureConfig & ForceTouchGestureConfig = {};\n\n constructor() {\n super();\n\n this.handlerName = 'ForceTouchGestureHandler';\n }\n\n /**\n * A minimal pressure that is required before gesture can activate.\n * Should be a value from range [0.0, 1.0]. Default is 0.2.\n * @param force\n */\n minForce(force: number) {\n this.config.minForce = force;\n return this;\n }\n\n /**\n * A maximal pressure that could be applied for gesture.\n * If the pressure is greater, gesture fails. Should be a value from range [0.0, 1.0].\n * @param force\n */\n maxForce(force: number) {\n this.config.maxForce = force;\n return this;\n }\n\n /**\n * Value defining if haptic feedback has to be performed on activation.\n * @param value\n */\n feedbackOnActivation(value: boolean) {\n this.config.feedbackOnActivation = value;\n return this;\n }\n\n onChange(\n callback: (\n event: GestureUpdateEvent<\n GestureUpdateEvent<\n ForceTouchGestureHandlerEventPayload &\n ForceTouchGestureChangeEventPayload\n >\n >\n ) => void\n ) {\n // @ts-ignore TS being overprotective, ForceTouchGestureHandlerEventPayload is Record\n this.handlers.changeEventCalculator = changeEventCalculator;\n return super.onChange(callback);\n }\n}\n\nexport type ForceTouchGestureType = InstanceType<typeof ForceTouchGesture>;\n"]}

View File

@@ -0,0 +1,362 @@
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
import { getNextHandlerTag } from '../handlersRegistry';
import { isRemoteDebuggingEnabled } from '../../utils';
export const CALLBACK_TYPE = {
UNDEFINED: 0,
BEGAN: 1,
START: 2,
UPDATE: 3,
CHANGE: 4,
END: 5,
FINALIZE: 6,
TOUCHES_DOWN: 7,
TOUCHES_MOVE: 8,
TOUCHES_UP: 9,
TOUCHES_CANCELLED: 10
}; // Allow using CALLBACK_TYPE as object and type
// eslint-disable-next-line @typescript-eslint/no-redeclare
export class Gesture {}
let nextGestureId = 0;
export class BaseGesture extends Gesture {
constructor() {
super(); // Used to check whether the gesture config has been updated when wrapping it
// with `useMemo`. Since every config will have a unique id, when the dependencies
// don't change, the config won't be recreated and the id will stay the same.
// If the id is different, it means that the config has changed and the gesture
// needs to be updated.
_defineProperty(this, "gestureId", -1);
_defineProperty(this, "handlerTag", -1);
_defineProperty(this, "handlerName", '');
_defineProperty(this, "config", {});
_defineProperty(this, "handlers", {
gestureId: -1,
handlerTag: -1,
isWorklet: []
});
this.gestureId = nextGestureId++;
this.handlers.gestureId = this.gestureId;
}
addDependency(key, gesture) {
const value = this.config[key];
this.config[key] = value ? Array().concat(value, gesture) : [gesture];
}
/**
* Sets a `ref` to the gesture object, allowing for interoperability with the old API.
* @param ref
*/
withRef(ref) {
this.config.ref = ref;
return this;
} // eslint-disable-next-line @typescript-eslint/ban-types
isWorklet(callback) {
//@ts-ignore if callback is a worklet, the property will be available, if not then the check will return false
return callback.__workletHash !== undefined;
}
/**
* Set the callback that is being called when given gesture handler starts receiving touches.
* At the moment of this callback the handler is in `BEGAN` state and we don't know yet if it will recognize the gesture at all.
* @param callback
*/
onBegin(callback) {
this.handlers.onBegin = callback;
this.handlers.isWorklet[CALLBACK_TYPE.BEGAN] = this.isWorklet(callback);
return this;
}
/**
* Set the callback that is being called when the gesture is recognized by the handler and it transitions to the `ACTIVE` state.
* @param callback
*/
onStart(callback) {
this.handlers.onStart = callback;
this.handlers.isWorklet[CALLBACK_TYPE.START] = this.isWorklet(callback);
return this;
}
/**
* Set the callback that is being called when the gesture that was recognized by the handler finishes and handler reaches `END` state.
* It will be called only if the handler was previously in the `ACTIVE` state.
* @param callback
*/
onEnd(callback) {
this.handlers.onEnd = callback; //@ts-ignore if callback is a worklet, the property will be available, if not then the check will return false
this.handlers.isWorklet[CALLBACK_TYPE.END] = this.isWorklet(callback);
return this;
}
/**
* Set the callback that is being called when the handler finalizes handling gesture - the gesture was recognized and has finished or it failed to recognize.
* @param callback
*/
onFinalize(callback) {
this.handlers.onFinalize = callback; //@ts-ignore if callback is a worklet, the property will be available, if not then the check will return false
this.handlers.isWorklet[CALLBACK_TYPE.FINALIZE] = this.isWorklet(callback);
return this;
}
/**
* Set the `onTouchesDown` callback which is called every time a pointer is placed on the screen.
* @param callback
*/
onTouchesDown(callback) {
this.config.needsPointerData = true;
this.handlers.onTouchesDown = callback;
this.handlers.isWorklet[CALLBACK_TYPE.TOUCHES_DOWN] = this.isWorklet(callback);
return this;
}
/**
* Set the `onTouchesMove` callback which is called every time a pointer is moved on the screen.
* @param callback
*/
onTouchesMove(callback) {
this.config.needsPointerData = true;
this.handlers.onTouchesMove = callback;
this.handlers.isWorklet[CALLBACK_TYPE.TOUCHES_MOVE] = this.isWorklet(callback);
return this;
}
/**
* Set the `onTouchesUp` callback which is called every time a pointer is lifted from the screen.
* @param callback
*/
onTouchesUp(callback) {
this.config.needsPointerData = true;
this.handlers.onTouchesUp = callback;
this.handlers.isWorklet[CALLBACK_TYPE.TOUCHES_UP] = this.isWorklet(callback);
return this;
}
/**
* Set the `onTouchesCancelled` callback which is called every time a pointer stops being tracked, for example when the gesture finishes.
* @param callback
*/
onTouchesCancelled(callback) {
this.config.needsPointerData = true;
this.handlers.onTouchesCancelled = callback;
this.handlers.isWorklet[CALLBACK_TYPE.TOUCHES_CANCELLED] = this.isWorklet(callback);
return this;
}
/**
* Indicates whether the given handler should be analyzing stream of touch events or not.
* @param enabled
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/pan-gesture#enabledvalue-boolean
*/
enabled(enabled) {
this.config.enabled = enabled;
return this;
}
/**
* When true the handler will cancel or fail recognition (depending on its current state) whenever the finger leaves the area of the connected view.
* @param value
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/pan-gesture#shouldcancelwhenoutsidevalue-boolean
*/
shouldCancelWhenOutside(value) {
this.config.shouldCancelWhenOutside = value;
return this;
}
/**
* This parameter enables control over what part of the connected view area can be used to begin recognizing the gesture.
* When a negative number is provided the bounds of the view will reduce the area by the given number of points in each of the sides evenly.
* @param hitSlop
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/pan-gesture#hitslopsettings
*/
hitSlop(hitSlop) {
this.config.hitSlop = hitSlop;
return this;
}
/**
* #### Web only
* This parameter allows to specify which `cursor` should be used when gesture activates.
* Supports all CSS cursor values (e.g. `"grab"`, `"zoom-in"`). Default value is set to `"auto"`.
* @param activeCursor
*/
activeCursor(activeCursor) {
this.config.activeCursor = activeCursor;
return this;
}
/**
* #### Web & Android only
* Allows users to choose which mouse button should handler respond to.
* Arguments can be combined using `|` operator, e.g. `mouseButton(MouseButton.LEFT | MouseButton.RIGHT)`.
* Default value is set to `MouseButton.LEFT`.
* @param mouseButton
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/pan-gesture#mousebuttonvalue-mousebutton-web--android-only
*/
mouseButton(mouseButton) {
this.config.mouseButton = mouseButton;
return this;
}
/**
* When `react-native-reanimated` is installed, the callbacks passed to the gestures are automatically workletized and run on the UI thread when called.
* This option allows for changing this behavior: when `true`, all the callbacks will be run on the JS thread instead of the UI thread, regardless of whether they are worklets or not.
* Defaults to `false`.
* @param runOnJS
*/
runOnJS(runOnJS) {
this.config.runOnJS = runOnJS;
return this;
}
/**
* Allows gestures across different components to be recognized simultaneously.
* @param gestures
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/fundamentals/gesture-composition/#simultaneouswithexternalgesture
*/
simultaneousWithExternalGesture(...gestures) {
for (const gesture of gestures) {
this.addDependency('simultaneousWith', gesture);
}
return this;
}
/**
* Allows to delay activation of the handler until all handlers passed as arguments to this method fail (or don't begin at all).
* @param gestures
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/fundamentals/gesture-composition/#requireexternalgesturetofail
*/
requireExternalGestureToFail(...gestures) {
for (const gesture of gestures) {
this.addDependency('requireToFail', gesture);
}
return this;
}
/**
* Works similarily to `requireExternalGestureToFail` but the direction of the relation is reversed - instead of being one-to-many relation, it's many-to-one.
* @param gestures
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/fundamentals/gesture-composition/#blocksexternalgesture
*/
blocksExternalGesture(...gestures) {
for (const gesture of gestures) {
this.addDependency('blocksHandlers', gesture);
}
return this;
}
/**
* Sets a `testID` property for gesture object, allowing for querying for it in tests.
* @param id
*/
withTestId(id) {
this.config.testId = id;
return this;
}
/**
* #### iOS only
* When `true`, the handler will cancel touches for native UI components (`UIButton`, `UISwitch`, etc) it's attached to when it becomes `ACTIVE`.
* Default value is `true`.
* @param value
*/
cancelsTouchesInView(value) {
this.config.cancelsTouchesInView = value;
return this;
}
initialize() {
this.handlerTag = getNextHandlerTag();
this.handlers = { ...this.handlers,
handlerTag: this.handlerTag
};
if (this.config.ref) {
this.config.ref.current = this;
}
}
toGestureArray() {
return [this];
} // eslint-disable-next-line @typescript-eslint/no-empty-function
prepare() {}
get shouldUseReanimated() {
// use Reanimated when runOnJS isn't set explicitly,
// and all defined callbacks are worklets,
// and remote debugging is disabled
return this.config.runOnJS !== true && !this.handlers.isWorklet.includes(false) && !isRemoteDebuggingEnabled();
}
}
export class ContinousBaseGesture extends BaseGesture {
/**
* Set the callback that is being called every time the gesture receives an update while it's active.
* @param callback
*/
onUpdate(callback) {
this.handlers.onUpdate = callback;
this.handlers.isWorklet[CALLBACK_TYPE.UPDATE] = this.isWorklet(callback);
return this;
}
/**
* Set the callback that is being called every time the gesture receives an update while it's active.
* This callback will receive information about change in value in relation to the last received event.
* @param callback
*/
onChange(callback) {
this.handlers.onChange = callback;
this.handlers.isWorklet[CALLBACK_TYPE.CHANGE] = this.isWorklet(callback);
return this;
}
/**
* When `true` the handler will not activate by itself even if its activation criteria are met.
* Instead you can manipulate its state using state manager.
* @param manualActivation
*/
manualActivation(manualActivation) {
this.config.manualActivation = manualActivation;
return this;
}
}
//# sourceMappingURL=gesture.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,90 @@
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
import { BaseGesture, Gesture } from './gesture';
function extendRelation(currentRelation, extendWith) {
if (currentRelation === undefined) {
return [...extendWith];
} else {
return [...currentRelation, ...extendWith];
}
}
export class ComposedGesture extends Gesture {
constructor(...gestures) {
super();
_defineProperty(this, "gestures", []);
_defineProperty(this, "simultaneousGestures", []);
_defineProperty(this, "requireGesturesToFail", []);
this.gestures = gestures;
}
prepareSingleGesture(gesture, simultaneousGestures, requireGesturesToFail) {
if (gesture instanceof BaseGesture) {
const newConfig = { ...gesture.config
};
newConfig.simultaneousWith = extendRelation(newConfig.simultaneousWith, simultaneousGestures);
newConfig.requireToFail = extendRelation(newConfig.requireToFail, requireGesturesToFail);
gesture.config = newConfig;
} else if (gesture instanceof ComposedGesture) {
gesture.simultaneousGestures = simultaneousGestures;
gesture.requireGesturesToFail = requireGesturesToFail;
gesture.prepare();
}
}
prepare() {
for (const gesture of this.gestures) {
this.prepareSingleGesture(gesture, this.simultaneousGestures, this.requireGesturesToFail);
}
}
initialize() {
for (const gesture of this.gestures) {
gesture.initialize();
}
}
toGestureArray() {
return this.gestures.flatMap(gesture => gesture.toGestureArray());
}
}
export class SimultaneousGesture extends ComposedGesture {
prepare() {
// this piece of magic works something like this:
// for every gesture in the array
const simultaneousArrays = this.gestures.map(gesture => // we take the array it's in
this.gestures // and make a copy without it
.filter(x => x !== gesture) // then we flatmap the result to get list of raw (not composed) gestures
// this way we don't make the gestures simultaneous with themselves, which is
// important when the gesture is `ExclusiveGesture` - we don't want to make
// exclusive gestures simultaneous
.flatMap(x => x.toGestureArray()));
for (let i = 0; i < this.gestures.length; i++) {
this.prepareSingleGesture(this.gestures[i], simultaneousArrays[i], this.requireGesturesToFail);
}
}
}
export class ExclusiveGesture extends ComposedGesture {
prepare() {
// transforms the array of gestures into array of grouped raw (not composed) gestures
// i.e. [gesture1, gesture2, ComposedGesture(gesture3, gesture4)] -> [[gesture1], [gesture2], [gesture3, gesture4]]
const gestureArrays = this.gestures.map(gesture => gesture.toGestureArray());
let requireToFail = [];
for (let i = 0; i < this.gestures.length; i++) {
this.prepareSingleGesture(this.gestures[i], this.simultaneousGestures, this.requireGesturesToFail.concat(requireToFail)); // every group gets to wait for all groups before it
requireToFail = requireToFail.concat(gestureArrays[i]);
}
}
}
//# sourceMappingURL=gestureComposition.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,138 @@
import { FlingGesture } from './flingGesture';
import { ForceTouchGesture } from './forceTouchGesture';
import { ComposedGesture, ExclusiveGesture, SimultaneousGesture } from './gestureComposition';
import { LongPressGesture } from './longPressGesture';
import { PanGesture } from './panGesture';
import { PinchGesture } from './pinchGesture';
import { RotationGesture } from './rotationGesture';
import { TapGesture } from './tapGesture';
import { NativeGesture } from './nativeGesture';
import { ManualGesture } from './manualGesture';
import { HoverGesture } from './hoverGesture';
/**
* `Gesture` is the object that allows you to create and compose gestures.
*
* ### Remarks
* - Consider wrapping your gesture configurations with `useMemo`, as it will reduce the amount of work Gesture Handler has to do under the hood when updating gestures.
*
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/gesture
*/
export const GestureObjects = {
/**
* A discrete gesture that recognizes one or many taps.
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/tap-gesture
*/
Tap: () => {
return new TapGesture();
},
/**
* A continuous gesture that can recognize a panning (dragging) gesture and track its movement.
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/pan-gesture
*/
Pan: () => {
return new PanGesture();
},
/**
* A continuous gesture that recognizes pinch gesture. It allows for tracking the distance between two fingers and use that information to scale or zoom your content.
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/pinch-gesture
*/
Pinch: () => {
return new PinchGesture();
},
/**
* A continuous gesture that can recognize rotation and track its movement.
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/rotation-gesture
*/
Rotation: () => {
return new RotationGesture();
},
/**
* A discrete gesture that activates when the movement is sufficiently fast.
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/fling-gesture
*/
Fling: () => {
return new FlingGesture();
},
/**
* A discrete gesture that activates when the corresponding view is pressed for a sufficiently long time.
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/long-press-gesture
*/
LongPress: () => {
return new LongPressGesture();
},
/**
* #### iOS only
* A continuous gesture that recognizes force of a touch. It allows for tracking pressure of touch on some iOS devices.
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/force-touch-gesture
*/
ForceTouch: () => {
return new ForceTouchGesture();
},
/**
* A gesture that allows other touch handling components to participate in RNGH's gesture system.
* When used, the other component should be the direct child of a `GestureDetector`.
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/native-gesture
*/
Native: () => {
return new NativeGesture();
},
/**
* A plain gesture that has no specific activation criteria nor event data set.
* Its state has to be controlled manually using a state manager.
* It will not fail when all the pointers are lifted from the screen.
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/manual-gesture
*/
Manual: () => {
return new ManualGesture();
},
/**
* A continuous gesture that can recognize hovering above the view it's attached to.
* The hover effect may be activated by moving a mouse or a stylus over the view.
*
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/hover-gesture
*/
Hover: () => {
return new HoverGesture();
},
/**
* Builds a composed gesture consisting of gestures provided as parameters.
* The first one that becomes active cancels the rest of gestures.
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/fundamentals/gesture-composition/#race
*/
Race: (...gestures) => {
return new ComposedGesture(...gestures);
},
/**
* Builds a composed gesture that allows all base gestures to run simultaneously.
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/fundamentals/gesture-composition/#simultaneous
*/
Simultaneous(...gestures) {
return new SimultaneousGesture(...gestures);
},
/**
* Builds a composed gesture where only one of the provided gestures can become active.
* Priority is decided through the order of gestures: the first one has higher priority
* than the second one, second one has higher priority than the third one, and so on.
* For example, to make a gesture that recognizes both single and double tap you need
* to call Exclusive(doubleTap, singleTap).
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/fundamentals/gesture-composition/#exclusive
*/
Exclusive(...gestures) {
return new ExclusiveGesture(...gestures);
}
};
//# sourceMappingURL=gestureObjects.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,56 @@
import { Reanimated } from './reanimatedWrapper';
import { State } from '../../State';
import { tagMessage } from '../../utils';
const warningMessage = tagMessage('react-native-reanimated is required in order to use synchronous state management'); // check if reanimated module is available, but look for useSharedValue as conditional
// require of reanimated can sometimes return content of `utils.ts` file (?)
const REANIMATED_AVAILABLE = (Reanimated === null || Reanimated === void 0 ? void 0 : Reanimated.useSharedValue) !== undefined;
const setGestureState = Reanimated === null || Reanimated === void 0 ? void 0 : Reanimated.setGestureState;
function create(handlerTag) {
'worklet';
return {
begin: () => {
'worklet';
if (REANIMATED_AVAILABLE) {
setGestureState(handlerTag, State.BEGAN);
} else {
console.warn(warningMessage);
}
},
activate: () => {
'worklet';
if (REANIMATED_AVAILABLE) {
setGestureState(handlerTag, State.ACTIVE);
} else {
console.warn(warningMessage);
}
},
fail: () => {
'worklet';
if (REANIMATED_AVAILABLE) {
setGestureState(handlerTag, State.FAILED);
} else {
console.warn(warningMessage);
}
},
end: () => {
'worklet';
if (REANIMATED_AVAILABLE) {
setGestureState(handlerTag, State.END);
} else {
console.warn(warningMessage);
}
}
};
}
export const GestureStateManager = {
create
};
//# sourceMappingURL=gestureStateManager.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["gestureStateManager.ts"],"names":["Reanimated","State","tagMessage","warningMessage","REANIMATED_AVAILABLE","useSharedValue","undefined","setGestureState","create","handlerTag","begin","BEGAN","console","warn","activate","ACTIVE","fail","FAILED","end","END","GestureStateManager"],"mappings":"AAAA,SAASA,UAAT,QAA2B,qBAA3B;AACA,SAASC,KAAT,QAAsB,aAAtB;AACA,SAASC,UAAT,QAA2B,aAA3B;AASA,MAAMC,cAAc,GAAGD,UAAU,CAC/B,kFAD+B,CAAjC,C,CAIA;AACA;;AACA,MAAME,oBAAoB,GAAG,CAAAJ,UAAU,SAAV,IAAAA,UAAU,WAAV,YAAAA,UAAU,CAAEK,cAAZ,MAA+BC,SAA5D;AACA,MAAMC,eAAe,GAAGP,UAAH,aAAGA,UAAH,uBAAGA,UAAU,CAAEO,eAApC;;AAEA,SAASC,MAAT,CAAgBC,UAAhB,EAA6D;AAC3D;;AACA,SAAO;AACLC,IAAAA,KAAK,EAAE,MAAM;AACX;;AACA,UAAIN,oBAAJ,EAA0B;AACxBG,QAAAA,eAAe,CAACE,UAAD,EAAaR,KAAK,CAACU,KAAnB,CAAf;AACD,OAFD,MAEO;AACLC,QAAAA,OAAO,CAACC,IAAR,CAAaV,cAAb;AACD;AACF,KARI;AAULW,IAAAA,QAAQ,EAAE,MAAM;AACd;;AACA,UAAIV,oBAAJ,EAA0B;AACxBG,QAAAA,eAAe,CAACE,UAAD,EAAaR,KAAK,CAACc,MAAnB,CAAf;AACD,OAFD,MAEO;AACLH,QAAAA,OAAO,CAACC,IAAR,CAAaV,cAAb;AACD;AACF,KAjBI;AAmBLa,IAAAA,IAAI,EAAE,MAAM;AACV;;AACA,UAAIZ,oBAAJ,EAA0B;AACxBG,QAAAA,eAAe,CAACE,UAAD,EAAaR,KAAK,CAACgB,MAAnB,CAAf;AACD,OAFD,MAEO;AACLL,QAAAA,OAAO,CAACC,IAAR,CAAaV,cAAb;AACD;AACF,KA1BI;AA4BLe,IAAAA,GAAG,EAAE,MAAM;AACT;;AACA,UAAId,oBAAJ,EAA0B;AACxBG,QAAAA,eAAe,CAACE,UAAD,EAAaR,KAAK,CAACkB,GAAnB,CAAf;AACD,OAFD,MAEO;AACLP,QAAAA,OAAO,CAACC,IAAR,CAAaV,cAAb;AACD;AACF;AAnCI,GAAP;AAqCD;;AAED,OAAO,MAAMiB,mBAAmB,GAAG;AACjCZ,EAAAA;AADiC,CAA5B","sourcesContent":["import { Reanimated } from './reanimatedWrapper';\nimport { State } from '../../State';\nimport { tagMessage } from '../../utils';\n\nexport interface GestureStateManagerType {\n begin: () => void;\n activate: () => void;\n fail: () => void;\n end: () => void;\n}\n\nconst warningMessage = tagMessage(\n 'react-native-reanimated is required in order to use synchronous state management'\n);\n\n// check if reanimated module is available, but look for useSharedValue as conditional\n// require of reanimated can sometimes return content of `utils.ts` file (?)\nconst REANIMATED_AVAILABLE = Reanimated?.useSharedValue !== undefined;\nconst setGestureState = Reanimated?.setGestureState;\n\nfunction create(handlerTag: number): GestureStateManagerType {\n 'worklet';\n return {\n begin: () => {\n 'worklet';\n if (REANIMATED_AVAILABLE) {\n setGestureState(handlerTag, State.BEGAN);\n } else {\n console.warn(warningMessage);\n }\n },\n\n activate: () => {\n 'worklet';\n if (REANIMATED_AVAILABLE) {\n setGestureState(handlerTag, State.ACTIVE);\n } else {\n console.warn(warningMessage);\n }\n },\n\n fail: () => {\n 'worklet';\n if (REANIMATED_AVAILABLE) {\n setGestureState(handlerTag, State.FAILED);\n } else {\n console.warn(warningMessage);\n }\n },\n\n end: () => {\n 'worklet';\n if (REANIMATED_AVAILABLE) {\n setGestureState(handlerTag, State.END);\n } else {\n console.warn(warningMessage);\n }\n },\n };\n}\n\nexport const GestureStateManager = {\n create,\n};\n"]}

View File

@@ -0,0 +1,21 @@
import NodeManager from '../../web/tools/NodeManager';
export const GestureStateManager = {
create(handlerTag) {
return {
begin: () => {
NodeManager.getHandler(handlerTag).begin();
},
activate: () => {
NodeManager.getHandler(handlerTag).activate(true);
},
fail: () => {
NodeManager.getHandler(handlerTag).fail();
},
end: () => {
NodeManager.getHandler(handlerTag).end();
}
};
}
};
//# sourceMappingURL=gestureStateManager.web.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["gestureStateManager.web.ts"],"names":["NodeManager","GestureStateManager","create","handlerTag","begin","getHandler","activate","fail","end"],"mappings":"AAAA,OAAOA,WAAP,MAAwB,6BAAxB;AAGA,OAAO,MAAMC,mBAAmB,GAAG;AACjCC,EAAAA,MAAM,CAACC,UAAD,EAA8C;AAClD,WAAO;AACLC,MAAAA,KAAK,EAAE,MAAM;AACXJ,QAAAA,WAAW,CAACK,UAAZ,CAAuBF,UAAvB,EAAmCC,KAAnC;AACD,OAHI;AAKLE,MAAAA,QAAQ,EAAE,MAAM;AACdN,QAAAA,WAAW,CAACK,UAAZ,CAAuBF,UAAvB,EAAmCG,QAAnC,CAA4C,IAA5C;AACD,OAPI;AASLC,MAAAA,IAAI,EAAE,MAAM;AACVP,QAAAA,WAAW,CAACK,UAAZ,CAAuBF,UAAvB,EAAmCI,IAAnC;AACD,OAXI;AAaLC,MAAAA,GAAG,EAAE,MAAM;AACTR,QAAAA,WAAW,CAACK,UAAZ,CAAuBF,UAAvB,EAAmCK,GAAnC;AACD;AAfI,KAAP;AAiBD;;AAnBgC,CAA5B","sourcesContent":["import NodeManager from '../../web/tools/NodeManager';\nimport { GestureStateManagerType } from './gestureStateManager';\n\nexport const GestureStateManager = {\n create(handlerTag: number): GestureStateManagerType {\n return {\n begin: () => {\n NodeManager.getHandler(handlerTag).begin();\n },\n\n activate: () => {\n NodeManager.getHandler(handlerTag).activate(true);\n },\n\n fail: () => {\n NodeManager.getHandler(handlerTag).fail();\n },\n\n end: () => {\n NodeManager.getHandler(handlerTag).end();\n },\n };\n },\n};\n"]}

View File

@@ -0,0 +1,62 @@
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
import { ContinousBaseGesture } from './gesture';
export let HoverEffect;
(function (HoverEffect) {
HoverEffect[HoverEffect["NONE"] = 0] = "NONE";
HoverEffect[HoverEffect["LIFT"] = 1] = "LIFT";
HoverEffect[HoverEffect["HIGHLIGHT"] = 2] = "HIGHLIGHT";
})(HoverEffect || (HoverEffect = {}));
export const hoverGestureHandlerProps = ['hoverEffect'];
function changeEventCalculator(current, previous) {
'worklet';
let changePayload;
if (previous === undefined) {
changePayload = {
changeX: current.x,
changeY: current.y
};
} else {
changePayload = {
changeX: current.x - previous.x,
changeY: current.y - previous.y
};
}
return { ...current,
...changePayload
};
}
export class HoverGesture extends ContinousBaseGesture {
constructor() {
super();
_defineProperty(this, "config", {});
this.handlerName = 'HoverGestureHandler';
}
/**
* #### iOS only
* Sets the visual hover effect.
*/
effect(effect) {
this.config.hoverEffect = effect;
return this;
}
onChange(callback) {
// @ts-ignore TS being overprotective, HoverGestureHandlerEventPayload is Record
this.handlers.changeEventCalculator = changeEventCalculator;
return super.onChange(callback);
}
}
//# sourceMappingURL=hoverGesture.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["hoverGesture.ts"],"names":["ContinousBaseGesture","HoverEffect","hoverGestureHandlerProps","changeEventCalculator","current","previous","changePayload","undefined","changeX","x","changeY","y","HoverGesture","constructor","handlerName","effect","config","hoverEffect","onChange","callback","handlers"],"mappings":";;AAAA,SAA4BA,oBAA5B,QAAwD,WAAxD;AAeA,WAAYC,WAAZ;;WAAYA,W;AAAAA,EAAAA,W,CAAAA,W;AAAAA,EAAAA,W,CAAAA,W;AAAAA,EAAAA,W,CAAAA,W;GAAAA,W,KAAAA,W;;AAUZ,OAAO,MAAMC,wBAAwB,GAAG,CAAC,aAAD,CAAjC;;AAEP,SAASC,qBAAT,CACEC,OADF,EAEEC,QAFF,EAGE;AACA;;AACA,MAAIC,aAAJ;;AACA,MAAID,QAAQ,KAAKE,SAAjB,EAA4B;AAC1BD,IAAAA,aAAa,GAAG;AACdE,MAAAA,OAAO,EAAEJ,OAAO,CAACK,CADH;AAEdC,MAAAA,OAAO,EAAEN,OAAO,CAACO;AAFH,KAAhB;AAID,GALD,MAKO;AACLL,IAAAA,aAAa,GAAG;AACdE,MAAAA,OAAO,EAAEJ,OAAO,CAACK,CAAR,GAAYJ,QAAQ,CAACI,CADhB;AAEdC,MAAAA,OAAO,EAAEN,OAAO,CAACO,CAAR,GAAYN,QAAQ,CAACM;AAFhB,KAAhB;AAID;;AAED,SAAO,EAAE,GAAGP,OAAL;AAAc,OAAGE;AAAjB,GAAP;AACD;;AAED,OAAO,MAAMM,YAAN,SAA2BZ,oBAA3B,CAGL;AAGAa,EAAAA,WAAW,GAAG;AACZ;;AADY,oCAF0C,EAE1C;;AAGZ,SAAKC,WAAL,GAAmB,qBAAnB;AACD;AAED;AACF;AACA;AACA;;;AACEC,EAAAA,MAAM,CAACA,MAAD,EAAsB;AAC1B,SAAKC,MAAL,CAAYC,WAAZ,GAA0BF,MAA1B;AACA,WAAO,IAAP;AACD;;AAEDG,EAAAA,QAAQ,CACNC,QADM,EAMN;AACA;AACA,SAAKC,QAAL,CAAcjB,qBAAd,GAAsCA,qBAAtC;AACA,WAAO,MAAMe,QAAN,CAAeC,QAAf,CAAP;AACD;;AA5BD","sourcesContent":["import { BaseGestureConfig, ContinousBaseGesture } from './gesture';\nimport { GestureUpdateEvent } from '../gestureHandlerCommon';\n\nexport type HoverGestureHandlerEventPayload = {\n x: number;\n y: number;\n absoluteX: number;\n absoluteY: number;\n};\n\nexport type HoverGestureChangeEventPayload = {\n changeX: number;\n changeY: number;\n};\n\nexport enum HoverEffect {\n NONE = 0,\n LIFT = 1,\n HIGHLIGHT = 2,\n}\n\nexport interface HoverGestureConfig {\n hoverEffect?: HoverEffect;\n}\n\nexport const hoverGestureHandlerProps = ['hoverEffect'] as const;\n\nfunction changeEventCalculator(\n current: GestureUpdateEvent<HoverGestureHandlerEventPayload>,\n previous?: GestureUpdateEvent<HoverGestureHandlerEventPayload>\n) {\n 'worklet';\n let changePayload: HoverGestureChangeEventPayload;\n if (previous === undefined) {\n changePayload = {\n changeX: current.x,\n changeY: current.y,\n };\n } else {\n changePayload = {\n changeX: current.x - previous.x,\n changeY: current.y - previous.y,\n };\n }\n\n return { ...current, ...changePayload };\n}\n\nexport class HoverGesture extends ContinousBaseGesture<\n HoverGestureHandlerEventPayload,\n HoverGestureChangeEventPayload\n> {\n public config: BaseGestureConfig & HoverGestureConfig = {};\n\n constructor() {\n super();\n\n this.handlerName = 'HoverGestureHandler';\n }\n\n /**\n * #### iOS only\n * Sets the visual hover effect.\n */\n effect(effect: HoverEffect) {\n this.config.hoverEffect = effect;\n return this;\n }\n\n onChange(\n callback: (\n event: GestureUpdateEvent<\n HoverGestureHandlerEventPayload & HoverGestureChangeEventPayload\n >\n ) => void\n ) {\n // @ts-ignore TS being overprotective, HoverGestureHandlerEventPayload is Record\n this.handlers.changeEventCalculator = changeEventCalculator;\n return super.onChange(callback);\n }\n}\n\nexport type HoverGestureType = InstanceType<typeof HoverGesture>;\n"]}

View File

@@ -0,0 +1,37 @@
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
import { BaseGesture } from './gesture';
export class LongPressGesture extends BaseGesture {
constructor() {
super();
_defineProperty(this, "config", {});
this.handlerName = 'LongPressGestureHandler';
this.shouldCancelWhenOutside(true);
}
/**
* Minimum time, expressed in milliseconds, that a finger must remain pressed on the corresponding view.
* The default value is 500.
* @param duration
*/
minDuration(duration) {
this.config.minDurationMs = duration;
return this;
}
/**
* Maximum distance, expressed in points, that defines how far the finger is allowed to travel during a long press gesture.
* @param distance
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/long-press-gesture#maxdistancevalue-number
*/
maxDistance(distance) {
this.config.maxDist = distance;
return this;
}
}
//# sourceMappingURL=longPressGesture.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["longPressGesture.ts"],"names":["BaseGesture","LongPressGesture","constructor","handlerName","shouldCancelWhenOutside","minDuration","duration","config","minDurationMs","maxDistance","distance","maxDist"],"mappings":";;AAAA,SAASA,WAAT,QAA+C,WAA/C;AAMA,OAAO,MAAMC,gBAAN,SAA+BD,WAA/B,CAAgF;AAGrFE,EAAAA,WAAW,GAAG;AACZ;;AADY,oCAF8C,EAE9C;;AAGZ,SAAKC,WAAL,GAAmB,yBAAnB;AACA,SAAKC,uBAAL,CAA6B,IAA7B;AACD;AAED;AACF;AACA;AACA;AACA;;;AACEC,EAAAA,WAAW,CAACC,QAAD,EAAmB;AAC5B,SAAKC,MAAL,CAAYC,aAAZ,GAA4BF,QAA5B;AACA,WAAO,IAAP;AACD;AAED;AACF;AACA;AACA;AACA;;;AACEG,EAAAA,WAAW,CAACC,QAAD,EAAmB;AAC5B,SAAKH,MAAL,CAAYI,OAAZ,GAAsBD,QAAtB;AACA,WAAO,IAAP;AACD;;AA5BoF","sourcesContent":["import { BaseGesture, BaseGestureConfig } from './gesture';\nimport {\n LongPressGestureConfig,\n LongPressGestureHandlerEventPayload,\n} from '../LongPressGestureHandler';\n\nexport class LongPressGesture extends BaseGesture<LongPressGestureHandlerEventPayload> {\n public config: BaseGestureConfig & LongPressGestureConfig = {};\n\n constructor() {\n super();\n\n this.handlerName = 'LongPressGestureHandler';\n this.shouldCancelWhenOutside(true);\n }\n\n /**\n * Minimum time, expressed in milliseconds, that a finger must remain pressed on the corresponding view.\n * The default value is 500.\n * @param duration\n */\n minDuration(duration: number) {\n this.config.minDurationMs = duration;\n return this;\n }\n\n /**\n * Maximum distance, expressed in points, that defines how far the finger is allowed to travel during a long press gesture.\n * @param distance\n * @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/long-press-gesture#maxdistancevalue-number\n */\n maxDistance(distance: number) {\n this.config.maxDist = distance;\n return this;\n }\n}\n\nexport type LongPressGestureType = InstanceType<typeof LongPressGesture>;\n"]}

View File

@@ -0,0 +1,22 @@
import { ContinousBaseGesture } from './gesture';
function changeEventCalculator(current, _previous) {
'worklet';
return current;
}
export class ManualGesture extends ContinousBaseGesture {
constructor() {
super();
this.handlerName = 'ManualGestureHandler';
}
onChange(callback) {
// @ts-ignore TS being overprotective, Record<string, never> is Record
this.handlers.changeEventCalculator = changeEventCalculator;
return super.onChange(callback);
}
}
//# sourceMappingURL=manualGesture.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["manualGesture.ts"],"names":["ContinousBaseGesture","changeEventCalculator","current","_previous","ManualGesture","constructor","handlerName","onChange","callback","handlers"],"mappings":"AACA,SAASA,oBAAT,QAAqC,WAArC;;AAEA,SAASC,qBAAT,CACEC,OADF,EAEEC,SAFF,EAGE;AACA;;AACA,SAAOD,OAAP;AACD;;AAED,OAAO,MAAME,aAAN,SAA4BJ,oBAA5B,CAGL;AACAK,EAAAA,WAAW,GAAG;AACZ;AAEA,SAAKC,WAAL,GAAmB,sBAAnB;AACD;;AAEDC,EAAAA,QAAQ,CACNC,QADM,EAEN;AACA;AACA,SAAKC,QAAL,CAAcR,qBAAd,GAAsCA,qBAAtC;AACA,WAAO,MAAMM,QAAN,CAAeC,QAAf,CAAP;AACD;;AAbD","sourcesContent":["import { GestureUpdateEvent } from '../gestureHandlerCommon';\nimport { ContinousBaseGesture } from './gesture';\n\nfunction changeEventCalculator(\n current: GestureUpdateEvent<Record<string, never>>,\n _previous?: GestureUpdateEvent<Record<string, never>>\n) {\n 'worklet';\n return current;\n}\n\nexport class ManualGesture extends ContinousBaseGesture<\n Record<string, never>,\n Record<string, never>\n> {\n constructor() {\n super();\n\n this.handlerName = 'ManualGestureHandler';\n }\n\n onChange(\n callback: (event: GestureUpdateEvent<Record<string, never>>) => void\n ) {\n // @ts-ignore TS being overprotective, Record<string, never> is Record\n this.handlers.changeEventCalculator = changeEventCalculator;\n return super.onChange(callback);\n }\n}\n\nexport type ManualGestureType = InstanceType<typeof ManualGesture>;\n"]}

View File

@@ -0,0 +1,34 @@
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
import { BaseGesture } from './gesture';
export class NativeGesture extends BaseGesture {
constructor() {
super();
_defineProperty(this, "config", {});
this.handlerName = 'NativeViewGestureHandler';
}
/**
* When true, underlying handler will activate unconditionally when in `BEGAN` or `UNDETERMINED` state.
* @param value
*/
shouldActivateOnStart(value) {
this.config.shouldActivateOnStart = value;
return this;
}
/**
* When true, cancels all other gesture handlers when this `NativeViewGestureHandler` receives an `ACTIVE` state event.
* @param value
*/
disallowInterruption(value) {
this.config.disallowInterruption = value;
return this;
}
}
//# sourceMappingURL=nativeGesture.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["nativeGesture.ts"],"names":["BaseGesture","NativeGesture","constructor","handlerName","shouldActivateOnStart","value","config","disallowInterruption"],"mappings":";;AAAA,SAA4BA,WAA5B,QAA+C,WAA/C;AAMA,OAAO,MAAMC,aAAN,SAA4BD,WAA5B,CAAyE;AAG9EE,EAAAA,WAAW,GAAG;AACZ;;AADY,oCAF+C,EAE/C;;AAGZ,SAAKC,WAAL,GAAmB,0BAAnB;AACD;AAED;AACF;AACA;AACA;;;AACEC,EAAAA,qBAAqB,CAACC,KAAD,EAAiB;AACpC,SAAKC,MAAL,CAAYF,qBAAZ,GAAoCC,KAApC;AACA,WAAO,IAAP;AACD;AAED;AACF;AACA;AACA;;;AACEE,EAAAA,oBAAoB,CAACF,KAAD,EAAiB;AACnC,SAAKC,MAAL,CAAYC,oBAAZ,GAAmCF,KAAnC;AACA,WAAO,IAAP;AACD;;AAzB6E","sourcesContent":["import { BaseGestureConfig, BaseGesture } from './gesture';\nimport {\n NativeViewGestureConfig,\n NativeViewGestureHandlerPayload,\n} from '../NativeViewGestureHandler';\n\nexport class NativeGesture extends BaseGesture<NativeViewGestureHandlerPayload> {\n public config: BaseGestureConfig & NativeViewGestureConfig = {};\n\n constructor() {\n super();\n\n this.handlerName = 'NativeViewGestureHandler';\n }\n\n /**\n * When true, underlying handler will activate unconditionally when in `BEGAN` or `UNDETERMINED` state.\n * @param value\n */\n shouldActivateOnStart(value: boolean) {\n this.config.shouldActivateOnStart = value;\n return this;\n }\n\n /**\n * When true, cancels all other gesture handlers when this `NativeViewGestureHandler` receives an `ACTIVE` state event.\n * @param value\n */\n disallowInterruption(value: boolean) {\n this.config.disallowInterruption = value;\n return this;\n }\n}\n\nexport type NativeGestureType = InstanceType<typeof NativeGesture>;\n"]}

View File

@@ -0,0 +1,216 @@
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
import { ContinousBaseGesture } from './gesture';
function changeEventCalculator(current, previous) {
'worklet';
let changePayload;
if (previous === undefined) {
changePayload = {
changeX: current.translationX,
changeY: current.translationY
};
} else {
changePayload = {
changeX: current.translationX - previous.translationX,
changeY: current.translationY - previous.translationY
};
}
return { ...current,
...changePayload
};
}
export class PanGesture extends ContinousBaseGesture {
constructor() {
super();
_defineProperty(this, "config", {});
this.handlerName = 'PanGestureHandler';
}
/**
* Range along Y axis (in points) where fingers travels without activation of gesture.
* @param offset
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/pan-gesture#activeoffsetyvalue-number--number
*/
activeOffsetY(offset) {
if (Array.isArray(offset)) {
this.config.activeOffsetYStart = offset[0];
this.config.activeOffsetYEnd = offset[1];
} else if (offset < 0) {
this.config.activeOffsetYStart = offset;
} else {
this.config.activeOffsetYEnd = offset;
}
return this;
}
/**
* Range along X axis (in points) where fingers travels without activation of gesture.
* @param offset
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/pan-gesture#activeoffsetxvalue-number--number
*/
activeOffsetX(offset) {
if (Array.isArray(offset)) {
this.config.activeOffsetXStart = offset[0];
this.config.activeOffsetXEnd = offset[1];
} else if (offset < 0) {
this.config.activeOffsetXStart = offset;
} else {
this.config.activeOffsetXEnd = offset;
}
return this;
}
/**
* When the finger moves outside this range (in points) along Y axis and gesture hasn't yet activated it will fail recognizing the gesture.
* @param offset
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/pan-gesture#failoffsetyvalue-number--number
*/
failOffsetY(offset) {
if (Array.isArray(offset)) {
this.config.failOffsetYStart = offset[0];
this.config.failOffsetYEnd = offset[1];
} else if (offset < 0) {
this.config.failOffsetYStart = offset;
} else {
this.config.failOffsetYEnd = offset;
}
return this;
}
/**
* When the finger moves outside this range (in points) along X axis and gesture hasn't yet activated it will fail recognizing the gesture.
* @param offset
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/pan-gesture#failoffsetxvalue-number--number
*/
failOffsetX(offset) {
if (Array.isArray(offset)) {
this.config.failOffsetXStart = offset[0];
this.config.failOffsetXEnd = offset[1];
} else if (offset < 0) {
this.config.failOffsetXStart = offset;
} else {
this.config.failOffsetXEnd = offset;
}
return this;
}
/**
* A number of fingers that is required to be placed before gesture can activate. Should be a higher or equal to 0 integer.
* @param minPointers
*/
minPointers(minPointers) {
this.config.minPointers = minPointers;
return this;
}
/**
* When the given number of fingers is placed on the screen and gesture hasn't yet activated it will fail recognizing the gesture.
* Should be a higher or equal to 0 integer.
* @param maxPointers
*/
maxPointers(maxPointers) {
this.config.maxPointers = maxPointers;
return this;
}
/**
* Minimum distance the finger (or multiple finger) need to travel before the gesture activates.
* Expressed in points.
* @param distance
*/
minDistance(distance) {
this.config.minDist = distance;
return this;
}
/**
* Minimum velocity the finger has to reach in order to activate handler.
* @param velocity
*/
minVelocity(velocity) {
this.config.minVelocity = velocity;
return this;
}
/**
* Minimum velocity along X axis the finger has to reach in order to activate handler.
* @param velocity
*/
minVelocityX(velocity) {
this.config.minVelocityX = velocity;
return this;
}
/**
* Minimum velocity along Y axis the finger has to reach in order to activate handler.
* @param velocity
*/
minVelocityY(velocity) {
this.config.minVelocityY = velocity;
return this;
}
/**
* #### Android only
* Android, by default, will calculate translation values based on the position of the leading pointer (the first one that was placed on the screen).
* This modifier allows that behavior to be changed to the one that is default on iOS - the averaged position of all active pointers will be used to calculate the translation values.
* @param value
*/
averageTouches(value) {
this.config.avgTouches = value;
return this;
}
/**
* #### iOS only
* Enables two-finger gestures on supported devices, for example iPads with trackpads.
* @param value
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/pan-gesture/#enabletrackpadtwofingergesturevalue-boolean-ios-only
*/
enableTrackpadTwoFingerGesture(value) {
this.config.enableTrackpadTwoFingerGesture = value;
return this;
}
/**
* Duration in milliseconds of the LongPress gesture before Pan is allowed to activate.
* @param duration
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/pan-gesture/#activateafterlongpressduration-number
*/
activateAfterLongPress(duration) {
this.config.activateAfterLongPress = duration;
return this;
}
onChange(callback) {
// @ts-ignore TS being overprotective, PanGestureHandlerEventPayload is Record
this.handlers.changeEventCalculator = changeEventCalculator;
return super.onChange(callback);
}
}
//# sourceMappingURL=panGesture.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,36 @@
import { ContinousBaseGesture } from './gesture';
function changeEventCalculator(current, previous) {
'worklet';
let changePayload;
if (previous === undefined) {
changePayload = {
scaleChange: current.scale
};
} else {
changePayload = {
scaleChange: current.scale / previous.scale
};
}
return { ...current,
...changePayload
};
}
export class PinchGesture extends ContinousBaseGesture {
constructor() {
super();
this.handlerName = 'PinchGestureHandler';
}
onChange(callback) {
// @ts-ignore TS being overprotective, PinchGestureHandlerEventPayload is Record
this.handlers.changeEventCalculator = changeEventCalculator;
return super.onChange(callback);
}
}
//# sourceMappingURL=pinchGesture.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["pinchGesture.ts"],"names":["ContinousBaseGesture","changeEventCalculator","current","previous","changePayload","undefined","scaleChange","scale","PinchGesture","constructor","handlerName","onChange","callback","handlers"],"mappings":"AAAA,SAASA,oBAAT,QAAqC,WAArC;;AAQA,SAASC,qBAAT,CACEC,OADF,EAEEC,QAFF,EAGE;AACA;;AACA,MAAIC,aAAJ;;AACA,MAAID,QAAQ,KAAKE,SAAjB,EAA4B;AAC1BD,IAAAA,aAAa,GAAG;AACdE,MAAAA,WAAW,EAAEJ,OAAO,CAACK;AADP,KAAhB;AAGD,GAJD,MAIO;AACLH,IAAAA,aAAa,GAAG;AACdE,MAAAA,WAAW,EAAEJ,OAAO,CAACK,KAAR,GAAgBJ,QAAQ,CAACI;AADxB,KAAhB;AAGD;;AAED,SAAO,EAAE,GAAGL,OAAL;AAAc,OAAGE;AAAjB,GAAP;AACD;;AAED,OAAO,MAAMI,YAAN,SAA2BR,oBAA3B,CAGL;AACAS,EAAAA,WAAW,GAAG;AACZ;AAEA,SAAKC,WAAL,GAAmB,qBAAnB;AACD;;AAEDC,EAAAA,QAAQ,CACNC,QADM,EAMN;AACA;AACA,SAAKC,QAAL,CAAcZ,qBAAd,GAAsCA,qBAAtC;AACA,WAAO,MAAMU,QAAN,CAAeC,QAAf,CAAP;AACD;;AAjBD","sourcesContent":["import { ContinousBaseGesture } from './gesture';\nimport { PinchGestureHandlerEventPayload } from '../PinchGestureHandler';\nimport { GestureUpdateEvent } from '../gestureHandlerCommon';\n\nexport type PinchGestureChangeEventPayload = {\n scaleChange: number;\n};\n\nfunction changeEventCalculator(\n current: GestureUpdateEvent<PinchGestureHandlerEventPayload>,\n previous?: GestureUpdateEvent<PinchGestureHandlerEventPayload>\n) {\n 'worklet';\n let changePayload: PinchGestureChangeEventPayload;\n if (previous === undefined) {\n changePayload = {\n scaleChange: current.scale,\n };\n } else {\n changePayload = {\n scaleChange: current.scale / previous.scale,\n };\n }\n\n return { ...current, ...changePayload };\n}\n\nexport class PinchGesture extends ContinousBaseGesture<\n PinchGestureHandlerEventPayload,\n PinchGestureChangeEventPayload\n> {\n constructor() {\n super();\n\n this.handlerName = 'PinchGestureHandler';\n }\n\n onChange(\n callback: (\n event: GestureUpdateEvent<\n PinchGestureHandlerEventPayload & PinchGestureChangeEventPayload\n >\n ) => void\n ) {\n // @ts-ignore TS being overprotective, PinchGestureHandlerEventPayload is Record\n this.handlers.changeEventCalculator = changeEventCalculator;\n return super.onChange(callback);\n }\n}\n\nexport type PinchGestureType = InstanceType<typeof PinchGesture>;\n"]}

View File

@@ -0,0 +1,30 @@
var _Reanimated;
import { tagMessage } from '../../utils';
let Reanimated;
try {
Reanimated = require('react-native-reanimated');
} catch (e) {
// When 'react-native-reanimated' is not available we want to quietly continue
// @ts-ignore TS demands the variable to be initialized
Reanimated = undefined;
}
if (!((_Reanimated = Reanimated) !== null && _Reanimated !== void 0 && _Reanimated.useSharedValue)) {
// @ts-ignore Make sure the loaded module is actually Reanimated, if it's not
// reset the module to undefined so we can fallback to the default implementation
Reanimated = undefined;
}
if (Reanimated !== undefined && !Reanimated.setGestureState) {
// The loaded module is Reanimated but it doesn't have the setGestureState defined
Reanimated.setGestureState = () => {
'worklet';
console.warn(tagMessage('Please use newer version of react-native-reanimated in order to control state of the gestures.'));
};
}
export { Reanimated };
//# sourceMappingURL=reanimatedWrapper.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["reanimatedWrapper.ts"],"names":["tagMessage","Reanimated","require","e","undefined","useSharedValue","setGestureState","console","warn"],"mappings":";;AAKA,SAASA,UAAT,QAA2B,aAA3B;AAMA,IAAIC,UAAJ;;AAkBA,IAAI;AACFA,EAAAA,UAAU,GAAGC,OAAO,CAAC,yBAAD,CAApB;AACD,CAFD,CAEE,OAAOC,CAAP,EAAU;AACV;AACA;AACAF,EAAAA,UAAU,GAAGG,SAAb;AACD;;AAED,IAAI,iBAACH,UAAD,wCAAC,YAAYI,cAAb,CAAJ,EAAiC;AAC/B;AACA;AACAJ,EAAAA,UAAU,GAAGG,SAAb;AACD;;AAED,IAAIH,UAAU,KAAKG,SAAf,IAA4B,CAACH,UAAU,CAACK,eAA5C,EAA6D;AAC3D;AACAL,EAAAA,UAAU,CAACK,eAAX,GAA6B,MAAM;AACjC;;AACAC,IAAAA,OAAO,CAACC,IAAR,CACER,UAAU,CACR,gGADQ,CADZ;AAKD,GAPD;AAQD;;AAED,SAASC,UAAT","sourcesContent":["import { ComponentClass } from 'react';\nimport {\n GestureUpdateEvent,\n GestureStateChangeEvent,\n} from '../gestureHandlerCommon';\nimport { tagMessage } from '../../utils';\n\nexport interface SharedValue<T> {\n value: T;\n}\n\nlet Reanimated: {\n default: {\n // Slightly modified definition copied from 'react-native-reanimated'\n // eslint-disable-next-line @typescript-eslint/ban-types\n createAnimatedComponent<P extends object>(\n component: ComponentClass<P>,\n options?: unknown\n ): ComponentClass<P>;\n };\n useEvent: (\n callback: (event: GestureUpdateEvent | GestureStateChangeEvent) => void,\n events: string[],\n rebuild: boolean\n ) => unknown;\n useSharedValue: <T>(value: T) => SharedValue<T>;\n setGestureState: (handlerTag: number, newState: number) => void;\n};\n\ntry {\n Reanimated = require('react-native-reanimated');\n} catch (e) {\n // When 'react-native-reanimated' is not available we want to quietly continue\n // @ts-ignore TS demands the variable to be initialized\n Reanimated = undefined;\n}\n\nif (!Reanimated?.useSharedValue) {\n // @ts-ignore Make sure the loaded module is actually Reanimated, if it's not\n // reset the module to undefined so we can fallback to the default implementation\n Reanimated = undefined;\n}\n\nif (Reanimated !== undefined && !Reanimated.setGestureState) {\n // The loaded module is Reanimated but it doesn't have the setGestureState defined\n Reanimated.setGestureState = () => {\n 'worklet';\n console.warn(\n tagMessage(\n 'Please use newer version of react-native-reanimated in order to control state of the gestures.'\n )\n );\n };\n}\n\nexport { Reanimated };\n"]}

View File

@@ -0,0 +1,36 @@
import { ContinousBaseGesture } from './gesture';
function changeEventCalculator(current, previous) {
'worklet';
let changePayload;
if (previous === undefined) {
changePayload = {
rotationChange: current.rotation
};
} else {
changePayload = {
rotationChange: current.rotation - previous.rotation
};
}
return { ...current,
...changePayload
};
}
export class RotationGesture extends ContinousBaseGesture {
constructor() {
super();
this.handlerName = 'RotationGestureHandler';
}
onChange(callback) {
// @ts-ignore TS being overprotective, RotationGestureHandlerEventPayload is Record
this.handlers.changeEventCalculator = changeEventCalculator;
return super.onChange(callback);
}
}
//# sourceMappingURL=rotationGesture.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["rotationGesture.ts"],"names":["ContinousBaseGesture","changeEventCalculator","current","previous","changePayload","undefined","rotationChange","rotation","RotationGesture","constructor","handlerName","onChange","callback","handlers"],"mappings":"AAAA,SAASA,oBAAT,QAAqC,WAArC;;AAQA,SAASC,qBAAT,CACEC,OADF,EAEEC,QAFF,EAGE;AACA;;AACA,MAAIC,aAAJ;;AACA,MAAID,QAAQ,KAAKE,SAAjB,EAA4B;AAC1BD,IAAAA,aAAa,GAAG;AACdE,MAAAA,cAAc,EAAEJ,OAAO,CAACK;AADV,KAAhB;AAGD,GAJD,MAIO;AACLH,IAAAA,aAAa,GAAG;AACdE,MAAAA,cAAc,EAAEJ,OAAO,CAACK,QAAR,GAAmBJ,QAAQ,CAACI;AAD9B,KAAhB;AAGD;;AAED,SAAO,EAAE,GAAGL,OAAL;AAAc,OAAGE;AAAjB,GAAP;AACD;;AAED,OAAO,MAAMI,eAAN,SAA8BR,oBAA9B,CAGL;AACAS,EAAAA,WAAW,GAAG;AACZ;AAEA,SAAKC,WAAL,GAAmB,wBAAnB;AACD;;AAEDC,EAAAA,QAAQ,CACNC,QADM,EAMN;AACA;AACA,SAAKC,QAAL,CAAcZ,qBAAd,GAAsCA,qBAAtC;AACA,WAAO,MAAMU,QAAN,CAAeC,QAAf,CAAP;AACD;;AAjBD","sourcesContent":["import { ContinousBaseGesture } from './gesture';\nimport { RotationGestureHandlerEventPayload } from '../RotationGestureHandler';\nimport { GestureUpdateEvent } from '../gestureHandlerCommon';\n\ntype RotationGestureChangeEventPayload = {\n rotationChange: number;\n};\n\nfunction changeEventCalculator(\n current: GestureUpdateEvent<RotationGestureHandlerEventPayload>,\n previous?: GestureUpdateEvent<RotationGestureHandlerEventPayload>\n) {\n 'worklet';\n let changePayload: RotationGestureChangeEventPayload;\n if (previous === undefined) {\n changePayload = {\n rotationChange: current.rotation,\n };\n } else {\n changePayload = {\n rotationChange: current.rotation - previous.rotation,\n };\n }\n\n return { ...current, ...changePayload };\n}\n\nexport class RotationGesture extends ContinousBaseGesture<\n RotationGestureHandlerEventPayload,\n RotationGestureChangeEventPayload\n> {\n constructor() {\n super();\n\n this.handlerName = 'RotationGestureHandler';\n }\n\n onChange(\n callback: (\n event: GestureUpdateEvent<\n RotationGestureHandlerEventPayload & RotationGestureChangeEventPayload\n >\n ) => void\n ) {\n // @ts-ignore TS being overprotective, RotationGestureHandlerEventPayload is Record\n this.handlers.changeEventCalculator = changeEventCalculator;\n return super.onChange(callback);\n }\n}\n\nexport type RotationGestureType = InstanceType<typeof RotationGesture>;\n"]}

View File

@@ -0,0 +1,92 @@
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
import { BaseGesture } from './gesture';
export class TapGesture extends BaseGesture {
constructor() {
super();
_defineProperty(this, "config", {});
this.handlerName = 'TapGestureHandler';
this.shouldCancelWhenOutside(true);
}
/**
* Minimum number of pointers (fingers) required to be placed before the gesture activates.
* Should be a positive integer. The default value is 1.
* @param minPointers
*/
minPointers(minPointers) {
this.config.minPointers = minPointers;
return this;
}
/**
* Number of tap gestures required to activate the gesture.
* The default value is 1.
* @param count
*/
numberOfTaps(count) {
this.config.numberOfTaps = count;
return this;
}
/**
* Maximum distance, expressed in points, that defines how far the finger is allowed to travel during a tap gesture.
* @param maxDist
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/tap-gesture#maxdistancevalue-number
*/
maxDistance(maxDist) {
this.config.maxDist = maxDist;
return this;
}
/**
* Maximum time, expressed in milliseconds, that defines how fast a finger must be released after a touch.
* The default value is 500.
* @param duration
*/
maxDuration(duration) {
this.config.maxDurationMs = duration;
return this;
}
/**
* Maximum time, expressed in milliseconds, that can pass before the next tap — if many taps are required.
* The default value is 500.
* @param delay
*/
maxDelay(delay) {
this.config.maxDelayMs = delay;
return this;
}
/**
* Maximum distance, expressed in points, that defines how far the finger is allowed to travel along the X axis during a tap gesture.
* @param delta
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/tap-gesture#maxdeltaxvalue-number
*/
maxDeltaX(delta) {
this.config.maxDeltaX = delta;
return this;
}
/**
* Maximum distance, expressed in points, that defines how far the finger is allowed to travel along the Y axis during a tap gesture.
* @param delta
* @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/tap-gesture#maxdeltayvalue-number
*/
maxDeltaY(delta) {
this.config.maxDeltaY = delta;
return this;
}
}
//# sourceMappingURL=tapGesture.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["tapGesture.ts"],"names":["BaseGesture","TapGesture","constructor","handlerName","shouldCancelWhenOutside","minPointers","config","numberOfTaps","count","maxDistance","maxDist","maxDuration","duration","maxDurationMs","maxDelay","delay","maxDelayMs","maxDeltaX","delta","maxDeltaY"],"mappings":";;AAAA,SAA4BA,WAA5B,QAA+C,WAA/C;AAMA,OAAO,MAAMC,UAAN,SAAyBD,WAAzB,CAAoE;AAGzEE,EAAAA,WAAW,GAAG;AACZ;;AADY,oCAFwC,EAExC;;AAGZ,SAAKC,WAAL,GAAmB,mBAAnB;AACA,SAAKC,uBAAL,CAA6B,IAA7B;AACD;AAED;AACF;AACA;AACA;AACA;;;AACEC,EAAAA,WAAW,CAACA,WAAD,EAAsB;AAC/B,SAAKC,MAAL,CAAYD,WAAZ,GAA0BA,WAA1B;AACA,WAAO,IAAP;AACD;AAED;AACF;AACA;AACA;AACA;;;AACEE,EAAAA,YAAY,CAACC,KAAD,EAAgB;AAC1B,SAAKF,MAAL,CAAYC,YAAZ,GAA2BC,KAA3B;AACA,WAAO,IAAP;AACD;AAED;AACF;AACA;AACA;AACA;;;AACEC,EAAAA,WAAW,CAACC,OAAD,EAAkB;AAC3B,SAAKJ,MAAL,CAAYI,OAAZ,GAAsBA,OAAtB;AACA,WAAO,IAAP;AACD;AAED;AACF;AACA;AACA;AACA;;;AACEC,EAAAA,WAAW,CAACC,QAAD,EAAmB;AAC5B,SAAKN,MAAL,CAAYO,aAAZ,GAA4BD,QAA5B;AACA,WAAO,IAAP;AACD;AAED;AACF;AACA;AACA;AACA;;;AACEE,EAAAA,QAAQ,CAACC,KAAD,EAAgB;AACtB,SAAKT,MAAL,CAAYU,UAAZ,GAAyBD,KAAzB;AACA,WAAO,IAAP;AACD;AAED;AACF;AACA;AACA;AACA;;;AACEE,EAAAA,SAAS,CAACC,KAAD,EAAgB;AACvB,SAAKZ,MAAL,CAAYW,SAAZ,GAAwBC,KAAxB;AACA,WAAO,IAAP;AACD;AAED;AACF;AACA;AACA;AACA;;;AACEC,EAAAA,SAAS,CAACD,KAAD,EAAgB;AACvB,SAAKZ,MAAL,CAAYa,SAAZ,GAAwBD,KAAxB;AACA,WAAO,IAAP;AACD;;AA9EwE","sourcesContent":["import { BaseGestureConfig, BaseGesture } from './gesture';\nimport {\n TapGestureConfig,\n TapGestureHandlerEventPayload,\n} from '../TapGestureHandler';\n\nexport class TapGesture extends BaseGesture<TapGestureHandlerEventPayload> {\n public config: BaseGestureConfig & TapGestureConfig = {};\n\n constructor() {\n super();\n\n this.handlerName = 'TapGestureHandler';\n this.shouldCancelWhenOutside(true);\n }\n\n /**\n * Minimum number of pointers (fingers) required to be placed before the gesture activates.\n * Should be a positive integer. The default value is 1.\n * @param minPointers\n */\n minPointers(minPointers: number) {\n this.config.minPointers = minPointers;\n return this;\n }\n\n /**\n * Number of tap gestures required to activate the gesture.\n * The default value is 1.\n * @param count\n */\n numberOfTaps(count: number) {\n this.config.numberOfTaps = count;\n return this;\n }\n\n /**\n * Maximum distance, expressed in points, that defines how far the finger is allowed to travel during a tap gesture.\n * @param maxDist\n * @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/tap-gesture#maxdistancevalue-number\n */\n maxDistance(maxDist: number) {\n this.config.maxDist = maxDist;\n return this;\n }\n\n /**\n * Maximum time, expressed in milliseconds, that defines how fast a finger must be released after a touch.\n * The default value is 500.\n * @param duration\n */\n maxDuration(duration: number) {\n this.config.maxDurationMs = duration;\n return this;\n }\n\n /**\n * Maximum time, expressed in milliseconds, that can pass before the next tap — if many taps are required.\n * The default value is 500.\n * @param delay\n */\n maxDelay(delay: number) {\n this.config.maxDelayMs = delay;\n return this;\n }\n\n /**\n * Maximum distance, expressed in points, that defines how far the finger is allowed to travel along the X axis during a tap gesture.\n * @param delta\n * @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/tap-gesture#maxdeltaxvalue-number\n */\n maxDeltaX(delta: number) {\n this.config.maxDeltaX = delta;\n return this;\n }\n\n /**\n * Maximum distance, expressed in points, that defines how far the finger is allowed to travel along the Y axis during a tap gesture.\n * @param delta\n * @see https://docs.swmansion.com/react-native-gesture-handler/docs/gestures/tap-gesture#maxdeltayvalue-number\n */\n maxDeltaY(delta: number) {\n this.config.maxDeltaY = delta;\n return this;\n }\n}\n\nexport type TapGestureType = InstanceType<typeof TapGesture>;\n"]}

View File

@@ -0,0 +1,44 @@
import { isJestEnv } from '../utils';
export const handlerIDToTag = {};
const gestures = new Map();
const oldHandlers = new Map();
const testIDs = new Map();
let handlerTag = 1;
export function getNextHandlerTag() {
return handlerTag++;
}
export function registerHandler(handlerTag, handler, testID) {
gestures.set(handlerTag, handler);
if (isJestEnv() && testID) {
testIDs.set(testID, handlerTag);
}
}
export function registerOldGestureHandler(handlerTag, handler) {
oldHandlers.set(handlerTag, handler);
}
export function unregisterHandler(handlerTag, testID) {
gestures.delete(handlerTag);
if (isJestEnv() && testID) {
testIDs.delete(testID);
}
}
export function findHandler(handlerTag) {
return gestures.get(handlerTag);
}
export function findOldGestureHandler(handlerTag) {
return oldHandlers.get(handlerTag);
}
export function findHandlerByTestID(testID) {
const handlerTag = testIDs.get(testID);
if (handlerTag !== undefined) {
var _findHandler;
return (_findHandler = findHandler(handlerTag)) !== null && _findHandler !== void 0 ? _findHandler : null;
}
return null;
}
//# sourceMappingURL=handlersRegistry.js.map

View File

@@ -0,0 +1 @@
{"version":3,"sources":["handlersRegistry.ts"],"names":["isJestEnv","handlerIDToTag","gestures","Map","oldHandlers","testIDs","handlerTag","getNextHandlerTag","registerHandler","handler","testID","set","registerOldGestureHandler","unregisterHandler","delete","findHandler","get","findOldGestureHandler","findHandlerByTestID","undefined"],"mappings":"AAAA,SAASA,SAAT,QAA0B,UAA1B;AAIA,OAAO,MAAMC,cAAsC,GAAG,EAA/C;AACP,MAAMC,QAAQ,GAAG,IAAIC,GAAJ,EAAjB;AACA,MAAMC,WAAW,GAAG,IAAID,GAAJ,EAApB;AACA,MAAME,OAAO,GAAG,IAAIF,GAAJ,EAAhB;AAEA,IAAIG,UAAU,GAAG,CAAjB;AAEA,OAAO,SAASC,iBAAT,GAAqC;AAC1C,SAAOD,UAAU,EAAjB;AACD;AAED,OAAO,SAASE,eAAT,CACLF,UADK,EAELG,OAFK,EAGLC,MAHK,EAIL;AACAR,EAAAA,QAAQ,CAACS,GAAT,CAAaL,UAAb,EAAyBG,OAAzB;;AACA,MAAIT,SAAS,MAAMU,MAAnB,EAA2B;AACzBL,IAAAA,OAAO,CAACM,GAAR,CAAYD,MAAZ,EAAoBJ,UAApB;AACD;AACF;AAED,OAAO,SAASM,yBAAT,CACLN,UADK,EAELG,OAFK,EAGL;AACAL,EAAAA,WAAW,CAACO,GAAZ,CAAgBL,UAAhB,EAA4BG,OAA5B;AACD;AAED,OAAO,SAASI,iBAAT,CAA2BP,UAA3B,EAA+CI,MAA/C,EAAgE;AACrER,EAAAA,QAAQ,CAACY,MAAT,CAAgBR,UAAhB;;AACA,MAAIN,SAAS,MAAMU,MAAnB,EAA2B;AACzBL,IAAAA,OAAO,CAACS,MAAR,CAAeJ,MAAf;AACD;AACF;AAED,OAAO,SAASK,WAAT,CAAqBT,UAArB,EAAyC;AAC9C,SAAOJ,QAAQ,CAACc,GAAT,CAAaV,UAAb,CAAP;AACD;AAED,OAAO,SAASW,qBAAT,CAA+BX,UAA/B,EAAmD;AACxD,SAAOF,WAAW,CAACY,GAAZ,CAAgBV,UAAhB,CAAP;AACD;AAED,OAAO,SAASY,mBAAT,CAA6BR,MAA7B,EAA6C;AAClD,QAAMJ,UAAU,GAAGD,OAAO,CAACW,GAAR,CAAYN,MAAZ,CAAnB;;AACA,MAAIJ,UAAU,KAAKa,SAAnB,EAA8B;AAAA;;AAC5B,2BAAOJ,WAAW,CAACT,UAAD,CAAlB,uDAAkC,IAAlC;AACD;;AACD,SAAO,IAAP;AACD","sourcesContent":["import { isJestEnv } from '../utils';\nimport { GestureType } from './gestures/gesture';\nimport { GestureEvent, HandlerStateChangeEvent } from './gestureHandlerCommon';\n\nexport const handlerIDToTag: Record<string, number> = {};\nconst gestures = new Map<number, GestureType>();\nconst oldHandlers = new Map<number, GestureHandlerCallbacks>();\nconst testIDs = new Map<string, number>();\n\nlet handlerTag = 1;\n\nexport function getNextHandlerTag(): number {\n return handlerTag++;\n}\n\nexport function registerHandler(\n handlerTag: number,\n handler: GestureType,\n testID?: string\n) {\n gestures.set(handlerTag, handler);\n if (isJestEnv() && testID) {\n testIDs.set(testID, handlerTag);\n }\n}\n\nexport function registerOldGestureHandler(\n handlerTag: number,\n handler: GestureHandlerCallbacks\n) {\n oldHandlers.set(handlerTag, handler);\n}\n\nexport function unregisterHandler(handlerTag: number, testID?: string) {\n gestures.delete(handlerTag);\n if (isJestEnv() && testID) {\n testIDs.delete(testID);\n }\n}\n\nexport function findHandler(handlerTag: number) {\n return gestures.get(handlerTag);\n}\n\nexport function findOldGestureHandler(handlerTag: number) {\n return oldHandlers.get(handlerTag);\n}\n\nexport function findHandlerByTestID(testID: string) {\n const handlerTag = testIDs.get(testID);\n if (handlerTag !== undefined) {\n return findHandler(handlerTag) ?? null;\n }\n return null;\n}\n\nexport interface GestureHandlerCallbacks {\n onGestureEvent: (event: GestureEvent<any>) => void;\n onGestureStateChange: (event: HandlerStateChangeEvent<any>) => void;\n}\n"]}