@navios/commander-tui 1.4.0 → 1.5.0

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": "@navios/commander-tui",
3
- "version": "1.4.0",
3
+ "version": "1.5.0",
4
4
  "license": "MIT",
5
5
  "author": {
6
6
  "name": "Oleksandr Hanzha",
@@ -15,9 +15,7 @@ import type { ScreenManagerInstance } from '../../services/screen_manager.ts'
15
15
  /**
16
16
  * Create a mock manager with TUI mode active (prompts go through TUI queue)
17
17
  */
18
- function createMockManager(
19
- overrides: Partial<ScreenManagerInstance> = {},
20
- ): ScreenManagerInstance {
18
+ function createMockManager(overrides: Partial<ScreenManagerInstance> = {}): ScreenManagerInstance {
21
19
  return {
22
20
  onScreenCompleted: vi.fn(),
23
21
  onScreenVisibilityChanged: vi.fn(),
@@ -37,7 +35,7 @@ describe('ScreenInstance', () => {
37
35
  let screen: ScreenInstance
38
36
 
39
37
  beforeEach(() => {
40
- screen = new ScreenInstance('test-id', { name: 'Test Screen' })
38
+ screen = new ScreenInstance('test-id', { name: 'Test Screen', static: true })
41
39
  })
42
40
 
43
41
  describe('construction and getters', () => {
@@ -50,7 +48,7 @@ describe('ScreenInstance', () => {
50
48
  })
51
49
 
52
50
  it('should set icon from options', () => {
53
- const screenWithIcon = new ScreenInstance('id', { name: 'Test', icon: '📦' })
51
+ const screenWithIcon = new ScreenInstance('id', { name: 'Test', icon: '📦', static: true })
54
52
  expect(screenWithIcon.getIcon()).toBe('📦')
55
53
  })
56
54
 
@@ -59,7 +57,11 @@ describe('ScreenInstance', () => {
59
57
  })
60
58
 
61
59
  it('should set badgeCount from options', () => {
62
- const screenWithBadge = new ScreenInstance('id', { name: 'Test', badgeCount: 5 })
60
+ const screenWithBadge = new ScreenInstance('id', {
61
+ name: 'Test',
62
+ badgeCount: 5,
63
+ static: true,
64
+ })
63
65
  expect(screenWithBadge.getBadgeCount()).toBe(5)
64
66
  })
65
67
 
@@ -72,12 +74,12 @@ describe('ScreenInstance', () => {
72
74
  })
73
75
 
74
76
  it('should set hidden from options', () => {
75
- const hiddenScreen = new ScreenInstance('id', { name: 'Test', hidden: true })
77
+ const hiddenScreen = new ScreenInstance('id', { name: 'Test', hidden: true, static: true })
76
78
  expect(hiddenScreen.isHidden()).toBe(true)
77
79
  })
78
80
 
79
- it('should default status to waiting', () => {
80
- expect(screen.getStatus()).toBe('waiting')
81
+ it('should default status to static', () => {
82
+ expect(screen.getStatus()).toBe('static')
81
83
  })
82
84
  })
83
85
 
@@ -2,10 +2,10 @@ import { EventEmitter } from 'node:events'
2
2
 
3
3
  import type { LogLevel } from '@navios/core'
4
4
 
5
+ import { RenderMode } from '../types/index.ts'
5
6
  import { getPromptDefaultValue, printSingleMessage } from '../utils/index.ts'
6
7
 
7
8
  import type { ScreenOptions } from '../schemas/index.ts'
8
- import { RenderMode } from '../types/index.ts'
9
9
  import type {
10
10
  ChoicePromptData,
11
11
  ConfirmPromptData,
@@ -51,9 +51,8 @@ export class ScreenInstance extends EventEmitter<ScreenEventMap> {
51
51
  this.icon = options.icon
52
52
  this.badgeCount = options.badgeCount ?? 0
53
53
  this.hidden = options.hidden ?? false
54
- if (options.static) {
55
- this.status = 'static'
56
- }
54
+
55
+ this.status = (options.static ?? true) ? 'static' : 'waiting'
57
56
  }
58
57
 
59
58
  incrementVersion(): void {
@@ -8,11 +8,16 @@ import type { CliRenderer } from '@opentui/core'
8
8
  import { getThemePreset } from '../themes/index.ts'
9
9
  import { Adapter } from '../tokens/adapter.ts'
10
10
  import { ScreenManager } from '../tokens/screen-manager.ts'
11
- import { dynamicImport, getPromptDefaultValue, isBunRuntime, printMessagesToStdout } from '../utils/index.ts'
11
+ import { RenderMode } from '../types/index.ts'
12
+ import {
13
+ dynamicImport,
14
+ getPromptDefaultValue,
15
+ isBunRuntime,
16
+ printMessagesToStdout,
17
+ } from '../utils/index.ts'
12
18
 
13
19
  import type { AdapterInterface, AdapterRoot } from '../adapters/interface.ts'
14
20
  import type { ScreenOptions } from '../schemas/index.ts'
15
- import { RenderMode } from '../types/index.ts'
16
21
  import type {
17
22
  BindOptions,
18
23
  FocusArea,
@@ -128,7 +133,7 @@ export class ScreenManagerInstance
128
133
  }
129
134
 
130
135
  // Determine useOpenTUI default: false for Bun (not supported), true for Node.js
131
- const useOpenTUI = options?.useOpenTUI ?? !isBunRuntime()
136
+ const useOpenTUI = options?.useOpenTUI ?? isBunRuntime()
132
137
 
133
138
  if (!useOpenTUI) {
134
139
  // Explicit stdout mode requested