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