@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.js CHANGED
@@ -2665,6 +2665,15 @@ var OPTION_RE2 = /^\s*(?:❯)?\s*(\d+)\.\s+(.+?)\s*$/;
2665
2665
  var QUESTION_RE = /\?\s*$/;
2666
2666
  var BOX_ONLY_RE2 = /^[\s│─┌┐└┘├┤┬┴┼╭╮╰╯╱╲=_-]+$/;
2667
2667
  var PERMISSION_LABEL_RE = /^(Yes|No)\b/i;
2668
+ var KNOWN_STATE_MARKER_RE = /^(?:\[(?:[ xX*]|✓|✔)\]|[☐☑☒])\s*/;
2669
+ var UNKNOWN_STATE_MARKER_RE = /^(?:\[[^\]]{0,3}\]|\([^)]{0,3}\))\s*/;
2670
+ function stripStateMarker(label) {
2671
+ if (KNOWN_STATE_MARKER_RE.test(label)) {
2672
+ return { label: label.replace(KNOWN_STATE_MARKER_RE, ""), marked: true };
2673
+ }
2674
+ if (UNKNOWN_STATE_MARKER_RE.test(label)) return { label, marked: true };
2675
+ return { label, marked: false };
2676
+ }
2668
2677
  function stripBoxGutter(line) {
2669
2678
  return line.replace(/^\s*[│|]\s?/, "").replace(/\s*[│|]\s*$/, "");
2670
2679
  }
@@ -2679,6 +2688,7 @@ function detectQuestionFromScreen(lines) {
2679
2688
  if (footerIdx === -1) return null;
2680
2689
  const options = [];
2681
2690
  let firstOptionIdx = -1;
2691
+ let sawStateMarker = false;
2682
2692
  for (let i = footerIdx - 1; i >= 0; i--) {
2683
2693
  const line = lines[i];
2684
2694
  const inner = stripBoxGutter(line);
@@ -2692,8 +2702,10 @@ function detectQuestionFromScreen(lines) {
2692
2702
  if (options.length > 0 && QUESTION_RE.test(trimmed) && !OPTION_RE2.test(inner)) break;
2693
2703
  const m = OPTION_RE2.exec(inner);
2694
2704
  if (m) {
2695
- const label = m[2].trim();
2696
- if (PERMISSION_LABEL_RE.test(label)) return null;
2705
+ const rendered = m[2].trim();
2706
+ if (PERMISSION_LABEL_RE.test(rendered)) return null;
2707
+ const { label, marked } = stripStateMarker(rendered);
2708
+ if (marked) sawStateMarker = true;
2697
2709
  options.unshift({ label, description: "" });
2698
2710
  firstOptionIdx = i;
2699
2711
  }
@@ -2712,7 +2724,7 @@ function detectQuestionFromScreen(lines) {
2712
2724
  }
2713
2725
  if (!question) return null;
2714
2726
  return {
2715
- questions: [{ question, header: "", multiSelect: false, options }]
2727
+ questions: [{ question, header: "", multiSelect: sawStateMarker, options }]
2716
2728
  };
2717
2729
  }
2718
2730
  function isQuestionMenuOnScreen(lines) {