mirror of
https://github.com/redphx/better-xcloud.git
synced 2025-06-06 07:37:19 +02:00
Use globalThis to declare global variables
This commit is contained in:
parent
c0efaf3e34
commit
9a76731c69
12
src/index.ts
12
src/index.ts
@ -40,15 +40,15 @@ import { PreloadedState } from "./utils/titles-info";
|
|||||||
import { patchAudioContext, patchRtcCodecs, patchRtcPeerConnection, patchVideoApi } from "./utils/monkey-patches";
|
import { patchAudioContext, patchRtcCodecs, patchRtcPeerConnection, patchVideoApi } from "./utils/monkey-patches";
|
||||||
import { interceptHttpRequests } from "./utils/network";
|
import { interceptHttpRequests } from "./utils/network";
|
||||||
|
|
||||||
const SCRIPT_VERSION = '3.5.3';
|
globalThis.SCRIPT_VERSION = '3.5.3';
|
||||||
const SCRIPT_HOME = 'https://github.com/redphx/better-xcloud';
|
globalThis.SCRIPT_HOME = 'https://github.com/redphx/better-xcloud';
|
||||||
|
|
||||||
const NATIVE_FETCH = window.fetch;
|
globalThis.NATIVE_FETCH = window.fetch;
|
||||||
|
|
||||||
let LOCALE = getLocale();
|
globalThis.LOCALE = getLocale();
|
||||||
|
|
||||||
const AppInterface = window.AppInterface;
|
globalThis.AppInterface = window.AppInterface;
|
||||||
let States: BxStates = {
|
globalThis.States = {
|
||||||
isPlaying: false,
|
isPlaying: false,
|
||||||
appContext: {},
|
appContext: {},
|
||||||
serverRegions: {},
|
serverRegions: {},
|
||||||
|
@ -1,5 +1,3 @@
|
|||||||
declare var States: BxStates;
|
|
||||||
|
|
||||||
export const BxExposed = {
|
export const BxExposed = {
|
||||||
onPollingModeChanged: (mode: 'All' | 'None') => {
|
onPollingModeChanged: (mode: 'All' | 'None') => {
|
||||||
if (!States.isPlaying) {
|
if (!States.isPlaying) {
|
||||||
|
14
src/types/index.d.ts
vendored
14
src/types/index.d.ts
vendored
@ -51,11 +51,11 @@ type BxStates = {
|
|||||||
|
|
||||||
type DualEnum = {[index: string]: number} & {[index: number]: string};
|
type DualEnum = {[index: string]: number} & {[index: number]: string};
|
||||||
|
|
||||||
declare const window: Window & typeof globalThis;
|
declare var SCRIPT_VERSION: string;
|
||||||
declare const AppInterface: any;
|
declare var window: Window & typeof globalThis;
|
||||||
declare const STREAM_WEBRTC: RTCPeerConnection;
|
declare var AppInterface: any;
|
||||||
declare let States: BxStates;
|
declare var STREAM_WEBRTC: RTCPeerConnection;
|
||||||
declare const NATIVE_FETCH: typeof window.fetch;
|
declare var States: BxStates;
|
||||||
declare const SCRIPT_VERSION: string;
|
declare var NATIVE_FETCH: typeof window.fetch;
|
||||||
declare const SCRIPT_HOME: string;
|
declare var SCRIPT_HOME: string;
|
||||||
declare var LOCALE: number;
|
declare var LOCALE: number;
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
import { getPref, Preferences, PrefKey } from "../modules/preferences";
|
import { getPref, Preferences, PrefKey } from "../modules/preferences";
|
||||||
|
|
||||||
|
|
||||||
declare var States: BxStates;
|
|
||||||
|
|
||||||
export function getPreferredServerRegion(shortName = false) {
|
export function getPreferredServerRegion(shortName = false) {
|
||||||
let preferredRegion = getPref(PrefKey.SERVER_REGION);
|
let preferredRegion = getPref(PrefKey.SERVER_REGION);
|
||||||
if (preferredRegion in States.serverRegions) {
|
if (preferredRegion in States.serverRegions) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user