paratix 0.12.5 → 0.12.8

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
@@ -61,7 +61,7 @@ import {
61
61
  user,
62
62
  validateHostLabel,
63
63
  validateSshConfig
64
- } from "./chunk-G5GVLFAI.js";
64
+ } from "./chunk-M3ZQJNKM.js";
65
65
 
66
66
  // src/conditionalModules.ts
67
67
  function createConditionalApplyState(environment) {
@@ -607,6 +607,9 @@ var MODULE_NAME_WIDTH = 56;
607
607
  var MIN_MODULE_NAME_WIDTH = 12;
608
608
  var OUTPUT_INDENT_UNIT = " ";
609
609
  var SPINNER_FRAME_INTERVAL_MS = 80;
610
+ var ASCII_ESC = 27;
611
+ var ANSI_HIDE_CURSOR = `${String.fromCharCode(ASCII_ESC)}[?25l`;
612
+ var ANSI_SHOW_CURSOR = `${String.fromCharCode(ASCII_ESC)}[?25h`;
610
613
  var SPINNER_FRAMES = ["\u280B", "\u2819", "\u2839", "\u2838", "\u283C", "\u2834", "\u2826", "\u2827", "\u2807", "\u280F"];
611
614
  var STATUS_ICONS = {
612
615
  changed: pc.yellow("\u21BA"),
@@ -615,10 +618,22 @@ var STATUS_ICONS = {
615
618
  skipped: pc.dim("\u2298"),
616
619
  waiting: pc.cyan("\u23F8")
617
620
  };
618
- var activeSpinner = null;
619
- var activeRecipeGuideDepths = [];
620
- var pendingRecipeClosureGuideDepths = [];
621
- var recipeOutputDepth = -1;
621
+ var LIVE_OUTPUT_STATE_KEY = /* @__PURE__ */ Symbol.for("paratix.output.liveState");
622
+ function getSharedLiveOutputState() {
623
+ const registry = globalThis;
624
+ const existing = registry[LIVE_OUTPUT_STATE_KEY];
625
+ if (existing != null) return existing;
626
+ const created = {
627
+ activeRecipeGuideDepths: [],
628
+ activeSpinner: null,
629
+ cursorHidden: false,
630
+ pendingRecipeClosureGuideDepths: [],
631
+ recipeOutputDepth: -1
632
+ };
633
+ registry[LIVE_OUTPUT_STATE_KEY] = created;
634
+ return created;
635
+ }
636
+ var liveOutputState = getSharedLiveOutputState();
622
637
  function supportsAnimatedModuleOutput() {
623
638
  return process.stdout.isTTY && typeof process.stdout.clearLine === "function" && typeof process.stdout.cursorTo === "function";
624
639
  }
@@ -645,7 +660,7 @@ function getModuleStatusText(status) {
645
660
  }
646
661
  }
647
662
  function getCurrentOutputDepth() {
648
- return Math.max(recipeOutputDepth, 0);
663
+ return Math.max(liveOutputState.recipeOutputDepth, 0);
649
664
  }
650
665
  function getGuideDot(depth) {
651
666
  return depth % 2 === 0 ? pc.gray("\xB7") : pc.cyan("\xB7");
@@ -653,7 +668,7 @@ function getGuideDot(depth) {
653
668
  function buildGuideIndent(baseIndent, options) {
654
669
  const indentCharacters = Array.from(baseIndent);
655
670
  const guideDepths = [
656
- ...options?.activeGuideDepths ?? activeRecipeGuideDepths,
671
+ ...options?.activeGuideDepths ?? liveOutputState.activeRecipeGuideDepths,
657
672
  ...options?.extraGuideDepths ?? []
658
673
  ];
659
674
  for (const guideDepth of guideDepths) {
@@ -664,16 +679,16 @@ function buildGuideIndent(baseIndent, options) {
664
679
  return indentCharacters.join("");
665
680
  }
666
681
  function clearPendingRecipeClosureGuides() {
667
- pendingRecipeClosureGuideDepths = [];
682
+ liveOutputState.pendingRecipeClosureGuideDepths = [];
668
683
  }
669
684
  function getModuleIndent() {
670
- if (recipeOutputDepth < 0) {
685
+ if (liveOutputState.recipeOutputDepth < 0) {
671
686
  return OUTPUT_INDENT_UNIT;
672
687
  }
673
688
  return OUTPUT_INDENT_UNIT.repeat(getCurrentOutputDepth() + 2);
674
689
  }
675
690
  function getRecipeHeaderIndent() {
676
- if (recipeOutputDepth < 0) return "";
691
+ if (liveOutputState.recipeOutputDepth < 0) return "";
677
692
  return OUTPUT_INDENT_UNIT.repeat(getCurrentOutputDepth() + 1);
678
693
  }
679
694
  function getErrorIndent() {
@@ -683,13 +698,13 @@ function getContinuationIndent() {
683
698
  return `${getModuleIndent()} `;
684
699
  }
685
700
  async function withRecipeOutputScope(scopedOperation) {
686
- recipeOutputDepth += 1;
701
+ liveOutputState.recipeOutputDepth += 1;
687
702
  try {
688
703
  return await scopedOperation();
689
704
  } finally {
690
- activeRecipeGuideDepths = activeRecipeGuideDepths.filter((depth) => depth !== recipeOutputDepth);
691
- pendingRecipeClosureGuideDepths = [recipeOutputDepth];
692
- recipeOutputDepth -= 1;
705
+ liveOutputState.activeRecipeGuideDepths = liveOutputState.activeRecipeGuideDepths.filter((depth) => depth !== liveOutputState.recipeOutputDepth);
706
+ liveOutputState.pendingRecipeClosureGuideDepths = [liveOutputState.recipeOutputDepth];
707
+ liveOutputState.recipeOutputDepth -= 1;
693
708
  }
694
709
  }
695
710
  function renderModuleLine(parameters) {
@@ -702,15 +717,28 @@ function renderModuleLine(parameters) {
702
717
  const alignedNameWidth = Math.max(MODULE_NAME_WIDTH - baseIndent.length, MIN_MODULE_NAME_WIDTH);
703
718
  return `${indent}${icon} ${name.padEnd(alignedNameWidth)} ${statusText}${detailSuffix}`;
704
719
  }
720
+ function hideCursor() {
721
+ if (liveOutputState.cursorHidden) return;
722
+ if (!supportsAnimatedModuleOutput()) return;
723
+ process.stdout.write(ANSI_HIDE_CURSOR);
724
+ liveOutputState.cursorHidden = true;
725
+ }
726
+ function showCursor() {
727
+ if (!liveOutputState.cursorHidden) return;
728
+ process.stdout.write(ANSI_SHOW_CURSOR);
729
+ liveOutputState.cursorHidden = false;
730
+ }
705
731
  function writeAnimatedModuleLine(line) {
732
+ hideCursor();
706
733
  process.stdout.clearLine(0);
707
734
  process.stdout.cursorTo(0);
708
735
  process.stdout.write(fitAnimatedModuleLine(line, process.stdout.columns));
709
736
  }
710
737
  function stopAnimatedModuleLine(clearCurrentLine = false) {
711
- if (activeSpinner == null) return;
712
- clearInterval(activeSpinner.interval);
713
- activeSpinner = null;
738
+ showCursor();
739
+ if (liveOutputState.activeSpinner == null) return;
740
+ clearInterval(liveOutputState.activeSpinner.interval);
741
+ liveOutputState.activeSpinner = null;
714
742
  if (clearCurrentLine && supportsAnimatedModuleOutput()) {
715
743
  process.stdout.clearLine(0);
716
744
  process.stdout.cursorTo(0);
@@ -745,7 +773,7 @@ function startModuleSpinner(name, detail) {
745
773
  }, SPINNER_FRAME_INTERVAL_MS)
746
774
  };
747
775
  if (typeof spinner.interval.unref === "function") spinner.interval.unref();
748
- activeSpinner = spinner;
776
+ liveOutputState.activeSpinner = spinner;
749
777
  writeAnimatedModuleLine(
750
778
  renderModuleLine({
751
779
  detail: displayModule.detail,
@@ -760,8 +788,8 @@ function printRecipeHeader(name) {
760
788
  clearPendingRecipeClosureGuides();
761
789
  const header = pc.bold(pc.blue(`[${name}]`));
762
790
  console.log(`${buildGuideIndent(getRecipeHeaderIndent())}${header}`);
763
- if (recipeOutputDepth >= 0) {
764
- activeRecipeGuideDepths = [...activeRecipeGuideDepths, recipeOutputDepth];
791
+ if (liveOutputState.recipeOutputDepth >= 0) {
792
+ liveOutputState.activeRecipeGuideDepths = [...liveOutputState.activeRecipeGuideDepths, liveOutputState.recipeOutputDepth];
765
793
  }
766
794
  }
767
795
  function colorizeDiffLine(line) {
@@ -815,7 +843,7 @@ function printRenderedModuleResult(parameters) {
815
843
  status: parameters.status
816
844
  });
817
845
  const diffLines = parameters.diff == null ? [] : renderDiffLines(parameters.diff);
818
- const usesSpinner = supportsAnimatedModuleOutput() && activeSpinner != null;
846
+ const usesSpinner = supportsAnimatedModuleOutput() && liveOutputState.activeSpinner != null;
819
847
  if (usesSpinner) {
820
848
  stopAnimatedModuleLine();
821
849
  writeAnimatedModuleLine(line);
@@ -838,7 +866,7 @@ function printRecipeModuleResult(name, status, detail, diff) {
838
866
  printRenderedModuleResult({
839
867
  detail,
840
868
  diff,
841
- extraGuideDepths: pendingRecipeClosureGuideDepths,
869
+ extraGuideDepths: liveOutputState.pendingRecipeClosureGuideDepths,
842
870
  name,
843
871
  status
844
872
  });