@electerm/electerm-react 3.11.11 → 3.12.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.
@@ -11,6 +11,11 @@ import {
11
11
  getLocalFileInfo,
12
12
  getRemoteFileInfo
13
13
  } from '../components/sftp/file-read'
14
+ import {
15
+ fixBookmarkData,
16
+ validateBookmarkData
17
+ } from '../components/bookmark-form/fix-bookmark-default'
18
+ import newTerm from '../common/new-terminal'
14
19
 
15
20
  export default Store => {
16
21
  // Initialize MCP handler - called when MCP widget is started
@@ -96,6 +101,9 @@ export default Store => {
96
101
  case 'open_local_terminal':
97
102
  result = store.mcpOpenLocalTerminal()
98
103
  break
104
+ case 'open_tab':
105
+ result = store.mcpOpenTab(args)
106
+ break
99
107
 
100
108
  // Terminal operations
101
109
  case 'send_terminal_command':
@@ -207,16 +215,14 @@ export default Store => {
207
215
 
208
216
  Store.prototype.mcpAddBookmark = async function (args) {
209
217
  const { store } = window
210
- const bookmark = {
218
+ const bookmark = fixBookmarkData({
211
219
  id: uid(),
212
- title: args.title,
213
- host: args.host || '',
214
- port: args.port || 22,
215
- username: args.username || '',
216
- password: args.password || '',
217
- type: args.type || 'local',
218
- term: 'xterm-256color',
219
220
  ...args
221
+ })
222
+
223
+ const { valid, errors } = validateBookmarkData(bookmark)
224
+ if (!valid) {
225
+ throw new Error(errors.join(', '))
220
226
  }
221
227
 
222
228
  store.addItem(bookmark, settingMap.bookmarks)
@@ -462,6 +468,32 @@ export default Store => {
462
468
  }
463
469
  }
464
470
 
471
+ Store.prototype.mcpOpenTab = function (args) {
472
+ const { store } = window
473
+ const data = fixBookmarkData({ ...args })
474
+
475
+ const { valid, errors } = validateBookmarkData(data)
476
+ if (!valid) {
477
+ throw new Error(errors.join(', '))
478
+ }
479
+
480
+ const tab = {
481
+ ...data,
482
+ from: 'mcp',
483
+ ...newTerm(true, true)
484
+ }
485
+
486
+ store.addTab(tab)
487
+ const newTabId = store.activeTabId
488
+
489
+ return {
490
+ success: true,
491
+ tabId: newTabId,
492
+ type: data.type,
493
+ message: `Opened ${data.type || 'local'} tab`
494
+ }
495
+ }
496
+
465
497
  // ==================== Terminal APIs ====================
466
498
 
467
499
  Store.prototype.mcpSendTerminalCommand = function (args) {
@@ -477,7 +509,7 @@ export default Store => {
477
509
  throw new Error('No command provided')
478
510
  }
479
511
 
480
- store.runQuickCommand(command, args.inputOnly || false)
512
+ store.runQuickCommand(command, args.inputOnly || false, tabId)
481
513
 
482
514
  return {
483
515
  success: true,
@@ -57,8 +57,9 @@ export default Store => {
57
57
  window.store.delItem({ id }, settingMap.quickCommands)
58
58
  }
59
59
 
60
- Store.prototype.runQuickCommand = function (cmd, inputOnly = false) {
61
- refs.get('term-' + window.store.activeTabId)?.runQuickCommand(cmd, inputOnly)
60
+ Store.prototype.runQuickCommand = function (cmd, inputOnly = false, tabId) {
61
+ const tid = tabId || window.store.activeTabId
62
+ refs.get('term-' + tid)?.runQuickCommand(cmd, inputOnly)
62
63
  }
63
64
 
64
65
  Store.prototype.runQuickCommandItem = debounce(async (id) => {
@@ -23,13 +23,13 @@ export default store => {
23
23
  for (const name of dbNamesForWatch) {
24
24
  window[`watch${name}Running`] = false
25
25
  window[`watch${name}`] = autoRun(async () => {
26
+ const n = store.getItems(name)
26
27
  if (window.migrating || window[`watch${name}Running`]) {
27
28
  return
28
29
  }
29
30
  window[`watch${name}Running`] = true
30
31
  try {
31
32
  const old = refsStatic.get('oldState-' + name)
32
- const n = store.getItems(name)
33
33
  const { updated, added, removed } = dataCompare(
34
34
  old,
35
35
  n
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@electerm/electerm-react",
3
- "version": "3.11.11",
3
+ "version": "3.12.0",
4
4
  "description": "react components src for electerm",
5
5
  "main": "./client/components/main/main.jsx",
6
6
  "license": "MIT",