decord/source/stores/DetectableGameStore.tsx
2026-07-29 08:29:29 +00:00

765 lines
23 KiB
TypeScript

// Module ID: 4221
// Function ID: 4222
// Name: gameFromServer
// Dependencies: [4212, 676, 4215, 687, 4222, 595, 500, 4223, 589, 11, 1351, 1906, 698, 3862, 709, 2]
// Module 4221 (gameFromServer)
import createExecutable from "createExecutable";
import { createExecutable } from "createExecutable";
import { AnalyticEvents } from "ME";
import { ApplicationTypes } from "ApplicationTypes";
import { Storage } from "Storage";
import set from "set";
import { PersistedStore } from "initialize";
import set from "ApplicationTypes";
const require = arg1;
function gameFromServer(id) {
const obj = { id: id.id, name: id.name, executables: null, overlay: null, overlayWarn: null, overlayCompatibilityHook: null, hook: null, aliases: null, supportsOutOfProcessOverlay: null, themes: null, icon: null, thirdPartySkus: null, cover_image_hash: null, content_classification: null };
let executables = id.executables;
if (executables == null) {
executables = [];
}
obj[2] = executables.map(createExecutable);
let flag = id.overlay;
if (flag == null) {
flag = false;
}
obj[3] = flag;
let flag2 = id.overlay_warn;
if (flag2 == null) {
flag2 = false;
}
obj[4] = flag2;
let flag3 = id.overlay_compatibility_hook;
if (flag3 == null) {
flag3 = false;
}
obj[5] = flag3;
let flag4 = id.hook;
if (flag4 == null) {
flag4 = true;
}
obj[6] = flag4;
let aliases = id.aliases;
if (aliases == null) {
aliases = [];
}
obj[7] = aliases;
obj[8] = createExecutable.supportsOutOfProcessOverlay(id.overlay_methods);
let themes = id.themes;
if (themes == null) {
themes = [];
}
obj[9] = themes;
const icon_hash = id.icon_hash;
obj[10] = icon_hash;
let third_party_skus = id.third_party_skus;
if (third_party_skus == null) {
third_party_skus = [];
}
obj[11] = third_party_skus;
const cover_image_hash = id.cover_image_hash;
obj[12] = cover_image_hash;
const content_classification = id.content_classification;
obj[13] = content_classification;
return obj;
}
function convertGameRecordToGame(id) {
let thirdPartySkus;
const obj = { id: id.id, name: id.name, executables: id.executables, overlayWarn: id.overlayWarn, overlayCompatibilityHook: id.overlayCompatibilityHook, overlay: id.overlay, hook: id.hook, aliases: id.aliases, supportsOutOfProcessOverlay: id.supportsOutOfProcessOverlay, themes: null, icon: null, thirdPartySkus: null, cover_image_hash: null, content_classification: null };
let themes = id.themes;
if (themes == null) {
themes = [];
}
obj[9] = themes;
({ icon: obj[10], thirdPartySkus } = id);
if (thirdPartySkus == null) {
thirdPartySkus = [];
}
obj[11] = thirdPartySkus;
const cover_image_hash = id.cover_image_hash;
obj[12] = cover_image_hash;
const content_classification = id.content_classification;
obj[13] = content_classification;
return obj;
}
function addGameIdToNameCache(id, item10026) {
if (null == dependencyMap[item10026]) {
dependencyMap[item10026] = [];
}
let arr = dependencyMap[item10026];
arr = arr.push(id);
}
function addDetectableGame(id) {
let name;
let tmp = id;
if (id instanceof require(4223) /* GameTheme */.DetectableGameRecord) {
tmp = convertGameRecordToGame(id);
const tmp2 = convertGameRecordToGame;
}
const result = tmp2.set(id.id, tmp);
({ name, id } = tmp);
addGameIdToNameCache(id, name.toLowerCase());
for (const item10026 of tmp5) {
let tmp6 = addGameIdToNameCache;
let tmp7 = addGameIdToNameCache(tmp.id, item10026.toLowerCase());
continue;
}
if (obj.isDesktop()) {
const executables = id.executables;
for (const item10044 of executables) {
let tmp10 = closure_11;
closure_11[item10044.name] = tmp.id;
continue;
}
}
}
const GameStoreReportedGames = "GameStoreReportedGames";
const DAY = require("set").Millis.DAY;
let c9 = new require("keys")();
let closure_10 = Object.create(null);
let closure_11 = Object.create(null);
let set = Storage.get("GameStoreReportedGames");
if (set == null) {
let _Object = Object;
set = Object.create(null);
}
let c13 = "";
let c14;
let c15 = null;
let c16 = false;
let c17 = null;
let c18 = false;
let c19 = "";
let closure_20 = [];
let closure_21 = [];
const map = new Map();
const HOUR = require("set").Millis.HOUR;
set = new Set();
const set1 = new Set();
let str = "win32";
if (!set.isWindows()) {
let str2 = "darwin";
if (!obj2.isMac()) {
let str3 = null;
if (obj3.isLinux()) {
str3 = "linux";
}
str2 = str3;
obj3 = require("set");
}
str = str2;
obj2 = require("set");
}
class DetectableGameStore extends PersistedStore {
}
const prototype = DetectableGameStore.prototype;
prototype["initialize"] = function initialize(detectableGamesEtag) {
if (null != detectableGamesEtag) {
if (null != detectableGamesEtag.detectableGamesEtag) {
detectableGamesEtag = detectableGamesEtag.detectableGamesEtag;
}
if (null != detectableGamesEtag.blocklistEtag) {
const blocklistEtag = detectableGamesEtag.blocklistEtag;
}
if (null != detectableGamesEtag.blocklistExecutables) {
const blocklistExecutables = detectableGamesEtag.blocklistExecutables;
}
if (null != detectableGamesEtag.blocklistPatterns) {
const blocklistPatterns = detectableGamesEtag.blocklistPatterns;
let closure_21 = blocklistPatterns.map((arg0) => {
const regExp = new RegExp(arg0, "i");
return regExp;
});
}
const detectableGames = detectableGamesEtag.detectableGames;
if (detectableGames != null) {
const item = detectableGames.forEach((arg0) => {
callback(arg0);
});
}
}
};
prototype["getState"] = function getState() {
let obj = require(500) /* set */;
if (obj.isDesktop()) {
obj = { detectableGamesEtag: null, detectableGames: null, blocklistEtag: null, blocklistExecutables: null, blocklistPatterns: null };
obj[0] = c13;
obj[1] = tmp2.values();
obj[2] = c19;
obj[3] = closure_20;
obj[4] = closure_21.map((source) => source.source);
} else {
obj = { detectableGamesEtag: "", detectableGames: null, blocklistEtag: "", blocklistExecutables: null, blocklistPatterns: null };
obj[1] = [];
obj[3] = [];
obj[4] = [];
}
return obj;
};
Object.defineProperty(prototype, "games", {
get: function games() {
return tmp2.values();
},
set: undefined
});
prototype["getDetectableGame"] = function getDetectableGame(id) {
return tmp2.get(importDefault(11).cast(id));
};
prototype["searchGamesByName"] = function searchGamesByName(name) {
if (null == name) {
return [];
} else {
const formatted = name.toLowerCase();
const _Object = Object;
const call = hasOwnProperty.call;
if (typeof call === "unknown" ? hasOwnProperty(formatted) : call(dependencyMap, formatted)) {
let items = dependencyMap[formatted];
} else {
items = [];
}
return items;
}
};
prototype["findGame"] = function findGame(nextResult) {
let self = this;
const _require = nextResult;
let closure_1 = arg1;
self = this;
let detectableGame = this.getDetectableGame(nextResult.id);
if (null != detectableGame) {
return detectableGame;
} else {
if (null != nextResult.name) {
const searchGamesByNameResult = self.searchGamesByName(nextResult.name);
function _loop() {
const detectableGame = self.getDetectableGame(closure_4);
if (null == detectableGame) {
return 0;
} else if (null != closure_1) {
tmp5(detectableGame);
return 0;
} else if (null != nextResult.exePath) {
if (null != detectableGame.executables) {
const parts = tmp6.exePath.split("/");
const found = parts.filter(nextResult(outer1_2[10]).isNotNullish);
nextResult = found.pop();
const executables = detectableGame.executables;
if (executables.some((name) => name.name === closure_0)) {
const obj = { v: null };
obj[0] = detectableGame;
return obj;
}
const str = tmp6.exePath;
}
}
}
const iter = searchGamesByNameResult[Symbol.iterator]();
while (iter !== undefined) {
let closure_4 = iter.next();
let _loopResult = _loop();
if (0 !== _loopResult) {
let tmp8 = _loopResult;
if (tmp7) {
let tmp9 = iter;
iter.return();
return _loopResult.v;
}
}
continue;
}
}
if (null != nextResult.exePath) {
let parts = nextResult.exePath.split("/");
let found = parts.filter(_require(1351).isNotNullish);
const gameByExecutable = self.getGameByExecutable(found.pop());
if (null != gameByExecutable) {
return gameByExecutable;
} else {
const parts1 = nextResult.exePath.split("/");
const found1 = parts1.filter(tmp15(1351).isNotNullish);
const substr = found1.slice(-2);
const gameByExecutable1 = self.getGameByExecutable(substr.join("/"));
if (null != gameByExecutable1) {
return gameByExecutable1;
}
const str3 = nextResult.exePath;
}
let str = nextResult.exePath;
tmp15 = _require;
}
if (tmp11) {
const result = self.trackNameMatchFallback(nextResult.name, dependencyMap, nextResult.exePath);
}
return dependencyMap;
}
};
prototype["getOfficialGame"] = function getOfficialGame(type) {
let detectableGame = null;
if (null != type) {
if (type.type === ApplicationTypes.GAME) {
let id = type.id;
} else {
const linkedGames = type.linkedGames;
if (linkedGames != null) {
const found = linkedGames.find((type) => type.type === callback(table[11]).GameLinkTypes.OFFICIAL);
if (found != null) {
id = found.id;
}
}
}
detectableGame = null;
if (null != id) {
const self = this;
detectableGame = this.getDetectableGame(id);
}
}
return detectableGame;
};
prototype["getGameByApplication"] = function getGameByApplication(id) {
let self = this;
self = this;
const detectableGame = this.getDetectableGame(id.id);
if (null != detectableGame) {
return detectableGame;
} else {
let str = "none";
if (null != id.linkedGames) {
const linkedGames = id.linkedGames;
for (const item10014 of linkedGames) {
let detectableGame1 = self.getDetectableGame(item10014.id);
let tmp6 = detectableGame1;
if (null != detectableGame1) {
str = "linked_game";
tmp = detectableGame1;
let tmp7 = obj;
obj.return();
break;
}
break;
}
}
if (null == tmp) {
const mapped = self.searchGamesByName(id.name).map((id) => self.getDetectableGame(id));
const first = mapped.reverse()[0];
if (null != first) {
str = "name";
tmp = first;
}
const searchGamesByNameResult = self.searchGamesByName(id.name);
}
const result = self.maybeTrackApplicationLookupFallthrough(id, str, tmp);
return tmp;
}
};
prototype["isGameInDatabase"] = function isGameInDatabase(nativeProcessObserverId) {
let tmp = null != this.findGame(nativeProcessObserverId);
if (!tmp) {
let tmp2 = undefined !== nativeProcessObserverId.nativeProcessObserverId;
if (tmp2) {
tmp2 = !(2147483648 & nativeProcessObserverId.nativeProcessObserverId);
}
tmp = tmp2;
}
return tmp;
};
Object.defineProperty(prototype, "fetching", {
get: function fetching() {
return true === c14;
},
set: undefined
});
Object.defineProperty(prototype, "detectableGamesEtag", {
get: function detectableGamesEtag() {
return c13;
},
set: undefined
});
Object.defineProperty(prototype, "blocklistEtag", {
get: function blocklistEtag() {
return c19;
},
set: undefined
});
Object.defineProperty(prototype, "lastFetched", {
get: function lastFetched() {
return c15;
},
set: undefined
});
Object.defineProperty(prototype, "hasAttemptedFetch", {
get: function hasAttemptedFetch() {
return c16;
},
set: undefined
});
Object.defineProperty(prototype, "detectableGamesTtl", {
get: function detectableGamesTtl() {
return DAY;
},
set: undefined
});
prototype["canFetchDetectableGames"] = function canFetchDetectableGames() {
let tmp = true !== c14;
if (tmp) {
let tmp4 = null == c15;
if (!tmp4) {
const _Date = Date;
tmp4 = Date.now() >= c15 + DAY;
}
tmp = tmp4;
}
return tmp;
};
prototype["canFetchExecutableBlocklist"] = function canFetchExecutableBlocklist() {
let tmp = !c18;
if (!c18) {
let tmp4 = null == c17;
if (!tmp4) {
const _Date = Date;
tmp4 = Date.now() >= c17 + DAY;
}
tmp = tmp4;
}
return tmp;
};
prototype["getGameByExecutable"] = function getGameByExecutable(found) {
if (null != found) {
const self = this;
return this.getDetectableGame(table[found]);
}
};
prototype["shouldBlock"] = function shouldBlock(exePath) {
let closure_0 = exePath;
if (null != exePath.exePath) {
if ("" !== exePath.exePath) {
const self = this;
let closure_1 = exePath.exePath.toLowerCase();
if (null != exePath.id) {
if (null != str) {
const detectableGame = self.getDetectableGame(exePath.id);
if (null != detectableGame) {
const executables = detectableGame.executables;
if (executables.some((os) => {
let endsWithResult = os.os === outer1_26;
if (endsWithResult) {
endsWithResult = closure_1.endsWith(os.name.toLowerCase());
const str = os.name;
}
return endsWithResult;
})) {
return false;
}
}
}
}
const found = closure_20.find((arg0) => closure_1.includes(arg0));
if (null != found) {
self.maybeTrackBlock(exePath, "explicit_list", found);
return true;
} else {
const found1 = closure_21.find((test) => test.test(exePath.exePath));
let flag = null != found1;
if (flag) {
self.maybeTrackBlock(exePath, "pattern_match", found1.source);
flag = true;
}
return flag;
}
const str4 = exePath.exePath;
}
}
return false;
};
prototype["getBlockReason"] = function getBlockReason(exePath) {
let closure_0 = exePath;
if (null != exePath.exePath) {
if ("" !== exePath.exePath) {
let closure_1 = exePath.exePath.toLowerCase();
const found = closure_20.find((arg0) => closure_1.includes(arg0));
if (null != found) {
let obj = { matchedExe: null, matchedPattern: null };
obj[0] = found;
return obj;
} else {
const found1 = closure_21.find((test) => test.test(exePath.exePath));
let tmp5 = null;
if (null != found1) {
obj = { matchedExe: null, matchedPattern: null };
obj[1] = found1.source;
tmp5 = obj;
}
return tmp5;
}
const str = exePath.exePath;
}
}
return null;
};
prototype["maybeTrackApplicationLookupFallthrough"] = function maybeTrackApplicationLookupFallthrough(id, arg1, id2) {
id = id.id;
let obj = set;
if (!set.has(id)) {
obj.add(id);
obj = { application_id: null, application_name: null, match_type: null, matched_game_id: null, matched_game_name: null };
obj[0] = id;
let name = id.name;
if (name == null) {
name = null;
}
obj[1] = name;
obj[2] = arg1;
id = undefined;
if (id2 != null) {
id = id2.id;
}
if (id == null) {
id = null;
}
obj[3] = id;
let name1;
if (id2 != null) {
name1 = id2.name;
}
if (name1 == null) {
name1 = null;
}
obj[4] = name1;
importDefault(698).track(AnalyticEvents.GAME_APPLICATION_LOOKUP_FALLTHROUGH, obj);
const obj2 = importDefault(698);
}
};
prototype["trackNameMatchFallback"] = function trackNameMatchFallback(name, dependencyMap, exePath) {
const formatted = name.toLowerCase();
let obj = set1;
if (!set1.has(formatted)) {
obj.add(formatted);
let tmp5 = null != exePath;
if (tmp5) {
tmp5 = "" !== exePath;
}
obj = { matched_name: null, matched_game_id: null, exe_name: null, had_exe_path: null };
obj[0] = name;
obj[1] = dependencyMap.id;
let tmp10 = null;
if (tmp5) {
const parts = exePath.split(/[/\\]/);
let arr = parts.pop();
if (arr == null) {
arr = null;
}
tmp10 = arr;
}
obj[2] = tmp10;
obj[3] = tmp5;
importDefault(698).track(AnalyticEvents.GAME_NAME_MATCH_FALLBACK, obj);
const obj2 = importDefault(698);
}
};
prototype["maybeTrackBlock"] = function maybeTrackBlock(exePath, explicit_list, found) {
const parts = exePath.exePath.split(/[/\\]/);
let str2 = parts.pop();
if (str2 == null) {
str2 = "unknown";
}
let obj = map;
const value = map.get(str2);
const timestamp = Date.now();
let tmp3 = null == value;
if (!tmp3) {
tmp3 = timestamp - value >= HOUR;
}
if (tmp3) {
const result = obj.set(str2, timestamp);
obj = { block_type: null, matched_entry: null, game_name: null, executable_name: null };
obj[0] = explicit_list;
obj[1] = found;
let origGameName = exePath.gameName;
if (origGameName == null) {
origGameName = exePath.origGameName;
}
obj[2] = origGameName;
obj[3] = str2;
importDefault(698).track(AnalyticEvents.GAME_BLOCKLIST_TRIGGERED, obj);
const obj2 = importDefault(698);
}
};
prototype["shouldReport"] = function shouldReport(name) {
const self = this;
if (this.shouldBlock(name)) {
return false;
} else {
let tmp2 = null != self.findGame(name);
let tmp3 = null != name.name;
if (tmp3) {
tmp3 = null != obj[name.name];
}
const ShowCurrentGame = require(3862) /* explicitContentFromProto */.ShowCurrentGame;
let setting = ShowCurrentGame.getSetting();
if (setting) {
setting = !c14;
}
if (setting) {
if (!tmp2) {
tmp2 = tmp3;
}
setting = !tmp2;
}
return setting;
}
};
prototype["markGameReported"] = function markGameReported(arg0) {
obj[arg0] = true;
const Storage = require(595) /* Storage */.Storage;
const result = Storage.set(GameStoreReportedGames, obj);
};
DetectableGameStore.displayName = "GameStore";
DetectableGameStore.persistKey = "GameStore";
let items = [
(arg0) => {
let detectableGames;
if (null != arg0) {
let obj = { detectableGamesEtag: null, detectableGames: null };
({ detectableGamesEtag: obj2[0], detectableGames } = arg0);
let mapped;
if (detectableGames != null) {
mapped = detectableGames.map((aliases) => {
let thirdPartySkus;
const detectableGameRecord = new callback(table[7]).DetectableGameRecord(aliases);
const obj = { id: detectableGameRecord.id, name: detectableGameRecord.name, executables: detectableGameRecord.executables, overlayWarn: detectableGameRecord.overlayWarn, overlayCompatibilityHook: detectableGameRecord.overlayCompatibilityHook, overlay: detectableGameRecord.overlay, hook: detectableGameRecord.hook, aliases: detectableGameRecord.aliases, supportsOutOfProcessOverlay: detectableGameRecord.supportsOutOfProcessOverlay, themes: null, icon: null, thirdPartySkus: null, cover_image_hash: null, content_classification: null };
let themes = detectableGameRecord.themes;
if (themes == null) {
themes = [];
}
obj[9] = themes;
({ icon: obj[10], thirdPartySkus } = detectableGameRecord);
if (thirdPartySkus == null) {
thirdPartySkus = [];
}
obj[11] = thirdPartySkus;
const cover_image_hash = detectableGameRecord.cover_image_hash;
obj[12] = cover_image_hash;
const content_classification = detectableGameRecord.content_classification;
obj[13] = content_classification;
return obj;
});
}
if (mapped == null) {
mapped = [];
}
obj[1] = mapped;
} else {
obj = { detectableGamesEtag: "", detectableGames: null };
obj[1] = [];
}
return obj;
},
(arg0) => {
let tmp = arg0;
let obj = require(500) /* set */;
if (!obj.isDesktop()) {
obj = { detectableGamesEtag: "", detectableGames: null };
obj[1] = [];
tmp = obj;
}
return tmp;
},
() => ({ detectableGamesEtag: "", detectableGames: [] }),
(blocklistEtag) => {
const obj = {};
const merged = Object.assign(blocklistEtag);
let str = blocklistEtag.blocklistEtag;
if (str == null) {
str = "";
}
obj.blocklistEtag = str;
let blocklistExecutables = blocklistEtag.blocklistExecutables;
if (blocklistExecutables == null) {
blocklistExecutables = [];
}
obj.blocklistExecutables = blocklistExecutables;
let blocklistPatterns = blocklistEtag.blocklistPatterns;
if (blocklistPatterns == null) {
blocklistPatterns = [];
}
obj.blocklistPatterns = blocklistPatterns;
return obj;
}
];
DetectableGameStore.migrations = items;
set = {
OVERLAY_INITIALIZE: function handleOverlayInitialize(arg0) {
tmp2.clear();
let closure_10 = Object.create(null);
let closure_11 = Object.create(null);
tmp2 = arg0.detectableApplications[Symbol.iterator]();
while (tmp2 !== undefined) {
let tmp4 = addDetectableGame;
let tmp5 = addDetectableGame(tmp3);
continue;
}
},
GAMES_DATABASE_FETCH: function handleApplicationsFetch() {
let c14 = true;
},
GAMES_DATABASE_FETCH_FAIL: function handleApplicationsFetchFail() {
let c14 = false;
let c16 = true;
},
GAMES_DATABASE_UPDATE: function handleDetectableGamesUpdated(arg0) {
let etag;
let games;
({ games, etag } = arg0);
let tmp = null != etag;
if (tmp) {
tmp = etag !== etag;
}
if (tmp) {
tmp2.clear();
const _Object = Object;
let closure_10 = Object.create(null);
const _Object2 = Object;
let closure_11 = Object.create(null);
}
while (tmp6 !== undefined) {
let tmp8 = addDetectableGame;
let tmp9 = gameFromServer;
let tmp10 = addDetectableGame(gameFromServer(tmp7));
continue;
}
let c14;
let closure_15 = Date.now();
let c16 = true;
},
GAMES_BLOCKLIST_FETCH: function handleGamesBlocklistFetch() {
let c18 = true;
},
GAMES_BLOCKLIST_FETCH_FAIL: function handleGamesBlocklistFetchFail() {
let c18 = false;
},
GAMES_BLOCKLIST_UPDATE: function handleGamesBlocklistUpdated(arg0) {
let etag;
let executables;
let patterns;
({ executables, patterns, etag } = arg0);
let tmp = null != etag;
if (tmp) {
tmp = etag !== etag;
}
if (tmp) {
let closure_20 = executables.map((str) => str.toLowerCase());
let closure_21 = patterns.map((arg0) => {
const regExp = new RegExp(arg0, "i");
return regExp;
});
}
let c18 = false;
let closure_17 = Date.now();
}
};
const detectableGameStore = new DetectableGameStore(require("dispatcher"), set);
let result = set.fileFinishedImporting("stores/DetectableGameStore.tsx");
export default detectableGameStore;
export { gameFromServer };