@bitcobblers/wod-wiki-lang 0.60.2257 → 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.cjs CHANGED
@@ -3686,18 +3686,41 @@ function structureKeywords() {
3686
3686
  apply: STRUCTURE_KEYWORD_DISPLAY[word] ?? word.toUpperCase()
3687
3687
  }));
3688
3688
  }
3689
+ var ACTION_CUE_COMPLETIONS = [
3690
+ { label: "[:rest]", detail: "Rest cue", type: "keyword", apply: "[:rest] ", boost: 20 },
3691
+ { label: "[:next]", detail: "Advance segment", type: "keyword", apply: "[:next] ", boost: 15 },
3692
+ { label: "[:done]", detail: "Complete block", type: "keyword", apply: "[:done] ", boost: 12 },
3693
+ { label: "[:mark]", detail: "Split / lap marker", type: "keyword", apply: "[:mark] ", boost: 10 }
3694
+ ];
3695
+ var completionAliases = /* @__PURE__ */ new WeakMap();
3689
3696
  function toCompletions(values, detail, quoteValues = false) {
3690
3697
  return values.map((value) => {
3691
3698
  const insertText = quoteValues ? !/^[A-Za-z][A-Za-z0-9]*$/.test(value.value) ? JSON.stringify(value.value) : value.value : value.label ?? value.value;
3692
- return {
3699
+ const item = {
3693
3700
  label: value.label ?? value.value,
3694
3701
  apply: insertText,
3695
3702
  detail: value.detail ?? (value.label && value.label !== value.value ? value.value : detail),
3696
3703
  type: "text",
3697
3704
  info: value.info
3698
3705
  };
3706
+ if (value.aliases?.length) {
3707
+ completionAliases.set(item, value.aliases.map((a) => a.toLowerCase()));
3708
+ }
3709
+ return item;
3699
3710
  });
3700
3711
  }
3712
+ function completionMatchesAliasOnly(option, typedLower) {
3713
+ const aliases = completionAliases.get(option);
3714
+ return aliases ? aliases.some((alias) => alias.includes(typedLower)) : false;
3715
+ }
3716
+ function completionMatchesWord(option, typedLower) {
3717
+ const inserted = (typeof option.apply === "string" ? option.apply : option.label).toLowerCase();
3718
+ const label = option.label.toLowerCase();
3719
+ if (inserted.startsWith(typedLower) || label.startsWith(typedLower)) return "prefix";
3720
+ if (inserted.includes(typedLower) || label.includes(typedLower)) return "word";
3721
+ if (completionMatchesAliasOnly(option, typedLower)) return "alias";
3722
+ return null;
3723
+ }
3701
3724
  function dialectWords(sport) {
3702
3725
  if (!sport) return [];
3703
3726
  const vocabulary = SPORT_VOCABULARY[SPORT_ALIASES[sport] ?? sport];
@@ -3764,6 +3787,14 @@ function whiteboardScriptCompletionSource(options = {}) {
3764
3787
  const before = line.text.slice(0, pos - line.from);
3765
3788
  const word = /([A-Za-z0-9-]*)$/.exec(before)[1];
3766
3789
  const beforeWord = before.slice(0, before.length - word.length);
3790
+ const actionMatch = /(\[:[a-zA-Z0-9-]*)$/.exec(before);
3791
+ if (actionMatch) {
3792
+ return {
3793
+ from: pos - actionMatch[1].length,
3794
+ options: ACTION_CUE_COMPLETIONS,
3795
+ validFor: /^\[:[a-zA-Z0-9-]*\]?$/
3796
+ };
3797
+ }
3767
3798
  if (beforeWord.endsWith("#") && options.tags) {
3768
3799
  return { from: pos - word.length, options: toCompletions(await options.tags(), "tag") };
3769
3800
  }
@@ -3788,9 +3819,27 @@ function whiteboardScriptCompletionSource(options = {}) {
3788
3819
  const effortOptions = [...keywords, ...efforts, ...equipmentPrefixes, ...sportWords];
3789
3820
  if (/^[ \t]*[A-Za-z][A-Za-z0-9]*$/.test(before)) {
3790
3821
  const supplied = suppliedPropertyKeys(context);
3822
+ const allStartOptions = [
3823
+ ...COMPLETION_PROPERTY_KEYS.filter((key) => !supplied.has(key)).map((key) => ({ label: key, detail: "property", type: "property", boost: 5 })),
3824
+ ...snippets,
3825
+ ...keywords,
3826
+ ...efforts,
3827
+ ...sportWords
3828
+ ];
3829
+ const typedStart = before.trimStart().toLowerCase();
3830
+ const hasAliasHit = typedStart.length >= 2 && effortOptions.some((opt) => completionMatchesWord(opt, typedStart) === "alias");
3831
+ if (hasAliasHit) {
3832
+ const matched = allStartOptions.filter((opt) => completionMatchesWord(opt, typedStart) !== null);
3833
+ return {
3834
+ from: pos - before.trimStart().length,
3835
+ options: matched,
3836
+ filter: false,
3837
+ validFor: /^[A-Za-z]*$/
3838
+ };
3839
+ }
3791
3840
  return {
3792
3841
  from: pos - before.trimStart().length,
3793
- options: [...COMPLETION_PROPERTY_KEYS.filter((key) => !supplied.has(key)).map((key) => ({ label: key, detail: "property", type: "property", boost: 5 })), ...snippets, ...keywords, ...efforts, ...sportWords],
3842
+ options: allStartOptions,
3794
3843
  validFor: /^[A-Za-z]*$/
3795
3844
  };
3796
3845
  }
@@ -3805,9 +3854,20 @@ function whiteboardScriptCompletionSource(options = {}) {
3805
3854
  (fragment) => fragment.firstChild?.name === "Action" && fragment.from < (quantity?.from ?? pos) && !context.state.doc.sliceString(fragment.from, fragment.to).includes(":")
3806
3855
  );
3807
3856
  if (quantity && !incompleteAction) {
3857
+ const wordText = completingWord ? context.state.doc.sliceString(last.from, pos).toLowerCase() : "";
3858
+ const hasAliasHit = wordText.length >= 2 && effortOptions.some((opt) => completionMatchesWord(opt, wordText) === "alias");
3859
+ const pool = [...quantity.getChild("AtSign") ? massUnitOptions : allUnitOptions, ...effortOptions];
3860
+ if (hasAliasHit && completingWord) {
3861
+ return {
3862
+ from: last.from,
3863
+ options: pool.filter((opt) => completionMatchesWord(opt, wordText) !== null),
3864
+ filter: false,
3865
+ validFor: /^[A-Za-z]*$/
3866
+ };
3867
+ }
3808
3868
  return {
3809
3869
  from: completingWord ? last.from : pos,
3810
- options: [...quantity.getChild("AtSign") ? massUnitOptions : allUnitOptions, ...effortOptions],
3870
+ options: pool,
3811
3871
  validFor: /^[A-Za-z]*$/
3812
3872
  };
3813
3873
  }
@@ -3826,11 +3886,14 @@ function whiteboardScriptCompletionSource(options = {}) {
3826
3886
  const last2 = effortRun[effortRun.length - 1];
3827
3887
  if (!first || !last2 || last2.to < pos) return null;
3828
3888
  const typed = context.state.doc.sliceString(first.from, pos).toLowerCase();
3829
- const compatible = effortOptions.filter((option) => {
3830
- const inserted = typeof option.apply === "string" ? option.apply : option.label;
3831
- return inserted.toLowerCase().startsWith(typed) || option.label.toLowerCase().startsWith(typed);
3832
- });
3833
- return { from: first.from, options: compatible, validFor: /^[A-Za-z ]*$/ };
3889
+ const compatible = effortOptions.filter((option) => completionMatchesWord(option, typed) !== null);
3890
+ const usesAlias = compatible.some((option) => completionMatchesWord(option, typed) === "alias");
3891
+ return {
3892
+ from: first.from,
3893
+ options: compatible,
3894
+ ...usesAlias ? { filter: false } : {},
3895
+ validFor: /^[A-Za-z ]*$/
3896
+ };
3834
3897
  }
3835
3898
  return null;
3836
3899
  };