UNPKG

@gitorial/sync

Version:

Universal sync library for real-time tutorial state synchronization between websites and VS Code extensions with built-in relay server orchestration

45 lines 1.62 kB
/** * Sync lifecycle phases for explicit state machine modeling */ export declare enum SyncPhase { CONNECTING = "connecting",// Establishing connection to relay server CONNECTED_IDLE = "connected_idle",// Connected but no sync direction chosen INITIALIZING_PULL = "initializing_pull",// Chose to pull (becoming ACTIVE) INITIALIZING_PUSH = "initializing_push",// Chose to push (becoming PASSIVE) ACTIVE = "active",// Has control, sends state updates PASSIVE = "passive",// Listens to state updates from active peer DISCONNECTED = "disconnected" } /** * Sync phase change event data */ export interface SyncPhaseChangeEvent { clientId: string; previousPhase: SyncPhase; newPhase: SyncPhase; timestamp: number; reason?: string; } /** * Sync phase permissions and capabilities */ export declare class SyncPhasePermissions { static canSendTutorialState(phase: SyncPhase): boolean; static canRequestSync(phase: SyncPhase): boolean; static canChooseSyncDirection(phase: SyncPhase): boolean; static canOfferControlTransfer(phase: SyncPhase): boolean; static canDisconnect(phase: SyncPhase): boolean; static canConnect(phase: SyncPhase): boolean; static getValidTransitions(currentPhase: SyncPhase): SyncPhase[]; } /** * Sync phase state machine for enforcing valid transitions */ export declare class SyncPhaseStateMachine { private currentPhase; getCurrentPhase(): SyncPhase; canTransitionTo(newPhase: SyncPhase): boolean; transitionTo(newPhase: SyncPhase): boolean; reset(): void; } //# sourceMappingURL=sync-phases.d.ts.map