@bitcobblers/wod-wiki-lang 0.55.2206 → 0.56.2210
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/{chunk-XDMS3U3W.mjs → chunk-3F27TTFS.mjs} +34 -8
- package/dist/chunk-3F27TTFS.mjs.map +1 -0
- package/dist/index.cjs +132 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +13 -1
- package/dist/index.d.ts +13 -1
- package/dist/index.mjs +102 -10
- package/dist/index.mjs.map +1 -1
- package/dist/react.cjs +32 -6
- package/dist/react.cjs.map +1 -1
- package/dist/react.mjs +2 -2
- package/package.json +2 -2
- package/dist/chunk-XDMS3U3W.mjs.map +0 -1
package/dist/index.d.cts
CHANGED
|
@@ -312,6 +312,7 @@ declare class UnitsDialect implements IDialect {
|
|
|
312
312
|
declare class CrossFitDialect implements IDialect {
|
|
313
313
|
id: string;
|
|
314
314
|
name: string;
|
|
315
|
+
transform(statement: ICodeStatement): void;
|
|
315
316
|
/**
|
|
316
317
|
* Check if any Action or Effort metrics contains a keyword (case-insensitive)
|
|
317
318
|
*/
|
|
@@ -344,6 +345,7 @@ declare class CrossFitDialect implements IDialect {
|
|
|
344
345
|
declare class WodDialect implements IDialect {
|
|
345
346
|
id: string;
|
|
346
347
|
name: string;
|
|
348
|
+
transform(statement: ICodeStatement): void;
|
|
347
349
|
/** Case-insensitive keyword check on Action/Effort metrics */
|
|
348
350
|
private hasKeyword;
|
|
349
351
|
analyze(statement: ICodeStatement): DialectAnalysis;
|
|
@@ -592,6 +594,8 @@ interface RoundsPrimitive extends BasePrimitive {
|
|
|
592
594
|
kind: 'rounds';
|
|
593
595
|
sequence?: number[];
|
|
594
596
|
label?: string;
|
|
597
|
+
sequenceMeta?: SyntaxMeta;
|
|
598
|
+
labelMeta?: SyntaxMeta;
|
|
595
599
|
}
|
|
596
600
|
/**
|
|
597
601
|
* Inline NxM rounds scheme — `5x5` or `5 x 5` — lexed as one token so a bare
|
|
@@ -2237,6 +2241,13 @@ interface CountupTimerConfig {
|
|
|
2237
2241
|
/** Timer role for display priority */
|
|
2238
2242
|
role?: 'primary' | 'secondary' | 'hidden' | 'auto';
|
|
2239
2243
|
polarity?: TimerPolarity;
|
|
2244
|
+
/**
|
|
2245
|
+
* Reset the initial open mount span to `now` on the first onNext.
|
|
2246
|
+
* SessionRootBlock enables this so the session clock starts at the
|
|
2247
|
+
* moment the WaitingToStart gate pops, not at session mount — the
|
|
2248
|
+
* athlete's idle wait at the gate is not workout time.
|
|
2249
|
+
*/
|
|
2250
|
+
resetOnFirstNext?: boolean;
|
|
2240
2251
|
}
|
|
2241
2252
|
/**
|
|
2242
2253
|
* CountupTimerBehavior manages the full lifecycle of a count-up timer.
|
|
@@ -2259,8 +2270,9 @@ declare class CountupTimerBehavior implements IRuntimeBehavior {
|
|
|
2259
2270
|
constructor(config?: CountupTimerConfig);
|
|
2260
2271
|
private subscriptions;
|
|
2261
2272
|
private isPaused;
|
|
2273
|
+
private firstNextSeen;
|
|
2262
2274
|
onMount(ctx: IBehaviorContext): IRuntimeAction[];
|
|
2263
|
-
onNext(
|
|
2275
|
+
onNext(ctx: IBehaviorContext): IRuntimeAction[];
|
|
2264
2276
|
onUnmount(ctx: IBehaviorContext): IRuntimeAction[];
|
|
2265
2277
|
onDispose(_ctx: IBehaviorContext): void;
|
|
2266
2278
|
private createFragment;
|
package/dist/index.d.ts
CHANGED
|
@@ -312,6 +312,7 @@ declare class UnitsDialect implements IDialect {
|
|
|
312
312
|
declare class CrossFitDialect implements IDialect {
|
|
313
313
|
id: string;
|
|
314
314
|
name: string;
|
|
315
|
+
transform(statement: ICodeStatement): void;
|
|
315
316
|
/**
|
|
316
317
|
* Check if any Action or Effort metrics contains a keyword (case-insensitive)
|
|
317
318
|
*/
|
|
@@ -344,6 +345,7 @@ declare class CrossFitDialect implements IDialect {
|
|
|
344
345
|
declare class WodDialect implements IDialect {
|
|
345
346
|
id: string;
|
|
346
347
|
name: string;
|
|
348
|
+
transform(statement: ICodeStatement): void;
|
|
347
349
|
/** Case-insensitive keyword check on Action/Effort metrics */
|
|
348
350
|
private hasKeyword;
|
|
349
351
|
analyze(statement: ICodeStatement): DialectAnalysis;
|
|
@@ -592,6 +594,8 @@ interface RoundsPrimitive extends BasePrimitive {
|
|
|
592
594
|
kind: 'rounds';
|
|
593
595
|
sequence?: number[];
|
|
594
596
|
label?: string;
|
|
597
|
+
sequenceMeta?: SyntaxMeta;
|
|
598
|
+
labelMeta?: SyntaxMeta;
|
|
595
599
|
}
|
|
596
600
|
/**
|
|
597
601
|
* Inline NxM rounds scheme — `5x5` or `5 x 5` — lexed as one token so a bare
|
|
@@ -2237,6 +2241,13 @@ interface CountupTimerConfig {
|
|
|
2237
2241
|
/** Timer role for display priority */
|
|
2238
2242
|
role?: 'primary' | 'secondary' | 'hidden' | 'auto';
|
|
2239
2243
|
polarity?: TimerPolarity;
|
|
2244
|
+
/**
|
|
2245
|
+
* Reset the initial open mount span to `now` on the first onNext.
|
|
2246
|
+
* SessionRootBlock enables this so the session clock starts at the
|
|
2247
|
+
* moment the WaitingToStart gate pops, not at session mount — the
|
|
2248
|
+
* athlete's idle wait at the gate is not workout time.
|
|
2249
|
+
*/
|
|
2250
|
+
resetOnFirstNext?: boolean;
|
|
2240
2251
|
}
|
|
2241
2252
|
/**
|
|
2242
2253
|
* CountupTimerBehavior manages the full lifecycle of a count-up timer.
|
|
@@ -2259,8 +2270,9 @@ declare class CountupTimerBehavior implements IRuntimeBehavior {
|
|
|
2259
2270
|
constructor(config?: CountupTimerConfig);
|
|
2260
2271
|
private subscriptions;
|
|
2261
2272
|
private isPaused;
|
|
2273
|
+
private firstNextSeen;
|
|
2262
2274
|
onMount(ctx: IBehaviorContext): IRuntimeAction[];
|
|
2263
|
-
onNext(
|
|
2275
|
+
onNext(ctx: IBehaviorContext): IRuntimeAction[];
|
|
2264
2276
|
onUnmount(ctx: IBehaviorContext): IRuntimeAction[];
|
|
2265
2277
|
onDispose(_ctx: IBehaviorContext): void;
|
|
2266
2278
|
private createFragment;
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { UnitRegistry, hintsToContainer, hasHint, CONSUMED_HINTS, wallClockNow, TimeSpan, metricPresentation, hintMetric, resolveTagContributions, tagReferenceFor, tagContributionMetrics, tagMarkerType, collectTagReferences, tagMarkerSlugs, getHints } from './chunk-
|
|
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-
|
|
1
|
+
import { UnitRegistry, hintsToContainer, hasHint, CONSUMED_HINTS, wallClockNow, TimeSpan, metricPresentation, hintMetric, resolveTagContributions, tagReferenceFor, tagContributionMetrics, tagMarkerType, collectTagReferences, tagMarkerSlugs, getHints } from './chunk-3F27TTFS.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-3F27TTFS.mjs';
|
|
3
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';
|
|
@@ -439,9 +439,15 @@ var UnitsDialect = class {
|
|
|
439
439
|
return {};
|
|
440
440
|
}
|
|
441
441
|
};
|
|
442
|
+
var CROSSFIT_UNITS = UnitRegistry.of([
|
|
443
|
+
{ canonical: "pood", dimension: "mass", aliases: ["poods", "pd"] }
|
|
444
|
+
]);
|
|
442
445
|
var CrossFitDialect = class {
|
|
443
446
|
id = "crossfit";
|
|
444
447
|
name = "CrossFit Dialect";
|
|
448
|
+
transform(statement) {
|
|
449
|
+
fuseUnits(statement, CROSSFIT_UNITS);
|
|
450
|
+
}
|
|
445
451
|
/**
|
|
446
452
|
* Check if any Action or Effort metrics contains a keyword (case-insensitive)
|
|
447
453
|
*/
|
|
@@ -490,9 +496,15 @@ var CrossFitDialect = class {
|
|
|
490
496
|
return { metrics: hintsToContainer(hints) };
|
|
491
497
|
}
|
|
492
498
|
};
|
|
499
|
+
var WOD_UNITS = UnitRegistry.of([
|
|
500
|
+
{ canonical: "pood", dimension: "mass", aliases: ["poods", "pd"] }
|
|
501
|
+
]);
|
|
493
502
|
var WodDialect = class {
|
|
494
503
|
id = "wod";
|
|
495
504
|
name = "WOD Dialect";
|
|
505
|
+
transform(statement) {
|
|
506
|
+
fuseUnits(statement, WOD_UNITS);
|
|
507
|
+
}
|
|
496
508
|
/** Case-insensitive keyword check on Action/Effort metrics */
|
|
497
509
|
hasKeyword(metrics, keyword2) {
|
|
498
510
|
return metrics.some(
|
|
@@ -1197,6 +1209,36 @@ var PROPERTY_KEY_TO_METRIC_TYPE = {
|
|
|
1197
1209
|
};
|
|
1198
1210
|
var STRUCTURAL_EFFORT_WORDS = /* @__PURE__ */ new Set(["rest", "amrap", "emom", "tabata", "for time"]);
|
|
1199
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
|
+
}
|
|
1200
1242
|
var REFERENCE_PAIR_KEYS = /* @__PURE__ */ new Set(["effort", "equipment"]);
|
|
1201
1243
|
function referenceMetadata(resolution) {
|
|
1202
1244
|
return {
|
|
@@ -1339,7 +1381,7 @@ function applyReferenceResolution(pairs, fact, references) {
|
|
|
1339
1381
|
if (metric.type === MetricType.Effort) {
|
|
1340
1382
|
const authored = metric instanceof EffortMetric ? metric.effort : String(metric.value ?? "");
|
|
1341
1383
|
const normalized = authored.trim().toLowerCase();
|
|
1342
|
-
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)) {
|
|
1343
1385
|
result.push(pair);
|
|
1344
1386
|
continue;
|
|
1345
1387
|
}
|
|
@@ -1443,14 +1485,49 @@ function classifyPrimitive(primitive) {
|
|
|
1443
1485
|
case "rounds": {
|
|
1444
1486
|
if (primitive.sequence) {
|
|
1445
1487
|
if (primitive.sequence.length === 1) {
|
|
1446
|
-
|
|
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
|
+
];
|
|
1447
1506
|
}
|
|
1448
1507
|
return [
|
|
1449
1508
|
{ metrics: new RoundsMetric(primitive.sequence.length), meta: primitive.meta },
|
|
1450
1509
|
...primitive.sequence.map((value) => ({ metrics: new RepMetric(value), meta: primitive.meta }))
|
|
1451
1510
|
];
|
|
1452
1511
|
}
|
|
1453
|
-
|
|
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 }];
|
|
1454
1531
|
}
|
|
1455
1532
|
case "round_scheme": {
|
|
1456
1533
|
return [
|
|
@@ -1846,13 +1923,17 @@ function mapFragmentToPrimitive(locator, source, node) {
|
|
|
1846
1923
|
}
|
|
1847
1924
|
case Rounds: {
|
|
1848
1925
|
const sequence = node.getChild("Sequence");
|
|
1849
|
-
const
|
|
1926
|
+
const identifiers = node.getChildren("Identifier");
|
|
1927
|
+
const firstId = identifiers[0];
|
|
1928
|
+
const lastId = identifiers[identifiers.length - 1];
|
|
1850
1929
|
const primitive = {
|
|
1851
1930
|
kind: "rounds",
|
|
1852
1931
|
raw,
|
|
1853
1932
|
meta: meta2,
|
|
1854
|
-
sequence: sequence ? source.slice(sequence.from, sequence.to).split("-").map((n) =>
|
|
1855
|
-
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
|
|
1856
1937
|
};
|
|
1857
1938
|
return primitive;
|
|
1858
1939
|
}
|
|
@@ -7481,6 +7562,7 @@ var CountupTimerBehavior = class {
|
|
|
7481
7562
|
config;
|
|
7482
7563
|
subscriptions = [];
|
|
7483
7564
|
isPaused = false;
|
|
7565
|
+
firstNextSeen = false;
|
|
7484
7566
|
onMount(ctx) {
|
|
7485
7567
|
const now = ctx.clock.currentDate.getTime();
|
|
7486
7568
|
const label = this.config.label ?? ctx.block.label;
|
|
@@ -7510,7 +7592,14 @@ var CountupTimerBehavior = class {
|
|
|
7510
7592
|
);
|
|
7511
7593
|
return [];
|
|
7512
7594
|
}
|
|
7513
|
-
onNext(
|
|
7595
|
+
onNext(ctx) {
|
|
7596
|
+
if (this.config.resetOnFirstNext && !this.firstNextSeen) {
|
|
7597
|
+
this.firstNextSeen = true;
|
|
7598
|
+
mutateTimerSpans(
|
|
7599
|
+
ctx,
|
|
7600
|
+
(spans, nowMs) => spans.length === 1 && spans[0].ended === void 0 ? [new TimeSpan(nowMs)] : [...spans]
|
|
7601
|
+
);
|
|
7602
|
+
}
|
|
7514
7603
|
return [];
|
|
7515
7604
|
}
|
|
7516
7605
|
onUnmount(ctx) {
|
|
@@ -11554,7 +11643,10 @@ var SessionRootBlock = class _SessionRootBlock extends RuntimeBlock {
|
|
|
11554
11643
|
const sessionLabel = config.label ?? "Session";
|
|
11555
11644
|
behaviors.push(new CountupTimerBehavior({
|
|
11556
11645
|
label: sessionLabel,
|
|
11557
|
-
role: "auto"
|
|
11646
|
+
role: "auto",
|
|
11647
|
+
// The session clock starts when the WaitingToStart gate pops —
|
|
11648
|
+
// not at mount — so idle wait time never counts as workout time.
|
|
11649
|
+
resetOnFirstNext: true
|
|
11558
11650
|
}));
|
|
11559
11651
|
behaviors.push(new ChildSelectionBehavior({
|
|
11560
11652
|
childGroups: config.childGroups,
|