decord/beta/source/modules/cache/CacheManager.native.tsx

85 lines
2.8 KiB
TypeScript
Raw Normal View History

2026-10-07 22:43:51 +00:00
// Module ID: 17468
// Function ID: 17469
// Name: CacheManager
2026-10-07 22:43:51 +00:00
// Dependencies: [5436, 6985, 3, 1102, 6613, 7138, 15400, 1369, 1105, 2]
2026-10-07 22:43:51 +00:00
// Module 17468 (CacheManager)
import LoggerDefault from "Logger" /* 3 */;
2026-10-07 22:43:51 +00:00
import DurationsDefault from "Durations" /* 1102 */;
import ConstantsIOS from "ConstantsIOS" /* 1105 */;
import PlatformUtils from "PlatformUtils" /* 1369 */;
import KvCacheVersionDefault from "KvCacheVersion" /* 7138 */;
import GatewayConnectionStore from "GatewayConnectionStore" /* 5436 */;
import CacheStore from "CacheStore" /* 6985 */;
import AutomaticLifecycleManager from "AutomaticLifecycleManager" /* 6613 */;
2026-10-01 14:13:23 +00:00
import size from "module_2" /* 2 */;
2026-10-01 14:13:23 +00:00
let tmp;
2026-10-07 22:43:51 +00:00
const CacheActionCreators = tmp(15400);
2026-10-01 14:13:23 +00:00
const hasOwnProperty = new LoggerDefault("CacheStore");
const tmp2 = new LoggerDefault("CacheStore");
let closure_6 = 15 * DurationsDefault.Millis.MINUTE;
2026-10-01 14:13:23 +00:00
class CacheManager extends AutomaticLifecycleManager {
constructor() {
2026-10-01 14:13:23 +00:00
const applyArgumentsResult = HermesBuiltin.applyArguments(this, new.target);
applyArgumentsResult.actions = {
POST_CONNECTION_OPEN: applyArgumentsResult.handleConnectionOpen,
CONNECTION_CLOSED: applyArgumentsResult.handleConnectionClose,
APP_STATE_UPDATE(arg0) {
2026-10-01 14:13:23 +00:00
return applyArgumentsResult.handleAppStateUpdate(arg0);
},
WINDOW_FOCUS(arg0) {
2026-10-01 14:13:23 +00:00
return applyArgumentsResult.handleWindowFocus(arg0);
}
};
return applyArgumentsResult;
}
2026-10-01 14:13:23 +00:00
handleConnectionOpen() {
let obj = KvCacheVersionDefault;
const result = obj.doesDatabaseVersionMatchJsConstants();
result.then((result) => {
const tmp = result;
if (!tmp) {
const obj = CacheActionCreators;
obj.writeCaches();
}
});
}
handleConnectionClose() {
return false;
}
2026-10-01 14:13:23 +00:00
handleAppStateUpdate(state) {
state = state.state;
const obj = PlatformUtils;
const isAndroidResult = obj.isAndroid();
const AppStates = ConstantsIOS.AppStates;
let isConnectedResult = (isAndroidResult ? AppStates.BACKGROUND : AppStates.INACTIVE) === state;
if (isConnectedResult) {
isConnectedResult = GatewayConnectionStore.isConnected();
}
if (isConnectedResult) {
const tmpResult = CacheActionCreators;
tmpResult.writeCaches();
}
return false;
}
2026-10-01 14:13:23 +00:00
handleWindowFocus(focused) {
if (!focused.focused) {
const _Date = Date;
if (Date.now() - CacheStore.lastWriteTime > closure_6) {
closure_5.verbose("Writing cache from window unfocus");
const obj = CacheActionCreators;
obj.writeCaches();
} else {
closure_5.verbose("Not writing cache from window unfocus");
}
}
2026-10-01 14:13:23 +00:00
return false;
}
2026-10-01 14:13:23 +00:00
}
const prototype = CacheManager.prototype;
const cacheManager = new CacheManager();
let result = size.fileFinishedImporting("modules/cache/CacheManager.native.tsx");
export default cacheManager;