decord/alpha/source/modules/device/native/DeviceOrientation.tsx

320 lines
10 KiB
TypeScript
Raw Normal View History

2026-10-09 10:00:15 +00:00
// Module ID: 8434
// Function ID: 8435
// Name: DeviceOrientation
2026-10-09 10:00:15 +00:00
// Dependencies: [19, 17, 570, 1382, 1272, 5067, 8435, 558, 576, 2]
2026-10-03 08:58:59 +00:00
// Exports: getOrientation, getOrientationLock, handleOrientationChange, lockOrientation, restoreDefaultOrientation, unlockOrientation, useOrientation
2026-07-20 16:05:17 +00:00
2026-10-09 10:00:15 +00:00
// Module 8434 (DeviceOrientation)
2026-10-03 08:58:59 +00:00
import react_native from "react-native" /* 17 */;
2026-10-09 10:00:15 +00:00
import react_native2 from "react-native" /* 1272 */;
import PlatformUtils from "PlatformUtils" /* 1382 */;
import DeviceUtils from "DeviceUtils" /* 5067 */;
2026-10-03 08:58:59 +00:00
import react from "react" /* 19 */;
import module_570 from "module_570" /* 570 */;
2026-10-09 10:00:15 +00:00
import react_native3_mod from "react-native" /* 8435 */;
2026-10-03 08:58:59 +00:00
import ReactCompilerGating_mod from "ReactCompilerGating" /* 558 */;
import size from "module_2" /* 2 */;
2026-07-23 10:11:24 +00:00
2026-10-03 08:58:59 +00:00
const require = globalThis.__r;
let _require;
2026-10-09 10:00:15 +00:00
const f98090 = () => {
2026-10-03 08:58:59 +00:00
state.setState({ orientationLock: null });
};
2026-07-20 16:05:17 +00:00
function handleOrientationChange(initialOrientation) {
2026-10-03 08:58:59 +00:00
let obj = PlatformUtils;
2026-07-20 16:05:17 +00:00
if (obj.isIOS()) {
handleDeviceOrientationChange(initialOrientation);
}
2026-10-03 08:58:59 +00:00
if (c7 !== initialOrientation) {
c7 = initialOrientation;
const orientationLock = obj2.getState().orientationLock;
const hasItem = null != orientationLock && closure_5.includes(orientationLock);
const tmp7 = c7;
if ("LANDSCAPE" === c7) {
2026-07-20 16:05:17 +00:00
if (!hasItem) {
2026-10-03 08:58:59 +00:00
const tmpResult = react_native2;
tmpResult.batchUpdates(() => {
const obj = { orientation: constants.LANDSCAPE };
return obj2.setState(obj);
});
2026-07-20 16:05:17 +00:00
}
}
2026-10-03 08:58:59 +00:00
let tmp9 = "PORTRAIT" === tmp7;
2026-07-29 08:29:29 +00:00
if (!tmp9) {
2026-10-03 08:58:59 +00:00
const tmpResult3 = DeviceUtils;
tmp9 = tmpResult3.isIpadOS() && "PORTRAITUPSIDEDOWN" === c7;
const isIpadOSResult = tmpResult3.isIpadOS() && "PORTRAITUPSIDEDOWN" === c7;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
if (tmp9) {
tmp9 = "LANDSCAPE" !== orientationLock;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
if (tmp9) {
2026-10-03 08:58:59 +00:00
const tmpResult4 = react_native2;
tmpResult4.batchUpdates(() => {
const obj = { orientation: constants.PORTRAIT };
return obj2.setState(obj);
});
2026-07-20 16:05:17 +00:00
}
}
}
function handleDeviceOrientationChange(LANDSCAPE) {
2026-10-03 08:58:59 +00:00
const orientationLock = obj2.getState().orientationLock;
const tmp = c8;
if (tmp) {
2026-07-20 16:05:17 +00:00
if ("LANDSCAPE" === LANDSCAPE) {
if ("LANDSCAPE" === orientationLock) {
2026-07-29 08:29:29 +00:00
const orientationLock3 = obj.getState().orientationLock;
2026-10-03 08:58:59 +00:00
const obj13 = PlatformUtils;
2026-07-29 08:29:29 +00:00
if (!obj13.isAndroid()) {
2026-10-03 08:58:59 +00:00
const tmp15Result = PlatformUtils;
if (tmp15Result.isIOS()) {
const tmp15Result3 = DeviceUtils;
tmp15Result3.getSystemVersionMajor() >= 16;
2026-07-29 08:29:29 +00:00
}
}
2026-10-03 08:58:59 +00:00
const obj9 = react_native;
obj9.ignoreAutoRotate(false);
const obj10 = react_native;
const result = obj10.unlockAllOrientations();
const tmp15Result4 = react_native2;
2026-10-09 10:00:15 +00:00
tmp15Result4.batchUpdates(f98090);
2026-07-29 08:29:29 +00:00
c8 = false;
2026-07-20 16:05:17 +00:00
}
} else if ("PORTRAIT" === LANDSCAPE) {
if ("PORTRAIT" === orientationLock) {
2026-07-29 08:29:29 +00:00
const orientationLock2 = obj.getState().orientationLock;
2026-10-03 08:58:59 +00:00
const obj12 = PlatformUtils;
2026-07-29 08:29:29 +00:00
if (!obj12.isAndroid()) {
2026-10-03 08:58:59 +00:00
const tmp13Result = PlatformUtils;
if (tmp13Result.isIOS()) {
const tmp13Result3 = DeviceUtils;
tmp13Result3.getSystemVersionMajor() >= 16;
2026-07-29 08:29:29 +00:00
}
}
2026-10-03 08:58:59 +00:00
const obj4 = react_native;
obj4.ignoreAutoRotate(false);
const obj5 = react_native;
const result1 = obj5.unlockAllOrientations();
const tmp13Result4 = react_native2;
2026-10-09 10:00:15 +00:00
tmp13Result4.batchUpdates(f98090);
2026-07-29 08:29:29 +00:00
c8 = false;
2026-07-20 16:05:17 +00:00
}
}
}
}
function lockOrientationForiOS(PORTRAIT) {
2026-10-03 08:58:59 +00:00
const obj = PlatformUtils;
let isAndroidResult = obj.isAndroid();
2026-07-20 16:05:17 +00:00
if (!isAndroidResult) {
2026-10-03 08:58:59 +00:00
const tmpResult = DeviceUtils;
isAndroidResult = tmpResult.isIpadOS() && null == PORTRAIT;
const isIpadOSResult = tmpResult.isIpadOS() && null == PORTRAIT;
2026-07-20 16:05:17 +00:00
}
if (!isAndroidResult) {
2026-10-03 08:58:59 +00:00
const obj3 = react_native;
obj3.ignoreAutoRotate(false);
2026-08-24 06:08:38 +00:00
c8 = false;
2026-07-29 08:29:29 +00:00
if ("LANDSCAPE" === PORTRAIT) {
2026-10-03 08:58:59 +00:00
const tmp6Result = react_native;
tmp6Result.lockToLandscapeLeft();
const tmpResult3 = react_native2;
tmpResult3.batchUpdates(() => {
obj2.setState({ orientationLock: "LANDSCAPE" });
2026-07-29 08:29:29 +00:00
});
} else {
2026-10-03 08:58:59 +00:00
const tmp6Result2 = react_native;
tmp6Result2.lockToPortrait();
const tmpResult4 = react_native2;
tmpResult4.batchUpdates(() => {
obj2.setState({ orientationLock: "PORTRAIT" });
2026-07-29 08:29:29 +00:00
});
}
2026-07-20 16:05:17 +00:00
}
}
2026-10-03 08:58:59 +00:00
const AppState = react_native.AppState;
const OrientationType = { PORTRAIT: 0, [0]: "PORTRAIT", LANDSCAPE: 1, [1]: "LANDSCAPE" };
2026-07-23 10:11:24 +00:00
let closure_5 = ["PORTRAIT", "PORTRAITUPSIDEDOWN"];
2026-10-03 08:58:59 +00:00
let obj2 = module_570.create(() => {
let obj;
2026-07-23 10:11:24 +00:00
obj = { orientation: obj.PORTRAIT, orientationLock: null };
2026-07-20 16:05:17 +00:00
return obj;
});
2026-10-03 08:58:59 +00:00
let c7 = null;
2026-07-23 10:11:24 +00:00
let c8 = false;
2026-10-03 08:58:59 +00:00
let react_native3 = react_native3_mod;
let result = react_native3.addOrientationDegreesChangeListener(function handleOrientationDegreesChange(arg0) {
2026-07-20 16:05:17 +00:00
let str = "PORTRAIT";
2026-10-03 08:58:59 +00:00
const tmp = arg0 >= 0 && arg0 <= 5 || arg0 >= 355;
2026-07-20 16:05:17 +00:00
if (tmp !== true) {
str = "LANDSCAPE-RIGHT";
2026-10-03 08:58:59 +00:00
const tmp2 = arg0 >= 85 && arg0 <= 95;
2026-07-20 16:05:17 +00:00
if (tmp2 !== true) {
str = "PORTRAITUPSIDEDOWN";
2026-10-03 08:58:59 +00:00
const tmp3 = arg0 >= 175 && arg0 <= 185;
2026-07-20 16:05:17 +00:00
if (tmp3 !== true) {
str = "LANDSCAPE-LEFT";
2026-10-03 08:58:59 +00:00
const tmp4 = arg0 >= 265 && arg0 <= 275;
2026-07-20 16:05:17 +00:00
if (tmp4 !== true) {
str = "UNKNOWN";
}
}
}
}
if ("LANDSCAPE-LEFT" !== str) {
if ("LANDSCAPE-RIGHT" !== str) {
if ("PORTRAIT" === str) {
handleDeviceOrientationChange("PORTRAIT");
}
}
}
handleDeviceOrientationChange("LANDSCAPE");
});
2026-10-03 08:58:59 +00:00
react_native3 = react_native3_mod;
let result1 = react_native3.addOrientationListener(handleOrientationChange);
react_native3 = react_native3_mod;
const result2 = handleOrientationChange(react_native3.getInitialOrientation());
const listener = AppState.addEventListener("change", function applyLockStateOnAppActive(event) {
2026-10-03 08:58:59 +00:00
const orientationLock = obj2.getState().orientationLock;
const tmp = "active" === event && null != orientationLock;
2026-07-20 16:05:17 +00:00
if (tmp) {
2026-10-03 08:58:59 +00:00
const obj = react_native;
obj.ignoreAutoRotate(true);
2026-08-24 06:08:38 +00:00
c8 = false;
2026-07-29 08:29:29 +00:00
if ("LANDSCAPE" === orientationLock) {
2026-10-03 08:58:59 +00:00
const tmp3Result = react_native;
tmp3Result.lockToLandscapeLeft();
const obj5 = react_native2;
obj5.batchUpdates(() => {
obj2.setState({ orientationLock: "LANDSCAPE" });
2026-07-29 08:29:29 +00:00
});
} else {
2026-10-03 08:58:59 +00:00
const tmp3Result2 = react_native;
tmp3Result2.lockToPortrait();
const obj3 = react_native2;
obj3.batchUpdates(() => {
2026-10-03 08:58:59 +00:00
obj2.setState({ orientationLock: "PORTRAIT" });
2026-07-29 08:29:29 +00:00
});
}
2026-07-20 16:05:17 +00:00
}
});
2026-10-03 08:58:59 +00:00
let ReactCompilerGating = ReactCompilerGating_mod;
ReactCompilerGating.isReactCompilerEnabled();
ReactCompilerGating = ReactCompilerGating_mod;
function unlockOrientation(unlockAfterRotatingToPreviousLock) {
unlockAfterRotatingToPreviousLock = unlockAfterRotatingToPreviousLock.unlockAfterRotatingToPreviousLock;
const orientationLock = obj2.getState().orientationLock;
const obj = PlatformUtils;
2026-07-29 08:29:29 +00:00
if (obj.isAndroid()) {
2026-10-03 08:58:59 +00:00
if (unlockAfterRotatingToPreviousLock) {
if (null != orientationLock) {
2026-08-24 06:08:38 +00:00
c8 = true;
2026-07-29 08:29:29 +00:00
}
}
} else {
2026-10-03 08:58:59 +00:00
const tmpResult = PlatformUtils;
2026-07-29 08:29:29 +00:00
if (tmpResult.isIOS()) {
2026-10-03 08:58:59 +00:00
DeviceUtils;
2026-07-29 08:29:29 +00:00
}
}
2026-10-03 08:58:59 +00:00
const obj4 = react_native;
obj4.ignoreAutoRotate(false);
const obj5 = react_native;
const result = obj5.unlockAllOrientations();
const tmpResult4 = react_native2;
2026-10-09 10:00:15 +00:00
tmpResult4.batchUpdates(f98090);
2026-10-03 08:58:59 +00:00
}
function lockOrientation(PORTRAIT, flag) {
const ignoreAutoRotate = react_native.ignoreAutoRotate;
react_native;
2026-07-29 08:29:29 +00:00
if (flag == null) {
flag = false;
}
2026-10-03 08:58:59 +00:00
ignoreAutoRotate(flag);
2026-08-24 06:08:38 +00:00
c8 = false;
2026-07-29 08:29:29 +00:00
if ("LANDSCAPE" === PORTRAIT) {
2026-10-03 08:58:59 +00:00
const tmpResult = react_native;
tmpResult.lockToLandscapeLeft();
const obj4 = react_native2;
obj4.batchUpdates(() => {
obj2.setState({ orientationLock: "LANDSCAPE" });
2026-07-29 08:29:29 +00:00
});
} else {
2026-10-03 08:58:59 +00:00
const tmpResult2 = react_native;
tmpResult2.lockToPortrait();
obj2 = react_native2;
obj2.batchUpdates(() => {
obj2.setState({ orientationLock: "PORTRAIT" });
2026-07-29 08:29:29 +00:00
});
}
2026-10-03 08:58:59 +00:00
}
2026-10-08 09:57:35 +00:00
function useOrientation() {
return obj2().orientation;
}
const tmp8 = ReactCompilerGating.isReactCompilerEnabled() ? (function useOrientationListener(arg0) {
2026-10-03 08:58:59 +00:00
let closure_0;
let tmp2;
let tmp3;
_require = arg0;
const obj = require("react");
const cResult = obj.c(3);
if (cResult[0] !== arg0) {
const fn = function o() {
return obj2.subscribe(closure_0);
};
const items = [arg0];
cResult[0] = arg0;
cResult[1] = fn;
cResult[2] = items;
tmp3 = items;
tmp2 = fn;
} else {
tmp2 = cResult[1];
tmp3 = cResult[2];
}
const effect = react.useEffect(tmp2, tmp3);
2026-10-08 09:57:35 +00:00
}) : (function useOrientationListener(arg0) {
2026-10-03 08:58:59 +00:00
let closure_0 = arg0;
const items = [arg0];
const effect = react.useEffect(() => obj2.subscribe(closure_0), items);
});
const result4 = size.fileFinishedImporting("modules/device/native/DeviceOrientation.tsx");
export { OrientationType };
export const useStore = obj2;
export { handleOrientationChange };
export { unlockOrientation };
export { lockOrientation };
2026-07-20 16:05:17 +00:00
export { lockOrientationForiOS };
export const getOrientation = function getOrientation() {
2026-10-03 08:58:59 +00:00
return obj2.getState().orientation;
2026-07-20 16:05:17 +00:00
};
export const getOrientationLock = function getOrientationLock() {
2026-10-03 08:58:59 +00:00
return obj2.getState().orientationLock;
2026-07-20 16:05:17 +00:00
};
2026-10-08 09:57:35 +00:00
export { useOrientation };
2026-10-03 08:58:59 +00:00
export const useOrientationListener = tmp8;
2026-07-20 16:05:17 +00:00
export const restoreDefaultOrientation = function restoreDefaultOrientation() {
2026-10-03 08:58:59 +00:00
let state;
const obj = PlatformUtils;
2026-07-20 16:05:17 +00:00
if (obj.isIOS()) {
2026-10-03 08:58:59 +00:00
DeviceUtils;
2026-07-29 08:29:29 +00:00
}
2026-10-03 08:58:59 +00:00
const orientationLock = obj2.getState().orientationLock;
const tmpResult5 = PlatformUtils;
if (!tmpResult5.isAndroid()) {
2026-10-03 08:58:59 +00:00
const tmpResult6 = PlatformUtils;
if (tmpResult6.isIOS()) {
2026-10-03 08:58:59 +00:00
const tmpResult7 = DeviceUtils;
tmpResult7.getSystemVersionMajor() >= 16;
2026-07-29 08:29:29 +00:00
}
2026-07-20 16:05:17 +00:00
}
2026-10-03 08:58:59 +00:00
const obj6 = react_native;
obj6.ignoreAutoRotate(false);
const obj7 = react_native;
const result = obj7.unlockAllOrientations();
const tmpResult8 = react_native2;
2026-10-09 10:00:15 +00:00
tmpResult8.batchUpdates(f98090);
2026-07-20 16:05:17 +00:00
lockOrientationForiOS();
};