@qodalis/cli 2.0.0-beta.14 → 2.0.0-beta.16

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/public-api.mjs CHANGED
@@ -1,4 +1,4 @@
1
- import { CliLogLevel, DefaultThemes, DefaultThemeInfos, DefaultLibraryAuthor, CliIcon, CliForegroundColor, LIBRARY_VERSION as LIBRARY_VERSION$1, resolveConfigurationCategories, ICliTranslationService_TOKEN, ICliAuthorizationService_TOKEN, resolveHeaders, appendQueryParams, buildAuthenticatedWebSocketUrl, ServerVersionNegotiator, CliHttpError, formatJson, visibleLength, stripAnsi, getRightOfWord, CancellablePromise, isCliAccessDeniedError, getParameterValue, ICliCommandGuard_TOKEN, CLI_CONFIGURE_STORE_NAME, CliModuleRegistry, initializeBrowserEnvironment, ICliPermissionRegistry_TOKEN, satisfiesVersionRange, CliServerPermissions, ICliDragDropService_TOKEN, cliAccessMetadataGuards, ICliServerAuthService_TOKEN, ICliCompletionProvider_TOKEN, delay, colorFirstWord, clearTerminalLine, ICliServerAuthTokenProvider_TOKEN } from '@qodalis/cli-core';
1
+ import { CliLogLevel, DefaultThemes, DefaultThemeInfos, DefaultLibraryAuthor, CliIcon, CliForegroundColor, LIBRARY_VERSION as LIBRARY_VERSION$1, resolveConfigurationCategories, ICliTranslationService_TOKEN, ICliAuthorizationService_TOKEN, resolveHeaders, appendQueryParams, buildAuthenticatedWebSocketUrl, ServerVersionNegotiator, CliHttpError, formatJson, visibleLength, stripAnsi, getRightOfWord, CancellablePromise, isCliAccessDeniedError, getParameterValue, ICliCommandGuard_TOKEN, CLI_CONFIGURE_STORE_NAME, CliModuleRegistry, initializeBrowserEnvironment, ICliPermissionRegistry_TOKEN, satisfiesVersionRange, CliServerPermissions, ICliDragDropService_TOKEN, cliAccessMetadataGuards, ICliServerAuthService_TOKEN, ICliCompletionProvider_TOKEN, delay, colorFirstWord, clearTerminalLine, ICliServerAuthTokenProvider_TOKEN, truncateToWidth } from '@qodalis/cli-core';
2
2
  export { ICliUserSessionService_TOKEN, ICliUsersStoreService_TOKEN } from '@qodalis/cli-core';
3
3
  import { Subject, BehaviorSubject } from 'rxjs';
4
4
  import { map, distinctUntilChanged } from 'rxjs/operators';
@@ -412,7 +412,7 @@ var CliKeyValueStore_TOKEN = "cli-key-value-store";
412
412
  var SyntaxHighlighterRegistry_TOKEN = "syntax-highlighter-registry";
413
413
 
414
414
  // src/lib/version.ts
415
- var LIBRARY_VERSION = "2.0.0-beta.14";
415
+ var LIBRARY_VERSION = "2.0.0-beta.16";
416
416
  var API_VERSION = 2;
417
417
  var ANONYMOUS = "\0anonymous";
418
418
  function aliasOwner(context2) {
@@ -12343,8 +12343,6 @@ var CliClipboard = class {
12343
12343
  }
12344
12344
  }
12345
12345
  };
