Files
discord-decomp/sources/modules/media_viewer/native/useMediaViewerPanGesture.tsx
T
2026-07-27 16:20:00 +03:00

189 lines
11 KiB
TypeScript

/* Metro module 9939; source: modules/media_viewer/native/useMediaViewerPanGesture.tsx; dependencies: [31, 4017, 9551, 9547, 4577, 8994, 5321, 2] */
function _fun77785(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#77785, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:10125:6, offset: 0x01e0bbfd, size: 232 bytes, params: 8, frame: 18
const env0_0 = require;
const Object = global.Object;
Object.defineProperty(exports, '__esModule', {value: true});
const env0_3 = importAll(31) /* metro dependency 31 */;
const env0_4 = {'damping': 15, 'mass': 1, 'stiffness': 250, 'overshootClamping': true, 'restSpeedThreshold': 0.001,
'restDisplacementThreshold': 0.001};
object = {code: 'function useMediaViewerPanGestureTsx1(){const{runOnJS,handleClose}=this.__closure;runOnJS(handleClose)();}'};
object = {code: 'function useMediaViewerPanGestureTsx2(){const{isInteracting,velocity,swipeVelocityThreshold,runOnJS,dismiss,translatePos,withSpring,SPRING_CONFIG}=this.__closure;isInteracting.set(false);const willClose=Math.abs(velocity.get())>swipeVelocityThreshold;if(willClose){runOnJS(dismiss)();}else if(translatePos.get()!==0){translatePos.set(withSpring(0,{velocity:velocity.get(),...SPRING_CONFIG}));}}'};
object = {code: 'function useMediaViewerPanGestureTsx3(_,manager){const{enabled}=this.__closure;if(!enabled.get()){manager.fail();}}'};
object = {code: 'function useMediaViewerPanGestureTsx4({velocityY:velocityY,translationY:translationY}){const{translatePos,start,velocity}=this.__closure;translatePos.set(translationY+start.get().y);velocity.set(velocityY);}'};
object = {code: 'function useMediaViewerPanGestureTsx5(){const{start,translatePos,isInteracting}=this.__closure;start.set({x:0,y:translatePos.get()});isInteracting.set(true);}'};
(require(2) /* metro dependency 2 */).fileFinishedImporting('modules/media_viewer/native/useMediaViewerPanGesture.tsx');
exports.useMediaViewerPanGestureConfig = useMediaViewerPanGestureConfig;
exports.useMediaViewerPanGesture = useMediaViewerPanGesture;
}
function useMediaViewerPanGestureConfig(a0, a1, a2) { // fn#77786, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:10125:1385, offset: 0x01e0bce5, size: 339 bytes, params: 4, frame: 25
const env0_0 = a0;
const env0_1 = a1;
const env0_2 = a2;
const value2 = (require(4017) /* metro dependency 4017: ReanimatedRexport */).useSharedValue(false);
const env0_3 = value2;
const value3 = (require(4017) /* metro dependency 4017: ReanimatedRexport */).useSharedValue(false);
const value4 = (require(4017) /* metro dependency 4017: ReanimatedRexport */).useSharedValue(0);
const value5 = (require(4017) /* metro dependency 4017: ReanimatedRexport */).useSharedValue(0);
const value6 = (require(4017) /* metro dependency 4017: ReanimatedRexport */).useSharedValue({'y': 0, 'x': 0});
const value7 = (require(4017) /* metro dependency 4017: ReanimatedRexport */).useSharedValue(true);
const binding = env0_3;
let value = binding.useCallback(function() {
require(dependencyMap[2]).tryPauseCurrentVideo();
if (importDefault != null) {
importDefault();
}
var MediaViewerAnalytics = require(dependencyMap[3]).MediaViewerAnalytics;
MediaViewerAnalytics.markSessionCompleted();
}, [a2]);
value = binding.useCallback(_fun77788, [a0, value, value2, value4, value5]);
return binding.useMemo(_fun77790, [value5, value2, value3, value4, a1, value, value6, value7]);
}
function useMediaViewerPanGesture({swipeVelocityThreshold, velocity, isInteracting, translatePos, start, dismiss}, a1) { // fn#77791, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:10125:2213, offset: 0x01e0bff3, size: 187 bytes, params: 3, frame: 21
const env0_3 = translatePos;
const env0_5 = a1;
const value2 = (importDefault(8994) /* metro dependency 8994: useStableCallback */)(dismiss);
const binding = env0_3;
return binding.useMemo(_fun77797, [binding.useCallback(_fun77792, [value2, a1, isInteracting, start,
swipeVelocityThreshold, translatePos, velocity])]);
}
function _fun77788() { // fn#77788, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:10125:1757, offset: 0x01e0be96, size: 223 bytes, params: 1, frame: 25
let binding = env0_3;
let set = binding.set;
Reflect.apply(set, binding, [true]);
const r8 = env0_6.get() < 0 ? -env0_0 : env0_0;
binding = env0_5;
set = binding.set;
const springModule = require(4577) /* metro dependency 4577: spring */;
const withSpring = springModule.withSpring;
const object3 = {};
object3.velocity = env0_6.get();
copyDataProperties(object3, env1_4, undefined);
const closure = t_77789;
const object4 = {};
object4.runOnJS = (require(4017) /* metro dependency 4017: ReanimatedRexport */).runOnJS;
object4.handleClose = env0_9;
closure.__closure = object4;
closure.__workletHash = 7033730772994;
closure.__initData = env1_5;
Reflect.apply(set, binding, [Reflect.apply(withSpring, springModule, [r8, object3, 'respect-motion-settings',
closure])]);
}
function _fun77790() { // fn#77790, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:10125:2043, offset: 0x01e0bfa5, size: 78 bytes, params: 1, frame: 3
return {velocity: env0_6, isClosing: env0_3, isInteracting: env0_4, overlayEnabled: env0_8, translatePos: env0_5,
swipeVelocityThreshold: require, dismiss: env0_10, start: env0_7};
}
function _fun77792() { // fn#77792, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:10125:2371, offset: 0x01e0c0ae, size: 458 bytes, params: 1, frame: 23
var object2;
const Gesture = (require(5321) /* metro dependency 5321 */).Gesture;
const value5 = Gesture.Pan().maxPointers(1).activeOffsetY([-10, 10]).failOffsetX([-10, 10]);
const onStart = value5.onStart;
let closure = function() {
var startBinding = start;
var object = {x: 0};
object.y = translatePos.get();
startBinding.set(object);
isInteracting.set(true);
};
let startBinding = start;
const translatePosBinding = translatePos;
const isInteractingBinding = isInteracting;
closure.__closure = {start: startBinding, translatePos: translatePosBinding, isInteracting: isInteractingBinding};
closure.__workletHash = 12024094550213;
closure.__initData = env1_9;
const value7 = Reflect.apply(onStart, value5, [closure]);
const onUpdate = value7.onUpdate;
closure = function({velocityY, translationY}) {
translatePos.set(translationY + start.get().y);
velocity.set(velocityY);
};
const velocityBinding = velocity;
closure.__closure = {translatePos: translatePosBinding, start: startBinding, velocity: velocityBinding};
closure.__workletHash = 9790035695747;
closure.__initData = env1_8;
const value8 = Reflect.apply(onUpdate, value7, [closure]);
const onTouchesDown = value8.onTouchesDown;
closure = function(a0, a1) {
if (!require.get()) {
a1.fail();
}
};
closure.__closure = {enabled: require};
closure.__workletHash = 10675684732258;
closure.__initData = env1_7;
const value9 = Reflect.apply(onTouchesDown, value8, [closure]);
const onEnd = value9.onEnd;
closure = t_77796;
object2 = {isInteracting: isInteractingBinding, velocity: velocityBinding};
object2.swipeVelocityThreshold = swipeVelocityThreshold;
object2.runOnJS = (require(4017) /* metro dependency 4017: ReanimatedRexport */).runOnJS;
object2.dismiss = env0_6;
object2.translatePos = translatePosBinding;
object2.withSpring = (require(4577) /* metro dependency 4577: spring */).withSpring;
object2.SPRING_CONFIG = env1_4;
closure.__closure = object2;
closure.__workletHash = 3185523772752;
closure.__initData = env1_6;
return Reflect.apply(onEnd, value9, [closure]);
}
function _fun77797() { // fn#77797, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:10125:3321, offset: 0x01e0c3f5, size: 76 bytes, params: 1, frame: 12
var environment;
let value = environment.__proto__;
const Gesture = (require(5321) /* metro dependency 5321 */).Gesture;
value = Gesture.Native();
const env0_1 = [];
return {panGestureGenerator: panGestureGenerator, nativeGesture: value};
}
function t_77789() { // fn#77789, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:10125:1876, offset: 0x01e0bf75, size: 48 bytes, params: 1, frame: 12
let value = environment.__proto__.__proto__;
value = require(4017) /* metro dependency 4017: ReanimatedRexport */;
value.runOnJS(env1_9)();
}
function t_77796() { // fn#77796, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:10125:2934, offset: 0x01e0c322, size: 211 bytes, params: 1, frame: 19
var translatePosBinding;
var value4;
var moduleValue;
var withSpring;
var object2;
var value5;
var moduleValue2;
isInteracting.set(false);
const Math = global.Math;
const abs = Math.abs;
const get = velocity.get;
if (Reflect.apply(abs, Math, [Reflect.apply(get, velocityBinding, [])]) > swipeVelocityThreshold) {
value5 = environment.__proto__.__proto__;
moduleValue2 = require(4017) /* metro dependency 4017: ReanimatedRexport */;
moduleValue2.runOnJS(env1_6)();
} else if (translatePos.get() !== 0) {
translatePosBinding = translatePos;
set = translatePosBinding.set;
value4 = environment.__proto__.__proto__;
moduleValue = require(4577) /* metro dependency 4577: spring */;
withSpring = moduleValue.withSpring;
object2 = {};
velocityBinding = velocity;
object2.velocity = velocityBinding.get();
copyDataProperties(object2, env2_4, velocityBinding);
Reflect.apply(set, translatePosBinding, [Reflect.apply(withSpring, moduleValue, [0, object2])]);
}
}
function panGestureGenerator(a0) { // fn#77798, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:10125:3389, offset: 0x01e0c441, size: 72 bytes, params: 2, frame: 14
if (env0_1[a0] != null) {
return env0_1[a0];
}
const value3 = env1_7();
const binding = env0_1;
binding[a0] = value3.blocksExternalGesture(env0_0);
return binding[a0];
}