This commit is contained in:
janisslsm committed 2026-11-01 12:12:55 +02:00
1 parent 1781d25a15
commit 732c0ad767
33051 files changed
+2591613 -3019689

No files matched your search

@@ -0,0 +1,87 @@
// Metro module 6171 (f6172).
import GameAutocompleteStore from "./GameAutocompleteStore";
import { Endpoints } from "../../../Constants";
import { normalizeGameAutocompleteQuery } from "./GameAutocompleteUtils";
import Dispatcher from "../../../Dispatcher";
import { HTTP } from "../../../_bundle/sendRequest";
export async function fetchGameAutocomplete(c25741_0) {
let body, c25741_2, c25741_3, c25741_4;
let c25741_5 = 0;
const r11 = void 0;
L17: {
try {
let env29682;
c25741_3 = r11;
const r29 = env29682 = {};
c25741_2 = r29;
env29682[0] = void 0;
env29682[1] = void 0;
const query = normalizeGameAutocompleteQuery(c25741_0);
env29682[0] = query;
if (query == null) {
break L17;
}
if (GameAutocompleteStore.shouldSuppressFetch(query)) {
Dispatcher.dispatch({
type: "GAME_AUTOCOMPLETE_FETCH_SUCCESS",
query,
results: []
});
break L17;
}
Dispatcher.dispatch({
type: "GAME_AUTOCOMPLETE_FETCH",
query
});
c25741_5 = 1;
const body2 = (await HTTP.get({
url: Endpoints.GAMES_AUTOCOMPLETE,
query: {
q: query
},
rejectWithError: false
})).body;
body = body2;
if (body2 == null) {
body = [];
}
env29682[1] = body.map((item) => ({
id: String(item.id),
name: item.name,
icon: item.icon
}));
Dispatcher.dispatch({
type: "GAME_AUTOCOMPLETE_FETCH_SUCCESS",
query: env29682[0],
results: env29682[1]
});
c25741_5 = 0;
} catch ($e) {
const r27 = $e;
let r8 = r27;
c25741_4 = r27;
if (c25741_5 !== 0) {
while (true) {
try {
const r96 = c25741_4;
c25741_5 = 0;
env29682[2] = r96;
Dispatcher.dispatch({
type: "GAME_AUTOCOMPLETE_FETCH_FAILURE",
query: env29682[0]
});
throw env29682[2];
} catch (r92) {
r8 = r92;
c25741_4 = r92;
if (c25741_5 === 0) {
break;
}
}
}
}
throw r8;
}
return void 0;
}
}
@@ -0,0 +1,74 @@
// Metro module 6160 (f6161).
import LRUCache from "../../../_bundle/LRUCache";
import Module589 from "../../../_bundle/Module589";
import { normalizeGameAutocompleteQuery, shouldSuppressAutocompleteFetch } from "./GameAutocompleteUtils";
import Dispatcher from "../../../Dispatcher";
let c3902_2 = new LRUCache({
max: 100
});
let c3902_3 = new Set();
let c3902_4 = new LRUCache({
max: 500
});
class GameAutocompleteStore extends Module589.Store {
static displayName = "GameAutocompleteStore";
getResults(a0) {
const r9 = normalizeGameAutocompleteQuery(a0);
return r9 == null ? void 0 : c3902_2.peek(r9);
}
getClosestResults(a0) {
const r15 = normalizeGameAutocompleteQuery(a0);
if (r15 != null) {
const r18 = c3902_2.peek(r15);
if (r18 != null) {
return r18;
}
let r0 = r15.length - 1;
while (1 <= r0) {
const r22 = c3902_2.peek(r15.slice(0, r0));
const r1 = r0;
if (r22 != null) {
return r22;
}
r0 = r1 - 1;
}
}
}
shouldSuppressFetch(a0) {
const r11 = normalizeGameAutocompleteQuery(a0);
let r12 = r11 != null;
if (r12) {
const r14 = c3902_2.has(r11);
r12 = (r14 ? !r14 : !c3902_3.has(r11)) && shouldSuppressAutocompleteFetch(r11, (a0) => c3902_2.peek(a0));
}
return r12;
}
isFetching(a0) {
const r8 = normalizeGameAutocompleteQuery(a0);
return r8 != null && c3902_3.has(r8);
}
getGameById(a0) {
return c3902_4.peek(a0);
}
}
const gameAutocompleteStore = new GameAutocompleteStore(Dispatcher, {
LOGOUT: function handleLogout() {
c3902_2.reset();
c3902_3 = new Set();
c3902_4.reset();
},
GAME_AUTOCOMPLETE_FETCH: function handleFetch(a0) {
c3902_3.add(a0.query);
},
GAME_AUTOCOMPLETE_FETCH_SUCCESS: function handleFetchSuccess({ query, results }) {
c3902_3.delete(query);
c3902_2.set(query, results);
for (const item of results) {
c3902_4.set(item.id, item);
}
},
GAME_AUTOCOMPLETE_FETCH_FAILURE: function handleFetchFailure(a0) {
c3902_3.delete(a0.query);
}
});
export default gameAutocompleteStore;
@@ -0,0 +1,26 @@
// Metro module 6161 (f6162).
import { GAME_WIDGET_BANNED_APPLICATION_IDS } from "../../../_bundle/Module5899";
export const GAME_AUTOCOMPLETE_MAX_QUERY_LENGTH = 100;
export const MIN_TRUSTED_EMPTY_PREFIX_LENGTH = 7;
export function shouldSuppressAutocompleteFetch(a0, a1) {
let r0 = a0.length - 1;
while (1 <= r0) {
const r12 = a1(a0.slice(0, r0));
const r1 = r0;
if (r12 != null) {
return !(r12.length > 0) && r1 >= 7;
}
r0 = r1 - 1;
}
return false;
}
export function normalizeGameAutocompleteQuery(a0) {
if (a0 == null) {
return null;
}
const r14 = a0.trim().toLowerCase().replaceAll("_", " ").slice(0, 100);
return r14.length > 0 ? r14 : null;
}
export function isGameAutocompleteResultAllowedInGameWidgets(a0) {
return !GAME_WIDGET_BANNED_APPLICATION_IDS.has(a0.id);
}
@@ -0,0 +1,25 @@
// Metro module 6169 (f6170).
import GameAutocompleteStore from "./GameAutocompleteStore";
import debounce from "../../../_bundle/debounce";
import { useGameAutocomplete, GAME_AUTOCOMPLETE_DEBOUNCE_MS, GAME_AUTOCOMPLETE_DEBOUNCE_MAX_WAIT_MS } from "./useGameAutocomplete";
import { normalizeGameAutocompleteQuery, isGameAutocompleteResultAllowedInGameWidgets } from "./GameAutocompleteUtils";
let c3910_3 = debounce((a0) => {
useGameAutocomplete.fetchMany([a0]);
}, GAME_AUTOCOMPLETE_DEBOUNCE_MS, {
leading: true,
maxWait: GAME_AUTOCOMPLETE_DEBOUNCE_MAX_WAIT_MS
});
export function queryGamesAutocomplete(a0) {
const r10 = normalizeGameAutocompleteQuery(a0);
const r2 = r10 == null;
let r11 = null;
if (!r2) {
c3910_3(r10);
let r16 = GameAutocompleteStore.getClosestResults(r10);
if (r16 == null) {
r16 = [];
}
r11 = r16.filter(isGameAutocompleteResultAllowedInGameWidgets);
}
return r11;
}
@@ -0,0 +1,80 @@
// Metro module 6170 (f6171).
import { useState, useRef, useEffect } from "react";
import GameAutocompleteStore from "./GameAutocompleteStore";
import { QueryIds } from "../../../Constants";
import { createFetchStore } from "../../../_bundle/Module589";
import { normalizeGameAutocompleteQuery } from "./GameAutocompleteUtils";
import { fetchGameAutocomplete } from "./GameAutocompleteActionCreators";
const fetchStore = createFetchStore(GameAutocompleteStore, {
getQueryId: (a0) => QueryIds.GAME_AUTOCOMPLETE(normalizeGameAutocompleteQuery(a0)),
get: (a0) => {
let r5 = GameAutocompleteStore.getResults(a0);
if (r5 == null) {
r5 = null;
}
return r5;
},
load: (a0) => fetchGameAutocomplete(a0),
getIsLoading: (a0) => GameAutocompleteStore.isFetching(a0),
retryConfig: {
retryableErrors: function isRetryableError({ status }) {
return status != null && (status === 429 || status >= 500 && status !== 503);
}
},
staleAfter: 3600,
failureStaleAfter: 60
});
export const GAME_AUTOCOMPLETE_DEBOUNCE_MS = 200;
export const GAME_AUTOCOMPLETE_DEBOUNCE_MAX_WAIT_MS = 500;
export { fetchStore as useGameAutocomplete };
export function useDebouncedGameAutocomplete(a0) {
const current = normalizeGameAutocompleteQuery(a0);
const [state, setState] = useState(current);
const ref = useRef(state);
const ref2 = useRef(0);
useEffect(() => {
if (current !== ref.current) {
if (current != null && ref.current != null) {
let c29681_0 = setTimeout(function emit() {
ref2.current = Date.now();
ref.current = current;
setState(current);
}, Math.min(200, Math.max(0, 500 - (Date.now() - ref2.current))));
return () => {
clearTimeout(c29681_0);
};
}
ref2.current = Date.now();
ref.current = current;
setState(current);
}
}, [current]);
const r31 = fetchStore(state);
let data = r31.data;
const error = r31.error;
let isLoading = r31.isLoading;
const [state2, setState2] = useState(null);
if (current == null) {
if (state2 != null) {
setState2(null);
}
} else if (data != null && data !== state2) {
setState2(data);
}
const r42 = current != null;
let results = null;
if (r42) {
if (data == null) {
data = state2;
}
results = data;
}
if (!isLoading) {
isLoading = state !== current;
}
return {
results,
isLoading,
error: state === current ? error : null
};
}