160 lines
5.6 KiB
TypeScript
160 lines
5.6 KiB
TypeScript
// Metro module 4360 (f4361).
|
|
import { isDetectionEnabled } from "../game_detection/RunningGameStore.native";
|
|
import { DistributorNames, Distributors } from "../../Constants";
|
|
import { RobloxMetadataKeys, ROBLOX_APPLICATION_ID, NativeRobloxSubgameKeys, ROBLOX_GAME_ID } from "./RobloxSubgameTypes";
|
|
import Module12 from "../../_bundle/Module12";
|
|
import RobloxSubgamePlatformUtils_native from "./RobloxSubgamePlatformUtils.native";
|
|
import openURL from "../../lib/openURL";
|
|
export function keyForRobloxGame(a0) {
|
|
const distributor = a0.distributor;
|
|
const ROBLOX = Distributors.ROBLOX;
|
|
let r9 = null;
|
|
if (distributor === ROBLOX) {
|
|
const r1 = a0.sku != null;
|
|
r9 = null;
|
|
if (r1) {
|
|
const { sku, gameMetadata } = a0;
|
|
let r13 = gameMetadata == null ? void 0 : gameMetadata[RobloxMetadataKeys.PLACE_ID];
|
|
if (r13 == null) {
|
|
r13 = "";
|
|
}
|
|
r9 = `${sku}:${r13}`;
|
|
}
|
|
}
|
|
return r9;
|
|
}
|
|
export function hasRunningGameChanged(a0, a1, a2) {
|
|
let r5 = a0.distributor === Distributors.ROBLOX;
|
|
if (r5) {
|
|
let r4 = a2 != null && a0.id !== a2.id;
|
|
if (!r4) {
|
|
const distributor = a0.distributor;
|
|
const ROBLOX = Distributors.ROBLOX;
|
|
let r17 = null;
|
|
if (distributor === ROBLOX) {
|
|
const r0 = a0.gameMetadata == null;
|
|
r17 = null;
|
|
if (!r0) {
|
|
const r20 = a0.sku == null;
|
|
r17 = null;
|
|
if (!r20) {
|
|
let placeId = a0.gameMetadata[RobloxMetadataKeys.PLACE_ID];
|
|
if (placeId == null) {
|
|
placeId = null;
|
|
}
|
|
r17 = {
|
|
placeId,
|
|
universeId: a0.sku
|
|
};
|
|
}
|
|
}
|
|
}
|
|
r4 = r17 == null && a1 != null || (r17 != null && a1 == null || r17 != null && a1 != null && !Module12.isEqual(r17, a1));
|
|
}
|
|
r5 = r4;
|
|
}
|
|
return r5;
|
|
}
|
|
export function hasSubgameInfoChanged(a0, a1) {
|
|
return a0 == null && a1 != null || (a0 != null && a1 == null || a0 != null && a1 != null && !Module12.isEqual(a0, a1));
|
|
}
|
|
export function updateRunningGameWithRobloxSubgameInfo(a0, a1) {
|
|
const r4 = {
|
|
...a0
|
|
};
|
|
const { subgameInfo, application } = a1;
|
|
const r10 = Number;
|
|
const gameMetadata = a0.gameMetadata;
|
|
let start2 = r10(gameMetadata == null ? void 0 : gameMetadata[RobloxMetadataKeys.ROBLOX_TIME_STARTED]);
|
|
if (isNaN(start2) || start2 === 0) {
|
|
let start = a0.start;
|
|
if (start == null) {
|
|
start = Date.now();
|
|
}
|
|
start2 = start;
|
|
}
|
|
if (subgameInfo == null) {
|
|
if (a0.distributor === Distributors.ROBLOX && a0.id !== ROBLOX_APPLICATION_ID) {
|
|
r4.id = ROBLOX_APPLICATION_ID;
|
|
r4.name = DistributorNames[Distributors.ROBLOX];
|
|
}
|
|
r4.gameMetadata = void 0;
|
|
r4.sku = void 0;
|
|
r4.start = start2;
|
|
r4.lastFocused = Math.floor(start2 / 1000);
|
|
} else {
|
|
if (application != null && (isDetectionEnabled({
|
|
exePath: a0.exePath,
|
|
name: application.name,
|
|
id: application.id,
|
|
distributor: Distributors.ROBLOX
|
|
}) && isDetectionEnabled({
|
|
exePath: a0.exePath,
|
|
name: DistributorNames[Distributors.ROBLOX],
|
|
id: ROBLOX_APPLICATION_ID,
|
|
distributor: Distributors.ROBLOX
|
|
}))) {
|
|
r4.id = application.id;
|
|
r4.name = application.name;
|
|
r4.gameName = application.name;
|
|
r4.start = Date.now();
|
|
r4.lastFocused = Math.floor(Date.now() / 1000);
|
|
} else {
|
|
r4.id = ROBLOX_APPLICATION_ID;
|
|
r4.name = DistributorNames[Distributors.ROBLOX];
|
|
r4.start = start2;
|
|
}
|
|
const r74 = {};
|
|
r74[RobloxMetadataKeys.ROBLOX_TIME_STARTED] = start2.toString();
|
|
let universeId = subgameInfo.universeId;
|
|
if (universeId == null) {
|
|
universeId = void 0;
|
|
}
|
|
r4.sku = universeId;
|
|
if (subgameInfo.placeId != null) {
|
|
r74[RobloxMetadataKeys.PLACE_ID] = subgameInfo.placeId;
|
|
}
|
|
r4.gameMetadata = Object.keys(r74).length > 0 ? r74 : void 0;
|
|
}
|
|
return r4;
|
|
}
|
|
export function convertMapToRobloxSubgameInfo(a0) {
|
|
return a0[NativeRobloxSubgameKeys.UNIVERSE_ID] == null ? null : a0[NativeRobloxSubgameKeys.PLACE_ID] == null ? null : {
|
|
universeId: a0[NativeRobloxSubgameKeys.UNIVERSE_ID],
|
|
placeId: a0[NativeRobloxSubgameKeys.PLACE_ID]
|
|
};
|
|
}
|
|
export function getSubgameMetadata(a0) {
|
|
return a0.distributor === Distributors.ROBLOX ? a0.gameMetadata != null ? a0.gameMetadata[RobloxMetadataKeys.PLACE_ID] != null ? JSON.stringify({
|
|
placeId: a0.gameMetadata[RobloxMetadataKeys.PLACE_ID]
|
|
}) : null : null : null;
|
|
}
|
|
export function maybeAddAdditionalGameMetadata(a0) {
|
|
return a0.distributor === Distributors.ROBLOX && (a0.gameMetadata != null && (a0.gameMetadata[RobloxMetadataKeys.ROBLOX_TIME_STARTED] != null && (a0.id !== ROBLOX_APPLICATION_ID && a0.gameName != null))) ? {
|
|
name: a0.gameName,
|
|
sync_id: a0.gameMetadata[RobloxMetadataKeys.ROBLOX_TIME_STARTED]
|
|
} : {};
|
|
}
|
|
export function isRobloxSubgame(a0) {
|
|
return a0.distributor === Distributors.ROBLOX && a0.id !== ROBLOX_APPLICATION_ID;
|
|
}
|
|
export function isRobloxSubgameApplication(a0) {
|
|
return a0.thirdPartySkus.some((thirdPartySku) => thirdPartySku.distributor === Distributors.ROBLOX);
|
|
}
|
|
export function isRobloxSubgameGame(a0) {
|
|
return a0.id !== ROBLOX_GAME_ID && a0.thirdPartySkus.some((thirdPartySku) => thirdPartySku.distributor === Distributors.ROBLOX);
|
|
}
|
|
export async function openRobloxURLWithRootPlaceId(c25054_0) {
|
|
let c25054_2;
|
|
c25054_2 = void 0;
|
|
let c29317_0 = await RobloxSubgamePlatformUtils_native.getRobloxSubgameURL(c25054_0);
|
|
return await openURL(c29317_0);
|
|
}
|
|
export function maybeTransformRobloxSubgameToRoblox(a0) {
|
|
return a0.distributor === Distributors.ROBLOX ? a0.id !== ROBLOX_APPLICATION_ID ? {
|
|
...a0,
|
|
id: ROBLOX_APPLICATION_ID,
|
|
name: DistributorNames[Distributors.ROBLOX]
|
|
} : a0 : a0;
|
|
}
|