@qodalis/cli 2.4.0 → 2.4.2

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
@@ -518,7 +518,7 @@ var CliKeyValueStore_TOKEN = createCliToken("cli-key-value-store");
518
518
  var SyntaxHighlighterRegistry_TOKEN = createCliToken("syntax-highlighter-registry");
519
519
 
520
520
  // src/lib/version.ts
521
- var LIBRARY_VERSION = "2.4.0";
521
+ var LIBRARY_VERSION = "2.4.2";
522
522
  var API_VERSION = 2;
523
523
  var ANONYMOUS = "\0anonymous";
524
524
  function aliasOwner(context2) {
@@ -14842,6 +14842,7 @@ var CliTerminalSpinner = class {
14842
14842
  }, 80);
14843
14843
  }
14844
14844
  hide() {
14845
+ if (!this.isRunning) return;
14845
14846
  this.isRunning = false;
14846
14847
  if (this.spinnerInterval) {
14847
14848
  clearInterval(this.spinnerInterval);
@@ -17998,6 +17999,19 @@ var CliExecutionContext = class {
17998
17999
  isProgressRunning() {
17999
18000
  return this.progressBar.isRunning || this.spinner.isRunning || this.textAnimator.isRunning;
18000
18001
  }
18002
+ /**
18003
+ * What pressing Ctrl+C does: the current input mode handles the key, so a
18004
+ * running command is aborted, a prompt cancelled or a context left exactly
18005
+ * as with the keyboard.
18006
+ */
18007
+ interrupt() {
18008
+ const event = new KeyboardEvent("keydown", {
18009
+ key: "c",
18010
+ code: "KeyC",
18011
+ ctrlKey: true
18012
+ });
18013
+ this.currentMode?.handleKeyEvent(event);
18014
+ }
18001
18015
  abort() {
18002
18016
  if (this.progressBar.isRunning) {
18003
18017
  this.progressBar.complete();
@@ -20204,8 +20218,8 @@ var CliBootLog = class {
20204
20218
  if (this.problems.length > 0) {
20205
20219
  this.terminal.write("\r\n");
20206
20220
  }
20207
- if (this.captured.length > 0) {
20208
- const output2 = this.captured.join("").replace(/(?:\s|\x1b\[[0-9;?]*[A-Za-z])+$/, "");
20221
+ const output2 = this.captured.join("").replace(/(?:\s|\x1b\[[0-9;?]*[A-Za-z])+$/, "");
20222
+ if (output2) {
20209
20223
  this.terminal.write(output2 + RESET4 + "\r\n\r\n");
20210
20224
  }
20211
20225
  }
@@ -23941,6 +23955,7 @@ function computeGlobalStatus(engine, now = Date.now()) {
23941
23955
  total: services.length
23942
23956
  };
23943
23957
  serviceDetails = services.map((s) => ({
23958
+ pid: s.pid,
23944
23959
  name: s.name,
23945
23960
  status: s.status,
23946
23961
  description: s.description
@@ -23987,6 +24002,27 @@ function computeGlobalStatus(engine, now = Date.now()) {
23987
24002
  const uptime = engine.startedAt ? now - engine.startedAt : 0;
23988
24003
  return { serviceCount, serviceDetails, serverState, serverDetails, uptime };
23989
24004
  }
24005
+ function killProcess(engine, pid) {
24006
+ const context2 = engine?.getContext();
24007
+ let registry;
24008
+ try {
24009
+ registry = context2?.services?.get?.(CliProcessRegistry_TOKEN);
24010
+ } catch {
24011
+ }
24012
+ return registry?.kill(pid) ?? false;
24013
+ }
24014
+ function interruptCommand(engines) {
24015
+ let interrupted = false;
24016
+ for (const engine of engines) {
24017
+ const context2 = engine.getContext();
24018
+ if (!context2?.interrupt) continue;
24019
+ if (context2.isExecuting || context2.contextProcessor) {
24020
+ context2.interrupt();
24021
+ interrupted = true;
24022
+ }
24023
+ }
24024
+ return interrupted;
24025
+ }
23990
24026
  var CliPanelStatusTracker = class {
23991
24027
  constructor(listener) {
23992
24028
  this.listener = listener;
@@ -24051,6 +24087,16 @@ var CliPanelStatusTracker = class {
24051
24087
  this.activeTabId = tabId;
24052
24088
  this.refreshGlobal();
24053
24089
  }
24090
+ /** The engine the global status (services, servers) is computed from: the first pane of the active tab. */
24091
+ get globalEngine() {
24092
+ const entry = this.activeTabId != null ? this.tabs.get(this.activeTabId) : void 0;
24093
+ return entry?.engines.values().next().value;
24094
+ }
24095
+ /** The engines of the active tab, one per pane. */
24096
+ get activeTabEngines() {
24097
+ const entry = this.activeTabId != null ? this.tabs.get(this.activeTabId) : void 0;
24098
+ return entry ? [...entry.engines.values()] : [];
24099
+ }
24054
24100
  /** Recompute everything now. */
24055
24101
  refresh() {
24056
24102
  for (const tabId of this.tabs.keys()) this.refreshTab(tabId);
@@ -24087,9 +24133,7 @@ var CliPanelStatusTracker = class {
24087
24133
  this.listener.onTabStatus(tabId, next);
24088
24134
  }
24089
24135
  refreshGlobal() {
24090
- const entry = this.activeTabId != null ? this.tabs.get(this.activeTabId) : void 0;
24091
- const engine = entry?.engines.values().next().value;
24092
- const next = computeGlobalStatus(engine);
24136
+ const next = computeGlobalStatus(this.globalEngine);
24093
24137
  if (sameJson(next, this.globalStatus)) return;
24094
24138
  this.globalStatus = next;
24095
24139
  this.listener.onGlobalStatus(next);
@@ -24571,6 +24615,25 @@ var CliPanelController = class {
24571
24615
  serversDropdownOpen: false
24572
24616
  });
24573
24617
  }
24618
+ /**
24619
+ * Stop the command running in the active tab, as Ctrl+C does. False when
24620
+ * no command runs there.
24621
+ */
24622
+ stopCommand() {
24623
+ const stopped = interruptCommand(this.tracker.activeTabEngines);
24624
+ if (stopped) this.tracker.refresh();
24625
+ return stopped;
24626
+ }
24627
+ /**
24628
+ * Stop a running background service listed in the services dropdown, as
24629
+ * `kill <pid>` does; the list refreshes. False when nothing was running
24630
+ * under that pid.
24631
+ */
24632
+ killProcess(pid) {
24633
+ const killed = killProcess(this.tracker.globalEngine, pid);
24634
+ if (killed) this.tracker.refresh();
24635
+ return killed;
24636
+ }
24574
24637
  /** `anchor` is the clicked status item; the dropdown is placed next to it. */
24575
24638
  toggleServicesDropdown(anchor) {
24576
24639
  const open = !this.snapshot.servicesDropdownOpen;
@@ -24999,6 +25062,9 @@ var PANEL_LABELS = {
24999
25062
  closePane: "Close pane",
25000
25063
  servicesHeader: "Background Services",
25001
25064
  servicesEmpty: "No services registered",
25065
+ stopService: "Stop",
25066
+ stopCommand: "Stop",
25067
+ stopCommandTitle: "Stop the running command (Ctrl+C)",
25002
25068
  serversHeader: "Server Connections",
25003
25069
  serversEmpty: "No servers configured"
25004
25070
  };
@@ -25063,10 +25129,11 @@ function statusIndicators(s) {
25063
25129
  items.push({
25064
25130
  key: "execution",
25065
25131
  itemClass: running ? "status-running" : "",
25066
- compactClass: "",
25132
+ compactClass: running ? "status-clickable" : "",
25067
25133
  dotClass: running ? "dot-running" : "dot-idle",
25068
25134
  label: s.status.executionState,
25069
- title: s.status.executionState
25135
+ title: running ? PANEL_LABELS.stopCommandTitle : s.status.executionState,
25136
+ stop: running ? { label: PANEL_LABELS.stopCommand, title: PANEL_LABELS.stopCommandTitle } : void 0
25070
25137
  });
25071
25138
  if (s.global.serviceCount.total > 0) {
25072
25139
  const label = `${s.global.serviceCount.running}/${s.global.serviceCount.total} services`;
@@ -25179,7 +25246,8 @@ function openStatusDropdown(s) {
25179
25246
  name: svc.name,
25180
25247
  description: svc.description,
25181
25248
  status: svc.status,
25182
- meta: []
25249
+ meta: [],
25250
+ stop: svc.status === "running" && svc.pid !== void 0 ? { pid: svc.pid, label: PANEL_LABELS.stopService, title: `${PANEL_LABELS.stopService} ${svc.name} (kill ${svc.pid})` } : void 0
25183
25251
  }))
25184
25252
  };
25185
25253
  }
@@ -25202,6 +25270,6 @@ function openStatusDropdown(s) {
25202
25270
  return null;
25203
25271
  }
25204
25272
 
25205
- export { API_VERSION, CLI_ENV_GLOBAL_PERMISSION, CLI_FRAMEWORK_SERVICE, CLOSE_GLYPH, CLOSE_ICON, CapturingTerminalWriter, CliAliasCommandProcessor, CliArgsParser, CliBackgroundServiceRegistry_TOKEN, CliBoot, CliBootLog, CliBootLog_TOKEN, CliCalCommandProcessor, CliCaptureCommandProcessor, CliClearCommandProcessor, CliClipboard, CliClipboardCommandProcessor, CliColorCommandProcessor, CliCommandExecutionContext, CliCommandExecutor, CliCommandHistory, CliCommandHistory_TOKEN, CliCommandProcessorRegistry, CliConfigureCommandProcessor, CliConvertCommandProcessor, CliDebugCommandProcessor, CliDefaultPingServerService, CliDiffCommandProcessor, CliDragDropService, CliEchoCommandProcessor, CliEngine, CliEnvCommandProcessor, CliEnvironment, CliEvalCommandProcessor, CliEventsCommandProcessor, CliExecutionContext, CliExecutionProcess, CliExportCommandProcessor, CliFalseCommandProcessor, CliFeedbackCommandProcessor, CliFontSizeCommandProcessor, CliFullScreenManager, CliHelpCommandProcessor, CliHistoryCommandProcessor, CliHotKeysCommandProcessor, CliHtopCommandProcessor, CliHttpClient, CliInputReader, CliJsonCommandProcessor, CliKeyValueStore, CliKeyValueStore_TOKEN, CliKillCommandProcessor, CliLogger, CliLoremCommandProcessor, CliModuleRegistry_TOKEN, CliNanoCommandProcessor, CliNotifier, CliOpenCommandProcessor, CliPackageManagerService, CliPackageManagerService_TOKEN, CliPackagesCommandProcessor, CliPanelController, CliPanelStatusTracker, CliPermissionRegistry, CliPingCommandProcessor, CliProcessRegistry, CliProcessRegistry_TOKEN, CliProcessorsRegistry_TOKEN, CliPsCommandProcessor, CliRandomCommandProcessor, CliScreenCommandProcessor, CliScriptSyntaxError, CliSeqCommandProcessor, CliServerCommandProcessor, CliServerConnection, CliServerManager, CliServerManager_TOKEN, CliServerMultiProxyProcessor, CliServerProxyProcessor, CliServiceContainer, CliServicesCommandProcessor, CliSleepCommandProcessor, CliSnippetCommandProcessor, CliSshCommandProcessor, CliStateStore, CliStateStoreManager, CliStateStoreManager_TOKEN, CliTerminalProgressBar, CliTerminalSpinner, CliTerminalTextAnimator, CliTerminalWriter, CliTestCommandProcessor, CliTestHarness, CliThemeCommandProcessor, CliTimeCommandProcessor, CliTimerManager, CliTimestampCommandProcessor, CliTrueCommandProcessor, CliUnAliasCommandProcessor, CliUnameCommandProcessor, CliUnsetCommandProcessor, CliUptimeCommandProcessor, CliVersionCommandProcessor, CliYesCommandProcessor, CommandParser, DEFAULT_CLI_NAME, DEFAULT_GLOBAL_STATUS, DEFAULT_PANEL_HEIGHT, DEFAULT_PANEL_WIDTH, DEFAULT_TAB_STATUS, ERROR_ICON, EXEC_POLL_MS, GLOBAL_POLL_MS, HIDE_ICON, HIDE_TAB_TERMINAL_ICON, ICliEnvironment_TOKEN, ICliPingServerService_TOKEN, ICliScriptRunner_TOKEN, JsFallbackAccelerator, LIBRARY_VERSION, MAXIMIZE_ICON, MIN_PANEL_SIZE, MIN_PANE_WIDTH_PERCENT, OverlayAddon, PANEL_LABELS, PANEL_POSITIONS, ProcessExitedError, RESTORE_ICON, SERVICES_ICON, SUCCESS_ICON, SVG_COMMON_ATTRS, SVG_VIEW_BOX, ScriptLoaderService, SyntaxHighlighterRegistry_TOKEN, TERMINAL_ICON, UPTIME_ICON, appendOutputToFile, appendStderrToFile, applyEnvironmentChange, builtinProcessors, capitalize, clampPanelSize, cliScriptRunner, collapseChevronIcon, computeDiff, computeGlobalStatus, computeTabStatus, contextGlobalParameter, contextMenuItems, contextMenuStyle, createCliEngine, createServerModule, defaultFontSize, describeShellClose, distributePaneWidths, dropdownAnchorStyle, executeOnServer, expandBraces, expandEnvironmentVars, expandGlobs, formatDiff, formatUptime2 as formatUptime, getAccelerator, getCliNameArt, getGreetingBasedOnTime, getTerminalOptions, glowLineClass, greetingModule, groupBy, handleRenameKey, helpGlobalParameter, hideTabChevronIcon, hotkeysInfo, initWasmAccelerator, initializeServices, initializeTerminal, isHorizontalPosition, isWasmAccelerated, joinClasses, matchGlob, mergeCliOptions, miscProcessors, nextRowsCommand, normalizePaneWidths, openLink, openStatusDropdown, paneClass, paneStyle, panelBranding, panelTabClass, panelTabDotClass, panelWrapperClass, panelWrapperStyle, panesContainerClass, panesContainerWidth, parseAssignments, parseScript, positionDropdownItemClass, positionIcon, positionOptions, reconcileArgs, renderServerResponse, renderSingleOutput, resizePaneWidths, resizedPanelSize, resolveCliBranding, resolveCliHostConfig, runContextMenuAction, runScript, splitWords, statusIndicators, substituteCommands, substituteVars, svgAttrs, systemProcessors, tabDotClass, themeInfos, themes, tryExecuteScript, versionGlobalParameter, waitForLayout, welcomeModule, writeOutputToFile, writeStderrToFile };
25273
+ export { API_VERSION, CLI_ENV_GLOBAL_PERMISSION, CLI_FRAMEWORK_SERVICE, CLOSE_GLYPH, CLOSE_ICON, CapturingTerminalWriter, CliAliasCommandProcessor, CliArgsParser, CliBackgroundServiceRegistry_TOKEN, CliBoot, CliBootLog, CliBootLog_TOKEN, CliCalCommandProcessor, CliCaptureCommandProcessor, CliClearCommandProcessor, CliClipboard, CliClipboardCommandProcessor, CliColorCommandProcessor, CliCommandExecutionContext, CliCommandExecutor, CliCommandHistory, CliCommandHistory_TOKEN, CliCommandProcessorRegistry, CliConfigureCommandProcessor, CliConvertCommandProcessor, CliDebugCommandProcessor, CliDefaultPingServerService, CliDiffCommandProcessor, CliDragDropService, CliEchoCommandProcessor, CliEngine, CliEnvCommandProcessor, CliEnvironment, CliEvalCommandProcessor, CliEventsCommandProcessor, CliExecutionContext, CliExecutionProcess, CliExportCommandProcessor, CliFalseCommandProcessor, CliFeedbackCommandProcessor, CliFontSizeCommandProcessor, CliFullScreenManager, CliHelpCommandProcessor, CliHistoryCommandProcessor, CliHotKeysCommandProcessor, CliHtopCommandProcessor, CliHttpClient, CliInputReader, CliJsonCommandProcessor, CliKeyValueStore, CliKeyValueStore_TOKEN, CliKillCommandProcessor, CliLogger, CliLoremCommandProcessor, CliModuleRegistry_TOKEN, CliNanoCommandProcessor, CliNotifier, CliOpenCommandProcessor, CliPackageManagerService, CliPackageManagerService_TOKEN, CliPackagesCommandProcessor, CliPanelController, CliPanelStatusTracker, CliPermissionRegistry, CliPingCommandProcessor, CliProcessRegistry, CliProcessRegistry_TOKEN, CliProcessorsRegistry_TOKEN, CliPsCommandProcessor, CliRandomCommandProcessor, CliScreenCommandProcessor, CliScriptSyntaxError, CliSeqCommandProcessor, CliServerCommandProcessor, CliServerConnection, CliServerManager, CliServerManager_TOKEN, CliServerMultiProxyProcessor, CliServerProxyProcessor, CliServiceContainer, CliServicesCommandProcessor, CliSleepCommandProcessor, CliSnippetCommandProcessor, CliSshCommandProcessor, CliStateStore, CliStateStoreManager, CliStateStoreManager_TOKEN, CliTerminalProgressBar, CliTerminalSpinner, CliTerminalTextAnimator, CliTerminalWriter, CliTestCommandProcessor, CliTestHarness, CliThemeCommandProcessor, CliTimeCommandProcessor, CliTimerManager, CliTimestampCommandProcessor, CliTrueCommandProcessor, CliUnAliasCommandProcessor, CliUnameCommandProcessor, CliUnsetCommandProcessor, CliUptimeCommandProcessor, CliVersionCommandProcessor, CliYesCommandProcessor, CommandParser, DEFAULT_CLI_NAME, DEFAULT_GLOBAL_STATUS, DEFAULT_PANEL_HEIGHT, DEFAULT_PANEL_WIDTH, DEFAULT_TAB_STATUS, ERROR_ICON, EXEC_POLL_MS, GLOBAL_POLL_MS, HIDE_ICON, HIDE_TAB_TERMINAL_ICON, ICliEnvironment_TOKEN, ICliPingServerService_TOKEN, ICliScriptRunner_TOKEN, JsFallbackAccelerator, LIBRARY_VERSION, MAXIMIZE_ICON, MIN_PANEL_SIZE, MIN_PANE_WIDTH_PERCENT, OverlayAddon, PANEL_LABELS, PANEL_POSITIONS, ProcessExitedError, RESTORE_ICON, SERVICES_ICON, SUCCESS_ICON, SVG_COMMON_ATTRS, SVG_VIEW_BOX, ScriptLoaderService, SyntaxHighlighterRegistry_TOKEN, TERMINAL_ICON, UPTIME_ICON, appendOutputToFile, appendStderrToFile, applyEnvironmentChange, builtinProcessors, capitalize, clampPanelSize, cliScriptRunner, collapseChevronIcon, computeDiff, computeGlobalStatus, computeTabStatus, contextGlobalParameter, contextMenuItems, contextMenuStyle, createCliEngine, createServerModule, defaultFontSize, describeShellClose, distributePaneWidths, dropdownAnchorStyle, executeOnServer, expandBraces, expandEnvironmentVars, expandGlobs, formatDiff, formatUptime2 as formatUptime, getAccelerator, getCliNameArt, getGreetingBasedOnTime, getTerminalOptions, glowLineClass, greetingModule, groupBy, handleRenameKey, helpGlobalParameter, hideTabChevronIcon, hotkeysInfo, initWasmAccelerator, initializeServices, initializeTerminal, interruptCommand, isHorizontalPosition, isWasmAccelerated, joinClasses, killProcess, matchGlob, mergeCliOptions, miscProcessors, nextRowsCommand, normalizePaneWidths, openLink, openStatusDropdown, paneClass, paneStyle, panelBranding, panelTabClass, panelTabDotClass, panelWrapperClass, panelWrapperStyle, panesContainerClass, panesContainerWidth, parseAssignments, parseScript, positionDropdownItemClass, positionIcon, positionOptions, reconcileArgs, renderServerResponse, renderSingleOutput, resizePaneWidths, resizedPanelSize, resolveCliBranding, resolveCliHostConfig, runContextMenuAction, runScript, splitWords, statusIndicators, substituteCommands, substituteVars, svgAttrs, systemProcessors, tabDotClass, themeInfos, themes, tryExecuteScript, versionGlobalParameter, waitForLayout, welcomeModule, writeOutputToFile, writeStderrToFile };
25206
25274
  //# sourceMappingURL=public-api.mjs.map
25207
25275
  //# sourceMappingURL=public-api.mjs.map