decord/source/6510_PressableStateMachine.js

77 lines
2.2 KiB
JavaScript
Raw Normal View History

2026-08-24 06:08:38 +00:00
// Module ID: 6510
// Function ID: 6511
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-24 06:08:38 +00:00
// Module 6510 (PressableStateMachine)
import _createClassDefault from "_createClass" /* 42 */;
import PressableStateMachine from "_classCallCheck" /* 41 */;
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;
2026-08-08 06:10:11 +00:00
if (self.currentStepIndex < self.states.length) {
if (self.states[self.currentStepIndex].eventName !== arg0) {
if (self.states[self.currentStepIndex].optional) {
self.currentStepIndex = self.currentStepIndex + 1;
while (self.currentStepIndex < self.states.length) {
if (self.states[self.currentStepIndex].eventName === arg0) {
break;
} else if (!self.states[self.currentStepIndex].optional) {
break;
}
}
}
}
}
if (self.currentStepIndex >= self.states.length) {
self.reset();
} else 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
}
];
2026-08-24 06:08:38 +00:00
export const PressableStateMachine = _createClassDefault(PressableStateMachine, items);