Files
discord-decomp/sources/by-id/module-01766-useAnimatedSensor.js
T
2026-07-28 01:06:53 +03:00

223 lines
14 KiB
JavaScript

/* Metro module 1766; source: unknown; dependencies: [31, 1635, 1654, 1617] */
import * as ReactModule from './module-00031-React.js'; /* Metro dependency 31 */
import * as Module01617Module from './module-01617.js'; /* Metro dependency 1617 */
import * as Module01635Module from './module-01635.js'; /* Metro dependency 1635 */
import * as Module01654Module from './module-01654.js'; /* Metro dependency 1654 */
function _fun19481(global, require, importDefault, importAll, module, exports, dependencyMap) { // fn#19481, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1893:6, offset: 0x00eab662, size: 207 bytes, params: 8, frame: 18
const env0_0 = require;
const Object = global.Object;
Object.defineProperty(exports, '__esModule', {value: true});
object = {code: 'function eulerToQuaternion_Pnpm_useAnimatedSensorTs1(pitch,roll,yaw){const c1=Math.cos(pitch/2);const s1=Math.sin(pitch/2);const c2=Math.cos(roll/2);const s2=Math.sin(roll/2);const c3=Math.cos(yaw/2);const s3=Math.sin(yaw/2);return[s1*c2*c3-c1*s2*s3,c1*s2*c3+s1*c2*s3,c1*c2*s3+s1*s2*c3,c1*c2*c3-s1*s2*s3];}'};
const env0_6 = _fun19482();
object = {code: 'function adjustRotationToInterfaceOrientation_Pnpm_useAnimatedSensorTs2(data){const{InterfaceOrientation,eulerToQuaternion}=this.__closure;const{interfaceOrientation:interfaceOrientation,pitch:pitch,roll:roll,yaw:yaw}=data;if(interfaceOrientation===InterfaceOrientation.ROTATION_90){data.pitch=roll;data.roll=-pitch;data.yaw=yaw-Math.PI/2;}else if(interfaceOrientation===InterfaceOrientation.ROTATION_270){data.pitch=-roll;data.roll=pitch;data.yaw=yaw+Math.PI/2;}else if(interfaceOrientation===InterfaceOrientation.ROTATION_180){data.pitch*=-1;data.roll*=-1;data.yaw*=-1;}const q=eulerToQuaternion(data.pitch,data.roll,data.yaw);data.qx=q[0];data.qy=q[1];data.qz=q[2];data.qw=q[3];return data;}'};
const env0_8 = _fun19484();
object = {code: 'function adjustVectorToInterfaceOrientation_Pnpm_useAnimatedSensorTs3(data){const{InterfaceOrientation}=this.__closure;const{interfaceOrientation:interfaceOrientation,x:x,y:y}=data;if(interfaceOrientation===InterfaceOrientation.ROTATION_90){data.x=-y;data.y=x;}else if(interfaceOrientation===InterfaceOrientation.ROTATION_270){data.x=y;data.y=-x;}else if(interfaceOrientation===InterfaceOrientation.ROTATION_180){data.x*=-1;data.y*=-1;}return data;}'};
const env0_10 = _fun19486();
object = {code: 'function pnpm_useAnimatedSensorTs4(data){const{adjustToInterfaceOrientation,sensorType,SensorType,adjustRotationToInterfaceOrientation,adjustVectorToInterfaceOrientation,sensorData,callMicrotasks}=this.__closure;if(adjustToInterfaceOrientation){if(sensorType===SensorType.ROTATION){data=adjustRotationToInterfaceOrientation(data);}else{data=adjustVectorToInterfaceOrientation(data);}}sensorData.value=data;callMicrotasks();}'};
exports.useAnimatedSensor = useAnimatedSensor;
function _fun19482() { // fn#19482, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1893:463, offset: 0x00eab731, size: 46 bytes, params: 1, frame: 2
const eulerToQuaternion2 = eulerToQuaternion;
eulerToQuaternion2.__closure = {};
eulerToQuaternion2.__workletHash = 14525486759705;
eulerToQuaternion2.__initData = env0_5;
return eulerToQuaternion2;
}
function _fun19484() { // fn#19484, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1893:1451, offset: 0x00eab851, size: 90 bytes, params: 1, frame: 14
const adjustRotationToInterfaceOrientation2 = adjustRotationToInterfaceOrientation;
const InterfaceOrientation = (Module01635Module).InterfaceOrientation;
adjustRotationToInterfaceOrientation2.__closure = {InterfaceOrientation: InterfaceOrientation,
eulerToQuaternion: env0_6};
adjustRotationToInterfaceOrientation2.__workletHash = 16635654688360;
adjustRotationToInterfaceOrientation2.__initData = env0_7;
return adjustRotationToInterfaceOrientation2;
function adjustRotationToInterfaceOrientation(a0) { // fn#19485, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1893:1468, offset: 0x00eab8ab, size: 369 bytes, params: 2, frame: 20
const interfaceOrientation = a0.interfaceOrientation;
const pitch = a0.pitch;
const roll = a0.roll;
const yaw = a0.yaw;
let value = environment.__proto__;
const InterfaceOrientation = (Module01635Module).InterfaceOrientation;
const ROTATION_90 = InterfaceOrientation.ROTATION_90;
if (interfaceOrientation === ROTATION_90) {
a0.pitch = roll;
a0.roll = -pitch;
a0.yaw = yaw - global.Math.PI / 2;
} else if (interfaceOrientation === InterfaceOrientation.ROTATION_270) {
a0.pitch = -roll;
a0.roll = pitch;
a0.yaw = yaw + global.Math.PI / 2;
} else if (interfaceOrientation === InterfaceOrientation.ROTATION_180) {
a0.pitch = a0.pitch * -1;
a0.roll = a0.roll * -1;
a0.yaw = a0.yaw * -1;
}
value = env1_6(a0.pitch, a0.roll, a0.yaw);
a0.qx = value[0];
a0.qy = value[1];
a0.qz = value[2];
a0.qw = value[3];
return a0;
}
}
function _fun19486() { // fn#19486, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1893:2510, offset: 0x00eaba1c, size: 79 bytes, params: 1, frame: 14
const adjustVectorToInterfaceOrientation2 = adjustVectorToInterfaceOrientation;
const InterfaceOrientation = (Module01635Module).InterfaceOrientation;
adjustVectorToInterfaceOrientation2.__closure = {InterfaceOrientation: InterfaceOrientation};
adjustVectorToInterfaceOrientation2.__workletHash = 5352466445526;
adjustVectorToInterfaceOrientation2.__initData = env0_9;
return adjustVectorToInterfaceOrientation2;
function adjustVectorToInterfaceOrientation(a0) { // fn#19487, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1893:2527, offset: 0x00eaba6b, size: 201 bytes, params: 2, frame: 17
const interfaceOrientation = a0.interfaceOrientation;
const x = a0.x;
const y = a0.y;
const InterfaceOrientation = (Module01635Module).InterfaceOrientation;
const ROTATION_90 = InterfaceOrientation.ROTATION_90;
if (interfaceOrientation === ROTATION_90) {
a0.x = -y;
a0.y = x;
} else if (interfaceOrientation === InterfaceOrientation.ROTATION_270) {
a0.x = y;
a0.y = -x;
} else if (interfaceOrientation === InterfaceOrientation.ROTATION_180) {
a0.x = a0.x * -1;
a0.y = a0.y * -1;
}
return a0;
}
}
function useAnimatedSensor(a0, a1) { // fn#19488, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1893:3388, offset: 0x00eabb34, size: 325 bytes, params: 3, frame: 20
const env0_0 = a0;
const value2 = undefined;
const value3 = useRef(a1);
const current = value3.current;
let r3 = (current == null ? value2 : current.adjustToInterfaceOrientation) !== (a1 == null ? value2 : a1.adjustToInterfaceOrientation) || (value3.current == null ? value2 : value3.current.interval) !== (a1 == null ? value2 : a1.interval);
r3 = !r3 ? (value3.current == null ? value2 : value3.current.iosReferenceFrame) !== (a1 == null ? value2 : a1.iosReferenceFrame) : r3;
if (r3) {
value3.current = global.Object.assign({}, a1);
}
const value7 = useMemo(_fun19489, [value3.current]);
object = {};
object.sensor = (require(1654) /* metro dependency 1654 */).initializeSensor(a0, value7);
object.unregister = function() {
};
object.isAvailable = false;
object.config = value7;
const value8 = useRef(object);
useEffect(_fun19491, [a0, value7]);
return value8.current;
function _fun19489() { // fn#19489, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1893:3751, offset: 0x00eabc79, size: 89 bytes, params: 1, frame: 15
const Object = global.Object;
const assign = Object.assign;
const IOSReferenceFrame = (Module01635Module).IOSReferenceFrame;
const Auto = IOSReferenceFrame.Auto;
return Reflect.apply(assign, Object, [{'interval': 'auto', 'adjustToInterfaceOrientation': true,
iosReferenceFrame: Auto}, env0_1.current]);
}
function _fun19491() { // fn#19491, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1893:4021, offset: 0x00eabcd2, size: 382 bytes, params: 1, frame: 25
let binding = ReactModule.useMemo;
const initializeSensor = Module01654Module.initializeSensor;
const binding2 = env0_0;
binding.current = {sensor: Reflect.apply(initializeSensor, Module01654Module, [binding2, ReactModule.useEffect]),
unregister: function() {
}, isAvailable: false, config: ReactModule.useEffect};
let current = ReactModule.useMemo.current;
const sensor = current.sensor;
const adjustToInterfaceOrientation = ReactModule.useMemo.current.config.adjustToInterfaceOrientation;
const registerSensor = Module01654Module.registerSensor;
binding = ReactModule.useEffect;
const pnpm_useAnimatedSensorTs42 = pnpm_useAnimatedSensorTs4;
object = {adjustToInterfaceOrientation: adjustToInterfaceOrientation, sensorType: binding2};
const SensorType = (Module01635Module).SensorType;
object.SensorType = SensorType;
object.adjustRotationToInterfaceOrientation = env1_8;
object.adjustVectorToInterfaceOrientation = env1_10;
object.sensorData = sensor;
object.callMicrotasks = (require(1617) /* metro dependency 1617 */).callMicrotasks;
pnpm_useAnimatedSensorTs42.__closure = object;
pnpm_useAnimatedSensorTs42.__workletHash = 6807952122364;
pnpm_useAnimatedSensorTs42.__initData = env1_11;
if (Reflect.apply(registerSensor, Module01654Module, [binding2, binding, pnpm_useAnimatedSensorTs42]) !== -1) {
current = ReactModule.useMemo.current;
current.unregister = unregister_19494;
current = ReactModule.useMemo.current;
current.isAvailable = true;
} else {
current = ReactModule.useMemo.current;
current.unregister = function() {
};
current = ReactModule.useMemo.current;
current.isAvailable = false;
}
return _fun19496;
function pnpm_useAnimatedSensorTs4(a0) { // fn#19493, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1893:4246, offset: 0x00eabe50, size: 134 bytes, params: 2, frame: 16
var r2;
var r1;
var value3;
var binding;
var value4;
let value = a0;
if (adjustToInterfaceOrientation) {
value3 = environment.__proto__;
binding = env1_0;
value4 = environment.__proto__.__proto__;
if (binding === (require(1635) /* metro dependency 1635 */).SensorType.ROTATION) {
value = env2_8(value);
r2 = value;
} else {
value = env2_10(value);
r2 = value;
}
r1 = r2;
} else {
r1 = value;
}
sensor.value = r1;
value = environment.__proto__.__proto__;
(Module01617Module).callMicrotasks();
}
function unregister_19494() { // fn#19494, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1893:4667, offset: 0x00eabed6, size: 45 bytes, params: 1, frame: 11
const value = environment.__proto__.__proto__;
return (Module01654Module).unregisterSensor(ReactModule.useEffect);
}
function _fun19496() { // fn#19496, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1893:4801, offset: 0x00eabf03, size: 26 bytes, params: 1, frame: 9
env1_3.current.unregister();
}
}
}
}
function eulerToQuaternion(a0, a1, a2) { // fn#19483, source: /ci/build/discord/discord/discord_android_rn/android/app/src/main/assets/index.android.bundle:1893:480, offset: 0x00eab75f, size: 242 bytes, params: 4, frame: 18
let Math = global.Math;
let value = Math.cos(a0 / 2);
Math = global.Math;
const value2 = Math.sin(a0 / 2);
Math = global.Math;
const value3 = Math.cos(a1 / 2);
Math = global.Math;
const value4 = Math.sin(a1 / 2);
Math = global.Math;
const value5 = Math.cos(a2 / 2);
Math = global.Math;
const value6 = Math.sin(a2 / 2);
const items2 = [value2 * value3 * value5 - value * value4 * value6];
items2[1] = value * value4 * value5 + value2 * value3 * value6;
items2[2] = value * value3 * value6 + value2 * value4 * value5;
value = value * value3 * value5;
items2[3] = value - value2 * value4 * value6;
return items2;
}
global.__d(_fun19481, 1766, [31, 1635, 1654, 1617]) /* metro module 1766, dependencies: [31, 1635, 1654, 1617] */;