@bitcobblers/wod-wiki-lang 0.53.2204 → 0.55.2206
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 +672 -79
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +18 -4
- package/dist/index.d.ts +18 -4
- package/dist/index.mjs +114 -537
- 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;
|
|
@@ -5237,48 +4784,6 @@ var DEFAULT_RUNTIME_OPTIONS = {
|
|
|
5237
4784
|
maxActionDepth: 20
|
|
5238
4785
|
};
|
|
5239
4786
|
|
|
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
4787
|
// src/runtime/RuntimeClock.ts
|
|
5283
4788
|
var SnapshotClock = class _SnapshotClock {
|
|
5284
4789
|
constructor(_underlying, _frozenTime) {
|
|
@@ -5333,12 +4838,16 @@ var SnapshotClock = class _SnapshotClock {
|
|
|
5333
4838
|
}
|
|
5334
4839
|
};
|
|
5335
4840
|
var RuntimeClock = class {
|
|
4841
|
+
constructor(_now = wallClockNow) {
|
|
4842
|
+
this._now = _now;
|
|
4843
|
+
}
|
|
4844
|
+
_now;
|
|
5336
4845
|
_spans = [];
|
|
5337
4846
|
/**
|
|
5338
|
-
* Current
|
|
4847
|
+
* Current clock time as a Date (from injected `INowProvider`, defaulting to wall clock).
|
|
5339
4848
|
*/
|
|
5340
4849
|
get currentDate() {
|
|
5341
|
-
return
|
|
4850
|
+
return this._now.now();
|
|
5342
4851
|
}
|
|
5343
4852
|
now() {
|
|
5344
4853
|
return this.currentDate;
|
|
@@ -5364,7 +4873,8 @@ var RuntimeClock = class {
|
|
|
5364
4873
|
* Sums all completed spans plus the current running span (if any).
|
|
5365
4874
|
*/
|
|
5366
4875
|
get elapsed() {
|
|
5367
|
-
|
|
4876
|
+
const currentMs = this._now.nowMs();
|
|
4877
|
+
return this._spans.reduce((total, span) => total + ((span.ended ?? currentMs) - span.started), 0);
|
|
5368
4878
|
}
|
|
5369
4879
|
/**
|
|
5370
4880
|
* Start the clock. Creates a new span with the current time.
|
|
@@ -5373,7 +4883,7 @@ var RuntimeClock = class {
|
|
|
5373
4883
|
* If the clock is already running, returns the current span's start time.
|
|
5374
4884
|
*/
|
|
5375
4885
|
start() {
|
|
5376
|
-
const now =
|
|
4886
|
+
const now = this._now.now();
|
|
5377
4887
|
if (this.isRunning) {
|
|
5378
4888
|
return this._spans[this._spans.length - 1].startDate;
|
|
5379
4889
|
}
|
|
@@ -5387,7 +4897,7 @@ var RuntimeClock = class {
|
|
|
5387
4897
|
* If the clock is not running, returns the current time.
|
|
5388
4898
|
*/
|
|
5389
4899
|
stop() {
|
|
5390
|
-
const now =
|
|
4900
|
+
const now = this._now.now();
|
|
5391
4901
|
if (!this.isRunning) {
|
|
5392
4902
|
return now;
|
|
5393
4903
|
}
|
|
@@ -6073,6 +5583,31 @@ var RuntimeLogger = new RuntimeLoggerImpl();
|
|
|
6073
5583
|
if (typeof window !== "undefined") {
|
|
6074
5584
|
window.RuntimeLogger = RuntimeLogger;
|
|
6075
5585
|
}
|
|
5586
|
+
var CurrentRoundMetric = class {
|
|
5587
|
+
/**
|
|
5588
|
+
* @param current The current round number (1-based)
|
|
5589
|
+
* @param total Total number of planned rounds (undefined for unbounded)
|
|
5590
|
+
* @param sourceBlockKey Block that owns this round counter
|
|
5591
|
+
* @param timestamp When this metrics was created
|
|
5592
|
+
* @param customImage Optional custom image string (e.g., "Completed 3 Round(s)")
|
|
5593
|
+
*/
|
|
5594
|
+
constructor(current, total, sourceBlockKey, timestamp, customImage) {
|
|
5595
|
+
this.current = current;
|
|
5596
|
+
this.total = total;
|
|
5597
|
+
this.sourceBlockKey = sourceBlockKey;
|
|
5598
|
+
this.timestamp = timestamp;
|
|
5599
|
+
this.value = current;
|
|
5600
|
+
this.image = customImage ?? (total !== void 0 ? `Round ${current} of ${total}` : `Round ${current}`);
|
|
5601
|
+
}
|
|
5602
|
+
current;
|
|
5603
|
+
total;
|
|
5604
|
+
sourceBlockKey;
|
|
5605
|
+
timestamp;
|
|
5606
|
+
type = MetricType.CurrentRound;
|
|
5607
|
+
origin = "tracked";
|
|
5608
|
+
value;
|
|
5609
|
+
image;
|
|
5610
|
+
};
|
|
6076
5611
|
var OutputEmitter = class {
|
|
6077
5612
|
_outputStatements = [];
|
|
6078
5613
|
_outputListeners = /* @__PURE__ */ new Set();
|
|
@@ -6102,6 +5637,17 @@ var OutputEmitter = class {
|
|
|
6102
5637
|
this._clock = deps.clock;
|
|
6103
5638
|
this._stack = deps.stack;
|
|
6104
5639
|
this._script = deps.script;
|
|
5640
|
+
if (this._analyticsEngine) {
|
|
5641
|
+
this._bindEngineClock(this._analyticsEngine);
|
|
5642
|
+
}
|
|
5643
|
+
}
|
|
5644
|
+
_bindEngineClock(engine) {
|
|
5645
|
+
if (!this._clock || !engine.setNowProvider) return;
|
|
5646
|
+
const clock = this._clock;
|
|
5647
|
+
engine.setNowProvider({
|
|
5648
|
+
now: () => clock.currentDate,
|
|
5649
|
+
nowMs: () => clock.currentDate.getTime()
|
|
5650
|
+
});
|
|
6105
5651
|
}
|
|
6106
5652
|
_requireClock() {
|
|
6107
5653
|
if (!this._clock) {
|
|
@@ -6166,6 +5712,7 @@ var OutputEmitter = class {
|
|
|
6166
5712
|
}
|
|
6167
5713
|
setAnalyticsEngine(engine) {
|
|
6168
5714
|
this._analyticsEngine = engine;
|
|
5715
|
+
this._bindEngineClock(engine);
|
|
6169
5716
|
engine.setLiveOutputEmitter((outputs) => this.emitLiveAnalytics(outputs));
|
|
6170
5717
|
}
|
|
6171
5718
|
/**
|
|
@@ -6218,6 +5765,11 @@ var OutputEmitter = class {
|
|
|
6218
5765
|
getLiveAnalytics() {
|
|
6219
5766
|
return [...this._liveAnalytics];
|
|
6220
5767
|
}
|
|
5768
|
+
/** Typed live Summary Metric projections directly from AnalyticsEngine. */
|
|
5769
|
+
getLiveProjections() {
|
|
5770
|
+
if (this._analyticsFinalized) return [];
|
|
5771
|
+
return this._analyticsEngine?.getLiveProjections?.() ?? [];
|
|
5772
|
+
}
|
|
6221
5773
|
dispose() {
|
|
6222
5774
|
this._outputStatements = [];
|
|
6223
5775
|
this._outputListeners.clear();
|
|
@@ -6324,6 +5876,22 @@ var OutputEmitter = class {
|
|
|
6324
5876
|
const sourceFragments = MetricContainer.from(displayLocs[i]?.metrics, block.key.toString());
|
|
6325
5877
|
const metrics = MetricContainer.empty(block.key.toString()).add(...sourceFragments.toArray()).add(...resultFragments.toArray());
|
|
6326
5878
|
if (metrics.length === 0) continue;
|
|
5879
|
+
if (!metrics.some((m) => m.type === MetricType.CurrentRound) && block.getMemoryByTag("children:status").length === 0 && block.blockType !== "SessionRoot" && block.blockType !== "Rounds") {
|
|
5880
|
+
const enclosingRoundBlock = (this._stack?.blocks ?? []).find(
|
|
5881
|
+
(ancestor2) => ancestor2.blockType !== "SessionRoot" && ancestor2.getMemoryByTag("round").length > 0
|
|
5882
|
+
);
|
|
5883
|
+
const roundState = enclosingRoundBlock?.getMemoryByTag("round")[0]?.metrics[0];
|
|
5884
|
+
if (roundState && typeof roundState.current === "number") {
|
|
5885
|
+
metrics.add(
|
|
5886
|
+
new CurrentRoundMetric(
|
|
5887
|
+
roundState.current,
|
|
5888
|
+
roundState.total,
|
|
5889
|
+
enclosingRoundBlock?.key.toString(),
|
|
5890
|
+
new Date(fallbackEndMs)
|
|
5891
|
+
)
|
|
5892
|
+
);
|
|
5893
|
+
}
|
|
5894
|
+
}
|
|
6327
5895
|
const fallbackStartMs = block.executionTiming?.startTime?.getTime() ?? fallbackEndMs;
|
|
6328
5896
|
const timeSpan = new TimeSpan(fallbackStartMs, fallbackEndMs);
|
|
6329
5897
|
this.add(new OutputStatement({
|
|
@@ -6703,6 +6271,9 @@ var ScriptRuntime = class {
|
|
|
6703
6271
|
getLiveAnalytics() {
|
|
6704
6272
|
return this._output.getLiveAnalytics();
|
|
6705
6273
|
}
|
|
6274
|
+
getLiveProjections() {
|
|
6275
|
+
return this._output.getLiveProjections();
|
|
6276
|
+
}
|
|
6706
6277
|
/**
|
|
6707
6278
|
* Add an output statement to the collection and notify subscribers.
|
|
6708
6279
|
* Used by BehaviorContext to emit outputs at any lifecycle point.
|
|
@@ -7919,7 +7490,9 @@ var CountupTimerBehavior = class {
|
|
|
7919
7490
|
direction: "up",
|
|
7920
7491
|
durationMs: void 0,
|
|
7921
7492
|
label,
|
|
7922
|
-
role
|
|
7493
|
+
role,
|
|
7494
|
+
required: false,
|
|
7495
|
+
polarity: this.config.polarity ?? "work"
|
|
7923
7496
|
})]);
|
|
7924
7497
|
this.subscriptions.push(
|
|
7925
7498
|
ctx.subscribe("timer:pause", (_event, pCtx) => {
|
|
@@ -8021,31 +7594,6 @@ function formatDuration(ms) {
|
|
|
8021
7594
|
const secs = totalSeconds % 60;
|
|
8022
7595
|
return `${mins}:${secs.toString().padStart(2, "0")}`;
|
|
8023
7596
|
}
|
|
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
7597
|
|
|
8050
7598
|
// src/runtime/behaviors/CountdownTimerBehavior.ts
|
|
8051
7599
|
var CountdownTimerBehavior = class {
|
|
@@ -8065,7 +7613,9 @@ var CountdownTimerBehavior = class {
|
|
|
8065
7613
|
direction: "down",
|
|
8066
7614
|
durationMs: this.config.durationMs,
|
|
8067
7615
|
label,
|
|
8068
|
-
role
|
|
7616
|
+
role,
|
|
7617
|
+
required: Boolean(this.config.required),
|
|
7618
|
+
polarity: this.config.polarity ?? "work"
|
|
8069
7619
|
})]);
|
|
8070
7620
|
if (this.config.durationMs <= 0) {
|
|
8071
7621
|
this.handleExpiry(ctx, mode);
|
|
@@ -11489,7 +11039,9 @@ var RestBlock = class _RestBlock extends RuntimeBlock {
|
|
|
11489
11039
|
durationMs: config.durationMs,
|
|
11490
11040
|
label: restLabel,
|
|
11491
11041
|
role: "primary",
|
|
11492
|
-
mode: "complete-block"
|
|
11042
|
+
mode: "complete-block",
|
|
11043
|
+
required: true,
|
|
11044
|
+
polarity: "rest"
|
|
11493
11045
|
}));
|
|
11494
11046
|
behaviors.push(new ExitBehavior({
|
|
11495
11047
|
mode: "immediate",
|
|
@@ -11679,6 +11231,7 @@ var BlockBuilder = class {
|
|
|
11679
11231
|
role: config.role,
|
|
11680
11232
|
mode,
|
|
11681
11233
|
required: config.required,
|
|
11234
|
+
polarity: config.polarity,
|
|
11682
11235
|
restBlockFactory: config.injectRest ? (durationMs, label) => {
|
|
11683
11236
|
const restBlock = new RestBlock(this.runtime, { durationMs, label });
|
|
11684
11237
|
return [new PushBlockAction(restBlock)];
|
|
@@ -11687,7 +11240,8 @@ var BlockBuilder = class {
|
|
|
11687
11240
|
} else {
|
|
11688
11241
|
this.addBehavior(new CountupTimerBehavior({
|
|
11689
11242
|
label: config.label,
|
|
11690
|
-
role: config.role
|
|
11243
|
+
role: config.role,
|
|
11244
|
+
polarity: config.polarity
|
|
11691
11245
|
}));
|
|
11692
11246
|
}
|
|
11693
11247
|
return this;
|
|
@@ -12197,11 +11751,22 @@ var AnalyticsEngine = class {
|
|
|
12197
11751
|
outputHistory = [];
|
|
12198
11752
|
/** Emits a live 'analytics' snapshot per segment so the UI updates in real time. */
|
|
12199
11753
|
_onLiveOutput;
|
|
11754
|
+
_liveProjections = [];
|
|
12200
11755
|
/**
|
|
12201
11756
|
* Signature of the last live projection emission. Used by finalize() to avoid
|
|
12202
11757
|
* re-emitting the same projections at session end. Timestamps are ignored.
|
|
12203
11758
|
*/
|
|
12204
11759
|
_lastLiveProjectionSignature;
|
|
11760
|
+
_now;
|
|
11761
|
+
constructor(now = wallClockNow) {
|
|
11762
|
+
this._now = now;
|
|
11763
|
+
}
|
|
11764
|
+
setNowProvider(now) {
|
|
11765
|
+
this._now = now;
|
|
11766
|
+
}
|
|
11767
|
+
getLiveProjections() {
|
|
11768
|
+
return [...this._liveProjections];
|
|
11769
|
+
}
|
|
12205
11770
|
/**
|
|
12206
11771
|
* Wire a sink for live analytics outputs. The sink receives the FULL
|
|
12207
11772
|
* projection snapshot (a replaceable, ephemeral set) each time projections
|
|
@@ -12229,8 +11794,9 @@ var AnalyticsEngine = class {
|
|
|
12229
11794
|
if (current.outputType === "segment") {
|
|
12230
11795
|
this.outputHistory.push(current);
|
|
12231
11796
|
if (this._onLiveOutput) {
|
|
12232
|
-
const now = Date.now();
|
|
12233
11797
|
const projections = this._runSummaries();
|
|
11798
|
+
this._liveProjections = projections;
|
|
11799
|
+
const now = this._now.nowMs();
|
|
12234
11800
|
const signature = this._projectionSignature(projections);
|
|
12235
11801
|
if (signature !== this._lastLiveProjectionSignature) {
|
|
12236
11802
|
this._lastLiveProjectionSignature = signature;
|
|
@@ -12243,7 +11809,8 @@ var AnalyticsEngine = class {
|
|
|
12243
11809
|
}
|
|
12244
11810
|
finalize() {
|
|
12245
11811
|
const projections = this._runSummaries();
|
|
12246
|
-
|
|
11812
|
+
this._liveProjections = [];
|
|
11813
|
+
const outputs = this._buildProjectionOutputs(projections, this._now.nowMs());
|
|
12247
11814
|
const signature = this._projectionSignature(projections);
|
|
12248
11815
|
if (this._lastLiveProjectionSignature !== void 0 && this._lastLiveProjectionSignature === signature) {
|
|
12249
11816
|
return [];
|
|
@@ -14175,7 +13742,7 @@ var RuntimeFactory = class {
|
|
|
14175
13742
|
const script = new WhiteboardScript(block.content, block.statements);
|
|
14176
13743
|
collapseUnresolvedChoices(script.statements);
|
|
14177
13744
|
const stack = new RuntimeStack();
|
|
14178
|
-
const clock = new RuntimeClock();
|
|
13745
|
+
const clock = new RuntimeClock(this.nowProvider);
|
|
14179
13746
|
const eventBus = new EventBus();
|
|
14180
13747
|
const dependencies = {
|
|
14181
13748
|
stack,
|
|
@@ -14410,6 +13977,7 @@ function compose(builder, template) {
|
|
|
14410
13977
|
completionConfig,
|
|
14411
13978
|
injectRest: t2.injectRest,
|
|
14412
13979
|
required: t2.required,
|
|
13980
|
+
polarity: t2.polarity,
|
|
14413
13981
|
...template.countdownTimerConfig ?? {}
|
|
14414
13982
|
});
|
|
14415
13983
|
}
|
|
@@ -14702,6 +14270,14 @@ var GenericTimerStrategy = class {
|
|
|
14702
14270
|
const isRequired = statements.some((s) => hasHint(s, CONSUMED_HINTS.REQUIRED_TIMER));
|
|
14703
14271
|
const injectRest = statements.some((s) => hasHint(s, CONSUMED_HINTS.INJECT_REST));
|
|
14704
14272
|
const isCountdown = !!(durationMs && direction === "down");
|
|
14273
|
+
const allMetrics = statements.flatMap((s) => [...s.metrics]);
|
|
14274
|
+
const hasRestKeyword = allMetrics.some(
|
|
14275
|
+
(m) => (m.type === MetricType.Effort || m.type === MetricType.Action) && typeof m.value === "string" && m.value.trim().toLowerCase() === "rest"
|
|
14276
|
+
);
|
|
14277
|
+
const hasNonRestMovement = allMetrics.some(
|
|
14278
|
+
(m) => m.type === MetricType.Effort && typeof m.value === "string" && m.value.trim().toLowerCase() !== "rest"
|
|
14279
|
+
);
|
|
14280
|
+
const polarity = hasRestKeyword && !hasNonRestMovement ? "rest" : "work";
|
|
14705
14281
|
const template = {
|
|
14706
14282
|
blockType: "Timer",
|
|
14707
14283
|
defaultLabel: direction === "down" ? "Countdown" : "For Time",
|
|
@@ -14714,7 +14290,8 @@ var GenericTimerStrategy = class {
|
|
|
14714
14290
|
role: "primary",
|
|
14715
14291
|
mode: isCountdown ? "complete-block" : "complete-block",
|
|
14716
14292
|
injectRest,
|
|
14717
|
-
required: isRequired
|
|
14293
|
+
required: isRequired,
|
|
14294
|
+
polarity
|
|
14718
14295
|
},
|
|
14719
14296
|
pickStatement: (stmts) => stmts.find(
|
|
14720
14297
|
(s) => s.metrics.some((f) => f.type === MetricType.Duration && f.origin !== "runtime")
|
|
@@ -16119,6 +15696,6 @@ function compareStatement(expectations, actual, mode) {
|
|
|
16119
15696
|
return diffs;
|
|
16120
15697
|
}
|
|
16121
15698
|
|
|
16122
|
-
export { ABSENT, AGGREGATE_BUILTINS, AUTHORITATIVE_CASTS, AbortSessionAction, AmrapLogicStrategy, AnalyticsEngine, AnalyticsTransformer, BUILTIN_CALCS, BUNDLED_EFFORT_COUNT, BehaviorContext, BlockBuilder, BlockContext, ButtonBehavior, COMPLETION_PROPERTY_KEYS,
|
|
15699
|
+
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
15700
|
//# sourceMappingURL=index.mjs.map
|
|
16124
15701
|
//# sourceMappingURL=index.mjs.map
|