@navios/commander-tui 1.6.0 → 1.6.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/.turbo/turbo-build.log +11 -11
- package/.turbo/turbo-lint.log +1 -1
- package/.turbo/turbo-test$colon$ci.log +9 -9
- package/.turbo/turbo-test.log +8 -8
- package/CHANGELOG.md +12 -0
- package/dist/base/src/keyboard/index.d.ts +1 -1
- package/dist/base/src/keyboard/index.d.ts.map +1 -1
- package/dist/base/src/services/screen_manager.d.ts.map +1 -1
- package/dist/base/tsconfig.tsbuildinfo +1 -1
- package/lib/index.cjs +127 -126
- package/lib/index.cjs.map +1 -1
- package/lib/index.d.cts +65 -65
- package/lib/index.d.cts.map +1 -1
- package/lib/index.d.mts +25 -25
- package/lib/index.d.mts.map +1 -1
- package/lib/index.mjs +127 -126
- package/lib/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/keyboard/index.ts +1 -1
- package/src/services/screen_manager.ts +6 -0
package/lib/index.cjs
CHANGED
|
@@ -7088,6 +7088,7 @@ var ScreenManagerInstance = class extends (_EventEmitter = node_events.EventEmit
|
|
|
7088
7088
|
* Non-blocking bind - starts TUI rendering in background
|
|
7089
7089
|
*/ async bind(options) {
|
|
7090
7090
|
if (this.mode !== RenderMode.UNBOUND) return;
|
|
7091
|
+
if (!process.stdout.isTTY || !process.stdin.isTTY) return;
|
|
7091
7092
|
this.bindOptions = options ?? {};
|
|
7092
7093
|
if (options?.theme) this.theme = typeof options.theme === "string" ? getThemePreset(options.theme) : options.theme;
|
|
7093
7094
|
if (!(options?.useOpenTUI ?? isBunRuntime())) {
|
|
@@ -8321,132 +8322,6 @@ var PromptInstance = class {
|
|
|
8321
8322
|
}
|
|
8322
8323
|
};
|
|
8323
8324
|
|
|
8324
|
-
//#endregion
|
|
8325
|
-
//#region src/keyboard/keyboard_manager.ts
|
|
8326
|
-
/**
|
|
8327
|
-
* Manages keyboard bindings and dispatches key events to handlers.
|
|
8328
|
-
*/ var KeyboardManager = class {
|
|
8329
|
-
bindings = [];
|
|
8330
|
-
disabled = /* @__PURE__ */ new Set();
|
|
8331
|
-
constructor(config$1) {
|
|
8332
|
-
if (config$1?.bindings) this.bindings = [...config$1.bindings];
|
|
8333
|
-
if (config$1?.disabled) this.disabled = new Set(config$1.disabled);
|
|
8334
|
-
this.sortBindings();
|
|
8335
|
-
}
|
|
8336
|
-
/**
|
|
8337
|
-
* Add bindings to the manager.
|
|
8338
|
-
*/ addBindings(bindings) {
|
|
8339
|
-
this.bindings.push(...bindings);
|
|
8340
|
-
this.sortBindings();
|
|
8341
|
-
}
|
|
8342
|
-
/**
|
|
8343
|
-
* Remove a binding by key name.
|
|
8344
|
-
*/ removeBinding(key) {
|
|
8345
|
-
this.bindings = this.bindings.filter((b) => {
|
|
8346
|
-
return !(Array.isArray(b.key) ? b.key : [b.key]).includes(key);
|
|
8347
|
-
});
|
|
8348
|
-
}
|
|
8349
|
-
/**
|
|
8350
|
-
* Disable a key (prevents it from being matched).
|
|
8351
|
-
*/ disableKey(key) {
|
|
8352
|
-
this.disabled.add(key);
|
|
8353
|
-
}
|
|
8354
|
-
/**
|
|
8355
|
-
* Enable a previously disabled key.
|
|
8356
|
-
*/ enableKey(key) {
|
|
8357
|
-
this.disabled.delete(key);
|
|
8358
|
-
}
|
|
8359
|
-
/**
|
|
8360
|
-
* Handle a key event, dispatching to the appropriate handler.
|
|
8361
|
-
* Returns true if a handler consumed the event.
|
|
8362
|
-
*/ handleKey(key, context) {
|
|
8363
|
-
const binding = this.findMatchingBinding(key, context);
|
|
8364
|
-
if (binding) return binding.handler(key, context) !== false;
|
|
8365
|
-
return false;
|
|
8366
|
-
}
|
|
8367
|
-
/**
|
|
8368
|
-
* Get all bindings for display in help overlay.
|
|
8369
|
-
*/ getBindingsForHelp() {
|
|
8370
|
-
return this.bindings.filter((b) => b.description);
|
|
8371
|
-
}
|
|
8372
|
-
/**
|
|
8373
|
-
* Get bindings grouped by category.
|
|
8374
|
-
*/ getBindingsByCategory() {
|
|
8375
|
-
const grouped = {
|
|
8376
|
-
general: [],
|
|
8377
|
-
navigation: [],
|
|
8378
|
-
screen: [],
|
|
8379
|
-
prompt: [],
|
|
8380
|
-
filter: []
|
|
8381
|
-
};
|
|
8382
|
-
for (const binding of this.bindings) if (binding.description) grouped[binding.category].push(binding);
|
|
8383
|
-
return grouped;
|
|
8384
|
-
}
|
|
8385
|
-
/**
|
|
8386
|
-
* Find a matching binding for the given key and context.
|
|
8387
|
-
*/ findMatchingBinding(key, context) {
|
|
8388
|
-
for (const binding of this.bindings) if (this.keyMatches(key, binding) && this.conditionMatches(binding.when, context) && !this.isDisabled(binding)) return binding;
|
|
8389
|
-
return null;
|
|
8390
|
-
}
|
|
8391
|
-
/**
|
|
8392
|
-
* Check if a key event matches a binding's key specification.
|
|
8393
|
-
*/ keyMatches(key, binding) {
|
|
8394
|
-
const keys = Array.isArray(binding.key) ? binding.key : [binding.key];
|
|
8395
|
-
if (!(keys.includes(key.name) || key.sequence && keys.includes(key.sequence))) return false;
|
|
8396
|
-
const ctrlMatches = (binding.ctrl ?? false) === (key.ctrl ?? false);
|
|
8397
|
-
const metaMatches = (binding.meta ?? false) === (key.meta ?? false);
|
|
8398
|
-
const shiftMatches = (binding.shift ?? false) === (key.shift ?? false);
|
|
8399
|
-
return ctrlMatches && metaMatches && shiftMatches;
|
|
8400
|
-
}
|
|
8401
|
-
/**
|
|
8402
|
-
* Check if context matches a binding's condition.
|
|
8403
|
-
*/ conditionMatches(condition, context) {
|
|
8404
|
-
if (!condition) return true;
|
|
8405
|
-
if (condition.hasPrompt !== void 0 && condition.hasPrompt !== context.hasPrompt) return false;
|
|
8406
|
-
if (condition.inInputMode !== void 0 && condition.inInputMode !== context.inInputMode) return false;
|
|
8407
|
-
if (condition.focusArea !== void 0 && condition.focusArea !== context.focusArea) return false;
|
|
8408
|
-
if (condition.isFilterActive !== void 0 && condition.isFilterActive !== context.isFilterActive) return false;
|
|
8409
|
-
if (condition.isHelpVisible !== void 0 && condition.isHelpVisible !== context.isHelpVisible) return false;
|
|
8410
|
-
if (condition.hasSidebar !== void 0 && condition.hasSidebar !== context.hasSidebar) return false;
|
|
8411
|
-
return true;
|
|
8412
|
-
}
|
|
8413
|
-
/**
|
|
8414
|
-
* Check if a binding is disabled.
|
|
8415
|
-
*/ isDisabled(binding) {
|
|
8416
|
-
return (Array.isArray(binding.key) ? binding.key : [binding.key]).some((k) => this.disabled.has(k));
|
|
8417
|
-
}
|
|
8418
|
-
/**
|
|
8419
|
-
* Sort bindings by priority (higher first).
|
|
8420
|
-
*/ sortBindings() {
|
|
8421
|
-
this.bindings.sort((a, b) => (b.priority ?? 0) - (a.priority ?? 0));
|
|
8422
|
-
}
|
|
8423
|
-
};
|
|
8424
|
-
/**
|
|
8425
|
-
* Format a key binding for display.
|
|
8426
|
-
*/ function formatKeyBinding(binding) {
|
|
8427
|
-
const keys = Array.isArray(binding.key) ? binding.key : [binding.key];
|
|
8428
|
-
const parts = [];
|
|
8429
|
-
if (binding.ctrl) parts.push("Ctrl");
|
|
8430
|
-
if (binding.meta) parts.push("Cmd");
|
|
8431
|
-
if (binding.shift) parts.push("Shift");
|
|
8432
|
-
const keyDisplay = keys.map((k) => {
|
|
8433
|
-
switch (k) {
|
|
8434
|
-
case "up": return "↑";
|
|
8435
|
-
case "down": return "↓";
|
|
8436
|
-
case "left": return "←";
|
|
8437
|
-
case "right": return "→";
|
|
8438
|
-
case "return": return "Enter";
|
|
8439
|
-
case "escape": return "Esc";
|
|
8440
|
-
case "space": return "Space";
|
|
8441
|
-
case "tab": return "Tab";
|
|
8442
|
-
case "\\": return "\\";
|
|
8443
|
-
default: return k;
|
|
8444
|
-
}
|
|
8445
|
-
}).join("/");
|
|
8446
|
-
parts.push(keyDisplay);
|
|
8447
|
-
return parts.join("+");
|
|
8448
|
-
}
|
|
8449
|
-
|
|
8450
8325
|
//#endregion
|
|
8451
8326
|
//#region src/keyboard/create_bindings.ts
|
|
8452
8327
|
/**
|
|
@@ -8842,6 +8717,132 @@ var PromptInstance = class {
|
|
|
8842
8717
|
return false;
|
|
8843
8718
|
}
|
|
8844
8719
|
|
|
8720
|
+
//#endregion
|
|
8721
|
+
//#region src/keyboard/keyboard_manager.ts
|
|
8722
|
+
/**
|
|
8723
|
+
* Manages keyboard bindings and dispatches key events to handlers.
|
|
8724
|
+
*/ var KeyboardManager = class {
|
|
8725
|
+
bindings = [];
|
|
8726
|
+
disabled = /* @__PURE__ */ new Set();
|
|
8727
|
+
constructor(config$1) {
|
|
8728
|
+
if (config$1?.bindings) this.bindings = [...config$1.bindings];
|
|
8729
|
+
if (config$1?.disabled) this.disabled = new Set(config$1.disabled);
|
|
8730
|
+
this.sortBindings();
|
|
8731
|
+
}
|
|
8732
|
+
/**
|
|
8733
|
+
* Add bindings to the manager.
|
|
8734
|
+
*/ addBindings(bindings) {
|
|
8735
|
+
this.bindings.push(...bindings);
|
|
8736
|
+
this.sortBindings();
|
|
8737
|
+
}
|
|
8738
|
+
/**
|
|
8739
|
+
* Remove a binding by key name.
|
|
8740
|
+
*/ removeBinding(key) {
|
|
8741
|
+
this.bindings = this.bindings.filter((b) => {
|
|
8742
|
+
return !(Array.isArray(b.key) ? b.key : [b.key]).includes(key);
|
|
8743
|
+
});
|
|
8744
|
+
}
|
|
8745
|
+
/**
|
|
8746
|
+
* Disable a key (prevents it from being matched).
|
|
8747
|
+
*/ disableKey(key) {
|
|
8748
|
+
this.disabled.add(key);
|
|
8749
|
+
}
|
|
8750
|
+
/**
|
|
8751
|
+
* Enable a previously disabled key.
|
|
8752
|
+
*/ enableKey(key) {
|
|
8753
|
+
this.disabled.delete(key);
|
|
8754
|
+
}
|
|
8755
|
+
/**
|
|
8756
|
+
* Handle a key event, dispatching to the appropriate handler.
|
|
8757
|
+
* Returns true if a handler consumed the event.
|
|
8758
|
+
*/ handleKey(key, context) {
|
|
8759
|
+
const binding = this.findMatchingBinding(key, context);
|
|
8760
|
+
if (binding) return binding.handler(key, context) !== false;
|
|
8761
|
+
return false;
|
|
8762
|
+
}
|
|
8763
|
+
/**
|
|
8764
|
+
* Get all bindings for display in help overlay.
|
|
8765
|
+
*/ getBindingsForHelp() {
|
|
8766
|
+
return this.bindings.filter((b) => b.description);
|
|
8767
|
+
}
|
|
8768
|
+
/**
|
|
8769
|
+
* Get bindings grouped by category.
|
|
8770
|
+
*/ getBindingsByCategory() {
|
|
8771
|
+
const grouped = {
|
|
8772
|
+
general: [],
|
|
8773
|
+
navigation: [],
|
|
8774
|
+
screen: [],
|
|
8775
|
+
prompt: [],
|
|
8776
|
+
filter: []
|
|
8777
|
+
};
|
|
8778
|
+
for (const binding of this.bindings) if (binding.description) grouped[binding.category].push(binding);
|
|
8779
|
+
return grouped;
|
|
8780
|
+
}
|
|
8781
|
+
/**
|
|
8782
|
+
* Find a matching binding for the given key and context.
|
|
8783
|
+
*/ findMatchingBinding(key, context) {
|
|
8784
|
+
for (const binding of this.bindings) if (this.keyMatches(key, binding) && this.conditionMatches(binding.when, context) && !this.isDisabled(binding)) return binding;
|
|
8785
|
+
return null;
|
|
8786
|
+
}
|
|
8787
|
+
/**
|
|
8788
|
+
* Check if a key event matches a binding's key specification.
|
|
8789
|
+
*/ keyMatches(key, binding) {
|
|
8790
|
+
const keys = Array.isArray(binding.key) ? binding.key : [binding.key];
|
|
8791
|
+
if (!(keys.includes(key.name) || key.sequence && keys.includes(key.sequence))) return false;
|
|
8792
|
+
const ctrlMatches = (binding.ctrl ?? false) === (key.ctrl ?? false);
|
|
8793
|
+
const metaMatches = (binding.meta ?? false) === (key.meta ?? false);
|
|
8794
|
+
const shiftMatches = (binding.shift ?? false) === (key.shift ?? false);
|
|
8795
|
+
return ctrlMatches && metaMatches && shiftMatches;
|
|
8796
|
+
}
|
|
8797
|
+
/**
|
|
8798
|
+
* Check if context matches a binding's condition.
|
|
8799
|
+
*/ conditionMatches(condition, context) {
|
|
8800
|
+
if (!condition) return true;
|
|
8801
|
+
if (condition.hasPrompt !== void 0 && condition.hasPrompt !== context.hasPrompt) return false;
|
|
8802
|
+
if (condition.inInputMode !== void 0 && condition.inInputMode !== context.inInputMode) return false;
|
|
8803
|
+
if (condition.focusArea !== void 0 && condition.focusArea !== context.focusArea) return false;
|
|
8804
|
+
if (condition.isFilterActive !== void 0 && condition.isFilterActive !== context.isFilterActive) return false;
|
|
8805
|
+
if (condition.isHelpVisible !== void 0 && condition.isHelpVisible !== context.isHelpVisible) return false;
|
|
8806
|
+
if (condition.hasSidebar !== void 0 && condition.hasSidebar !== context.hasSidebar) return false;
|
|
8807
|
+
return true;
|
|
8808
|
+
}
|
|
8809
|
+
/**
|
|
8810
|
+
* Check if a binding is disabled.
|
|
8811
|
+
*/ isDisabled(binding) {
|
|
8812
|
+
return (Array.isArray(binding.key) ? binding.key : [binding.key]).some((k) => this.disabled.has(k));
|
|
8813
|
+
}
|
|
8814
|
+
/**
|
|
8815
|
+
* Sort bindings by priority (higher first).
|
|
8816
|
+
*/ sortBindings() {
|
|
8817
|
+
this.bindings.sort((a, b) => (b.priority ?? 0) - (a.priority ?? 0));
|
|
8818
|
+
}
|
|
8819
|
+
};
|
|
8820
|
+
/**
|
|
8821
|
+
* Format a key binding for display.
|
|
8822
|
+
*/ function formatKeyBinding(binding) {
|
|
8823
|
+
const keys = Array.isArray(binding.key) ? binding.key : [binding.key];
|
|
8824
|
+
const parts = [];
|
|
8825
|
+
if (binding.ctrl) parts.push("Ctrl");
|
|
8826
|
+
if (binding.meta) parts.push("Cmd");
|
|
8827
|
+
if (binding.shift) parts.push("Shift");
|
|
8828
|
+
const keyDisplay = keys.map((k) => {
|
|
8829
|
+
switch (k) {
|
|
8830
|
+
case "up": return "↑";
|
|
8831
|
+
case "down": return "↓";
|
|
8832
|
+
case "left": return "←";
|
|
8833
|
+
case "right": return "→";
|
|
8834
|
+
case "return": return "Enter";
|
|
8835
|
+
case "escape": return "Esc";
|
|
8836
|
+
case "space": return "Space";
|
|
8837
|
+
case "tab": return "Tab";
|
|
8838
|
+
case "\\": return "\\";
|
|
8839
|
+
default: return k;
|
|
8840
|
+
}
|
|
8841
|
+
}).join("/");
|
|
8842
|
+
parts.push(keyDisplay);
|
|
8843
|
+
return parts.join("+");
|
|
8844
|
+
}
|
|
8845
|
+
|
|
8845
8846
|
//#endregion
|
|
8846
8847
|
//#region src/filter/filter_engine.ts
|
|
8847
8848
|
/**
|