@bitcobblers/wod-wiki-lang 0.54.2205 → 0.56.2208
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/{browserRuntimeNow-JnK2JvJg.d.cts → ScriptOutlineProjection-BnS5Xkgf.d.cts} +160 -1
- package/dist/{browserRuntimeNow-JnK2JvJg.d.ts → ScriptOutlineProjection-BnS5Xkgf.d.ts} +160 -1
- package/dist/chunk-XDMS3U3W.mjs +1172 -0
- package/dist/chunk-XDMS3U3W.mjs.map +1 -0
- package/dist/index.cjs +759 -85
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +22 -4
- package/dist/index.d.ts +22 -4
- package/dist/index.mjs +201 -543
- package/dist/index.mjs.map +1 -1
- package/dist/react.cjs +808 -37
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +33 -3
- package/dist/react.d.ts +33 -3
- package/dist/react.mjs +114 -15
- package/dist/react.mjs.map +1 -1
- package/package.json +2 -2
- package/dist/chunk-27K5HAHU.mjs +0 -164
- package/dist/chunk-27K5HAHU.mjs.map +0 -1
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { wallClockNow,
|
|
2
|
-
export { calculateDuration, createBrowserRuntimeNow, formatDurationCompact, formatDurationSmart, formatSecondsHHMMSS, formatSecondsMMSS, formatTime, formatTimeHHMMSS, formatTimeMMSS, formatTimePrecise, formatTimestamp, frozenNow, getRuntimeNowMs, roundToTenth, wallClockNow } from './chunk-
|
|
3
|
-
import { MetricType, MetricContainer, BlockKey, REFERENCE_METADATA_KEY, ParsedCodeStatement, getReferenceMetadata, TAG_REFERENCE_METADATA_KEY, parseFrontmatter, getScalar, OutputStatement, valueKindOf, normalizeFieldPath
|
|
1
|
+
import { UnitRegistry, hintsToContainer, hasHint, CONSUMED_HINTS, wallClockNow, TimeSpan, metricPresentation, hintMetric, resolveTagContributions, tagReferenceFor, tagContributionMetrics, tagMarkerType, collectTagReferences, tagMarkerSlugs, getHints } from './chunk-XDMS3U3W.mjs';
|
|
2
|
+
export { CONSUMED_HINTS, CONSUMED_HINT_KEYS, MAX_TAG_CONTRIBUTION_DEPTH, STANDARD_UNITS, TAG_MARKER_PREFIX, TimeSpan, UnitRegistry, UnitSet, buildTooltip, calculateDuration, computeColumnLabel, computeLabel, createBrowserRuntimeNow, createPolicy as createMetricPresentationPolicy, findTagContributionCycles, formatDurationCompact, formatDurationSmart, formatSecondsHHMMSS, formatSecondsMMSS, formatTime, formatTimeHHMMSS, formatTimeMMSS, formatTimePrecise, formatTimestamp, frozenNow, getHints, getRuntimeNowMs, hasHint, hintMetric, hintsToContainer, interpolateSessionClockFrame, isRequiredCountdownLocked, isTimeLikeMetric, metricPresentation, observeSessionClockInputs, projectLiveSessionTelemetry, projectScriptOutline, projectSessionClock, resolveTagContributions, resolveVisualPolarity, roundToTenth, synthesizeWorkoutFormat, tagContributionMetrics, tagMarkerSlug, tagMarkerSlugs, tagMarkerType, wallClockNow } from './chunk-XDMS3U3W.mjs';
|
|
3
|
+
import { MetricType, MetricContainer, BlockKey, REFERENCE_METADATA_KEY, ParsedCodeStatement, getReferenceMetadata, TAG_REFERENCE_METADATA_KEY, parseFrontmatter, getScalar, OutputStatement, valueKindOf, normalizeFieldPath } from '@bitcobblers/wod-wiki-core';
|
|
4
4
|
import { LRParser } from '@lezer/lr';
|
|
5
5
|
import { LRLanguage, LanguageSupport, syntaxTree } from '@codemirror/language';
|
|
6
6
|
import { NodeProp } from '@lezer/common';
|
|
@@ -53,459 +53,6 @@ var Registry = class {
|
|
|
53
53
|
return this.items.size;
|
|
54
54
|
}
|
|
55
55
|
};
|
|
56
|
-
var CONSUMED_HINTS = {
|
|
57
|
-
/** IntervalLogicStrategy: treats the block as an EMOM-style repeating interval. */
|
|
58
|
-
REPEATING_INTERVAL: "behavior.repeating_interval",
|
|
59
|
-
/** GenericTimerStrategy: block cannot be skipped past until timer:complete fires. */
|
|
60
|
-
REQUIRED_TIMER: "behavior.required_timer",
|
|
61
|
-
/** GenericTimerStrategy: injects a rest block between repeating intervals. */
|
|
62
|
-
INJECT_REST: "behavior.inject_rest",
|
|
63
|
-
/** LabelComposer: overrides the generated label with a workout-type name. */
|
|
64
|
-
LABEL_AMRAP: "workout.amrap",
|
|
65
|
-
LABEL_EMOM: "workout.emom",
|
|
66
|
-
LABEL_TABATA: "workout.tabata",
|
|
67
|
-
LABEL_FOR_TIME: "workout.for_time"
|
|
68
|
-
};
|
|
69
|
-
var CONSUMED_HINT_KEYS = Object.values(CONSUMED_HINTS);
|
|
70
|
-
function metricsOf(source) {
|
|
71
|
-
if (!source) return [];
|
|
72
|
-
if (Array.isArray(source.rawMetrics)) return source.rawMetrics;
|
|
73
|
-
const m = source.metrics;
|
|
74
|
-
if (!m) return [];
|
|
75
|
-
if (Array.isArray(m)) return m;
|
|
76
|
-
return m.rawMetrics ?? [];
|
|
77
|
-
}
|
|
78
|
-
function hintMetric(hint, origin = "dialect", icon) {
|
|
79
|
-
return { type: MetricType.Hint, value: hint, image: hint, origin, ...icon ? { icon } : {} };
|
|
80
|
-
}
|
|
81
|
-
function hintsToContainer(hints, existing, origin = "dialect") {
|
|
82
|
-
const container = existing ?? MetricContainer.empty("dialect");
|
|
83
|
-
const seen = new Set(getHints(container));
|
|
84
|
-
for (const hint of hints) {
|
|
85
|
-
if (seen.has(hint)) continue;
|
|
86
|
-
seen.add(hint);
|
|
87
|
-
container.add(hintMetric(hint, origin));
|
|
88
|
-
}
|
|
89
|
-
return container;
|
|
90
|
-
}
|
|
91
|
-
function getHints(source) {
|
|
92
|
-
return metricsOf(source).filter((m) => m.type === MetricType.Hint && typeof m.value === "string").map((m) => m.value);
|
|
93
|
-
}
|
|
94
|
-
function hasHint(source, hint) {
|
|
95
|
-
return metricsOf(source).some((m) => m.type === MetricType.Hint && m.value === hint);
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
// src/metrics/units/UnitRegistry.ts
|
|
99
|
-
var LEADING_WORD = /^([a-zA-Z]+)([\s\S]*)$/;
|
|
100
|
-
var UnitSet = class _UnitSet {
|
|
101
|
-
/** Definitions in priority order (later entries override earlier on token collision). */
|
|
102
|
-
defs;
|
|
103
|
-
byToken;
|
|
104
|
-
constructor(defs = []) {
|
|
105
|
-
this.defs = defs;
|
|
106
|
-
this.byToken = /* @__PURE__ */ new Map();
|
|
107
|
-
for (const def of defs) {
|
|
108
|
-
this.byToken.set(def.canonical.toLowerCase(), def);
|
|
109
|
-
for (const alias of def.aliases) {
|
|
110
|
-
this.byToken.set(alias.toLowerCase(), def);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
/** Look up a unit by canonical spelling or alias (case-insensitive). */
|
|
115
|
-
get(token) {
|
|
116
|
-
return this.byToken.get(token.trim().toLowerCase());
|
|
117
|
-
}
|
|
118
|
-
/** Whether the token is a recognized unit (canonical or alias). */
|
|
119
|
-
has(token) {
|
|
120
|
-
return this.byToken.has(token.trim().toLowerCase());
|
|
121
|
-
}
|
|
122
|
-
/**
|
|
123
|
-
* Peel a leading unit token off the front of `text`.
|
|
124
|
-
*
|
|
125
|
-
* Returns `null` when the first whitespace/letter-delimited word is not a
|
|
126
|
-
* recognized unit — this is what keeps `5 Burpees` from ever fusing while
|
|
127
|
-
* `4 mile Run` → `{ unit: mile, rest: "Run" }`.
|
|
128
|
-
*/
|
|
129
|
-
consumeLeading(text) {
|
|
130
|
-
const m = LEADING_WORD.exec(text.trimStart());
|
|
131
|
-
if (!m) return null;
|
|
132
|
-
const token = m[1];
|
|
133
|
-
const unit = this.get(token);
|
|
134
|
-
if (!unit) return null;
|
|
135
|
-
return { unit, token, rest: m[2].trim() };
|
|
136
|
-
}
|
|
137
|
-
/**
|
|
138
|
-
* Compose into a new set. Later units override earlier ones on token
|
|
139
|
-
* collision — the mechanism a Dialect uses to add or redefine units.
|
|
140
|
-
*/
|
|
141
|
-
extend(...units) {
|
|
142
|
-
return new _UnitSet([...this.defs, ...units]);
|
|
143
|
-
}
|
|
144
|
-
/** All definitions in priority order. */
|
|
145
|
-
toArray() {
|
|
146
|
-
return [...this.defs];
|
|
147
|
-
}
|
|
148
|
-
};
|
|
149
|
-
var STANDARD_UNITS = [
|
|
150
|
-
// length
|
|
151
|
-
{ canonical: "m", dimension: "length", aliases: ["meter", "meters", "metre", "metres"] },
|
|
152
|
-
{ canonical: "km", dimension: "length", aliases: ["kilometer", "kilometers", "kilometre", "kilometres"] },
|
|
153
|
-
{ canonical: "cm", dimension: "length", aliases: ["centimeter", "centimeters", "centimetre", "centimetres"] },
|
|
154
|
-
{ canonical: "mm", dimension: "length", aliases: ["millimeter", "millimeters", "millimetre", "millimetres"] },
|
|
155
|
-
{ canonical: "ft", dimension: "length", aliases: ["foot", "feet"] },
|
|
156
|
-
{ canonical: "in", dimension: "length", aliases: ["inch", "inches"] },
|
|
157
|
-
{ canonical: "yd", dimension: "length", aliases: ["yard", "yards"] },
|
|
158
|
-
{ canonical: "mi", dimension: "length", aliases: ["mile", "miles"] },
|
|
159
|
-
// mass
|
|
160
|
-
{ canonical: "kg", dimension: "mass", aliases: ["kilo", "kilos", "kilogram", "kilograms"] },
|
|
161
|
-
{ canonical: "g", dimension: "mass", aliases: ["gram", "grams"] },
|
|
162
|
-
{ canonical: "lb", dimension: "mass", aliases: ["lbs", "pound", "pounds"] },
|
|
163
|
-
{ canonical: "bw", dimension: "mass", aliases: ["bodyweight"] },
|
|
164
|
-
// energy
|
|
165
|
-
{ canonical: "cal", dimension: "energy", aliases: ["cals", "calorie", "calories"] },
|
|
166
|
-
{ canonical: "kcal", dimension: "energy", aliases: ["kcals", "kilocalorie", "kilocalories"] }
|
|
167
|
-
];
|
|
168
|
-
var UnitRegistry = {
|
|
169
|
-
/** The base catalog used by the base Units Dialect. */
|
|
170
|
-
standard() {
|
|
171
|
-
return new UnitSet(STANDARD_UNITS);
|
|
172
|
-
},
|
|
173
|
-
/** Build a set from arbitrary definitions. */
|
|
174
|
-
of(units) {
|
|
175
|
-
return new UnitSet(units);
|
|
176
|
-
}
|
|
177
|
-
};
|
|
178
|
-
var TIME_LIKE_TYPES = /* @__PURE__ */ new Set([
|
|
179
|
-
MetricType.Duration,
|
|
180
|
-
MetricType.Time,
|
|
181
|
-
MetricType.Elapsed,
|
|
182
|
-
MetricType.Total
|
|
183
|
-
]);
|
|
184
|
-
function isTimeLikeMetric(type) {
|
|
185
|
-
return TIME_LIKE_TYPES.has(type);
|
|
186
|
-
}
|
|
187
|
-
function baseText(metric) {
|
|
188
|
-
if (metric.image) return metric.image;
|
|
189
|
-
if (metric.value === void 0 || metric.value === null) return metric.type;
|
|
190
|
-
if (typeof metric.value === "object") {
|
|
191
|
-
const v = metric.value;
|
|
192
|
-
if ("text" in v) return String(v.text);
|
|
193
|
-
if ("current" in v) return `Round ${v.current}`;
|
|
194
|
-
return JSON.stringify(metric.value);
|
|
195
|
-
}
|
|
196
|
-
return String(metric.value);
|
|
197
|
-
}
|
|
198
|
-
function computeLabel(metric, _surface) {
|
|
199
|
-
if (isTimeLikeMetric(metric.type) && typeof metric.value === "number") {
|
|
200
|
-
return formatDurationSmart(metric.value);
|
|
201
|
-
}
|
|
202
|
-
const base = baseText(metric);
|
|
203
|
-
if (metric.type === MetricType.Rounds || metric.type === "rounds") {
|
|
204
|
-
const trimmed = base.trim();
|
|
205
|
-
if (/^\d+$/.test(trimmed)) {
|
|
206
|
-
const n = Number(trimmed);
|
|
207
|
-
return `${base} ${n === 1 ? "Round" : "Rounds"}`;
|
|
208
|
-
}
|
|
209
|
-
}
|
|
210
|
-
return base;
|
|
211
|
-
}
|
|
212
|
-
function buildTooltip(metric) {
|
|
213
|
-
const parts = [];
|
|
214
|
-
parts.push(`Type: ${metric.type}`);
|
|
215
|
-
if (metric.value !== void 0) parts.push(`Value: ${metric.value}`);
|
|
216
|
-
if (metric.origin) parts.push(`Origin: ${metric.origin}`);
|
|
217
|
-
if (metric.sourceBlockKey) parts.push(`Block: ${metric.sourceBlockKey}`);
|
|
218
|
-
if (metric.timestamp) parts.push(`Time: ${metric.timestamp.toISOString()}`);
|
|
219
|
-
return parts.join("\n");
|
|
220
|
-
}
|
|
221
|
-
var COLUMN_LABEL_MAP = {
|
|
222
|
-
duration: "Duration",
|
|
223
|
-
rep: "Reps",
|
|
224
|
-
effort: "Effort",
|
|
225
|
-
distance: "Distance",
|
|
226
|
-
rounds: "Rounds",
|
|
227
|
-
resistance: "Resistance",
|
|
228
|
-
action: "Action",
|
|
229
|
-
increment: "Increment",
|
|
230
|
-
metric: "Metric",
|
|
231
|
-
label: "Label",
|
|
232
|
-
text: "Text",
|
|
233
|
-
custom: "Custom",
|
|
234
|
-
calculated: "Calculated",
|
|
235
|
-
"current-round": "Current Round",
|
|
236
|
-
volume: "Volume",
|
|
237
|
-
intensity: "Intensity",
|
|
238
|
-
load: "Load",
|
|
239
|
-
work: "Work",
|
|
240
|
-
lap: "Lap",
|
|
241
|
-
group: "Group",
|
|
242
|
-
time: "Time",
|
|
243
|
-
elapsed: "Elapsed",
|
|
244
|
-
total: "Total",
|
|
245
|
-
"system-time": "System Time",
|
|
246
|
-
spans: "Spans",
|
|
247
|
-
system: "System",
|
|
248
|
-
rir: "RIR",
|
|
249
|
-
"session-rpe": "Session RPE",
|
|
250
|
-
"session-load": "Session Load",
|
|
251
|
-
"met-score": "MET Score",
|
|
252
|
-
tis: "TIS",
|
|
253
|
-
sound: "Sound"
|
|
254
|
-
};
|
|
255
|
-
function humanizeMetricKey(value) {
|
|
256
|
-
const spaced = value.replace(/[_-]+/g, " ").replace(/([a-z0-9])([A-Z])/g, "$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g, "$1 $2").trim();
|
|
257
|
-
if (spaced.length === 0) return "";
|
|
258
|
-
return spaced.split(/\s+/).map((word) => {
|
|
259
|
-
if (word === word.toUpperCase()) return word;
|
|
260
|
-
if (/^[A-Z]{2,}$/.test(word)) return word;
|
|
261
|
-
return word.charAt(0).toUpperCase() + word.slice(1).toLowerCase();
|
|
262
|
-
}).join(" ");
|
|
263
|
-
}
|
|
264
|
-
function computeColumnLabel(type) {
|
|
265
|
-
const key = String(type).trim();
|
|
266
|
-
const normalized = key.toLowerCase();
|
|
267
|
-
return COLUMN_LABEL_MAP[normalized] ?? humanizeMetricKey(key);
|
|
268
|
-
}
|
|
269
|
-
function tagReferenceFor(tagIndex, slug) {
|
|
270
|
-
const resolved = resolveTagContributions(tagIndex, slug);
|
|
271
|
-
const sound = resolved.metrics.find(
|
|
272
|
-
(contribution) => contribution.type === MetricType.Sound && typeof contribution.value === "string"
|
|
273
|
-
);
|
|
274
|
-
return {
|
|
275
|
-
slug,
|
|
276
|
-
label: slug,
|
|
277
|
-
...resolved.functions.length > 0 ? { functions: [...resolved.functions] } : {},
|
|
278
|
-
...sound ? { soundProfileId: sound.value } : {}
|
|
279
|
-
};
|
|
280
|
-
}
|
|
281
|
-
function collectTagReferences(metrics, into = []) {
|
|
282
|
-
for (const metric of metrics) {
|
|
283
|
-
const reference = getTagReference(metric.metadata);
|
|
284
|
-
if (!reference) continue;
|
|
285
|
-
if (into.some((existing) => existing.slug === reference.slug)) continue;
|
|
286
|
-
into.push(reference);
|
|
287
|
-
}
|
|
288
|
-
return into;
|
|
289
|
-
}
|
|
290
|
-
var TAG_MARKER_PREFIX = "tag.";
|
|
291
|
-
var MAX_TAG_CONTRIBUTION_DEPTH = 8;
|
|
292
|
-
var EMPTY = { metrics: [], functions: [], tags: [] };
|
|
293
|
-
function resolveTagContributions(tagIndex, slug) {
|
|
294
|
-
if (!tagIndex) return EMPTY;
|
|
295
|
-
const metrics = [];
|
|
296
|
-
const functions = [];
|
|
297
|
-
const tags2 = [];
|
|
298
|
-
const seenFunctions = /* @__PURE__ */ new Set();
|
|
299
|
-
const visited = /* @__PURE__ */ new Set();
|
|
300
|
-
const walk = (currentSlug, depth) => {
|
|
301
|
-
if (depth > MAX_TAG_CONTRIBUTION_DEPTH) return;
|
|
302
|
-
if (visited.has(currentSlug)) return;
|
|
303
|
-
const definition = tagIndex.resolve(currentSlug);
|
|
304
|
-
if (!definition) return;
|
|
305
|
-
visited.add(currentSlug);
|
|
306
|
-
tags2.push(currentSlug);
|
|
307
|
-
for (const contribution of definition.contributions) {
|
|
308
|
-
if (contribution.kind === "metric") metrics.push(contribution);
|
|
309
|
-
else if (contribution.kind === "function") {
|
|
310
|
-
if (!seenFunctions.has(contribution.name)) {
|
|
311
|
-
seenFunctions.add(contribution.name);
|
|
312
|
-
functions.push(contribution.name);
|
|
313
|
-
}
|
|
314
|
-
}
|
|
315
|
-
}
|
|
316
|
-
for (const contribution of definition.contributions) {
|
|
317
|
-
if (contribution.kind === "tag") walk(contribution.slug, depth + 1);
|
|
318
|
-
}
|
|
319
|
-
};
|
|
320
|
-
walk(slug, 0);
|
|
321
|
-
return { metrics, functions, tags: tags2 };
|
|
322
|
-
}
|
|
323
|
-
function findTagContributionCycles(tagIndex) {
|
|
324
|
-
if (!tagIndex) return [];
|
|
325
|
-
const cycles = [];
|
|
326
|
-
const seen = /* @__PURE__ */ new Set();
|
|
327
|
-
const walk = (slug, path, onPath) => {
|
|
328
|
-
if (onPath.has(slug)) {
|
|
329
|
-
const start = path.indexOf(slug);
|
|
330
|
-
if (start >= 0) {
|
|
331
|
-
const cycle = [...path.slice(start), slug];
|
|
332
|
-
const key = cycleKey(cycle);
|
|
333
|
-
if (!seen.has(key)) {
|
|
334
|
-
seen.add(key);
|
|
335
|
-
cycles.push(cycle);
|
|
336
|
-
}
|
|
337
|
-
}
|
|
338
|
-
return;
|
|
339
|
-
}
|
|
340
|
-
const definition = tagIndex.resolve(slug);
|
|
341
|
-
if (!definition) return;
|
|
342
|
-
const nextPath = [...path, slug];
|
|
343
|
-
const nextOnPath = new Set(onPath);
|
|
344
|
-
nextOnPath.add(slug);
|
|
345
|
-
for (const contribution of definition.contributions) {
|
|
346
|
-
if (contribution.kind === "tag") walk(contribution.slug, nextPath, nextOnPath);
|
|
347
|
-
}
|
|
348
|
-
};
|
|
349
|
-
for (const definition of tagIndex.list()) {
|
|
350
|
-
walk(definition.slug, [], /* @__PURE__ */ new Set());
|
|
351
|
-
}
|
|
352
|
-
return cycles;
|
|
353
|
-
}
|
|
354
|
-
function cycleKey(cycle) {
|
|
355
|
-
const nodes = cycle.slice(0, -1);
|
|
356
|
-
if (nodes.length === 0) return "";
|
|
357
|
-
let smallest = 0;
|
|
358
|
-
for (let index = 1; index < nodes.length; index++) {
|
|
359
|
-
if (nodes[index] < nodes[smallest]) smallest = index;
|
|
360
|
-
}
|
|
361
|
-
return [...nodes.slice(smallest), ...nodes.slice(0, smallest)].join(">");
|
|
362
|
-
}
|
|
363
|
-
function tagMarkerType(slug) {
|
|
364
|
-
return `${TAG_MARKER_PREFIX}${slug}`;
|
|
365
|
-
}
|
|
366
|
-
function tagMarkerSlug(type) {
|
|
367
|
-
if (!type.startsWith(TAG_MARKER_PREFIX)) return void 0;
|
|
368
|
-
const slug = type.slice(TAG_MARKER_PREFIX.length);
|
|
369
|
-
return slug.length > 0 ? slug : void 0;
|
|
370
|
-
}
|
|
371
|
-
function tagMarkerSlugs(metrics) {
|
|
372
|
-
const slugs = [];
|
|
373
|
-
for (const metric of metrics) {
|
|
374
|
-
const slug = tagMarkerSlug(metric.type);
|
|
375
|
-
if (slug !== void 0 && !slugs.includes(slug)) slugs.push(slug);
|
|
376
|
-
}
|
|
377
|
-
return slugs;
|
|
378
|
-
}
|
|
379
|
-
function isEquationMetricValue(value) {
|
|
380
|
-
if (typeof value !== "string") return false;
|
|
381
|
-
const trimmed = value.trim();
|
|
382
|
-
if (!trimmed) return false;
|
|
383
|
-
if (/^[+-]?\d+(?:\.\d+)?(?:\s*[A-Za-z%/][\w%/.-]*)?$/.test(trimmed)) return false;
|
|
384
|
-
if (/^[a-zA-Z0-9_]+(?:-[a-zA-Z0-9_]+)*$/.test(trimmed)) return false;
|
|
385
|
-
return /[*/+()]|\s-\s|->|\b(?:convert|sum|avg|min|max|count|last|round|floor|ceil|abs|clamp|lookup|when|and|or)\b/.test(trimmed);
|
|
386
|
-
}
|
|
387
|
-
function tagContributionMetrics(contributions, origin = "parser") {
|
|
388
|
-
return contributions.filter((c) => !c.type.trim().startsWith("summaries.") && !isEquationMetricValue(c.value)).map((contribution) => ({
|
|
389
|
-
type: contribution.type,
|
|
390
|
-
value: contribution.value,
|
|
391
|
-
origin,
|
|
392
|
-
image: contribution.unit ? `${String(contribution.value)} ${contribution.unit}` : String(contribution.value),
|
|
393
|
-
...contribution.unit ? { unit: contribution.unit } : {}
|
|
394
|
-
}));
|
|
395
|
-
}
|
|
396
|
-
|
|
397
|
-
// src/metrics/presentation/MetricPresentationPolicy.ts
|
|
398
|
-
function isRestMetric(metric) {
|
|
399
|
-
const t2 = metric.type.toLowerCase();
|
|
400
|
-
if (t2 !== "effort") return false;
|
|
401
|
-
const v = metric.value ?? metric.image ?? "";
|
|
402
|
-
return v.trim().toLowerCase() === "rest";
|
|
403
|
-
}
|
|
404
|
-
function computeTone(metric, rest) {
|
|
405
|
-
if (rest) return "rest";
|
|
406
|
-
const t2 = metric.type.toLowerCase();
|
|
407
|
-
const toneMap = {
|
|
408
|
-
time: "time",
|
|
409
|
-
duration: "time",
|
|
410
|
-
elapsed: "time",
|
|
411
|
-
total: "time",
|
|
412
|
-
spans: "time",
|
|
413
|
-
rep: "rep",
|
|
414
|
-
effort: "effort",
|
|
415
|
-
distance: "distance",
|
|
416
|
-
rounds: "rounds",
|
|
417
|
-
increment: "rounds",
|
|
418
|
-
"current-round": "rounds",
|
|
419
|
-
action: "action",
|
|
420
|
-
resistance: "resistance",
|
|
421
|
-
text: "muted",
|
|
422
|
-
label: "muted",
|
|
423
|
-
group: "muted",
|
|
424
|
-
lap: "muted",
|
|
425
|
-
system: "system",
|
|
426
|
-
"system-time": "system",
|
|
427
|
-
volume: "rep",
|
|
428
|
-
intensity: "effort",
|
|
429
|
-
load: "resistance",
|
|
430
|
-
work: "effort",
|
|
431
|
-
rir: "effort",
|
|
432
|
-
"session-rpe": "effort",
|
|
433
|
-
"session-load": "resistance",
|
|
434
|
-
"met-score": "distance",
|
|
435
|
-
tis: "action",
|
|
436
|
-
sound: "system",
|
|
437
|
-
metric: "effort",
|
|
438
|
-
custom: "muted",
|
|
439
|
-
calculated: "effort"
|
|
440
|
-
};
|
|
441
|
-
return toneMap[t2] ?? "unknown";
|
|
442
|
-
}
|
|
443
|
-
function createPolicy() {
|
|
444
|
-
const policy = {
|
|
445
|
-
isStructural(metric) {
|
|
446
|
-
const t2 = metric.type;
|
|
447
|
-
if (t2 === MetricType.Group || t2 === "group") {
|
|
448
|
-
const img = metric.image ?? "";
|
|
449
|
-
return img === "+" || img === "-";
|
|
450
|
-
}
|
|
451
|
-
return t2 === MetricType.Lap || t2 === "lap";
|
|
452
|
-
},
|
|
453
|
-
isHidden(metric, surface) {
|
|
454
|
-
if (this.isStructural(metric)) {
|
|
455
|
-
return surface !== "debug";
|
|
456
|
-
}
|
|
457
|
-
const t2 = metric.type;
|
|
458
|
-
if ((t2 === MetricType.Sound || t2 === "sound") && surface !== "debug") return true;
|
|
459
|
-
if (t2.startsWith(TAG_MARKER_PREFIX) && surface !== "debug") return true;
|
|
460
|
-
if (surface === "review-grid-column") {
|
|
461
|
-
if (t2 === MetricType.Elapsed || t2 === "elapsed" || t2 === MetricType.Total || t2 === "total") return true;
|
|
462
|
-
if (t2 === MetricType.System || t2 === "system") return true;
|
|
463
|
-
}
|
|
464
|
-
return false;
|
|
465
|
-
},
|
|
466
|
-
present(metric, surface) {
|
|
467
|
-
const structural = this.isStructural(metric);
|
|
468
|
-
const hidden = this.isHidden(metric, surface);
|
|
469
|
-
const rest = isRestMetric(metric);
|
|
470
|
-
const comment2 = (metric.type === MetricType.Text || metric.type === "text") && metric.origin === "parser";
|
|
471
|
-
const userEntered = metric.origin === "user";
|
|
472
|
-
let renderKind;
|
|
473
|
-
if (hidden) {
|
|
474
|
-
renderKind = "hidden";
|
|
475
|
-
} else if (comment2) {
|
|
476
|
-
renderKind = "comment";
|
|
477
|
-
} else if (surface === "timer-subtitle" || surface === "history-label" || surface === "label-composer") {
|
|
478
|
-
renderKind = "plain-text";
|
|
479
|
-
} else if (surface === "review-grid-column") {
|
|
480
|
-
renderKind = "column-heading";
|
|
481
|
-
} else {
|
|
482
|
-
renderKind = "badge";
|
|
483
|
-
}
|
|
484
|
-
return {
|
|
485
|
-
metric,
|
|
486
|
-
label: computeLabel(metric),
|
|
487
|
-
tooltip: buildTooltip(metric),
|
|
488
|
-
renderKind,
|
|
489
|
-
tone: computeTone(metric, rest),
|
|
490
|
-
iconKey: rest ? "rest" : metric.type,
|
|
491
|
-
visible: !hidden,
|
|
492
|
-
structural,
|
|
493
|
-
rest,
|
|
494
|
-
comment: comment2,
|
|
495
|
-
userEntered,
|
|
496
|
-
columnLabel: computeColumnLabel(metric.type)
|
|
497
|
-
};
|
|
498
|
-
},
|
|
499
|
-
presentGroup(metrics, surface) {
|
|
500
|
-
return metrics.map((m) => this.present(m, surface));
|
|
501
|
-
},
|
|
502
|
-
columnLabel(type) {
|
|
503
|
-
return computeColumnLabel(type);
|
|
504
|
-
}
|
|
505
|
-
};
|
|
506
|
-
return policy;
|
|
507
|
-
}
|
|
508
|
-
var metricPresentation = createPolicy();
|
|
509
56
|
var EffortMetric = class {
|
|
510
57
|
constructor(effort, options) {
|
|
511
58
|
this.effort = effort;
|
|
@@ -892,9 +439,15 @@ var UnitsDialect = class {
|
|
|
892
439
|
return {};
|
|
893
440
|
}
|
|
894
441
|
};
|
|
442
|
+
var CROSSFIT_UNITS = UnitRegistry.of([
|
|
443
|
+
{ canonical: "pood", dimension: "mass", aliases: ["poods", "pd"] }
|
|
444
|
+
]);
|
|
895
445
|
var CrossFitDialect = class {
|
|
896
446
|
id = "crossfit";
|
|
897
447
|
name = "CrossFit Dialect";
|
|
448
|
+
transform(statement) {
|
|
449
|
+
fuseUnits(statement, CROSSFIT_UNITS);
|
|
450
|
+
}
|
|
898
451
|
/**
|
|
899
452
|
* Check if any Action or Effort metrics contains a keyword (case-insensitive)
|
|
900
453
|
*/
|
|
@@ -943,9 +496,15 @@ var CrossFitDialect = class {
|
|
|
943
496
|
return { metrics: hintsToContainer(hints) };
|
|
944
497
|
}
|
|
945
498
|
};
|
|
499
|
+
var WOD_UNITS = UnitRegistry.of([
|
|
500
|
+
{ canonical: "pood", dimension: "mass", aliases: ["poods", "pd"] }
|
|
501
|
+
]);
|
|
946
502
|
var WodDialect = class {
|
|
947
503
|
id = "wod";
|
|
948
504
|
name = "WOD Dialect";
|
|
505
|
+
transform(statement) {
|
|
506
|
+
fuseUnits(statement, WOD_UNITS);
|
|
507
|
+
}
|
|
949
508
|
/** Case-insensitive keyword check on Action/Effort metrics */
|
|
950
509
|
hasKeyword(metrics, keyword2) {
|
|
951
510
|
return metrics.some(
|
|
@@ -1650,6 +1209,36 @@ var PROPERTY_KEY_TO_METRIC_TYPE = {
|
|
|
1650
1209
|
};
|
|
1651
1210
|
var STRUCTURAL_EFFORT_WORDS = /* @__PURE__ */ new Set(["rest", "amrap", "emom", "tabata", "for time"]);
|
|
1652
1211
|
var STANDARD_UNITS2 = UnitRegistry.standard();
|
|
1212
|
+
var DIALECT_UNIT_WORDS = /* @__PURE__ */ new Set(["pood", "poods", "pd"]);
|
|
1213
|
+
var ROUNDS_LABEL_WORDS = /^(rounds?|rds?|sets?|laps?|cycles?|intervals?)$/i;
|
|
1214
|
+
var TIME_UNIT_SECONDS = {
|
|
1215
|
+
s: 1,
|
|
1216
|
+
sec: 1,
|
|
1217
|
+
secs: 1,
|
|
1218
|
+
second: 1,
|
|
1219
|
+
seconds: 1,
|
|
1220
|
+
min: 60,
|
|
1221
|
+
mins: 60,
|
|
1222
|
+
minute: 60,
|
|
1223
|
+
minutes: 60,
|
|
1224
|
+
hr: 3600,
|
|
1225
|
+
hrs: 3600,
|
|
1226
|
+
hour: 3600,
|
|
1227
|
+
hours: 3600
|
|
1228
|
+
};
|
|
1229
|
+
function formatSecondsAsTimer(totalSeconds) {
|
|
1230
|
+
const hours = Math.floor(totalSeconds / 3600);
|
|
1231
|
+
const minutes = Math.floor(totalSeconds % 3600 / 60);
|
|
1232
|
+
const seconds = totalSeconds % 60;
|
|
1233
|
+
const pad22 = (n) => String(n).padStart(2, "0");
|
|
1234
|
+
if (hours > 0) {
|
|
1235
|
+
return `${hours}:${pad22(minutes)}:${pad22(seconds)}`;
|
|
1236
|
+
}
|
|
1237
|
+
if (minutes > 0) {
|
|
1238
|
+
return `${minutes}:${pad22(seconds)}`;
|
|
1239
|
+
}
|
|
1240
|
+
return `:${pad22(seconds)}`;
|
|
1241
|
+
}
|
|
1653
1242
|
var REFERENCE_PAIR_KEYS = /* @__PURE__ */ new Set(["effort", "equipment"]);
|
|
1654
1243
|
function referenceMetadata(resolution) {
|
|
1655
1244
|
return {
|
|
@@ -1792,7 +1381,7 @@ function applyReferenceResolution(pairs, fact, references) {
|
|
|
1792
1381
|
if (metric.type === MetricType.Effort) {
|
|
1793
1382
|
const authored = metric instanceof EffortMetric ? metric.effort : String(metric.value ?? "");
|
|
1794
1383
|
const normalized = authored.trim().toLowerCase();
|
|
1795
|
-
if (STRUCTURAL_EFFORT_WORDS.has(normalized) || STANDARD_UNITS2.has(normalized)) {
|
|
1384
|
+
if (STRUCTURAL_EFFORT_WORDS.has(normalized) || STANDARD_UNITS2.has(normalized) || DIALECT_UNIT_WORDS.has(normalized)) {
|
|
1796
1385
|
result.push(pair);
|
|
1797
1386
|
continue;
|
|
1798
1387
|
}
|
|
@@ -1896,14 +1485,49 @@ function classifyPrimitive(primitive) {
|
|
|
1896
1485
|
case "rounds": {
|
|
1897
1486
|
if (primitive.sequence) {
|
|
1898
1487
|
if (primitive.sequence.length === 1) {
|
|
1899
|
-
|
|
1488
|
+
const amount = primitive.sequence[0];
|
|
1489
|
+
const trimmedLabel2 = primitive.label?.trim();
|
|
1490
|
+
if (!trimmedLabel2 || ROUNDS_LABEL_WORDS.test(trimmedLabel2)) {
|
|
1491
|
+
return [{ metrics: new RoundsMetric(amount), meta: primitive.meta }];
|
|
1492
|
+
}
|
|
1493
|
+
const lowerLabel2 = trimmedLabel2.toLowerCase();
|
|
1494
|
+
const unitSeconds = TIME_UNIT_SECONDS[lowerLabel2];
|
|
1495
|
+
if (unitSeconds !== void 0) {
|
|
1496
|
+
const totalSeconds = Math.max(0, Math.round(amount * unitSeconds));
|
|
1497
|
+
return [{ metrics: new DurationMetric(formatSecondsAsTimer(totalSeconds)), meta: primitive.meta }];
|
|
1498
|
+
}
|
|
1499
|
+
if (/^(reps?)$/i.test(trimmedLabel2)) {
|
|
1500
|
+
return [{ metrics: new RepMetric(amount), meta: primitive.meta }];
|
|
1501
|
+
}
|
|
1502
|
+
return [
|
|
1503
|
+
{ metrics: new RepMetric(amount), meta: primitive.sequenceMeta ?? primitive.meta },
|
|
1504
|
+
{ metrics: new EffortMetric(trimmedLabel2), meta: primitive.labelMeta ?? primitive.meta }
|
|
1505
|
+
];
|
|
1900
1506
|
}
|
|
1901
1507
|
return [
|
|
1902
1508
|
{ metrics: new RoundsMetric(primitive.sequence.length), meta: primitive.meta },
|
|
1903
1509
|
...primitive.sequence.map((value) => ({ metrics: new RepMetric(value), meta: primitive.meta }))
|
|
1904
1510
|
];
|
|
1905
1511
|
}
|
|
1906
|
-
|
|
1512
|
+
if (!primitive.label) {
|
|
1513
|
+
return [];
|
|
1514
|
+
}
|
|
1515
|
+
const trimmedLabel = primitive.label.trim();
|
|
1516
|
+
const lowerLabel = trimmedLabel.toLowerCase();
|
|
1517
|
+
if (/^(reps?)$/i.test(trimmedLabel)) {
|
|
1518
|
+
return [{ metrics: new RepMetric(void 0), meta: primitive.meta }];
|
|
1519
|
+
}
|
|
1520
|
+
const stdUnit = STANDARD_UNITS2.get(lowerLabel);
|
|
1521
|
+
if (stdUnit) {
|
|
1522
|
+
return [{ metrics: metricForDimension(void 0, trimmedLabel, stdUnit.dimension), meta: primitive.meta }];
|
|
1523
|
+
}
|
|
1524
|
+
if (DIALECT_UNIT_WORDS.has(lowerLabel)) {
|
|
1525
|
+
return [{ metrics: new ResistanceMetric(void 0, trimmedLabel), meta: primitive.meta }];
|
|
1526
|
+
}
|
|
1527
|
+
if (TIME_UNIT_SECONDS[lowerLabel] !== void 0) {
|
|
1528
|
+
return [{ metrics: new DurationMetric(":?"), meta: primitive.meta }];
|
|
1529
|
+
}
|
|
1530
|
+
return [{ metrics: new RoundsMetric(primitive.label), meta: primitive.meta }];
|
|
1907
1531
|
}
|
|
1908
1532
|
case "round_scheme": {
|
|
1909
1533
|
return [
|
|
@@ -2299,13 +1923,17 @@ function mapFragmentToPrimitive(locator, source, node) {
|
|
|
2299
1923
|
}
|
|
2300
1924
|
case Rounds: {
|
|
2301
1925
|
const sequence = node.getChild("Sequence");
|
|
2302
|
-
const
|
|
1926
|
+
const identifiers = node.getChildren("Identifier");
|
|
1927
|
+
const firstId = identifiers[0];
|
|
1928
|
+
const lastId = identifiers[identifiers.length - 1];
|
|
2303
1929
|
const primitive = {
|
|
2304
1930
|
kind: "rounds",
|
|
2305
1931
|
raw,
|
|
2306
1932
|
meta: meta2,
|
|
2307
|
-
sequence: sequence ? source.slice(sequence.from, sequence.to).split("-").map((n) =>
|
|
2308
|
-
label:
|
|
1933
|
+
sequence: sequence ? source.slice(sequence.from, sequence.to).split("-").map((n) => Number(n.trim())) : void 0,
|
|
1934
|
+
label: identifiers.length > 0 ? identifiers.map((id) => source.slice(id.from, id.to)).join(" ") : void 0,
|
|
1935
|
+
sequenceMeta: sequence ? createMeta(locator, sequence.from, sequence.to, source.slice(sequence.from, sequence.to)) : void 0,
|
|
1936
|
+
labelMeta: firstId && lastId ? createMeta(locator, firstId.from, lastId.to, source.slice(firstId.from, lastId.to)) : void 0
|
|
2309
1937
|
};
|
|
2310
1938
|
return primitive;
|
|
2311
1939
|
}
|
|
@@ -5237,48 +4865,6 @@ var DEFAULT_RUNTIME_OPTIONS = {
|
|
|
5237
4865
|
maxActionDepth: 20
|
|
5238
4866
|
};
|
|
5239
4867
|
|
|
5240
|
-
// src/runtime/models/TimeSpan.ts
|
|
5241
|
-
var TimeSpan = class _TimeSpan {
|
|
5242
|
-
constructor(started, ended) {
|
|
5243
|
-
this.started = started;
|
|
5244
|
-
this.ended = ended;
|
|
5245
|
-
}
|
|
5246
|
-
started;
|
|
5247
|
-
ended;
|
|
5248
|
-
static fromJSON(json) {
|
|
5249
|
-
return new _TimeSpan(json.started, json.ended);
|
|
5250
|
-
}
|
|
5251
|
-
/**
|
|
5252
|
-
* Create a TimeSpan from Date objects (legacy support/compatibility)
|
|
5253
|
-
*/
|
|
5254
|
-
static fromDates(start, end) {
|
|
5255
|
-
return new _TimeSpan(start.getTime(), end?.getTime());
|
|
5256
|
-
}
|
|
5257
|
-
/**
|
|
5258
|
-
* Length of this individual span in milliseconds.
|
|
5259
|
-
* Uses current time if the span is still open.
|
|
5260
|
-
*
|
|
5261
|
-
* Note: Not to be confused with the glossary term "Duration" which
|
|
5262
|
-
* refers to the parser-defined planned target (DurationMetric).
|
|
5263
|
-
*/
|
|
5264
|
-
get duration() {
|
|
5265
|
-
const end = this.ended ?? Date.now();
|
|
5266
|
-
return Math.max(0, end - this.started);
|
|
5267
|
-
}
|
|
5268
|
-
/**
|
|
5269
|
-
* Whether the span is currently open (no end time).
|
|
5270
|
-
*/
|
|
5271
|
-
get isOpen() {
|
|
5272
|
-
return this.ended === void 0;
|
|
5273
|
-
}
|
|
5274
|
-
get startDate() {
|
|
5275
|
-
return new Date(this.started);
|
|
5276
|
-
}
|
|
5277
|
-
get endDate() {
|
|
5278
|
-
return this.ended ? new Date(this.ended) : void 0;
|
|
5279
|
-
}
|
|
5280
|
-
};
|
|
5281
|
-
|
|
5282
4868
|
// src/runtime/RuntimeClock.ts
|
|
5283
4869
|
var SnapshotClock = class _SnapshotClock {
|
|
5284
4870
|
constructor(_underlying, _frozenTime) {
|
|
@@ -5333,12 +4919,16 @@ var SnapshotClock = class _SnapshotClock {
|
|
|
5333
4919
|
}
|
|
5334
4920
|
};
|
|
5335
4921
|
var RuntimeClock = class {
|
|
4922
|
+
constructor(_now = wallClockNow) {
|
|
4923
|
+
this._now = _now;
|
|
4924
|
+
}
|
|
4925
|
+
_now;
|
|
5336
4926
|
_spans = [];
|
|
5337
4927
|
/**
|
|
5338
|
-
* Current
|
|
4928
|
+
* Current clock time as a Date (from injected `INowProvider`, defaulting to wall clock).
|
|
5339
4929
|
*/
|
|
5340
4930
|
get currentDate() {
|
|
5341
|
-
return
|
|
4931
|
+
return this._now.now();
|
|
5342
4932
|
}
|
|
5343
4933
|
now() {
|
|
5344
4934
|
return this.currentDate;
|
|
@@ -5364,7 +4954,8 @@ var RuntimeClock = class {
|
|
|
5364
4954
|
* Sums all completed spans plus the current running span (if any).
|
|
5365
4955
|
*/
|
|
5366
4956
|
get elapsed() {
|
|
5367
|
-
|
|
4957
|
+
const currentMs = this._now.nowMs();
|
|
4958
|
+
return this._spans.reduce((total, span) => total + ((span.ended ?? currentMs) - span.started), 0);
|
|
5368
4959
|
}
|
|
5369
4960
|
/**
|
|
5370
4961
|
* Start the clock. Creates a new span with the current time.
|
|
@@ -5373,7 +4964,7 @@ var RuntimeClock = class {
|
|
|
5373
4964
|
* If the clock is already running, returns the current span's start time.
|
|
5374
4965
|
*/
|
|
5375
4966
|
start() {
|
|
5376
|
-
const now =
|
|
4967
|
+
const now = this._now.now();
|
|
5377
4968
|
if (this.isRunning) {
|
|
5378
4969
|
return this._spans[this._spans.length - 1].startDate;
|
|
5379
4970
|
}
|
|
@@ -5387,7 +4978,7 @@ var RuntimeClock = class {
|
|
|
5387
4978
|
* If the clock is not running, returns the current time.
|
|
5388
4979
|
*/
|
|
5389
4980
|
stop() {
|
|
5390
|
-
const now =
|
|
4981
|
+
const now = this._now.now();
|
|
5391
4982
|
if (!this.isRunning) {
|
|
5392
4983
|
return now;
|
|
5393
4984
|
}
|
|
@@ -6073,6 +5664,31 @@ var RuntimeLogger = new RuntimeLoggerImpl();
|
|
|
6073
5664
|
if (typeof window !== "undefined") {
|
|
6074
5665
|
window.RuntimeLogger = RuntimeLogger;
|
|
6075
5666
|
}
|
|
5667
|
+
var CurrentRoundMetric = class {
|
|
5668
|
+
/**
|
|
5669
|
+
* @param current The current round number (1-based)
|
|
5670
|
+
* @param total Total number of planned rounds (undefined for unbounded)
|
|
5671
|
+
* @param sourceBlockKey Block that owns this round counter
|
|
5672
|
+
* @param timestamp When this metrics was created
|
|
5673
|
+
* @param customImage Optional custom image string (e.g., "Completed 3 Round(s)")
|
|
5674
|
+
*/
|
|
5675
|
+
constructor(current, total, sourceBlockKey, timestamp, customImage) {
|
|
5676
|
+
this.current = current;
|
|
5677
|
+
this.total = total;
|
|
5678
|
+
this.sourceBlockKey = sourceBlockKey;
|
|
5679
|
+
this.timestamp = timestamp;
|
|
5680
|
+
this.value = current;
|
|
5681
|
+
this.image = customImage ?? (total !== void 0 ? `Round ${current} of ${total}` : `Round ${current}`);
|
|
5682
|
+
}
|
|
5683
|
+
current;
|
|
5684
|
+
total;
|
|
5685
|
+
sourceBlockKey;
|
|
5686
|
+
timestamp;
|
|
5687
|
+
type = MetricType.CurrentRound;
|
|
5688
|
+
origin = "tracked";
|
|
5689
|
+
value;
|
|
5690
|
+
image;
|
|
5691
|
+
};
|
|
6076
5692
|
var OutputEmitter = class {
|
|
6077
5693
|
_outputStatements = [];
|
|
6078
5694
|
_outputListeners = /* @__PURE__ */ new Set();
|
|
@@ -6102,6 +5718,17 @@ var OutputEmitter = class {
|
|
|
6102
5718
|
this._clock = deps.clock;
|
|
6103
5719
|
this._stack = deps.stack;
|
|
6104
5720
|
this._script = deps.script;
|
|
5721
|
+
if (this._analyticsEngine) {
|
|
5722
|
+
this._bindEngineClock(this._analyticsEngine);
|
|
5723
|
+
}
|
|
5724
|
+
}
|
|
5725
|
+
_bindEngineClock(engine) {
|
|
5726
|
+
if (!this._clock || !engine.setNowProvider) return;
|
|
5727
|
+
const clock = this._clock;
|
|
5728
|
+
engine.setNowProvider({
|
|
5729
|
+
now: () => clock.currentDate,
|
|
5730
|
+
nowMs: () => clock.currentDate.getTime()
|
|
5731
|
+
});
|
|
6105
5732
|
}
|
|
6106
5733
|
_requireClock() {
|
|
6107
5734
|
if (!this._clock) {
|
|
@@ -6166,6 +5793,7 @@ var OutputEmitter = class {
|
|
|
6166
5793
|
}
|
|
6167
5794
|
setAnalyticsEngine(engine) {
|
|
6168
5795
|
this._analyticsEngine = engine;
|
|
5796
|
+
this._bindEngineClock(engine);
|
|
6169
5797
|
engine.setLiveOutputEmitter((outputs) => this.emitLiveAnalytics(outputs));
|
|
6170
5798
|
}
|
|
6171
5799
|
/**
|
|
@@ -6218,6 +5846,11 @@ var OutputEmitter = class {
|
|
|
6218
5846
|
getLiveAnalytics() {
|
|
6219
5847
|
return [...this._liveAnalytics];
|
|
6220
5848
|
}
|
|
5849
|
+
/** Typed live Summary Metric projections directly from AnalyticsEngine. */
|
|
5850
|
+
getLiveProjections() {
|
|
5851
|
+
if (this._analyticsFinalized) return [];
|
|
5852
|
+
return this._analyticsEngine?.getLiveProjections?.() ?? [];
|
|
5853
|
+
}
|
|
6221
5854
|
dispose() {
|
|
6222
5855
|
this._outputStatements = [];
|
|
6223
5856
|
this._outputListeners.clear();
|
|
@@ -6324,6 +5957,22 @@ var OutputEmitter = class {
|
|
|
6324
5957
|
const sourceFragments = MetricContainer.from(displayLocs[i]?.metrics, block.key.toString());
|
|
6325
5958
|
const metrics = MetricContainer.empty(block.key.toString()).add(...sourceFragments.toArray()).add(...resultFragments.toArray());
|
|
6326
5959
|
if (metrics.length === 0) continue;
|
|
5960
|
+
if (!metrics.some((m) => m.type === MetricType.CurrentRound) && block.getMemoryByTag("children:status").length === 0 && block.blockType !== "SessionRoot" && block.blockType !== "Rounds") {
|
|
5961
|
+
const enclosingRoundBlock = (this._stack?.blocks ?? []).find(
|
|
5962
|
+
(ancestor2) => ancestor2.blockType !== "SessionRoot" && ancestor2.getMemoryByTag("round").length > 0
|
|
5963
|
+
);
|
|
5964
|
+
const roundState = enclosingRoundBlock?.getMemoryByTag("round")[0]?.metrics[0];
|
|
5965
|
+
if (roundState && typeof roundState.current === "number") {
|
|
5966
|
+
metrics.add(
|
|
5967
|
+
new CurrentRoundMetric(
|
|
5968
|
+
roundState.current,
|
|
5969
|
+
roundState.total,
|
|
5970
|
+
enclosingRoundBlock?.key.toString(),
|
|
5971
|
+
new Date(fallbackEndMs)
|
|
5972
|
+
)
|
|
5973
|
+
);
|
|
5974
|
+
}
|
|
5975
|
+
}
|
|
6327
5976
|
const fallbackStartMs = block.executionTiming?.startTime?.getTime() ?? fallbackEndMs;
|
|
6328
5977
|
const timeSpan = new TimeSpan(fallbackStartMs, fallbackEndMs);
|
|
6329
5978
|
this.add(new OutputStatement({
|
|
@@ -6703,6 +6352,9 @@ var ScriptRuntime = class {
|
|
|
6703
6352
|
getLiveAnalytics() {
|
|
6704
6353
|
return this._output.getLiveAnalytics();
|
|
6705
6354
|
}
|
|
6355
|
+
getLiveProjections() {
|
|
6356
|
+
return this._output.getLiveProjections();
|
|
6357
|
+
}
|
|
6706
6358
|
/**
|
|
6707
6359
|
* Add an output statement to the collection and notify subscribers.
|
|
6708
6360
|
* Used by BehaviorContext to emit outputs at any lifecycle point.
|
|
@@ -7919,7 +7571,9 @@ var CountupTimerBehavior = class {
|
|
|
7919
7571
|
direction: "up",
|
|
7920
7572
|
durationMs: void 0,
|
|
7921
7573
|
label,
|
|
7922
|
-
role
|
|
7574
|
+
role,
|
|
7575
|
+
required: false,
|
|
7576
|
+
polarity: this.config.polarity ?? "work"
|
|
7923
7577
|
})]);
|
|
7924
7578
|
this.subscriptions.push(
|
|
7925
7579
|
ctx.subscribe("timer:pause", (_event, pCtx) => {
|
|
@@ -8021,31 +7675,6 @@ function formatDuration(ms) {
|
|
|
8021
7675
|
const secs = totalSeconds % 60;
|
|
8022
7676
|
return `${mins}:${secs.toString().padStart(2, "0")}`;
|
|
8023
7677
|
}
|
|
8024
|
-
var CurrentRoundMetric = class {
|
|
8025
|
-
/**
|
|
8026
|
-
* @param current The current round number (1-based)
|
|
8027
|
-
* @param total Total number of planned rounds (undefined for unbounded)
|
|
8028
|
-
* @param sourceBlockKey Block that owns this round counter
|
|
8029
|
-
* @param timestamp When this metrics was created
|
|
8030
|
-
* @param customImage Optional custom image string (e.g., "Completed 3 Round(s)")
|
|
8031
|
-
*/
|
|
8032
|
-
constructor(current, total, sourceBlockKey, timestamp, customImage) {
|
|
8033
|
-
this.current = current;
|
|
8034
|
-
this.total = total;
|
|
8035
|
-
this.sourceBlockKey = sourceBlockKey;
|
|
8036
|
-
this.timestamp = timestamp;
|
|
8037
|
-
this.value = current;
|
|
8038
|
-
this.image = customImage ?? (total !== void 0 ? `Round ${current} of ${total}` : `Round ${current}`);
|
|
8039
|
-
}
|
|
8040
|
-
current;
|
|
8041
|
-
total;
|
|
8042
|
-
sourceBlockKey;
|
|
8043
|
-
timestamp;
|
|
8044
|
-
type = MetricType.CurrentRound;
|
|
8045
|
-
origin = "tracked";
|
|
8046
|
-
value;
|
|
8047
|
-
image;
|
|
8048
|
-
};
|
|
8049
7678
|
|
|
8050
7679
|
// src/runtime/behaviors/CountdownTimerBehavior.ts
|
|
8051
7680
|
var CountdownTimerBehavior = class {
|
|
@@ -8065,7 +7694,9 @@ var CountdownTimerBehavior = class {
|
|
|
8065
7694
|
direction: "down",
|
|
8066
7695
|
durationMs: this.config.durationMs,
|
|
8067
7696
|
label,
|
|
8068
|
-
role
|
|
7697
|
+
role,
|
|
7698
|
+
required: Boolean(this.config.required),
|
|
7699
|
+
polarity: this.config.polarity ?? "work"
|
|
8069
7700
|
})]);
|
|
8070
7701
|
if (this.config.durationMs <= 0) {
|
|
8071
7702
|
this.handleExpiry(ctx, mode);
|
|
@@ -11489,7 +11120,9 @@ var RestBlock = class _RestBlock extends RuntimeBlock {
|
|
|
11489
11120
|
durationMs: config.durationMs,
|
|
11490
11121
|
label: restLabel,
|
|
11491
11122
|
role: "primary",
|
|
11492
|
-
mode: "complete-block"
|
|
11123
|
+
mode: "complete-block",
|
|
11124
|
+
required: true,
|
|
11125
|
+
polarity: "rest"
|
|
11493
11126
|
}));
|
|
11494
11127
|
behaviors.push(new ExitBehavior({
|
|
11495
11128
|
mode: "immediate",
|
|
@@ -11679,6 +11312,7 @@ var BlockBuilder = class {
|
|
|
11679
11312
|
role: config.role,
|
|
11680
11313
|
mode,
|
|
11681
11314
|
required: config.required,
|
|
11315
|
+
polarity: config.polarity,
|
|
11682
11316
|
restBlockFactory: config.injectRest ? (durationMs, label) => {
|
|
11683
11317
|
const restBlock = new RestBlock(this.runtime, { durationMs, label });
|
|
11684
11318
|
return [new PushBlockAction(restBlock)];
|
|
@@ -11687,7 +11321,8 @@ var BlockBuilder = class {
|
|
|
11687
11321
|
} else {
|
|
11688
11322
|
this.addBehavior(new CountupTimerBehavior({
|
|
11689
11323
|
label: config.label,
|
|
11690
|
-
role: config.role
|
|
11324
|
+
role: config.role,
|
|
11325
|
+
polarity: config.polarity
|
|
11691
11326
|
}));
|
|
11692
11327
|
}
|
|
11693
11328
|
return this;
|
|
@@ -12197,11 +11832,22 @@ var AnalyticsEngine = class {
|
|
|
12197
11832
|
outputHistory = [];
|
|
12198
11833
|
/** Emits a live 'analytics' snapshot per segment so the UI updates in real time. */
|
|
12199
11834
|
_onLiveOutput;
|
|
11835
|
+
_liveProjections = [];
|
|
12200
11836
|
/**
|
|
12201
11837
|
* Signature of the last live projection emission. Used by finalize() to avoid
|
|
12202
11838
|
* re-emitting the same projections at session end. Timestamps are ignored.
|
|
12203
11839
|
*/
|
|
12204
11840
|
_lastLiveProjectionSignature;
|
|
11841
|
+
_now;
|
|
11842
|
+
constructor(now = wallClockNow) {
|
|
11843
|
+
this._now = now;
|
|
11844
|
+
}
|
|
11845
|
+
setNowProvider(now) {
|
|
11846
|
+
this._now = now;
|
|
11847
|
+
}
|
|
11848
|
+
getLiveProjections() {
|
|
11849
|
+
return [...this._liveProjections];
|
|
11850
|
+
}
|
|
12205
11851
|
/**
|
|
12206
11852
|
* Wire a sink for live analytics outputs. The sink receives the FULL
|
|
12207
11853
|
* projection snapshot (a replaceable, ephemeral set) each time projections
|
|
@@ -12229,8 +11875,9 @@ var AnalyticsEngine = class {
|
|
|
12229
11875
|
if (current.outputType === "segment") {
|
|
12230
11876
|
this.outputHistory.push(current);
|
|
12231
11877
|
if (this._onLiveOutput) {
|
|
12232
|
-
const now = Date.now();
|
|
12233
11878
|
const projections = this._runSummaries();
|
|
11879
|
+
this._liveProjections = projections;
|
|
11880
|
+
const now = this._now.nowMs();
|
|
12234
11881
|
const signature = this._projectionSignature(projections);
|
|
12235
11882
|
if (signature !== this._lastLiveProjectionSignature) {
|
|
12236
11883
|
this._lastLiveProjectionSignature = signature;
|
|
@@ -12243,7 +11890,8 @@ var AnalyticsEngine = class {
|
|
|
12243
11890
|
}
|
|
12244
11891
|
finalize() {
|
|
12245
11892
|
const projections = this._runSummaries();
|
|
12246
|
-
|
|
11893
|
+
this._liveProjections = [];
|
|
11894
|
+
const outputs = this._buildProjectionOutputs(projections, this._now.nowMs());
|
|
12247
11895
|
const signature = this._projectionSignature(projections);
|
|
12248
11896
|
if (this._lastLiveProjectionSignature !== void 0 && this._lastLiveProjectionSignature === signature) {
|
|
12249
11897
|
return [];
|
|
@@ -14175,7 +13823,7 @@ var RuntimeFactory = class {
|
|
|
14175
13823
|
const script = new WhiteboardScript(block.content, block.statements);
|
|
14176
13824
|
collapseUnresolvedChoices(script.statements);
|
|
14177
13825
|
const stack = new RuntimeStack();
|
|
14178
|
-
const clock = new RuntimeClock();
|
|
13826
|
+
const clock = new RuntimeClock(this.nowProvider);
|
|
14179
13827
|
const eventBus = new EventBus();
|
|
14180
13828
|
const dependencies = {
|
|
14181
13829
|
stack,
|
|
@@ -14410,6 +14058,7 @@ function compose(builder, template) {
|
|
|
14410
14058
|
completionConfig,
|
|
14411
14059
|
injectRest: t2.injectRest,
|
|
14412
14060
|
required: t2.required,
|
|
14061
|
+
polarity: t2.polarity,
|
|
14413
14062
|
...template.countdownTimerConfig ?? {}
|
|
14414
14063
|
});
|
|
14415
14064
|
}
|
|
@@ -14702,6 +14351,14 @@ var GenericTimerStrategy = class {
|
|
|
14702
14351
|
const isRequired = statements.some((s) => hasHint(s, CONSUMED_HINTS.REQUIRED_TIMER));
|
|
14703
14352
|
const injectRest = statements.some((s) => hasHint(s, CONSUMED_HINTS.INJECT_REST));
|
|
14704
14353
|
const isCountdown = !!(durationMs && direction === "down");
|
|
14354
|
+
const allMetrics = statements.flatMap((s) => [...s.metrics]);
|
|
14355
|
+
const hasRestKeyword = allMetrics.some(
|
|
14356
|
+
(m) => (m.type === MetricType.Effort || m.type === MetricType.Action) && typeof m.value === "string" && m.value.trim().toLowerCase() === "rest"
|
|
14357
|
+
);
|
|
14358
|
+
const hasNonRestMovement = allMetrics.some(
|
|
14359
|
+
(m) => m.type === MetricType.Effort && typeof m.value === "string" && m.value.trim().toLowerCase() !== "rest"
|
|
14360
|
+
);
|
|
14361
|
+
const polarity = hasRestKeyword && !hasNonRestMovement ? "rest" : "work";
|
|
14705
14362
|
const template = {
|
|
14706
14363
|
blockType: "Timer",
|
|
14707
14364
|
defaultLabel: direction === "down" ? "Countdown" : "For Time",
|
|
@@ -14714,7 +14371,8 @@ var GenericTimerStrategy = class {
|
|
|
14714
14371
|
role: "primary",
|
|
14715
14372
|
mode: isCountdown ? "complete-block" : "complete-block",
|
|
14716
14373
|
injectRest,
|
|
14717
|
-
required: isRequired
|
|
14374
|
+
required: isRequired,
|
|
14375
|
+
polarity
|
|
14718
14376
|
},
|
|
14719
14377
|
pickStatement: (stmts) => stmts.find(
|
|
14720
14378
|
(s) => s.metrics.some((f) => f.type === MetricType.Duration && f.origin !== "runtime")
|
|
@@ -16119,6 +15777,6 @@ function compareStatement(expectations, actual, mode) {
|
|
|
16119
15777
|
return diffs;
|
|
16120
15778
|
}
|
|
16121
15779
|
|
|
16122
|
-
export { ABSENT, AGGREGATE_BUILTINS, AUTHORITATIVE_CASTS, AbortSessionAction, AmrapLogicStrategy, AnalyticsEngine, AnalyticsTransformer, BUILTIN_CALCS, BUNDLED_EFFORT_COUNT, BehaviorContext, BlockBuilder, BlockContext, ButtonBehavior, COMPLETION_PROPERTY_KEYS,
|
|
15780
|
+
export { ABSENT, AGGREGATE_BUILTINS, AUTHORITATIVE_CASTS, AbortSessionAction, AmrapLogicStrategy, AnalyticsEngine, AnalyticsTransformer, BUILTIN_CALCS, BUNDLED_EFFORT_COUNT, BehaviorContext, BlockBuilder, BlockContext, ButtonBehavior, COMPLETION_PROPERTY_KEYS, CONTEXT_ATOMS, CalcEngine, CalcEvalError, CalcParseError, CalcRegistrationError, CalcUnitError, CalculationRegistry, CardioDialect, ChildSelectionBehavior, ChildrenStrategy, ChoiceGroupMetric, ClearChildrenAction, ClimbDialect, ClimbMetricType, CompileAndPushBlockAction, CompletionTimestampBehavior, CompositeEffortRegistry, CompositeEquipmentRegistry, CompositePropertyRegistry, CountdownTimerBehavior, CountupTimerBehavior, CrossFitDialect, DAY, DEFAULT_RESOLVER_OPTIONS, DEFAULT_RUNTIME_OPTIONS, DEFAULT_SOUND_PROFILE, DEFAULT_UNRESOLVED_EFFORT_MET, DIM_COUNT, DIM_ENERGY, DIM_LENGTH, DIM_MASS, DIM_TIME, DIM_ZERO, DISCIPLINE_FACTORS, DialectStack, EFFORT_DATA_METRIC_TYPE, EFFORT_DISCIPLINES, EFFORT_REGISTRY_ORIGINS, EffortBlock, EffortFallbackStrategy, EffortResolver, EmitEventAction, EmitSystemOutputAction, ErrorAction, EventBus, ExecutionContext, ExitBehavior, FixtureSyntaxError, GenericGroupStrategy, GenericLoopStrategy, GenericTimerStrategy, HabitsDialect, INTENSITY_TIERS, InMemoryEffortRegistry, IntervalLogicStrategy, JitCompiler, LabelingBehavior, LocalEventProvider, LocalRuntimeSubscription, LookupRegistry, MdTimerRuntime, MemoryLocation, MemoryTypeEnum, MetricPromotionBehavior, NAMED_COMPOUNDS, NextAction, NextEvent, NextEventHandler, OutputEmitter, PRODUCTION_STRATEGIES, PROPERTY_KEY_TO_METRIC_TYPE, PopBlockAction, PushBlockAction, PushRestBlockAction, REFERENCE_PAIR_KEYS, REST_EXCLUSION, RPE_LABELS, RUNTIME_LOG_SUBJECT_WIDTH, RegisterEventHandlerAction, Registry, ReportOutputBehavior, ReportOutputStrategy, RestBlock, RoundsMetric, RuntimeAdapter, RuntimeBlock, RuntimeBuilder, RuntimeClock, RuntimeFactory, RuntimeLogger, RuntimeMemory, RuntimeObservers, RuntimeStack, SEED_PRECEDENCE_RANK, SOUND_PLAY_EVENT, SOUND_PROFILE_METRIC, STORE_CALCS, STREAM_ATOMS, STRUCTURAL_EFFORT_WORDS, ScriptRuntime, SessionRootBlock, SessionRootStrategy, SnapshotClock, SoundProfileBehavior, SoundStrategy, SpanTrackingBehavior, StandardAnalyticsProfile, StartSessionAction, StartWorkoutAction, SubscriptionManager, ThrowError, ThrowErrorAction, TwoPassEffortResolutionProcess, TypedMemoryReference, UNITS, UnitsDialect, UnregisterEventHandlerAction, UpdateNextPreviewAction, VISIBILITY_ICONS, VISIBILITY_LABELS, WaitingToStartBlock, WaitingToStartInjectorBehavior, WhiteboardScript, WodDialect, YogaDialect, addAliasToEffort, addDim, applyTemplateDefaults, buildStaticLookups, bundledEfforts, calculateElapsed, canonicalizeType, checkCalcLine, classifyStatements, closeCurrentSpan, collapseUnresolvedChoices, commonFixtureSet, compareStatement, compileLineForm, compilePropertySummaryCalcs, compilePropertySummaryCalcsWithDiagnostics, composeDivUnit, composeMulUnit, compoundName, computeWorkloadRollups, convertScalar, createAnalyticsEngineForBlock, createCalcEngine, createCalcStack, createCompiler, createDialectStack, createDisciplinesTable, createEffortTable, createLineLocator, createMockClock, createParser, createProfileTable, createReferenceIndex, createRpeLabelsTable, dailySessionLoads, dayBucket, dedupeEntitiesByPrecedence, dialectRegistry, dialectStack, diffStatement, dimEquals, disciplineFactorFor, documentToEffort, documentToEquipment, documentToTag, effortToDocument, equipmentToDocument, evaluate, extractEffortData, extractMetrics, extractPropertyRulesFromMeta, extractStatementRefs, extractStatements, extractStatementsRaw, extractSyntaxFacts, extractTagPropertyRules, filterTagsByVisibility, findBestFuzzyMatch, findUnresolvedChoices, fixtureBackSquat, fixtureBurpee, fixturePlank, fixtureRowing, fixtureRunning, fixtureUserCustom, fixtureUserOverride, formatDim, formatDuration, formatRuntimeLogLine, formatRuntimeLogRule, formatRuntimeTimestamp, formatSoundTrigger, metricsToLabel as fragmentsToLabel, fullFixtureSet, fuseUnits, fuseUnitsInMetrics, getAnalyticsFromLogs, getAnalyticsFromRuntime, getMetricVisibility, getUnit, inferDim, isCastSubscription, isChoiceResolved, isDimensionless, isEffortDiscipline, isFragmentTag, isWithinThreshold, levenshteinDistance, mutateTimerSpans, normalizeForFuzzy, num, openSpan, outputNodeId, outputNodeIds, padRuntimeLogEvent, padRuntimeLogSubject, parseCalcLine, parseEffortFile, parseEquipmentFile, parseExpression, parseMetricLine, parseScript, parseSoundTrigger, printCalculation, readNestedSection, readTimer, realtimeProcessorRegistry, renderMetric, resolveDominantOrigin, resolveEntityRank, resolveEntityTier, resolveFusedEffortReferences, resolveProfileRules, resolvePropertyDashboardWidgets, resolveSoundProfile, resolveSourceRank, resolveSourceTier, runMetricShakeOutQueue, slugifyRefLabel, snippetCompletions, startSpan, str, strategyRegistry, subDim, summaryProcessorRegistry, tagCategoryRecordToDocument, tagCategoryToDocument, tagRecordToDocument, tagToDocument, toStoredOutputStatement, truthy, validateOutputUnit, parser as whiteboardParser, whiteboardScript, whiteboardScriptCompletion, whiteboardScriptCompletionSource, whiteboardScriptLanguage, whiteboardScriptSnippets, writeChoiceSelection };
|
|
16123
15781
|
//# sourceMappingURL=index.mjs.map
|
|
16124
15782
|
//# sourceMappingURL=index.mjs.map
|