diff --git a/.vscode/settings.json b/.vscode/settings.json index d1f8a0db..a7634a71 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,178 +1,25 @@ { - // ========================================== - // FORMATTING & LINTING - // ========================================== - - // Biome as default formatter "editor.defaultFormatter": "biomejs.biome", "editor.formatOnSave": true, - "editor.formatOnPaste": true, - "editor.formatOnType": false, - - // Language-specific formatters - "[javascript]": { - "editor.defaultFormatter": "biomejs.biome", - "editor.formatOnSave": true + "editor.codeActionsOnSave": { + "source.fixAll.biome": "explicit" }, "[typescript]": { - "editor.defaultFormatter": "biomejs.biome", - "editor.formatOnSave": true + "editor.defaultFormatter": "biomejs.biome" }, "[typescriptreact]": { - "editor.defaultFormatter": "biomejs.biome", - "editor.formatOnSave": true + "editor.defaultFormatter": "biomejs.biome" + }, + "[javascript]": { + "editor.defaultFormatter": "biomejs.biome" }, "[javascriptreact]": { - "editor.defaultFormatter": "biomejs.biome", - "editor.formatOnSave": true + "editor.defaultFormatter": "biomejs.biome" }, "[json]": { - "editor.defaultFormatter": "biomejs.biome", - "editor.formatOnSave": true + "editor.defaultFormatter": "biomejs.biome" }, - "[jsonc]": { - "editor.defaultFormatter": "biomejs.biome", - "editor.formatOnSave": true - }, - "[swift]": { - "editor.insertSpaces": true, - "editor.tabSize": 2 - }, - - // ========================================== - // TYPESCRIPT & JAVASCRIPT - // ========================================== - - // TypeScript performance optimizations - "typescript.preferences.includePackageJsonAutoImports": "auto", - "typescript.suggest.autoImports": true, - "typescript.updateImportsOnFileMove.enabled": "always", - "typescript.preferences.preferTypeOnlyAutoImports": true, - "typescript.preferences.importModuleSpecifier": "relative", - "typescript.preferences.includeCompletionsForImportStatements": true, - "typescript.preferences.includeCompletionsWithSnippetText": true, - - // JavaScript settings - "javascript.preferences.importModuleSpecifier": "relative", - "javascript.suggest.autoImports": true, - "javascript.updateImportsOnFileMove.enabled": "always", - - // ========================================== - // REACT NATIVE & EXPO - // ========================================== - - // File associations for React Native - "files.associations": { - "*.expo.ts": "typescript", - "*.expo.tsx": "typescriptreact", - "*.expo.js": "javascript", - "*.expo.jsx": "javascriptreact", - "metro.config.js": "javascript", - "babel.config.js": "javascript", - "app.config.js": "javascript", - "eas.json": "jsonc" - }, - - // React Native specific settings - "emmet.includeLanguages": { - "typescriptreact": "html", - "javascriptreact": "html" - }, - "emmet.triggerExpansionOnTab": true, - - // Exclude build directories from search - "search.exclude": { - "**/node_modules": true - }, - - // ========================================== - // EDITOR PERFORMANCE & UX - // ========================================== - - // Performance optimizations - "editor.largeFileOptimizations": true, - "files.watcherExclude": { - "**/.git/objects/**": true, - "**/.git/subtree-cache/**": true, - "**/node_modules/**": true, - "**/.expo/**": true, - "**/ios/**": true, - "**/android/**": true, - "**/build/**": true, - "**/dist/**": true - }, - - // Better editor behavior - "editor.suggestSelection": "first", - "editor.quickSuggestions": { - "strings": true, - "comments": true, - "other": true - }, - "editor.snippetSuggestions": "top", - "editor.tabCompletion": "on", - "editor.wordBasedSuggestions": "off", - - // ========================================== - // TERMINAL & DEVELOPMENT - // ========================================== - - // Terminal settings for Bun (Windows-specific) - "terminal.integrated.profiles.windows": { - "Command Prompt": { - "path": "C:\\Windows\\System32\\cmd.exe", - "env": { - "PATH": "${env:PATH};./node_modules/.bin" - } - } - }, - - // ========================================== - // WORKSPACE & NAVIGATION - // ========================================== - - // Better workspace navigation - "explorer.fileNesting.enabled": true, - "explorer.fileNesting.expand": false, - "explorer.fileNesting.patterns": { - "*.ts": "${capture}.js", - "*.tsx": "${capture}.js", - "*.js": "${capture}.js,${capture}.js.map,${capture}.min.js,${capture}.d.ts", - "*.jsx": "${capture}.js", - "package.json": "package-lock.json,yarn.lock,bun.lock,bun.lockb,.yarnrc,.yarnrc.yml", - "tsconfig.json": "tsconfig.*.json", - ".env": ".env.*", - "app.json": "app.config.js,eas.json,expo-env.d.ts", - "README.md": "LICENSE.txt,SECURITY.md,CODE_OF_CONDUCT.md,CONTRIBUTING.md" - }, - - // Better breadcrumbs and navigation - "breadcrumbs.enabled": true, - "outline.showVariables": true, - "outline.showConstants": true, - - // ========================================== - // GIT & VERSION CONTROL - // ========================================== - - // Git integration - "git.autofetch": true, - "git.enableSmartCommit": true, - "git.confirmSync": false, - "git.ignoreLimitWarning": true, - - // ========================================== - // CODE QUALITY & ERRORS - // ========================================== - - // Better error detection - "typescript.validate.enable": true, - "javascript.validate.enable": true, - "editor.codeActionsOnSave": { - "source.fixAll": "explicit", - "source.organizeImports": "explicit" - }, - - // Problem matcher for better error display - "typescript.tsc.autoDetect": "on" + "typescript.tsdk": "node_modules/typescript/lib", + "typescript.enablePromptUseWorkspaceTsdk": true, + "editor.formatOnSaveMode": "file" } diff --git a/hooks/useOrientation.ts b/hooks/useOrientation.ts index 62270c4f..3483aefb 100644 --- a/hooks/useOrientation.ts +++ b/hooks/useOrientation.ts @@ -1,12 +1,19 @@ +import type { OrientationChangeEvent } from "expo-screen-orientation"; import { useEffect, useState } from "react"; import { Platform } from "react-native"; -import * as ScreenOrientation from "@/packages/expo-screen-orientation"; -import { OrientationLock } from "@/packages/expo-screen-orientation"; +import { + addOrientationChangeListener, + getOrientationAsync, + lockAsync, + Orientation as OrientationEnum, + OrientationLock, + unlockAsync, +} from "@/packages/expo-screen-orientation"; import { Orientation } from "../packages/expo-screen-orientation.tv"; const orientationToOrientationLock = ( - orientation: Orientation, -): OrientationLock => { + orientation: (typeof OrientationEnum)[keyof typeof OrientationEnum], +): (typeof OrientationLock)[keyof typeof OrientationLock] => { switch (orientation) { case Orientation.LANDSCAPE_LEFT: return OrientationLock.LANDSCAPE_LEFT; @@ -21,44 +28,52 @@ const orientationToOrientationLock = ( export const useOrientation = () => { const [orientation, setOrientation] = useState( - Platform.isTV - ? ScreenOrientation.OrientationLock.LANDSCAPE - : ScreenOrientation.OrientationLock.UNKNOWN, + Platform.isTV ? OrientationLock.LANDSCAPE : OrientationLock.UNKNOWN, ); useEffect(() => { if (Platform.isTV) return; - const orientationSubscription = - ScreenOrientation.addOrientationChangeListener((event) => { + const orientationSubscription = addOrientationChangeListener( + (event: OrientationChangeEvent) => { setOrientation( orientationToOrientationLock(event.orientationInfo.orientation), ); - }); + }, + ); - ScreenOrientation.getOrientationAsync().then((orientation) => { - setOrientation(orientationToOrientationLock(orientation)); - }); + getOrientationAsync().then( + (orientation: (typeof OrientationEnum)[keyof typeof OrientationEnum]) => { + setOrientation(orientationToOrientationLock(orientation)); + }, + ); return () => { orientationSubscription.remove(); }; }, []); - const lockOrientation = async (lock: OrientationLock) => { + const lockOrientation = async ( + lock: (typeof OrientationLock)[keyof typeof OrientationLock], + ) => { if (Platform.isTV) return; - if (lock === ScreenOrientation.OrientationLock.DEFAULT) { - await ScreenOrientation.unlockAsync(); + if (lock === OrientationLock.DEFAULT) { + await unlockAsync(); } else { - await ScreenOrientation.lockAsync(lock); + await lockAsync(lock); } }; - const unlockOrientation = async () => { + const unlockOrientationFn = async () => { if (Platform.isTV) return; - await ScreenOrientation.unlockAsync(); + await unlockAsync(); }; - return { orientation, setOrientation, lockOrientation, unlockOrientation }; + return { + orientation, + setOrientation, + lockOrientation, + unlockOrientation: unlockOrientationFn, + }; }; diff --git a/packages/expo-screen-orientation.ts b/packages/expo-screen-orientation.ts index bb409b1e..19c472c7 100644 --- a/packages/expo-screen-orientation.ts +++ b/packages/expo-screen-orientation.ts @@ -1,24 +1,26 @@ 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, -}; +enum DummyOrientationLock { + DEFAULT = 0, + ALL = 1, + PORTRAIT = 2, + PORTRAIT_UP = 3, + PORTRAIT_DOWN = 4, + LANDSCAPE = 5, + LANDSCAPE_LEFT = 6, + LANDSCAPE_RIGHT = 7, + OTHER = 8, + UNKNOWN = 9, +} -const DummyOrientation = { - UNKNOWN: 0, - PORTRAIT_UP: 1, - PORTRAIT_DOWN: 2, - LANDSCAPE_LEFT: 3, - LANDSCAPE_RIGHT: 4, -}; +enum DummyOrientation { + UNKNOWN = 0, + PORTRAIT_UP = 1, + PORTRAIT_DOWN = 2, + LANDSCAPE_LEFT = 3, + LANDSCAPE_RIGHT = 4, +} const dummyLockAsync = async () => {}; const dummyUnlockAsync = async () => {}; @@ -38,6 +40,10 @@ export const OrientationLock = Platform.isTV export const Orientation = Platform.isTV ? DummyOrientation : ScreenOrientation?.Orientation; + +// Export types +export type OrientationLockType = typeof OrientationLock; +export type OrientationType = typeof Orientation; export const lockAsync = Platform.isTV ? dummyLockAsync : ScreenOrientation?.lockAsync; diff --git a/utils/atoms/settings.ts b/utils/atoms/settings.ts index ac49a19f..ee0e8625 100644 --- a/utils/atoms/settings.ts +++ b/utils/atoms/settings.ts @@ -26,7 +26,7 @@ export type DownloadOption = { }; export const ScreenOrientationEnum: Record< - ScreenOrientation.OrientationLock, + (typeof ScreenOrientation.OrientationLock)[keyof typeof ScreenOrientation.OrientationLock], string > = { [ScreenOrientation.OrientationLock.DEFAULT]: @@ -154,7 +154,7 @@ export type Settings = { subtitleMode: SubtitlePlaybackMode; rememberSubtitleSelections: boolean; showHomeTitles: boolean; - defaultVideoOrientation: ScreenOrientation.OrientationLock; + defaultVideoOrientation: (typeof ScreenOrientation.OrientationLock)[keyof typeof ScreenOrientation.OrientationLock]; forwardSkipTime: number; rewindSkipTime: number; showCustomMenuLinks: boolean;