Rename EventBus to BxEventBus

This commit is contained in:
redphx 2024-12-08 20:09:12 +07:00
parent de7bf3edc7
commit 741bc9a4e5
21 changed files with 130 additions and 125 deletions

View File

@ -156,10 +156,10 @@ var BxEvent;
BxEvent.dispatch = dispatch;
})(BxEvent ||= {});
window.BxEvent = BxEvent;
class EventBus {
class BxEventBus {
listeners = new Map;
static Script = new EventBus;
static Stream = new EventBus;
static Script = new BxEventBus;
static Stream = new BxEventBus;
on(event, callback) {
if (!this.listeners.has(event)) this.listeners.set(event, new Set);
this.listeners.get(event).add(callback), BX_FLAGS.Debug && BxLogger.warning("EventBus", "on", event, callback);
@ -183,6 +183,7 @@ class EventBus {
callback(payload);
}
}
window.BxEventBus = BxEventBus;
class GhPagesUtils {
static fetchLatestCommit() {
NATIVE_FETCH("https://api.github.com/repos/redphx/better-xcloud/branches/gh-pages", {
@ -206,7 +207,7 @@ class GhPagesUtils {
static getNativeMkbCustomList(update = !1) {
let key = "BetterXcloud.GhPages.ForceNativeMkb";
update && NATIVE_FETCH(GhPagesUtils.getUrl("native-mkb/ids.json")).then((response) => response.json()).then((json) => {
if (json.$schemaVersion === 1) window.localStorage.setItem(key, JSON.stringify(json)), EventBus.Script.emit("listForcedNativeMkbUpdated", {});
if (json.$schemaVersion === 1) window.localStorage.setItem(key, JSON.stringify(json)), BxEventBus.Script.emit("listForcedNativeMkbUpdated", {});
});
let info = JSON.parse(window.localStorage.getItem(key) || "{}");
if (info.$schemaVersion !== 1) return window.localStorage.removeItem(key), {};
@ -905,7 +906,7 @@ class BaseSettingsStore {
return this.settings[key];
}
setSetting(key, value, emitEvent = !1) {
return value = this.validateValue("set", key, value), this.settings[key] = this.validateValue("get", key, value), this.saveSettings(), emitEvent && EventBus.Script.emit("settingChanged", {
return value = this.validateValue("set", key, value), this.settings[key] = this.validateValue("get", key, value), this.saveSettings(), emitEvent && BxEventBus.Script.emit("settingChanged", {
storageKey: this.storageKey,
settingKey: key,
settingValue: value
@ -1539,7 +1540,7 @@ class GlobalSettingsStorage extends BaseSettingsStore {
default: [],
unsupported: !AppInterface && UserAgent.isMobile(),
ready: (setting) => {
if (!setting.unsupported) setting.multipleOptions = GhPagesUtils.getNativeMkbCustomList(!0), EventBus.Script.on("listForcedNativeMkbUpdated", () => {
if (!setting.unsupported) setting.multipleOptions = GhPagesUtils.getNativeMkbCustomList(!0), BxEventBus.Script.on("listForcedNativeMkbUpdated", () => {
setting.multipleOptions = GhPagesUtils.getNativeMkbCustomList();
});
},
@ -2168,7 +2169,7 @@ class StreamStatsCollector {
} catch (e) {}
}
static setupEvents() {
EventBus.Stream.on("statePlaying", () => {
BxEventBus.Stream.on("statePlaying", () => {
StreamStatsCollector.getInstance().reset();
});
}
@ -2306,7 +2307,7 @@ class StreamStats {
this.refreshStyles(), document.documentElement.appendChild(this.$container);
}
static setupEvents() {
EventBus.Stream.on("statePlaying", () => {
BxEventBus.Stream.on("statePlaying", () => {
let PREF_STATS_QUICK_GLANCE = getPref("stats.quickGlance.enabled"), PREF_STATS_SHOW_WHEN_PLAYING = getPref("stats.showWhenPlaying"), streamStats = StreamStats.getInstance();
if (PREF_STATS_SHOW_WHEN_PLAYING) streamStats.start();
else if (PREF_STATS_QUICK_GLANCE) streamStats.quickGlanceSetup(), !PREF_STATS_SHOW_WHEN_PLAYING && streamStats.start(!0);
@ -2600,7 +2601,7 @@ class StreamSettings {
if (!STATES.browser.capabilities.deviceVibration) return;
let mode = StreamSettings.getPref("deviceVibration.mode"), intensity = 0;
if (mode === "on" || mode === "auto" && !hasGamepad()) intensity = StreamSettings.getPref("deviceVibration.intensity") / 100;
StreamSettings.settings.deviceVibrationIntensity = intensity, EventBus.Script.emit("deviceVibrationUpdated", {});
StreamSettings.settings.deviceVibrationIntensity = intensity, BxEventBus.Script.emit("deviceVibrationUpdated", {});
}
static async refreshMkbSettings() {
let settings = StreamSettings.settings, presetId = StreamSettings.getPref("mkb.p1.preset.mappingId"), orgPreset = await MkbMappingPresetsTable.getInstance().getPreset(presetId), orgPresetData = orgPreset.data, converted = {
@ -2614,12 +2615,12 @@ class StreamSettings {
if (typeof keyName === "string") converted.mapping[keyName] = buttonIndex;
}
let mouse = converted.mouse;
mouse["sensitivityX"] *= 0.001, mouse["sensitivityY"] *= 0.001, mouse["deadzoneCounterweight"] *= 0.01, settings.mkbPreset = converted, setPref("mkb.p1.preset.mappingId", orgPreset.id), EventBus.Script.emit("mkbSettingUpdated", {});
mouse["sensitivityX"] *= 0.001, mouse["sensitivityY"] *= 0.001, mouse["deadzoneCounterweight"] *= 0.01, settings.mkbPreset = converted, setPref("mkb.p1.preset.mappingId", orgPreset.id), BxEventBus.Script.emit("mkbSettingUpdated", {});
}
static async refreshKeyboardShortcuts() {
let settings = StreamSettings.settings, presetId = StreamSettings.getPref("keyboardShortcuts.preset.inGameId");
if (presetId === 0) {
settings.keyboardShortcuts = null, setPref("keyboardShortcuts.preset.inGameId", presetId), EventBus.Script.emit("keyboardShortcutsUpdated", {});
settings.keyboardShortcuts = null, setPref("keyboardShortcuts.preset.inGameId", presetId), BxEventBus.Script.emit("keyboardShortcutsUpdated", {});
return;
}
let orgPreset = await KeyboardShortcutsTable.getInstance().getPreset(presetId), orgPresetData = orgPreset.data.mapping, converted = {}, action;
@ -2627,7 +2628,7 @@ class StreamSettings {
let info = orgPresetData[action], key = `${info.code}:${info.modifiers || 0}`;
converted[key] = action;
}
settings.keyboardShortcuts = converted, setPref("keyboardShortcuts.preset.inGameId", orgPreset.id), EventBus.Script.emit("keyboardShortcutsUpdated", {});
settings.keyboardShortcuts = converted, setPref("keyboardShortcuts.preset.inGameId", orgPreset.id), BxEventBus.Script.emit("keyboardShortcutsUpdated", {});
}
static async refreshAllSettings() {
window.BX_STREAM_SETTINGS = StreamSettings.settings, await StreamSettings.refreshControllerSettings(), await StreamSettings.refreshMkbSettings(), await StreamSettings.refreshKeyboardShortcuts();
@ -2654,7 +2655,7 @@ class MkbPopup {
$btnActivate;
mkbHandler;
constructor() {
this.render(), EventBus.Script.on("keyboardShortcutsUpdated", () => {
this.render(), BxEventBus.Script.on("keyboardShortcutsUpdated", () => {
let $newButton = this.createActivateButton();
this.$btnActivate.replaceWith($newButton), this.$btnActivate = $newButton;
});
@ -4278,7 +4279,7 @@ class SettingsDialog extends NavigationDialog {
},
onCreated: (setting, $elm) => {
let $range = $elm.querySelector("input[type=range");
EventBus.Script.on("settingChanged", (payload) => {
BxEventBus.Script.on("settingChanged", (payload) => {
let { storageKey, settingKey, settingValue } = payload;
if (storageKey === "BetterXcloud" && settingKey === "audio.volume") $range.value = settingValue, BxEvent.dispatch($range, "input", { ignoreOnChange: !0 });
});
@ -5455,7 +5456,7 @@ class XcloudInterceptor {
ip && request.headers.set("X-Forwarded-For", ip);
}
let response = await NATIVE_FETCH(request, init);
if (response.status !== 200) return EventBus.Script.emit("xcloudServerUnavailable", {}), response;
if (response.status !== 200) return BxEventBus.Script.emit("xcloudServerUnavailable", {}), response;
let obj = await response.clone().json();
RemotePlayManager.getInstance()?.setXcloudToken(obj.gsToken);
let serverRegex = /\/\/(\w+)\./, serverExtra = XcloudInterceptor.SERVER_EXTRA_INFO, region;
@ -5467,7 +5468,7 @@ class XcloudInterceptor {
else region.contintent = "other";
region.shortName = shortName.toUpperCase(), STATES.serverRegions[region.name] = Object.assign({}, region);
}
EventBus.Script.emit("xcloudServerReady", {});
BxEventBus.Script.emit("xcloudServerReady", {});
let preferredRegion = getPreferredServerRegion();
if (preferredRegion && preferredRegion in STATES.serverRegions) {
let tmp = Object.assign({}, STATES.serverRegions[preferredRegion]);
@ -5476,7 +5477,7 @@ class XcloudInterceptor {
return STATES.gsToken = obj.gsToken, response.json = () => Promise.resolve(obj), response;
}
static async handlePlay(request, init) {
EventBus.Stream.emit("stateLoading", {});
BxEventBus.Stream.emit("stateLoading", {});
let PREF_STREAM_TARGET_RESOLUTION = getPref("stream.video.resolution"), PREF_STREAM_PREFERRED_LOCALE = getPref("stream.locale"), url = typeof request === "string" ? request : request.url, parsedUrl = new URL(url), badgeRegion = parsedUrl.host.split(".", 1)[0];
for (let regionName in STATES.serverRegions) {
let region = STATES.serverRegions[regionName];
@ -5512,7 +5513,7 @@ class XcloudInterceptor {
if (request.method !== "GET") return NATIVE_FETCH(request, init);
let response = await NATIVE_FETCH(request, init), text = await response.clone().text();
if (!text.length) return response;
EventBus.Stream.emit("stateStarting", {});
BxEventBus.Stream.emit("stateStarting", {});
let obj = JSON.parse(text), overrides = JSON.parse(obj.clientStreamingConfigOverrides || "{}") || {};
overrides.inputConfiguration = overrides.inputConfiguration || {}, overrides.inputConfiguration.enableVibration = !0;
let overrideMkb = null;
@ -5742,7 +5743,7 @@ function patchHistoryMethod(type) {
}
function onHistoryChanged(e) {
if (e && e.arguments && e.arguments[0] && e.arguments[0].origin === "better-xcloud") return;
window.setTimeout(RemotePlayManager.detect, 10), NavigationDialogManager.getInstance().hide(), LoadingScreen.reset(), window.setTimeout(HeaderSection.watchHeader, 2000), EventBus.Stream.emit("stateStopped", {});
window.setTimeout(RemotePlayManager.detect, 10), NavigationDialogManager.getInstance().hide(), LoadingScreen.reset(), window.setTimeout(HeaderSection.watchHeader, 2000), BxEventBus.Stream.emit("stateStopped", {});
}
function setCodecPreferences(sdp, preferredCodec) {
let h264Pattern = /a=fmtp:(\d+).*profile-level-id=([0-9a-f]{6})/g, profilePrefix = preferredCodec === "high" ? "4d" : preferredCodec === "low" ? "420" : "42e", preferredCodecIds = [], matches = sdp.matchAll(h264Pattern) || [];
@ -6098,7 +6099,7 @@ function patchVideoApi() {
contrast: getPref("video.contrast"),
brightness: getPref("video.brightness")
};
STATES.currentStream.streamPlayer = new StreamPlayer(this, getPref("video.player.type"), playerOptions), EventBus.Stream.emit("statePlaying", {
STATES.currentStream.streamPlayer = new StreamPlayer(this, getPref("video.player.type"), playerOptions), BxEventBus.Stream.emit("statePlaying", {
$video: this
});
}, nativePlay = HTMLMediaElement.prototype.play;
@ -6297,7 +6298,7 @@ class StreamUiHandler {
if (!($elm instanceof HTMLElement)) return;
let className = $elm.className || "";
if (className.includes("PureErrorPage")) {
EventBus.Stream.emit("stateError", {});
BxEventBus.Stream.emit("stateError", {});
return;
}
if (className.startsWith("StreamMenu-module__container")) {
@ -6418,25 +6419,25 @@ window.addEventListener(BxEvent.POPSTATE, onHistoryChanged);
window.addEventListener("popstate", onHistoryChanged);
window.history.pushState = patchHistoryMethod("pushState");
window.history.replaceState = patchHistoryMethod("replaceState");
EventBus.Script.on("xcloudServerUnavailable", () => {
if (EventBus.Script.off("xcloudServerUnavailable", null), STATES.supportedRegion = !1, window.setTimeout(HeaderSection.watchHeader, 2000), document.querySelector("div[class^=UnsupportedMarketPage-module__container]")) SettingsDialog.getInstance().show();
BxEventBus.Script.on("xcloudServerUnavailable", () => {
if (BxEventBus.Script.off("xcloudServerUnavailable", null), STATES.supportedRegion = !1, window.setTimeout(HeaderSection.watchHeader, 2000), document.querySelector("div[class^=UnsupportedMarketPage-module__container]")) SettingsDialog.getInstance().show();
});
EventBus.Script.on("xcloudServerReady", () => {
BxEventBus.Script.on("xcloudServerReady", () => {
STATES.isSignedIn = !0, window.setTimeout(HeaderSection.watchHeader, 2000);
});
EventBus.Stream.on("stateLoading", () => {
BxEventBus.Stream.on("stateLoading", () => {
if (window.location.pathname.includes("/launch/") && STATES.currentStream.titleInfo) STATES.currentStream.titleSlug = productTitleToSlug(STATES.currentStream.titleInfo.product.title);
else STATES.currentStream.titleSlug = "remote-play";
});
getPref("loadingScreen.gameArt.show") && EventBus.Script.on("titleInfoReady", LoadingScreen.setup);
EventBus.Stream.on("stateStarting", () => {
getPref("loadingScreen.gameArt.show") && BxEventBus.Script.on("titleInfoReady", LoadingScreen.setup);
BxEventBus.Stream.on("stateStarting", () => {
LoadingScreen.hide();
});
EventBus.Stream.on("statePlaying", (payload) => {
BxEventBus.Stream.on("statePlaying", (payload) => {
window.BX_STREAM_SETTINGS = StreamSettings.settings, StreamSettings.refreshAllSettings(), STATES.isPlaying = !0, StreamUiHandler.observe(), updateVideoPlayer();
});
EventBus.Stream.on("stateError", () => {
EventBus.Stream.emit("stateStopped", {});
BxEventBus.Stream.on("stateError", () => {
BxEventBus.Stream.emit("stateStopped", {});
});
window.addEventListener(BxEvent.DATA_CHANNEL_CREATED, (e) => {
let dataChannel = e.dataChannel;
@ -6458,9 +6459,9 @@ function unload() {
if (!STATES.isPlaying) return;
STATES.currentStream.streamPlayer?.destroy(), STATES.isPlaying = !1, STATES.currentStream = {}, window.BX_EXPOSED.shouldShowSensorControls = !1, window.BX_EXPOSED.stopTakRendering = !1, NavigationDialogManager.getInstance().hide(), StreamStats.getInstance().destroy(), StreamBadges.getInstance().destroy();
}
EventBus.Stream.on("stateStopped", unload);
BxEventBus.Stream.on("stateStopped", unload);
window.addEventListener("pagehide", (e) => {
EventBus.Stream.emit("stateStopped", {});
BxEventBus.Stream.emit("stateStopped", {});
});
function main() {
if (GhPagesUtils.fetchLatestCommit(), getPref("nativeMkb.mode") !== "off") {

View File

@ -185,10 +185,10 @@ var GamepadKeyName = {
202: ["Right Stick Left", "↽"],
203: ["Right Stick Right", "⇁"]
};
class EventBus {
class BxEventBus {
listeners = new Map;
static Script = new EventBus;
static Stream = new EventBus;
static Script = new BxEventBus;
static Stream = new BxEventBus;
on(event, callback) {
if (!this.listeners.has(event)) this.listeners.set(event, new Set);
this.listeners.get(event).add(callback), BX_FLAGS.Debug && BxLogger.warning("EventBus", "on", event, callback);
@ -212,6 +212,7 @@ class EventBus {
callback(payload);
}
}
window.BxEventBus = BxEventBus;
class GhPagesUtils {
static fetchLatestCommit() {
NATIVE_FETCH("https://api.github.com/repos/redphx/better-xcloud/branches/gh-pages", {
@ -235,7 +236,7 @@ class GhPagesUtils {
static getNativeMkbCustomList(update = !1) {
let key = "BetterXcloud.GhPages.ForceNativeMkb";
update && NATIVE_FETCH(GhPagesUtils.getUrl("native-mkb/ids.json")).then((response) => response.json()).then((json) => {
if (json.$schemaVersion === 1) window.localStorage.setItem(key, JSON.stringify(json)), EventBus.Script.emit("listForcedNativeMkbUpdated", {});
if (json.$schemaVersion === 1) window.localStorage.setItem(key, JSON.stringify(json)), BxEventBus.Script.emit("listForcedNativeMkbUpdated", {});
});
let info = JSON.parse(window.localStorage.getItem(key) || "{}");
if (info.$schemaVersion !== 1) return window.localStorage.removeItem(key), {};
@ -980,7 +981,7 @@ class BaseSettingsStore {
return this.settings[key];
}
setSetting(key, value, emitEvent = !1) {
return value = this.validateValue("set", key, value), this.settings[key] = this.validateValue("get", key, value), this.saveSettings(), emitEvent && EventBus.Script.emit("settingChanged", {
return value = this.validateValue("set", key, value), this.settings[key] = this.validateValue("get", key, value), this.saveSettings(), emitEvent && BxEventBus.Script.emit("settingChanged", {
storageKey: this.storageKey,
settingKey: key,
settingValue: value
@ -1614,7 +1615,7 @@ class GlobalSettingsStorage extends BaseSettingsStore {
default: [],
unsupported: !AppInterface && UserAgent.isMobile(),
ready: (setting) => {
if (!setting.unsupported) setting.multipleOptions = GhPagesUtils.getNativeMkbCustomList(!0), EventBus.Script.on("listForcedNativeMkbUpdated", () => {
if (!setting.unsupported) setting.multipleOptions = GhPagesUtils.getNativeMkbCustomList(!0), BxEventBus.Script.on("listForcedNativeMkbUpdated", () => {
setting.multipleOptions = GhPagesUtils.getNativeMkbCustomList();
});
},
@ -2277,7 +2278,7 @@ class StreamStatsCollector {
} catch (e) {}
}
static setupEvents() {
EventBus.Stream.on("statePlaying", () => {
BxEventBus.Stream.on("statePlaying", () => {
StreamStatsCollector.getInstance().reset();
});
}
@ -2415,7 +2416,7 @@ class StreamStats {
this.refreshStyles(), document.documentElement.appendChild(this.$container);
}
static setupEvents() {
EventBus.Stream.on("statePlaying", () => {
BxEventBus.Stream.on("statePlaying", () => {
let PREF_STATS_QUICK_GLANCE = getPref("stats.quickGlance.enabled"), PREF_STATS_SHOW_WHEN_PLAYING = getPref("stats.showWhenPlaying"), streamStats = StreamStats.getInstance();
if (PREF_STATS_SHOW_WHEN_PLAYING) streamStats.start();
else if (PREF_STATS_QUICK_GLANCE) streamStats.quickGlanceSetup(), !PREF_STATS_SHOW_WHEN_PLAYING && streamStats.start(!0);
@ -2715,7 +2716,7 @@ class StreamSettings {
if (!STATES.browser.capabilities.deviceVibration) return;
let mode = StreamSettings.getPref("deviceVibration.mode"), intensity = 0;
if (mode === "on" || mode === "auto" && !hasGamepad()) intensity = StreamSettings.getPref("deviceVibration.intensity") / 100;
StreamSettings.settings.deviceVibrationIntensity = intensity, EventBus.Script.emit("deviceVibrationUpdated", {});
StreamSettings.settings.deviceVibrationIntensity = intensity, BxEventBus.Script.emit("deviceVibrationUpdated", {});
}
static async refreshMkbSettings() {
let settings = StreamSettings.settings, presetId = StreamSettings.getPref("mkb.p1.preset.mappingId"), orgPreset = await MkbMappingPresetsTable.getInstance().getPreset(presetId), orgPresetData = orgPreset.data, converted = {
@ -2729,12 +2730,12 @@ class StreamSettings {
if (typeof keyName === "string") converted.mapping[keyName] = buttonIndex;
}
let mouse = converted.mouse;
mouse["sensitivityX"] *= 0.001, mouse["sensitivityY"] *= 0.001, mouse["deadzoneCounterweight"] *= 0.01, settings.mkbPreset = converted, setPref("mkb.p1.preset.mappingId", orgPreset.id), EventBus.Script.emit("mkbSettingUpdated", {});
mouse["sensitivityX"] *= 0.001, mouse["sensitivityY"] *= 0.001, mouse["deadzoneCounterweight"] *= 0.01, settings.mkbPreset = converted, setPref("mkb.p1.preset.mappingId", orgPreset.id), BxEventBus.Script.emit("mkbSettingUpdated", {});
}
static async refreshKeyboardShortcuts() {
let settings = StreamSettings.settings, presetId = StreamSettings.getPref("keyboardShortcuts.preset.inGameId");
if (presetId === 0) {
settings.keyboardShortcuts = null, setPref("keyboardShortcuts.preset.inGameId", presetId), EventBus.Script.emit("keyboardShortcutsUpdated", {});
settings.keyboardShortcuts = null, setPref("keyboardShortcuts.preset.inGameId", presetId), BxEventBus.Script.emit("keyboardShortcutsUpdated", {});
return;
}
let orgPreset = await KeyboardShortcutsTable.getInstance().getPreset(presetId), orgPresetData = orgPreset.data.mapping, converted = {}, action;
@ -2742,7 +2743,7 @@ class StreamSettings {
let info = orgPresetData[action], key = `${info.code}:${info.modifiers || 0}`;
converted[key] = action;
}
settings.keyboardShortcuts = converted, setPref("keyboardShortcuts.preset.inGameId", orgPreset.id), EventBus.Script.emit("keyboardShortcutsUpdated", {});
settings.keyboardShortcuts = converted, setPref("keyboardShortcuts.preset.inGameId", orgPreset.id), BxEventBus.Script.emit("keyboardShortcutsUpdated", {});
}
static async refreshAllSettings() {
window.BX_STREAM_SETTINGS = StreamSettings.settings, await StreamSettings.refreshControllerSettings(), await StreamSettings.refreshMkbSettings(), await StreamSettings.refreshKeyboardShortcuts();
@ -2769,7 +2770,7 @@ class MkbPopup {
$btnActivate;
mkbHandler;
constructor() {
this.render(), EventBus.Script.on("keyboardShortcutsUpdated", () => {
this.render(), BxEventBus.Script.on("keyboardShortcutsUpdated", () => {
let $newButton = this.createActivateButton();
this.$btnActivate.replaceWith($newButton), this.$btnActivate = $newButton;
});
@ -3264,11 +3265,11 @@ class EmulatedMkbHandler extends MkbHandler {
this.waitForMouseData(!0), this.mouseDataProvider?.stop();
}
static setupEvents() {
if (EventBus.Stream.on("statePlaying", () => {
if (BxEventBus.Stream.on("statePlaying", () => {
if (STATES.currentStream.titleInfo?.details.hasMkbSupport) NativeMkbHandler.getInstance()?.init();
else EmulatedMkbHandler.getInstance()?.init();
}), EmulatedMkbHandler.isAllowed())
EventBus.Script.on("mkbSettingUpdated", () => {
BxEventBus.Script.on("mkbSettingUpdated", () => {
EmulatedMkbHandler.getInstance()?.refreshPresetData();
});
}
@ -6139,7 +6140,7 @@ class SettingsDialog extends NavigationDialog {
},
onCreated: (setting, $elm) => {
let $range = $elm.querySelector("input[type=range");
EventBus.Script.on("settingChanged", (payload) => {
BxEventBus.Script.on("settingChanged", (payload) => {
let { storageKey, settingKey, settingValue } = payload;
if (storageKey === "BetterXcloud" && settingKey === "audio.volume") $range.value = settingValue, BxEvent.dispatch($range, "input", { ignoreOnChange: !0 });
});
@ -6988,7 +6989,7 @@ var BxExposed = {
if (touchControllerAvailability === "off") supportedInputTypes = supportedInputTypes.filter((i) => i !== "CustomTouchOverlay" && i !== "GenericTouch"), titleInfo.details.supportedTabs = [];
if (titleInfo.details.hasNativeTouchSupport = supportedInputTypes.includes("NativeTouch"), titleInfo.details.hasTouchSupport = titleInfo.details.hasNativeTouchSupport || supportedInputTypes.includes("CustomTouchOverlay") || supportedInputTypes.includes("GenericTouch"), !titleInfo.details.hasTouchSupport && touchControllerAvailability === "all") titleInfo.details.hasFakeTouchSupport = !0, supportedInputTypes.push("GenericTouch");
}
return titleInfo.details.supportedInputTypes = supportedInputTypes, STATES.currentStream.titleInfo = titleInfo, EventBus.Script.emit("titleInfoReady", {}), titleInfo;
return titleInfo.details.supportedInputTypes = supportedInputTypes, STATES.currentStream.titleInfo = titleInfo, BxEventBus.Script.emit("titleInfoReady", {}), titleInfo;
},
setupGainNode: ($media, audioStream) => {
if ($media instanceof HTMLAudioElement) $media.muted = !0, $media.addEventListener("playing", (e) => {
@ -7310,7 +7311,7 @@ class XhomeInterceptor {
return NATIVE_FETCH(request);
}
static async handleConfiguration(request) {
EventBus.Stream.emit("stateStarting", {});
BxEventBus.Stream.emit("stateStarting", {});
let response = await NATIVE_FETCH(request), obj = await response.clone().json(), serverDetails = obj.serverDetails, pairs = [
["ipAddress", "port"],
["ipV4Address", "ipV4Port"],
@ -7355,7 +7356,7 @@ class XhomeInterceptor {
}), NATIVE_FETCH(request);
}
static async handlePlay(request) {
EventBus.Stream.emit("stateLoading", {});
BxEventBus.Stream.emit("stateLoading", {});
let body = await request.clone().json(), newRequest = new Request(request, {
body: JSON.stringify(body)
});
@ -7764,7 +7765,7 @@ class XcloudInterceptor {
ip && request.headers.set("X-Forwarded-For", ip);
}
let response = await NATIVE_FETCH(request, init);
if (response.status !== 200) return EventBus.Script.emit("xcloudServerUnavailable", {}), response;
if (response.status !== 200) return BxEventBus.Script.emit("xcloudServerUnavailable", {}), response;
let obj = await response.clone().json();
RemotePlayManager.getInstance()?.setXcloudToken(obj.gsToken);
let serverRegex = /\/\/(\w+)\./, serverExtra = XcloudInterceptor.SERVER_EXTRA_INFO, region;
@ -7776,7 +7777,7 @@ class XcloudInterceptor {
else region.contintent = "other";
region.shortName = shortName.toUpperCase(), STATES.serverRegions[region.name] = Object.assign({}, region);
}
EventBus.Script.emit("xcloudServerReady", {});
BxEventBus.Script.emit("xcloudServerReady", {});
let preferredRegion = getPreferredServerRegion();
if (preferredRegion && preferredRegion in STATES.serverRegions) {
let tmp = Object.assign({}, STATES.serverRegions[preferredRegion]);
@ -7785,7 +7786,7 @@ class XcloudInterceptor {
return STATES.gsToken = obj.gsToken, response.json = () => Promise.resolve(obj), response;
}
static async handlePlay(request, init) {
EventBus.Stream.emit("stateLoading", {});
BxEventBus.Stream.emit("stateLoading", {});
let PREF_STREAM_TARGET_RESOLUTION = getPref("stream.video.resolution"), PREF_STREAM_PREFERRED_LOCALE = getPref("stream.locale"), url = typeof request === "string" ? request : request.url, parsedUrl = new URL(url), badgeRegion = parsedUrl.host.split(".", 1)[0];
for (let regionName in STATES.serverRegions) {
let region = STATES.serverRegions[regionName];
@ -7823,7 +7824,7 @@ class XcloudInterceptor {
else TouchController.enable();
let response = await NATIVE_FETCH(request, init), text = await response.clone().text();
if (!text.length) return response;
EventBus.Stream.emit("stateStarting", {});
BxEventBus.Stream.emit("stateStarting", {});
let obj = JSON.parse(text), overrides = JSON.parse(obj.clientStreamingConfigOverrides || "{}") || {};
overrides.inputConfiguration = overrides.inputConfiguration || {}, overrides.inputConfiguration.enableVibration = !0;
let overrideMkb = null;
@ -8087,7 +8088,7 @@ function patchHistoryMethod(type) {
}
function onHistoryChanged(e) {
if (e && e.arguments && e.arguments[0] && e.arguments[0].origin === "better-xcloud") return;
window.setTimeout(RemotePlayManager.detect, 10), NavigationDialogManager.getInstance().hide(), LoadingScreen.reset(), window.setTimeout(HeaderSection.watchHeader, 2000), EventBus.Stream.emit("stateStopped", {});
window.setTimeout(RemotePlayManager.detect, 10), NavigationDialogManager.getInstance().hide(), LoadingScreen.reset(), window.setTimeout(HeaderSection.watchHeader, 2000), BxEventBus.Stream.emit("stateStopped", {});
}
function setCodecPreferences(sdp, preferredCodec) {
let h264Pattern = /a=fmtp:(\d+).*profile-level-id=([0-9a-f]{6})/g, profilePrefix = preferredCodec === "high" ? "4d" : preferredCodec === "low" ? "420" : "42e", preferredCodecIds = [], matches = sdp.matchAll(h264Pattern) || [];
@ -8444,7 +8445,7 @@ function patchVideoApi() {
contrast: getPref("video.contrast"),
brightness: getPref("video.brightness")
};
STATES.currentStream.streamPlayer = new StreamPlayer(this, getPref("video.player.type"), playerOptions), EventBus.Stream.emit("statePlaying", {
STATES.currentStream.streamPlayer = new StreamPlayer(this, getPref("video.player.type"), playerOptions), BxEventBus.Stream.emit("statePlaying", {
$video: this
});
}, nativePlay = HTMLMediaElement.prototype.play;
@ -9000,7 +9001,7 @@ class StreamUiHandler {
if (!($elm instanceof HTMLElement)) return;
let className = $elm.className || "";
if (className.includes("PureErrorPage")) {
EventBus.Stream.emit("stateError", {});
BxEventBus.Stream.emit("stateError", {});
return;
}
if (className.startsWith("StreamMenu-module__container")) {
@ -9128,7 +9129,7 @@ class DeviceVibrationManager {
this.boundOnMessage = this.onMessage.bind(this), window.addEventListener(BxEvent.DATA_CHANNEL_CREATED, (e) => {
let dataChannel = e.dataChannel;
if (dataChannel?.label === "input") this.reset(), this.dataChannel = dataChannel, this.setupDataChannel();
}), EventBus.Script.on("deviceVibrationUpdated", () => this.setupDataChannel());
}), BxEventBus.Script.on("deviceVibrationUpdated", () => this.setupDataChannel());
}
setupDataChannel() {
if (!this.dataChannel) return;
@ -9218,25 +9219,25 @@ window.addEventListener(BxEvent.POPSTATE, onHistoryChanged);
window.addEventListener("popstate", onHistoryChanged);
window.history.pushState = patchHistoryMethod("pushState");
window.history.replaceState = patchHistoryMethod("replaceState");
EventBus.Script.on("xcloudServerUnavailable", () => {
if (EventBus.Script.off("xcloudServerUnavailable", null), STATES.supportedRegion = !1, window.setTimeout(HeaderSection.watchHeader, 2000), document.querySelector("div[class^=UnsupportedMarketPage-module__container]")) SettingsDialog.getInstance().show();
BxEventBus.Script.on("xcloudServerUnavailable", () => {
if (BxEventBus.Script.off("xcloudServerUnavailable", null), STATES.supportedRegion = !1, window.setTimeout(HeaderSection.watchHeader, 2000), document.querySelector("div[class^=UnsupportedMarketPage-module__container]")) SettingsDialog.getInstance().show();
});
EventBus.Script.on("xcloudServerReady", () => {
BxEventBus.Script.on("xcloudServerReady", () => {
STATES.isSignedIn = !0, window.setTimeout(HeaderSection.watchHeader, 2000);
});
EventBus.Stream.on("stateLoading", () => {
BxEventBus.Stream.on("stateLoading", () => {
if (window.location.pathname.includes("/launch/") && STATES.currentStream.titleInfo) STATES.currentStream.titleSlug = productTitleToSlug(STATES.currentStream.titleInfo.product.title);
else STATES.currentStream.titleSlug = "remote-play";
});
getPref("loadingScreen.gameArt.show") && EventBus.Script.on("titleInfoReady", LoadingScreen.setup);
EventBus.Stream.on("stateStarting", () => {
getPref("loadingScreen.gameArt.show") && BxEventBus.Script.on("titleInfoReady", LoadingScreen.setup);
BxEventBus.Stream.on("stateStarting", () => {
LoadingScreen.hide();
{
let cursorHider = MouseCursorHider.getInstance();
if (cursorHider) cursorHider.start(), cursorHider.hide();
}
});
EventBus.Stream.on("statePlaying", (payload) => {
BxEventBus.Stream.on("statePlaying", (payload) => {
window.BX_STREAM_SETTINGS = StreamSettings.settings, StreamSettings.refreshAllSettings(), STATES.isPlaying = !0, StreamUiHandler.observe();
{
let gameBar = GameBar.getInstance();
@ -9247,8 +9248,8 @@ EventBus.Stream.on("statePlaying", (payload) => {
}
updateVideoPlayer();
});
EventBus.Stream.on("stateError", () => {
EventBus.Stream.emit("stateStopped", {});
BxEventBus.Stream.on("stateError", () => {
BxEventBus.Stream.emit("stateStopped", {});
});
window.addEventListener(BxEvent.XCLOUD_RENDERING_COMPONENT, (e) => {
if (e.component === "product-detail") ProductDetailsPage.injectButtons();
@ -9273,9 +9274,9 @@ function unload() {
if (!STATES.isPlaying) return;
KeyboardShortcutHandler.getInstance().stop(), EmulatedMkbHandler.getInstance()?.destroy(), NativeMkbHandler.getInstance()?.destroy(), DeviceVibrationManager.getInstance()?.reset(), STATES.currentStream.streamPlayer?.destroy(), STATES.isPlaying = !1, STATES.currentStream = {}, window.BX_EXPOSED.shouldShowSensorControls = !1, window.BX_EXPOSED.stopTakRendering = !1, NavigationDialogManager.getInstance().hide(), StreamStats.getInstance().destroy(), StreamBadges.getInstance().destroy(), MouseCursorHider.getInstance()?.stop(), TouchController.reset(), GameBar.getInstance()?.disable();
}
EventBus.Stream.on("stateStopped", unload);
BxEventBus.Stream.on("stateStopped", unload);
window.addEventListener("pagehide", (e) => {
EventBus.Stream.emit("stateStopped", {});
BxEventBus.Stream.emit("stateStopped", {});
});
window.addEventListener(BxEvent.CAPTURE_SCREENSHOT, (e) => {
ScreenshotManager.getInstance().takeScreenshot();

View File

@ -44,7 +44,7 @@ import { StreamSettings } from "./utils/stream-settings";
import { KeyboardShortcutHandler } from "./modules/mkb/keyboard-shortcut-handler";
import { GhPagesUtils } from "./utils/gh-pages";
import { DeviceVibrationManager } from "./modules/device-vibration-manager";
import { EventBus } from "./utils/event-bus";
import { BxEventBus } from "./utils/bx-event-bus";
// Handle login page
if (window.location.pathname.includes('/auth/msa')) {
@ -191,8 +191,8 @@ window.addEventListener('popstate', onHistoryChanged);
window.history.pushState = patchHistoryMethod('pushState');
window.history.replaceState = patchHistoryMethod('replaceState');
EventBus.Script.on('xcloudServerUnavailable', () => {
EventBus.Script.off('xcloudServerUnavailable', null);
BxEventBus.Script.on('xcloudServerUnavailable', () => {
BxEventBus.Script.off('xcloudServerUnavailable', null);
STATES.supportedRegion = false;
window.setTimeout(HeaderSection.watchHeader, 2000);
@ -204,12 +204,12 @@ EventBus.Script.on('xcloudServerUnavailable', () => {
}
});
EventBus.Script.on('xcloudServerReady', () => {
BxEventBus.Script.on('xcloudServerReady', () => {
STATES.isSignedIn = true;
window.setTimeout(HeaderSection.watchHeader, 2000);
});
EventBus.Stream.on('stateLoading', () => {
BxEventBus.Stream.on('stateLoading', () => {
// Get title ID for screenshot's name
if (window.location.pathname.includes('/launch/') && STATES.currentStream.titleInfo) {
STATES.currentStream.titleSlug = productTitleToSlug(STATES.currentStream.titleInfo.product.title);
@ -219,9 +219,9 @@ EventBus.Stream.on('stateLoading', () => {
});
// Setup loading screen
getPref(PrefKey.LOADING_SCREEN_GAME_ART) && EventBus.Script.on('titleInfoReady', LoadingScreen.setup);
getPref(PrefKey.LOADING_SCREEN_GAME_ART) && BxEventBus.Script.on('titleInfoReady', LoadingScreen.setup);
EventBus.Stream.on('stateStarting', () => {
BxEventBus.Stream.on('stateStarting', () => {
// Hide loading screen
LoadingScreen.hide();
@ -235,7 +235,7 @@ EventBus.Stream.on('stateStarting', () => {
}
});
EventBus.Stream.on('statePlaying', payload => {
BxEventBus.Stream.on('statePlaying', payload => {
window.BX_STREAM_SETTINGS = StreamSettings.settings;
StreamSettings.refreshAllSettings();
@ -265,8 +265,8 @@ EventBus.Stream.on('statePlaying', payload => {
updateVideoPlayer();
});
EventBus.Stream.on('stateError', () => {
EventBus.Stream.emit('stateStopped', {});
BxEventBus.Stream.on('stateError', () => {
BxEventBus.Stream.emit('stateStopped', {});
});
isFullVersion() && window.addEventListener(BxEvent.XCLOUD_RENDERING_COMPONENT, e => {
@ -343,9 +343,9 @@ function unload() {
}
}
EventBus.Stream.on('stateStopped', unload);
BxEventBus.Stream.on('stateStopped', unload);
window.addEventListener('pagehide', e => {
EventBus.Stream.emit('stateStopped', {});
BxEventBus.Stream.emit('stateStopped', {});
});
isFullVersion() && window.addEventListener(BxEvent.CAPTURE_SCREENSHOT, e => {

View File

@ -1,7 +1,7 @@
import { AppInterface, STATES } from "@utils/global";
import { BxEvent } from "@utils/bx-event";
import { StreamSettings } from "@/utils/stream-settings";
import { EventBus } from "@/utils/event-bus";
import { BxEventBus } from "@/utils/bx-event-bus";
const VIBRATION_DATA_MAP = {
gamepadIndex: 8,
@ -48,7 +48,7 @@ export class DeviceVibrationManager {
}
});
EventBus.Script.on('deviceVibrationUpdated', () => this.setupDataChannel());
BxEventBus.Script.on('deviceVibrationUpdated', () => this.setupDataChannel());
}
private setupDataChannel() {

View File

@ -18,7 +18,7 @@ import { MkbPopup } from "./mkb-popup";
import type { MkbConvertedPresetData } from "@/types/presets";
import { StreamSettings } from "@/utils/stream-settings";
import { ShortcutAction } from "@/enums/shortcut-actions";
import { EventBus } from "@/utils/event-bus";
import { BxEventBus } from "@/utils/bx-event-bus";
const PointerToMouseButton = {
1: 0,
@ -640,7 +640,7 @@ export class EmulatedMkbHandler extends MkbHandler {
static setupEvents() {
if (isFullVersion()) {
EventBus.Stream.on('statePlaying', () => {
BxEventBus.Stream.on('statePlaying', () => {
if (STATES.currentStream.titleInfo?.details.hasMkbSupport) {
// Enable native MKB in Android app
NativeMkbHandler.getInstance()?.init();
@ -650,7 +650,7 @@ export class EmulatedMkbHandler extends MkbHandler {
});
if (EmulatedMkbHandler.isAllowed()) {
EventBus.Script.on('mkbSettingUpdated', () => {
BxEventBus.Script.on('mkbSettingUpdated', () => {
EmulatedMkbHandler.getInstance()?.refreshPresetData();
});
}

View File

@ -6,7 +6,7 @@ import type { MkbHandler } from "./base-mkb-handler";
import { NativeMkbHandler } from "./native-mkb-handler";
import { StreamSettings } from "@/utils/stream-settings";
import { KeyHelper } from "./key-helper";
import { EventBus } from "@/utils/event-bus";
import { BxEventBus } from "@/utils/bx-event-bus";
type MkbPopupType = 'virtual' | 'native';
@ -24,7 +24,7 @@ export class MkbPopup {
constructor() {
this.render();
EventBus.Script.on('keyboardShortcutsUpdated', () => {
BxEventBus.Script.on('keyboardShortcutsUpdated', () => {
const $newButton = this.createActivateButton();
this.$btnActivate.replaceWith($newButton);
this.$btnActivate = $newButton;

View File

@ -6,7 +6,7 @@ import { getPref } from "@/utils/settings-storages/global-settings-storage"
import { StreamStatsCollector, type StreamStatGrade } from "@/utils/stream-stats-collector"
import { BxLogger } from "@/utils/bx-logger"
import { StreamStat } from "@/enums/pref-values"
import { EventBus } from "@/utils/event-bus"
import { BxEventBus } from "@/utils/bx-event-bus"
export class StreamStats {
@ -230,7 +230,7 @@ export class StreamStats {
}
static setupEvents() {
EventBus.Stream.on('statePlaying', () => {
BxEventBus.Stream.on('statePlaying', () => {
const PREF_STATS_QUICK_GLANCE = getPref(PrefKey.STATS_QUICK_GLANCE_ENABLED);
const PREF_STATS_SHOW_WHEN_PLAYING = getPref(PrefKey.STATS_SHOW_WHEN_PLAYING);

View File

@ -5,7 +5,7 @@ import { t } from "@utils/translation.ts";
import { StreamBadges } from "./stream-badges.ts";
import { StreamStats } from "./stream-stats.ts";
import { SettingsDialog } from "../ui/dialog/settings-dialog.ts";
import { EventBus } from "@/utils/event-bus.ts";
import { BxEventBus } from "@/utils/bx-event-bus.ts";
export class StreamUiHandler {
@ -243,7 +243,7 @@ export class StreamUiHandler {
// Error Page: .PureErrorPage.ErrorScreen
if (className.includes('PureErrorPage')) {
EventBus.Stream.emit('stateError', {});
BxEventBus.Stream.emit('stateError', {});
return;
}

View File

@ -30,7 +30,7 @@ import { SuggestionsSetting } from "./settings/suggestions";
import { StreamSettings } from "@/utils/stream-settings";
import { MkbExtraSettings } from "./settings/mkb-extra";
import { BxExposed } from "@/utils/bx-exposed";
import { EventBus } from "@/utils/event-bus";
import { BxEventBus } from "@/utils/bx-event-bus";
type SettingTabSectionItem = Partial<{
@ -436,7 +436,7 @@ export class SettingsDialog extends NavigationDialog {
onCreated: (setting: SettingTabSectionItem, $elm: HTMLElement) => {
const $range = $elm.querySelector<HTMLInputElement>('input[type=range')!;
EventBus.Script.on('settingChanged', payload => {
BxEventBus.Script.on('settingChanged', payload => {
const { storageKey, settingKey, settingValue } = payload;
if (storageKey === StorageKey.GLOBAL && settingKey === PrefKey.AUDIO_VOLUME) {
$range.value = settingValue;

View File

@ -30,6 +30,7 @@ declare global {
BX_FETCH: typeof window['fetch'];
BxEvent: typeof BxEvent;
BxEventBus: typeof BxEventBus;
BxLogger: typeof BxLogger;
localRedirect: (path: stringn) => void;
testTouchLayout: (layout: any) => void;

View File

@ -31,11 +31,11 @@ type StreamEvents = {
stateError: {};
};
export class EventBus<TEvents extends Record<string, any>> {
export class BxEventBus<TEvents extends Record<string, any>> {
private listeners: Map<keyof TEvents, Set<EventCallback<any>>> = new Map();
static readonly Script = new EventBus<ScriptEvents>();
static readonly Stream = new EventBus<StreamEvents>();
static readonly Script = new BxEventBus<ScriptEvents>();
static readonly Stream = new BxEventBus<StreamEvents>();
on<K extends keyof TEvents>(event: K, callback: EventCallback<TEvents[K]>): void {
if (!this.listeners.has(event)) {
@ -79,3 +79,5 @@ export class EventBus<TEvents extends Record<string, any>> {
}
}
}
window.BxEventBus = BxEventBus;

View File

@ -11,7 +11,7 @@ import { GamePassCloudGallery } from "@/enums/game-pass-gallery";
import { TouchController } from "@/modules/touch-controller";
import { NativeMkbMode, TouchControllerMode } from "@/enums/pref-values";
import { Patcher, type PatchPage } from "@/modules/patcher/patcher";
import { EventBus } from "./event-bus";
import { BxEventBus } from "./bx-event-bus";
export enum SupportedInputType {
CONTROLLER = 'Controller',
@ -139,7 +139,7 @@ export const BxExposed = {
// Save this info in STATES
STATES.currentStream.titleInfo = titleInfo;
EventBus.Script.emit('titleInfoReady', {});
BxEventBus.Script.emit('titleInfoReady', {});
return titleInfo;
},

View File

@ -1,7 +1,7 @@
import { StorageKey } from "@/enums/pref-keys";
import { NATIVE_FETCH } from "./bx-flags";
import { BxLogger } from "./bx-logger";
import { EventBus } from "./event-bus";
import { BxEventBus } from "./bx-event-bus";
export type ForceNativeMkbResponse = {
@ -53,7 +53,7 @@ export class GhPagesUtils {
if (json.$schemaVersion === supportedSchema) {
// Save to storage
window.localStorage.setItem(key, JSON.stringify(json));
EventBus.Script.emit('listForcedNativeMkbUpdated', {});
BxEventBus.Script.emit('listForcedNativeMkbUpdated', {});
}
});

View File

@ -2,7 +2,7 @@ import { BxEvent } from "@utils/bx-event";
import { LoadingScreen } from "@modules/loading-screen";
import { RemotePlayManager } from "@/modules/remote-play-manager";
import { HeaderSection } from "@/modules/ui/header";
import { EventBus } from "./event-bus";
import { BxEventBus } from "./bx-event-bus";
import { NavigationDialogManager } from "@/modules/ui/dialog/navigation-dialog";
export function patchHistoryMethod(type: 'pushState' | 'replaceState') {
@ -33,5 +33,5 @@ export function onHistoryChanged(e: PopStateEvent) {
LoadingScreen.reset();
window.setTimeout(HeaderSection.watchHeader, 2000);
EventBus.Stream.emit('stateStopped', {});
BxEventBus.Stream.emit('stateStopped', {});
}

View File

@ -7,7 +7,7 @@ import { PrefKey } from "@/enums/pref-keys";
import { getPref, getPrefDefinition } from "./settings-storages/global-settings-storage";
import { CodecProfile } from "@/enums/pref-values";
import type { SettingDefinition } from "@/types/setting-definition";
import { EventBus } from "./event-bus";
import { BxEventBus } from "./bx-event-bus";
export function patchVideoApi() {
const PREF_SKIP_SPLASH_VIDEO = getPref(PrefKey.UI_SKIP_SPLASH_VIDEO);
@ -28,7 +28,7 @@ export function patchVideoApi() {
} satisfies StreamPlayerOptions;
STATES.currentStream.streamPlayer = new StreamPlayer(this, getPref(PrefKey.VIDEO_PLAYER_TYPE), playerOptions);
EventBus.Stream.emit('statePlaying', {
BxEventBus.Stream.emit('statePlaying', {
$video: this,
})
}

View File

@ -2,7 +2,7 @@ import type { PrefKey, StorageKey } from "@/enums/pref-keys";
import type { NumberStepperParams, SettingAction, SettingDefinitions } from "@/types/setting-definition";
import { t } from "../translation";
import { SCRIPT_VARIANT } from "../global";
import { EventBus } from "../event-bus";
import { BxEventBus } from "../bx-event-bus";
export class BaseSettingsStore {
private storage: Storage;
@ -93,7 +93,7 @@ export class BaseSettingsStore {
this.settings[key] = this.validateValue('get', key, value);
this.saveSettings();
emitEvent && EventBus.Script.emit('settingChanged', {
emitEvent && BxEventBus.Script.emit('settingChanged', {
storageKey: this.storageKey,
settingKey: key,
settingValue: value,

View File

@ -12,7 +12,7 @@ import { CodecProfile, StreamResolution, TouchControllerMode, TouchControllerSty
import { MkbMappingDefaultPresetId } from "../local-db/mkb-mapping-presets-table";
import { KeyboardShortcutDefaultId } from "../local-db/keyboard-shortcuts-table";
import { GhPagesUtils } from "../gh-pages";
import { EventBus } from "../event-bus";
import { BxEventBus } from "../bx-event-bus";
function getSupportedCodecProfiles() {
@ -432,7 +432,7 @@ export class GlobalSettingsStorage extends BaseSettingsStorage {
if (!setting.unsupported) {
(setting as any).multipleOptions = GhPagesUtils.getNativeMkbCustomList(true);
EventBus.Script.on('listForcedNativeMkbUpdated', () => {
BxEventBus.Script.on('listForcedNativeMkbUpdated', () => {
(setting as any).multipleOptions = GhPagesUtils.getNativeMkbCustomList();
});
}

View File

@ -13,7 +13,7 @@ import { MkbPresetKey, MouseConstant } from "@/enums/mkb";
import { KeyboardShortcutDefaultId, KeyboardShortcutsTable } from "./local-db/keyboard-shortcuts-table";
import { ShortcutAction } from "@/enums/shortcut-actions";
import { KeyHelper } from "@/modules/mkb/key-helper";
import { EventBus } from "./event-bus";
import { BxEventBus } from "./bx-event-bus";
export type StreamSettingsData = {
@ -110,7 +110,7 @@ export class StreamSettings {
}
StreamSettings.settings.deviceVibrationIntensity = intensity;
EventBus.Script.emit('deviceVibrationUpdated', {});
BxEventBus.Script.emit('deviceVibrationUpdated', {});
}
static async refreshMkbSettings() {
@ -148,7 +148,7 @@ export class StreamSettings {
settings.mkbPreset = converted;
setPref(PrefKey.MKB_P1_MAPPING_PRESET_ID, orgPreset.id);
EventBus.Script.emit('mkbSettingUpdated', {});
BxEventBus.Script.emit('mkbSettingUpdated', {});
}
static async refreshKeyboardShortcuts() {
@ -159,7 +159,7 @@ export class StreamSettings {
settings.keyboardShortcuts = null;
setPref(PrefKey.KEYBOARD_SHORTCUTS_IN_GAME_PRESET_ID, presetId);
EventBus.Script.emit('keyboardShortcutsUpdated', {});
BxEventBus.Script.emit('keyboardShortcutsUpdated', {});
return;
}
@ -179,7 +179,7 @@ export class StreamSettings {
settings.keyboardShortcuts = converted;
setPref(PrefKey.KEYBOARD_SHORTCUTS_IN_GAME_PRESET_ID, orgPreset.id);
EventBus.Script.emit('keyboardShortcutsUpdated', {});
BxEventBus.Script.emit('keyboardShortcutsUpdated', {});
}
static async refreshAllSettings() {

View File

@ -4,7 +4,7 @@ import { humanFileSize, secondsToHm } from "./html";
import { getPref } from "./settings-storages/global-settings-storage";
import { BxLogger } from "./bx-logger";
import { StreamStat } from "@/enums/pref-values";
import { EventBus } from "./event-bus";
import { BxEventBus } from "./bx-event-bus";
export type StreamStatGrade = '' | 'bad' | 'ok' | 'good';
@ -310,7 +310,7 @@ export class StreamStatsCollector {
}
static setupEvents() {
EventBus.Stream.on('statePlaying', () => {
BxEventBus.Stream.on('statePlaying', () => {
StreamStatsCollector.getInstance().reset();
});
}

View File

@ -12,7 +12,7 @@ import { BypassServerIps } from "@/enums/bypass-servers";
import { PrefKey } from "@/enums/pref-keys";
import { getPref } from "./settings-storages/global-settings-storage";
import { NativeMkbMode, StreamResolution, TouchControllerMode } from "@/enums/pref-values";
import { EventBus } from "./event-bus";
import { BxEventBus } from "./bx-event-bus";
export class XcloudInterceptor {
private static readonly SERVER_EXTRA_INFO: Record<string, [string, ServerContinent]> = {
@ -52,7 +52,7 @@ export class XcloudInterceptor {
const response = await NATIVE_FETCH(request, init);
if (response.status !== 200) {
// Unsupported region
EventBus.Script.emit('xcloudServerUnavailable', {});
BxEventBus.Script.emit('xcloudServerUnavailable', {});
return response;
}
@ -89,7 +89,7 @@ export class XcloudInterceptor {
STATES.serverRegions[region.name] = Object.assign({}, region);
}
EventBus.Script.emit('xcloudServerReady', {});
BxEventBus.Script.emit('xcloudServerReady', {});
const preferredRegion = getPreferredServerRegion();
if (preferredRegion && preferredRegion in STATES.serverRegions) {
@ -107,7 +107,7 @@ export class XcloudInterceptor {
}
private static async handlePlay(request: RequestInfo | URL, init?: RequestInit) {
EventBus.Stream.emit('stateLoading', {});
BxEventBus.Stream.emit('stateLoading', {});
const PREF_STREAM_TARGET_RESOLUTION = getPref<StreamResolution>(PrefKey.STREAM_RESOLUTION);
const PREF_STREAM_PREFERRED_LOCALE = getPref<StreamPreferredLocale>(PrefKey.STREAM_PREFERRED_LOCALE);
@ -189,7 +189,7 @@ export class XcloudInterceptor {
return response;
}
EventBus.Stream.emit('stateStarting', {});
BxEventBus.Stream.emit('stateStarting', {});
const obj = JSON.parse(text);
let overrides = JSON.parse(obj.clientStreamingConfigOverrides || '{}') || {};

View File

@ -9,7 +9,7 @@ import { getPref } from "./settings-storages/global-settings-storage";
import type { RemotePlayConsoleAddresses } from "@/types/network";
import { RemotePlayManager } from "@/modules/remote-play-manager";
import { StreamResolution, TouchControllerMode } from "@/enums/pref-values";
import { EventBus } from "./event-bus";
import { BxEventBus } from "./bx-event-bus";
export class XhomeInterceptor {
private static consoleAddrs: RemotePlayConsoleAddresses = {};
@ -36,7 +36,7 @@ export class XhomeInterceptor {
}
private static async handleConfiguration(request: Request | URL) {
EventBus.Stream.emit('stateStarting', {});
BxEventBus.Stream.emit('stateStarting', {});
const response = await NATIVE_FETCH(request);
const obj = await response.clone().json();
@ -125,7 +125,7 @@ export class XhomeInterceptor {
}
private static async handlePlay(request: RequestInfo | URL) {
EventBus.Stream.emit('stateLoading', {});
BxEventBus.Stream.emit('stateLoading', {});
const clone = (request as Request).clone();
const body = await clone.json();