@bitcobblers/wod-wiki-lang 0.11.43 → 0.35.2115

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.
@@ -141,11 +141,22 @@ interface IEffort {
141
141
  }
142
142
  interface IEffortRegistry {
143
143
  resolve(slug: string): IEffort | null;
144
+ resolveByAlias(label: string): IEffort | null;
144
145
  list(): readonly IEffort[];
145
146
  listByOrigin(origin: EffortRegistrySource): readonly IEffort[];
146
147
  upsert(effort: IEffort): Promise<void>;
147
148
  delete(slug: string): Promise<void>;
148
149
  loadBundled(): Promise<void>;
150
+ isInitialized(): boolean;
151
+ }
152
+ /**
153
+ * Pluggable asynchronous persistence adapter for user-defined efforts.
154
+ * Implemented by host environments (e.g. IndexedDB in browser, filesystem in CLI).
155
+ */
156
+ interface EffortStorageAdapter {
157
+ load(): Promise<IEffort[]>;
158
+ save(effort: IEffort): Promise<void>;
159
+ delete(slug: string): Promise<void>;
149
160
  }
150
161
  interface EffortResolutionOptions {
151
162
  /** Attribute metrics from /effort/:slug query params or logged execution metrics. */
@@ -383,14 +394,141 @@ interface IRuntimeMemory {
383
394
  release(reference: IMemoryReference): void;
384
395
  }
385
396
 
397
+ /**
398
+ * Configuration for method interception behavior.
399
+ * Defined here (in runtime/contracts) so that both production runtime
400
+ * code and the testing layer can reference it without creating a
401
+ * runtime → testing circular dependency.
402
+ */
403
+ type InterceptMode = 'passthrough' | 'spy' | 'override' | 'ignore';
404
+ /**
405
+ * Configuration for TestableBlock behavior.
406
+ * Used by IRuntimeOptions to allow debug-mode block wrapping.
407
+ */
408
+ interface TestableBlockConfig {
409
+ /** Custom ID for easy identification in visualizations */
410
+ testId?: string;
411
+ /** Custom label override for display purposes */
412
+ labelOverride?: string;
413
+ /** Mode for mount() interception */
414
+ mountMode?: InterceptMode;
415
+ /** Custom mount implementation when mode is 'override' */
416
+ mountOverride?: (runtime: IRuntimeActionable) => IRuntimeAction[];
417
+ /** Mode for next() interception */
418
+ nextMode?: InterceptMode;
419
+ /** Custom next implementation when mode is 'override' */
420
+ nextOverride?: (runtime: IRuntimeActionable) => IRuntimeAction[];
421
+ /** Mode for inspectNext() interception */
422
+ inspectNextMode?: InterceptMode;
423
+ /** Custom inspectNext implementation when mode is 'override' */
424
+ inspectNextOverride?: (runtime: IRuntimeActionable) => CompletionDecision;
425
+ /** Mode for unmount() interception */
426
+ unmountMode?: InterceptMode;
427
+ /** Custom unmount implementation when mode is 'override' */
428
+ unmountOverride?: (runtime: IRuntimeActionable) => IRuntimeAction[];
429
+ /** Mode for dispose() interception */
430
+ disposeMode?: InterceptMode;
431
+ /** Custom dispose implementation when mode is 'override' */
432
+ disposeOverride?: (runtime: IRuntimeActionable) => void;
433
+ }
434
+
435
+ /**
436
+ * Factory function type for wrapping blocks in debug mode.
437
+ * Receives the original block and returns a wrapped version.
438
+ */
439
+ type BlockWrapperFactory = (block: IRuntimeBlock, config?: TestableBlockConfig) => IRuntimeBlock;
440
+ /**
441
+ * Configuration options for ScriptRuntime initialization.
442
+ * These options control debugging, logging, and testing capabilities.
443
+ */
444
+ interface IRuntimeOptions {
445
+ /**
446
+ * Enable debug mode for the runtime.
447
+ * When true:
448
+ * - All blocks pushed to the stack are automatically wrapped with TestableBlock
449
+ * - Additional lifecycle events are logged
450
+ */
451
+ debugMode?: boolean;
452
+ /**
453
+ * Custom factory for wrapping blocks when debugMode is true.
454
+ * If not provided, uses the default TestableBlock wrapper with spy mode.
455
+ */
456
+ blockWrapperFactory?: BlockWrapperFactory;
457
+ /**
458
+ * Default configuration for TestableBlock wrappers.
459
+ * Applied to all blocks wrapped in debug mode unless overridden.
460
+ */
461
+ defaultTestableConfig?: Partial<TestableBlockConfig>;
462
+ /**
463
+ * Enable console logging for runtime debug output.
464
+ * Automatically set to true when debugMode is true.
465
+ */
466
+ enableLogging?: boolean;
467
+ /**
468
+ * Custom log handler for debug events.
469
+ * If provided, called in addition to console logging.
470
+ */
471
+ onDebugLog?: (event: DebugLogEvent) => void;
472
+ /**
473
+ * Maximum depth for nested actions within a single execution turn.
474
+ * Defaults to 20 if not specified.
475
+ */
476
+ maxActionDepth?: number;
477
+ }
478
+ /**
479
+ * Types of debug log events
480
+ */
481
+ type DebugLogEventType = 'block-wrapped' | 'block-mount' | 'block-next' | 'block-unmount' | 'block-dispose' | 'stack-push' | 'stack-pop' | 'memory-allocate' | 'memory-release' | 'event-handled';
482
+ /**
483
+ * Debug log event structure
484
+ */
485
+ interface DebugLogEvent {
486
+ type: DebugLogEventType;
487
+ timestamp: number;
488
+ blockKey?: string;
489
+ blockType?: string;
490
+ details?: Record<string, unknown>;
491
+ }
492
+ /**
493
+ * Default runtime options
494
+ */
495
+ declare const DEFAULT_RUNTIME_OPTIONS: Required<Omit<IRuntimeOptions, 'blockWrapperFactory' | 'onDebugLog' | 'defaultTestableConfig'>>;
496
+ interface RuntimeStackWrapper {
497
+ wrap?: (block: IRuntimeBlock, parent?: IRuntimeBlock) => IRuntimeBlock;
498
+ cleanup?: (block: IRuntimeBlock) => void;
499
+ }
500
+ interface RuntimeStackLogger {
501
+ debug?: (message: string, details?: Record<string, unknown>) => void;
502
+ error?: (message: string, error: unknown, details?: Record<string, unknown>) => void;
503
+ }
504
+ interface RuntimeStackHooks {
505
+ onBeforePush?: (block: IRuntimeBlock, parent?: IRuntimeBlock) => void;
506
+ onAfterPush?: (block: IRuntimeBlock, parent?: IRuntimeBlock) => void;
507
+ onBeforePop?: (block: IRuntimeBlock | undefined) => void;
508
+ onAfterPop?: (block: IRuntimeBlock | undefined) => void;
509
+ unregisterByOwner?: (ownerKey: string) => void;
510
+ }
511
+ interface RuntimeStackOptions extends IRuntimeOptions {
512
+ wrapper?: RuntimeStackWrapper;
513
+ logger?: RuntimeStackLogger;
514
+ hooks?: RuntimeStackHooks;
515
+ analyticsOptions?: {
516
+ effortResolver?: IEffortResolver;
517
+ userProfile?: {
518
+ vo2max?: number;
519
+ };
520
+ };
521
+ }
522
+
386
523
  declare class TypedMemoryReference<T> implements IMemoryReference {
387
524
  private readonly _memory;
388
525
  readonly ownerId: string;
389
526
  readonly type: string;
390
527
  visibility: 'public' | 'private' | 'inherited';
528
+ private readonly _logger?;
391
529
  id: string;
392
530
  private _subscriptions;
393
- constructor(_memory: IRuntimeMemory, ownerId: string, type: string, visibility?: 'public' | 'private' | 'inherited');
531
+ constructor(_memory: IRuntimeMemory, ownerId: string, type: string, visibility?: 'public' | 'private' | 'inherited', _logger?: RuntimeStackLogger | undefined);
394
532
  /**
395
533
  * Get the current value in an untyped manner.
396
534
  * Implements IMemoryReference.value() for debugging and inspection.
@@ -804,7 +942,7 @@ declare class TimeSpan implements TimeSpan$1 {
804
942
  started: number;
805
943
  ended?: number | undefined;
806
944
  constructor(started: number, ended?: number | undefined);
807
- static fromJSON(json: any): TimeSpan;
945
+ static fromJSON(json: TimeSpan$1): TimeSpan;
808
946
  /**
809
947
  * Create a TimeSpan from Date objects (legacy support/compatibility)
810
948
  */
@@ -1035,7 +1173,7 @@ type Unsubscribe$1 = () => void;
1035
1173
  /**
1036
1174
  * Event types that behaviors can subscribe to.
1037
1175
  */
1038
- type BehaviorEventType = 'tick' | 'next' | 'timer:complete' | 'pause' | 'resume' | '*';
1176
+ type BehaviorEventType = 'tick' | 'next' | 'timer:complete' | 'timer:reset' | 'timer:pause' | 'timer:resume' | 'timer:skip-attempt' | 'pause' | 'resume' | '*';
1039
1177
  /**
1040
1178
  * Listener function for behavior event subscriptions.
1041
1179
  */
@@ -1318,12 +1456,12 @@ interface IRuntimeBehavior {
1318
1456
  * Legacy API: called when a block is pushed onto the stack.
1319
1457
  * Superseded by onMount. Retained for backward-compatible mock behaviors.
1320
1458
  */
1321
- onPush?(block: any, clock: any): IRuntimeAction[];
1459
+ onPush?(block: IRuntimeBlock, clock: IRuntimeClock): IRuntimeAction[];
1322
1460
  /**
1323
1461
  * Legacy API: called when a block is popped from the stack.
1324
1462
  * Superseded by onUnmount. Retained for backward-compatible mock behaviors.
1325
1463
  */
1326
- onPop?(block: any, clock: any): IRuntimeAction[];
1464
+ onPop?(block: IRuntimeBlock, clock: IRuntimeClock): IRuntimeAction[];
1327
1465
  }
1328
1466
 
1329
1467
  /**
@@ -1516,7 +1654,7 @@ interface IRuntimeBlock extends IBlockRef {
1516
1654
  * @param behaviorType Constructor/class of the behavior to find
1517
1655
  * @returns The behavior instance or undefined if not found
1518
1656
  */
1519
- getBehavior<T extends IRuntimeBehavior>(behaviorType: new (...args: any[]) => T): T | undefined;
1657
+ getBehavior<T extends IRuntimeBehavior>(behaviorType: new (...args: unknown[]) => T): T | undefined;
1520
1658
  /**
1521
1659
  * Read-only list of all behaviors attached to this block.
1522
1660
  * Useful for debug/inspection UIs.
@@ -1756,7 +1894,7 @@ interface ProjectionResult {
1756
1894
  */
1757
1895
  origin?: MetricOrigin;
1758
1896
  /** Optional additional metadata for the projection */
1759
- metadata?: Record<string, any>;
1897
+ metadata?: Record<string, unknown>;
1760
1898
  }
1761
1899
 
1762
1900
  /**
@@ -1787,132 +1925,6 @@ interface IAnalyticsEngine {
1787
1925
  finalize(): IOutputStatement[];
1788
1926
  }
1789
1927
 
1790
- /**
1791
- * Configuration for method interception behavior.
1792
- * Defined here (in runtime/contracts) so that both production runtime
1793
- * code and the testing layer can reference it without creating a
1794
- * runtime → testing circular dependency.
1795
- */
1796
- type InterceptMode = 'passthrough' | 'spy' | 'override' | 'ignore';
1797
- /**
1798
- * Configuration for TestableBlock behavior.
1799
- * Used by IRuntimeOptions to allow debug-mode block wrapping.
1800
- */
1801
- interface TestableBlockConfig {
1802
- /** Custom ID for easy identification in visualizations */
1803
- testId?: string;
1804
- /** Custom label override for display purposes */
1805
- labelOverride?: string;
1806
- /** Mode for mount() interception */
1807
- mountMode?: InterceptMode;
1808
- /** Custom mount implementation when mode is 'override' */
1809
- mountOverride?: (runtime: IRuntimeActionable) => IRuntimeAction[];
1810
- /** Mode for next() interception */
1811
- nextMode?: InterceptMode;
1812
- /** Custom next implementation when mode is 'override' */
1813
- nextOverride?: (runtime: IRuntimeActionable) => IRuntimeAction[];
1814
- /** Mode for inspectNext() interception */
1815
- inspectNextMode?: InterceptMode;
1816
- /** Custom inspectNext implementation when mode is 'override' */
1817
- inspectNextOverride?: (runtime: IRuntimeActionable) => CompletionDecision;
1818
- /** Mode for unmount() interception */
1819
- unmountMode?: InterceptMode;
1820
- /** Custom unmount implementation when mode is 'override' */
1821
- unmountOverride?: (runtime: IRuntimeActionable) => IRuntimeAction[];
1822
- /** Mode for dispose() interception */
1823
- disposeMode?: InterceptMode;
1824
- /** Custom dispose implementation when mode is 'override' */
1825
- disposeOverride?: (runtime: IRuntimeActionable) => void;
1826
- }
1827
-
1828
- /**
1829
- * Factory function type for wrapping blocks in debug mode.
1830
- * Receives the original block and returns a wrapped version.
1831
- */
1832
- type BlockWrapperFactory = (block: IRuntimeBlock, config?: TestableBlockConfig) => IRuntimeBlock;
1833
- /**
1834
- * Configuration options for ScriptRuntime initialization.
1835
- * These options control debugging, logging, and testing capabilities.
1836
- */
1837
- interface IRuntimeOptions {
1838
- /**
1839
- * Enable debug mode for the runtime.
1840
- * When true:
1841
- * - All blocks pushed to the stack are automatically wrapped with TestableBlock
1842
- * - Additional lifecycle events are logged
1843
- */
1844
- debugMode?: boolean;
1845
- /**
1846
- * Custom factory for wrapping blocks when debugMode is true.
1847
- * If not provided, uses the default TestableBlock wrapper with spy mode.
1848
- */
1849
- blockWrapperFactory?: BlockWrapperFactory;
1850
- /**
1851
- * Default configuration for TestableBlock wrappers.
1852
- * Applied to all blocks wrapped in debug mode unless overridden.
1853
- */
1854
- defaultTestableConfig?: Partial<TestableBlockConfig>;
1855
- /**
1856
- * Enable console logging for runtime debug output.
1857
- * Automatically set to true when debugMode is true.
1858
- */
1859
- enableLogging?: boolean;
1860
- /**
1861
- * Custom log handler for debug events.
1862
- * If provided, called in addition to console logging.
1863
- */
1864
- onDebugLog?: (event: DebugLogEvent) => void;
1865
- /**
1866
- * Maximum depth for nested actions within a single execution turn.
1867
- * Defaults to 20 if not specified.
1868
- */
1869
- maxActionDepth?: number;
1870
- }
1871
- /**
1872
- * Types of debug log events
1873
- */
1874
- type DebugLogEventType = 'block-wrapped' | 'block-mount' | 'block-next' | 'block-unmount' | 'block-dispose' | 'stack-push' | 'stack-pop' | 'memory-allocate' | 'memory-release' | 'event-handled';
1875
- /**
1876
- * Debug log event structure
1877
- */
1878
- interface DebugLogEvent {
1879
- type: DebugLogEventType;
1880
- timestamp: number;
1881
- blockKey?: string;
1882
- blockType?: string;
1883
- details?: Record<string, any>;
1884
- }
1885
- /**
1886
- * Default runtime options
1887
- */
1888
- declare const DEFAULT_RUNTIME_OPTIONS: Required<Omit<IRuntimeOptions, 'blockWrapperFactory' | 'onDebugLog' | 'defaultTestableConfig'>>;
1889
- interface RuntimeStackWrapper {
1890
- wrap?: (block: IRuntimeBlock, parent?: IRuntimeBlock) => IRuntimeBlock;
1891
- cleanup?: (block: IRuntimeBlock) => void;
1892
- }
1893
- interface RuntimeStackLogger {
1894
- debug?: (message: string, details?: Record<string, unknown>) => void;
1895
- error?: (message: string, error: unknown, details?: Record<string, unknown>) => void;
1896
- }
1897
- interface RuntimeStackHooks {
1898
- onBeforePush?: (block: IRuntimeBlock, parent?: IRuntimeBlock) => void;
1899
- onAfterPush?: (block: IRuntimeBlock, parent?: IRuntimeBlock) => void;
1900
- onBeforePop?: (block: IRuntimeBlock | undefined) => void;
1901
- onAfterPop?: (block: IRuntimeBlock | undefined) => void;
1902
- unregisterByOwner?: (ownerKey: string) => void;
1903
- }
1904
- interface RuntimeStackOptions extends IRuntimeOptions {
1905
- wrapper?: RuntimeStackWrapper;
1906
- logger?: RuntimeStackLogger;
1907
- hooks?: RuntimeStackHooks;
1908
- analyticsOptions?: {
1909
- effortResolver?: IEffortResolver;
1910
- userProfile?: {
1911
- vo2max?: number;
1912
- };
1913
- };
1914
- }
1915
-
1916
1928
  /**
1917
1929
  * AnalyticsContext — shared services injected into the analytics pipeline.
1918
1930
  *
@@ -2351,4 +2363,4 @@ declare function getRuntimeNowMs(): number;
2351
2363
  /** Creates an INowProvider that reads the browser sender-clock when available. */
2352
2364
  declare function createBrowserRuntimeNow(): INowProvider;
2353
2365
 
2354
- export { ScriptRuntime as $, type AnalyticsContext as A, type BehaviorEventType as B, type CompletionDecision as C, type IRuntimeMemory as D, type EffortResolverOptions as E, TypedMemoryReference as F, type MemorySearchCriteria as G, type IMemoryReference as H, type IScript as I, type StackObserver as J, type StackSnapshot as K, type StackListener as L, type MemoryTag as M, MemoryTypeEnum as N, type OutputListener as O, type IAnchorValue as P, type ButtonConfig as Q, type ResolvedEffort as R, type SubscribeOptions as S, TimeSpan as T, type Unsubscribe as U, type IEventHandler as V, WhiteboardScript as W, type HandlerScope as X, type IScriptRuntime as Y, type TestableBlockConfig as Z, type IRuntimeOptions as _, type IEffortResolver as a, type EventHandlerOptions as a0, type EventCallback as a1, type TimerState as a2, type IRealtimeProcessor as a3, type ISummaryProcessor as a4, type ProjectionResult as a5, type ButtonVariant as a6, type ButtonsState as a7, type ChildrenStatusState as a8, type CompletionState as a9, VISIBILITY_ICONS as aA, VISIBILITY_LABELS as aB, createBrowserRuntimeNow as aC, disciplineFactorFor as aD, filterTagsByVisibility as aE, frozenNow as aF, getMetricVisibility as aG, getRuntimeNowMs as aH, isEffortDiscipline as aI, isFragmentTag as aJ, wallClockNow as aK, DEFAULT_RESOLVER_OPTIONS as aa, DEFAULT_RUNTIME_OPTIONS as ab, DISCIPLINE_FACTORS as ac, type DisplayState as ad, EFFORT_DISCIPLINES as ae, EFFORT_REGISTRY_ORIGINS as af, type EffortBaseAttributes as ag, type EffortDerivation as ah, type EffortDiscipline as ai, type EffortResolvedFrom as aj, type FenceDialect as ak, type FragmentDisplayState as al, type FragmentState as am, type IAnalyticsProcessorDescriptor as an, INTENSITY_TIERS as ao, type IntensityTier as ap, type InterceptMode as aq, MemoryLocation as ar, type MemoryType as as, type MemoryTypeMap as at, type MemoryValueOf as au, type RoundState as av, type RuntimeState as aw, type ScriptRuntimeDependencies as ax, type StackEvent as ay, type TimerDirection as az, type IEffortRegistry as b, type IEffort as c, type EffortResolutionOptions as d, type EffortRegistrySource as e, type IRuntimeActionable as f, type IEventBus as g, type IRuntimeStack as h, type IRuntimeClock as i, type IJitCompiler as j, type INowProvider as k, type RuntimeStackOptions as l, type RuntimeError as m, type IEvent as n, type IRuntimeAction as o, type IAnalyticsEngine as p, type IRuntimeBlock as q, type IBehaviorContext as r, type BehaviorEventListener as s, type Unsubscribe$1 as t, type OutputOptions as u, type IMemoryLocation as v, type IRuntimeBehavior as w, type IBlockContext as x, type MetricVisibility as y, type BlockLifecycleOptions as z };
2366
+ export { type IRuntimeOptions as $, type AnalyticsContext as A, type BehaviorEventType as B, type CompletionDecision as C, type IRuntimeMemory as D, type EffortResolverOptions as E, TypedMemoryReference as F, type MemorySearchCriteria as G, type IMemoryReference as H, type IEffortResolver as I, type RuntimeStackLogger as J, type StackObserver as K, type StackSnapshot as L, type MemoryTag as M, type StackListener as N, type OutputListener as O, MemoryTypeEnum as P, type IAnchorValue as Q, type ResolvedEffort as R, type SubscribeOptions as S, TimeSpan as T, type Unsubscribe as U, type ButtonConfig as V, WhiteboardScript as W, type IEventHandler as X, type HandlerScope as Y, type IScriptRuntime as Z, type TestableBlockConfig as _, type IEffortRegistry as a, ScriptRuntime as a0, type EventHandlerOptions as a1, type EventCallback as a2, type TimerState as a3, type IRealtimeProcessor as a4, type ISummaryProcessor as a5, type ProjectionResult as a6, type ButtonVariant as a7, type ButtonsState as a8, type ChildrenStatusState as a9, type StackEvent as aA, type TimerDirection as aB, VISIBILITY_ICONS as aC, VISIBILITY_LABELS as aD, createBrowserRuntimeNow as aE, disciplineFactorFor as aF, filterTagsByVisibility as aG, frozenNow as aH, getMetricVisibility as aI, getRuntimeNowMs as aJ, isEffortDiscipline as aK, isFragmentTag as aL, wallClockNow as aM, type CompletionState as aa, DEFAULT_RESOLVER_OPTIONS as ab, DEFAULT_RUNTIME_OPTIONS as ac, DISCIPLINE_FACTORS as ad, type DisplayState as ae, EFFORT_DISCIPLINES as af, EFFORT_REGISTRY_ORIGINS as ag, type EffortBaseAttributes as ah, type EffortDerivation as ai, type EffortDiscipline as aj, type EffortResolvedFrom as ak, type FenceDialect as al, type FragmentDisplayState as am, type FragmentState as an, type IAnalyticsProcessorDescriptor as ao, INTENSITY_TIERS as ap, type IScript as aq, type IntensityTier as ar, type InterceptMode as as, MemoryLocation as at, type MemoryType as au, type MemoryTypeMap as av, type MemoryValueOf as aw, type RoundState as ax, type RuntimeState as ay, type ScriptRuntimeDependencies as az, type IEffort as b, type EffortResolutionOptions as c, type EffortRegistrySource as d, type EffortStorageAdapter as e, type IRuntimeActionable as f, type IEventBus as g, type IRuntimeStack as h, type IRuntimeClock as i, type IJitCompiler as j, type INowProvider as k, type RuntimeStackOptions as l, type RuntimeError as m, type IEvent as n, type IRuntimeAction as o, type IAnalyticsEngine as p, type IRuntimeBlock as q, type IBehaviorContext as r, type BehaviorEventListener as s, type Unsubscribe$1 as t, type OutputOptions as u, type IMemoryLocation as v, type IRuntimeBehavior as w, type IBlockContext as x, type MetricVisibility as y, type BlockLifecycleOptions as z };