@bitcobblers/wod-wiki-lang 0.60.2258 → 0.62.2260

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/react.cjs CHANGED
@@ -818,14 +818,46 @@ var TIME_LIKE_TYPES = /* @__PURE__ */ new Set([
818
818
  function isTimeLikeMetric(type) {
819
819
  return TIME_LIKE_TYPES.has(type);
820
820
  }
821
+ function dedupePresentedLabels(labels) {
822
+ const deduped = [];
823
+ for (const raw of labels) {
824
+ const label = raw.trim();
825
+ if (!label) continue;
826
+ const lower = label.toLowerCase();
827
+ const prev = deduped[deduped.length - 1]?.toLowerCase();
828
+ if (prev && (prev === lower || prev.endsWith(` ${lower}`))) continue;
829
+ deduped.push(label);
830
+ }
831
+ return deduped;
832
+ }
821
833
  function baseText(metric) {
822
834
  if (metric.image) return metric.image;
823
835
  if (metric.value === void 0 || metric.value === null) return metric.type;
836
+ if (metric.value instanceof Date) {
837
+ return metric.value.toISOString();
838
+ }
839
+ if (Array.isArray(metric.value)) {
840
+ const spans = metric.value.filter(
841
+ (item) => Boolean(item) && typeof item === "object" && "started" in item && typeof item.started === "number"
842
+ );
843
+ if (spans.length > 0 && spans.length === metric.value.length) {
844
+ const totalMs = spans.reduce((acc, s) => acc + Math.max(0, (s.ended ?? s.started) - s.started), 0);
845
+ return formatDurationSmart(totalMs);
846
+ }
847
+ return metric.value.map((item) => String(item)).filter(Boolean).join(", ");
848
+ }
824
849
  if (typeof metric.value === "object") {
825
850
  const v = metric.value;
851
+ if ("amount" in v && "units" in v) {
852
+ return v.amount !== void 0 ? `${v.amount} ${v.units}` : String(v.units);
853
+ }
826
854
  if ("text" in v) return String(v.text);
827
855
  if ("current" in v) return `Round ${v.current}`;
828
- return JSON.stringify(metric.value);
856
+ if ("started" in v && typeof v.started === "number") {
857
+ const ended = typeof v.ended === "number" ? v.ended : v.started;
858
+ return formatDurationSmart(Math.max(0, ended - v.started));
859
+ }
860
+ return computeColumnLabel(metric.type);
829
861
  }
830
862
  return String(metric.value);
831
863
  }
@@ -848,6 +880,24 @@ function formatTooltipValue(metric) {
848
880
  return formatDurationSmart(metric.value);
849
881
  }
850
882
  const val = metric.value;
883
+ if (typeof val === "number" && Number.isFinite(val)) {
884
+ const formatted = Number.isInteger(val) ? String(val) : (Math.round(val * 10) / 10).toFixed(1);
885
+ return metric.unit ? `${formatted} ${metric.unit}` : formatted;
886
+ }
887
+ if (val instanceof Date) {
888
+ return val.toISOString();
889
+ }
890
+ if (Array.isArray(val)) {
891
+ if (metric.image) return metric.image;
892
+ const spans = val.filter(
893
+ (item) => Boolean(item) && typeof item === "object" && "started" in item && typeof item.started === "number"
894
+ );
895
+ if (spans.length > 0 && spans.length === val.length) {
896
+ const totalMs = spans.reduce((acc, s) => acc + Math.max(0, (s.ended ?? s.started) - s.started), 0);
897
+ return formatDurationSmart(totalMs);
898
+ }
899
+ return val.map((item) => String(item)).filter(Boolean).join(", ");
900
+ }
851
901
  if (val !== null && typeof val === "object") {
852
902
  if (metric.image) return metric.image;
853
903
  const obj = val;
@@ -856,11 +906,23 @@ function formatTooltipValue(metric) {
856
906
  }
857
907
  if ("text" in obj) return String(obj.text);
858
908
  if ("current" in obj) return `Round ${obj.current}`;
859
- return JSON.stringify(val);
909
+ if ("started" in obj && typeof obj.started === "number") {
910
+ const ended = typeof obj.ended === "number" ? obj.ended : obj.started;
911
+ return formatDurationSmart(Math.max(0, ended - obj.started));
912
+ }
913
+ return computeColumnLabel(metric.type);
914
+ }
915
+ if (metric.image && metric.unit && typeof val === "string" && !val.includes(metric.unit)) {
916
+ return metric.image;
860
917
  }
861
- return String(val);
918
+ return val !== void 0 && val !== null ? String(val) : metric.image ?? computeColumnLabel(metric.type);
862
919
  }
863
- function buildTooltip(metric) {
920
+ function buildTooltip(metric, surface) {
921
+ if (surface && surface !== "debug") {
922
+ const heading = computeColumnLabel(metric.type);
923
+ const valText = formatTooltipValue(metric);
924
+ return valText ? `${heading}: ${valText}` : heading;
925
+ }
864
926
  const parts = [];
865
927
  parts.push(`Type: ${metric.type}`);
866
928
  if (metric.value !== void 0) parts.push(`Value: ${formatTooltipValue(metric)}`);
@@ -1010,6 +1072,18 @@ function createPolicy() {
1010
1072
  const t = metric.type;
1011
1073
  if ((t === wodWikiCore.MetricType.Sound || t === "sound") && surface !== "debug") return true;
1012
1074
  if (t.startsWith(TAG_MARKER_PREFIX) && surface !== "debug") return true;
1075
+ if (surface !== "debug") {
1076
+ if (t === wodWikiCore.MetricType.SystemTime || t === "system-time" || t === wodWikiCore.MetricType.Spans || t === "spans") {
1077
+ return true;
1078
+ }
1079
+ if (t === wodWikiCore.MetricType.Equipment || t === "equipment") {
1080
+ const refMeta = metric.metadata?.[wodWikiCore.REFERENCE_METADATA_KEY];
1081
+ const directMatched = metric.metadata?.matched;
1082
+ if (metric.origin === "compiler" || refMeta?.matched === "whole" || directMatched === "whole") {
1083
+ return true;
1084
+ }
1085
+ }
1086
+ }
1013
1087
  if (surface === "review-grid-column") {
1014
1088
  if (t === wodWikiCore.MetricType.Elapsed || t === "elapsed" || t === wodWikiCore.MetricType.Total || t === "total") return true;
1015
1089
  if (t === wodWikiCore.MetricType.System || t === "system") return true;
@@ -1037,7 +1111,7 @@ function createPolicy() {
1037
1111
  return {
1038
1112
  metric,
1039
1113
  label: computeLabel(metric),
1040
- tooltip: buildTooltip(metric),
1114
+ tooltip: buildTooltip(metric, surface),
1041
1115
  renderKind,
1042
1116
  tone: computeTone(metric, rest),
1043
1117
  iconKey: rest ? "rest" : metric.type,
@@ -1154,7 +1228,9 @@ function readNextPreviewText(blocks) {
1154
1228
  const merged = wodWikiCore.MetricContainer.empty(block.key.toString());
1155
1229
  for (const loc of nextLocs) merged.merge(loc.metrics);
1156
1230
  if (merged.length > 0) {
1157
- return metricPresentation.presentGroup([...merged], "timer-subtitle").filter((t) => t.visible).map((t) => t.label).filter(Boolean).join(" ").trim() || null;
1231
+ return dedupePresentedLabels(
1232
+ metricPresentation.presentGroup([...merged], "timer-subtitle").filter((t) => t.visible).map((t) => t.label)
1233
+ ).join(" ").trim() || null;
1158
1234
  }
1159
1235
  }
1160
1236
  return null;
@@ -1284,7 +1360,9 @@ function projectSessionClock(runtime, options = {}) {
1284
1360
  let subLabels;
1285
1361
  if (!isRestHero && leafEntry && leafEntry.displayRows.length > 1) {
1286
1362
  const lines = leafEntry.displayRows.map(
1287
- (row) => metricPresentation.presentGroup([...row], "timer-subtitle").filter((t) => t.visible).map((t) => t.label).filter(Boolean).join(" ").trim()
1363
+ (row) => dedupePresentedLabels(
1364
+ metricPresentation.presentGroup([...row], "timer-subtitle").filter((t) => t.visible).map((t) => t.label)
1365
+ ).join(" ").trim()
1288
1366
  ).filter(Boolean);
1289
1367
  if (lines.length > 0) subLabels = lines;
1290
1368
  }
@@ -1551,14 +1629,7 @@ function formatStatementLabel(statement) {
1551
1629
  [...statement.metrics].filter((m) => m.type !== wodWikiCore.MetricType.Hint),
1552
1630
  "timer-subtitle"
1553
1631
  ).filter((t) => t.visible).map((t) => t.label.trim()).filter(Boolean);
1554
- const deduped = [];
1555
- for (const label of labels) {
1556
- const lower = label.toLowerCase();
1557
- const prev = deduped[deduped.length - 1]?.toLowerCase();
1558
- if (prev && (prev === lower || prev.endsWith(` ${lower}`))) continue;
1559
- deduped.push(label);
1560
- }
1561
- const presented = deduped.join(" ").trim();
1632
+ const presented = dedupePresentedLabels(labels).join(" ").trim();
1562
1633
  return presented || statement.text?.trim() || "Step";
1563
1634
  }
1564
1635
  function projectScriptOutline(runtime) {