@bitcobblers/wod-wiki-lang 0.60.2250 → 0.60.2258

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -809,6 +809,8 @@ interface CompletionValueOption {
809
809
  value: string;
810
810
  /** Display label; defaults to `value`. */
811
811
  label?: string;
812
+ /** Optional aliases (e.g. "swing", "kbs") matched alongside label and value. */
813
+ aliases?: readonly string[];
812
814
  /** Short annotation shown after the label; the provider supplies a default. */
813
815
  detail?: string;
814
816
  /** Longer description shown in the completion info panel. */
@@ -2605,7 +2607,9 @@ declare class ReportOutputBehavior implements IRuntimeBehavior {
2605
2607
  private collectStateFragments;
2606
2608
  private mergeFragments;
2607
2609
  private buildMilestoneFragments;
2610
+ private resolveFallbackTiming;
2608
2611
  private computeTimeResults;
2612
+ private buildWeightedSplitGroups;
2609
2613
  private computeSplitTimeResults;
2610
2614
  private writeResultMemory;
2611
2615
  private writeResultGroups;
package/dist/index.d.ts CHANGED
@@ -809,6 +809,8 @@ interface CompletionValueOption {
809
809
  value: string;
810
810
  /** Display label; defaults to `value`. */
811
811
  label?: string;
812
+ /** Optional aliases (e.g. "swing", "kbs") matched alongside label and value. */
813
+ aliases?: readonly string[];
812
814
  /** Short annotation shown after the label; the provider supplies a default. */
813
815
  detail?: string;
814
816
  /** Longer description shown in the completion info panel. */
@@ -2605,7 +2607,9 @@ declare class ReportOutputBehavior implements IRuntimeBehavior {
2605
2607
  private collectStateFragments;
2606
2608
  private mergeFragments;
2607
2609
  private buildMilestoneFragments;
2610
+ private resolveFallbackTiming;
2608
2611
  private computeTimeResults;
2612
+ private buildWeightedSplitGroups;
2609
2613
  private computeSplitTimeResults;
2610
2614
  private writeResultMemory;
2611
2615
  private writeResultGroups;
package/dist/index.mjs CHANGED
@@ -3089,18 +3089,41 @@ function structureKeywords() {
3089
3089
  apply: STRUCTURE_KEYWORD_DISPLAY[word] ?? word.toUpperCase()
3090
3090
  }));
3091
3091
  }
3092
+ var ACTION_CUE_COMPLETIONS = [
3093
+ { label: "[:rest]", detail: "Rest cue", type: "keyword", apply: "[:rest] ", boost: 20 },
3094
+ { label: "[:next]", detail: "Advance segment", type: "keyword", apply: "[:next] ", boost: 15 },
3095
+ { label: "[:done]", detail: "Complete block", type: "keyword", apply: "[:done] ", boost: 12 },
3096
+ { label: "[:mark]", detail: "Split / lap marker", type: "keyword", apply: "[:mark] ", boost: 10 }
3097
+ ];
3098
+ var completionAliases = /* @__PURE__ */ new WeakMap();
3092
3099
  function toCompletions(values, detail, quoteValues = false) {
3093
3100
  return values.map((value) => {
3094
3101
  const insertText = quoteValues ? !/^[A-Za-z][A-Za-z0-9]*$/.test(value.value) ? JSON.stringify(value.value) : value.value : value.label ?? value.value;
3095
- return {
3102
+ const item = {
3096
3103
  label: value.label ?? value.value,
3097
3104
  apply: insertText,
3098
3105
  detail: value.detail ?? (value.label && value.label !== value.value ? value.value : detail),
3099
3106
  type: "text",
3100
3107
  info: value.info
3101
3108
  };
3109
+ if (value.aliases?.length) {
3110
+ completionAliases.set(item, value.aliases.map((a) => a.toLowerCase()));
3111
+ }
3112
+ return item;
3102
3113
  });
3103
3114
  }
3115
+ function completionMatchesAliasOnly(option, typedLower) {
3116
+ const aliases = completionAliases.get(option);
3117
+ return aliases ? aliases.some((alias) => alias.includes(typedLower)) : false;
3118
+ }
3119
+ function completionMatchesWord(option, typedLower) {
3120
+ const inserted = (typeof option.apply === "string" ? option.apply : option.label).toLowerCase();
3121
+ const label = option.label.toLowerCase();
3122
+ if (inserted.startsWith(typedLower) || label.startsWith(typedLower)) return "prefix";
3123
+ if (inserted.includes(typedLower) || label.includes(typedLower)) return "word";
3124
+ if (completionMatchesAliasOnly(option, typedLower)) return "alias";
3125
+ return null;
3126
+ }
3104
3127
  function dialectWords(sport) {
3105
3128
  if (!sport) return [];
3106
3129
  const vocabulary = SPORT_VOCABULARY[SPORT_ALIASES[sport] ?? sport];
@@ -3167,6 +3190,14 @@ function whiteboardScriptCompletionSource(options = {}) {
3167
3190
  const before = line.text.slice(0, pos - line.from);
3168
3191
  const word = /([A-Za-z0-9-]*)$/.exec(before)[1];
3169
3192
  const beforeWord = before.slice(0, before.length - word.length);
3193
+ const actionMatch = /(\[:[a-zA-Z0-9-]*)$/.exec(before);
3194
+ if (actionMatch) {
3195
+ return {
3196
+ from: pos - actionMatch[1].length,
3197
+ options: ACTION_CUE_COMPLETIONS,
3198
+ validFor: /^\[:[a-zA-Z0-9-]*\]?$/
3199
+ };
3200
+ }
3170
3201
  if (beforeWord.endsWith("#") && options.tags) {
3171
3202
  return { from: pos - word.length, options: toCompletions(await options.tags(), "tag") };
3172
3203
  }
@@ -3191,9 +3222,27 @@ function whiteboardScriptCompletionSource(options = {}) {
3191
3222
  const effortOptions = [...keywords, ...efforts, ...equipmentPrefixes, ...sportWords];
3192
3223
  if (/^[ \t]*[A-Za-z][A-Za-z0-9]*$/.test(before)) {
3193
3224
  const supplied = suppliedPropertyKeys(context);
3225
+ const allStartOptions = [
3226
+ ...COMPLETION_PROPERTY_KEYS.filter((key) => !supplied.has(key)).map((key) => ({ label: key, detail: "property", type: "property", boost: 5 })),
3227
+ ...snippets,
3228
+ ...keywords,
3229
+ ...efforts,
3230
+ ...sportWords
3231
+ ];
3232
+ const typedStart = before.trimStart().toLowerCase();
3233
+ const hasAliasHit = typedStart.length >= 2 && effortOptions.some((opt) => completionMatchesWord(opt, typedStart) === "alias");
3234
+ if (hasAliasHit) {
3235
+ const matched = allStartOptions.filter((opt) => completionMatchesWord(opt, typedStart) !== null);
3236
+ return {
3237
+ from: pos - before.trimStart().length,
3238
+ options: matched,
3239
+ filter: false,
3240
+ validFor: /^[A-Za-z]*$/
3241
+ };
3242
+ }
3194
3243
  return {
3195
3244
  from: pos - before.trimStart().length,
3196
- options: [...COMPLETION_PROPERTY_KEYS.filter((key) => !supplied.has(key)).map((key) => ({ label: key, detail: "property", type: "property", boost: 5 })), ...snippets, ...keywords, ...efforts, ...sportWords],
3245
+ options: allStartOptions,
3197
3246
  validFor: /^[A-Za-z]*$/
3198
3247
  };
3199
3248
  }
@@ -3208,9 +3257,20 @@ function whiteboardScriptCompletionSource(options = {}) {
3208
3257
  (fragment) => fragment.firstChild?.name === "Action" && fragment.from < (quantity?.from ?? pos) && !context.state.doc.sliceString(fragment.from, fragment.to).includes(":")
3209
3258
  );
3210
3259
  if (quantity && !incompleteAction) {
3260
+ const wordText = completingWord ? context.state.doc.sliceString(last.from, pos).toLowerCase() : "";
3261
+ const hasAliasHit = wordText.length >= 2 && effortOptions.some((opt) => completionMatchesWord(opt, wordText) === "alias");
3262
+ const pool = [...quantity.getChild("AtSign") ? massUnitOptions : allUnitOptions, ...effortOptions];
3263
+ if (hasAliasHit && completingWord) {
3264
+ return {
3265
+ from: last.from,
3266
+ options: pool.filter((opt) => completionMatchesWord(opt, wordText) !== null),
3267
+ filter: false,
3268
+ validFor: /^[A-Za-z]*$/
3269
+ };
3270
+ }
3211
3271
  return {
3212
3272
  from: completingWord ? last.from : pos,
3213
- options: [...quantity.getChild("AtSign") ? massUnitOptions : allUnitOptions, ...effortOptions],
3273
+ options: pool,
3214
3274
  validFor: /^[A-Za-z]*$/
3215
3275
  };
3216
3276
  }
@@ -3229,11 +3289,14 @@ function whiteboardScriptCompletionSource(options = {}) {
3229
3289
  const last2 = effortRun[effortRun.length - 1];
3230
3290
  if (!first || !last2 || last2.to < pos) return null;
3231
3291
  const typed = context.state.doc.sliceString(first.from, pos).toLowerCase();
3232
- const compatible = effortOptions.filter((option) => {
3233
- const inserted = typeof option.apply === "string" ? option.apply : option.label;
3234
- return inserted.toLowerCase().startsWith(typed) || option.label.toLowerCase().startsWith(typed);
3235
- });
3236
- return { from: first.from, options: compatible, validFor: /^[A-Za-z ]*$/ };
3292
+ const compatible = effortOptions.filter((option) => completionMatchesWord(option, typed) !== null);
3293
+ const usesAlias = compatible.some((option) => completionMatchesWord(option, typed) === "alias");
3294
+ return {
3295
+ from: first.from,
3296
+ options: compatible,
3297
+ ...usesAlias ? { filter: false } : {},
3298
+ validFor: /^[A-Za-z ]*$/
3299
+ };
3237
3300
  }
3238
3301
  return null;
3239
3302
  };
@@ -6026,8 +6089,11 @@ var OutputEmitter = class {
6026
6089
  );
6027
6090
  }
6028
6091
  }
6029
- const fallbackStartMs = block.executionTiming?.startTime?.getTime() ?? fallbackEndMs;
6030
- const timeSpan = new TimeSpan(fallbackStartMs, fallbackEndMs);
6092
+ const recordedSpans = resultFragments.filter((m) => m.type === MetricType.Spans && Array.isArray(m.value)).flatMap((m) => m.value).filter((s) => typeof s?.started === "number" && Number.isFinite(s.started));
6093
+ const timeSpan = recordedSpans.length > 0 ? new TimeSpan(
6094
+ Math.min(...recordedSpans.map((s) => s.started)),
6095
+ Math.max(...recordedSpans.map((s) => typeof s.ended === "number" && Number.isFinite(s.ended) ? s.ended : fallbackEndMs))
6096
+ ) : new TimeSpan(block.executionTiming?.startTime?.getTime() ?? fallbackEndMs, fallbackEndMs);
6031
6097
  this.add(new OutputStatement({
6032
6098
  outputType: "segment",
6033
6099
  completionReason: block.completionReason,
@@ -10693,6 +10759,19 @@ var ReportOutputBehavior = class {
10693
10759
  }
10694
10760
  return metrics;
10695
10761
  }
10762
+ resolveFallbackTiming(ctx, nowMs) {
10763
+ if (ctx.block.blockType === "WaitingToStart") return null;
10764
+ const timing = ctx.block.executionTiming;
10765
+ const execStartMs = timing?.startTime?.getTime();
10766
+ if (execStartMs === void 0 || !Number.isFinite(execStartMs) || execStartMs > nowMs) {
10767
+ return null;
10768
+ }
10769
+ return {
10770
+ started: execStartMs,
10771
+ ended: nowMs,
10772
+ elapsedMs: Math.max(0, nowMs - execStartMs)
10773
+ };
10774
+ }
10696
10775
  computeTimeResults(ctx, timer, customRoundLabel) {
10697
10776
  const now = ctx.clock.currentDate;
10698
10777
  const nowMs = now.getTime();
@@ -10700,14 +10779,17 @@ var ReportOutputBehavior = class {
10700
10779
  const round = ctx.getMemoryByTag("round")[0]?.metrics[0];
10701
10780
  if (timer && timer.spans.length > 0) {
10702
10781
  const elapsed = calculateElapsed(timer, nowMs);
10703
- const firstStart = timer.spans[0].started;
10704
- const lastSpan = timer.spans[timer.spans.length - 1];
10782
+ const closedSpans = timer.spans.map(
10783
+ (s) => s.ended !== void 0 ? s : new TimeSpan(s.started, nowMs)
10784
+ );
10785
+ const firstStart = closedSpans[0].started;
10786
+ const lastSpan = closedSpans[closedSpans.length - 1];
10705
10787
  const lastEnd = lastSpan.ended ?? nowMs;
10706
10788
  const total = Math.max(0, lastEnd - firstStart);
10707
10789
  const metrics2 = MetricContainer.empty(blockKey).add(
10708
10790
  new ElapsedMetric(elapsed, blockKey, now),
10709
10791
  new TotalMetric(total, blockKey, now),
10710
- new SpansMetric([...timer.spans], blockKey, now),
10792
+ new SpansMetric(closedSpans, blockKey, now),
10711
10793
  new SystemTimeMetric(this._now.now(), blockKey)
10712
10794
  );
10713
10795
  if (round) {
@@ -10715,11 +10797,13 @@ var ReportOutputBehavior = class {
10715
10797
  }
10716
10798
  return metrics2;
10717
10799
  }
10718
- const degenerateSpan = new TimeSpan(nowMs, nowMs);
10800
+ const fallback = this.resolveFallbackTiming(ctx, nowMs);
10801
+ const span = fallback ? new TimeSpan(fallback.started, fallback.ended) : new TimeSpan(nowMs, nowMs);
10802
+ const fallbackElapsed = fallback?.elapsedMs ?? 0;
10719
10803
  const metrics = MetricContainer.empty(blockKey).add(
10720
- new ElapsedMetric(0, blockKey, now),
10721
- new TotalMetric(0, blockKey, now),
10722
- new SpansMetric([degenerateSpan], blockKey, now),
10804
+ new ElapsedMetric(fallbackElapsed, blockKey, now),
10805
+ new TotalMetric(fallbackElapsed, blockKey, now),
10806
+ new SpansMetric([span], blockKey, now),
10723
10807
  new SystemTimeMetric(this._now.now(), blockKey)
10724
10808
  );
10725
10809
  if (round) {
@@ -10727,29 +10811,7 @@ var ReportOutputBehavior = class {
10727
10811
  }
10728
10812
  return metrics;
10729
10813
  }
10730
- computeSplitTimeResults(ctx, timer, groups, customRoundLabel) {
10731
- const now = ctx.clock.currentDate;
10732
- const nowMs = now.getTime();
10733
- const blockKey = ctx.block.key.toString();
10734
- const round = ctx.getMemoryByTag("round")[0]?.metrics[0];
10735
- if (!timer || timer.spans.length === 0) {
10736
- return groups.map((group) => {
10737
- const groupFragments = group.clone().add(
10738
- new ElapsedMetric(0, blockKey, now),
10739
- new TotalMetric(0, blockKey, now),
10740
- new SpansMetric([new TimeSpan(nowMs, nowMs)], blockKey, now),
10741
- new SystemTimeMetric(this._now.now(), blockKey)
10742
- );
10743
- if (round) {
10744
- groupFragments.add(new CurrentRoundMetric(round.current, round.total, blockKey, now, customRoundLabel));
10745
- }
10746
- return groupFragments;
10747
- });
10748
- }
10749
- const totalElapsed = calculateElapsed(timer, nowMs);
10750
- const firstStart = timer.spans[0].started;
10751
- const lastEnd = timer.spans[timer.spans.length - 1].ended ?? nowMs;
10752
- const totalDuration = lastEnd - firstStart;
10814
+ buildWeightedSplitGroups(firstStart, totalElapsed, totalDuration, now, blockKey, round, groups, customRoundLabel) {
10753
10815
  const weights = groups.map((group) => {
10754
10816
  const reps = group.filter((f) => f.type === MetricType.Rep && typeof f.value === "number").reduce((sum, f) => sum + f.value, 0);
10755
10817
  return reps > 0 ? reps : 1;
@@ -10776,6 +10838,53 @@ var ReportOutputBehavior = class {
10776
10838
  return groupFragments;
10777
10839
  });
10778
10840
  }
10841
+ computeSplitTimeResults(ctx, timer, groups, customRoundLabel) {
10842
+ const now = ctx.clock.currentDate;
10843
+ const nowMs = now.getTime();
10844
+ const blockKey = ctx.block.key.toString();
10845
+ const round = ctx.getMemoryByTag("round")[0]?.metrics[0];
10846
+ if (!timer || timer.spans.length === 0) {
10847
+ const fallback = this.resolveFallbackTiming(ctx, nowMs);
10848
+ if (fallback) {
10849
+ return this.buildWeightedSplitGroups(
10850
+ fallback.started,
10851
+ fallback.elapsedMs,
10852
+ fallback.elapsedMs,
10853
+ now,
10854
+ blockKey,
10855
+ round,
10856
+ groups,
10857
+ customRoundLabel
10858
+ );
10859
+ }
10860
+ return groups.map((group) => {
10861
+ const groupFragments = group.clone().add(
10862
+ new ElapsedMetric(0, blockKey, now),
10863
+ new TotalMetric(0, blockKey, now),
10864
+ new SpansMetric([new TimeSpan(nowMs, nowMs)], blockKey, now),
10865
+ new SystemTimeMetric(this._now.now(), blockKey)
10866
+ );
10867
+ if (round) {
10868
+ groupFragments.add(new CurrentRoundMetric(round.current, round.total, blockKey, now, customRoundLabel));
10869
+ }
10870
+ return groupFragments;
10871
+ });
10872
+ }
10873
+ const totalElapsed = calculateElapsed(timer, nowMs);
10874
+ const firstStart = timer.spans[0].started;
10875
+ const lastEnd = timer.spans[timer.spans.length - 1].ended ?? nowMs;
10876
+ const totalDuration = lastEnd - firstStart;
10877
+ return this.buildWeightedSplitGroups(
10878
+ firstStart,
10879
+ totalElapsed,
10880
+ totalDuration,
10881
+ now,
10882
+ blockKey,
10883
+ round,
10884
+ groups,
10885
+ customRoundLabel
10886
+ );
10887
+ }
10779
10888
  writeResultMemory(ctx, resultFragments) {
10780
10889
  const existing = ctx.block.getMemoryByTag("metric:result");
10781
10890
  if (existing.length > 0) {