UNPKG

@bitcobblers/wod-wiki-library

Version:

A specialized markdown-like workout syntax editor and runtime for defining workouts

65 lines (64 loc) 3.19 kB
import { IRuntimeAction } from '../../IRuntimeAction'; import { ITimerRuntime } from '../../ITimerRuntime'; import { RuntimeMetric } from '../../RuntimeMetric'; import { IRuntimeEvent } from '../../IRuntimeEvent'; import { EventHandler } from '../EventHandler'; import { IRuntimeBlock } from '../../IRuntimeBlock'; import { JitStatement } from '../../JitStatement'; import { BlockKey } from '../../BlockKey'; import { ResultSpanBuilder } from '../../metrics/ResultSpanBuilder'; import { RuntimeSpan } from '../../RuntimeSpan'; /** * Legacy base class for runtime blocks, now extends AbstractBlockLifecycle * to leverage the template method pattern while maintaining backward compatibility */ export declare abstract class RuntimeBlock implements IRuntimeBlock { sources: JitStatement[]; constructor(sources: JitStatement[]); duration?: number | undefined; blockId: string; blockKey: BlockKey; parent?: IRuntimeBlock | undefined; leaf: boolean; private spanBuilder; handlers: EventHandler[]; /** * Get the ResultSpanBuilder to create and manage spans for this block * @returns The ResultSpanBuilder instance for this block */ getSpanBuilder(): ResultSpanBuilder; /** * Temporary method to access spans for testing compatibility * @returns Array of RuntimeSpan objects from the span builder without auto-closing */ spans(): RuntimeSpan[]; selectMany<T>(fn: (node: JitStatement) => T[]): T[]; protected abstract onEnter(runtime: ITimerRuntime): IRuntimeAction[]; protected abstract onLeave(runtime: ITimerRuntime): IRuntimeAction[]; protected abstract onNext(runtime: ITimerRuntime): IRuntimeAction[]; protected abstract onBlockStart(runtime: ITimerRuntime): IRuntimeAction[]; protected abstract onBlockStop(runtime: ITimerRuntime): IRuntimeAction[]; enter(runtime: ITimerRuntime): IRuntimeAction[]; leave(runtime: ITimerRuntime): IRuntimeAction[]; next(runtime: ITimerRuntime): IRuntimeAction[]; handle(runtime: ITimerRuntime, event: IRuntimeEvent, system: EventHandler[]): IRuntimeAction[]; /** * Retrieves a sequence of consecutive child JitStatements that are part of a 'compose' group. * Iteration starts from the given startIndex and continues as long as subsequent statements * have a LapFragment with group type 'compose'. * * @param startIndex The index in `this.sources` to start looking for the compose group. * @returns An array of JitStatement objects belonging to the consecutive compose group. */ nextChildStatements(runtime: ITimerRuntime, startIndex: number): JitStatement[]; onStart(runtime: ITimerRuntime): IRuntimeAction[]; onStop(runtime: ITimerRuntime): IRuntimeAction[]; /** * Generates a complete set of metrics for this runtime block using the RuntimeMetricBuilder. * This method provides a simplified way to collect metrics from fragments by type. * * @param runtime The timer runtime instance * @returns An array of RuntimeMetric objects containing effort, repetitions, distance, and resistance */ metrics(runtime: ITimerRuntime): RuntimeMetric[]; }