12346
-
12347
- // src/lib/input/modes/input-mode-base.ts
12348
12346
  var InputModeBase = class {
12349
12347
  constructor(host, resolve) {
12350
12348
  this.host = host;
@@ -12413,6 +12411,17 @@ var InputModeBase = class {
12413
12411
  }
12414
12412
  this.host.terminal.write(buf);
12415
12413
  }
12414
+ /**
12415
+ * Cut a line to the terminal width. Lines redrawn in place must stay on one row:
12416
+ * a wrapped line takes two rows and breaks the cursor-up arithmetic of the redraw.
12417
+ */
12418
+ fitLine(text) {
12419
+ return truncateToWidth(text, Math.max(1, this.host.getTerminalCols() - 1));
12420
+ }
12421
+ /** Start a new row and write `text` cut to the terminal width. */
12422
+ writeRow(text) {
12423
+ this.host.terminal.write("\r\n" + this.fitLine(text));
12424
+ }
12416
12425
  /**
12417
12426
  * Render a dimmed help bar below the current line.
12418
12427
  */
@@ -12420,7 +12429,7 @@ var InputModeBase = class {
12420
12429
  this.extraLines++;
12421
12430
  this.host.terminal.write(
12422
12431
  `\r
12423
- \x1B[2m${text}\x1B[0m\x1B[${this.extraLines}A`
12432
+ ${this.fitLine(` \x1B[2m${text}\x1B[0m`)}\x1B[${this.extraLines}A`
12424
12433
  );
12425
12434
  }
12426
12435
  /**
@@ -12430,7 +12439,7 @@ var InputModeBase = class {
12430
12439
  this.extraLines++;
12431
12440
  this.host.terminal.write(
12432
12441
  `\r
12433
- \x1B[31m\u2718 ${message}\x1B[0m\x1B[${this.extraLines}A`
12442
+ ${this.fitLine(` \x1B[31m\u2718 ${message}\x1B[0m`)}\x1B[${this.extraLines}A`
12434
12443
  );
12435
12444
  }
12436
12445
  /**
@@ -12932,15 +12941,15 @@ var SelectInputMode = class extends InputModeBase {
12932
12941
  if (this.selectOptions?.searchable) {
12933
12942
  if (this.filter.length > 0) {
12934
12943
  this.host.terminal.write(
12935
- `\x1B[36m?\x1B[0m ${this.promptText}: ${this.filter}`
12944
+ this.fitLine(`\x1B[36m?\x1B[0m ${this.promptText}: ${this.filter}`)
12936
12945
  );
12937
12946
  } else {
12938
12947
  this.host.terminal.write(
12939
- `\x1B[36m?\x1B[0m ${this.promptText}: \x1B[2mType to filter...\x1B[0m`
12948
+ this.fitLine(`\x1B[36m?\x1B[0m ${this.promptText}: \x1B[2mType to filter...\x1B[0m`)
12940
12949
  );
12941
12950
  }
12942
12951
  } else {
12943
- this.host.terminal.write(`\x1B[36m?\x1B[0m ${this.promptText}:`);
12952
+ this.host.terminal.write(this.fitLine(`\x1B[36m?\x1B[0m ${this.promptText}:`));
12944
12953
  }
12945
12954
  }
12946
12955
  /**
@@ -12955,17 +12964,15 @@ var SelectInputMode = class extends InputModeBase {
12955
12964
  this.scrollOffset + this.maxVisible
12956
12965
  );
12957
12966
  if (visibleStart > 0) {
12958
- this.host.terminal.write(`\r
12959
- \x1B[2m \u2191 ${visibleStart} more above\x1B[0m`);
12967
+ this.writeRow(`\x1B[2m \u2191 ${visibleStart} more above\x1B[0m`);
12960
12968
  this.renderedLines++;
12961
12969
  }
12962
12970
  let selectableIdx = 0;
12963
12971
  for (const item of items) {
12964
12972
  if (item.type === "group-header") {
12965
12973
  if (this.isGroupVisible(item.groupName, items, visibleStart, visibleEnd)) {
12966
- this.host.terminal.write(
12967
- `\r
12968
- \x1B[35m\u2500\u2500 ${item.groupName} \u2500\u2500\x1B[0m`
12974
+ this.writeRow(
12975
+ `\x1B[35m\u2500\u2500 ${item.groupName} \u2500\u2500\x1B[0m`
12969
12976
  );
12970
12977
  this.renderedLines++;
12971
12978
  }
@@ -12988,8 +12995,7 @@ var SelectInputMode = class extends InputModeBase {
12988
12995
  }
12989
12996
  const remaining = selectables.length - visibleEnd;
12990
12997
  if (remaining > 0) {
12991
- this.host.terminal.write(`\r
12992
- \x1B[2m \u2193 ${remaining} more below\x1B[0m`);
12998
+ this.writeRow(`\x1B[2m \u2193 ${remaining} more below\x1B[0m`);
12993
12999
  this.renderedLines++;
12994
13000
  }
12995
13001
  }
@@ -13031,19 +13037,16 @@ var SelectInputMode = class extends InputModeBase {
13031
13037
  const label = this.highlightMatch(opt.label);
13032
13038
  const desc = opt.description ? ` \x1B[2;3m\u2014 ${opt.description}\x1B[0m` : "";
13033
13039
  if (opt.disabled) {
13034
- this.host.terminal.write(
13035
- `\r
13036
- \x1B[2m${opt.label}${desc} (disabled)\x1B[0m`
13040
+ this.writeRow(
13041
+ ` \x1B[2m${opt.label}${desc} (disabled)\x1B[0m`
13037
13042
  );
13038
13043
  } else if (isSelected) {
13039
- this.host.terminal.write(
13040
- `\r
13041
- \x1B[48;5;24m\x1B[38;5;117m\u276F ${label}${desc}\x1B[0m`
13044
+ this.writeRow(
13045
+ ` \x1B[48;5;24m\x1B[38;5;117m\u276F ${label}${desc}\x1B[0m`
13042
13046
  );
13043
13047
  } else {
13044
- this.host.terminal.write(
13045
- `\r
13046
- ${label}${desc}`
13048
+ this.writeRow(
13049
+ ` ${label}${desc}`
13047
13050
  );
13048
13051
  }
13049
13052
  }
@@ -13077,8 +13080,7 @@ var SelectInputMode = class extends InputModeBase {
13077
13080
  } else {
13078
13081
  help = "\u2191/\u2193 navigate \xB7 enter to select \xB7 esc to cancel";
13079
13082
  }
13080
- this.host.terminal.write(`\r
13081
- \x1B[2m${help}\x1B[0m`);
13083
+ this.writeRow(` \x1B[2m${help}\x1B[0m`);
13082
13084
  this.renderedLines++;
13083
13085
  }
13084
13086
  };
@@ -13556,15 +13558,15 @@ var MultiSelectInputMode = class extends InputModeBase {
13556
13558
  if (this.selectOptions?.searchable) {
13557
13559
  if (this.filter.length > 0) {
13558
13560
  this.host.terminal.write(
13559
- `\x1B[36m?\x1B[0m ${this.promptText}: ${this.filter}`
13561
+ this.fitLine(`\x1B[36m?\x1B[0m ${this.promptText}: ${this.filter}`)
13560
13562
  );
13561
13563
  } else {
13562
13564
  this.host.terminal.write(
13563
- `\x1B[36m?\x1B[0m ${this.promptText}: \x1B[2mType to filter...\x1B[0m`
13565
+ this.fitLine(`\x1B[36m?\x1B[0m ${this.promptText}: \x1B[2mType to filter...\x1B[0m`)
13564
13566
  );
13565
13567
  }
13566
13568
  } else {
13567
- this.host.terminal.write(`\x1B[36m?\x1B[0m ${this.promptText}:`);
13569
+ this.host.terminal.write(this.fitLine(`\x1B[36m?\x1B[0m ${this.promptText}:`));
13568
13570
  }
13569
13571
  }
13570
13572
  /**
@@ -13579,17 +13581,15 @@ var MultiSelectInputMode = class extends InputModeBase {
13579
13581
  this.scrollOffset + this.maxVisible
13580
13582
  );
13581
13583
  if (visibleStart > 0) {
13582
- this.host.terminal.write(`\r
13583
- \x1B[2m \u2191 ${visibleStart} more above\x1B[0m`);
13584
+ this.writeRow(`\x1B[2m \u2191 ${visibleStart} more above\x1B[0m`);
13584
13585
  this.renderedLines++;
13585
13586
  }
13586
13587
  let selectableIdx = 0;
13587
13588
  for (const item of items) {
13588
13589
  if (item.type === "group-header") {
13589
13590
  if (this.isGroupVisible(item.groupName, items, visibleStart, visibleEnd)) {
13590
- this.host.terminal.write(
13591
- `\r
13592
- \x1B[35m\u2500\u2500 ${item.groupName} \u2500\u2500\x1B[0m`
13591
+ this.writeRow(
13592
+ `\x1B[35m\u2500\u2500 ${item.groupName} \u2500\u2500\x1B[0m`
13593
13593
  );
13594
13594
  this.renderedLines++;
13595
13595
  }
@@ -13612,8 +13612,7 @@ var MultiSelectInputMode = class extends InputModeBase {
13612
13612
  }
13613
13613
  const remaining = selectables.length - visibleEnd;
13614
13614
  if (remaining > 0) {
13615
- this.host.terminal.write(`\r
13616
- \x1B[2m \u2193 ${remaining} more below\x1B[0m`);
13615
+ this.writeRow(`\x1B[2m \u2193 ${remaining} more below\x1B[0m`);
13617
13616
  this.renderedLines++;
13618
13617
  }
13619
13618
  }
@@ -13658,19 +13657,16 @@ var MultiSelectInputMode = class extends InputModeBase {
13658
13657
  const checkbox = isChecked ? "\x1B[32m\u25C9\x1B[0m" : "\x1B[2m\u25CB\x1B[0m";
13659
13658
  if (opt.disabled) {
13660
13659
  const disabledCheckbox = isChecked ? "\x1B[2m\u25C9\x1B[0m" : "\x1B[2m\u25CB\x1B[0m";
13661
- this.host.terminal.write(
13662
- `\r
13663
- ${disabledCheckbox} \x1B[2m${opt.label}${desc} (disabled)\x1B[0m`
13660
+ this.writeRow(
13661
+ ` ${disabledCheckbox} \x1B[2m${opt.label}${desc} (disabled)\x1B[0m`
13664
13662
  );
13665
13663
  } else if (isSelected) {
13666
- this.host.terminal.write(
13667
- `\r
13668
- \x1B[48;5;24m\x1B[38;5;117m\u276F ${checkbox} ${label}${desc}\x1B[0m`
13664
+ this.writeRow(
13665
+ ` \x1B[48;5;24m\x1B[38;5;117m\u276F ${checkbox} ${label}${desc}\x1B[0m`
13669
13666
  );
13670
13667
  } else {
13671
- this.host.terminal.write(
13672
- `\r
13673
- ${checkbox} ${label}${desc}`
13668
+ this.writeRow(
13669
+ ` ${checkbox} ${label}${desc}`
13674
13670
  );
13675
13671
  }
13676
13672
  }
@@ -13705,8 +13701,7 @@ var MultiSelectInputMode = class extends InputModeBase {
13705
13701
  } else {
13706
13702
  help = `${checkedCount} selected \xB7 space to toggle \xB7 a to select all \xB7 enter to confirm`;
13707
13703
  }
13708
- this.host.terminal.write(`\r
13709
- \x1B[2m${help}\x1B[0m`);
13704
+ this.writeRow(` \x1B[2m${help}\x1B[0m`);
13710
13705
  this.renderedLines++;
13711
13706
  }
13712
13707
  };