fix: apple tv runtime crash
Some checks failed
🏗️ Build Apps / 🤖 Build Android APK (Phone) (push) Has been cancelled
🏗️ Build Apps / 🤖 Build Android APK (TV) (push) Has been cancelled
🏗️ Build Apps / 🍎 Build iOS IPA (Phone) (push) Has been cancelled
🔒 Lockfile Consistency Check / 🔍 Check bun.lock and package.json consistency (push) Has been cancelled
🛡️ CodeQL Analysis / 🔎 Analyze with CodeQL (actions) (push) Has been cancelled
🛡️ CodeQL Analysis / 🔎 Analyze with CodeQL (javascript-typescript) (push) Has been cancelled
🏷️🔀Merge Conflict Labeler / 🏷️ Labeling Merge Conflicts (push) Has been cancelled
🚦 Security & Quality Gate / 📝 Validate PR Title (push) Has been cancelled
🚦 Security & Quality Gate / 🔍 Vulnerable Dependencies (push) Has been cancelled
🚦 Security & Quality Gate / 🚑 Expo Doctor Check (push) Has been cancelled
🚦 Security & Quality Gate / 🔍 Lint & Test (check) (push) Has been cancelled
🚦 Security & Quality Gate / 🔍 Lint & Test (format) (push) Has been cancelled
🚦 Security & Quality Gate / 🔍 Lint & Test (lint) (push) Has been cancelled
🚦 Security & Quality Gate / 🔍 Lint & Test (typecheck) (push) Has been cancelled
🕒 Handle Stale Issues / 🗑️ Cleanup Stale Issues (push) Has been cancelled

This commit is contained in:
Fredrik Burmester
2025-11-15 18:23:25 +01:00
parent e1c69a9ec9
commit 36178c2082
2 changed files with 71 additions and 1 deletions

View File

@@ -1 +1,70 @@
export * from "expo-screen-orientation";
import { Platform } from "react-native";
// Dummy exports for TV
const DummyOrientationLock = {
DEFAULT: 0,
ALL: 1,
PORTRAIT: 2,
PORTRAIT_UP: 3,
PORTRAIT_DOWN: 4,
LANDSCAPE: 5,
LANDSCAPE_LEFT: 6,
LANDSCAPE_RIGHT: 7,
};
const DummyOrientation = {
UNKNOWN: 0,
PORTRAIT_UP: 1,
PORTRAIT_DOWN: 2,
LANDSCAPE_LEFT: 3,
LANDSCAPE_RIGHT: 4,
};
const dummyLockAsync = async () => {};
const dummyUnlockAsync = async () => {};
const dummyGetOrientationAsync = async () => DummyOrientation.UNKNOWN;
const dummyGetOrientationLockAsync = async () => DummyOrientationLock.DEFAULT;
const dummySupportsOrientationLockAsync = async () => false;
// Conditionally export based on platform
let ScreenOrientation: any;
if (!Platform.isTV) {
ScreenOrientation = require("expo-screen-orientation");
}
export const OrientationLock = Platform.isTV
? DummyOrientationLock
: ScreenOrientation?.OrientationLock;
export const Orientation = Platform.isTV
? DummyOrientation
: ScreenOrientation?.Orientation;
export const lockAsync = Platform.isTV
? dummyLockAsync
: ScreenOrientation?.lockAsync;
export const unlockAsync = Platform.isTV
? dummyUnlockAsync
: ScreenOrientation?.unlockAsync;
export const getOrientationAsync = Platform.isTV
? dummyGetOrientationAsync
: ScreenOrientation?.getOrientationAsync;
export const getOrientationLockAsync = Platform.isTV
? dummyGetOrientationLockAsync
: ScreenOrientation?.getOrientationLockAsync;
export const supportsOrientationLockAsync = Platform.isTV
? dummySupportsOrientationLockAsync
: ScreenOrientation?.supportsOrientationLockAsync;
export const lockPlatformAsync = Platform.isTV
? dummyLockAsync
: ScreenOrientation?.lockPlatformAsync;
export const getPlatformLockAsync = Platform.isTV
? dummyGetOrientationLockAsync
: ScreenOrientation?.getPlatformLockAsync;
export const addOrientationChangeListener = Platform.isTV
? () => ({ remove: () => {} })
: ScreenOrientation?.addOrientationChangeListener;
export const removeOrientationChangeListener = Platform.isTV
? () => {}
: ScreenOrientation?.removeOrientationChangeListener;
export const removeOrientationChangeListeners = Platform.isTV
? () => {}
: ScreenOrientation?.removeOrientationChangeListeners;

View File

@@ -32,6 +32,7 @@ module.exports = {
"expo-haptics": disableForTV("expo-haptics"),
"expo-brightness": disableForTV("expo-brightness"),
"expo-sensors": disableForTV("expo-sensors"),
"expo-screen-orientation": disableForTV("expo-screen-orientation"),
"react-native-ios-context-menu": disableForTV(
"react-native-ios-context-menu",
),