decord/source/5445_PressableStateMachine.js

60 lines
1.4 KiB
JavaScript
Raw Normal View History

2026-08-04 08:36:32 +00:00
// Module ID: 5445
// Function ID: 5446
2026-07-20 16:05:17 +00:00
// Name: PressableStateMachine
2026-07-29 08:29:29 +00:00
// Dependencies: [41, 42]
2026-07-20 16:05:17 +00:00
2026-08-04 08:36:32 +00:00
// Module 5445 (PressableStateMachine)
2026-07-29 08:29:29 +00:00
import PressableStateMachine from "_classCallCheck";
2026-07-20 16:05:17 +00:00
2026-07-29 08:29:29 +00:00
class PressableStateMachine {
constructor() {
tmp = PressableStateMachine(this, PressableStateMachine);
this.states = null;
this.currentStepIndex = 0;
this.eventPayload = null;
return;
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
}
const items = [
{
2026-07-20 16:05:17 +00:00
key: "setStates",
value: function setStates(statesConfig) {
this.states = statesConfig;
}
2026-07-29 08:29:29 +00:00
},
{
2026-07-20 16:05:17 +00:00
key: "reset",
value: function reset() {
2026-07-29 08:29:29 +00:00
2026-07-20 16:05:17 +00:00
}
2026-07-29 08:29:29 +00:00
},
{
2026-07-20 16:05:17 +00:00
key: "handleEvent",
value: function handleEvent(arg0, arg1) {
const self = this;
if (this.states) {
let eventPayload = arg1;
if (!arg1) {
eventPayload = self.eventPayload;
}
self.eventPayload = eventPayload;
if (self.states[self.currentStepIndex].eventName === arg0) {
2026-07-29 08:29:29 +00:00
if (tmp5) {
2026-07-20 16:05:17 +00:00
obj.callback(self.eventPayload);
}
self.currentStepIndex = self.currentStepIndex + 1;
if (self.currentStepIndex === self.states.length) {
self.reset();
}
2026-07-29 08:29:29 +00:00
tmp5 = self.eventPayload && obj.callback;
2026-07-20 16:05:17 +00:00
} else if (self.currentStepIndex > 0) {
self.reset();
self.handleEvent(arg0, arg1);
}
}
}
2026-07-29 08:29:29 +00:00
}
];
export const PressableStateMachine = require("_createClass")(PressableStateMachine, items);