Files
discord-decomp/_bundle/isActiveSignal.js
T
2026-11-01 12:12:55 +02:00

601 lines
19 KiB
JavaScript

// Metro module 292 (f293).
import _classCallCheck from "./_classCallCheck";
import _createClass from "./_createClass";
import { shouldPressibilityUseW3CPointerEventsForHover } from "./Module27";
import PressabilityPerformanceEventEmitter from "./PressabilityPerformanceEventEmitter";
import Module38 from "./Module38";
import Module294 from "./Module294";
import Module68 from "./Module68";
import { normalizeRect } from "./Module297";
let isActivationSignal, isPressInSignal, c303_9, c303_10, c303_11, c303_12, getTouchFromPressEvent;
let Pressability;
let env303 = {};
const c303_5 = Object.freeze({
NOT_RESPONDER: {
DELAY: "ERROR",
RESPONDER_GRANT: "RESPONDER_INACTIVE_PRESS_IN",
RESPONDER_RELEASE: "ERROR",
RESPONDER_TERMINATED: "ERROR",
ENTER_PRESS_RECT: "ERROR",
LEAVE_PRESS_RECT: "ERROR",
LONG_PRESS_DETECTED: "ERROR"
},
RESPONDER_INACTIVE_PRESS_IN: {
DELAY: "RESPONDER_ACTIVE_PRESS_IN",
RESPONDER_GRANT: "ERROR",
RESPONDER_RELEASE: "NOT_RESPONDER",
RESPONDER_TERMINATED: "NOT_RESPONDER",
ENTER_PRESS_RECT: "RESPONDER_INACTIVE_PRESS_IN",
LEAVE_PRESS_RECT: "RESPONDER_INACTIVE_PRESS_OUT",
LONG_PRESS_DETECTED: "ERROR"
},
RESPONDER_INACTIVE_PRESS_OUT: {
DELAY: "RESPONDER_ACTIVE_PRESS_OUT",
RESPONDER_GRANT: "ERROR",
RESPONDER_RELEASE: "NOT_RESPONDER",
RESPONDER_TERMINATED: "NOT_RESPONDER",
ENTER_PRESS_RECT: "RESPONDER_INACTIVE_PRESS_IN",
LEAVE_PRESS_RECT: "RESPONDER_INACTIVE_PRESS_OUT",
LONG_PRESS_DETECTED: "ERROR"
},
RESPONDER_ACTIVE_PRESS_IN: {
DELAY: "ERROR",
RESPONDER_GRANT: "ERROR",
RESPONDER_RELEASE: "NOT_RESPONDER",
RESPONDER_TERMINATED: "NOT_RESPONDER",
ENTER_PRESS_RECT: "RESPONDER_ACTIVE_PRESS_IN",
LEAVE_PRESS_RECT: "RESPONDER_ACTIVE_PRESS_OUT",
LONG_PRESS_DETECTED: "RESPONDER_ACTIVE_LONG_PRESS_IN"
},
RESPONDER_ACTIVE_PRESS_OUT: {
DELAY: "ERROR",
RESPONDER_GRANT: "ERROR",
RESPONDER_RELEASE: "NOT_RESPONDER",
RESPONDER_TERMINATED: "NOT_RESPONDER",
ENTER_PRESS_RECT: "RESPONDER_ACTIVE_PRESS_IN",
LEAVE_PRESS_RECT: "RESPONDER_ACTIVE_PRESS_OUT",
LONG_PRESS_DETECTED: "ERROR"
},
RESPONDER_ACTIVE_LONG_PRESS_IN: {
DELAY: "ERROR",
RESPONDER_GRANT: "ERROR",
RESPONDER_RELEASE: "NOT_RESPONDER",
RESPONDER_TERMINATED: "NOT_RESPONDER",
ENTER_PRESS_RECT: "RESPONDER_ACTIVE_LONG_PRESS_IN",
LEAVE_PRESS_RECT: "RESPONDER_ACTIVE_LONG_PRESS_OUT",
LONG_PRESS_DETECTED: "RESPONDER_ACTIVE_LONG_PRESS_IN"
},
RESPONDER_ACTIVE_LONG_PRESS_OUT: {
DELAY: "ERROR",
RESPONDER_GRANT: "ERROR",
RESPONDER_RELEASE: "NOT_RESPONDER",
RESPONDER_TERMINATED: "NOT_RESPONDER",
ENTER_PRESS_RECT: "RESPONDER_ACTIVE_LONG_PRESS_IN",
LEAVE_PRESS_RECT: "RESPONDER_ACTIVE_LONG_PRESS_OUT",
LONG_PRESS_DETECTED: "ERROR"
},
ERROR: {
DELAY: "NOT_RESPONDER",
RESPONDER_GRANT: "RESPONDER_INACTIVE_PRESS_IN",
RESPONDER_RELEASE: "NOT_RESPONDER",
RESPONDER_TERMINATED: "NOT_RESPONDER",
ENTER_PRESS_RECT: "NOT_RESPONDER",
LEAVE_PRESS_RECT: "NOT_RESPONDER",
LONG_PRESS_DETECTED: "NOT_RESPONDER"
}
});
const isActiveSignal = (a0) => {};
isActivationSignal = (a0) => {};
isPressInSignal = (a0) => {};
c303_9 = 30;
c303_10 = 20;
c303_11 = 20;
c303_12 = 20;
env303[13] = 10;
Pressability = function Pressability(a0) {
_classCallCheck(this, Pressability);
this._eventHandlers = null;
this._hoverInDelayTimeout = null;
this._hoverOutDelayTimeout = null;
this._isHovered = false;
this._longPressDelayTimeout = null;
this._pressDelayTimeout = null;
this._pressOutDelayTimeout = null;
this._responderID = null;
this._responderRegion = null;
this._touchState = "NOT_RESPONDER";
this._measureCallback = (a0, a1, a2, a3, a4, a5) => {
if ((a0 ? a0 : a1) || a2 || a3 || a4 || a5) {
this._responderRegion = {
bottom: a5 + a3,
left: a4,
right: a4 + a2,
top: a5
};
}
};
this.configure(a0);
};
const r73 = _createClass(Pressability, [{
key: "configure",
value: function configure(a0) {
this._config = a0;
}
}, {
key: "reset",
value: function reset() {
this._cancelHoverInDelayTimeout();
this._cancelHoverOutDelayTimeout();
this._cancelLongPressDelayTimeout();
this._cancelPressDelayTimeout();
this._cancelPressOutDelayTimeout();
this._config = Object.freeze({});
}
}, {
key: "getEventHandlers",
value: function getEventHandlers() {
if (this._eventHandlers == null) {
this._eventHandlers = this._createEventHandlers();
}
return this._eventHandlers;
}
}, {
key: "_createEventHandlers",
value: function _createEventHandlers() {
let onHoverOut, onHoverIn;
const r4 = {
onBlur: (a0) => {
const onBlur2 = this._config.onBlur;
if (onBlur2 != null) {
onBlur2(a0);
}
},
onFocus: (a0) => {
const onFocus2 = this._config.onFocus;
if (onFocus2 != null) {
onFocus2(a0);
}
}
};
const r10 = {
onStartShouldSetResponder: () => !this._config.disabled,
onResponderGrant: (a0) => {
a0.persist();
this._cancelPressOutDelayTimeout();
this._responderID = a0.currentTarget;
this._touchState = "NOT_RESPONDER";
this._receiveSignal("RESPONDER_GRANT", a0);
let delayPressIn = this._config.delayPressIn;
const r7 = Math;
if (delayPressIn == null) {
delayPressIn = 0;
}
const r21 = r7.max(0, delayPressIn);
if (r21 > 0) {
this._pressDelayTimeout = setTimeout(() => {
this._receiveSignal("DELAY", a0);
}, r21);
} else {
this._receiveSignal("DELAY", a0);
}
let delayLongPress = this._config.delayLongPress;
const r31 = 500 - r21;
const r32 = Math;
if (delayLongPress == null) {
delayLongPress = r31;
}
this._longPressDelayTimeout = setTimeout(() => {
this._handleLongPress(a0);
}, r32.max(10, delayLongPress) + r21);
return this._config.blockNativeResponder === true;
},
onResponderMove: (a0) => {
const onPressMove = this._config.onPressMove;
if (onPressMove != null) {
onPressMove(a0);
}
const _responderRegion = this._responderRegion;
if (_responderRegion != null) {
const nativeEvent = a0.nativeEvent;
const { changedTouches, touches } = nativeEvent;
const r23 = touches != null && touches.length > 0 ? touches[0] : changedTouches != null && changedTouches.length > 0 ? changedTouches[0] : a0.nativeEvent;
if (r23 == null) {
this._cancelLongPressDelayTimeout();
this._receiveSignal("LEAVE_PRESS_RECT", a0);
return void 0;
}
if (this._touchActivatePosition != null && Math.hypot(this._touchActivatePosition.pageX - r23.pageX, this._touchActivatePosition.pageY - r23.pageY) > env303[13]) {
this._cancelLongPressDelayTimeout();
}
if (this._isTouchWithinResponderRegion(r23, _responderRegion)) {
this._receiveSignal("ENTER_PRESS_RECT", a0);
} else {
this._cancelLongPressDelayTimeout();
this._receiveSignal("LEAVE_PRESS_RECT", a0);
}
}
},
onResponderRelease: (a0) => {
this._receiveSignal("RESPONDER_RELEASE", a0);
},
onResponderTerminate: (a0) => {
this._receiveSignal("RESPONDER_TERMINATED", a0);
},
onResponderTerminationRequest: () => {
let cancelable = this._config.cancelable;
if (cancelable == null) {
cancelable = true;
}
return cancelable;
},
onClick: (a0) => {
const r1 = a0 == null;
let r3 = void 0;
if (!r1) {
const nativeEvent = a0.nativeEvent;
const r8 = nativeEvent == null;
r3 = void 0;
if (!r8) {
const hasOwnProperty = nativeEvent.hasOwnProperty;
r3 = hasOwnProperty == null ? void 0 : hasOwnProperty.call(nativeEvent, "pointerType");
}
}
if (!r3) {
if (a0?.currentTarget === a0?.target) {
const _config = this._config;
const { onPress, disabled } = _config;
if (onPress != null && disabled !== true) {
onPress(a0);
}
} else if (a0 != null) {
a0.stopPropagation();
}
}
}
};
if (shouldPressibilityUseW3CPointerEventsForHover()) {
const r28 = {
onPointerEnter: void 0,
onPointerLeave: void 0
};
const _config = this._config;
onHoverIn = _config.onHoverIn;
onHoverOut = _config.onHoverOut;
if (onHoverIn != null) {
r28.onPointerEnter = (a0) => {
this._isHovered = true;
this._cancelHoverOutDelayTimeout();
if (onHoverIn != null) {
let delayHoverIn = this._config.delayHoverIn;
const r6 = Math;
if (delayHoverIn == null) {
delayHoverIn = 0;
}
const r19 = r6.max(0, delayHoverIn);
if (r19 > 0) {
a0.persist();
this._hoverInDelayTimeout = setTimeout(() => {
const nativeEvent = a0.nativeEvent;
const { clientX, clientY } = nativeEvent;
onHoverIn({
...a0,
nativeEvent: {
clientX,
clientY,
pageX: clientX,
pageY: clientY,
timestamp: a0.timeStamp
}
});
}, r19);
} else {
const nativeEvent = a0.nativeEvent;
const { clientX, clientY } = nativeEvent;
onHoverIn({
...a0,
nativeEvent: {
clientX,
clientY,
pageX: clientX,
pageY: clientY,
timestamp: a0.timeStamp
}
});
}
}
};
}
if (onHoverOut != null) {
r28.onPointerLeave = (a0) => {
if (this._isHovered) {
this._isHovered = false;
this._cancelHoverInDelayTimeout();
if (onHoverOut != null) {
let delayHoverOut = this._config.delayHoverOut;
const r6 = Math;
if (delayHoverOut == null) {
delayHoverOut = 0;
}
const r20 = r6.max(0, delayHoverOut);
if (r20 > 0) {
a0.persist();
this._hoverOutDelayTimeout = setTimeout(() => {
const nativeEvent = a0.nativeEvent;
const { clientX, clientY } = nativeEvent;
onHoverOut({
...a0,
nativeEvent: {
clientX,
clientY,
pageX: clientX,
pageY: clientY,
timestamp: a0.timeStamp
}
});
}, r20);
} else {
const nativeEvent = a0.nativeEvent;
const { clientX, clientY } = nativeEvent;
onHoverOut({
...a0,
nativeEvent: {
clientX,
clientY,
pageX: clientX,
pageY: clientY,
timestamp: a0.timeStamp
}
});
}
}
}
};
}
return {
...r4,
...r10,
...r28
};
}
return {
...r4,
...r10
};
}
}, {
key: "_receiveSignal",
value: function _receiveSignal(a0, a1) {
const signal = a0;
if (a1.nativeEvent.timestamp != null) {
PressabilityPerformanceEventEmitter.emitEvent(() => ({
signal,
nativeTimestamp: a1.nativeEvent.timestamp
}));
}
const _touchState = this._touchState;
const r10 = c303_5[_touchState];
const _touchState2 = r10 == null ? void 0 : r10[a0];
if (!(this._responderID == null && a0 === "RESPONDER_RELEASE")) {
Module38(_touchState2 != null && _touchState2 !== "ERROR", "Pressability: Invalid signal `%s` for state `%s` on responder: %s", a0, _touchState, typeof this._responderID === "number" ? this._responderID : "<<host component>>");
if (_touchState !== _touchState2) {
this._performTransitionSideEffects(_touchState, _touchState2, a0, a1);
this._touchState = _touchState2;
}
}
}
}, {
key: "_performTransitionSideEffects",
value: function _performTransitionSideEffects(a0, a1, a2, a3) {
if (a2 === "RESPONDER_TERMINATED" || a2 === "RESPONDER_RELEASE") {
this._touchActivatePosition = null;
this._cancelLongPressDelayTimeout();
}
let r22 = a0 === "NOT_RESPONDER" && a1 === "RESPONDER_INACTIVE_PRESS_IN";
const r1 = a0 === "RESPONDER_ACTIVE_PRESS_OUT" || a0 === "RESPONDER_ACTIVE_PRESS_IN";
const r2 = r1 ? !r1 : a1 === "RESPONDER_ACTIVE_PRESS_OUT" || a1 === "RESPONDER_ACTIVE_PRESS_IN";
if (!r22) {
r22 = r2;
}
if (r22) {
this._measureResponderRegion();
}
let r36 = a0 === "RESPONDER_INACTIVE_PRESS_IN";
if (((r36 ? r36 : a0 === "RESPONDER_ACTIVE_PRESS_IN") || a0 === "RESPONDER_ACTIVE_LONG_PRESS_IN") && a2 === "LONG_PRESS_DETECTED") {
const onLongPress = this._config.onLongPress;
if (onLongPress != null) {
onLongPress(a3);
}
}
const r4 = a0 === "RESPONDER_ACTIVE_PRESS_IN";
const r50 = r4 ? r4 : a0 === "RESPONDER_ACTIVE_LONG_PRESS_IN";
let r53 = a1 === "RESPONDER_ACTIVE_PRESS_IN" || a1 === "RESPONDER_ACTIVE_LONG_PRESS_IN";
if (!r50 && r53) {
this._activate(a3);
} else if (r50 ? !r53 : r50) {
this._deactivate(a3);
}
if (!r36) {
r36 = r4;
}
if (!r36) {
r36 = a0 === "RESPONDER_ACTIVE_LONG_PRESS_IN";
}
if (r36 && a2 === "RESPONDER_RELEASE") {
if (!r53) {
r53 = r50;
}
if (!r53) {
this._activate(a3);
this._deactivate(a3);
}
const _config = this._config;
const { onLongPress: onLongPress2, onPress, android_disableSound } = _config;
if (onPress != null && !(onLongPress2 != null && a0 === "RESPONDER_ACTIVE_LONG_PRESS_IN")) {
if (android_disableSound !== true) {
Module294.playTouchSound();
}
onPress(a3);
}
}
this._cancelPressDelayTimeout();
}
}, {
key: "_activate",
value: function _activate(a0) {
const onPressIn = this._config.onPressIn;
const nativeEvent = a0.nativeEvent;
const { changedTouches, touches } = nativeEvent;
const r16 = touches != null && touches.length > 0 ? touches[0] : changedTouches != null && changedTouches.length > 0 ? changedTouches[0] : a0.nativeEvent;
this._touchActivatePosition = {
pageX: r16.pageX,
pageY: r16.pageY
};
this._touchActivateTime = Date.now();
if (onPressIn != null) {
onPressIn(a0);
}
}
}, {
key: "_deactivate",
value: function _deactivate(a0) {
const onPressOut = this._config.onPressOut;
if (onPressOut != null) {
let minPressDuration = this._config.minPressDuration;
const r9 = Math;
if (minPressDuration == null) {
minPressDuration = 130;
}
const r16 = r9.max(0, minPressDuration);
const r19 = Date.now();
let _touchActivateTime = this._touchActivateTime;
if (_touchActivateTime == null) {
_touchActivateTime = 0;
}
const r21 = r19 - _touchActivateTime;
const r11 = Math;
const r23 = r16 - r21;
let delayPressOut = this._config.delayPressOut;
const r12 = Math;
if (delayPressOut == null) {
delayPressOut = 0;
}
const r27 = r11.max(r23, r12.max(0, delayPressOut));
if (r27 > 0) {
a0.persist();
this._pressOutDelayTimeout = setTimeout(() => {
onPressOut(a0);
}, r27);
} else {
onPressOut(a0);
}
}
this._touchActivateTime = null;
}
}, {
key: "_measureResponderRegion",
value: function _measureResponderRegion() {
if (this._responderID != null) {
if (typeof this._responderID === "number") {
Module68.measure(this._responderID, this._measureCallback);
} else {
this._responderID.measureAsyncOnUI(this._measureCallback);
}
}
}
}, {
key: "_isTouchWithinResponderRegion",
value: function _isTouchWithinResponderRegion(a0, a1) {
const r13 = normalizeRect(this._config.hitSlop);
const r23 = normalizeRect(this._config.pressRectOffset);
const { bottom, left, right, top } = a1;
let r24 = top;
let r25 = right;
let r26 = left;
let r27 = bottom;
if (r13 != null) {
const r29 = r13.bottom != null ? bottom + r13.bottom : bottom;
const r32 = r13.left != null ? left - r13.left : left;
const r35 = r13.right != null ? right + r13.right : right;
r24 = r13.top != null ? top - r13.top : top;
r25 = r35;
r26 = r32;
r27 = r29;
}
let r40 = r23?.bottom;
if (r40 == null) {
r40 = c303_9;
}
const r41 = r27 + r40;
let r43 = r23?.left;
if (r43 == null) {
r43 = c303_10;
}
const r44 = r26 - r43;
let r46 = r23?.right;
if (r46 == null) {
r46 = c303_11;
}
const r47 = r25 + r46;
let r49 = r23?.top;
if (r49 == null) {
r49 = c303_12;
}
const r51 = r24 - r49;
return a0.pageX > r44 && a0.pageX < r47 && a0.pageY > r51 && a0.pageY < r41;
}
}, {
key: "_handleLongPress",
value: function _handleLongPress(a0) {
if (!(this._touchState !== "RESPONDER_ACTIVE_PRESS_IN" && this._touchState !== "RESPONDER_ACTIVE_LONG_PRESS_IN")) {
this._receiveSignal("LONG_PRESS_DETECTED", a0);
}
}
}, {
key: "_cancelHoverInDelayTimeout",
value: function _cancelHoverInDelayTimeout() {
if (this._hoverInDelayTimeout != null) {
clearTimeout(this._hoverInDelayTimeout);
this._hoverInDelayTimeout = null;
}
}
}, {
key: "_cancelHoverOutDelayTimeout",
value: function _cancelHoverOutDelayTimeout() {
if (this._hoverOutDelayTimeout != null) {
clearTimeout(this._hoverOutDelayTimeout);
this._hoverOutDelayTimeout = null;
}
}
}, {
key: "_cancelLongPressDelayTimeout",
value: function _cancelLongPressDelayTimeout() {
if (this._longPressDelayTimeout != null) {
clearTimeout(this._longPressDelayTimeout);
this._longPressDelayTimeout = null;
}
}
}, {
key: "_cancelPressDelayTimeout",
value: function _cancelPressDelayTimeout() {
if (this._pressDelayTimeout != null) {
clearTimeout(this._pressDelayTimeout);
this._pressDelayTimeout = null;
}
}
}, {
key: "_cancelPressOutDelayTimeout",
value: function _cancelPressOutDelayTimeout() {
if (this._pressOutDelayTimeout != null) {
clearTimeout(this._pressOutDelayTimeout);
this._pressOutDelayTimeout = null;
}
}
}], [{
key: "setLongPressDeactivationDistance",
value: function setLongPressDeactivationDistance(a0) {
env303[13] = a0;
}
}]);
getTouchFromPressEvent = (a0) => {};
export default r73;