@bitcobblers/wod-wiki-lang 0.1.6 → 0.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +179 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +178 -7
- package/dist/index.d.ts +178 -7
- package/dist/index.mjs +176 -7
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -1880,6 +1880,58 @@ interface IRuntimeBlockStrategy {
|
|
|
1880
1880
|
apply(builder: BlockBuilder, statements: ICodeStatement[], runtime: IRuntimeContext): void;
|
|
1881
1881
|
}
|
|
1882
1882
|
|
|
1883
|
+
/**
|
|
1884
|
+
* A subscription that receives runtime state updates.
|
|
1885
|
+
*
|
|
1886
|
+
* Implementations determine what happens with the data:
|
|
1887
|
+
* - LocalRuntimeSubscription updates the workbench store (local UI)
|
|
1888
|
+
* - ChromecastRuntimeSubscription serializes and sends over RPC transport
|
|
1889
|
+
*
|
|
1890
|
+
* Multiple subscriptions can be active simultaneously. The SubscriptionManager
|
|
1891
|
+
* fans out stack snapshots and output statements to all registered subscriptions.
|
|
1892
|
+
*/
|
|
1893
|
+
interface IRuntimeSubscription {
|
|
1894
|
+
/** Unique identifier for add/remove tracking */
|
|
1895
|
+
readonly id: string;
|
|
1896
|
+
/**
|
|
1897
|
+
* Called when a stack mutation occurs (push/pop/clear/initial).
|
|
1898
|
+
* The snapshot contains the full block list, the affected block, and timing.
|
|
1899
|
+
*/
|
|
1900
|
+
onStackSnapshot(snapshot: StackSnapshot): void;
|
|
1901
|
+
/**
|
|
1902
|
+
* Called when an output statement is emitted (block unmount, milestone, etc.).
|
|
1903
|
+
*/
|
|
1904
|
+
onOutput(output: IOutputStatement): void;
|
|
1905
|
+
/**
|
|
1906
|
+
* Clean up resources held by this subscription (unsubscribe listeners, close channels, etc.).
|
|
1907
|
+
*/
|
|
1908
|
+
dispose(): void;
|
|
1909
|
+
}
|
|
1910
|
+
|
|
1911
|
+
/**
|
|
1912
|
+
* Chromecast-specific subscription interface that extends IRuntimeSubscription
|
|
1913
|
+
* with analytics summary functionality.
|
|
1914
|
+
*
|
|
1915
|
+
* Only ChromecastRuntimeSubscription implements this interface — local
|
|
1916
|
+
* subscriptions do not support analytics summary.
|
|
1917
|
+
*/
|
|
1918
|
+
interface ICastSubscription extends IRuntimeSubscription {
|
|
1919
|
+
/**
|
|
1920
|
+
* Send analytics summary with projection results to Chromecast review.
|
|
1921
|
+
* Called by browser when workout completes to show focused review.
|
|
1922
|
+
*/
|
|
1923
|
+
sendAnalyticsSummary(projections: Array<{
|
|
1924
|
+
name: string;
|
|
1925
|
+
value: number;
|
|
1926
|
+
unit: string;
|
|
1927
|
+
metricType?: string;
|
|
1928
|
+
}>, totalDurationMs: number, completedSegments: number): void;
|
|
1929
|
+
}
|
|
1930
|
+
/**
|
|
1931
|
+
* Type guard to check if a subscription supports Chromecast analytics.
|
|
1932
|
+
*/
|
|
1933
|
+
declare function isCastSubscription(s: IRuntimeSubscription): s is ICastSubscription;
|
|
1934
|
+
|
|
1883
1935
|
/**
|
|
1884
1936
|
* Action that pushes a compiled block onto the runtime stack.
|
|
1885
1937
|
* Used by behaviors to add child blocks for execution.
|
|
@@ -3154,6 +3206,125 @@ declare class RuntimeAdapter implements IRuntimeAdapter {
|
|
|
3154
3206
|
private getMemoryIcon;
|
|
3155
3207
|
}
|
|
3156
3208
|
|
|
3209
|
+
/**
|
|
3210
|
+
* LocalRuntimeSubscription — a no-op subscription that simply receives
|
|
3211
|
+
* stack snapshots and output statements without transforming them.
|
|
3212
|
+
*
|
|
3213
|
+
* This is the "identity" subscription: the SubscriptionManager fans out
|
|
3214
|
+
* runtime events to all subscriptions, and the local one simply consumes
|
|
3215
|
+
* them for any local-side effect (e.g., updating the workbench store).
|
|
3216
|
+
*
|
|
3217
|
+
* An optional callback can be provided for each event type to allow
|
|
3218
|
+
* the consumer to react to state changes.
|
|
3219
|
+
*/
|
|
3220
|
+
declare class LocalRuntimeSubscription implements IRuntimeSubscription {
|
|
3221
|
+
readonly id: string;
|
|
3222
|
+
private onStackSnapshotCallback?;
|
|
3223
|
+
private onOutputCallback?;
|
|
3224
|
+
constructor(options?: {
|
|
3225
|
+
id?: string;
|
|
3226
|
+
onStackSnapshot?: (snapshot: StackSnapshot) => void;
|
|
3227
|
+
onOutput?: (output: IOutputStatement) => void;
|
|
3228
|
+
});
|
|
3229
|
+
onStackSnapshot(snapshot: StackSnapshot): void;
|
|
3230
|
+
onOutput(output: IOutputStatement): void;
|
|
3231
|
+
dispose(): void;
|
|
3232
|
+
}
|
|
3233
|
+
|
|
3234
|
+
/**
|
|
3235
|
+
* Provides bidirectional event flow between runtime consumers.
|
|
3236
|
+
*
|
|
3237
|
+
* Implementations determine the transport:
|
|
3238
|
+
* - LocalEventProvider dispatches directly to the local IScriptRuntime
|
|
3239
|
+
* - ChromecastEventProvider sends/receives events over the RPC transport
|
|
3240
|
+
*
|
|
3241
|
+
* This abstracts away whether an event originates locally (button press)
|
|
3242
|
+
* or remotely (Chromecast D-Pad) — the runtime processes both identically.
|
|
3243
|
+
*/
|
|
3244
|
+
interface IRuntimeEventProvider {
|
|
3245
|
+
/**
|
|
3246
|
+
* Dispatch an event to be processed by the runtime.
|
|
3247
|
+
* For local: calls runtime.handle(event) directly.
|
|
3248
|
+
* For chromecast: serializes and sends over the RPC channel.
|
|
3249
|
+
*/
|
|
3250
|
+
dispatch(event: IEvent): void;
|
|
3251
|
+
/**
|
|
3252
|
+
* Listen for incoming events (from remote sources or the runtime event bus).
|
|
3253
|
+
* Returns an unsubscribe function.
|
|
3254
|
+
*/
|
|
3255
|
+
onEvent(handler: (event: IEvent) => void): Unsubscribe;
|
|
3256
|
+
/**
|
|
3257
|
+
* Clean up resources.
|
|
3258
|
+
*/
|
|
3259
|
+
dispose(): void;
|
|
3260
|
+
}
|
|
3261
|
+
|
|
3262
|
+
/**
|
|
3263
|
+
* LocalEventProvider — dispatches events directly to the local IScriptRuntime.
|
|
3264
|
+
*
|
|
3265
|
+
* - dispatch(event) → runtime.handle(event), which triggers the event bus
|
|
3266
|
+
* and executes resulting actions in a single turn.
|
|
3267
|
+
* - onEvent(handler) → registers on the runtime event bus to receive
|
|
3268
|
+
* all events (using the 'global' callback registration path).
|
|
3269
|
+
*/
|
|
3270
|
+
declare class LocalEventProvider implements IRuntimeEventProvider {
|
|
3271
|
+
private readonly runtime;
|
|
3272
|
+
private static subscriptionCounter;
|
|
3273
|
+
private unsubscribes;
|
|
3274
|
+
private disposed;
|
|
3275
|
+
constructor(runtime: IScriptRuntime);
|
|
3276
|
+
dispatch(event: IEvent): void;
|
|
3277
|
+
onEvent(handler: (event: IEvent) => void): Unsubscribe;
|
|
3278
|
+
dispose(): void;
|
|
3279
|
+
}
|
|
3280
|
+
|
|
3281
|
+
/**
|
|
3282
|
+
* SubscriptionManager — fans out runtime stack and output events to
|
|
3283
|
+
* multiple IRuntimeSubscription instances.
|
|
3284
|
+
*
|
|
3285
|
+
* Lifecycle:
|
|
3286
|
+
* 1. Created when a runtime is initialized (by RuntimeLifecycleProvider)
|
|
3287
|
+
* 2. Always holds a LocalRuntimeSubscription for the browser UI
|
|
3288
|
+
* 3. ChromecastRuntimeSubscription added/removed via cast session lifecycle
|
|
3289
|
+
* 4. Disposed when the runtime is disposed
|
|
3290
|
+
*
|
|
3291
|
+
* The manager subscribes once to the runtime's stack and output APIs,
|
|
3292
|
+
* then iterates over all registered subscriptions for each event.
|
|
3293
|
+
*/
|
|
3294
|
+
declare class SubscriptionManager {
|
|
3295
|
+
private readonly runtime;
|
|
3296
|
+
private subscriptions;
|
|
3297
|
+
private stackUnsub;
|
|
3298
|
+
private outputUnsub;
|
|
3299
|
+
private disposed;
|
|
3300
|
+
constructor(runtime: IScriptRuntime);
|
|
3301
|
+
/**
|
|
3302
|
+
* Register a subscription. If a subscription with the same ID already exists,
|
|
3303
|
+
* the old one is disposed and replaced.
|
|
3304
|
+
*
|
|
3305
|
+
* New subscriptions immediately receive the current stack state and any
|
|
3306
|
+
* existing output statements to catch them up.
|
|
3307
|
+
*/
|
|
3308
|
+
add(subscription: IRuntimeSubscription): void;
|
|
3309
|
+
/**
|
|
3310
|
+
* Remove and dispose a subscription by ID.
|
|
3311
|
+
* Returns true if the subscription was found and removed.
|
|
3312
|
+
*/
|
|
3313
|
+
remove(id: string): boolean;
|
|
3314
|
+
/**
|
|
3315
|
+
* Check if a subscription with the given ID is registered.
|
|
3316
|
+
*/
|
|
3317
|
+
has(id: string): boolean;
|
|
3318
|
+
/**
|
|
3319
|
+
* Get the number of active subscriptions.
|
|
3320
|
+
*/
|
|
3321
|
+
get count(): number;
|
|
3322
|
+
/**
|
|
3323
|
+
* Dispose all subscriptions and unsubscribe from the runtime.
|
|
3324
|
+
*/
|
|
3325
|
+
dispose(): void;
|
|
3326
|
+
}
|
|
3327
|
+
|
|
3157
3328
|
/**
|
|
3158
3329
|
* AST for the composed-calculation expression language (spec §2).
|
|
3159
3330
|
*
|
|
@@ -4226,13 +4397,13 @@ declare function toStoredOutputStatement(output: IOutputStatement | OutputStatem
|
|
|
4226
4397
|
* Auto-generated build version metadata.
|
|
4227
4398
|
* Do not edit directly; updated by scripts/stamp-version.ts
|
|
4228
4399
|
*/
|
|
4229
|
-
declare const VERSION = "0.1.
|
|
4230
|
-
declare const GIT_SHA = "
|
|
4231
|
-
declare const BUILD_TIME = "2026-08-18T18:
|
|
4400
|
+
declare const VERSION = "0.1.8";
|
|
4401
|
+
declare const GIT_SHA = "52af1e3";
|
|
4402
|
+
declare const BUILD_TIME = "2026-08-18T18:19:06.086Z";
|
|
4232
4403
|
declare const SEMVER: {
|
|
4233
|
-
readonly version: "0.1.
|
|
4234
|
-
readonly gitSha: "
|
|
4235
|
-
readonly buildTime: "2026-08-18T18:
|
|
4404
|
+
readonly version: "0.1.8";
|
|
4405
|
+
readonly gitSha: "52af1e3";
|
|
4406
|
+
readonly buildTime: "2026-08-18T18:19:06.086Z";
|
|
4236
4407
|
};
|
|
4237
4408
|
|
|
4238
|
-
export { AbortSessionAction, type ActionDescriptor, type ActionPrimitive, AnalyticsContext, AnalyticsEngine, type AnalyticsProfileContext, type AnalyticsResult, AnalyticsTransformer, BUILD_TIME, BUILTIN_CALCS, BUNDLED_EFFORT_COUNT, BehaviorContext, BlockContext, BlockLifecycleOptions, CONSUMED_HINTS, CONSUMED_HINT_KEYS, type CalculationDefinition$1 as CalcDefinition, CalcEngine, type CalcOrigin, type CalcScope, type CalculationDefinition as CalculateBlockDefinition, type CalculateBlockParseError, type CalculateBlockParseResult, CalculateBlockProcessor, CalculationRegistry, CardioDialect, ClearChildrenAction, ClimbDialect, type ClimbGradeMetricValue, type ClimbGradeSystem, ClimbMetricType, CompileAndPushBlockAction, CompletionDecision, type CreateAnalyticsEngineOptions, type CreateAnalyticsEngineResult, CrossFitDialect, DAY, DEFAULT_UNRESOLVED_EFFORT_MET, DIM_LENGTH, DIM_MASS, DIM_TIME, DIM_ZERO, type DayRollup, DialectStack, type Dimension, type DurationPrimitive, EFFORT_DATA_METRIC_TYPE, EffortBlock, type EffortBlockConfig, type EffortPrimitive, EffortRegistrySource, EffortResolutionOptions, EffortResolver, EffortResolverOptions, EmitEventAction, EmitSystemOutputAction, ErrorAction, EventBus, type EventHandlerRegistration, ExecutionContext, type FuzzyCandidate, GIT_SHA, HabitsDialect, type HeadingPrimitive, IAnalyticsEngine, type IAnalyticsProfile, IBlockContext, IEffort, IEffortRegistry, IEffortResolver, IEvent, IEventBus, IJitCompiler, type ILookupTable, IMemoryLocation, IMemoryReference, type IMetricPresentationPolicy, INowProvider, IRealtimeProcessor, IRuntimeAction, IRuntimeBehavior, IRuntimeBlock, type IRuntimeBlockStrategy, IRuntimeClock, type IRuntimeFactory, IRuntimeStack, IScript, IScriptRuntime, ISummaryProcessor, InMemoryEffortRegistry, JitCompiler, type LapPrimitive, type LineLocator, type LogLevel, LookupRegistry, MdTimerRuntime, MemoryTag, MemoryTypeEnum, type MetricObjectPrimitive, type MetricPresentationSurface, type MetricPresentationToken, type MetricRenderKind, type MetricTone, MetricVisibility, type MockClock, NextAction, NextEvent, NextEventHandler, OutputEmitter, PREDEFINED_SOUNDS, PRODUCTION_STRATEGIES, type ParseOptions, PlaySoundAction, PopBlockAction, type PredefinedSoundName, ProjectionResult, type PropertyPrimitive, PushBlockAction, PushRestBlockAction, type QuantityPrimitive, RegisterEventHandlerAction, Registry, ResolvedEffort, type ResolvedEffortData, RestBlock, type RestBlockConfig, type RoundsPrimitive, RuntimeAdapter, RuntimeBlock, type RuntimeBlockOptions, RuntimeBuilder, type RuntimeButton, RuntimeClock, type RuntimeController, type RuntimeControls, RuntimeError, RuntimeFactory, type RuntimeLogEntry, RuntimeLogger, RuntimeMemory, type RuntimeMemoryLocation, RuntimeObservers, RuntimeStack, SEMVER, STANDARD_UNITS, STORE_CALCS, ScriptRuntime, type SegmentWithMetadata, SessionRootBlock, type SessionRootConfig, SnapshotClock, type SoundBehaviorConfig, type SoundCue, type SoundCueState, type SoundState, type SourceInput, type SpanList, StackObserver, StackSnapshot, StandardAnalyticsProfile, StartSessionAction, type StartSessionOptions, StartWorkoutAction, type StartWorkoutOptions, type SyntaxFacts, type SyntaxMeta, type SyntaxPrimitive, type SyntaxStatement, type TextPrimitive, ThrowError, ThrowErrorAction, TimeSpan, TimerState, TwoPassEffortResolutionProcess, TypedMemoryReference, type UnitDef$1 as UnitDef, type UnitMatch, UnitRegistry, UnitSet, UnitsDialect, UnregisterEventHandlerAction, Unsubscribe, UpdateNextPreviewAction, VERSION, WaitingToStartBlock, WhiteboardScript, WodDialect, YogaDialect, buildTooltip, bundledEfforts, index as calc, calculateElapsed, classifyStatements, closeCurrentSpan, commonFixtureSet, computeColumnLabel, computeLabel, computeWorkloadRollups, createAnalyticsEngineForBlock, createCalcEngine, createCompiler, createDialectStack, createLineLocator, createPolicy as createMetricPresentationPolicy, createMockClock, createParser, dailySessionLoads, dayBucket, dialectRegistry, dialectStack, evaluate, evaluateCalculateDefinitions, extractEffortData, extractMetrics, extractStatements, extractStatementsRaw, extractSyntaxFacts, findBestFuzzyMatch, fixtureBackSquat, fixtureBurpee, fixturePlank, fixtureRowing, fixtureRunning, fixtureUserCustom, fixtureUserOverride, formatDuration, metricsToLabel as fragmentsToLabel, fullFixtureSet, fuseUnits, fuseUnitsInMetrics, getAnalyticsFromLogs, getAnalyticsFromRuntime, getHints, hasHint, hintMetric, hintsToContainer, isTimeLikeMetric, isWithinThreshold, levenshteinDistance, metricPresentation, mutateTimerSpans, normalizeForFuzzy, openSpan, parseCalcLine, parseCalculateBlock, parseExpression, parseScript, readTimer, realtimeProcessorRegistry, resolveDominantOrigin, sharedParser, startSpan, strategyRegistry, summaryProcessorRegistry, toStoredOutputStatement, parser as whiteboardParser, whiteboardScript, whiteboardScriptLanguage };
|
|
4409
|
+
export { AbortSessionAction, type ActionDescriptor, type ActionPrimitive, AnalyticsContext, AnalyticsEngine, type AnalyticsProfileContext, type AnalyticsResult, AnalyticsTransformer, BUILD_TIME, BUILTIN_CALCS, BUNDLED_EFFORT_COUNT, BehaviorContext, BlockContext, BlockLifecycleOptions, CONSUMED_HINTS, CONSUMED_HINT_KEYS, type CalculationDefinition$1 as CalcDefinition, CalcEngine, type CalcOrigin, type CalcScope, type CalculationDefinition as CalculateBlockDefinition, type CalculateBlockParseError, type CalculateBlockParseResult, CalculateBlockProcessor, CalculationRegistry, CardioDialect, ClearChildrenAction, ClimbDialect, type ClimbGradeMetricValue, type ClimbGradeSystem, ClimbMetricType, CompileAndPushBlockAction, CompletionDecision, type CreateAnalyticsEngineOptions, type CreateAnalyticsEngineResult, CrossFitDialect, DAY, DEFAULT_UNRESOLVED_EFFORT_MET, DIM_LENGTH, DIM_MASS, DIM_TIME, DIM_ZERO, type DayRollup, DialectStack, type Dimension, type DurationPrimitive, EFFORT_DATA_METRIC_TYPE, EffortBlock, type EffortBlockConfig, type EffortPrimitive, EffortRegistrySource, EffortResolutionOptions, EffortResolver, EffortResolverOptions, EmitEventAction, EmitSystemOutputAction, ErrorAction, EventBus, type EventHandlerRegistration, ExecutionContext, type ExecutionSnapshot, type FuzzyCandidate, GIT_SHA, HabitsDialect, type HeadingPrimitive, IAnalyticsEngine, type IAnalyticsProfile, IBlockContext, type ICastSubscription, IEffort, IEffortRegistry, IEffortResolver, IEvent, IEventBus, IEventHandler, IJitCompiler, type ILookupTable, IMemoryLocation, IMemoryReference, type IMetricPresentationPolicy, INowProvider, IRealtimeProcessor, IRuntimeAction, IRuntimeBehavior, IRuntimeBlock, type IRuntimeBlockStrategy, IRuntimeClock, type IRuntimeFactory, IRuntimeStack, type IRuntimeSubscription, IScript, IScriptRuntime, ISummaryProcessor, InMemoryEffortRegistry, JitCompiler, type LapPrimitive, type LineLocator, LocalEventProvider, LocalRuntimeSubscription, type LogLevel, LookupRegistry, MdTimerRuntime, type MemoryEntry, MemoryTag, MemoryTypeEnum, type MetricObjectPrimitive, type MetricPresentationSurface, type MetricPresentationToken, type MetricRenderKind, type MetricTone, MetricVisibility, type MockClock, NextAction, NextEvent, NextEventHandler, OutputEmitter, PREDEFINED_SOUNDS, PRODUCTION_STRATEGIES, type ParseOptions, PlaySoundAction, PopBlockAction, type PredefinedSoundName, ProjectionResult, type PropertyPrimitive, PushBlockAction, PushRestBlockAction, type QuantityPrimitive, RegisterEventHandlerAction, Registry, ResolvedEffort, type ResolvedEffortData, RestBlock, type RestBlockConfig, type RoundsPrimitive, RuntimeAdapter, RuntimeBlock, type RuntimeBlockOptions, RuntimeBuilder, type RuntimeButton, RuntimeClock, type RuntimeController, type RuntimeControls, RuntimeError, RuntimeFactory, type RuntimeLogEntry, RuntimeLogger, RuntimeMemory, type RuntimeMemoryLocation, RuntimeObservers, RuntimeStack, SEMVER, STANDARD_UNITS, STORE_CALCS, ScriptRuntime, type SegmentWithMetadata, SessionRootBlock, type SessionRootConfig, SnapshotClock, type SoundBehaviorConfig, type SoundCue, type SoundCueState, type SoundState, type SourceInput, type SpanList, StackObserver, StackSnapshot, StandardAnalyticsProfile, StartSessionAction, type StartSessionOptions, StartWorkoutAction, type StartWorkoutOptions, SubscriptionManager, type SyntaxFacts, type SyntaxMeta, type SyntaxPrimitive, type SyntaxStatement, type TextPrimitive, ThrowError, ThrowErrorAction, TimeSpan, TimerState, TwoPassEffortResolutionProcess, TypedMemoryReference, type UnitDef$1 as UnitDef, type UnitMatch, UnitRegistry, UnitSet, UnitsDialect, UnregisterEventHandlerAction, Unsubscribe, UpdateNextPreviewAction, VERSION, WaitingToStartBlock, WhiteboardScript, WodDialect, YogaDialect, buildTooltip, bundledEfforts, index as calc, calculateElapsed, classifyStatements, closeCurrentSpan, commonFixtureSet, computeColumnLabel, computeLabel, computeWorkloadRollups, createAnalyticsEngineForBlock, createCalcEngine, createCompiler, createDialectStack, createLineLocator, createPolicy as createMetricPresentationPolicy, createMockClock, createParser, dailySessionLoads, dayBucket, dialectRegistry, dialectStack, evaluate, evaluateCalculateDefinitions, extractEffortData, extractMetrics, extractStatements, extractStatementsRaw, extractSyntaxFacts, findBestFuzzyMatch, fixtureBackSquat, fixtureBurpee, fixturePlank, fixtureRowing, fixtureRunning, fixtureUserCustom, fixtureUserOverride, formatDuration, metricsToLabel as fragmentsToLabel, fullFixtureSet, fuseUnits, fuseUnitsInMetrics, getAnalyticsFromLogs, getAnalyticsFromRuntime, getHints, hasHint, hintMetric, hintsToContainer, isCastSubscription, isTimeLikeMetric, isWithinThreshold, levenshteinDistance, metricPresentation, mutateTimerSpans, normalizeForFuzzy, openSpan, parseCalcLine, parseCalculateBlock, parseExpression, parseScript, readTimer, realtimeProcessorRegistry, resolveDominantOrigin, sharedParser, startSpan, strategyRegistry, summaryProcessorRegistry, toStoredOutputStatement, parser as whiteboardParser, whiteboardScript, whiteboardScriptLanguage };
|
package/dist/index.d.ts
CHANGED
|
@@ -1880,6 +1880,58 @@ interface IRuntimeBlockStrategy {
|
|
|
1880
1880
|
apply(builder: BlockBuilder, statements: ICodeStatement[], runtime: IRuntimeContext): void;
|
|
1881
1881
|
}
|
|
1882
1882
|
|
|
1883
|
+
/**
|
|
1884
|
+
* A subscription that receives runtime state updates.
|
|
1885
|
+
*
|
|
1886
|
+
* Implementations determine what happens with the data:
|
|
1887
|
+
* - LocalRuntimeSubscription updates the workbench store (local UI)
|
|
1888
|
+
* - ChromecastRuntimeSubscription serializes and sends over RPC transport
|
|
1889
|
+
*
|
|
1890
|
+
* Multiple subscriptions can be active simultaneously. The SubscriptionManager
|
|
1891
|
+
* fans out stack snapshots and output statements to all registered subscriptions.
|
|
1892
|
+
*/
|
|
1893
|
+
interface IRuntimeSubscription {
|
|
1894
|
+
/** Unique identifier for add/remove tracking */
|
|
1895
|
+
readonly id: string;
|
|
1896
|
+
/**
|
|
1897
|
+
* Called when a stack mutation occurs (push/pop/clear/initial).
|
|
1898
|
+
* The snapshot contains the full block list, the affected block, and timing.
|
|
1899
|
+
*/
|
|
1900
|
+
onStackSnapshot(snapshot: StackSnapshot): void;
|
|
1901
|
+
/**
|
|
1902
|
+
* Called when an output statement is emitted (block unmount, milestone, etc.).
|
|
1903
|
+
*/
|
|
1904
|
+
onOutput(output: IOutputStatement): void;
|
|
1905
|
+
/**
|
|
1906
|
+
* Clean up resources held by this subscription (unsubscribe listeners, close channels, etc.).
|
|
1907
|
+
*/
|
|
1908
|
+
dispose(): void;
|
|
1909
|
+
}
|
|
1910
|
+
|
|
1911
|
+
/**
|
|
1912
|
+
* Chromecast-specific subscription interface that extends IRuntimeSubscription
|
|
1913
|
+
* with analytics summary functionality.
|
|
1914
|
+
*
|
|
1915
|
+
* Only ChromecastRuntimeSubscription implements this interface — local
|
|
1916
|
+
* subscriptions do not support analytics summary.
|
|
1917
|
+
*/
|
|
1918
|
+
interface ICastSubscription extends IRuntimeSubscription {
|
|
1919
|
+
/**
|
|
1920
|
+
* Send analytics summary with projection results to Chromecast review.
|
|
1921
|
+
* Called by browser when workout completes to show focused review.
|
|
1922
|
+
*/
|
|
1923
|
+
sendAnalyticsSummary(projections: Array<{
|
|
1924
|
+
name: string;
|
|
1925
|
+
value: number;
|
|
1926
|
+
unit: string;
|
|
1927
|
+
metricType?: string;
|
|
1928
|
+
}>, totalDurationMs: number, completedSegments: number): void;
|
|
1929
|
+
}
|
|
1930
|
+
/**
|
|
1931
|
+
* Type guard to check if a subscription supports Chromecast analytics.
|
|
1932
|
+
*/
|
|
1933
|
+
declare function isCastSubscription(s: IRuntimeSubscription): s is ICastSubscription;
|
|
1934
|
+
|
|
1883
1935
|
/**
|
|
1884
1936
|
* Action that pushes a compiled block onto the runtime stack.
|
|
1885
1937
|
* Used by behaviors to add child blocks for execution.
|
|
@@ -3154,6 +3206,125 @@ declare class RuntimeAdapter implements IRuntimeAdapter {
|
|
|
3154
3206
|
private getMemoryIcon;
|
|
3155
3207
|
}
|
|
3156
3208
|
|
|
3209
|
+
/**
|
|
3210
|
+
* LocalRuntimeSubscription — a no-op subscription that simply receives
|
|
3211
|
+
* stack snapshots and output statements without transforming them.
|
|
3212
|
+
*
|
|
3213
|
+
* This is the "identity" subscription: the SubscriptionManager fans out
|
|
3214
|
+
* runtime events to all subscriptions, and the local one simply consumes
|
|
3215
|
+
* them for any local-side effect (e.g., updating the workbench store).
|
|
3216
|
+
*
|
|
3217
|
+
* An optional callback can be provided for each event type to allow
|
|
3218
|
+
* the consumer to react to state changes.
|
|
3219
|
+
*/
|
|
3220
|
+
declare class LocalRuntimeSubscription implements IRuntimeSubscription {
|
|
3221
|
+
readonly id: string;
|
|
3222
|
+
private onStackSnapshotCallback?;
|
|
3223
|
+
private onOutputCallback?;
|
|
3224
|
+
constructor(options?: {
|
|
3225
|
+
id?: string;
|
|
3226
|
+
onStackSnapshot?: (snapshot: StackSnapshot) => void;
|
|
3227
|
+
onOutput?: (output: IOutputStatement) => void;
|
|
3228
|
+
});
|
|
3229
|
+
onStackSnapshot(snapshot: StackSnapshot): void;
|
|
3230
|
+
onOutput(output: IOutputStatement): void;
|
|
3231
|
+
dispose(): void;
|
|
3232
|
+
}
|
|
3233
|
+
|
|
3234
|
+
/**
|
|
3235
|
+
* Provides bidirectional event flow between runtime consumers.
|
|
3236
|
+
*
|
|
3237
|
+
* Implementations determine the transport:
|
|
3238
|
+
* - LocalEventProvider dispatches directly to the local IScriptRuntime
|
|
3239
|
+
* - ChromecastEventProvider sends/receives events over the RPC transport
|
|
3240
|
+
*
|
|
3241
|
+
* This abstracts away whether an event originates locally (button press)
|
|
3242
|
+
* or remotely (Chromecast D-Pad) — the runtime processes both identically.
|
|
3243
|
+
*/
|
|
3244
|
+
interface IRuntimeEventProvider {
|
|
3245
|
+
/**
|
|
3246
|
+
* Dispatch an event to be processed by the runtime.
|
|
3247
|
+
* For local: calls runtime.handle(event) directly.
|
|
3248
|
+
* For chromecast: serializes and sends over the RPC channel.
|
|
3249
|
+
*/
|
|
3250
|
+
dispatch(event: IEvent): void;
|
|
3251
|
+
/**
|
|
3252
|
+
* Listen for incoming events (from remote sources or the runtime event bus).
|
|
3253
|
+
* Returns an unsubscribe function.
|
|
3254
|
+
*/
|
|
3255
|
+
onEvent(handler: (event: IEvent) => void): Unsubscribe;
|
|
3256
|
+
/**
|
|
3257
|
+
* Clean up resources.
|
|
3258
|
+
*/
|
|
3259
|
+
dispose(): void;
|
|
3260
|
+
}
|
|
3261
|
+
|
|
3262
|
+
/**
|
|
3263
|
+
* LocalEventProvider — dispatches events directly to the local IScriptRuntime.
|
|
3264
|
+
*
|
|
3265
|
+
* - dispatch(event) → runtime.handle(event), which triggers the event bus
|
|
3266
|
+
* and executes resulting actions in a single turn.
|
|
3267
|
+
* - onEvent(handler) → registers on the runtime event bus to receive
|
|
3268
|
+
* all events (using the 'global' callback registration path).
|
|
3269
|
+
*/
|
|
3270
|
+
declare class LocalEventProvider implements IRuntimeEventProvider {
|
|
3271
|
+
private readonly runtime;
|
|
3272
|
+
private static subscriptionCounter;
|
|
3273
|
+
private unsubscribes;
|
|
3274
|
+
private disposed;
|
|
3275
|
+
constructor(runtime: IScriptRuntime);
|
|
3276
|
+
dispatch(event: IEvent): void;
|
|
3277
|
+
onEvent(handler: (event: IEvent) => void): Unsubscribe;
|
|
3278
|
+
dispose(): void;
|
|
3279
|
+
}
|
|
3280
|
+
|
|
3281
|
+
/**
|
|
3282
|
+
* SubscriptionManager — fans out runtime stack and output events to
|
|
3283
|
+
* multiple IRuntimeSubscription instances.
|
|
3284
|
+
*
|
|
3285
|
+
* Lifecycle:
|
|
3286
|
+
* 1. Created when a runtime is initialized (by RuntimeLifecycleProvider)
|
|
3287
|
+
* 2. Always holds a LocalRuntimeSubscription for the browser UI
|
|
3288
|
+
* 3. ChromecastRuntimeSubscription added/removed via cast session lifecycle
|
|
3289
|
+
* 4. Disposed when the runtime is disposed
|
|
3290
|
+
*
|
|
3291
|
+
* The manager subscribes once to the runtime's stack and output APIs,
|
|
3292
|
+
* then iterates over all registered subscriptions for each event.
|
|
3293
|
+
*/
|
|
3294
|
+
declare class SubscriptionManager {
|
|
3295
|
+
private readonly runtime;
|
|
3296
|
+
private subscriptions;
|
|
3297
|
+
private stackUnsub;
|
|
3298
|
+
private outputUnsub;
|
|
3299
|
+
private disposed;
|
|
3300
|
+
constructor(runtime: IScriptRuntime);
|
|
3301
|
+
/**
|
|
3302
|
+
* Register a subscription. If a subscription with the same ID already exists,
|
|
3303
|
+
* the old one is disposed and replaced.
|
|
3304
|
+
*
|
|
3305
|
+
* New subscriptions immediately receive the current stack state and any
|
|
3306
|
+
* existing output statements to catch them up.
|
|
3307
|
+
*/
|
|
3308
|
+
add(subscription: IRuntimeSubscription): void;
|
|
3309
|
+
/**
|
|
3310
|
+
* Remove and dispose a subscription by ID.
|
|
3311
|
+
* Returns true if the subscription was found and removed.
|
|
3312
|
+
*/
|
|
3313
|
+
remove(id: string): boolean;
|
|
3314
|
+
/**
|
|
3315
|
+
* Check if a subscription with the given ID is registered.
|
|
3316
|
+
*/
|
|
3317
|
+
has(id: string): boolean;
|
|
3318
|
+
/**
|
|
3319
|
+
* Get the number of active subscriptions.
|
|
3320
|
+
*/
|
|
3321
|
+
get count(): number;
|
|
3322
|
+
/**
|
|
3323
|
+
* Dispose all subscriptions and unsubscribe from the runtime.
|
|
3324
|
+
*/
|
|
3325
|
+
dispose(): void;
|
|
3326
|
+
}
|
|
3327
|
+
|
|
3157
3328
|
/**
|
|
3158
3329
|
* AST for the composed-calculation expression language (spec §2).
|
|
3159
3330
|
*
|
|
@@ -4226,13 +4397,13 @@ declare function toStoredOutputStatement(output: IOutputStatement | OutputStatem
|
|
|
4226
4397
|
* Auto-generated build version metadata.
|
|
4227
4398
|
* Do not edit directly; updated by scripts/stamp-version.ts
|
|
4228
4399
|
*/
|
|
4229
|
-
declare const VERSION = "0.1.
|
|
4230
|
-
declare const GIT_SHA = "
|
|
4231
|
-
declare const BUILD_TIME = "2026-08-18T18:
|
|
4400
|
+
declare const VERSION = "0.1.8";
|
|
4401
|
+
declare const GIT_SHA = "52af1e3";
|
|
4402
|
+
declare const BUILD_TIME = "2026-08-18T18:19:06.086Z";
|
|
4232
4403
|
declare const SEMVER: {
|
|
4233
|
-
readonly version: "0.1.
|
|
4234
|
-
readonly gitSha: "
|
|
4235
|
-
readonly buildTime: "2026-08-18T18:
|
|
4404
|
+
readonly version: "0.1.8";
|
|
4405
|
+
readonly gitSha: "52af1e3";
|
|
4406
|
+
readonly buildTime: "2026-08-18T18:19:06.086Z";
|
|
4236
4407
|
};
|
|
4237
4408
|
|
|
4238
|
-
export { AbortSessionAction, type ActionDescriptor, type ActionPrimitive, AnalyticsContext, AnalyticsEngine, type AnalyticsProfileContext, type AnalyticsResult, AnalyticsTransformer, BUILD_TIME, BUILTIN_CALCS, BUNDLED_EFFORT_COUNT, BehaviorContext, BlockContext, BlockLifecycleOptions, CONSUMED_HINTS, CONSUMED_HINT_KEYS, type CalculationDefinition$1 as CalcDefinition, CalcEngine, type CalcOrigin, type CalcScope, type CalculationDefinition as CalculateBlockDefinition, type CalculateBlockParseError, type CalculateBlockParseResult, CalculateBlockProcessor, CalculationRegistry, CardioDialect, ClearChildrenAction, ClimbDialect, type ClimbGradeMetricValue, type ClimbGradeSystem, ClimbMetricType, CompileAndPushBlockAction, CompletionDecision, type CreateAnalyticsEngineOptions, type CreateAnalyticsEngineResult, CrossFitDialect, DAY, DEFAULT_UNRESOLVED_EFFORT_MET, DIM_LENGTH, DIM_MASS, DIM_TIME, DIM_ZERO, type DayRollup, DialectStack, type Dimension, type DurationPrimitive, EFFORT_DATA_METRIC_TYPE, EffortBlock, type EffortBlockConfig, type EffortPrimitive, EffortRegistrySource, EffortResolutionOptions, EffortResolver, EffortResolverOptions, EmitEventAction, EmitSystemOutputAction, ErrorAction, EventBus, type EventHandlerRegistration, ExecutionContext, type FuzzyCandidate, GIT_SHA, HabitsDialect, type HeadingPrimitive, IAnalyticsEngine, type IAnalyticsProfile, IBlockContext, IEffort, IEffortRegistry, IEffortResolver, IEvent, IEventBus, IJitCompiler, type ILookupTable, IMemoryLocation, IMemoryReference, type IMetricPresentationPolicy, INowProvider, IRealtimeProcessor, IRuntimeAction, IRuntimeBehavior, IRuntimeBlock, type IRuntimeBlockStrategy, IRuntimeClock, type IRuntimeFactory, IRuntimeStack, IScript, IScriptRuntime, ISummaryProcessor, InMemoryEffortRegistry, JitCompiler, type LapPrimitive, type LineLocator, type LogLevel, LookupRegistry, MdTimerRuntime, MemoryTag, MemoryTypeEnum, type MetricObjectPrimitive, type MetricPresentationSurface, type MetricPresentationToken, type MetricRenderKind, type MetricTone, MetricVisibility, type MockClock, NextAction, NextEvent, NextEventHandler, OutputEmitter, PREDEFINED_SOUNDS, PRODUCTION_STRATEGIES, type ParseOptions, PlaySoundAction, PopBlockAction, type PredefinedSoundName, ProjectionResult, type PropertyPrimitive, PushBlockAction, PushRestBlockAction, type QuantityPrimitive, RegisterEventHandlerAction, Registry, ResolvedEffort, type ResolvedEffortData, RestBlock, type RestBlockConfig, type RoundsPrimitive, RuntimeAdapter, RuntimeBlock, type RuntimeBlockOptions, RuntimeBuilder, type RuntimeButton, RuntimeClock, type RuntimeController, type RuntimeControls, RuntimeError, RuntimeFactory, type RuntimeLogEntry, RuntimeLogger, RuntimeMemory, type RuntimeMemoryLocation, RuntimeObservers, RuntimeStack, SEMVER, STANDARD_UNITS, STORE_CALCS, ScriptRuntime, type SegmentWithMetadata, SessionRootBlock, type SessionRootConfig, SnapshotClock, type SoundBehaviorConfig, type SoundCue, type SoundCueState, type SoundState, type SourceInput, type SpanList, StackObserver, StackSnapshot, StandardAnalyticsProfile, StartSessionAction, type StartSessionOptions, StartWorkoutAction, type StartWorkoutOptions, type SyntaxFacts, type SyntaxMeta, type SyntaxPrimitive, type SyntaxStatement, type TextPrimitive, ThrowError, ThrowErrorAction, TimeSpan, TimerState, TwoPassEffortResolutionProcess, TypedMemoryReference, type UnitDef$1 as UnitDef, type UnitMatch, UnitRegistry, UnitSet, UnitsDialect, UnregisterEventHandlerAction, Unsubscribe, UpdateNextPreviewAction, VERSION, WaitingToStartBlock, WhiteboardScript, WodDialect, YogaDialect, buildTooltip, bundledEfforts, index as calc, calculateElapsed, classifyStatements, closeCurrentSpan, commonFixtureSet, computeColumnLabel, computeLabel, computeWorkloadRollups, createAnalyticsEngineForBlock, createCalcEngine, createCompiler, createDialectStack, createLineLocator, createPolicy as createMetricPresentationPolicy, createMockClock, createParser, dailySessionLoads, dayBucket, dialectRegistry, dialectStack, evaluate, evaluateCalculateDefinitions, extractEffortData, extractMetrics, extractStatements, extractStatementsRaw, extractSyntaxFacts, findBestFuzzyMatch, fixtureBackSquat, fixtureBurpee, fixturePlank, fixtureRowing, fixtureRunning, fixtureUserCustom, fixtureUserOverride, formatDuration, metricsToLabel as fragmentsToLabel, fullFixtureSet, fuseUnits, fuseUnitsInMetrics, getAnalyticsFromLogs, getAnalyticsFromRuntime, getHints, hasHint, hintMetric, hintsToContainer, isTimeLikeMetric, isWithinThreshold, levenshteinDistance, metricPresentation, mutateTimerSpans, normalizeForFuzzy, openSpan, parseCalcLine, parseCalculateBlock, parseExpression, parseScript, readTimer, realtimeProcessorRegistry, resolveDominantOrigin, sharedParser, startSpan, strategyRegistry, summaryProcessorRegistry, toStoredOutputStatement, parser as whiteboardParser, whiteboardScript, whiteboardScriptLanguage };
|
|
4409
|
+
export { AbortSessionAction, type ActionDescriptor, type ActionPrimitive, AnalyticsContext, AnalyticsEngine, type AnalyticsProfileContext, type AnalyticsResult, AnalyticsTransformer, BUILD_TIME, BUILTIN_CALCS, BUNDLED_EFFORT_COUNT, BehaviorContext, BlockContext, BlockLifecycleOptions, CONSUMED_HINTS, CONSUMED_HINT_KEYS, type CalculationDefinition$1 as CalcDefinition, CalcEngine, type CalcOrigin, type CalcScope, type CalculationDefinition as CalculateBlockDefinition, type CalculateBlockParseError, type CalculateBlockParseResult, CalculateBlockProcessor, CalculationRegistry, CardioDialect, ClearChildrenAction, ClimbDialect, type ClimbGradeMetricValue, type ClimbGradeSystem, ClimbMetricType, CompileAndPushBlockAction, CompletionDecision, type CreateAnalyticsEngineOptions, type CreateAnalyticsEngineResult, CrossFitDialect, DAY, DEFAULT_UNRESOLVED_EFFORT_MET, DIM_LENGTH, DIM_MASS, DIM_TIME, DIM_ZERO, type DayRollup, DialectStack, type Dimension, type DurationPrimitive, EFFORT_DATA_METRIC_TYPE, EffortBlock, type EffortBlockConfig, type EffortPrimitive, EffortRegistrySource, EffortResolutionOptions, EffortResolver, EffortResolverOptions, EmitEventAction, EmitSystemOutputAction, ErrorAction, EventBus, type EventHandlerRegistration, ExecutionContext, type ExecutionSnapshot, type FuzzyCandidate, GIT_SHA, HabitsDialect, type HeadingPrimitive, IAnalyticsEngine, type IAnalyticsProfile, IBlockContext, type ICastSubscription, IEffort, IEffortRegistry, IEffortResolver, IEvent, IEventBus, IEventHandler, IJitCompiler, type ILookupTable, IMemoryLocation, IMemoryReference, type IMetricPresentationPolicy, INowProvider, IRealtimeProcessor, IRuntimeAction, IRuntimeBehavior, IRuntimeBlock, type IRuntimeBlockStrategy, IRuntimeClock, type IRuntimeFactory, IRuntimeStack, type IRuntimeSubscription, IScript, IScriptRuntime, ISummaryProcessor, InMemoryEffortRegistry, JitCompiler, type LapPrimitive, type LineLocator, LocalEventProvider, LocalRuntimeSubscription, type LogLevel, LookupRegistry, MdTimerRuntime, type MemoryEntry, MemoryTag, MemoryTypeEnum, type MetricObjectPrimitive, type MetricPresentationSurface, type MetricPresentationToken, type MetricRenderKind, type MetricTone, MetricVisibility, type MockClock, NextAction, NextEvent, NextEventHandler, OutputEmitter, PREDEFINED_SOUNDS, PRODUCTION_STRATEGIES, type ParseOptions, PlaySoundAction, PopBlockAction, type PredefinedSoundName, ProjectionResult, type PropertyPrimitive, PushBlockAction, PushRestBlockAction, type QuantityPrimitive, RegisterEventHandlerAction, Registry, ResolvedEffort, type ResolvedEffortData, RestBlock, type RestBlockConfig, type RoundsPrimitive, RuntimeAdapter, RuntimeBlock, type RuntimeBlockOptions, RuntimeBuilder, type RuntimeButton, RuntimeClock, type RuntimeController, type RuntimeControls, RuntimeError, RuntimeFactory, type RuntimeLogEntry, RuntimeLogger, RuntimeMemory, type RuntimeMemoryLocation, RuntimeObservers, RuntimeStack, SEMVER, STANDARD_UNITS, STORE_CALCS, ScriptRuntime, type SegmentWithMetadata, SessionRootBlock, type SessionRootConfig, SnapshotClock, type SoundBehaviorConfig, type SoundCue, type SoundCueState, type SoundState, type SourceInput, type SpanList, StackObserver, StackSnapshot, StandardAnalyticsProfile, StartSessionAction, type StartSessionOptions, StartWorkoutAction, type StartWorkoutOptions, SubscriptionManager, type SyntaxFacts, type SyntaxMeta, type SyntaxPrimitive, type SyntaxStatement, type TextPrimitive, ThrowError, ThrowErrorAction, TimeSpan, TimerState, TwoPassEffortResolutionProcess, TypedMemoryReference, type UnitDef$1 as UnitDef, type UnitMatch, UnitRegistry, UnitSet, UnitsDialect, UnregisterEventHandlerAction, Unsubscribe, UpdateNextPreviewAction, VERSION, WaitingToStartBlock, WhiteboardScript, WodDialect, YogaDialect, buildTooltip, bundledEfforts, index as calc, calculateElapsed, classifyStatements, closeCurrentSpan, commonFixtureSet, computeColumnLabel, computeLabel, computeWorkloadRollups, createAnalyticsEngineForBlock, createCalcEngine, createCompiler, createDialectStack, createLineLocator, createPolicy as createMetricPresentationPolicy, createMockClock, createParser, dailySessionLoads, dayBucket, dialectRegistry, dialectStack, evaluate, evaluateCalculateDefinitions, extractEffortData, extractMetrics, extractStatements, extractStatementsRaw, extractSyntaxFacts, findBestFuzzyMatch, fixtureBackSquat, fixtureBurpee, fixturePlank, fixtureRowing, fixtureRunning, fixtureUserCustom, fixtureUserOverride, formatDuration, metricsToLabel as fragmentsToLabel, fullFixtureSet, fuseUnits, fuseUnitsInMetrics, getAnalyticsFromLogs, getAnalyticsFromRuntime, getHints, hasHint, hintMetric, hintsToContainer, isCastSubscription, isTimeLikeMetric, isWithinThreshold, levenshteinDistance, metricPresentation, mutateTimerSpans, normalizeForFuzzy, openSpan, parseCalcLine, parseCalculateBlock, parseExpression, parseScript, readTimer, realtimeProcessorRegistry, resolveDominantOrigin, sharedParser, startSpan, strategyRegistry, summaryProcessorRegistry, toStoredOutputStatement, parser as whiteboardParser, whiteboardScript, whiteboardScriptLanguage };
|
package/dist/index.mjs
CHANGED
|
@@ -5542,6 +5542,11 @@ var RuntimeStack = class {
|
|
|
5542
5542
|
}
|
|
5543
5543
|
}
|
|
5544
5544
|
};
|
|
5545
|
+
|
|
5546
|
+
// src/runtime/contracts/ICastSubscription.ts
|
|
5547
|
+
function isCastSubscription(s) {
|
|
5548
|
+
return "sendAnalyticsSummary" in s && typeof s.sendAnalyticsSummary === "function";
|
|
5549
|
+
}
|
|
5545
5550
|
var CompletionTimestampBehavior = class {
|
|
5546
5551
|
completionTime;
|
|
5547
5552
|
wasComplete = false;
|
|
@@ -11864,6 +11869,170 @@ var RuntimeAdapter = class {
|
|
|
11864
11869
|
return icons[memoryType];
|
|
11865
11870
|
}
|
|
11866
11871
|
};
|
|
11872
|
+
|
|
11873
|
+
// src/runtime/subscriptions/LocalRuntimeSubscription.ts
|
|
11874
|
+
var LocalRuntimeSubscription = class {
|
|
11875
|
+
id;
|
|
11876
|
+
onStackSnapshotCallback;
|
|
11877
|
+
onOutputCallback;
|
|
11878
|
+
constructor(options) {
|
|
11879
|
+
this.id = options?.id ?? "local";
|
|
11880
|
+
this.onStackSnapshotCallback = options?.onStackSnapshot;
|
|
11881
|
+
this.onOutputCallback = options?.onOutput;
|
|
11882
|
+
}
|
|
11883
|
+
onStackSnapshot(snapshot) {
|
|
11884
|
+
this.onStackSnapshotCallback?.(snapshot);
|
|
11885
|
+
}
|
|
11886
|
+
onOutput(output) {
|
|
11887
|
+
this.onOutputCallback?.(output);
|
|
11888
|
+
}
|
|
11889
|
+
dispose() {
|
|
11890
|
+
this.onStackSnapshotCallback = void 0;
|
|
11891
|
+
this.onOutputCallback = void 0;
|
|
11892
|
+
}
|
|
11893
|
+
};
|
|
11894
|
+
|
|
11895
|
+
// src/runtime/subscriptions/LocalEventProvider.ts
|
|
11896
|
+
var LocalEventProvider = class _LocalEventProvider {
|
|
11897
|
+
constructor(runtime) {
|
|
11898
|
+
this.runtime = runtime;
|
|
11899
|
+
}
|
|
11900
|
+
runtime;
|
|
11901
|
+
static subscriptionCounter = 0;
|
|
11902
|
+
unsubscribes = [];
|
|
11903
|
+
disposed = false;
|
|
11904
|
+
dispatch(event) {
|
|
11905
|
+
if (this.disposed) return;
|
|
11906
|
+
this.runtime.handle(event);
|
|
11907
|
+
}
|
|
11908
|
+
onEvent(handler) {
|
|
11909
|
+
if (this.disposed) return () => {
|
|
11910
|
+
};
|
|
11911
|
+
const ownerId = `local-event-provider-${_LocalEventProvider.subscriptionCounter++}`;
|
|
11912
|
+
const unsubscribeFromBus = this.runtime.eventBus.on("*", (event) => {
|
|
11913
|
+
handler(event);
|
|
11914
|
+
}, ownerId);
|
|
11915
|
+
const unsubscribe = () => {
|
|
11916
|
+
unsubscribeFromBus();
|
|
11917
|
+
this.unsubscribes = this.unsubscribes.filter((candidate) => candidate !== unsubscribe);
|
|
11918
|
+
};
|
|
11919
|
+
this.unsubscribes.push(unsubscribe);
|
|
11920
|
+
return unsubscribe;
|
|
11921
|
+
}
|
|
11922
|
+
dispose() {
|
|
11923
|
+
if (this.disposed) return;
|
|
11924
|
+
this.disposed = true;
|
|
11925
|
+
const unsubscribes = [...this.unsubscribes];
|
|
11926
|
+
this.unsubscribes = [];
|
|
11927
|
+
for (const unsubscribe of unsubscribes) {
|
|
11928
|
+
unsubscribe();
|
|
11929
|
+
}
|
|
11930
|
+
}
|
|
11931
|
+
};
|
|
11932
|
+
|
|
11933
|
+
// src/runtime/subscriptions/SubscriptionManager.ts
|
|
11934
|
+
var SubscriptionManager = class {
|
|
11935
|
+
constructor(runtime) {
|
|
11936
|
+
this.runtime = runtime;
|
|
11937
|
+
this.stackUnsub = this.runtime.subscribeToStack((snapshot) => {
|
|
11938
|
+
for (const sub of this.subscriptions.values()) {
|
|
11939
|
+
try {
|
|
11940
|
+
sub.onStackSnapshot(snapshot);
|
|
11941
|
+
} catch (err) {
|
|
11942
|
+
console.error(`[SubscriptionManager] Error in subscription '${sub.id}' onStackSnapshot:`, err);
|
|
11943
|
+
}
|
|
11944
|
+
}
|
|
11945
|
+
});
|
|
11946
|
+
this.outputUnsub = this.runtime.subscribeToOutput((output) => {
|
|
11947
|
+
for (const sub of this.subscriptions.values()) {
|
|
11948
|
+
try {
|
|
11949
|
+
sub.onOutput(output);
|
|
11950
|
+
} catch (err) {
|
|
11951
|
+
console.error(`[SubscriptionManager] Error in subscription '${sub.id}' onOutput:`, err);
|
|
11952
|
+
}
|
|
11953
|
+
}
|
|
11954
|
+
});
|
|
11955
|
+
}
|
|
11956
|
+
runtime;
|
|
11957
|
+
subscriptions = /* @__PURE__ */ new Map();
|
|
11958
|
+
stackUnsub = null;
|
|
11959
|
+
outputUnsub = null;
|
|
11960
|
+
disposed = false;
|
|
11961
|
+
/**
|
|
11962
|
+
* Register a subscription. If a subscription with the same ID already exists,
|
|
11963
|
+
* the old one is disposed and replaced.
|
|
11964
|
+
*
|
|
11965
|
+
* New subscriptions immediately receive the current stack state and any
|
|
11966
|
+
* existing output statements to catch them up.
|
|
11967
|
+
*/
|
|
11968
|
+
add(subscription) {
|
|
11969
|
+
if (this.disposed) {
|
|
11970
|
+
console.warn("[SubscriptionManager] Cannot add subscription after dispose");
|
|
11971
|
+
return;
|
|
11972
|
+
}
|
|
11973
|
+
const existing = this.subscriptions.get(subscription.id);
|
|
11974
|
+
if (existing) {
|
|
11975
|
+
existing.dispose();
|
|
11976
|
+
}
|
|
11977
|
+
this.subscriptions.set(subscription.id, subscription);
|
|
11978
|
+
try {
|
|
11979
|
+
subscription.onStackSnapshot({
|
|
11980
|
+
type: "initial",
|
|
11981
|
+
blocks: [...this.runtime.stack.blocks],
|
|
11982
|
+
depth: this.runtime.stack.count,
|
|
11983
|
+
clockTime: this.runtime.clock.currentDate
|
|
11984
|
+
});
|
|
11985
|
+
const currentOutputs = this.runtime.getOutputStatements();
|
|
11986
|
+
for (const output of currentOutputs) {
|
|
11987
|
+
subscription.onOutput(output);
|
|
11988
|
+
}
|
|
11989
|
+
} catch (err) {
|
|
11990
|
+
console.error(`[SubscriptionManager] Error catching up subscription '${subscription.id}':`, err);
|
|
11991
|
+
}
|
|
11992
|
+
}
|
|
11993
|
+
/**
|
|
11994
|
+
* Remove and dispose a subscription by ID.
|
|
11995
|
+
* Returns true if the subscription was found and removed.
|
|
11996
|
+
*/
|
|
11997
|
+
remove(id) {
|
|
11998
|
+
const sub = this.subscriptions.get(id);
|
|
11999
|
+
if (!sub) return false;
|
|
12000
|
+
sub.dispose();
|
|
12001
|
+
this.subscriptions.delete(id);
|
|
12002
|
+
return true;
|
|
12003
|
+
}
|
|
12004
|
+
/**
|
|
12005
|
+
* Check if a subscription with the given ID is registered.
|
|
12006
|
+
*/
|
|
12007
|
+
has(id) {
|
|
12008
|
+
return this.subscriptions.has(id);
|
|
12009
|
+
}
|
|
12010
|
+
/**
|
|
12011
|
+
* Get the number of active subscriptions.
|
|
12012
|
+
*/
|
|
12013
|
+
get count() {
|
|
12014
|
+
return this.subscriptions.size;
|
|
12015
|
+
}
|
|
12016
|
+
/**
|
|
12017
|
+
* Dispose all subscriptions and unsubscribe from the runtime.
|
|
12018
|
+
*/
|
|
12019
|
+
dispose() {
|
|
12020
|
+
if (this.disposed) return;
|
|
12021
|
+
this.disposed = true;
|
|
12022
|
+
this.stackUnsub?.();
|
|
12023
|
+
this.stackUnsub = null;
|
|
12024
|
+
this.outputUnsub?.();
|
|
12025
|
+
this.outputUnsub = null;
|
|
12026
|
+
for (const sub of this.subscriptions.values()) {
|
|
12027
|
+
try {
|
|
12028
|
+
sub.dispose();
|
|
12029
|
+
} catch (err) {
|
|
12030
|
+
console.error(`[SubscriptionManager] Error disposing subscription '${sub.id}':`, err);
|
|
12031
|
+
}
|
|
12032
|
+
}
|
|
12033
|
+
this.subscriptions.clear();
|
|
12034
|
+
}
|
|
12035
|
+
};
|
|
11867
12036
|
function formatMetricLabel(key) {
|
|
11868
12037
|
return key.charAt(0).toUpperCase() + key.slice(1).replace(/_/g, " ");
|
|
11869
12038
|
}
|
|
@@ -13032,15 +13201,15 @@ function toStoredOutputStatement(output) {
|
|
|
13032
13201
|
}
|
|
13033
13202
|
|
|
13034
13203
|
// src/version.ts
|
|
13035
|
-
var VERSION = "0.1.
|
|
13036
|
-
var GIT_SHA = "
|
|
13037
|
-
var BUILD_TIME = "2026-08-18T18:
|
|
13204
|
+
var VERSION = "0.1.8";
|
|
13205
|
+
var GIT_SHA = "52af1e3";
|
|
13206
|
+
var BUILD_TIME = "2026-08-18T18:19:06.086Z";
|
|
13038
13207
|
var SEMVER = {
|
|
13039
|
-
version: "0.1.
|
|
13040
|
-
gitSha: "
|
|
13041
|
-
buildTime: "2026-08-18T18:
|
|
13208
|
+
version: "0.1.8",
|
|
13209
|
+
gitSha: "52af1e3",
|
|
13210
|
+
buildTime: "2026-08-18T18:19:06.086Z"
|
|
13042
13211
|
};
|
|
13043
13212
|
|
|
13044
|
-
export { AbortSessionAction, AnalyticsEngine, AnalyticsTransformer, BUILD_TIME, BUILTIN_CALCS, BUNDLED_EFFORT_COUNT, BehaviorContext, BlockContext, CONSUMED_HINTS, CONSUMED_HINT_KEYS, CalcEngine, CalculateBlockProcessor, CalculationRegistry, CardioDialect, ClearChildrenAction, ClimbDialect, ClimbMetricType, CompileAndPushBlockAction, CrossFitDialect, DAY, DEFAULT_RESOLVER_OPTIONS, DEFAULT_UNRESOLVED_EFFORT_MET, DIM_LENGTH, DIM_MASS, DIM_TIME, DIM_ZERO, DISCIPLINE_FACTORS, DialectStack, EFFORT_DATA_METRIC_TYPE, EFFORT_DISCIPLINES, EFFORT_REGISTRY_ORIGINS, EffortBlock, EffortResolver, EmitEventAction, EmitSystemOutputAction, ErrorAction, EventBus, ExecutionContext, GIT_SHA, HabitsDialect, INTENSITY_TIERS, InMemoryEffortRegistry, JitCompiler, LookupRegistry, MdTimerRuntime, MemoryLocation, MemoryTypeEnum, NextAction, NextEvent, NextEventHandler, OutputEmitter, PREDEFINED_SOUNDS, PRODUCTION_STRATEGIES, PlaySoundAction, PopBlockAction, PushBlockAction, PushRestBlockAction, RegisterEventHandlerAction, Registry, RestBlock, RuntimeAdapter, RuntimeBlock, RuntimeBuilder, RuntimeClock, RuntimeFactory, RuntimeLogger, RuntimeMemory, RuntimeObservers, RuntimeStack, SEMVER, STANDARD_UNITS, STORE_CALCS, ScriptRuntime, SessionRootBlock, SnapshotClock, StandardAnalyticsProfile, StartSessionAction, StartWorkoutAction, ThrowError, ThrowErrorAction, TimeSpan, TwoPassEffortResolutionProcess, TypedMemoryReference, UnitRegistry, UnitSet, UnitsDialect, UnregisterEventHandlerAction, UpdateNextPreviewAction, VERSION, VISIBILITY_ICONS, VISIBILITY_LABELS, WaitingToStartBlock, WhiteboardScript, WodDialect, YogaDialect, buildTooltip, bundledEfforts, calc_exports as calc, calculateElapsed, classifyStatements, closeCurrentSpan, commonFixtureSet, computeColumnLabel, computeLabel, computeWorkloadRollups, createAnalyticsEngineForBlock, createCalcEngine, createCompiler, createDialectStack, createLineLocator, createPolicy as createMetricPresentationPolicy, createMockClock, createParser, dailySessionLoads, dayBucket, dialectRegistry, dialectStack, disciplineFactorFor, evaluate, evaluateCalculateDefinitions, extractEffortData, extractMetrics, extractStatements, extractStatementsRaw, extractSyntaxFacts, filterTagsByVisibility, findBestFuzzyMatch, fixtureBackSquat, fixtureBurpee, fixturePlank, fixtureRowing, fixtureRunning, fixtureUserCustom, fixtureUserOverride, formatDuration, metricsToLabel as fragmentsToLabel, fullFixtureSet, fuseUnits, fuseUnitsInMetrics, getAnalyticsFromLogs, getAnalyticsFromRuntime, getHints, getMetricVisibility, hasHint, hintMetric, hintsToContainer, isEffortDiscipline, isFragmentTag, isTimeLikeMetric, isWithinThreshold, levenshteinDistance, metricPresentation, mutateTimerSpans, normalizeForFuzzy, openSpan, parseCalcLine, parseCalculateBlock, parseExpression, parseScript, readTimer, realtimeProcessorRegistry, resolveDominantOrigin, sharedParser, startSpan, strategyRegistry, summaryProcessorRegistry, toStoredOutputStatement, parser as whiteboardParser, whiteboardScript, whiteboardScriptLanguage };
|
|
13213
|
+
export { AbortSessionAction, AnalyticsEngine, AnalyticsTransformer, BUILD_TIME, BUILTIN_CALCS, BUNDLED_EFFORT_COUNT, BehaviorContext, BlockContext, CONSUMED_HINTS, CONSUMED_HINT_KEYS, CalcEngine, CalculateBlockProcessor, CalculationRegistry, CardioDialect, ClearChildrenAction, ClimbDialect, ClimbMetricType, CompileAndPushBlockAction, CrossFitDialect, DAY, DEFAULT_RESOLVER_OPTIONS, DEFAULT_UNRESOLVED_EFFORT_MET, DIM_LENGTH, DIM_MASS, DIM_TIME, DIM_ZERO, DISCIPLINE_FACTORS, DialectStack, EFFORT_DATA_METRIC_TYPE, EFFORT_DISCIPLINES, EFFORT_REGISTRY_ORIGINS, EffortBlock, EffortResolver, EmitEventAction, EmitSystemOutputAction, ErrorAction, EventBus, ExecutionContext, GIT_SHA, HabitsDialect, INTENSITY_TIERS, InMemoryEffortRegistry, JitCompiler, LocalEventProvider, LocalRuntimeSubscription, LookupRegistry, MdTimerRuntime, MemoryLocation, MemoryTypeEnum, NextAction, NextEvent, NextEventHandler, OutputEmitter, PREDEFINED_SOUNDS, PRODUCTION_STRATEGIES, PlaySoundAction, PopBlockAction, PushBlockAction, PushRestBlockAction, RegisterEventHandlerAction, Registry, RestBlock, RuntimeAdapter, RuntimeBlock, RuntimeBuilder, RuntimeClock, RuntimeFactory, RuntimeLogger, RuntimeMemory, RuntimeObservers, RuntimeStack, SEMVER, STANDARD_UNITS, STORE_CALCS, ScriptRuntime, SessionRootBlock, SnapshotClock, StandardAnalyticsProfile, StartSessionAction, StartWorkoutAction, SubscriptionManager, ThrowError, ThrowErrorAction, TimeSpan, TwoPassEffortResolutionProcess, TypedMemoryReference, UnitRegistry, UnitSet, UnitsDialect, UnregisterEventHandlerAction, UpdateNextPreviewAction, VERSION, VISIBILITY_ICONS, VISIBILITY_LABELS, WaitingToStartBlock, WhiteboardScript, WodDialect, YogaDialect, buildTooltip, bundledEfforts, calc_exports as calc, calculateElapsed, classifyStatements, closeCurrentSpan, commonFixtureSet, computeColumnLabel, computeLabel, computeWorkloadRollups, createAnalyticsEngineForBlock, createCalcEngine, createCompiler, createDialectStack, createLineLocator, createPolicy as createMetricPresentationPolicy, createMockClock, createParser, dailySessionLoads, dayBucket, dialectRegistry, dialectStack, disciplineFactorFor, evaluate, evaluateCalculateDefinitions, extractEffortData, extractMetrics, extractStatements, extractStatementsRaw, extractSyntaxFacts, filterTagsByVisibility, findBestFuzzyMatch, fixtureBackSquat, fixtureBurpee, fixturePlank, fixtureRowing, fixtureRunning, fixtureUserCustom, fixtureUserOverride, formatDuration, metricsToLabel as fragmentsToLabel, fullFixtureSet, fuseUnits, fuseUnitsInMetrics, getAnalyticsFromLogs, getAnalyticsFromRuntime, getHints, getMetricVisibility, hasHint, hintMetric, hintsToContainer, isCastSubscription, isEffortDiscipline, isFragmentTag, isTimeLikeMetric, isWithinThreshold, levenshteinDistance, metricPresentation, mutateTimerSpans, normalizeForFuzzy, openSpan, parseCalcLine, parseCalculateBlock, parseExpression, parseScript, readTimer, realtimeProcessorRegistry, resolveDominantOrigin, sharedParser, startSpan, strategyRegistry, summaryProcessorRegistry, toStoredOutputStatement, parser as whiteboardParser, whiteboardScript, whiteboardScriptLanguage };
|
|
13045
13214
|
//# sourceMappingURL=index.mjs.map
|
|
13046
13215
|
//# sourceMappingURL=index.mjs.map
|