@threadbase-sh/streamer 1.70.3 → 1.70.5

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
@@ -2724,6 +2724,15 @@ var OPTION_RE2 = /^\s*(?:❯)?\s*(\d+)\.\s+(.+?)\s*$/;
2724
2724
  var QUESTION_RE = /\?\s*$/;
2725
2725
  var BOX_ONLY_RE2 = /^[\s│─┌┐└┘├┤┬┴┼╭╮╰╯╱╲=_-]+$/;
2726
2726
  var PERMISSION_LABEL_RE = /^(Yes|No)\b/i;
2727
+ var KNOWN_STATE_MARKER_RE = /^(?:\[(?:[ xX*]|✓|✔)\]|[☐☑☒])\s*/;
2728
+ var UNKNOWN_STATE_MARKER_RE = /^(?:\[[^\]]{0,3}\]|\([^)]{0,3}\))\s*/;
2729
+ function stripStateMarker(label) {
2730
+ if (KNOWN_STATE_MARKER_RE.test(label)) {
2731
+ return { label: label.replace(KNOWN_STATE_MARKER_RE, ""), marked: true };
2732
+ }
2733
+ if (UNKNOWN_STATE_MARKER_RE.test(label)) return { label, marked: true };
2734
+ return { label, marked: false };
2735
+ }
2727
2736
  function stripBoxGutter(line) {
2728
2737
  return line.replace(/^\s*[│|]\s?/, "").replace(/\s*[│|]\s*$/, "");
2729
2738
  }
@@ -2738,6 +2747,7 @@ function detectQuestionFromScreen(lines) {
2738
2747
  if (footerIdx === -1) return null;
2739
2748
  const options = [];
2740
2749
  let firstOptionIdx = -1;
2750
+ let sawStateMarker = false;
2741
2751
  for (let i = footerIdx - 1; i >= 0; i--) {
2742
2752
  const line = lines[i];
2743
2753
  const inner = stripBoxGutter(line);
@@ -2751,8 +2761,10 @@ function detectQuestionFromScreen(lines) {
2751
2761
  if (options.length > 0 && QUESTION_RE.test(trimmed) && !OPTION_RE2.test(inner)) break;
2752
2762
  const m = OPTION_RE2.exec(inner);
2753
2763
  if (m) {
2754
- const label = m[2].trim();
2755
- if (PERMISSION_LABEL_RE.test(label)) return null;
2764
+ const rendered = m[2].trim();
2765
+ if (PERMISSION_LABEL_RE.test(rendered)) return null;
2766
+ const { label, marked } = stripStateMarker(rendered);
2767
+ if (marked) sawStateMarker = true;
2756
2768
  options.unshift({ label, description: "" });
2757
2769
  firstOptionIdx = i;
2758
2770
  }
@@ -2771,7 +2783,7 @@ function detectQuestionFromScreen(lines) {
2771
2783
  }
2772
2784
  if (!question) return null;
2773
2785
  return {
2774
- questions: [{ question, header: "", multiSelect: false, options }]
2786
+ questions: [{ question, header: "", multiSelect: sawStateMarker, options }]
2775
2787
  };
2776
2788
  }
2777
2789
  function isQuestionMenuOnScreen(lines) {