UNPKG

@atlaskit/editor-common

Version:

A package that contains common classes and components for editor and renderer

22 lines (21 loc) 880 B
/** * State transition map defining valid state transitions. */ export var EXPERIENCE_STATE_TRANSITIONS = { pending: ['started'], started: ['aborted', 'failed', 'succeeded'], aborted: ['started'], failed: ['started'], succeeded: ['started'] }; /** * Validates whether a state transition is allowed. * * @param fromState - The current state * @param toState - The target state to transition to * @returns true if the transition is valid, false otherwise */ export var canTransition = function canTransition(fromState, toState) { var _EXPERIENCE_STATE_TRA, _EXPERIENCE_STATE_TRA2; return (_EXPERIENCE_STATE_TRA = (_EXPERIENCE_STATE_TRA2 = EXPERIENCE_STATE_TRANSITIONS[fromState]) === null || _EXPERIENCE_STATE_TRA2 === void 0 ? void 0 : _EXPERIENCE_STATE_TRA2.includes(toState)) !== null && _EXPERIENCE_STATE_TRA !== void 0 ? _EXPERIENCE_STATE_TRA : false; };