decord/source/lib/StateManager.tsx

94 lines
2.3 KiB
TypeScript
Raw Normal View History

2026-08-24 06:08:38 +00:00
// Module ID: 13283
// Function ID: 13284
2026-07-29 08:29:29 +00:00
// Name: shouldCommit
// Dependencies: [659, 2]
2026-07-20 16:05:17 +00:00
2026-08-24 06:08:38 +00:00
// Module 13283 (shouldCommit)
import set from "set" /* 2 */;
import isUndefinedOrNullDefault from "isUndefinedOrNull" /* 659 */;
const result = set.fileFinishedImporting("lib/StateManager.tsx");
2026-07-29 08:29:29 +00:00
class StateManager {
constructor() {
flag = global;
if (global === undefined) {
flag = true;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
obj = Object.create(new.target.prototype);
obj.state = obj.getInitialState();
obj.alwaysUpdateState = flag;
return obj;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
}
const prototype = StateManager.prototype;
prototype["shouldCommit"] = function shouldCommit() {
return true;
};
prototype["setState"] = function setState(arg0) {
const merged = Object.assign(this.state);
const merged1 = Object.assign(arg0);
this.state = {};
};
prototype["getState"] = function getState() {
return this.state;
};
prototype["reset"] = function reset() {
this.dirty = false;
this.state = this.getInitialState();
};
prototype["update"] = function update() {
let obj = arg0;
if (arg0 === undefined) {
obj = {};
}
let flag = arg1;
if (arg1 === undefined) {
flag = false;
}
const self = this;
obj = {};
const merged = Object.assign(this.state);
const merged1 = Object.assign(obj);
const nextState = this.getNextState(obj);
if (flag) {
2026-08-24 06:08:38 +00:00
self.dirty = !isUndefinedOrNullDefault(nextState, self.getInitialState());
const tmp14 = isUndefinedOrNullDefault;
2026-07-29 08:29:29 +00:00
} else {
const _Object = Object;
const keys = Object.keys(nextState);
for (const item10021 of keys) {
let tmp8 = item10021;
let dirty = self.dirty;
if (!dirty) {
let tmp9 = importDefault;
let tmp10 = dependencyMap;
let tmp11 = item10021;
2026-08-24 06:08:38 +00:00
dirty = !isUndefinedOrNullDefault(self.state[tmp8], nextState[tmp8]);
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
self.dirty = dirty;
continue;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
}
const tmp15 = self.dirty && self.shouldCommit();
let alwaysUpdateState = tmp15;
if (!tmp15) {
alwaysUpdateState = self.alwaysUpdateState;
}
if (alwaysUpdateState) {
self.state = nextState;
}
let flag2 = tmp15;
if (flag2) {
self.dirty = false;
self.didCommit(self.state);
flag2 = true;
}
return flag2;
};
prototype["forceUpdate"] = function forceUpdate() {
this.dirty = false;
this.didCommit(this.state);
};
2026-07-20 16:05:17 +00:00
2026-07-29 08:29:29 +00:00
export default StateManager;