decord/alpha/source/modules/games/hooks/useGame.tsx

130 lines
3.3 KiB
TypeScript
Raw Normal View History

// Module ID: 6722
// Function ID: 6723
// Name: useGame
// Dependencies: [5, 19, 2000, 1074, 504, 1091, 6723, 2]
2026-07-20 16:05:17 +00:00
// Exports: useGames
// Module 6722 (useGame)
import DurationsDefault from "Durations" /* 1091 */;
import GameActionCreators from "GameActionCreators" /* 6723 */;
import asyncGeneratorStep from "asyncGeneratorStep" /* 5 */;
import noop from "module_19" /* 19 */;
import GameStore from "GameStore" /* 2000 */;
2026-07-23 10:11:24 +00:00
require = fn;
const initialize = fn(504);
const obj2 = {
getQueryId: fn(1074).QueryIds.GAME,
failureStaleAfter: 15 * DurationsDefault.Seconds.SECOND,
get(gameId) {
if (null == gameId) {
2026-07-20 16:05:17 +00:00
return null;
} else {
if (GameStore.hasNoData(gameId)) {
let NO_DATA = require("initialize").NO_DATA;
2026-07-29 08:29:29 +00:00
} else {
NO_DATA = obj.getGame(gameId);
2026-07-29 08:29:29 +00:00
if (NO_DATA == null) {
NO_DATA = null;
}
2026-07-20 16:05:17 +00:00
}
obj = GameStore;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
},
load: null,
getIsLoading: null,
getError: null
2026-07-20 16:05:17 +00:00
};
let closure_2 = asyncGeneratorStep(async (arg0, value) => {
if (c1 === 2) {
c1 = 3;
throw new TypeError("Generator functions may not be called on executing generators");
} else if (tmp3 === 3) {
if (arg0 === 1) {
throw value;
} else if (arg0 === 2) {
const obj3 = { value, done: true };
return obj3;
2026-07-29 08:29:29 +00:00
} else {
return { value: "HermesInternal", done: null };
}
} else {
try {
c1 = 2;
if (0 === c2) {
if (arg0 === 1) {
c1 = 3;
throw value;
2026-07-29 08:29:29 +00:00
} else if (arg0 === 2) {
c1 = 3;
const obj4 = { value, done: true };
return obj4;
} else if (null != closure_0) {
const items = [tmp5];
c2 = 1;
c1 = 1;
const obj5 = { value: GameActionCreators.fetchGamesWithSupplementalData(items), done: false };
return obj5;
2026-07-29 08:29:29 +00:00
}
} else if (arg0 === 1) {
c1 = 3;
throw value;
} else if (arg0 === 2) {
c1 = 3;
const obj = { value, done: true };
return obj;
2026-07-29 08:29:29 +00:00
}
c1 = 3;
return { value: "HermesInternal", done: null };
} catch (tmp9) {
c1 = tmp;
throw tmp9;
2026-07-29 08:29:29 +00:00
}
}
2026-07-20 16:05:17 +00:00
});
obj2.load = function() {
2026-07-29 08:29:29 +00:00
const self = this;
const apply = closure_2.apply;
if (typeof apply === "unknown") {
let applyArgumentsResult = HermesBuiltin.applyArguments(self);
} else {
applyArgumentsResult = apply(self, arguments);
}
return applyArgumentsResult;
2026-07-20 16:05:17 +00:00
};
obj2.getIsLoading = function getIsLoading(arg0) {
2026-07-29 08:29:29 +00:00
let isFetchingResult = null != arg0;
2026-07-20 16:05:17 +00:00
if (isFetchingResult) {
isFetchingResult = GameStore.isFetching(arg0);
2026-07-20 16:05:17 +00:00
}
return isFetchingResult;
};
obj2.getError = function getError(item) {
let error = null;
if (null != item) {
2026-07-20 16:05:17 +00:00
error = null;
if (GameStore.didFetchingFail(item)) {
2026-07-20 16:05:17 +00:00
const _Error = Error;
error = new Error("Failed to fetch game data");
}
}
return error;
};
const fetchStore = initialize.createFetchStore(GameStore, obj2);
const size = fn(2);
const result = size.fileFinishedImporting("modules/games/hooks/useGame.tsx");
2026-07-20 16:05:17 +00:00
export const useGame = fetchStore;
export const useGames = function useGames(memo) {
2026-07-23 10:11:24 +00:00
let items = [memo];
const effect = noop.useEffect(() => {
2026-07-23 10:11:24 +00:00
let items = [
...closure_0.map((item) => {
const items = [item];
2026-07-20 16:05:17 +00:00
return items;
})
];
fetchStore.fetchMany.apply(items);
2026-07-20 16:05:17 +00:00
}, items);
};