Simplify import paths

This commit is contained in:
redphx 2024-05-01 22:01:39 +07:00
parent 006e21f477
commit 0114108bdf
29 changed files with 167 additions and 163 deletions

View File

@ -1,32 +1,32 @@
import "./utils/global";
import { BxEvent } from "./utils/bx-event";
import { BX_FLAGS } from "./utils/bx-flags";
import { BxExposed } from "./utils/bx-exposed";
import { t } from "./utils/translation";
import { interceptHttpRequests } from "./utils/network";
import { CE } from "./utils/html";
import { showGamepadToast } from "./utils/gamepad";
import { MkbHandler } from "./modules/mkb/mkb-handler";
import { StreamBadges } from "./modules/stream/stream-badges";
import { StreamStats } from "./modules/stream/stream-stats";
import { addCss } from "./utils/css";
import { Toast } from "./utils/toast";
import { setupBxUi, updateVideoPlayerCss } from "./modules/ui/ui";
import { PrefKey, getPref } from "./utils/preferences";
import { LoadingScreen } from "./modules/loading-screen";
import { MouseCursorHider } from "./modules/mkb/mouse-cursor-hider";
import { TouchController } from "./modules/touch-controller";
import { watchHeader } from "./modules/ui/header";
import { checkForUpdate, disablePwa } from "./utils/utils";
import { Patcher } from "./modules/patcher";
import { RemotePlay } from "./modules/remote-play";
import { onHistoryChanged, patchHistoryMethod } from "./utils/history";
import { VibrationManager } from "./modules/vibration-manager";
import { PreloadedState } from "./utils/titles-info";
import { patchAudioContext, patchRtcCodecs, patchRtcPeerConnection, patchVideoApi } from "./utils/monkey-patches";
import { STATES } from "./utils/global";
import { injectStreamMenuButtons } from "./modules/stream/stream-ui";
import { BxLogger } from "./utils/bx-logger";
import "@/utils/global";
import { BxEvent } from "@/utils/bx-event";
import { BX_FLAGS } from "@/utils/bx-flags";
import { BxExposed } from "@/utils/bx-exposed";
import { t } from "@/utils/translation";
import { interceptHttpRequests } from "@/utils/network";
import { CE } from "@/utils/html";
import { showGamepadToast } from "@/utils/gamepad";
import { MkbHandler } from "@/modules/mkb/mkb-handler";
import { StreamBadges } from "@/modules/stream/stream-badges";
import { StreamStats } from "@/modules/stream/stream-stats";
import { addCss } from "@/utils/css";
import { Toast } from "@/utils/toast";
import { setupBxUi, updateVideoPlayerCss } from "@/modules/ui/ui";
import { PrefKey, getPref } from "@/utils/preferences";
import { LoadingScreen } from "@/modules/loading-screen";
import { MouseCursorHider } from "@/modules/mkb/mouse-cursor-hider";
import { TouchController } from "@/modules/touch-controller";
import { watchHeader } from "@/modules/ui/header";
import { checkForUpdate, disablePwa } from "@/utils/utils";
import { Patcher } from "@/modules/patcher";
import { RemotePlay } from "@/modules/remote-play";
import { onHistoryChanged, patchHistoryMethod } from "@/utils/history";
import { VibrationManager } from "@/modules/vibration-manager";
import { PreloadedState } from "@/utils/titles-info";
import { patchAudioContext, patchRtcCodecs, patchRtcPeerConnection, patchVideoApi } from "@/utils/monkey-patches";
import { STATES } from "@/utils/global";
import { injectStreamMenuButtons } from "@/modules/stream/stream-ui";
import { BxLogger } from "@/utils/bx-logger";
// Handle login page
if (window.location.pathname.includes('/auth/msa')) {

View File

@ -1,7 +1,7 @@
import stylus from 'stylus';
// @ts-ignore
import cssStr from "../assets/css/styles.styl" with { type: "text" };
import cssStr from "@/assets/css/styles.styl" with { type: "text" };
const generatedCss = await (stylus(cssStr, {})
.set('filename', 'styles.css')

View File

@ -1,5 +1,5 @@
import { t } from "../utils/translation";
import { CE, createButton, ButtonStyle, Icon } from "../utils/html";
import { t } from "@/utils/translation";
import { CE, createButton, ButtonStyle, Icon } from "@/utils/html";
type DialogOptions = {
title?: string;

View File

@ -1,8 +1,8 @@
import { CE } from "../utils/html";
import { getPreferredServerRegion } from "../utils/region";
import { PrefKey, getPref } from "../utils/preferences";
import { t } from "../utils/translation";
import { STATES } from "../utils/global";
import { CE } from "@/utils/html";
import { getPreferredServerRegion } from "@/utils/region";
import { PrefKey, getPref } from "@/utils/preferences";
import { t } from "@/utils/translation";
import { STATES } from "@/utils/global";
export class LoadingScreen {
static #$bgStyle: HTMLElement;

View File

@ -1,4 +1,4 @@
import type { GamepadKeyNameType } from "../../types/mkb";
import type { GamepadKeyNameType } from "@/types/mkb";
export enum GamepadKey {
A = 0,

View File

@ -1,17 +1,17 @@
import { MkbPreset } from "./mkb-preset";
import { GamepadKey, MkbPresetKey, GamepadStick, MouseMapTo } from "./definitions";
import { createButton, Icon, ButtonStyle, CE } from "../../utils/html";
import { BxEvent } from "../../utils/bx-event";
import { PrefKey, getPref } from "../../utils/preferences";
import { Toast } from "../../utils/toast";
import { t } from "../../utils/translation";
import { LocalDb } from "../../utils/local-db";
import { createButton, Icon, ButtonStyle, CE } from "@/utils/html";
import { BxEvent } from "@/utils/bx-event";
import { PrefKey, getPref } from "@/utils/preferences";
import { Toast } from "@/utils/toast";
import { t } from "@/utils/translation";
import { LocalDb } from "@/utils/local-db";
import { KeyHelper } from "./key-helper";
import type { MkbStoredPreset } from "../../types/mkb";
import { showStreamSettings } from "../stream/stream-ui";
import { STATES } from "../../utils/global";
import { UserAgent } from "../../utils/user-agent";
import { BxLogger } from "../../utils/bx-logger";
import type { MkbStoredPreset } from "@/types/mkb";
import { showStreamSettings } from "@/modules/stream/stream-ui";
import { STATES } from "@/utils/global";
import { UserAgent } from "@/utils/user-agent";
import { BxLogger } from "@/utils/bx-logger";
const LOG_TAG = 'MkbHandler';

View File

@ -1,9 +1,9 @@
import { t } from "../../utils/translation";
import { SettingElementType } from "../../utils/settings";
import { t } from "@/utils/translation";
import { SettingElementType } from "@/utils/settings";
import { GamepadKey, MouseButtonCode, MouseMapTo, MkbPresetKey } from "./definitions";
import { MkbHandler } from "./mkb-handler";
import type { MkbPresetData, MkbConvertedPresetData } from "../../types/mkb";
import type { PreferenceSettings } from "../../types/preferences";
import type { MkbPresetData, MkbConvertedPresetData } from "@/types/mkb";
import type { PreferenceSettings } from "@/types/preferences";
export class MkbPreset {

View File

@ -1,16 +1,16 @@
import { GamepadKey } from "./definitions";
import { CE, createButton, ButtonStyle } from "../../utils/html";
import { t } from "../../utils/translation";
import { Dialog } from "../dialog";
import { getPref, setPref, PrefKey } from "../../utils/preferences";
import { CE, createButton, ButtonStyle } from "@/utils/html";
import { t } from "@/utils/translation";
import { Dialog } from "@/modules/dialog";
import { getPref, setPref, PrefKey } from "@/utils/preferences";
import { MkbPresetKey, GamepadKeyName } from "./definitions";
import { KeyHelper } from "./key-helper";
import { MkbPreset } from "./mkb-preset";
import { MkbHandler } from "./mkb-handler";
import { LocalDb } from "../../utils/local-db";
import { Icon } from "../../utils/html";
import { SettingElement } from "../../utils/settings";
import type { MkbPresetData, MkbStoredPresets } from "../../types/mkb";
import { LocalDb } from "@/utils/local-db";
import { Icon } from "@/utils/html";
import { SettingElement } from "@/utils/settings";
import type { MkbPresetData, MkbStoredPresets } from "@/types/mkb";
type MkbRemapperElements = {

View File

@ -1,8 +1,8 @@
import { STATES } from "../utils/global";
import { BX_FLAGS } from "../utils/bx-flags";
import { getPref, PrefKey } from "../utils/preferences";
import { VibrationManager } from "./vibration-manager";
import { BxLogger } from "../utils/bx-logger";
import { STATES } from "@/utils/global";
import { BX_FLAGS } from "@/utils/bx-flags";
import { getPref, PrefKey } from "@/utils/preferences";
import { VibrationManager } from "@/modules/vibration-manager";
import { BxLogger } from "@/utils/bx-logger";
const LOG_TAG = 'Patcher';

View File

@ -1,11 +1,11 @@
import { STATES, AppInterface } from "../utils/global";
import { CE, createButton, ButtonStyle, Icon } from "../utils/html";
import { Toast } from "../utils/toast";
import { BxEvent } from "../utils/bx-event";
import { getPref, PrefKey, setPref } from "../utils/preferences";
import { t } from "../utils/translation";
import { localRedirect } from "./ui/ui";
import { BxLogger } from "../utils/bx-logger";
import { STATES, AppInterface } from "@/utils/global";
import { CE, createButton, ButtonStyle, Icon } from "@/utils/html";
import { Toast } from "@/utils/toast";
import { BxEvent } from "@/utils/bx-event";
import { getPref, PrefKey, setPref } from "@/utils/preferences";
import { t } from "@/utils/translation";
import { localRedirect } from "@/modules/ui/ui";
import { BxLogger } from "@/utils/bx-logger";
const LOG_TAG = 'RemotePlay';

View File

@ -1,5 +1,5 @@
import { STATES, AppInterface } from "../utils/global";
import { CE } from "../utils/html";
import { STATES, AppInterface } from "@/utils/global";
import { CE } from "@/utils/html";
export function takeScreenshot(callback: any) {
const currentStream = STATES.currentStream!;

View File

@ -1,7 +1,7 @@
import { t } from "../../utils/translation";
import { BxEvent } from "../../utils/bx-event";
import { CE } from "../../utils/html";
import { STATES } from "../../utils/global";
import { t } from "@/utils/translation";
import { BxEvent } from "@/utils/bx-event";
import { CE } from "@/utils/html";
import { STATES } from "@/utils/global";
enum StreamBadge {
PLAYTIME = 'playtime',

View File

@ -1,11 +1,11 @@
import { PrefKey } from "../../utils/preferences"
import { BxEvent } from "../../utils/bx-event"
import { getPref } from "../../utils/preferences"
import { PrefKey } from "@/utils/preferences"
import { BxEvent } from "@/utils/bx-event"
import { getPref } from "@/utils/preferences"
import { StreamBadges } from "./stream-badges"
import { CE } from "../../utils/html"
import { t } from "../../utils/translation"
import { STATES } from "../../utils/global"
import { BxLogger } from "../../utils/bx-logger"
import { CE } from "@/utils/html"
import { t } from "@/utils/translation"
import { STATES } from "@/utils/global"
import { BxLogger } from "@/utils/bx-logger"
export enum StreamStat {
PING = 'ping',

View File

@ -1,10 +1,10 @@
import { STATES } from "../../utils/global";
import { Icon, createSvgIcon } from "../../utils/html";
import { BxEvent } from "../../utils/bx-event";
import { PrefKey, getPref } from "../../utils/preferences";
import { t } from "../../utils/translation";
import { StreamBadges } from "./stream-badges";
import { StreamStats } from "./stream-stats";
import { STATES } from "@/utils/global.ts";
import { Icon, createSvgIcon } from "@/utils/html.ts";
import { BxEvent } from "@/utils/bx-event.ts";
import { PrefKey, getPref } from "@/utils/preferences.ts";
import { t } from "@/utils/translation.ts";
import { StreamBadges } from "./stream-badges.ts";
import { StreamStats } from "./stream-stats.ts";
class MouseHoldEvent {

View File

@ -1,12 +1,12 @@
import { STATES } from "../utils/global";
import { CE } from "../utils/html";
import { Toast } from "../utils/toast";
import { BxEvent } from "../utils/bx-event";
import { BX_FLAGS } from "../utils/bx-flags";
import { getPref, PrefKey } from "../utils/preferences";
import { t } from "../utils/translation";
import { NATIVE_FETCH } from "../utils/network";
import { BxLogger } from "../utils/bx-logger";
import { STATES } from "@/utils/global";
import { CE } from "@/utils/html";
import { Toast } from "@/utils/toast";
import { BxEvent } from "@/utils/bx-event";
import { BX_FLAGS } from "@/utils/bx-flags";
import { getPref, PrefKey } from "@/utils/preferences";
import { t } from "@/utils/translation";
import { NATIVE_FETCH } from "@/utils/network";
import { BxLogger } from "@/utils/bx-logger";
const LOG_TAG = 'TouchController';

View File

@ -1,9 +1,9 @@
import { STATES, AppInterface, SCRIPT_HOME, SCRIPT_VERSION } from "../../utils/global";
import { CE, createButton, Icon, ButtonStyle } from "../../utils/html";
import { getPreferredServerRegion } from "../../utils/region";
import { UserAgent, UserAgentProfile } from "../../utils/user-agent";
import { getPref, Preferences, PrefKey, setPref, toPrefElement } from "../../utils/preferences";
import { t, refreshCurrentLocale } from "../../utils/translation";
import { STATES, AppInterface, SCRIPT_HOME, SCRIPT_VERSION } from "@/utils/global";
import { CE, createButton, Icon, ButtonStyle } from "@/utils/html";
import { getPreferredServerRegion } from "@/utils/region";
import { UserAgent, UserAgentProfile } from "@/utils/user-agent";
import { getPref, Preferences, PrefKey, setPref, toPrefElement } from "@/utils/preferences";
import { t, refreshCurrentLocale } from "@/utils/translation";
const SETTINGS_UI = {
'Better xCloud': {

View File

@ -1,9 +1,9 @@
import { SCRIPT_VERSION } from "../../utils/global";
import { createButton, Icon, ButtonStyle } from "../../utils/html";
import { getPreferredServerRegion } from "../../utils/region";
import { PrefKey, getPref } from "../../utils/preferences";
import { RemotePlay } from "../remote-play";
import { t } from "../../utils/translation";
import { SCRIPT_VERSION } from "@/utils/global";
import { createButton, Icon, ButtonStyle } from "@/utils/html";
import { getPreferredServerRegion } from "@/utils/region";
import { PrefKey, getPref } from "@/utils/preferences";
import { RemotePlay } from "@/modules/remote-play";
import { t } from "@/utils/translation";
import { setupSettingsUi } from "./global-settings";

View File

@ -1,14 +1,14 @@
import { STATES } from "../../utils/global";
import { Icon, CE, createButton, ButtonStyle, createSvgIcon } from "../../utils/html";
import { UserAgent } from "../../utils/user-agent";
import { BxEvent } from "../../utils/bx-event";
import { MkbRemapper } from "../mkb/mkb-remapper";
import { getPref, PrefKey, toPrefElement } from "../../utils/preferences";
import { setupScreenshotButton } from "../screenshot";
import { StreamStats } from "../stream/stream-stats";
import { TouchController } from "../touch-controller";
import { t } from "../../utils/translation";
import { VibrationManager } from "../vibration-manager";
import { STATES } from "@/utils/global";
import { Icon, CE, createButton, ButtonStyle, createSvgIcon } from "@/utils/html";
import { UserAgent } from "@/utils/user-agent";
import { BxEvent } from "@/utils/bx-event";
import { MkbRemapper } from "@/modules/mkb/mkb-remapper";
import { getPref, PrefKey, toPrefElement } from "@/utils/preferences";
import { setupScreenshotButton } from "@/modules/screenshot";
import { StreamStats } from "@/modules/stream/stream-stats";
import { TouchController } from "@/modules/touch-controller";
import { t } from "@/utils/translation";
import { VibrationManager } from "@/modules/vibration-manager";
export function localRedirect(path: string) {

View File

@ -1,6 +1,6 @@
import { AppInterface } from "../utils/global";
import { BxEvent } from "../utils/bx-event";
import { PrefKey, getPref } from "../utils/preferences";
import { AppInterface } from "@/utils/global";
import { BxEvent } from "@/utils/bx-event";
import { PrefKey, getPref } from "@/utils/preferences";
const VIBRATION_DATA_MAP = {
'gamepadIndex': 8,

2
src/types/mkb.d.ts vendored
View File

@ -1,4 +1,4 @@
import { MkbPresetKey } from "../modules/mkb/definitions";
import { MkbPresetKey } from "@/modules/mkb/definitions";
type GamepadKeyNameType = {[index: string | number]: string[]};

View File

@ -1,6 +1,6 @@
import { CE } from "./html";
import { PrefKey, getPref } from "./preferences";
import { renderStylus } from "../macros/build" with {type: "macro"};
import { renderStylus } from "@/macros/build" with {type: "macro"};
export function addCss() {

View File

@ -1,4 +1,4 @@
import { MkbHandler } from "../modules/mkb/mkb-handler";
import { MkbHandler } from "@/modules/mkb/mkb-handler";
import { PrefKey, getPref } from "./preferences";
import { t } from "./translation";
import { Toast } from "./toast";

View File

@ -1,7 +1,7 @@
import { BxEvent } from "./bx-event";
import { LoadingScreen } from "../modules/loading-screen";
import { RemotePlay } from "../modules/remote-play";
import { checkHeader } from "../modules/ui/header";
import { LoadingScreen } from "@/modules/loading-screen";
import { RemotePlay } from "@/modules/remote-play";
import { checkHeader } from "@/modules/ui/header";
export function patchHistoryMethod(type: 'pushState' | 'replaceState') {
const orig = window.history[type];

View File

@ -1,27 +1,27 @@
// @ts-ignore
import iconController from "../assets/svg/controller.svg" with { type: "text" };
import iconController from "@/assets/svg/controller.svg" with { type: "text" };
// @ts-ignore
import iconCopy from "../assets/svg/copy.svg" with { type: "text" };
import iconCopy from "@/assets/svg/copy.svg" with { type: "text" };
// @ts-ignore
import iconCursorText from "../assets/svg/cursor-text.svg" with { type: "text" };
import iconCursorText from "@/assets/svg/cursor-text.svg" with { type: "text" };
// @ts-ignore
import iconDisplay from "../assets/svg/display.svg" with { type: "text" };
import iconDisplay from "@/assets/svg/display.svg" with { type: "text" };
// @ts-ignore
import iconMouseSettings from "../assets/svg/mouse-settings.svg" with { type: "text" };
import iconMouseSettings from "@/assets/svg/mouse-settings.svg" with { type: "text" };
// @ts-ignore
import iconMouse from "../assets/svg/mouse.svg" with { type: "text" };
import iconMouse from "@/assets/svg/mouse.svg" with { type: "text" };
// @ts-ignore
import iconNew from "../assets/svg/new.svg" with { type: "text" };
import iconNew from "@/assets/svg/new.svg" with { type: "text" };
// @ts-ignore
import iconQuestion from "../assets/svg/question.svg" with { type: "text" };
import iconQuestion from "@/assets/svg/question.svg" with { type: "text" };
// @ts-ignore
import iconRemotePlay from "../assets/svg/remote-play.svg" with { type: "text" };
import iconRemotePlay from "@/assets/svg/remote-play.svg" with { type: "text" };
// @ts-ignore
import iconStreamSettings from "../assets/svg/stream-settings.svg" with { type: "text" };
import iconStreamSettings from "@/assets/svg/stream-settings.svg" with { type: "text" };
// @ts-ignore
import iconStreamStats from "../assets/svg/stream-stats.svg" with { type: "text" };
import iconStreamStats from "@/assets/svg/stream-stats.svg" with { type: "text" };
// @ts-ignore
import iconTrash from "../assets/svg/trash.svg" with { type: "text" };
import iconTrash from "@/assets/svg/trash.svg" with { type: "text" };
type BxButton = {

View File

@ -1,7 +1,7 @@
import { MkbPreset } from "../modules/mkb/mkb-preset";
import { MkbPreset } from "@/modules/mkb/mkb-preset";
import { PrefKey, setPref } from "./preferences";
import { t } from "./translation";
import type { MkbStoredPreset, MkbStoredPresets } from "../types/mkb";
import type { MkbStoredPreset, MkbStoredPresets } from "@/types/mkb";
export class LocalDb {
static #instance: LocalDb;

View File

@ -1,12 +1,12 @@
import { BxEvent } from "./bx-event";
import { BX_FLAGS } from "./bx-flags";
import { LoadingScreen } from "../modules/loading-screen";
import { PrefKey, getPref } from "./preferences";
import { RemotePlay } from "../modules/remote-play";
import { StreamBadges } from "../modules/stream/stream-badges";
import { TouchController } from "../modules/touch-controller";
import { STATES } from "./global";
import { getPreferredServerRegion } from "./region";
import { BxEvent } from "@/utils/bx-event";
import { BX_FLAGS } from "@/utils/bx-flags";
import { LoadingScreen } from "@/modules/loading-screen";
import { PrefKey, getPref } from "@/utils/preferences";
import { RemotePlay } from "@/modules/remote-play";
import { StreamBadges } from "@/modules/stream/stream-badges";
import { TouchController } from "@/modules/touch-controller";
import { STATES } from "@/utils/global";
import { getPreferredServerRegion } from "@/utils/region";
export const NATIVE_FETCH = window.fetch;

View File

@ -2,8 +2,8 @@ import { CE } from "./html";
import { SUPPORTED_LANGUAGES, t } from "./translation";
import { SettingElement, SettingElementType } from "./settings";
import { UserAgentProfile } from "./user-agent";
import { StreamStat } from "../modules/stream/stream-stats";
import type { PreferenceSettings } from "../types/preferences";
import { StreamStat } from "@/modules/stream/stream-stats";
import type { PreferenceSettings } from "@/types/preferences";
import { STATES } from "./global";
export enum PrefKey {

View File

@ -1,4 +1,4 @@
import type { PreferenceSetting } from "../types/preferences";
import type { PreferenceSetting } from "@/types/preferences";
import { CE } from "./html";
type MultipleOptionsParams = {

View File

@ -7,15 +7,19 @@
"dist"
],
"compilerOptions": {
"baseUrl": "./src",
"paths": {
"@/*": ["./*"]
},
// Enable latest features
"lib": ["ESNext", "DOM"],
"target": "ESNext",
"module": "ESNext",
"moduleDetection": "force",
"allowJs": true,
"allowJs": false,
// Bundler mode
"moduleResolution": "bundler",
"moduleResolution": "Bundler",
"allowImportingTsExtensions": true,
"verbatimModuleSyntax": true,
"noEmit": true,