@bitcobblers/wod-wiki-lang 0.1.5 → 0.1.6

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.mjs CHANGED
@@ -11520,6 +11520,350 @@ var PlaySoundAction = class {
11520
11520
  return runtime.eventBus.dispatch(event, runtime);
11521
11521
  }
11522
11522
  };
11523
+
11524
+ // src/runtime/utils/MemoryUtils.ts
11525
+ function searchStackMemory(runtime, criteria) {
11526
+ const results = [];
11527
+ if (!runtime.stack || !runtime.stack.blocks) {
11528
+ return results;
11529
+ }
11530
+ for (const block of runtime.stack.blocks) {
11531
+ if (!block.context || !block.context.references) {
11532
+ continue;
11533
+ }
11534
+ const matches = block.context.references.filter((ref) => {
11535
+ if (criteria.id !== void 0 && criteria.id !== null && ref.id !== criteria.id) return false;
11536
+ if (criteria.ownerId !== void 0 && criteria.ownerId !== null && ref.ownerId !== criteria.ownerId) return false;
11537
+ if (criteria.type !== void 0 && criteria.type !== null && ref.type !== criteria.type) return false;
11538
+ if (criteria.visibility !== void 0 && criteria.visibility !== null && ref.visibility !== criteria.visibility) return false;
11539
+ return true;
11540
+ });
11541
+ results.push(...matches);
11542
+ }
11543
+ return results;
11544
+ }
11545
+
11546
+ // src/runtime/adapters/RuntimeAdapter.ts
11547
+ var RuntimeAdapter = class {
11548
+ /**
11549
+ * Creates immutable snapshot of runtime state for UI rendering
11550
+ */
11551
+ createSnapshot(runtime) {
11552
+ const stackBlocks = this.extractStackBlocks(runtime);
11553
+ const memoryEntries = this.extractMemoryEntries(runtime);
11554
+ const activeIndex = stackBlocks.findIndex((block) => block.isActive);
11555
+ const groupedByOwner = this.groupMemoryEntries(memoryEntries, "owner");
11556
+ const groupedByType = this.groupMemoryEntries(memoryEntries, "type");
11557
+ const status = this.determineExecutionStatus(stackBlocks);
11558
+ return {
11559
+ stack: {
11560
+ blocks: stackBlocks,
11561
+ activeIndex: activeIndex >= 0 ? activeIndex : 0,
11562
+ depth: stackBlocks.length,
11563
+ rootBlockKey: stackBlocks.length > 0 ? stackBlocks[0].key : void 0
11564
+ },
11565
+ memory: {
11566
+ entries: memoryEntries,
11567
+ groupedByOwner,
11568
+ groupedByType,
11569
+ totalEntries: memoryEntries.length
11570
+ },
11571
+ status,
11572
+ metadata: {
11573
+ stepCount: 0,
11574
+ // TODO: Track actual step count
11575
+ elapsedTime: 0,
11576
+ // TODO: Track actual elapsed time
11577
+ lastEvent: void 0,
11578
+ lastEventTime: void 0
11579
+ },
11580
+ timestamp: Date.now()
11581
+ };
11582
+ }
11583
+ /**
11584
+ * Extracts RuntimeStackBlocks from runtime stack
11585
+ */
11586
+ extractStackBlocks(runtime) {
11587
+ const blocks = runtime.stack.blocks;
11588
+ return blocks.map((block, index) => {
11589
+ const blockType = this.mapBlockType(block);
11590
+ const isActive = index === blocks.length - 1;
11591
+ const status = this.determineBlockStatus(isActive);
11592
+ const metrics = this.extractBlockFragments(runtime, block);
11593
+ const displayLocs = block.getMemoryByTag("metric:display");
11594
+ const metricGroups = displayLocs.length > 1 ? displayLocs.map((loc) => MetricContainer.from([...loc.metrics])) : void 0;
11595
+ return {
11596
+ key: block.key.toString(),
11597
+ blockType,
11598
+ parentKey: this.findParentKey(blocks, index),
11599
+ children: this.findChildrenKeys(blocks, block.key.toString()),
11600
+ depth: index,
11601
+ label: block.label || this.generateBlockLabel(blockType),
11602
+ color: this.getBlockColor(blockType),
11603
+ icon: this.getBlockIcon(blockType),
11604
+ isActive,
11605
+ isComplete: status === "complete",
11606
+ status,
11607
+ metric: {},
11608
+ // TODO: Extract actual metrics
11609
+ metrics,
11610
+ metricGroups,
11611
+ sourceIds: block.sourceIds,
11612
+ lineNumber: block.sourceIds.length > 0 ? block.sourceIds[0] : void 0,
11613
+ metadata: {
11614
+ mountTime: void 0,
11615
+ executionTime: void 0,
11616
+ iterationCount: void 0
11617
+ }
11618
+ };
11619
+ });
11620
+ }
11621
+ /**
11622
+ * Extracts metrics from block's source statements for unified visualization
11623
+ */
11624
+ extractBlockFragments(_runtime, block) {
11625
+ if (!block.sourceIds || block.sourceIds.length === 0) {
11626
+ return void 0;
11627
+ }
11628
+ return void 0;
11629
+ }
11630
+ /**
11631
+ * Extracts MemoryEntries from runtime memory
11632
+ */
11633
+ extractMemoryEntries(runtime) {
11634
+ const entries = [];
11635
+ const ownerLineMap = /* @__PURE__ */ new Map();
11636
+ const ownerLabelMap = /* @__PURE__ */ new Map();
11637
+ runtime.stack.blocks.forEach((block) => {
11638
+ const key = block.key.toString();
11639
+ if (block.sourceIds && block.sourceIds.length > 0) {
11640
+ ownerLineMap.set(key, block.sourceIds[0]);
11641
+ }
11642
+ ownerLabelMap.set(key, block.label);
11643
+ });
11644
+ for (const block of runtime.stack.blocks) {
11645
+ const blockKey = block.key.toString();
11646
+ const locations = block.getAllMemory();
11647
+ for (const loc of locations) {
11648
+ const tag = loc.tag;
11649
+ const value = loc.metrics.length > 0 ? loc.metrics[0].value : void 0;
11650
+ const memoryType = this.mapMemoryType(tag);
11651
+ const entryId = `${blockKey}-${tag}`;
11652
+ entries.push({
11653
+ id: entryId,
11654
+ ownerId: blockKey,
11655
+ ownerLabel: ownerLabelMap.get(blockKey) ?? blockKey,
11656
+ type: memoryType,
11657
+ value,
11658
+ valueFormatted: this.formatValue(value),
11659
+ label: this.generateMemoryLabelFromType(tag, memoryType),
11660
+ groupLabel: this.generateGroupLabel(memoryType),
11661
+ icon: this.getMemoryIcon(memoryType),
11662
+ lineNumber: ownerLineMap.get(blockKey),
11663
+ isValid: value !== void 0,
11664
+ isHighlighted: false,
11665
+ metadata: {
11666
+ createdAt: void 0,
11667
+ lastModified: void 0,
11668
+ accessCount: void 0
11669
+ },
11670
+ references: [],
11671
+ referencedBy: []
11672
+ });
11673
+ }
11674
+ }
11675
+ const references = searchStackMemory(runtime, {});
11676
+ for (const ref of references) {
11677
+ const existingId = `${ref.ownerId}-${ref.type}`;
11678
+ if (entries.some((e) => e.id === existingId)) {
11679
+ continue;
11680
+ }
11681
+ const value = ref.value();
11682
+ const memoryType = this.mapMemoryType(ref.type);
11683
+ entries.push({
11684
+ id: ref.id,
11685
+ ownerId: ref.ownerId,
11686
+ ownerLabel: ownerLabelMap.get(ref.ownerId) ?? this.generateOwnerLabel(ref.ownerId),
11687
+ type: memoryType,
11688
+ value,
11689
+ valueFormatted: this.formatValue(value),
11690
+ label: this.generateMemoryLabel(ref, memoryType),
11691
+ groupLabel: this.generateGroupLabel(memoryType),
11692
+ icon: this.getMemoryIcon(memoryType),
11693
+ lineNumber: ownerLineMap.get(ref.ownerId),
11694
+ isValid: value !== void 0,
11695
+ isHighlighted: false,
11696
+ metadata: {
11697
+ createdAt: void 0,
11698
+ lastModified: void 0,
11699
+ accessCount: void 0
11700
+ },
11701
+ references: [],
11702
+ referencedBy: []
11703
+ });
11704
+ }
11705
+ return entries;
11706
+ }
11707
+ /**
11708
+ * Generates a label for a memory entry from its type
11709
+ */
11710
+ generateMemoryLabelFromType(rawType, _displayType) {
11711
+ const typeStr = rawType.toString();
11712
+ return typeStr.charAt(0).toUpperCase() + typeStr.slice(1).replace(/-/g, " ");
11713
+ }
11714
+ /**
11715
+ * Groups memory entries by specified grouping strategy
11716
+ */
11717
+ groupMemoryEntries(entries, groupBy) {
11718
+ const groups = /* @__PURE__ */ new Map();
11719
+ if (groupBy === "none") {
11720
+ groups.set("All Entries", entries);
11721
+ return groups;
11722
+ }
11723
+ for (const entry of entries) {
11724
+ let groupKey;
11725
+ switch (groupBy) {
11726
+ case "owner":
11727
+ groupKey = entry.ownerLabel || entry.ownerId;
11728
+ break;
11729
+ case "type":
11730
+ groupKey = entry.type;
11731
+ break;
11732
+ default:
11733
+ groupKey = "Unknown";
11734
+ }
11735
+ if (!groups.has(groupKey)) {
11736
+ groups.set(groupKey, []);
11737
+ }
11738
+ groups.get(groupKey).push(entry);
11739
+ }
11740
+ return groups;
11741
+ }
11742
+ // Helper methods
11743
+ determineExecutionStatus(stackBlocks) {
11744
+ if (stackBlocks.length === 0) {
11745
+ return "idle";
11746
+ }
11747
+ const hasActiveBlock = stackBlocks.some((block) => block.isActive);
11748
+ if (hasActiveBlock) {
11749
+ return "executing";
11750
+ }
11751
+ return "idle";
11752
+ }
11753
+ mapBlockType(block) {
11754
+ const blockType = block.blockType?.toLowerCase();
11755
+ switch (blockType) {
11756
+ case "workout":
11757
+ return "workout";
11758
+ case "group":
11759
+ return "group";
11760
+ case "timer":
11761
+ return "timer";
11762
+ case "rounds":
11763
+ return "rounds";
11764
+ case "effort":
11765
+ return "effort";
11766
+ case "exercise":
11767
+ return "exercise";
11768
+ default:
11769
+ return "custom";
11770
+ }
11771
+ }
11772
+ determineBlockStatus(isActive) {
11773
+ if (isActive) {
11774
+ return "active";
11775
+ }
11776
+ return "pending";
11777
+ }
11778
+ findParentKey(blocks, currentIndex) {
11779
+ if (currentIndex === 0) return void 0;
11780
+ return blocks[currentIndex - 1].key.toString();
11781
+ }
11782
+ findChildrenKeys(_blocks, _parentKey) {
11783
+ return [];
11784
+ }
11785
+ generateBlockLabel(blockType) {
11786
+ return `${blockType.charAt(0).toUpperCase() + blockType.slice(1)} Block`;
11787
+ }
11788
+ getBlockColor(blockType) {
11789
+ const colors = {
11790
+ workout: "#3B82F6",
11791
+ // blue
11792
+ group: "#10B981",
11793
+ // green
11794
+ timer: "#F59E0B",
11795
+ // yellow
11796
+ rounds: "#8B5CF6",
11797
+ // purple
11798
+ effort: "#EF4444",
11799
+ // red
11800
+ exercise: "#06B6D4",
11801
+ // cyan
11802
+ custom: "#6B7280"
11803
+ // gray
11804
+ };
11805
+ return colors[blockType];
11806
+ }
11807
+ getBlockIcon(blockType) {
11808
+ const icons = {
11809
+ workout: "\u{1F3CB}\uFE0F",
11810
+ timer: "\u23F1\uFE0F",
11811
+ rounds: "\u{1F504}",
11812
+ exercise: "\u{1F4AA}"
11813
+ };
11814
+ return icons[blockType];
11815
+ }
11816
+ mapMemoryType(type) {
11817
+ if (!type) return "unknown";
11818
+ const lowerType = type.toLowerCase();
11819
+ if (lowerType.includes("metric")) return "metric";
11820
+ if (lowerType.includes("timer")) return "timer-state";
11821
+ if (lowerType.includes("loop")) return "loop-state";
11822
+ if (lowerType.includes("group")) return "group-state";
11823
+ if (lowerType.includes("handler")) return "handler";
11824
+ if (lowerType.includes("span")) return "span";
11825
+ return "unknown";
11826
+ }
11827
+ generateOwnerLabel(ownerId) {
11828
+ return ownerId;
11829
+ }
11830
+ formatValue(value) {
11831
+ if (value === void 0 || value === null) {
11832
+ return "undefined";
11833
+ }
11834
+ if (typeof value === "string") {
11835
+ return `"${value}"`;
11836
+ }
11837
+ if (typeof value === "number" || typeof value === "boolean") {
11838
+ return value.toString();
11839
+ }
11840
+ if (Array.isArray(value)) {
11841
+ return `Array(${value.length})`;
11842
+ }
11843
+ if (typeof value === "object") {
11844
+ return `{${Object.keys(value).length} properties}`;
11845
+ }
11846
+ return typeof value;
11847
+ }
11848
+ generateMemoryLabel(ref, memoryType) {
11849
+ return `${memoryType}: ${ref.id}`;
11850
+ }
11851
+ generateGroupLabel(memoryType) {
11852
+ return memoryType;
11853
+ }
11854
+ getMemoryIcon(memoryType) {
11855
+ const icons = {
11856
+ metric: "\u{1F4CA}",
11857
+ "timer-state": "\u23F1\uFE0F",
11858
+ "loop-state": "\u{1F504}",
11859
+ "group-state": "\u{1F4C1}",
11860
+ handler: "\u2699\uFE0F",
11861
+ span: "\u{1F4CF}",
11862
+ unknown: "\u2753"
11863
+ };
11864
+ return icons[memoryType];
11865
+ }
11866
+ };
11523
11867
  function formatMetricLabel(key) {
11524
11868
  return key.charAt(0).toUpperCase() + key.slice(1).replace(/_/g, " ");
11525
11869
  }
@@ -12688,15 +13032,15 @@ function toStoredOutputStatement(output) {
12688
13032
  }
12689
13033
 
12690
13034
  // src/version.ts
12691
- var VERSION = "0.1.5";
12692
- var GIT_SHA = "8c595e1";
12693
- var BUILD_TIME = "2026-08-18T18:07:40.647Z";
13035
+ var VERSION = "0.1.6";
13036
+ var GIT_SHA = "9c5467d";
13037
+ var BUILD_TIME = "2026-08-18T18:12:54.408Z";
12694
13038
  var SEMVER = {
12695
- version: "0.1.5",
12696
- gitSha: "8c595e1",
12697
- buildTime: "2026-08-18T18:07:40.647Z"
13039
+ version: "0.1.6",
13040
+ gitSha: "9c5467d",
13041
+ buildTime: "2026-08-18T18:12:54.408Z"
12698
13042
  };
12699
13043
 
12700
- 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, 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 };
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 };
12701
13045
  //# sourceMappingURL=index.mjs.map
12702
13046
  //# sourceMappingURL=index.mjs.map