decord/source/modules/games/autocomplete/useGameAutocomplete.tsx
github-actions 7450227d0b chore: update source for alpha 345.4
Skipped 1 file(s) >100MB (GitHub limit): source/__vendor/09xxx/9596_m.js (380.6 MB)
2026-09-04 17:41:35 +00:00

131 lines
3.6 KiB
TypeScript

// Module ID: 8829
// Function ID: 8830
// Name: fetchStore
// Dependencies: [32, 19, 5069, 673, 586, 5070, 8830, 2]
// Exports: useDebouncedGameAutocomplete
// Module 8829 (fetchStore)
import GAME_AUTOCOMPLETE_MAX_QUERY_LENGTH from "GAME_AUTOCOMPLETE_MAX_QUERY_LENGTH" /* 5070 */;
import _fetchGameAutocomplete from "_fetchGameAutocomplete" /* 8830 */;
import closure_2 from "_slicedToArray" /* 32 */;
import closure_3 from "noop" /* 19 */;
import importDefaultResult from "set" /* 5069 */;
import { QueryIds } from "ME" /* 673 */;
import initialize from "initialize" /* 586 */;
require = arg1;
let c4 = importDefaultResult;
initialize = {
getQueryId(c0) {
return QueryIds.GAME_AUTOCOMPLETE(GAME_AUTOCOMPLETE_MAX_QUERY_LENGTH.normalizeGameAutocompleteQuery(c0));
},
get(arg0) {
let results = importDefaultResult.getResults(arg0);
if (results == null) {
results = null;
}
return results;
},
load(arg0) {
return _fetchGameAutocomplete.fetchGameAutocomplete(arg0);
},
getIsLoading(arg0) {
return importDefaultResult.isFetching(arg0);
},
retryConfig: initialize,
staleAfter: 3600,
failureStaleAfter: 60
};
initialize = {
retryableErrors: function isRetryableError(status) {
status = status.status;
let tmp = null != status;
if (tmp) {
let tmp2 = 429 === status;
if (!tmp2) {
let tmp3 = status >= 500;
if (tmp3) {
tmp3 = 503 !== status;
}
tmp2 = tmp3;
}
tmp = tmp2;
}
return tmp;
}
};
const fetchStore = initialize.createFetchStore(importDefaultResult, initialize);
let result = require("set").fileFinishedImporting("modules/games/autocomplete/useGameAutocomplete.tsx");
export const GAME_AUTOCOMPLETE_DEBOUNCE_MS = 200;
export const GAME_AUTOCOMPLETE_DEBOUNCE_MAX_WAIT_MS = 500;
export const useGameAutocomplete = fetchStore;
export const useDebouncedGameAutocomplete = function useDebouncedGameAutocomplete(c0) {
let obj = GAME_AUTOCOMPLETE_MAX_QUERY_LENGTH;
const result = obj.normalizeGameAutocompleteQuery(c0);
require = result;
dependencyMap = undefined;
let callback;
let React;
[tmp3, c1] = callback(React.useState(result), 2);
callback = React.useRef(tmp3);
React = React.useRef(0);
const items = [result];
const effect = React.useEffect(() => {
if (timeout !== ref.current) {
if (null != tmp) {
if (null != tmp2.current) {
const _Date2 = Date;
function emit() {
closure_3.current = Date.now();
closure_2.current = closure_0;
callback(closure_0);
}
const _Math = Math;
const _Math2 = Math;
const _setTimeout = setTimeout;
timeout = setTimeout(emit, Math.min(200, Math.max(0, 500 - (Date.now() - ref2.current))));
return () => {
clearTimeout(closure_0);
};
}
}
const _Date = Date;
ref2.current = Date.now();
tmp2.current = tmp;
_undefined(tmp);
}
}, items);
const tmp5 = fetchStore(tmp3);
({ data, isLoading } = tmp5);
const tmp2 = callback(React.useState(result), 2);
[tmp7, tmp8] = callback(React.useState(null), 2);
if (null == result) {
if (null != tmp7) {
tmp8(null);
}
} else {
if (tmp9) {
tmp8(data);
}
tmp9 = null != data && data !== tmp7;
}
let tmp12 = null;
if (null != result) {
if (data == null) {
data = tmp7;
}
tmp12 = data;
}
obj = { results: tmp12, isLoading: null, error: null };
if (!isLoading) {
isLoading = tmp3 !== result;
}
obj[1] = isLoading;
error = null;
if (tmp3 === result) {
error = tmp5.error;
}
obj[2] = error;
return obj;
};