@qodalis/cli 2.0.0-beta.20 → 2.0.0-beta.21

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@qodalis/cli",
3
- "version": "2.0.0-beta.20",
3
+ "version": "2.0.0-beta.21",
4
4
  "description": "Framework-agnostic CLI engine for @qodalis terminal applications.",
5
5
  "author": "Nicolae Lupei, Qodalis Solutions",
6
6
  "license": "MIT",
@@ -30,7 +30,7 @@
30
30
  "./assets/*": "./assets/*"
31
31
  },
32
32
  "dependencies": {
33
- "@qodalis/cli-core": "2.0.0-beta.20",
33
+ "@qodalis/cli-core": "2.0.0-beta.21",
34
34
  "@xterm/xterm": "^5.5.0",
35
35
  "@xterm/addon-fit": "^0.10.0",
36
36
  "@xterm/addon-web-links": "^0.11.0",
package/public-api.d.mts CHANGED
@@ -165,7 +165,7 @@ declare const CliKeyValueStore_TOKEN: any;
165
165
  */
166
166
  declare const SyntaxHighlighterRegistry_TOKEN: any;
167
167
 
168
- declare const LIBRARY_VERSION = "2.0.0-beta.20";
168
+ declare const LIBRARY_VERSION = "2.0.0-beta.21";
169
169
  declare const API_VERSION = 2;
170
170
 
171
171
  declare class CliAliasCommandProcessor implements ICliCommandProcessor {
@@ -2850,6 +2850,21 @@ interface CliEngineOptions extends CliOptions {
2850
2850
  * `/assets/wasm/` and `/wasm/`; the CLI works without it.
2851
2851
  */
2852
2852
  wasmUrl?: string;
2853
+ /**
2854
+ * The welcome banner and greeting shown at startup. `false` starts with
2855
+ * just the prompt (embedded terminals, playgrounds, terminals driven by
2856
+ * `execute()`); an object configures the banner like
2857
+ * `welcomeModule.configure()`.
2858
+ * @default true
2859
+ */
2860
+ welcome?: boolean | CliWelcomeMessageConfig;
2861
+ /**
2862
+ * Focus the terminal when it starts. Turn it off when the terminal sits
2863
+ * next to other inputs that should keep the keyboard (an editor that
2864
+ * rebuilds the terminal while the user types); `focus()` still works.
2865
+ * @default true
2866
+ */
2867
+ autoFocus?: boolean;
2853
2868
  }
2854
2869
  declare class CliEngine {
2855
2870
  private readonly container;
@@ -2931,6 +2946,8 @@ declare class CliEngine {
2931
2946
  * greeting, which runs after every other `onAfterBoot` hook.
2932
2947
  */
2933
2948
  private modulesToBoot;
2949
+ /** Whether startup shows the welcome banner (which also shows the first prompt). */
2950
+ private get showsWelcome();
2934
2951
  /** 7. Replace the boot report with the terminal and mark the CLI booted. */
2935
2952
  private completeBoot;
2936
2953
  /**
@@ -3026,7 +3043,7 @@ declare function getTerminalOptions(userOptions?: Partial<ITerminalOptions & ITe
3026
3043
  * Create and configure an xterm.js Terminal with all required addons,
3027
3044
  * open it into the given container, and return the instances.
3028
3045
  */
3029
- declare function initializeTerminal(container: HTMLElement, opts: ITerminalOptions & ITerminalInitOnlyOptions): TerminalSetupResult;
3046
+ declare function initializeTerminal(container: HTMLElement, opts: ITerminalOptions & ITerminalInitOnlyOptions, focus?: boolean): TerminalSetupResult;
3030
3047
  /**
3031
3048
  * Wait until the container element has non-zero dimensions.
3032
3049
  * xterm.js requires the host element to be laid out before open() is called.
package/public-api.d.ts CHANGED
@@ -165,7 +165,7 @@ declare const CliKeyValueStore_TOKEN: any;
165
165
  */
166
166
  declare const SyntaxHighlighterRegistry_TOKEN: any;
167
167
 
168
- declare const LIBRARY_VERSION = "2.0.0-beta.20";
168
+ declare const LIBRARY_VERSION = "2.0.0-beta.21";
169
169
  declare const API_VERSION = 2;
170
170
 
171
171
  declare class CliAliasCommandProcessor implements ICliCommandProcessor {
@@ -2850,6 +2850,21 @@ interface CliEngineOptions extends CliOptions {
2850
2850
  * `/assets/wasm/` and `/wasm/`; the CLI works without it.
2851
2851
  */
2852
2852
  wasmUrl?: string;
2853
+ /**
2854
+ * The welcome banner and greeting shown at startup. `false` starts with
2855
+ * just the prompt (embedded terminals, playgrounds, terminals driven by
2856
+ * `execute()`); an object configures the banner like
2857
+ * `welcomeModule.configure()`.
2858
+ * @default true
2859
+ */
2860
+ welcome?: boolean | CliWelcomeMessageConfig;
2861
+ /**
2862
+ * Focus the terminal when it starts. Turn it off when the terminal sits
2863
+ * next to other inputs that should keep the keyboard (an editor that
2864
+ * rebuilds the terminal while the user types); `focus()` still works.
2865
+ * @default true
2866
+ */
2867
+ autoFocus?: boolean;
2853
2868
  }
2854
2869
  declare class CliEngine {
2855
2870
  private readonly container;
@@ -2931,6 +2946,8 @@ declare class CliEngine {
2931
2946
  * greeting, which runs after every other `onAfterBoot` hook.
2932
2947
  */
2933
2948
  private modulesToBoot;
2949
+ /** Whether startup shows the welcome banner (which also shows the first prompt). */
2950
+ private get showsWelcome();
2934
2951
  /** 7. Replace the boot report with the terminal and mark the CLI booted. */
2935
2952
  private completeBoot;
2936
2953
  /**
@@ -3026,7 +3043,7 @@ declare function getTerminalOptions(userOptions?: Partial<ITerminalOptions & ITe
3026
3043
  * Create and configure an xterm.js Terminal with all required addons,
3027
3044
  * open it into the given container, and return the instances.
3028
3045
  */
3029
- declare function initializeTerminal(container: HTMLElement, opts: ITerminalOptions & ITerminalInitOnlyOptions): TerminalSetupResult;
3046
+ declare function initializeTerminal(container: HTMLElement, opts: ITerminalOptions & ITerminalInitOnlyOptions, focus?: boolean): TerminalSetupResult;
3030
3047
  /**
3031
3048
  * Wait until the container element has non-zero dimensions.
3032
3049
  * xterm.js requires the host element to be laid out before open() is called.
package/public-api.js CHANGED
@@ -512,7 +512,7 @@ var CliKeyValueStore_TOKEN = cliCore.createCliToken("cli-key-value-store");
512
512
  var SyntaxHighlighterRegistry_TOKEN = cliCore.createCliToken("syntax-highlighter-registry");
513
513
 
514
514
  // src/lib/version.ts
515
- var LIBRARY_VERSION = "2.0.0-beta.20";
515
+ var LIBRARY_VERSION = "2.0.0-beta.21";
516
516
  var API_VERSION = 2;
517
517
  var ANONYMOUS = "\0anonymous";
518
518
  function aliasOwner(context2) {
@@ -4188,7 +4188,7 @@ function getTerminalOptions(userOptions) {
4188
4188
  ...userOptions ?? {}
4189
4189
  };
4190
4190
  }
4191
- function initializeTerminal(container, opts) {
4191
+ function initializeTerminal(container, opts, focus = true) {
4192
4192
  const terminal = new xterm.Terminal(opts);
4193
4193
  const fitAddon = new addonFit.FitAddon();
4194
4194
  terminal.loadAddon(fitAddon);
@@ -4209,7 +4209,9 @@ function initializeTerminal(container, opts) {
4209
4209
  container.style.background = opts.theme?.background ?? "#000";
4210
4210
  const wheelListener = (e) => e.preventDefault();
4211
4211
  container.addEventListener("wheel", wheelListener, { passive: false });
4212
- terminal.focus();
4212
+ if (focus) {
4213
+ terminal.focus();
4214
+ }
4213
4215
  const dragDropService = new CliDragDropService(container);
4214
4216
  return { terminal, fitAddon, serializeAddon, dragDropService, wheelListener };
4215
4217
  }
@@ -22586,6 +22588,9 @@ var CliEngine = class {
22586
22588
  }
22587
22589
  await this.completeBoot(bootLog);
22588
22590
  await this.runAfterBootHooks(modules);
22591
+ if (this.options?.welcome === false && !this.options?.snapshot) {
22592
+ this.executionContext.showPrompt();
22593
+ }
22589
22594
  if (this.options?.snapshot) {
22590
22595
  await this.restoreSnapshot(this.options.snapshot);
22591
22596
  }
@@ -22600,7 +22605,11 @@ var CliEngine = class {
22600
22605
  this.terminalOptions = getTerminalOptions(
22601
22606
  this.options?.terminalOptions
22602
22607
  );
22603
- const setup = initializeTerminal(this.container, this.terminalOptions);
22608
+ const setup = initializeTerminal(
22609
+ this.container,
22610
+ this.terminalOptions,
22611
+ this.options?.autoFocus !== false
22612
+ );
22604
22613
  this.terminal = setup.terminal;
22605
22614
  this.fitAddon = setup.fitAddon;
22606
22615
  this.serializeAddon = setup.serializeAddon;
@@ -22737,13 +22746,21 @@ var CliEngine = class {
22737
22746
  */
22738
22747
  modulesToBoot() {
22739
22748
  const serverModule = createServerModule();
22740
- return this.options?.snapshot ? [serverModule, ...this.userModules] : [
22741
- welcomeModule,
22749
+ if (!this.showsWelcome) {
22750
+ return [serverModule, ...this.userModules];
22751
+ }
22752
+ const welcome = this.options?.welcome;
22753
+ return [
22754
+ typeof welcome === "object" ? welcomeModule.configure(welcome) : welcomeModule,
22742
22755
  serverModule,
22743
22756
  ...this.userModules,
22744
22757
  greetingModule
22745
22758
  ];
22746
22759
  }
22760
+ /** Whether startup shows the welcome banner (which also shows the first prompt). */
22761
+ get showsWelcome() {
22762
+ return !this.options?.snapshot && this.options?.welcome !== false;
22763
+ }
22747
22764
  /** 7. Replace the boot report with the terminal and mark the CLI booted. */
22748
22765
  async completeBoot(bootLog) {
22749
22766
  await bootLog.finish(